@unchainedshop/api 4.8.12 → 5.0.0-alpha.2

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 (111) hide show
  1. package/lib/acl.d.ts +2 -2
  2. package/lib/acl.js +36 -8
  3. package/lib/api-index.d.ts +3 -1
  4. package/lib/chat/generateImageHandler.js +6 -5
  5. package/lib/context.d.ts +3 -1
  6. package/lib/context.js +9 -4
  7. package/lib/events.d.ts +2 -0
  8. package/lib/events.js +2 -0
  9. package/lib/express/createMCPMiddleware.js +1 -1
  10. package/lib/express/index.d.ts +6 -9
  11. package/lib/express/index.js +53 -126
  12. package/lib/fastify/index.d.ts +6 -9
  13. package/lib/fastify/index.js +52 -118
  14. package/lib/fastify/mcpHandler.js +1 -1
  15. package/lib/loaders/buildTextMap.js +6 -3
  16. package/lib/loaders/index.d.ts +0 -25
  17. package/lib/loaders/index.js +0 -10
  18. package/lib/locale-context.d.ts +4 -2
  19. package/lib/locale-context.js +2 -6
  20. package/lib/mcp/tools/assortment/assortmentManagement.d.ts +2 -2
  21. package/lib/mcp/tools/assortment/assortmentManagement.js +2 -2
  22. package/lib/mcp/tools/assortment/schemas.d.ts +322 -141
  23. package/lib/mcp/tools/assortment/schemas.js +179 -96
  24. package/lib/mcp/tools/filter/filterManagement.d.ts +2 -2
  25. package/lib/mcp/tools/filter/filterManagement.js +2 -2
  26. package/lib/mcp/tools/filter/schemas.d.ts +184 -75
  27. package/lib/mcp/tools/filter/schemas.js +87 -51
  28. package/lib/mcp/tools/localization/getLocalizationsConfig.d.ts +1 -1
  29. package/lib/mcp/tools/localization/localizationManagement.d.ts +2 -2
  30. package/lib/mcp/tools/localization/localizationManagement.js +2 -2
  31. package/lib/mcp/tools/localization/schemas.d.ts +144 -47
  32. package/lib/mcp/tools/localization/schemas.js +51 -36
  33. package/lib/mcp/tools/order/handlers/getTopCustomers.d.ts +2 -0
  34. package/lib/mcp/tools/order/orderManagement.d.ts +2 -2
  35. package/lib/mcp/tools/order/orderManagement.js +2 -2
  36. package/lib/mcp/tools/order/schemas.d.ts +184 -75
  37. package/lib/mcp/tools/order/schemas.js +113 -51
  38. package/lib/mcp/tools/product/productManagement.d.ts +2 -2
  39. package/lib/mcp/tools/product/productManagement.js +2 -2
  40. package/lib/mcp/tools/product/schemas.d.ts +642 -317
  41. package/lib/mcp/tools/product/schemas.js +287 -191
  42. package/lib/mcp/tools/provider/providerManagement.d.ts +2 -2
  43. package/lib/mcp/tools/provider/providerManagement.js +2 -2
  44. package/lib/mcp/tools/provider/schemas.d.ts +142 -47
  45. package/lib/mcp/tools/provider/schemas.js +67 -32
  46. package/lib/mcp/tools/quotation/handlers/getQuotation.d.ts +2 -0
  47. package/lib/mcp/tools/quotation/handlers/listQuotations.d.ts +2 -0
  48. package/lib/mcp/tools/quotation/handlers/makeQuotationProposal.d.ts +2 -0
  49. package/lib/mcp/tools/quotation/handlers/rejectQuotation.d.ts +2 -0
  50. package/lib/mcp/tools/quotation/handlers/verifyQuotation.d.ts +2 -0
  51. package/lib/mcp/tools/quotation/quotationManagement.d.ts +2 -2
  52. package/lib/mcp/tools/quotation/quotationManagement.js +2 -2
  53. package/lib/mcp/tools/quotation/schemas.d.ts +111 -40
  54. package/lib/mcp/tools/quotation/schemas.js +54 -29
  55. package/lib/mcp/tools/system/handlers/countEvents.d.ts +8 -1
  56. package/lib/mcp/tools/system/handlers/countWork.d.ts +10 -1
  57. package/lib/mcp/tools/system/handlers/countWork.js +1 -0
  58. package/lib/mcp/tools/system/handlers/index.d.ts +4 -4
  59. package/lib/mcp/tools/system/handlers/listEvents.d.ts +12 -1
  60. package/lib/mcp/tools/system/handlers/listWork.d.ts +14 -1
  61. package/lib/mcp/tools/system/handlers/listWork.js +1 -0
  62. package/lib/mcp/tools/system/schemas.d.ts +179 -84
  63. package/lib/mcp/tools/system/schemas.js +188 -67
  64. package/lib/mcp/tools/system/systemManagement.d.ts +1 -1
  65. package/lib/mcp/tools/system/systemManagement.js +1 -1
  66. package/lib/mcp/tools/users/handlers/addUserEmail.d.ts +2 -0
  67. package/lib/mcp/tools/users/handlers/createUser.d.ts +2 -0
  68. package/lib/mcp/tools/users/handlers/enrollUser.d.ts +2 -0
  69. package/lib/mcp/tools/users/handlers/getCurrentUser.d.ts +2 -0
  70. package/lib/mcp/tools/users/handlers/getUser.d.ts +2 -0
  71. package/lib/mcp/tools/users/handlers/listUsers.d.ts +2 -0
  72. package/lib/mcp/tools/users/handlers/setUserTags.d.ts +2 -0
  73. package/lib/mcp/tools/users/handlers/setUserUsername.d.ts +2 -0
  74. package/lib/mcp/tools/users/handlers/updateUser.d.ts +2 -0
  75. package/lib/mcp/tools/users/schemas.d.ts +296 -163
  76. package/lib/mcp/tools/users/schemas.js +152 -71
  77. package/lib/mcp/tools/users/usersManagement.d.ts +2 -2
  78. package/lib/mcp/tools/users/usersManagement.js +2 -2
  79. package/lib/mcp/utils/getNormalizedQuotationDetails.d.ts +2 -0
  80. package/lib/mcp/utils/getNormalizedUserDetails.d.ts +2 -0
  81. package/lib/mcp/utils/normalizeMediaUrl.js +1 -1
  82. package/lib/mcp/utils/sanitizeLocalizationEntityData.d.ts +1 -1
  83. package/lib/mcp/utils/sharedSchemas.d.ts +28 -39
  84. package/lib/mcp/utils/sharedSchemas.js +28 -47
  85. package/lib/mcp/utils/validateIsoCode.d.ts +1 -1
  86. package/lib/middleware/createAuthMiddleware.js +1 -3
  87. package/lib/resolvers/mutations/accounts/changePassword.js +1 -2
  88. package/lib/resolvers/mutations/index.d.ts +150 -155
  89. package/lib/resolvers/mutations/index.js +2 -12
  90. package/lib/resolvers/mutations/orders/updateCart.js +7 -1
  91. package/lib/resolvers/mutations/users/setRoles.d.ts +1 -1
  92. package/lib/resolvers/mutations/users/setRoles.js +6 -4
  93. package/lib/resolvers/queries/events/registeredEventTypes.d.ts +1 -1
  94. package/lib/resolvers/queries/events/registeredEventTypes.js +1 -1
  95. package/lib/resolvers/queries/index.d.ts +71 -71
  96. package/lib/resolvers/queries/index.js +1 -1
  97. package/lib/resolvers/type/index.d.ts +5 -6
  98. package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +0 -1
  99. package/lib/resolvers/type/order/order-delivery-pickup-types.js +0 -7
  100. package/lib/resolvers/type/order/order-types.d.ts +5 -5
  101. package/lib/resolvers/type/order/order-types.js +27 -12
  102. package/lib/resolvers/type/shop-types.js +1 -1
  103. package/lib/resolvers/type/user-types.js +3 -3
  104. package/lib/roles/index.d.ts +4 -11
  105. package/lib/roles/index.js +16 -11
  106. package/lib/roles/loggedIn.js +2 -1
  107. package/lib/schema/mutation.js +6 -44
  108. package/lib/schema/query.js +5 -5
  109. package/lib/schema/types/index.js +2 -2
  110. package/lib/schema/types/order/delivery.js +0 -2
  111. package/package.json +14 -24
