Skip to content

Commit 9a77f0a

Browse files
committed
feat(types): derive object-form/object-calendar spec keys, rename the legacy zod ActionSchema
Work item 4 of #25923. ObjectFormSchema gains contentLayout and confirmOnDiscard, ObjectCalendarSchema gains locale and loading, each the ComponentPropsMap row member by reference on both faces. The zod ActionSchema (legacy type: 'action' node) is renamed CRUDActionSchema so @object-ui/types/zod no longer publishes the spec's ActionSchema name for an unrelated contract. zod-mirror-parity.test.ts gains the spec-only census over the derived spec pairs. Claude-Session: https://claude.ai/code/session_01WGufzhgTn8yFwqXxanJd4c Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4373103 commit 9a77f0a

13 files changed

Lines changed: 277 additions & 48 deletions

‎ui/content/docs/core/enhanced-actions.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ const complexAction: ActionSchema = {
483483
## Runtime Validation
484484

485485
```ts
486-
import { ActionSchema } from '@object-ui/types/zod';
486+
import { CRUDActionSchema } from '@object-ui/types/zod';
487487

488488
const myAction = {
489489
type: 'action',
@@ -492,7 +492,7 @@ const myAction = {
492492
confirmText: 'Are you sure?',
493493
};
494494

495-
const result = ActionSchema.safeParse(myAction);
495+
const result = CRUDActionSchema.safeParse(myAction);
496496

497497
if (result.success) {
498498
console.log('Valid action configuration');

‎ui/content/docs/guide/schema-overview.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ For runtime validation, use the included Zod schemas:
187187
```typescript
188188
import {
189189
AppComponentSchema,
190-
ActionSchema,
190+
CRUDActionSchema,
191191
ReportComponentSchema
192192
} from '@object-ui/types/zod';
193193

‎ui/packages/types/src/__tests__/action-callback-retired-7068.test.ts‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import ts from 'typescript';
5959
import { ActionSchema as SpecActionSchema } from '@objectstack/spec/ui';
6060
import * as crudZod from '../zod/crud.zod.js';
6161
import * as zodBarrel from '../zod/index.zod.js';
62-
import { ActionSchema, DetailSchema } from '../zod/crud.zod.js';
62+
import { CRUDActionSchema, DetailSchema } from '../zod/crud.zod.js';
6363
import { BaseSchema } from '../zod/base.zod.js';
6464
import { safeValidateSchema } from '../zod/index.zod.js';
6565
import type { ActionSchema as ActionSchemaTS } from '../crud.js';
@@ -105,9 +105,9 @@ type Issue = { code: string; path: PropertyKey[]; message: string; expected?: st
105105
const flatIssues = (issues: Issue[]): Issue[] =>
106106
issues.flatMap((i) => (i.code === 'invalid_union' && i.errors ? i.errors.flat().flatMap((e) => flatIssues([e])) : [i]));
107107

108-
/** The lazy mirror's object shape — `ActionSchema` is `z.lazy(() => BaseSchema.extend(…))`. */
108+
/** The lazy mirror's object shape — `CRUDActionSchema` is `z.lazy(() => BaseSchema.extend(…))`. */
109109
const actionShape = (): Record<string, { description?: string }> =>
110-
(ActionSchema as unknown as { _def: { getter: () => { shape: Record<string, { description?: string }> } } })._def.getter().shape;
110+
(CRUDActionSchema as unknown as { _def: { getter: () => { shape: Record<string, { description?: string }> } } })._def.getter().shape;
111111

112112
/* ── the Zod half: refused BY NAME, with the guidance in the message ─────── */
113113

@@ -120,7 +120,7 @@ describe.each([
120120
// .optional()`). Asserting the ENVELOPE — code, path, expected and the exact
121121
// message — so the pin cannot be satisfied by an unrelated rejection, and a
122122
// WELL-FORMED callback so it is the KEY that is refused, not its members.
123-
const result = ActionSchema.safeParse({ ...LEGACY_ACTION, [key]: value });
123+
const result = CRUDActionSchema.safeParse({ ...LEGACY_ACTION, [key]: value });
124124
expect(result.success, `an authored \`${key}\` was ACCEPTED`).toBe(false);
125125
if (result.success) return;
126126

@@ -157,7 +157,7 @@ describe.each([
157157
// exactly this acceptance, kept the callback unvalidated, and stayed green.
158158
const doc = { ...LEGACY_ACTION, [key]: CALLBACKS[0][1] };
159159
expect(BaseSchema.safeParse(doc).success).toBe(true);
160-
expect(ActionSchema.safeParse(doc).success).toBe(false);
160+
expect(CRUDActionSchema.safeParse(doc).success).toBe(false);
161161
});
162162

163163
it('keeps the key DECLARED, with the same guidance on `.describe()` — one string, both channels', () => {
@@ -171,34 +171,34 @@ describe.each([
171171

172172
describe('the retirement narrows exactly `onSuccess` / `onFailure` (objectui#7068)', () => {
173173
it('a legacy action WITHOUT the two keys still parses, and its values survive', () => {
174-
const result = ActionSchema.safeParse(LEGACY_ACTION);
174+
const result = CRUDActionSchema.safeParse(LEGACY_ACTION);
175175
expect(result.success).toBe(true);
176176
if (!result.success) return;
177177
expect(result.data.api).toBe('/api/data');
178178
});
179179

180180
it('control: the adjacent `successMessage` / `errorMessage` — NOT retired — still parse and survive', () => {
181-
const result = ActionSchema.safeParse({ ...LEGACY_ACTION, successMessage: 'Loaded', errorMessage: 'Failed' });
181+
const result = CRUDActionSchema.safeParse({ ...LEGACY_ACTION, successMessage: 'Loaded', errorMessage: 'Failed' });
182182
expect(result.success).toBe(true);
183183
if (!result.success) return;
184184
expect(result.data.successMessage).toBe('Loaded');
185185
expect(result.data.errorMessage).toBe('Failed');
186186
});
187187

188188
it('control: the mirror did not stop validating — a wrong-typed `successMessage` is still refused', () => {
189-
const result = ActionSchema.safeParse({ ...LEGACY_ACTION, successMessage: 42 });
189+
const result = CRUDActionSchema.safeParse({ ...LEGACY_ACTION, successMessage: 42 });
190190
expect(result.success).toBe(false);
191191
if (result.success) return;
192192
expect(result.error.issues.map((i) => i.path.join('.'))).toContain('successMessage');
193193
});
194194

195195
it('control: `chain` and `redirect` — the declared follow-up and post-action keys — still parse', () => {
196-
const result = ActionSchema.safeParse({ ...LEGACY_ACTION, chain: [{ type: 'action', label: 'Next' }], redirect: '/done' });
196+
const result = CRUDActionSchema.safeParse({ ...LEGACY_ACTION, chain: [{ type: 'action', label: 'Next' }], redirect: '/done' });
197197
expect(result.success).toBe(true);
198198
});
199199

200200
it('an UNDECLARED key still rides `.passthrough()` — the contrast the tombstones exist for, measured live', () => {
201-
const result = ActionSchema.safeParse({ ...LEGACY_ACTION, notAKeyAtAll: 'anything' });
201+
const result = CRUDActionSchema.safeParse({ ...LEGACY_ACTION, notAKeyAtAll: 'anything' });
202202
expect(result.success).toBe(true);
203203
if (!result.success) return;
204204
expect((result.data as unknown as Record<string, unknown>).notAKeyAtAll).toBe('anything');
@@ -212,7 +212,7 @@ describe('`ActionCallback` / `ActionCallbackSchema` are DELETED, not tombstoned
212212
expect('ActionCallbackSchema' in crudZod).toBe(false);
213213
expect('ActionCallbackSchema' in zodBarrel).toBe(false);
214214
// Non-vacuity: the neighbours the barrel still carries.
215-
expect('ActionSchema' in crudZod).toBe(true);
215+
expect('CRUDActionSchema' in crudZod).toBe(true);
216216
expect('ActionExecutionModeSchema' in zodBarrel).toBe(true);
217217
});
218218

‎ui/packages/types/src/__tests__/disabled-twin-symmetry-7087.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import type {
9595
ToggleSchema,
9696
} from '../form';
9797

98-
import { ActionSchema as ActionMirror } from '../zod/crud.zod';
98+
import { CRUDActionSchema as ActionMirror } from '../zod/crud.zod';
9999
import {
100100
AccordionItemSchema,
101101
CollapsibleSchema as CollapsibleMirror,
@@ -199,7 +199,7 @@ const IN_SCOPE: readonly MirrorCase[] = [
199199
{ name: 'form.zod.ts#InputOTPSchema', mirror: FormMirrors.InputOTPSchema, fixture: { type: 'input-otp' } },
200200
{ name: 'form.zod.ts#FormSchema', mirror: FormMirrors.FormSchema, fixture: { type: 'form', fields: [{ name: 'title', type: 'text' }] } },
201201
{ name: 'form.zod.ts#ComboboxSchema', mirror: FormMirrors.ComboboxSchema, fixture: { type: 'combobox', options: [{ label: 'A', value: 'a' }] } },
202-
{ name: 'crud.zod.ts#ActionSchema', mirror: ActionMirror, fixture: { type: 'action', label: 'Save' } },
202+
{ name: 'crud.zod.ts#CRUDActionSchema', mirror: ActionMirror, fixture: { type: 'action', label: 'Save' } },
203203
{
204204
name: 'disclosure.zod.ts#CollapsibleSchema',
205205
mirror: CollapsibleMirror,

‎ui/packages/types/src/__tests__/duration-unit-key-renames-25762.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import type { ToastSchema as ToastInterface } from '../feedback';
3737
import type { HoverCardSchema as HoverCardInterface, TooltipSchema as TooltipInterface } from '../overlay';
3838
import type { ReportComponentSchema as ReportInterface } from '../reports';
3939
import {
40-
ActionSchema,
40+
CRUDActionSchema,
4141
CarouselSchema,
4242
ChatbotEnhancedSchema,
4343
ChatbotFloatingSchema,
@@ -70,8 +70,8 @@ const CASES: readonly RenameCase[] = [
7070
{ schema: ChatbotSchema, base: { type: 'chatbot', messages: [] }, at: [], retired: 'autoResponseDelay', renamed: 'autoResponseDelayMs', unit: 'milliseconds' },
7171
{ schema: ChatbotEnhancedSchema, base: { type: 'chatbot-enhanced', messages: [] }, at: [], retired: 'autoResponseDelay', renamed: 'autoResponseDelayMs', unit: 'milliseconds' },
7272
{ schema: ChatbotFloatingSchema, base: { type: 'chatbot-floating', messages: [] }, at: [], retired: 'autoResponseDelay', renamed: 'autoResponseDelayMs', unit: 'milliseconds' },
73-
{ schema: ActionSchema, base: { type: 'action', label: 'Go' }, at: [], retired: 'timeout', renamed: 'timeoutMs', unit: 'milliseconds' },
74-
{ schema: ActionSchema, base: { type: 'action', label: 'Go', retry: { maxAttempts: 2 } }, at: ['retry'], retired: 'delay', renamed: 'delayMs', unit: 'milliseconds' },
73+
{ schema: CRUDActionSchema, base: { type: 'action', label: 'Go' }, at: [], retired: 'timeout', renamed: 'timeoutMs', unit: 'milliseconds' },
74+
{ schema: CRUDActionSchema, base: { type: 'action', label: 'Go', retry: { maxAttempts: 2 } }, at: ['retry'], retired: 'delay', renamed: 'delayMs', unit: 'milliseconds' },
7575
{ schema: ToastSchema, base: { type: 'toast' }, at: [], retired: 'duration', renamed: 'durationMs', unit: 'milliseconds' },
7676
{ schema: TooltipSchema, base: { type: 'tooltip', content: 'Hi' }, at: [], retired: 'delayDuration', renamed: 'delayDurationMs', unit: 'milliseconds' },
7777
{ schema: HoverCardSchema, base: { type: 'hover-card', ...node }, at: [], retired: 'openDelay', renamed: 'openDelayMs', unit: 'milliseconds' },

‎ui/packages/types/src/__tests__/handler-keys-string-any-mirrors-7344.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ import { z } from 'zod';
157157

158158
import { CalendarViewSchema as CalendarViewZod } from '../zod/complex.zod';
159159
import {
160-
ActionSchema as ActionZod,
160+
CRUDActionSchema as ActionZod,
161161
CRUDDialogSchema as CRUDDialogZod,
162162
DetailSchema as DetailZod,
163163
} from '../zod/crud.zod';
@@ -191,7 +191,7 @@ const objectOf = (mirror: z.ZodType, key: string): z.ZodObject<z.ZodRawShape> =>
191191
/** The six keys whose function value REACHES a renderer (channels above). */
192192
const RUNTIME_SLOT: readonly Site[] = [
193193
['views.zod.ts', 'DetailViewSchema', 'onBack', DetailViewZod],
194-
['crud.zod.ts', 'ActionSchema', 'onClick', ActionZod],
194+
['crud.zod.ts', 'CRUDActionSchema', 'onClick', ActionZod],
195195
['crud.zod.ts', 'DetailSchema', 'onBack', DetailZod],
196196
// objectui#7804 — the two keys `DetailView` reads off a `'detail'` document
197197
// that its arm never declared. They arrive by a DIFFERENT route from the four

‎ui/packages/types/src/__tests__/phase2-schemas.test.ts‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
AppComponentSchema,
99
ReportComponentSchema,
1010
ReportBuilderSchema,
11-
ActionSchema,
11+
CRUDActionSchema,
1212
DetailViewSchema,
1313
ViewSwitcherSchema,
1414
FilterUISchema,
@@ -364,7 +364,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
364364
errorMessage: 'Failed to load data',
365365
};
366366

367-
const result = ActionSchema.safeParse(ajaxAction);
367+
const result = CRUDActionSchema.safeParse(ajaxAction);
368368
expect(result.success).toBe(true);
369369
});
370370

@@ -378,7 +378,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
378378
method: 'DELETE',
379379
};
380380

381-
const result = ActionSchema.safeParse(confirmAction);
381+
const result = CRUDActionSchema.safeParse(confirmAction);
382382
expect(result.success).toBe(true);
383383
});
384384

@@ -394,7 +394,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
394394
// value is a LOUD parse rejection — never a silent strip, which would let
395395
// the author believe the dialog they configured exists. Absent stays
396396
// valid (accept case above).
397-
const result = ActionSchema.safeParse(structured);
397+
const result = CRUDActionSchema.safeParse(structured);
398398
expect(result.success).toBe(false);
399399
if (!result.success) {
400400
expect(result.error.issues.map((i) => i.path.join('.'))).toContain('confirm');
@@ -408,7 +408,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
408408
// nothing else. The author now reads the remedy (`confirmText`) in the
409409
// message itself, which is what `packages/cli`'s `validate` / `check`
410410
// print verbatim beside the path and code.
411-
const result = ActionSchema.safeParse({
411+
const result = CRUDActionSchema.safeParse({
412412
type: 'action',
413413
label: 'Delete Record',
414414
actionType: 'confirm',
@@ -427,7 +427,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
427427

428428
// Non-vacuity, IN THIS TEST: the canonical spelling still parses green.
429429
expect(
430-
ActionSchema.safeParse({ type: 'action', label: 'Delete Record', confirmText: 'Sure?' }).success,
430+
CRUDActionSchema.safeParse({ type: 'action', label: 'Delete Record', confirmText: 'Sure?' }).success,
431431
).toBe(true);
432432
});
433433

@@ -462,7 +462,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
462462
},
463463
};
464464

465-
const result = ActionSchema.safeParse(dialogAction);
465+
const result = CRUDActionSchema.safeParse(dialogAction);
466466
expect(result.success).toBe(true);
467467
});
468468

@@ -492,7 +492,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
492492
chainMode: 'sequential',
493493
};
494494

495-
const result = ActionSchema.safeParse(chainedAction);
495+
const result = CRUDActionSchema.safeParse(chainedAction);
496496
expect(result.success).toBe(true);
497497
});
498498

@@ -516,7 +516,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
516516
condition,
517517
};
518518

519-
const result = ActionSchema.safeParse(gatedAction);
519+
const result = CRUDActionSchema.safeParse(gatedAction);
520520
expect(result.success).toBe(true);
521521
});
522522

@@ -549,7 +549,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
549549
},
550550
};
551551

552-
const result = ActionSchema.safeParse(branchAction);
552+
const result = CRUDActionSchema.safeParse(branchAction);
553553
expect(result.success).toBe(false);
554554
if (result.success) return;
555555
const issues = result.error.issues.filter((i) => i.path[0] === 'condition');
@@ -573,7 +573,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
573573
},
574574
};
575575

