Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .changeset/36860-metadata-list-columns.md
Original file line number Diff line number Diff line change
@@ -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.<type>.fields.<field>.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.
1 change: 1 addition & 0 deletions content/docs/references/api/protocol.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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. |


---
Expand Down
10 changes: 5 additions & 5 deletions content/docs/references/index.mdx
Original file line number Diff line number Diff line change
@@ -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/. */}
Expand Down Expand Up @@ -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 |

---

Expand Down Expand Up @@ -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.

Expand All @@ -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` |

---

Expand Down
81 changes: 79 additions & 2 deletions content/docs/references/ui/view.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<string, string>` | 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<string, any> }` | optional | Data source configuration (defaults to "object" provider) |
| **columns** | `{ field: string; label?: string \| Record<string, string>; 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<string, any>` | 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<string, string>` | optional | Display label override |
| **type** | `Enum<'text' \| 'badge' \| 'boolean' \| 'count' \| 'list' \| 'summary'>` | optional | Cell renderer; `text` when absent |


---

## NavigationConfig
Expand Down
24 changes: 21 additions & 3 deletions packages/lint/src/i18n-walk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@
* metadataForms.<type>.fields.<dotPath>.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.<path>.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} —
Expand All @@ -175,6 +176,7 @@

import {
METADATA_FORM_REGISTRY,
METADATA_LIST_REGISTRY,
PAGE_COMPONENT_COPY_KEYS,
FLOW_SCREEN_COPY_KEYS,
FLOW_SCREEN_FIELD_COPY_KEYS,
Expand Down Expand Up @@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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 } : {}),
Expand Down
Loading
Loading