@unchainedshop/api 4.7.2 → 4.8.1

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 (96) hide show
  1. package/lib/acl.js +1 -29
  2. package/lib/api-index.d.ts +0 -1
  3. package/lib/chat/generateImageHandler.js +5 -6
  4. package/lib/context.d.ts +0 -1
  5. package/lib/context.js +3 -8
  6. package/lib/events.d.ts +0 -2
  7. package/lib/events.js +0 -2
  8. package/lib/express/createMCPMiddleware.js +1 -1
  9. package/lib/express/index.d.ts +9 -6
  10. package/lib/express/index.js +125 -52
  11. package/lib/fastify/index.d.ts +9 -6
  12. package/lib/fastify/index.js +113 -51
  13. package/lib/fastify/mcpHandler.js +1 -1
  14. package/lib/loaders/buildTextMap.js +13 -15
  15. package/lib/mcp/tools/assortment/assortmentManagement.d.ts +2 -2
  16. package/lib/mcp/tools/assortment/assortmentManagement.js +2 -2
  17. package/lib/mcp/tools/assortment/handlers/getAssortment.js +1 -1
  18. package/lib/mcp/tools/assortment/schemas.d.ts +141 -322
  19. package/lib/mcp/tools/assortment/schemas.js +96 -179
  20. package/lib/mcp/tools/filter/filterManagement.d.ts +2 -2
  21. package/lib/mcp/tools/filter/filterManagement.js +2 -2
  22. package/lib/mcp/tools/filter/schemas.d.ts +75 -184
  23. package/lib/mcp/tools/filter/schemas.js +51 -87
  24. package/lib/mcp/tools/localization/getLocalizationsConfig.d.ts +1 -1
  25. package/lib/mcp/tools/localization/localizationManagement.d.ts +2 -2
  26. package/lib/mcp/tools/localization/localizationManagement.js +2 -2
  27. package/lib/mcp/tools/localization/schemas.d.ts +47 -144
  28. package/lib/mcp/tools/localization/schemas.js +36 -51
  29. package/lib/mcp/tools/order/handlers/getTopCustomers.d.ts +0 -2
  30. package/lib/mcp/tools/order/orderManagement.d.ts +2 -2
  31. package/lib/mcp/tools/order/orderManagement.js +2 -2
  32. package/lib/mcp/tools/order/schemas.d.ts +75 -184
  33. package/lib/mcp/tools/order/schemas.js +51 -113
  34. package/lib/mcp/tools/product/handlers/getProduct.js +1 -1
  35. package/lib/mcp/tools/product/productManagement.d.ts +2 -2
  36. package/lib/mcp/tools/product/productManagement.js +2 -2
  37. package/lib/mcp/tools/product/schemas.d.ts +317 -642
  38. package/lib/mcp/tools/product/schemas.js +191 -287
  39. package/lib/mcp/tools/provider/providerManagement.d.ts +2 -2
  40. package/lib/mcp/tools/provider/providerManagement.js +2 -2
  41. package/lib/mcp/tools/provider/schemas.d.ts +47 -142
  42. package/lib/mcp/tools/provider/schemas.js +32 -67
  43. package/lib/mcp/tools/quotation/handlers/getQuotation.d.ts +0 -2
  44. package/lib/mcp/tools/quotation/handlers/listQuotations.d.ts +0 -2
  45. package/lib/mcp/tools/quotation/handlers/makeQuotationProposal.d.ts +0 -2
  46. package/lib/mcp/tools/quotation/handlers/rejectQuotation.d.ts +0 -2
  47. package/lib/mcp/tools/quotation/handlers/verifyQuotation.d.ts +0 -2
  48. package/lib/mcp/tools/quotation/quotationManagement.d.ts +2 -2
  49. package/lib/mcp/tools/quotation/quotationManagement.js +2 -2
  50. package/lib/mcp/tools/quotation/schemas.d.ts +40 -111
  51. package/lib/mcp/tools/quotation/schemas.js +29 -54
  52. package/lib/mcp/tools/system/handlers/countEvents.d.ts +1 -8
  53. package/lib/mcp/tools/system/handlers/countWork.d.ts +1 -10
  54. package/lib/mcp/tools/system/handlers/countWork.js +0 -1
  55. package/lib/mcp/tools/system/handlers/index.d.ts +4 -4
  56. package/lib/mcp/tools/system/handlers/listEvents.d.ts +1 -12
  57. package/lib/mcp/tools/system/handlers/listWork.d.ts +1 -14
  58. package/lib/mcp/tools/system/handlers/listWork.js +0 -1
  59. package/lib/mcp/tools/system/schemas.d.ts +84 -179
  60. package/lib/mcp/tools/system/schemas.js +67 -188
  61. package/lib/mcp/tools/system/systemManagement.d.ts +1 -1
  62. package/lib/mcp/tools/system/systemManagement.js +1 -1
  63. package/lib/mcp/tools/users/handlers/addUserEmail.d.ts +0 -2
  64. package/lib/mcp/tools/users/handlers/createUser.d.ts +0 -2
  65. package/lib/mcp/tools/users/handlers/enrollUser.d.ts +0 -2
  66. package/lib/mcp/tools/users/handlers/getCurrentUser.d.ts +0 -2
  67. package/lib/mcp/tools/users/handlers/getUser.d.ts +0 -2
  68. package/lib/mcp/tools/users/handlers/listUsers.d.ts +0 -2
  69. package/lib/mcp/tools/users/handlers/setUserTags.d.ts +0 -2
  70. package/lib/mcp/tools/users/handlers/setUserUsername.d.ts +0 -2
  71. package/lib/mcp/tools/users/handlers/updateUser.d.ts +0 -2
  72. package/lib/mcp/tools/users/schemas.d.ts +163 -296
  73. package/lib/mcp/tools/users/schemas.js +71 -152
  74. package/lib/mcp/tools/users/usersManagement.d.ts +2 -2
  75. package/lib/mcp/tools/users/usersManagement.js +2 -2
  76. package/lib/mcp/utils/getNormalizedQuotationDetails.d.ts +0 -2
  77. package/lib/mcp/utils/getNormalizedUserDetails.d.ts +0 -2
  78. package/lib/mcp/utils/normalizeMediaUrl.js +1 -1
  79. package/lib/mcp/utils/sanitizeLocalizationEntityData.d.ts +1 -1
  80. package/lib/mcp/utils/sharedSchemas.d.ts +39 -28
  81. package/lib/mcp/utils/sharedSchemas.js +47 -28
  82. package/lib/mcp/utils/validateIsoCode.d.ts +1 -1
  83. package/lib/resolvers/mutations/accounts/changePassword.js +1 -4
  84. package/lib/resolvers/mutations/index.d.ts +6 -1
  85. package/lib/resolvers/mutations/index.js +12 -2
  86. package/lib/resolvers/mutations/orders/updateCart.js +1 -7
  87. package/lib/resolvers/queries/orders/orders.js +2 -2
  88. package/lib/resolvers/type/index.d.ts +1 -0
  89. package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +1 -0
  90. package/lib/resolvers/type/order/order-delivery-pickup-types.js +7 -0
  91. package/lib/roles/index.js +0 -1
  92. package/lib/roles/loggedIn.js +0 -1
  93. package/lib/schema/mutation.js +44 -6
  94. package/lib/schema/types/index.js +2 -2
  95. package/lib/schema/types/order/delivery.js +2 -0
  96. package/package.json +17 -8
