From f48d0f41fe3f284de9a699091125a2f6a7ec4264 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 12:26:37 +0000 Subject: [PATCH 01/18] feat(spec): timesheet list view type and its binding block Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- packages/spec/liveness/view.json | 7 +++- .../src/kernel/functional-completeness.ts | 13 +++++++ .../src/type-alias-convention.pin.test.ts | 1 + packages/spec/src/ui/view.form.ts | 7 ++++ packages/spec/src/ui/view.zod.ts | 34 ++++++++++++++++++- 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/packages/spec/liveness/view.json b/packages/spec/liveness/view.json index 341e45bfc5a..4555de4879c 100644 --- a/packages/spec/liveness/view.json +++ b/packages/spec/liveness/view.json @@ -34,7 +34,7 @@ }, "type": { "status": "live", - "note": "objectui: ListView.tsx routes grid/kanban/calendar/gantt/gallery/timeline/chart/tree renderers (audit L16). [#17063] The enum carried a ninth member, `page`, which routed nowhere in ListView — it was to delegate to the existing page renderer via the sibling `pageName` key (#13216, maintainer ruling 2026-08-29) and objectui's half was never built. Retired 2026-09-10 under ADR-0049 enforce-or-remove (maintainer ruling 2026-09-09 「撤」): the value is refused by name on the enum's own error map, which is where an enum-VALUE narrowing's prescription has to live. Every member listed above is still routed by that switch." + "note": "objectui: ListView.tsx routes grid/kanban/calendar/gantt/gallery/timeline/chart/tree/timesheet renderers (audit L16). [#17063] The enum carried a ninth member, `page`, which routed nowhere in ListView — it was to delegate to the existing page renderer via the sibling `pageName` key (#13216, maintainer ruling 2026-08-29) and objectui's half was never built. Retired 2026-09-10 under ADR-0049 enforce-or-remove (maintainer ruling 2026-09-09 「撤」): the value is refused by name on the enum's own error map, which is where an enum-VALUE narrowing's prescription has to live. Every member listed above is still routed by that switch." }, "data": { "status": "live", @@ -127,6 +127,11 @@ "status": "live", "note": "objectui: @object-ui/plugin-tree ObjectTree.tsx (spec CHANGELOG: 'Renderer ships in objectui @object-ui/plugin-tree')." }, + "timesheet": { + "status": "live", + "evidenceScope": "in-repo", + "evidence": "ui/packages/plugin-list/src/ListView.tsx `case 'timesheet'` forwards the view's `timesheet` block into an `object-timesheet` node; ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx `resolveTimesheetConfig` reads `rowFields` (row key and the values written onto a created record), `dateField` (the week-window filter and the day column) and `valueField` (the cell value, each per-cell create/update/delete, and the totals), and renders the \"Timesheet configuration required\" refusal when any of the three is missing. Pinned by ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx." + }, "pageName": { "status": "dead", "verifiedAt": "2026-09-10", diff --git a/packages/spec/src/kernel/functional-completeness.ts b/packages/spec/src/kernel/functional-completeness.ts index 48b181ae501..87e9db738f7 100644 --- a/packages/spec/src/kernel/functional-completeness.ts +++ b/packages/spec/src/kernel/functional-completeness.ts @@ -358,6 +358,14 @@ export function checkFieldCompleteness(def: unknown): CompletenessFinding[] { * `TreeConfigSchema` key is optional, so `tree: {}` satisfies THIS table and * still renders flat — the parent pointer has its own rule, * {@link VIEW_TREE_WITHOUT_PARENT_FIELD}, below. + * - `timesheet` → NO fallback, and no silence. `ListView.tsx`'s + * `case 'timesheet'` forwards the declared block alone, and + * `ObjectTimesheet`'s `resolveTimesheetConfig` returns `null` unless + * `rowFields`, `dateField` and `valueField` are all present, which renders + * the "Timesheet configuration required" refusal + * (`data-testid="timesheet-missing-binding"`). `TimesheetConfigSchema` + * requires all three keys, so a present block is a complete binding and + * only an absent one can reach the refusal. * * RE-MEASUREMENT HISTORY. [#17445] corrected the `calendar` row, reading * objectui `main` at `0cf2d6644` (2026-09-21), and found the `gantt`, @@ -401,6 +409,7 @@ const VIEW_BINDING_BLOCKS: Readonly> = { timeline: 'timeline', map: 'map', tree: 'tree', + timesheet: 'timesheet', }; /** @@ -417,6 +426,7 @@ const VIEW_BINDING_FIX: Readonly> = { timeline: "timeline: { startDateField: '', titleField: '' }", map: "map: { locationField: '' } — or { latitudeField: '', longitudeField: '' }", tree: "tree: { parentField: '', labelField: '' }", + timesheet: "timesheet: { rowFields: [''], dateField: '', valueField: '' }", }; /** @@ -464,6 +474,9 @@ const VIEW_BINDING_MESSAGE: Readonly> = { map: 'A `map` view with no `map` block shows the "Map configuration required" screen on every ' + 'object (`ObjectMap.tsx` — its `hasCoordinateBinding` gate fails)', + timesheet: + 'A `timesheet` view with no `timesheet` block shows the "Timesheet configuration required" ' + + 'screen on every object (`ObjectTimesheet.tsx` — `resolveTimesheetConfig` resolves `null`)', }; /** diff --git a/packages/spec/src/type-alias-convention.pin.test.ts b/packages/spec/src/type-alias-convention.pin.test.ts index 98d5e5a39d8..f8ddcf6cf0b 100644 --- a/packages/spec/src/type-alias-convention.pin.test.ts +++ b/packages/spec/src/type-alias-convention.pin.test.ts @@ -1754,6 +1754,7 @@ export type Iso_ui_view__ListMapConfigSchema = Assert, z.infer< typeof M167.NavigationModeSchema > >>; export type Iso_ui_view__RowColorConfigSchema = Assert, z.infer< typeof M167.RowColorConfigSchema > >>; export type Iso_ui_view__RowHeightSchema = Assert, z.infer< typeof M167.RowHeightSchema > >>; +export type Iso_ui_view__TimesheetConfigSchema = Assert, z.infer< typeof M167.TimesheetConfigSchema > >>; export type Iso_ui_view__TreeConfigSchema = Assert, z.infer< typeof M167.TreeConfigSchema > >>; export type Iso_ui_view__UserFilterFieldSchema = Assert, z.infer< typeof M167.UserFilterFieldSchema > >>; export type Iso_ui_view__ViewItemNameSchema = Assert, z.infer< typeof M167.ViewItemNameSchema > >>; diff --git a/packages/spec/src/ui/view.form.ts b/packages/spec/src/ui/view.form.ts index a78c3cceb3b..09777568d1c 100644 --- a/packages/spec/src/ui/view.form.ts +++ b/packages/spec/src/ui/view.form.ts @@ -182,6 +182,13 @@ export const viewForm = defineForm({ visibleWhen: "data.type == 'chart'", fields: [{ field: 'chart', type: 'composite' }], }, + { + name: 'timesheet', + label: 'Timesheet', + description: 'Timesheet-specific configuration.', + visibleWhen: "data.type == 'timesheet'", + fields: [{ field: 'timesheet', type: 'composite' }], + }, // [#17063] The `page` section was REMOVED with the mount it configured // (ADR-0049 enforce-or-remove, maintainer ruling 2026-09-09 「撤」). It bound // the one input `pageName`, which is now a `retiredKey()` tombstone on diff --git a/packages/spec/src/ui/view.zod.ts b/packages/spec/src/ui/view.zod.ts index f36edc5ccd5..af024892880 100644 --- a/packages/spec/src/ui/view.zod.ts +++ b/packages/spec/src/ui/view.zod.ts @@ -2782,6 +2782,35 @@ export const TreeConfigSchema = lazySchema(() => strictObject({ // declares nothing new and refuses only what no renderer ever read. })); +/** + * Timesheet (weekly entry grid) Settings + * + * Pivots the view's records into an editable row × weekday grid: one row per + * distinct `rowFields` value tuple, one column per day of the displayed week, + * and in each cell the `valueField` of the one record that row and day hold. + * Typing a value creates or updates that record, clearing the cell deletes it, + * and every write goes through the ordinary record door, so hooks, validation + * and permissions judge each cell on its own. Row, day and week totals are + * always shown. A cell that holds two or more records shows their sum and is + * read-only, because one typed value could not say which record it changes. + * + * The week follows the viewer's locale for its first day; there is no period + * key, because a week is the only window the renderer draws. Every key is + * required: an unbound timesheet has nothing to pivot, and the renderer + * refuses it with a "Timesheet configuration required" screen. + */ +export const TimesheetConfigSchema = lazySchema(() => strictObject({ + surface: 'this timesheet configuration', + history: VIEW_HISTORY, +}, { + rowFields: z.array(z.string()).min(1).max(3) + .describe('One to three fields whose values key a row (e.g. ["project", "task"]); a record\'s values for these fields place it on its row, and a new row\'s values are written onto each record it creates'), + dateField: z.string() + .describe('Date field placing a record on a day column; the renderer fetches only the records whose value falls in the displayed week'), + valueField: z.string() + .describe('Numeric field (number, currency or percent) a cell shows and edits; row, day and week totals sum it'), +})); + /** * Map View Settings * @@ -3344,7 +3373,8 @@ const ListViewShapeSchema = lazySchema(() => strictObject({ 'gantt', // Project Timeline 'map', // Geospatial 'chart', // Aggregate visualisation - 'tree' // Self-referencing hierarchy (tree-grid) + 'tree', // Self-referencing hierarchy (tree-grid) + 'timesheet' // Editable row × weekday entry grid ], { error: (issue) => (issue.input === 'page' ? LIST_VIEW_TYPE_PAGE_RETIRED : undefined), }).default('grid'), @@ -3487,6 +3517,7 @@ const ListViewShapeSchema = lazySchema(() => strictObject({ .describe('Chart binding — applies when the view renders as a chart. A `type: \'chart\'` view must bind one: it names the ADR-0021 `dataset` and the measures (`values`) the chart plots, and there is no default binding'), map: ListMapConfigSchema.optional().describe('Map configuration — applies when the view renders as a map layout'), tree: TreeConfigSchema.optional().describe('Tree/hierarchy configuration — applies when the view renders as a tree layout'), + timesheet: TimesheetConfigSchema.optional().describe('Timesheet binding — applies when the view renders as a timesheet. A `type: \'timesheet\'` view must bind one: the row fields, the date field and the numeric value field the weekly grid pivots and edits'), /** * [#17063] REMOVED — the `type: 'page'` mount this key named was never @@ -8227,4 +8258,5 @@ export type KanbanConfig = z.input; export type ListMapConfig = z.input; export type NavigationMode = z.input; export type TreeConfig = z.input; +export type TimesheetConfig = z.input; export type ViewItemName = z.input; From bdf4c328ce3bb7e4f128ec5c34513465c0115fed Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 12:41:19 +0000 Subject: [PATCH 02/18] feat(i18n): lazy timesheet locale namespace and spec regenerated artifacts Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- content/docs/references/api/metadata.mdx | 2 +- content/docs/references/api/protocol.mdx | 10 +- content/docs/references/data/object.mdx | 5 +- content/docs/references/index.mdx | 10 +- content/docs/references/system/migration.mdx | 4 +- content/docs/references/ui/view.mdx | 59 +++++-- .../ui.md | 12 +- packages/spec/api-surface/ui.json | 2 + packages/spec/authorable-surface/ui.json | 5 + packages/spec/declaration-map/ui.json | 2 + packages/spec/export-origins/ui.json | 2 + packages/spec/json-schema.manifest/ui.json | 1 + packages/spec/liveness/state-counts/view.md | 2 +- packages/spec/liveness/view.json | 19 ++- scripts/regen-artifacts.mjs | 12 ++ .../objectstack-ui/references/react-blocks.md | 2 +- ui/apps/console/vite.config.ts | 16 ++ ui/packages/i18n/package.json | 5 + ui/packages/i18n/scripts/zh-hant.mjs | 5 + .../src/__tests__/timesheet-namespace.test.ts | 158 ++++++++++++++++++ .../src/__tests__/zh-hant-generated.test.ts | 1 + ui/packages/i18n/src/locales/index.ts | 58 +++++-- .../i18n/src/namespaces/timesheet/ar.ts | 35 ++++ .../i18n/src/namespaces/timesheet/de.ts | 35 ++++ .../i18n/src/namespaces/timesheet/en.ts | 35 ++++ .../i18n/src/namespaces/timesheet/es.ts | 35 ++++ .../i18n/src/namespaces/timesheet/fr.ts | 35 ++++ .../i18n/src/namespaces/timesheet/index.ts | 116 +++++++++++++ .../i18n/src/namespaces/timesheet/ja.ts | 35 ++++ .../i18n/src/namespaces/timesheet/ko.ts | 35 ++++ .../i18n/src/namespaces/timesheet/pt-BR.ts | 35 ++++ .../i18n/src/namespaces/timesheet/ru.ts | 35 ++++ .../i18n/src/namespaces/timesheet/zh-Hans.ts | 35 ++++ .../i18n/src/namespaces/timesheet/zh-Hant.ts | 32 ++++ .../__tests__/check-i18n-en-drift.test.ts | 1 + ui/scripts/check-i18n-call-site-keys.mjs | 2 + 36 files changed, 841 insertions(+), 52 deletions(-) create mode 100644 ui/packages/i18n/src/__tests__/timesheet-namespace.test.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/ar.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/de.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/en.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/es.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/fr.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/index.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/ja.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/ko.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/ru.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts create mode 100644 ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts diff --git a/content/docs/references/api/metadata.mdx b/content/docs/references/api/metadata.mdx index 6de257e8714..32a1efab39f 100644 --- a/content/docs/references/api/metadata.mdx +++ b/content/docs/references/api/metadata.mdx @@ -965,7 +965,7 @@ Metadata query with filtering, sorting, and pagination | **relatedLists** | `string[]` | optional | Business order of this object's related lists on its record page, most important first. Each entry is a child object name (e.g. "task"), or object.field when that child has more than one relationship to this object (e.g. "event.related_to"). Listed relationships come first in this order; unlisted ones follow in the derived order (owned master_detail children, then lookup children). An entry whose child is in the stack but has no inbound lookup / master_detail field to this object is refused everywhere. An entry whose child exists nowhere is refused by os validate / os build (which leave a sys_ / cloud_ / ai_ name to the runtime) and by a metadata write that names no package; a write into a package stores it, since a child outside the package may be a downstream package's object that points here, and the record page places nothing for it. It orders only: relatedList: false on the relationship still hides a list, and relatedList: 'primary' still places a list in the record's body, so the order applies among the body tables and among the side cards. | | **stageField** | `string \| false` | optional | [ADR-0085] Lifecycle stage field (linear/ordered), or false to declare the status field non-linear and suppress stage heuristics. Absent = heuristic detection allowed. When the named field carries options, it must be a single-value `select` / `radio` with inline `options`, each declaring its `kind` ('open' / 'won' / 'lost'); a picklist-backed or multi-value stage field is refused. A name that resolves to no declared field, or a field with no options, is not judged at parse. | | **editMode** | `Enum<'modal' \| 'page'>` | optional | Edit-interaction intent for records of this object: 'modal' opens the edit form as a dialog over the current view; 'page' navigates to a dedicated full-page edit route. Absent = the renderer picks its own default (objectui defaults to modal). Cross-renderer intent, not pixel styling (family). | -| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | +| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | | **searchableFields** | `string[]` | optional | Fields the `$search` query matches against (ADR-0061). Canonical default for the record picker, list quick-search and global search; views may narrow it. When unset, search auto-defaults to the name/title field plus short-text fields. Entries must name a STORED column: a virtual `formula` field is computed on read and materializes no column, so searching it can never match and it is refused — mirror the value onto a stored text field and declare that. | | **enable** | `{ trackHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; apiMethods?: Enum<'get' \| 'list' \| 'create' \| 'update' \| 'delete' \| 'bulk'>[]; … }` | optional | Enabled system features modules | | **sharingModel** | `Enum<'private' \| 'public_read' \| 'public_read_write' \| 'controlled_by_parent'>` | optional | Org-Wide Default record visibility (OWD) for INTERNAL users. Canonical four only (legacy aliases removed, ADR-0090 D4): private (owner-only) \| public_read (everyone reads, owner writes) \| public_read_write (everyone reads+writes) \| controlled_by_parent (derived from the master record). A CUSTOM object that omits this resolves to private at runtime (ADR-0090 D1). | diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 3a46d4f7a23..c4f4096e41f 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1907,9 +1907,9 @@ The published metadata item body, opaque by ruling (1C). Shape is the item's own | **name** | `string` | optional | Item name — supplied by the metadata door; for an object-scoped container it is the object name. | | **label** | `string \| Record` | optional | Human-readable label shown in metadata lists. | | **object** | `string` | optional | Object this container binds to — how a stack-level `views: [...]` entry says which object its views belong to; read by `getViewsByObject()` / `GET /meta/view?object=`. | -| **list** | `{ name?: string; label?: string \| Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>; data?: object \| object \| object; … }` | optional | | +| **list** | `{ name?: string; label?: string \| Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }` | optional | | | **form** | `{ type?: Enum<'simple' \| 'tabbed' \| 'wizard'>; layout?: Enum<'vertical' \| 'horizontal'>; columns?: integer; title?: string; … }` | optional | | -| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>; data?: object \| object \| object; … }>` | optional | Additional named list views (views mode — dropdown userFilters allowed, no tabs; ADR-0047) | +| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }>` | optional | Additional named list views (views mode — dropdown userFilters allowed, no tabs; ADR-0047) | | **formViews** | `Record; layout?: Enum<'vertical' \| 'horizontal'>; columns?: integer; title?: string; … }>` | optional | Additional named form views | | **protection** | `{ lock: Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>; reason: string; docsUrl?: string }` | optional | Package author protection block — lock policy for this view. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | @@ -1926,7 +1926,7 @@ The published metadata item body, opaque by ruling (1C). Shape is the item's own | :--- | :--- | :--- | :--- | | **name** | `string` | optional | Internal view name (lowercase snake_case) | | **label** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | -| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>` | optional (default: `"grid"`) | | +| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>` | optional (default: `"grid"`) | | | **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | | **columns** | `string[] \| { field: string; label?: string \| Record; width?: number; align?: Enum<'left' \| 'center' \| 'right'>; … }[]` | ✅ | Fields to display as columns — the PROJECTION of the per-view field composition `columns` x `hiddenFields` x `fieldOrder`: this list is the candidate set AND the baseline order; `hiddenFields` subtracts from it and `fieldOrder` orders what survives. `hiddenFields` and `fieldOrder` cannot add a field omitted here. An empty list declares no projection, so neither of them applies: which columns show is then left to the renderer (objectui's `ListView` grid derives the object's default columns). | | **filter** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Filter criteria (JSON Rules) | @@ -1946,6 +1946,7 @@ The published metadata item body, opaque by ruling (1C). Shape is the item's own | **chart** | `{ chartType?: Enum<'bar' \| 'line' \| 'pie' \| 'area' \| 'scatter'>; dataset: string; dimensions?: string[]; values: string[] }` | optional | Chart binding — applies when the view renders as a chart. A `type: 'chart'` view must bind one: it names the ADR-0021 `dataset` and the measures (`values`) the chart plots, and there is no default binding | | **map** | `{ latitudeField?: string; longitudeField?: string; locationField?: string; titleField?: string; … }` | optional | Map configuration — applies when the view renders as a map layout | | **tree** | `{ parentField?: string; labelField?: string; fields?: string[]; defaultExpandedDepth?: integer }` | optional | Tree/hierarchy configuration — applies when the view renders as a tree layout | +| **timesheet** | `{ rowFields: string[]; dateField: string; valueField: string }` | optional | Timesheet binding — applies when the view renders as a timesheet. A `type: 'timesheet'` view must bind one: the row fields, the date field and the numeric value field the weekly grid pivots and edits | | **pageName** | `never` | optional | [REMOVED] `view.pageName` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — it named the page a `type: 'page'` view was to mount, and that mount was never built: no renderer read the key, so the named page was never reached and the view drew an empty grid. Delete the key; to put a published page in front of users, give the app a navigation item — `{ type: 'page', pageName: '' }` under the app's `navigation` — which is a different key on a different surface and is the page mount that has always rendered. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **description** | `string \| Record` | optional | View description for documentation/tooltips | | **sharing** | `{ lockedBy?: string }` | optional | View sharing configuration: who locked the view configuration | @@ -2005,7 +2006,7 @@ The published metadata item body, opaque by ruling (1C). Shape is the item's own | :--- | :--- | :--- | :--- | | **name** | `string` | optional | Internal view name (lowercase snake_case) | | **label** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | -| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>` | optional (default: `"grid"`) | | +| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>` | optional (default: `"grid"`) | | | **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | | **columns** | `string[] \| { field: string; label?: string \| Record; width?: number; align?: Enum<'left' \| 'center' \| 'right'>; … }[]` | ✅ | Fields to display as columns — the PROJECTION of the per-view field composition `columns` x `hiddenFields` x `fieldOrder`: this list is the candidate set AND the baseline order; `hiddenFields` subtracts from it and `fieldOrder` orders what survives. `hiddenFields` and `fieldOrder` cannot add a field omitted here. An empty list declares no projection, so neither of them applies: which columns show is then left to the renderer (objectui's `ListView` grid derives the object's default columns). | | **filter** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Filter criteria (JSON Rules) | @@ -2025,6 +2026,7 @@ The published metadata item body, opaque by ruling (1C). Shape is the item's own | **chart** | `{ chartType?: Enum<'bar' \| 'line' \| 'pie' \| 'area' \| 'scatter'>; dataset: string; dimensions?: string[]; values: string[] }` | optional | Chart binding — applies when the view renders as a chart. A `type: 'chart'` view must bind one: it names the ADR-0021 `dataset` and the measures (`values`) the chart plots, and there is no default binding | | **map** | `{ latitudeField?: string; longitudeField?: string; locationField?: string; titleField?: string; … }` | optional | Map configuration — applies when the view renders as a map layout | | **tree** | `{ parentField?: string; labelField?: string; fields?: string[]; defaultExpandedDepth?: integer }` | optional | Tree/hierarchy configuration — applies when the view renders as a tree layout | +| **timesheet** | `{ rowFields: string[]; dateField: string; valueField: string }` | optional | Timesheet binding — applies when the view renders as a timesheet. A `type: 'timesheet'` view must bind one: the row fields, the date field and the numeric value field the weekly grid pivots and edits | | **pageName** | `never` | optional | [REMOVED] `view.pageName` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — it named the page a `type: 'page'` view was to mount, and that mount was never built: no renderer read the key, so the named page was never reached and the view drew an empty grid. Delete the key; to put a published page in front of users, give the app a navigation item — `{ type: 'page', pageName: '' }` under the app's `navigation` — which is a different key on a different surface and is the page mount that has always rendered. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **description** | `string \| Record` | optional | View description for documentation/tooltips | | **sharing** | `{ lockedBy?: string }` | optional | View sharing configuration: who locked the view configuration | diff --git a/content/docs/references/data/object.mdx b/content/docs/references/data/object.mdx index d5640b9fcf6..72c025bbc76 100644 --- a/content/docs/references/data/object.mdx +++ b/content/docs/references/data/object.mdx @@ -177,7 +177,7 @@ const result = ApiMethod.parse(data); | **relatedLists** | `string[]` | optional | Business order of this object's related lists on its record page, most important first. Each entry is a child object name (e.g. "task"), or object.field when that child has more than one relationship to this object (e.g. "event.related_to"). Listed relationships come first in this order; unlisted ones follow in the derived order (owned master_detail children, then lookup children). An entry whose child is in the stack but has no inbound lookup / master_detail field to this object is refused everywhere. An entry whose child exists nowhere is refused by os validate / os build (which leave a sys_ / cloud_ / ai_ name to the runtime) and by a metadata write that names no package; a write into a package stores it, since a child outside the package may be a downstream package's object that points here, and the record page places nothing for it. It orders only: relatedList: false on the relationship still hides a list, and relatedList: 'primary' still places a list in the record's body, so the order applies among the body tables and among the side cards. | | **stageField** | `string \| false` | optional | [ADR-0085] Lifecycle stage field (linear/ordered), or false to declare the status field non-linear and suppress stage heuristics. Absent = heuristic detection allowed. When the named field carries options, it must be a single-value `select` / `radio` with inline `options`, each declaring its `kind` ('open' / 'won' / 'lost'); a picklist-backed or multi-value stage field is refused. A name that resolves to no declared field, or a field with no options, is not judged at parse. | | **editMode** | `Enum<'modal' \| 'page'>` | optional | Edit-interaction intent for records of this object: 'modal' opens the edit form as a dialog over the current view; 'page' navigates to a dedicated full-page edit route. Absent = the renderer picks its own default (objectui defaults to modal). Cross-renderer intent, not pixel styling (family). | -| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | +| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | | **searchableFields** | `string[]` | optional | Fields the `$search` query matches against (ADR-0061). Canonical default for the record picker, list quick-search and global search; views may narrow it. When unset, search auto-defaults to the name/title field plus short-text fields. Entries must name a STORED column: a virtual `formula` field is computed on read and materializes no column, so searching it can never match and it is refused — mirror the value onto a stored text field and declare that. | | **enable** | `{ trackHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; apiMethods?: Enum<'get' \| 'list' \| 'create' \| 'update' \| 'delete' \| 'bulk'>[]; … }` | optional | Enabled system features modules | | **sharingModel** | `Enum<'private' \| 'public_read' \| 'public_read_write' \| 'controlled_by_parent'>` | optional | Org-Wide Default record visibility (OWD) for INTERNAL users. Canonical four only (legacy aliases removed, ADR-0090 D4): private (owner-only) \| public_read (everyone reads, owner writes) \| public_read_write (everyone reads+writes) \| controlled_by_parent (derived from the master record). A CUSTOM object that omits this resolves to private at runtime (ADR-0090 D1). | @@ -385,7 +385,7 @@ const result = ApiMethod.parse(data); | :--- | :--- | :--- | :--- | | **name** | `string` | optional | Internal view name (lowercase snake_case) | | **label** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | -| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>` | optional (default: `"grid"`) | | +| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>` | optional (default: `"grid"`) | | | **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | | **columns** | `string[] \| { field: string; label?: string \| Record; width?: number; align?: Enum<'left' \| 'center' \| 'right'>; … }[]` | ✅ | Fields to display as columns — the PROJECTION of the per-view field composition `columns` x `hiddenFields` x `fieldOrder`: this list is the candidate set AND the baseline order; `hiddenFields` subtracts from it and `fieldOrder` orders what survives. `hiddenFields` and `fieldOrder` cannot add a field omitted here. An empty list declares no projection, so neither of them applies: which columns show is then left to the renderer (objectui's `ListView` grid derives the object's default columns). | | **filter** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Filter criteria (JSON Rules) | @@ -405,6 +405,7 @@ const result = ApiMethod.parse(data); | **chart** | `{ chartType?: Enum<'bar' \| 'line' \| 'pie' \| 'area' \| 'scatter'>; dataset: string; dimensions?: string[]; values: string[] }` | optional | Chart binding — applies when the view renders as a chart. A `type: 'chart'` view must bind one: it names the ADR-0021 `dataset` and the measures (`values`) the chart plots, and there is no default binding | | **map** | `{ latitudeField?: string; longitudeField?: string; locationField?: string; titleField?: string; … }` | optional | Map configuration — applies when the view renders as a map layout | | **tree** | `{ parentField?: string; labelField?: string; fields?: string[]; defaultExpandedDepth?: integer }` | optional | Tree/hierarchy configuration — applies when the view renders as a tree layout | +| **timesheet** | `{ rowFields: string[]; dateField: string; valueField: string }` | optional | Timesheet binding — applies when the view renders as a timesheet. A `type: 'timesheet'` view must bind one: the row fields, the date field and the numeric value field the weekly grid pivots and edits | | **pageName** | `never` | optional | [REMOVED] `view.pageName` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — it named the page a `type: 'page'` view was to mount, and that mount was never built: no renderer read the key, so the named page was never reached and the view drew an empty grid. Delete the key; to put a published page in front of users, give the app a navigation item — `{ type: 'page', pageName: '' }` under the app's `navigation` — which is a different key on a different surface and is the page mount that has always rendered. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **description** | `string \| Record` | optional | View description for documentation/tooltips | | **sharing** | `{ lockedBy?: string }` | optional | View sharing configuration: who locked the view configuration | diff --git a/content/docs/references/index.mdx b/content/docs/references/index.mdx index d6c69c93bff..f704897084a 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 — 1669 schemas across 14 protocol modules +description: Every schema published by @objectstack/spec — 1670 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 | 297 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. | -| [UI Protocol](/docs/references/ui) | 16 | 177 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | -| **Total** | **218** | **1669** | 14 protocol modules | +| [UI Protocol](/docs/references/ui) | 16 | 178 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | +| **Total** | **218** | **1670** | 14 protocol modules | --- @@ -385,7 +385,7 @@ The runtime environment — logging, jobs, cache, metrics, notifications, i18n a ## UI Protocol -**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 177 schemas** +**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 178 schemas** Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. @@ -406,7 +406,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`, `ListChartConfig`, `ListColumn`, `ListMapConfig`, `ListView`, `NavigationConfig`, `NavigationMode`, `ObjectListView`, `ObjectUserFilters`, `PaginationConfig`, `RowColorConfig`, `RowHeight`, `SelectionConfig`, `TimelineConfig`, `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`, `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` | --- diff --git a/content/docs/references/system/migration.mdx b/content/docs/references/system/migration.mdx index 102c9953f41..78bfd1f989a 100644 --- a/content/docs/references/system/migration.mdx +++ b/content/docs/references/system/migration.mdx @@ -356,7 +356,7 @@ Create a new object | **relatedLists** | `string[]` | optional | Business order of this object's related lists on its record page, most important first. Each entry is a child object name (e.g. "task"), or object.field when that child has more than one relationship to this object (e.g. "event.related_to"). Listed relationships come first in this order; unlisted ones follow in the derived order (owned master_detail children, then lookup children). An entry whose child is in the stack but has no inbound lookup / master_detail field to this object is refused everywhere. An entry whose child exists nowhere is refused by os validate / os build (which leave a sys_ / cloud_ / ai_ name to the runtime) and by a metadata write that names no package; a write into a package stores it, since a child outside the package may be a downstream package's object that points here, and the record page places nothing for it. It orders only: relatedList: false on the relationship still hides a list, and relatedList: 'primary' still places a list in the record's body, so the order applies among the body tables and among the side cards. | | **stageField** | `string \| false` | optional | [ADR-0085] Lifecycle stage field (linear/ordered), or false to declare the status field non-linear and suppress stage heuristics. Absent = heuristic detection allowed. When the named field carries options, it must be a single-value `select` / `radio` with inline `options`, each declaring its `kind` ('open' / 'won' / 'lost'); a picklist-backed or multi-value stage field is refused. A name that resolves to no declared field, or a field with no options, is not judged at parse. | | **editMode** | `Enum<'modal' \| 'page'>` | optional | Edit-interaction intent for records of this object: 'modal' opens the edit form as a dialog over the current view; 'page' navigates to a dedicated full-page edit route. Absent = the renderer picks its own default (objectui defaults to modal). Cross-renderer intent, not pixel styling (family). | -| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | +| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | | **searchableFields** | `string[]` | optional | Fields the `$search` query matches against (ADR-0061). Canonical default for the record picker, list quick-search and global search; views may narrow it. When unset, search auto-defaults to the name/title field plus short-text fields. Entries must name a STORED column: a virtual `formula` field is computed on read and materializes no column, so searching it can never match and it is refused — mirror the value onto a stored text field and declare that. | | **enable** | `{ trackHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; apiMethods?: Enum<'get' \| 'list' \| 'create' \| 'update' \| 'delete' \| 'bulk'>[]; … }` | optional | Enabled system features modules | | **sharingModel** | `Enum<'private' \| 'public_read' \| 'public_read_write' \| 'controlled_by_parent'>` | optional | Org-Wide Default record visibility (OWD) for INTERNAL users. Canonical four only (legacy aliases removed, ADR-0090 D4): private (owner-only) \| public_read (everyone reads, owner writes) \| public_read_write (everyone reads+writes) \| controlled_by_parent (derived from the master record). A CUSTOM object that omits this resolves to private at runtime (ADR-0090 D1). | @@ -657,7 +657,7 @@ Create a new object | **relatedLists** | `string[]` | optional | Business order of this object's related lists on its record page, most important first. Each entry is a child object name (e.g. "task"), or object.field when that child has more than one relationship to this object (e.g. "event.related_to"). Listed relationships come first in this order; unlisted ones follow in the derived order (owned master_detail children, then lookup children). An entry whose child is in the stack but has no inbound lookup / master_detail field to this object is refused everywhere. An entry whose child exists nowhere is refused by os validate / os build (which leave a sys_ / cloud_ / ai_ name to the runtime) and by a metadata write that names no package; a write into a package stores it, since a child outside the package may be a downstream package's object that points here, and the record page places nothing for it. It orders only: relatedList: false on the relationship still hides a list, and relatedList: 'primary' still places a list in the record's body, so the order applies among the body tables and among the side cards. | | **stageField** | `string \| false` | optional | [ADR-0085] Lifecycle stage field (linear/ordered), or false to declare the status field non-linear and suppress stage heuristics. Absent = heuristic detection allowed. When the named field carries options, it must be a single-value `select` / `radio` with inline `options`, each declaring its `kind` ('open' / 'won' / 'lost'); a picklist-backed or multi-value stage field is refused. A name that resolves to no declared field, or a field with no options, is not judged at parse. | | **editMode** | `Enum<'modal' \| 'page'>` | optional | Edit-interaction intent for records of this object: 'modal' opens the edit form as a dialog over the current view; 'page' navigates to a dedicated full-page edit route. Absent = the renderer picks its own default (objectui defaults to modal). Cross-renderer intent, not pixel styling (family). | -| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | +| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | | **searchableFields** | `string[]` | optional | Fields the `$search` query matches against (ADR-0061). Canonical default for the record picker, list quick-search and global search; views may narrow it. When unset, search auto-defaults to the name/title field plus short-text fields. Entries must name a STORED column: a virtual `formula` field is computed on read and materializes no column, so searching it can never match and it is refused — mirror the value onto a stored text field and declare that. | | **enable** | `{ trackHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; apiMethods?: Enum<'get' \| 'list' \| 'create' \| 'update' \| 'delete' \| 'bulk'>[]; … }` | optional | Enabled system features modules | | **sharingModel** | `Enum<'private' \| 'public_read' \| 'public_read_write' \| 'controlled_by_parent'>` | optional | Org-Wide Default record visibility (OWD) for INTERNAL users. Canonical four only (legacy aliases removed, ADR-0090 D4): private (owner-only) \| public_read (everyone reads, owner writes) \| public_read_write (everyone reads+writes) \| controlled_by_parent (derived from the master record). A CUSTOM object that omits this resolves to private at runtime (ADR-0090 D1). | diff --git a/content/docs/references/ui/view.mdx b/content/docs/references/ui/view.mdx index 6d043ab1bbd..4ae5296e8f8 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, ListChartConfigSchema, ListColumnSchema, ListMapConfigSchema, ListViewSchema, NavigationConfigSchema, NavigationModeSchema, ObjectListViewSchema, ObjectUserFiltersSchema, PaginationConfigSchema, RowColorConfigSchema, RowHeightSchema, SelectionConfigSchema, TimelineConfigSchema, 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, ListChartConfig, ListColumn, ListMapConfig, ListView, NavigationConfig, NavigationMode, PaginationConfig, RowColorConfig, RowHeight, SelectionConfig, TimelineConfig, 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, 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, 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'; // Validate data const result = AddRecordConfigSchema.parse(data); @@ -777,7 +777,7 @@ Map view configuration | :--- | :--- | :--- | :--- | | **name** | `string` | optional | Internal view name (lowercase snake_case) | | **label** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | -| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>` | optional (default: `"grid"`) | | +| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree' \| 'timesheet'>` | optional (default: `"grid"`) | | | **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | | **columns** | `string[] \| { field: string; label?: string \| Record; width?: number; align?: Enum<'left' \| 'center' \| 'right'>; … }[]` | ✅ | Fields to display as columns — the PROJECTION of the per-view field composition `columns` x `hiddenFields` x `fieldOrder`: this list is the candidate set AND the baseline order; `hiddenFields` subtracts from it and `fieldOrder` orders what survives. `hiddenFields` and `fieldOrder` cannot add a field omitted here. An empty list declares no projection, so neither of them applies: which columns show is then left to the renderer (objectui's `ListView` grid derives the object's default columns). | | **filter** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Filter criteria (JSON Rules) | @@ -798,6 +798,7 @@ Map view configuration | **chart** | `{ chartType?: Enum<'bar' \| 'line' \| 'pie' \| 'area' \| 'scatter'>; dataset: string; dimensions?: string[]; values: string[] }` | optional | Chart binding — applies when the view renders as a chart. A `type: 'chart'` view must bind one: it names the ADR-0021 `dataset` and the measures (`values`) the chart plots, and there is no default binding | | **map** | `{ latitudeField?: string; longitudeField?: string; locationField?: string; titleField?: string; … }` | optional | Map configuration — applies when the view renders as a map layout | | **tree** | `{ parentField?: string; labelField?: string; fields?: string[]; defaultExpandedDepth?: integer }` | optional | Tree/hierarchy configuration — applies when the view renders as a tree layout | +| **timesheet** | `{ rowFields: string[]; dateField: string; valueField: string }` | optional | Timesheet binding — applies when the view renders as a timesheet. A `type: 'timesheet'` view must bind one: the row fields, the date field and the numeric value field the weekly grid pivots and edits | | **pageName** | `never` | optional | [REMOVED] `view.pageName` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — it named the page a `type: 'page'` view was to mount, and that mount was never built: no renderer read the key, so the named page was never reached and the view drew an empty grid. Delete the key; to put a published page in front of users, give the app a navigation item — `{ type: 'page', pageName: '' }` under the app's `navigation` — which is a different key on a different surface and is the page mount that has always rendered. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **description** | `string \| Record` | optional | View description for documentation/tooltips | | **sharing** | `{ lockedBy?: string }` | optional | View sharing configuration: who locked the view configuration | @@ -1022,6 +1023,14 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | **fields** | `string[]` | optional | Additional fields rendered as flat columns alongside the label | | **defaultExpandedDepth** | `integer` | optional | Initial expansion depth (0 = roots only; omit = expand all) | +### Nested Shape: `ListView.timesheet` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **rowFields** | `string[]` | ✅ | One to three fields whose values key a row (e.g. ["project", "task"]); a record's values for these fields place it on its row, and a new row's values are written onto each record it creates | +| **dateField** | `string` | ✅ | Date field placing a record on a day column; the renderer fetches only the records whose value falls in the displayed week | +| **valueField** | `string` | ✅ | Numeric field (number, currency or percent) a cell shows and edits; row, day and week totals sum it | + ### Nested Shape: `ListView.sharing` | Property | Type | Required | Description | @@ -1166,7 +1175,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | :--- | :--- | :--- | :--- | | **name** | `string` | optional | Internal view name (lowercase snake_case) | | **label** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | -| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>` | optional (default: `"grid"`) | | +| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree' \| 'timesheet'>` | optional (default: `"grid"`) | | | **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | | **columns** | `string[] \| { field: string; label?: string \| Record; width?: number; align?: Enum<'left' \| 'center' \| 'right'>; … }[]` | ✅ | Fields to display as columns — the PROJECTION of the per-view field composition `columns` x `hiddenFields` x `fieldOrder`: this list is the candidate set AND the baseline order; `hiddenFields` subtracts from it and `fieldOrder` orders what survives. `hiddenFields` and `fieldOrder` cannot add a field omitted here. An empty list declares no projection, so neither of them applies: which columns show is then left to the renderer (objectui's `ListView` grid derives the object's default columns). | | **filter** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Filter criteria (JSON Rules) | @@ -1186,6 +1195,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | **chart** | `{ chartType?: Enum<'bar' \| 'line' \| 'pie' \| 'area' \| 'scatter'>; dataset: string; dimensions?: string[]; values: string[] }` | optional | Chart binding — applies when the view renders as a chart. A `type: 'chart'` view must bind one: it names the ADR-0021 `dataset` and the measures (`values`) the chart plots, and there is no default binding | | **map** | `{ latitudeField?: string; longitudeField?: string; locationField?: string; titleField?: string; … }` | optional | Map configuration — applies when the view renders as a map layout | | **tree** | `{ parentField?: string; labelField?: string; fields?: string[]; defaultExpandedDepth?: integer }` | optional | Tree/hierarchy configuration — applies when the view renders as a tree layout | +| **timesheet** | `{ rowFields: string[]; dateField: string; valueField: string }` | optional | Timesheet binding — applies when the view renders as a timesheet. A `type: 'timesheet'` view must bind one: the row fields, the date field and the numeric value field the weekly grid pivots and edits | | **pageName** | `never` | optional | [REMOVED] `view.pageName` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — it named the page a `type: 'page'` view was to mount, and that mount was never built: no renderer read the key, so the named page was never reached and the view drew an empty grid. Delete the key; to put a published page in front of users, give the app a navigation item — `{ type: 'page', pageName: '' }` under the app's `navigation` — which is a different key on a different surface and is the page mount that has always rendered. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **description** | `string \| Record` | optional | View description for documentation/tooltips | | **sharing** | `{ lockedBy?: string }` | optional | View sharing configuration: who locked the view configuration | @@ -1401,6 +1411,14 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | **fields** | `string[]` | optional | Additional fields rendered as flat columns alongside the label | | **defaultExpandedDepth** | `integer` | optional | Initial expansion depth (0 = roots only; omit = expand all) | +### Nested Shape: `ObjectListView.timesheet` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **rowFields** | `string[]` | ✅ | One to three fields whose values key a row (e.g. ["project", "task"]); a record's values for these fields place it on its row, and a new row's values are written onto each record it creates | +| **dateField** | `string` | ✅ | Date field placing a record on a day column; the renderer fetches only the records whose value falls in the displayed week | +| **valueField** | `string` | ✅ | Numeric field (number, currency or percent) a cell shows and edits; row, day and week totals sum it | + ### Nested Shape: `ObjectListView.sharing` | Property | Type | Required | Description | @@ -1609,6 +1627,19 @@ Timeline view configuration | **scale** | `Enum<'hour' \| 'day' \| 'week' \| 'month' \| 'quarter' \| 'year'>` | optional (default: `"week"`) | Default timeline scale | +--- + +## TimesheetConfig + +### Properties + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **rowFields** | `string[]` | ✅ | One to three fields whose values key a row (e.g. ["project", "task"]); a record's values for these fields place it on its row, and a new row's values are written onto each record it creates | +| **dateField** | `string` | ✅ | Date field placing a record on a day column; the renderer fetches only the records whose value falls in the displayed week | +| **valueField** | `string` | ✅ | Numeric field (number, currency or percent) a cell shows and edits; row, day and week totals sum it | + + --- ## TreeConfig @@ -1729,9 +1760,9 @@ Tab configuration for multi-tab view interface | **name** | `string` | optional | Item name — supplied by the metadata door; for an object-scoped container it is the object name. | | **label** | `string \| Record` | optional | Human-readable label shown in metadata lists. | | **object** | `string` | optional | Object this container binds to — how a stack-level `views: [...]` entry says which object its views belong to; read by `getViewsByObject()` / `GET /meta/view?object=`. | -| **list** | `{ name?: string; label?: string \| Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>; data?: object \| object \| object; … }` | optional | | +| **list** | `{ name?: string; label?: string \| Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }` | optional | | | **form** | `{ type?: Enum<'simple' \| 'tabbed' \| 'wizard'>; layout?: Enum<'vertical' \| 'horizontal'>; columns?: integer; title?: string; … }` | optional | | -| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>; data?: object \| object \| object; … }>` | optional | Additional named list views (views mode — dropdown userFilters allowed, no tabs; ADR-0047) | +| **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }>` | optional | Additional named list views (views mode — dropdown userFilters allowed, no tabs; ADR-0047) | | **formViews** | `Record; layout?: Enum<'vertical' \| 'horizontal'>; columns?: integer; title?: string; … }>` | optional | Additional named form views | | **protection** | `{ lock: Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>; reason: string; docsUrl?: string }` | optional | Package author protection block — lock policy for this view. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | @@ -1748,7 +1779,7 @@ Tab configuration for multi-tab view interface | :--- | :--- | :--- | :--- | | **name** | `string` | optional | Internal view name (lowercase snake_case) | | **label** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | -| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>` | optional (default: `"grid"`) | | +| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>` | optional (default: `"grid"`) | | | **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | | **columns** | `string[] \| { field: string; label?: string \| Record; width?: number; align?: Enum<'left' \| 'center' \| 'right'>; … }[]` | ✅ | Fields to display as columns — the PROJECTION of the per-view field composition `columns` x `hiddenFields` x `fieldOrder`: this list is the candidate set AND the baseline order; `hiddenFields` subtracts from it and `fieldOrder` orders what survives. `hiddenFields` and `fieldOrder` cannot add a field omitted here. An empty list declares no projection, so neither of them applies: which columns show is then left to the renderer (objectui's `ListView` grid derives the object's default columns). | | **filter** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Filter criteria (JSON Rules) | @@ -1768,6 +1799,7 @@ Tab configuration for multi-tab view interface | **chart** | `{ chartType?: Enum<'bar' \| 'line' \| 'pie' \| 'area' \| 'scatter'>; dataset: string; dimensions?: string[]; values: string[] }` | optional | Chart binding — applies when the view renders as a chart. A `type: 'chart'` view must bind one: it names the ADR-0021 `dataset` and the measures (`values`) the chart plots, and there is no default binding | | **map** | `{ latitudeField?: string; longitudeField?: string; locationField?: string; titleField?: string; … }` | optional | Map configuration — applies when the view renders as a map layout | | **tree** | `{ parentField?: string; labelField?: string; fields?: string[]; defaultExpandedDepth?: integer }` | optional | Tree/hierarchy configuration — applies when the view renders as a tree layout | +| **timesheet** | `{ rowFields: string[]; dateField: string; valueField: string }` | optional | Timesheet binding — applies when the view renders as a timesheet. A `type: 'timesheet'` view must bind one: the row fields, the date field and the numeric value field the weekly grid pivots and edits | | **pageName** | `never` | optional | [REMOVED] `view.pageName` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — it named the page a `type: 'page'` view was to mount, and that mount was never built: no renderer read the key, so the named page was never reached and the view drew an empty grid. Delete the key; to put a published page in front of users, give the app a navigation item — `{ type: 'page', pageName: '' }` under the app's `navigation` — which is a different key on a different surface and is the page mount that has always rendered. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **description** | `string \| Record` | optional | View description for documentation/tooltips | | **sharing** | `{ lockedBy?: string }` | optional | View sharing configuration: who locked the view configuration | @@ -1827,7 +1859,7 @@ Tab configuration for multi-tab view interface | :--- | :--- | :--- | :--- | | **name** | `string` | optional | Internal view name (lowercase snake_case) | | **label** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | -| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>` | optional (default: `"grid"`) | | +| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>` | optional (default: `"grid"`) | | | **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | | **columns** | `string[] \| { field: string; label?: string \| Record; width?: number; align?: Enum<'left' \| 'center' \| 'right'>; … }[]` | ✅ | Fields to display as columns — the PROJECTION of the per-view field composition `columns` x `hiddenFields` x `fieldOrder`: this list is the candidate set AND the baseline order; `hiddenFields` subtracts from it and `fieldOrder` orders what survives. `hiddenFields` and `fieldOrder` cannot add a field omitted here. An empty list declares no projection, so neither of them applies: which columns show is then left to the renderer (objectui's `ListView` grid derives the object's default columns). | | **filter** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Filter criteria (JSON Rules) | @@ -1847,6 +1879,7 @@ Tab configuration for multi-tab view interface | **chart** | `{ chartType?: Enum<'bar' \| 'line' \| 'pie' \| 'area' \| 'scatter'>; dataset: string; dimensions?: string[]; values: string[] }` | optional | Chart binding — applies when the view renders as a chart. A `type: 'chart'` view must bind one: it names the ADR-0021 `dataset` and the measures (`values`) the chart plots, and there is no default binding | | **map** | `{ latitudeField?: string; longitudeField?: string; locationField?: string; titleField?: string; … }` | optional | Map configuration — applies when the view renders as a map layout | | **tree** | `{ parentField?: string; labelField?: string; fields?: string[]; defaultExpandedDepth?: integer }` | optional | Tree/hierarchy configuration — applies when the view renders as a tree layout | +| **timesheet** | `{ rowFields: string[]; dateField: string; valueField: string }` | optional | Timesheet binding — applies when the view renders as a timesheet. A `type: 'timesheet'` view must bind one: the row fields, the date field and the numeric value field the weekly grid pivots and edits | | **pageName** | `never` | optional | [REMOVED] `view.pageName` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — it named the page a `type: 'page'` view was to mount, and that mount was never built: no renderer read the key, so the named page was never reached and the view drew an empty grid. Delete the key; to put a published page in front of users, give the app a navigation item — `{ type: 'page', pageName: '' }` under the app's `navigation` — which is a different key on a different surface and is the page mount that has always rendered. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **description** | `string \| Record` | optional | View description for documentation/tooltips | | **sharing** | `{ lockedBy?: string }` | optional | View sharing configuration: who locked the view configuration | @@ -2098,7 +2131,7 @@ This schema accepts one of the following structures: | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **viewKind** | `'list'` | ✅ | | -| **config** | `{ name?: string; label?: string \| Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>; data?: object \| object \| object; … }` | ✅ | List-family view configuration. | +| **config** | `{ name?: string; label?: string \| Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }` | ✅ | List-family view configuration. | | **name** | `string` | ✅ | Globally-unique view id, `.`. | | **object** | `string` | ✅ | Bound object name — the foreign key used to aggregate views. | | **label** | `string \| Record` | optional | Display label (supports i18n). | @@ -2123,7 +2156,7 @@ This schema accepts one of the following structures: | :--- | :--- | :--- | :--- | | **name** | `string` | optional | Internal view name (lowercase snake_case) | | **label** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | -| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>` | optional (default: `"grid"`) | | +| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>` | optional (default: `"grid"`) | | | **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | | **columns** | `string[] \| { field: string; label?: string \| Record; width?: number; align?: Enum<'left' \| 'center' \| 'right'>; … }[]` | ✅ | Fields to display as columns — the PROJECTION of the per-view field composition `columns` x `hiddenFields` x `fieldOrder`: this list is the candidate set AND the baseline order; `hiddenFields` subtracts from it and `fieldOrder` orders what survives. `hiddenFields` and `fieldOrder` cannot add a field omitted here. An empty list declares no projection, so neither of them applies: which columns show is then left to the renderer (objectui's `ListView` grid derives the object's default columns). | | **filter** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Filter criteria (JSON Rules) | @@ -2144,6 +2177,7 @@ This schema accepts one of the following structures: | **chart** | `{ chartType?: Enum<'bar' \| 'line' \| 'pie' \| 'area' \| 'scatter'>; dataset: string; dimensions?: string[]; values: string[] }` | optional | Chart binding — applies when the view renders as a chart. A `type: 'chart'` view must bind one: it names the ADR-0021 `dataset` and the measures (`values`) the chart plots, and there is no default binding | | **map** | `{ latitudeField?: string; longitudeField?: string; locationField?: string; titleField?: string; … }` | optional | Map configuration — applies when the view renders as a map layout | | **tree** | `{ parentField?: string; labelField?: string; fields?: string[]; defaultExpandedDepth?: integer }` | optional | Tree/hierarchy configuration — applies when the view renders as a tree layout | +| **timesheet** | `{ rowFields: string[]; dateField: string; valueField: string }` | optional | Timesheet binding — applies when the view renders as a timesheet. A `type: 'timesheet'` view must bind one: the row fields, the date field and the numeric value field the weekly grid pivots and edits | | **pageName** | `never` | optional | [REMOVED] `view.pageName` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — it named the page a `type: 'page'` view was to mount, and that mount was never built: no renderer read the key, so the named page was never reached and the view drew an empty grid. Delete the key; to put a published page in front of users, give the app a navigation item — `{ type: 'page', pageName: '' }` under the app's `navigation` — which is a different key on a different surface and is the page mount that has always rendered. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **description** | `string \| Record` | optional | View description for documentation/tooltips | | **sharing** | `{ lockedBy?: string }` | optional | View sharing configuration: who locked the view configuration | @@ -2281,7 +2315,7 @@ This schema accepts one of the following structures: | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **viewKind** | `'list'` | ✅ | | -| **config** | `{ name?: string; label?: string \| Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>; data?: object \| object \| object; … }` | ✅ | List-family view configuration. | +| **config** | `{ name?: string; label?: string \| Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }` | ✅ | List-family view configuration. | | **name** | `string` | ✅ | Globally-unique view id, `.`. | | **object** | `string` | ✅ | Bound object name — the foreign key used to aggregate views. | | **label** | `string \| Record` | optional | Display label (supports i18n). | @@ -2311,7 +2345,7 @@ This schema accepts one of the following structures: | :--- | :--- | :--- | :--- | | **name** | `string` | optional | Internal view name (lowercase snake_case) | | **label** | `string \| Record` | optional | Display label — the default-language string, or an inline locale map (`{ en, "zh-CN" }`) resolved at render time | -| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>` | optional (default: `"grid"`) | | +| **type** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>` | optional (default: `"grid"`) | | | **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | | **columns** | `string[] \| { field: string; label?: string \| Record; width?: number; align?: Enum<'left' \| 'center' \| 'right'>; … }[]` | ✅ | Fields to display as columns — the PROJECTION of the per-view field composition `columns` x `hiddenFields` x `fieldOrder`: this list is the candidate set AND the baseline order; `hiddenFields` subtracts from it and `fieldOrder` orders what survives. `hiddenFields` and `fieldOrder` cannot add a field omitted here. An empty list declares no projection, so neither of them applies: which columns show is then left to the renderer (objectui's `ListView` grid derives the object's default columns). | | **filter** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Filter criteria (JSON Rules) | @@ -2332,6 +2366,7 @@ This schema accepts one of the following structures: | **chart** | `{ chartType?: Enum<'bar' \| 'line' \| 'pie' \| 'area' \| 'scatter'>; dataset: string; dimensions?: string[]; values: string[] }` | optional | Chart binding — applies when the view renders as a chart. A `type: 'chart'` view must bind one: it names the ADR-0021 `dataset` and the measures (`values`) the chart plots, and there is no default binding | | **map** | `{ latitudeField?: string; longitudeField?: string; locationField?: string; titleField?: string; … }` | optional | Map configuration — applies when the view renders as a map layout | | **tree** | `{ parentField?: string; labelField?: string; fields?: string[]; defaultExpandedDepth?: integer }` | optional | Tree/hierarchy configuration — applies when the view renders as a tree layout | +| **timesheet** | `{ rowFields: string[]; dateField: string; valueField: string }` | optional | Timesheet binding — applies when the view renders as a timesheet. A `type: 'timesheet'` view must bind one: the row fields, the date field and the numeric value field the weekly grid pivots and edits | | **pageName** | `never` | optional | [REMOVED] `view.pageName` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — it named the page a `type: 'page'` view was to mount, and that mount was never built: no renderer read the key, so the named page was never reached and the view drew an empty grid. Delete the key; to put a published page in front of users, give the app a navigation item — `{ type: 'page', pageName: '' }` under the app's `navigation` — which is a different key on a different surface and is the page mount that has always rendered. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **description** | `string \| Record` | optional | View description for documentation/tooltips | | **sharing** | `{ lockedBy?: string }` | optional | View sharing configuration: who locked the view configuration | diff --git a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md index bd14a2b1cdd..5cbe68fcbb7 100644 --- a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md +++ b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md @@ -21,7 +21,7 @@ The `strict` column is the one the campaign schedules against; it counts both th | Dir | Sites | strict | passthrough | catchall | strip | |---|---|---|---|---|---| -| `ui/` | 224 | 213 | 6 | 0 | 5 | +| `ui/` | 225 | 214 | 6 | 0 | 5 | ## `ui/` — sites @@ -44,9 +44,9 @@ classify and is not listed (it becomes reportable the day it grows its first sit | `report.zod.ts` | 4 | | `responsive.zod.ts` | 1 | | `sharing.zod.ts` | 1 | -| `view.zod.ts` | 59 | +| `view.zod.ts` | 60 | | `widget.zod.ts` | 1 | -| **total** | **224** | +| **total** | **225** | ## `ui/` — open @@ -54,15 +54,15 @@ Per file, how many of its sites still silently discard unknown keys. The `Class` column that decides the bucket split is hand-written in the ledger; the arithmetic over it is here. -**5 strip of 224**, in 4 file(s). +**5 strip of 225**, in 4 file(s). | File | Strip | Sites | |---|---|---| | `action-params.zod.ts` | 1 | 1 | | `app.zod.ts` | 1 | 20 | -| `view.zod.ts` | 2 | 59 | +| `view.zod.ts` | 2 | 60 | | `widget.zod.ts` | 1 | 1 | -| **total** | **5** | **224** | +| **total** | **5** | **225** | | Bucket | Sites | |---|---| diff --git a/packages/spec/api-surface/ui.json b/packages/spec/api-surface/ui.json index 929a8063a33..5de7c859b00 100644 --- a/packages/spec/api-surface/ui.json +++ b/packages/spec/api-surface/ui.json @@ -451,6 +451,8 @@ "TimelineConfig (type)", "TimelineConfigParsed (type)", "TimelineConfigSchema (const)", + "TimesheetConfig (type)", + "TimesheetConfigSchema (const)", "TreeConfig (type)", "TreeConfigSchema (const)", "UNMAPPED_COLUMN_SUMMARIES (const)", diff --git a/packages/spec/authorable-surface/ui.json b/packages/spec/authorable-surface/ui.json index 4adf3548c7a..b88629c064b 100644 --- a/packages/spec/authorable-surface/ui.json +++ b/packages/spec/authorable-surface/ui.json @@ -784,6 +784,7 @@ "ui/ListView:sort", "ui/ListView:tabs [RETIRED]", "ui/ListView:timeline", + "ui/ListView:timesheet", "ui/ListView:tree", "ui/ListView:type", "ui/ListView:userActions", @@ -966,6 +967,7 @@ "ui/ObjectListView:sort", "ui/ObjectListView:tabs [RETIRED]", "ui/ObjectListView:timeline", + "ui/ObjectListView:timesheet", "ui/ObjectListView:tree", "ui/ObjectListView:type", "ui/ObjectListView:userActions", @@ -1328,6 +1330,9 @@ "ui/TimelineConfig:scale", "ui/TimelineConfig:startDateField", "ui/TimelineConfig:titleField", + "ui/TimesheetConfig:dateField", + "ui/TimesheetConfig:rowFields", + "ui/TimesheetConfig:valueField", "ui/TreeConfig:defaultExpandedDepth", "ui/TreeConfig:fields", "ui/TreeConfig:labelField", diff --git a/packages/spec/declaration-map/ui.json b/packages/spec/declaration-map/ui.json index 2a31b911e0a..c9677200761 100644 --- a/packages/spec/declaration-map/ui.json +++ b/packages/spec/declaration-map/ui.json @@ -280,6 +280,8 @@ "StyleMapSchema": "ui/StyleMap", "TimelineConfig": "ui/TimelineConfig", "TimelineConfigSchema": "ui/TimelineConfig", + "TimesheetConfig": "ui/TimesheetConfig", + "TimesheetConfigSchema": "ui/TimesheetConfig", "TreeConfig": "ui/TreeConfig", "TreeConfigSchema": "ui/TreeConfig", "UrlNavItem": "ui/UrlNavItem", diff --git a/packages/spec/export-origins/ui.json b/packages/spec/export-origins/ui.json index f7675b375c4..2c75dd24fb7 100644 --- a/packages/spec/export-origins/ui.json +++ b/packages/spec/export-origins/ui.json @@ -434,6 +434,8 @@ "TimelineConfig": "src/ui/view.zod.ts#TimelineConfig (type)", "TimelineConfigParsed": "src/ui/view.zod.ts#TimelineConfigParsed (type)", "TimelineConfigSchema": "src/ui/view.zod.ts#TimelineConfigSchema (const)", + "TimesheetConfig": "src/ui/view.zod.ts#TimesheetConfig (type)", + "TimesheetConfigSchema": "src/ui/view.zod.ts#TimesheetConfigSchema (const)", "TreeConfig": "src/ui/view.zod.ts#TreeConfig (type)", "TreeConfigSchema": "src/ui/view.zod.ts#TreeConfigSchema (const)", "UNMAPPED_COLUMN_SUMMARIES": "src/ui/view-grouping-query.ts#UNMAPPED_COLUMN_SUMMARIES (const)", diff --git a/packages/spec/json-schema.manifest/ui.json b/packages/spec/json-schema.manifest/ui.json index a8f2ad41ff1..6ed37637412 100644 --- a/packages/spec/json-schema.manifest/ui.json +++ b/packages/spec/json-schema.manifest/ui.json @@ -159,6 +159,7 @@ "ui/SharingConfig", "ui/StyleMap", "ui/TimelineConfig", + "ui/TimesheetConfig", "ui/TreeConfig", "ui/UrlNavItem", "ui/UserActionsConfig", diff --git a/packages/spec/liveness/state-counts/view.md b/packages/spec/liveness/state-counts/view.md index a040c094b70..1fad8a6ef1f 100644 --- a/packages/spec/liveness/state-counts/view.md +++ b/packages/spec/liveness/state-counts/view.md @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them. | Type | live | exp | elsewhere | dead | planned | classified | |---|---|---|---|---|---|---| -| `view` | 73 | 0 | 0 | 10 | 0 | 83 | +| `view` | 74 | 0 | 0 | 10 | 0 | 84 | diff --git a/packages/spec/liveness/view.json b/packages/spec/liveness/view.json index 4555de4879c..14e87a6c9b4 100644 --- a/packages/spec/liveness/view.json +++ b/packages/spec/liveness/view.json @@ -130,7 +130,24 @@ "timesheet": { "status": "live", "evidenceScope": "in-repo", - "evidence": "ui/packages/plugin-list/src/ListView.tsx `case 'timesheet'` forwards the view's `timesheet` block into an `object-timesheet` node; ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx `resolveTimesheetConfig` reads `rowFields` (row key and the values written onto a created record), `dateField` (the week-window filter and the day column) and `valueField` (the cell value, each per-cell create/update/delete, and the totals), and renders the \"Timesheet configuration required\" refusal when any of the three is missing. Pinned by ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx." + "evidence": "ui/packages/plugin-list/src/ListView.tsx `case 'timesheet'` forwards the view's `timesheet` block into an `object-timesheet` node; ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx `resolveTimesheetConfig` reads `rowFields` (row key and the values written onto a created record), `dateField` (the week-window filter and the day column) and `valueField` (the cell value, each per-cell create/update/delete, and the totals), and renders the \"Timesheet configuration required\" refusal when any of the three is missing. Pinned by ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx.", + "children": { + "rowFields": { + "status": "live", + "evidenceScope": "in-repo", + "evidence": "ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx `resolveTimesheetConfig` reads `rowFields`; `buildTimesheetRows` keys each row on the records' values for these fields, and a created record carries the row's values for them." + }, + "dateField": { + "status": "live", + "evidenceScope": "in-repo", + "evidence": "ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx `resolveTimesheetConfig` reads `dateField`; the fetch filters it to the displayed week and `buildTimesheetRows` places each record on its day column." + }, + "valueField": { + "status": "live", + "evidenceScope": "in-repo", + "evidence": "ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx `resolveTimesheetConfig` reads `valueField`; each cell shows and writes it (create, update, or delete on a cleared cell) and the row, day and week totals sum it." + } + } }, "pageName": { "status": "dead", diff --git a/scripts/regen-artifacts.mjs b/scripts/regen-artifacts.mjs index 52acaf45002..6337ff54237 100644 --- a/scripts/regen-artifacts.mjs +++ b/scripts/regen-artifacts.mjs @@ -957,6 +957,18 @@ export const NOT_DRIVER_MANAGED = Object.freeze([ + 'target. Line-aligned with its source, so a conflict is resolved by taking either side and ' + 'running `pnpm --filter @object-ui/i18n gen:zh-hant`.', }, + // The timesheet namespace's Traditional Chinese catalogue, same command. + { + path: 'ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts', + gen: 'gen:zh-hant', + owner: '@object-ui/i18n', + why: + 'generated WHOLE from the namespace\'s `zh-Hans.ts` by the same `gen:zh-hant` run that writes ' + + 'the pack, and not routed for the same reason as the marketplace catalogue above: no `check:` ' + + 'script proves its currency. The proof is the same package test, which walks every generated ' + + 'target. Line-aligned with its source, so a conflict is resolved by taking either side and ' + + 'running `pnpm --filter @object-ui/i18n gen:zh-hant`.', + }, ]); /** Marker file (inside the git dir, never the worktree) listing paths the driver deferred. */ diff --git a/skills/objectstack-ui/references/react-blocks.md b/skills/objectstack-ui/references/react-blocks.md index 9ec87202440..472d8e6c7c6 100644 --- a/skills/objectstack-ui/references/react-blocks.md +++ b/skills/objectstack-ui/references/react-blocks.md @@ -64,7 +64,7 @@ Server-connected object table with toolbar and switchable visualizations (grid/k | `onRowClick` | `(record) => void` | callback | | Called with the clicked row's record — the hook for master/detail. | | `onNavigate` | `(recordId, action: 'view' \| 'new_window') => void` | callback | | Called for page-level navigation. The second argument is a navigation-MODE token from a CLOSED vocabulary — 'view' opens the record page, 'new_window' opens it in a new browser tab; the reference implementation emits no other value and reads no other branch. | | `columns` | `string[] \| object[]` | data | ✓ | Fields to display as columns — the PROJECTION of the per-view field composition `columns` x `hiddenFields` x `fieldOrder`: this list is the candidate set AND t… | -| `type` | `'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'` | data | | | +| `type` | `'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree' \| 'timesheet'` | data | | | | `sort` | `object[]` | data | | | | `searchableFields` | `string[]` | data | | Fields enabled for search | | `userFilters` | `object` | data | | End-user quick-filter bar: dropdown/toggle fields or tab presets. Omit to let the renderer derive filters from select/boolean fields | diff --git a/ui/apps/console/vite.config.ts b/ui/apps/console/vite.config.ts index 42c624ba3e2..bfd612ae2b5 100644 --- a/ui/apps/console/vite.config.ts +++ b/ui/apps/console/vite.config.ts @@ -1313,6 +1313,22 @@ export default defineConfig({ { name: 'i18n-ns-developer-ja', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]developer[\\/]ja\.ts$/, priority: 84 }, { name: 'i18n-ns-developer-ko', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]developer[\\/]ko\.ts$/, priority: 84 }, // + // The `timesheet` namespace: `timesheet.*`, the timesheet list view's strings, + // never in the packs. Every catalogue is `import()`ed by + // `packages/i18n/src/namespaces/timesheet/index.ts` when a timesheet view + // mounts, one group per catalogue; the loader rides `plugin-timesheet`'s lazy chunk. + { name: 'i18n-ns-timesheet-en', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]en\.ts$/, priority: 84 }, + { name: 'i18n-ns-timesheet-zh-Hans', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]zh-Hans\.ts$/, priority: 84 }, + { name: 'i18n-ns-timesheet-zh-Hant', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]zh-Hant\.ts$/, priority: 84 }, + { name: 'i18n-ns-timesheet-es', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]es\.ts$/, priority: 84 }, + { name: 'i18n-ns-timesheet-ar', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]ar\.ts$/, priority: 84 }, + { name: 'i18n-ns-timesheet-fr', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]fr\.ts$/, priority: 84 }, + { name: 'i18n-ns-timesheet-pt-BR', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]pt-BR\.ts$/, priority: 84 }, + { name: 'i18n-ns-timesheet-ru', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]ru\.ts$/, priority: 84 }, + { name: 'i18n-ns-timesheet-de', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]de\.ts$/, priority: 84 }, + { name: 'i18n-ns-timesheet-ja', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]ja\.ts$/, priority: 84 }, + { name: 'i18n-ns-timesheet-ko', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]timesheet[\\/]ko\.ts$/, priority: 84 }, + // // ⛔ `i18n-runtime` takes `includeDependenciesRecursively: false` // for the reason `data-adapter` below does (objectui#9345, read out // there in full): it outranks `framework` (83 over 80), and since diff --git a/ui/packages/i18n/package.json b/ui/packages/i18n/package.json index c9e0af829a9..ff01b3479db 100644 --- a/ui/packages/i18n/package.json +++ b/ui/packages/i18n/package.json @@ -47,6 +47,11 @@ "types": "./dist/namespaces/developer/index.d.ts", "import": "./dist/namespaces/developer/index.js", "default": "./dist/namespaces/developer/index.js" + }, + "./namespaces/timesheet": { + "types": "./dist/namespaces/timesheet/index.d.ts", + "import": "./dist/namespaces/timesheet/index.js", + "default": "./dist/namespaces/timesheet/index.js" } }, "scripts": { diff --git a/ui/packages/i18n/scripts/zh-hant.mjs b/ui/packages/i18n/scripts/zh-hant.mjs index d913530158c..c4f83a7b5e8 100644 --- a/ui/packages/i18n/scripts/zh-hant.mjs +++ b/ui/packages/i18n/scripts/zh-hant.mjs @@ -433,4 +433,9 @@ export const ZH_HANT_TARGETS = Object.freeze([ target: 'src/namespaces/developer/zh-Hant.ts', generate: generateZhHantNamespaceCatalogue, }), + Object.freeze({ + source: 'src/namespaces/timesheet/zh-Hans.ts', + target: 'src/namespaces/timesheet/zh-Hant.ts', + generate: generateZhHantNamespaceCatalogue, + }), ]); diff --git a/ui/packages/i18n/src/__tests__/timesheet-namespace.test.ts b/ui/packages/i18n/src/__tests__/timesheet-namespace.test.ts new file mode 100644 index 00000000000..c990c1f45a7 --- /dev/null +++ b/ui/packages/i18n/src/__tests__/timesheet-namespace.test.ts @@ -0,0 +1,158 @@ +/** + * The `timesheet` namespace: its shape, and how it sits beside the packs — the + * properties `developer-namespace.test.ts` holds for the `developer` namespace. + * + * 1. LAZY BY CONSTRUCTION. `namespaces/timesheet/index.ts` reaches its + * catalogues through one literal `import()` each and nothing else, so each + * is a chunk of its own and none is in the console's first load. + * 2. KEPT OUT OF THE PACKS. Every catalogue holds exactly the `timesheet` + * group, and no pack holds it. + * 3. THE ALL-PACKS DOOR IS COMPLETE. `locales/index.ts` hands out each + * language as its pack merged with its catalogue; the package entry's + * `en` is the resident pack alone. + * 4. THE LOADER refuses a language it ships nothing for and memoises a load. + */ +import { describe, expect, it } from 'vitest'; +import { readFileSync } from 'node:fs'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import ts from 'typescript'; + +import { en as entryEn } from '../index.js'; +import { BUILT_IN_LANGUAGE_CODES } from '../locales/registry.js'; +import { builtInLocales } from '../locales/index.js'; +import enPack from '../locales/en.js'; +import zhHansPack from '../locales/zh-Hans.js'; +import zhHantPack from '../locales/zh-Hant.js'; +import jaPack from '../locales/ja.js'; +import koPack from '../locales/ko.js'; +import dePack from '../locales/de.js'; +import frPack from '../locales/fr.js'; +import esPack from '../locales/es.js'; +import ptBrPack from '../locales/pt-BR.js'; +import ruPack from '../locales/ru.js'; +import arPack from '../locales/ar.js'; +import enNs from '../namespaces/timesheet/en.js'; +import zhHansNs from '../namespaces/timesheet/zh-Hans.js'; +import zhHantNs from '../namespaces/timesheet/zh-Hant.js'; +import jaNs from '../namespaces/timesheet/ja.js'; +import koNs from '../namespaces/timesheet/ko.js'; +import deNs from '../namespaces/timesheet/de.js'; +import frNs from '../namespaces/timesheet/fr.js'; +import esNs from '../namespaces/timesheet/es.js'; +import ptBrNs from '../namespaces/timesheet/pt-BR.js'; +import ruNs from '../namespaces/timesheet/ru.js'; +import arNs from '../namespaces/timesheet/ar.js'; +import { + TIMESHEET_LANGUAGE_CODES, + TIMESHEET_NAMESPACE, + TIMESHEET_NAMESPACE_PROBE_KEY, + isTimesheetCatalogueLoaded, + loadTimesheetCatalogue, +} from '../namespaces/timesheet/index.js'; + +const HERE = dirname(fileURLToPath(import.meta.url)); +const INDEX_PATH = join(HERE, '..', 'namespaces', 'timesheet', 'index.ts'); + +type Tree = Record; +const PACKS: Record = { + en: enPack, 'zh-Hans': zhHansPack, 'zh-Hant': zhHantPack, ja: jaPack, ko: koPack, de: dePack, + fr: frPack, es: esPack, 'pt-BR': ptBrPack, ru: ruPack, ar: arPack, +}; +const CATALOGUES: Record = { + en: enNs, 'zh-Hans': zhHansNs, 'zh-Hant': zhHantNs, ja: jaNs, ko: koNs, de: deNs, + fr: frNs, es: esNs, 'pt-BR': ptBrNs, ru: ruNs, ar: arNs, +}; + +function leaves(node: unknown, prefix = ''): string[] { + if (typeof node !== 'object' || node === null) return [prefix]; + return Object.entries(node).flatMap(([k, v]) => leaves(v, prefix ? `${prefix}.${k}` : k)); +} + +function lookup(tree: unknown, path: string): unknown { + let node: unknown = tree; + for (const segment of path.split('.')) { + if (typeof node !== 'object' || node === null || !Object.prototype.hasOwnProperty.call(node, segment)) return undefined; + node = (node as Tree)[segment]; + } + return node; +} + +describe('timesheet namespace — lazy by construction', () => { + const source = readFileSync(INDEX_PATH, 'utf8'); + const file = ts.createSourceFile('index.ts', source, ts.ScriptTarget.Latest, true); + const staticSpecifiers: string[] = []; + const dynamicSpecifiers: string[] = []; + const nonLiteralImports: string[] = []; + const visit = (node: ts.Node) => { + if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) { + staticSpecifiers.push(node.moduleSpecifier.text); + } else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) { + const arg = node.arguments[0]; + if (arg && ts.isStringLiteral(arg)) dynamicSpecifiers.push(arg.text); + else nonLiteralImports.push(node.getText(file)); + } + ts.forEachChild(node, visit); + }; + visit(file); + + it('imports one literal `import()` per catalogue, one catalogue per built-in language', () => { + expect([...dynamicSpecifiers].sort()).toEqual(BUILT_IN_LANGUAGE_CODES.map((code) => `./${code}.js`).sort()); + expect(nonLiteralImports).toEqual([]); + }); + + it('statically imports no catalogue, and builds on the one pack-namespace loader', () => { + expect(staticSpecifiers.filter((s) => /^\.\/[a-z]{2}(?:-[A-Za-z]+)?\.js$/.test(s))).toEqual([]); + // Lit control, and the "no second loader" half: the runtime is the shared one. + expect(staticSpecifiers).toContain('../packNamespace.js'); + }); + + it('ships one catalogue per built-in language (the platform locale table)', () => { + expect([...TIMESHEET_LANGUAGE_CODES].sort()).toEqual([...BUILT_IN_LANGUAGE_CODES].sort()); + }); +}); + +describe('timesheet namespace — kept out of the packs', () => { + it.each(BUILT_IN_LANGUAGE_CODES.map((code) => [code]))('%s: the catalogue holds the timesheet group only', (code) => { + const catalogue = CATALOGUES[code]; + expect(Object.keys(catalogue)).toEqual([TIMESHEET_NAMESPACE]); + expect(typeof lookup(catalogue, TIMESHEET_NAMESPACE_PROBE_KEY)).toBe('string'); + }); + + it.each(BUILT_IN_LANGUAGE_CODES.map((code) => [code]))('%s: no pack holds the group', (code) => { + expect(lookup(PACKS[code], TIMESHEET_NAMESPACE)).toBeUndefined(); + // Lit control: the pack itself is there. + expect(typeof lookup(PACKS[code], 'console.errors.tryAgain')).toBe('string'); + }); + + it.each(BUILT_IN_LANGUAGE_CODES.map((code) => [code]))('%s: the same leaves as the en catalogue', (code) => { + expect(leaves(CATALOGUES[code]).sort()).toEqual(leaves(enNs).sort()); + }); +}); + +describe('timesheet namespace — the all-packs door hands out complete languages', () => { + it.each(BUILT_IN_LANGUAGE_CODES.map((code) => [code]))('%s: pack keys and namespace keys are both there', (code) => { + const complete = (builtInLocales as unknown as Record)[code]; + expect(lookup(complete, TIMESHEET_NAMESPACE)).toEqual(lookup(CATALOGUES[code], TIMESHEET_NAMESPACE)); + expect(lookup(complete, 'console.errors.tryAgain')).toBe(lookup(PACKS[code], 'console.errors.tryAgain')); + }); + + it("the package entry's `en` is the resident pack alone", () => { + expect(lookup(entryEn, TIMESHEET_NAMESPACE_PROBE_KEY)).toBeUndefined(); + expect(typeof lookup(entryEn, 'console.errors.somethingWentWrong')).toBe('string'); + }); +}); + +describe('timesheet namespace — the loader', () => { + it('refuses a code it ships no catalogue for', async () => { + await expect(loadTimesheetCatalogue('tlh')).rejects.toThrow(/timesheet namespace ships no `tlh` catalogue/); + expect(isTimesheetCatalogueLoaded('tlh')).toBe(false); + }); + + it('loads a catalogue once and answers the same object after', async () => { + const first = await loadTimesheetCatalogue('fr'); + expect(lookup(first, TIMESHEET_NAMESPACE_PROBE_KEY)).toBe(lookup(frNs, TIMESHEET_NAMESPACE_PROBE_KEY)); + expect(isTimesheetCatalogueLoaded('fr')).toBe(true); + await expect(loadTimesheetCatalogue('fr')).resolves.toBe(first); + }); +}); diff --git a/ui/packages/i18n/src/__tests__/zh-hant-generated.test.ts b/ui/packages/i18n/src/__tests__/zh-hant-generated.test.ts index 8ecb795319c..8f22a1718ab 100644 --- a/ui/packages/i18n/src/__tests__/zh-hant-generated.test.ts +++ b/ui/packages/i18n/src/__tests__/zh-hant-generated.test.ts @@ -59,6 +59,7 @@ describe('every zh-Hant catalogue is generated, and current', () => { 'src/locales/zh-Hant.ts', 'src/namespaces/marketplace/zh-Hant.ts', 'src/namespaces/developer/zh-Hant.ts', + 'src/namespaces/timesheet/zh-Hant.ts', ]); }); diff --git a/ui/packages/i18n/src/locales/index.ts b/ui/packages/i18n/src/locales/index.ts index 4b0fcf03f39..fcbce545a93 100644 --- a/ui/packages/i18n/src/locales/index.ts +++ b/ui/packages/i18n/src/locales/index.ts @@ -22,8 +22,9 @@ * Some of a language's strings are not in its pack: the `marketplace.*` group * is a lazy namespace (`../namespaces/marketplace/`), fetched when a * marketplace page mounts, and `console.developer.*` / `connectAgent.*` are - * another (`../namespaces/developer/`), so the console's eager `en` pack does - * not carry them. + * another (`../namespaces/developer/`), and `timesheet.*` a third + * (`../namespaces/timesheet/`), so the console's eager `en` pack does not carry + * them. * This door's two purposes both want every string, so each language it hands * out is its pack deep-merged with its catalogue from every such namespace: * the parity / drift suites keep walking the moved keys, and an app that makes @@ -67,6 +68,17 @@ import esDeveloper from '../namespaces/developer/es.js'; import ptBrDeveloper from '../namespaces/developer/pt-BR.js'; import ruDeveloper from '../namespaces/developer/ru.js'; import arDeveloper from '../namespaces/developer/ar.js'; +import enTimesheet from '../namespaces/timesheet/en.js'; +import zhHansTimesheet from '../namespaces/timesheet/zh-Hans.js'; +import zhHantTimesheet from '../namespaces/timesheet/zh-Hant.js'; +import jaTimesheet from '../namespaces/timesheet/ja.js'; +import koTimesheet from '../namespaces/timesheet/ko.js'; +import deTimesheet from '../namespaces/timesheet/de.js'; +import frTimesheet from '../namespaces/timesheet/fr.js'; +import esTimesheet from '../namespaces/timesheet/es.js'; +import ptBrTimesheet from '../namespaces/timesheet/pt-BR.js'; +import ruTimesheet from '../namespaces/timesheet/ru.js'; +import arTimesheet from '../namespaces/timesheet/ar.js'; import type { PlatformLocaleTag } from '@objectstack/spec/system'; export type { TranslationKeys } from './en.js'; @@ -80,12 +92,13 @@ const isPlainObject = (value: unknown): value is Record => * sides hold is a key defined twice, which no reader could resolve the same * way twice, and throws. */ -function complete

( +function complete

( pack: P, marketplace: M, developer: D, + timesheet: T, label: string, -): P & M & D { +): P & M & D & T { const merge = (into: Record, from: Record, at: string) => { const out: Record = { ...into }; for (const key of Object.keys(from)) { @@ -102,8 +115,8 @@ function complete

( return out; }; let out = pack as Record; - for (const partial of [marketplace, developer]) out = merge(out, partial as Record, ''); - return out as P & M & D; + for (const partial of [marketplace, developer, timesheet]) out = merge(out, partial as Record, ''); + return out as P & M & D & T; } // Export names are JavaScript identifiers, not pack keys: `zh` is the zh-Hans @@ -113,70 +126,81 @@ function complete

( // Annotated rather than inferred: the inferred type spells the packs' literal // types out inline in the emitted declaration, which outgrew what tsc will // serialize (TS7056). Each `typeof` is emitted as a reference. -export const en: typeof enPack & typeof enMarketplace & typeof enDeveloper = complete( +export const en: typeof enPack & typeof enMarketplace & typeof enDeveloper & typeof enTimesheet = complete( enPack, enMarketplace, enDeveloper, + enTimesheet, 'en', ); -export const zh: typeof zhHansPack & typeof zhHansMarketplace & typeof zhHansDeveloper = complete( +export const zh: typeof zhHansPack & typeof zhHansMarketplace & typeof zhHansDeveloper & typeof zhHansTimesheet = complete( zhHansPack, zhHansMarketplace, zhHansDeveloper, + zhHansTimesheet, 'zh-Hans', ); -export const zhHant: typeof zhHantPack & typeof zhHantMarketplace & typeof zhHantDeveloper = complete( +export const zhHant: typeof zhHantPack & typeof zhHantMarketplace & typeof zhHantDeveloper & typeof zhHantTimesheet = complete( zhHantPack, zhHantMarketplace, zhHantDeveloper, + zhHantTimesheet, 'zh-Hant', ); -export const ja: typeof jaPack & typeof jaMarketplace & typeof jaDeveloper = complete( +export const ja: typeof jaPack & typeof jaMarketplace & typeof jaDeveloper & typeof jaTimesheet = complete( jaPack, jaMarketplace, jaDeveloper, + jaTimesheet, 'ja', ); -export const ko: typeof koPack & typeof koMarketplace & typeof koDeveloper = complete( +export const ko: typeof koPack & typeof koMarketplace & typeof koDeveloper & typeof koTimesheet = complete( koPack, koMarketplace, koDeveloper, + koTimesheet, 'ko', ); -export const de: typeof dePack & typeof deMarketplace & typeof deDeveloper = complete( +export const de: typeof dePack & typeof deMarketplace & typeof deDeveloper & typeof deTimesheet = complete( dePack, deMarketplace, deDeveloper, + deTimesheet, 'de', ); -export const fr: typeof frPack & typeof frMarketplace & typeof frDeveloper = complete( +export const fr: typeof frPack & typeof frMarketplace & typeof frDeveloper & typeof frTimesheet = complete( frPack, frMarketplace, frDeveloper, + frTimesheet, 'fr', ); -export const es: typeof esPack & typeof esMarketplace & typeof esDeveloper = complete( +export const es: typeof esPack & typeof esMarketplace & typeof esDeveloper & typeof esTimesheet = complete( esPack, esMarketplace, esDeveloper, + esTimesheet, 'es', ); -export const pt: typeof ptBrPack & typeof ptBrMarketplace & typeof ptBrDeveloper = complete( +export const pt: typeof ptBrPack & typeof ptBrMarketplace & typeof ptBrDeveloper & typeof ptBrTimesheet = complete( ptBrPack, ptBrMarketplace, ptBrDeveloper, + ptBrTimesheet, 'pt-BR', ); -export const ru: typeof ruPack & typeof ruMarketplace & typeof ruDeveloper = complete( +export const ru: typeof ruPack & typeof ruMarketplace & typeof ruDeveloper & typeof ruTimesheet = complete( ruPack, ruMarketplace, ruDeveloper, + ruTimesheet, 'ru', ); -export const ar: typeof arPack & typeof arMarketplace & typeof arDeveloper = complete( +export const ar: typeof arPack & typeof arMarketplace & typeof arDeveloper & typeof arTimesheet = complete( arPack, arMarketplace, arDeveloper, + arTimesheet, 'ar', ); diff --git a/ui/packages/i18n/src/namespaces/timesheet/ar.ts b/ui/packages/i18n/src/namespaces/timesheet/ar.ts new file mode 100644 index 00000000000..3a944eb1391 --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/ar.ts @@ -0,0 +1,35 @@ +/** + * العربية (ar) — the lazy `timesheet` namespace's catalogue. + * + * A PARTIAL pack: the same shape as `../../locales/ar.ts`, holding only + * the `timesheet` group, which `./index.ts` deep-merges into an i18next + * instance when a timesheet view mounts. `./index.ts` says what the namespace + * is, why it is lazy, and which gates read this file. + * + * ⛔ Keep the declaration `const ar = { … }` and `export default ar`: + * the i18n gates under `ui/scripts/` read this file by AST under that name. + */ +const ar = { + timesheet: { + missingBindingTitle: 'يلزم إعداد جدول الساعات', + missingBindingMessage: 'عرّف timesheet.rowFields وtimesheet.dateField وtimesheet.valueField في طريقة العرض هذه.', + previousWeek: 'الأسبوع السابق', + thisWeek: 'هذا الأسبوع', + nextWeek: 'الأسبوع التالي', + total: 'الإجمالي', + addRow: 'إضافة صف', + addRowConfirm: 'إضافة', + cancel: 'إلغاء', + noRows: 'لا توجد إدخالات هذا الأسبوع. أضف صفًا للبدء.', + multipleRecords: 'يحتوي هذا اليوم على {{count}} سجلات. عدّلها في القائمة.', + invalidNumber: 'أدخل رقمًا', + saveFailed: 'لم يتم الحفظ: {{message}}', + loadFailed: 'تعذر تحميل هذا الأسبوع.', + rowIncomplete: 'املأ جميع حقول الصف أولاً.', + cellLabel: '{{row}}، {{day}}', + rowTotalLabel: 'إجمالي {{row}}', + dayTotalLabel: 'إجمالي {{day}}', + }, +}; + +export default ar; diff --git a/ui/packages/i18n/src/namespaces/timesheet/de.ts b/ui/packages/i18n/src/namespaces/timesheet/de.ts new file mode 100644 index 00000000000..bc45207de39 --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/de.ts @@ -0,0 +1,35 @@ +/** + * Deutsch (de) — the lazy `timesheet` namespace's catalogue. + * + * A PARTIAL pack: the same shape as `../../locales/de.ts`, holding only + * the `timesheet` group, which `./index.ts` deep-merges into an i18next + * instance when a timesheet view mounts. `./index.ts` says what the namespace + * is, why it is lazy, and which gates read this file. + * + * ⛔ Keep the declaration `const de = { … }` and `export default de`: + * the i18n gates under `ui/scripts/` read this file by AST under that name. + */ +const de = { + timesheet: { + missingBindingTitle: 'Zeiterfassung muss konfiguriert werden', + missingBindingMessage: 'Deklarieren Sie timesheet.rowFields, timesheet.dateField und timesheet.valueField in dieser Ansicht.', + previousWeek: 'Vorherige Woche', + thisWeek: 'Diese Woche', + nextWeek: 'Nächste Woche', + total: 'Summe', + addRow: 'Zeile hinzufügen', + addRowConfirm: 'Hinzufügen', + cancel: 'Abbrechen', + noRows: 'Keine Einträge in dieser Woche. Fügen Sie eine Zeile hinzu, um zu beginnen.', + multipleRecords: 'Dieser Tag enthält {{count}} Datensätze. Bearbeiten Sie sie in der Liste.', + invalidNumber: 'Geben Sie eine Zahl ein', + saveFailed: 'Nicht gespeichert: {{message}}', + loadFailed: 'Diese Woche konnte nicht geladen werden.', + rowIncomplete: 'Füllen Sie zuerst alle Zeilenfelder aus.', + cellLabel: '{{row}}, {{day}}', + rowTotalLabel: 'Summe {{row}}', + dayTotalLabel: 'Summe {{day}}', + }, +}; + +export default de; diff --git a/ui/packages/i18n/src/namespaces/timesheet/en.ts b/ui/packages/i18n/src/namespaces/timesheet/en.ts new file mode 100644 index 00000000000..c344569b878 --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/en.ts @@ -0,0 +1,35 @@ +/** + * English (en) — the lazy `timesheet` namespace's catalogue. + * + * A PARTIAL pack: the same shape as `../../locales/en.ts`, holding only + * the `timesheet` group, which `./index.ts` deep-merges into an i18next + * instance when a timesheet view mounts. `./index.ts` says what the namespace + * is, why it is lazy, and which gates read this file. + * + * ⛔ Keep the declaration `const en = { … }` and `export default en`: + * the i18n gates under `ui/scripts/` read this file by AST under that name. + */ +const en = { + timesheet: { + missingBindingTitle: 'Timesheet configuration required', + missingBindingMessage: 'Declare timesheet.rowFields, timesheet.dateField and timesheet.valueField on this view.', + previousWeek: 'Previous week', + thisWeek: 'This week', + nextWeek: 'Next week', + total: 'Total', + addRow: 'Add row', + addRowConfirm: 'Add', + cancel: 'Cancel', + noRows: 'No entries this week. Add a row to start.', + multipleRecords: 'This day holds {{count}} records. Edit them in the list.', + invalidNumber: 'Enter a number', + saveFailed: 'Not saved: {{message}}', + loadFailed: 'This week could not be loaded.', + rowIncomplete: 'Fill in every row field first.', + cellLabel: '{{row}}, {{day}}', + rowTotalLabel: '{{row}} total', + dayTotalLabel: '{{day}} total', + }, +}; + +export default en; diff --git a/ui/packages/i18n/src/namespaces/timesheet/es.ts b/ui/packages/i18n/src/namespaces/timesheet/es.ts new file mode 100644 index 00000000000..94a7e6e5254 --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/es.ts @@ -0,0 +1,35 @@ +/** + * Español (es) — the lazy `timesheet` namespace's catalogue. + * + * A PARTIAL pack: the same shape as `../../locales/es.ts`, holding only + * the `timesheet` group, which `./index.ts` deep-merges into an i18next + * instance when a timesheet view mounts. `./index.ts` says what the namespace + * is, why it is lazy, and which gates read this file. + * + * ⛔ Keep the declaration `const es = { … }` and `export default es`: + * the i18n gates under `ui/scripts/` read this file by AST under that name. + */ +const es = { + timesheet: { + missingBindingTitle: 'Se requiere configurar la hoja de horas', + missingBindingMessage: 'Declara timesheet.rowFields, timesheet.dateField y timesheet.valueField en esta vista.', + previousWeek: 'Semana anterior', + thisWeek: 'Esta semana', + nextWeek: 'Semana siguiente', + total: 'Total', + addRow: 'Añadir fila', + addRowConfirm: 'Añadir', + cancel: 'Cancelar', + noRows: 'No hay entradas esta semana. Añade una fila para empezar.', + multipleRecords: 'Este día tiene {{count}} registros. Edítalos en la lista.', + invalidNumber: 'Introduce un número', + saveFailed: 'No guardado: {{message}}', + loadFailed: 'No se pudo cargar esta semana.', + rowIncomplete: 'Rellena primero todos los campos de la fila.', + cellLabel: '{{row}}, {{day}}', + rowTotalLabel: 'Total de {{row}}', + dayTotalLabel: 'Total de {{day}}', + }, +}; + +export default es; diff --git a/ui/packages/i18n/src/namespaces/timesheet/fr.ts b/ui/packages/i18n/src/namespaces/timesheet/fr.ts new file mode 100644 index 00000000000..999ebac0468 --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/fr.ts @@ -0,0 +1,35 @@ +/** + * Français (fr) — the lazy `timesheet` namespace's catalogue. + * + * A PARTIAL pack: the same shape as `../../locales/fr.ts`, holding only + * the `timesheet` group, which `./index.ts` deep-merges into an i18next + * instance when a timesheet view mounts. `./index.ts` says what the namespace + * is, why it is lazy, and which gates read this file. + * + * ⛔ Keep the declaration `const fr = { … }` and `export default fr`: + * the i18n gates under `ui/scripts/` read this file by AST under that name. + */ +const fr = { + timesheet: { + missingBindingTitle: 'Configuration de la feuille de temps requise', + missingBindingMessage: 'Déclarez timesheet.rowFields, timesheet.dateField et timesheet.valueField sur cette vue.', + previousWeek: 'Semaine précédente', + thisWeek: 'Cette semaine', + nextWeek: 'Semaine suivante', + total: 'Total', + addRow: 'Ajouter une ligne', + addRowConfirm: 'Ajouter', + cancel: 'Annuler', + noRows: 'Aucune saisie cette semaine. Ajoutez une ligne pour commencer.', + multipleRecords: 'Ce jour contient {{count}} enregistrements. Modifiez-les dans la liste.', + invalidNumber: 'Saisissez un nombre', + saveFailed: 'Non enregistré : {{message}}', + loadFailed: 'Impossible de charger cette semaine.', + rowIncomplete: 'Renseignez d\'abord tous les champs de la ligne.', + cellLabel: '{{row}}, {{day}}', + rowTotalLabel: 'Total {{row}}', + dayTotalLabel: 'Total {{day}}', + }, +}; + +export default fr; diff --git a/ui/packages/i18n/src/namespaces/timesheet/index.ts b/ui/packages/i18n/src/namespaces/timesheet/index.ts new file mode 100644 index 00000000000..36706e52bdc --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/index.ts @@ -0,0 +1,116 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * @object-ui/i18n — the `timesheet` namespace: the timesheet list view's strings. + * + * ## What this is + * + * The `timesheet.*` group, kept out of the language packs in one PARTIAL pack + * per platform locale table tag — `./.ts`, each the same shape as + * `../../locales/.ts` with only the `timesheet` group in it (`./zh-Hant.ts` + * generated from `./zh-Hans.ts` by `gen:zh-hant`) — fetched when a timesheet + * view mounts and deep-merged into the page's i18next instance. The call sites + * ask `t('timesheet.…')` of the default `translation` namespace, and the keys + * are there by the time `ObjectTimesheet` (`@object-ui/plugin-timesheet`) + * renders past its namespace frame. + * + * ## Why it is lazy + * + * `locales/en.ts` is the console's one EAGER catalogue, held under a ceiling + * by `ui/scripts/check-eager-closure-budget.mjs` (`i18n-locale-en`). The + * timesheet is a lazily registered list view, so its strings are paid by the + * visitor who opens one, in the language they read, and never on every page + * load. ⛔ A key a surface outside `@object-ui/plugin-timesheet` reads belongs + * in the packs, not here. + * + * ## Residency + * + * Nothing here is resident: every catalogue is one literal `() => import()`, + * its own chunk (`apps/console/vite.config.ts` names them + * `i18n-ns-timesheet-`). ⛔ Never collapse the loaders into a + * template-literal `import()`; the registry's header says why. The runtime is + * `../packNamespace.ts`, the one loader every pack-shaped namespace is built by. + * + * ## Which gates read it + * + * The i18n gates under `ui/scripts/` read `./.ts` beside the packs, and + * `../../locales/index.ts` (the all-packs door) hands out each language's pack + * merged with its catalogue here, so the key-parity suites walk these keys. + * `../../__tests__/timesheet-namespace.test.ts` holds this module's own shape. + */ +import type { PlatformLocaleTag } from '@objectstack/spec/system'; +import { + createPackNamespace, + type PackNamespaceCatalogue, + type PackNamespaceState, +} from '../packNamespace.js'; + +/** One language's catalogue: a partial pack holding the `timesheet` group. */ +export type TimesheetCatalogue = PackNamespaceCatalogue; + +/** The namespace's name — and the pack group its catalogues hold. */ +export const TIMESHEET_NAMESPACE = 'timesheet'; + +/** + * A key every catalogue defines and no pack does: whether an instance can + * render the namespace in a language is whether it holds this key there. + */ +export const TIMESHEET_NAMESPACE_PROBE_KEY = 'timesheet.missingBindingTitle'; + +/** + * The catalogues, each fetched on demand — one literal specifier each, so each + * one is a chunk of its own. Keyed by platform locale table tag and typed on + * the table: a tag the table gains without its catalogue here is a compile + * error. + */ +const TIMESHEET_LOADERS: Readonly< + Record Promise<{ default: TimesheetCatalogue }>> +> = Object.freeze({ + en: () => import('./en.js'), + 'zh-Hans': () => import('./zh-Hans.js'), + 'zh-Hant': () => import('./zh-Hant.js'), + es: () => import('./es.js'), + ar: () => import('./ar.js'), + fr: () => import('./fr.js'), + 'pt-BR': () => import('./pt-BR.js'), + ru: () => import('./ru.js'), + de: () => import('./de.js'), + ja: () => import('./ja.js'), + ko: () => import('./ko.js'), +}); + +const timesheet = createPackNamespace({ + name: TIMESHEET_NAMESPACE, + groups: [TIMESHEET_NAMESPACE], + probeKey: TIMESHEET_NAMESPACE_PROBE_KEY, + loaders: TIMESHEET_LOADERS, +}); + +/** Every language this namespace ships a catalogue for. */ +export const TIMESHEET_LANGUAGE_CODES: readonly string[] = timesheet.languageCodes; + +/** + * The tag of the catalogue that serves `lang` (`zh-CN` → `zh-Hans`, `pt` → + * `pt-BR`), or `null` when `lang` is served by the `en` fallback. + */ +export const resolveTimesheetLanguage: (lang: string | undefined) => string | null = timesheet.resolveLanguage; + +/** Whether the catalogue `code` names is resident (no fetch needed). */ +export const isTimesheetCatalogueLoaded: (code: string) => boolean = timesheet.isCatalogueLoaded; + +/** + * Fetch the catalogue `code` names and resolve it — memoised; a rejected load + * is recorded, not memoised. + */ +export const loadTimesheetCatalogue: (code: string) => Promise = timesheet.loadCatalogue; + +/** What {@link useTimesheetNamespace} answers. */ +export type TimesheetNamespaceState = PackNamespaceState; + +/** + * React hook: whether the page's i18next instance can render the + * `timesheet.*` strings in its current language, starting the fetch when it + * cannot. `ObjectTimesheet` renders nothing that reads a `timesheet.*` key + * until this answers `ready`. + */ +export const useTimesheetNamespace: () => TimesheetNamespaceState = timesheet.useNamespace; diff --git a/ui/packages/i18n/src/namespaces/timesheet/ja.ts b/ui/packages/i18n/src/namespaces/timesheet/ja.ts new file mode 100644 index 00000000000..932189f1fa9 --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/ja.ts @@ -0,0 +1,35 @@ +/** + * 日本語 (ja) — the lazy `timesheet` namespace's catalogue. + * + * A PARTIAL pack: the same shape as `../../locales/ja.ts`, holding only + * the `timesheet` group, which `./index.ts` deep-merges into an i18next + * instance when a timesheet view mounts. `./index.ts` says what the namespace + * is, why it is lazy, and which gates read this file. + * + * ⛔ Keep the declaration `const ja = { … }` and `export default ja`: + * the i18n gates under `ui/scripts/` read this file by AST under that name. + */ +const ja = { + timesheet: { + missingBindingTitle: 'タイムシートの設定が必要です', + missingBindingMessage: 'このビューに timesheet.rowFields、timesheet.dateField、timesheet.valueField を宣言してください。', + previousWeek: '前の週', + thisWeek: '今週', + nextWeek: '次の週', + total: '合計', + addRow: '行を追加', + addRowConfirm: '追加', + cancel: 'キャンセル', + noRows: '今週のエントリはありません。行を追加して開始してください。', + multipleRecords: 'この日には {{count}} 件のレコードがあります。一覧で編集してください。', + invalidNumber: '数値を入力してください', + saveFailed: '保存されていません: {{message}}', + loadFailed: '今週のデータを読み込めませんでした。', + rowIncomplete: '先にすべての行フィールドを入力してください。', + cellLabel: '{{row}}、{{day}}', + rowTotalLabel: '{{row}} の合計', + dayTotalLabel: '{{day}} の合計', + }, +}; + +export default ja; diff --git a/ui/packages/i18n/src/namespaces/timesheet/ko.ts b/ui/packages/i18n/src/namespaces/timesheet/ko.ts new file mode 100644 index 00000000000..57c13dfdb45 --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/ko.ts @@ -0,0 +1,35 @@ +/** + * 한국어 (ko) — the lazy `timesheet` namespace's catalogue. + * + * A PARTIAL pack: the same shape as `../../locales/ko.ts`, holding only + * the `timesheet` group, which `./index.ts` deep-merges into an i18next + * instance when a timesheet view mounts. `./index.ts` says what the namespace + * is, why it is lazy, and which gates read this file. + * + * ⛔ Keep the declaration `const ko = { … }` and `export default ko`: + * the i18n gates under `ui/scripts/` read this file by AST under that name. + */ +const ko = { + timesheet: { + missingBindingTitle: '타임시트 구성이 필요합니다', + missingBindingMessage: '이 뷰에 timesheet.rowFields, timesheet.dateField, timesheet.valueField를 선언하세요.', + previousWeek: '이전 주', + thisWeek: '이번 주', + nextWeek: '다음 주', + total: '합계', + addRow: '행 추가', + addRowConfirm: '추가', + cancel: '취소', + noRows: '이번 주에는 항목이 없습니다. 행을 추가하여 시작하세요.', + multipleRecords: '이 날에는 레코드가 {{count}}개 있습니다. 목록에서 편집하세요.', + invalidNumber: '숫자를 입력하세요', + saveFailed: '저장되지 않음: {{message}}', + loadFailed: '이번 주를 불러올 수 없습니다.', + rowIncomplete: '먼저 모든 행 필드를 입력하세요.', + cellLabel: '{{row}}, {{day}}', + rowTotalLabel: '{{row}} 합계', + dayTotalLabel: '{{day}} 합계', + }, +}; + +export default ko; diff --git a/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts b/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts new file mode 100644 index 00000000000..17b2ec528fe --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts @@ -0,0 +1,35 @@ +/** + * Português (pt-BR) — the lazy `timesheet` namespace's catalogue. + * + * A PARTIAL pack: the same shape as `../../locales/pt-BR.ts`, holding only + * the `timesheet` group, which `./index.ts` deep-merges into an i18next + * instance when a timesheet view mounts. `./index.ts` says what the namespace + * is, why it is lazy, and which gates read this file. + * + * ⛔ Keep the declaration `const pt = { … }` and `export default pt`: + * the i18n gates under `ui/scripts/` read this file by AST under that name. + */ +const pt = { + timesheet: { + missingBindingTitle: 'Configuração da folha de horas necessária', + missingBindingMessage: 'Declare timesheet.rowFields, timesheet.dateField e timesheet.valueField nesta visualização.', + previousWeek: 'Semana anterior', + thisWeek: 'Esta semana', + nextWeek: 'Próxima semana', + total: 'Total', + addRow: 'Adicionar linha', + addRowConfirm: 'Adicionar', + cancel: 'Cancelar', + noRows: 'Nenhum lançamento nesta semana. Adicione uma linha para começar.', + multipleRecords: 'Este dia tem {{count}} registros. Edite-os na lista.', + invalidNumber: 'Digite um número', + saveFailed: 'Não salvo: {{message}}', + loadFailed: 'Não foi possível carregar esta semana.', + rowIncomplete: 'Preencha primeiro todos os campos da linha.', + cellLabel: '{{row}}, {{day}}', + rowTotalLabel: 'Total de {{row}}', + dayTotalLabel: 'Total de {{day}}', + }, +}; + +export default pt; diff --git a/ui/packages/i18n/src/namespaces/timesheet/ru.ts b/ui/packages/i18n/src/namespaces/timesheet/ru.ts new file mode 100644 index 00000000000..930e712cbcb --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/ru.ts @@ -0,0 +1,35 @@ +/** + * Русский (ru) — the lazy `timesheet` namespace's catalogue. + * + * A PARTIAL pack: the same shape as `../../locales/ru.ts`, holding only + * the `timesheet` group, which `./index.ts` deep-merges into an i18next + * instance when a timesheet view mounts. `./index.ts` says what the namespace + * is, why it is lazy, and which gates read this file. + * + * ⛔ Keep the declaration `const ru = { … }` and `export default ru`: + * the i18n gates under `ui/scripts/` read this file by AST under that name. + */ +const ru = { + timesheet: { + missingBindingTitle: 'Требуется настройка табеля', + missingBindingMessage: 'Объявите timesheet.rowFields, timesheet.dateField и timesheet.valueField в этом представлении.', + previousWeek: 'Предыдущая неделя', + thisWeek: 'Эта неделя', + nextWeek: 'Следующая неделя', + total: 'Итого', + addRow: 'Добавить строку', + addRowConfirm: 'Добавить', + cancel: 'Отмена', + noRows: 'На этой неделе нет записей. Добавьте строку, чтобы начать.', + multipleRecords: 'В этот день записей: {{count}}. Измените их в списке.', + invalidNumber: 'Введите число', + saveFailed: 'Не сохранено: {{message}}', + loadFailed: 'Не удалось загрузить эту неделю.', + rowIncomplete: 'Сначала заполните все поля строки.', + cellLabel: '{{row}}, {{day}}', + rowTotalLabel: 'Итого: {{row}}', + dayTotalLabel: 'Итого: {{day}}', + }, +}; + +export default ru; diff --git a/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts b/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts new file mode 100644 index 00000000000..54f84388cc1 --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts @@ -0,0 +1,35 @@ +/** + * 简体中文 (zh-Hans) — the lazy `timesheet` namespace's catalogue. + * + * A PARTIAL pack: the same shape as `../../locales/zh-Hans.ts`, holding only + * the `timesheet` group, which `./index.ts` deep-merges into an i18next + * instance when a timesheet view mounts. `./index.ts` says what the namespace + * is, why it is lazy, and which gates read this file. + * + * ⛔ Keep the declaration `const zh = { … }` and `export default zh`: + * the i18n gates under `ui/scripts/` read this file by AST under that name. + */ +const zh = { + timesheet: { + missingBindingTitle: '需要配置工时表', + missingBindingMessage: '请在此视图上声明 timesheet.rowFields、timesheet.dateField 和 timesheet.valueField。', + previousWeek: '上一周', + thisWeek: '本周', + nextWeek: '下一周', + total: '合计', + addRow: '添加行', + addRowConfirm: '添加', + cancel: '取消', + noRows: '本周没有记录。添加一行即可开始。', + multipleRecords: '这一天有 {{count}} 条记录,请在列表中编辑。', + invalidNumber: '请输入数字', + saveFailed: '未保存:{{message}}', + loadFailed: '无法加载本周数据。', + rowIncomplete: '请先填写每个行字段。', + cellLabel: '{{row}},{{day}}', + rowTotalLabel: '{{row}} 合计', + dayTotalLabel: '{{day}} 合计', + }, +}; + +export default zh; diff --git a/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts b/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts new file mode 100644 index 00000000000..dca7b671b61 --- /dev/null +++ b/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts @@ -0,0 +1,32 @@ +// @generated by ui/packages/i18n/scripts/gen-zh-hant.mjs from ./zh-Hans.ts. +// Do not edit this file: edit zh-Hans.ts (or a rule in scripts/zh-hant.mjs), +// then run `pnpm --filter @object-ui/i18n gen:zh-hant` and commit both. +/** + * 繁體中文 (zh-Hant) - a lazy namespace's catalogue, converted from its zh-Hans + * catalogue (OpenCC s2twp with the overrides in scripts/zh-hant.mjs). `./index.ts` + * says what the namespace is, why it is lazy, and which gates read this file. + */ +const zhHant = { + timesheet: { + missingBindingTitle: '需要配置工時表', + missingBindingMessage: '請在此檢視上宣告 timesheet.rowFields、timesheet.dateField 和 timesheet.valueField。', + previousWeek: '上一週', + thisWeek: '本週', + nextWeek: '下一週', + total: '合計', + addRow: '新增行', + addRowConfirm: '新增', + cancel: '取消', + noRows: '本週沒有記錄。新增一行即可開始。', + multipleRecords: '這一天有 {{count}} 條記錄,請在列表中編輯。', + invalidNumber: '請輸入數字', + saveFailed: '未儲存:{{message}}', + loadFailed: '無法載入本週資料。', + rowIncomplete: '請先填寫每個行欄位。', + cellLabel: '{{row}},{{day}}', + rowTotalLabel: '{{row}} 合計', + dayTotalLabel: '{{day}} 合計', + }, +}; + +export default zhHant; diff --git a/ui/scripts/__tests__/check-i18n-en-drift.test.ts b/ui/scripts/__tests__/check-i18n-en-drift.test.ts index 99d3c39f661..119d63d2f25 100644 --- a/ui/scripts/__tests__/check-i18n-en-drift.test.ts +++ b/ui/scripts/__tests__/check-i18n-en-drift.test.ts @@ -533,6 +533,7 @@ describe('a language is its pack plus its namespace partial packs', () => { expect(namespacePackPaths('zh-Hans')).toEqual([ 'packages/i18n/src/namespaces/marketplace/zh-Hans.ts', 'packages/i18n/src/namespaces/developer/zh-Hans.ts', + 'packages/i18n/src/namespaces/timesheet/zh-Hans.ts', ]); }); diff --git a/ui/scripts/check-i18n-call-site-keys.mjs b/ui/scripts/check-i18n-call-site-keys.mjs index c519f3802e4..336a12e54d9 100644 --- a/ui/scripts/check-i18n-call-site-keys.mjs +++ b/ui/scripts/check-i18n-call-site-keys.mjs @@ -1390,6 +1390,8 @@ export const PACK_NAMESPACE_FRAMES = Object.freeze({ 'apps/console/src/pages/developer/', 'packages/app-shell/src/console/connect/', ]), + // `timesheet.*`, read under `ObjectTimesheet`'s own namespace frame. + 'packages/i18n/src/namespaces/timesheet/': Object.freeze(['packages/plugin-timesheet/src/']), }); /** The pack-shaped namespace directories: the keys of {@link PACK_NAMESPACE_FRAMES}. */ From 265d9e7e56cca3c84b32bdb194c9f5cd44c23b1c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 13:02:01 +0000 Subject: [PATCH 03/18] feat(ui): timesheet renderer package, list view wiring, lint field refs and docs Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- .changeset/34382-timesheet-list-view.md | 36 + .changeset/config.json | 1 + content/docs/references/api/protocol.mdx | 4 +- content/docs/references/data/object.mdx | 2 +- content/docs/references/ui/page.mdx | 6 +- content/docs/references/ui/view.mdx | 19 +- content/docs/ui/views.mdx | 35 +- packages/lint/src/rule-explanations.ts | 14 +- packages/lint/src/validate-field-consumers.ts | 2 +- .../lint/src/validate-list-view-field-refs.ts | 10 + packages/spec/liveness/state-counts/view.md | 2 +- packages/spec/liveness/view.json | 8 +- packages/spec/src/ui/view.zod.ts | 1 + pnpm-lock.yaml | 67 ++ ui/apps/console/dev/manifest-registry.ts | 1 + ui/apps/console/package.json | 1 + ui/apps/console/src/register-plugins.ts | 8 + ui/apps/console/vite.config.ts | 2 + .../app-shell/src/views/CreateViewDialog.tsx | 26 + ...ateViewDialog.viewTypeParse-11581.test.tsx | 5 + .../app-shell/src/views/newViewSpec.ts | 1 + .../src/views/objectViewListRenderer.tsx | 5 + .../studio-design/ListViewMoreSection.tsx | 1 + .../studio-design/ListViewTypeSection.tsx | 1 + .../cli/src/utils/known-schema-types.ts | 2 + .../core/src/utils/normalize-list-view.ts | 1 + ui/packages/i18n/src/locales/ar.ts | 8 + ui/packages/i18n/src/locales/de.ts | 8 + ui/packages/i18n/src/locales/en.ts | 8 + ui/packages/i18n/src/locales/es.ts | 8 + ui/packages/i18n/src/locales/fr.ts | 8 + ui/packages/i18n/src/locales/ja.ts | 8 + ui/packages/i18n/src/locales/ko.ts | 8 + ui/packages/i18n/src/locales/pt-BR.ts | 8 + ui/packages/i18n/src/locales/ru.ts | 8 + ui/packages/i18n/src/locales/zh-Hans.ts | 8 + ui/packages/i18n/src/locales/zh-Hant.ts | 8 + ui/packages/i18n/src/namespaces/studio/en.ts | 1 + ui/packages/i18n/src/namespaces/studio/zh.ts | 1 + ui/packages/plugin-list/src/ListView.tsx | 30 +- ui/packages/plugin-list/src/ViewSwitcher.tsx | 4 + ui/packages/plugin-list/src/index.tsx | 7 + ui/packages/plugin-timesheet/CHANGELOG.md | 1 + ui/packages/plugin-timesheet/LICENSE | 21 + ui/packages/plugin-timesheet/README.md | 80 +++ ui/packages/plugin-timesheet/package.json | 86 +++ .../plugin-timesheet/src/ObjectTimesheet.tsx | 645 ++++++++++++++++++ .../src/__tests__/ObjectTimesheet.test.tsx | 181 +++++ .../src/__tests__/timesheetModel.test.ts | 149 ++++ ui/packages/plugin-timesheet/src/index.tsx | 68 ++ .../plugin-timesheet/src/timesheetModel.ts | 272 ++++++++ ui/packages/plugin-timesheet/tsconfig.json | 27 + .../plugin-timesheet/tsconfig.test.json | 12 + ui/packages/plugin-timesheet/vite.config.ts | 71 ++ ui/packages/plugin-view/src/ObjectView.tsx | 4 +- ...de-effects-declaration-consistency.test.ts | 1 + ui/vitest.config.mts | 1 + 57 files changed, 1980 insertions(+), 31 deletions(-) create mode 100644 .changeset/34382-timesheet-list-view.md create mode 100644 ui/packages/plugin-timesheet/CHANGELOG.md create mode 100644 ui/packages/plugin-timesheet/LICENSE create mode 100644 ui/packages/plugin-timesheet/README.md create mode 100644 ui/packages/plugin-timesheet/package.json create mode 100644 ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx create mode 100644 ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx create mode 100644 ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts create mode 100644 ui/packages/plugin-timesheet/src/index.tsx create mode 100644 ui/packages/plugin-timesheet/src/timesheetModel.ts create mode 100644 ui/packages/plugin-timesheet/tsconfig.json create mode 100644 ui/packages/plugin-timesheet/tsconfig.test.json create mode 100644 ui/packages/plugin-timesheet/vite.config.ts diff --git a/.changeset/34382-timesheet-list-view.md b/.changeset/34382-timesheet-list-view.md new file mode 100644 index 00000000000..85541804f0a --- /dev/null +++ b/.changeset/34382-timesheet-list-view.md @@ -0,0 +1,36 @@ +--- +'@objectstack/spec': minor +'@objectstack/lint': minor +'@object-ui/plugin-timesheet': minor +'@object-ui/plugin-list': minor +'@object-ui/plugin-view': minor +'@object-ui/core': minor +'@object-ui/i18n': minor +'@object-ui/app-shell': minor +'@object-ui/cli': minor +'@object-ui/console': minor +--- + +feat(ui): timesheet list view, an editable row × weekday entry grid + +Clause-②: yes (widening — new list view type `timesheet`, its `timesheet` block and the `VisualizationType` member; new locale keys) +Metadata-protocol: added + +A list view can now be `type: 'timesheet'`. It pivots detail records into rows × the seven days of one week, and every cell is editable: + +```ts +type: 'timesheet', +timesheet: { + rowFields: ['project', 'task'], // 1–3 fields; one row per distinct combination + dateField: 'work_date', // date or datetime + valueField: 'hours', // number, currency or percent +} +``` + +- Typing into an empty cell creates a record carrying the row's field values, the day and the number. Changing a cell updates that record, and clearing it deletes the record. Each cell is one call on the record API, so hooks, validation rules and permissions judge it; a refusal stays on that cell with the server's message. +- A cell holding several records shows their sum and is read-only. +- The week starts on the viewer's locale first day, with previous / this / next navigation. Row, day and week totals are always shown. +- **Add row** asks for the row field values first; typing a day then creates the record. The view's `filter` applies to the week's query. +- A `timesheet` view with an incomplete block shows "Timesheet configuration required", and `os validate` warns with `view/layout-without-binding`. `view/list-view-field-refs` checks the three field names. + +The renderer is the new lazy package `@object-ui/plugin-timesheet` (`object-timesheet`), with its own lazy locale namespace `timesheet.*`. The view switcher, the create-view dialog and the Studio list-view type section offer the new type. diff --git a/.changeset/config.json b/.changeset/config.json index c0d06b28e64..a4da88444f3 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -113,6 +113,7 @@ "@object-ui/plugin-markdown", "@object-ui/plugin-report", "@object-ui/plugin-timeline", + "@object-ui/plugin-timesheet", "@object-ui/plugin-tree", "@object-ui/plugin-view", "@object-ui/react", diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index c4f4096e41f..349271a063d 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1963,7 +1963,7 @@ The published metadata item body, opaque by ruling (1C). Shape is the item's own | **inlineEdit** | `boolean` | optional | Allow inline editing of records directly in the list view | | **exportOptions** | `Enum<'csv' \| 'xlsx' \| 'json'>[] \| { formats?: Enum<'csv' \| 'xlsx' \| 'json'>[]; maxRecords?: integer; includeHeaders?: boolean; fileNamePrefix?: string; … }` | optional | Export configuration for the list toolbar export menu: `{ formats?, maxRecords?, includeHeaders?, fileNamePrefix?, streaming? }`. A bare format array is the legacy spelling and lifts to `{ formats: [...] }` at parse. | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles for the view toolbar | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **tabs** | `never` | optional | [REMOVED] `view.list.tabs` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — no renderer ever mounted a tab bar for it, so authoring it drew nothing: the tab strip above an object's records is the saved-view switcher (ViewTabBar), which renders one tab per named list view and never read this key. Delete the key, and move each tab you want to a named list view under the object's `listViews` instead: the tab's `name` becomes the entry's key, its `label` the entry's `label`, and its `filter` rules join the view's own `filter` on that entry (copy the view's `columns` too); a tab whose `view` already named a list view needs nothing more. Every `listViews` entry renders as a tab in the switcher. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | | **showRecordCount** | `boolean` | optional | Show record count at the bottom of the list | @@ -2043,7 +2043,7 @@ The published metadata item body, opaque by ruling (1C). Shape is the item's own | **inlineEdit** | `boolean` | optional | Allow inline editing of records directly in the list view | | **exportOptions** | `Enum<'csv' \| 'xlsx' \| 'json'>[] \| { formats?: Enum<'csv' \| 'xlsx' \| 'json'>[]; maxRecords?: integer; includeHeaders?: boolean; fileNamePrefix?: string; … }` | optional | Export configuration for the list toolbar export menu: `{ formats?, maxRecords?, includeHeaders?, fileNamePrefix?, streaming? }`. A bare format array is the legacy spelling and lifts to `{ formats: [...] }` at parse. | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles for the view toolbar | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **tabs** | `never` | optional | [REMOVED] `view.list.tabs` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — no renderer ever mounted a tab bar for it, so authoring it drew nothing: the tab strip above an object's records is the saved-view switcher (ViewTabBar), which renders one tab per named list view and never read this key. Delete the key, and move each tab you want to a named list view under the object's `listViews` instead: the tab's `name` becomes the entry's key, its `label` the entry's `label`, and its `filter` rules join the view's own `filter` on that entry (copy the view's `columns` too); a tab whose `view` already named a list view needs nothing more. Every `listViews` entry renders as a tab in the switcher. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | | **showRecordCount** | `boolean` | optional | Show record count at the bottom of the list | diff --git a/content/docs/references/data/object.mdx b/content/docs/references/data/object.mdx index 72c025bbc76..dc79dc87584 100644 --- a/content/docs/references/data/object.mdx +++ b/content/docs/references/data/object.mdx @@ -422,7 +422,7 @@ const result = ApiMethod.parse(data); | **inlineEdit** | `boolean` | optional | Allow inline editing of records directly in the list view | | **exportOptions** | `Enum<'csv' \| 'xlsx' \| 'json'>[] \| { formats?: Enum<'csv' \| 'xlsx' \| 'json'>[]; maxRecords?: integer; includeHeaders?: boolean; fileNamePrefix?: string; … }` | optional | Export configuration for the list toolbar export menu: `{ formats?, maxRecords?, includeHeaders?, fileNamePrefix?, streaming? }`. A bare format array is the legacy spelling and lifts to `{ formats: [...] }` at parse. | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles for the view toolbar | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **tabs** | `never` | optional | [REMOVED] `view.list.tabs` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — no renderer ever mounted a tab bar for it, so authoring it drew nothing: the tab strip above an object's records is the saved-view switcher (ViewTabBar), which renders one tab per named list view and never read this key. Delete the key, and move each tab you want to a named list view under the object's `listViews` instead: the tab's `name` becomes the entry's key, its `label` the entry's `label`, and its `filter` rules join the view's own `filter` on that entry (copy the view's `columns` too); a tab whose `view` already named a list view needs nothing more. Every `listViews` entry renders as a tab in the switcher. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | | **showRecordCount** | `boolean` | optional | Show record count at the bottom of the list | diff --git a/content/docs/references/ui/page.mdx b/content/docs/references/ui/page.mdx index 1ede09cba3a..a4d52b36391 100644 --- a/content/docs/references/ui/page.mdx +++ b/content/docs/references/ui/page.mdx @@ -100,7 +100,7 @@ Interface-level page configuration (Airtable parity) | **filterBy** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Always-on page filter (base filter). | | **levels** | `integer` | optional | Number of hierarchy levels to display | | **sourceView** | `string` | optional | @deprecated Legacy named-view inheritance. Define columns/sort/filterBy on the page instead. | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **userFilters** | `{ element?: Enum<'dropdown' \| 'tabs' \| 'toggle'>; fields?: object[]; tabs?: object[]; showAllRecords?: boolean; … }` | optional | End-user quick-filter bar for this page (overrides the source view's userFilters) | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | @@ -161,7 +161,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **showDescription** | `boolean` | optional (default: `true`) | Show the view description text | -| **allowedVisualizations** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[]` | optional | Whitelist of visualization types users can switch between (e.g. ["grid", "gallery", "kanban"]) | +| **allowedVisualizations** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[]` | optional | Whitelist of visualization types users can switch between (e.g. ["grid", "gallery", "kanban"]) | ### Nested Shape: `InterfacePageConfig.userFilters` @@ -281,7 +281,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | **filterBy** | `({ field: string; operator: Enum<'equals' \| 'not_equals' \| 'contains' \| 'not_contains' \| 'icontains' \| …>; value?: string \| number \| boolean \| null \| (string \| number)[] } \| { or: object[] })[]` | optional | Always-on page filter (base filter). | | **levels** | `integer` | optional | Number of hierarchy levels to display | | **sourceView** | `string` | optional | @deprecated Legacy named-view inheritance. Define columns/sort/filterBy on the page instead. | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **userFilters** | `{ element?: Enum<'dropdown' \| 'tabs' \| 'toggle'>; fields?: object[]; tabs?: object[]; showAllRecords?: boolean; … }` | optional | End-user quick-filter bar for this page (overrides the source view's userFilters) | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | diff --git a/content/docs/references/ui/view.mdx b/content/docs/references/ui/view.mdx index 4ae5296e8f8..72e5cbdf36c 100644 --- a/content/docs/references/ui/view.mdx +++ b/content/docs/references/ui/view.mdx @@ -93,7 +93,7 @@ Appearance and visualization configuration | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **showDescription** | `boolean` | optional (default: `true`) | Show the view description text | -| **allowedVisualizations** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[]` | optional | Whitelist of visualization types users can switch between (e.g. ["grid", "gallery", "kanban"]) | +| **allowedVisualizations** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree' \| 'timesheet'>[]` | optional | Whitelist of visualization types users can switch between (e.g. ["grid", "gallery", "kanban"]) | --- @@ -815,7 +815,7 @@ Map view configuration | **inlineEdit** | `boolean` | optional | Allow inline editing of records directly in the list view | | **exportOptions** | `Enum<'csv' \| 'xlsx' \| 'json'>[] \| { formats?: Enum<'csv' \| 'xlsx' \| 'json'>[]; maxRecords?: integer; includeHeaders?: boolean; fileNamePrefix?: string; … }` | optional | Export configuration for the list toolbar export menu: `{ formats?, maxRecords?, includeHeaders?, fileNamePrefix?, streaming? }`. A bare format array is the legacy spelling and lifts to `{ formats: [...] }` at parse. | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles for the view toolbar | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **tabs** | `never` | optional | [REMOVED] `view.list.tabs` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — no renderer ever mounted a tab bar for it, so authoring it drew nothing: the tab strip above an object's records is the saved-view switcher (ViewTabBar), which renders one tab per named list view and never read this key. Delete the key, and move each tab you want to a named list view under the object's `listViews` instead: the tab's `name` becomes the entry's key, its `label` the entry's `label`, and its `filter` rules join the view's own `filter` on that entry (copy the view's `columns` too); a tab whose `view` already named a list view needs nothing more. Every `listViews` entry renders as a tab in the switcher. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | | **showRecordCount** | `boolean` | optional | Show record count at the bottom of the list | @@ -1108,7 +1108,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **showDescription** | `boolean` | optional (default: `true`) | Show the view description text | -| **allowedVisualizations** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[]` | optional | Whitelist of visualization types users can switch between (e.g. ["grid", "gallery", "kanban"]) | +| **allowedVisualizations** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[]` | optional | Whitelist of visualization types users can switch between (e.g. ["grid", "gallery", "kanban"]) | ### Nested Shape: `ListView.addRecord` @@ -1212,7 +1212,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | **inlineEdit** | `boolean` | optional | Allow inline editing of records directly in the list view | | **exportOptions** | `Enum<'csv' \| 'xlsx' \| 'json'>[] \| { formats?: Enum<'csv' \| 'xlsx' \| 'json'>[]; maxRecords?: integer; includeHeaders?: boolean; fileNamePrefix?: string; … }` | optional | Export configuration for the list toolbar export menu: `{ formats?, maxRecords?, includeHeaders?, fileNamePrefix?, streaming? }`. A bare format array is the legacy spelling and lifts to `{ formats: [...] }` at parse. | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles for the view toolbar | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **tabs** | `never` | optional | [REMOVED] `view.list.tabs` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — no renderer ever mounted a tab bar for it, so authoring it drew nothing: the tab strip above an object's records is the saved-view switcher (ViewTabBar), which renders one tab per named list view and never read this key. Delete the key, and move each tab you want to a named list view under the object's `listViews` instead: the tab's `name` becomes the entry's key, its `label` the entry's `label`, and its `filter` rules join the view's own `filter` on that entry (copy the view's `columns` too); a tab whose `view` already named a list view needs nothing more. Every `listViews` entry renders as a tab in the switcher. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | | **showRecordCount** | `boolean` | optional | Show record count at the bottom of the list | @@ -1496,7 +1496,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **showDescription** | `boolean` | optional (default: `true`) | Show the view description text | -| **allowedVisualizations** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[]` | optional | Whitelist of visualization types users can switch between (e.g. ["grid", "gallery", "kanban"]) | +| **allowedVisualizations** | `Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[]` | optional | Whitelist of visualization types users can switch between (e.g. ["grid", "gallery", "kanban"]) | ### Nested Shape: `ObjectListView.addRecord` @@ -1816,7 +1816,7 @@ Tab configuration for multi-tab view interface | **inlineEdit** | `boolean` | optional | Allow inline editing of records directly in the list view | | **exportOptions** | `Enum<'csv' \| 'xlsx' \| 'json'>[] \| { formats?: Enum<'csv' \| 'xlsx' \| 'json'>[]; maxRecords?: integer; includeHeaders?: boolean; fileNamePrefix?: string; … }` | optional | Export configuration for the list toolbar export menu: `{ formats?, maxRecords?, includeHeaders?, fileNamePrefix?, streaming? }`. A bare format array is the legacy spelling and lifts to `{ formats: [...] }` at parse. | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles for the view toolbar | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **tabs** | `never` | optional | [REMOVED] `view.list.tabs` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — no renderer ever mounted a tab bar for it, so authoring it drew nothing: the tab strip above an object's records is the saved-view switcher (ViewTabBar), which renders one tab per named list view and never read this key. Delete the key, and move each tab you want to a named list view under the object's `listViews` instead: the tab's `name` becomes the entry's key, its `label` the entry's `label`, and its `filter` rules join the view's own `filter` on that entry (copy the view's `columns` too); a tab whose `view` already named a list view needs nothing more. Every `listViews` entry renders as a tab in the switcher. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | | **showRecordCount** | `boolean` | optional | Show record count at the bottom of the list | @@ -1896,7 +1896,7 @@ Tab configuration for multi-tab view interface | **inlineEdit** | `boolean` | optional | Allow inline editing of records directly in the list view | | **exportOptions** | `Enum<'csv' \| 'xlsx' \| 'json'>[] \| { formats?: Enum<'csv' \| 'xlsx' \| 'json'>[]; maxRecords?: integer; includeHeaders?: boolean; fileNamePrefix?: string; … }` | optional | Export configuration for the list toolbar export menu: `{ formats?, maxRecords?, includeHeaders?, fileNamePrefix?, streaming? }`. A bare format array is the legacy spelling and lifts to `{ formats: [...] }` at parse. | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles for the view toolbar | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **tabs** | `never` | optional | [REMOVED] `view.list.tabs` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — no renderer ever mounted a tab bar for it, so authoring it drew nothing: the tab strip above an object's records is the saved-view switcher (ViewTabBar), which renders one tab per named list view and never read this key. Delete the key, and move each tab you want to a named list view under the object's `listViews` instead: the tab's `name` becomes the entry's key, its `label` the entry's `label`, and its `filter` rules join the view's own `filter` on that entry (copy the view's `columns` too); a tab whose `view` already named a list view needs nothing more. Every `listViews` entry renders as a tab in the switcher. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | | **showRecordCount** | `boolean` | optional | Show record count at the bottom of the list | @@ -2194,7 +2194,7 @@ This schema accepts one of the following structures: | **inlineEdit** | `boolean` | optional | Allow inline editing of records directly in the list view | | **exportOptions** | `Enum<'csv' \| 'xlsx' \| 'json'>[] \| { formats?: Enum<'csv' \| 'xlsx' \| 'json'>[]; maxRecords?: integer; includeHeaders?: boolean; fileNamePrefix?: string; … }` | optional | Export configuration for the list toolbar export menu: `{ formats?, maxRecords?, includeHeaders?, fileNamePrefix?, streaming? }`. A bare format array is the legacy spelling and lifts to `{ formats: [...] }` at parse. | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles for the view toolbar | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **tabs** | `never` | optional | [REMOVED] `view.list.tabs` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — no renderer ever mounted a tab bar for it, so authoring it drew nothing: the tab strip above an object's records is the saved-view switcher (ViewTabBar), which renders one tab per named list view and never read this key. Delete the key, and move each tab you want to a named list view under the object's `listViews` instead: the tab's `name` becomes the entry's key, its `label` the entry's `label`, and its `filter` rules join the view's own `filter` on that entry (copy the view's `columns` too); a tab whose `view` already named a list view needs nothing more. Every `listViews` entry renders as a tab in the switcher. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | | **showRecordCount** | `boolean` | optional | Show record count at the bottom of the list | @@ -2383,7 +2383,7 @@ This schema accepts one of the following structures: | **inlineEdit** | `boolean` | optional | Allow inline editing of records directly in the list view | | **exportOptions** | `Enum<'csv' \| 'xlsx' \| 'json'>[] \| { formats?: Enum<'csv' \| 'xlsx' \| 'json'>[]; maxRecords?: integer; includeHeaders?: boolean; fileNamePrefix?: string; … }` | optional | Export configuration for the list toolbar export menu: `{ formats?, maxRecords?, includeHeaders?, fileNamePrefix?, streaming? }`. A bare format array is the legacy spelling and lifts to `{ formats: [...] }` at parse. | | **userActions** | `{ sort?: boolean; search?: boolean; filter?: boolean; refresh?: boolean; … }` | optional | User action toggles for the view toolbar | -| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| 'chart' \| 'tree'>[] }` | optional | Appearance and visualization configuration | +| **appearance** | `{ showDescription?: boolean; allowedVisualizations?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>[] }` | optional | Appearance and visualization configuration | | **tabs** | `never` | optional | [REMOVED] `view.list.tabs` was removed in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — no renderer ever mounted a tab bar for it, so authoring it drew nothing: the tab strip above an object's records is the saved-view switcher (ViewTabBar), which renders one tab per named list view and never read this key. Delete the key, and move each tab you want to a named list view under the object's `listViews` instead: the tab's `name` becomes the entry's key, its `label` the entry's `label`, and its `filter` rules join the view's own `filter` on that entry (copy the view's `columns` too); a tab whose `view` already named a list view needs nothing more. Every `listViews` entry renders as a tab in the switcher. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **addRecord** | `{ enabled: boolean; position?: Enum<'top' \| 'bottom' \| 'both'> }` | optional | Add record entry point configuration | | **showRecordCount** | `boolean` | optional | Show record count at the bottom of the list | @@ -2593,6 +2593,7 @@ Visualization type that users can switch to * `map` * `chart` * `tree` +* `timesheet` --- diff --git a/content/docs/ui/views.mdx b/content/docs/ui/views.mdx index 45875635f06..2a471ef99b4 100644 --- a/content/docs/ui/views.mdx +++ b/content/docs/ui/views.mdx @@ -89,6 +89,7 @@ A List View controls how a collection of records is presented. It supports multi | `map` | Geographic map pins | Location-based data | | `chart` | Aggregate chart visualization | Dashboards and summaries | | `tree` | Self-referencing hierarchy (tree-grid) | Org charts, category trees | +| `timesheet` | Editable row × weekday entry grid | Weekly time entry, daily quantities | ### List View Properties @@ -358,7 +359,7 @@ see [Element data sources](/docs/ui/pages#element-data-sources). Each non-grid visualization reads its settings from a **nested config block named after the type** (`kanban`, `calendar`, `gantt`, `gallery`, `timeline`, -`chart`, `tree`) — not from top-level keys. +`chart`, `tree`, `timesheet`) — not from top-level keys. #### Kanban @@ -397,6 +398,38 @@ gantt: { } ``` +#### Timesheet + +A timesheet pivots detail records into rows × the days of one week, and every cell is +editable. Each record lands in the row its `rowFields` values name and the day its +`dateField` falls on; the cell shows its `valueField`. + +```typescript +type: 'timesheet', +columns: ['project', 'task', 'work_date', 'hours'], +timesheet: { + rowFields: ['project', 'task'], // 1–3 fields; one row per distinct combination + dateField: 'work_date', // date or datetime; places the record on a day + valueField: 'hours', // number, currency or percent; the cell value +} +``` + +- **One record per cell.** Typing into an empty cell creates a record carrying the row's + field values, the day and the number; changing a cell updates that record; clearing it + deletes the record. Each cell is its own call on the record API, so the object's hooks, + validation rules and permissions judge it, and a refusal stays on that cell with the + server's message. +- **A cell holding several records** shows their sum and is read-only; edit those records + in a grid view. +- **The week** starts on the viewer's locale first day, with previous / this / next + navigation. Row, day and week totals are always shown. +- **Add row** asks for the row field values first; the row is kept until a typed cell + creates its first record. The view's `filter` applies to the week's query, so a row the + filter excludes disappears on the next read. + +All three keys are required: a `timesheet` view without them shows "Timesheet +configuration required", and `os validate` warns (`view/layout-without-binding`). + ### Switching views In the Console the list's title is the view switcher: it reads the open view's `label` and a diff --git a/packages/lint/src/rule-explanations.ts b/packages/lint/src/rule-explanations.ts index 36e172e7309..4d260156cbd 100644 --- a/packages/lint/src/rule-explanations.ts +++ b/packages/lint/src/rule-explanations.ts @@ -207,10 +207,11 @@ const VIEW_LAYOUT_WITHOUT_BINDING_EXPLANATION: RuleExplanation = { rule: 'view/layout-without-binding', covers: 'what each view type renders without its block', paragraphs: [ - 'Six list-view types read their layout from a config block named after the type: `kanban`, ' + - '`calendar`, `gantt`, `timeline`, `map` and `tree`. A view of one of them with no block parses ' + - 'and publishes clean, but the surface the author asked for is not the one that renders. What ' + - 'renders instead differs by type, as read from the renderer below; the rule is a warning on all six.', + 'Seven list-view types read their layout from a config block named after the type: `kanban`, ' + + '`calendar`, `gantt`, `timeline`, `map`, `tree` and `timesheet`. A view of one of them with no ' + + 'block parses and publishes clean, but the surface the author asked for is not the one that ' + + 'renders. What renders instead differs by type, as read from the renderer below; the rule is a ' + + 'warning on all seven.', '`calendar`: no date axis, and the renderer does not invent one. objectui\'s `ListView.tsx` ' + 'calendar branch forwards only the bindings the view declared, so `getCalendarConfig` ' + '(`ObjectCalendar.tsx`) resolves `null` and the view renders its "Calendar configuration ' + @@ -241,6 +242,11 @@ const VIEW_LAYOUT_WITHOUT_BINDING_EXPLANATION: RuleExplanation = { 'authoring reports success. For `tree` a block is not the whole story either: every `tree` key ' + 'is optional, and a tree with no resolvable parent pointer renders flat — that is ' + '`view/tree-without-parent-field`.', + '`timesheet`: objectui\'s `ListView.tsx` timesheet branch hands the block to `ObjectTimesheet` ' + + '(`@object-ui/plugin-timesheet`) as declared, and its `resolveTimesheetConfig` resolves `null` ' + + 'without all three keys, so the view renders its "Timesheet configuration required" screen ' + + 'instead of a grid, on any object. Declare `timesheet.rowFields`, `timesheet.dateField` and ' + + '`timesheet.valueField`, the three keys `TimesheetConfigSchema` requires.', 'A `gallery` view is not judged: no `gallery` key is required, and its fallback mis-titles ' + 'cards rather than emptying the view.', ], diff --git a/packages/lint/src/validate-field-consumers.ts b/packages/lint/src/validate-field-consumers.ts index d18a34fcae0..2d4321b1991 100644 --- a/packages/lint/src/validate-field-consumers.ts +++ b/packages/lint/src/validate-field-consumers.ts @@ -502,7 +502,7 @@ const BEHAVIOUR_SEGMENTS: ReadonlySet = new Set([ 'startField', 'endField', 'dateField', 'startDateField', 'endDateField', 'coverField', 'titleField', 'colorField', 'latitudeField', 'longitudeField', 'locationField', 'addressField', 'parentField', 'statusField', 'kanban', 'calendar', 'gantt', 'timeline', - 'map', 'tree', 'rowColor', 'rowTint', 'conditionalFormatting', + 'map', 'tree', 'timesheet', 'rowColor', 'rowTint', 'conditionalFormatting', // `settledWhen` (#22227) is the fourth field-rule predicate slot, a deadline's // settle condition — a read of the fields it names, like its three siblings. 'expression', 'formula', 'visibleWhen', 'readonlyWhen', 'requiredWhen', 'settledWhen', 'validations', diff --git a/packages/lint/src/validate-list-view-field-refs.ts b/packages/lint/src/validate-list-view-field-refs.ts index 96633d8e900..0f3b088496c 100644 --- a/packages/lint/src/validate-list-view-field-refs.ts +++ b/packages/lint/src/validate-list-view-field-refs.ts @@ -833,6 +833,16 @@ const POSITIONS: Record = { scalars: { parentField: 'error', labelField: 'warning' }, lists: { fields: 'warning' }, }, + timesheet: { + // [#34382] Every key is the grid's binding, and every one is WRITTEN: a + // typed cell creates a record carrying the row field values, the day and + // the value. A stale date field places no record on a day (an empty + // week); a stale value field sums nothing; a stale row field keys every + // record to one blank row. Each new record then writes the stale name and + // is refused at the door. + scalars: { dateField: 'error', valueField: 'error' }, + lists: { rowFields: 'error' }, + }, }; /** diff --git a/packages/spec/liveness/state-counts/view.md b/packages/spec/liveness/state-counts/view.md index 1fad8a6ef1f..d0f2b87b3cc 100644 --- a/packages/spec/liveness/state-counts/view.md +++ b/packages/spec/liveness/state-counts/view.md @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them. | Type | live | exp | elsewhere | dead | planned | classified | |---|---|---|---|---|---|---| -| `view` | 74 | 0 | 0 | 10 | 0 | 84 | +| `view` | 76 | 0 | 0 | 10 | 0 | 86 | diff --git a/packages/spec/liveness/view.json b/packages/spec/liveness/view.json index 14e87a6c9b4..ad66a92778e 100644 --- a/packages/spec/liveness/view.json +++ b/packages/spec/liveness/view.json @@ -130,22 +130,22 @@ "timesheet": { "status": "live", "evidenceScope": "in-repo", - "evidence": "ui/packages/plugin-list/src/ListView.tsx `case 'timesheet'` forwards the view's `timesheet` block into an `object-timesheet` node; ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx `resolveTimesheetConfig` reads `rowFields` (row key and the values written onto a created record), `dateField` (the week-window filter and the day column) and `valueField` (the cell value, each per-cell create/update/delete, and the totals), and renders the \"Timesheet configuration required\" refusal when any of the three is missing. Pinned by ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx.", + "evidence": "ui/packages/plugin-list/src/ListView.tsx `case 'timesheet'` forwards the view's `timesheet` block into an `object-timesheet` node; ui/packages/plugin-timesheet/src/timesheetModel.ts `resolveTimesheetConfig` (called by ObjectTimesheet.tsx) reads `rowFields` (row key and the values written onto a created record), `dateField` (the week-window filter and the day column) and `valueField` (the cell value, each per-cell create/update/delete, and the totals), and renders the \"Timesheet configuration required\" refusal when any of the three is missing. Pinned by ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx and timesheetModel.test.ts.", "children": { "rowFields": { "status": "live", "evidenceScope": "in-repo", - "evidence": "ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx `resolveTimesheetConfig` reads `rowFields`; `buildTimesheetRows` keys each row on the records' values for these fields, and a created record carries the row's values for them." + "evidence": "ui/packages/plugin-timesheet/src/timesheetModel.ts `resolveTimesheetConfig` reads `rowFields`; `buildTimesheetRows` keys each row on the records' values for these fields, and `planCellWrite` gives a created record the row's values for them." }, "dateField": { "status": "live", "evidenceScope": "in-repo", - "evidence": "ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx `resolveTimesheetConfig` reads `dateField`; the fetch filters it to the displayed week and `buildTimesheetRows` places each record on its day column." + "evidence": "ui/packages/plugin-timesheet/src/timesheetModel.ts `resolveTimesheetConfig` reads `dateField`; ObjectTimesheet.tsx's fetch filters it to the displayed week and `buildTimesheetRows` places each record on its day column." }, "valueField": { "status": "live", "evidenceScope": "in-repo", - "evidence": "ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx `resolveTimesheetConfig` reads `valueField`; each cell shows and writes it (create, update, or delete on a cleared cell) and the row, day and week totals sum it." + "evidence": "ui/packages/plugin-timesheet/src/timesheetModel.ts `resolveTimesheetConfig` reads `valueField`; `planCellWrite` writes it on each cell edit (create, update, or delete on a cleared cell) and `buildTimesheetRows` sums it into the row, day and week totals." } } }, diff --git a/packages/spec/src/ui/view.zod.ts b/packages/spec/src/ui/view.zod.ts index af024892880..5d9bd0db8bb 100644 --- a/packages/spec/src/ui/view.zod.ts +++ b/packages/spec/src/ui/view.zod.ts @@ -1903,6 +1903,7 @@ export const VisualizationTypeSchema = lazySchema(() => z.enum([ 'map', 'chart', 'tree', + 'timesheet', ]).describe('Visualization type that users can switch to')); /** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e9810d8a0f9..a0466d20b31 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3899,6 +3899,9 @@ importers: '@object-ui/plugin-timeline': specifier: workspace:* version: link:../../packages/plugin-timeline + '@object-ui/plugin-timesheet': + specifier: workspace:* + version: link:../../packages/plugin-timesheet '@object-ui/plugin-tree': specifier: workspace:* version: link:../../packages/plugin-tree @@ -5961,6 +5964,70 @@ importers: specifier: ^4.1.10 version: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@26.6.5)(@vitest/coverage-v8@4.1.12)(@vitest/ui@4.1.10)(happy-dom@21.0.4)(jsdom@30.1.1(@noble/hashes@2.4.0))(msw@2.15.0(@types/node@26.6.5)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.5)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15(patch_hash=4d1d35da1809be2a945519cb26890e48107810b9b66c6913a6a89abb5ad6a1e6))(yaml@2.9.1)) + ui/packages/plugin-timesheet: + dependencies: + '@object-ui/components': + specifier: workspace:* + version: link:../components + '@object-ui/core': + specifier: workspace:* + version: link:../core + '@object-ui/fields': + specifier: workspace:* + version: link:../fields + '@object-ui/i18n': + specifier: workspace:* + version: link:../i18n + '@object-ui/permissions': + specifier: workspace:* + version: link:../permissions + '@object-ui/react': + specifier: workspace:* + version: link:../react + '@object-ui/types': + specifier: workspace:* + version: link:../types + '@objectstack/spec': + specifier: workspace:^ + version: link:../../../packages/spec + lucide-react: + specifier: ^1.43.0 + version: 1.43.0(react@19.3.0) + react: + specifier: 19.3.0 + version: 19.3.0 + react-dom: + specifier: 19.3.0 + version: 19.3.0(react@19.3.0) + devDependencies: + '@object-ui/test-support': + specifier: workspace:* + version: link:../test-support + '@objectstack/sdui-parser': + specifier: workspace:* + version: link:../../../packages/sdui-parser + '@types/react': + specifier: 19.3.0 + version: 19.3.0 + '@types/react-dom': + specifier: 19.3.0 + version: 19.3.0(@types/react@19.3.0) + '@vitejs/plugin-react': + specifier: ^6.0.5 + version: 6.0.5(vite@8.3.5(@types/node@26.6.5)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15(patch_hash=4d1d35da1809be2a945519cb26890e48107810b9b66c6913a6a89abb5ad6a1e6))(yaml@2.9.1)) + typescript: + specifier: ^6.0.3 + version: 6.0.3 + vite: + specifier: ^8.2.1 + version: 8.3.5(@types/node@26.6.5)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15(patch_hash=4d1d35da1809be2a945519cb26890e48107810b9b66c6913a6a89abb5ad6a1e6))(yaml@2.9.1) + vite-plugin-dts: + specifier: ^5.1.2 + version: 5.1.2(@microsoft/api-extractor@7.58.2(@types/node@26.6.5))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.62.2)(typescript@6.0.3)(vite@8.3.5(@types/node@26.6.5)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15(patch_hash=4d1d35da1809be2a945519cb26890e48107810b9b66c6913a6a89abb5ad6a1e6))(yaml@2.9.1)) + vitest: + specifier: ^4.1.10 + version: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@26.6.5)(@vitest/coverage-v8@4.1.12)(@vitest/ui@4.1.10)(happy-dom@21.0.4)(jsdom@30.1.1(@noble/hashes@2.4.0))(msw@2.15.0(@types/node@26.6.5)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.5)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15(patch_hash=4d1d35da1809be2a945519cb26890e48107810b9b66c6913a6a89abb5ad6a1e6))(yaml@2.9.1)) + ui/packages/plugin-tree: dependencies: '@object-ui/components': diff --git a/ui/apps/console/dev/manifest-registry.ts b/ui/apps/console/dev/manifest-registry.ts index 3f2128489a2..2736f153cc3 100644 --- a/ui/apps/console/dev/manifest-registry.ts +++ b/ui/apps/console/dev/manifest-registry.ts @@ -36,3 +36,4 @@ import '@object-ui/plugin-map'; import '@object-ui/plugin-markdown'; import '@object-ui/plugin-report'; import '@object-ui/plugin-tree'; +import '@object-ui/plugin-timesheet'; diff --git a/ui/apps/console/package.json b/ui/apps/console/package.json index 7f1e11871fd..812a7f92c5b 100644 --- a/ui/apps/console/package.json +++ b/ui/apps/console/package.json @@ -82,6 +82,7 @@ "@object-ui/plugin-markdown": "workspace:*", "@object-ui/plugin-report": "workspace:*", "@object-ui/plugin-timeline": "workspace:*", + "@object-ui/plugin-timesheet": "workspace:*", "@object-ui/plugin-tree": "workspace:*", "@object-ui/plugin-view": "workspace:*", "@object-ui/react": "workspace:*", diff --git a/ui/apps/console/src/register-plugins.ts b/ui/apps/console/src/register-plugins.ts index 292ebd0d0fc..8d40edc09f7 100644 --- a/ui/apps/console/src/register-plugins.ts +++ b/ui/apps/console/src/register-plugins.ts @@ -106,6 +106,14 @@ ComponentRegistry.registerLazy('object-tree', () => import('@object-ui/plugin-tr namespace: 'plugin-tree', category: 'view', }); + +// objectstack#34382 — the editable row × weekday grid a `type: 'timesheet'` +// list view draws (`ListView` composes the `object-timesheet` node). Lazy like +// every view plugin, and its strings ride their own lazy locale namespace. +ComponentRegistry.registerLazy('object-timesheet', () => import('@object-ui/plugin-timesheet'), { + namespace: 'plugin-timesheet', + category: 'view', +}); // ⛔ The bare `tree` node type key is RETIRED (objectui#10859 batch 8, the // objectui#10393 route) — `object-tree` above is the surviving spelling. The // STORED / host view type `tree` is a different layer and is untouched: diff --git a/ui/apps/console/vite.config.ts b/ui/apps/console/vite.config.ts index bfd612ae2b5..f818b608e98 100644 --- a/ui/apps/console/vite.config.ts +++ b/ui/apps/console/vite.config.ts @@ -661,6 +661,7 @@ const workspaceAliases: Record = { '@object-ui/plugin-map': path.resolve(import.meta.dirname, '../../packages/plugin-map/src'), '@object-ui/plugin-markdown': path.resolve(import.meta.dirname, '../../packages/plugin-markdown/src'), '@object-ui/plugin-timeline': path.resolve(import.meta.dirname, '../../packages/plugin-timeline/src'), + '@object-ui/plugin-timesheet': path.resolve(import.meta.dirname, '../../packages/plugin-timesheet/src'), '@object-ui/plugin-tree': path.resolve(import.meta.dirname, '../../packages/plugin-tree/src'), '@object-ui/plugin-view/core': path.resolve(import.meta.dirname, '../../packages/plugin-view/src/core.ts'), '@object-ui/plugin-view': path.resolve(import.meta.dirname, '../../packages/plugin-view/src'), @@ -1538,6 +1539,7 @@ export default defineConfig({ { name: 'plugin-markdown', test: /[\\/]packages[\\/]plugin-markdown[\\/]/, priority: 70 }, { name: 'plugin-timeline', test: /[\\/]packages[\\/]plugin-timeline[\\/]/, priority: 70 }, { name: 'plugin-tree', test: /[\\/]packages[\\/]plugin-tree[\\/]/, priority: 70 }, + { name: 'plugin-timesheet', test: /[\\/]packages[\\/]plugin-timesheet[\\/]/, priority: 70 }, { name: 'plugin-calendar', test: /[\\/]packages[\\/]plugin-calendar[\\/]/, priority: 70 }, { name: 'plugin-kanban', test: /[\\/]packages[\\/]plugin-kanban[\\/]/, priority: 70 }, // diff --git a/ui/packages/app-shell/src/views/CreateViewDialog.tsx b/ui/packages/app-shell/src/views/CreateViewDialog.tsx index 6b37e6a7fe3..457847506fa 100644 --- a/ui/packages/app-shell/src/views/CreateViewDialog.tsx +++ b/ui/packages/app-shell/src/views/CreateViewDialog.tsx @@ -72,6 +72,7 @@ import { Map as MapIcon, BarChart3, ListTree, + CalendarClock, AlertCircle, } from 'lucide-react'; @@ -149,6 +150,7 @@ function buildViewTypeMeta(t: (k: string) => string): ViewTypeMeta[] { map: { icon: MapIcon, label: t('console.objectView.viewTypeMap'), description: t('console.objectView.viewTypeMapDesc') }, chart: { icon: BarChart3, label: t('console.objectView.viewTypeChart'), description: t('console.objectView.viewTypeChartDesc') }, tree: { icon: ListTree, label: t('console.objectView.viewTypeTree'), description: t('console.objectView.viewTypeTreeDesc') }, + timesheet: { icon: CalendarClock, label: t('console.objectView.viewTypeTimesheet'), description: t('console.objectView.viewTypeTimesheetDesc') }, }; return (Object.entries(meta) as [ListViewVisualization, Omit][]) .map(([type, row]) => ({ type, ...row })); @@ -452,6 +454,30 @@ const REQUIRED_FIELDS_BY_TYPE: Record = { f.rawType === 'master_detail', }, ], + // objectstack#34382 — the dialog picks ONE row field (`rowFields` is a list + // of one to three; more are added in the view's settings), the date field + // and the numeric value field the cells edit. + timesheet: [ + { + key: 'rowFields', + i18nKey: 'console.objectView.timesheetRowField', + helpI18nKey: 'console.objectView.timesheetRowFieldHelp', + list: true, + }, + { + key: 'dateField', + i18nKey: 'console.objectView.timesheetDateField', + helpI18nKey: 'console.objectView.timesheetDateFieldHelp', + filter: (f) => f.type === 'date', + preferred: PRIMARY_DATE_PREFERRED, + }, + { + key: 'valueField', + i18nKey: 'console.objectView.timesheetValueField', + helpI18nKey: 'console.objectView.timesheetValueFieldHelp', + filter: (f) => f.rawType === 'number' || f.rawType === 'currency' || f.rawType === 'percent', + }, + ], // grid has no strictly required fields at create time }; diff --git a/ui/packages/app-shell/src/views/CreateViewDialog.viewTypeParse-11581.test.tsx b/ui/packages/app-shell/src/views/CreateViewDialog.viewTypeParse-11581.test.tsx index 69c96072a47..c86b32aea51 100644 --- a/ui/packages/app-shell/src/views/CreateViewDialog.viewTypeParse-11581.test.tsx +++ b/ui/packages/app-shell/src/views/CreateViewDialog.viewTypeParse-11581.test.tsx @@ -201,6 +201,11 @@ const PARSE_ROWS: Record = { block: { chartType: 'bar', dataset: 'deal_metrics', values: ['total_amount'], dimensions: ['stage'] }, }, tree: { picks: [['parentField', 'Parent deal']], block: { parentField: 'parent' } }, + // objectstack#34382 — one row field, written as the spec's list. + timesheet: { + picks: [['rowFields', 'Stage'], ['dateField', 'Start'], ['valueField', 'Amount']], + block: { rowFields: ['stage'], dateField: 'start_date', valueField: 'amount' }, + }, }; /** diff --git a/ui/packages/app-shell/src/views/newViewSpec.ts b/ui/packages/app-shell/src/views/newViewSpec.ts index accf26f1db9..6aa6dc971ac 100644 --- a/ui/packages/app-shell/src/views/newViewSpec.ts +++ b/ui/packages/app-shell/src/views/newViewSpec.ts @@ -57,6 +57,7 @@ const COLUMN_MIRRORS: Record = { map: null, chart: null, tree: null, + timesheet: null, }; /** diff --git a/ui/packages/app-shell/src/views/objectViewListRenderer.tsx b/ui/packages/app-shell/src/views/objectViewListRenderer.tsx index 48bc4da498e..8463bb207df 100644 --- a/ui/packages/app-shell/src/views/objectViewListRenderer.tsx +++ b/ui/packages/app-shell/src/views/objectViewListRenderer.tsx @@ -966,6 +966,11 @@ export function useObjectViewListRenderer({ // rather than the old permanently-truthy husk, which is what // keeps the gate from offering a chart nobody configured. chart: holdBlock('chart', viewDef.chart), + // The timesheet binding the view DECLARED, forwarded whole for + // the reason the chart block above is: `ListView`'s capability + // gate and `case 'timesheet'` read its three keys by name + // (objectstack#34382). + timesheet: holdBlock('timesheet', viewDef.timesheet), }; diff --git a/ui/packages/app-shell/src/views/studio-design/ListViewMoreSection.tsx b/ui/packages/app-shell/src/views/studio-design/ListViewMoreSection.tsx index 71b49a69430..813e41a9b81 100644 --- a/ui/packages/app-shell/src/views/studio-design/ListViewMoreSection.tsx +++ b/ui/packages/app-shell/src/views/studio-design/ListViewMoreSection.tsx @@ -58,6 +58,7 @@ const EDITED_BY_THE_PANEL: ReadonlySet = new Set([ 'gantt', 'map', 'tree', + 'timesheet', ]); /** The fields the curated controls own, hidden from the form as the view inspector hides them. */ diff --git a/ui/packages/app-shell/src/views/studio-design/ListViewTypeSection.tsx b/ui/packages/app-shell/src/views/studio-design/ListViewTypeSection.tsx index 17ad0ee5da3..bb0f39ea895 100644 --- a/ui/packages/app-shell/src/views/studio-design/ListViewTypeSection.tsx +++ b/ui/packages/app-shell/src/views/studio-design/ListViewTypeSection.tsx @@ -66,6 +66,7 @@ const VIEW_TYPE_LABEL_KEYS: Record = { map: 'engine.inspector.view.type.map', chart: 'engine.inspector.view.type.chart', tree: 'engine.inspector.view.type.tree', + timesheet: 'engine.inspector.view.type.timesheet', }; /** diff --git a/ui/packages/cli/src/utils/known-schema-types.ts b/ui/packages/cli/src/utils/known-schema-types.ts index 5e60be00822..6445a3d7649 100644 --- a/ui/packages/cli/src/utils/known-schema-types.ts +++ b/ui/packages/cli/src/utils/known-schema-types.ts @@ -240,6 +240,7 @@ export const KNOWN_SCHEMA_TYPES: readonly string[] = [ 'object-metric', 'object-pivot', 'object-timeline', + 'object-timesheet', 'object-tree', 'object-view', 'ol', @@ -295,6 +296,7 @@ export const KNOWN_SCHEMA_TYPES: readonly string[] = [ 'plugin-report:report-viewer', 'plugin-timeline:object-timeline', 'plugin-timeline:timeline', + 'plugin-timesheet:object-timesheet', 'plugin-tree:object-tree', 'plugin-view:object-view', 'plugin-view:view:simple', diff --git a/ui/packages/core/src/utils/normalize-list-view.ts b/ui/packages/core/src/utils/normalize-list-view.ts index 5ee8a5c92a6..3b9a15e6ae4 100644 --- a/ui/packages/core/src/utils/normalize-list-view.ts +++ b/ui/packages/core/src/utils/normalize-list-view.ts @@ -224,6 +224,7 @@ const LIST_VIEW_KINDS: Record = { map: true, chart: true, tree: true, + timesheet: true, }; /** diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index 6c1b37e4d93..0470a050f48 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -2765,8 +2765,16 @@ const ar = { }, viewTypeTree: "شجرة", viewTypeTreeDesc: "يرتّب السجلات ذاتية المرجعية في تسلسل هرمي عبر حقل أب.", + viewTypeTimesheet: "جدول الساعات", + viewTypeTimesheetDesc: "أدخل رقمًا لكل صف ويوم من أيام الأسبوع؛ كل خلية معبأة سجل واحد.", parentField: "الحقل الأب", parentFieldHelp: "الحقل الذي يشير إلى السجل الأب (الكائن نفسه) ويحدد التسلسل الهرمي. الحقول ذاتية المرجعية فقط هي المؤهلة.", + timesheetRowField: "حقل الصف", + timesheetRowFieldHelp: "كل صف في الشبكة قيمة واحدة لهذا الحقل، مثل مشروع.", + timesheetDateField: "حقل التاريخ", + timesheetDateFieldHelp: "توضع السجلات في عمود يوم الأسبوع المطابق لهذا التاريخ.", + timesheetValueField: "حقل القيمة", + timesheetValueFieldHelp: "الرقم الذي تعرضه كل خلية وتعدّله، مثل الساعات.", viewName: "الاسم", viewNameHelp: "مفتاح برمجي (snake_case). يُملأ تلقائيًا من العنوان — عدّله إن أردت.", viewNameRequired: "أدخل مفتاحًا (أحرف إنجليزية صغيرة وأرقام وشرطة سفلية). لا يُملأ تلقائيًا للعناوين غير اللاتينية.", diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index e13a0334a49..62e86ada73c 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -2510,8 +2510,16 @@ const de = { }, viewTypeTree: "Baum", viewTypeTreeDesc: "Selbstreferenzierende Datensätze über ein übergeordnetes Feld zu einer Hierarchie verschachteln.", + viewTypeTimesheet: "Zeiterfassung", + viewTypeTimesheetDesc: "Eine Zahl pro Zeile und Wochentag eingeben; jede ausgefüllte Zelle ist ein Datensatz.", parentField: "Übergeordnetes Feld", parentFieldHelp: "Das Feld, das auf den übergeordneten Datensatz (dasselbe Objekt) verweist und die Hierarchie definiert. Nur selbstreferenzierende Felder kommen infrage.", + timesheetRowField: "Zeilenfeld", + timesheetRowFieldHelp: "Jede Zeile des Rasters ist ein Wert dieses Felds, etwa ein Projekt.", + timesheetDateField: "Datumsfeld", + timesheetDateFieldHelp: "Datensätze werden dem Wochentag dieses Datums zugeordnet.", + timesheetValueField: "Wertfeld", + timesheetValueFieldHelp: "Die Zahl, die jede Zelle anzeigt und bearbeitet, etwa Stunden.", viewName: "Name", viewNameHelp: "Technischer Schlüssel (snake_case). Wird aus dem Titel automatisch gefüllt — bei Bedarf anpassen.", viewNameRequired: "Geben Sie einen Schlüssel ein (Kleinbuchstaben, Ziffern, Unterstrich). Bei nicht-lateinischen Titeln wird er nicht automatisch gefüllt.", diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index 05de0782a93..5b52f897dce 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -3185,8 +3185,16 @@ const en = { viewTypeChartDesc: 'Aggregated bar / line / pie visualisations.', viewTypeTree: 'Tree', viewTypeTreeDesc: 'Nest self-referencing records into a hierarchy by a parent field.', + viewTypeTimesheet: 'Timesheet', + viewTypeTimesheetDesc: 'Enter a number per row and weekday; each filled cell is one record.', parentField: 'Parent field', parentFieldHelp: 'The field pointing to the parent record (same object) that defines the hierarchy. Only self-referencing fields qualify.', + timesheetRowField: 'Row field', + timesheetRowFieldHelp: 'Each row of the grid is one value of this field, such as a project.', + timesheetDateField: 'Date field', + timesheetDateFieldHelp: 'Records are placed on the weekday matching this date.', + timesheetValueField: 'Value field', + timesheetValueFieldHelp: 'The number each cell shows and edits, such as hours.', newView: 'New View', viewName: 'Name', viewNameHelp: 'Machine key (snake_case). Auto-filled from the title — edit if you like.', diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index 29a924f63e9..25282cc1db9 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -2576,8 +2576,16 @@ const es = { }, viewTypeTree: "Árbol", viewTypeTreeDesc: "Anida los registros autorreferenciados en una jerarquía mediante un campo principal.", + viewTypeTimesheet: "Hoja de horas", + viewTypeTimesheetDesc: "Introduce un número por fila y día de la semana; cada celda rellena es un registro.", parentField: "Campo principal", parentFieldHelp: "El campo que apunta al registro principal (mismo objeto) y define la jerarquía. Solo son válidos los campos autorreferenciados.", + timesheetRowField: "Campo de fila", + timesheetRowFieldHelp: "Cada fila de la cuadrícula es un valor de este campo, como un proyecto.", + timesheetDateField: "Campo de fecha", + timesheetDateFieldHelp: "Los registros se colocan en el día de la semana de esta fecha.", + timesheetValueField: "Campo de valor", + timesheetValueFieldHelp: "El número que cada celda muestra y edita, como las horas.", viewName: "Nombre", viewNameHelp: "Clave técnica (snake_case). Se rellena automáticamente a partir del título — edítela si lo desea.", viewNameRequired: "Introduzca una clave (minúsculas, números, guion bajo). No se rellena automáticamente con títulos no latinos.", diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index d8267583b7a..ee5fbafe392 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -2572,8 +2572,16 @@ const fr = { }, viewTypeTree: "Arborescence", viewTypeTreeDesc: "Imbriquer les enregistrements auto-référencés en hiérarchie via un champ parent.", + viewTypeTimesheet: "Feuille de temps", + viewTypeTimesheetDesc: "Saisissez un nombre par ligne et par jour ; chaque cellule remplie est un enregistrement.", parentField: "Champ parent", parentFieldHelp: "Le champ pointant vers l'enregistrement parent (même objet) qui définit la hiérarchie. Seuls les champs auto-référencés conviennent.", + timesheetRowField: "Champ de ligne", + timesheetRowFieldHelp: "Chaque ligne de la grille est une valeur de ce champ, par exemple un projet.", + timesheetDateField: "Champ de date", + timesheetDateFieldHelp: "Les enregistrements sont placés sur le jour correspondant à cette date.", + timesheetValueField: "Champ de valeur", + timesheetValueFieldHelp: "Le nombre que chaque cellule affiche et modifie, par exemple des heures.", viewName: "Nom", viewNameHelp: "Clé technique (snake_case). Remplie automatiquement à partir du titre — modifiable si vous le souhaitez.", viewNameRequired: "Saisissez une clé (minuscules, chiffres, tiret bas). Non remplie automatiquement pour les titres non latins.", diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index 69b4c36ae06..d8524e3b17e 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -2512,8 +2512,16 @@ const ja = { }, viewTypeTree: "ツリー", viewTypeTreeDesc: "親項目によって自己参照レコードを階層に入れ子にします。", + viewTypeTimesheet: "タイムシート", + viewTypeTimesheetDesc: "行と曜日ごとに数値を入力します。入力済みのセルが1件のレコードです。", parentField: "親項目", parentFieldHelp: "階層を定義する親レコード(同一オブジェクト)を指す項目です。自己参照の項目のみ指定できます。", + timesheetRowField: "行の項目", + timesheetRowFieldHelp: "グリッドの各行はこの項目の値(例: プロジェクト)に対応します。", + timesheetDateField: "日付項目", + timesheetDateFieldHelp: "レコードはこの日付の曜日列に配置されます。", + timesheetValueField: "数値項目", + timesheetValueFieldHelp: "各セルに表示・編集する数値(例: 時間)です。", viewName: "名前", viewNameHelp: "マシンキー(snake_case)。タイトルから自動入力されます — 必要に応じて編集してください。", viewNameRequired: "キーを入力してください(英小文字、数字、アンダースコア)。ラテン文字以外のタイトルでは自動入力されません。", diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index a390244a8b2..7a6681c6112 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -2510,8 +2510,16 @@ const ko = { }, viewTypeTree: "트리", viewTypeTreeDesc: "상위 필드를 기준으로 자기 참조 레코드를 계층 구조로 중첩합니다.", + viewTypeTimesheet: "타임시트", + viewTypeTimesheetDesc: "행과 요일별로 숫자를 입력합니다. 입력된 셀 하나가 레코드 하나입니다.", parentField: "상위 필드", parentFieldHelp: "계층 구조를 정의하는 상위 레코드(같은 객체)를 가리키는 필드입니다. 자기 참조 필드만 사용할 수 있습니다.", + timesheetRowField: "행 필드", + timesheetRowFieldHelp: "그리드의 각 행은 이 필드의 값 하나(예: 프로젝트)입니다.", + timesheetDateField: "날짜 필드", + timesheetDateFieldHelp: "레코드는 이 날짜에 해당하는 요일 열에 놓입니다.", + timesheetValueField: "값 필드", + timesheetValueFieldHelp: "각 셀에 표시되고 편집되는 숫자(예: 시간)입니다.", viewName: "이름", viewNameHelp: "머신 키(snake_case)입니다. 제목에서 자동으로 채워집니다 — 원하면 수정하세요.", viewNameRequired: "키를 입력하세요(소문자, 숫자, 밑줄). 비라틴 문자 제목에서는 자동으로 채워지지 않습니다.", diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index e229bb8cb57..0f59f40cc27 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -2571,8 +2571,16 @@ const pt = { }, viewTypeTree: "Árvore", viewTypeTreeDesc: "Aninha registros autorreferenciados em uma hierarquia por um campo pai.", + viewTypeTimesheet: "Folha de horas", + viewTypeTimesheetDesc: "Informe um número por linha e dia da semana; cada célula preenchida é um registro.", parentField: "Campo pai", parentFieldHelp: "O campo que aponta para o registro pai (mesmo objeto) e define a hierarquia. Apenas campos autorreferenciados são válidos.", + timesheetRowField: "Campo de linha", + timesheetRowFieldHelp: "Cada linha da grade é um valor deste campo, como um projeto.", + timesheetDateField: "Campo de data", + timesheetDateFieldHelp: "Os registros são colocados no dia da semana desta data.", + timesheetValueField: "Campo de valor", + timesheetValueFieldHelp: "O número que cada célula mostra e edita, como horas.", viewName: "Nome", viewNameHelp: "Chave técnica (snake_case). Preenchida automaticamente a partir do título — edite se quiser.", viewNameRequired: "Informe uma chave (letras minúsculas, números, sublinhado). Não é preenchida automaticamente para títulos não latinos.", diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index 2b96fe82ee3..d287987cdab 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -2644,8 +2644,16 @@ const ru = { }, viewTypeTree: "Дерево", viewTypeTreeDesc: "Выстраивает самоссылающиеся записи в иерархию по родительскому полю.", + viewTypeTimesheet: "Табель", + viewTypeTimesheetDesc: "Введите число для каждой строки и дня недели; каждая заполненная ячейка — одна запись.", parentField: "Родительское поле", parentFieldHelp: "Поле, указывающее на родительскую запись (тот же объект) и задающее иерархию. Подходят только самоссылающиеся поля.", + timesheetRowField: "Поле строки", + timesheetRowFieldHelp: "Каждая строка сетки — одно значение этого поля, например проект.", + timesheetDateField: "Поле даты", + timesheetDateFieldHelp: "Записи размещаются в столбце дня недели по этой дате.", + timesheetValueField: "Поле значения", + timesheetValueFieldHelp: "Число, которое показывает и редактирует каждая ячейка, например часы.", viewName: "Название", viewNameHelp: "Машинный ключ (snake_case). Заполняется автоматически из заголовка — при желании измените.", viewNameRequired: "Введите ключ (строчные буквы, цифры, подчёркивание). Для нелатинских заголовков автозаполнение не работает.", diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index f3936cb8be0..2523b719209 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -2688,8 +2688,16 @@ const zh = { viewTypeChartDesc: '聚合的柱状/折线/饼状图。', viewTypeTree: '树形', viewTypeTreeDesc: '按父级字段把自引用记录嵌套成层级树。', + viewTypeTimesheet: '工时表', + viewTypeTimesheetDesc: '按行和星期逐格填写数值,每个已填格子对应一条记录。', parentField: '父级字段', parentFieldHelp: '指向同一对象的父级字段,决定树的层级(仅自引用字段可选)。', + timesheetRowField: '行字段', + timesheetRowFieldHelp: '表格的每一行对应该字段的一个取值,例如项目。', + timesheetDateField: '日期字段', + timesheetDateFieldHelp: '记录按该日期落在对应的星期列。', + timesheetValueField: '数值字段', + timesheetValueFieldHelp: '每个格子显示和编辑的数值,例如工时。', newView: '新视图', viewName: '名称', viewNameHelp: '机器标识(snake_case),根据标题自动生成,可自行修改。', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index bb963982c9f..30b9b069752 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -2688,8 +2688,16 @@ const zhHant = { viewTypeChartDesc: '聚合的柱狀/折線/餅狀圖。', viewTypeTree: '樹形', viewTypeTreeDesc: '按父級欄位把自引用記錄巢狀成層級樹。', + viewTypeTimesheet: '工時表', + viewTypeTimesheetDesc: '按行和星期逐格填寫數值,每個已填格子對應一條記錄。', parentField: '父級欄位', parentFieldHelp: '指向同一物件的父級欄位,決定樹的層級(僅自引用欄位可選)。', + timesheetRowField: '行欄位', + timesheetRowFieldHelp: '表格的每一行對應該欄位的一個取值,例如專案。', + timesheetDateField: '日期欄位', + timesheetDateFieldHelp: '記錄按該日期落在對應的星期列。', + timesheetValueField: '數值欄位', + timesheetValueFieldHelp: '每個格子顯示和編輯的數值,例如工時。', newView: '新檢視', viewName: '名稱', viewNameHelp: '機器標識(snake_case),根據標題自動生成,可自行修改。', diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index 2387370b143..08e4a303f68 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -1496,6 +1496,7 @@ const STUDIO_EN: Record = { 'engine.inspector.view.type.map': 'Map', 'engine.inspector.view.type.chart': 'Chart', 'engine.inspector.view.type.tree': 'Tree', + 'engine.inspector.view.type.timesheet': 'Timesheet', // Report default ("home") inspector 'engine.inspector.report.kind': 'Report', 'engine.inspector.report.close': 'Close report', diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index ab5164daba9..317e550df6a 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -1329,6 +1329,7 @@ const STUDIO_ZH: Record = { 'engine.inspector.view.type.map': '地图', 'engine.inspector.view.type.chart': '图表', 'engine.inspector.view.type.tree': '树形', + 'engine.inspector.view.type.timesheet': '工时表', // Report default ("home") inspector 'engine.inspector.report.kind': '报表', 'engine.inspector.report.close': '关闭报表', diff --git a/ui/packages/plugin-list/src/ListView.tsx b/ui/packages/plugin-list/src/ListView.tsx index f62cd135210..83a7cc14261 100644 --- a/ui/packages/plugin-list/src/ListView.tsx +++ b/ui/packages/plugin-list/src/ListView.tsx @@ -2105,7 +2105,9 @@ export const ListView = React.forwardRef(({ * typed term itself is kept: switching back to a view that draws the * fetched rows applies it again. */ - const searchlessViewOnScreen = currentView === 'tree' || currentView === 'chart'; + // `timesheet` (objectstack#34382) is searchless for the same reason: its + // week query takes the view filter and the date window, and no term. + const searchlessViewOnScreen = currentView === 'tree' || currentView === 'chart' || currentView === 'timesheet'; // The object definition, read from the data source below ("Fetch object // definition"). Declared here because the toolbar's search decision reads it. @@ -4383,6 +4385,14 @@ export const ListView = React.forwardRef(({ resolvable.push('chart'); } + // Check for Timesheet capabilities — the three keys `ObjectTimesheet`'s + // `resolveTimesheetConfig` requires, so the switcher never offers a grid + // that would draw its "configuration required" screen (objectstack#34382). + const timesheet = schema.timesheet; + if (Array.isArray(timesheet?.rowFields) && timesheet.rowFields.length > 0 && timesheet?.dateField && timesheet?.valueField) { + resolvable.push('timesheet'); + } + // Always allow switching back to the viewType defined in schema — but only // when it names a visualization this renderer actually draws. // @@ -4410,7 +4420,7 @@ export const ListView = React.forwardRef(({ } return resolvable; - }, [schema.viewType, schema.kanban, schema.calendar, schema.gantt, schema.gallery, schema.timeline, schema.map, schema.tree, schema.chart, schema.appearance?.allowedVisualizations]); + }, [schema.viewType, schema.kanban, schema.calendar, schema.gantt, schema.gallery, schema.timeline, schema.map, schema.tree, schema.chart, schema.timesheet, schema.appearance?.allowedVisualizations]); /** * Whether the visualization switcher is actually WORTH drawing (objectui#7547). @@ -4715,7 +4725,7 @@ export const ListView = React.forwardRef(({ */ const selfQueryFilterRef = React.useRef<{ key: string; value: unknown } | null>(null); let selfQueryFilter: unknown = authoredFilter; - if (currentView === 'gantt' || currentView === 'tree' || currentView === 'chart' || gridOwnsGroupedFetch || kanbanLanesPaged) { + if (currentView === 'gantt' || currentView === 'tree' || currentView === 'chart' || currentView === 'timesheet' || gridOwnsGroupedFetch || kanbanLanesPaged) { try { const value = buildEffectiveFilter(authoredFilter, appliedFilters, appliedUserFilterConditions, appliedQueueSittingConditions); const key = JSON.stringify(value ?? null); @@ -5326,6 +5336,20 @@ export const ListView = React.forwardRef(({ defaultExpandedDepth: treeCfg.defaultExpandedDepth, }; } + case 'timesheet': { + // objectstack#34382 — the editable row × weekday grid. It runs its own + // week query from `filter` (the effective filter, so the toolbar + // Filter and the chips reach it — see `selfQueryFilter` above) and + // reads the spec's `timesheet` block by name; `ObjectTimesheet`'s + // `resolveTimesheetConfig` judges it and draws the refusal screen + // when it is incomplete. + return { + type: 'object-timesheet', + ...baseProps, + filter: selfQueryFilter, + timesheet: schema.timesheet, + }; + } case 'chart': { // A `chart` list view renders a chart of an ADR-0021 `dataset`, // delegating to the same object-chart component the dashboard uses. diff --git a/ui/packages/plugin-list/src/ViewSwitcher.tsx b/ui/packages/plugin-list/src/ViewSwitcher.tsx index 39d285d851b..bd6ac8e292e 100644 --- a/ui/packages/plugin-list/src/ViewSwitcher.tsx +++ b/ui/packages/plugin-list/src/ViewSwitcher.tsx @@ -20,6 +20,7 @@ import { Map, // map ChartColumn, // chart ListTree, // tree + CalendarClock, // timesheet Check, ChevronDown, } from 'lucide-react'; @@ -92,6 +93,7 @@ const VIEW_ICONS: Record = { map: , chart: , tree: , + timesheet: , }; /** @@ -119,6 +121,7 @@ const VIEW_LABEL_KEYS: Record = { map: 'console.objectView.viewTypeMap', chart: 'console.objectView.viewTypeChart', tree: 'console.objectView.viewTypeTree', + timesheet: 'console.objectView.viewTypeTimesheet', }; /** @@ -141,6 +144,7 @@ const VIEW_LABEL_DEFAULTS: Record = { 'console.objectView.viewTypeMap': 'Map', 'console.objectView.viewTypeChart': 'Chart', 'console.objectView.viewTypeTree': 'Tree', + 'console.objectView.viewTypeTimesheet': 'Timesheet', }; const useViewSwitcherTranslation = createSafeTranslation( diff --git a/ui/packages/plugin-list/src/index.tsx b/ui/packages/plugin-list/src/index.tsx index 97a97cb5f91..b48b44935f2 100644 --- a/ui/packages/plugin-list/src/index.tsx +++ b/ui/packages/plugin-list/src/index.tsx @@ -67,6 +67,7 @@ const VIEW_TYPE_LABELS: Record = { map: 'Map', chart: 'Chart', tree: 'Tree', + timesheet: 'Timesheet', }; const VIEW_TYPE_OPTIONS = Object.entries(VIEW_TYPE_LABELS).map(([value, label]) => ({ label, value })); @@ -360,6 +361,12 @@ const LIST_VIEW_INPUTS: ComponentInput[] = [ description: 'The chart a `type: "chart"` list draws, bound to an ADR-0021 dataset: `{ dataset, values, dimensions, chartType }`. There is no default binding.', }, + { + name: 'timesheet', + type: 'object', + description: + 'The editable row × weekday grid a `type: "timesheet"` list draws: `{ rowFields, dateField, valueField }`. All three are required; each typed cell creates, updates or deletes one record.', + }, ]; // Register ListView component diff --git a/ui/packages/plugin-timesheet/CHANGELOG.md b/ui/packages/plugin-timesheet/CHANGELOG.md new file mode 100644 index 00000000000..9dde5d9c75e --- /dev/null +++ b/ui/packages/plugin-timesheet/CHANGELOG.md @@ -0,0 +1 @@ +# @object-ui/plugin-timesheet diff --git a/ui/packages/plugin-timesheet/LICENSE b/ui/packages/plugin-timesheet/LICENSE new file mode 100644 index 00000000000..cf2ca28574c --- /dev/null +++ b/ui/packages/plugin-timesheet/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 ObjectQL + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ui/packages/plugin-timesheet/README.md b/ui/packages/plugin-timesheet/README.md new file mode 100644 index 00000000000..49a50612833 --- /dev/null +++ b/ui/packages/plugin-timesheet/README.md @@ -0,0 +1,80 @@ +# @object-ui/plugin-timesheet + +Timesheet view plugin for Object UI: an editable **row × weekday** entry grid. + +A list view of `type: 'timesheet'` pivots detail records (time entries, daily +quantities) into rows × the seven days of one week. Each record lands in the row +its `rowFields` values name and the day its `dateField` falls on, and the cell +shows its `valueField`. Every cell is editable, and every edit is one call on the +record API. + +It registers one component type via the `ComponentRegistry`: + +- `object-timesheet` — composed by `@object-ui/plugin-list`'s `ListView` for a + `timesheet` view. It is not a curated page block. + +## Usage + +Declare the view in metadata; `ListView` composes the node: + +```ts +const view = { + type: 'timesheet', + data: { provider: 'object', object: 'time_entry' }, + columns: ['project', 'task', 'work_date', 'hours'], + timesheet: { + rowFields: ['project', 'task'], // 1–3 fields; one row per distinct combination + dateField: 'work_date', // date or datetime + valueField: 'hours', // number, currency or percent + }, +}; +``` + +The component can also be rendered directly: + +```tsx +import { ObjectTimesheet } from '@object-ui/plugin-timesheet'; + +; +``` + +### Keys + +| Key | Description | +| --- | --- | +| `objectName` | The object whose records the grid pivots. | +| `timesheet` | `{ rowFields, dateField, valueField }`. All three are required; without them the grid shows "Timesheet configuration required". | +| `filter` | Base filter, joined with the displayed week on `dateField`. | + +## Behaviour + +- **Writes.** Typing into an empty cell `create`s a record carrying the row field + values, the day and the number. Changing a cell `update`s that record; clearing + it `delete`s it. Hooks, validation and permissions judge each cell; a refusal + stays on the cell with the server's message and the typed text, and Enter retries. + Every write is announced with `notifyDataChanged`, which re-reads the week. +- **Multi-record cells** show their sum and are read-only. +- **Week.** Starts on the display locale's first day (`firstDayOfWeek`), with + previous / this / next navigation. Row, day and week totals are always shown. +- **Add row** asks for the row field values (with each field's own edit widget) + and adds an empty row; typing a day then creates its first record. +- **Query.** One `find` per week: the view filter AND `dateField` in the week, + capped at the platform's non-grid row ceiling, with the row fields' relations + expanded (field-level read access permitting). + +## Strings + +`timesheet.*` is a lazy locale namespace +(`@object-ui/i18n/namespaces/timesheet`), fetched when a timesheet mounts. The +grid renders nothing that reads one of its keys until the catalogue for the +page's language is resident. + +## Exports + +`ObjectTimesheet`, `ObjectTimesheetRenderer`, and the pure model: +`resolveTimesheetConfig`, `buildTimesheetRows`, `planCellWrite`, `startOfWeek`, +`weekDays`, with the types `TimesheetBinding`, `TimesheetGrid`, `TimesheetRow`, +`TimesheetCell` and `CellWrite`. diff --git a/ui/packages/plugin-timesheet/package.json b/ui/packages/plugin-timesheet/package.json new file mode 100644 index 00000000000..fa3e4f90960 --- /dev/null +++ b/ui/packages/plugin-timesheet/package.json @@ -0,0 +1,86 @@ +{ + "name": "@object-ui/plugin-timesheet", + "version": "18.5.0", + "type": "module", + "license": "MIT", + "description": "Timesheet (row × weekday entry grid) list view plugin for ObjectUI", + "homepage": "https://objectstack.ai/docs/frontend/plugins", + "repository": { + "type": "git", + "url": "git+https://github.com/objectstack-ai/objectstack.git", + "directory": "ui/packages/plugin-timesheet" + }, + "bugs": { + "url": "https://github.com/objectstack-ai/objectui/issues" + }, + "main": "dist/index.umd.cjs", + "module": "dist/index.js", + "types": "dist/index.d.ts", + "sideEffects": [ + "./dist/index.js", + "./dist/index.umd.cjs", + "./src/index.tsx" + ], + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": "./dist/index.umd.cjs" + } + }, + "scripts": { + "build": "vite build", + "test": "vitest run --root ../.. packages/plugin-timesheet/", + "test:watch": "vitest --root ../.. packages/plugin-timesheet/", + "type-check": "tsc --noEmit && tsc -p tsconfig.test.json", + "lint": "eslint ." + }, + "dependencies": { + "@object-ui/components": "workspace:*", + "@object-ui/core": "workspace:*", + "@object-ui/fields": "workspace:*", + "@object-ui/i18n": "workspace:*", + "@object-ui/permissions": "workspace:*", + "@object-ui/react": "workspace:*", + "@object-ui/types": "workspace:*", + "@objectstack/spec": "workspace:^", + "lucide-react": "^1.43.0" + }, + "peerDependencies": { + "react": "^19.0.0", + "react-dom": "^19.0.0" + }, + "devDependencies": { + "@object-ui/test-support": "workspace:*", + "@objectstack/sdui-parser": "workspace:*", + "@types/react": "19.3.0", + "@types/react-dom": "19.3.0", + "@vitejs/plugin-react": "^6.0.5", + "typescript": "^6.0.3", + "vite": "^8.2.1", + "vite-plugin-dts": "^5.1.2", + "vitest": "^4.1.10" + }, + "keywords": [ + "objectui", + "sdui", + "schema-driven-ui", + "react", + "tailwind", + "shadcn", + "objectstack", + "plugin", + "timesheet", + "time-entry" + ], + "author": "ObjectStack Team ", + "publishConfig": { + "access": "public" + }, + "files": [ + "dist", + "README.md", + "CHANGELOG.md", + "LICENSE" + ] +} diff --git a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx new file mode 100644 index 00000000000..564ba8b7075 --- /dev/null +++ b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx @@ -0,0 +1,645 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * `object-timesheet` — the editable row × weekday entry grid a list view of + * `type: 'timesheet'` draws (objectstack#34382). + * + * ## What it reads + * + * The view's `timesheet` block (`rowFields`, `dateField`, `valueField`), the + * view's effective `filter` (`ListView` hands down the authored filter joined + * with the toolbar's), and `objectName`. A missing or incomplete block draws + * the "Timesheet configuration required" screen (`timesheet-missing-binding`), + * the refusal `view/layout-without-binding` names. + * + * ## What it queries + * + * One `find` per displayed week: the view filter AND `dateField` inside the + * week, capped at the platform's non-grid row ceiling, with the row fields' + * relations expanded so a lookup row shows its record's name. The week starts + * on the display locale's first day (`firstDayOfWeek`). + * + * ## What it writes + * + * Each cell edit is ONE call on the record doors — `create`, `update` or + * `delete` (`planCellWrite` in `./timesheetModel.ts` decides which) — so the + * object's hooks, validation and permissions judge every cell on its own. A + * refusal stays on the cell that caused it, with the server's message, and the + * typed text is kept so the viewer can correct it. Every write is announced + * with `notifyDataChanged`, which also re-reads this grid. + * + * ## Strings + * + * `timesheet.*`, a lazy namespace (`@object-ui/i18n/namespaces/timesheet`): + * nothing that reads one renders before `useTimesheetNamespace` answers + * `ready`. Provider-less hosts get the English table below. + */ + +import React, { useEffect, useMemo, useState } from 'react'; +import type { DataSource } from '@object-ui/types'; +import { + useDataInvalidation, + useFilterScope, + useResolvedFilter, + useSafeFieldLabel, + useSettledSchema, + notifyDataChanged, + NonGridRowCeilingNote, +} from '@object-ui/react'; +import { + Button, + DataErrorState, + Dialog, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, + Skeleton, + cn, +} from '@object-ui/components'; +import { createSafeTranslation, firstDayOfWeek, useDisplayLocale, useSafeTranslate } from '@object-ui/i18n'; +import { useTimesheetNamespace } from '@object-ui/i18n/namespaces/timesheet'; +import { FieldEditWidget, getCellRenderer, resolveCellRendererType } from '@object-ui/fields'; +import { usePermissions } from '@object-ui/permissions'; +import { + applyNonGridRowCeiling, + buildExpandFields, + mergeFilterNodes, + nonGridRowCeilingQuery, + type NonGridCeilingResult, +} from '@object-ui/core'; +import { ChevronLeft, ChevronRight, Plus } from 'lucide-react'; +import { + addDays, + buildTimesheetRows, + parseCellInput, + planCellWrite, + recordIdOf, + resolveTimesheetConfig, + rowKeyOf, + rowValuesComplete, + startOfWeek, + weekDays, + fromDayKey, + type TimesheetBinding, + type TimesheetCell, + type TimesheetRow, +} from './timesheetModel'; + +/** English for a host with no i18n provider; the catalogues hold the rest. */ +const TIMESHEET_DEFAULT_TRANSLATIONS: Record = { + 'timesheet.missingBindingTitle': 'Timesheet configuration required', + 'timesheet.missingBindingMessage': + 'Declare timesheet.rowFields, timesheet.dateField and timesheet.valueField on this view.', + 'timesheet.previousWeek': 'Previous week', + 'timesheet.thisWeek': 'This week', + 'timesheet.nextWeek': 'Next week', + 'timesheet.total': 'Total', + 'timesheet.addRow': 'Add row', + 'timesheet.addRowConfirm': 'Add', + 'timesheet.cancel': 'Cancel', + 'timesheet.noRows': 'No entries this week. Add a row to start.', + 'timesheet.multipleRecords': 'This day holds {{count}} records. Edit them in the list.', + 'timesheet.invalidNumber': 'Enter a number', + 'timesheet.saveFailed': 'Not saved: {{message}}', + 'timesheet.loadFailed': 'This week could not be loaded.', + 'timesheet.rowIncomplete': 'Fill in every row field first.', + 'timesheet.cellLabel': '{{row}}, {{day}}', + 'timesheet.rowTotalLabel': '{{row}} total', + 'timesheet.dayTotalLabel': '{{day}} total', +}; + +const useTimesheetTranslation = createSafeTranslation( + TIMESHEET_DEFAULT_TRANSLATIONS, + 'timesheet.missingBindingTitle', +); + +/** The `object-timesheet` node `ListView` composes for a timesheet view. */ +export interface ObjectTimesheetSchema { + type?: 'object-timesheet'; + objectName?: string; + timesheet?: unknown; + filter?: unknown; + className?: string; + [key: string]: unknown; +} + +export interface ObjectTimesheetProps { + schema: ObjectTimesheetSchema; + dataSource?: DataSource; + className?: string; + /** The day the first displayed week holds; today when omitted. */ + initialDate?: Date; +} + +type Translate = (key: string, options?: Record) => string; + +/** One cell's in-flight state: the typed text, and a refusal if one came back. */ +interface CellDraft { + text: string; + saving?: boolean; + error?: string; +} + +const cellId = (rowKey: string, day: string): string => `${rowKey}|${day}`; + +export const ObjectTimesheet: React.FC = (props) => { + // The namespace frame: no `timesheet.*` key is read before its catalogue is + // resident in the page's language. + const namespace = useTimesheetNamespace(); + // The retry control cannot read a `timesheet.*` key: its catalogue is what + // failed. It reads the packs' own `common.retry`. + const tt = useSafeTranslate(); + if (namespace.status === 'loading') { + return ( +

+ + +
+ ); + } + if (namespace.status === 'failed') { + return ( +
+ +
+ ); + } + return ; +}; + +const TimesheetFrame: React.FC = ({ schema, dataSource, className, initialDate }) => { + const { t } = useTimesheetTranslation(); + const binding = useMemo( + () => resolveTimesheetConfig(schema.timesheet), + // Keyed on the block's content, never on its identity (AGENTS.md #10). + // eslint-disable-next-line react-hooks/exhaustive-deps + [JSON.stringify(schema.timesheet ?? null)], + ); + if (!binding || !schema.objectName) { + return ( +
+

{t('timesheet.missingBindingTitle')}

+

{t('timesheet.missingBindingMessage')}

+
+ ); + } + return ( + + ); +}; + +interface GridViewProps { + schema: ObjectTimesheetSchema; + objectName: string; + binding: TimesheetBinding; + dataSource?: DataSource; + className?: string; + initialDate?: Date; + t: Translate; +} + +function TimesheetGridView({ schema, objectName, binding, dataSource, className, initialDate, t }: GridViewProps) { + const locale = useDisplayLocale(); + const firstDay = useMemo(() => { + try { + return firstDayOfWeek(locale); + } catch { + return 1; + } + }, [locale]); + const [anchor, setAnchor] = useState(() => initialDate ?? new Date()); + const weekStart = startOfWeek(anchor, firstDay); + const days = useMemo(() => weekDays(weekStart), [weekStart]); + const weekEnd = addDays(weekStart, 7); + + const { ready: schemaSettled, def: objectSchema } = useSettledSchema(objectName, dataSource); + const perms = usePermissions(); + const filterScope = useFilterScope(); + const queryFilter = useResolvedFilter(schema.filter as any, filterScope); + const invalidationNonce = useDataInvalidation(dataSource ? objectName : undefined); + const rowFieldsKey = binding.rowFields.join('\u0000'); + + const [records, setRecords] = useState[] | null>(null); + const [ceiling, setCeiling] = useState(null); + const [loadError, setLoadError] = useState(null); + const [drafts, setDrafts] = useState>({}); + const [addedRows, setAddedRows] = useState[]>([]); + const [adding, setAdding] = useState(false); + + useEffect(() => { + if (!dataSource || typeof dataSource.find !== 'function' || !schemaSettled) return; + let cancelled = false; + (async () => { + try { + setLoadError(null); + // Only the row fields' relations are drawn, so only theirs are + // expanded — each judged against field-level read access first. + const expandable = buildExpandFields(objectSchema?.fields, binding.rowFields); + const expand = !perms?.isLoaded + ? expandable + : expandable.filter((f) => perms.checkField(objectName, f, 'read')); + const result = await dataSource.find(objectName, { + $filter: mergeFilterNodes( + queryFilter, + [binding.dateField, '>=', weekStart], + [binding.dateField, '<', weekEnd], + ) as any, + ...nonGridRowCeilingQuery(), + ...(expand.length > 0 ? { $expand: expand } : {}), + }); + if (cancelled) return; + const capped = applyNonGridRowCeiling>(result); + setRecords(capped.rows); + setCeiling(capped); + } catch (error) { + if (!cancelled) setLoadError(error instanceof Error ? error : new Error(String(error))); + } + })(); + return () => { + cancelled = true; + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [dataSource, objectName, schemaSettled, objectSchema, perms, queryFilter, invalidationNonce, weekStart, weekEnd, rowFieldsKey, binding.dateField]); + + const grid = useMemo( + () => buildTimesheetRows(records ?? [], binding, days, addedRows), + [records, binding, days, addedRows], + ); + + const fieldLabels = useSafeFieldLabel(); + const fieldDef = (name: string): any => objectSchema?.fields?.[name] ?? { name, type: 'text' }; + const fieldLabel = (name: string): string => { + const fallback = objectSchema?.fields?.[name]?.label || name.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()); + return fieldLabels.fieldLabel(objectName, name, fallback); + }; + const numberFormat = useMemo(() => new Intl.NumberFormat(locale, { maximumFractionDigits: 2 }), [locale]); + const dayHeading = useMemo( + () => new Intl.DateTimeFormat(locale, { weekday: 'short', month: 'numeric', day: 'numeric' }), + [locale], + ); + const rangeFormat = useMemo(() => new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }), [locale]); + const rowName = (row: TimesheetRow): string => + binding.rowFields.map((f) => displayText(row.values[f])).filter(Boolean).join(' · '); + + const writeCell = async (row: TimesheetRow, day: string, cell: TimesheetCell, text: string) => { + const id = cellId(row.key, day); + const parsed = parseCellInput(text); + if (parsed === 'invalid') { + setDrafts((d) => ({ ...d, [id]: { text, error: t('timesheet.invalidNumber') } })); + return; + } + const write = planCellWrite(binding, row, day, cell, parsed, fieldDef(binding.dateField)?.type); + if (write.kind === 'none' || write.kind === 'readonly' || !dataSource) { + setDrafts(({ [id]: _dropped, ...rest }) => rest); + return; + } + setDrafts((d) => ({ ...d, [id]: { text, saving: true } })); + try { + let recordId: string | undefined; + if (write.kind === 'create') { + const created = (await dataSource.create(objectName, write.data)) as Record | undefined; + recordId = created ? recordIdOf(created) : undefined; + setRecords((rs) => [...(rs ?? []), { ...write.data, ...row.values, ...(created ?? {}) }]); + } else if (write.kind === 'update') { + await dataSource.update(objectName, write.id, write.data); + recordId = write.id; + setRecords((rs) => (rs ?? []).map((r) => (recordIdOf(r) === write.id ? { ...r, ...write.data } : r))); + } else { + await dataSource.delete(objectName, write.id); + recordId = write.id; + setRecords((rs) => (rs ?? []).filter((r) => recordIdOf(r) !== write.id)); + } + setDrafts(({ [id]: _saved, ...rest }) => rest); + notifyDataChanged({ objectName, ...(recordId ? { recordId } : {}) }); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + setDrafts((d) => ({ ...d, [id]: { text, error: t('timesheet.saveFailed', { message }) } })); + } + }; + + if (loadError) { + return ( + + ); + } + + const today = new Date(); + return ( +
+
+ + + + + {`${rangeFormat.format(fromDayKey(weekStart))} – ${rangeFormat.format(fromDayKey(addDays(weekStart, 6)))}`} + + +
+ + {records === null ? ( + + ) : ( + + + + {binding.rowFields.map((f) => ( + + ))} + {days.map((day) => ( + + ))} + + + + + {grid.rows.length === 0 && ( + + + + )} + {grid.rows.map((row) => { + const name = rowName(row); + return ( + + {binding.rowFields.map((f) => { + const def = fieldDef(f); + const Cell = getCellRenderer(resolveCellRendererType(def)); + return ( + + ); + })} + {days.map((day) => { + const cell = row.cells[day]; + const id = cellId(row.key, day); + const label = t('timesheet.cellLabel', { row: name, day: dayHeading.format(fromDayKey(day)) }); + if (cell.records.length > 1) { + return ( + + ); + } + return ( + + ); + })} + + + ); + })} + + + + + {days.map((day) => ( + + ))} + + + +
+ {fieldLabel(f)} + + {dayHeading.format(fromDayKey(day))} + + {t('timesheet.total')} +
+ {t('timesheet.noRows')} +
+ + + + {numberFormat.format(cell.sum)} + + + setDrafts((d) => ({ ...d, [id]: { text } }))} + onCommit={(text) => writeCell(row, day, cell, text)} + onRevert={() => setDrafts(({ [id]: _reverted, ...rest }) => rest)} + /> + + {numberFormat.format(row.total)} +
+ {t('timesheet.total')} + + {numberFormat.format(grid.dayTotals[day])} + + {numberFormat.format(grid.weekTotal)} +
+ )} + {ceiling && } + + setAdding(false)} + onAdd={(values) => { + setAdding(false); + setAddedRows((rows) => + rows.some((r) => rowKeyOf(r, binding.rowFields) === rowKeyOf(values, binding.rowFields)) + ? rows + : [...rows, values], + ); + }} + /> +
+ ); +} + +/** A row field value as plain text, for the accessible row name. */ +function displayText(value: unknown): string { + if (value === null || value === undefined) return ''; + if (typeof value === 'object' && !Array.isArray(value)) { + const v = value as Record; + return String(v.name ?? v.label ?? v.title ?? v.id ?? v._id ?? ''); + } + return String(value); +} + +interface CellInputProps { + label: string; + value: string; + draft?: CellDraft; + onDraft: (text: string) => void; + onCommit: (text: string) => void; + onRevert: () => void; +} + +function TimesheetCellInput({ label, value, draft, onDraft, onCommit, onRevert }: CellInputProps) { + const text = draft ? draft.text : value; + const commit = () => { + if (draft && !draft.saving && !draft.error) onCommit(draft.text); + }; + return ( + <> + onDraft(e.target.value)} + onBlur={commit} + onKeyDown={(e) => { + if (e.key === 'Enter') { + e.preventDefault(); + if (draft?.error) onCommit(draft.text); + else commit(); + } else if (e.key === 'Escape') { + onRevert(); + } + }} + /> + {draft?.error && ( + + {draft.error} + + )} + + ); +} + +interface AddRowDialogProps { + open: boolean; + binding: TimesheetBinding; + fieldDef: (name: string) => any; + fieldLabel: (name: string) => string; + t: Translate; + onCancel: () => void; + onAdd: (values: Record) => void; +} + +function AddRowDialog({ open, binding, fieldDef, fieldLabel, t, onCancel, onAdd }: AddRowDialogProps) { + const [values, setValues] = useState>({}); + const [showError, setShowError] = useState(false); + useEffect(() => { + if (open) { + setValues({}); + setShowError(false); + } + }, [open]); + const complete = rowValuesComplete(values, binding.rowFields); + return ( + { if (!next) onCancel(); }}> + + + {t('timesheet.addRow')} + +
+ {binding.rowFields.map((f) => ( + + ))} + {showError && !complete && ( + + {t('timesheet.rowIncomplete')} + + )} +
+ + + + +
+
+ ); +} diff --git a/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx b/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx new file mode 100644 index 00000000000..3344213df21 --- /dev/null +++ b/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx @@ -0,0 +1,181 @@ +import React from 'react'; +import { render, screen, fireEvent, waitFor, cleanup, within } from '@testing-library/react'; +import { describe, it, expect, afterEach, vi } from 'vitest'; +import { ObjectTimesheet } from '../ObjectTimesheet'; + +afterEach(cleanup); + +// Monday 16 November 2026; the test runner's locale is en-US, whose week +// starts on Sunday 15 November. +const WEDNESDAY = new Date(2026, 10, 18); + +const objectSchema = { + name: 'time_entry', + fields: { + project: { name: 'project', type: 'text', label: 'Project' }, + work_date: { name: 'work_date', type: 'date', label: 'Date' }, + hours: { name: 'hours', type: 'number', label: 'Hours' }, + }, +}; + +function makeDataSource(rows: Record[]) { + let store = rows.map((r) => ({ ...r })); + let nextId = 100; + return { + getObjectSchema: vi.fn(async () => objectSchema), + find: vi.fn(async () => ({ data: store.map((r) => ({ ...r })), total: store.length })), + create: vi.fn(async (_object: string, data: Record) => { + const record = { id: `n${nextId++}`, ...data }; + store.push(record); + return record; + }), + update: vi.fn(async (_object: string, id: string, data: Record) => { + store = store.map((r) => (r.id === id ? { ...r, ...data } : r)); + return store.find((r) => r.id === id); + }), + delete: vi.fn(async (_object: string, id: string) => { + store = store.filter((r) => r.id !== id); + return true; + }), + }; +} + +const view = { + type: 'object-timesheet' as const, + objectName: 'time_entry', + timesheet: { rowFields: ['project'], dateField: 'work_date', valueField: 'hours' }, +}; + +function renderTimesheet(ds: ReturnType, schema: any = view) { + return render(); +} + +describe('ObjectTimesheet', () => { + it('shows the missing-binding screen for a view with no timesheet block', () => { + renderTimesheet(makeDataSource([]), { type: 'object-timesheet', objectName: 'time_entry' }); + expect(screen.getByTestId('timesheet-missing-binding').textContent).toContain('Timesheet configuration required'); + }); + + it('queries the displayed week on the date field, joined with the view filter', async () => { + const ds = makeDataSource([]); + renderTimesheet(ds, { ...view, filter: [['project', '=', 'Apollo']] }); + await waitFor(() => expect(ds.find).toHaveBeenCalled()); + const [object, params] = ds.find.mock.calls[0] as any[]; + expect(object).toBe('time_entry'); + const filter = JSON.stringify(params.$filter); + expect(filter).toContain('["work_date",">=","2026-11-15"]'); + expect(filter).toContain('["work_date","<","2026-11-22"]'); + expect(filter).toContain('Apollo'); + }); + + it('pivots records into rows and days with row, day and week totals', async () => { + const ds = makeDataSource([ + { id: 'r1', project: 'Apollo', work_date: '2026-11-16', hours: 2 }, + { id: 'r2', project: 'Apollo', work_date: '2026-11-17', hours: 3 }, + { id: 'r3', project: 'Hermes', work_date: '2026-11-17', hours: 1 }, + ]); + renderTimesheet(ds); + await waitFor(() => expect(screen.getAllByTestId('timesheet-row')).toHaveLength(2)); + const totals = screen.getAllByTestId('timesheet-row-total').map((el) => el.textContent); + expect(totals).toEqual(['5', '1']); + const dayTotals = screen.getAllByTestId('timesheet-day-total').map((el) => el.textContent); + expect(dayTotals).toEqual(['0', '2', '4', '0', '0', '0', '0']); + expect(screen.getByTestId('timesheet-week-total').textContent).toBe('6'); + }); + + it('shows a cell holding two records as a read-only sum', async () => { + const ds = makeDataSource([ + { id: 'r1', project: 'Apollo', work_date: '2026-11-17', hours: 2 }, + { id: 'r2', project: 'Apollo', work_date: '2026-11-17', hours: 1.5 }, + ]); + renderTimesheet(ds); + const cell = await screen.findByTestId('timesheet-cell-readonly'); + expect(cell.textContent).toBe('3.5'); + expect(cell.getAttribute('title')).toContain('2 records'); + }); + + it('updates a one-record cell through the record door', async () => { + const ds = makeDataSource([{ id: 'r1', project: 'Apollo', work_date: '2026-11-16', hours: 2 }]); + renderTimesheet(ds); + await waitFor(() => expect(screen.getAllByTestId('timesheet-row')).toHaveLength(1)); + const cells = screen.getAllByTestId('timesheet-cell'); + // Sunday first: Monday is the second day column. + const monday = cells[1] as HTMLInputElement; + expect(monday.value).toBe('2'); + fireEvent.change(monday, { target: { value: '6' } }); + fireEvent.blur(monday); + await waitFor(() => expect(ds.update).toHaveBeenCalledWith('time_entry', 'r1', { hours: 6 })); + await waitFor(() => expect(screen.getByTestId('timesheet-week-total').textContent).toBe('6')); + }); + + it('creates a record when an empty cell is typed into, and deletes it when cleared', async () => { + const ds = makeDataSource([{ id: 'r1', project: 'Apollo', work_date: '2026-11-16', hours: 2 }]); + renderTimesheet(ds); + await waitFor(() => expect(screen.getAllByTestId('timesheet-row')).toHaveLength(1)); + const tuesday = screen.getAllByTestId('timesheet-cell')[2] as HTMLInputElement; + fireEvent.change(tuesday, { target: { value: '4' } }); + fireEvent.keyDown(tuesday, { key: 'Enter' }); + await waitFor(() => + expect(ds.create).toHaveBeenCalledWith('time_entry', { project: 'Apollo', work_date: '2026-11-17', hours: 4 }), + ); + await waitFor(() => expect(screen.getByTestId('timesheet-week-total').textContent).toBe('6')); + + const monday = screen.getAllByTestId('timesheet-cell')[1] as HTMLInputElement; + fireEvent.change(monday, { target: { value: '' } }); + fireEvent.blur(monday); + await waitFor(() => expect(ds.delete).toHaveBeenCalledWith('time_entry', 'r1')); + }); + + it('keeps a refused write on its cell with the server message', async () => { + const ds = makeDataSource([{ id: 'r1', project: 'Apollo', work_date: '2026-11-16', hours: 2 }]); + ds.update.mockRejectedValueOnce(new Error('Hours must be 24 or less')); + renderTimesheet(ds); + await waitFor(() => expect(screen.getAllByTestId('timesheet-row')).toHaveLength(1)); + const monday = screen.getAllByTestId('timesheet-cell')[1] as HTMLInputElement; + fireEvent.change(monday, { target: { value: '30' } }); + fireEvent.blur(monday); + const alert = await screen.findByTestId('timesheet-cell-error'); + expect(alert.textContent).toBe('Not saved: Hours must be 24 or less'); + expect(monday.getAttribute('aria-invalid')).toBe('true'); + expect(monday.value).toBe('30'); + }); + + it('refuses text that is not a number without writing', async () => { + const ds = makeDataSource([]); + renderTimesheet(ds, view); + await screen.findByTestId('timesheet-empty'); + fireEvent.click(screen.getByTestId('timesheet-add-row')); + const dialog = await screen.findByTestId('timesheet-add-row-dialog'); + fireEvent.click(within(dialog).getByTestId('timesheet-add-row-confirm')); + expect(within(dialog).getByTestId('timesheet-row-incomplete')).toBeTruthy(); + fireEvent.change(within(dialog).getByRole('textbox'), { target: { value: 'Zeus' } }); + fireEvent.click(within(dialog).getByTestId('timesheet-add-row-confirm')); + await waitFor(() => expect(screen.getAllByTestId('timesheet-row')).toHaveLength(1)); + + const cell = screen.getAllByTestId('timesheet-cell')[3] as HTMLInputElement; + fireEvent.change(cell, { target: { value: 'lots' } }); + fireEvent.blur(cell); + expect((await screen.findByTestId('timesheet-cell-error')).textContent).toBe('Enter a number'); + expect(ds.create).not.toHaveBeenCalled(); + + fireEvent.change(cell, { target: { value: '5' } }); + fireEvent.keyDown(cell, { key: 'Enter' }); + await waitFor(() => + expect(ds.create).toHaveBeenCalledWith('time_entry', { project: 'Zeus', work_date: '2026-11-18', hours: 5 }), + ); + }); + + it('moves between weeks', async () => { + const ds = makeDataSource([]); + renderTimesheet(ds); + await waitFor(() => expect(ds.find).toHaveBeenCalledTimes(1)); + fireEvent.click(screen.getByTestId('timesheet-next-week')); + await waitFor(() => expect(ds.find).toHaveBeenCalledTimes(2)); + expect(JSON.stringify((ds.find.mock.calls[1] as any[])[1].$filter)).toContain('"2026-11-22"'); + fireEvent.click(screen.getByTestId('timesheet-prev-week')); + fireEvent.click(screen.getByTestId('timesheet-prev-week')); + await waitFor(() => + expect(JSON.stringify((ds.find.mock.calls.at(-1) as any[])[1].$filter)).toContain('"2026-11-08"'), + ); + }); +}); diff --git a/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts b/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts new file mode 100644 index 00000000000..83352c7353e --- /dev/null +++ b/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts @@ -0,0 +1,149 @@ +import { describe, it, expect } from 'vitest'; +import { + buildTimesheetRows, + dateFieldValue, + dayKeyOf, + parseCellInput, + planCellWrite, + resolveTimesheetConfig, + rowValuesComplete, + startOfWeek, + weekDays, + type TimesheetBinding, +} from '../timesheetModel'; + +const binding: TimesheetBinding = { rowFields: ['project', 'task'], dateField: 'work_date', valueField: 'hours' }; +const days = weekDays('2026-11-16'); + +describe('resolveTimesheetConfig', () => { + it('reads a complete block', () => { + expect(resolveTimesheetConfig({ rowFields: ['project'], dateField: 'd', valueField: 'v' })).toEqual({ + rowFields: ['project'], + dateField: 'd', + valueField: 'v', + }); + }); + + it.each([ + ['no block', undefined], + ['no row fields', { rowFields: [], dateField: 'd', valueField: 'v' }], + ['four row fields', { rowFields: ['a', 'b', 'c', 'd'], dateField: 'd', valueField: 'v' }], + ['no date field', { rowFields: ['a'], valueField: 'v' }], + ['no value field', { rowFields: ['a'], dateField: 'd' }], + ['an empty row field name', { rowFields: [''], dateField: 'd', valueField: 'v' }], + ])('refuses %s', (_label, block) => { + expect(resolveTimesheetConfig(block)).toBeNull(); + }); +}); + +describe('week arithmetic', () => { + it('starts the week on the locale first day', () => { + // Wednesday 18 November 2026. + const wed = new Date(2026, 10, 18); + expect(startOfWeek(wed, 1)).toBe('2026-11-16'); + expect(startOfWeek(wed, 0)).toBe('2026-11-15'); + expect(startOfWeek(wed, 6)).toBe('2026-11-14'); + }); + + it('lists seven consecutive days across a month end', () => { + expect(weekDays('2026-11-30')).toEqual([ + '2026-11-30', '2026-12-01', '2026-12-02', '2026-12-03', '2026-12-04', '2026-12-05', '2026-12-06', + ]); + }); + + it('places a date-only value on its own day and an instant on the local day', () => { + expect(dayKeyOf('2026-11-17')).toBe('2026-11-17'); + const local = new Date(2026, 10, 17, 23, 30); + expect(dayKeyOf(local.toISOString())).toBe('2026-11-17'); + expect(dayKeyOf(null)).toBeNull(); + expect(dayKeyOf('not a date')).toBeNull(); + }); + + it('writes a date-time day at local noon', () => { + expect(dateFieldValue('2026-11-17')).toBe('2026-11-17'); + expect(dayKeyOf(dateFieldValue('2026-11-17', 'datetime'))).toBe('2026-11-17'); + }); +}); + +describe('buildTimesheetRows', () => { + const records = [ + { id: 'r1', project: { id: 'p1', name: 'Apollo' }, task: 'Design', work_date: '2026-11-16', hours: 2 }, + { id: 'r2', project: 'p1', task: 'Design', work_date: '2026-11-17', hours: 3.5 }, + { id: 'r3', project: 'p2', task: 'Build', work_date: '2026-11-17', hours: 1 }, + { id: 'r4', project: 'p2', task: 'Build', work_date: '2026-11-17', hours: 4 }, + { id: 'r5', project: 'p2', task: 'Build', work_date: '2026-11-23', hours: 8 }, + ]; + + it('keys a row by its row field values, an expanded lookup by its id', () => { + const grid = buildTimesheetRows(records, binding, days); + expect(grid.rows).toHaveLength(2); + const [apollo, build] = grid.rows; + expect(apollo.cells['2026-11-16'].sum).toBe(2); + expect(apollo.cells['2026-11-17'].sum).toBe(3.5); + expect(apollo.total).toBe(5.5); + expect(build.cells['2026-11-17'].records).toHaveLength(2); + expect(build.cells['2026-11-17'].sum).toBe(5); + }); + + it('leaves out records outside the week and sums day and week totals', () => { + const grid = buildTimesheetRows(records, binding, days); + expect(grid.dayTotals['2026-11-16']).toBe(2); + expect(grid.dayTotals['2026-11-17']).toBe(8.5); + expect(grid.dayTotals['2026-11-22']).toBe(0); + expect(grid.weekTotal).toBe(10.5); + }); + + it('appends added rows that no record made yet', () => { + const grid = buildTimesheetRows(records, binding, days, [ + { project: 'p1', task: 'Design' }, + { project: 'p3', task: 'Test' }, + ]); + expect(grid.rows).toHaveLength(3); + expect(grid.rows[2].values).toEqual({ project: 'p3', task: 'Test' }); + expect(grid.rows[2].total).toBe(0); + }); +}); + +describe('planCellWrite', () => { + const row = { values: { project: { id: 'p1', name: 'Apollo' }, task: 'Design' } }; + const empty = { records: [], sum: 0 }; + const one = { records: [{ id: 'r1', hours: 2 }], sum: 2 }; + const two = { records: [{ id: 'r1', hours: 2 }, { id: 'r2', hours: 1 }], sum: 3 }; + + it('creates a record carrying the row values, the day and the value', () => { + expect(planCellWrite(binding, row, '2026-11-18', empty, 4)).toEqual({ + kind: 'create', + data: { project: 'p1', task: 'Design', work_date: '2026-11-18', hours: 4 }, + }); + }); + + it('writes nothing when an empty cell stays empty', () => { + expect(planCellWrite(binding, row, '2026-11-18', empty, null)).toEqual({ kind: 'none' }); + }); + + it('updates a one-record cell and deletes it when cleared', () => { + expect(planCellWrite(binding, row, '2026-11-18', one, 6)).toEqual({ kind: 'update', id: 'r1', data: { hours: 6 } }); + expect(planCellWrite(binding, row, '2026-11-18', one, 2)).toEqual({ kind: 'none' }); + expect(planCellWrite(binding, row, '2026-11-18', one, null)).toEqual({ kind: 'delete', id: 'r1' }); + }); + + it('never writes a cell holding several records', () => { + expect(planCellWrite(binding, row, '2026-11-18', two, 9)).toEqual({ kind: 'readonly' }); + expect(planCellWrite(binding, row, '2026-11-18', two, null)).toEqual({ kind: 'readonly' }); + }); +}); + +describe('parseCellInput and rowValuesComplete', () => { + it('parses numbers, clears on empty, refuses text', () => { + expect(parseCellInput(' 7.5 ')).toBe(7.5); + expect(parseCellInput('1,5')).toBe(1.5); + expect(parseCellInput('')).toBeNull(); + expect(parseCellInput('abc')).toBe('invalid'); + }); + + it('requires every row field', () => { + expect(rowValuesComplete({ project: 'p1', task: 'x' }, binding.rowFields)).toBe(true); + expect(rowValuesComplete({ project: 'p1', task: '' }, binding.rowFields)).toBe(false); + expect(rowValuesComplete({ project: 'p1' }, binding.rowFields)).toBe(false); + }); +}); diff --git a/ui/packages/plugin-timesheet/src/index.tsx b/ui/packages/plugin-timesheet/src/index.tsx new file mode 100644 index 00000000000..f52c6381a44 --- /dev/null +++ b/ui/packages/plugin-timesheet/src/index.tsx @@ -0,0 +1,68 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import React from 'react'; +import { ComponentRegistry } from '@object-ui/core'; +import { useSchemaContext } from '@object-ui/react'; +import { ObjectTimesheet } from './ObjectTimesheet'; +import type { ObjectTimesheetProps, ObjectTimesheetSchema } from './ObjectTimesheet'; + +export { ObjectTimesheet }; +export type { ObjectTimesheetProps, ObjectTimesheetSchema }; +export { + buildTimesheetRows, + planCellWrite, + resolveTimesheetConfig, + startOfWeek, + weekDays, + type TimesheetBinding, + type TimesheetGrid, + type TimesheetRow, + type TimesheetCell, + type CellWrite, +} from './timesheetModel'; + +// Renderer wrapper: pulls the dataSource from schema context, mirroring the +// other view plugins (object-tree / object-gantt / …). +export const ObjectTimesheetRenderer: React.FC = ({ schema, ...props }) => { + const { dataSource } = useSchemaContext() || {}; + return ; +}; + +// The keys `ObjectTimesheet` reads off its node. The node is composed by +// `@object-ui/plugin-list`'s `ListView` for a `type: 'timesheet'` view; it is +// not a curated page block (`PUBLIC_BLOCKS`), so these inputs describe the +// renderer to the designer and the registry, not a page-authoring contract. +const timesheetInputs = [ + { + name: 'objectName', + type: 'string' as const, + required: true, + description: 'The object whose records the grid pivots, one record per filled cell.', + }, + { + name: 'timesheet', + type: 'object' as const, + required: true, + description: + 'The binding: `rowFields` (one to three fields whose values key a row), `dateField` (the field placing a record on a day column) and `valueField` (the number a cell shows and edits). Without all three the grid shows the "Timesheet configuration required" screen.', + }, + { + name: 'filter', + type: 'array' as const, + description: + 'Base query filter, joined with the displayed week on `dateField`. Rows a filter removes are not drawn, so a record typed into a row the filter excludes disappears on the next read.', + }, +]; + +ComponentRegistry.register('object-timesheet', ObjectTimesheetRenderer, { + namespace: 'plugin-timesheet', + label: 'Object Timesheet', + category: 'view', + inputs: timesheetInputs, +}); diff --git a/ui/packages/plugin-timesheet/src/timesheetModel.ts b/ui/packages/plugin-timesheet/src/timesheetModel.ts new file mode 100644 index 00000000000..1d2bd5a2f00 --- /dev/null +++ b/ui/packages/plugin-timesheet/src/timesheetModel.ts @@ -0,0 +1,272 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * The timesheet's pure model: the binding block read, the week arithmetic, the + * pivot from detail records to rows × days, and the decision of what one cell + * edit writes. No React, no adapter — `ObjectTimesheet.tsx` draws what this + * module computes, and `__tests__/timesheetModel.test.ts` pins it. + * + * ## The pivot + * + * Each record lands in ONE row and ONE day column: + * - its row is the tuple of its `rowFields` values (a lookup's value is its + * id, whether the adapter returned the bare id or an expanded record); + * - its day is the calendar day its `dateField` value falls on, read in the + * viewer's own time zone for a date-time value. + * A cell sums the `valueField` of every record that landed in it. A cell + * holding more than one record is shown as that sum and is read-only: the grid + * cannot tell which record a typed number belongs to. + */ + +/** The `timesheet` binding block, as the renderer reads it. */ +export interface TimesheetBinding { + rowFields: string[]; + dateField: string; + valueField: string; +} + +/** + * The binding a view's `timesheet` block declares, or `null` when the block is + * missing or incomplete — the "Timesheet configuration required" screen. The + * spec requires all three keys and one to three row fields; a stored block + * that skipped validation is judged here the same way rather than drawn half. + */ +export function resolveTimesheetConfig(block: unknown): TimesheetBinding | null { + if (!block || typeof block !== 'object') return null; + const { rowFields, dateField, valueField } = block as Record; + if (!Array.isArray(rowFields) || rowFields.length < 1 || rowFields.length > 3) return null; + if (!rowFields.every((f) => typeof f === 'string' && f.length > 0)) return null; + if (typeof dateField !== 'string' || dateField.length === 0) return null; + if (typeof valueField !== 'string' || valueField.length === 0) return null; + return { rowFields: [...rowFields] as string[], dateField, valueField }; +} + +const pad = (n: number): string => String(n).padStart(2, '0'); + +/** A local calendar day as `YYYY-MM-DD`. */ +export function toDayKey(date: Date): string { + return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`; +} + +/** The local midnight a `YYYY-MM-DD` key names. */ +export function fromDayKey(key: string): Date { + const [y, m, d] = key.split('-').map(Number); + return new Date(y, m - 1, d); +} + +/** `key` moved by `days` calendar days. */ +export function addDays(key: string, days: number): string { + const date = fromDayKey(key); + date.setDate(date.getDate() + days); + return toDayKey(date); +} + +/** + * The first day of the week holding `date`, where the week starts on + * `firstDay` (`Date.prototype.getDay` numbering: 0 is Sunday). + */ +export function startOfWeek(date: Date, firstDay: number): string { + const offset = (date.getDay() - firstDay + 7) % 7; + const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - offset); + return toDayKey(start); +} + +/** The seven day keys of the week starting on `start`. */ +export function weekDays(start: string): string[] { + return Array.from({ length: 7 }, (_, i) => addDays(start, i)); +} + +const DATE_ONLY = /^(\d{4})-(\d{2})-(\d{2})$/; + +/** + * The day a stored `dateField` value falls on, or `null` when it names none. + * A date-only string is that day exactly (no time zone shift); anything with a + * time is read as an instant and placed on the viewer's local day. + */ +export function dayKeyOf(value: unknown): string | null { + if (value === null || value === undefined || value === '') return null; + if (typeof value === 'string' && DATE_ONLY.test(value)) return value; + const date = value instanceof Date ? value : new Date(value as string | number); + return Number.isNaN(date.getTime()) ? null : toDayKey(date); +} + +/** A record's id, as the record doors key it. */ +export function recordIdOf(record: Record): string | undefined { + const id = record.id ?? record._id; + return id === undefined || id === null ? undefined : String(id); +} + +/** + * The value a row field contributes to a row's identity: an expanded lookup + * record contributes its id, so a row keys the same whether the adapter + * expanded the relation or returned the bare id. + */ +export function rowFieldKeyValue(value: unknown): unknown { + if (value && typeof value === 'object' && !Array.isArray(value)) { + const id = (value as Record).id ?? (value as Record)._id; + if (id !== undefined && id !== null) return id; + } + return value ?? null; +} + +/** The identity of the row a set of row field values names. */ +export function rowKeyOf(values: Record, rowFields: readonly string[]): string { + return JSON.stringify(rowFields.map((f) => rowFieldKeyValue(values[f]))); +} + +/** A number a `valueField` holds, or 0 for anything that is not one. */ +export function numericValue(value: unknown): number { + const n = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : NaN; + return Number.isFinite(n) ? n : 0; +} + +/** One day cell: the records that landed in it and the sum of their values. */ +export interface TimesheetCell { + records: Record[]; + sum: number; +} + +/** One row: its row field values, one cell per day, and the row total. */ +export interface TimesheetRow { + key: string; + /** The row field values as the first record of the row carried them. */ + values: Record; + cells: Record; + total: number; +} + +export interface TimesheetGrid { + rows: TimesheetRow[]; + /** Sum per day key, over every row. */ + dayTotals: Record; + /** Sum over the whole week. */ + weekTotal: number; +} + +function emptyRow(key: string, values: Record, days: readonly string[]): TimesheetRow { + const cells: Record = {}; + for (const day of days) cells[day] = { records: [], sum: 0 }; + return { key, values, cells, total: 0 }; +} + +/** + * Pivot `records` into the week's rows. Records whose day falls outside + * `days` are left out. `extraRows` (rows the viewer added that hold no record + * yet) are appended, in order, unless a record already made the same row. + * Rows keep the order their first record arrived in, which is the order the + * query sorted them. + */ +export function buildTimesheetRows( + records: readonly Record[], + binding: TimesheetBinding, + days: readonly string[], + extraRows: readonly Record[] = [], +): TimesheetGrid { + const inWeek = new Set(days); + const rows = new Map(); + for (const record of records) { + const day = dayKeyOf(record[binding.dateField]); + if (!day || !inWeek.has(day)) continue; + const key = rowKeyOf(record, binding.rowFields); + let row = rows.get(key); + if (!row) { + const values: Record = {}; + for (const f of binding.rowFields) values[f] = record[f]; + row = emptyRow(key, values, days); + rows.set(key, row); + } + const amount = numericValue(record[binding.valueField]); + row.cells[day].records.push(record); + row.cells[day].sum += amount; + row.total += amount; + } + for (const values of extraRows) { + const key = rowKeyOf(values, binding.rowFields); + if (!rows.has(key)) rows.set(key, emptyRow(key, values, days)); + } + const dayTotals: Record = {}; + for (const day of days) dayTotals[day] = 0; + let weekTotal = 0; + for (const row of rows.values()) { + for (const day of days) dayTotals[day] += row.cells[day].sum; + weekTotal += row.total; + } + return { rows: [...rows.values()], dayTotals, weekTotal }; +} + +/** + * What a typed cell value means: `null` clears the cell, a number sets it, and + * `'invalid'` is text that is neither (the cell shows "Enter a number"). + */ +export function parseCellInput(text: string): number | null | 'invalid' { + const trimmed = text.trim(); + if (trimmed === '') return null; + const n = Number(trimmed.replace(',', '.')); + return Number.isFinite(n) ? n : 'invalid'; +} + +/** + * The value a new record's `dateField` takes for `day`: the day key for a date + * field, and the instant at local noon for a date-time field, so the record + * reads back on the same day in every time zone within twelve hours of the + * viewer's. + */ +export function dateFieldValue(day: string, dateFieldType?: string): string { + if (dateFieldType !== 'datetime') return day; + const noon = fromDayKey(day); + noon.setHours(12); + return noon.toISOString(); +} + +/** The record write one cell edit makes. */ +export type CellWrite = + | { kind: 'none' } + | { kind: 'readonly' } + | { kind: 'create'; data: Record } + | { kind: 'update'; id: string; data: Record } + | { kind: 'delete'; id: string }; + +/** + * Decide the write that setting `cell` (in row `row`, on `day`) to `next` + * makes. An empty cell typed into creates a record carrying the row field + * values, the day and the value; a one-record cell is updated, or deleted when + * cleared; a cell holding several records is never written. + */ +export function planCellWrite( + binding: TimesheetBinding, + row: Pick, + day: string, + cell: TimesheetCell, + next: number | null, + dateFieldType?: string, +): CellWrite { + if (cell.records.length > 1) return { kind: 'readonly' }; + if (cell.records.length === 0) { + if (next === null) return { kind: 'none' }; + const data: Record = {}; + for (const f of binding.rowFields) data[f] = rowFieldKeyValue(row.values[f]); + data[binding.dateField] = dateFieldValue(day, dateFieldType); + data[binding.valueField] = next; + return { kind: 'create', data }; + } + const record = cell.records[0]; + const id = recordIdOf(record); + if (id === undefined) return { kind: 'readonly' }; + if (next === null) return { kind: 'delete', id }; + if (next === numericValue(record[binding.valueField])) return { kind: 'none' }; + return { kind: 'update', id, data: { [binding.valueField]: next } }; +} + +/** Whether every row field holds a value — the add-row form's gate. */ +export function rowValuesComplete(values: Record, rowFields: readonly string[]): boolean { + return rowFields.every((f) => { + const v = values[f]; + return v !== undefined && v !== null && v !== '' && !(Array.isArray(v) && v.length === 0); + }); +} diff --git a/ui/packages/plugin-timesheet/tsconfig.json b/ui/packages/plugin-timesheet/tsconfig.json new file mode 100644 index 00000000000..3b9730f6bcc --- /dev/null +++ b/ui/packages/plugin-timesheet/tsconfig.json @@ -0,0 +1,27 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "dist", + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + }, + "noEmit": false, + "declaration": true, + // Kept outside `dist` (objectui#9189). + "tsBuildInfoFile": "./tsconfig.tsbuildinfo", + "composite": true, + "declarationMap": true + }, + "include": ["src"], + // Tooling excluded by directory (pnpm check:published-tsconfig-exclude). + "exclude": [ + "node_modules", + "dist", + "**/__tests__/**", + "**/__mocks__/**", + "**/__benchmarks__/**", + "**/*.test.ts", + "**/*.test.tsx" + ] +} diff --git a/ui/packages/plugin-timesheet/tsconfig.test.json b/ui/packages/plugin-timesheet/tsconfig.test.json new file mode 100644 index 00000000000..5e443d08f3c --- /dev/null +++ b/ui/packages/plugin-timesheet/tsconfig.test.json @@ -0,0 +1,12 @@ +{ + // Type-checks this package's tests, which `tsconfig.json` excludes. + "extends": "../../tsconfig.json", + "compilerOptions": { + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "noEmit": true, + "composite": false, + // Resolve workspace deps through their built typings. + "paths": {} + }, + "include": ["src/**/*.test.ts", "src/**/*.test.tsx"] +} diff --git a/ui/packages/plugin-timesheet/vite.config.ts b/ui/packages/plugin-timesheet/vite.config.ts new file mode 100644 index 00000000000..3242317557a --- /dev/null +++ b/ui/packages/plugin-timesheet/vite.config.ts @@ -0,0 +1,71 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; +import dts from 'vite-plugin-dts'; +import { resolve } from 'path'; + +import { createDtsExplicitExtensions } from '../../scripts/vite-dts-explicit-extensions.ts'; +import { createDtsFailOnTypeErrors } from '../../scripts/vite-dts-fail-on-type-errors.ts'; + +// Vitest falls back to this file from this directory; refuse that entry point +// (route 4 in scripts/vitest-invocation-guard.mjs). +import { + assertCanonicalVitestInvocation, + repoRootFrom, +} from '../../scripts/vitest-invocation-guard.mjs'; + +if (process.env.VITEST) { + assertCanonicalVitestInvocation({ repoRoot: repoRootFrom(import.meta.url) }); +} + +export default defineConfig({ + plugins: [ + react(), + dts({ + insertTypesEntry: true, + // Resolve `@object-ui/*` to published typings, not workspace sources (TS6059). + compilerOptions: { rootDir: resolve(__dirname, 'src'), paths: {} }, + aliasesExclude: [/^@object-ui\//], + include: ['src'], + exclude: ['**/*.test.ts', '**/*.test.tsx', 'node_modules'], + ...createDtsExplicitExtensions({ packageDir: __dirname }), + ...createDtsFailOnTypeErrors({ packageDir: __dirname }), + }), + ], + resolve: { + alias: { + '@': resolve(__dirname, './src'), + '@object-ui/core': resolve(__dirname, '../core/src/index.ts'), + }, + }, + build: { + lib: { + entry: resolve(__dirname, 'src/index.tsx'), + name: 'ObjectUIPluginTimesheet', + fileName: 'index', + }, + rollupOptions: { + external: (id) => !/^[./]/.test(id) && !id.startsWith(__dirname), + output: { + inlineDynamicImports: true, + globals: { + react: 'React', + 'react-dom': 'ReactDOM', + '@object-ui/components': 'ObjectUIComponents', + '@object-ui/core': 'ObjectUICore', + '@object-ui/i18n': 'ObjectUII18n', + '@object-ui/react': 'ObjectUIReact', + '@object-ui/types': 'ObjectUITypes', + 'lucide-react': 'LucideReact', + }, + }, + }, + }, +}); diff --git a/ui/packages/plugin-view/src/ObjectView.tsx b/ui/packages/plugin-view/src/ObjectView.tsx index b2d5a9ebdeb..2428b73e20d 100644 --- a/ui/packages/plugin-view/src/ObjectView.tsx +++ b/ui/packages/plugin-view/src/ObjectView.tsx @@ -229,8 +229,8 @@ function pickFlatMapConfig( ); } -/** The eight per-kind blocks a list view carries at its top level. */ -const LIST_VIEW_KIND_BLOCKS = ['kanban', 'calendar', 'gallery', 'timeline', 'gantt', 'map', 'chart', 'tree'] as const; +/** The nine per-kind blocks a list view carries at its top level. */ +const LIST_VIEW_KIND_BLOCKS = ['kanban', 'calendar', 'gallery', 'timeline', 'gantt', 'map', 'chart', 'tree', 'timesheet'] as const; /** * [#25923] The per-kind blocks a host `views` entry declares, by reference, diff --git a/ui/scripts/__tests__/side-effects-declaration-consistency.test.ts b/ui/scripts/__tests__/side-effects-declaration-consistency.test.ts index 5e0a848af21..737ea43dbf3 100644 --- a/ui/scripts/__tests__/side-effects-declaration-consistency.test.ts +++ b/ui/scripts/__tests__/side-effects-declaration-consistency.test.ts @@ -1119,6 +1119,7 @@ describe('`sideEffects` declarations match load-time behaviour (objectui#3943)', '@object-ui/plugin-markdown', '@object-ui/plugin-report', '@object-ui/plugin-timeline', + '@object-ui/plugin-timesheet', '@object-ui/plugin-tree', '@object-ui/plugin-view', '@object-ui/react', diff --git a/ui/vitest.config.mts b/ui/vitest.config.mts index 20ded5433cb..3588de1352b 100644 --- a/ui/vitest.config.mts +++ b/ui/vitest.config.mts @@ -548,6 +548,7 @@ export default defineConfig({ '@object-ui/plugin-map': path.resolve(__dirname, './packages/plugin-map/src'), '@object-ui/plugin-markdown': path.resolve(__dirname, './packages/plugin-markdown/src'), '@object-ui/plugin-timeline': path.resolve(__dirname, './packages/plugin-timeline/src'), + '@object-ui/plugin-timesheet': path.resolve(__dirname, './packages/plugin-timesheet/src'), '@object-ui/plugin-view/core': path.resolve(__dirname, './packages/plugin-view/src/core.ts'), '@object-ui/plugin-view': path.resolve(__dirname, './packages/plugin-view/src'), '@object-ui/plugin-report': path.resolve(__dirname, './packages/plugin-report/src'), From bc71aa6e8a116ce7abd00cd92efa18bd8cc2b75d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 14:43:53 +0000 Subject: [PATCH 04/18] feat(ui): timesheet view types arms, parity pins and gate fixes Add the object-timesheet arm to the types union and its zod mirror, let NamedListView carry the timesheet block, re-point the plugin's schema type at @object-ui/types, drop the view form section and the unused spec dependency, and update the census and ratchet pins the new arm moves. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- packages/spec/src/ui/view.form.ts | 7 ----- pnpm-lock.yaml | 3 -- .../registry-inputs-spec-parity.test.ts | 4 +++ ...ateViewDialog.viewTypeParse-11581.test.tsx | 3 ++ ...tered-types-validate-ratchet-10859.test.ts | 6 +++- .../i18n/src/namespaces/timesheet/ar.ts | 2 +- .../i18n/src/namespaces/timesheet/de.ts | 2 +- .../i18n/src/namespaces/timesheet/en.ts | 2 +- .../i18n/src/namespaces/timesheet/es.ts | 2 +- .../i18n/src/namespaces/timesheet/fr.ts | 2 +- .../i18n/src/namespaces/timesheet/ja.ts | 2 +- .../i18n/src/namespaces/timesheet/ko.ts | 2 +- .../i18n/src/namespaces/timesheet/pt-BR.ts | 2 +- .../i18n/src/namespaces/timesheet/ru.ts | 2 +- .../i18n/src/namespaces/timesheet/zh-Hans.ts | 2 +- .../i18n/src/namespaces/timesheet/zh-Hant.ts | 2 +- .../ListViewBlock.specInputs-13047.test.tsx | 15 ++++++++++ ui/packages/plugin-timesheet/README.md | 8 ++--- ui/packages/plugin-timesheet/package.json | 1 - .../plugin-timesheet/src/ObjectTimesheet.tsx | 16 ++-------- .../src/__tests__/ObjectTimesheet.test.tsx | 2 +- ui/packages/plugin-timesheet/src/index.tsx | 5 ++-- ui/packages/plugin-view/src/ObjectView.tsx | 9 ++++++ .../__tests__/objectViewHostSurface.test.tsx | 10 +++++-- .../__tests__/imported-defaults-8317.test.ts | 2 ++ .../object-gallery-filter-9309.test.ts | 1 + .../object-view-unmirrored-keys-7779.test.ts | 30 +++++++++---------- .../objectql-union-arms-7363.test.ts | 3 +- .../src/__tests__/zod-mirror-parity.test.ts | 10 +++++-- ui/packages/types/src/index.ts | 1 + ui/packages/types/src/objectql.ts | 23 ++++++++++++++ ui/packages/types/src/zod/index.zod.ts | 1 + ui/packages/types/src/zod/objectql.zod.ts | 18 +++++++++++ 33 files changed, 134 insertions(+), 66 deletions(-) diff --git a/packages/spec/src/ui/view.form.ts b/packages/spec/src/ui/view.form.ts index 09777568d1c..a78c3cceb3b 100644 --- a/packages/spec/src/ui/view.form.ts +++ b/packages/spec/src/ui/view.form.ts @@ -182,13 +182,6 @@ export const viewForm = defineForm({ visibleWhen: "data.type == 'chart'", fields: [{ field: 'chart', type: 'composite' }], }, - { - name: 'timesheet', - label: 'Timesheet', - description: 'Timesheet-specific configuration.', - visibleWhen: "data.type == 'timesheet'", - fields: [{ field: 'timesheet', type: 'composite' }], - }, // [#17063] The `page` section was REMOVED with the mount it configured // (ADR-0049 enforce-or-remove, maintainer ruling 2026-09-09 「撤」). It bound // the one input `pageName`, which is now a `retiredKey()` tombstone on diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a0466d20b31..dd4347652bc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5987,9 +5987,6 @@ importers: '@object-ui/types': specifier: workspace:* version: link:../types - '@objectstack/spec': - specifier: workspace:^ - version: link:../../../packages/spec lucide-react: specifier: ^1.43.0 version: 1.43.0(react@19.3.0) diff --git a/ui/apps/console/src/__tests__/registry-inputs-spec-parity.test.ts b/ui/apps/console/src/__tests__/registry-inputs-spec-parity.test.ts index 0c98da696c7..c73aca5cab1 100644 --- a/ui/apps/console/src/__tests__/registry-inputs-spec-parity.test.ts +++ b/ui/apps/console/src/__tests__/registry-inputs-spec-parity.test.ts @@ -3072,6 +3072,10 @@ const MEMBER_PINS: Record = { file: LIST_VIEW_PIN_FILE, pins: 'The timeline block\'s `startDateField` (on the `object-timeline` node both flat and in its nested `timeline` config) and `titleField`; with no block, a `type: \'timeline\'` node hands no start date (objectui#13047).', }, + 'list-view.timesheet': { + file: LIST_VIEW_PIN_FILE, + pins: 'The timesheet block\'s binding members `rowFields`, `dateField` and `valueField`, reaching the `object-timesheet` node `ListView` builds unchanged; with no block, a `type: \'timesheet\'` node hands the grid none (objectstack#34382).', + }, 'list-view.tree': { file: LIST_VIEW_PIN_FILE, pins: 'The tree block\'s `parentField` and `labelField`, each reaching the `object-tree` node `ListView` builds; with no block, a `type: \'tree\'` node hands no parent field (objectui#13047).', diff --git a/ui/packages/app-shell/src/views/CreateViewDialog.viewTypeParse-11581.test.tsx b/ui/packages/app-shell/src/views/CreateViewDialog.viewTypeParse-11581.test.tsx index c86b32aea51..b5f8874747d 100644 --- a/ui/packages/app-shell/src/views/CreateViewDialog.viewTypeParse-11581.test.tsx +++ b/ui/packages/app-shell/src/views/CreateViewDialog.viewTypeParse-11581.test.tsx @@ -45,6 +45,9 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { render, cleanup, fireEvent, waitFor, screen, within } from '@testing-library/react'; import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom'; import { ListViewSchema, ViewItemSchema } from '@objectstack/spec/ui'; +// Paid during collection: the source under test reaches a dynamic +// `import('@objectstack/lint')` (celAuthoring.ts), see check:test-source-alias. +import '@objectstack/lint'; import { getMetadataTypeSchema } from '@objectstack/spec/kernel'; import { MetadataClient } from '@object-ui/data-objectstack'; diff --git a/ui/packages/cli/src/__tests__/registered-types-validate-ratchet-10859.test.ts b/ui/packages/cli/src/__tests__/registered-types-validate-ratchet-10859.test.ts index eb1a298e5ba..0c284a8a5fa 100644 --- a/ui/packages/cli/src/__tests__/registered-types-validate-ratchet-10859.test.ts +++ b/ui/packages/cli/src/__tests__/registered-types-validate-ratchet-10859.test.ts @@ -181,8 +181,12 @@ const REFUSED_AT_TYPE = 0; * refused at `type` for the same reason: the bare `row-table` is the one * authorable key, and its arm landed with it. A named stopgap raise of that * one key; any other rise is still a regression. + * objectstack#34382: plus `plugin-timesheet:object-timesheet`, the namespaced + * twin of the timesheet list view's renderer, registered the way every view + * plugin is; the bare `object-timesheet` is the one authorable key, and its arm + * landed with it. A named stopgap raise of that one key, on #31856's terms. */ -const NAMESPACED_REFUSED_AT_TYPE = 307; +const NAMESPACED_REFUSED_AT_TYPE = 308; /** The bare registry keys — the population the card measured. */ const BARE_KEYS = KNOWN_SCHEMA_TYPES.filter((key) => !key.includes(':')); diff --git a/ui/packages/i18n/src/namespaces/timesheet/ar.ts b/ui/packages/i18n/src/namespaces/timesheet/ar.ts index 3a944eb1391..f1c5579b583 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/ar.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/ar.ts @@ -21,7 +21,7 @@ const ar = { addRowConfirm: 'إضافة', cancel: 'إلغاء', noRows: 'لا توجد إدخالات هذا الأسبوع. أضف صفًا للبدء.', - multipleRecords: 'يحتوي هذا اليوم على {{count}} سجلات. عدّلها في القائمة.', + multipleRecords: 'يحتوي هذا اليوم على أكثر من سجل واحد. عدّلها في القائمة.', invalidNumber: 'أدخل رقمًا', saveFailed: 'لم يتم الحفظ: {{message}}', loadFailed: 'تعذر تحميل هذا الأسبوع.', diff --git a/ui/packages/i18n/src/namespaces/timesheet/de.ts b/ui/packages/i18n/src/namespaces/timesheet/de.ts index bc45207de39..9482096bf0c 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/de.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/de.ts @@ -21,7 +21,7 @@ const de = { addRowConfirm: 'Hinzufügen', cancel: 'Abbrechen', noRows: 'Keine Einträge in dieser Woche. Fügen Sie eine Zeile hinzu, um zu beginnen.', - multipleRecords: 'Dieser Tag enthält {{count}} Datensätze. Bearbeiten Sie sie in der Liste.', + multipleRecords: 'Dieser Tag enthält mehr als einen Datensatz. Bearbeiten Sie sie in der Liste.', invalidNumber: 'Geben Sie eine Zahl ein', saveFailed: 'Nicht gespeichert: {{message}}', loadFailed: 'Diese Woche konnte nicht geladen werden.', diff --git a/ui/packages/i18n/src/namespaces/timesheet/en.ts b/ui/packages/i18n/src/namespaces/timesheet/en.ts index c344569b878..b6c9d37682f 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/en.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/en.ts @@ -21,7 +21,7 @@ const en = { addRowConfirm: 'Add', cancel: 'Cancel', noRows: 'No entries this week. Add a row to start.', - multipleRecords: 'This day holds {{count}} records. Edit them in the list.', + multipleRecords: 'This day holds more than one record. Edit them in the list.', invalidNumber: 'Enter a number', saveFailed: 'Not saved: {{message}}', loadFailed: 'This week could not be loaded.', diff --git a/ui/packages/i18n/src/namespaces/timesheet/es.ts b/ui/packages/i18n/src/namespaces/timesheet/es.ts index 94a7e6e5254..111eb7b211a 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/es.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/es.ts @@ -21,7 +21,7 @@ const es = { addRowConfirm: 'Añadir', cancel: 'Cancelar', noRows: 'No hay entradas esta semana. Añade una fila para empezar.', - multipleRecords: 'Este día tiene {{count}} registros. Edítalos en la lista.', + multipleRecords: 'Este día tiene más de un registro. Edítalos en la lista.', invalidNumber: 'Introduce un número', saveFailed: 'No guardado: {{message}}', loadFailed: 'No se pudo cargar esta semana.', diff --git a/ui/packages/i18n/src/namespaces/timesheet/fr.ts b/ui/packages/i18n/src/namespaces/timesheet/fr.ts index 999ebac0468..21544464c29 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/fr.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/fr.ts @@ -21,7 +21,7 @@ const fr = { addRowConfirm: 'Ajouter', cancel: 'Annuler', noRows: 'Aucune saisie cette semaine. Ajoutez une ligne pour commencer.', - multipleRecords: 'Ce jour contient {{count}} enregistrements. Modifiez-les dans la liste.', + multipleRecords: 'Ce jour contient plus d’un enregistrement. Modifiez-les dans la liste.', invalidNumber: 'Saisissez un nombre', saveFailed: 'Non enregistré : {{message}}', loadFailed: 'Impossible de charger cette semaine.', diff --git a/ui/packages/i18n/src/namespaces/timesheet/ja.ts b/ui/packages/i18n/src/namespaces/timesheet/ja.ts index 932189f1fa9..98fa73a9ada 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/ja.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/ja.ts @@ -21,7 +21,7 @@ const ja = { addRowConfirm: '追加', cancel: 'キャンセル', noRows: '今週のエントリはありません。行を追加して開始してください。', - multipleRecords: 'この日には {{count}} 件のレコードがあります。一覧で編集してください。', + multipleRecords: 'この日には複数のレコードがあります。一覧で編集してください。', invalidNumber: '数値を入力してください', saveFailed: '保存されていません: {{message}}', loadFailed: '今週のデータを読み込めませんでした。', diff --git a/ui/packages/i18n/src/namespaces/timesheet/ko.ts b/ui/packages/i18n/src/namespaces/timesheet/ko.ts index 57c13dfdb45..f8eb52f7a66 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/ko.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/ko.ts @@ -21,7 +21,7 @@ const ko = { addRowConfirm: '추가', cancel: '취소', noRows: '이번 주에는 항목이 없습니다. 행을 추가하여 시작하세요.', - multipleRecords: '이 날에는 레코드가 {{count}}개 있습니다. 목록에서 편집하세요.', + multipleRecords: '이 날에는 레코드가 여러 개 있습니다. 목록에서 편집하세요.', invalidNumber: '숫자를 입력하세요', saveFailed: '저장되지 않음: {{message}}', loadFailed: '이번 주를 불러올 수 없습니다.', diff --git a/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts b/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts index 17b2ec528fe..cb98b8394f5 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts @@ -21,7 +21,7 @@ const pt = { addRowConfirm: 'Adicionar', cancel: 'Cancelar', noRows: 'Nenhum lançamento nesta semana. Adicione uma linha para começar.', - multipleRecords: 'Este dia tem {{count}} registros. Edite-os na lista.', + multipleRecords: 'Este dia tem mais de um registro. Edite-os na lista.', invalidNumber: 'Digite um número', saveFailed: 'Não salvo: {{message}}', loadFailed: 'Não foi possível carregar esta semana.', diff --git a/ui/packages/i18n/src/namespaces/timesheet/ru.ts b/ui/packages/i18n/src/namespaces/timesheet/ru.ts index 930e712cbcb..a63f4d1a063 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/ru.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/ru.ts @@ -21,7 +21,7 @@ const ru = { addRowConfirm: 'Добавить', cancel: 'Отмена', noRows: 'На этой неделе нет записей. Добавьте строку, чтобы начать.', - multipleRecords: 'В этот день записей: {{count}}. Измените их в списке.', + multipleRecords: 'В этот день несколько записей. Измените их в списке.', invalidNumber: 'Введите число', saveFailed: 'Не сохранено: {{message}}', loadFailed: 'Не удалось загрузить эту неделю.', diff --git a/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts b/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts index 54f84388cc1..77b0b5d6ddb 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts @@ -21,7 +21,7 @@ const zh = { addRowConfirm: '添加', cancel: '取消', noRows: '本周没有记录。添加一行即可开始。', - multipleRecords: '这一天有 {{count}} 条记录,请在列表中编辑。', + multipleRecords: '这一天有多条记录,请在列表中编辑。', invalidNumber: '请输入数字', saveFailed: '未保存:{{message}}', loadFailed: '无法加载本周数据。', diff --git a/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts b/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts index dca7b671b61..1f44931403f 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts @@ -18,7 +18,7 @@ const zhHant = { addRowConfirm: '新增', cancel: '取消', noRows: '本週沒有記錄。新增一行即可開始。', - multipleRecords: '這一天有 {{count}} 條記錄,請在列表中編輯。', + multipleRecords: '這一天有多條記錄,請在列表中編輯。', invalidNumber: '請輸入數字', saveFailed: '未儲存:{{message}}', loadFailed: '無法載入本週資料。', diff --git a/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx b/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx index c0efd5175d1..dafc4b95be9 100644 --- a/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx @@ -116,6 +116,7 @@ const CHILD_VIEWS = [ 'object-map', 'object-tree', 'object-chart', + 'object-timesheet', ] as const; type ChildView = (typeof CHILD_VIEWS)[number]; @@ -728,6 +729,20 @@ describe('objectui#13047 — each kind\'s own block, handed to the node of the v expect(tree.labelField).toBe('owner'); }); + it('`timesheet`: the `rowFields` / `dateField` / `valueField` binding reaches the grid', async () => { + const control = mount({ type: 'timesheet' }); + await loaded(control.dataSource); + expect(lastHanded('object-timesheet')?.timesheet).toBeUndefined(); + cleanup(); + resetHanded(); + + const block = { rowFields: ['owner'], dateField: 'due', valueField: 'amount' }; + const { dataSource } = mount({ type: 'timesheet', timesheet: block }); + await handedTo('object-timesheet'); + await loaded(dataSource); + expect(lastHanded('object-timesheet').timesheet).toEqual(block); + }); + it('`chart`: the `dataset` binding and its `values` / `dimensions` reach the chart', async () => { const { dataSource } = mount({ type: 'chart', diff --git a/ui/packages/plugin-timesheet/README.md b/ui/packages/plugin-timesheet/README.md index 49a50612833..97f3ed7909c 100644 --- a/ui/packages/plugin-timesheet/README.md +++ b/ui/packages/plugin-timesheet/README.md @@ -15,13 +15,11 @@ It registers one component type via the `ComponentRegistry`: ## Usage -Declare the view in metadata; `ListView` composes the node: +Declare a list view whose `type` is `timesheet`, with its binding block; +`ListView` composes the node: ```ts -const view = { - type: 'timesheet', - data: { provider: 'object', object: 'time_entry' }, - columns: ['project', 'task', 'work_date', 'hours'], +const binding = { timesheet: { rowFields: ['project', 'task'], // 1–3 fields; one row per distinct combination dateField: 'work_date', // date or datetime diff --git a/ui/packages/plugin-timesheet/package.json b/ui/packages/plugin-timesheet/package.json index fa3e4f90960..7c81f958f31 100644 --- a/ui/packages/plugin-timesheet/package.json +++ b/ui/packages/plugin-timesheet/package.json @@ -43,7 +43,6 @@ "@object-ui/permissions": "workspace:*", "@object-ui/react": "workspace:*", "@object-ui/types": "workspace:*", - "@objectstack/spec": "workspace:^", "lucide-react": "^1.43.0" }, "peerDependencies": { diff --git a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx index 564ba8b7075..439c7fdfa0b 100644 --- a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx +++ b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx @@ -42,7 +42,7 @@ */ import React, { useEffect, useMemo, useState } from 'react'; -import type { DataSource } from '@object-ui/types'; +import type { DataSource, ObjectTimesheetSchema } from '@object-ui/types'; import { useDataInvalidation, useFilterScope, @@ -105,7 +105,7 @@ const TIMESHEET_DEFAULT_TRANSLATIONS: Record = { 'timesheet.addRowConfirm': 'Add', 'timesheet.cancel': 'Cancel', 'timesheet.noRows': 'No entries this week. Add a row to start.', - 'timesheet.multipleRecords': 'This day holds {{count}} records. Edit them in the list.', + 'timesheet.multipleRecords': 'This day holds more than one record. Edit them in the list.', 'timesheet.invalidNumber': 'Enter a number', 'timesheet.saveFailed': 'Not saved: {{message}}', 'timesheet.loadFailed': 'This week could not be loaded.', @@ -120,16 +120,6 @@ const useTimesheetTranslation = createSafeTranslation( 'timesheet.missingBindingTitle', ); -/** The `object-timesheet` node `ListView` composes for a timesheet view. */ -export interface ObjectTimesheetSchema { - type?: 'object-timesheet'; - objectName?: string; - timesheet?: unknown; - filter?: unknown; - className?: string; - [key: string]: unknown; -} - export interface ObjectTimesheetProps { schema: ObjectTimesheetSchema; dataSource?: DataSource; @@ -439,7 +429,7 @@ function TimesheetGridView({ schema, objectName, binding, dataSource, className, diff --git a/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx b/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx index 3344213df21..cee9fea84ab 100644 --- a/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx +++ b/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx @@ -91,7 +91,7 @@ describe('ObjectTimesheet', () => { renderTimesheet(ds); const cell = await screen.findByTestId('timesheet-cell-readonly'); expect(cell.textContent).toBe('3.5'); - expect(cell.getAttribute('title')).toContain('2 records'); + expect(cell.getAttribute('title')).toContain('more than one record'); }); it('updates a one-record cell through the record door', async () => { diff --git a/ui/packages/plugin-timesheet/src/index.tsx b/ui/packages/plugin-timesheet/src/index.tsx index f52c6381a44..9cfc717e893 100644 --- a/ui/packages/plugin-timesheet/src/index.tsx +++ b/ui/packages/plugin-timesheet/src/index.tsx @@ -10,10 +10,11 @@ import React from 'react'; import { ComponentRegistry } from '@object-ui/core'; import { useSchemaContext } from '@object-ui/react'; import { ObjectTimesheet } from './ObjectTimesheet'; -import type { ObjectTimesheetProps, ObjectTimesheetSchema } from './ObjectTimesheet'; +import type { ObjectTimesheetProps } from './ObjectTimesheet'; export { ObjectTimesheet }; -export type { ObjectTimesheetProps, ObjectTimesheetSchema }; +export type { ObjectTimesheetProps }; +export type { ObjectTimesheetSchema } from '@object-ui/types'; export { buildTimesheetRows, planCellWrite, diff --git a/ui/packages/plugin-view/src/ObjectView.tsx b/ui/packages/plugin-view/src/ObjectView.tsx index 2428b73e20d..146661e70ca 100644 --- a/ui/packages/plugin-view/src/ObjectView.tsx +++ b/ui/packages/plugin-view/src/ObjectView.tsx @@ -2156,6 +2156,7 @@ export const ObjectView: React.FC = ({ map: currentNamedViewConfig?.map, chart: currentNamedViewConfig?.chart, tree: currentNamedViewConfig?.tree, + timesheet: currentNamedViewConfig?.timesheet, }; const declaredKinds = Object.keys(canonicalViewKindBlocks) .filter((kind) => canonicalViewKindBlocks[kind] != null); @@ -2572,6 +2573,14 @@ export const ObjectView: React.FC = ({ // added undeclared keys and let a block key named like a node key // override the node's own value. }; + case 'timesheet': + // objectstack#34382 — the editable row × weekday grid, its binding by + // reference; `ObjectTimesheet` judges it and refuses an incomplete one. + return { + type: 'object-timesheet', + ...baseProps, + timesheet: viewOptions.timesheet, + }; case 'chart': { // ⛔ HOST-COMPOSITION ONLY (objectui#5321) — the same record as // `tree` above: `chart` is in neither authored union, so the ADR-0021 diff --git a/ui/packages/plugin-view/src/__tests__/objectViewHostSurface.test.tsx b/ui/packages/plugin-view/src/__tests__/objectViewHostSurface.test.tsx index cf8c8f91eb8..76f58dd2a30 100644 --- a/ui/packages/plugin-view/src/__tests__/objectViewHostSurface.test.tsx +++ b/ui/packages/plugin-view/src/__tests__/objectViewHostSurface.test.tsx @@ -600,9 +600,13 @@ const branchSlice = (): string => { const caseLabelsIn = (slice: string): string[] => [...new Set([...stripComments(slice).matchAll(/case '([a-z-]+)':/g)].map((m) => m[1]))].sort(); -/** The eight branches the card was measured on. */ +/** + * The eight branches the card was measured on, plus `timesheet` + * (objectstack#34382), which is authored: `NamedListView.type` takes the + * spec's list-view enum, which declares it. + */ const MEASURED_BRANCHES = [ - 'calendar', 'chart', 'gallery', 'gantt', 'kanban', 'map', 'timeline', 'tree', + 'calendar', 'chart', 'gallery', 'gantt', 'kanban', 'map', 'timeline', 'timesheet', 'tree', ]; // --------------------------------------------------------------------------- @@ -612,7 +616,7 @@ const MEASURED_BRANCHES = [ describe('the host-only view-type record matches the branches (objectui#5321)', () => { const recorded: string[] = [...OBJECT_VIEW_HOST_COMPOSITION_VIEW_TYPES].sort(); - it('the fenced switch carries exactly the eight branches the card measured', () => { + it('the fenced switch carries exactly the branches the card measured, plus timesheet', () => { expect( caseLabelsIn(branchSlice()), 'A view-type branch was added to or removed from `generateViewSchema`. That is a contract\n' diff --git a/ui/packages/types/src/__tests__/imported-defaults-8317.test.ts b/ui/packages/types/src/__tests__/imported-defaults-8317.test.ts index 9285cc76baf..21b5fad8323 100644 --- a/ui/packages/types/src/__tests__/imported-defaults-8317.test.ts +++ b/ui/packages/types/src/__tests__/imported-defaults-8317.test.ts @@ -67,6 +67,7 @@ import { GalleryConfigSchema as SpecGalleryConfigSchema, TimelineConfigSchema as SpecTimelineConfigSchema, TreeConfigSchema as SpecTreeConfigSchema, + TimesheetConfigSchema as SpecTimesheetConfigSchema, HttpMethodSubsetSchema as SpecHttpMethodSubsetSchema, HttpRequestSchema as SpecHttpRequestSchema, ViewDataSchema as SpecViewDataSchema, @@ -258,6 +259,7 @@ const IMPORTED: Array = [ // objectui#11168 slice 3: `ObjectTreeSchema.tree` is the spec's tree block, // crossed through this boundary like the other view-config blocks above. ['TreeConfigSchema', SpecTreeConfigSchema], + ['TimesheetConfigSchema', SpecTimesheetConfigSchema], ['HttpMethodSubsetSchema', SpecHttpMethodSubsetSchema], ['HttpRequestSchema', SpecHttpRequestSchema], ['ViewDataSchema', SpecViewDataSchema], diff --git a/ui/packages/types/src/__tests__/object-gallery-filter-9309.test.ts b/ui/packages/types/src/__tests__/object-gallery-filter-9309.test.ts index d4a938ea447..def4cfd9cbf 100644 --- a/ui/packages/types/src/__tests__/object-gallery-filter-9309.test.ts +++ b/ui/packages/types/src/__tests__/object-gallery-filter-9309.test.ts @@ -193,6 +193,7 @@ const EXPECTED_CENSUS: readonly FilterRow[] = [ { owner: 'ObjectMapSchema', type: "SpecObjectMapProps['filter']" }, // objectui#9549 — declared in the shape this card settled. { owner: 'ObjectTreeSchema', type: "QueryParams['$filter']" }, + { owner: 'ObjectTimesheetSchema', type: "QueryParams['$filter']" }, { owner: 'ObjectGanttSchema', type: "SpecObjectGanttProps['filter']" }, { owner: 'ObjectCalendarSchema', type: "SpecObjectCalendarProps['filter']" }, { owner: 'ObjectKanbanSchema', type: "SpecObjectKanbanProps['filter']" }, diff --git a/ui/packages/types/src/__tests__/object-view-unmirrored-keys-7779.test.ts b/ui/packages/types/src/__tests__/object-view-unmirrored-keys-7779.test.ts index 911507c7f1c..cdb3fa1698f 100644 --- a/ui/packages/types/src/__tests__/object-view-unmirrored-keys-7779.test.ts +++ b/ui/packages/types/src/__tests__/object-view-unmirrored-keys-7779.test.ts @@ -248,7 +248,7 @@ const NAMED_VIEW_READS = [ 'description', 'emptyState', 'exportOptions', 'fieldOrder', 'filter', 'gallery', 'gantt', 'grouping', 'hiddenFields', 'inlineEdit', 'kanban', 'label', 'map', 'name', 'navigation', 'pagination', 'resizable', 'rowActions', 'rowColor', 'rowHeight', - 'searchableFields', 'selection', 'sharing', 'showRecordCount', 'sort', 'timeline', 'tree', + 'searchableFields', 'selection', 'sharing', 'showRecordCount', 'sort', 'timeline', 'timesheet', 'tree', 'type', 'userActions', 'userFilters', ] as const; @@ -258,7 +258,7 @@ const NAMED_VIEW_READS = [ * that moves between the two sets — in EITHER direction — fails by name. */ -/** Every top-level member `NamedListView` declares. 65 today (47 + objectui#8980's seventeen + objectui#12341's `requiredPermissions`), sorted. */ +/** Every top-level member `NamedListView` declares. 66 today (47 + objectui#8980's seventeen + objectui#12341's `requiredPermissions` + objectstack#34382's `timesheet`), sorted. */ const NAMED_LIST_VIEW_DECLARED = [ 'addDeleteRecordsInline', 'addRecord', 'addRecordViaForm', 'allowExport', 'allowPrinting', 'appearance', 'aria', 'bulkActionDefs', 'bulkActions', 'calendar', 'chart', @@ -269,12 +269,12 @@ const NAMED_LIST_VIEW_DECLARED = [ 'pageName', 'pagination', 'prefixField', 'requiredPermissions', 'resizable', 'rowActions', 'rowColor', 'rowHeight', 'searchableFields', 'selection', 'sharing', 'showColor', 'showDensity', 'showDescription', 'showFilters', 'showGroup', 'showHideFields', 'showRecordCount', 'showSearch', 'showSort', - 'sort', 'tabs', 'timeline', 'tree', 'type', 'userActions', 'userFilters', 'wrapHeaders', + 'sort', 'tabs', 'timeline', 'timesheet', 'tree', 'type', 'userActions', 'userFilters', 'wrapHeaders', ] as const; /** - * The DECLARED members the renderer reads off a named view. All 42 of them - * (43 until objectui#13118 stopped reading `filterableFields`; 20 until + * The DECLARED members the renderer reads off a named view. All 43 of them + * (42 until objectstack#34382 added `timesheet`; 43 until objectui#13118 stopped reading `filterableFields`; 20 until * objectui#10758 added bucket ①; 21 until objectui#7928 dropped `options`) — * the read set and the declared set disagree on no name since objectui#8980, * which is what closed {@link NAMED_VIEW_READ_UNDECLARED}. @@ -285,7 +285,7 @@ const NAMED_VIEW_READ_DECLARED = [ 'description', 'emptyState', 'exportOptions', 'fieldOrder', 'filter', 'gallery', 'gantt', 'grouping', 'hiddenFields', 'inlineEdit', 'kanban', 'label', 'map', 'name', 'navigation', 'pagination', 'resizable', 'rowActions', 'rowColor', 'rowHeight', - 'searchableFields', 'selection', 'sharing', 'showRecordCount', 'sort', 'timeline', 'tree', + 'searchableFields', 'selection', 'sharing', 'showRecordCount', 'sort', 'timeline', 'timesheet', 'tree', 'type', 'userActions', 'userFilters', ] as const; @@ -387,7 +387,7 @@ const PROTOCOL_LIST_VIEW_KEYS = [ 'grouping', 'hiddenFields', 'inlineEdit', 'kanban', 'label', 'map', 'name', 'navigation', 'pageName', 'pagination', 'requiredPermissions', 'resizable', 'rowActions', 'rowColor', 'rowHeight', 'searchableFields', 'selection', 'sharing', 'showRecordCount', 'sort', - 'tabs', 'timeline', 'tree', 'type', 'userActions', 'userFilters', + 'tabs', 'timeline', 'timesheet', 'tree', 'type', 'userActions', 'userFilters', ] as const; /** @@ -1540,8 +1540,8 @@ describe('objectui#7779 → objectui#7928 — `listViews` was ledgered on the fa // figures could stale silently in either direction. expect( declared, - 'NamedListView\'s top-level member count moved (was 65 — 47 plus objectui#8980\'s seventeen plus objectui#12341\'s requiredPermissions). Re-derive it with this file\'s own namedListViewMemberCount() regex, then update the "64 declared / 43 unread" figures in the three files that carry them together — .changeset/object-view-unmirrored-keys-7779.md, packages/types/src/zod/objectql.zod.ts and packages/types/src/__tests__/zod-mirror-parity.test.ts — plus this file\'s own header. A shrink toward the read set also re-opens the listViews decision (objectui#7928).', - ).toBe(65); + 'NamedListView\'s top-level member count moved (was 66 — 47 plus objectui#8980\'s seventeen plus objectui#12341\'s requiredPermissions plus objectstack#34382\'s timesheet). Re-derive it with this file\'s own namedListViewMemberCount() regex, then update the "64 declared / 43 unread" figures in the three files that carry them together — .changeset/object-view-unmirrored-keys-7779.md, packages/types/src/zod/objectql.zod.ts and packages/types/src/__tests__/zod-mirror-parity.test.ts — plus this file\'s own header. A shrink toward the read set also re-opens the listViews decision (objectui#7928).', + ).toBe(66); expect(declared).toBeGreaterThan(NAMED_VIEW_READS.length); }); @@ -1573,15 +1573,15 @@ describe('objectui#7924 — the per-member liveness census on `NamedListView`, r it('the declared member set is EXACTLY the census, by name', () => { expect([...namedListViewMembers().names].sort()).toEqual([...NAMED_LIST_VIEW_DECLARED].sort()); - expect(NAMED_LIST_VIEW_DECLARED).toHaveLength(65); - expect(new Set(NAMED_LIST_VIEW_DECLARED).size).toBe(65); + expect(NAMED_LIST_VIEW_DECLARED).toHaveLength(66); + expect(new Set(NAMED_LIST_VIEW_DECLARED).size).toBe(66); }); it('all three instruments read the same declaration, and the two that disagree disagree for a stated reason', () => { const ast = namedListViewMembers().names.length; // The parser and the strict regex agree — that agreement is what licenses // replacing the regex without re-opening the number. - expect(ast).toBe(65); + expect(ast).toBe(66); expect(namedListViewMemberCount()).toBe(ast); // …and the loose regex does NOT, by 9, because it also counts nested // object-literal lines. The gap stayed exactly 12 through objectui#8980: @@ -1594,7 +1594,7 @@ describe('objectui#7924 — the per-member liveness census on `NamedListView`, r // is a single-line type reference too, so it moved both counts by one and // left the gap at 9. Pinned so "a figure between two // instruments is neither" stays a reading rather than a remembered sentence. - expect(namedListViewLooseMemberCount()).toBe(74); + expect(namedListViewLooseMemberCount()).toBe(75); expect(namedListViewLooseMemberCount()).toBeGreaterThan(ast); }); @@ -1625,7 +1625,7 @@ describe('objectui#7924 — the per-member liveness census on `NamedListView`, r const d = deriveNamedViewReads(); expect(d.reads).toEqual([...NAMED_VIEW_READS]); // 43 until objectui#13118 stopped reading the spec-retired `filterableFields`. - expect(d.reads).toHaveLength(42); + expect(d.reads).toHaveLength(43); // ⭐ THE INSTRUMENTS NOW DISAGREE BY ONE NAME, and the difference is pinned // rather than smoothed over. The AST finds STRICTLY more than the // `currentNamedViewConfig?.KEY` regex it replaced — that was already true @@ -1651,7 +1651,7 @@ describe('objectui#7924 — the per-member liveness census on `NamedListView`, r const unread = [...declared].filter((m) => !reads.has(m)).sort(); expect(read).toEqual([...NAMED_VIEW_READ_DECLARED]); expect(unread).toEqual([...NAMED_LIST_VIEW_UNREAD]); - expect(read).toHaveLength(42); + expect(read).toHaveLength(43); expect(unread).toHaveLength(23); expect(read.length + unread.length).toBe(declared.size); expect(read.filter((m) => unread.includes(m))).toEqual([]); diff --git a/ui/packages/types/src/__tests__/objectql-union-arms-7363.test.ts b/ui/packages/types/src/__tests__/objectql-union-arms-7363.test.ts index a8f933076fb..54baf84ef33 100644 --- a/ui/packages/types/src/__tests__/objectql-union-arms-7363.test.ts +++ b/ui/packages/types/src/__tests__/objectql-union-arms-7363.test.ts @@ -93,7 +93,8 @@ describe('objectui#7363 — the two objectui#6576 schemas are arms of the Object // (`object-grid-properties-bag-11276.test.ts`), and `list-view`, whose // authored page arm left in objectui#12670 // (`list-view-properties-bag-12670.test.ts`). - expect(literals).toHaveLength(6); + // Seven since objectstack#34382 armed `object-timesheet`. + expect(literals).toHaveLength(7); expect(literals).not.toContain('list-view'); expect(literals).not.toContain('object-grid'); expect(literals).not.toContain('object-form'); diff --git a/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts b/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts index eb67e7c09e8..49a58ea6a79 100644 --- a/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts +++ b/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts @@ -998,7 +998,7 @@ import { EmptySchema, LoadingSchema, ProgressSchema, SkeletonSchema, SonnerSchem import { ButtonSchema, CalendarSchema, CheckboxSchema, CodeEditorSchema, ComboboxOptionSchema, ComboboxSchema, CommandGroupSchema, CommandItemSchema, CommandSchema, DatePickerSchema, FieldConditionSchema, FieldConstraintsSchema, FileUploadSchema, FormFieldSchema, FormSchema, InputOTPSchema, InputSchema, InputShorthandSchema, LabelSchema, RadioGroupSchema, RadioOptionSchema, SelectOptionSchema, SelectSchema, SliderSchema, SwitchSchema, TextareaSchema, ToggleSchema, UiCalendarSchema } from '../zod/form.zod.js'; import { AspectRatioSchema, BoxSchema, CardSchema, ContainerSchema, DivSchema, FlexSchema, GridSchema, HtmlElementSchema, IconSchema, ImageSchema, PageNodeRegionSchema, SemanticElementSchema, PageNodeSchema, ResizablePanelSchema, ResizableSchema, ScrollAreaSchema, SeparatorSchema, StackSchema, TabItemSchema, TabsSchema, TextSchema, TextSpanSchema } from '../zod/layout.zod.js'; import { BreadcrumbItemSchema, BreadcrumbSchema, ButtonGroupButtonSchema, ButtonGroupSchema, HeaderBarSchema, NavigationMenuItemSchema, NavigationMenuSchema, PaginationSchema, SidebarSchema } from '../zod/navigation.zod.js'; -import { ObjectCalendarSchema, ObjectChartSchema, ObjectDataTableSchema, ObjectFormSchema, ObjectGallerySchema, ObjectGanttSchema, ObjectGridSchema, ObjectKanbanSchema, ObjectMapConfigSchema, ObjectMapSchema, ObjectTreeSchema, ObjectViewSchema, SortConfigSchema } from '../zod/objectql.zod.js'; +import { ObjectCalendarSchema, ObjectChartSchema, ObjectDataTableSchema, ObjectFormSchema, ObjectGallerySchema, ObjectGanttSchema, ObjectGridSchema, ObjectKanbanSchema, ObjectMapConfigSchema, ObjectMapSchema, ObjectTimesheetSchema, ObjectTreeSchema, ObjectViewSchema, SortConfigSchema } from '../zod/objectql.zod.js'; import { AlertDialogSchema, ContextMenuSchema, DialogSchema, DrawerSchema, DropdownMenuSchema, HoverCardSchema, MenubarMenuSchema, MenubarSchema, MenuItemSchema as OverlayMenuItemSchema, PopoverSchema, SheetSchema, TooltipSchema } from '../zod/overlay.zod.js'; import { ReportBuilderSchema, ReportComponentSchema, ReportExportConfigSchema, ReportFieldSchema, ReportFilterSchema, ReportGroupBySchema, ReportSectionSchema, ReportViewerSchema } from '../zod/reports.zod.js'; import { DetailSectionNodeSchema, DetailViewFieldSchema, DetailViewSchema, DetailViewSectionSchema, DetailViewTabSchema, FilterUISchema, SortUISchema, ViewSwitcherSchema } from '../zod/views.zod.js'; @@ -1020,7 +1020,7 @@ import type { EmptySchema as Ts_EmptySchema, LoadingSchema as Ts_LoadingSchema, import type { ButtonSchema as Ts_ButtonSchema, CalendarSchema as Ts_CalendarSchema, CheckboxSchema as Ts_CheckboxSchema, CodeEditorSchema as Ts_CodeEditorSchema, ComboboxOption as Ts_ComboboxOption, ComboboxSchema as Ts_ComboboxSchema, CommandGroup as Ts_CommandGroup, CommandItem as Ts_CommandItem, CommandSchema as Ts_CommandSchema, DatePickerSchema as Ts_DatePickerSchema, FieldCondition as Ts_FieldCondition, FieldValidationRules as Ts_FieldValidationRules, FileUploadSchema as Ts_FileUploadSchema, FormField as Ts_FormField, FormSchema as Ts_FormSchema, InputOTPSchema as Ts_InputOTPSchema, InputSchema as Ts_InputSchema, InputShorthandSchema as Ts_InputShorthandSchema, UiCalendarSchema as Ts_UiCalendarSchema, LabelSchema as Ts_LabelSchema, RadioGroupSchema as Ts_RadioGroupSchema, RadioOption as Ts_RadioOption, SelectOption as Ts_SelectOption, SelectSchema as Ts_SelectSchema, SliderSchema as Ts_SliderSchema, SwitchSchema as Ts_SwitchSchema, TextareaSchema as Ts_TextareaSchema, ToggleSchema as Ts_ToggleSchema } from '../form'; import type { AspectRatioSchema as Ts_AspectRatioSchema, BoxSchema as Ts_BoxSchema, CardSchema as Ts_CardSchema, ContainerSchema as Ts_ContainerSchema, DivSchema as Ts_DivSchema, FlexSchema as Ts_FlexSchema, GridSchema as Ts_GridSchema, HtmlElementSchema as Ts_HtmlElementSchema, IconSchema as Ts_IconSchema, ImageSchema as Ts_ImageSchema, SemanticElementSchema as Ts_SemanticElementSchema, PageNodeRegion as Ts_PageNodeRegion, PageNodeSchema as Ts_PageNodeSchema, ResizablePanel as Ts_ResizablePanel, ResizableSchema as Ts_ResizableSchema, ScrollAreaSchema as Ts_ScrollAreaSchema, SeparatorSchema as Ts_SeparatorSchema, StackSchema as Ts_StackSchema, TabItem as Ts_TabItem, TabsSchema as Ts_TabsSchema, TextSchema as Ts_TextSchema, TextSpanSchema as Ts_TextSpanSchema } from '../layout'; import type { ButtonGroupButton as Ts_ButtonGroupButton, ButtonGroupSchema as Ts_ButtonGroupSchema, HeaderBarSchema as Ts_HeaderBarSchema, NavigationMenuSchema as Ts_NavigationMenuSchema, PaginationSchema as Ts_PaginationSchema, SidebarSchema as Ts_SidebarSchema } from '../navigation'; -import type { ObjectCalendarSchema as Ts_ObjectCalendarSchema, ObjectChartSchema as Ts_ObjectChartSchema, ObjectDataTableSchema as Ts_ObjectDataTableSchema, ObjectFormSchema as Ts_ObjectFormSchema, ObjectGallerySchema as Ts_ObjectGallerySchema, ObjectGanttSchema as Ts_ObjectGanttSchema, ObjectGridSchema as Ts_ObjectGridSchema, ObjectKanbanSchema as Ts_ObjectKanbanSchema, ObjectMapConfig as Ts_ObjectMapConfig, ObjectMapSchema as Ts_ObjectMapSchema, ObjectTreeSchema as Ts_ObjectTreeSchema, ObjectViewSchema as Ts_ObjectViewSchema, SortConfig as Ts_SortConfig } from '../objectql'; +import type { ObjectCalendarSchema as Ts_ObjectCalendarSchema, ObjectChartSchema as Ts_ObjectChartSchema, ObjectDataTableSchema as Ts_ObjectDataTableSchema, ObjectFormSchema as Ts_ObjectFormSchema, ObjectGallerySchema as Ts_ObjectGallerySchema, ObjectGanttSchema as Ts_ObjectGanttSchema, ObjectGridSchema as Ts_ObjectGridSchema, ObjectKanbanSchema as Ts_ObjectKanbanSchema, ObjectMapConfig as Ts_ObjectMapConfig, ObjectMapSchema as Ts_ObjectMapSchema, ObjectTimesheetSchema as Ts_ObjectTimesheetSchema, ObjectTreeSchema as Ts_ObjectTreeSchema, ObjectViewSchema as Ts_ObjectViewSchema, SortConfig as Ts_SortConfig } from '../objectql'; import type { AlertDialogSchema as Ts_AlertDialogSchema, ContextMenuSchema as Ts_ContextMenuSchema, DialogSchema as Ts_DialogSchema, DrawerSchema as Ts_DrawerSchema, DropdownMenuSchema as Ts_DropdownMenuSchema, HoverCardSchema as Ts_HoverCardSchema, MenubarMenu as Ts_MenubarMenu, MenubarSchema as Ts_MenubarSchema, PopoverSchema as Ts_PopoverSchema, SheetSchema as Ts_SheetSchema, TooltipSchema as Ts_TooltipSchema } from '../overlay'; import type { ReportBuilderSchema as Ts_ReportBuilderSchema, ReportComponentSchema as Ts_ReportComponentSchema, ReportExportConfig as Ts_ReportExportConfig, ReportField as Ts_ReportField, ReportFilter as Ts_ReportFilter, ReportGroupBy as Ts_ReportGroupBy, ReportSection as Ts_ReportSection, ReportViewerSchema as Ts_ReportViewerSchema } from '../reports'; import type { DetailSectionNodeSchema as Ts_DetailSectionNodeSchema, DetailViewField as Ts_DetailViewField, DetailViewSchema as Ts_DetailViewSchema, DetailViewSection as Ts_DetailViewSection, DetailViewTab as Ts_DetailViewTab, FilterUISchema as Ts_FilterUISchema, SortUISchema as Ts_SortUISchema, ViewSwitcherSchema as Ts_ViewSwitcherSchema } from '../views'; @@ -2019,6 +2019,7 @@ const MIRRORS = { 'objectql.zod.ts#ObjectKanbanSchema': ObjectKanbanSchema, 'objectql.zod.ts#ObjectMapConfigSchema': ObjectMapConfigSchema, 'objectql.zod.ts#ObjectMapSchema': ObjectMapSchema, + 'objectql.zod.ts#ObjectTimesheetSchema': ObjectTimesheetSchema, 'objectql.zod.ts#ObjectTreeSchema': ObjectTreeSchema, 'objectql.zod.ts#ObjectViewSchema': ObjectViewSchema, 'objectql.zod.ts#SortConfigSchema': SortConfigSchema, @@ -2227,6 +2228,7 @@ interface Declared { 'objectql.zod.ts#ObjectKanbanSchema': Ts_ObjectKanbanSchema; 'objectql.zod.ts#ObjectMapConfigSchema': Ts_ObjectMapConfig; 'objectql.zod.ts#ObjectMapSchema': Ts_ObjectMapSchema; + 'objectql.zod.ts#ObjectTimesheetSchema': Ts_ObjectTimesheetSchema; 'objectql.zod.ts#ObjectTreeSchema': Ts_ObjectTreeSchema; 'objectql.zod.ts#ObjectViewSchema': Ts_ObjectViewSchema; 'objectql.zod.ts#SortConfigSchema': Ts_SortConfig; @@ -5372,6 +5374,8 @@ const SPEC_DERIVED_PAIRS: readonly string[] = [ // declares — the first spec references in this mirror. So a spec bump that moves // either vocabulary moves ONE side of this pair. 'objectql.zod.ts#ObjectTreeSchema', + // objectstack#34382: `timesheet` is the spec's `TimesheetConfigSchema` by reference. + 'objectql.zod.ts#ObjectTimesheetSchema', // objectui#7779: BACK, by a real code reference this time — `navigation`, // `searchableFields` and `filterableFields` are `SpecListViewSchema.shape.*` // by reference (identity-pinned in `object-view-unmirrored-keys-7779.test.ts`). @@ -5413,7 +5417,7 @@ const ZOD_DIR = join(dirname(fileURLToPath(import.meta.url)), '..', 'zod'); * MINUEND under it had moved. Nothing failed on any of those days, because nothing * compared the registry to a number. objectui#7433 is that absence, not the digits. */ -const EXPECTED_MIRROR_PAIRS = 201; +const EXPECTED_MIRROR_PAIRS = 202; /** * A ledger this file can size from its own AST. `WiderThanDeclared` joined at diff --git a/ui/packages/types/src/index.ts b/ui/packages/types/src/index.ts index 69fee66ce73..26548aa0c84 100644 --- a/ui/packages/types/src/index.ts +++ b/ui/packages/types/src/index.ts @@ -531,6 +531,7 @@ export type { ObjectMapSchema, ObjectMapConfig, ObjectTreeSchema, + ObjectTimesheetSchema, ObjectGanttSchema, ObjectCalendarSchema, ObjectKanbanSchema, diff --git a/ui/packages/types/src/objectql.ts b/ui/packages/types/src/objectql.ts index 262e9f53238..d38f7b1a96a 100644 --- a/ui/packages/types/src/objectql.ts +++ b/ui/packages/types/src/objectql.ts @@ -158,6 +158,8 @@ import type { // `ObjectTreeSchema.tree` below takes the protocol's own type. Aliased for // the reason `SpecGanttConfig` above is. TreeConfig as SpecTreeConfig, + // objectstack#34382 — the `object-timesheet` node's `timesheet` block. + TimesheetConfig as SpecTimesheetConfig, // objectui#9239 — `ComponentPropsMap['object-calendar']`'s author state, so // `ObjectCalendarSchema.data` below DERIVES the protocol's `data` row rather // than re-spelling it. Aliased because the bare name is the protocol's, and a @@ -3293,6 +3295,9 @@ export interface NamedListView { */ tree?: ListViewSchema['tree']; + /** Timesheet configuration. Consumed by `ObjectTimesheet` (`@object-ui/plugin-timesheet`, objectstack#34382). */ + timesheet?: ListViewSchema['timesheet']; + /** * The audience gate — `@objectstack/spec` 18's one list-view capability key * (objectstack#22611, ruling A): a list of capabilities, ALL required, with @@ -3821,6 +3826,23 @@ export interface ObjectTreeSchema extends BaseSchema { children?: never; } +/** + * Object Timesheet Component Schema (objectstack#34382) + * + * The editable row × weekday grid `ListView` composes for a `type: 'timesheet'` + * view: one record per filled cell, keyed by `timesheet.rowFields`, placed by + * `timesheet.dateField` and valued by `timesheet.valueField`. + */ +export interface ObjectTimesheetSchema extends BaseSchema { + type: 'object-timesheet'; + /** The object whose records the grid pivots. */ + objectName: string; + /** The binding — the spec's `TimesheetConfig`, by reference. */ + timesheet?: SpecTimesheetConfig; + /** Base query filter, joined with the displayed week on `dateField`. */ + filter?: QueryParams['$filter']; +} + /** * Object Gantt Component Schema * @@ -6182,6 +6204,7 @@ export type ObjectQLComponentSchema = | ObjectViewSchema | ObjectMapSchema | ObjectTreeSchema + | ObjectTimesheetSchema | ObjectGanttSchema | ObjectCalendarSchema | ObjectKanbanSchema diff --git a/ui/packages/types/src/zod/index.zod.ts b/ui/packages/types/src/zod/index.zod.ts index 30c81b1f31b..eaed1437bc3 100644 --- a/ui/packages/types/src/zod/index.zod.ts +++ b/ui/packages/types/src/zod/index.zod.ts @@ -330,6 +330,7 @@ export { ObjectMapSchema, ObjectMapConfigSchema, ObjectTreeSchema, + ObjectTimesheetSchema, ObjectGanttSchema, ObjectCalendarSchema, ObjectKanbanSchema, diff --git a/ui/packages/types/src/zod/objectql.zod.ts b/ui/packages/types/src/zod/objectql.zod.ts index 99504c68388..c023fe68f0a 100644 --- a/ui/packages/types/src/zod/objectql.zod.ts +++ b/ui/packages/types/src/zod/objectql.zod.ts @@ -25,6 +25,8 @@ import { // objectui#11168 slice 3 — the `object-tree` element's `tree` block, by // reference (`ObjectTreeSchema.tree` below). TreeConfigSchema as SpecTreeConfigSchema, + // objectstack#34382 — the `object-timesheet` node's `timesheet` block. + TimesheetConfigSchema as SpecTimesheetConfigSchema, HttpMethodSubsetSchema as SpecHttpMethodSubsetSchema, HttpRequestSchema as SpecHttpRequestSchema, ViewDataSchema as SpecViewDataSchema, @@ -2873,6 +2875,21 @@ export const ObjectTreeSchema = BaseSchema.extend({ children: retirementTombstone(OBJECT_TREE_NEITHER_CHANNEL), }).superRefine(...requireRecordSource('object-tree', RECORD_SOURCE_KEYS, 'node', 'not-read')); +/** + * ObjectTimesheet Schema (objectstack#34382) — the editable row × weekday grid + * `ListView` composes for a `type: 'timesheet'` view. `timesheet` takes the + * spec's `TimesheetConfig` by reference; the renderer reads no content channel. + */ +export const ObjectTimesheetSchema = BaseSchema.extend({ + type: z.literal('object-timesheet'), + objectName: z.string().describe('ObjectQL object name — the records the grid pivots, one per filled cell'), + timesheet: stripImportedDefaults(SpecTimesheetConfigSchema).optional().describe('The binding (rowFields, dateField, valueField) — the spec TimesheetConfig, by reference; incomplete, the grid shows its configuration-required screen'), + filter: z.union([ + z.array(z.any()), + z.record(z.string(), z.any()), + ]).optional().describe('Base query filter, joined with the displayed week on dateField — the two arms of QueryParams[$filter]'), +}); + /** objectui#9256 (E3 residual): ONE refusal string for both content channels of `ObjectGanttSchema`. */ const OBJECT_GANTT_NEITHER_CHANNEL = neitherContentChannelGuidance( 'object-gantt', @@ -4344,6 +4361,7 @@ export const ObjectDataTableSchema = BaseSchema.extend({ const ObjectQLComponentSchemaInferred = z.discriminatedUnion('type', [ ObjectViewSchema, ObjectTreeSchema, + ObjectTimesheetSchema, ObjectCalendarSchema, ObjectKanbanSchema, ObjectGallerySchema, From 70f915f4cee17b67071d617ad4e51b8653d7b871 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 14:52:13 +0000 Subject: [PATCH 05/18] feat(lint): timesheet field-ref rows, explanation text and spec pin count Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- packages/lint/src/rule-explanations.ts | 5 +++-- .../lint/src/validate-list-view-field-refs.test.ts | 4 ++++ packages/spec/src/type-alias-convention.pin.test.ts | 10 +++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/lint/src/rule-explanations.ts b/packages/lint/src/rule-explanations.ts index 4d260156cbd..e3bd0e86466 100644 --- a/packages/lint/src/rule-explanations.ts +++ b/packages/lint/src/rule-explanations.ts @@ -4026,7 +4026,7 @@ const LIST_VIEW_FIELD_UNKNOWN_EXPLANATION: RuleExplanation = { 'column\'s `summary` and `prefix`), `hiddenFields`, `fieldOrder`, ' + '`grouping` (and a grouping level\'s `orderBy`), `rowColor` and `userFilters`, the keys of its `filter` and of each ' + '`userFilters.tabs[].filter`, and every binding inside a `kanban`, `calendar`, `gantt`, ' + - '`timeline`, `gallery`, `map` or `tree` block. Nothing resolves the name at render time: the ' + + '`timeline`, `gallery`, `map`, `tree` or `timesheet` block. Nothing resolves the name at render time: the ' + 'view renders successfully with a blank, empty or wrong result, and nothing else reports the ' + 'miss. The verdict\'s "Did you mean" names the nearest field the object declares.', 'An error where the miss changes what the view returns or collapses what it lays out — for ' + @@ -4036,7 +4036,8 @@ const LIST_VIEW_FIELD_UNKNOWN_EXPLANATION: RuleExplanation = { 'collapses every card into one lane; a required date field of a `gantt`, `calendar` or ' + '`timeline` leaves nothing to place; a map with no coordinate field plots no marker; a ' + '`tree.parentField` flattens the tree; a `gantt.lockField` unfreezes every row and a ' + - '`gantt.objectField` stops every bar opening its record. A warning where one decoration ' + + '`gantt.objectField` stops every bar opening its record, and every `timesheet` binding is written ' + + 'into each record a typed cell creates. A warning where one decoration ' + 'drops and the rest renders — an optional colour, title, tooltip or cover binding, or a stale ' + '`hiddenFields` or `fieldOrder` entry, which hides or orders nothing.', LIST_VIEW_HEAD_ONLY, diff --git a/packages/lint/src/validate-list-view-field-refs.test.ts b/packages/lint/src/validate-list-view-field-refs.test.ts index 45799171f82..d592930810d 100644 --- a/packages/lint/src/validate-list-view-field-refs.test.ts +++ b/packages/lint/src/validate-list-view-field-refs.test.ts @@ -373,6 +373,10 @@ describe('#14107 — every other walked position', () => { [{ tree: { parentField: BAD } }, 'views[0].list.tree.parentField', 'error'], [{ tree: { labelField: BAD } }, 'views[0].list.tree.labelField', 'warning'], [{ tree: { fields: [BAD] } }, 'views[0].list.tree.fields[0]', 'warning'], + // [#34382] Every timesheet binding is written into the records its cells create. + [{ timesheet: { rowFields: [BAD] } }, 'views[0].list.timesheet.rowFields[0]', 'error'], + [{ timesheet: { dateField: BAD } }, 'views[0].list.timesheet.dateField', 'error'], + [{ timesheet: { valueField: BAD } }, 'views[0].list.timesheet.valueField', 'error'], ]; for (const [patch, path, severity] of cases) { diff --git a/packages/spec/src/type-alias-convention.pin.test.ts b/packages/spec/src/type-alias-convention.pin.test.ts index f8ddcf6cf0b..07971518166 100644 --- a/packages/spec/src/type-alias-convention.pin.test.ts +++ b/packages/spec/src/type-alias-convention.pin.test.ts @@ -304,7 +304,7 @@ import type * as M204 from './ai/dataset-tools.zod.js'; import type * as M205 from './ai/object-query-source.zod.js'; // --------------------------------------------------------------------------- -// 857 isomorphic aliases: `z.input` === `z.infer`, so no `XParsed` is declared. +// 858 isomorphic aliases: `z.input` === `z.infer`, so no `XParsed` is declared. // // That number is machine-checked, not hand-kept. The runtime companion at the // bottom of this file recomputes the pin count from the source and asserts that @@ -1833,7 +1833,7 @@ describe('ADR-0122 type-alias convention', () => { // this title and the section header above the pin list — are now asserted // against the recomputed count below, so neither can go stale without a red // test naming it. - it('still declares all 857 isomorphic pins', () => { + it('still declares all 858 isomorphic pins', () => { // The truth of each pin is proved by tsc, not here — an `Assert>` // that stops holding is a compile error with the alias named. What tsc // cannot notice is a pin that was DELETED: removing the assertion removes @@ -2910,7 +2910,11 @@ describe('ADR-0122 type-alias convention', () => { // (`data/hook.zod.ts`), closed at `message` / `params` with no default or // transform, pinned here (Iso_data_hook__HookTextSchema) beside its // refusal sibling rather than given a `…Parsed` synonym. +1 added. - expect(pins).toHaveLength(857); + // 857 -> 858 is #34382: a timesheet list view's binding, + // `TimesheetConfigSchema` (`ui/view.zod.ts`), a closed object of a string + // array and two strings with no default or transform + // (Iso_ui_view__TimesheetConfigSchema). +1 added. + expect(pins).toHaveLength(858); // The count is stated in PROSE twice as well — this case's title and the // section header above the pin list — and until commit c6b05c76a nothing read either From 0985a74049a1efc9cf5def0ea76ae78c4fa55ec5 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 15:45:15 +0000 Subject: [PATCH 06/18] chore(spec): regenerate reference docs on the merged tree Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- content/docs/references/api/protocol.mdx | 3 ++- content/docs/references/index.mdx | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 349271a063d..89a65f1ca4a 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1711,7 +1711,7 @@ One changed key path of the pending draft, and the last write that changed it. | :--- | :--- | :--- | :--- | | **object** | `string` | ✅ | Object name | | **permissions** | `{ allowCreate?: boolean; allowRead?: boolean; allowEdit?: boolean; allowDelete?: boolean; … }` | ✅ | Object-level permissions | -| **fieldPermissions** | `Record` | optional | Field-level permissions keyed by field name | +| **fieldPermissions** | `Record` | optional | Field-level permissions keyed by field name | ### Nested Shape: `GetObjectPermissionsResponse.permissions` @@ -1739,6 +1739,7 @@ One changed key path of the pending draft, and the last write that changed it. | **readable** | `boolean` | optional (default: `true`) | Field read access | | **editable** | `boolean` | optional (default: `false`) | Field edit access | | **when** | `string` | optional | Row condition narrowing where this entry votes, authored in canonical CEL like `rowLevelSecurity[].using` (a field of this object compared with a literal or a `current_user.*` value using `==`, `!=`, `<`, `<=`, `>`, `>=` or `in`, combined with `&&` / `\|\|`; e.g. status in ["approved", "signing", "active"]). Absent, the entry votes on every row. Present, the entry votes as declared on the rows the condition matches and is ABSENT on every other row, so the most-permissive merge across the caller's sets is unchanged: a set that locks a field only from a stage onward does not lock the rows before it, and a co-held set that says nothing about the field still lifts nothing, unless it holds the super-user bypass on the object (its own entry for the object, otherwise its `'*'` wildcard). Such a set votes on every field of the object, on every row, whatever `when` says: `viewAllRecords` votes `readable: true`, and `modifyAllRecords` votes `readable: true` and `editable: true`, so a row-conditioned lock never binds a Modify All holder. View All never grants an edit. Otherwise union without deny is unchanged. The write gate judges the condition on the stored row BEFORE an update (so a lock on `status in [...]` holds on an approved row even when the write changes `status`) and on the incoming row of an insert, as the caller sent it. It reaches the EDIT vote only — reads are judged row-blind — so `readable: false` beside a `when` is refused at parse time: keep `readable: true` (the default) on a row-conditioned entry. Where no row can be judged (a predicate update with no row address, a stored row the caller cannot read, a condition that does not resolve for the request) the entry is judged as its lock: it contributes no edit grant on that write. Validated like an RLS predicate at authoring and publish time: the fields it names must exist on the entry's object and it may not reach across a relation; a condition that cannot be lowered is refused there, never dropped at runtime. Readers that hold no row (`/auth/me/permissions`, the object-wide field projections, the write preview on an update) report a row-conditioned entry as its lock, so a client never advertises an edit the gate refuses. The record-scoped field projection (`GET /data/{object}/{id}/field-access`, the answer a record's edit form reads) holds the row: it judges the condition on the stored row exactly as the write gate does on an update of that row, so a lock that applies only from a stage onward disables the field only on the rows it names. | +| **rollupSourceUnreadableReason** | `string` | optional | Authoring-time acknowledgement, read only by `os lint` (the runtime does not read it): why holders of this set are meant to read this roll-up `summary` column although the set cannot read the child object, the aggregated child field or a child field the roll-up's `filter` tests (e.g. 'Service staff read account totals but not invoice rows'). Declared on the set's entry for the summary column, it turns that set's `security-rollup-source-unreadable` warning for the column into an `info` note quoting the reason, so `os lint --strict` passes; every other finding is unchanged. The runtime does not read the key, but the entry that carries it is an ordinary declaring entry: it votes `readable: true` in the field merge (only declaring sets vote, and the most permissive vote wins), so on a set that had no entry for the column, adding one to carry the reason restores the column for holders whose other sets mask it. A blank reason is refused, and so is a reason beside `readable: false`, an entry that declares no read to acknowledge. | --- diff --git a/content/docs/references/index.mdx b/content/docs/references/index.mdx index f704897084a..d0d461c2b0e 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 — 1670 schemas across 14 protocol modules +description: Every schema published by @objectstack/spec — 1671 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/. */} @@ -20,7 +20,7 @@ counts are sums of the rows they head. Regenerate with | Module | Pages | Schemas | Description | | :--- | ---: | ---: | :--- | -| [AI Protocol](/docs/references/ai) | 14 | 81 | Agents, tools, skills, RAG and knowledge sources, model registry, conversations. | +| [AI Protocol](/docs/references/ai) | 14 | 82 | Agents, tools, skills, RAG and knowledge sources, model registry, conversations. | | [API Protocol](/docs/references/api) | 36 | 496 | REST contracts, endpoints, routing, realtime, batch, discovery. | | [Automation Protocol](/docs/references/automation) | 16 | 82 | Flows and their nodes, approvals, ETL pipelines, webhooks, state machines, execution records. | | [Data Protocol](/docs/references/data) | 35 | 188 | Objects, fields, queries, filters, datasources and drivers — the ObjectQL layer. | @@ -34,13 +34,13 @@ counts are sums of the rows they head. Regenerate with | [Studio Protocol](/docs/references/studio) | 3 | 35 | Studio designer metadata — the authoring surfaces for the protocols above. | | [System Protocol](/docs/references/system) | 40 | 297 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. | | [UI Protocol](/docs/references/ui) | 16 | 178 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | -| **Total** | **218** | **1670** | 14 protocol modules | +| **Total** | **218** | **1671** | 14 protocol modules | --- ## AI Protocol -**Source:** `packages/spec/src/ai/` · **Import:** `@objectstack/spec/ai` · **14 pages, 81 schemas** +**Source:** `packages/spec/src/ai/` · **Import:** `@objectstack/spec/ai` · **14 pages, 82 schemas** Agents, tools, skills, RAG and knowledge sources, model registry, conversations. @@ -49,7 +49,7 @@ Agents, tools, skills, RAG and knowledge sources, model registry, conversations. | [`agent.zod.ts`](/docs/references/ai/agent) | `AIModelConfig`, `Agent`, `StructuredOutputConfig`, `StructuredOutputFormat`, `TransformPipelineStep` | | [`build-progress.zod.ts`](/docs/references/ai/build-progress) | `BuildProgressFrame`, `BuildProgressPhase` | | [`conversation.zod.ts`](/docs/references/ai/conversation) | `CodeContent`, `ConversationAnalytics`, `ConversationContext`, `ConversationMessage`, `ConversationSession`, `ConversationSummary`, `FileContent`, `FunctionCall`, `ImageContent`, `MessageContent`, `MessageContentType`, `MessagePruningEvent`, `MessageRole`, `TextContent`, `TokenBudgetConfig`, `TokenBudgetStrategy`, `TokenUsageStats`, `ToolCall` | -| [`dataset-tools.zod.ts`](/docs/references/ai/dataset-tools) | `DatasetProvenance`, `DatasetTermMatch`, `DatasetTermMatchedOn`, `DatasetToolCatalogDimension`, `DatasetToolCatalogEntry`, `DatasetToolCatalogMeasure`, `ListDatasetsInput`, `ListDatasetsOutput`, `QueryDatasetInput`, `QueryDatasetOutput` | +| [`dataset-tools.zod.ts`](/docs/references/ai/dataset-tools) | `DatasetProvenance`, `DatasetTermCandidate`, `DatasetTermMatch`, `DatasetTermMatchedOn`, `DatasetToolCatalogDimension`, `DatasetToolCatalogEntry`, `DatasetToolCatalogMeasure`, `ListDatasetsInput`, `ListDatasetsOutput`, `QueryDatasetInput`, `QueryDatasetOutput` | | [`embedding.zod.ts`](/docs/references/ai/embedding) | `EmbeddingModel`, `VectorStore`, `VectorStoreProvider` | | [`knowledge-document.zod.ts`](/docs/references/ai/knowledge-document) | `KnowledgeChunk`, `KnowledgeDocument`, `KnowledgeHit` | | [`knowledge-source.zod.ts`](/docs/references/ai/knowledge-source) | `FileKnowledgeSource`, `HttpKnowledgeSource`, `KnowledgeRefreshPolicy`, `KnowledgeSource`, `KnowledgeSourceKind`, `ObjectKnowledgeSource` | From 76988b5e00e8f0d00d594873f4e6274d8b30b16a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:10:01 +0000 Subject: [PATCH 07/18] fix(ui): timesheet in the view switcher's label and icon tables and the drawn-kinds pin Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- .../normalize-list-view.undrawableBothLegs-9880.test.ts | 7 ++++--- ui/packages/plugin-view/src/ObjectView.tsx | 1 + ui/packages/plugin-view/src/ViewSwitcher.tsx | 3 +++ .../plugin-view/src/__tests__/ViewSwitcher.test.tsx | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ui/packages/core/src/utils/__tests__/normalize-list-view.undrawableBothLegs-9880.test.ts b/ui/packages/core/src/utils/__tests__/normalize-list-view.undrawableBothLegs-9880.test.ts index 09f3f980120..9c685024d76 100644 --- a/ui/packages/core/src/utils/__tests__/normalize-list-view.undrawableBothLegs-9880.test.ts +++ b/ui/packages/core/src/utils/__tests__/normalize-list-view.undrawableBothLegs-9880.test.ts @@ -144,7 +144,7 @@ export const drawableUnderGrownOnceExplained: Record< * ------------------------------------------------------------------ */ /** - * The exported visualization union is the nine kinds `ListView` has a `case` + * The exported visualization union is the ten kinds `ListView` has a `case` * for — under the resolved spec AND under `main`'s. This is what makes the * change a re-spelling rather than a re-definition: the published type does not * move, only the way it is derived. @@ -155,10 +155,10 @@ export const drawableUnderGrownOnceExplained: Record< * union) fails the build there first. That record and `ListView`'s `case` list * are where the new kind is drawn; this list follows them. */ -export type _VisualizationUnionIsTheNineDrawnKinds = Expect< +export type _VisualizationUnionIsTheTenDrawnKinds = Expect< Equal< ListViewVisualization, - 'grid' | 'kanban' | 'gallery' | 'calendar' | 'timeline' | 'gantt' | 'map' | 'chart' | 'tree' + 'grid' | 'kanban' | 'gallery' | 'calendar' | 'timeline' | 'gantt' | 'map' | 'chart' | 'tree' | 'timesheet' > >; @@ -172,6 +172,7 @@ const DRAWN_KINDS = [ 'map', 'chart', 'tree', + 'timesheet', ] as const; describe('the undrawable table survives an upstream retirement (objectui#9880)', () => { diff --git a/ui/packages/plugin-view/src/ObjectView.tsx b/ui/packages/plugin-view/src/ObjectView.tsx index 146661e70ca..4d86d8966ee 100644 --- a/ui/packages/plugin-view/src/ObjectView.tsx +++ b/ui/packages/plugin-view/src/ObjectView.tsx @@ -2013,6 +2013,7 @@ export const ObjectView: React.FC = ({ chart: 'chart-column', tree: 'list-tree', page: 'layout-template', + timesheet: 'calendar-clock', } satisfies Record; /** `never` only while every {@link ViewType} has an icon name. */ diff --git a/ui/packages/plugin-view/src/ViewSwitcher.tsx b/ui/packages/plugin-view/src/ViewSwitcher.tsx index 90f60360046..b1d5e78f1a2 100644 --- a/ui/packages/plugin-view/src/ViewSwitcher.tsx +++ b/ui/packages/plugin-view/src/ViewSwitcher.tsx @@ -37,6 +37,7 @@ import { Map, ListTree, LayoutTemplate, + CalendarClock, Plus, Share2, Settings, @@ -105,6 +106,7 @@ const DEFAULT_VIEW_LABELS = { chart: 'Chart', tree: 'Tree', page: 'Page', + timesheet: 'Timesheet', } satisfies Record; /** Every {@link ViewType} has a label — see {@link _AssertNever}. */ @@ -136,6 +138,7 @@ const DEFAULT_VIEW_ICONS = { chart: ChartColumn, tree: ListTree, page: LayoutTemplate, + timesheet: CalendarClock, } satisfies Record; /** Every {@link ViewType} has an icon — see {@link _AssertNever}. */ diff --git a/ui/packages/plugin-view/src/__tests__/ViewSwitcher.test.tsx b/ui/packages/plugin-view/src/__tests__/ViewSwitcher.test.tsx index f8d50123261..3263dad3f1b 100644 --- a/ui/packages/plugin-view/src/__tests__/ViewSwitcher.test.tsx +++ b/ui/packages/plugin-view/src/__tests__/ViewSwitcher.test.tsx @@ -71,6 +71,7 @@ const ALL_VIEW_TYPES_TABLE = { chart: true, tree: true, page: true, + timesheet: true, } satisfies Record; type _UncoveredViewType = _AssertNever>; From 3635a48233bc582aceba5000181ab195daaa900e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:23:15 +0000 Subject: [PATCH 08/18] chore(changeset): name @object-ui/types in the timesheet changeset Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- .changeset/34382-timesheet-list-view.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/34382-timesheet-list-view.md b/.changeset/34382-timesheet-list-view.md index 85541804f0a..8310f0f67da 100644 --- a/.changeset/34382-timesheet-list-view.md +++ b/.changeset/34382-timesheet-list-view.md @@ -5,6 +5,7 @@ '@object-ui/plugin-list': minor '@object-ui/plugin-view': minor '@object-ui/core': minor +'@object-ui/types': minor '@object-ui/i18n': minor '@object-ui/app-shell': minor '@object-ui/cli': minor From 6d78684a0c937f7e862a7010440423fb57e806f4 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:36:36 +0000 Subject: [PATCH 09/18] fix(ui): bound a date-time timesheet week by local midnight, and show cell values without grouping Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- .../plugin-timesheet/src/ObjectTimesheet.tsx | 8 +- .../src/__tests__/ObjectTimesheet.test.tsx | 24 ++++ .../timesheet.dateTimeZone-34382.test.ts | 107 ++++++++++++++++++ .../src/__tests__/timesheetModel.test.ts | 21 ++++ .../plugin-timesheet/src/timesheetModel.ts | 23 ++++ .../date-only-zone-pins-10183.test.ts | 4 + 6 files changed, 184 insertions(+), 3 deletions(-) create mode 100644 ui/packages/plugin-timesheet/src/__tests__/timesheet.dateTimeZone-34382.test.ts diff --git a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx index 439c7fdfa0b..eb629121945 100644 --- a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx +++ b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx @@ -86,6 +86,7 @@ import { rowValuesComplete, startOfWeek, weekDays, + weekQueryBounds, fromDayKey, type TimesheetBinding, type TimesheetCell, @@ -248,11 +249,12 @@ function TimesheetGridView({ schema, objectName, binding, dataSource, className, const expand = !perms?.isLoaded ? expandable : expandable.filter((f) => perms.checkField(objectName, f, 'read')); + const [from, to] = weekQueryBounds(weekStart, weekEnd, objectSchema?.fields?.[binding.dateField]?.type); const result = await dataSource.find(objectName, { $filter: mergeFilterNodes( queryFilter, - [binding.dateField, '>=', weekStart], - [binding.dateField, '<', weekEnd], + [binding.dateField, '>=', from], + [binding.dateField, '<', to], ) as any, ...nonGridRowCeilingQuery(), ...(expand.length > 0 ? { $expand: expand } : {}), @@ -282,7 +284,7 @@ function TimesheetGridView({ schema, objectName, binding, dataSource, className, const fallback = objectSchema?.fields?.[name]?.label || name.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()); return fieldLabels.fieldLabel(objectName, name, fallback); }; - const numberFormat = useMemo(() => new Intl.NumberFormat(locale, { maximumFractionDigits: 2 }), [locale]); + const numberFormat = useMemo(() => new Intl.NumberFormat(locale, { maximumFractionDigits: 2, useGrouping: false }), [locale]); const dayHeading = useMemo( () => new Intl.DateTimeFormat(locale, { weekday: 'short', month: 'numeric', day: 'numeric' }), [locale], diff --git a/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx b/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx index cee9fea84ab..2a74bd4f7a3 100644 --- a/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx +++ b/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx @@ -68,6 +68,30 @@ describe('ObjectTimesheet', () => { expect(filter).toContain('Apollo'); }); + it('bounds a date-time date field by local-midnight instants, not day keys', async () => { + const ds = makeDataSource([]); + ds.getObjectSchema.mockResolvedValue({ + ...objectSchema, + fields: { ...objectSchema.fields, work_date: { name: 'work_date', type: 'datetime', label: 'Date' } }, + } as any); + renderTimesheet(ds); + await waitFor(() => expect(ds.find).toHaveBeenCalled()); + const filter = JSON.stringify((ds.find.mock.calls[0] as any[])[1].$filter); + expect(filter).toContain(`["work_date",">=","${new Date(2026, 10, 15).toISOString()}"]`); + expect(filter).toContain(`["work_date","<","${new Date(2026, 10, 22).toISOString()}"]`); + }); + + it('shows a value of a thousand or more without grouping, so it edits back', async () => { + const ds = makeDataSource([{ id: 'r1', project: 'Apollo', work_date: '2026-11-16', hours: 1234.5 }]); + renderTimesheet(ds); + await waitFor(() => expect(screen.getAllByTestId('timesheet-row')).toHaveLength(1)); + const monday = screen.getAllByTestId('timesheet-cell')[1] as HTMLInputElement; + expect(monday.value).toBe('1234.5'); + fireEvent.change(monday, { target: { value: '1234.6' } }); + fireEvent.blur(monday); + await waitFor(() => expect(ds.update).toHaveBeenCalledWith('time_entry', 'r1', { hours: 1234.6 })); + }); + it('pivots records into rows and days with row, day and week totals', async () => { const ds = makeDataSource([ { id: 'r1', project: 'Apollo', work_date: '2026-11-16', hours: 2 }, diff --git a/ui/packages/plugin-timesheet/src/__tests__/timesheet.dateTimeZone-34382.test.ts b/ui/packages/plugin-timesheet/src/__tests__/timesheet.dateTimeZone-34382.test.ts new file mode 100644 index 00000000000..65c0696a1b1 --- /dev/null +++ b/ui/packages/plugin-timesheet/src/__tests__/timesheet.dateTimeZone-34382.test.ts @@ -0,0 +1,107 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * objectstack#34382 — a timesheet bound to a `datetime` date field queries the + * week it places records in. + * + * Records are placed on the viewer's LOCAL day (`dayKeyOf`), and a typed cell + * writes the instant of local noon (`dateFieldValue`). A bare `YYYY-MM-DD` + * comparand is read by the data layer as UTC midnight, so a date-time week + * bounded by day keys disagrees with the placement everywhere off UTC: east of + * UTC the first morning of the week is never fetched, and at UTC+13 a cell typed + * on the first day is written before the window and vanishes on the re-read. + * `weekQueryBounds` bounds a date-time week by the instants of local midnight. + * + * ── ⚠️ The zone cases run ONLY when driven, in a FORKS child ──────────────── + * `process.env.TZ` written inside a test of the normal run does not move the + * zone (the root config runs `pool: 'threads'`), so these cases are skipped + * there and `scripts/__tests__/date-only-zone-pins-10183.test.ts` runs them on + * the forks pool and fails unless every one ran and passed. Each zone opens + * with a rig case, so a child whose zone did not move reds. + */ + +import { describe, expect, it } from 'vitest'; +import { dateFieldValue, dayKeyOf, weekQueryBounds } from '../timesheetModel'; + +const DRIVEN = process.env.OBJECTUI_DATE_ZONE_CHILD === '1'; + +/** UTC+13 in November — New Zealand daylight time, the card's worst case. */ +const FAR_EAST = 'Pacific/Auckland'; +/** UTC-8 in November — the other direction. */ +const WEST = 'America/Los_Angeles'; + +/** A fixed instant: 01:00 on the 17th in Auckland, 04:00 on the 16th in Los Angeles. */ +const INSTANT = '2026-11-16T12:00:00.000Z'; + +const WEEK_START = '2026-11-16'; +const WEEK_END = '2026-11-23'; + +function enter(zone: string): void { + process.env.TZ = zone; +} + +/** The written value is inside `[from, to)` and reads back on `day`. */ +function staysOnItsDay(day: string): void { + const [from, to] = weekQueryBounds(WEEK_START, WEEK_END, 'datetime'); + const written = dateFieldValue(day, 'datetime'); + expect(written >= from && written < to).toBe(true); + expect(dayKeyOf(written)).toBe(day); +} + +describe.runIf(DRIVEN)('timesheet date-time week at UTC+13 (objectstack#34382)', () => { + it('rig: the zone really moved', () => { + enter(FAR_EAST); + expect(Intl.DateTimeFormat().resolvedOptions().timeZone).toBe(FAR_EAST); + expect(new Date(INSTANT).getHours()).toBe(1); + }); + + it('bounds the week by the instants of local midnight, not by UTC days', () => { + enter(FAR_EAST); + expect(weekQueryBounds(WEEK_START, WEEK_END, 'datetime')).toEqual([ + '2026-11-15T11:00:00.000Z', + '2026-11-22T11:00:00.000Z', + ]); + }); + + it('keeps a cell typed on the first day inside the week it was typed in', () => { + enter(FAR_EAST); + // Local noon on the 16th is 23:00Z on the 15th: before a day-key bound. + expect(dateFieldValue(WEEK_START, 'datetime')).toBe('2026-11-15T23:00:00.000Z'); + staysOnItsDay(WEEK_START); + staysOnItsDay('2026-11-22'); + }); + + it('control: a date field keeps its day keys', () => { + enter(FAR_EAST); + expect(weekQueryBounds(WEEK_START, WEEK_END, 'date')).toEqual([WEEK_START, WEEK_END]); + expect(dateFieldValue(WEEK_START, 'date')).toBe(WEEK_START); + }); +}); + +describe.runIf(DRIVEN)('timesheet date-time week at UTC-8 (objectstack#34382)', () => { + it('rig: the zone really moved', () => { + enter(WEST); + expect(Intl.DateTimeFormat().resolvedOptions().timeZone).toBe(WEST); + expect(new Date(INSTANT).getHours()).toBe(4); + }); + + it('bounds the week by the instants of local midnight, not by UTC days', () => { + enter(WEST); + expect(weekQueryBounds(WEEK_START, WEEK_END, 'datetime')).toEqual([ + '2026-11-16T08:00:00.000Z', + '2026-11-23T08:00:00.000Z', + ]); + }); + + it('keeps a cell typed on the last day inside the week it was typed in', () => { + enter(WEST); + staysOnItsDay(WEEK_START); + staysOnItsDay('2026-11-22'); + }); +}); diff --git a/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts b/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts index 83352c7353e..39f5e03623a 100644 --- a/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts +++ b/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts @@ -9,6 +9,7 @@ import { rowValuesComplete, startOfWeek, weekDays, + weekQueryBounds, type TimesheetBinding, } from '../timesheetModel'; @@ -65,6 +66,19 @@ describe('week arithmetic', () => { }); }); +describe('week query bounds, in the suite zone', () => { + // The off-UTC cases are in `timesheet.dateTimeZone-34382.test.ts`, driven on + // the forks pool by `scripts/__tests__/date-only-zone-pins-10183.test.ts`. + it('bounds a date field by the day keys and a date-time field by instants', () => { + expect(weekQueryBounds('2026-11-16', '2026-11-23', 'date')).toEqual(['2026-11-16', '2026-11-23']); + expect(weekQueryBounds('2026-11-16', '2026-11-23')).toEqual(['2026-11-16', '2026-11-23']); + expect(weekQueryBounds('2026-11-16', '2026-11-23', 'datetime')).toEqual([ + new Date(2026, 10, 16).toISOString(), + new Date(2026, 10, 23).toISOString(), + ]); + }); +}); + describe('buildTimesheetRows', () => { const records = [ { id: 'r1', project: { id: 'p1', name: 'Apollo' }, task: 'Design', work_date: '2026-11-16', hours: 2 }, @@ -141,6 +155,13 @@ describe('parseCellInput and rowValuesComplete', () => { expect(parseCellInput('abc')).toBe('invalid'); }); + it('reads the ungrouped display back, and refuses a grouped number rather than misread it', () => { + expect(parseCellInput('1234.5')).toBe(1234.5); + expect(parseCellInput('1234,5')).toBe(1234.5); + expect(parseCellInput('1,234.5')).toBe('invalid'); + expect(parseCellInput('1,234,5')).toBe('invalid'); + }); + it('requires every row field', () => { expect(rowValuesComplete({ project: 'p1', task: 'x' }, binding.rowFields)).toBe(true); expect(rowValuesComplete({ project: 'p1', task: '' }, binding.rowFields)).toBe(false); diff --git a/ui/packages/plugin-timesheet/src/timesheetModel.ts b/ui/packages/plugin-timesheet/src/timesheetModel.ts index 1d2bd5a2f00..4929dbed309 100644 --- a/ui/packages/plugin-timesheet/src/timesheetModel.ts +++ b/ui/packages/plugin-timesheet/src/timesheetModel.ts @@ -207,10 +207,33 @@ export function buildTimesheetRows( export function parseCellInput(text: string): number | null | 'invalid' { const trimmed = text.trim(); if (trimmed === '') return null; + // One `,` is a decimal comma (de, fr, ru…); the grid displays without digit + // grouping, so a `,` never stands for a thousands separator here. + if ((trimmed.match(/,/g) ?? []).length > 1 || (trimmed.includes(',') && trimmed.includes('.'))) return 'invalid'; const n = Number(trimmed.replace(',', '.')); return Number.isFinite(n) ? n : 'invalid'; } +/** + * The comparands that bound one displayed week on `dateField`: `[start, end)`. + * + * A date field stores calendar days, so the week's day keys bound it exactly. A + * date-time field stores instants, and a bare `YYYY-MM-DD` comparand is read by + * the data layer as UTC midnight, while every record is placed on the viewer's + * LOCAL day (`dayKeyOf`). So a date-time week is bounded by the instants of + * local midnight at its first day and the day after its last: the query and the + * placement then agree in every time zone, and a record written at local noon + * (`dateFieldValue`) is always inside the week it was typed in. + */ +export function weekQueryBounds( + weekStart: string, + weekEnd: string, + dateFieldType?: string, +): [string, string] { + if (dateFieldType !== 'datetime') return [weekStart, weekEnd]; + return [fromDayKey(weekStart).toISOString(), fromDayKey(weekEnd).toISOString()]; +} + /** * The value a new record's `dateField` takes for `day`: the day key for a date * field, and the instant at local noon for a date-time field, so the record diff --git a/ui/scripts/__tests__/date-only-zone-pins-10183.test.ts b/ui/scripts/__tests__/date-only-zone-pins-10183.test.ts index a06b6bd1c98..f4b99df3caf 100644 --- a/ui/scripts/__tests__/date-only-zone-pins-10183.test.ts +++ b/ui/scripts/__tests__/date-only-zone-pins-10183.test.ts @@ -130,6 +130,10 @@ const PINS = [ // objectui#12759: the same editor moves a `datetime` to another day and // keeps its wall-clock time, at UTC+8 and at UTC-5. 'packages/plugin-detail/src/__tests__/InlineFieldInput.datetimePicker-12759.test.tsx', + // objectstack#34382: a timesheet bound to a `datetime` field bounds its week + // query by local midnight, so a cell typed on the first day reads back in it, + // at UTC+13 and at UTC-8. + 'packages/plugin-timesheet/src/__tests__/timesheet.dateTimeZone-34382.test.ts', ] as const; /** The vitest CLI entry, resolved rather than assumed at a `node_modules` path. */ From 6b331e13fcd33533f9b6f92d75ef4326e6d563a4 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:41:40 +0000 Subject: [PATCH 10/18] chore(sdui): regenerate the manifest for the timesheet list-view inputs Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- scripts/sdui-manifest.record.json | 6 +++--- sdui.manifest.json | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/sdui-manifest.record.json b/scripts/sdui-manifest.record.json index d3c660d2fdb..5f80224a7a8 100644 --- a/scripts/sdui-manifest.record.json +++ b/scripts/sdui-manifest.record.json @@ -13,11 +13,11 @@ ], "source": "built-tree", "generator": "scripts/gen-sdui-manifest-node.mjs", - "generatedAt": "2026-11-04", - "sha256": "dbe784f92f9b28de779d520da827f8b43ba780ce28684a9dcfb9b8662fe44541", + "generatedAt": "2026-11-17", + "sha256": "240fb9507b04431628938e1ace914645d6502d5489af6311c638539ea3c335ea", "components": 106, "inTree": { "modulesRoot": "ui/apps/console", - "objectuiWorkspaceVersion": "18.3.0" + "objectuiWorkspaceVersion": "18.5.0" } } diff --git a/sdui.manifest.json b/sdui.manifest.json index 283123c753f..080c33f28a3 100644 --- a/sdui.manifest.json +++ b/sdui.manifest.json @@ -224,6 +224,10 @@ { "label": "Tree", "value": "tree" + }, + { + "label": "Timesheet", + "value": "timesheet" } ], "description": "The list kind, the spec's list view `type`. Absent, a bound saved view's kind applies, else a grid. On a metadata page it is written `properties.type`; the node's own `type` stays `list-view`." @@ -439,6 +443,11 @@ "type": "object", "description": "The chart a `type: \"chart\"` list draws, bound to an ADR-0021 dataset: `{ dataset, values, dimensions, chartType }`. There is no default binding." }, + { + "name": "timesheet", + "type": "object", + "description": "The editable row × weekday grid a `type: \"timesheet\"` list draws: `{ rowFields, dateField, valueField }`. All three are required; each typed cell creates, updates or deletes one record." + }, { "name": "dataSource", "type": "object", From 19b3f8df5df298d483c45d72e6ac77bade715474 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:44:34 +0000 Subject: [PATCH 11/18] test(ui): type the zone pin's process read without Node types Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- .../src/__tests__/timesheet.dateTimeZone-34382.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/packages/plugin-timesheet/src/__tests__/timesheet.dateTimeZone-34382.test.ts b/ui/packages/plugin-timesheet/src/__tests__/timesheet.dateTimeZone-34382.test.ts index 65c0696a1b1..01f89695c0a 100644 --- a/ui/packages/plugin-timesheet/src/__tests__/timesheet.dateTimeZone-34382.test.ts +++ b/ui/packages/plugin-timesheet/src/__tests__/timesheet.dateTimeZone-34382.test.ts @@ -29,6 +29,9 @@ import { describe, expect, it } from 'vitest'; import { dateFieldValue, dayKeyOf, weekQueryBounds } from '../timesheetModel'; +// This package's test config carries no Node types; the pin reads and writes the zone. +declare const process: { env: Record }; + const DRIVEN = process.env.OBJECTUI_DATE_ZONE_CHILD === '1'; /** UTC+13 in November — New Zealand daylight time, the card's worst case. */ From dba3abe870738857afa9b0d9d19b072ed45a947a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:48:54 +0000 Subject: [PATCH 12/18] docs(ui): timesheet in the README view-type record and a typed direct-render snippet Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- ui/packages/plugin-list/README.md | 1 + ui/packages/plugin-timesheet/README.md | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/packages/plugin-list/README.md b/ui/packages/plugin-list/README.md index 181cc465e41..28a84eafafd 100644 --- a/ui/packages/plugin-list/README.md +++ b/ui/packages/plugin-list/README.md @@ -392,6 +392,7 @@ const viewTypes: Record, string> = { map: 'Records at their geographic coordinates', chart: 'Aggregated bar / line / pie / area chart', tree: 'Hierarchical parent-child rows', + timesheet: 'Editable row × weekday entry grid', }; export { view, richColumns, viewTypes }; diff --git a/ui/packages/plugin-timesheet/README.md b/ui/packages/plugin-timesheet/README.md index 97f3ed7909c..c33dd05e626 100644 --- a/ui/packages/plugin-timesheet/README.md +++ b/ui/packages/plugin-timesheet/README.md @@ -32,9 +32,16 @@ The component can also be rendered directly: ```tsx import { ObjectTimesheet } from '@object-ui/plugin-timesheet'; +import type { DataSource } from '@object-ui/types'; + +declare const dataSource: DataSource; ; ``` From 4be2b2dcb7276536d5c526d8b38e0599b005b8e7 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:55:37 +0000 Subject: [PATCH 13/18] docs(ui): regenerate the component reference for the timesheet list input The SDUI manifest gained the `timesheet` input and enum member on `list-view`; content/docs/ui/components/ is generated from it by scripts/gen-sdui-reference.mjs, and check:sdui-reference reds until the two match. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- content/docs/ui/components/index.mdx | 2 +- content/docs/ui/components/plugins.mdx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/content/docs/ui/components/index.mdx b/content/docs/ui/components/index.mdx index e74b3c4c9b5..352d67f149f 100644 --- a/content/docs/ui/components/index.mdx +++ b/content/docs/ui/components/index.mdx @@ -87,7 +87,7 @@ regenerates from the renderer registry. Regenerate it with | [`ins`](/docs/ui/components/html#ins) | `ui` | 2 | [HTML Elements](/docs/ui/components/html) | | [`label`](/docs/ui/components/html#label) | `ui` | 2 | [HTML Elements](/docs/ui/components/html) | | [`li`](/docs/ui/components/html#li) | `ui` | 2 | [HTML Elements](/docs/ui/components/html) | -| [`list-view`](/docs/ui/components/plugins#list-view) | `plugin-list` | 41 | [Plugin Blocks](/docs/ui/components/plugins) | +| [`list-view`](/docs/ui/components/plugins#list-view) | `plugin-list` | 42 | [Plugin Blocks](/docs/ui/components/plugins) | | [`main`](/docs/ui/components/html#main) | `ui` | 2 | [HTML Elements](/docs/ui/components/html) | | [`mark`](/docs/ui/components/html#mark) | `ui` | 2 | [HTML Elements](/docs/ui/components/html) | | [`markdown`](/docs/ui/components/plugins#markdown) | `plugin-markdown` | 2 | [Plugin Blocks](/docs/ui/components/plugins) | diff --git a/content/docs/ui/components/plugins.mdx b/content/docs/ui/components/plugins.mdx index ecb6ce41073..b54fa1ac90d 100644 --- a/content/docs/ui/components/plugins.mdx +++ b/content/docs/ui/components/plugins.mdx @@ -280,7 +280,7 @@ Namespace `plugin-list`. | Input | Type | Required | Description | | :--- | :--- | :--- | :--- | | `data` | `object` | | Where this list's records come from, the spec's `ViewData`: `{ provider: 'object', object }` lists that object's records, and `{ provider: 'value', items }` hands the list its rows. Not required: the node's `dataSource` binding can name the object instead, and `dataSource.object` outranks this key. With neither, the list shows a hint naming `data.object` instead of an empty list. | -| `type` | `enum`: `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]` | | The list kind, the spec's list view `type`. Absent, a bound saved view's kind applies, else a grid. On a metadata page it is written `properties.type`; the node's own `type` stays `list-view`. | +| `type` | `enum`: `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]`, `[object Object]` | | The list kind, the spec's list view `type`. Absent, a bound saved view's kind applies, else a grid. On a metadata page it is written `properties.type`; the node's own `type` stays `list-view`. | | `columns` | `array` | | The fields the list shows, in order: field names (`["name", "stage"]`) or the spec's `ListColumn` objects. They are also the query's `$select`. Optional on a page node: a node bound to a saved view through `dataSource.view` draws that view's columns. | | `filter` | `array` | | The base query filter, the spec's `ViewFilterRule` array `[{ field, operator, value }]`, lowered to `$filter`. | | `sort` | `array` | | The initial sort order, `[{ field, order }]`, lowered to `$orderby` in the order written. | @@ -319,6 +319,7 @@ Namespace `plugin-list`. | `map` | `object` | | The map, `{ locationField }` or `{ latitudeField, longitudeField }`, with `titleField`, `zoom` and `center`. | | `tree` | `object` | | The tree, `{ parentField, labelField, fields, defaultExpandedDepth }`. | | `chart` | `object` | | The chart a `type: "chart"` list draws, bound to an ADR-0021 dataset: `{ dataset, values, dimensions, chartType }`. There is no default binding. | +| `timesheet` | `object` | | The editable row × weekday grid a `type: "timesheet"` list draws: `{ rowFields, dateField, valueField }`. All three are required; each typed cell creates, updates or deletes one record. | | `dataSource` | `object` (`object` data binding) | | Per-element data binding: \{ object, view, filter, sort, limit \}. Overrides the page-level object context for this block; `view` names a saved view of `object`, and `filter` is ANDed with the view’s own rather than replacing it. | ## `object-map` [#object-map] From 534d20c7df045ac19525c0c06ef3e5b7c5fd11ee Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 17:24:09 +0000 Subject: [PATCH 14/18] fix(ui): timesheet cell writes read the affordance-to-grant map; relay and label the new view type Test UI on the full suite named four gaps the narrower runs missed: - the write census (objectui#12082) found the grid's three cell writes behind no map row. Each now reads one: an empty cell typed into and Add row read `gridAddRow`, a retyped one-record cell reads `listInlineEdit` plus the value field's write question, and a cleared cell reads `rowDelete`. A cell no granted write can change renders read-only, and a write the caller may not make stays on its cell with a message (new lazy key `timesheet.notAllowed`, eleven catalogues, zh-Hant regenerated) instead of going out. - InterfaceListPage relays the view's `timesheet` block, as it relays `tree` and `chart` (relay census objectui#11572). - the metadata-admin view-type label table gains `timesheet`, so the allowedVisualizations chips read the view-type words in zh-CN. - the defaults-table rule resolves keys against the en pack together with the pack-shaped lazy namespaces' en catalogues, which the provider path serves once a surface's namespace is loaded. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- .changeset/34382-timesheet-list-view.md | 1 + .../defaults-maps-mirror-en-pack.test.tsx | 35 ++++- ...nterfaceListPage.relayCensus-11572.test.ts | 4 +- .../app-shell/src/views/InterfaceListPage.tsx | 6 + ...SelectWidget.viewTypeLabels-30358.test.tsx | 2 + .../views/metadata-admin/viewTypeLabels.ts | 1 + .../core/src/utils/affordanceGrants.ts | 10 +- .../i18n/src/namespaces/timesheet/ar.ts | 1 + .../i18n/src/namespaces/timesheet/de.ts | 1 + .../i18n/src/namespaces/timesheet/en.ts | 1 + .../i18n/src/namespaces/timesheet/es.ts | 1 + .../i18n/src/namespaces/timesheet/fr.ts | 1 + .../i18n/src/namespaces/timesheet/ja.ts | 1 + .../i18n/src/namespaces/timesheet/ko.ts | 1 + .../i18n/src/namespaces/timesheet/pt-BR.ts | 1 + .../i18n/src/namespaces/timesheet/ru.ts | 1 + .../i18n/src/namespaces/timesheet/zh-Hans.ts | 1 + .../i18n/src/namespaces/timesheet/zh-Hant.ts | 1 + .../src/affordanceGrantMap-12082.test.tsx | 8 + ui/packages/plugin-timesheet/README.md | 7 + .../plugin-timesheet/src/ObjectTimesheet.tsx | 63 ++++++-- .../src/__tests__/ObjectTimesheet.test.tsx | 144 ++++++++++++++++++ .../plugin-timesheet/src/timesheetModel.ts | 31 ++++ 23 files changed, 298 insertions(+), 25 deletions(-) diff --git a/.changeset/34382-timesheet-list-view.md b/.changeset/34382-timesheet-list-view.md index 8310f0f67da..c8967374b55 100644 --- a/.changeset/34382-timesheet-list-view.md +++ b/.changeset/34382-timesheet-list-view.md @@ -30,6 +30,7 @@ timesheet: { - Typing into an empty cell creates a record carrying the row's field values, the day and the number. Changing a cell updates that record, and clearing it deletes the record. Each cell is one call on the record API, so hooks, validation rules and permissions judge it; a refusal stays on that cell with the server's message. - A cell holding several records shows their sum and is read-only. +- The grid offers each write only to a caller who may make it (the affordance-to-grant map's `gridAddRow`, `listInlineEdit` with the value field's write permission, and `rowDelete`). A cell no granted write can change is read-only, and **Add row** needs the create grant. An interface page's list block relays the view's `timesheet` block. - The week starts on the viewer's locale first day, with previous / this / next navigation. Row, day and week totals are always shown. - **Add row** asks for the row field values first; typing a day then creates the record. The view's `filter` applies to the week's query. - A `timesheet` view with an incomplete block shows "Timesheet configuration required", and `os validate` warns with `view/layout-without-binding`. `view/list-view-field-refs` checks the three field names. diff --git a/ui/packages/app-shell/src/__tests__/defaults-maps-mirror-en-pack.test.tsx b/ui/packages/app-shell/src/__tests__/defaults-maps-mirror-en-pack.test.tsx index c64d432df75..079b2f0b468 100644 --- a/ui/packages/app-shell/src/__tests__/defaults-maps-mirror-en-pack.test.tsx +++ b/ui/packages/app-shell/src/__tests__/defaults-maps-mirror-en-pack.test.tsx @@ -120,15 +120,40 @@ import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { scanDefaultsTables } from '@object-ui/test-support/defaults-table-scan'; import { en } from '@object-ui/i18n'; +import { loadDeveloperCatalogue } from '@object-ui/i18n/namespaces/developer'; +import { loadMarketplaceCatalogue } from '@object-ui/i18n/namespaces/marketplace'; +import { loadTimesheetCatalogue } from '@object-ui/i18n/namespaces/timesheet'; import { DETAIL_DEFAULT_TRANSLATIONS } from '@object-ui/plugin-detail'; import { LIST_DEFAULT_TRANSLATIONS } from '@object-ui/plugin-list'; import { DESIGNER_DEFAULT_TRANSLATIONS } from '@object-ui/plugin-designer'; -/** Resolve a dotted i18n key against a pack. Returns `undefined` at any miss. */ -const packValueAt = (key: string): unknown => - key - .split('.') - .reduce((node, part) => (node as Record | undefined)?.[part], en); +/** + * The pack-shaped lazy namespaces' `en` catalogues (`@object-ui/i18n`'s + * `namespaces/packNamespace.ts`). Each holds groups of the en pack moved out + * of the eager catalogue: a surface that reads one renders only once its + * namespace is loaded and merged into the page's i18next instance, and the + * provider path then serves those keys exactly as it serves pack keys. So the + * pack a row is resolved against is `en` together with these (#34382: the + * timesheet's defaults table is the first to name a lazy group's keys). + */ +const LAZY_EN_CATALOGUES: readonly unknown[] = [ + await loadDeveloperCatalogue('en'), + await loadMarketplaceCatalogue('en'), + await loadTimesheetCatalogue('en'), +]; + +/** Resolve a dotted i18n key against one pack. Returns `undefined` at any miss. */ +const valueIn = (pack: unknown, key: string): unknown => + key.split('.').reduce((node, part) => (node as Record | undefined)?.[part], pack); + +/** Resolve a dotted i18n key against the en pack and its lazy namespaces. Returns `undefined` at any miss. */ +const packValueAt = (key: string): unknown => { + for (const pack of [en, ...LAZY_EN_CATALOGUES]) { + const value = valueIn(pack, key); + if (value !== undefined) return value; + } + return undefined; +}; /** Codepoints, so a failure distinguishes `…` from `...` and NBSP from a space. */ const codepoints = (s: string) => [...s].map((c) => c.codePointAt(0)).join(','); diff --git a/ui/packages/app-shell/src/views/InterfaceListPage.relayCensus-11572.test.ts b/ui/packages/app-shell/src/views/InterfaceListPage.relayCensus-11572.test.ts index a8db731bb9f..1a6acdf6715 100644 --- a/ui/packages/app-shell/src/views/InterfaceListPage.relayCensus-11572.test.ts +++ b/ui/packages/app-shell/src/views/InterfaceListPage.relayCensus-11572.test.ts @@ -640,8 +640,8 @@ describe('objectui#11572 — every member `ListView` reads is relayed or answere ).toEqual([]); }); - it("objectui#11572 — the view's declared `tree` and `chart` blocks are relayed", () => { - for (const member of ['tree', 'chart']) { + it("objectui#11572 — the view's declared `tree` and `chart` blocks are relayed (and #34382's `timesheet`)", () => { + for (const member of ['tree', 'chart', 'timesheet']) { expect( readsView(member), `The \`${member}\` relay is gone. A whitelisted ${member} reaches \`ListView\` with no block, so its\n` diff --git a/ui/packages/app-shell/src/views/InterfaceListPage.tsx b/ui/packages/app-shell/src/views/InterfaceListPage.tsx index 2259e27cadf..617ccbb5c62 100644 --- a/ui/packages/app-shell/src/views/InterfaceListPage.tsx +++ b/ui/packages/app-shell/src/views/InterfaceListPage.tsx @@ -558,6 +558,12 @@ export function InterfaceListPage({ page, className, onConfigChange, reserveEdit // is relayed: the spec retired it (#25923) and `ListView` reads none. ...(view.tree !== undefined ? { tree: view.tree } : {}), ...(view.chart !== undefined ? { chart: view.chart } : {}), + // #34382 — a `type: 'timesheet'` view's `timesheet` block + // (`{ rowFields, dateField, valueField }`), carried whole like the two + // above for the same reason: `ListView`'s timesheet branch draws nothing + // but its configuration notice without it, and no page-derived default + // can guess which fields make the rows, the day and the value. + ...(view.timesheet !== undefined ? { timesheet: view.timesheet } : {}), // Presentation policy — the page layer (ADR-0047). userFilters: cfg.userFilters ?? view.userFilters, diff --git a/ui/packages/app-shell/src/views/metadata-admin/MultiSelectWidget.viewTypeLabels-30358.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/MultiSelectWidget.viewTypeLabels-30358.test.tsx index 7ca24006626..7d71a682b7e 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/MultiSelectWidget.viewTypeLabels-30358.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/MultiSelectWidget.viewTypeLabels-30358.test.tsx @@ -79,6 +79,8 @@ describe('allowedVisualizations chips read the view-type words (objectstack#3035 'Map', 'Chart', 'Tree', + // #34382 added the tenth view type. + 'Timesheet', ]); }); diff --git a/ui/packages/app-shell/src/views/metadata-admin/viewTypeLabels.ts b/ui/packages/app-shell/src/views/metadata-admin/viewTypeLabels.ts index 8a08f7318dc..081d2c691c5 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/viewTypeLabels.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/viewTypeLabels.ts @@ -23,6 +23,7 @@ const VIEW_TYPE_FALLBACK_LABELS: Record = { map: 'Map', chart: 'Chart', tree: 'Tree', + timesheet: 'Timesheet', }; /** Whether `value` is a view type this module has a name for. */ diff --git a/ui/packages/core/src/utils/affordanceGrants.ts b/ui/packages/core/src/utils/affordanceGrants.ts index 2669402633c..4e510677eb3 100644 --- a/ui/packages/core/src/utils/affordanceGrants.ts +++ b/ui/packages/core/src/utils/affordanceGrants.ts @@ -154,7 +154,11 @@ export const AFFORDANCE_GRANTS = { listImport: { crud: 'import', grant: 'create', field: 'create' }, /** The import wizard's template download — its endpoint answers 403 without the create grant. */ importTemplate: { crud: null, grant: 'create' }, - /** A list's inline (in-cell) editing, each of whose cells asks the update question (objectui#12103). */ + /** + * A list's inline (in-cell) editing, each of whose cells asks the update + * question (objectui#12103) — and a timesheet's retyped one-record cell, + * which updates that record's value field (#34382). + */ listInlineEdit: { crud: 'edit', grant: 'update', field: 'write' }, /** A list's bulk Delete. */ listBulkDelete: { crud: 'delete', grant: 'delete' }, @@ -165,9 +169,9 @@ export const AFFORDANCE_GRANTS = { * and progress, its title edited in place, and its dependency links). */ rowEdit: { crud: 'edit', grant: 'update' }, - /** A grid row's Delete — and a gantt row's Delete. */ + /** A grid row's Delete — and a gantt row's Delete, and a timesheet's cleared one-record cell (#34382). */ rowDelete: { crud: 'delete', grant: 'delete' }, - /** A grid's inline add-record row. */ + /** A grid's inline add-record row — and a timesheet's empty cell typed into, and its Add row (#34382). */ gridAddRow: { crud: 'create', grant: 'create' }, /** * A related list's "+ New", asked of the CHILD object — and a line-items diff --git a/ui/packages/i18n/src/namespaces/timesheet/ar.ts b/ui/packages/i18n/src/namespaces/timesheet/ar.ts index f1c5579b583..7bebd1bc518 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/ar.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/ar.ts @@ -24,6 +24,7 @@ const ar = { multipleRecords: 'يحتوي هذا اليوم على أكثر من سجل واحد. عدّلها في القائمة.', invalidNumber: 'أدخل رقمًا', saveFailed: 'لم يتم الحفظ: {{message}}', + notAllowed: 'ليس لديك إذن لإجراء هذا التغيير.', loadFailed: 'تعذر تحميل هذا الأسبوع.', rowIncomplete: 'املأ جميع حقول الصف أولاً.', cellLabel: '{{row}}، {{day}}', diff --git a/ui/packages/i18n/src/namespaces/timesheet/de.ts b/ui/packages/i18n/src/namespaces/timesheet/de.ts index 9482096bf0c..e78db858e0f 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/de.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/de.ts @@ -24,6 +24,7 @@ const de = { multipleRecords: 'Dieser Tag enthält mehr als einen Datensatz. Bearbeiten Sie sie in der Liste.', invalidNumber: 'Geben Sie eine Zahl ein', saveFailed: 'Nicht gespeichert: {{message}}', + notAllowed: 'Sie haben keine Berechtigung für diese Änderung.', loadFailed: 'Diese Woche konnte nicht geladen werden.', rowIncomplete: 'Füllen Sie zuerst alle Zeilenfelder aus.', cellLabel: '{{row}}, {{day}}', diff --git a/ui/packages/i18n/src/namespaces/timesheet/en.ts b/ui/packages/i18n/src/namespaces/timesheet/en.ts index b6c9d37682f..b8ce5fe573b 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/en.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/en.ts @@ -24,6 +24,7 @@ const en = { multipleRecords: 'This day holds more than one record. Edit them in the list.', invalidNumber: 'Enter a number', saveFailed: 'Not saved: {{message}}', + notAllowed: "You don't have permission to make this change.", loadFailed: 'This week could not be loaded.', rowIncomplete: 'Fill in every row field first.', cellLabel: '{{row}}, {{day}}', diff --git a/ui/packages/i18n/src/namespaces/timesheet/es.ts b/ui/packages/i18n/src/namespaces/timesheet/es.ts index 111eb7b211a..9a9d1ddd86a 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/es.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/es.ts @@ -24,6 +24,7 @@ const es = { multipleRecords: 'Este día tiene más de un registro. Edítalos en la lista.', invalidNumber: 'Introduce un número', saveFailed: 'No guardado: {{message}}', + notAllowed: 'No tiene permiso para realizar este cambio.', loadFailed: 'No se pudo cargar esta semana.', rowIncomplete: 'Rellena primero todos los campos de la fila.', cellLabel: '{{row}}, {{day}}', diff --git a/ui/packages/i18n/src/namespaces/timesheet/fr.ts b/ui/packages/i18n/src/namespaces/timesheet/fr.ts index 21544464c29..3650814ac84 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/fr.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/fr.ts @@ -24,6 +24,7 @@ const fr = { multipleRecords: 'Ce jour contient plus d’un enregistrement. Modifiez-les dans la liste.', invalidNumber: 'Saisissez un nombre', saveFailed: 'Non enregistré : {{message}}', + notAllowed: "Vous n'avez pas l'autorisation d'effectuer cette modification.", loadFailed: 'Impossible de charger cette semaine.', rowIncomplete: 'Renseignez d\'abord tous les champs de la ligne.', cellLabel: '{{row}}, {{day}}', diff --git a/ui/packages/i18n/src/namespaces/timesheet/ja.ts b/ui/packages/i18n/src/namespaces/timesheet/ja.ts index 98fa73a9ada..956772e1360 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/ja.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/ja.ts @@ -24,6 +24,7 @@ const ja = { multipleRecords: 'この日には複数のレコードがあります。一覧で編集してください。', invalidNumber: '数値を入力してください', saveFailed: '保存されていません: {{message}}', + notAllowed: 'この変更を行う権限がありません。', loadFailed: '今週のデータを読み込めませんでした。', rowIncomplete: '先にすべての行フィールドを入力してください。', cellLabel: '{{row}}、{{day}}', diff --git a/ui/packages/i18n/src/namespaces/timesheet/ko.ts b/ui/packages/i18n/src/namespaces/timesheet/ko.ts index f8eb52f7a66..0b7043a5e5c 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/ko.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/ko.ts @@ -24,6 +24,7 @@ const ko = { multipleRecords: '이 날에는 레코드가 여러 개 있습니다. 목록에서 편집하세요.', invalidNumber: '숫자를 입력하세요', saveFailed: '저장되지 않음: {{message}}', + notAllowed: '이 변경을 할 권한이 없습니다.', loadFailed: '이번 주를 불러올 수 없습니다.', rowIncomplete: '먼저 모든 행 필드를 입력하세요.', cellLabel: '{{row}}, {{day}}', diff --git a/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts b/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts index cb98b8394f5..c4846176127 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/pt-BR.ts @@ -24,6 +24,7 @@ const pt = { multipleRecords: 'Este dia tem mais de um registro. Edite-os na lista.', invalidNumber: 'Digite um número', saveFailed: 'Não salvo: {{message}}', + notAllowed: 'Você não tem permissão para fazer esta alteração.', loadFailed: 'Não foi possível carregar esta semana.', rowIncomplete: 'Preencha primeiro todos os campos da linha.', cellLabel: '{{row}}, {{day}}', diff --git a/ui/packages/i18n/src/namespaces/timesheet/ru.ts b/ui/packages/i18n/src/namespaces/timesheet/ru.ts index a63f4d1a063..913c7430620 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/ru.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/ru.ts @@ -24,6 +24,7 @@ const ru = { multipleRecords: 'В этот день несколько записей. Измените их в списке.', invalidNumber: 'Введите число', saveFailed: 'Не сохранено: {{message}}', + notAllowed: 'У вас нет прав на это изменение.', loadFailed: 'Не удалось загрузить эту неделю.', rowIncomplete: 'Сначала заполните все поля строки.', cellLabel: '{{row}}, {{day}}', diff --git a/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts b/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts index 77b0b5d6ddb..53b9bdb5512 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/zh-Hans.ts @@ -24,6 +24,7 @@ const zh = { multipleRecords: '这一天有多条记录,请在列表中编辑。', invalidNumber: '请输入数字', saveFailed: '未保存:{{message}}', + notAllowed: '您没有进行此更改的权限。', loadFailed: '无法加载本周数据。', rowIncomplete: '请先填写每个行字段。', cellLabel: '{{row}},{{day}}', diff --git a/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts b/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts index 1f44931403f..0d8b90b47ca 100644 --- a/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts +++ b/ui/packages/i18n/src/namespaces/timesheet/zh-Hant.ts @@ -21,6 +21,7 @@ const zhHant = { multipleRecords: '這一天有多條記錄,請在列表中編輯。', invalidNumber: '請輸入數字', saveFailed: '未儲存:{{message}}', + notAllowed: '您沒有進行此更改的權限。', loadFailed: '無法載入本週資料。', rowIncomplete: '請先填寫每個行欄位。', cellLabel: '{{row}},{{day}}', diff --git a/ui/packages/plugin-form/src/affordanceGrantMap-12082.test.tsx b/ui/packages/plugin-form/src/affordanceGrantMap-12082.test.tsx index a5e77ffe10a..dcbbf02b699 100644 --- a/ui/packages/plugin-form/src/affordanceGrantMap-12082.test.tsx +++ b/ui/packages/plugin-form/src/affordanceGrantMap-12082.test.tsx @@ -887,6 +887,14 @@ const WRITE_SITES: Record = { mapped(['recordEdit'], RECORD_PANEL), 'packages/plugin-kanban/src/ObjectKanban.tsx :: ObjectKanban > renderRecordOverlay > onDelete :: delete': mapped(['recordDelete'], DETAIL_VIEW), + // ── plugin-timesheet ── (#34382: typing into an empty cell creates, retyping + // a one-record cell updates its value field, clearing it deletes the record) + 'packages/plugin-timesheet/src/ObjectTimesheet.tsx :: TimesheetGridView > writeCell :: create': + mapped(['gridAddRow'], 'packages/plugin-timesheet/src/ObjectTimesheet.tsx'), + 'packages/plugin-timesheet/src/ObjectTimesheet.tsx :: TimesheetGridView > writeCell :: update': + mapped(['listInlineEdit'], 'packages/plugin-timesheet/src/ObjectTimesheet.tsx'), + 'packages/plugin-timesheet/src/ObjectTimesheet.tsx :: TimesheetGridView > writeCell :: delete': + mapped(['rowDelete'], 'packages/plugin-timesheet/src/ObjectTimesheet.tsx'), // ── plugin-view ── 'packages/plugin-view/src/ObjectView.tsx :: ObjectView > onClick :: delete': mapped(['rowDelete'], OBJECT_GRID), diff --git a/ui/packages/plugin-timesheet/README.md b/ui/packages/plugin-timesheet/README.md index c33dd05e626..2c16e3f860d 100644 --- a/ui/packages/plugin-timesheet/README.md +++ b/ui/packages/plugin-timesheet/README.md @@ -61,6 +61,13 @@ declare const dataSource: DataSource; it `delete`s it. Hooks, validation and permissions judge each cell; a refusal stays on the cell with the server's message and the typed text, and Enter retries. Every write is announced with `notifyDataChanged`, which re-reads the week. +- **Grants.** The console offers each write only to a caller who may make it, + through the affordance-to-grant map in `@object-ui/core`: an empty cell and + **Add row** need `gridAddRow` (create), a new value in a filled cell needs + `listInlineEdit` (update, plus the value field's write permission), and + clearing it needs `rowDelete` (delete). A cell no granted write can change is + read-only, and a write the caller may not make stays on its cell with a + message instead of being sent. With no permission provider all three are open. - **Multi-record cells** show their sum and are read-only. - **Week.** Starts on the display locale's first day (`firstDayOfWeek`), with previous / this / next navigation. Row, day and week totals are always shown. diff --git a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx index eb629121945..7fd32cb5456 100644 --- a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx +++ b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx @@ -72,12 +72,16 @@ import { buildExpandFields, mergeFilterNodes, nonGridRowCeilingQuery, + resolveAffordance, + resolveFieldAffordance, type NonGridCeilingResult, + type SchemaLike, } from '@object-ui/core'; import { ChevronLeft, ChevronRight, Plus } from 'lucide-react'; import { addDays, buildTimesheetRows, + cellEditable, parseCellInput, planCellWrite, recordIdOf, @@ -87,7 +91,9 @@ import { startOfWeek, weekDays, weekQueryBounds, + writeGranted, fromDayKey, + type CellWriteGrants, type TimesheetBinding, type TimesheetCell, type TimesheetRow, @@ -109,6 +115,7 @@ const TIMESHEET_DEFAULT_TRANSLATIONS: Record = { 'timesheet.multipleRecords': 'This day holds more than one record. Edit them in the list.', 'timesheet.invalidNumber': 'Enter a number', 'timesheet.saveFailed': 'Not saved: {{message}}', + 'timesheet.notAllowed': "You don't have permission to make this change.", 'timesheet.loadFailed': 'This week could not be loaded.', 'timesheet.rowIncomplete': 'Fill in every row field first.', 'timesheet.cellLabel': '{{row}}, {{day}}', @@ -293,6 +300,25 @@ function TimesheetGridView({ schema, objectName, binding, dataSource, className, const rowName = (row: TimesheetRow): string => binding.rowFields.map((f) => displayText(row.values[f])).filter(Boolean).join(' · '); + // objectui#12082 — each cell write is a row of the affordance-to-grant map + // (`resolveAffordance` in `@object-ui/core`), asked of the object the grid + // writes: typing into an empty cell creates a record inline, as a grid's + // add-record row does (`gridAddRow`); retyping a one-record cell is an + // in-cell edit of the value field (`listInlineEdit`, with that field's write + // question); clearing it deletes the record (`rowDelete`). A cell no granted + // write can change renders read-only, Add row is offered only to a caller + // who may create, and a write the caller may not make is refused with a + // message before it goes out. With no permission provider every row reads + // open. + const writeSource = { objectSchema: (objectSchema ?? null) as SchemaLike | null, objectName, perms }; + const grants: CellWriteGrants = { + create: resolveAffordance('gridAddRow', writeSource).allowed, + update: + resolveAffordance('listInlineEdit', writeSource).allowed && + resolveFieldAffordance('listInlineEdit', perms, objectName, binding.valueField), + delete: resolveAffordance('rowDelete', writeSource).allowed, + }; + const writeCell = async (row: TimesheetRow, day: string, cell: TimesheetCell, text: string) => { const id = cellId(row.key, day); const parsed = parseCellInput(text); @@ -305,6 +331,10 @@ function TimesheetGridView({ schema, objectName, binding, dataSource, className, setDrafts(({ [id]: _dropped, ...rest }) => rest); return; } + if (!writeGranted(write, grants)) { + setDrafts((d) => ({ ...d, [id]: { text, error: t('timesheet.notAllowed') } })); + return; + } setDrafts((d) => ({ ...d, [id]: { text, saving: true } })); try { let recordId: string | undefined; @@ -368,16 +398,18 @@ function TimesheetGridView({ schema, objectName, binding, dataSource, className, {`${rangeFormat.format(fromDayKey(weekStart))} – ${rangeFormat.format(fromDayKey(addDays(weekStart, 6)))}`} - + {grants.create && ( + + )} {records === null ? ( @@ -426,16 +458,17 @@ function TimesheetGridView({ schema, objectName, binding, dataSource, className, const cell = row.cells[day]; const id = cellId(row.key, day); const label = t('timesheet.cellLabel', { row: name, day: dayHeading.format(fromDayKey(day)) }); - if (cell.records.length > 1) { + if (!cellEditable(cell, grants)) { + const shown = cell.records.length > 0 ? numberFormat.format(cell.sum) : ''; return ( 1 ? t('timesheet.multipleRecords') : undefined} + aria-label={shown ? `${label}: ${shown}` : label} data-testid="timesheet-cell-readonly" > - {numberFormat.format(cell.sum)} + {shown} ); diff --git a/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx b/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx index 2a74bd4f7a3..ba8ee3c2754 100644 --- a/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx +++ b/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { render, screen, fireEvent, waitFor, cleanup, within } from '@testing-library/react'; import { describe, it, expect, afterEach, vi } from 'vitest'; +import { MePermissionsProvider, type MePermissionsAuthenticatedResponse } from '@object-ui/permissions'; import { ObjectTimesheet } from '../ObjectTimesheet'; afterEach(cleanup); @@ -203,3 +204,146 @@ describe('ObjectTimesheet', () => { ); }); }); + +/** + * #34382 — the timesheet's three cell writes read the affordance-to-grant map + * (objectui#12082), asked of the object the grid writes: + * + * - typing into an empty cell creates a record inline: `gridAddRow`, which also + * gates Add row; + * - retyping a one-record cell updates its value field: `listInlineEdit`, with + * that field's write question; + * - clearing a one-record cell deletes its record: `rowDelete`. + * + * A cell that no granted write can change renders read-only. A write the caller + * may not make (clearing with update but no delete) is refused on its cell + * before it goes out. With no permission provider every row reads open, which + * is what the `ObjectTimesheet` describe above exercises. + */ +const OBJECT = 'time_entry'; + +const GRANT_SCHEMA = { + type: 'object-timesheet' as const, + objectName: OBJECT, + timesheet: { rowFields: ['project'], dateField: 'work_date', valueField: 'hours' }, +}; + +function makeGrantDataSource() { + return { + getObjectSchema: vi.fn(async () => ({ + name: OBJECT, + fields: { + project: { name: 'project', type: 'text', label: 'Project' }, + work_date: { name: 'work_date', type: 'date', label: 'Date' }, + hours: { name: 'hours', type: 'number', label: 'Hours' }, + }, + })), + // One row: Monday holds one record, every other day is empty. + find: vi.fn(async () => ({ data: [{ id: 'r1', project: 'Apollo', work_date: '2026-11-16', hours: 2 }], total: 1 })), + create: vi.fn(async (_o: string, data: Record) => ({ id: 'n1', ...data })), + update: vi.fn(async () => ({})), + delete: vi.fn(async () => true), + }; +} + +const envelope = ( + bits: Record, + fields: Record = {}, +): MePermissionsAuthenticatedResponse => ({ + authenticated: true, + userId: 'u-pin', + tenantId: null, + hasAnyQueue: false, + objectsUsingQueues: [], + positions: ['member'], + permissionSets: ['member'], + objects: { [OBJECT]: bits as never }, + fields, +}); + +async function mountGranted(perms: MePermissionsAuthenticatedResponse) { + const ds = makeGrantDataSource(); + render( + + + , + ); + await waitFor(() => expect(screen.getAllByTestId('timesheet-row')).toHaveLength(1)); + await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); + return ds; +} + +/** Sunday..Saturday: whether each day's cell is an input. Monday (index 1) holds the record. */ +const inputDays = (): boolean[] => { + const row = screen.getByTestId('timesheet-row'); + return Array.from(row.querySelectorAll('td')) + .slice(1, 8) + .map((td) => td.querySelector('[data-testid="timesheet-cell"]') !== null); +}; + +const R = { allowRead: true }; + +describe('ObjectTimesheet cell writes under each grant (#34382)', () => { + it('read-only: every cell is read-only, Add row is not offered, and the filled cell still shows its value', async () => { + await mountGranted(envelope({ ...R, allowCreate: false, allowEdit: false, allowDelete: false })); + expect(inputDays()).toEqual([false, false, false, false, false, false, false]); + expect(screen.queryByTestId('timesheet-add-row')).toBeNull(); + const readonly = screen.getAllByTestId('timesheet-cell-readonly'); + expect(readonly.map((el) => el.textContent)).toEqual(['', '2', '', '', '', '', '']); + }); + + it('create-only: empty cells take input and create, the filled cell is read-only, Add row is offered', async () => { + const ds = await mountGranted(envelope({ ...R, allowCreate: true, allowEdit: false, allowDelete: false })); + expect(inputDays()).toEqual([true, false, true, true, true, true, true]); + expect(screen.getByTestId('timesheet-add-row')).toBeTruthy(); + const tuesday = screen.getAllByTestId('timesheet-cell')[1] as HTMLInputElement; + fireEvent.change(tuesday, { target: { value: '3' } }); + fireEvent.blur(tuesday); + await waitFor(() => expect(ds.create).toHaveBeenCalledTimes(1)); + expect(ds.update).not.toHaveBeenCalled(); + }); + + it('edit-only: the filled cell updates, empty cells are read-only, and clearing it is refused before it goes out', async () => { + const ds = await mountGranted(envelope({ ...R, allowCreate: false, allowEdit: true, allowDelete: false })); + expect(inputDays()).toEqual([false, true, false, false, false, false, false]); + expect(screen.queryByTestId('timesheet-add-row')).toBeNull(); + const monday = screen.getByTestId('timesheet-cell') as HTMLInputElement; + fireEvent.change(monday, { target: { value: '4' } }); + fireEvent.blur(monday); + await waitFor(() => expect(ds.update).toHaveBeenCalledWith(OBJECT, 'r1', { hours: 4 })); + fireEvent.change(monday, { target: { value: '' } }); + fireEvent.blur(monday); + expect(await screen.findByText("You don't have permission to make this change.")).toBeTruthy(); + expect(ds.delete).not.toHaveBeenCalled(); + }); + + it('delete-only: the filled cell can be cleared, but a new value is refused', async () => { + const ds = await mountGranted(envelope({ ...R, allowCreate: false, allowEdit: false, allowDelete: true })); + expect(inputDays()).toEqual([false, true, false, false, false, false, false]); + const monday = screen.getByTestId('timesheet-cell') as HTMLInputElement; + fireEvent.change(monday, { target: { value: '5' } }); + fireEvent.blur(monday); + expect(await screen.findByText("You don't have permission to make this change.")).toBeTruthy(); + expect(ds.update).not.toHaveBeenCalled(); + fireEvent.change(monday, { target: { value: '' } }); + fireEvent.blur(monday); + await waitFor(() => expect(ds.delete).toHaveBeenCalledWith(OBJECT, 'r1')); + }); + + it('the value field marked not editable closes the update even with the edit grant', async () => { + const ds = await mountGranted( + envelope( + { ...R, allowCreate: false, allowEdit: true, allowDelete: false }, + { [`${OBJECT}.hours`]: { readable: true, editable: false } }, + ), + ); + expect(inputDays()).toEqual([false, false, false, false, false, false, false]); + expect(ds.update).not.toHaveBeenCalled(); + }); + + it('full: every cell takes input and Add row is offered', async () => { + await mountGranted(envelope({ ...R, allowCreate: true, allowEdit: true, allowDelete: true })); + expect(inputDays()).toEqual([true, true, true, true, true, true, true]); + expect(screen.getByTestId('timesheet-add-row')).toBeTruthy(); + }); +}); diff --git a/ui/packages/plugin-timesheet/src/timesheetModel.ts b/ui/packages/plugin-timesheet/src/timesheetModel.ts index 4929dbed309..34901e56bba 100644 --- a/ui/packages/plugin-timesheet/src/timesheetModel.ts +++ b/ui/packages/plugin-timesheet/src/timesheetModel.ts @@ -286,6 +286,37 @@ export function planCellWrite( return { kind: 'update', id, data: { [binding.valueField]: next } }; } +/** + * Which of a cell's three writes the caller may make. The view resolves each + * from a row of the affordance-to-grant map (`resolveAffordance` in + * `@object-ui/core`, objectui#12082); with no permission provider all three + * read open. + */ +export interface CellWriteGrants { + create: boolean; + update: boolean; + delete: boolean; +} + +/** + * Whether a cell offers an input: an empty cell when the caller may create, a + * one-record cell when they may update or clear it, and a cell holding + * several records never. + */ +export function cellEditable(cell: TimesheetCell, grants: CellWriteGrants): boolean { + if (cell.records.length > 1) return false; + if (cell.records.length === 0) return grants.create; + return grants.update || grants.delete; +} + +/** Whether the caller may make a planned write. A plan that writes nothing needs no grant. */ +export function writeGranted(write: CellWrite, grants: CellWriteGrants): boolean { + if (write.kind === 'create') return grants.create; + if (write.kind === 'update') return grants.update; + if (write.kind === 'delete') return grants.delete; + return true; +} + /** Whether every row field holds a value — the add-row form's gate. */ export function rowValuesComplete(values: Record, rowFields: readonly string[]): boolean { return rowFields.every((f) => { From 37ec7c061f5d9686176d37c5a21ed738a39b7a0a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 17:36:33 +0000 Subject: [PATCH 15/18] test(ui): pay the CEL authoring dependencies' load at collection in the view-type label pin The edited 30358 pin reaches celAuthoring.ts, whose dynamic imports of @objectstack/formula and @objectstack/lint would load inside a case's clocked window; check:test-source-alias asks for module-top side-effect imports in a test file a change edits. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- .../MultiSelectWidget.viewTypeLabels-30358.test.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/packages/app-shell/src/views/metadata-admin/MultiSelectWidget.viewTypeLabels-30358.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/MultiSelectWidget.viewTypeLabels-30358.test.tsx index 7d71a682b7e..e0d73562077 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/MultiSelectWidget.viewTypeLabels-30358.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/MultiSelectWidget.viewTypeLabels-30358.test.tsx @@ -16,6 +16,12 @@ import { describe, it, expect, vi, afterEach } from 'vitest'; import { render, screen, cleanup } from '@testing-library/react'; +// The widgets module reaches `celAuthoring.ts`, which loads these two +// dependencies with a dynamic `import()` inside a function body. Paying the +// load here at collection keeps it out of a case's clocked window +// (`check:test-source-alias`, "The source reach"). +import '@objectstack/formula'; +import '@objectstack/lint'; import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; import { WIDGETS } from './widgets'; import { getListVariantSchema } from './view-schema'; From 8f6048c352d08544a03c2c7d9ca39a760add5a1f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:01:15 +0000 Subject: [PATCH 16/18] fix(timesheet): refuse a block-less timesheet view, parse cells in the display locale - spec: checkListViewTimesheetBinding refuses `type: 'timesheet'` with no `timesheet` block at the three list-view doors and the component face; objectui's ListView props bag attaches it too. The kind is new this release, so refusing is not breaking. - plugin-timesheet: parseCellInput reads the display locale's decimal and group marks (en 1,000 = 1000; de 1.000 = 1000, 1,5 = 1.5), refuses a second decimal mark, misplaced groups, hex and exponents. - functional-completeness: timesheet joins the spec it.each and the lint completeness test; TimesheetConfigSchema bounds pinned (0/4 rowFields, each missing key, an unknown key). - fixtures that parsed a block-less timesheet now carry a binding. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- .../validate-functional-completeness.test.ts | 15 +++++ packages/spec/api-surface/ui.json | 1 + packages/spec/export-origins/ui.json | 1 + .../kernel/functional-completeness.test.ts | 17 ++++-- .../src/kernel/functional-completeness.ts | 5 +- packages/spec/src/ui/component.zod.ts | 8 ++- .../object-refinement-check-exports.test.ts | 23 ++++++++ .../spec/src/ui/view-form-pagination.test.ts | 5 +- packages/spec/src/ui/view.test.ts | 58 +++++++++++++++++++ packages/spec/src/ui/view.zod.ts | 44 +++++++++++++- .../ListViewBlock.specInputs-13047.test.tsx | 9 +-- .../plugin-timesheet/src/ObjectTimesheet.tsx | 2 +- .../src/__tests__/ObjectTimesheet.test.tsx | 10 ++++ .../src/__tests__/timesheetModel.test.ts | 50 ++++++++++++---- .../plugin-timesheet/src/timesheetModel.ts | 45 ++++++++++++-- .../__tests__/imported-defaults-8317.test.ts | 3 + .../list-view-properties-bag-12670.test.ts | 11 +++- .../spec-object-refinements-7715.test.ts | 4 +- ui/packages/types/src/zod/README.md | 2 +- ui/packages/types/src/zod/objectql.zod.ts | 11 ++-- 20 files changed, 280 insertions(+), 44 deletions(-) diff --git a/packages/lint/src/validate-functional-completeness.test.ts b/packages/lint/src/validate-functional-completeness.test.ts index 7c4d224143f..aea2580ba66 100644 --- a/packages/lint/src/validate-functional-completeness.test.ts +++ b/packages/lint/src/validate-functional-completeness.test.ts @@ -167,6 +167,21 @@ describe('validateFunctionalCompleteness — the walk', () => { expect(findings[0].path).toBe('objects[0].listViews.plan.gantt'); }); + it('flags a block-less `timesheet` view through the nested door, and is silent once it binds (#34382)', () => { + expect(validateFunctionalCompleteness({ + objects: [{ name: 'time_entry', fields: [], listViews: { week: { type: 'timesheet' } } }], + }).map((f) => [f.rule, f.severity, f.path])).toEqual([ + ['view/layout-without-binding', 'warning', 'objects[0].listViews.week.timesheet'], + ]); + expect(validateFunctionalCompleteness({ + objects: [{ + name: 'time_entry', + fields: [], + listViews: { week: { type: 'timesheet', timesheet: { rowFields: ['project'], dateField: 'work_date', valueField: 'hours' } } }, + }], + })).toEqual([]); + }); + it('walks the object-nested default `list` slot too', () => { expect(validateFunctionalCompleteness({ objects: [{ name: 'task', fields: [], list: { type: 'timeline' } }], diff --git a/packages/spec/api-surface/ui.json b/packages/spec/api-surface/ui.json index 5de7c859b00..f3e37a151a8 100644 --- a/packages/spec/api-surface/ui.json +++ b/packages/spec/api-surface/ui.json @@ -541,6 +541,7 @@ "checkGlobalFilterDateDefaultValue (function)", "checkListViewCalendarVisualization (function)", "checkListViewChartBinding (function)", + "checkListViewTimesheetBinding (function)", "checkPageDefaultPlacement (function)", "checkPageMainRegionWidth (function)", "checkPagePrintComposition (function)", diff --git a/packages/spec/export-origins/ui.json b/packages/spec/export-origins/ui.json index 2c75dd24fb7..8d7de30a1ad 100644 --- a/packages/spec/export-origins/ui.json +++ b/packages/spec/export-origins/ui.json @@ -524,6 +524,7 @@ "checkGlobalFilterDateDefaultValue": "src/ui/dashboard.zod.ts#checkGlobalFilterDateDefaultValue (function)", "checkListViewCalendarVisualization": "src/ui/view.zod.ts#checkListViewCalendarVisualization (function)", "checkListViewChartBinding": "src/ui/view.zod.ts#checkListViewChartBinding (function)", + "checkListViewTimesheetBinding": "src/ui/view.zod.ts#checkListViewTimesheetBinding (function)", "checkPageDefaultPlacement": "src/ui/page.zod.ts#checkPageDefaultPlacement (function)", "checkPageMainRegionWidth": "src/ui/page.zod.ts#checkPageMainRegionWidth (function)", "checkPagePrintComposition": "src/ui/page.zod.ts#checkPagePrintComposition (function)", diff --git a/packages/spec/src/kernel/functional-completeness.test.ts b/packages/spec/src/kernel/functional-completeness.test.ts index 45d9a5c5322..5c9fee9a4a0 100644 --- a/packages/spec/src/kernel/functional-completeness.test.ts +++ b/packages/spec/src/kernel/functional-completeness.test.ts @@ -118,18 +118,21 @@ describe('checkFieldCompleteness — the verified inert shapes go red', () => { }); describe('checkViewCompleteness — layout bindings', () => { - // Six of the view `type` members carry a binding block, and the missing - // block is the same defect on all six: the surface the author asked for is - // not the one that renders, while authoring reports success. + // Seven of the view `type` members carry a binding block, and the missing + // block is the same defect on all seven: the surface the author asked for is + // not the one that renders, while authoring reports success. (`timesheet`, + // the seventh, #34382, is also refused at the spec door when the block is + // absent — `checkListViewTimesheetBinding` — so this row is what an + // unparsed stack meets.) // // ⛔ What it is NOT is one shared mechanism. This comment used to say the // renderer's fallback for every one is a literal field name; objectui has // been deleting those floors one view type at a time, and for `calendar` // (#17445), `gantt`, `timeline` and `map` (#19630) the renderer now REFUSES - // by name instead. The rule fires on all six either way — that is what this + // by name instead. The rule fires on all seven either way — that is what this // pin holds — and the per-type mechanism belongs to the table's docblock, // which states each row's own measurement. - it.each(['kanban', 'calendar', 'gantt', 'timeline', 'map', 'tree'])('flags a %s view missing its block as a WARNING', (type) => { + it.each(['kanban', 'calendar', 'gantt', 'timeline', 'map', 'tree', 'timesheet'])('flags a %s view missing its block as a WARNING', (type) => { const f = only(checkViewCompleteness({ type }) as never); expect(f.rule).toBe(VIEW_LAYOUT_WITHOUT_BINDING); expect(f.severity).toBe('warning'); @@ -156,6 +159,10 @@ describe('checkViewCompleteness — layout bindings', () => { map: { latitudeField: 'lat', longitudeField: 'lng' }, })).toEqual([]); expect(checkViewCompleteness({ type: 'tree', tree: { parentField: 'parent' } })).toEqual([]); + expect(checkViewCompleteness({ + type: 'timesheet', + timesheet: { rowFields: ['project'], dateField: 'work_date', valueField: 'hours' }, + })).toEqual([]); }); it('the calendar body describes the REFUSAL, not a deleted literal fallback', () => { diff --git a/packages/spec/src/kernel/functional-completeness.ts b/packages/spec/src/kernel/functional-completeness.ts index 87e9db738f7..980f0555b60 100644 --- a/packages/spec/src/kernel/functional-completeness.ts +++ b/packages/spec/src/kernel/functional-completeness.ts @@ -365,7 +365,10 @@ export function checkFieldCompleteness(def: unknown): CompletenessFinding[] { * the "Timesheet configuration required" refusal * (`data-testid="timesheet-missing-binding"`). `TimesheetConfigSchema` * requires all three keys, so a present block is a complete binding and - * only an absent one can reach the refusal. + * only an absent one can reach the refusal. The spec's list-view doors + * refuse that absent block outright (`checkListViewTimesheetBinding`, + * `ui/view.zod.ts`), so this row is what a stack meets before it parses + * (`os validate` over source); it stays a warning like its six siblings. * * RE-MEASUREMENT HISTORY. [#17445] corrected the `calendar` row, reading * objectui `main` at `0cf2d6644` (2026-09-21), and found the `gantt`, diff --git a/packages/spec/src/ui/component.zod.ts b/packages/spec/src/ui/component.zod.ts index f4d64ba0835..24943a433cd 100644 --- a/packages/spec/src/ui/component.zod.ts +++ b/packages/spec/src/ui/component.zod.ts @@ -51,6 +51,7 @@ import { // `ListViewPageProps`. checkListViewCalendarVisualization, checkListViewChartBinding, + checkListViewTimesheetBinding, VIEW_METADATA_MEMBERS, } from './view.zod'; // [#22444] The one prescription both tiers refuse a list view's retired @@ -8552,8 +8553,9 @@ const LIST_VIEW_PAGE_ALIAS_GUIDANCE: Readonly strictObject({ ...ListViewSchema.shape, columns: ListViewSchema.shape.columns.optional(), options: VIEW_METADATA_MEMBERS.listOverlay.shape.options, -}).superRefine(checkListViewCalendarVisualization).superRefine(checkListViewChartBinding)); +}).superRefine(checkListViewCalendarVisualization).superRefine(checkListViewChartBinding).superRefine(checkListViewTimesheetBinding)); /** * ---------------------------------------------------------------------- diff --git a/packages/spec/src/ui/object-refinement-check-exports.test.ts b/packages/spec/src/ui/object-refinement-check-exports.test.ts index ee22a6f19a4..fc5ab133ca4 100644 --- a/packages/spec/src/ui/object-refinement-check-exports.test.ts +++ b/packages/spec/src/ui/object-refinement-check-exports.test.ts @@ -56,6 +56,7 @@ import { ObjectListViewSchema, checkListViewCalendarVisualization, checkListViewChartBinding, + checkListViewTimesheetBinding, } from './view.zod'; import { PageSchema, @@ -236,6 +237,18 @@ const chartBindingFixtures: Fixture[] = [ { label: 'a block-less view of another type', value: { type: 'kanban', columns: ['stage'] }, refusesAt: [] }, ]; +// [#34382] The timesheet-binding check: a `type: 'timesheet'` view must +// declare its `timesheet` block; the block's own strict schema judges its keys. +const timesheetBindingFixtures: Fixture[] = [ + { label: "`type: 'timesheet'` with no `timesheet` block", value: { type: 'timesheet', columns: ['project'] }, refusesAt: ['timesheet'] }, + { + label: "`type: 'timesheet'` with a complete block", + value: { type: 'timesheet', columns: ['project'], timesheet: { rowFields: ['project'], dateField: 'work_date', valueField: 'hours' } }, + refusesAt: [], + }, + { label: 'a block-less view of another type', value: { type: 'grid', columns: ['project'] }, refusesAt: [] }, +]; + const PAGE_BASE = { name: 'home_page', label: 'Home', type: 'home' } as const; const pageSourceFixtures: Fixture[] = [ @@ -553,6 +566,7 @@ const chartMeasureArityFixtures: Fixture[] = [ const listViewExports: ExportUnderTest[] = [ { name: 'checkListViewCalendarVisualization', check: checkListViewCalendarVisualization, fixtures: calendarFixtures }, { name: 'checkListViewChartBinding', check: checkListViewChartBinding, fixtures: chartBindingFixtures }, + { name: 'checkListViewTimesheetBinding', check: checkListViewTimesheetBinding, fixtures: timesheetBindingFixtures }, ]; const MIRRORED: MirroredSchema[] = [ @@ -718,6 +732,14 @@ describe('each schema attaches its export BY IDENTIFIER — no inline copy', () /ListViewShapeSchema\s*\.superRefine\(checkListViewCalendarVisualization\)\s*\.superRefine\(checkListViewChartBinding\)/, ); expect(attachments(src, 'checkListViewChartBinding')).toBe(3); + // [#34382] The timesheet-binding check: declared once, chained after the + // chart-binding check at the same three doors. + expect(src).toContain('export function checkListViewTimesheetBinding('); + expect(declarations(src, 'checkListViewTimesheetBinding')).toBe(1); + expect(src).toMatch( + /\.superRefine\(checkListViewChartBinding\)\s*\.superRefine\(checkListViewTimesheetBinding\)/, + ); + expect(attachments(src, 'checkListViewTimesheetBinding')).toBe(3); // [#17063] `checkListViewPageMount` was retired with the `type: 'page'` // mount it policed, so neither a declaration nor an attachment of it may // return: a re-attachment would be a check with no rule left to enforce. @@ -771,6 +793,7 @@ describe('`./index` (the `@objectstack/spec/ui` surface) exports the same functi it.each([ ['checkListViewCalendarVisualization', checkListViewCalendarVisualization], ['checkListViewChartBinding', checkListViewChartBinding], + ['checkListViewTimesheetBinding', checkListViewTimesheetBinding], ['checkPageSourceCompleteness', checkPageSourceCompleteness], ['checkPageRequiresKind', checkPageRequiresKind], ['checkPagePrintComposition', checkPagePrintComposition], diff --git a/packages/spec/src/ui/view-form-pagination.test.ts b/packages/spec/src/ui/view-form-pagination.test.ts index 41abdf52351..50021821f15 100644 --- a/packages/spec/src/ui/view-form-pagination.test.ts +++ b/packages/spec/src/ui/view-form-pagination.test.ts @@ -128,8 +128,11 @@ describe('view form — `pagination` is offered to every view type', () => { // A `chart` view binds a dataset (#22491), so it carries that binding here; // every other type parses with no block of its own. + // `chart` and `timesheet` each refuse a list view with no binding block, so they carry one. const bindingFor = (type: string) => - (type === 'chart' ? { chart: { dataset: 'lead_metrics', values: ['amount_sum'] } } : {}); + (type === 'chart' ? { chart: { dataset: 'lead_metrics', values: ['amount_sum'] } } + : type === 'timesheet' ? { timesheet: { rowFields: ['name'], dateField: 'work_date', valueField: 'hours' } } + : {}); it.each(VIEW_TYPES.map((t) => [t]))("is backed by the door: type '%s' parses a pagination block and keeps it", (type) => { const r = ListViewSchema.safeParse({ type, columns: ['name'], ...bindingFor(type), pagination: { pageSize: 50 } }); diff --git a/packages/spec/src/ui/view.test.ts b/packages/spec/src/ui/view.test.ts index 5a6a1c94b45..5c700ab44c6 100644 --- a/packages/spec/src/ui/view.test.ts +++ b/packages/spec/src/ui/view.test.ts @@ -9,6 +9,7 @@ import { KanbanConfigSchema, CalendarConfigSchema, GanttConfigSchema, + TimesheetConfigSchema, ListColumnSchema, FormFieldSchema, SelectionConfigSchema, @@ -4939,3 +4940,60 @@ describe('view row bound — `pagination.pageSize` is the one bound; no per-kind } }); }); + +/** + * [#34382] The timesheet list view: its binding block's bounds, and the door + * check that a `type: 'timesheet'` view declares one. + * + * `TimesheetConfigSchema` is strict and requires all three keys; `rowFields` + * names 1 to 3 fields. A `type: 'timesheet'` view with no block renders only + * the "configuration required" screen, so `checkListViewTimesheetBinding` + * refuses it at `timesheet` at every list-view door, beside the chart-binding + * check. Both halves are pinned here so neither can be quietly relaxed + * (ADR-0078 §6). + */ +describe('TimesheetConfigSchema and the timesheet binding (#34382)', () => { + const BLOCK = { rowFields: ['project'], dateField: 'work_date', valueField: 'hours' } as const; + const paths = (r: { success: boolean; error?: z.ZodError }) => + r.success ? [] : flattenUnionIssues(r.error!.issues).map((i) => i.path.join('.')); + + it('accepts a block of one to three row fields with a date field and a value field', () => { + expect(TimesheetConfigSchema.safeParse(BLOCK).success).toBe(true); + expect(TimesheetConfigSchema.safeParse({ ...BLOCK, rowFields: ['project', 'task', 'phase'] }).success).toBe(true); + }); + + it('refuses no row fields and four row fields', () => { + expect(paths(TimesheetConfigSchema.safeParse({ ...BLOCK, rowFields: [] }))).toContain('rowFields'); + expect(paths(TimesheetConfigSchema.safeParse({ ...BLOCK, rowFields: ['a', 'b', 'c', 'd'] }))).toContain('rowFields'); + }); + + it.each(['rowFields', 'dateField', 'valueField'] as const)('refuses a block missing `%s`', (key) => { + const { [key]: _dropped, ...rest } = BLOCK; + expect(paths(TimesheetConfigSchema.safeParse(rest))).toContain(key); + }); + + it('refuses an unknown key in the block', () => { + const r = TimesheetConfigSchema.safeParse({ ...BLOCK, weekStart: 'monday' }); + expect(r.success).toBe(false); + }); + + describe.each(viewDoorsCarryingObjectLevelChecks)('%s', (_label, parse) => { + it("REFUSES `type: 'timesheet'` with no `timesheet` block, at `timesheet`", () => { + const r = parse({ type: 'timesheet', columns: ['project'] }); + expect(r.success).toBe(false); + const issue = flattenUnionIssues((r as { error: z.ZodError }).error.issues) + .find((i) => i.path.join('.') === 'timesheet'); + expect(issue, JSON.stringify((r as { error: z.ZodError }).error.issues)).toBeDefined(); + expect(issue!.message).toContain("`type: 'timesheet'` but declares no `timesheet` block"); + }); + + it('ACCEPTS the same view once it binds a block — the lit control', () => { + const r = parse({ type: 'timesheet', columns: ['project'], timesheet: BLOCK }); + expect(r.success, JSON.stringify(r.success ? null : (r as { error: z.ZodError }).error.issues)).toBe(true); + }); + + it('does not judge a block-less view of another type', () => { + expect(parse({ type: 'grid', columns: ['project'] }).success).toBe(true); + }); + }); +}); diff --git a/packages/spec/src/ui/view.zod.ts b/packages/spec/src/ui/view.zod.ts index 5d9bd0db8bb..f6d14e29cc4 100644 --- a/packages/spec/src/ui/view.zod.ts +++ b/packages/spec/src/ui/view.zod.ts @@ -3299,6 +3299,43 @@ export function checkListViewChartBinding( ctx.addIssue({ code: 'custom', path: ['chart'], message: LIST_VIEW_CHART_NEEDS_BINDING }); } +/** [#34382] `type: 'timesheet'` with no `timesheet` block — refused at `timesheet`. */ +const LIST_VIEW_TIMESHEET_NEEDS_BINDING = + "This list view is `type: 'timesheet'` but declares no `timesheet` block, so the weekly grid has no " + + "rows, day or value to pivot. Declare `timesheet: { rowFields: [''], dateField: '', " + + "valueField: '' }`: `rowFields` names the 1 to 3 fields whose distinct values make the " + + 'rows, `dateField` the date each record falls on, and `valueField` the number each cell edits. There is ' + + 'no default binding to fall back on. A view that is not meant to be a timesheet takes another `type`.'; + +/** + * [#34382] A `type: 'timesheet'` list view must bind its grid: a `timesheet` + * block naming its row fields, date field and value field. + * + * - No block ⇒ one issue at `timesheet`. + * - A declared block ⇒ nothing here: {@link TimesheetConfigSchema} is strict + * and requires all three keys, at `timesheet.*`. + * + * Without the block the renderer has nothing to fall back on (only the + * author knows which fields make the rows, the day and the value), so it + * draws only its "configuration required" screen — the fully inert case + * ADR-0078 §1 grades an error. The type is new in this release, so refusing + * the block-less shape here narrows nothing a published version accepted; + * the six older binding rows in `kernel/functional-completeness.ts` stay + * warnings because escalating THEM would be that narrowing. + * + * Reads `type` as the door hands it, exactly as + * {@link checkListViewChartBinding} does, and is attached beside it at the + * same three list-view doors, exported for the same reason: a mirror built + * from `ListViewSchema.shape` re-attaches it. + */ +export function checkListViewTimesheetBinding( + view: { type?: unknown; timesheet?: unknown }, + ctx: z.RefinementCtx, +): void { + if (view.type !== 'timesheet' || view.timesheet !== undefined) return; + ctx.addIssue({ code: 'custom', path: ['timesheet'], message: LIST_VIEW_TIMESHEET_NEEDS_BINDING }); +} + /** * List View Schema (Expanded) * Defines how a collection of records is displayed to the user. @@ -3736,7 +3773,8 @@ const ListViewShapeSchema = lazySchema(() => strictObject({ export const ListViewSchema = lazySchema(() => ListViewShapeSchema .superRefine(checkListViewCalendarVisualization) - .superRefine(checkListViewChartBinding)); + .superRefine(checkListViewChartBinding) + .superRefine(checkListViewTimesheetBinding)); /** * [commit c459da6bc] Form-view select option — {@link SelectOptionSchema} minus the @@ -5686,7 +5724,8 @@ export const ObjectListViewSchema = lazySchema(() => // authoring surface — as the one door where a calendar-enabled view with // no `calendar:` block, or a chart view binding no dataset, parses clean. .superRefine(checkListViewCalendarVisualization) - .superRefine(checkListViewChartBinding)); + .superRefine(checkListViewChartBinding) + .superRefine(checkListViewTimesheetBinding)); /** * [#4001/#7741] The wrap remedy, ONE prose source for two doors: the container's @@ -7201,6 +7240,7 @@ const ListViewOverlayWireSchema = lazySchema(() => .superRefine(checkListOverlayTypeNeedsColumns) .superRefine(checkListViewCalendarVisualization) .superRefine(checkListViewChartBinding) + .superRefine(checkListViewTimesheetBinding) .overwrite(applyListOverlayTypeDefault), ); diff --git a/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx b/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx index dafc4b95be9..17ad27a2978 100644 --- a/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx @@ -730,12 +730,9 @@ describe('objectui#13047 — each kind\'s own block, handed to the node of the v }); it('`timesheet`: the `rowFields` / `dateField` / `valueField` binding reaches the grid', async () => { - const control = mount({ type: 'timesheet' }); - await loaded(control.dataSource); - expect(lastHanded('object-timesheet')?.timesheet).toBeUndefined(); - cleanup(); - resetHanded(); - + // No block-less control here: the spec refuses `type: 'timesheet'` without a + // `timesheet` block (checkListViewTimesheetBinding), so, as for `chart`, the + // fixture always carries one. const block = { rowFields: ['owner'], dateField: 'due', valueField: 'amount' }; const { dataSource } = mount({ type: 'timesheet', timesheet: block }); await handedTo('object-timesheet'); diff --git a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx index 7fd32cb5456..54e4ec08996 100644 --- a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx +++ b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx @@ -321,7 +321,7 @@ function TimesheetGridView({ schema, objectName, binding, dataSource, className, const writeCell = async (row: TimesheetRow, day: string, cell: TimesheetCell, text: string) => { const id = cellId(row.key, day); - const parsed = parseCellInput(text); + const parsed = parseCellInput(text, locale); if (parsed === 'invalid') { setDrafts((d) => ({ ...d, [id]: { text, error: t('timesheet.invalidNumber') } })); return; diff --git a/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx b/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx index ba8ee3c2754..b412019a9b2 100644 --- a/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx +++ b/ui/packages/plugin-timesheet/src/__tests__/ObjectTimesheet.test.tsx @@ -93,6 +93,16 @@ describe('ObjectTimesheet', () => { await waitFor(() => expect(ds.update).toHaveBeenCalledWith('time_entry', 'r1', { hours: 1234.6 })); }); + it('reads a typed `1,000` in the display locale (en-US) as a thousand, never one', async () => { + const ds = makeDataSource([{ id: 'r1', project: 'Apollo', work_date: '2026-11-16', hours: 2 }]); + renderTimesheet(ds); + await waitFor(() => expect(screen.getAllByTestId('timesheet-row')).toHaveLength(1)); + const monday = screen.getAllByTestId('timesheet-cell')[1] as HTMLInputElement; + fireEvent.change(monday, { target: { value: '1,000' } }); + fireEvent.blur(monday); + await waitFor(() => expect(ds.update).toHaveBeenCalledWith('time_entry', 'r1', { hours: 1000 })); + }); + it('pivots records into rows and days with row, day and week totals', async () => { const ds = makeDataSource([ { id: 'r1', project: 'Apollo', work_date: '2026-11-16', hours: 2 }, diff --git a/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts b/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts index 39f5e03623a..6a3b26c4323 100644 --- a/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts +++ b/ui/packages/plugin-timesheet/src/__tests__/timesheetModel.test.ts @@ -149,17 +149,45 @@ describe('planCellWrite', () => { describe('parseCellInput and rowValuesComplete', () => { it('parses numbers, clears on empty, refuses text', () => { - expect(parseCellInput(' 7.5 ')).toBe(7.5); - expect(parseCellInput('1,5')).toBe(1.5); - expect(parseCellInput('')).toBeNull(); - expect(parseCellInput('abc')).toBe('invalid'); - }); - - it('reads the ungrouped display back, and refuses a grouped number rather than misread it', () => { - expect(parseCellInput('1234.5')).toBe(1234.5); - expect(parseCellInput('1234,5')).toBe(1234.5); - expect(parseCellInput('1,234.5')).toBe('invalid'); - expect(parseCellInput('1,234,5')).toBe('invalid'); + expect(parseCellInput(' 7.5 ', 'en')).toBe(7.5); + expect(parseCellInput('-2', 'en')).toBe(-2); + expect(parseCellInput('', 'en')).toBeNull(); + expect(parseCellInput('abc', 'en')).toBe('invalid'); + // Number() would take these; a typed hour never means them. + expect(parseCellInput('0x10', 'en')).toBe('invalid'); + expect(parseCellInput('1e3', 'en')).toBe('invalid'); + }); + + it('reads the ungrouped display back in its own locale', () => { + expect(parseCellInput('1234.5', 'en')).toBe(1234.5); + expect(parseCellInput('1234,5', 'de')).toBe(1234.5); + }); + + it("en: a comma groups thousands, so `1,000` is a thousand, never one (#34382 L2 S2)", () => { + expect(parseCellInput('1,000', 'en')).toBe(1000); + expect(parseCellInput('1,234', 'en')).toBe(1234); + expect(parseCellInput('1,234.5', 'en')).toBe(1234.5); + expect(parseCellInput('12,345,678', 'en')).toBe(12345678); + // A comma that is not between whole groups of three is refused, not read as a decimal. + expect(parseCellInput('1,5', 'en')).toBe('invalid'); + expect(parseCellInput('1,234,5', 'en')).toBe('invalid'); + expect(parseCellInput('1.2.3', 'en')).toBe('invalid'); + }); + + it('de: a comma is the decimal and a dot groups thousands, so `1.000` is a thousand', () => { + expect(parseCellInput('1,5', 'de')).toBe(1.5); + expect(parseCellInput('1.000', 'de')).toBe(1000); + expect(parseCellInput('1.234', 'de')).toBe(1234); + expect(parseCellInput('1.234,5', 'de')).toBe(1234.5); + expect(parseCellInput('1,000', 'de')).toBe(1); + expect(parseCellInput('7.5', 'de')).toBe('invalid'); + expect(parseCellInput('1,2,3', 'de')).toBe('invalid'); + }); + + it('a locale that groups with a space takes a space there; a locale with its own decimal mark reads Latin input', () => { + expect(parseCellInput('1 234,5', 'fr')).toBe(1234.5); + expect(parseCellInput('1\u202f234,5', 'fr')).toBe(1234.5); + expect(parseCellInput('7.5', 'ar-EG')).toBe(7.5); }); it('requires every row field', () => { diff --git a/ui/packages/plugin-timesheet/src/timesheetModel.ts b/ui/packages/plugin-timesheet/src/timesheetModel.ts index 34901e56bba..27e7f5c5dc6 100644 --- a/ui/packages/plugin-timesheet/src/timesheetModel.ts +++ b/ui/packages/plugin-timesheet/src/timesheetModel.ts @@ -200,17 +200,52 @@ export function buildTimesheetRows( return { rows: [...rows.values()], dayTotals, weekTotal }; } +/** The decimal and digit-group marks `locale` writes numbers with. */ +function numberMarks(locale: string | undefined): { decimal: string; group: string } { + try { + const parts = new Intl.NumberFormat(locale).formatToParts(12345.6); + const decimal = parts.find((p) => p.type === 'decimal')?.value ?? '.'; + const group = parts.find((p) => p.type === 'group')?.value ?? ','; + // A locale that writes its own decimal mark (Arabic's `٫`) gets the Latin + // marks: a typed number there is ASCII, and its own digits never parse. + if (decimal !== '.' && decimal !== ',') return { decimal: '.', group: ',' }; + return { decimal, group }; + } catch { + return { decimal: '.', group: ',' }; + } +} + /** * What a typed cell value means: `null` clears the cell, a number sets it, and * `'invalid'` is text that is neither (the cell shows "Enter a number"). + * + * Read in the display `locale`'s own marks (#34382): its decimal mark, at most + * once, and its digit-group mark only between whole groups of three — so in + * `en` `1,000` is a thousand and `1,5` is refused, and in `de` `1.000` is a + * thousand and `1,5` is one and a half. A locale grouping with a space + * (`fr`, `ru`) takes any space there. Any other mark, an exponent or a hex + * prefix is refused rather than guessed at. The grid displays without + * grouping in the same locale, so what it shows always reads back. */ -export function parseCellInput(text: string): number | null | 'invalid' { +export function parseCellInput(text: string, locale?: string): number | null | 'invalid' { const trimmed = text.trim(); if (trimmed === '') return null; - // One `,` is a decimal comma (de, fr, ru…); the grid displays without digit - // grouping, so a `,` never stands for a thousands separator here. - if ((trimmed.match(/,/g) ?? []).length > 1 || (trimmed.includes(',') && trimmed.includes('.'))) return 'invalid'; - const n = Number(trimmed.replace(',', '.')); + const { decimal, group } = numberMarks(locale); + const negative = trimmed.startsWith('-'); + const body = negative ? trimmed.slice(1) : trimmed; + const decimalAt = body.indexOf(decimal); + if (decimalAt !== body.lastIndexOf(decimal)) return 'invalid'; + const whole = decimalAt < 0 ? body : body.slice(0, decimalAt); + const fraction = decimalAt < 0 ? '' : body.slice(decimalAt + 1); + if (!/^\d*$/.test(fraction)) return 'invalid'; + let digits = whole; + if (!/^\d*$/.test(whole)) { + const groups = whole.split(/\s/.test(group) ? /\s/ : group); + if (!/^\d{1,3}$/.test(groups[0]) || groups.slice(1).some((g) => !/^\d{3}$/.test(g))) return 'invalid'; + digits = groups.join(''); + } + if (digits === '' && fraction === '') return 'invalid'; + const n = Number(`${negative ? '-' : ''}${digits || '0'}${fraction ? `.${fraction}` : ''}`); return Number.isFinite(n) ? n : 'invalid'; } diff --git a/ui/packages/types/src/__tests__/imported-defaults-8317.test.ts b/ui/packages/types/src/__tests__/imported-defaults-8317.test.ts index 21b5fad8323..c44e4f6aae1 100644 --- a/ui/packages/types/src/__tests__/imported-defaults-8317.test.ts +++ b/ui/packages/types/src/__tests__/imported-defaults-8317.test.ts @@ -141,6 +141,7 @@ import { navItemVisibleDataNeedsDataSource, checkListViewCalendarVisualization, checkListViewChartBinding, + checkListViewTimesheetBinding, checkPageSourceCompleteness, checkDashboardWidgetStageOrder, checkDashboardWidgetMetricMeasureArity, @@ -757,6 +758,8 @@ describe('the import boundary strips every imported default (objectui#8317)', () // `ListViewSchema`, attached on the authored page `list-view` node's bag // (`ListViewPropsBag`), whose `type` is the spec's view kind. ['checkListViewChartBinding', checkListViewChartBinding], + // objectstack#34382: the timesheet-binding check, attached beside it on the same bag. + ['checkListViewTimesheetBinding', checkListViewTimesheetBinding], // objectstack#28450: the spec's `AppSchema.landing` check, re-attached on // `AppComponentSchema` under the objectui#7715 ruling. ['checkAppLandingItems', checkAppLandingItems], diff --git a/ui/packages/types/src/__tests__/list-view-properties-bag-12670.test.ts b/ui/packages/types/src/__tests__/list-view-properties-bag-12670.test.ts index 2de223736e2..80bf71d72fe 100644 --- a/ui/packages/types/src/__tests__/list-view-properties-bag-12670.test.ts +++ b/ui/packages/types/src/__tests__/list-view-properties-bag-12670.test.ts @@ -189,8 +189,11 @@ describe('a page `list-view` validates in the spec spelling, in its `properties` it.each(SpecListViewSchema.shape.type.removeDefault().options.map((kind) => [kind] as const))( 'the bag\'s `type` takes the spec\'s list kind `%s`', (kind) => { - // A `chart` list names its dataset binding: the spec's own check (section 5) requires one. - const chart = kind === 'chart' ? { chart: { chartType: 'bar', dataset: 'deal_ds', values: ['total'] } } : {}; + // A `chart` list names its dataset binding, and a `timesheet` list its weekly-grid + // binding: the spec's own checks (section 5) require each. + const chart = kind === 'chart' ? { chart: { chartType: 'bar', dataset: 'deal_ds', values: ['total'] } } + : kind === 'timesheet' ? { timesheet: { rowFields: ['project'], dateField: 'work_date', valueField: 'hours' } } + : {}; for (const [face, parse] of FACES) { const result = parse({ ...RULED, properties: { ...RULED.properties, type: kind, kanban: undefined, ...chart } }); expect(result.success, `${face}: ${JSON.stringify(result.error?.issues)}`).toBe(true); @@ -373,6 +376,7 @@ describe('the spec\'s list view checks run in the bag, with the spec\'s own issu it.each([ ['`checkListViewCalendarVisualization`: a calendar offered with no `calendar` block', { appearance: { allowedVisualizations: ['calendar'] } }, 'calendar'], ['`checkListViewChartBinding`: a `chart` list with no dataset binding', { type: 'chart' }, 'chart'], + ['`checkListViewTimesheetBinding`: a `timesheet` list with no `timesheet` block', { type: 'timesheet' }, 'timesheet'], ] as const)('%s', (_label, props, path) => { const expected = specIssue(props, path); expect(expected?.code, 'the spec refuses the same list view (lit control)').toBe('custom'); @@ -382,10 +386,11 @@ describe('the spec\'s list view checks run in the bag, with the spec\'s own issu } }); - it('controls: a declared calendar block, and a dataset-bound chart, pass on both faces', () => { + it('controls: a declared calendar block, a dataset-bound chart, and a bound timesheet, pass on both faces', () => { for (const props of [ { appearance: { allowedVisualizations: ['calendar'] }, calendar: { startDateField: 'starts_at' } }, { type: 'chart', chart: { chartType: 'bar', dataset: 'deal_ds', dimensions: ['stage'], values: ['total'] } }, + { type: 'timesheet', timesheet: { rowFields: ['project'], dateField: 'work_date', valueField: 'hours' } }, ]) { expect(SpecListViewSchema.safeParse({ columns: ['name'], ...props }).success).toBe(true); for (const [face, parse] of FACES) expect(parse(page(props)).success, face).toBe(true); diff --git a/ui/packages/types/src/__tests__/spec-object-refinements-7715.test.ts b/ui/packages/types/src/__tests__/spec-object-refinements-7715.test.ts index 7172856d16d..fc8fdb2c5b6 100644 --- a/ui/packages/types/src/__tests__/spec-object-refinements-7715.test.ts +++ b/ui/packages/types/src/__tests__/spec-object-refinements-7715.test.ts @@ -466,7 +466,9 @@ const SITES = [ // `list-view` node's bag (`ListViewPropsBag`, objectui#12670), whose `type` IS the spec's // view kind, attaches both checks by reference; `list-view-properties-bag-12670.test.ts` // measures each against the spec's own issue. - notAttachable: ['checkListViewChartBinding'], + // `checkListViewTimesheetBinding` joined with objectstack#34382 and is not attachable + // here for the same reason: it judges `type: 'timesheet'`. + notAttachable: ['checkListViewChartBinding', 'checkListViewTimesheetBinding'], }, ] as const; diff --git a/ui/packages/types/src/zod/README.md b/ui/packages/types/src/zod/README.md index aaa6c4528ba..a043e90cdc6 100644 --- a/ui/packages/types/src/zod/README.md +++ b/ui/packages/types/src/zod/README.md @@ -293,7 +293,7 @@ The ADR-0080 public blocks `object-metric`, `object-master-detail-form`, `object `ObjectGanttBlockSchema` is the authored `object-gantt` node, built the way `ObjectMapBlockSchema` is (objectui#10859 batch 6). Each member of the row written flat on the node is refused by name, naming `properties.KEY`, except `label`, which `@objectstack/spec`'s page component also declares on the node itself. The flat mirror's `GanttConfig` keys (`startDateField`, `viewMode`, …) and its `dependencyField` alias are refused by name too, pointing at the bag's `gantt` block, `properties.gantt.KEY`. The record-source rule stays, read in the bag, as on `object-map`. `ObjectGanttSchema`, the flat mirror of the TypeScript `ObjectGanttSchema`, stays exported as the node as `ObjectGantt` reads it, and as the list and object views compose it; it is no longer an arm of `AnyComponentSchema`. `ObjectGridBlockSchema` is the authored `object-grid` node (objectui#11276's `object-grid` batch), built the way `ObjectGanttBlockSchema` is from the spec's `ComponentPropsMap['object-grid']` row. `label` stays on the node, as on `object-gantt`, and a flat `defaultSort` keeps the row's own retirement. The flat mirror's retirements of keys the row does not declare (`operators`, `rowSpecActions`, `bulkSpecActions`, `name`, `placeholder`, `showFilters`) and its content-channel refusals ride onto the arm by reference, and its `onNavigate` runtime slot is declared as the mirror declares it. The record-source rule stays, read in the bag: the node needs `properties.objectName`, or the node's `dataSource` binding. `ObjectGridSchema`, the flat mirror of the TypeScript `ObjectGridSchema`, stays exported as the node as `ObjectGrid` reads it, and still builds the `object-view` `table` slot; it is no longer an arm of `AnyComponentSchema`. `ObjectPivotBlockSchema` and `EmbeddableFormBlockSchema` (objectui#11440) are the authored `object-pivot` and `embeddable-form` nodes, two more blocks with no `ComponentPropsMap` row. Each bag is built from the block's registration `inputs`, and it is required, because those inputs include required members: `rowField`, `columnField` and `valueField` on the pivot, `formId` on the form. `objectName` is required unless the node's `dataSource` binding names the object. The pivot's cross-tab members are the `PivotTableSchema` mirror's own, by reference; its `drillDown` refuses `mode` by name (a pivot always drills through), and its retired `dataProvider` is refused by name. A member written flat is refused by name toward `properties.KEY`, the node declares the `dataSource` binding, and both content channels are refused. -`ListViewBlockSchema` is the authored page `list-view` node (objectui#12670, ruling C on objectstack-ai/objectstack#22444), built the way `ObjectChartBlockSchema` is: `@objectstack/spec` has no `ComponentPropsMap['list-view']` row, so the bag's members are the flat `ListViewSchema` mirror's own, by reference, with three differences the ruling makes: the bag's `type` is the list kind (the spec's own view-kind enum), and `objectName` and `viewType` are refused by name, pointing at `properties.data` and `properties.type`, in the bag and written flat alike. The spec's list view checks run in the bag, by reference: `checkListViewCalendarVisualization`, and `checkListViewChartBinding`, which the flat mirror cannot attach because its kind is `viewType`; so does objectui's dataset-chart filter refusal. The record source is `properties.data` or the node's `dataSource` binding naming the object (`RECORD_SOURCE_REQUIRED` at `properties.data` otherwise); `properties.objectName` is not one. Every other list view member written flat is refused by name toward `properties.KEY`; the five runtime slots `ListView` reads (`onAddRecord`, `onBulkAction`, `onDensityChange`, `onNavigate`, `onPageSizeChange`) keep their own refusal, and both content channels are refused. `ListViewSchema` stays exported as the `ListView` component's props; it is no longer an arm of `AnyComponentSchema`. +`ListViewBlockSchema` is the authored page `list-view` node (objectui#12670, ruling C on objectstack-ai/objectstack#22444), built the way `ObjectChartBlockSchema` is: `@objectstack/spec` has no `ComponentPropsMap['list-view']` row, so the bag's members are the flat `ListViewSchema` mirror's own, by reference, with three differences the ruling makes: the bag's `type` is the list kind (the spec's own view-kind enum), and `objectName` and `viewType` are refused by name, pointing at `properties.data` and `properties.type`, in the bag and written flat alike. The spec's list view checks run in the bag, by reference: `checkListViewCalendarVisualization`, and `checkListViewChartBinding` and `checkListViewTimesheetBinding`, which the flat mirror cannot attach because its kind is `viewType`; so does objectui's dataset-chart filter refusal. The record source is `properties.data` or the node's `dataSource` binding naming the object (`RECORD_SOURCE_REQUIRED` at `properties.data` otherwise); `properties.objectName` is not one. Every other list view member written flat is refused by name toward `properties.KEY`; the five runtime slots `ListView` reads (`onAddRecord`, `onBulkAction`, `onDensityChange`, `onNavigate`, `onPageSizeChange`) keep their own refusal, and both content channels are refused. `ListViewSchema` stays exported as the `ListView` component's props; it is no longer an arm of `AnyComponentSchema`. - `ObjectMetricBlockSchema`, `ObjectMasterDetailFormBlockSchema`, `ObjectTimelineBlockSchema`, `ObjectFormBlockSchema`, `ObjectMapBlockSchema`, `ObjectChartBlockSchema`, `ObjectGanttBlockSchema`, `ObjectGridBlockSchema` - `ObjectPivotBlockSchema`, `EmbeddableFormBlockSchema`, `ListViewBlockSchema` diff --git a/ui/packages/types/src/zod/objectql.zod.ts b/ui/packages/types/src/zod/objectql.zod.ts index c023fe68f0a..c0275ed3f02 100644 --- a/ui/packages/types/src/zod/objectql.zod.ts +++ b/ui/packages/types/src/zod/objectql.zod.ts @@ -88,6 +88,7 @@ import { // attachable there; in the authored `list-view` node's bag the kind is the // spec's own `type`, so `ListViewPropsBag` below attaches it. checkListViewChartBinding, + checkListViewTimesheetBinding, } from '@objectstack/spec/ui'; // objectui#11266 — one inline master-detail grid column, the closed shape // `@objectstack/spec` 17.6.0 judges `FormViewSchema.subforms[].columns` by @@ -5390,10 +5391,11 @@ function checkListViewBagDatasetChartFilter( * instead: `properties.data` and `properties.type`. ⛔ No fallback * acceptance and no second spelling. * - * The spec's two object-level list view checks are attached, both by + * The spec's three object-level list view checks are attached, each by * reference: `checkListViewCalendarVisualization`, as on the flat mirror, and - * `checkListViewChartBinding`, which the flat mirror cannot attach (its view - * kind is `viewType`) and the bag can, because its `type` is the spec's. So is + * `checkListViewChartBinding` and `checkListViewTimesheetBinding`, which the + * flat mirror cannot attach (its view kind is `viewType`) and the bag can, + * because its `type` is the spec's. So is * objectui's own dataset-chart filter refusal, read in the bag * ({@link checkListViewBagDatasetChartFilter}). * @@ -5408,7 +5410,7 @@ const ListViewPropsBag = z .extend({ type: ViewKindEnum.optional().describe( 'The list kind — `@objectstack/spec`\'s list view `type` (grid, kanban, gallery, calendar, timeline, gantt, ' - + 'map, chart, tree), by reference. Absent, the list is a grid, or the kind of the saved view the node\'s ' + + 'map, chart, tree, timesheet), by reference. Absent, the list is a grid, or the kind of the saved view the node\'s ' + '`dataSource.view` names.', ), objectName: aliasKeyRefusal('objectName', 'properties.data', 'a page `list-view` node', LIST_VIEW_PAGE_OBJECT_NAME_RETIRED), @@ -5416,6 +5418,7 @@ const ListViewPropsBag = z }) .superRefine(checkListViewCalendarVisualization) .superRefine(checkListViewChartBinding) + .superRefine(checkListViewTimesheetBinding) .superRefine(checkListViewBagDatasetChartFilter); /** From eb6f5e2cca142949012cff1b5a4574a83c2c0d70 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 22:33:40 +0000 Subject: [PATCH 17/18] chore(spec): regenerate artefacts on the merged tree Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- content/docs/references/api/protocol.mdx | 3 ++- content/docs/references/data/object.mdx | 1 + content/docs/references/index.mdx | 10 +++++----- packages/spec/api-surface/ui.json | 2 ++ packages/spec/authorable-surface/ui.json | 5 +++++ packages/spec/declaration-map/ui.json | 2 ++ packages/spec/export-origins/ui.json | 2 ++ packages/spec/json-schema.manifest/ui.json | 1 + 8 files changed, 20 insertions(+), 6 deletions(-) diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 89a65f1ca4a..4d721aa68d4 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1504,6 +1504,7 @@ This schema accepts one of the following structures: | **member** | `string` | optional | Bundle member selector, for a metadata type whose identity is a pair (today only `email_template`, identified by `(name, locale)`): the member this request addresses, spelled as its discriminator value (`zh-CN`). Absent, the canonical member (`en-US` for `email_template`), which is what a bare-name read answers; naming the canonical value is the same request. It is not the response translation locale, which `?locale=` and `Accept-Language` choose. Refused with 400 `VALIDATION_ERROR` on a type that has no members, and for a blank value or one longer than a stored member can be (100 characters). A well-formed member with nothing stored or shipped answers as that door answers an absent item. | | **state** | `Enum<'active' \| 'draft'>` | optional | Draft-visibility switch — which lifecycle row to read (strict mode): `'draft'` opens the pending draft buffer (Studio's editor read) and fails when no draft exists; absent or `'active'` reads the live published row. Distinct from `previewDrafts`, which FALLS BACK to the active row when no draft exists. Declaration ≠ authorization: this member only selects which stored row is read — ADR-0106 masking is unaffected, and draft access is gated upstream, not by this schema. | | **previewDrafts** | `boolean` | optional | Draft-visibility switch (ADR-0033 draft-overlay preview, non-strict): when true and `state` is not `'draft'`, a pending draft row is preferred if one exists, else the read falls back to the active row — the render path degrades to the published value instead of erroring. A served draft is tagged `_draft: true` so UIs can badge it. Declaration ≠ authorization: this member only switches which row is read, and ADR-0106 masking is unaffected — draft preview is admin-gated upstream, not by this schema. | +| **userTextLocales** | `string[]` | optional | The locales the user-facing sentences of a served DRAFT's check findings are composed in, in ladder order: the locale the request names, then the workspace default — the save request's member of the same name, read the same way (each value against the platform locale table, whole and then one subtag shorter at a time; a value that names no table language is passed over; `en` is the last rung). Read only by the `state: 'draft'` read, which folds what publishing the draft would say into its `_diagnostics`: an advisory finding that carries a user sentence becomes a `_diagnostics.warnings[]` entry in that sentence. Stated by the door that holds the request (the REST door and the dispatcher state `[ExecutionContext.locale, ExecutionContext.workspaceLocale]`), never read from a query string. ABSENT ⇒ the sentences are composed in `en`. It selects a language only: which row is read, and what the verdict is, do not depend on it. | --- @@ -1530,7 +1531,7 @@ This schema accepts one of the following structures: | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off under Setup › Packaged Actions): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off through the activation door, for example on the action in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | diff --git a/content/docs/references/data/object.mdx b/content/docs/references/data/object.mdx index dc79dc87584..449d8e7a499 100644 --- a/content/docs/references/data/object.mdx +++ b/content/docs/references/data/object.mdx @@ -501,6 +501,7 @@ const result = ApiMethod.parse(data); | **target** | `string` | optional | URL, Script Name, Flow ID, or API Endpoint. Supports $`{param.X}` and $`{ctx.X}` interpolation. For type:'url': an http:// or https:// URL, a mailto: address, or an in-app path starting with / or ./ (a console route; a record is /apps/APP/OBJECT/record/ID, APP being the app's route segment — see onSuccess.navigate) — every other scheme and a protocol-relative //host are refused. | | **openIn** | `Enum<'self' \| 'new-tab'>` | optional | For type:'url' — where to open `target`. 'new-tab' opens a new browser tab; 'self' navigates in place. When omitted, external/absolute URLs open in a new tab and relative URLs navigate in place. Static execution option — keep it OUT of `params` (which is user-input-collection only). | | **body** | `{ language: 'expression'; source: string } \| { language: 'js'; source: string; capabilities?: Enum<'api.read' \| 'api.write' \| 'api.transaction' \| 'crypto.uuid' \| 'log' \| …>[]; timeoutMs?: integer; … }` | optional | Action body — expression (L1) or sandboxed JS (L2). Only used when type is `script`. An action body runs as system, and its update, transfer, delete, purge or restore of an object declared managedBy: 'append-only' is refused with PERMISSION_DENIED; an insert is not judged by this rule. | +| **refusals** | `Record; params?: string[] }>` | optional | Refusal catalogue keyed by the SCREAMING_SNAKE code the action's js body throws: `{ message, status?, reasons?, params? }`. The body refuses by code only, optionally with a declared reason and params; the runtime answers with the declared message (translated through objects.``._actions.``.refusals.``.message, or globalActions.``.refusals.``.message for an object-less action, ….reasons.``.message for a reason, in the caller's locale, holes filled from params) and status. A code not declared here, or a reason a code with reasons does not declare, is refused loudly — at save when the body throws it literally, otherwise at run time. Only a type: 'script' action with a js body declares one | | **operation** | `Enum<'update'>` | optional | The declarative single-record field write, mirroring a list view's `bulkActionDefs`: `'update'` applies `patch` (merged under the collected `params`) to the current record on the data plane AS THE CALLER — never system-elevated — so the caller's permissions, the object's hooks and its validations fire as for a user edit. `type` stays at its default `'script'` (the platform action route the write is performed on); `target`/`body`/`method`/`bodyExtra` are refused beside it. `'delete'` and `'custom'` have no row-level form. | | **patch** | `Record` | optional | For `operation: 'update'` — static field values written to the current record, merged UNDER the user-supplied `params` so a fixed value can be declared without exposing it in the dialog. Written on the data plane as the caller: object permissions, hooks and validations fire as for a user edit. Refused on an action without `operation: 'update'` (it would be silently dropped). | | **execution** | `Enum<'perRecord' \| 'aggregate'>` | optional | The bulk dispatch contract this action's BODY is written for, in `bulkActionDefs`' own vocabulary: 'perRecord' = one dispatch per selected row carrying that row's `recordId` (the view's `bulkActions: ['']` bare-string form); 'aggregate' = ONE dispatch for the whole selection carrying every id in `params._selectedIds` (a `bulkActionDefs` entry with `execution: 'aggregate'`). Optional with NO default — omit it only when the body genuinely serves both. A list view wiring a declared action under the other contract is refused by `@objectstack/lint` (`action-dispatch-contract-mismatch`). | diff --git a/content/docs/references/index.mdx b/content/docs/references/index.mdx index d0d461c2b0e..f044cb67419 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 — 1671 schemas across 14 protocol modules +description: Every schema published by @objectstack/spec — 1672 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 | 297 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. | -| [UI Protocol](/docs/references/ui) | 16 | 178 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | -| **Total** | **218** | **1671** | 14 protocol modules | +| [UI Protocol](/docs/references/ui) | 16 | 179 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | +| **Total** | **218** | **1672** | 14 protocol modules | --- @@ -385,13 +385,13 @@ The runtime environment — logging, jobs, cache, metrics, notifications, i18n a ## UI Protocol -**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 178 schemas** +**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 179 schemas** Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | File | Schemas | | :--- | :--- | -| [`action.zod.ts`](/docs/references/ui/action) | `Action`, `ActionAi`, `ActionLocation`, `ActionParam`, `ActionType`, `InlineAction` | +| [`action.zod.ts`](/docs/references/ui/action) | `Action`, `ActionAi`, `ActionLocation`, `ActionParam`, `ActionRefusal`, `ActionType`, `InlineAction` | | [`action-params.zod.ts`](/docs/references/ui/action-params) | `ActionSession` | | [`app.zod.ts`](/docs/references/ui/app) | `ActionNavItem`, `App`, `AppBranding`, `AppContextSelector`, `AppLandingEntry`, `ComponentNavItem`, `DashboardNavItem`, `DocNavItem`, `GroupNavItem`, `NavigationArea`, `NavigationContribution`, `NavigationItem`, `ObjectNavItem`, `PageNavItem`, `ReportNavItem`, `UrlNavItem` | | [`bulk-action.zod.ts`](/docs/references/ui/bulk-action) | `BulkActionDef`, `BulkActionExecution`, `BulkActionOperation`, `BulkActionParam`, `BulkActionResult` | diff --git a/packages/spec/api-surface/ui.json b/packages/spec/api-surface/ui.json index f3e37a151a8..d9d95241a60 100644 --- a/packages/spec/api-surface/ui.json +++ b/packages/spec/api-surface/ui.json @@ -40,6 +40,8 @@ "ActionParamParsed (type)", "ActionParamSchema (const)", "ActionParsed (type)", + "ActionRefusal (type)", + "ActionRefusalSchema (const)", "ActionSchema (const)", "ActionSession (type)", "ActionSessionSchema (const)", diff --git a/packages/spec/authorable-surface/ui.json b/packages/spec/authorable-surface/ui.json index b88629c064b..084e7bae6b9 100644 --- a/packages/spec/authorable-surface/ui.json +++ b/packages/spec/authorable-surface/ui.json @@ -44,6 +44,7 @@ "ui/Action:recordIdField", "ui/Action:recordIdParam", "ui/Action:refreshAfter", + "ui/Action:refusals", "ui/Action:requiredPermissions", "ui/Action:requiresFeature", "ui/Action:requiresMembershipReach", @@ -160,6 +161,10 @@ "ui/ActionParam:type", "ui/ActionParam:visible", "ui/ActionParam:widget", + "ui/ActionRefusal:message", + "ui/ActionRefusal:params", + "ui/ActionRefusal:reasons", + "ui/ActionRefusal:status", "ui/ActionSession:organizationId", "ui/ActionSession:positions", "ui/ActionSession:roles", diff --git a/packages/spec/declaration-map/ui.json b/packages/spec/declaration-map/ui.json index c9677200761..cd76aad6299 100644 --- a/packages/spec/declaration-map/ui.json +++ b/packages/spec/declaration-map/ui.json @@ -19,6 +19,8 @@ "ActionNavItemSchema": "ui/ActionNavItem", "ActionParam": "ui/ActionParam", "ActionParamSchema": "ui/ActionParam", + "ActionRefusal": "ui/ActionRefusal", + "ActionRefusalSchema": "ui/ActionRefusal", "ActionSchema": "ui/Action", "ActionSession": "ui/ActionSession", "ActionSessionSchema": "ui/ActionSession", diff --git a/packages/spec/export-origins/ui.json b/packages/spec/export-origins/ui.json index 8d7de30a1ad..1e5d15a72c3 100644 --- a/packages/spec/export-origins/ui.json +++ b/packages/spec/export-origins/ui.json @@ -39,6 +39,8 @@ "ActionParamParsed": "src/ui/action.zod.ts#ActionParamParsed (type)", "ActionParamSchema": "src/ui/action.zod.ts#ActionParamSchema (const)", "ActionParsed": "src/ui/action.zod.ts#ActionParsed (type)", + "ActionRefusal": "src/ui/action.zod.ts#ActionRefusal (type)", + "ActionRefusalSchema": "src/ui/action.zod.ts#ActionRefusalSchema (const)", "ActionSchema": "src/ui/action.zod.ts#ActionSchema (const)", "ActionSession": "src/ui/action-params.zod.ts#ActionSession (type)", "ActionSessionSchema": "src/ui/action-params.zod.ts#ActionSessionSchema (const)", diff --git a/packages/spec/json-schema.manifest/ui.json b/packages/spec/json-schema.manifest/ui.json index 6ed37637412..2a8ec8ea85d 100644 --- a/packages/spec/json-schema.manifest/ui.json +++ b/packages/spec/json-schema.manifest/ui.json @@ -11,6 +11,7 @@ "ui/ActionMenuProps", "ui/ActionNavItem", "ui/ActionParam", + "ui/ActionRefusal", "ui/ActionSession", "ui/ActionType", "ui/AddRecordConfig", From ac061cea79e90bf5eafbbc06f9f236ccf8b6b9f0 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 00:10:50 +0000 Subject: [PATCH 18/18] chore(spec): regenerate artefacts on the merged tree Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgTk2cRpVHpSVk9tzF --- content/docs/references/index.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/docs/references/index.mdx b/content/docs/references/index.mdx index f044cb67419..e8e0464e67d 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 — 1672 schemas across 14 protocol modules +description: Every schema published by @objectstack/spec — 1674 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/. */} @@ -20,7 +20,7 @@ counts are sums of the rows they head. Regenerate with | Module | Pages | Schemas | Description | | :--- | ---: | ---: | :--- | -| [AI Protocol](/docs/references/ai) | 14 | 82 | Agents, tools, skills, RAG and knowledge sources, model registry, conversations. | +| [AI Protocol](/docs/references/ai) | 14 | 84 | Agents, tools, skills, RAG and knowledge sources, model registry, conversations. | | [API Protocol](/docs/references/api) | 36 | 496 | REST contracts, endpoints, routing, realtime, batch, discovery. | | [Automation Protocol](/docs/references/automation) | 16 | 82 | Flows and their nodes, approvals, ETL pipelines, webhooks, state machines, execution records. | | [Data Protocol](/docs/references/data) | 35 | 188 | Objects, fields, queries, filters, datasources and drivers — the ObjectQL layer. | @@ -34,13 +34,13 @@ counts are sums of the rows they head. Regenerate with | [Studio Protocol](/docs/references/studio) | 3 | 35 | Studio designer metadata — the authoring surfaces for the protocols above. | | [System Protocol](/docs/references/system) | 40 | 297 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. | | [UI Protocol](/docs/references/ui) | 16 | 179 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | -| **Total** | **218** | **1672** | 14 protocol modules | +| **Total** | **218** | **1674** | 14 protocol modules | --- ## AI Protocol -**Source:** `packages/spec/src/ai/` · **Import:** `@objectstack/spec/ai` · **14 pages, 82 schemas** +**Source:** `packages/spec/src/ai/` · **Import:** `@objectstack/spec/ai` · **14 pages, 84 schemas** Agents, tools, skills, RAG and knowledge sources, model registry, conversations. @@ -49,7 +49,7 @@ Agents, tools, skills, RAG and knowledge sources, model registry, conversations. | [`agent.zod.ts`](/docs/references/ai/agent) | `AIModelConfig`, `Agent`, `StructuredOutputConfig`, `StructuredOutputFormat`, `TransformPipelineStep` | | [`build-progress.zod.ts`](/docs/references/ai/build-progress) | `BuildProgressFrame`, `BuildProgressPhase` | | [`conversation.zod.ts`](/docs/references/ai/conversation) | `CodeContent`, `ConversationAnalytics`, `ConversationContext`, `ConversationMessage`, `ConversationSession`, `ConversationSummary`, `FileContent`, `FunctionCall`, `ImageContent`, `MessageContent`, `MessageContentType`, `MessagePruningEvent`, `MessageRole`, `TextContent`, `TokenBudgetConfig`, `TokenBudgetStrategy`, `TokenUsageStats`, `ToolCall` | -| [`dataset-tools.zod.ts`](/docs/references/ai/dataset-tools) | `DatasetProvenance`, `DatasetTermCandidate`, `DatasetTermMatch`, `DatasetTermMatchedOn`, `DatasetToolCatalogDimension`, `DatasetToolCatalogEntry`, `DatasetToolCatalogMeasure`, `ListDatasetsInput`, `ListDatasetsOutput`, `QueryDatasetInput`, `QueryDatasetOutput` | +| [`dataset-tools.zod.ts`](/docs/references/ai/dataset-tools) | `DatasetNextStep`, `DatasetNextStepDecision`, `DatasetProvenance`, `DatasetTermCandidate`, `DatasetTermMatch`, `DatasetTermMatchedOn`, `DatasetToolCatalogDimension`, `DatasetToolCatalogEntry`, `DatasetToolCatalogMeasure`, `ListDatasetsInput`, `ListDatasetsOutput`, `QueryDatasetInput`, `QueryDatasetOutput` | | [`embedding.zod.ts`](/docs/references/ai/embedding) | `EmbeddingModel`, `VectorStore`, `VectorStoreProvider` | | [`knowledge-document.zod.ts`](/docs/references/ai/knowledge-document) | `KnowledgeChunk`, `KnowledgeDocument`, `KnowledgeHit` | | [`knowledge-source.zod.ts`](/docs/references/ai/knowledge-source) | `FileKnowledgeSource`, `HttpKnowledgeSource`, `KnowledgeRefreshPolicy`, `KnowledgeSource`, `KnowledgeSourceKind`, `ObjectKnowledgeSource` |