@@ -1,7 +1,7 @@
1
- import { z } from 'zod/v4-mini';
1
+ import { z } from 'zod';
2
2
  import { SortDirection } from '@unchainedshop/utils';
3
3
  import { ProductType, ProductVariationType } from '@unchainedshop/core-products';
4
- import { PaginationSchema, SortingSchema, SearchSchema, LocalizationTextSchema, createManagementSchemaFromValidators, } from "../../utils/sharedSchemas.js";
4
+ import { PaginationSchema, SortingSchema, SearchSchema, LocalizationTextSchema, } from "../../utils/sharedSchemas.js";
5
5
  export const productTypeKeys = Object.keys(ProductType);
6
6
  export const productVariationTypeKeys = Object.keys(ProductVariationType);
7
7
  export const sortDirectionKeys = Object.keys(SortDirection);
@@ -14,299 +14,395 @@ export const ProductPlanConfigurationIntervalEnum = z.enum([
14
14
  'YEARS',
15
15
  ]);
16
16
  export const UpdateProductPlanInputSchema = z.object({
17
- usageCalculationType: ProductPlanUsageCalculationTypeEnum.check(z.describe('The billing usage calculation method')),
18
- billingInterval: ProductPlanConfigurationIntervalEnum.check(z.describe('The interval unit for billing cycles')),
19
- billingIntervalCount: z.int().check(z.positive(), z.describe('Number of billing intervals per cycle')),
20
- trialInterval: z
21
- .optional(ProductPlanConfigurationIntervalEnum)
22
- .check(z.describe('Optional trial period interval')),
23
- trialIntervalCount: z
24
- .optional(z.int().check(z.positive()))
25
- .check(z.describe('Number of trial intervals')),
17
+ usageCalculationType: ProductPlanUsageCalculationTypeEnum.describe('The billing usage calculation method'),
18
+ billingInterval: ProductPlanConfigurationIntervalEnum.describe('The interval unit for billing cycles'),
19
+ billingIntervalCount: z.number().int().positive().describe('Number of billing intervals per cycle'),
20
+ trialInterval: ProductPlanConfigurationIntervalEnum.optional().describe('Optional trial period interval'),
21
+ trialIntervalCount: z.number().int().positive().optional().describe('Number of trial intervals'),
26
22
  });
