@coveo/thermidor-schema 1.0.0-beta.1 → 1.0.0-beta.13

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.
Files changed (43) hide show
  1. package/README.md +32 -5
  2. package/dist/generated/schemas.d.ts +2547 -378
  3. package/dist/generated/schemas.js +689 -143
  4. package/dist/generated/zod3/schemas.d.ts +23821 -0
  5. package/dist/generated/zod3/schemas.js +1087 -0
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +1 -1
  8. package/dist/zod3/index.d.ts +3 -0
  9. package/dist/zod3/index.js +5 -0
  10. package/dist/zod3-compat.d.ts +79 -0
  11. package/dist/zod3-compat.js +82 -0
  12. package/package.json +26 -20
  13. package/schema/base/catalog.schema.json +3 -2
  14. package/schema/base/component.schema.json +24 -20
  15. package/schema/{components/component-contracts.schema.json → component-contracts.schema.json} +23 -5
  16. package/schema/components/bundle-display.schema.json +11 -6
  17. package/schema/components/cart.schema.json +85 -46
  18. package/schema/components/category-facet.schema.json +35 -24
  19. package/schema/components/commerce-search.schema.json +186 -0
  20. package/schema/components/comparison-table.schema.json +35 -11
  21. package/schema/components/date-facet.schema.json +39 -26
  22. package/schema/components/facet-manager.schema.json +16 -18
  23. package/schema/components/layout-stack.schema.json +50 -0
  24. package/schema/components/next-actions-bar.schema.json +16 -18
  25. package/schema/components/numeric-facet.schema.json +43 -26
  26. package/schema/components/page-size.schema.json +79 -0
  27. package/schema/components/pagination.schema.json +45 -19
  28. package/schema/components/product-carousel.schema.json +15 -7
  29. package/schema/components/product-list.schema.json +77 -7
  30. package/schema/components/product-research-card.schema.json +70 -0
  31. package/schema/components/product-summary.schema.json +64 -0
  32. package/schema/components/query-suggestions.schema.json +113 -0
  33. package/schema/components/query-summary.schema.json +76 -0
  34. package/schema/components/regular-facet.schema.json +42 -32
  35. package/schema/components/sort.schema.json +18 -18
  36. package/schema/definitions/bundle-tier.schema.json +9 -4
  37. package/schema/definitions/child-list.schema.json +32 -0
  38. package/schema/definitions/comparison-attribute.schema.json +2 -2
  39. package/schema/definitions/comparison-product.schema.json +2 -2
  40. package/schema/definitions/component-id.schema.json +9 -0
  41. package/schema/definitions/data-binding.schema.json +16 -0
  42. package/schema/components/search-box.schema.json +0 -74
  43. package/schema/definitions/cart-item.schema.json +0 -29
@@ -1,6 +1,7 @@
1
1
  // This file is generated from the canonical JSON Schema documents.
2
2
  // Do not edit it directly; run `mise run generate` from the repository root.
3
3
  import * as z from 'zod/v4';
4
+ export const CartUpdateOperationSchema = z.enum(['add', 'remove', 'setQuantity']);
4
5
  // The kind of action: "followup" triggers a conversational follow-up, "search" triggers a
5
6
  // standalone search.
6
7
  //
@@ -37,22 +38,42 @@ export const ProductSchema = z.strictObject({
37
38
  ec_thumbnails: z.array(z.url()).optional(),
38
39
  permanentid: z.string(),
39
40
  });
41
+ export const DataBindingSchema = z.strictObject({
42
+ path: z.string(),
43
+ });
44
+ export const ChildListClassSchema = z.strictObject({
45
+ componentId: z.string().regex(new RegExp('^[a-z][a-z0-9-]*$')),
46
+ path: z.string(),
47
+ });
40
48
  export const ProductCarouselActionsSchema = z.strictObject({});
41
49
  export const ProductCarouselStateSchema = z.strictObject({
42
50
  heading: z.string(),
43
51
  products: z.array(ProductSchema),
44
52
  });
