diff --git a/.changeset/36913-dashboard-columns-describe.md b/.changeset/36913-dashboard-columns-describe.md new file mode 100644 index 00000000000..187663a41ea --- /dev/null +++ b/.changeset/36913-dashboard-columns-describe.md @@ -0,0 +1,11 @@ +--- +'@objectstack/spec': patch +'@objectstack/cli': patch +--- + +fix(spec): `DashboardSchema.columns` says what the renderer does when it is absent + +Clause-②: no +Metadata-protocol: none + +The `columns` describe said "(default 12)". The dashboard renderer has no fixed default: when `columns` is absent it infers the grid from the widgets, 12 if any widget layout reaches past column 4 (`x + w > 4`), otherwise 4. The describe, its TSDoc, the generated reference page and the `os explain dashboard` table now say that. No runtime change. diff --git a/.changeset/36927-bulk-param-allowcreate-prescription.md b/.changeset/36927-bulk-param-allowcreate-prescription.md new file mode 100644 index 00000000000..d76b4ec211b --- /dev/null +++ b/.changeset/36927-bulk-param-allowcreate-prescription.md @@ -0,0 +1,10 @@ +--- +'@objectstack/spec': patch +--- + +fix(spec): the bulk-param widget-config refusal names `allowCreate` among the field keys a promoted action carries + +Clause-②: no +Metadata-protocol: none + +Since #36919, a promoted bulk action's field-backed lookup param takes the field's `allowCreate`, so `allowCreate: false` on the field keeps the picker's create entry out of the selection bar's dialog. The `BULK_PARAM_WIDGET_CONFIG_KEYS` prescription and the `list.bulkActionDefs` liveness note still left it off the carried keys, telling authors the opposite. Both now name `allowCreate` with `lookupFilters` / `lookupColumns` / `lookupPageSize` / `descriptionField`. Text only; the refused key set is unchanged. diff --git a/content/docs/references/ui/dashboard.mdx b/content/docs/references/ui/dashboard.mdx index 4097f4caebc..3923b8f61f1 100644 --- a/content/docs/references/ui/dashboard.mdx +++ b/content/docs/references/ui/dashboard.mdx @@ -33,7 +33,7 @@ const result = DashboardSchema.parse(data); | **description** | `string \| Record` | optional | Dashboard description | | **header** | `{ showTitle?: boolean; showDescription?: boolean; actions?: object[] }` | optional | Dashboard header configuration | | **widgets** | `{ id: string; title?: string \| Record; description?: string \| Record; type?: Enum<'bar' \| 'horizontal-bar' \| 'column' \| 'line' \| 'area' \| 'pie' \| 'donut' \| …>; … }[]` | ✅ | Widgets to display | -| **columns** | `integer` | optional | Number of grid columns (default 12) | +| **columns** | `integer` | optional | Number of grid columns. When absent, inferred from the widgets: 12 if any widget layout reaches past column 4 (x + w > 4), otherwise 4 | | **gap** | `integer` | optional | Space between widgets, in steps of 0.25rem (4 = 1rem) | | **refreshIntervalSeconds** | `number` | optional | Auto-refresh interval in seconds | | **refreshInterval** | `never` | optional | [REMOVED] `dashboard.refreshInterval` was renamed to `refreshIntervalSeconds` in @objectstack/spec 17 — the unit of a duration-shaped number lives in the key name, not only in the describe prose. Rename the key to `refreshIntervalSeconds`; the value (seconds) is unchanged. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | diff --git a/packages/cli/src/commands/explain.ts b/packages/cli/src/commands/explain.ts index 3ae9396af87..d6bc7c6b4ef 100644 --- a/packages/cli/src/commands/explain.ts +++ b/packages/cli/src/commands/explain.ts @@ -289,7 +289,7 @@ export const SCHEMAS: Record = { ], optional: [ { name: 'description', type: 'string', description: 'Dashboard description' }, - { name: 'columns', type: 'number (1-24)', description: 'Number of grid columns (default 12)' }, + { name: 'columns', type: 'number (1-24)', description: 'Number of grid columns. When absent, inferred from the widgets: 12 if any widget layout reaches past column 4 (x + w > 4), otherwise 4' }, { name: 'gap', type: 'number', description: 'Space between widgets, in steps of 0.25rem (4 = 1rem)' }, // There is no dashboard-level `layout` template — the key is rejected by // name. Positioning is per-widget: `layout: { x, y, w, h }`, and a widget diff --git a/packages/rest/src/meta-types-schema-titles.test.ts b/packages/rest/src/meta-types-schema-titles.test.ts index 03bd77566d5..db837bf9385 100644 --- a/packages/rest/src/meta-types-schema-titles.test.ts +++ b/packages/rest/src/meta-types-schema-titles.test.ts @@ -18,12 +18,15 @@ import { describe, it, expect, vi } from 'vitest'; import { RestServer } from './rest-server.js'; +// Paid at collection, not inside a clocked case: the routes reached through +// RestServer load it lazily (check:test-source-alias). +import '@objectstack/objectql'; /** The served shape `getMetaTypes()` derives for a `dashboard` entry, trimmed to the header. */ const DASHBOARD_SCHEMA = () => ({ type: 'object', properties: { - columns: { type: 'integer', description: 'Number of grid columns (default 12)' }, + columns: { type: 'integer', description: 'Number of grid columns. When absent, inferred from the widgets: 12 if any widget layout reaches past column 4 (x + w > 4), otherwise 4' }, header: { type: 'object', properties: { @@ -145,7 +148,7 @@ describe('#16458 — GET /meta serves a localised `schema` beside the localised expect(entry.form.sections[0].fields[0].label).toBe('列数'); // The overlay wrote `title` and nothing else on the node. expect(rowProps(entry).label.type).toBe('string'); - expect(entry.schema.properties.columns.description).toBe('Number of grid columns (default 12)'); + expect(entry.schema.properties.columns.description).toBe('Number of grid columns. When absent, inferred from the widgets: 12 if any widget layout reaches past column 4 (x + w > 4), otherwise 4'); }); it('control — an en request leaves the authored titles in place', async () => { diff --git a/packages/spec/liveness/view.json b/packages/spec/liveness/view.json index 9f3e11ab537..30464a0e1ef 100644 --- a/packages/spec/liveness/view.json +++ b/packages/spec/liveness/view.json @@ -217,7 +217,7 @@ "bulkActionDefs": { "status": "live", "evidence": "packages/spec/src/ui/bulk-action.zod.ts", - "note": "objectui: ListView.tsx:1343 forwards rich defs to ObjectGrid (BulkActionDialog). Dispatch: useBulkExecutor.ts run() — per-record fan-out by default; execution:'aggregate' defs go through the ONE-call bulkCall branch injecting params._selectedIds (ObjectGrid.runBulkActionAggregate, objectui#3139). Verified objectui@4bf612c. #4457 gave the def a SHAPE (it was z.record(z.any())): the entry schema is BulkActionDefSchema, strict, and it refuses the combinations that parse but the executor never reads — so this row's liveness now covers the keys inside a def, not just the array. A PROMOTED def's field-backed params (packages/spec/src/ui/bulk-action.zod.ts; moved out of spec source, #23434): resolved when the dialog opens by objectui main @dca25aff2 packages/plugin-grid/src/resolveBulkActions.ts#resolvePromotedBulkParams through `resolveActionParams` (objectui 29b99490), then renamed onto the bulk vocabulary by the same file's #toBulkParam, which carries the field's type, translated label, options, required, description, placeholder, defaultValue, multiple, `dependsOn`, `accept` and `maxSize` (plus a reference-bearing field's reference and display field) and that field's lookup settings `lookupFilters`, `lookupColumns`, `lookupPageSize` and `descriptionField`, which reach the selection bar's picker as they reach the single-record dialog's (objectstack#26951); `idField` / `titleFormat` are still not carried. An authored param's `options[]` entries (packages/spec/src/ui/bulk-action.zod.ts, the `.passthrough()` rationale; moved out of spec source, #23434): objectui @b9814b334 packages/plugin-grid/src/components/bulkParamToField.ts#bulkParamToField spreads each entry into the field metadata (`options?.map(o => ({ ...o, value: String(o.value) }))`), so every extra key reaches the widget, whose option vocabulary is objectui @b9814b334 packages/types/src/field-types.ts#SelectOptionMetadata, extending objectui @b9814b334 packages/types/src/select-option.ts#SelectOptionBase (`color`, `visibleWhen`, `disabled` and `icon` beyond the pair); the select cell reads `option?.color` in objectui @b9814b334 packages/fields/src/index.tsx#SelectCellRenderer. The renderer's own param type now agrees: objectui @b9814b334 packages/types/src/objectql.ts#BulkActionParam types an `options` entry open (an index signature, citing objectstack#4001), where the source's sha-less reading had it closed (`Array<{ label; value }>`). Re-read 2026-10-15, first cited by line, sha-less." + "note": "objectui: ListView.tsx:1343 forwards rich defs to ObjectGrid (BulkActionDialog). Dispatch: useBulkExecutor.ts run() — per-record fan-out by default; execution:'aggregate' defs go through the ONE-call bulkCall branch injecting params._selectedIds (ObjectGrid.runBulkActionAggregate, objectui#3139). Verified objectui@4bf612c. #4457 gave the def a SHAPE (it was z.record(z.any())): the entry schema is BulkActionDefSchema, strict, and it refuses the combinations that parse but the executor never reads — so this row's liveness now covers the keys inside a def, not just the array. A PROMOTED def's field-backed params (packages/spec/src/ui/bulk-action.zod.ts; moved out of spec source, #23434): resolved when the dialog opens by objectui main @dca25aff2 packages/plugin-grid/src/resolveBulkActions.ts#resolvePromotedBulkParams through `resolveActionParams` (objectui 29b99490), then renamed onto the bulk vocabulary by the same file's #toBulkParam, which carries the field's type, translated label, options, required, description, placeholder, defaultValue, multiple, `dependsOn`, `accept` and `maxSize` (plus a reference-bearing field's reference and display field) and that field's lookup settings `lookupFilters`, `lookupColumns`, `lookupPageSize`, `descriptionField` and `allowCreate`, which reach the selection bar's picker as they reach the single-record dialog's (objectstack#26951; `allowCreate` since objectstack#36919, carried by #toBulkParam so `allowCreate: false` on the field keeps the picker's create entry out); `idField` / `titleFormat` are still not carried. An authored param's `options[]` entries (packages/spec/src/ui/bulk-action.zod.ts, the `.passthrough()` rationale; moved out of spec source, #23434): objectui @b9814b334 packages/plugin-grid/src/components/bulkParamToField.ts#bulkParamToField spreads each entry into the field metadata (`options?.map(o => ({ ...o, value: String(o.value) }))`), so every extra key reaches the widget, whose option vocabulary is objectui @b9814b334 packages/types/src/field-types.ts#SelectOptionMetadata, extending objectui @b9814b334 packages/types/src/select-option.ts#SelectOptionBase (`color`, `visibleWhen`, `disabled` and `icon` beyond the pair); the select cell reads `option?.color` in objectui @b9814b334 packages/fields/src/index.tsx#SelectCellRenderer. The renderer's own param type now agrees: objectui @b9814b334 packages/types/src/objectql.ts#BulkActionParam types an `options` entry open (an index signature, citing objectstack#4001), where the source's sha-less reading had it closed (`Array<{ label; value }>`). Re-read 2026-10-15, first cited by line, sha-less." }, "conditionalFormatting": { "status": "live", diff --git a/packages/spec/src/ui/bulk-action.test.ts b/packages/spec/src/ui/bulk-action.test.ts index c34576de7a7..089aa84d07f 100644 --- a/packages/spec/src/ui/bulk-action.test.ts +++ b/packages/spec/src/ui/bulk-action.test.ts @@ -78,7 +78,7 @@ describe('BulkActionDefSchema — the def shape is typed, not `z.any()`', () => // ⛔ The prescription must NOT send this author to the field: a key // declared there reaches the bulk dialog only through a PROMOTED action // (`bulkActions`), and of this family only `accept` / `maxSize` and the - // four lookup picker settings make that trip. They are named by subject, + // five lookup picker settings (`allowCreate` among them since #36919) make that trip. They are named by subject, // so the rejection says which route and which keys rather than implying // `min` would follow. expect(issues).toContain('`bulkActions`'); diff --git a/packages/spec/src/ui/bulk-action.zod.ts b/packages/spec/src/ui/bulk-action.zod.ts index 83aa6f19110..0733d01ac0a 100644 --- a/packages/spec/src/ui/bulk-action.zod.ts +++ b/packages/spec/src/ui/bulk-action.zod.ts @@ -221,7 +221,7 @@ export type BulkActionResultParsed = z.infer; * to name it beside min/max/step, and the sweep found no FORM widget reading it * at all. * - * ⚠️ The prescription refuses the obvious-sounding remedy for all but six of + * ⚠️ The prescription refuses the obvious-sounding remedy for all but seven of * these keys. An AUTHORED def's params reach the dialog as written: nothing on * that path consults the object's field definitions. The bulk surface's * field-backed route is the PROMOTED def, an action the object declares, named @@ -235,13 +235,16 @@ export type BulkActionResultParsed = z.infer; * `description` (as the help text), `placeholder`, `defaultValue`, `multiple`, * `accept` and `maxSize`, plus a reference-bearing field's `reference`, * `displayField` and `dependsOn`, and that field's lookup settings - * `lookupFilters` / `lookupColumns` / `lookupPageSize` / `descriptionField`, - * which reach the selection bar's picker as they reach the single-record - * dialog's. From THIS list only those four and `accept` / `maxSize` make the + * `lookupFilters` / `lookupColumns` / `lookupPageSize` / `descriptionField` / + * `allowCreate`, which reach the selection bar's picker as they reach the + * single-record dialog's (`allowCreate` since objectstack#36919: the resolver + * copies it and `toBulkParam` carries it, so `allowCreate: false` on the field + * keeps the picker's create entry out). From THIS list only those five and + * `accept` / `maxSize` make the * trip, and the rest are never read off the field (`idField` has no * `FieldSchema` spelling to declare; the resolver's snake `id_field` read is * still not carried onto the bulk param). So - * "declare it on the field and let the dialog inherit" is right for those six + * "declare it on the field and let the dialog inherit" is right for those seven * keys on a promoted def, and a confidently wrong answer for every other key * here, the shape this campaign has already shipped more than once. */ @@ -336,10 +339,10 @@ export const BulkActionParamSchema = lazySchema(() => strictObject( + 'carries the field\'s `type`, `label`, `options`, `required`, `description` (as the help ' + 'text), `placeholder`, `defaultValue`, `multiple`, `accept` and `maxSize`, plus a ' + 'reference field\'s `reference`, `displayField` and `dependsOn` and its picker settings ' - + '`lookupFilters` / `lookupColumns` / `lookupPageSize` / `descriptionField`, which reach ' - + 'the selection bar\'s picker as they reach the single-record dialog\'s. ⛔ So of these ' - + 'keys only `accept` / `maxSize` and those four picker settings arrive that way, and the ' - + 'rest are never read off the field. Remove the key, or for one of those six move the ' + + '`lookupFilters` / `lookupColumns` / `lookupPageSize` / `descriptionField` / `allowCreate`, ' + + 'which reach the selection bar\'s picker as they reach the single-record dialog\'s. ⛔ So ' + + 'of these keys only `accept` / `maxSize` and those five picker settings arrive that way, ' + + 'and the rest are never read off the field. Remove the key, or for one of those seven move the ' + 'param onto a promoted action; open an issue if a bulk param genuinely needs a key ' + 'declared here.', }], diff --git a/packages/spec/src/ui/dashboard.zod.ts b/packages/spec/src/ui/dashboard.zod.ts index dd608b3e790..2d6b98ff55b 100644 --- a/packages/spec/src/ui/dashboard.zod.ts +++ b/packages/spec/src/ui/dashboard.zod.ts @@ -1820,8 +1820,11 @@ export const DashboardSchema = lazySchema(() => strictObject({ /** Collection of widgets */ widgets: z.array(DashboardWidgetSchema).describe('Widgets to display'), - /** Grid column count — defaults to 12 for a standard 12-column grid */ - columns: z.number().int().min(1).max(24).optional().describe('Number of grid columns (default 12)'), + /** + * Grid column count. Absent, the renderer infers it from the widgets: 12 when + * any widget's layout reaches past column 4 (`x + w > 4`), otherwise 4. + */ + columns: z.number().int().min(1).max(24).optional().describe('Number of grid columns. When absent, inferred from the widgets: 12 if any widget layout reaches past column 4 (x + w > 4), otherwise 4'), /** Space between widgets, in steps of 0.25rem (4 = 1rem) */ gap: z.number().int().min(0).optional().describe('Space between widgets, in steps of 0.25rem (4 = 1rem)'),