Skip to content

Commit 6b15981

Browse files
committed
feat(spec): an action param can name the widget that draws it (permission-ref picker)
ActionParamSchema gains an optional `widget`, the same key, vocabulary and meaning as FieldSchema.widget, so a param can ask for the permission-set picker ADR-0131 D4 gives the grant column. `type` stays the value's type; an unregistered name is kept and degrades to the type renderer. The action form's Params repeater offers the key, labelled in four locales. The console reader is #30260. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzhmTfrR3b13itPTmu3
1 parent 959c26b commit 6b15981

10 files changed

Lines changed: 152 additions & 1 deletion

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/platform-objects': minor
4+
---
5+
6+
feat(spec): an action param can name the widget that draws it (`widget`, same key as on a field), so a param can ask for the permission-set picker (ADR-0131 D4)
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: additive
10+
11+
- **`@objectstack/spec`: `ActionParamSchema.widget`**, an optional string with the same key, vocabulary and meaning as `FieldSchema.widget`. It names a registered field component, looked up as `field:` plus the name, to draw the param in the action dialog instead of the `type` default. `type` stays the value's type. The case it exists for is `widget: 'permission-ref'` on a `text` param: it lists the permission sets of the security catalog and submits the chosen machine name, the picker the grant column `sys_user_permission_set.permission_set` already uses. Like the field key it is an open string: an unregistered name is kept, and the dialog draws the `type` renderer instead. A non-string is refused. A param that does not declare the key parses exactly as before. Until now a param naming `widget` was refused as an unknown key.
12+
- **Not read yet.** The console's param resolver does not carry the key to the dialog's widget until objectstack#30260 lands. Until then a param that declares it is drawn by its `type` renderer, and its value is submitted as before.
13+
- **`@objectstack/platform-objects`: the action form's Params repeater offers the key** as a `Widget` column, labelled in en, zh-CN, ja-JP and es-ES.

