@@ -8,89 +8,108 @@ import {
88 UpdateFolderInputSchema ,
99 UpdateProductInputSchema ,
1010} from '../pim/index.js' ;
11- import { IdSchema } from '../shared/index.js ' ;
11+ import { checkTuriOrId , IdSchema , RefSchema , TURISchema } from '../shared' ;
1212
1313export const CreateDocumentOperationSchema = CreateDocumentInputSchema . extend ( {
14+ _ref : RefSchema . optional ( ) ,
1415 intent : z . literal ( 'document/create' ) ,
1516 language : z . string ( ) . min ( 1 ) ,
17+ turi : TURISchema . optional ( ) ,
1618} ) ;
1719
1820export const UpdateDocumentOperationSchema = UpdateDocumentInputSchema . extend ( {
21+ _ref : RefSchema . optional ( ) ,
1922 intent : z . literal ( 'document/update' ) ,
20- itemId : IdSchema ,
2123 language : z . string ( ) . min ( 1 ) ,
22- } ) ;
24+ itemId : IdSchema . optional ( ) ,
25+ turi : TURISchema . optional ( ) ,
26+ } ) . superRefine ( checkTuriOrId ) ;
2327
2428export const UpsertDocumentOperationSchema = CreateDocumentInputSchema . extend ( {
29+ _ref : RefSchema . optional ( ) ,
2530 intent : z . literal ( 'document/upsert' ) ,
2631 language : z . string ( ) . min ( 1 ) ,
27- itemId : IdSchema ,
32+ itemId : IdSchema . optional ( ) ,
33+ turi : TURISchema . optional ( ) ,
2834} ) ;
2935
3036export const CreateFolderOperationSchema = CreateFolderInputSchema . extend ( {
37+ _ref : RefSchema . optional ( ) ,
3138 intent : z . literal ( 'folder/create' ) ,
3239 language : z . string ( ) . min ( 1 ) ,
40+ turi : TURISchema . optional ( ) ,
3341} ) ;
3442
3543export const UpdateFolderOperationSchema = UpdateFolderInputSchema . extend ( {
44+ _ref : RefSchema . optional ( ) ,
3645 intent : z . literal ( 'folder/update' ) ,
3746 language : z . string ( ) . min ( 1 ) ,
38- itemId : IdSchema ,
39- } ) ;
47+ itemId : IdSchema . optional ( ) ,
48+ turi : TURISchema . optional ( ) ,
49+ } ) . superRefine ( checkTuriOrId ) ;
4050
4151export const UpsertFolderOperationSchema = CreateFolderInputSchema . extend ( {
52+ _ref : RefSchema . optional ( ) ,
4253 intent : z . literal ( 'folder/upsert' ) ,
4354 language : z . string ( ) . min ( 1 ) ,
44- itemId : IdSchema ,
55+ itemId : IdSchema . optional ( ) ,
56+ turi : TURISchema . optional ( ) ,
4557} ) ;
4658
4759export const CreateProductOperationSchema = CreateProductInputSchema . extend ( {
60+ _ref : RefSchema . optional ( ) ,
4861 intent : z . literal ( 'product/create' ) ,
4962 language : z . string ( ) . min ( 1 ) ,
63+ turi : TURISchema . optional ( ) ,
5064} ) ;
5165
5266export const UpdateProductOperationSchema = UpdateProductInputSchema . extend ( {
67+ _ref : RefSchema . optional ( ) ,
5368 intent : z . literal ( 'product/update' ) ,
5469 language : z . string ( ) . min ( 1 ) ,
55- itemId : IdSchema ,
56- } ) ;
70+ itemId : IdSchema . optional ( ) ,
71+ turi : TURISchema . optional ( ) ,
72+ } ) . superRefine ( checkTuriOrId ) ;
5773
5874export const UpsertProductOperationSchema = CreateProductInputSchema . extend ( {
75+ _ref : RefSchema . optional ( ) ,
5976 intent : z . literal ( 'product/upsert' ) ,
6077 language : z . string ( ) . min ( 1 ) ,
61- itemId : IdSchema ,
78+ itemId : IdSchema . optional ( ) ,
79+ turi : TURISchema . optional ( ) ,
6280} ) ;
6381
64- export const UpdateItemComponentOperationSchema = z . object ( {
65- intent : z . literal ( 'item/updateComponent/item' ) ,
82+ export const UpdateItemComponentOperationSchema = z
83+ . object ( {
84+ _ref : RefSchema . optional ( ) ,
85+ intent : z . literal ( 'item/updateComponent/item' ) ,
86+ language : z . string ( ) . min ( 1 ) ,
87+ component : ComponentContentInputSchema ,
88+ itemId : IdSchema . optional ( ) ,
89+ turi : TURISchema . optional ( ) ,
90+ } )
91+ . superRefine ( checkTuriOrId ) ;
92+
93+ export const UpdateSkuComponentOperationSchema = z . object ( {
94+ _ref : RefSchema . optional ( ) ,
95+ intent : z . literal ( 'item/updateComponent/sku' ) ,
6696 language : z . string ( ) . min ( 1 ) ,
6797 component : ComponentContentInputSchema ,
68- sku : z . never ( ) . optional ( ) ,
69- itemId : IdSchema ,
70- } ) ;
71-
72- export const UpdateSkuComponentOperationSchema = UpdateItemComponentOperationSchema . omit ( {
73- intent : true ,
74- itemId : true ,
75- sku : true ,
76- } ) . extend ( {
77- intent : z . literal ( 'item/updateComponent/sku' ) ,
7898 sku : z . string ( ) ,
79- itemId : z . never ( ) . optional ( ) ,
8099} ) ;
81100
82101export const PublishItemOperationSchema = z . object ( {
102+ _ref : RefSchema . optional ( ) ,
83103 intent : z . literal ( 'item/publish' ) ,
84- itemId : IdSchema ,
85104 language : z . string ( ) . min ( 1 ) ,
86105 includeDescendants : z . boolean ( ) . optional ( ) ,
106+ itemId : IdSchema . optional ( ) ,
107+ turi : TURISchema . optional ( ) ,
87108} ) ;
88109
89- export const UnPublishItemOperationSchema = PublishItemOperationSchema . omit ( { intent : true } ) . merge (
90- z . object ( {
91- intent : z . literal ( 'item/unpublish' ) ,
92- } ) ,
93- ) ;
110+ export const UnPublishItemOperationSchema = PublishItemOperationSchema . omit ( { intent : true } ) . extend ( {
111+ intent : z . literal ( 'item/unpublish' ) ,
112+ } ) ;
94113
95114export type UpdateItemComponentOperation = z . infer < typeof UpdateItemComponentOperationSchema > ;
96115export type UpdateSkuComponentOperation = z . infer < typeof UpdateSkuComponentOperationSchema > ;
0 commit comments