27
- export const ProductTextInputSchema = z
28
- .extend(LocalizationTextSchema, {
29
- slug: z.optional(z.string()).check(z.describe('URL slug')),
30
- description: z.optional(z.string()).check(z.describe('Markdown description')),
31
- vendor: z.optional(z.string()).check(z.describe('Vendor name')),
32
- brand: z.optional(z.string()).check(z.describe('Brand name')),
33
- labels: z.optional(z.array(z.string())).check(z.describe('Labels or tags')),
34
- })
35
- .check(z.describe('Product localized text data'));
36
- export const ProductVariationTextInputSchema = LocalizationTextSchema.check(z.describe('Product variation localized text data'));
37
- export const ProductMediaTextInputSchema = LocalizationTextSchema.check(z.describe('Product media localized text data'));
23
+ export const ProductTextInputSchema = LocalizationTextSchema.extend({
24
+ slug: z.string().optional().describe('URL slug'),
25
+ description: z.string().optional().describe('Markdown description'),
26
+ vendor: z.string().optional().describe('Vendor name'),
27
+ brand: z.string().optional().describe('Brand name'),
28
+ labels: z.array(z.string()).optional().describe('Labels or tags'),
29
+ }).describe('Product localized text data');
30
+ export const ProductVariationTextInputSchema = LocalizationTextSchema.describe('Product variation localized text data');
31
+ export const ProductMediaTextInputSchema = LocalizationTextSchema.describe('Product media localized text data');
38
32
  export const ProductAssignmentVectorSchema = z.object({
39
- key: z.string().check(z.minLength(1), z.describe('Attribute key (e.g., "Color", "Size")')),
40
- value: z.string().check(z.minLength(1), z.describe('Attribute value (e.g., "Red", "M")')),
33
+ key: z.string().min(1).describe('Attribute key (e.g., "Color", "Size")'),
34
+ value: z.string().min(1).describe('Attribute value (e.g., "Red", "M")'),
41
35
  });
42
36
  export const ProductSchema = z.object({
43
- type: z.optional(z.enum(productTypeKeys)).check(z.describe('Product type (required for CREATE)')),
44
- tags: z
45
- .optional(z.array(z.string().check(z.minLength(1), z.toLowerCase())))
46
- .check(z.describe('Tags (lowercased strings)')),
47
- sequence: z.optional(z.int()).check(z.describe('Sorting sequence')),
48
- meta: z.optional(z.record(z.any(), z.any())).check(z.describe('Custom metadata as key-value pairs')),
49
- plan: z
50
- .optional(UpdateProductPlanInputSchema)
51
- .check(z.describe('Plan configuration - ONLY for PLAN_PRODUCT')),
37
+ type: z.enum(productTypeKeys).optional().describe('Product type (required for CREATE)'),
38
+ tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Tags (lowercased strings)'),
39
+ sequence: z.number().int().optional().describe('Sorting sequence'),
40
+ meta: z.record(z.any(), z.any()).optional().describe('Custom metadata as key-value pairs'),
41
+ plan: UpdateProductPlanInputSchema.optional().describe('Plan configuration - ONLY for PLAN_PRODUCT'),
52
42
  warehousing: z
53
- .optional(z.object({
54
- sku: z.optional(z.string().check(z.minLength(1))).check(z.describe('Stock keeping unit')),
55
- baseUnit: z
56
- .optional(z.string().check(z.minLength(1)))
57
- .check(z.describe('Base unit (e.g., "piece", "kg")')),
58
- }))
59
- .check(z.describe('Warehousing details - ONLY for SIMPLE_PRODUCT')),
43
+ .object({
44
+ sku: z.string().min(1).optional().describe('Stock keeping unit'),
45
+ baseUnit: z.string().min(1).optional().describe('Base unit (e.g., "piece", "kg")'),
46
+ })
47
+ .optional()
48
+ .describe('Warehousing details - ONLY for SIMPLE_PRODUCT'),
60
49
  supply: z
61
- .optional(z.object({
62
- weightInGram: z.optional(z.int().check(z.positive())).check(z.describe('Weight in grams')),
63
- heightInMillimeters: z
64
- .optional(z.int().check(z.positive()))
65
- .check(z.describe('Height in millimeters')),
66
- lengthInMillimeters: z
67
- .optional(z.int().check(z.positive()))
68
- .check(z.describe('Length in millimeters')),
69
- widthInMillimeters: z
70
- .optional(z.int().check(z.positive()))
71
- .check(z.describe('Width in millimeters')),
72
- }))
73
- .check(z.describe('Supply attributes - ONLY for SIMPLE_PRODUCT')),
50
+ .object({
51
+ weightInGram: z.number().int().positive().optional().describe('Weight in grams'),
52
+ heightInMillimeters: z.number().int().positive().optional().describe('Height in millimeters'),
53
+ lengthInMillimeters: z.number().int().positive().optional().describe('Length in millimeters'),
54
+ widthInMillimeters: z.number().int().positive().optional().describe('Width in millimeters'),
55
+ })
56
+ .optional()
57
+ .describe('Supply attributes - ONLY for SIMPLE_PRODUCT'),
74
58
  tokenization: z
75
- .optional(z.object({
76
- contractAddress: z.string().check(z.minLength(1), z.describe('Blockchain contract address')),
77
- contractStandard: z.string().check(z.describe('Smart contract standard (e.g., ERC-721)')),
78
- tokenId: z.string().check(z.minLength(1), z.describe('Unique token identifier')),
79
- supply: z.int().check(z.positive(), z.describe('Total supply of the token')),
59
+ .object({
60
+ contractAddress: z.string().min(1).describe('Blockchain contract address'),
61
+ contractStandard: z.string().describe('Smart contract standard (e.g., ERC-721)'),
62
+ tokenId: z.string().min(1).describe('Unique token identifier'),
63
+ supply: z.number().int().positive().describe('Total supply of the token'),
80
64
  ercMetadataProperties: z
81
- .optional(z.record(z.any(), z.any()))
82
- .check(z.describe('Optional ERC metadata properties')),
83
- }))
84
- .check(z.describe('Tokenization details - ONLY for TOKENIZED_PRODUCT')),
65
+ .record(z.any(), z.any())
66
+ .optional()
67
+ .describe('Optional ERC metadata properties'),
68
+ })
69
+ .optional()
70
+ .describe('Tokenization details - ONLY for TOKENIZED_PRODUCT'),
85
71
  commerce: z
86
- .optional(z.object({
72
+ .object({
87
73
  pricing: z
88
74
  .array(z.object({
89
- amount: z.int().check(z.describe('Price amount in smallest currency unit.')),
75
+ amount: z.number().int().describe('Price amount in smallest currency unit.'),
90
76
  maxQuantity: z
91
- .optional(z.int())
92
- .check(z.describe('Optional maximum quantity for this price tier')),
93
- isTaxable: z.optional(z.boolean()).check(z.describe('Whether tax applies to this price')),
94
- isNetPrice: z
95
- .optional(z.boolean())
96
- .check(z.describe('Whether this is a net price (without tax)')),
77
+ .number()
78
+ .int()
79
+ .optional()
80
+ .describe('Optional maximum quantity for this price tier'),
81
+ isTaxable: z.boolean().optional().describe('Whether tax applies to this price'),
82
+ isNetPrice: z.boolean().optional().describe('Whether this is a net price (without tax)'),
97
83
  currencyCode: z
98
84
  .string()
99
- .check(z.minLength(3), z.maxLength(3), z.describe('ISO currency code (e.g., USD, EUR). Must match an available currency from the shop currencies resource. If it does not exist, prompt the user to add the currency. NEVER add it automatically unless explicitly specified by the user.')),
85
+ .min(3)
86
+ .max(3)
87
+ .describe('ISO currency code (e.g., USD, EUR). Must match an available currency from the shop currencies resource. If it does not exist, prompt the user to add the currency. NEVER add it automatically unless explicitly specified by the user.'),
100
88
  countryCode: z
101
89
  .string()
102
- .check(z.minLength(2), z.maxLength(2), z.describe('ISO country code (e.g., US, DE). Must match an available country from the shop countries resource. If it does not exist, prompt the user to add the country. NEVER add it automatically unless explicitly specified by the user.')),
90
+ .min(2)
91
+ .max(2)
92
+ .describe('ISO country code (e.g., US, DE). Must match an available country from the shop countries resource. If it does not exist, prompt the user to add the country. NEVER add it automatically unless explicitly specified by the user.'),
103
93
  }))
104
- .check(z.minLength(1), z.describe('List of price configurations. Use only countryCode and currencyCode values from the shop resources.')),
105
- }))
106
- .check(z.describe('Commerce info - Available for ALL except CONFIGURABLE_PRODUCT. Use only registered countries and currencies from shop resources.')),
94
+ .nonempty()
95
+ .describe('List of price configurations. Use only countryCode and currencyCode values from the shop resources.'),
96
+ })
97
+ .optional()
98
+ .describe('Commerce info - Available for ALL except CONFIGURABLE_PRODUCT. Use only registered countries and currencies from shop resources.'),
107
99
  });