45
- export const CartItemSchema = z.strictObject({
46
- name: z.string(),
47
- price: z.number().min(0),
48
- productId: z.string(),
53
+ export const PurchaseProductSchema = z.strictObject({
54
+ name: z.string().optional(),
55
+ price: z.union([z.number(), z.null()]).optional(),
56
+ productId: z.string().min(1),
57
+ quantity: z.number().int().min(1),
58
+ });
59
+ export const TransactionSchema = z.strictObject({
60
+ id: z.string().min(1),
61
+ revenue: z.number(),
62
+ });
63
+ export const UpdateCartPayloadSchema = z.strictObject({
64
+ name: z.string().optional(),
65
+ operation: z.enum(['add', 'remove', 'setQuantity']),
66
+ price: z.union([z.number(), z.null()]).optional(),
67
+ productId: z.string().min(1),
49
68
  quantity: z.number().int().min(1),
50
69
  });
51
- export const UpdateItemQuantityPayloadSchema = z.strictObject({
52
- item: CartItemSchema,
70
+ export const CartStateSchema = z.strictObject({});
71
+ export const FetchSuggestionsPayloadSchema = z.strictObject({
72
+ query: z.string(),
53
73
  });
54
- export const CartStateSchema = z.strictObject({
55
- items: z.array(CartItemSchema),
74
+ export const QueryCompletionSchema = z.strictObject({
75
+ expression: z.string(),
76
+ score: z.number().optional(),
56
77
  });
57
78
  export const SelectActionPayloadSchema = z.strictObject({
58
79
  text: z.string(),
@@ -65,7 +86,7 @@ export const ActionItemSchema = z.strictObject({
65
86
  export const BundleDisplayActionsSchema = z.strictObject({});
66
87
  export const BundleSlotSchema = z.strictObject({
67
88
  categoryLabel: z.string(),
68
- surfaceRef: z.string(),
89
+ childId: z.string(),
69
90
  });
70
91
  export const ComparisonTableActionsSchema = z.strictObject({});
71
92
  export const ComparisonAttributeSchema = z.strictObject({
@@ -78,18 +99,38 @@ export const ComparisonProductSchema = z.strictObject({
78
99
  price: z.number().optional(),
79
100
  productId: z.string(),
80
101
  rating: z.number().min(0).max(5).optional(),
81
- values: z.record(z.string(), z.string()),
102
+ values: z.record(z.string(), z.string()).optional(),
103
+ });
104
+ export const ProductClickPayloadSchema = z.strictObject({
105
+ name: z.string().optional(),
106
+ position: z.number().int().min(0),
107
+ price: z.union([z.number(), z.null()]).optional(),
108
+ productId: z.string().min(1),
109
+ });
110
+ export const SelectProductsPayloadSchema = z.strictObject({
111
+ productIds: z.array(z.string().min(1)),
82
112
  });
83
- export const ProductListActionsSchema = z.strictObject({});
84
113
  export const ProductListStateSchema = z.strictObject({
85
114
  products: z.array(ProductSchema),
86
115
  });
116
+ export const ProductSummaryActionsSchema = z.strictObject({});
117
+ export const ProductSummaryStateSchema = z.strictObject({
118
+ categoryLabel: z.string(),
119
+ product: z.union([ProductSchema, z.null()]),
120
+ });
121
+ export const ProductResearchCardActionsSchema = z.strictObject({});
122
+ export const ProductResearchCardStateSchema = z.strictObject({
123
+ bullets: z.array(z.string().min(1)).min(1),
124
+ product: ProductSchema,
125
+ summary: z.string().min(1),
126
+ });
87
127
  export const SelectPagePayloadSchema = z.strictObject({
88
128
  page: z.number().int().min(0),
89
129
  });
90
- export const SetPageSizePayloadSchema = z.strictObject({
130
+ export const PayloadSchema = z.strictObject({
91
131
  pageSize: z.number().int().min(1),
92
132
  });
133
+ export const ShowMorePayloadSchema = z.strictObject({});
93
134
  export const PaginationStateSchema = z.strictObject({
94
135
  page: z.number().int().min(0),
95
136
  pageSize: z.number().int().min(1),
@@ -104,12 +145,6 @@ export const SortCriterionSchema = z.strictObject({
104
145
  fields: z.array(z.unknown()),
105
146
  sortCriteria: z.string(),
106
147
  });
107
- export const SubmitQueryPayloadSchema = z.strictObject({
108
- query: z.string(),
109
- });
110
- export const SearchBoxStateSchema = z.strictObject({
111
- query: z.string(),
112
- });
113
148
  export const ActionSchema = z.strictObject({
114
149
  payload: z.unknown(),
115
150
  });
@@ -204,45 +239,99 @@ export const CategoryFacetValuesSchema = z.strictObject({
204
239
  selected: z.union([CategoryFacetValueSchema, z.null()]),
205
240
  });
206
241
  export const FacetManagerActionsSchema = z.strictObject({});
207
- export const FacetManagerStateSchema = z.strictObject({
208
- facetIds: z.array(z.string().regex(new RegExp('^[a-z][a-z0-9-]*$'))),
242
+ export const FacetManagerStateSchema = z.strictObject({});
243
+ export const OverrideCorrectionPayloadSchema = z.strictObject({
244
+ originalQuery: z.string().min(1),
209
245
  });
210
- export const ProductCarouselSchema = z.strictObject({
211
- actions: ProductCarouselActionsSchema,
212
- componentType: z.literal('product-carousel'),
213
- state: ProductCarouselStateSchema,
246
+ export const NumericRangeRestoreSchema = z.strictObject({
247
+ end: z.number(),
248
+ endInclusive: z.boolean().optional(),
249
+ start: z.number(),
214
250
  });
215
- export const SetItemsPayloadSchema = z.strictObject({
216
- items: z.array(CartItemSchema),
251
+ export const SubmitQueryPayloadSchema = z.strictObject({
252
+ query: z.string(),
217
253
  });
218
- export const UpdateItemQuantitySchema = z.strictObject({
219
- payload: UpdateItemQuantityPayloadSchema,
254
+ export const CommerceSearchStateSchema = z.strictObject({});
255
+ export const LayoutStackActionsSchema = z.strictObject({});
256
+ export const LayoutStackStateSchema = z.strictObject({});
257
+ export const QuerySummaryActionsSchema = z.strictObject({});
258
+ export const QuerySummaryStateSchema = z.strictObject({
259
+ firstIndex: z.number().int().min(0),
260
+ lastIndex: z.number().int().min(0),
261
+ query: z.string(),
262
+ totalEntries: z.number().int().min(0),
263
+ });
264
+ export const SetPageSizePayloadSchema = z.strictObject({
265
+ pageSize: z.number().int().min(1),
266
+ });
267
+ export const PageSizeStateSchema = z.strictObject({
268
+ pageSize: z.number().int().min(1),
269
+ });
270
+ export const ProductCarouselSchema = z.looseObject({
271
+ actions: ProductCarouselActionsSchema.optional(),
272
+ component: z.literal('ProductCarousel'),
273
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
274
+ state: ProductCarouselStateSchema.optional(),
275
+ });
276
+ export const PurchasePayloadSchema = z.strictObject({
277
+ products: z.array(PurchaseProductSchema),
278
+ transaction: TransactionSchema,
279
+ });
280
+ export const UpdateCartSchema = z.strictObject({
281
+ payload: UpdateCartPayloadSchema,
282
+ });
283
+ export const FetchSuggestionsSchema = z.strictObject({
284
+ payload: FetchSuggestionsPayloadSchema,
285
+ });
286
+ export const QuerySuggestionsStateSchema = z.strictObject({
287
+ completions: z.array(QueryCompletionSchema),
288
+ products: z.array(ProductSchema),
289
+ query: z.string(),
220
290
  });
221
291
  export const SelectActionSchema = z.strictObject({
222
292
  payload: SelectActionPayloadSchema,
223
293
  });
224
294
  export const NextActionsStateSchema = z.strictObject({
225
- actions: z.array(ActionItemSchema),
295
+ suggestedActions: z.array(ActionItemSchema),
226
296
  });
227
297
  export const BundleTierSchema = z.strictObject({
228
298
  description: z.string(),
229
299
  label: z.string(),
230
300
  slots: z.array(BundleSlotSchema),
301
+ total: z.number().min(0),
231
302
  });
232
303
  export const ComparisonTableStateSchema = z.strictObject({
233
304
  attributes: z.array(ComparisonAttributeSchema),
305
+ heading: z.string(),
234
306
  products: z.array(ComparisonProductSchema),
307
+ summary: z.string(),
308
+ });
309
+ export const ProductClickSchema = z.strictObject({
310
+ payload: ProductClickPayloadSchema,
311
+ });
312
+ export const SelectProductsSchema = z.strictObject({
313
+ payload: SelectProductsPayloadSchema,
235
314
  });
236
- export const ProductListSchema = z.strictObject({
237
- actions: ProductListActionsSchema,
238
- componentType: z.literal('product-list'),
239
- state: ProductListStateSchema,
315
+ export const ProductSummarySchema = z.looseObject({
316
+ actions: ProductSummaryActionsSchema.optional(),
317
+ component: z.literal('ProductSummary'),
318
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
319
+ state: ProductSummaryStateSchema.optional(),
320
+ });
321
+ export const ProductResearchCardSchema = z.looseObject({
322
+ actions: ProductResearchCardActionsSchema.optional(),
323
+ component: z.literal('ProductResearchCard'),
324
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
325
+ state: ProductResearchCardStateSchema.optional(),
240
326
  });
241
327
  export const SelectPageSchema = z.strictObject({
242
328
  payload: SelectPagePayloadSchema,
243
329
  });
244
- export const SetPageSizeSchema = z.strictObject({
245
- payload: SetPageSizePayloadSchema,
330
+ export const PurpleSetPageSizeSchema = z.strictObject({
331
+ payload: PayloadSchema,
332
+ });
333
+ export const ShowMoreSchema = z.strictObject({
334
+ payload: ShowMorePayloadSchema,
246
335
  });
247
336
  export const SelectSortSchema = z.strictObject({
248
337
  payload: SelectSortPayloadSchema,
@@ -251,9 +340,6 @@ export const SortStateSchema = z.strictObject({
251
340
  appliedSort: SortCriterionSchema,
252
341
  availableSorts: z.array(SortCriterionSchema),
253
342
  });
254
- export const SubmitQuerySchema = z.strictObject({
255
- payload: SubmitQueryPayloadSchema,
256
- });
257
343
  export const SearchSchema = z.strictObject({
258
344
  payload: SearchPayloadSchema,
259
345
  });
@@ -322,13 +408,43 @@ export const FacetSearchClassSchema = z.strictObject({
322
408
  query: z.string().max(256),
323
409
  results: z.array(CategoryFacetValueSchema),
324
410
  });
325
- export const FacetManagerSchema = z.strictObject({
326
- actions: FacetManagerActionsSchema,
327
- componentType: z.literal('facet-manager'),
328
- state: FacetManagerStateSchema,
411
+ export const FacetManagerSchema = z.looseObject({
412
+ actions: FacetManagerActionsSchema.optional(),
413
+ component: z.literal('FacetManager'),
414
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
415
+ state: FacetManagerStateSchema.optional(),
416
+ });
417
+ export const OverrideCorrectionSchema = z.strictObject({
418
+ payload: OverrideCorrectionPayloadSchema,
419
+ });
420
+ export const FacetRestoreSchema = z.strictObject({
421
+ facetId: z.string().min(1),
422
+ numericRanges: z.array(NumericRangeRestoreSchema).optional(),
423
+ values: z.array(z.string()).optional(),
424
+ });
425
+ export const SubmitQuerySchema = z.strictObject({
426
+ payload: SubmitQueryPayloadSchema,
427
+ });
428
+ export const LayoutStackSchema = z.looseObject({
429
+ actions: LayoutStackActionsSchema.optional(),
430
+ component: z.literal('LayoutStack'),
431
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
432
+ state: LayoutStackStateSchema.optional(),
433
+ });
434
+ export const QuerySummarySchema = z.looseObject({
435
+ actions: QuerySummaryActionsSchema.optional(),
436
+ component: z.literal('QuerySummary'),
437
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
438
+ state: QuerySummaryStateSchema.optional(),
439
+ });
440
+ export const FluffySetPageSizeSchema = z.strictObject({
441
+ payload: SetPageSizePayloadSchema,
442
+ });
443
+ export const PurchaseSchema = z.strictObject({
444
+ payload: PurchasePayloadSchema,
329
445
  });
330
- export const SetItemsSchema = z.strictObject({
331
- payload: SetItemsPayloadSchema,
446
+ export const QuerySuggestionsActionsSchema = z.strictObject({
447
+ fetchSuggestions: FetchSuggestionsSchema,
332
448
  });
333
449
  export const NextActionsBarActionsSchema = z.strictObject({
334
450
  selectAction: SelectActionSchema,
@@ -336,21 +452,24 @@ export const NextActionsBarActionsSchema = z.strictObject({
336
452
  export const BundleDisplayStateSchema = z.strictObject({
337
453
  tiers: z.array(BundleTierSchema),
338
454
  });
339
- export const ComparisonTableSchema = z.strictObject({
340
- actions: ComparisonTableActionsSchema,
341
- componentType: z.literal('comparison-table'),
342
- state: ComparisonTableStateSchema,
455
+ export const ComparisonTableSchema = z.looseObject({
456
+ actions: ComparisonTableActionsSchema.optional(),
457
+ component: z.literal('ComparisonTable'),
458
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
459
+ state: ComparisonTableStateSchema.optional(),
460
+ });
461
+ export const ProductListActionsSchema = z.strictObject({
462
+ productClick: ProductClickSchema,
463
+ selectProducts: SelectProductsSchema,
343
464
  });
344
465
  export const PaginationActionsSchema = z.strictObject({
345
466
  selectPage: SelectPageSchema,
346
- setPageSize: SetPageSizeSchema,
467
+ setPageSize: PurpleSetPageSizeSchema,
468
+ showMore: ShowMoreSchema,
347
469
  });
348
470
  export const SortActionsSchema = z.strictObject({
349
471
  selectSort: SelectSortSchema,
350
472
  });
351
- export const SearchBoxActionsSchema = z.strictObject({
352
- submitQuery: SubmitQuerySchema,
353
- });
354
473
  export const RegularFacetActionsSchema = z.strictObject({
355
474
  clearAllActiveValues: ActionSchema,
356
475
  clearSearch: ActionSchema,
@@ -405,135 +524,562 @@ export const CategoryFacetStateSchema = z.strictObject({
405
524
  field: z.string(),
406
525
  values: CategoryFacetValuesSchema,
407
526
  });
527
+ export const RestoreStatePayloadSchema = z.strictObject({
528
+ facets: z.array(FacetRestoreSchema).optional(),
529
+ page: z.number().int().min(0),
530
+ pageSize: z.number().int().min(1),
531
+ pinnedProducts: z.array(z.string()).optional(),
532
+ query: z.string(),
533
+ sortCriteria: z.string().optional(),
534
+ });
535
+ export const PageSizeActionsSchema = z.strictObject({
536
+ setPageSize: FluffySetPageSizeSchema,
537
+ });
408
538
  export const CartActionsSchema = z.strictObject({
409
- setItems: SetItemsSchema,
410
- updateItemQuantity: UpdateItemQuantitySchema,
411
- });
412
- export const NextActionsBarSchema = z.strictObject({
413
- actions: NextActionsBarActionsSchema,
414
- componentType: z.literal('next-actions-bar'),
415
- state: NextActionsStateSchema,
416
- });
417
- export const BundleDisplaySchema = z.strictObject({
418
- actions: BundleDisplayActionsSchema,
419
- componentType: z.literal('bundle-display'),
420
- state: BundleDisplayStateSchema,
421
- });
422
- export const PaginationSchema = z.strictObject({
423
- actions: PaginationActionsSchema,
424
- componentType: z.literal('pagination'),
425
- state: PaginationStateSchema,
426
- });
427
- export const SortSchema = z.strictObject({
428
- actions: SortActionsSchema,
429
- componentType: z.literal('sort'),
430
- state: SortStateSchema,
431
- });
432
- export const SearchBoxSchema = z.strictObject({
433
- actions: SearchBoxActionsSchema,
434
- componentType: z.literal('search-box'),
435
- state: SearchBoxStateSchema,
436
- });
437
- export const RegularFacetSchema = z.strictObject({
438
- actions: RegularFacetActionsSchema,
439
- componentType: z.literal('regular-facet'),
440
- state: RegularFacetStateSchema,
441
- });
442
- export const NumericFacetSchema = z.strictObject({
443
- actions: NumericFacetActionsSchema,
444
- componentType: z.literal('numeric-facet'),
445
- state: NumericFacetStateSchema,
446
- });
447
- export const DateFacetSchema = z.strictObject({
448
- actions: DateFacetActionsSchema,
449
- componentType: z.literal('date-facet'),
450
- state: DateFacetStateSchema,
451
- });
452
- export const CategoryFacetSchema = z.strictObject({
453
- actions: CategoryFacetActionsSchema,
454
- componentType: z.literal('category-facet'),
455
- state: CategoryFacetStateSchema,
456
- });
457
- export const CartSchema = z.strictObject({
458
- actions: CartActionsSchema,
459
- componentType: z.literal('cart'),
460
- state: CartStateSchema,
461
- });
462
- export const ComponentContractsSchema = z.discriminatedUnion('componentType', [
539
+ purchase: PurchaseSchema,
540
+ updateCart: UpdateCartSchema,
541
+ });
542
+ export const QuerySuggestionsSchema = z.looseObject({
543
+ actions: QuerySuggestionsActionsSchema.optional(),
544
+ component: z.literal('QuerySuggestions'),
545
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
546
+ state: QuerySuggestionsStateSchema.optional(),
547
+ });
548
+ export const NextActionsBarSchema = z.looseObject({
549
+ actions: NextActionsBarActionsSchema.optional(),
550
+ component: z.literal('NextActionsBar'),
551
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
552
+ state: NextActionsStateSchema.optional(),
553
+ });
554
+ export const BundleDisplaySchema = z.looseObject({
555
+ actions: BundleDisplayActionsSchema.optional(),
556
+ component: z.literal('BundleDisplay'),
557
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
558
+ state: BundleDisplayStateSchema.optional(),
559
+ });
560
+ export const ProductListSchema = z.looseObject({
561
+ actions: ProductListActionsSchema.optional(),
562
+ component: z.literal('ProductList'),
563
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
564
+ state: ProductListStateSchema.optional(),
565
+ });
566
+ export const PaginationSchema = z.looseObject({
567
+ actions: PaginationActionsSchema.optional(),
568
+ component: z.literal('Pagination'),
569
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
570
+ state: PaginationStateSchema.optional(),
571
+ });
572
+ export const SortSchema = z.looseObject({
573
+ actions: SortActionsSchema.optional(),
574
+ component: z.literal('Sort'),
575
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
576
+ state: SortStateSchema.optional(),
577
+ });
578
+ export const RegularFacetSchema = z.looseObject({
579
+ actions: RegularFacetActionsSchema.optional(),
580
+ component: z.literal('RegularFacet'),
581
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
582
+ state: RegularFacetStateSchema.optional(),
583
+ });
584
+ export const NumericFacetSchema = z.looseObject({
585
+ actions: NumericFacetActionsSchema.optional(),
586
+ component: z.literal('NumericFacet'),
587
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
588
+ state: NumericFacetStateSchema.optional(),
589
+ });
590
+ export const DateFacetSchema = z.looseObject({
591
+ actions: DateFacetActionsSchema.optional(),
592
+ component: z.literal('DateFacet'),
593
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
594
+ state: DateFacetStateSchema.optional(),
595
+ });
596
+ export const CategoryFacetSchema = z.looseObject({
597
+ actions: CategoryFacetActionsSchema.optional(),
598
+ component: z.literal('CategoryFacet'),
599
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
600
+ state: CategoryFacetStateSchema.optional(),
601
+ });
602
+ export const RestoreStateSchema = z.strictObject({
603
+ payload: RestoreStatePayloadSchema,
604
+ });
605
+ export const PageSizeSchema = z.looseObject({
606
+ actions: PageSizeActionsSchema.optional(),
607
+ component: z.literal('PageSize'),
608
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
609
+ state: PageSizeStateSchema.optional(),
610
+ });
611
+ export const CartSchema = z.looseObject({
612
+ actions: CartActionsSchema.optional(),
613
+ component: z.literal('Cart'),
614
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
615
+ state: CartStateSchema.optional(),
616
+ });
617
+ export const CommerceSearchActionsSchema = z.strictObject({
618
+ overrideCorrection: OverrideCorrectionSchema,
619
+ restoreState: RestoreStateSchema,
620
+ submitQuery: SubmitQuerySchema,
621
+ });
622
+ export const CommerceSearchSchema = z.looseObject({
623
+ actions: CommerceSearchActionsSchema.optional(),
624
+ component: z.literal('CommerceSearch'),
625
+ id: z.string().min(1).max(256).regex(new RegExp('^[a-z][a-z0-9-]*$')),
626
+ state: CommerceSearchStateSchema.optional(),
627
+ });
628
+ export const ComponentContractsSchema = z.discriminatedUnion('component', [
463
629
  ProductCarouselSchema,
464
630
  CartSchema,
631
+ QuerySuggestionsSchema,
465
632
  NextActionsBarSchema,
466
633
  BundleDisplaySchema,
467
634
  ComparisonTableSchema,
468
635
  ProductListSchema,
636
+ ProductSummarySchema,
637
+ ProductResearchCardSchema,
469
638
  PaginationSchema,
470
639
  SortSchema,
471
- SearchBoxSchema,
472
640
  RegularFacetSchema,
473
641
  NumericFacetSchema,
474
642
  DateFacetSchema,
475
643
  CategoryFacetSchema,
476
644
  FacetManagerSchema,
645
+ CommerceSearchSchema,
646
+ LayoutStackSchema,
647
+ QuerySummarySchema,
648
+ PageSizeSchema,
477
649
  ]);
478
650
  /**
479
- * Component props schemas.
480
- * These props are injected by the A2-UI surface layer (backend) and passed to catalog
481
- * renderers automatically. Consumers should NOT hardcode these values; they arrive via
482
- * the createSurface message's components[].props.
651
+ * A2-UI dynamic-value building blocks (self-contained; no renderer / @a2ui/web_core dependency).
652
+ * A bindable prop is an A2-UI Dynamic_Value: a union admitting a literal resolved value, an
653
+ * A2-UI Data_Binding object { path }, or a function-call form. The frozen renderer's binder
654
+ * classifies a field as resolvable only when its schema is such a union including DataBinding,
655
+ * so it dereferences the { path } against the data model before the renderer sees it.
656
+ *
657
+ * `DataBindingSchema` is projected from the shared definitions/data-binding.schema.json (like
658
+ * ComponentId / ChildList), so it is not re-declared here; the unions below reference it.
483
659
  */
484
- export const BundleDisplayPropsSchema = z.object({
485
- componentId: z.string(),
486
- componentType: z.literal('bundle-display'),
660
+ export const FunctionCallSchema = z.object({
661
+ call: z.string(),
662
+ args: z.record(z.string(), z.any()),
663
+ returnType: z
664
+ .enum(['string', 'number', 'boolean', 'array', 'object', 'any', 'void'])
665
+ .default('boolean'),
666
+ });
667
+ export const DynamicNumberSchema = z.union([z.number(), DataBindingSchema, FunctionCallSchema]);
668
+ export const DynamicStringSchema = z.union([z.string(), DataBindingSchema, FunctionCallSchema]);
669
+ export const DynamicBooleanSchema = z.union([z.boolean(), DataBindingSchema, FunctionCallSchema]);
670
+ export const DynamicStringListSchema = z.union([
671
+ z.array(z.string()),
672
+ DataBindingSchema,
673
+ FunctionCallSchema,
674
+ ]);
675
+ export const DynamicValueSchema = z.union([z.unknown(), DataBindingSchema, FunctionCallSchema]);
676
+ /**
677
+ * The A2-UI Action schema for an action-typed prop: the standard A2-UI event shape
678
+ * { event: { name; context } }. Named DynamicAction to stay distinct from the generated base
679
+ * action-contract ActionSchema and from a component's dispatchable *Actions contract.
680
+ */
681
+ export const DynamicActionSchema = z.object({
682
+ event: z.object({
683
+ name: z.string(),
684
+ context: z.unknown().optional(),
685
+ }),
487
686
  });
488
- export const CartPropsSchema = z.object({
489
- componentId: z.string(),
490
- componentType: z.literal('cart'),
687
+ /**
688
+ * Per-component props schemas for the renderer catalog (one per component), passed to
689
+ * `createCatalog` as each component's `{ props }` schema. Each bindable prop is an A2-UI
690
+ * Dynamic_Value, so the renderer's binder resolves its `{ path }` binding against the A2-UI
691
+ * data model; composition child-ref props stay static so child ids reach the renderer
692
+ * untouched. The resolved shape a renderer actually reads is the `XxxProps` type.
693
+ */
694
+ export const BundleDisplayPropsSchema = z.object({
695
+ tiers: z.union([BundleDisplayStateSchema.shape['tiers'], DataBindingSchema, FunctionCallSchema]),
491
696
  });
697
+ export const CartPropsSchema = z.object({});
492
698
  export const CategoryFacetPropsSchema = z.object({
493
- componentId: z.string(),
494
- componentType: z.literal('category-facet'),
699
+ field: DynamicStringSchema,
700
+ displayName: DynamicStringSchema,
701
+ values: z.union([
702
+ CategoryFacetStateSchema.shape['values'],
703
+ DataBindingSchema,
704
+ FunctionCallSchema,
705
+ ]),
706
+ canShowMoreValues: DynamicBooleanSchema,
707
+ canShowLessValues: DynamicBooleanSchema,
708
+ facetSearch: z.union([
709
+ CategoryFacetStateSchema.shape['facetSearch'],
710
+ DataBindingSchema,
711
+ FunctionCallSchema,
712
+ ]),
713
+ });
714
+ export const CommerceSearchPropsSchema = z.object({
715
+ sidebarChild: z.string().optional(),
716
+ mainChild: z.string().optional(),
495
717
  });
496
718
  export const ComparisonTablePropsSchema = z.object({
497
- componentId: z.string(),
498
- componentType: z.literal('comparison-table'),
719
+ heading: DynamicStringSchema,
720
+ summary: DynamicStringSchema,
721
+ products: z.union([
722
+ ComparisonTableStateSchema.shape['products'],
723
+ DataBindingSchema,
724
+ FunctionCallSchema,
725
+ ]),
726
+ attributes: z.union([
727
+ ComparisonTableStateSchema.shape['attributes'],
728
+ DataBindingSchema,
729
+ FunctionCallSchema,
730
+ ]),
499
731
  });
500
732
  export const DateFacetPropsSchema = z.object({
501
- componentId: z.string(),
502
- componentType: z.literal('date-facet'),
733
+ field: DynamicStringSchema,
734
+ displayName: DynamicStringSchema,
735
+ values: z.union([DateFacetStateSchema.shape['values'], DataBindingSchema, FunctionCallSchema]),
736
+ customRange: z.union([
737
+ DateFacetStateSchema.shape['customRange'],
738
+ DataBindingSchema,
739
+ FunctionCallSchema,
740
+ ]),
741
+ hasActiveValues: DynamicBooleanSchema,
742
+ canShowMoreValues: DynamicBooleanSchema,
743
+ canShowLessValues: DynamicBooleanSchema,
503
744
  });
504
745
  export const FacetManagerPropsSchema = z.object({
505
- componentId: z.string(),
506
- componentType: z.literal('facet-manager'),
746
+ children: z.array(z.string()).optional(),
747
+ });
748
+ export const LayoutStackPropsSchema = z.object({
749
+ direction: z.string().optional(),
750
+ children: z.array(z.string()).optional(),
507
751
  });
508
752
  export const NextActionsBarPropsSchema = z.object({
509
- componentId: z.string(),
510
- componentType: z.literal('next-actions-bar'),
753
+ suggestedActions: z.union([
754
+ NextActionsStateSchema.shape['suggestedActions'],
755
+ DataBindingSchema,
756
+ FunctionCallSchema,
757
+ ]),
511
758
  });
512
759
  export const NumericFacetPropsSchema = z.object({
513
- componentId: z.string(),
514
- componentType: z.literal('numeric-facet'),
760
+ field: DynamicStringSchema,
761
+ displayName: DynamicStringSchema,
762
+ values: z.union([NumericFacetStateSchema.shape['values'], DataBindingSchema, FunctionCallSchema]),
763
+ customRange: z.union([
764
+ NumericFacetStateSchema.shape['customRange'],
765
+ DataBindingSchema,
766
+ FunctionCallSchema,
767
+ ]),
768
+ hasActiveValues: DynamicBooleanSchema,
769
+ canShowMoreValues: DynamicBooleanSchema,
770
+ canShowLessValues: DynamicBooleanSchema,
771
+ domain: z.union([NumericFacetStateSchema.shape['domain'], DataBindingSchema, FunctionCallSchema]),
772
+ });
773
+ export const PageSizePropsSchema = z.object({
774
+ pageSize: DynamicNumberSchema,
515
775
  });
516
776
  export const PaginationPropsSchema = z.object({
517
- componentId: z.string(),
518
- componentType: z.literal('pagination'),
777
+ page: DynamicNumberSchema,
778
+ pageSize: DynamicNumberSchema,
779
+ totalEntries: DynamicNumberSchema,
780
+ totalPages: DynamicNumberSchema,
519
781
  });
520
782
  export const ProductCarouselPropsSchema = z.object({
521
- componentId: z.string(),
522
- componentType: z.literal('product-carousel'),
783
+ heading: DynamicStringSchema,
784
+ products: z.union([
785
+ ProductCarouselStateSchema.shape['products'],
786
+ DataBindingSchema,
787
+ FunctionCallSchema,
788
+ ]),
523
789
  });
524
790
  export const ProductListPropsSchema = z.object({
525
- componentId: z.string(),
526
- componentType: z.literal('product-list'),
791
+ products: z.union([
792
+ ProductListStateSchema.shape['products'],
793
+ DataBindingSchema,
794
+ FunctionCallSchema,
795
+ ]),
796
+ });
797
+ export const ProductResearchCardPropsSchema = z.object({
798
+ product: z.union([
799
+ ProductResearchCardStateSchema.shape['product'],
800
+ DataBindingSchema,
801
+ FunctionCallSchema,
802
+ ]),
803
+ summary: DynamicStringSchema,
804
+ bullets: DynamicStringListSchema,
805
+ });
806
+ export const ProductSummaryPropsSchema = z.object({
807
+ categoryLabel: DynamicStringSchema,
808
+ product: z.union([
809
+ ProductSummaryStateSchema.shape['product'],
810
+ DataBindingSchema,
811
+ FunctionCallSchema,
812
+ ]),
813
+ });
814
+ export const QuerySuggestionsPropsSchema = z.object({
815
+ query: DynamicStringSchema,
816
+ completions: z.union([
817
+ QuerySuggestionsStateSchema.shape['completions'],
818
+ DataBindingSchema,
819
+ FunctionCallSchema,
820
+ ]),
821
+ products: z.union([
822
+ QuerySuggestionsStateSchema.shape['products'],
823
+ DataBindingSchema,
824
+ FunctionCallSchema,
825
+ ]),
826
+ });
827
+ export const QuerySummaryPropsSchema = z.object({
828
+ query: DynamicStringSchema,
829
+ firstIndex: DynamicNumberSchema,
830
+ lastIndex: DynamicNumberSchema,
831
+ totalEntries: DynamicNumberSchema,
527
832
  });
528
833
  export const RegularFacetPropsSchema = z.object({
529
- componentId: z.string(),
530
- componentType: z.literal('regular-facet'),
531
- });
532
- export const SearchBoxPropsSchema = z.object({
533
- componentId: z.string(),
534
- componentType: z.literal('search-box'),
834
+ field: DynamicStringSchema,
835
+ displayName: DynamicStringSchema,
836
+ values: z.union([RegularFacetStateSchema.shape['values'], DataBindingSchema, FunctionCallSchema]),
837
+ hasActiveValues: DynamicBooleanSchema,
838
+ canShowMoreValues: DynamicBooleanSchema,
839
+ canShowLessValues: DynamicBooleanSchema,
840
+ facetSearch: z.union([
841
+ RegularFacetStateSchema.shape['facetSearch'],
842
+ DataBindingSchema,
843
+ FunctionCallSchema,
844
+ ]),
535
845
  });
536
846
  export const SortPropsSchema = z.object({
537
- componentId: z.string(),
538
- componentType: z.literal('sort'),
847
+ appliedSort: z.union([
848
+ SortStateSchema.shape['appliedSort'],
849
+ DataBindingSchema,
850
+ FunctionCallSchema,
851
+ ]),
852
+ availableSorts: z.union([
853
+ SortStateSchema.shape['availableSorts'],
854
+ DataBindingSchema,
855
+ FunctionCallSchema,
856
+ ]),
539
857
  });
858
+ /**
859
+ * Per-component action unions in the standard A2-UI event shape
860
+ * { event: { name: <literal>; context: <typed payload> } }, one member per declared action.
861
+ * Derived from each component's *Actions contract (action-map key -> payload), NOT from
862
+ * quicktype's auto-named payload wrappers. A component with no actions has `type XxxAction =
863
+ * never`. The wire field is `context`; the internal validation layer calls the same data
864
+ * `payload` (see design: Action typing).
865
+ */
866
+ export const BundleDisplayActionSchema = z.never();
867
+ export const CartActionSchema = z.union([
868
+ z.object({
869
+ event: z.object({
870
+ name: z.literal('updateCart'),
871
+ context: z.strictObject({
872
+ productId: z.string(),
873
+ name: z.string().optional(),
874
+ price: z.unknown().optional(),
875
+ quantity: z.number().int().min(1),
876
+ operation: z.enum(['add', 'remove', 'setQuantity']),
877
+ }),
878
+ }),
879
+ }),
880
+ z.object({
881
+ event: z.object({
882
+ name: z.literal('purchase'),
883
+ context: z.strictObject({ products: z.array(z.unknown()), transaction: z.unknown() }),
884
+ }),
885
+ }),
886
+ ]);
887
+ export const CategoryFacetActionSchema = z.union([
888
+ z.object({
889
+ event: z.object({
890
+ name: z.literal('selectPath'),
891
+ context: z.strictObject({ path: z.array(z.string()) }),
892
+ }),
893
+ }),
894
+ z.object({ event: z.object({ name: z.literal('clearSelectedPath'), context: z.unknown() }) }),
895
+ z.object({
896
+ event: z.object({
897
+ name: z.literal('search'),
898
+ context: z.strictObject({ query: z.string().max(256) }),
899
+ }),
900
+ }),
901
+ z.object({ event: z.object({ name: z.literal('showMoreSearchResults'), context: z.unknown() }) }),
902
+ z.object({ event: z.object({ name: z.literal('clearSearch'), context: z.unknown() }) }),
903
+ z.object({ event: z.object({ name: z.literal('showMoreValues'), context: z.unknown() }) }),
904
+ z.object({ event: z.object({ name: z.literal('showLessValues'), context: z.unknown() }) }),
905
+ ]);
906
+ export const CommerceSearchActionSchema = z.union([
907
+ z.object({
908
+ event: z.object({ name: z.literal('submitQuery'), context: z.strictObject({ query: z.string() }) }),
909
+ }),
910
+ z.object({
911
+ event: z.object({
912
+ name: z.literal('restoreState'),
913
+ context: z.strictObject({
914
+ query: z.string(),
915
+ page: z.number().int().min(0),
916
+ pageSize: z.number().int().min(1),
917
+ sortCriteria: z.string().optional(),
918
+ facets: z.array(z.unknown()).optional(),
919
+ pinnedProducts: z.array(z.string()).optional(),
920
+ }),
921
+ }),
922
+ }),
923
+ z.object({
924
+ event: z.object({
925
+ name: z.literal('overrideCorrection'),
926
+ context: z.strictObject({ originalQuery: z.string() }),
927
+ }),
928
+ }),
929
+ ]);
930
+ export const ComparisonTableActionSchema = z.never();
931
+ export const DateFacetActionSchema = z.union([
932
+ z.object({
933
+ event: z.object({
934
+ name: z.literal('toggleSelect'),
935
+ context: z.strictObject({ start: z.string(), end: z.string() }),
936
+ }),
937
+ }),
938
+ z.object({
939
+ event: z.object({
940
+ name: z.literal('toggleSingleSelect'),
941
+ context: z.strictObject({ start: z.string(), end: z.string() }),
942
+ }),
943
+ }),
944
+ z.object({ event: z.object({ name: z.literal('clearAllActiveValues'), context: z.unknown() }) }),
945
+ z.object({
946
+ event: z.object({
947
+ name: z.literal('applyCustomRange'),
948
+ context: z.strictObject({ start: z.string(), end: z.string() }),
949
+ }),
950
+ }),
951
+ z.object({ event: z.object({ name: z.literal('showMoreValues'), context: z.unknown() }) }),
952
+ z.object({ event: z.object({ name: z.literal('showLessValues'), context: z.unknown() }) }),
953
+ ]);
954
+ export const FacetManagerActionSchema = z.never();
955
+ export const LayoutStackActionSchema = z.never();
956
+ export const NextActionsBarActionSchema = z.union([
957
+ z.object({
958
+ event: z.object({
959
+ name: z.literal('selectAction'),
960
+ context: z.strictObject({ text: z.string(), type: z.enum(['followup', 'search']) }),
961
+ }),
962
+ }),
963
+ ]);
964
+ export const NumericFacetActionSchema = z.union([
965
+ z.object({
966
+ event: z.object({
967
+ name: z.literal('toggleSelect'),
968
+ context: z.strictObject({ start: z.number(), end: z.number() }),
969
+ }),
970
+ }),
971
+ z.object({
972
+ event: z.object({
973
+ name: z.literal('toggleSingleSelect'),
974
+ context: z.strictObject({ start: z.number(), end: z.number() }),
975
+ }),
976
+ }),
977
+ z.object({ event: z.object({ name: z.literal('clearAllActiveValues'), context: z.unknown() }) }),
978
+ z.object({
979
+ event: z.object({
980
+ name: z.literal('applyCustomRange'),
981
+ context: z.strictObject({ start: z.number(), end: z.number() }),
982
+ }),
983
+ }),
984
+ z.object({ event: z.object({ name: z.literal('showMoreValues'), context: z.unknown() }) }),
985
+ z.object({ event: z.object({ name: z.literal('showLessValues'), context: z.unknown() }) }),
986
+ ]);
987
+ export const PageSizeActionSchema = z.union([
988
+ z.object({
989
+ event: z.object({
990
+ name: z.literal('setPageSize'),
991
+ context: z.strictObject({ pageSize: z.number().int().min(1) }),
992
+ }),
993
+ }),
994
+ ]);
995
+ export const PaginationActionSchema = z.union([
996
+ z.object({
997
+ event: z.object({
998
+ name: z.literal('selectPage'),
999
+ context: z.strictObject({ page: z.number().int().min(0) }),
1000
+ }),
1001
+ }),
1002
+ z.object({
1003
+ event: z.object({
1004
+ name: z.literal('setPageSize'),
1005
+ context: z.strictObject({ pageSize: z.number().int().min(1) }),
1006
+ }),
1007
+ }),
1008
+ z.object({ event: z.object({ name: z.literal('showMore'), context: z.strictObject({}) }) }),
1009
+ ]);
1010
+ export const ProductCarouselActionSchema = z.never();
1011
+ export const ProductListActionSchema = z.union([
1012
+ z.object({
1013
+ event: z.object({
1014
+ name: z.literal('selectProducts'),
1015
+ context: z.strictObject({ productIds: z.array(z.string()) }),
1016
+ }),
1017
+ }),
1018
+ z.object({
1019
+ event: z.object({
1020
+ name: z.literal('productClick'),
1021
+ context: z.strictObject({
1022
+ productId: z.string(),
1023
+ name: z.string().optional(),
1024
+ price: z.unknown().optional(),
1025
+ position: z.number().int().min(0),
1026
+ }),
1027
+ }),
1028
+ }),
1029
+ ]);
1030
+ export const ProductResearchCardActionSchema = z.never();
1031
+ export const ProductSummaryActionSchema = z.never();
1032
+ export const QuerySuggestionsActionSchema = z.union([
1033
+ z.object({
1034
+ event: z.object({
1035
+ name: z.literal('fetchSuggestions'),
1036
+ context: z.strictObject({ query: z.string() }),
1037
+ }),
1038
+ }),
1039
+ ]);
1040
+ export const QuerySummaryActionSchema = z.never();
1041
+ export const RegularFacetActionSchema = z.union([
1042
+ z.object({
1043
+ event: z.object({
1044
+ name: z.literal('toggleSelect'),
1045
+ context: z.strictObject({ value: z.string().max(1024) }),
1046
+ }),
1047
+ }),
1048
+ z.object({
1049
+ event: z.object({
1050
+ name: z.literal('toggleExclude'),
1051
+ context: z.strictObject({ value: z.string().max(1024) }),
1052
+ }),
1053
+ }),
1054
+ z.object({
1055
+ event: z.object({
1056
+ name: z.literal('toggleSingleSelect'),
1057
+ context: z.strictObject({ value: z.string().max(1024) }),
1058
+ }),
1059
+ }),
1060
+ z.object({
1061
+ event: z.object({
1062
+ name: z.literal('toggleSingleExclude'),
1063
+ context: z.strictObject({ value: z.string().max(1024) }),
1064
+ }),
1065
+ }),
1066
+ z.object({ event: z.object({ name: z.literal('clearAllActiveValues'), context: z.unknown() }) }),
1067
+ z.object({
1068
+ event: z.object({
1069
+ name: z.literal('search'),
1070
+ context: z.strictObject({ query: z.string().max(1024) }),
1071
+ }),
1072
+ }),
1073
+ z.object({ event: z.object({ name: z.literal('showMoreSearchResults'), context: z.unknown() }) }),
1074
+ z.object({ event: z.object({ name: z.literal('clearSearch'), context: z.unknown() }) }),
1075
+ z.object({ event: z.object({ name: z.literal('showMoreValues'), context: z.unknown() }) }),
1076
+ z.object({ event: z.object({ name: z.literal('showLessValues'), context: z.unknown() }) }),
1077
+ ]);
1078
+ export const SortActionSchema = z.union([
1079
+ z.object({
1080
+ event: z.object({
1081
+ name: z.literal('selectSort'),
1082
+ context: z.strictObject({ sortCriteria: z.string(), fields: z.array(z.unknown()) }),
1083
+ }),
1084
+ }),
1085
+ ]);