@@ -1,253 +1,144 @@
1
- import { z } from 'zod';
2
- export declare const OrderStatusEnum: z.ZodEnum<{
1
+ import { z } from 'zod/v4-mini';
2
+ export declare const OrderStatusEnum: z.ZodMiniEnum<{
3
3
  DELIVERED: "DELIVERED";
4
4
  PENDING: "PENDING";
5
5
  CONFIRMED: "CONFIRMED";
6
6
  SHIPPED: "SHIPPED";
7
7
  CANCELLED: "CANCELLED";
8
8
  }>;
9
- export declare const PaymentProviderTypeEnum: z.ZodEnum<{
9
+ export declare const PaymentProviderTypeEnum: z.ZodMiniEnum<{
10
10
  INVOICE: "INVOICE";
11
11
  GENERIC: "GENERIC";
12
12
  CARD: "CARD";
13
13
  }>;
14
- export declare const DeliveryProviderTypeEnum: z.ZodEnum<{
14
+ export declare const DeliveryProviderTypeEnum: z.ZodMiniEnum<{
15
15
  SHIPPING: "SHIPPING";
16
16
  PICKUP: "PICKUP";
17
17
  LOCAL: "LOCAL";
18
18
  }>;
19
- export declare const SortDirectionEnum: z.ZodEnum<{
19
+ export declare const SortDirectionEnum: z.ZodMiniEnum<{
20
20
  ASC: "ASC";
21
21
  DESC: "DESC";
22
22
  }>;
23
- export declare const SortOptionInput: z.ZodObject<{
24
- key: z.ZodString;
25
- value: z.ZodEnum<{
23
+ export declare const SortOptionInput: z.ZodMiniObject<{
24
+ key: z.ZodMiniString<string>;
25
+ value: z.ZodMiniEnum<{
26
26
  ASC: "ASC";
27
27
  DESC: "DESC";
28
28
  }>;
29
29
  }, z.core.$strict>;
30
- export declare const DateFilterInput: z.ZodObject<{
31
- from: z.ZodOptional<z.ZodString>;
32
- to: z.ZodOptional<z.ZodString>;
30
+ export declare const DateFilterInput: z.ZodMiniObject<{
31
+ from: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
32
+ to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
33
33
  }, z.core.$strip>;
34
34
  export declare const actionValidators: {
35
- readonly LIST: z.ZodObject<{
36
- includeCarts: z.ZodOptional<z.ZodBoolean>;
37
- paymentProviderTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
35
+ readonly LIST: z.ZodMiniObject<{
36
+ includeCarts: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
37
+ paymentProviderTypes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniEnum<{
38
38
  INVOICE: "INVOICE";
39
39
  GENERIC: "GENERIC";
40
40
  CARD: "CARD";
41
41
  }>>>;
42
- deliveryProviderTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
42
+ deliveryProviderTypes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniEnum<{
43
43
  SHIPPING: "SHIPPING";
44
44
  PICKUP: "PICKUP";
45
45
  LOCAL: "LOCAL";
46
46
  }>>>;
47
- dateRange: z.ZodOptional<z.ZodObject<{
48
- from: z.ZodOptional<z.ZodString>;
49
- to: z.ZodOptional<z.ZodString>;
47
+ dateRange: z.ZodMiniOptional<z.ZodMiniObject<{
48
+ from: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
49
+ to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
50
50
  }, z.core.$strip>>;
51
- paymentProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
52
- deliveryProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
- status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
51
+ paymentProviderIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
52
+ deliveryProviderIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
53
+ status: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniEnum<{
54
54
  DELIVERED: "DELIVERED";
55
55
  PENDING: "PENDING";
56
56
  CONFIRMED: "CONFIRMED";
57
57
  SHIPPED: "SHIPPED";
58
58
  CANCELLED: "CANCELLED";
59
59
  }>>>;
60
- queryString: z.ZodOptional<z.ZodString>;
61
- includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
62
- sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
63
- key: z.ZodString;
64
- value: z.ZodEnum<{
60
+ queryString: z.ZodMiniOptional<z.ZodMiniString<string>>;
61
+ includeInactive: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
62
+ sort: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
63
+ key: z.ZodMiniString<string>;
64
+ value: z.ZodMiniEnum<{
65
65
  [x: string]: string;
66
66
  }>;
67
67
  }, z.core.$strip>>>;
68
- limit: z.ZodOptional<z.ZodNumber>;
69
- offset: z.ZodOptional<z.ZodNumber>;
68
+ limit: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
69
+ offset: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
70
70
  }, z.core.$strip>;
71
- readonly SALES_SUMMARY: z.ZodObject<{
72
- days: z.ZodOptional<z.ZodNumber>;
73
- paymentProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
74
- deliveryProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
75
- status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
71
+ readonly SALES_SUMMARY: z.ZodMiniObject<{
72
+ days: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
73
+ paymentProviderIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
74
+ deliveryProviderIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
75
+ status: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniEnum<{
76
76
  DELIVERED: "DELIVERED";
77
77
  PENDING: "PENDING";
78
78
  CONFIRMED: "CONFIRMED";
79
79
  SHIPPED: "SHIPPED";
80
80
  CANCELLED: "CANCELLED";
81
81
  }>>>;
82
- from: z.ZodOptional<z.ZodString>;
83
- to: z.ZodOptional<z.ZodString>;
82
+ from: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
83
+ to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
84
84
  }, z.core.$strip>;
85
- readonly MONTHLY_BREAKDOWN: z.ZodObject<{
86
- paymentProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
87
- deliveryProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
88
- status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
85
+ readonly MONTHLY_BREAKDOWN: z.ZodMiniObject<{
86
+ paymentProviderIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
87
+ deliveryProviderIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
88
+ status: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniEnum<{
89
89
  DELIVERED: "DELIVERED";
90
90
  PENDING: "PENDING";
91
91
  CONFIRMED: "CONFIRMED";
92
92
  SHIPPED: "SHIPPED";
93
93
  CANCELLED: "CANCELLED";
94
94
  }>>>;
95
- from: z.ZodOptional<z.ZodString>;
96
- to: z.ZodOptional<z.ZodString>;
95
+ from: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
96
+ to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
97
97
  }, z.core.$strip>;
98
- readonly TOP_CUSTOMERS: z.ZodObject<{
99
- customerStatus: z.ZodOptional<z.ZodString>;
100
- from: z.ZodOptional<z.ZodString>;
101
- to: z.ZodOptional<z.ZodString>;
102
- limit: z.ZodOptional<z.ZodNumber>;
103
- offset: z.ZodOptional<z.ZodNumber>;
98
+ readonly TOP_CUSTOMERS: z.ZodMiniObject<{
99
+ customerStatus: z.ZodMiniOptional<z.ZodMiniString<string>>;
100
+ from: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
101
+ to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
102
+ limit: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
103
+ offset: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
104
104
  }, z.core.$strip>;
105
- readonly TOP_PRODUCTS: z.ZodObject<{
106
- from: z.ZodOptional<z.ZodString>;
107
- to: z.ZodOptional<z.ZodString>;
108
- limit: z.ZodOptional<z.ZodNumber>;
109
- offset: z.ZodOptional<z.ZodNumber>;
105
+ readonly TOP_PRODUCTS: z.ZodMiniObject<{
106
+ from: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
107
+ to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
108
+ limit: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
109
+ offset: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
110
110
  }, z.core.$strip>;
111
- readonly GET_CART: z.ZodObject<{
112
- userId: z.ZodString;
113
- orderNumber: z.ZodOptional<z.ZodString>;
111
+ readonly GET_CART: z.ZodMiniObject<{
112
+ userId: z.ZodMiniString<string>;
113
+ orderNumber: z.ZodMiniOptional<z.ZodMiniString<string>>;
114
114
  }, z.core.$strip>;
115
- readonly GET: z.ZodObject<{
116
- orderId: z.ZodOptional<z.ZodString>;
117
- orderNumber: z.ZodOptional<z.ZodString>;
115
+ readonly GET: z.ZodMiniObject<{
116
+ orderId: z.ZodMiniOptional<z.ZodMiniString<string>>;
117
+ orderNumber: z.ZodMiniOptional<z.ZodMiniString<string>>;
118
118
  }, z.core.$strip>;
119
- readonly PAY_ORDER: z.ZodObject<{
120
- orderId: z.ZodString;
119
+ readonly PAY_ORDER: z.ZodMiniObject<{
120
+ orderId: z.ZodMiniString<string>;
121
121
  }, z.core.$strip>;
122
- readonly DELIVER_ORDER: z.ZodObject<{
123
- orderId: z.ZodString;
122
+ readonly DELIVER_ORDER: z.ZodMiniObject<{
123
+ orderId: z.ZodMiniString<string>;
124
124
  }, z.core.$strip>;
125
- readonly CONFIRM_ORDER: z.ZodObject<{
126
- orderId: z.ZodString;
127
- paymentContext: z.ZodOptional<z.ZodRecord<z.ZodAny, z.ZodAny>>;
128
- deliveryContext: z.ZodOptional<z.ZodRecord<z.ZodAny, z.ZodAny>>;
129
- comment: z.ZodOptional<z.ZodString>;
125
+ readonly CONFIRM_ORDER: z.ZodMiniObject<{
126
+ orderId: z.ZodMiniString<string>;
127
+ paymentContext: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
128
+ deliveryContext: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
129
+ comment: z.ZodMiniOptional<z.ZodMiniString<string>>;
130
130
  }, z.core.$strip>;
131
- readonly REJECT_ORDER: z.ZodObject<{
132
- orderId: z.ZodString;
133
- paymentContext: z.ZodOptional<z.ZodRecord<z.ZodAny, z.ZodAny>>;
134
- deliveryContext: z.ZodOptional<z.ZodRecord<z.ZodAny, z.ZodAny>>;
135
- comment: z.ZodOptional<z.ZodString>;
131
+ readonly REJECT_ORDER: z.ZodMiniObject<{
132
+ orderId: z.ZodMiniString<string>;
133
+ paymentContext: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
134
+ deliveryContext: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
135
+ comment: z.ZodMiniOptional<z.ZodMiniString<string>>;
136
136
  }, z.core.$strip>;
137
137
  };
138
138
  export declare const OrderManagementSchema: {
139
- includeCarts: z.ZodOptional<z.ZodBoolean>;
140
- paymentProviderTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
141
- INVOICE: "INVOICE";
142
- GENERIC: "GENERIC";
143
- CARD: "CARD";
144
- }>>>;
145
- deliveryProviderTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
146
- SHIPPING: "SHIPPING";
147
- PICKUP: "PICKUP";
148
- LOCAL: "LOCAL";
149
- }>>>;
150
- dateRange: z.ZodOptional<z.ZodObject<{
151
- from: z.ZodOptional<z.ZodString>;
152
- to: z.ZodOptional<z.ZodString>;
153
- }, z.core.$strip>>;
154
- days: z.ZodOptional<z.ZodNumber>;
155
- customerStatus: z.ZodOptional<z.ZodString>;
156
- orderId: z.ZodOptional<z.ZodString>;
157
- orderNumber: z.ZodOptional<z.ZodString>;
158
- userId: z.ZodOptional<z.ZodString>;
159
- paymentProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
160
- deliveryProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
161
- status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
162
- DELIVERED: "DELIVERED";
163
- PENDING: "PENDING";
164
- CONFIRMED: "CONFIRMED";
165
- SHIPPED: "SHIPPED";
166
- CANCELLED: "CANCELLED";
167
- }>>>;
168
- from: z.ZodOptional<z.ZodString>;
169
- to: z.ZodOptional<z.ZodString>;
170
- queryString: z.ZodOptional<z.ZodString>;
171
- includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
172
- sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
173
- key: z.ZodString;
174
- value: z.ZodEnum<{
175
- [x: string]: string;
176
- }>;
177
- }, z.core.$strip>>>;
178
- limit: z.ZodOptional<z.ZodNumber>;
179
- offset: z.ZodOptional<z.ZodNumber>;
180
- action: z.ZodEnum<{
181
- GET: "GET";
182
- LIST: "LIST";
183
- SALES_SUMMARY: "SALES_SUMMARY";
184
- MONTHLY_BREAKDOWN: "MONTHLY_BREAKDOWN";
185
- TOP_CUSTOMERS: "TOP_CUSTOMERS";
186
- TOP_PRODUCTS: "TOP_PRODUCTS";
187
- GET_CART: "GET_CART";
188
- PAY_ORDER: "PAY_ORDER";
189
- DELIVER_ORDER: "DELIVER_ORDER";
190
- CONFIRM_ORDER: "CONFIRM_ORDER";
191
- REJECT_ORDER: "REJECT_ORDER";
192
- }>;
193
- };
194
- export declare const OrderManagementZodSchema: z.ZodObject<{
195
- includeCarts: z.ZodOptional<z.ZodBoolean>;
196
- paymentProviderTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
197
- INVOICE: "INVOICE";
198
- GENERIC: "GENERIC";
199
- CARD: "CARD";
200
- }>>>;
201
- deliveryProviderTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
202
- SHIPPING: "SHIPPING";
203
- PICKUP: "PICKUP";
204
- LOCAL: "LOCAL";
205
- }>>>;
206
- dateRange: z.ZodOptional<z.ZodObject<{
207
- from: z.ZodOptional<z.ZodString>;
208
- to: z.ZodOptional<z.ZodString>;
209
- }, z.core.$strip>>;
210
- days: z.ZodOptional<z.ZodNumber>;
211
- customerStatus: z.ZodOptional<z.ZodString>;
212
- orderId: z.ZodOptional<z.ZodString>;
213
- orderNumber: z.ZodOptional<z.ZodString>;
214
- userId: z.ZodOptional<z.ZodString>;
215
- paymentProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
216
- deliveryProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
217
- status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
218
- DELIVERED: "DELIVERED";
219
- PENDING: "PENDING";
220
- CONFIRMED: "CONFIRMED";
221
- SHIPPED: "SHIPPED";
222
- CANCELLED: "CANCELLED";
223
- }>>>;
224
- from: z.ZodOptional<z.ZodString>;
225
- to: z.ZodOptional<z.ZodString>;
226
- queryString: z.ZodOptional<z.ZodString>;
227
- includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
228
- sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
229
- key: z.ZodString;
230
- value: z.ZodEnum<{
231
- [x: string]: string;
232
- }>;
233
- }, z.core.$strip>>>;
234
- limit: z.ZodOptional<z.ZodNumber>;
235
- offset: z.ZodOptional<z.ZodNumber>;
236
- action: z.ZodEnum<{
237
- GET: "GET";
238
- LIST: "LIST";
239
- SALES_SUMMARY: "SALES_SUMMARY";
240
- MONTHLY_BREAKDOWN: "MONTHLY_BREAKDOWN";
241
- TOP_CUSTOMERS: "TOP_CUSTOMERS";
242
- TOP_PRODUCTS: "TOP_PRODUCTS";
243
- GET_CART: "GET_CART";
244
- PAY_ORDER: "PAY_ORDER";
245
- DELIVER_ORDER: "DELIVER_ORDER";
246
- CONFIRM_ORDER: "CONFIRM_ORDER";
247
- REJECT_ORDER: "REJECT_ORDER";
248
- }>;
249
- }, z.core.$strip>;
250
- export type OrderManagementParams = z.infer<typeof OrderManagementZodSchema>;
139
+ action: z.core.$ZodType<string>;
140
+ } & Record<string, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
141
+ export type { ManagementParams as OrderManagementParams } from '../../utils/sharedSchemas.ts';
251
142
  export type ActionName = keyof typeof actionValidators;
252
143
  export type Params<T extends ActionName> = z.infer<(typeof actionValidators)[T]>;
253
144
  export type Handler<T extends ActionName> = (orderModule: any, params: Params<T>) => Promise<unknown>;
@@ -1,15 +1,13 @@
1
- import { z } from 'zod';
2
- import { PaginationSchema, SortingSchema, SearchSchema, DateRangeSchema, OrderFilterSchema, } from "../../utils/sharedSchemas.js";
1
+ import { z } from 'zod/v4-mini';
2
+ import { PaginationSchema, SortingSchema, SearchSchema, DateRangeSchema, OrderFilterSchema, createManagementSchemaFromValidators, } from "../../utils/sharedSchemas.js";
3
3
  export const OrderStatusEnum = z.enum(['PENDING', 'CONFIRMED', 'SHIPPED', 'DELIVERED', 'CANCELLED']);
4
4
  export const PaymentProviderTypeEnum = z.enum(['CARD', 'INVOICE', 'GENERIC']);
5
5
  export const DeliveryProviderTypeEnum = z.enum(['PICKUP', 'SHIPPING', 'LOCAL']);
6
6
  export const SortDirectionEnum = z.enum(['ASC', 'DESC']);
7
- export const SortOptionInput = z
8
- .object({
9
- key: z.string().min(1).describe('Field to sort by'),
10
- value: SortDirectionEnum.describe('Sort direction'),
11
- })
12
- .strict();
7
+ export const SortOptionInput = z.strictObject({
8
+ key: z.string().check(z.minLength(1), z.describe('Field to sort by')),
9
+ value: SortDirectionEnum.check(z.describe('Sort direction')),
10
+ });
13
11
  export const DateFilterInput = z.object(DateRangeSchema);
14
12
  export const actionValidators = {
15
13
  LIST: z.object({
@@ -17,27 +15,21 @@ export const actionValidators = {
17
15
  ...SortingSchema,
18
16
  ...SearchSchema,
19
17
  ...OrderFilterSchema,
20
- includeCarts: z.boolean().optional().describe('Include cart orders in results'),
18
+ includeCarts: z.optional(z.boolean()).check(z.describe('Include cart orders in results')),
21
19
  paymentProviderTypes: z
22
- .array(PaymentProviderTypeEnum)
23
- .optional()
24
- .describe('Filter by payment provider types'),
20
+ .optional(z.array(PaymentProviderTypeEnum))
21
+ .check(z.describe('Filter by payment provider types')),
25
22
  deliveryProviderTypes: z
26
- .array(DeliveryProviderTypeEnum)
27
- .optional()
28
- .describe('Filter by delivery provider types'),
29
- dateRange: DateFilterInput.optional().describe('Date range filter'),
23
+ .optional(z.array(DeliveryProviderTypeEnum))
24
+ .check(z.describe('Filter by delivery provider types')),
25
+ dateRange: z.optional(DateFilterInput).check(z.describe('Date range filter')),
30
26
  }),
31
27
  SALES_SUMMARY: z.object({
32
28
  ...DateRangeSchema,
33
29
  ...OrderFilterSchema,
34
30
  days: z
35
- .number()
36
- .int()
37
- .min(1)
38
- .max(365)
39
- .optional()
40
- .describe('Number of days for daily breakdown (default: 30)'),
31
+ .optional(z.int().check(z.gte(1), z.lte(365)))
32
+ .check(z.describe('Number of days for daily breakdown (default: 30)')),
41
33
  }),
42
34
  MONTHLY_BREAKDOWN: z.object({
43
35
  ...DateRangeSchema,
@@ -46,45 +38,48 @@ export const actionValidators = {
46
38
  TOP_CUSTOMERS: z.object({
47
39
  ...PaginationSchema,
48
40
  ...DateRangeSchema,
49
- customerStatus: z.string().optional().describe('Order status for customer analysis'),
41
+ customerStatus: z.optional(z.string()).check(z.describe('Order status for customer analysis')),
50
42
  }),
51
43
  TOP_PRODUCTS: z.object({
52
44
  ...PaginationSchema,
53
45
  ...DateRangeSchema,
54
46
  }),
55
47
  GET_CART: z.object({
56
- userId: z.string().describe('User ID to get cart for'),
57
- orderNumber: z.string().optional().describe('Optional orderNumber if known to get user cart'),
48
+ userId: z.string().check(z.describe('User ID to get cart for')),
49
+ orderNumber: z
50
+ .optional(z.string())
51
+ .check(z.describe('Optional orderNumber if known to get user cart')),
58
52
  }),
59
53
  GET: z
60
54
  .object({
61
- orderId: z.string().optional().describe('Order ID of the order'),
62
- orderNumber: z.string().optional().describe('Optional orderNumber if known to get user cart'),
55
+ orderId: z.optional(z.string()).check(z.describe('Order ID of the order')),
56
+ orderNumber: z
57
+ .optional(z.string())
58
+ .check(z.describe('Optional orderNumber if known to get user cart')),
63
59
  })
64
- .superRefine((data, ctx) => {
60
+ .check(z.superRefine((data, ctx) => {
65
61
  if (!data?.orderId && !data?.orderNumber) {
66
62
  ctx.addIssue({
67
- code: z.ZodIssueCode.custom,
63
+ code: 'custom',
68
64
  message: 'Either orderId or orderNumber is required',
69
65
  path: ['GET'],
70
66
  });
71
67
  }
72
- }),
68
+ })),
73
69
  PAY_ORDER: z
74
70
  .object({
75
71
  orderId: z
76
72
  .string({
77
73
  error: (issue) => issue.input ? 'orderId is required to pay an order' : 'orderId must be a string',
78
74
  })
79
- .min(1, 'orderId cannot be empty')
80
- .describe('The unique identifier of the order to mark as PAID'),
75
+ .check(z.minLength(1, 'orderId cannot be empty'), z.describe('The unique identifier of the order to mark as PAID')),
81
76
  })
82
- .describe("This operation is used for manually marking an order's payment as PAID. " +
77
+ .check(z.describe("This operation is used for manually marking an order's payment as PAID. " +
83
78
  'The following conditions must be met:\n' +
84
79
  '- The order must already exist and must not be in OPEN (cart) status.\n' +
85
80
  '- The order must have a valid payment record.\n' +
86
81
  '- The payment status of the order must currently be OPEN.\n' +
87
- 'If these conditions are not met, an appropriate error will be thrown.'),
82
+ 'If these conditions are not met, an appropriate error will be thrown.')),
88
83
  DELIVER_ORDER: z
89
84
  .object({
90
85
  orderId: z
@@ -93,110 +88,53 @@ export const actionValidators = {
93
88
  ? 'orderId is required to mark an order as delivered'
94
89
  : 'orderId must be a string',
95
90
  })
96
- .min(1, 'orderId cannot be empty')
97
- .describe('The unique identifier of the order to mark as DELIVERED'),
91
+ .check(z.minLength(1, 'orderId cannot be empty'), z.describe('The unique identifier of the order to mark as DELIVERED')),
98
92
  })
99
- .describe("This operation is used for manually marking an order's delivery as DELIVERED. " +
93
+ .check(z.describe("This operation is used for manually marking an order's delivery as DELIVERED. " +
100
94
  'The following conditions must be met:\n' +
101
95
  '- The order must exist and must not be in OPEN (cart) status.\n' +
102
96
  '- The order must have a valid delivery record.\n' +
103
97
  '- The delivery status of the order must currently be OPEN, if the order is confirmed.\n' +
104
- 'If these conditions are not satisfied, an appropriate error will be thrown.'),
98
+ 'If these conditions are not satisfied, an appropriate error will be thrown.')),
105
99
  CONFIRM_ORDER: z
106
100
  .object({
107
101
  orderId: z
108
102
  .string({
109
103
  error: (issue) => (issue.input ? 'orderId is required' : 'orderId must be a string'),
110
104
  })
111
- .min(1, 'orderId cannot be empty'),
105
+ .check(z.minLength(1, 'orderId cannot be empty')),
112
106
  paymentContext: z
113
- .record(z.any(), z.any())
114
- .optional()
115
- .describe('Optional JSON context related to payment (e.g., transaction details).'),
107
+ .optional(z.record(z.any(), z.any()))
108
+ .check(z.describe('Optional JSON context related to payment (e.g., transaction details).')),
116
109
  deliveryContext: z
117
- .record(z.any(), z.any())
118
- .optional()
119
- .describe('Optional JSON context related to delivery (e.g., shipping info).'),
110
+ .optional(z.record(z.any(), z.any()))
111
+ .check(z.describe('Optional JSON context related to delivery (e.g., shipping info).')),
120
112
  comment: z
121
- .string()
122
- .optional()
123
- .describe('Optional comment or note to attach to the order confirmation.'),
113
+ .optional(z.string())
114
+ .check(z.describe('Optional comment or note to attach to the order confirmation.')),
124
115
  })
125
- .describe('Confirms an order. Requirements:\n' +
116
+ .check(z.describe('Confirms an order. Requirements:\n' +
126
117
  '- The order must exist.\n' +
127
118
  '- The order status must be PENDING.\n' +
128
- '- paymentContext, deliveryContext, and comment are optional additional inputs.'),
119
+ '- paymentContext, deliveryContext, and comment are optional additional inputs.')),
129
120
  REJECT_ORDER: z
130
121
  .object({
131
122
  orderId: z
132
123
  .string({
133
124
  error: (issue) => (issue.input ? 'orderId is required' : 'orderId must be a string'),
134
125
  })
135
- .min(1, 'orderId cannot be empty')
136
- .describe('The unique identifier of the order to reject.'),
126
+ .check(z.minLength(1, 'orderId cannot be empty'), z.describe('The unique identifier of the order to reject.')),
137
127
  paymentContext: z
138
- .record(z.any(), z.any())
139
- .optional()
140
- .describe('Optional JSON context related to payment, e.g., transaction adjustments.'),
128
+ .optional(z.record(z.any(), z.any()))
129
+ .check(z.describe('Optional JSON context related to payment, e.g., transaction adjustments.')),
141
130
  deliveryContext: z
142
- .record(z.any(), z.any())
143
- .optional()
144
- .describe('Optional JSON context related to delivery, e.g., shipment adjustments.'),
131
+ .optional(z.record(z.any(), z.any()))
132
+ .check(z.describe('Optional JSON context related to delivery, e.g., shipment adjustments.')),
145
133
  comment: z
146
- .string()
147
- .optional()
148
- .describe('Optional comment explaining the reason for rejecting the order.'),
134
+ .optional(z.string())
135
+ .check(z.describe('Optional comment explaining the reason for rejecting the order.')),
149
136
  })
150
- .describe('Manually rejects an order which is currently PENDING. ' +
151
- 'All additional properties (paymentContext, deliveryContext, comment) are forwarded to services.orders.rejectOrder.'),
152
- };
153
- export const OrderManagementSchema = {
154
- action: z
155
- .enum([
156
- 'LIST',
157
- 'SALES_SUMMARY',
158
- 'MONTHLY_BREAKDOWN',
159
- 'TOP_CUSTOMERS',
160
- 'TOP_PRODUCTS',
161
- 'GET_CART',
162
- 'GET',
163
- 'PAY_ORDER',
164
- 'DELIVER_ORDER',
165
- 'CONFIRM_ORDER',
166
- 'REJECT_ORDER',
167
- ])
168
- .describe('Order action: LIST (get orders with filters), SALES_SUMMARY (daily sales analytics), MONTHLY_BREAKDOWN (12-month sales analysis), TOP_CUSTOMERS (highest spending customers), TOP_PRODUCTS (best-selling products), GET_CART (user cart), GET (single order), PAY_ORDER (mark single order as PAID), DELIVER_ORDER (mark single order as DELIVERED), CONFIRM_ORDER (manually mark order as CONFIRMED), REJECT_ORDER (reject order that is in progress)'),
169
- ...PaginationSchema,
170
- ...SortingSchema,
171
- ...SearchSchema,
172
- ...DateRangeSchema,
173
- ...OrderFilterSchema,
174
- includeCarts: z.boolean().optional().describe('Include cart orders in results (LIST only)'),
175
- paymentProviderTypes: z
176
- .array(PaymentProviderTypeEnum)
177
- .optional()
178
- .describe('Filter by payment provider types'),
179
- deliveryProviderTypes: z
180
- .array(DeliveryProviderTypeEnum)
181
- .optional()
182
- .describe('Filter by delivery provider types'),
183
- dateRange: DateFilterInput.optional().describe('Date range filter'),
184
- days: z
185
- .number()
186
- .int()
187
- .min(1)
188
- .max(365)
189
- .optional()
190
- .describe('Number of days for daily breakdown (SALES_SUMMARY only, default: 30)'),
191
- customerStatus: z
192
- .string()
193
- .optional()
194
- .describe('Order status for customer analysis (TOP_CUSTOMERS only)'),
195
- orderId: z
196
- .string()
197
- .optional()
198
- .describe('Optional ID of order, to get user cart (GET, PAY_ORDER & DELIVERY_ORDER, CONFIRM_ORDER & REJECT_ORDER only)'),
199
- orderNumber: z.string().optional().describe('Optional orderNumber oof a order (GET_CART & GET only)'),
200
- userId: z.string().optional().describe('User ID to get cart for (GET_CART only)'),
137
+ .check(z.describe('Manually rejects an order which is currently PENDING. ' +
138
+ 'All additional properties (paymentContext, deliveryContext, comment) are forwarded to services.orders.rejectOrder.')),
201
139
  };
202
- export const OrderManagementZodSchema = z.object(OrderManagementSchema);
140
+ export const OrderManagementSchema = createManagementSchemaFromValidators(actionValidators);
@@ -3,7 +3,7 @@ import { getNormalizedProductDetails } from "../../../utils/getNormalizedProduct
3
3
  export default async function getProduct(context, params) {
4
4
  const { modules } = context;
5
5
  const { productId, slug, sku } = params;
6
- let query = {};
6
+ let query;
7
7
  if (productId)
8
8
  query = { productId };
9
9
  else if (slug)
@@ -1,6 +1,6 @@
1
1
  import type { Context } from '../../../context.ts';
2
- import { ProductManagementSchema, ProductManagementZodSchema, type ProductManagementParams } from './schemas.ts';
3
- export { ProductManagementSchema, ProductManagementZodSchema };
2
+ import { ProductManagementSchema, type ProductManagementParams } from './schemas.ts';
3
+ export { ProductManagementSchema };
4
4
  export type { ProductManagementParams };
5
5
  export declare function productManagement(context: Context, params: ProductManagementParams): Promise<{
6
6
  content: {
@@ -1,8 +1,8 @@
1
1
  import { log } from '@unchainedshop/logger';
2
- import { actionValidators, ProductManagementSchema, ProductManagementZodSchema, } from "./schemas.js";
2
+ import { actionValidators, ProductManagementSchema, } from "./schemas.js";
3
3
  import { actionHandlers } from "./handlers/index.js";
4
4
  import { createMcpErrorResponse, createMcpResponse } from "../../utils/sharedSchemas.js";
5
- export { ProductManagementSchema, ProductManagementZodSchema };
5
+ export { ProductManagementSchema };
6
6
  export async function productManagement(context, params) {
7
7
  const { action, ...actionParams } = params;
8
8
  log('MCP productManagement', { userId: context.userId, params });