@viyv/agent-ui-schema 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viyv/agent-ui-schema",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -225,6 +225,62 @@ describe('PageSpecSchema', () => {
225
225
  expect(result.success).toBe(true);
226
226
  });
227
227
 
228
+ it('accepts parentId as string', () => {
229
+ const spec = {
230
+ id: 'child-page',
231
+ parentId: 'parent-page',
232
+ title: 'Child Page',
233
+ root: 'root',
234
+ elements: { root: { type: 'Stack', props: {} } },
235
+ };
236
+ const result = PageSpecSchema.safeParse(spec);
237
+ expect(result.success).toBe(true);
238
+ if (result.success) {
239
+ expect(result.data.parentId).toBe('parent-page');
240
+ }
241
+ });
242
+
243
+ it('accepts parentId as null (detach from parent)', () => {
244
+ const spec = {
245
+ id: 'child-page',
246
+ parentId: null,
247
+ title: 'Child Page',
248
+ root: 'root',
249
+ elements: { root: { type: 'Stack', props: {} } },
250
+ };
251
+ const result = PageSpecSchema.safeParse(spec);
252
+ expect(result.success).toBe(true);
253
+ if (result.success) {
254
+ expect(result.data.parentId).toBeNull();
255
+ }
256
+ });
257
+
258
+ it('rejects empty string parentId', () => {
259
+ const spec = {
260
+ id: 'child-page',
261
+ parentId: '',
262
+ title: 'Child Page',
263
+ root: 'root',
264
+ elements: { root: { type: 'Stack', props: {} } },
265
+ };
266
+ const result = PageSpecSchema.safeParse(spec);
267
+ expect(result.success).toBe(false);
268
+ });
269
+
270
+ it('allows omitting parentId', () => {
271
+ const spec = {
272
+ id: 'standalone',
273
+ title: 'Standalone Page',
274
+ root: 'root',
275
+ elements: { root: { type: 'Stack', props: {} } },
276
+ };
277
+ const result = PageSpecSchema.safeParse(spec);
278
+ expect(result.success).toBe(true);
279
+ if (result.success) {
280
+ expect(result.data.parentId).toBeUndefined();
281
+ }
282
+ });
283
+
228
284
  it('rejects invalid hook definitions', () => {
229
285
  const spec = {
230
286
  id: 'test',
package/src/page-spec.ts CHANGED
@@ -24,6 +24,7 @@ export const PageMetaSchema = z.object({
24
24
 
25
25
  export const PageSpecSchema = z.object({
26
26
  id: z.string().min(1),
27
+ parentId: z.string().min(1).nullable().optional(),
27
28
  title: z.string().min(1),
28
29
  description: z.string().optional(),
29
30
  hooks: z.record(HookDefSchema).default({}),