|
1 | 1 | import { z } from 'zod'; |
2 | 2 |
|
3 | | -export const LoopingOperationOperationSchema = z.object({ |
4 | | - _ref: z.string().optional(), |
5 | | -}); |
6 | | - |
7 | | -// Helper function to extend any operation schema with base properties |
8 | | -export const withLoopingOperationProperties = <T extends z.ZodRawShape>(schema: z.ZodObject<T>) => { |
9 | | - return LoopingOperationOperationSchema.extend(schema.shape); |
10 | | -}; |
11 | | - |
12 | 3 | import { |
13 | 4 | PublishItemOperationSchema, |
14 | 5 | UnPublishItemOperationSchema, |
@@ -49,50 +40,53 @@ import { |
49 | 40 | UpsertSubscriptionContractOperationSchema, |
50 | 41 | } from './subscription-contract.js'; |
51 | 42 |
|
| 43 | +import { RegisterImageOperationSchema } from './asset.js'; |
| 44 | + |
52 | 45 | export const OperationSchema = z.discriminatedUnion('intent', [ |
53 | | - withLoopingOperationProperties(CreateDocumentOperationSchema), |
54 | | - withLoopingOperationProperties(UpdateDocumentOperationSchema), |
55 | | - withLoopingOperationProperties(UpsertDocumentOperationSchema), |
| 46 | + CreateDocumentOperationSchema, |
| 47 | + UpdateDocumentOperationSchema, |
| 48 | + UpsertDocumentOperationSchema, |
56 | 49 |
|
57 | | - withLoopingOperationProperties(CreateFolderOperationSchema), |
58 | | - withLoopingOperationProperties(UpdateFolderOperationSchema), |
59 | | - withLoopingOperationProperties(UpsertFolderOperationSchema), |
| 50 | + CreateFolderOperationSchema, |
| 51 | + UpdateFolderOperationSchema, |
| 52 | + UpsertFolderOperationSchema, |
60 | 53 |
|
61 | | - withLoopingOperationProperties(CreateProductOperationSchema), |
62 | | - withLoopingOperationProperties(UpdateProductOperationSchema), |
63 | | - withLoopingOperationProperties(UpsertProductOperationSchema), |
| 54 | + CreateProductOperationSchema, |
| 55 | + UpdateProductOperationSchema, |
| 56 | + UpsertProductOperationSchema, |
64 | 57 |
|
65 | | - withLoopingOperationProperties(PublishItemOperationSchema), |
66 | | - withLoopingOperationProperties(UnPublishItemOperationSchema), |
| 58 | + PublishItemOperationSchema, |
| 59 | + UnPublishItemOperationSchema, |
67 | 60 |
|
68 | | - withLoopingOperationProperties(UpdateItemComponentOperationSchema), |
69 | | - withLoopingOperationProperties(UpdateSkuComponentOperationSchema), |
| 61 | + UpdateItemComponentOperationSchema, |
| 62 | + UpdateSkuComponentOperationSchema, |
70 | 63 |
|
71 | | - withLoopingOperationProperties(CreateShapeOperationSchema), |
72 | | - withLoopingOperationProperties(UpdateShapeOperationSchema), |
73 | | - withLoopingOperationProperties(UpsertShapeOperationSchema), |
| 64 | + CreateShapeOperationSchema, |
| 65 | + UpdateShapeOperationSchema, |
| 66 | + UpsertShapeOperationSchema, |
74 | 67 |
|
75 | | - withLoopingOperationProperties(CreatePieceOperationSchema), |
76 | | - withLoopingOperationProperties(UpdatePieceOperationSchema), |
77 | | - withLoopingOperationProperties(UpsertPieceOperationSchema), |
| 68 | + CreatePieceOperationSchema, |
| 69 | + UpdatePieceOperationSchema, |
| 70 | + UpsertPieceOperationSchema, |
78 | 71 |
|
79 | | - withLoopingOperationProperties(ModifyProductVariantStockOperationSchema), |
| 72 | + ModifyProductVariantStockOperationSchema, |
| 73 | + RegisterImageOperationSchema, |
80 | 74 |
|
81 | | - withLoopingOperationProperties(CreateCustomerGroupOperationSchema), |
82 | | - withLoopingOperationProperties(UpdateCustomerGroupOperationSchema), |
83 | | - withLoopingOperationProperties(UpsertCustomerGroupOperationSchema), |
| 75 | + CreateCustomerGroupOperationSchema, |
| 76 | + UpdateCustomerGroupOperationSchema, |
| 77 | + UpsertCustomerGroupOperationSchema, |
84 | 78 |
|
85 | | - withLoopingOperationProperties(CreateCustomerOperationSchema), |
86 | | - withLoopingOperationProperties(UpdateCustomerOperationSchema), |
87 | | - withLoopingOperationProperties(UpsertCustomerOperationSchema), |
| 79 | + CreateCustomerOperationSchema, |
| 80 | + UpdateCustomerOperationSchema, |
| 81 | + UpsertCustomerOperationSchema, |
88 | 82 |
|
89 | | - withLoopingOperationProperties(RegisterOrderOperationSchema), |
90 | | - withLoopingOperationProperties(UpdateOrderOperationSchema), |
91 | | - withLoopingOperationProperties(UpsertOrderOperationSchema), |
| 83 | + RegisterOrderOperationSchema, |
| 84 | + UpdateOrderOperationSchema, |
| 85 | + UpsertOrderOperationSchema, |
92 | 86 |
|
93 | | - withLoopingOperationProperties(CreateSubscriptionContractOperationSchema), |
94 | | - withLoopingOperationProperties(UpdateSubscriptionContractOperationSchema), |
95 | | - withLoopingOperationProperties(UpsertSubscriptionContractOperationSchema), |
| 87 | + CreateSubscriptionContractOperationSchema, |
| 88 | + UpdateSubscriptionContractOperationSchema, |
| 89 | + UpsertSubscriptionContractOperationSchema, |
96 | 90 | ]); |
97 | 91 |
|
98 | 92 | export const OperationsSchema = z.object({ |
@@ -146,3 +140,7 @@ export type { |
146 | 140 | UpdateSubscriptionContractOperation, |
147 | 141 | UpsertSubscriptionContractOperation, |
148 | 142 | } from './subscription-contract.js'; |
| 143 | + |
| 144 | +export type { |
| 145 | + RegisterImageOperation |
| 146 | +} from './asset.js'; |
0 commit comments