‎packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,9 @@ export const enMetadataForms: NonNullable<TranslationData['metadataForms']> = {
17561756
"params.type": {
17571757
label: "Type"
17581758
},
1759+
"params.widget": {
1760+
label: "Widget"
1761+
},
17591762
"params.required": {
17601763
label: "Required"
17611764
},

‎packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,9 @@ export const esESMetadataForms: NonNullable<TranslationData['metadataForms']> =
17561756
"params.type": {
17571757
label: "Tipo"
17581758
},
1759+
"params.widget": {
1760+
label: "Control del campo"
1761+
},
17591762
"params.required": {
17601763
label: "Obligatorio"
17611764
},

‎packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,9 @@ export const jaJPMetadataForms: NonNullable<TranslationData['metadataForms']> =
17561756
"params.type": {
17571757
label: "型"
17581758
},
1759+
"params.widget": {
1760+
label: "ウィジェット指定"
1761+
},
17591762
"params.required": {
17601763
label: "必須"
17611764
},

‎packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,9 @@ export const zhCNMetadataForms: NonNullable<TranslationData['metadataForms']> =
17561756
"params.type": {
17571757
label: "类型"
17581758
},
1759+
"params.widget": {
1760+
label: "控件覆盖"
1761+
},
17591762
"params.required": {
17601763
label: "必填"
17611764
},

‎packages/spec/authorable-surface/ui.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
"ui/ActionParam:requiresFeature",
159159
"ui/ActionParam:type",
160160
"ui/ActionParam:visible",
161+
"ui/ActionParam:widget",
161162
"ui/ActionSession:organizationId",
162163
"ui/ActionSession:positions",
163164
"ui/ActionSession:roles",

‎packages/spec/liveness/action.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"verifiedAt": "2026-09-15",
9696
"evidenceScope": "cross-repo",
9797
"evidence": "cloud @cb8ee7ff: packages/service-ai/src/tools/action-tools.ts#buildParametersSchema — each declared param becomes one JSON Schema property on the exposed tool.",
98-
"note": "field/objectOverride/defaultFromRow/options/placeholder/helpText/defaultValue/required all consumed."
98+
"note": "field/objectOverride/defaultFromRow/options/placeholder/helpText/defaultValue/required all consumed. `widget` (#30259, ADR-0131 D4) is the exception, and PLANNED: it is declared spec-first, and the console's param resolver (ui/packages/fields/src/resolveActionParams.ts, then ui/packages/app-shell/src/utils/paramToField.ts) does not carry it to the dialog's widget until #30260 adds that pass-through. Until then the dialog draws the param's `type` renderer and submits its value as before, which is the degradation the key's own describe() promises for an unregistered name. This container is undrilled (a `containers` row in packages/spec/scripts/liveness/undrilled-containers.baseline.json), so the gate asks no per-key verdict here and drilling it means evidence for every member; this sentence is the record until #30260 lands and flips it."
9999
},
100100
"variant": {
101101
"status": "live",
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// #30259 — `ActionParamSchema.widget`: an action param can name the widget that
2+
// draws it, with the same key, vocabulary and meaning as `FieldSchema.widget`.
3+
// The case that asked for it is the permission-set picker ADR-0131 D4 gives the
4+
// grant column `sys_user_permission_set.permission_set` (`widget:
5+
// 'permission-ref'`): before this key no param could ask for that picker, so
6+
// Create User's `permissionSet` param was a box for a typed machine name
7+
// (#30117).
8+
//
9+
// These pins hold the widening: a param that declares the key parses and keeps
10+
// it; an unregistered name is KEPT, exactly as the field key keeps it (both
11+
// degrade to the `type` renderer at draw time); a non-string is refused; and a
12+
// param that does not declare the key parses exactly as it did before.
13+
import { describe, it, expect } from 'vitest';
14+
import { ActionParamSchema } from './action.zod';
15+
import { FieldSchema } from '../data/field.zod';
16+
17+
describe('ActionParamSchema.widget — a param names the widget that draws it (#30259)', () => {
18+
it('accepts permission-ref on an inline text param and keeps it, with `type` unchanged', () => {
19+
const r = ActionParamSchema.safeParse({
20+
name: 'permissionSet',
21+
label: 'Permission Set',
22+
type: 'text',
23+
widget: 'permission-ref',
24+
});
25+
expect(r.success, JSON.stringify((r as { error?: unknown }).error)).toBe(true);
26+
if (!r.success) return;
27+
expect(r.data.widget).toBe('permission-ref');
28+
// `type` stays the VALUE's type: the widget changes how it is picked only.
29+
expect(r.data.type).toBe('text');
30+
});
31+
32+
it('accepts the key on a field-backed param (an authored override, as every inline value is)', () => {
33+
const r = ActionParamSchema.safeParse({ field: 'permission_set', widget: 'permission-ref' });
34+
expect(r.success, JSON.stringify((r as { error?: unknown }).error)).toBe(true);
35+
if (!r.success) return;
36+
expect(r.data.widget).toBe('permission-ref');
37+
});
38+
39+
it('is a declared key, not an unrecognized one', () => {
40+
const r = ActionParamSchema.safeParse({ name: 'p', type: 'text', widget: 'permission-ref' });
41+
const issues = r.success ? [] : r.error.issues;
42+
expect(issues.filter((i) => i.code === 'unrecognized_keys')).toEqual([]);
43+
});
44+
45+
describe('value — an open string, matching FieldSchema.widget', () => {
46+
// The field key is `z.string().optional()`: an unregistered name is kept and
47+
// the renderer falls back to the `type` default. The param key makes the same
48+
// promise, so each value below must get the same verdict on both surfaces.
49+
const values: unknown[] = ['permission-ref', 'position-ref', 'object-ref', 'no-such-widget', 42, true, null];
50+
51+
for (const value of values) {
52+
it(`gives ${JSON.stringify(value)} the verdict the field key gives it`, () => {
53+
const onParam = ActionParamSchema.safeParse({ name: 'p', type: 'text', widget: value });
54+
const onField = FieldSchema.safeParse({ name: 'p', type: 'text', widget: value });
55+
expect(onParam.success).toBe(onField.success);
56+
if (onParam.success && onField.success) {
57+
expect(onParam.data.widget).toBe(value);
58+
expect(onField.data.widget).toBe(value);
59+
}
60+
});
61+
}
62+
63+
it('keeps an unregistered name rather than refusing it (it degrades at draw time)', () => {
64+
const r = ActionParamSchema.safeParse({ name: 'p', type: 'text', widget: 'no-such-widget' });
65+
expect(r.success).toBe(true);
66+
if (!r.success) return;
67+
expect(r.data.widget).toBe('no-such-widget');
68+
});
69+
70+
it('refuses a non-string on the widget path', () => {
71+
const r = ActionParamSchema.safeParse({ name: 'p', type: 'text', widget: 42 });
72+
expect(r.success).toBe(false);
73+
if (r.success) return;
74+
expect(r.error.issues.some((i) => i.path.join('.') === 'widget' && i.code === 'invalid_type')).toBe(true);
75+
});
76+
});
77+
78+
describe('existing params parse unchanged', () => {
79+
const existing: Array<Record<string, unknown>> = [
80+
// Create User's param as it stands on main (sys-user.object.ts): inline text.
81+
{ name: 'permissionSet', label: 'Permission Set', type: 'text', required: false },
82+
{ field: 'email' },
83+
{ field: 'role', objectOverride: 'sys_member' },
84+
{ name: 'inspector', label: 'Inspector', type: 'lookup', reference: 'sys_user' },
85+
{ name: 'tier', type: 'select', options: [{ label: 'Gold', value: 'gold' }] },
86+
];
87+
88+
for (const param of existing) {
89+
it(`parses ${JSON.stringify(param)} with no widget member added`, () => {
90+
const r = ActionParamSchema.safeParse(param);
91+
expect(r.success, JSON.stringify((r as { error?: unknown }).error)).toBe(true);
92+
if (!r.success) return;
93+
expect('widget' in r.data).toBe(false);
94+
});
95+
}
96+
});
97+
});

‎packages/spec/src/ui/action.form.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const actionForm = defineForm({
7777
{ field: 'objectOverride', label: 'Object Override' },
7878
{ field: 'label', label: 'Label' },
7979
{ field: 'type', label: 'Type' },
80+
{ field: 'widget', label: 'Widget' },
8081
{ field: 'required', label: 'Required' },
8182
{ field: 'options', label: 'Options' },
8283
{ field: 'placeholder', label: 'Placeholder' },

‎packages/spec/src/ui/action.zod.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,33 @@ export const ActionParamSchema = lazySchema(() => strictObject(
236236
label: I18nLabelSchema.optional().meta({ title: 'Label' }),
237237
/** Overrides the resolved field type (or sets it for inline params). */
238238
type: FieldType.optional().meta({ title: 'Type' }),
239+
/**
240+
* Widget override (#30259) — the same key, with the same vocabulary and the
241+
* same meaning, as `FieldSchema.widget`: it names a registered field
242+
* component (looked up as `field:` plus this name) that draws this param in
243+
* the dialog instead of the `type` default. `type` stays the VALUE's type;
244+
* the widget only changes how the value is picked.
245+
*
246+
* The case it exists for is a name that must be picked, not typed:
247+
* `widget: 'permission-ref'` on a `text` param lists the permission sets of
248+
* the security catalog and submits the chosen machine name — the picker
249+
* ADR-0131 D4 gives the grant column
250+
* `sys_user_permission_set.permission_set` ("a picker lists the registry, an
251+
* assignment names one of its entries"). Before this key no param could ask
252+
* for it, so Create User's `permissionSet` was a box for a typed name.
253+
*
254+
* Like the field key it is an open string, not an enum: an unregistered name
255+
* is kept and the dialog draws the `type` renderer instead, so it degrades
256+
* safely. Planned: the console's param resolver does not carry it to the
257+
* widget yet (#30260); until it does, the param draws its `type` renderer
258+
* and its value is submitted as before.
259+
*/
260+
widget: z.string().optional().describe(
261+
'Widget override for this param — names a registered field component (resolved as `field:<widget>`) '
262+
+ 'to draw it instead of the `type` default; same key and vocabulary as FieldSchema.widget, and `type` '
263+
+ 'stays the value\'s type. e.g. "permission-ref" on a text param picks a permission set by name '
264+
+ '(ADR-0131 D4). Degrades to the `type` renderer when unregistered.',
265+
).meta({ title: 'Widget' }),
239266
/**
240267
* Required override; when omitted defaults to `false`. Consumers that wish
241268
* to inherit the underlying field's `required` flag should leave this

0 commit comments

Comments
 (0)