108
100
  export const actionValidators = {
109
101
  CREATE: z.object({
110
- product: z
111
- .extend(ProductSchema, {
112
- type: z.enum(productTypeKeys).check(z.describe('Product type (required for CREATE)')),
113
- })
114
- .check(z.describe('Product data with type required')),
115
- texts: z
116
- .optional(z.array(ProductTextInputSchema))
117
- .check(z.describe('Localized product text entries')),
102
+ product: ProductSchema.extend({
103
+ type: z.enum(productTypeKeys).describe('Product type (required for CREATE)'),
104
+ }).describe('Product data with type required'),
105
+ texts: z.array(ProductTextInputSchema).optional().describe('Localized product text entries'),
118
106
  }),
119
107
  UPDATE: z.object({
120
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
121
- product: ProductSchema.check(z.describe('Product data to update')),
108
+ productId: z.string().min(1).describe('Product ID'),
109
+ product: ProductSchema.describe('Product data to update'),
122
110
  }),
123
111
  REMOVE: z.object({
124
112
  productId: z
125
113
  .string()
126
- .check(z.minLength(1), z.describe('Product ID, (the product status to remove must be inactive or in DRAFT state other wise it will throw error) so if it is active please unpublish it first before removing the product')),
114
+ .min(1)
115
+ .describe('Product ID, (the product status to remove must be inactive or in DRAFT state other wise it will throw error) so if it is active please unpublish it first before removing the product'),
127
116
  }),
128
117
  GET: z
129
118
  .object({
130
- productId: z.optional(z.string().check(z.minLength(1))).check(z.describe('Product ID')),
131
- slug: z.optional(z.string()).check(z.describe('Product slug')),
132
- sku: z.optional(z.string()).check(z.describe('Product SKU')),
119
+ productId: z.string().min(1).optional().describe('Product ID'),
120
+ slug: z.string().optional().describe('Product slug'),
121
+ sku: z.string().optional().describe('Product SKU'),
133
122
  })
134
- .check(z.refine((data) => data.productId || data.slug || data.sku, {
123
+ .refine((data) => data.productId || data.slug || data.sku, {
135
124
  message: 'Either productId, slug, or sku is required',
136
- })),
125
+ }),
137
126
  LIST: z.object({
138
127
  ...PaginationSchema,
139
128
  ...SortingSchema,
140
129
  ...SearchSchema,
141
- tags: z
142
- .optional(z.array(z.string().check(z.minLength(1), z.toLowerCase())))
143
- .check(z.describe('Filter by tags')),
144
- slugs: z
145
- .optional(z.array(z.string().check(z.minLength(1))))
146
- .check(z.describe('Filter by product slugs')),
147
- includeDrafts: z.optional(z.boolean()).check(z.describe('Include draft/unpublished products')),
130
+ tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Filter by tags'),
131
+ slugs: z.array(z.string().min(1)).optional().describe('Filter by product slugs'),
132
+ includeDrafts: z.boolean().optional().describe('Include draft/unpublished products'),
148
133
  }),
149
134
  COUNT: z.object({
150
135
  ...SearchSchema,
151
- tags: z
152
- .optional(z.array(z.string().check(z.minLength(1), z.toLowerCase())))
153
- .check(z.describe('Filter by tags')),
154
- slugs: z
155
- .optional(z.array(z.string().check(z.minLength(1))))
156
- .check(z.describe('Filter by product slugs')),
157
- includeDrafts: z.optional(z.boolean()).check(z.describe('Include draft/unpublished products')),
136
+ tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Filter by tags'),
137
+ slugs: z.array(z.string().min(1)).optional().describe('Filter by product slugs'),
138
+ includeDrafts: z.boolean().optional().describe('Include draft/unpublished products'),
158
139
  }),
159
140
  UPDATE_STATUS: z.object({
160
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
161
- statusAction: z.enum(['PUBLISH', 'UNPUBLISH']).check(z.describe('Status action')),
141
+ productId: z.string().min(1).describe('Product ID'),
142
+ statusAction: z.enum(['PUBLISH', 'UNPUBLISH']).describe('Status action'),
162
143
  }),
163
144
  ADD_MEDIA: z.object({
164
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
165
- mediaName: z.string().check(z.minLength(1), z.describe('Media file name')),
166
- url: z.url().check(z.describe('Media URL')),
145
+ productId: z.string().min(1).describe('Product ID'),
146
+ mediaName: z.string().min(1).describe('Media file name'),
147
+ url: z.string().url().describe('Media URL'),
167
148
  }),
168
149
  REMOVE_MEDIA: z.object({
169
- productMediaId: z.string().check(z.minLength(1), z.describe('Product media ID')),
150
+ productMediaId: z.string().min(1).describe('Product media ID'),
170
151
  }),
171
152
  REORDER_MEDIA: z.object({
172
153
  sortKeys: z
173
154
  .array(z.object({
174
- productMediaId: z.string().check(z.minLength(1), z.describe('Media asset ID')),
175
- sortKey: z.int().check(z.describe('New sort position')),
155
+ productMediaId: z.string().min(1).describe('Media asset ID'),
156
+ sortKey: z.number().int().describe('New sort position'),
176
157
  }))
177
- .check(z.minLength(1), z.describe('Sort keys')),
158
+ .nonempty()
159
+ .describe('Sort keys'),
178
160
  }),
179
161
  GET_MEDIA: z.object({
180
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
181
- tags: z
182
- .optional(z.array(z.string().check(z.minLength(1), z.toLowerCase())))
183
- .check(z.describe('Filter by tags')),
162
+ productId: z.string().min(1).describe('Product ID'),
163
+ tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Filter by tags'),
184
164
  ...PaginationSchema,
185
165
  }),
186
166
  UPDATE_MEDIA_TEXTS: z.object({
187
- productMediaId: z.string().check(z.minLength(1), z.describe('Product media ID')),
188
- mediaTexts: z.array(ProductMediaTextInputSchema).check(z.describe('Media texts')),
167
+ productMediaId: z.string().min(1).describe('Product media ID'),
168
+ mediaTexts: z.array(ProductMediaTextInputSchema).describe('Media texts'),
189
169
  }),
190
170
  CREATE_VARIATION: z.object({
191
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
171
+ productId: z.string().min(1).describe('Product ID'),
192
172
  variation: z
193
173
  .object({
194
- key: z
195
- .string()
196
- .check(z.minLength(1), z.describe('Unique variation key (e.g., "Color", "Size")')),
197
- type: z.enum(productVariationTypeKeys).check(z.describe('Variation type')),
174
+ key: z.string().min(1).describe('Unique variation key (e.g., "Color", "Size")'),
175
+ type: z.enum(productVariationTypeKeys).describe('Variation type'),
198
176
  })
199
- .check(z.describe('Variation definition')),
200
- variationTexts: z
201
- .optional(z.array(ProductVariationTextInputSchema))
202
- .check(z.describe('Variation texts')),
177
+ .describe('Variation definition'),
178
+ variationTexts: z.array(ProductVariationTextInputSchema).optional().describe('Variation texts'),
203
179
  }),
204
180
  REMOVE_VARIATION: z.object({
205
- productVariationId: z.string().check(z.minLength(1), z.describe('Product variation ID')),
181
+ productVariationId: z.string().min(1).describe('Product variation ID'),
206
182
  }),
207
183
  ADD_VARIATION_OPTION: z.object({
208
- productVariationId: z.string().check(z.minLength(1), z.describe('Product variation ID')),
209
- option: z.string().check(z.minLength(1), z.describe('Option value')),
210
- variationTexts: z
211
- .optional(z.array(ProductVariationTextInputSchema))
212
- .check(z.describe('Variation texts')),
184
+ productVariationId: z.string().min(1).describe('Product variation ID'),
185
+ option: z.string().min(1).describe('Option value'),
186
+ variationTexts: z.array(ProductVariationTextInputSchema).optional().describe('Variation texts'),
213
187
  }),
214
188
  REMOVE_VARIATION_OPTION: z.object({
215
- productVariationId: z.string().check(z.minLength(1), z.describe('Product variation ID')),
216
- productVariationOptionValue: z.string().check(z.minLength(1), z.describe('Option value')),
189
+ productVariationId: z.string().min(1).describe('Product variation ID'),
190
+ productVariationOptionValue: z.string().min(1).describe('Option value'),
217
191
  }),
218
192
  UPDATE_VARIATION_TEXTS: z.object({
219
- productVariationId: z.string().check(z.minLength(1), z.describe('Product variation ID')),
220
- variationTexts: z.array(ProductVariationTextInputSchema).check(z.describe('Variation texts')),
221
- productVariationOptionValue: z
222
- .optional(z.string().check(z.minLength(1)))
223
- .check(z.describe('Option value')),
193
+ productVariationId: z.string().min(1).describe('Product variation ID'),
194
+ variationTexts: z.array(ProductVariationTextInputSchema).describe('Variation texts'),
195
+ productVariationOptionValue: z.string().min(1).optional().describe('Option value'),
224
196
  }),
225
197
  GET_VARIATION_PRODUCTS: z.object({
226
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
227
- vectors: z.array(ProductAssignmentVectorSchema).check(z.describe('Variation vectors')),
228
- includeInactive: z._default(z.boolean(), true).check(z.describe('Include inactive products')),
198
+ productId: z.string().min(1).describe('Product ID'),
199
+ vectors: z.array(ProductAssignmentVectorSchema).describe('Variation vectors'),
200
+ includeInactive: z.boolean().optional().default(true).describe('Include inactive products'),
229
201
  }),
230
202
  GET_ASSIGNMENTS: z.object({
231
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
232
- includeInactive: z.optional(z.boolean()).check(z.describe('Include inactive assignments')),
203
+ productId: z.string().min(1).describe('Product ID'),
204
+ includeInactive: z.boolean().optional().describe('Include inactive assignments'),
233
205
  }),
234
206
  ADD_ASSIGNMENT: z.object({
235
- proxyId: z.string().check(z.minLength(1), z.describe('Proxy product ID')),
236
- assignProductId: z.string().check(z.minLength(1), z.describe('Product to assign')),
237
- vectors: z.array(ProductAssignmentVectorSchema).check(z.describe('Variation vectors')),
207
+ proxyId: z.string().min(1).describe('Proxy product ID'),
208
+ assignProductId: z.string().min(1).describe('Product to assign'),
209
+ vectors: z.array(ProductAssignmentVectorSchema).describe('Variation vectors'),
238
210
  }),
239
211
  REMOVE_ASSIGNMENT: z.object({
240
- proxyId: z.string().check(z.minLength(1), z.describe('Proxy product ID')),
241
- vectors: z.array(ProductAssignmentVectorSchema).check(z.describe('Variation vectors')),
212
+ proxyId: z.string().min(1).describe('Proxy product ID'),
213
+ vectors: z.array(ProductAssignmentVectorSchema).describe('Variation vectors'),
242
214
  }),
243
215
  ADD_BUNDLE_ITEM: z.object({
244
- bundleId: z.string().check(z.minLength(1), z.describe('Bundle product ID')),
245
- bundleProductId: z.string().check(z.minLength(1), z.describe('Product to add to bundle')),
246
- quantity: z._default(z.int().check(z.positive()), 1).check(z.describe('Quantity')),
216
+ bundleId: z.string().min(1).describe('Bundle product ID'),
217
+ bundleProductId: z.string().min(1).describe('Product to add to bundle'),
218
+ quantity: z.number().int().positive().default(1).describe('Quantity'),
247
219
  }),
248
220
  REMOVE_BUNDLE_ITEM: z.object({
249
- bundleId: z.string().check(z.minLength(1), z.describe('Bundle product ID')),
250
- index: z.int().check(z.gte(0), z.describe('Bundle item index')),
221
+ bundleId: z.string().min(1).describe('Bundle product ID'),
222
+ index: z.number().int().min(0).describe('Bundle item index'),
251
223
  }),
252
224
  GET_BUNDLE_ITEMS: z.object({
253
- bundleId: z.string().check(z.minLength(1), z.describe('Bundle product ID')),
225
+ bundleId: z.string().min(1).describe('Bundle product ID'),
254
226
  }),
255
227
  GET_CATALOG_PRICE: z.object({
256
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
257
- quantity: z.optional(z.int().check(z.positive())).check(z.describe('Quantity')),
258
- currencyCode: z
259
- .optional(z.string().check(z.minLength(3), z.maxLength(3)))
260
- .check(z.describe('ISO currency code')),
228
+ productId: z.string().min(1).describe('Product ID'),
229
+ quantity: z.number().int().positive().optional().describe('Quantity'),
230
+ currencyCode: z.string().min(3).max(3).optional().describe('ISO currency code'),
261
231
  }),
262
232
  SIMULATE_PRICE: z.object({
263
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
264
- vectors: z.optional(z.array(ProductAssignmentVectorSchema)).check(z.describe('Variation vectors')),
265
- quantity: z.optional(z.int().check(z.positive())).check(z.describe('Quantity')),
266
- currencyCode: z
267
- .optional(z.string().check(z.minLength(3), z.maxLength(3)))
268
- .check(z.describe('ISO currency code')),
269
- useNetPrice: z.optional(z.boolean()).check(z.describe('Whether to use net price')),
233
+ productId: z.string().min(1).describe('Product ID'),
234
+ vectors: z.array(ProductAssignmentVectorSchema).optional().describe('Variation vectors'),
235
+ quantity: z.number().int().positive().optional().describe('Quantity'),
236
+ currencyCode: z.string().min(3).max(3).optional().describe('ISO currency code'),
237
+ useNetPrice: z.boolean().optional().describe('Whether to use net price'),
270
238
  }),
271
239
  SIMULATE_PRICE_RANGE: z.object({
272
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
273
- vectors: z.optional(z.array(ProductAssignmentVectorSchema)).check(z.describe('Variation vectors')),
274
- quantity: z.optional(z.int().check(z.positive())).check(z.describe('Quantity')),
275
- currencyCode: z
276
- .optional(z.string().check(z.minLength(3), z.maxLength(3)))
277
- .check(z.describe('ISO currency code')),
278
- useNetPrice: z.optional(z.boolean()).check(z.describe('Whether to use net price')),
240
+ productId: z.string().min(1).describe('Product ID'),
241
+ vectors: z.array(ProductAssignmentVectorSchema).optional().describe('Variation vectors'),
242
+ quantity: z.number().int().positive().optional().describe('Quantity'),
243
+ currencyCode: z.string().min(3).max(3).optional().describe('ISO currency code'),
244
+ useNetPrice: z.boolean().optional().describe('Whether to use net price'),
279
245
  }),
280
246
  GET_PRODUCT_TEXTS: z.object({
281
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
247
+ productId: z.string().min(1).describe('Product ID'),
282
248
  }),
283
249
  GET_VARIATION_TEXTS: z.object({
284
- productVariationId: z.string().check(z.minLength(1), z.describe('Product variation ID')),
285
- productVariationOptionValue: z
286
- .optional(z.string().check(z.minLength(1)))
287
- .check(z.describe('Option value')),
250
+ productVariationId: z.string().min(1).describe('Product variation ID'),
251
+ productVariationOptionValue: z.string().min(1).optional().describe('Option value'),
288
252
  }),
289
253
  GET_MEDIA_TEXTS: z.object({
290
- productMediaId: z.string().check(z.minLength(1), z.describe('Product media ID')),
254
+ productMediaId: z.string().min(1).describe('Product media ID'),
291
255
  }),
292
256
  GET_REVIEWS: z.object({
293
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
257
+ productId: z.string().min(1).describe('Product ID'),
294
258
  ...PaginationSchema,
295
259
  ...SortingSchema,
296
260
  ...SearchSchema,
297
261
  }),
298
262
  COUNT_REVIEWS: z.object({
299
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
263
+ productId: z.string().min(1).describe('Product ID'),
300
264
  ...SearchSchema,
301
265
  }),
302
266
  GET_SIBLINGS: z.object({
303
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
304
- assortmentId: z.optional(z.string()).check(z.describe('Assortment ID')),
305
- includeInactive: z.optional(z.boolean()).check(z.describe('Include inactive products')),
267
+ productId: z.string().min(1).describe('Product ID'),
268
+ assortmentId: z.string().optional().describe('Assortment ID'),
269
+ includeInactive: z.boolean().optional().describe('Include inactive products'),
306
270
  }),
307
271
  UPDATE_PRODUCT_TEXTS: z.object({
308
- productId: z.string().check(z.minLength(1), z.describe('Product ID')),
309
- texts: z.array(ProductTextInputSchema).check(z.describe('Product texts to update')),
272
+ productId: z.string().min(1).describe('Product ID'),
273
+ texts: z.array(ProductTextInputSchema).describe('Product texts to update'),
310
274
  }),
311
275
  };
