@@ -11,6 +11,12 @@ import {
1111import { checkResourceIdentifierOrId , IdSchema , RefSchema , ResourceIdentifierSchema } from '../shared' ;
1212import { FlowContentActionConfigInputSchema , ItemFlowStageAssociationInputSchema } from '../pim/flow/flow-input' ;
1313
14+
15+ const itemIdAndResourceIdentifierSchemaFields = {
16+ itemId : IdSchema . optional ( ) ,
17+ resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
18+ }
19+
1420export const CreateDocumentOperationSchema = CreateDocumentInputSchema . extend ( {
1521 _ref : RefSchema . optional ( ) ,
1622 intent : z . literal ( 'document/create' ) ,
@@ -22,16 +28,14 @@ export const UpdateDocumentOperationSchema = UpdateDocumentInputSchema.extend({
2228 _ref : RefSchema . optional ( ) ,
2329 intent : z . literal ( 'document/update' ) ,
2430 language : z . string ( ) . min ( 1 ) ,
25- itemId : IdSchema . optional ( ) ,
26- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
31+ ...itemIdAndResourceIdentifierSchemaFields ,
2732} ) . superRefine ( checkResourceIdentifierOrId ) ;
2833
2934export const UpsertDocumentOperationSchema = CreateDocumentInputSchema . extend ( {
3035 _ref : RefSchema . optional ( ) ,
3136 intent : z . literal ( 'document/upsert' ) ,
3237 language : z . string ( ) . min ( 1 ) ,
33- itemId : IdSchema . optional ( ) ,
34- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
38+ ...itemIdAndResourceIdentifierSchemaFields ,
3539} ) ;
3640
3741export const CreateFolderOperationSchema = CreateFolderInputSchema . extend ( {
@@ -45,16 +49,14 @@ export const UpdateFolderOperationSchema = UpdateFolderInputSchema.extend({
4549 _ref : RefSchema . optional ( ) ,
4650 intent : z . literal ( 'folder/update' ) ,
4751 language : z . string ( ) . min ( 1 ) ,
48- itemId : IdSchema . optional ( ) ,
49- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
52+ ...itemIdAndResourceIdentifierSchemaFields ,
5053} ) . superRefine ( checkResourceIdentifierOrId ) ;
5154
5255export const UpsertFolderOperationSchema = CreateFolderInputSchema . extend ( {
5356 _ref : RefSchema . optional ( ) ,
5457 intent : z . literal ( 'folder/upsert' ) ,
5558 language : z . string ( ) . min ( 1 ) ,
56- itemId : IdSchema . optional ( ) ,
57- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
59+ ...itemIdAndResourceIdentifierSchemaFields ,
5860} ) ;
5961
6062export const CreateProductOperationSchema = CreateProductInputSchema . extend ( {
@@ -68,16 +70,14 @@ export const UpdateProductOperationSchema = UpdateProductInputSchema.extend({
6870 _ref : RefSchema . optional ( ) ,
6971 intent : z . literal ( 'product/update' ) ,
7072 language : z . string ( ) . min ( 1 ) ,
71- itemId : IdSchema . optional ( ) ,
72- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
73+ ...itemIdAndResourceIdentifierSchemaFields ,
7374} ) . superRefine ( checkResourceIdentifierOrId ) ;
7475
7576export const UpsertProductOperationSchema = CreateProductInputSchema . extend ( {
7677 _ref : RefSchema . optional ( ) ,
7778 intent : z . literal ( 'product/upsert' ) ,
7879 language : z . string ( ) . min ( 1 ) ,
79- itemId : IdSchema . optional ( ) ,
80- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
80+ ...itemIdAndResourceIdentifierSchemaFields ,
8181} ) ;
8282
8383export const UpdateItemComponentOperationSchema = z
@@ -86,8 +86,7 @@ export const UpdateItemComponentOperationSchema = z
8686 intent : z . literal ( 'item/updateComponent/item' ) ,
8787 language : z . string ( ) . min ( 1 ) ,
8888 component : ComponentContentInputSchema ,
89- itemId : IdSchema . optional ( ) ,
90- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
89+ ...itemIdAndResourceIdentifierSchemaFields
9190 } )
9291 . superRefine ( checkResourceIdentifierOrId ) ;
9392
@@ -99,62 +98,27 @@ export const UpdateSkuComponentOperationSchema = z.object({
9998 sku : z . string ( ) ,
10099} ) ;
101100
102- export const PublishItemOperationSchema = z . object ( {
101+ const publishUnpublishItemBaseSchemaFields = {
103102 _ref : RefSchema . optional ( ) ,
104- intent : z . literal ( 'item/publish' ) ,
105103 language : z . string ( ) . min ( 1 ) ,
106104 includeDescendants : z . boolean ( ) . optional ( ) ,
107- itemId : IdSchema . optional ( ) ,
108- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
109- } ) ;
105+ ...itemIdAndResourceIdentifierSchemaFields ,
106+ }
107+ export const PublishItemOperationSchema = z . object ( {
108+ intent : z . literal ( 'item/publish' ) ,
109+ ...publishUnpublishItemBaseSchemaFields ,
110+ } ) . superRefine ( checkResourceIdentifierOrId ) ;
110111
111- export const UnPublishItemOperationSchema = PublishItemOperationSchema . omit ( { intent : true } ) . extend ( {
112+ export const UnPublishItemOperationSchema = z . object ( {
112113 intent : z . literal ( 'item/unpublish' ) ,
113- } ) ;
114+ ...publishUnpublishItemBaseSchemaFields ,
115+ } ) . superRefine ( checkResourceIdentifierOrId ) ;
114116
115117export const DeleteItemOperationSchema = z
116118 . object ( {
117119 _ref : RefSchema . optional ( ) ,
118120 intent : z . literal ( 'item/delete' ) ,
119- itemId : IdSchema . optional ( ) ,
120- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
121- } )
122- . superRefine ( checkResourceIdentifierOrId ) ;
123-
124- export const AddItemTreeNodeShortcutsOperationSchema = z
125- . object ( {
126- _ref : RefSchema . optional ( ) ,
127- intent : z . literal ( 'item/paths/addShortcuts' ) ,
128- itemId : IdSchema . optional ( ) ,
129- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
130- shortcuts : z . array (
131- z . object ( {
132- parentId : IdSchema ,
133- position : z . number ( ) . int ( ) . min ( 0 ) . optional ( ) ,
134- } ) ,
135- ) ,
136- } )
137- . superRefine ( checkResourceIdentifierOrId ) ;
138-
139- export const AddItemTreeNodeAliasesOperationSchema = z
140- . object ( {
141- _ref : RefSchema . optional ( ) ,
142- intent : z . literal ( 'item/paths/addAliases' ) ,
143- itemId : IdSchema . optional ( ) ,
144- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
145- language : z . string ( ) . min ( 1 ) ,
146- paths : z . array ( z . string ( ) . min ( 1 ) ) ,
147- } )
148- . superRefine ( checkResourceIdentifierOrId ) ;
149-
150- export const AddItemTreeNodeHistoryOperationSchema = z
151- . object ( {
152- _ref : RefSchema . optional ( ) ,
153- intent : z . literal ( 'item/paths/addHistory' ) ,
154- itemId : IdSchema . optional ( ) ,
155- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
156- language : z . string ( ) . min ( 1 ) ,
157- paths : z . array ( z . string ( ) . min ( 1 ) ) ,
121+ ...itemIdAndResourceIdentifierSchemaFields
158122 } )
159123 . superRefine ( checkResourceIdentifierOrId ) ;
160124
@@ -185,7 +149,4 @@ export type CreateProductOperation = z.infer<typeof CreateProductOperationSchema
185149export type UpdateProductOperation = z . infer < typeof UpdateProductOperationSchema > ;
186150export type UpsertProductOperation = z . infer < typeof UpsertProductOperationSchema > ;
187151
188- export type AddItemTreeNodeShortcutsOperation = z . infer < typeof AddItemTreeNodeShortcutsOperationSchema > ;
189- export type AddItemTreeNodeAliasesOperation = z . infer < typeof AddItemTreeNodeAliasesOperationSchema > ;
190- export type AddItemTreeNodeHistoryOperation = z . infer < typeof AddItemTreeNodeHistoryOperationSchema > ;
191152export type AddItemsToFlowStageOperation = z . infer < typeof AddItemsToFlowStageOperationSchema > ;
0 commit comments