From 276d7d956654ab6cbaecda5af0493378b0c3115b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 05:26:01 +0000 Subject: [PATCH 1/5] wip(spec): declare metadata list columns and serve them on /meta/types Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzg7mFFG5b13DcQ93kf --- .../src/protocol-discovery-and-bases.ts | 5 + .../src/protocol-meta-type-schema.ts | 12 +- .../src/protocol-meta-types-listing.ts | 4 +- packages/rest/src/rest-server.ts | 7 +- packages/spec/src/api/protocol.zod.ts | 3 +- packages/spec/src/system/i18n-resolver.ts | 32 +++ packages/spec/src/system/index.ts | 1 + .../spec/src/system/metadata-list-registry.ts | 223 ++++++++++++++++++ .../metadata-list-zod-reconciliation.test.ts | 182 ++++++++++++++ packages/spec/src/ui/view.zod.ts | 89 +++++++ 10 files changed, 553 insertions(+), 5 deletions(-) create mode 100644 packages/spec/src/system/metadata-list-registry.ts create mode 100644 packages/spec/src/system/metadata-list-zod-reconciliation.test.ts diff --git a/packages/metadata-protocol/src/protocol-discovery-and-bases.ts b/packages/metadata-protocol/src/protocol-discovery-and-bases.ts index 567127ec024..8fdb2e46311 100644 --- a/packages/metadata-protocol/src/protocol-discovery-and-bases.ts +++ b/packages/metadata-protocol/src/protocol-discovery-and-bases.ts @@ -56,6 +56,7 @@ import type { Equal, MetaTypesListing } from './protocol-meta-types-listing.js'; import { HAND_CRAFTED_SCHEMAS, TYPE_TO_FORM, + TYPE_TO_LIST, canonicalMetaType, toJsonSchemaSafe, } from './protocol-meta-type-schema.js'; @@ -651,6 +652,8 @@ export class ProtocolDiscoveryAndBasesFacet { const schema = (zodSchema ? toJsonSchemaSafe(zodSchema, singular) : undefined) ?? HAND_CRAFTED_SCHEMAS[singular]; const form = TYPE_TO_FORM[singular]; + // The Studio list layout, beside the form; omitted for a type with none. + const list = TYPE_TO_LIST[singular]; // Phase 2: the authoritative minimal create seed (single source of // truth in @objectstack/spec). Studio/CLI derive create defaults // from this via /meta/types instead of re-inventing them. @@ -677,6 +680,7 @@ export class ProtocolDiscoveryAndBasesFacet { : 'registry' as const, schema, form, + ...(list !== undefined ? { list } : {}), ...(createSeed !== undefined ? { createSeed } : {}), // Override the spread `base.actions` with the merged view // (declarative + plugin-registered). Omit when empty to @@ -754,6 +758,7 @@ export class ProtocolDiscoveryAndBasesFacet { overrideSource: writableOverrides.has(singular) ? 'env' as const : 'registry' as const, schema, form, + ...(list !== undefined ? { list } : {}), ...(createSeed !== undefined ? { createSeed } : {}), // Plugin-registered actions on a type with no registry entry. ...(typeActions.length ? { actions: typeActions } : {}), diff --git a/packages/metadata-protocol/src/protocol-meta-type-schema.ts b/packages/metadata-protocol/src/protocol-meta-type-schema.ts index 0d3d9a6f629..da71b122af2 100644 --- a/packages/metadata-protocol/src/protocol-meta-type-schema.ts +++ b/packages/metadata-protocol/src/protocol-meta-type-schema.ts @@ -26,8 +26,8 @@ import { stripInjectedSystemColumns, } from '@objectstack/metadata-core'; import { PLURAL_TO_SINGULAR, canonicalMetaUrlType, metaUrlSpellingRefusal } from '@objectstack/spec/shared'; -import { type FormView } from '@objectstack/spec/ui'; -import { METADATA_FORM_REGISTRY } from '@objectstack/spec/system'; +import { type FormView, type MetadataListViewParsed } from '@objectstack/spec/ui'; +import { METADATA_FORM_REGISTRY, METADATA_LIST_REGISTRY } from '@objectstack/spec/system'; import { getMetadataTypeSchema } from '@objectstack/spec/kernel'; import { z } from 'zod'; import { @@ -57,6 +57,13 @@ import { */ const TYPE_TO_FORM: Readonly> = METADATA_FORM_REGISTRY; +/** + * Canonical Studio list layout per metadata type — the columns its metadata + * list shows — from the shared {@link METADATA_LIST_REGISTRY}, served beside + * the form as `list`. Types without an entry get Studio's default list. + */ +const TYPE_TO_LIST: Readonly> = METADATA_LIST_REGISTRY; + /** * The ONE canonical spelling of a metadata type at the `/meta` read/write/delete * boundary (#4432). @@ -619,6 +626,7 @@ function declaredKeySchema(schema: unknown, key: string, depth: number): z.ZodTy export { HAND_CRAFTED_SCHEMAS, TYPE_TO_FORM, + TYPE_TO_LIST, canonicalizeMetaRequestType, resolveOverlaySchema, toJsonSchemaSafe, diff --git a/packages/metadata-protocol/src/protocol-meta-types-listing.ts b/packages/metadata-protocol/src/protocol-meta-types-listing.ts index 81483bc18bc..5b5cf694601 100644 --- a/packages/metadata-protocol/src/protocol-meta-types-listing.ts +++ b/packages/metadata-protocol/src/protocol-meta-types-listing.ts @@ -18,7 +18,7 @@ // Not exported from the package index: no new public name. import type { MetadataTypeRegistryEntryParsed } from '@objectstack/spec/kernel'; -import type { Action, FormView } from '@objectstack/spec/ui'; +import type { Action, FormView, MetadataListViewParsed } from '@objectstack/spec/ui'; /** Flattens an intersection into one object type, so it compares EQUAL to an inferred object literal. */ type Flatten = { [K in keyof T]: T[K] }; @@ -42,6 +42,8 @@ export type MetaTypesListingEntry = Flatten< schema: Record; /** Form layout of the type's editor. */ form: FormView; + /** Studio list layout of the type (`METADATA_LIST_REGISTRY`); absent for a type with none. */ + list?: MetadataListViewParsed; /** The minimal create seed, when the spec declares one. */ createSeed?: {} | null; /** diff --git a/packages/rest/src/rest-server.ts b/packages/rest/src/rest-server.ts index 81dac7a37d2..e33154f0d98 100644 --- a/packages/rest/src/rest-server.ts +++ b/packages/rest/src/rest-server.ts @@ -4768,7 +4768,8 @@ export class RestServer { * Translate the `entries` payload returned by `getMetaTypes()` — applies * the active locale to each entry's `label`, `description`, the * nested `form` layout (section labels, field labels, helpText, - * placeholders) and the derived JSON `schema` (a `title` per node the + * placeholders), the `list` layout's column headers (through the same + * field-label slots) and the derived JSON `schema` (a `title` per node the * bundle names — the only channel that reaches a repeater row's column * headers, #16458) via the `metadataForms.` translation namespace. * @@ -4787,6 +4788,7 @@ export class RestServer { resolveMetadataTypeDescription, resolveMetadataFormLabels, resolveMetadataFormSchemaTitles, + resolveMetadataListLabels, } = await import('@objectstack/spec/system'); const opts = RestServer.translateOptionsFor(i18n, locale); const entries = payload.entries.map((entry: any) => { @@ -4798,6 +4800,9 @@ export class RestServer { if (entry.form) { next.form = resolveMetadataFormLabels(entry.form, entry.type, bundle, opts); } + if (entry.list) { + next.list = resolveMetadataListLabels(entry.list, entry.type, bundle, opts); + } if (entry.schema && typeof entry.schema === 'object') { next.schema = resolveMetadataFormSchemaTitles(entry.schema, entry.type, bundle, opts); } diff --git a/packages/spec/src/api/protocol.zod.ts b/packages/spec/src/api/protocol.zod.ts index 2cc732b54d9..430c64f081b 100644 --- a/packages/spec/src/api/protocol.zod.ts +++ b/packages/spec/src/api/protocol.zod.ts @@ -1,7 +1,7 @@ // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. import { z } from 'zod'; -import { ViewSchema } from '../ui/view.zod'; +import { MetadataListViewSchema, ViewSchema } from '../ui/view.zod'; import { I18nLabelSchema } from '../ui/i18n.zod'; import { DiscoverySchema } from './discovery.zod'; import { @@ -223,6 +223,7 @@ export const GetMetaTypesResponseSchema = lazySchema(() => z.object({ domain: z.enum(['data', 'ui', 'automation', 'system', 'security', 'ai']).describe('Protocol domain'), overrideSource: z.enum(['registry', 'env']).describe('Whether allowEnvironmentOverlay comes from the static registry or is elevated by the OS_METADATA_WRITABLE environment variable'), createSeed: z.unknown().optional().describe('Authoritative minimal valid create seed for this type — Studio/CLI/API derive create defaults from it (single source of truth in @objectstack/spec). Absent for canvas-create types whose shape is built interactively.'), + list: MetadataListViewSchema.optional().describe('Studio list layout of this type: the columns its metadata list shows, each naming a key of the type schema, headers in the request locale. Absent for a type with no declared list, which Studio lists by name, label and description.'), })).optional().describe('Enriched per-type registry entries (Phase 3a)'), })); diff --git a/packages/spec/src/system/i18n-resolver.ts b/packages/spec/src/system/i18n-resolver.ts index b17df591156..1d2f0c95845 100644 --- a/packages/spec/src/system/i18n-resolver.ts +++ b/packages/spec/src/system/i18n-resolver.ts @@ -6336,6 +6336,38 @@ export function resolveMetadataFormLabels>( return next as T; } +/** + * Translate the column headers of a metadata type's Studio list layout (a + * `METADATA_LIST_REGISTRY` entry) against the active translation bundle. + * + * A column is translated through the slot of the type's form field of the + * same path, `metadataForms..fields..label`, so a column header + * and the form label of that key read the same words. A column whose slot has + * no translation keeps its English header. + * + * Returns a new list object; the input is not mutated. + * + * @example + * ```ts + * const localized = resolveMetadataListLabels(METADATA_LIST_REGISTRY.hook, 'hook', bundle, { locale: 'zh-CN' }); + * ``` + */ +export function resolveMetadataListLabels> }>( + list: T, + type: string, + bundle: TranslationBundle | undefined, + opts?: ResolveOptions, +): T { + if (!list || typeof list !== 'object' || !Array.isArray(list.columns)) return list; + if (!lookupMetadataForm(bundle, type, opts)) return list; + const columns = list.columns.map((column) => { + if (!column || typeof column !== 'object' || typeof column.field !== 'string') return column; + const label = lookupMetadataFormField(bundle, type, column.field, 'label', opts); + return label ? { ...column, label } : column; + }); + return { ...list, columns }; +} + /** * Every `metadataForms..fields.` key recorded at any locale of the * chain — the union, so a key one locale names and another does not is still diff --git a/packages/spec/src/system/index.ts b/packages/spec/src/system/index.ts index 433927f3d3e..fcd0abbdcf2 100644 --- a/packages/spec/src/system/index.ts +++ b/packages/spec/src/system/index.ts @@ -80,6 +80,7 @@ export * from './sms-config.zod'; export * from './push-config.zod'; export * from './push-device.zod'; export * from './metadata-form-registry'; +export * from './metadata-list-registry'; // compliance.zod (GDPR/HIPAA/PCI configs) and masking.zod (role-based data // masking) were REMOVED per ADR-0056 D8 "design+enforce or remove": both were // declared-but-never-enforced (no runtime consumer), and compliance-grade diff --git a/packages/spec/src/system/metadata-list-registry.ts b/packages/spec/src/system/metadata-list-registry.ts new file mode 100644 index 00000000000..805c415d3f0 --- /dev/null +++ b/packages/spec/src/system/metadata-list-registry.ts @@ -0,0 +1,223 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * Canonical registry of the Studio list layout of each metadata type: which + * columns the "All metadata" list of a type shows. The list counterpart of + * {@link METADATA_FORM_REGISTRY}, and consumed the same way: + * + * - `getMetaTypes()` in `@objectstack/metadata-protocol` serves each entry as + * `list` on the type's `/meta/types` row, beside `form`, so Studio, the CLI + * and AI clients read one declaration; + * - the REST `/meta/types` handler translates each column header through the + * type's form field slot, `metadataForms..fields..label`, so a + * column and the form field of the same key read the same words; + * - `os i18n extract` emits that slot for every column whose path the type's + * form does not already declare. + * + * Every column names a key of the type's own schema (or a dotted path into it). + * `metadata-list-zod-reconciliation.test.ts` refuses a column naming a key the + * schema does not declare, and a header that differs from the form field label + * of the same path (one translation slot, one English source). + * + * A type with no entry here gets the Studio default list (name, label, + * description). + * + * @see METADATA_FORM_REGISTRY — the form layouts this registry sits beside + */ + +import { defineList, type MetadataListViewParsed } from '../ui/view.zod'; + +const NAME = { field: 'name', label: 'Name' } as const; +const LABEL = { field: 'label', label: 'Label' } as const; +const DESCRIPTION = { field: 'description', label: 'Description' } as const; + +/** + * Frozen map of metadata type → canonical list layout. + * + * @example + * + * ```ts + * import { METADATA_LIST_REGISTRY } from '@objectstack/spec/system'; + * + * for (const [type, list] of Object.entries(METADATA_LIST_REGISTRY)) { + * console.log(type, list.columns.map((c) => c.field).join(', ')); + * } + * ``` + */ +export const METADATA_LIST_REGISTRY: Readonly> = Object.freeze({ + // ── data ────────────────────────────────────────────────────────────── + object: defineList({ + schemaId: 'object', + columns: [NAME, LABEL, { field: 'pluralLabel', label: 'Plural Label' }, { field: 'fields', label: 'Fields', type: 'count' }, DESCRIPTION], + }), + field: defineList({ + schemaId: 'field', + // A field row's `object` is stamped by the server, not a `FieldSchema` + // key, so the console appends it as its own column. + columns: [NAME, { field: 'type', label: 'Type', type: 'badge' }, LABEL], + }), + hook: defineList({ + schemaId: 'hook', + columns: [ + NAME, LABEL, + { field: 'object', label: 'Object', type: 'list' }, + { field: 'events', label: 'Events', type: 'list' }, + { field: 'priority', label: 'Priority' }, + { field: 'async', label: 'Async', type: 'boolean' }, + DESCRIPTION, + ], + }), + seed: defineList({ + schemaId: 'seed', + columns: [{ field: 'object', label: 'Object' }, { field: 'mode', label: 'Mode', type: 'badge' }], + }), + mapping: defineList({ + schemaId: 'mapping', + columns: [ + NAME, LABEL, + { field: 'targetObject', label: 'Target Object' }, + { field: 'mode', label: 'Mode', type: 'badge' }, + { field: 'sourceFormat', label: 'Source Format', type: 'badge' }, + ], + }), + picklist: defineList({ + schemaId: 'picklist', + columns: [NAME, LABEL, { field: 'options', label: 'Options', type: 'count' }, DESCRIPTION], + }), + + // ── ui ──────────────────────────────────────────────────────────────── + view: defineList({ + schemaId: 'view', + columns: [NAME, { field: 'object', label: 'Object' }, { field: 'type', label: 'Type', type: 'badge' }, LABEL], + }), + page: defineList({ + schemaId: 'page', + columns: [NAME, LABEL, { field: 'type', label: 'Type', type: 'badge' }, DESCRIPTION], + }), + dashboard: defineList({ + schemaId: 'dashboard', + columns: [NAME, LABEL, DESCRIPTION], + }), + action: defineList({ + schemaId: 'action', + columns: [NAME, LABEL, { field: 'type', label: 'Type', type: 'badge' }, { field: 'objectName', label: 'Object Name' }, DESCRIPTION], + }), + report: defineList({ + schemaId: 'report', + columns: [NAME, LABEL, { field: 'type', label: 'Type', type: 'badge' }, { field: 'dataset', label: 'Dataset' }, DESCRIPTION], + }), + dataset: defineList({ + schemaId: 'dataset', + columns: [NAME, LABEL, { field: 'object', label: 'Object' }, DESCRIPTION], + }), + + // ── automation ──────────────────────────────────────────────────────── + flow: defineList({ + schemaId: 'flow', + columns: [NAME, LABEL, { field: 'type', label: 'Type', type: 'badge' }, DESCRIPTION], + }), + job: defineList({ + schemaId: 'job', + columns: [ + NAME, LABEL, + { field: 'schedule', label: 'Schedule', type: 'summary' }, + { field: 'enabled', label: 'Enabled', type: 'boolean' }, + DESCRIPTION, + ], + }), + assignment_rule: defineList({ + schemaId: 'assignment_rule', + columns: [ + NAME, LABEL, + { field: 'object', label: 'Object' }, + { field: 'entries', label: 'Entries', type: 'count' }, + { field: 'active', label: 'Active', type: 'boolean' }, + DESCRIPTION, + ], + }), + + // ── system ──────────────────────────────────────────────────────────── + api: defineList({ + schemaId: 'api', + columns: [ + NAME, + { field: 'method', label: 'Method', type: 'badge' }, + { field: 'path', label: 'Path' }, + { field: 'type', label: 'Type', type: 'badge' }, + { field: 'objectParams.object', label: 'Object' }, + { field: 'objectParams.operation', label: 'Operation', type: 'badge' }, + ], + }), + translation: defineList({ + schemaId: 'translation', + columns: [NAME, LABEL, { field: 'locale', label: 'Locale', type: 'badge' }], + }), + email_template: defineList({ + schemaId: 'email_template', + columns: [ + NAME, LABEL, + { field: 'locale', label: 'Locale', type: 'badge' }, + { field: 'subject', label: 'Subject' }, + { field: 'active', label: 'Active', type: 'boolean' }, + DESCRIPTION, + ], + }), + doc: defineList({ + schemaId: 'doc', + columns: [NAME, LABEL, { field: 'group', label: 'Group' }, { field: 'tags', label: 'Tags', type: 'list' }, DESCRIPTION], + }), + book: defineList({ + schemaId: 'book', + columns: [NAME, LABEL, { field: 'audience', label: 'Audience' }, { field: 'groups', label: 'Groups', type: 'count' }, DESCRIPTION], + }), + + // ── security ────────────────────────────────────────────────────────── + permission: defineList({ + schemaId: 'permission', + columns: [NAME, LABEL, DESCRIPTION], + }), + position: defineList({ + schemaId: 'position', + columns: [NAME, LABEL, DESCRIPTION], + }), + sharing_rule: defineList({ + schemaId: 'sharing_rule', + columns: [ + NAME, LABEL, + { field: 'object', label: 'Object' }, + { field: 'sharedWith', label: 'Shared With', type: 'summary' }, + { field: 'accessLevel', label: 'Access Level', type: 'badge' }, + ], + }), + queue: defineList({ + schemaId: 'queue', + columns: [NAME, LABEL, { field: 'members', label: 'Members', type: 'count' }, DESCRIPTION], + }), + + // ── ai ──────────────────────────────────────────────────────────────── + agent: defineList({ + schemaId: 'agent', + columns: [ + NAME, LABEL, + { field: 'role', label: 'Role' }, + { field: 'model.model', label: 'Model' }, + { field: 'active', label: 'Active', type: 'boolean' }, + ], + }), + tool: defineList({ + schemaId: 'tool', + columns: [NAME, LABEL, { field: 'objectName', label: 'Object Name' }, DESCRIPTION], + }), + skill: defineList({ + schemaId: 'skill', + columns: [ + NAME, LABEL, + { field: 'tools', label: 'Tools', type: 'count' }, + { field: 'active', label: 'Active', type: 'boolean' }, + DESCRIPTION, + ], + }), +}); + +/** Union of metadata type keys with a registered list layout. */ +export type MetadataListType = keyof typeof METADATA_LIST_REGISTRY; diff --git a/packages/spec/src/system/metadata-list-zod-reconciliation.test.ts b/packages/spec/src/system/metadata-list-zod-reconciliation.test.ts new file mode 100644 index 00000000000..9bb690b11be --- /dev/null +++ b/packages/spec/src/system/metadata-list-zod-reconciliation.test.ts @@ -0,0 +1,182 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * **Metadata list ↔ Zod reconciliation.** + * + * Every column in {@link METADATA_LIST_REGISTRY} names a key of a Zod schema + * the registry never imports — the same hand-copied-list shape + * `metadata-form-zod-reconciliation.test.ts` closes for forms. A column naming + * a key the schema does not declare renders an empty cell on every row and + * fails nowhere else, so this file is where it fails: + * + * - every registered type has a schema, and its list binds to that type; + * - every column path resolves, segment by segment, to a declared key (unions + * looked through, the same walk the form gate uses) that is not a + * `retiredKey()` tombstone and not the provenance/lock overlay; + * - every header equals the English source of the slot it is translated + * through, `metadataForms..fields..label`: the form field's own + * label when the type's form declares that path, else the humanized path + * (what `os i18n extract` emits for it). Two English sources for one slot + * would leave one of them untranslated. + */ + +import { describe, it, expect } from 'vitest'; + +import { METADATA_LIST_REGISTRY } from './metadata-list-registry'; +import { METADATA_FORM_REGISTRY } from './metadata-form-registry'; +import { getMetadataTypeSchema } from '../kernel/metadata-type-schemas'; +import { defineList } from '../ui/view.zod'; + +/** Peel wrapper nodes until an object/union node is reached (the form gate's walk). */ +function unwrap(schema: unknown, depth = 0): any { + const s = schema as any; + if (!s || depth > 25) return s; + const d = s.def ?? s._def; + if (!d) return s; + switch (d.type) { + case 'optional': + case 'nullable': + case 'default': + case 'prefault': + case 'readonly': + case 'catch': + case 'nonoptional': + return unwrap(d.innerType, depth + 1); + case 'array': + return unwrap(d.element, depth + 1); + case 'record': + return unwrap(d.valueType, depth + 1); + case 'lazy': + return unwrap(d.getter(), depth + 1); + case 'pipe': { + const inner = unwrap(d.in, depth + 1); + const innerType = (inner?.def ?? inner?._def)?.type; + return innerType === 'transform' ? unwrap(d.out, depth + 1) : inner; + } + default: + return s; + } +} + +/** The property node under `key`, looking through union members; `undefined` when undeclared. */ +function propertyOf(schema: unknown, key: string): unknown { + const u = unwrap(schema); + const d = u?.def ?? u?._def; + if (d?.type === 'object') return (d.shape ?? u.shape ?? {})[key]; + if (d?.type === 'union' || d?.type === 'discriminated_union') { + for (const option of d.options ?? []) { + const found = propertyOf(option, key); + if (found !== undefined && !isRetiredNode(found)) return found; + } + for (const option of d.options ?? []) { + const found = propertyOf(option, key); + if (found !== undefined) return found; + } + } + return undefined; +} + +/** A `retiredKey()` tombstone: `z.never()` under its optional wrapper. */ +function isRetiredNode(prop: unknown): boolean { + const u = unwrap(prop); + return (u?.def ?? u?._def)?.type === 'never'; +} + +/** Why `path` does not resolve to a writable key of `root`, or `null` when it does. */ +function pathDefect(root: unknown, path: string): string | null { + let node: unknown = root; + for (const segment of path.split('.')) { + if (segment.startsWith('_')) return `\`${segment}\` is the provenance/lock overlay, not the type's own key`; + const next = propertyOf(node, segment); + if (next === undefined) return `\`${segment}\` is not declared`; + if (isRetiredNode(next)) return `\`${segment}\` is retired`; + node = next; + } + return null; +} + +/** The extractor's fallback label for a path with no declared label (`humanizeFieldPath`, `@objectstack/lint`). */ +function humanizeFieldPath(path: string): string { + const leaf = path.split('.').pop() ?? path; + return leaf + .replace(/([a-z0-9])([A-Z])/g, '$1 $2') + .replace(/[_-]+/g, ' ') + .replace(/\b\w/g, (c) => c.toUpperCase()); +} + +/** `path → English label` for every field the type's form declares, at every depth. */ +function formFieldLabels(type: string): Map { + const out = new Map(); + const form = METADATA_FORM_REGISTRY[type] as any; + const walk = (fields: any[] | undefined, parent: string) => { + for (const f of fields ?? []) { + if (!f || typeof f !== 'object') continue; + const path = typeof f.field === 'string' ? (parent ? `${parent}.${f.field}` : f.field) : parent; + if (path && typeof f.field === 'string') { + out.set(path, typeof f.label === 'string' ? f.label : humanizeFieldPath(path)); + } + walk(f.fields, path); + } + }; + for (const section of [...(form?.sections ?? []), ...(form?.groups ?? [])]) walk(section?.fields, ''); + return out; +} + +const TYPES = Object.keys(METADATA_LIST_REGISTRY); + +describe('METADATA_LIST_REGISTRY ↔ the type schemas', () => { + it('declares a list for the first-batch types and the nine types the console used to declare', () => { + expect(TYPES.sort()).toEqual([ + 'action', 'agent', 'api', 'assignment_rule', 'book', 'dashboard', 'dataset', 'doc', + 'email_template', 'field', 'flow', 'hook', 'job', 'mapping', 'object', 'page', + 'permission', 'picklist', 'position', 'queue', 'report', 'seed', 'sharing_rule', + 'skill', 'tool', 'translation', 'view', + ]); + }); + + it.each(TYPES)('%s: binds to its own type, which has a schema', (type) => { + const list = METADATA_LIST_REGISTRY[type] as any; + expect(list.data).toEqual({ provider: 'schema', schemaId: type }); + expect(getMetadataTypeSchema(type)).toBeDefined(); + }); + + it.each(TYPES)('%s: every column names a declared, writable key of the schema', (type) => { + const root = getMetadataTypeSchema(type); + const defects = METADATA_LIST_REGISTRY[type].columns + .map((c) => [c.field, pathDefect(root, c.field)] as const) + .filter(([, defect]) => defect !== null) + .map(([field, defect]) => `${type}.${field}: ${defect}`); + expect(defects).toEqual([]); + }); + + it.each(TYPES)('%s: no column is declared twice', (type) => { + const fields = METADATA_LIST_REGISTRY[type].columns.map((c) => c.field); + expect(new Set(fields).size).toBe(fields.length); + }); + + it.each(TYPES)('%s: every header is the English source of its translation slot', (type) => { + const formLabels = formFieldLabels(type); + const mismatches = METADATA_LIST_REGISTRY[type].columns + .map((c) => ({ field: c.field, label: c.label, source: formLabels.get(c.field) ?? humanizeFieldPath(c.field) })) + .filter((c) => c.label !== c.source) + .map((c) => `${type}.${c.field}: header ${JSON.stringify(c.label)}, slot source ${JSON.stringify(c.source)}`); + expect(mismatches).toEqual([]); + }); +}); + +describe('the gate can fail', () => { + it('names an undeclared key, a retired key and an overlay key', () => { + const hook = getMetadataTypeSchema('hook'); + expect(pathDefect(hook, 'objectName')).toBe('`objectName` is not declared'); + expect(pathDefect(hook, '_packageId')).toMatch(/overlay/); + expect(pathDefect(getMetadataTypeSchema('email_template'), 'category')).toBe('`category` is retired'); + expect(pathDefect(getMetadataTypeSchema('api'), 'objectParams.object')).toBeNull(); + expect(pathDefect(getMetadataTypeSchema('api'), 'objectParams.target')).toBe('`target` is not declared'); + }); + + it('defineList refuses a column with a renderer outside the closed vocabulary, or no columns', () => { + expect(() => defineList({ schemaId: 'hook', columns: [{ field: 'name', type: 'currency' as never }] })).toThrow(); + expect(() => defineList({ schemaId: 'hook', columns: [] })).toThrow(); + expect(() => defineList({ schemaId: 'hook', columns: [{ field: 'name', width: 120 } as never] })).toThrow(); + }); +}); diff --git a/packages/spec/src/ui/view.zod.ts b/packages/spec/src/ui/view.zod.ts index 1944dba063f..aa3bfb68844 100644 --- a/packages/spec/src/ui/view.zod.ts +++ b/packages/spec/src/ui/view.zod.ts @@ -3904,6 +3904,55 @@ export const ListViewSchema = lazySchema(() => .superRefine(checkListViewChartBinding) .superRefine(checkListViewTimesheetBinding)); +/** + * How a metadata list cell draws its value. The vocabulary is closed: each value + * names a renderer the Studio metadata list ships. + * + * - `text` (the default): the value as written. + * - `badge`: a short enum value, as a chip. + * - `boolean`: a yes/no mark. + * - `count`: how many entries an array or a keyed record holds. + * - `list`: the entries of an array, joined; a single value as itself. + * - `summary`: the scalar members of an object value, joined in key order. + */ +export const MetadataListCellTypeSchema = lazySchema(() => z.enum([ + 'text', + 'badge', + 'boolean', + 'count', + 'list', + 'summary', +]).describe('How a metadata list cell draws its value')); + +/** + * One column of a metadata type's list: {@link ListColumnSchema} narrowed to the + * three members a platform list declares. `field` names a key of the type's own + * schema (or a dotted path into it), `label` is the English header, and `type` + * picks the cell renderer from {@link MetadataListCellTypeSchema}. + * + * The header is translated through the same slot as the type's form field of + * that path: `metadataForms..fields..label`. + */ +export const MetadataListColumnSchema = lazySchema(() => ListColumnSchema + .pick({ field: true, label: true, type: true }) + .extend({ + field: z.string().min(1).describe('Key of the metadata type\'s schema: a top-level key, or a dotted path into it'), + type: MetadataListCellTypeSchema.optional().describe('Cell renderer; `text` when absent'), + }) + .describe('One column of a metadata type list')); + +/** + * The list layout of a metadata type in Studio: {@link ListViewSchema} narrowed + * to its data binding and its columns, the list counterpart of a + * {@link defineForm} layout. Build one with {@link defineList}. + */ +export const MetadataListViewSchema = lazySchema(() => ListViewShapeSchema + .pick({ data: true, columns: true }) + .extend({ + columns: z.array(MetadataListColumnSchema).min(1).describe('Columns of the list, in display order'), + }) + .describe('List layout of a metadata type: its schema binding and its columns')); + /** * [commit c459da6bc] Form-view select option — {@link SelectOptionSchema} minus the * per-option `default` key (maintainer-ruled narrowing, 2026-08-28, on the @@ -8202,6 +8251,39 @@ export function defineForm( throw refusal; } +/** + * Type-safe factory for a metadata type's Studio list layout — the list + * counterpart of {@link defineForm}. It binds the columns to the type's JSON + * Schema (`data.provider === 'schema'`) and validates them against + * {@link MetadataListViewSchema} at definition time, so a malformed column + * fails at module load. + * + * @example + * ```ts + * export const hookList = defineList({ + * schemaId: 'hook', + * columns: [ + * { field: 'name', label: 'Name' }, + * { field: 'object', label: 'Object', type: 'list' }, + * { field: 'events', label: 'Events', type: 'list' }, + * ], + * }); + * ``` + */ +export function defineList( + config: Omit, 'data'> & { schemaId: string }, +): MetadataListViewParsed { + const { schemaId, ...rest } = config; + const parsed = MetadataListViewSchema.safeParse({ + ...rest, + data: { provider: 'schema', schemaId }, + }); + if (parsed.success) return parsed.data; + const refusal = new z.ZodRealError(parsed.error.issues); + z.core.util.captureStackTrace(refusal, defineList); + throw refusal; +} + /** * [#19678] The remedy {@link defineForm}'s refusal of an unspellable inline * option `value` carries — ruling 乙 (record 5805845085, narrowing ruling @@ -8338,6 +8420,13 @@ export type FormSelectOptionParsed = z.infer; export type ListColumn = z.input; /** Post-parse shape of {@link ListColumn} — defaults applied, transforms run (ADR-0122). */ export type ListColumnParsed = z.infer; +export type MetadataListCellType = z.input; +export type MetadataListColumn = z.input; +/** Post-parse shape of {@link MetadataListColumn} — defaults applied, transforms run (ADR-0122). */ +export type MetadataListColumnParsed = z.infer; +export type MetadataListView = z.input; +/** Post-parse shape of {@link MetadataListView} — defaults applied, transforms run (ADR-0122). */ +export type MetadataListViewParsed = z.infer; // `FormField` is declared next to FormFieldSchema — it IS that schema's // annotation, so it cannot be inferred back out of it (#4171). export type SelectionConfig = z.input; From 440232f0f82885e742530bd6a4ace19c91a96d61 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 05:30:16 +0000 Subject: [PATCH 2/5] wip(console): read served metadata list columns first Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzg7mFFG5b13DcQ93kf --- packages/lint/src/i18n-walk.ts | 24 +- scripts/check-i18n-bundles.mjs | 4 + .../src/services/builtinComponents.tsx | 71 ++---- ...eListPage.servedListColumns-36860.test.tsx | 216 ++++++++++++++++++ .../views/metadata-admin/ResourceListPage.tsx | 18 +- .../src/views/metadata-admin/anchors.ts | 37 +-- .../src/views/metadata-admin/registry.ts | 33 ++- .../metadata-admin/servedListColumns.test.tsx | 87 +++++++ .../metadata-admin/servedListColumns.tsx | 156 +++++++++++++ .../src/views/metadata-admin/useMetadata.ts | 7 + 10 files changed, 562 insertions(+), 91 deletions(-) create mode 100644 ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx create mode 100644 ui/packages/app-shell/src/views/metadata-admin/servedListColumns.test.tsx create mode 100644 ui/packages/app-shell/src/views/metadata-admin/servedListColumns.tsx diff --git a/packages/lint/src/i18n-walk.ts b/packages/lint/src/i18n-walk.ts index fc71c5179bb..839003b0f47 100644 --- a/packages/lint/src/i18n-walk.ts +++ b/packages/lint/src/i18n-walk.ts @@ -161,9 +161,10 @@ * metadataForms..fields..label / .helpText / .placeholder * * The `metadataForms.*` surface is registry-driven (sourced from - * `METADATA_FORM_REGISTRY` + `DEFAULT_METADATA_TYPE_REGISTRY` in - * `@objectstack/spec`) — it is included unconditionally, independent of - * the supplied stack config. + * `METADATA_FORM_REGISTRY`, `METADATA_LIST_REGISTRY` and + * `DEFAULT_METADATA_TYPE_REGISTRY` in `@objectstack/spec`; a list column's + * header is the `fields..label` slot of its path) — it is included + * unconditionally, independent of the supplied stack config. * * Pure given its inputs: no network, and the only filesystem read is the * shipped liveness ledger behind {@link authorWarnedTranslationGroups} — @@ -175,6 +176,7 @@ import { METADATA_FORM_REGISTRY, + METADATA_LIST_REGISTRY, PAGE_COMPONENT_COPY_KEYS, FLOW_SCREEN_COPY_KEYS, FLOW_SCREEN_FIELD_COPY_KEYS, @@ -2757,6 +2759,22 @@ function walkMetadataForms(out: ExpectedEntry[]): void { } } } + + // 3) List column headers (`METADATA_LIST_REGISTRY`). A column is translated + // through the form field slot of the same path, so only a path the + // type's form does not already declare needs its own entry. + const formFieldSlots = new Set( + out + .filter((e) => e.source === 'metadataFormField' && e.path[0] === 'metadataForms' && e.path[2] === 'fields' && e.path[4] === 'label') + .map((e) => `${e.path[1]}\u0000${e.path[3]}`), + ); + for (const [type, list] of Object.entries(METADATA_LIST_REGISTRY)) { + for (const column of list.columns) { + if (formFieldSlots.has(`${type}\u0000${column.field}`)) continue; + formFieldSlots.add(`${type}\u0000${column.field}`); + pushEntry(out, ['metadataForms', type, 'fields', column.field, 'label'], inlineText(column.label) ?? humanizeFieldPath(column.field), 'metadataFormField', { metadataType: type }); + } + } } /** Recursive walker for FormField nodes, accumulating dot-path. */ diff --git a/scripts/check-i18n-bundles.mjs b/scripts/check-i18n-bundles.mjs index 39698702162..81af7abacef 100644 --- a/scripts/check-i18n-bundles.mjs +++ b/scripts/check-i18n-bundles.mjs @@ -183,6 +183,10 @@ const SURFACE_MODULE = 'scripts/i18n-bundle-surface.mjs'; */ const METADATA_TYPE_REGISTRY_MODULE = 'packages/spec/src/kernel/metadata-plugin.zod.ts'; const METADATA_FORM_REGISTRY_MODULE = 'packages/spec/src/system/metadata-form-registry.ts'; +// The list registry is a third producer of the same surface: `walkMetadataForms` +// emits `metadataForms..fields..label` for each list column whose +// path the type's form does not declare. +const METADATA_LIST_REGISTRY_MODULE = 'packages/spec/src/system/metadata-list-registry.ts'; /** The one command this gate invokes per package, as oclif topic/command parts. */ const EXTRACT_COMMAND_ID = ['i18n', 'extract']; diff --git a/ui/packages/app-shell/src/services/builtinComponents.tsx b/ui/packages/app-shell/src/services/builtinComponents.tsx index d986c460349..985d69311bf 100644 --- a/ui/packages/app-shell/src/services/builtinComponents.tsx +++ b/ui/packages/app-shell/src/services/builtinComponents.tsx @@ -317,11 +317,7 @@ registerMetadataResource({ description: 'Domain entities — tables in the data model. Each object owns its fields, relationships, validations, and lifecycle hooks.', domain: 'data', searchableFields: ['name', 'label', 'description'], - listColumns: [ - { key: 'name', label: 'Name', width: '25%' }, - { key: 'label', label: 'Label', width: '25%' }, - { key: 'description', label: 'Description' }, - ], + // objectstack#36860 — the list columns are the spec's (`METADATA_LIST_REGISTRY`). // objectui#10202 — the editor is seeded from the SERVED object, where a // picklist-bound field carries `picklist` plus the options resolved from the // list; the authoring door refuses the two together. The saved body drops @@ -337,12 +333,9 @@ registerMetadataResource({ description: 'Columns attached to objects — name, type, validation, and storage settings.', domain: 'data', searchableFields: ['name', 'label', 'object', 'type'], - listColumns: [ - { key: 'name', label: 'Name', width: '25%' }, - { key: 'object', label: 'Object', width: '20%' }, - { key: 'type', label: 'Type', width: '15%' }, - { key: 'label', label: 'Label' }, - ], + // objectstack#36860 — name / type / label are the spec's columns; a field + // row's `object` is stamped by the server, not a `FieldSchema` key. + listExtraColumns: [{ key: 'object', label: 'Object', width: '20%' }], }); /* -------------------------------------------------------------------------- */ @@ -360,12 +353,8 @@ registerMetadataResource({ // objectui#7611 — no `managedBy` column: the registry serves no such key on a // permission set (measured on objectstack main), so it read "Custom" for every // set, the platform's own included. Provenance is the list's own Source badge, - // read from the served `_packageId` / `_provenance`. - listColumns: [ - { key: 'name', label: 'Name', width: '30%' }, - { key: 'label', label: 'Label', width: '30%' }, - { key: 'description', label: 'Description' }, - ], + // read from the served `_packageId` / `_provenance`. objectstack#36860 — the + // columns are the spec's. }); // objectstack#25333 — the position list says who holds each position and which @@ -384,10 +373,9 @@ registerMetadataResource({ // admits a live position create (`allowRuntimeCreate`); under `?package=` // the create stays a package draft (ADR-0086). createLive: true, - listColumns: [ - { key: 'name', label: 'Name', width: '20%' }, - { key: 'label', label: 'Label', width: '20%' }, - { key: 'description', label: 'Description' }, + // objectstack#36860 — name / label / description are the spec's columns; the + // holder count and the granted sets are served beside each row. + listExtraColumns: [ { key: '_holderCount', label: 'Holders', @@ -413,20 +401,16 @@ registerMetadataResource({ label: 'Views', description: 'Saved list / kanban / calendar / gantt configurations on top of an object.', domain: 'ui', - listColumns: [ - { key: 'name', label: 'Name', width: '30%' }, - { key: 'object', label: 'Object', width: '20%' }, - { - key: 'type', - label: 'Type', + // objectstack#36860 — the columns are the spec's. + listCells: { + type: { width: '15%', // Expanded ViewItems keep their display type under `config.type` // and only the list/form family at the top level — derive it so the // column shows "calendar" / "grid" / "form" instead of "—". render: (_v, item) => viewDisplayType(item) ?? '—', }, - { key: 'label', label: 'Label' }, - ], + }, // ADR-0017 — the framework exposes each view as a canonical first-class // ViewItem ({ name, object, viewKind, label, config }). The inspector and // preview read that shape directly (`draft.config`), so NO toDraft/fromDraft @@ -441,11 +425,6 @@ registerMetadataResource({ label: 'Dashboards', description: 'Composed dashboards with charts, KPIs, and tables.', domain: 'ui', - listColumns: [ - { key: 'name', label: 'Name', width: '30%' }, - { key: 'label', label: 'Label', width: '30%' }, - { key: 'description', label: 'Description' }, - ], }); /** @@ -475,11 +454,6 @@ registerMetadataResource({ label: 'Pages', description: 'Visual page layouts authored as JSON metadata.', domain: 'ui', - listColumns: [ - { key: 'name', label: 'Name', width: '30%' }, - { key: 'label', label: 'Label', width: '30%' }, - { key: 'route', label: 'Route' }, - ], fromDraft: pageSaveBody, }); @@ -495,12 +469,10 @@ registerMetadataResource({ description: 'Documentation navigation spine — ordered groups with membership derived over docs (glob/tag rules), plus an explicit pages override for curated order.', domain: 'system', searchableFields: ['name', 'label', 'description', 'slug'], - listColumns: [ - { key: 'name', label: 'Name', width: '25%' }, - { key: 'label', label: 'Label', width: '25%' }, - { - key: 'audience', - label: 'Audience', + // objectstack#36860 — the columns are the spec's; the audience cell names + // the org default and a permission-set audience in words. + listCells: { + audience: { width: '12%', render: (v) => v == null @@ -509,12 +481,5 @@ registerMetadataResource({ ? `permission set: ${(v as { permissionSet: string }).permissionSet}` : String(v), }, - { - key: 'groups', - label: 'Groups', - width: '10%', - render: (v) => (Array.isArray(v) ? String(v.length) : '0'), - }, - { key: 'description', label: 'Description' }, - ], + }, }); diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx new file mode 100644 index 00000000000..d81bd263922 --- /dev/null +++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx @@ -0,0 +1,216 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36860 — the generic metadata list reads the columns the type's + * `/meta/types` entry serves (`entries[].list`, the spec's + * `METADATA_LIST_REGISTRY`), ahead of the console's own declaration. + * + * What is pinned, each against a control: + * + * - a served list decides the columns and their order, and its headers are + * shown exactly as served (already in the reader's locale), never replaced + * by the console's `engine.list.col.*` text for the same key; + * - each declared renderer draws its cell: a list joins, a count counts, a + * boolean marks, a dotted path reads into the body; + * - a key the stored row leaves out shows the schema default the served JSON + * Schema declares (what the runtime uses), and a key with no default shows + * the empty cell; + * - a type serving no list keeps the default name / label / description; + * - a console `listCells` override draws the cell of a served column, and a + * console `listExtraColumns` column follows the served ones. + */ +import { describe, it, expect, vi, afterEach } from 'vitest'; +import { render, cleanup, screen, within } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import * as React from 'react'; +import { MemoryRouter, Route, Routes } from 'react-router-dom'; + +const HOOKS: Record[] = [ + { name: 'stamp_owner', label: 'Stamp owner', object: 'account', events: ['beforeInsert', 'beforeUpdate'], async: true }, + // `priority` and `async` left at their schema defaults: stored rows omit them. + { name: 'audit_all', label: 'Audit all', object: ['account', 'contact'], events: ['afterDelete'] }, +]; +const AGENTS: Record[] = [{ name: 'helper', label: 'Helper', model: { provider: 'openai', model: 'gpt-4o' } }]; +const QUEUES: Record[] = [{ name: 'tier1', label: 'Tier 1', members: [{ type: 'user', id: 'a' }, { type: 'user', id: 'b' }] }]; +const VIEWS: Record[] = [ + { name: 'all_accounts', object: 'account', label: 'All accounts', viewKind: 'list', config: { type: 'kanban' } }, +]; + +const CLIENT = { + list: async (type: string) => + type === 'hook' ? HOOKS : type === 'agent' ? AGENTS : type === 'queue' ? QUEUES : type === 'view' ? VIEWS : [], +}; + +// Headers as the server serves them to a zh-CN reader. +const HOOK_ENTRY = { + type: 'hook', + label: '钩子', + allowEnvironmentOverlay: false, + allowRuntimeCreate: true, + schema: { + type: 'object', + properties: { + name: { type: 'string' }, + priority: { type: 'number', default: 100 }, + async: { type: 'boolean', default: false }, + events: { type: 'array', items: { type: 'string' } }, + }, + }, + list: { + data: { provider: 'schema', schemaId: 'hook' }, + columns: [ + { field: 'name', label: '名称' }, + { field: 'object', label: '对象', type: 'list' }, + { field: 'events', label: '事件', type: 'list' }, + { field: 'priority', label: '优先级' }, + { field: 'async', label: '异步', type: 'boolean' }, + { field: 'description', label: '描述' }, + ], + }, +}; +const AGENT_ENTRY = { + type: 'agent', + label: 'Agent', + allowEnvironmentOverlay: false, + allowRuntimeCreate: true, + list: { + data: { provider: 'schema', schemaId: 'agent' }, + columns: [ + { field: 'name', label: 'Name' }, + { field: 'model.model', label: 'Model' }, + ], + }, +}; +const QUEUE_ENTRY = { + type: 'queue', + label: 'Queue', + allowEnvironmentOverlay: false, + allowRuntimeCreate: true, + list: { + data: { provider: 'schema', schemaId: 'queue' }, + columns: [ + { field: 'name', label: 'Name' }, + { field: 'members', label: 'Members', type: 'count' }, + ], + }, +}; +// Control: a type that serves no list. +const SKILL_ENTRY = { type: 'skill', label: 'Skill', allowEnvironmentOverlay: false, allowRuntimeCreate: true }; +const VIEW_ENTRY = { + type: 'view', + label: 'View', + allowEnvironmentOverlay: false, + allowRuntimeCreate: true, + list: { + data: { provider: 'schema', schemaId: 'view' }, + columns: [ + { field: 'name', label: 'Name' }, + { field: 'type', label: 'Type', type: 'badge' }, + ], + }, +}; + +vi.mock('./useMetadata', async (importOriginal) => ({ + ...(await importOriginal>()), + useMetadataClient: () => CLIENT, + useMetadataTypes: () => ({ + loading: false, + error: null, + entries: [HOOK_ENTRY, AGENT_ENTRY, QUEUE_ENTRY, SKILL_ENTRY, VIEW_ENTRY], + }), +})); + +vi.mock('./i18n', async (importOriginal) => ({ + ...(await importOriginal>()), + useMetadataLocale: () => 'en-US', +})); + +vi.mock('../../hooks/useCanAuthorMetadata', () => ({ + useCanAuthorMetadata: () => true, +})); + +vi.mock('../../hooks/useTenancyPosture', async (importOriginal) => ({ + ...(await importOriginal>()), + useTenancyPosture: () => 'single', +})); + +// Imported AFTER the mocks so the page picks them up. +import { MetadataResourceListPage } from './ResourceListPage'; +import { registerBuiltinAnchors } from './anchors'; +import { registerMetadataResource } from './registry'; +import '../../services/builtinComponents'; + +registerBuiltinAnchors(); +registerMetadataResource({ + type: 'queue', + listCells: { members: { render: (v) => `${Array.isArray(v) ? v.length : 0} people` } }, + listExtraColumns: [{ key: '_packageId', label: 'Package' }], +}); + +afterEach(() => { + cleanup(); +}); + +function mount(type: string) { + return render( + + + } /> + + , + ); +} + +async function headersOf(): Promise { + const table = await screen.findByRole('table'); + return within(table) + .getAllByRole('columnheader') + .map((th) => th.textContent?.trim() ?? '') + .filter((text) => text !== ''); +} + +async function rowOf(name: string): Promise { + const cell = await screen.findByText(name); + const row = cell.closest('tr'); + if (!row) throw new Error(`no row for ${name}`); + return within(row).getAllByRole('cell').map((td) => td.textContent?.trim() ?? ''); +} + +describe('the generic list reads the served columns (objectstack#36860)', () => { + it('a served list decides the columns, in order, under the served headers', async () => { + mount('hook'); + const headers = await headersOf(); + expect(headers.slice(0, 6)).toEqual(['名称', '对象', '事件', '优先级', '异步', '描述']); + }); + + it('each declared renderer draws its cell, and an absent key shows its schema default', async () => { + mount('hook'); + expect((await rowOf('stamp_owner')).slice(0, 5)).toEqual(['stamp_owner', 'account', 'beforeInsert, beforeUpdate', '100', '✓']); + // `object` as a list of objects; `priority` / `async` absent → 100 / ✗. + expect((await rowOf('audit_all')).slice(0, 5)).toEqual(['audit_all', 'account, contact', 'afterDelete', '100', '✗']); + }); + + it('a dotted path reads into the body', async () => { + mount('agent'); + expect((await rowOf('helper')).slice(0, 2)).toEqual(['helper', 'gpt-4o']); + }); + + it('a type serving no list keeps the default columns (control)', async () => { + mount('skill'); + const headers = await headersOf(); + expect(headers).toContain('Name'); + expect(headers).toContain('Description'); + expect(headers).not.toContain('Tools'); + }); + + it('a console cell override draws a served column; a console extra column follows the served ones', async () => { + mount('queue'); + expect((await headersOf()).slice(0, 3)).toEqual(['Name', 'Members', 'Package']); + expect((await rowOf('tier1')).slice(0, 2)).toEqual(['tier1', '2 people']); + }); + + it('the view list keeps its derived display type through its cell override', async () => { + mount('view'); + expect((await rowOf('all_accounts')).slice(0, 2)).toEqual(['all_accounts', 'kanban']); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.tsx index fe624a36508..c291298966b 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.tsx @@ -58,6 +58,7 @@ import { resolveResourceConfig, } from './registry.js'; import { t, tFormat, translateMetadataType, useMetadataLocale } from './i18n.js'; +import { servedListColumns, withExtraColumns, type ListColumns } from './servedListColumns.js'; import { buildPackageScopeOptions } from './package-scope.js'; import { ENVIRONMENT_SCOPE_QUERY, isEnvironmentScope, useWalledCatalogReadOnly } from './catalog-scope.js'; import { useMetadataAreaHost } from './metadataAreaHost.js'; @@ -714,8 +715,15 @@ function DefaultMetadataList({ type, appName }: { type: string; appName?: string [scopedItems], ); + // objectstack#36860 — the served list layout first, then the console's own + // columns, then the default (`servedListColumns.tsx` states the precedence). const columns = withBundleMemberColumn( - config.listColumns ?? defaultColumns(config.primaryKey ?? 'name'), + withExtraColumns( + servedListColumns(entry?.list, entry?.schema, config.listCells) + ?? config.listColumns + ?? defaultColumns(config.primaryKey ?? 'name'), + config.listExtraColumns, + ), config.bundleMemberField, ); const typeLabel = translateMetadataType(type, locale, entry?.label ?? type); @@ -742,9 +750,10 @@ function DefaultMetadataList({ type, appName }: { type: string; appName?: string // area never wait on them. const packagesPending = !envScope && !host && projectPackages === null; - // Localise default column labels — registered columns keep their - // hand-authored labels (consumers may want bespoke wording). - const localizeColumnLabel = (col: { key: string; label: string }) => { + // Localise a console column's header through `engine.list.col.`. A + // served header is already in the reader's locale and is shown as served. + const localizeColumnLabel = (col: { key: string; label: string; labelLocalized?: boolean }) => { + if (col.labelLocalized) return col.label; const tryKey = `engine.list.col.${col.key}`; const translated = t(tryKey, locale); return translated === tryKey ? col.label : translated; @@ -1389,7 +1398,6 @@ export function openRowFromClick(e: React.MouseEvent, open: () => v const ROW_OWN_CONTROLS = 'a,button,input,select,textarea,label,summary,[role="button"],[role="switch"],[role="checkbox"],[role="menuitem"],[role="link"],[contenteditable="true"]'; -type ListColumns = NonNullable; /** * objectstack#26649 — the member column of a type whose identity is a pair, diff --git a/ui/packages/app-shell/src/views/metadata-admin/anchors.ts b/ui/packages/app-shell/src/views/metadata-admin/anchors.ts index c839973fd13..d6e87cbb74c 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/anchors.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/anchors.ts @@ -571,26 +571,9 @@ export function registerBuiltinAnchors(): void { // seed it as an empty record so the saved body validates. createDefaults: { fields: {} }, searchableFields: ['name', 'label', 'pluralLabel', 'description'], - listColumns: [ - { key: 'name', label: 'Name', width: '24%' }, - { key: 'label', label: 'Label', width: '22%' }, - { key: 'pluralLabel', label: 'Plural', width: '22%' }, - { - key: 'fields', - label: 'Fields', - width: '90px', - render: (value) => { - if (value == null) return '—'; - const count = Array.isArray(value) - ? value.length - : typeof value === 'object' - ? Object.keys(value as Record).length - : 0; - return count; - }, - }, - { key: 'description', label: 'Description' }, - ], + // objectstack#36860 — the list columns are the spec's + // (`METADATA_LIST_REGISTRY`): name, label, plural label, field count, + // description. }); // objectui#12982 — the declared sharing rules Setup lists read-only @@ -600,19 +583,17 @@ export function registerBuiltinAnchors(): void { type: 'sharing_rule', iconName: 'share-2', searchableFields: ['name', 'label', 'description', 'object'], - listColumns: [ - { key: 'name', label: 'Name' }, - { key: 'label', label: 'Label' }, - { key: 'object', label: 'Object' }, - { - key: 'sharedWith', - label: 'Shared with', + // objectstack#36860 — name / label / object / shared with / access level + // are the spec's columns; the declaring package is served beside each row. + listCells: { + sharedWith: { render: (value) => { const v = value as { type?: unknown; value?: unknown } | null | undefined; return v && typeof v === 'object' ? `${String(v.type ?? '')}: ${String(v.value ?? '')}` : '—'; }, }, - { key: 'accessLevel', label: 'Access' }, + }, + listExtraColumns: [ { key: '_packageId', label: 'Package', diff --git a/ui/packages/app-shell/src/views/metadata-admin/registry.ts b/ui/packages/app-shell/src/views/metadata-admin/registry.ts index e1029d6af16..2c755bbc1b2 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/registry.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/registry.ts @@ -131,7 +131,7 @@ export interface MetadataResourceConfig { * What the list page asks the server to serve beside each item (the list * read's `include`). `'grants'` is the `position` list's holder count and * permission sets in force (objectstack#25333); the columns that read them - * are this type's own `listColumns`. Omit for the plain list. + * are this type's own `listExtraColumns`. Omit for the plain list. */ listInclude?: 'grants'; /** @@ -145,7 +145,13 @@ export interface MetadataResourceConfig { */ bundleMemberField?: string; - /** Columns rendered in the list page. */ + /** + * Columns rendered in the list page of a type that serves NO list layout + * (`/meta/types` `entries[].list`, the spec's `METADATA_LIST_REGISTRY`). + * A type that declares its list in the spec never reads this: its columns + * are the served ones, with {@link listCells} and {@link listExtraColumns} + * (`servedListColumns.tsx`). + */ listColumns?: Array<{ key: string; label: string; @@ -153,7 +159,30 @@ export interface MetadataResourceConfig { render?: (value: unknown, item: Record) => ReactNode; /** Column width hint in CSS (e.g. `'180px'`, `'30%'`). */ width?: string; + /** + * The header is already in the reader's locale (a served column), so it is + * shown as is and not looked up in the `engine.list.col.*` table. + */ + labelLocalized?: boolean; }>; + /** + * Console cell drawing for a column the served list layout declares, keyed by + * the column's `field`: a renderer for a value whose shape the declared + * renderer cannot draw well, and an optional width. The header stays the + * served one. + */ + listCells?: Record) => ReactNode; + width?: string; + }>; + /** + * Columns appended after the list's own (served, else {@link listColumns}, + * else the default): values the server stamps on a list row + * (`_holderCount`, `_packageId`, a field's `object`) that are not keys of the + * type's own schema, so the spec cannot declare them. + */ + listExtraColumns?: MetadataResourceConfig['listColumns']; /** * Fully custom list page. When provided, the generic shell is bypassed. * Receives `{ type }`. Use this for ObjectManager, etc. diff --git a/ui/packages/app-shell/src/views/metadata-admin/servedListColumns.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/servedListColumns.test.tsx new file mode 100644 index 00000000000..8397af98ffd --- /dev/null +++ b/ui/packages/app-shell/src/views/metadata-admin/servedListColumns.test.tsx @@ -0,0 +1,87 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36860 — the cell renderers and the path/default readers behind + * the served list columns, pinned without the page around them. + */ +import { describe, it, expect } from 'vitest'; +import { render } from '@testing-library/react'; +import * as React from 'react'; + +import { renderListCell, schemaDefaultAt, servedListColumns, valueAtPath, withExtraColumns } from './servedListColumns'; + +function text(node: React.ReactNode): string { + const { container } = render(<>{node}); + return container.textContent ?? ''; +} + +describe('renderListCell', () => { + it('count counts an array and a keyed record', () => { + expect(text(renderListCell('count', [1, 2, 3]))).toBe('3'); + expect(text(renderListCell('count', { a: 1, b: 2 }))).toBe('2'); + expect(text(renderListCell('count', []))).toBe('0'); + }); + + it('list joins an array and shows a single value as itself', () => { + expect(text(renderListCell('list', ['a', 'b']))).toBe('a, b'); + expect(text(renderListCell('list', 'account'))).toBe('account'); + }); + + it('summary joins the scalar members of an object', () => { + expect(text(renderListCell('summary', { type: 'cron', expression: '0 0 * * *', timezone: 'UTC' }))).toBe('cron · 0 0 * * * · UTC'); + }); + + it('boolean marks, badge shows the value, text shows a scalar as written', () => { + expect(text(renderListCell('boolean', true))).toBe('✓'); + expect(text(renderListCell('boolean', false))).toBe('✗'); + expect(text(renderListCell('badge', 'GET'))).toBe('GET'); + expect(text(renderListCell(undefined, 42))).toBe('42'); + }); + + it('an empty value is the empty cell, not a blank and not a zero', () => { + const empty = text(renderListCell(undefined, undefined)); + expect(text(renderListCell('list', []))).toBe(empty); + expect(text(renderListCell('badge', ''))).toBe(empty); + expect(text(renderListCell('count', undefined))).toBe(empty); + }); +}); + +describe('valueAtPath / schemaDefaultAt', () => { + it('reads a dotted path and answers undefined past a missing segment', () => { + expect(valueAtPath({ model: { model: 'gpt-4o' } }, 'model.model')).toBe('gpt-4o'); + expect(valueAtPath({ model: 'x' }, 'model.model')).toBeUndefined(); + expect(valueAtPath({}, 'objectParams.object')).toBeUndefined(); + }); + + it('finds a default at a dotted path, through union arms', () => { + const schema = { + properties: { + priority: { type: 'number', default: 100 }, + schedule: { anyOf: [{ properties: { timezone: { default: 'UTC' } } }] }, + }, + }; + expect(schemaDefaultAt(schema, 'priority')).toBe(100); + expect(schemaDefaultAt(schema, 'schedule.timezone')).toBe('UTC'); + expect(schemaDefaultAt(schema, 'name')).toBeUndefined(); + expect(schemaDefaultAt(undefined, 'priority')).toBeUndefined(); + }); +}); + +describe('servedListColumns / withExtraColumns', () => { + it('answers undefined for a type that serves no list, so the caller falls back', () => { + expect(servedListColumns(undefined, undefined)).toBeUndefined(); + expect(servedListColumns({ columns: [] } as never, undefined)).toBeUndefined(); + }); + + it('marks every served header as already localized', () => { + const cols = servedListColumns({ columns: [{ field: 'name', label: '名称' }] }, undefined)!; + expect(cols).toEqual([expect.objectContaining({ key: 'name', label: '名称', labelLocalized: true })]); + }); + + it('appends only the extra columns the base does not already show', () => { + const base = [{ key: 'name', label: 'Name' }]; + const merged = withExtraColumns(base, [{ key: 'name', label: 'dup' }, { key: '_packageId', label: 'Package' }]); + expect(merged.map((c) => c.key)).toEqual(['name', '_packageId']); + expect(withExtraColumns(base, undefined)).toBe(base); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/servedListColumns.tsx b/ui/packages/app-shell/src/views/metadata-admin/servedListColumns.tsx new file mode 100644 index 00000000000..10a16f7ed88 --- /dev/null +++ b/ui/packages/app-shell/src/views/metadata-admin/servedListColumns.tsx @@ -0,0 +1,156 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The generic metadata list's columns from the type's served list layout + * (`/meta/types` `entries[].list`, the spec's `METADATA_LIST_REGISTRY`). + * + * Precedence, read by `ResourceListPage`: + * + * 1. the served list, when the type declares one — each column's cell drawn by + * its declared renderer, or by the console's `listCells` override for that + * key; + * 2. else the console's own `listColumns`; + * 3. else the default name / label / description; + * + * and after whichever applies, the console's `listExtraColumns`: values the + * server stamps on a row that are not keys of the type's schema. + * + * A served header is already in the reader's locale (the server translates it + * through the form field slot of the same path), so it is shown as served and + * never looked up again in the console's `engine.list.col.*` table. + * + * A stored row omits a key the author left at its schema default, so an absent + * value shows the default the served JSON Schema declares at that path: the + * value the runtime uses. + */ + +import * as React from 'react'; +import { Badge, EmptyValue } from '@object-ui/components'; +import type { MetadataListView } from '@objectstack/spec/ui'; + +import type { MetadataResourceConfig } from './registry.js'; + +export type ListColumns = NonNullable; +type ListCell = NonNullable[string]; + +/** The value at a dotted `path` of `item`; `undefined` when any segment is missing. */ +export function valueAtPath(item: Record, path: string): unknown { + let node: unknown = item; + for (const segment of path.split('.')) { + if (node == null || typeof node !== 'object' || Array.isArray(node)) return undefined; + node = (node as Record)[segment]; + } + return node; +} + +/** The JSON Schema node at a dotted `path`, looking through `anyOf` / `oneOf` / `allOf` arms. */ +function schemaNodeAt(schema: unknown, path: string): Record | undefined { + let node = schema as Record | undefined; + for (const segment of path.split('.')) { + node = propertyNode(node, segment); + if (!node) return undefined; + } + return node; +} + +function propertyNode(node: Record | undefined, key: string): Record | undefined { + if (!node || typeof node !== 'object') return undefined; + const props = node.properties as Record> | undefined; + if (props && typeof props === 'object' && props[key]) return props[key]; + for (const arms of [node.anyOf, node.oneOf, node.allOf]) { + if (!Array.isArray(arms)) continue; + for (const arm of arms) { + const found = propertyNode(arm as Record, key); + if (found) return found; + } + } + return undefined; +} + +/** The default the type's JSON Schema declares at `path`, or `undefined`. */ +export function schemaDefaultAt(schema: unknown, path: string): unknown { + const node = schemaNodeAt(schema, path); + return node && 'default' in node ? node.default : undefined; +} + +function isEmpty(value: unknown): boolean { + return value == null || value === '' || (Array.isArray(value) && value.length === 0); +} + +function scalarText(value: unknown): string | undefined { + if (typeof value === 'string') return value; + if (typeof value === 'number' || typeof value === 'bigint') return String(value); + if (typeof value === 'boolean') return value ? '✓' : '✗'; + return undefined; +} + +/** Draw one cell by the column's declared renderer. */ +export function renderListCell(type: string | undefined, value: unknown): React.ReactNode { + if (type === 'count') { + if (Array.isArray(value)) return value.length; + if (value && typeof value === 'object') return Object.keys(value).length; + return value == null ? : 0; + } + if (isEmpty(value)) return ; + switch (type) { + case 'boolean': + return value ? '✓' : '✗'; + case 'badge': + return ( + + {scalarText(value) ?? JSON.stringify(value)} + + ); + case 'list': + return (Array.isArray(value) ? value : [value]).map((v) => scalarText(v) ?? JSON.stringify(v)).join(', '); + case 'summary': { + if (value && typeof value === 'object' && !Array.isArray(value)) { + const parts = Object.values(value as Record) + .map(scalarText) + .filter((v): v is string => v !== undefined && v !== ''); + if (parts.length > 0) return parts.join(' · '); + } + return scalarText(value) ?? JSON.stringify(value); + } + default: { + const text = scalarText(value); + if (text !== undefined) return text; + return {JSON.stringify(value).slice(0, 60)}; + } + } +} + +/** + * The list page's columns from a served list layout, or `undefined` when the + * type serves none (the caller then falls back to the console's own columns). + */ +export function servedListColumns( + list: MetadataListView | undefined, + schema: Record | undefined, + cells?: Readonly>, +): ListColumns | undefined { + if (!list || !Array.isArray(list.columns) || list.columns.length === 0) return undefined; + return list.columns.map((column) => { + const override = cells?.[column.field]; + const fallback = schemaDefaultAt(schema, column.field); + const valueOf = (item: Record) => { + const value = valueAtPath(item, column.field); + return value === undefined ? fallback : value; + }; + return { + key: column.field, + label: typeof column.label === 'string' && column.label ? column.label : column.field, + labelLocalized: true, + ...(override?.width ? { width: override.width } : {}), + render: (_value: unknown, item: Record) => + override?.render ? override.render(valueOf(item), item) : renderListCell(column.type, valueOf(item)), + }; + }); +} + +/** `base`, then each of the console's extra columns whose key `base` does not already show. */ +export function withExtraColumns(base: ListColumns, extra: ListColumns | undefined): ListColumns { + if (!extra || extra.length === 0) return base; + const shown = new Set(base.map((c) => c.key)); + return [...base, ...extra.filter((c) => !shown.has(c.key))]; +} diff --git a/ui/packages/app-shell/src/views/metadata-admin/useMetadata.ts b/ui/packages/app-shell/src/views/metadata-admin/useMetadata.ts index b506b259d93..a84ad1fc932 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/useMetadata.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/useMetadata.ts @@ -25,6 +25,7 @@ import { createConsoleMetadataClient } from './metadataClientFactory.js'; import { dropPublishedViewList, installViewListDrop } from './viewListDrop.js'; import { emitSaveAdvisories, type TranslateFn } from '../../providers/saveAdvisoryToast.js'; import type { FormViewSpec } from './form-spec.js'; +import type { MetadataListView } from '@objectstack/spec/ui'; /** * A declarative **type-level** action surfaced on a metadata type by the @@ -119,6 +120,12 @@ export interface RichMetadataTypeEntry { * refuses one with no member source instead of assuming `fields`. */ form?: FormViewSpec; + /** + * The type's Studio list layout (objectstack#36860, the spec's + * `METADATA_LIST_REGISTRY`): its columns, headers in the request locale. + * Absent for a type with no declared list. Read by `servedListColumns`. + */ + list?: MetadataListView; /** UI hints (icon, color, etc.) the framework may include. */ ui?: Record; } From bebf96fc5621eb7aa6573dccbf7977c81c457e40 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 05:59:44 +0000 Subject: [PATCH 3/5] feat(spec): serve metadata list columns on /meta/types, hook first Trim the list registry to hook for the first half of the card (the other 26 types, their bundle leaves and the nine console moves follow in the second half), keep the console declarations as they were, regenerate the spec baselines and add the changeset. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzg7mFFG5b13DcQ93kf --- .changeset/36860-metadata-list-columns.md | 22 +++ content/docs/references/api/protocol.mdx | 1 + content/docs/references/index.mdx | 10 +- content/docs/references/ui/view.mdx | 81 ++++++++- packages/spec/api-surface/system.json | 3 + packages/spec/api-surface/ui.json | 10 ++ packages/spec/authorable-surface/ui.json | 5 + packages/spec/declaration-map/ui.json | 6 + packages/spec/export-origins/system.json | 3 + packages/spec/export-origins/ui.json | 10 ++ packages/spec/json-schema.manifest/ui.json | 3 + .../spec/src/system/metadata-list-registry.ts | 162 +----------------- .../metadata-list-zod-reconciliation.test.ts | 9 +- packages/spec/src/ui/view.zod.ts | 2 + .../src/services/builtinComponents.tsx | 71 ++++++-- ...eListPage.servedListColumns-36860.test.tsx | 36 ++-- .../src/views/metadata-admin/anchors.ts | 37 +++- 17 files changed, 243 insertions(+), 228 deletions(-) create mode 100644 .changeset/36860-metadata-list-columns.md diff --git a/.changeset/36860-metadata-list-columns.md b/.changeset/36860-metadata-list-columns.md new file mode 100644 index 00000000000..316bfb5e14d --- /dev/null +++ b/.changeset/36860-metadata-list-columns.md @@ -0,0 +1,22 @@ +--- +'@objectstack/spec': minor +'@objectstack/metadata-protocol': minor +'@objectstack/rest': minor +'@objectstack/lint': minor +'@object-ui/app-shell': minor +--- + +feat(spec): declare a metadata type's Studio list columns in the spec and serve them on `/meta/types` + +Clause-②: yes (widening: new exported schemas and a new optional `list` on each `/meta/types` entry) +Metadata-protocol: added +Skills-docs: none — no skill under `skills/**` teaches Studio's metadata list columns; `skills/objectstack-ui/SKILL.md` names `entries[].schema` only, which is unchanged + +Which columns Studio's generic list shows for a metadata type is now declared in the spec, beside the type's form, instead of in console code: + +- **Spec.** `MetadataListViewSchema` is a list layout bound to the type's own schema (`data: { provider: 'schema', schemaId }`) with its `columns`; each `MetadataListColumnSchema` names a key of that schema or a dotted path into it, a header, and a cell renderer (`MetadataListCellTypeSchema`: `text`, `badge`, `boolean`, `count`, `list`, `summary`). `defineList({ schemaId, columns })` builds one and refuses an unknown renderer, an empty column list and any `ListColumn` key outside `field` / `label` / `type`. `METADATA_LIST_REGISTRY` (`@objectstack/spec/system`) is the list counterpart of `METADATA_FORM_REGISTRY`; this release declares `hook`, and a type with no entry keeps Studio's default list. A reconciliation test refuses a column naming a key the type's schema does not declare (or declares retired, or as an overlay `_` key) and a header that differs from the form field label of the same path. +- **Serve.** `getMetaTypes()` serves the registry entry as `list` on the type's `/meta/types` row, next to `form`; `GetMetaTypesResponseSchema` declares it. The REST handler translates each header through the type's form field slot, `metadataForms..fields..label`, so a column and the form field of the same key read the same words. `resolveMetadataListLabels` (`@objectstack/spec/system`) does the lookup. +- **i18n.** `os i18n extract` emits that slot for every column whose path the type's form does not already label, with the column's header as the English source. Every `hook` header reuses a form label, so no bundle changes here. +- **Console.** Studio's generic list reads the served columns first: the served list, else the console's own `listColumns`, else name / label / description. A served header is shown as served, already in the reader's language. A key the stored row leaves out shows the default the type's JSON Schema declares there, the value the runtime uses. The console can still draw a served column's cell its own way (`listCells`) and append values the server stamps on a row that are not schema keys (`listExtraColumns`). + +New exports: `@objectstack/spec` adds `MetadataListCellTypeSchema`, `MetadataListColumnSchema`, `MetadataListViewSchema`, `defineList` and their types (`ui`), and `METADATA_LIST_REGISTRY`, `MetadataListType` and `resolveMetadataListLabels` (`system`). Nothing that was accepted before is refused, and a client that ignores `list` sees the `/meta/types` it saw before. diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index fc5064c4861..5190c1da149 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1714,6 +1714,7 @@ One changed key path of the pending draft, and the last write that changed it. | **domain** | `Enum<'data' \| 'ui' \| 'automation' \| 'system' \| 'security' \| 'ai'>` | ✅ | Protocol domain | | **overrideSource** | `Enum<'registry' \| 'env'>` | ✅ | Whether allowEnvironmentOverlay comes from the static registry or is elevated by the OS_METADATA_WRITABLE environment variable | | **createSeed** | `any` | optional | Authoritative minimal valid create seed for this type — Studio/CLI/API derive create defaults from it (single source of truth in @objectstack/spec). Absent for canvas-create types whose shape is built interactively. | +| **list** | `{ data?: object \| object \| object; columns: object[] }` | optional | Studio list layout of this type: the columns its metadata list shows, each naming a key of the type schema, headers in the request locale. Absent for a type with no declared list, which Studio lists by name, label and description. | --- diff --git a/content/docs/references/index.mdx b/content/docs/references/index.mdx index e21f7d0c705..11ae8323d2a 100644 --- a/content/docs/references/index.mdx +++ b/content/docs/references/index.mdx @@ -1,7 +1,7 @@ --- title: Protocol reference — every schema by module navTitle: Protocol Reference -description: Every schema published by @objectstack/spec — 1714 schemas across 14 protocol modules +description: Every schema published by @objectstack/spec — 1717 schemas across 14 protocol modules --- {/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */} @@ -33,8 +33,8 @@ counts are sums of the rows they head. Regenerate with | [Shared Protocol](/docs/references/shared) | 10 | 31 | Primitives used across every protocol — identifiers, HTTP, expressions, error maps, enums. | | [Studio Protocol](/docs/references/studio) | 3 | 35 | Studio designer metadata — the authoring surfaces for the protocols above. | | [System Protocol](/docs/references/system) | 40 | 298 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. | -| [UI Protocol](/docs/references/ui) | 16 | 181 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | -| **Total** | **219** | **1714** | 14 protocol modules | +| [UI Protocol](/docs/references/ui) | 16 | 184 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | +| **Total** | **219** | **1717** | 14 protocol modules | --- @@ -386,7 +386,7 @@ The runtime environment — logging, jobs, cache, metrics, notifications, i18n a ## UI Protocol -**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 181 schemas** +**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 184 schemas** Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. @@ -407,7 +407,7 @@ Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI lay | [`report.zod.ts`](/docs/references/ui/report) | `JoinedReportBlock`, `Report`, `ReportChart`, `ReportSort`, `ReportType` | | [`responsive.zod.ts`](/docs/references/ui/responsive) | `ResponsiveStyles`, `StyleMap` | | [`sharing.zod.ts`](/docs/references/ui/sharing) | `SharingConfig` | -| [`view.zod.ts`](/docs/references/ui/view) | `AddRecordConfig`, `AppearanceConfig`, `CalendarConfig`, `ColumnPrefix`, `ColumnSummary`, `ColumnSummaryConfig`, `EmptyState`, `FormButtonConfig`, `FormField`, `FormSection`, `FormSelectOption`, `FormView`, `GalleryConfig`, `GanttConfig`, `GanttQuickFilter`, `GroupingConfig`, `GroupingField`, `HttpMethodSubset`, `HttpRequest`, `KanbanConfig`, `KanbanLaneSummary`, `ListChartConfig`, `ListColumn`, `ListMapConfig`, `ListView`, `NavigationConfig`, `NavigationMode`, `ObjectListView`, `ObjectUserFilters`, `PaginationConfig`, `RowColorConfig`, `RowHeight`, `SelectionConfig`, `TimelineConfig`, `TimesheetConfig`, `TreeConfig`, `UserActionsConfig`, `UserFilterField`, `UserFilters`, `View`, `ViewData`, `ViewFilterElement`, `ViewFilterOrGroup`, `ViewFilterRule`, `ViewItem`, `ViewItemName`, `ViewItemWire`, `ViewKind`, `ViewScope`, `ViewSharing`, `ViewTab`, `VisualizationType` | +| [`view.zod.ts`](/docs/references/ui/view) | `AddRecordConfig`, `AppearanceConfig`, `CalendarConfig`, `ColumnPrefix`, `ColumnSummary`, `ColumnSummaryConfig`, `EmptyState`, `FormButtonConfig`, `FormField`, `FormSection`, `FormSelectOption`, `FormView`, `GalleryConfig`, `GanttConfig`, `GanttQuickFilter`, `GroupingConfig`, `GroupingField`, `HttpMethodSubset`, `HttpRequest`, `KanbanConfig`, `KanbanLaneSummary`, `ListChartConfig`, `ListColumn`, `ListMapConfig`, `ListView`, `MetadataListCellType`, `MetadataListColumn`, `MetadataListView`, `NavigationConfig`, `NavigationMode`, `ObjectListView`, `ObjectUserFilters`, `PaginationConfig`, `RowColorConfig`, `RowHeight`, `SelectionConfig`, `TimelineConfig`, `TimesheetConfig`, `TreeConfig`, `UserActionsConfig`, `UserFilterField`, `UserFilters`, `View`, `ViewData`, `ViewFilterElement`, `ViewFilterOrGroup`, `ViewFilterRule`, `ViewItem`, `ViewItemName`, `ViewItemWire`, `ViewKind`, `ViewScope`, `ViewSharing`, `ViewTab`, `VisualizationType` | --- diff --git a/content/docs/references/ui/view.mdx b/content/docs/references/ui/view.mdx index 79057ea8406..ff73f258cf3 100644 --- a/content/docs/references/ui/view.mdx +++ b/content/docs/references/ui/view.mdx @@ -59,8 +59,8 @@ nothing. The one item-name grammar itself lives in ## TypeScript Usage ```typescript -import { AddRecordConfigSchema, AppearanceConfigSchema, CalendarConfigSchema, ColumnPrefixSchema, ColumnSummarySchema, ColumnSummaryConfigSchema, EmptyStateSchema, FormButtonConfigSchema, FormFieldSchema, FormSectionSchema, FormSelectOptionSchema, FormViewSchema, GalleryConfigSchema, GanttConfigSchema, GanttQuickFilterSchema, GroupingConfigSchema, GroupingFieldSchema, HttpMethodSubsetSchema, HttpRequestSchema, KanbanConfigSchema, KanbanLaneSummarySchema, ListChartConfigSchema, ListColumnSchema, ListMapConfigSchema, ListViewSchema, NavigationConfigSchema, NavigationModeSchema, ObjectListViewSchema, ObjectUserFiltersSchema, PaginationConfigSchema, RowColorConfigSchema, RowHeightSchema, SelectionConfigSchema, TimelineConfigSchema, TimesheetConfigSchema, TreeConfigSchema, UserActionsConfigSchema, UserFilterFieldSchema, UserFiltersSchema, ViewSchema, ViewDataSchema, ViewFilterElementSchema, ViewFilterOrGroupSchema, ViewFilterRuleSchema, ViewItemSchema, ViewItemNameSchema, ViewItemWireSchema, ViewKindSchema, ViewScopeSchema, ViewSharingSchema, ViewTabSchema, VisualizationTypeSchema } from '@objectstack/spec/ui'; -import type { AddRecordConfig, AppearanceConfig, CalendarConfig, ColumnPrefix, ColumnSummary, ColumnSummaryConfig, EmptyState, FormButtonConfig, FormField, FormSection, FormSelectOption, FormView, GalleryConfig, GanttConfig, GanttQuickFilter, GroupingConfig, HttpMethodSubset, HttpRequest, KanbanConfig, KanbanLaneSummary, ListChartConfig, ListColumn, ListMapConfig, ListView, NavigationConfig, NavigationMode, PaginationConfig, RowColorConfig, RowHeight, SelectionConfig, TimelineConfig, TimesheetConfig, TreeConfig, UserActionsConfig, UserFilterField, UserFilters, View, ViewData, ViewFilterElement, ViewFilterOrGroup, ViewFilterRule, ViewItem, ViewItemName, ViewItemWire, ViewKind, ViewScope, ViewSharing, ViewTab, VisualizationType } from '@objectstack/spec/ui'; +import { AddRecordConfigSchema, AppearanceConfigSchema, CalendarConfigSchema, ColumnPrefixSchema, ColumnSummarySchema, ColumnSummaryConfigSchema, EmptyStateSchema, FormButtonConfigSchema, FormFieldSchema, FormSectionSchema, FormSelectOptionSchema, FormViewSchema, GalleryConfigSchema, GanttConfigSchema, GanttQuickFilterSchema, GroupingConfigSchema, GroupingFieldSchema, HttpMethodSubsetSchema, HttpRequestSchema, KanbanConfigSchema, KanbanLaneSummarySchema, ListChartConfigSchema, ListColumnSchema, ListMapConfigSchema, ListViewSchema, MetadataListCellTypeSchema, MetadataListColumnSchema, MetadataListViewSchema, NavigationConfigSchema, NavigationModeSchema, ObjectListViewSchema, ObjectUserFiltersSchema, PaginationConfigSchema, RowColorConfigSchema, RowHeightSchema, SelectionConfigSchema, TimelineConfigSchema, TimesheetConfigSchema, TreeConfigSchema, UserActionsConfigSchema, UserFilterFieldSchema, UserFiltersSchema, ViewSchema, ViewDataSchema, ViewFilterElementSchema, ViewFilterOrGroupSchema, ViewFilterRuleSchema, ViewItemSchema, ViewItemNameSchema, ViewItemWireSchema, ViewKindSchema, ViewScopeSchema, ViewSharingSchema, ViewTabSchema, VisualizationTypeSchema } from '@objectstack/spec/ui'; +import type { AddRecordConfig, AppearanceConfig, CalendarConfig, ColumnPrefix, ColumnSummary, ColumnSummaryConfig, EmptyState, FormButtonConfig, FormField, FormSection, FormSelectOption, FormView, GalleryConfig, GanttConfig, GanttQuickFilter, GroupingConfig, HttpMethodSubset, HttpRequest, KanbanConfig, KanbanLaneSummary, ListChartConfig, ListColumn, ListMapConfig, ListView, MetadataListCellType, MetadataListColumn, MetadataListView, NavigationConfig, NavigationMode, PaginationConfig, RowColorConfig, RowHeight, SelectionConfig, TimelineConfig, TimesheetConfig, TreeConfig, UserActionsConfig, UserFilterField, UserFilters, View, ViewData, ViewFilterElement, ViewFilterOrGroup, ViewFilterRule, ViewItem, ViewItemName, ViewItemWire, ViewKind, ViewScope, ViewSharing, ViewTab, VisualizationType } from '@objectstack/spec/ui'; // Validate data const result = AddRecordConfigSchema.parse(data); @@ -1200,6 +1200,83 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | **role** | `string` | optional | WAI-ARIA role attribute (e.g., "dialog", "navigation", "alert") | +--- + +## MetadataListCellType + +How a metadata list cell draws its value + +### Allowed Values + +* `text` +* `badge` +* `boolean` +* `count` +* `list` +* `summary` + + +--- + +## MetadataListColumn + +One column of a metadata type list + +### Properties + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **field** | `string` | ✅ | Key of the metadata type's schema: a top-level key, or a dotted path into it | +| **label** | `string \| Record` | optional | Display label override | +| **type** | `Enum<'text' \| 'badge' \| 'boolean' \| 'count' \| 'list' \| 'summary'>` | optional | Cell renderer; `text` when absent | + + +--- + +## MetadataListView + +List layout of a metadata type: its schema binding and its columns + +### Properties + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | +| **columns** | `{ field: string; label?: string \| Record; type?: Enum<'text' \| 'badge' \| 'boolean' \| 'count' \| 'list' \| 'summary'> }[]` | ✅ | Columns of the list, in display order | + +### Nested Shape: `MetadataListView.data[provider='object']` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **provider** | `'object'` | ✅ | | +| **object** | `string` | ✅ | Target object name | + +### Nested Shape: `MetadataListView.data[provider='value']` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **provider** | `'value'` | ✅ | | +| **items** | `any[]` | ✅ | Static data array | + +### Nested Shape: `MetadataListView.data[provider='schema']` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **provider** | `'schema'` | ✅ | | +| **schemaId** | `string` | ✅ | Schema identifier — typically the metadata type name | +| **schema** | `Record` | optional | Inline JSON Schema (Draft 2020-12). Optional when schemaId is resolvable. | + +### Nested Shape: `MetadataListView.columns[number]` + +One column of a metadata type list + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **field** | `string` | ✅ | Key of the metadata type's schema: a top-level key, or a dotted path into it | +| **label** | `string \| Record` | optional | Display label override | +| **type** | `Enum<'text' \| 'badge' \| 'boolean' \| 'count' \| 'list' \| 'summary'>` | optional | Cell renderer; `text` when absent | + + --- ## NavigationConfig diff --git a/packages/spec/api-surface/system.json b/packages/spec/api-surface/system.json index 588c3b5a96b..16e1d3e81f4 100644 --- a/packages/spec/api-surface/system.json +++ b/packages/spec/api-surface/system.json @@ -350,6 +350,7 @@ "MCP_DOOR_TOOL_NAMES (const)", "MCP_FILE_TOOL_NAMES (const)", "METADATA_FORM_REGISTRY (const)", + "METADATA_LIST_REGISTRY (const)", "MIGRATION_JOURNAL_KINDS (const)", "MIGRATION_JOURNAL_OBJECT (const)", "MappingLike (interface)", @@ -375,6 +376,7 @@ "MetadataHistoryRetentionPolicy (type)", "MetadataHistoryRetentionPolicyParsed (type)", "MetadataHistoryRetentionPolicySchema (const)", + "MetadataListType (type)", "MetadataLoadOptions (type)", "MetadataLoadOptionsSchema (const)", "MetadataLoadResult (type)", @@ -917,6 +919,7 @@ "resolveLocaleAmong (function)", "resolveMetadataFormLabels (function)", "resolveMetadataFormSchemaTitles (function)", + "resolveMetadataListLabels (function)", "resolveMetadataTypeDescription (function)", "resolveMetadataTypeLabel (function)", "resolveObjectFieldLabels (function)", diff --git a/packages/spec/api-surface/ui.json b/packages/spec/api-surface/ui.json index 8f67ffa931b..2c045b605a3 100644 --- a/packages/spec/api-surface/ui.json +++ b/packages/spec/api-surface/ui.json @@ -291,6 +291,15 @@ "ListViewGroupQuerySource (interface)", "ListViewParsed (type)", "ListViewSchema (const)", + "MetadataListCellType (type)", + "MetadataListCellTypeParsed (type)", + "MetadataListCellTypeSchema (const)", + "MetadataListColumn (type)", + "MetadataListColumnParsed (type)", + "MetadataListColumnSchema (const)", + "MetadataListView (type)", + "MetadataListViewParsed (type)", + "MetadataListViewSchema (const)", "NavigationArea (type)", "NavigationAreaParsed (type)", "NavigationAreaSchema (const)", @@ -572,6 +581,7 @@ "defineApp (function)", "defineDataset (function)", "defineForm (function)", + "defineList (function)", "definePage (function)", "defineReport (function)", "defineView (function)", diff --git a/packages/spec/authorable-surface/ui.json b/packages/spec/authorable-surface/ui.json index a510f9427e9..a2eb1f182f8 100644 --- a/packages/spec/authorable-surface/ui.json +++ b/packages/spec/authorable-surface/ui.json @@ -800,6 +800,11 @@ "ui/ListView:type", "ui/ListView:userActions", "ui/ListView:userFilters", + "ui/MetadataListColumn:field", + "ui/MetadataListColumn:label", + "ui/MetadataListColumn:type", + "ui/MetadataListView:columns", + "ui/MetadataListView:data", "ui/NavigationArea:description", "ui/NavigationArea:icon", "ui/NavigationArea:id", diff --git a/packages/spec/declaration-map/ui.json b/packages/spec/declaration-map/ui.json index bee4d67f93b..758905e105e 100644 --- a/packages/spec/declaration-map/ui.json +++ b/packages/spec/declaration-map/ui.json @@ -181,6 +181,12 @@ "ListMapConfigSchema": "ui/ListMapConfig", "ListView": "ui/ListView", "ListViewSchema": "ui/ListView", + "MetadataListCellType": "ui/MetadataListCellType", + "MetadataListCellTypeSchema": "ui/MetadataListCellType", + "MetadataListColumn": "ui/MetadataListColumn", + "MetadataListColumnSchema": "ui/MetadataListColumn", + "MetadataListView": "ui/MetadataListView", + "MetadataListViewSchema": "ui/MetadataListView", "NavigationArea": "ui/NavigationArea", "NavigationAreaSchema": "ui/NavigationArea", "NavigationConfig": "ui/NavigationConfig", diff --git a/packages/spec/export-origins/system.json b/packages/spec/export-origins/system.json index 5693886471c..e638da027a2 100644 --- a/packages/spec/export-origins/system.json +++ b/packages/spec/export-origins/system.json @@ -337,6 +337,7 @@ "MCP_DOOR_TOOL_NAMES": "src/system/constants/platform-tool-names.ts#MCP_DOOR_TOOL_NAMES (const)", "MCP_FILE_TOOL_NAMES": "src/system/constants/platform-tool-names.ts#MCP_FILE_TOOL_NAMES (const)", "METADATA_FORM_REGISTRY": "src/system/metadata-form-registry.ts#METADATA_FORM_REGISTRY (const)", + "METADATA_LIST_REGISTRY": "src/system/metadata-list-registry.ts#METADATA_LIST_REGISTRY (const)", "MIGRATION_JOURNAL_KINDS": "src/system/migration.zod.ts#MIGRATION_JOURNAL_KINDS (const)", "MIGRATION_JOURNAL_OBJECT": "src/system/migration.zod.ts#MIGRATION_JOURNAL_OBJECT (const)", "MappingLike": "src/system/i18n-resolver.ts#MappingLike (interface)", @@ -362,6 +363,7 @@ "MetadataHistoryRetentionPolicy": "src/system/metadata-persistence.zod.ts#MetadataHistoryRetentionPolicy (type)", "MetadataHistoryRetentionPolicyParsed": "src/system/metadata-persistence.zod.ts#MetadataHistoryRetentionPolicyParsed (type)", "MetadataHistoryRetentionPolicySchema": "src/system/metadata-persistence.zod.ts#MetadataHistoryRetentionPolicySchema (const)", + "MetadataListType": "src/system/metadata-list-registry.ts#MetadataListType (type)", "MetadataLoadOptions": "src/system/metadata-persistence.zod.ts#MetadataLoadOptions (type)", "MetadataLoadOptionsSchema": "src/system/metadata-persistence.zod.ts#MetadataLoadOptionsSchema (const)", "MetadataLoadResult": "src/system/metadata-persistence.zod.ts#MetadataLoadResult (type)", @@ -877,6 +879,7 @@ "resolveLocaleAmong": "src/system/i18n-resolver.ts#resolveLocaleAmong (function)", "resolveMetadataFormLabels": "src/system/i18n-resolver.ts#resolveMetadataFormLabels (function)", "resolveMetadataFormSchemaTitles": "src/system/i18n-resolver.ts#resolveMetadataFormSchemaTitles (function)", + "resolveMetadataListLabels": "src/system/i18n-resolver.ts#resolveMetadataListLabels (function)", "resolveMetadataTypeDescription": "src/system/i18n-resolver.ts#resolveMetadataTypeDescription (function)", "resolveMetadataTypeLabel": "src/system/i18n-resolver.ts#resolveMetadataTypeLabel (function)", "resolveObjectFieldLabels": "src/system/i18n-resolver.ts#resolveObjectFieldLabels (function)", diff --git a/packages/spec/export-origins/ui.json b/packages/spec/export-origins/ui.json index 656f4f5abf5..16278e9e5be 100644 --- a/packages/spec/export-origins/ui.json +++ b/packages/spec/export-origins/ui.json @@ -285,6 +285,15 @@ "ListViewGroupQuerySource": "src/ui/view-grouping-query.ts#ListViewGroupQuerySource (interface)", "ListViewParsed": "src/ui/view.zod.ts#ListViewParsed (type)", "ListViewSchema": "src/ui/view.zod.ts#ListViewSchema (const)", + "MetadataListCellType": "src/ui/view.zod.ts#MetadataListCellType (type)", + "MetadataListCellTypeParsed": "src/ui/view.zod.ts#MetadataListCellTypeParsed (type)", + "MetadataListCellTypeSchema": "src/ui/view.zod.ts#MetadataListCellTypeSchema (const)", + "MetadataListColumn": "src/ui/view.zod.ts#MetadataListColumn (type)", + "MetadataListColumnParsed": "src/ui/view.zod.ts#MetadataListColumnParsed (type)", + "MetadataListColumnSchema": "src/ui/view.zod.ts#MetadataListColumnSchema (const)", + "MetadataListView": "src/ui/view.zod.ts#MetadataListView (type)", + "MetadataListViewParsed": "src/ui/view.zod.ts#MetadataListViewParsed (type)", + "MetadataListViewSchema": "src/ui/view.zod.ts#MetadataListViewSchema (const)", "NavigationArea": "src/ui/app.zod.ts#NavigationArea (type)", "NavigationAreaParsed": "src/ui/app.zod.ts#NavigationAreaParsed (type)", "NavigationAreaSchema": "src/ui/app.zod.ts#NavigationAreaSchema (const)", @@ -555,6 +564,7 @@ "defineApp": "src/ui/app.zod.ts#defineApp (function)", "defineDataset": "src/ui/dataset.zod.ts#defineDataset (function)", "defineForm": "src/ui/view.zod.ts#defineForm (function)", + "defineList": "src/ui/view.zod.ts#defineList (function)", "definePage": "src/ui/page.zod.ts#definePage (function)", "defineReport": "src/ui/report.zod.ts#defineReport (function)", "defineView": "src/ui/view.zod.ts#defineView (function)", diff --git a/packages/spec/json-schema.manifest/ui.json b/packages/spec/json-schema.manifest/ui.json index 49e425745dc..3a43042256a 100644 --- a/packages/spec/json-schema.manifest/ui.json +++ b/packages/spec/json-schema.manifest/ui.json @@ -99,6 +99,9 @@ "ui/ListColumn", "ui/ListMapConfig", "ui/ListView", + "ui/MetadataListCellType", + "ui/MetadataListColumn", + "ui/MetadataListView", "ui/NavigationArea", "ui/NavigationConfig", "ui/NavigationContribution", diff --git a/packages/spec/src/system/metadata-list-registry.ts b/packages/spec/src/system/metadata-list-registry.ts index 805c415d3f0..2c9775e8030 100644 --- a/packages/spec/src/system/metadata-list-registry.ts +++ b/packages/spec/src/system/metadata-list-registry.ts @@ -45,17 +45,7 @@ const DESCRIPTION = { field: 'description', label: 'Description' } as const; * ``` */ export const METADATA_LIST_REGISTRY: Readonly> = Object.freeze({ - // ── data ────────────────────────────────────────────────────────────── - object: defineList({ - schemaId: 'object', - columns: [NAME, LABEL, { field: 'pluralLabel', label: 'Plural Label' }, { field: 'fields', label: 'Fields', type: 'count' }, DESCRIPTION], - }), - field: defineList({ - schemaId: 'field', - // A field row's `object` is stamped by the server, not a `FieldSchema` - // key, so the console appends it as its own column. - columns: [NAME, { field: 'type', label: 'Type', type: 'badge' }, LABEL], - }), + // ── logic ───────────────────────────────────────────────────────────── hook: defineList({ schemaId: 'hook', columns: [ @@ -67,156 +57,6 @@ export const METADATA_LIST_REGISTRY: Readonly { const TYPES = Object.keys(METADATA_LIST_REGISTRY); describe('METADATA_LIST_REGISTRY ↔ the type schemas', () => { - it('declares a list for the first-batch types and the nine types the console used to declare', () => { - expect(TYPES.sort()).toEqual([ - 'action', 'agent', 'api', 'assignment_rule', 'book', 'dashboard', 'dataset', 'doc', - 'email_template', 'field', 'flow', 'hook', 'job', 'mapping', 'object', 'page', - 'permission', 'picklist', 'position', 'queue', 'report', 'seed', 'sharing_rule', - 'skill', 'tool', 'translation', 'view', - ]); + it('declares the list of each type it covers, hook first', () => { + expect(TYPES.sort()).toEqual(['hook']); }); it.each(TYPES)('%s: binds to its own type, which has a schema', (type) => { diff --git a/packages/spec/src/ui/view.zod.ts b/packages/spec/src/ui/view.zod.ts index aa3bfb68844..cbd6921db46 100644 --- a/packages/spec/src/ui/view.zod.ts +++ b/packages/spec/src/ui/view.zod.ts @@ -8421,6 +8421,8 @@ export type ListColumn = z.input; /** Post-parse shape of {@link ListColumn} — defaults applied, transforms run (ADR-0122). */ export type ListColumnParsed = z.infer; export type MetadataListCellType = z.input; +/** Post-parse shape of {@link MetadataListCellType} (ADR-0122). */ +export type MetadataListCellTypeParsed = z.infer; export type MetadataListColumn = z.input; /** Post-parse shape of {@link MetadataListColumn} — defaults applied, transforms run (ADR-0122). */ export type MetadataListColumnParsed = z.infer; diff --git a/ui/packages/app-shell/src/services/builtinComponents.tsx b/ui/packages/app-shell/src/services/builtinComponents.tsx index 985d69311bf..d986c460349 100644 --- a/ui/packages/app-shell/src/services/builtinComponents.tsx +++ b/ui/packages/app-shell/src/services/builtinComponents.tsx @@ -317,7 +317,11 @@ registerMetadataResource({ description: 'Domain entities — tables in the data model. Each object owns its fields, relationships, validations, and lifecycle hooks.', domain: 'data', searchableFields: ['name', 'label', 'description'], - // objectstack#36860 — the list columns are the spec's (`METADATA_LIST_REGISTRY`). + listColumns: [ + { key: 'name', label: 'Name', width: '25%' }, + { key: 'label', label: 'Label', width: '25%' }, + { key: 'description', label: 'Description' }, + ], // objectui#10202 — the editor is seeded from the SERVED object, where a // picklist-bound field carries `picklist` plus the options resolved from the // list; the authoring door refuses the two together. The saved body drops @@ -333,9 +337,12 @@ registerMetadataResource({ description: 'Columns attached to objects — name, type, validation, and storage settings.', domain: 'data', searchableFields: ['name', 'label', 'object', 'type'], - // objectstack#36860 — name / type / label are the spec's columns; a field - // row's `object` is stamped by the server, not a `FieldSchema` key. - listExtraColumns: [{ key: 'object', label: 'Object', width: '20%' }], + listColumns: [ + { key: 'name', label: 'Name', width: '25%' }, + { key: 'object', label: 'Object', width: '20%' }, + { key: 'type', label: 'Type', width: '15%' }, + { key: 'label', label: 'Label' }, + ], }); /* -------------------------------------------------------------------------- */ @@ -353,8 +360,12 @@ registerMetadataResource({ // objectui#7611 — no `managedBy` column: the registry serves no such key on a // permission set (measured on objectstack main), so it read "Custom" for every // set, the platform's own included. Provenance is the list's own Source badge, - // read from the served `_packageId` / `_provenance`. objectstack#36860 — the - // columns are the spec's. + // read from the served `_packageId` / `_provenance`. + listColumns: [ + { key: 'name', label: 'Name', width: '30%' }, + { key: 'label', label: 'Label', width: '30%' }, + { key: 'description', label: 'Description' }, + ], }); // objectstack#25333 — the position list says who holds each position and which @@ -373,9 +384,10 @@ registerMetadataResource({ // admits a live position create (`allowRuntimeCreate`); under `?package=` // the create stays a package draft (ADR-0086). createLive: true, - // objectstack#36860 — name / label / description are the spec's columns; the - // holder count and the granted sets are served beside each row. - listExtraColumns: [ + listColumns: [ + { key: 'name', label: 'Name', width: '20%' }, + { key: 'label', label: 'Label', width: '20%' }, + { key: 'description', label: 'Description' }, { key: '_holderCount', label: 'Holders', @@ -401,16 +413,20 @@ registerMetadataResource({ label: 'Views', description: 'Saved list / kanban / calendar / gantt configurations on top of an object.', domain: 'ui', - // objectstack#36860 — the columns are the spec's. - listCells: { - type: { + listColumns: [ + { key: 'name', label: 'Name', width: '30%' }, + { key: 'object', label: 'Object', width: '20%' }, + { + key: 'type', + label: 'Type', width: '15%', // Expanded ViewItems keep their display type under `config.type` // and only the list/form family at the top level — derive it so the // column shows "calendar" / "grid" / "form" instead of "—". render: (_v, item) => viewDisplayType(item) ?? '—', }, - }, + { key: 'label', label: 'Label' }, + ], // ADR-0017 — the framework exposes each view as a canonical first-class // ViewItem ({ name, object, viewKind, label, config }). The inspector and // preview read that shape directly (`draft.config`), so NO toDraft/fromDraft @@ -425,6 +441,11 @@ registerMetadataResource({ label: 'Dashboards', description: 'Composed dashboards with charts, KPIs, and tables.', domain: 'ui', + listColumns: [ + { key: 'name', label: 'Name', width: '30%' }, + { key: 'label', label: 'Label', width: '30%' }, + { key: 'description', label: 'Description' }, + ], }); /** @@ -454,6 +475,11 @@ registerMetadataResource({ label: 'Pages', description: 'Visual page layouts authored as JSON metadata.', domain: 'ui', + listColumns: [ + { key: 'name', label: 'Name', width: '30%' }, + { key: 'label', label: 'Label', width: '30%' }, + { key: 'route', label: 'Route' }, + ], fromDraft: pageSaveBody, }); @@ -469,10 +495,12 @@ registerMetadataResource({ description: 'Documentation navigation spine — ordered groups with membership derived over docs (glob/tag rules), plus an explicit pages override for curated order.', domain: 'system', searchableFields: ['name', 'label', 'description', 'slug'], - // objectstack#36860 — the columns are the spec's; the audience cell names - // the org default and a permission-set audience in words. - listCells: { - audience: { + listColumns: [ + { key: 'name', label: 'Name', width: '25%' }, + { key: 'label', label: 'Label', width: '25%' }, + { + key: 'audience', + label: 'Audience', width: '12%', render: (v) => v == null @@ -481,5 +509,12 @@ registerMetadataResource({ ? `permission set: ${(v as { permissionSet: string }).permissionSet}` : String(v), }, - }, + { + key: 'groups', + label: 'Groups', + width: '10%', + render: (v) => (Array.isArray(v) ? String(v.length) : '0'), + }, + { key: 'description', label: 'Description' }, + ], }); diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx index d81bd263922..f0a411428ee 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx @@ -24,6 +24,10 @@ import { render, cleanup, screen, within } from '@testing-library/react'; import '@testing-library/jest-dom'; import * as React from 'react'; import { MemoryRouter, Route, Routes } from 'react-router-dom'; +// Dynamic imports the page's anchors and editors reach, paid at collection +// rather than inside a case's clocked window. +import '@object-ui/plugin-detail'; +import '@objectstack/lint'; const HOOKS: Record[] = [ { name: 'stamp_owner', label: 'Stamp owner', object: 'account', events: ['beforeInsert', 'beforeUpdate'], async: true }, @@ -32,13 +36,11 @@ const HOOKS: Record[] = [ ]; const AGENTS: Record[] = [{ name: 'helper', label: 'Helper', model: { provider: 'openai', model: 'gpt-4o' } }]; const QUEUES: Record[] = [{ name: 'tier1', label: 'Tier 1', members: [{ type: 'user', id: 'a' }, { type: 'user', id: 'b' }] }]; -const VIEWS: Record[] = [ - { name: 'all_accounts', object: 'account', label: 'All accounts', viewKind: 'list', config: { type: 'kanban' } }, -]; +const SKILLS: Record[] = [{ name: 'triage', label: 'Triage', tools: ['a', 'b'] }]; const CLIENT = { list: async (type: string) => - type === 'hook' ? HOOKS : type === 'agent' ? AGENTS : type === 'queue' ? QUEUES : type === 'view' ? VIEWS : [], + type === 'hook' ? HOOKS : type === 'agent' ? AGENTS : type === 'queue' ? QUEUES : type === 'skill' ? SKILLS : [], }; // Headers as the server serves them to a zh-CN reader. @@ -96,19 +98,6 @@ const QUEUE_ENTRY = { }; // Control: a type that serves no list. const SKILL_ENTRY = { type: 'skill', label: 'Skill', allowEnvironmentOverlay: false, allowRuntimeCreate: true }; -const VIEW_ENTRY = { - type: 'view', - label: 'View', - allowEnvironmentOverlay: false, - allowRuntimeCreate: true, - list: { - data: { provider: 'schema', schemaId: 'view' }, - columns: [ - { field: 'name', label: 'Name' }, - { field: 'type', label: 'Type', type: 'badge' }, - ], - }, -}; vi.mock('./useMetadata', async (importOriginal) => ({ ...(await importOriginal>()), @@ -116,7 +105,7 @@ vi.mock('./useMetadata', async (importOriginal) => ({ useMetadataTypes: () => ({ loading: false, error: null, - entries: [HOOK_ENTRY, AGENT_ENTRY, QUEUE_ENTRY, SKILL_ENTRY, VIEW_ENTRY], + entries: [HOOK_ENTRY, AGENT_ENTRY, QUEUE_ENTRY, SKILL_ENTRY], }), })); @@ -153,7 +142,7 @@ afterEach(() => { function mount(type: string) { return render( - + } /> @@ -198,8 +187,8 @@ describe('the generic list reads the served columns (objectstack#36860)', () => it('a type serving no list keeps the default columns (control)', async () => { mount('skill'); const headers = await headersOf(); - expect(headers).toContain('Name'); - expect(headers).toContain('Description'); + // The setup list's default: label first (#27356), then description. + expect(headers.slice(0, 2)).toEqual(['Label', 'Description']); expect(headers).not.toContain('Tools'); }); @@ -208,9 +197,4 @@ describe('the generic list reads the served columns (objectstack#36860)', () => expect((await headersOf()).slice(0, 3)).toEqual(['Name', 'Members', 'Package']); expect((await rowOf('tier1')).slice(0, 2)).toEqual(['tier1', '2 people']); }); - - it('the view list keeps its derived display type through its cell override', async () => { - mount('view'); - expect((await rowOf('all_accounts')).slice(0, 2)).toEqual(['all_accounts', 'kanban']); - }); }); diff --git a/ui/packages/app-shell/src/views/metadata-admin/anchors.ts b/ui/packages/app-shell/src/views/metadata-admin/anchors.ts index d6e87cbb74c..c839973fd13 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/anchors.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/anchors.ts @@ -571,9 +571,26 @@ export function registerBuiltinAnchors(): void { // seed it as an empty record so the saved body validates. createDefaults: { fields: {} }, searchableFields: ['name', 'label', 'pluralLabel', 'description'], - // objectstack#36860 — the list columns are the spec's - // (`METADATA_LIST_REGISTRY`): name, label, plural label, field count, - // description. + listColumns: [ + { key: 'name', label: 'Name', width: '24%' }, + { key: 'label', label: 'Label', width: '22%' }, + { key: 'pluralLabel', label: 'Plural', width: '22%' }, + { + key: 'fields', + label: 'Fields', + width: '90px', + render: (value) => { + if (value == null) return '—'; + const count = Array.isArray(value) + ? value.length + : typeof value === 'object' + ? Object.keys(value as Record).length + : 0; + return count; + }, + }, + { key: 'description', label: 'Description' }, + ], }); // objectui#12982 — the declared sharing rules Setup lists read-only @@ -583,17 +600,19 @@ export function registerBuiltinAnchors(): void { type: 'sharing_rule', iconName: 'share-2', searchableFields: ['name', 'label', 'description', 'object'], - // objectstack#36860 — name / label / object / shared with / access level - // are the spec's columns; the declaring package is served beside each row. - listCells: { - sharedWith: { + listColumns: [ + { key: 'name', label: 'Name' }, + { key: 'label', label: 'Label' }, + { key: 'object', label: 'Object' }, + { + key: 'sharedWith', + label: 'Shared with', render: (value) => { const v = value as { type?: unknown; value?: unknown } | null | undefined; return v && typeof v === 'object' ? `${String(v.type ?? '')}: ${String(v.value ?? '')}` : '—'; }, }, - }, - listExtraColumns: [ + { key: 'accessLevel', label: 'Access' }, { key: '_packageId', label: 'Package', From e5477f472565e9a104a232cc855c862a4cbe104b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 06:07:18 +0000 Subject: [PATCH 4/5] test(rest,metadata-protocol): pin the served list layout and its translated headers Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzg7mFFG5b13DcQ93kf --- ...tocol.meta-types-list-layout-36860.test.ts | 82 +++++++++++ .../rest/src/meta-types-list-headers.test.ts | 131 ++++++++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 packages/metadata-protocol/src/protocol.meta-types-list-layout-36860.test.ts create mode 100644 packages/rest/src/meta-types-list-headers.test.ts diff --git a/packages/metadata-protocol/src/protocol.meta-types-list-layout-36860.test.ts b/packages/metadata-protocol/src/protocol.meta-types-list-layout-36860.test.ts new file mode 100644 index 00000000000..e0b04a6524a --- /dev/null +++ b/packages/metadata-protocol/src/protocol.meta-types-list-layout-36860.test.ts @@ -0,0 +1,82 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36860 — `getMetaTypes()` serves each type's declared list layout + * (`METADATA_LIST_REGISTRY`) as `list` on its entry, beside `form`. + * + * - every registry type is served with its own layout, the object the spec + * froze, not a copy that could drift; + * - a type the registry does not cover carries no `list` key at all, so a + * client that reads it falls back to its own columns (the control). + */ +import { describe, expect, it } from 'vitest'; +// `./protocol.js` reaches `import('@objectstack/lint')`; pay its first load at +// collection, never inside a clocked case. +import '@objectstack/lint'; +import { + assertEngineDeleteDispatch, + assertEngineUpdateDispatch, + assertEngineFindOnePredicate, + type EngineFindOneQueryInput, +} from '@objectstack/metadata-core'; +import { DEFAULT_METADATA_TYPE_REGISTRY } from '@objectstack/spec/kernel'; +import { METADATA_LIST_REGISTRY } from '@objectstack/spec/system'; +import { ObjectStackProtocolImplementation } from './protocol.js'; + +const SERVED_TYPES = Array.from(new Set(DEFAULT_METADATA_TYPE_REGISTRY.map((e) => e.type))); + +function makeProtocol() { + const engine: any = { + async findOne(object: string, query?: EngineFindOneQueryInput) { + assertEngineFindOnePredicate(object, query); return null; + }, + async find() { return []; }, + async insert() { return { id: 'unused' }; }, + async update(_t: string, data: Record, opts?: Record) { + assertEngineUpdateDispatch(data, opts); + return { id: null }; + }, + async delete(_t: string, opts?: Record) { + assertEngineDeleteDispatch(opts); + return { deleted: 1 }; + }, + async count() { return 0; }, + async transaction(fn: (ctx: unknown) => Promise) { return fn(undefined); }, + async execute() { return {}; }, + async getObjectSchema() { return undefined; }, + registry: { + getRegisteredTypes: () => [...SERVED_TYPES], + registerItem: () => {}, + registerObject: () => {}, + unregisterItem: () => {}, + listItems: () => [], + getItem: () => undefined, + getArtifactItem: () => undefined, + }, + }; + return new ObjectStackProtocolImplementation(engine, () => new Map(), undefined) as any; +} + +describe('GET /meta/types serves the declared list layout (objectstack#36860)', () => { + it('serves every registry type with its own frozen layout', async () => { + const { entries } = await makeProtocol().getMetaTypes(); + const byType = new Map(entries.map((e: any) => [e.type, e])); + const declared = Object.keys(METADATA_LIST_REGISTRY); + expect(declared.length).toBeGreaterThan(0); + for (const type of declared) { + const entry = byType.get(type); + expect(entry, `${type} is served`).toBeDefined(); + expect(entry.list).toBe(METADATA_LIST_REGISTRY[type]); + } + expect(byType.get('hook').list.columns.map((c: any) => c.field)).toEqual([ + 'name', 'label', 'object', 'events', 'priority', 'async', 'description', + ]); + }); + + it('control — a type with no declared list carries no `list` key', async () => { + const { entries } = await makeProtocol().getMetaTypes(); + const undeclared = entries.filter((e: any) => !(e.type in METADATA_LIST_REGISTRY)); + expect(undeclared.length).toBeGreaterThan(0); + for (const entry of undeclared) expect(Object.prototype.hasOwnProperty.call(entry, 'list'), entry.type).toBe(false); + }); +}); diff --git a/packages/rest/src/meta-types-list-headers.test.ts b/packages/rest/src/meta-types-list-headers.test.ts new file mode 100644 index 00000000000..2a1923e8a68 --- /dev/null +++ b/packages/rest/src/meta-types-list-headers.test.ts @@ -0,0 +1,131 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36860 — `GET /meta` localises the headers of a type's served + * list layout (`entries[].list`) through the type's form field slot, + * `metadataForms..fields..label`, the slot the form field of the + * same key reads. + * + * The rule lives in `@objectstack/spec/system` (`resolveMetadataListLabels`); + * what is pinned here is the plumbing: `translateMetaTypesResponse` hands + * `entry.list` through it with the bundle and locale it hands `entry.form`. + */ + +import { describe, it, expect, vi } from 'vitest'; +import { RestServer } from './rest-server.js'; + +const LIST = () => ({ + data: { provider: 'schema', schemaId: 'hook' }, + columns: [ + { field: 'name', label: 'Name' }, + { field: 'events', label: 'Events', type: 'list' }, + { field: 'retryPolicy.maxRetries', label: 'Max Retries' }, + ], +}); + +const ZH_DATA = { + metadataForms: { + hook: { + label: '钩子', + fields: { + name: { label: '名称' }, + events: { label: '事件' }, + 'retryPolicy.maxRetries': { label: '最大重试次数' }, + }, + }, + }, +}; + +function i18nFor(bundles: Record) { + return { + getLocales: () => Object.keys(bundles), + getTranslations: (locale: string) => bundles[locale] ?? {}, + getDefaultLocale: () => 'en', + getFallbackLocale: () => 'en', + }; +} + +function mockServer() { + return { + get: vi.fn(), post: vi.fn(), put: vi.fn(), delete: vi.fn(), patch: vi.fn(), + use: vi.fn(), listen: vi.fn().mockResolvedValue(undefined), close: vi.fn().mockResolvedValue(undefined), + }; +} + +function mockRes() { + return { json: vi.fn(), status: vi.fn().mockReturnThis(), header: vi.fn(), send: vi.fn() }; +} + +function protocol() { + return { + getDiscovery: vi.fn().mockResolvedValue({ + version: 'v0', + routes: { data: '', metadata: '', ui: '', auth: '/auth' }, + }), + getMetaTypes: vi.fn(async () => ({ + entries: [ + { type: 'hook', label: 'Hook', list: LIST() }, + // Control: a type serving no list. + { type: 'skill', label: 'Skill' }, + ], + types: ['hook', 'skill'], + registered: ['hook', 'skill'], + })), + getMetaItems: vi.fn(async () => []), + getMetaItem: vi.fn(async () => undefined), + getMetaItemCached: undefined as any, + findData: vi.fn().mockResolvedValue([]), + }; +} + +function makeRest(i18n: any) { + const rest = new RestServer( + mockServer() as any, protocol() as any, { api: { requireAuth: false } } as any, + undefined, undefined, undefined, undefined, undefined, + undefined, undefined, undefined, undefined, undefined, + async () => i18n, + ); + (rest as any).resolveExecCtx = async () => ({ userId: 'u1', systemPermissions: [] }); + rest.registerRoutes(); + return rest; +} + +async function readTypes(rest: RestServer, locale: string | undefined): Promise { + const route = (rest as any).getRoutes().find((r: any) => r.method === 'GET' && r.path === '/api/v1/meta'); + if (!route) throw new Error('route not registered: GET /api/v1/meta'); + const res = mockRes(); + await route.handler( + { method: 'GET', params: {}, query: {}, body: {}, headers: locale ? { 'accept-language': locale } : {} }, + res, + ); + const calls = res.json.mock.calls; + return calls.length ? calls[calls.length - 1][0] : undefined; +} + +const headers = (entry: any) => entry.list.columns.map((c: any) => c.label); + +describe('GET /meta serves the list headers in the reader\'s language (objectstack#36860)', () => { + const bundles = () => ({ en: {}, 'zh-CN': ZH_DATA }); + + it('a zh-CN request names each column through its form field slot, dotted paths included', async () => { + const body = await readTypes(makeRest(i18nFor(bundles())), 'zh-CN'); + const entry = body.entries.find((e: any) => e.type === 'hook'); + expect(headers(entry)).toEqual(['名称', '事件', '最大重试次数']); + // Only the header is rewritten. + expect(entry.list.columns[1]).toEqual({ field: 'events', label: '事件', type: 'list' }); + expect(entry.list.data).toEqual({ provider: 'schema', schemaId: 'hook' }); + }); + + it('control — an en request keeps the declared headers, and a type serving no list gains none', async () => { + const body = await readTypes(makeRest(i18nFor(bundles())), 'en'); + expect(headers(body.entries.find((e: any) => e.type === 'hook'))).toEqual(['Name', 'Events', 'Max Retries']); + expect('list' in body.entries.find((e: any) => e.type === 'skill')).toBe(false); + }); + + it('control — the served list is not rewritten in place across requests', async () => { + const rest = makeRest(i18nFor(bundles())); + await readTypes(rest, 'zh-CN'); + const body = await readTypes(rest, 'en'); + expect(headers(body.entries.find((e: any) => e.type === 'hook'))).toEqual(['Name', 'Events', 'Max Retries']); + }); +}); From 597f70e74069d518950e6ea574de3ac32c71e2e1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 06:49:15 +0000 Subject: [PATCH 5/5] test: pay the objectql load at collection, record the new engine doubles Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzg7mFFG5b13DcQ93kf --- packages/rest/src/meta-types-list-headers.test.ts | 3 +++ scripts/engine-double-contract.pinned.json | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/rest/src/meta-types-list-headers.test.ts b/packages/rest/src/meta-types-list-headers.test.ts index 2a1923e8a68..a75102b80d4 100644 --- a/packages/rest/src/meta-types-list-headers.test.ts +++ b/packages/rest/src/meta-types-list-headers.test.ts @@ -12,6 +12,9 @@ */ import { describe, it, expect, vi } from 'vitest'; +// The server's routes reach `import('@objectstack/objectql')`; pay its first +// load at collection, never inside a clocked case. +import '@objectstack/objectql'; import { RestServer } from './rest-server.js'; const LIST = () => ({ diff --git a/scripts/engine-double-contract.pinned.json b/scripts/engine-double-contract.pinned.json index a323e3980b2..27475b530e1 100644 --- a/scripts/engine-double-contract.pinned.json +++ b/scripts/engine-double-contract.pinned.json @@ -1396,6 +1396,21 @@ "verb": "update", "pinned": 1 }, + { + "file": "packages/metadata-protocol/src/protocol.meta-types-list-layout-36860.test.ts", + "verb": "delete", + "pinned": 1 + }, + { + "file": "packages/metadata-protocol/src/protocol.meta-types-list-layout-36860.test.ts", + "verb": "findOne", + "pinned": 1 + }, + { + "file": "packages/metadata-protocol/src/protocol.meta-types-list-layout-36860.test.ts", + "verb": "update", + "pinned": 1 + }, { "file": "packages/metadata-protocol/src/protocol.meta-types-mint-door-agreement.test.ts", "verb": "delete",