576-
const result = ActionSchema.safeParse(trackedAction);
576+
const result = CRUDActionSchema.safeParse(trackedAction);
577577
expect(result.success).toBe(true);
578578
});
579579

@@ -590,7 +590,7 @@ describe('Phase 2: Enhanced ActionSchema Zod Validation', () => {
590590
},
591591
};
592592

593-
const result = ActionSchema.safeParse(retryAction);
593+
const result = CRUDActionSchema.safeParse(retryAction);
594594
expect(result.success).toBe(true);
595595
});
596596
});

‎ui/packages/types/src/__tests__/zod-lazy-getter-identity-7918.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
import { describe, it, expect } from 'vitest';
105105
import { z } from 'zod';
106106
import {
107-
ActionSchema,
107+
CRUDActionSchema,
108108
AppMenuItemSchema,
109109
FilterBuilderConditionSchema,
110110
FilterGroupSchema,
@@ -143,7 +143,7 @@ const MEMOISED: ReadonlyArray<readonly [string, unknown]> = [
143143
];
144144
/** ⛔ Do not "fix" these — each one's `z.lazy` dodges a real ReferenceError. */
145145
const TDZ_BOUND: ReadonlyArray<readonly [string, unknown]> = [
146-
['ActionSchema', ActionSchema],
146+
['CRUDActionSchema', CRUDActionSchema],
147147
['AppMenuItemSchema', AppMenuItemSchema],
148148
['MenuItemSchema', MenuItemSchema],
149149
['NavLinkSchema', NavLinkSchema],

0 commit comments

Comments
 (0)