312
- export const ProductManagementSchema = createManagementSchemaFromValidators(actionValidators);
276
+ export const ProductManagementSchema = {
277
+ action: z
278
+ .enum([
279
+ 'CREATE',
280
+ 'UPDATE',
281
+ 'REMOVE',
282
+ 'GET',
283
+ 'LIST',
284
+ 'COUNT',
285
+ 'UPDATE_STATUS',
286
+ 'ADD_MEDIA',
287
+ 'REMOVE_MEDIA',
288
+ 'REORDER_MEDIA',
289
+ 'GET_MEDIA',
290
+ 'UPDATE_MEDIA_TEXTS',
291
+ 'CREATE_VARIATION',
292
+ 'REMOVE_VARIATION',
293
+ 'ADD_VARIATION_OPTION',
294
+ 'REMOVE_VARIATION_OPTION',
295
+ 'ADD_ASSIGNMENT',
296
+ 'REMOVE_ASSIGNMENT',
297
+ 'GET_ASSIGNMENTS',
298
+ 'GET_VARIATION_PRODUCTS',
299
+ 'UPDATE_VARIATION_TEXTS',
300
+ 'ADD_BUNDLE_ITEM',
301
+ 'REMOVE_BUNDLE_ITEM',
302
+ 'GET_BUNDLE_ITEMS',
303
+ 'SIMULATE_PRICE',
304
+ 'SIMULATE_PRICE_RANGE',
305
+ 'GET_CATALOG_PRICE',
306
+ 'GET_PRODUCT_TEXTS',
307
+ 'GET_MEDIA_TEXTS',
308
+ 'GET_VARIATION_TEXTS',
309
+ 'GET_REVIEWS',
310
+ 'COUNT_REVIEWS',
311
+ 'GET_SIBLINGS',
312
+ 'UPDATE_PRODUCT_TEXTS',
313
+ ])
314
+ .describe('Product management action to perform'),
315
+ productId: z
316
+ .string()
317
+ .min(1)
318
+ .optional()
319
+ .describe('Product ID (required for most actions except CREATE, LIST, COUNT)'),
320
+ slug: z.string().optional().describe('Product slug (alternative to productId for GET action)'),
321
+ sku: z.string().optional().describe('Product SKU (alternative to productId for GET action)'),
322
+ productMediaId: z
323
+ .string()
324
+ .min(1)
325
+ .optional()
326
+ .describe('Product media ID (required for media-specific actions)'),
327
+ productVariationId: z
328
+ .string()
329
+ .min(1)
330
+ .optional()
331
+ .describe('Product variation ID (required for variation-specific actions)'),
332
+ product: ProductSchema.optional().describe('Product data object for CREATE/UPDATE actions'),
333
+ texts: z
334
+ .array(ProductTextInputSchema)
335
+ .optional()
336
+ .describe('Localized product text entries for CREATE action'),
337
+ statusAction: z
338
+ .enum(['PUBLISH', 'UNPUBLISH'])
339
+ .optional()
340
+ .describe('Status action for UPDATE_STATUS action'),
341
+ mediaName: z.string().min(1).optional().describe('Media file name for ADD_MEDIA action'),
342
+ url: z.string().url().optional().describe('Media URL for ADD_MEDIA action'),
343
+ sortKeys: z
344
+ .array(z.object({
345
+ productMediaId: z.string().min(1).describe('Media asset ID'),
346
+ sortKey: z.number().int().describe('New sort position'),
347
+ }))
348
+ .optional()
349
+ .describe('Sort keys for REORDER_MEDIA action'),
350
+ mediaTexts: z
351
+ .array(ProductMediaTextInputSchema)
352
+ .optional()
353
+ .describe('Media text updates for UPDATE_MEDIA_TEXTS action'),
354
+ tags: z.array(z.string()).optional().describe('Media tags filter for GET_MEDIA action'),
355
+ variation: z
356
+ .object({
357
+ key: z.string().min(1).describe('Unique variation key (e.g., "Color", "Size")'),
358
+ type: z.enum(productVariationTypeKeys).describe('Variation type from ProductVariationType enum'),
359
+ })
360
+ .optional()
361
+ .describe('Variation definition for CREATE_VARIATION action'),
362
+ option: z
363
+ .string()
364
+ .min(1)
365
+ .optional()
366
+ .describe('Option value for ADD_VARIATION_OPTION action (e.g., "Red", "Large")'),
367
+ productVariationOptionValue: z
368
+ .string()
369
+ .min(1)
370
+ .optional()
371
+ .describe('Option value for REMOVE_VARIATION_OPTION action'),
372
+ variationTexts: z
373
+ .array(ProductVariationTextInputSchema)
374
+ .optional()
375
+ .describe('Variation text updates for UPDATE_VARIATION_TEXTS action'),
376
+ assignProductId: z
377
+ .string()
378
+ .min(1)
379
+ .optional()
380
+ .describe('Product to assign (ADD_ASSIGNMENT/REMOVE_ASSIGNMENT actions)'),
381
+ proxyId: z.string().min(1).optional().describe('CONFIGURABLE_PRODUCT ID for assignments'),
382
+ vectors: z
383
+ .array(ProductAssignmentVectorSchema)
384
+ .optional()
385
+ .describe('Complete variation combination vectors'),
386
+ includeInactive: z.boolean().optional().describe('Include inactive variants in results'),
387
+ bundleId: z
388
+ .string()
389
+ .min(1)
390
+ .optional()
391
+ .describe('Bundle product ID for ADD_BUNDLE_ITEM/REMOVE_BUNDLE_ITEM actions'),
392
+ bundleProductId: z
393
+ .string()
394
+ .min(1)
395
+ .optional()
396
+ .describe('Product to add to bundle for ADD_BUNDLE_ITEM action'),
397
+ index: z.number().int().min(0).optional().describe('Bundle item index for REMOVE_BUNDLE_ITEM action'),
398
+ quantity: z.number().int().positive().optional().describe('Quantity for pricing calculations'),
399
+ currencyCode: z.string().min(3).max(3).optional().describe('ISO currency code for pricing'),
400
+ useNetPrice: z.boolean().optional().describe('Whether to use net price in calculations'),
401
+ ...PaginationSchema,
402
+ ...SortingSchema,
403
+ ...SearchSchema,
404
+ includeDrafts: z.boolean().optional().describe('Include draft products in results'),
405
+ productIds: z.array(z.string()).optional().describe('Filter by specific product IDs'),
406
+ assortmentId: z.string().optional().describe('Filter by assortment ID (for GET_SIBLINGS action)'),
407
+ };
408
+ export const ProductManagementZodSchema = z.object(ProductManagementSchema);
@@ -1,6 +1,6 @@
1
1
  import type { Context } from '../../../context.ts';
2
- import { ProviderManagementSchema, type ProviderManagementParams } from './schemas.ts';
3
- export { ProviderManagementSchema };
2
+ import { ProviderManagementSchema, ProviderManagementZodSchema, type ProviderManagementParams } from './schemas.ts';
3
+ export { ProviderManagementSchema, ProviderManagementZodSchema };
4
4
  export type { ProviderManagementParams };
5
5
  export declare function providerManagement(context: Context, params: ProviderManagementParams): Promise<{
6
6
  content: {
@@ -1,8 +1,8 @@
1
1
  import { log } from '@unchainedshop/logger';
2
- import { actionValidators, ProviderManagementSchema, } from "./schemas.js";
2
+ import { actionValidators, ProviderManagementSchema, ProviderManagementZodSchema, } from "./schemas.js";
3
3
  import actionHandlers from "./handlers/index.js";
4
4
  import { createMcpErrorResponse, createMcpResponse } from "../../utils/sharedSchemas.js";
5
- export { ProviderManagementSchema };
5
+ export { ProviderManagementSchema, ProviderManagementZodSchema };
6
6
  export async function providerManagement(context, params) {
7
7
  const { action, ...actionParams } = params;
8
8
  log('MCP providerManagement', { userId: context.userId, params });