@@ -11,6 +11,11 @@ import {
1111import { checkResourceIdentifierOrId , IdSchema , RefSchema , ResourceIdentifierSchema } from '../shared' ;
1212import { FlowContentActionConfigInputSchema , ItemFlowStageAssociationInputSchema } from '../pim/flow/flow-input' ;
1313
14+ const itemIdAndResourceIdentifierSchemaFields = {
15+ itemId : IdSchema . optional ( ) ,
16+ resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
17+ } ;
18+
1419export const CreateDocumentOperationSchema = CreateDocumentInputSchema . extend ( {
1520 _ref : RefSchema . optional ( ) ,
1621 intent : z . literal ( 'document/create' ) ,
@@ -22,16 +27,14 @@ export const UpdateDocumentOperationSchema = UpdateDocumentInputSchema.extend({
2227 _ref : RefSchema . optional ( ) ,
2328 intent : z . literal ( 'document/update' ) ,
2429 language : z . string ( ) . min ( 1 ) ,
25- itemId : IdSchema . optional ( ) ,
26- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
30+ ...itemIdAndResourceIdentifierSchemaFields ,
2731} ) . superRefine ( checkResourceIdentifierOrId ) ;
2832
2933export const UpsertDocumentOperationSchema = CreateDocumentInputSchema . extend ( {
3034 _ref : RefSchema . optional ( ) ,
3135 intent : z . literal ( 'document/upsert' ) ,
3236 language : z . string ( ) . min ( 1 ) ,
33- itemId : IdSchema . optional ( ) ,
34- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
37+ ...itemIdAndResourceIdentifierSchemaFields ,
3538} ) ;
3639
3740export const CreateFolderOperationSchema = CreateFolderInputSchema . extend ( {
@@ -45,16 +48,14 @@ export const UpdateFolderOperationSchema = UpdateFolderInputSchema.extend({
4548 _ref : RefSchema . optional ( ) ,
4649 intent : z . literal ( 'folder/update' ) ,
4750 language : z . string ( ) . min ( 1 ) ,
48- itemId : IdSchema . optional ( ) ,
49- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
51+ ...itemIdAndResourceIdentifierSchemaFields ,
5052} ) . superRefine ( checkResourceIdentifierOrId ) ;
5153
5254export const UpsertFolderOperationSchema = CreateFolderInputSchema . extend ( {
5355 _ref : RefSchema . optional ( ) ,
5456 intent : z . literal ( 'folder/upsert' ) ,
5557 language : z . string ( ) . min ( 1 ) ,
56- itemId : IdSchema . optional ( ) ,
57- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
58+ ...itemIdAndResourceIdentifierSchemaFields ,
5859} ) ;
5960
6061export const CreateProductOperationSchema = CreateProductInputSchema . extend ( {
@@ -68,16 +69,14 @@ export const UpdateProductOperationSchema = UpdateProductInputSchema.extend({
6869 _ref : RefSchema . optional ( ) ,
6970 intent : z . literal ( 'product/update' ) ,
7071 language : z . string ( ) . min ( 1 ) ,
71- itemId : IdSchema . optional ( ) ,
72- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
72+ ...itemIdAndResourceIdentifierSchemaFields ,
7373} ) . superRefine ( checkResourceIdentifierOrId ) ;
7474
7575export const UpsertProductOperationSchema = CreateProductInputSchema . extend ( {
7676 _ref : RefSchema . optional ( ) ,
7777 intent : z . literal ( 'product/upsert' ) ,
7878 language : z . string ( ) . min ( 1 ) ,
79- itemId : IdSchema . optional ( ) ,
80- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
79+ ...itemIdAndResourceIdentifierSchemaFields ,
8180} ) ;
8281
8382export const UpdateItemComponentOperationSchema = z
@@ -86,8 +85,7 @@ export const UpdateItemComponentOperationSchema = z
8685 intent : z . literal ( 'item/updateComponent/item' ) ,
8786 language : z . string ( ) . min ( 1 ) ,
8887 component : ComponentContentInputSchema ,
89- itemId : IdSchema . optional ( ) ,
90- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
88+ ...itemIdAndResourceIdentifierSchemaFields ,
9189 } )
9290 . superRefine ( checkResourceIdentifierOrId ) ;
9391
@@ -99,62 +97,31 @@ export const UpdateSkuComponentOperationSchema = z.object({
9997 sku : z . string ( ) ,
10098} ) ;
10199
102- export const PublishItemOperationSchema = z . object ( {
100+ const publishUnpublishItemBaseSchemaFields = {
103101 _ref : RefSchema . optional ( ) ,
104- intent : z . literal ( 'item/publish' ) ,
105102 language : z . string ( ) . min ( 1 ) ,
106103 includeDescendants : z . boolean ( ) . optional ( ) ,
107- itemId : IdSchema . optional ( ) ,
108- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
109- } ) ;
110-
111- export const UnPublishItemOperationSchema = PublishItemOperationSchema . omit ( { intent : true } ) . extend ( {
112- intent : z . literal ( 'item/unpublish' ) ,
113- } ) ;
114-
115- export const DeleteItemOperationSchema = z
104+ ...itemIdAndResourceIdentifierSchemaFields ,
105+ } ;
106+ export const PublishItemOperationSchema = z
116107 . object ( {
117- _ref : RefSchema . optional ( ) ,
118- intent : z . literal ( 'item/delete' ) ,
119- itemId : IdSchema . optional ( ) ,
120- resourceIdentifier : ResourceIdentifierSchema . optional ( ) ,
108+ intent : z . literal ( 'item/publish' ) ,
109+ ...publishUnpublishItemBaseSchemaFields ,
121110 } )
122111 . superRefine ( checkResourceIdentifierOrId ) ;
123112
124- export const AddItemTreeNodeShortcutsOperationSchema = z
113+ export const UnPublishItemOperationSchema = z
125114 . 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- ) ,
115+ intent : z . literal ( 'item/unpublish' ) ,
116+ ...publishUnpublishItemBaseSchemaFields ,
136117 } )
137118 . superRefine ( checkResourceIdentifierOrId ) ;
138119
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
120+ export const DeleteItemOperationSchema = z
151121 . object ( {
152122 _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 ) ) ,
123+ intent : z . literal ( 'item/delete' ) ,
124+ ...itemIdAndResourceIdentifierSchemaFields ,
158125 } )
159126 . superRefine ( checkResourceIdentifierOrId ) ;
160127
@@ -185,7 +152,4 @@ export type CreateProductOperation = z.infer<typeof CreateProductOperationSchema
185152export type UpdateProductOperation = z . infer < typeof UpdateProductOperationSchema > ;
186153export type UpsertProductOperation = z . infer < typeof UpsertProductOperationSchema > ;
187154
188- export type AddItemTreeNodeShortcutsOperation = z . infer < typeof AddItemTreeNodeShortcutsOperationSchema > ;
189- export type AddItemTreeNodeAliasesOperation = z . infer < typeof AddItemTreeNodeAliasesOperationSchema > ;
190- export type AddItemTreeNodeHistoryOperation = z . infer < typeof AddItemTreeNodeHistoryOperationSchema > ;
191155export type AddItemsToFlowStageOperation = z . infer < typeof AddItemsToFlowStageOperationSchema > ;
0 commit comments