@unchainedshop/api 4.8.3 → 5.0.0-alpha.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 (109) hide show
  1. package/lib/acl.js +30 -3
  2. package/lib/api-index.d.ts +3 -1
  3. package/lib/chat/generateImageHandler.js +6 -5
  4. package/lib/context.d.ts +4 -1
  5. package/lib/context.js +9 -3
  6. package/lib/events.d.ts +2 -0
  7. package/lib/events.js +2 -0
  8. package/lib/express/createMCPMiddleware.js +1 -1
  9. package/lib/express/index.d.ts +6 -9
  10. package/lib/express/index.js +52 -125
  11. package/lib/fastify/index.d.ts +6 -9
  12. package/lib/fastify/index.js +51 -117
  13. package/lib/fastify/mcpHandler.js +1 -1
  14. package/lib/loaders/buildTextMap.js +15 -13
  15. package/lib/locale-context.d.ts +4 -2
  16. package/lib/locale-context.js +2 -6
  17. package/lib/mcp/tools/assortment/assortmentManagement.d.ts +2 -2
  18. package/lib/mcp/tools/assortment/assortmentManagement.js +2 -2
  19. package/lib/mcp/tools/assortment/handlers/getAssortment.js +1 -1
  20. package/lib/mcp/tools/assortment/schemas.d.ts +322 -141
  21. package/lib/mcp/tools/assortment/schemas.js +179 -96
  22. package/lib/mcp/tools/filter/filterManagement.d.ts +2 -2
  23. package/lib/mcp/tools/filter/filterManagement.js +2 -2
  24. package/lib/mcp/tools/filter/schemas.d.ts +184 -75
  25. package/lib/mcp/tools/filter/schemas.js +87 -51
  26. package/lib/mcp/tools/localization/getLocalizationsConfig.d.ts +1 -1
  27. package/lib/mcp/tools/localization/localizationManagement.d.ts +2 -2
  28. package/lib/mcp/tools/localization/localizationManagement.js +2 -2
  29. package/lib/mcp/tools/localization/schemas.d.ts +144 -47
  30. package/lib/mcp/tools/localization/schemas.js +51 -36
  31. package/lib/mcp/tools/order/handlers/getTopCustomers.d.ts +2 -0
  32. package/lib/mcp/tools/order/orderManagement.d.ts +2 -2
  33. package/lib/mcp/tools/order/orderManagement.js +2 -2
  34. package/lib/mcp/tools/order/schemas.d.ts +184 -75
  35. package/lib/mcp/tools/order/schemas.js +113 -51
  36. package/lib/mcp/tools/product/handlers/getProduct.js +1 -1
  37. package/lib/mcp/tools/product/productManagement.d.ts +2 -2
  38. package/lib/mcp/tools/product/productManagement.js +2 -2
  39. package/lib/mcp/tools/product/schemas.d.ts +642 -317
  40. package/lib/mcp/tools/product/schemas.js +287 -191
  41. package/lib/mcp/tools/provider/providerManagement.d.ts +2 -2
  42. package/lib/mcp/tools/provider/providerManagement.js +2 -2
  43. package/lib/mcp/tools/provider/schemas.d.ts +142 -47
  44. package/lib/mcp/tools/provider/schemas.js +67 -32
  45. package/lib/mcp/tools/quotation/handlers/getQuotation.d.ts +2 -0
  46. package/lib/mcp/tools/quotation/handlers/listQuotations.d.ts +2 -0
  47. package/lib/mcp/tools/quotation/handlers/makeQuotationProposal.d.ts +2 -0
  48. package/lib/mcp/tools/quotation/handlers/rejectQuotation.d.ts +2 -0
  49. package/lib/mcp/tools/quotation/handlers/verifyQuotation.d.ts +2 -0
  50. package/lib/mcp/tools/quotation/quotationManagement.d.ts +2 -2
  51. package/lib/mcp/tools/quotation/quotationManagement.js +2 -2
  52. package/lib/mcp/tools/quotation/schemas.d.ts +111 -40
  53. package/lib/mcp/tools/quotation/schemas.js +54 -29
  54. package/lib/mcp/tools/system/handlers/countEvents.d.ts +8 -1
  55. package/lib/mcp/tools/system/handlers/countWork.d.ts +10 -1
  56. package/lib/mcp/tools/system/handlers/countWork.js +1 -0
  57. package/lib/mcp/tools/system/handlers/index.d.ts +4 -4
  58. package/lib/mcp/tools/system/handlers/listEvents.d.ts +12 -1
  59. package/lib/mcp/tools/system/handlers/listWork.d.ts +14 -1
  60. package/lib/mcp/tools/system/handlers/listWork.js +1 -0
  61. package/lib/mcp/tools/system/schemas.d.ts +179 -84
  62. package/lib/mcp/tools/system/schemas.js +188 -67
  63. package/lib/mcp/tools/system/systemManagement.d.ts +1 -1
  64. package/lib/mcp/tools/system/systemManagement.js +1 -1
  65. package/lib/mcp/tools/users/handlers/addUserEmail.d.ts +2 -0
  66. package/lib/mcp/tools/users/handlers/createUser.d.ts +2 -0
  67. package/lib/mcp/tools/users/handlers/enrollUser.d.ts +2 -0
  68. package/lib/mcp/tools/users/handlers/getCurrentUser.d.ts +2 -0
  69. package/lib/mcp/tools/users/handlers/getUser.d.ts +2 -0
  70. package/lib/mcp/tools/users/handlers/listUsers.d.ts +2 -0
  71. package/lib/mcp/tools/users/handlers/setUserTags.d.ts +2 -0
  72. package/lib/mcp/tools/users/handlers/setUserUsername.d.ts +2 -0
  73. package/lib/mcp/tools/users/handlers/updateUser.d.ts +2 -0
  74. package/lib/mcp/tools/users/schemas.d.ts +296 -163
  75. package/lib/mcp/tools/users/schemas.js +152 -71
  76. package/lib/mcp/tools/users/usersManagement.d.ts +2 -2
  77. package/lib/mcp/tools/users/usersManagement.js +2 -2
  78. package/lib/mcp/utils/getNormalizedQuotationDetails.d.ts +2 -0
  79. package/lib/mcp/utils/getNormalizedUserDetails.d.ts +2 -0
  80. package/lib/mcp/utils/normalizeMediaUrl.js +1 -1
  81. package/lib/mcp/utils/sanitizeLocalizationEntityData.d.ts +1 -1
  82. package/lib/mcp/utils/sharedSchemas.d.ts +28 -39
  83. package/lib/mcp/utils/sharedSchemas.js +28 -47
  84. package/lib/mcp/utils/validateIsoCode.d.ts +1 -1
  85. package/lib/resolvers/mutations/accounts/changePassword.js +1 -2
  86. package/lib/resolvers/mutations/index.d.ts +1 -6
  87. package/lib/resolvers/mutations/index.js +2 -12
  88. package/lib/resolvers/mutations/orders/updateCart.js +7 -1
  89. package/lib/resolvers/mutations/users/setRoles.d.ts +1 -1
  90. package/lib/resolvers/mutations/users/setRoles.js +8 -1
  91. package/lib/resolvers/queries/events/registeredEventTypes.d.ts +1 -1
  92. package/lib/resolvers/queries/events/registeredEventTypes.js +1 -1
  93. package/lib/resolvers/queries/index.d.ts +1 -1
  94. package/lib/resolvers/queries/index.js +1 -1
  95. package/lib/resolvers/type/index.d.ts +0 -1
  96. package/lib/resolvers/type/login-method-response-types.js +2 -1
  97. package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +0 -1
  98. package/lib/resolvers/type/order/order-delivery-pickup-types.js +0 -7
  99. package/lib/resolvers/type/shop-types.js +1 -1
  100. package/lib/resolvers/type/user-types.js +3 -3
  101. package/lib/roles/all.js +5 -3
  102. package/lib/roles/index.d.ts +4 -11
  103. package/lib/roles/index.js +16 -11
  104. package/lib/roles/loggedIn.js +2 -0
  105. package/lib/schema/mutation.js +6 -44
  106. package/lib/schema/query.js +5 -5
  107. package/lib/schema/types/index.js +2 -2
  108. package/lib/schema/types/order/delivery.js +0 -2
  109. package/package.json +13 -23
@@ -1,144 +1,253 @@
1
- import { z } from 'zod/v4-mini';
2
- export declare const OrderStatusEnum: z.ZodMiniEnum<{
1
+ import { z } from 'zod';
2
+ export declare const OrderStatusEnum: z.ZodEnum<{
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.ZodMiniEnum<{
9
+ export declare const PaymentProviderTypeEnum: z.ZodEnum<{
10
10
  INVOICE: "INVOICE";
11
11
  GENERIC: "GENERIC";
12
12
  CARD: "CARD";
13
13
  }>;
14
- export declare const DeliveryProviderTypeEnum: z.ZodMiniEnum<{
14
+ export declare const DeliveryProviderTypeEnum: z.ZodEnum<{
15
15
  SHIPPING: "SHIPPING";
16
16
  PICKUP: "PICKUP";
17
17
  LOCAL: "LOCAL";
18
18
  }>;
19
- export declare const SortDirectionEnum: z.ZodMiniEnum<{
19
+ export declare const SortDirectionEnum: z.ZodEnum<{
20
20
  ASC: "ASC";
21
21
  DESC: "DESC";
22
22
  }>;
23
- export declare const SortOptionInput: z.ZodMiniObject<{
24
- key: z.ZodMiniString<string>;
25
- value: z.ZodMiniEnum<{
23
+ export declare const SortOptionInput: z.ZodObject<{
24
+ key: z.ZodString;
25
+ value: z.ZodEnum<{
26
26
  ASC: "ASC";
27
27
  DESC: "DESC";
28
28
  }>;
29
29
  }, z.core.$strict>;
30
- export declare const DateFilterInput: z.ZodMiniObject<{
31
- from: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
32
- to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
30
+ export declare const DateFilterInput: z.ZodObject<{
31
+ from: z.ZodOptional<z.ZodString>;
32
+ to: z.ZodOptional<z.ZodString>;
33
33
  }, z.core.$strip>;
34
34
  export declare const actionValidators: {
35
- readonly LIST: z.ZodMiniObject<{
36
- includeCarts: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
37
- paymentProviderTypes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniEnum<{
35
+ readonly LIST: z.ZodObject<{
36
+ includeCarts: z.ZodOptional<z.ZodBoolean>;
37
+ paymentProviderTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
38
38
  INVOICE: "INVOICE";
39
39
  GENERIC: "GENERIC";
40
40
  CARD: "CARD";
41
41
  }>>>;
42
- deliveryProviderTypes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniEnum<{
42
+ deliveryProviderTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
43
43
  SHIPPING: "SHIPPING";
44
44
  PICKUP: "PICKUP";
45
45
  LOCAL: "LOCAL";
46
46
  }>>>;
47
- dateRange: z.ZodMiniOptional<z.ZodMiniObject<{
48
- from: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
49
- to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
47
+ dateRange: z.ZodOptional<z.ZodObject<{
48
+ from: z.ZodOptional<z.ZodString>;
49
+ to: z.ZodOptional<z.ZodString>;
50
50
  }, z.core.$strip>>;
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<{
51
+ paymentProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
52
+ deliveryProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
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.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<{
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<{
65
65
  [x: string]: string;
66
66
  }>;
67
67
  }, z.core.$strip>>>;
68
- limit: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
69
- offset: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
68
+ limit: z.ZodOptional<z.ZodNumber>;
69
+ offset: z.ZodOptional<z.ZodNumber>;
70
70
  }, z.core.$strip>;
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<{
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<{
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.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
83
- to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
82
+ from: z.ZodOptional<z.ZodString>;
83
+ to: z.ZodOptional<z.ZodString>;
84
84
  }, z.core.$strip>;
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<{
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<{
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.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
96
- to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
95
+ from: z.ZodOptional<z.ZodString>;
96
+ to: z.ZodOptional<z.ZodString>;
97
97
  }, z.core.$strip>;
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>;
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>;
104
104
  }, z.core.$strip>;
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>;
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>;
110
110
  }, z.core.$strip>;
111
- readonly GET_CART: z.ZodMiniObject<{
112
- userId: z.ZodMiniString<string>;
113
- orderNumber: z.ZodMiniOptional<z.ZodMiniString<string>>;
111
+ readonly GET_CART: z.ZodObject<{
112
+ userId: z.ZodString;
113
+ orderNumber: z.ZodOptional<z.ZodString>;
114
114
  }, z.core.$strip>;
115
- readonly GET: z.ZodMiniObject<{
116
- orderId: z.ZodMiniOptional<z.ZodMiniString<string>>;
117
- orderNumber: z.ZodMiniOptional<z.ZodMiniString<string>>;
115
+ readonly GET: z.ZodObject<{
116
+ orderId: z.ZodOptional<z.ZodString>;
117
+ orderNumber: z.ZodOptional<z.ZodString>;
118
118
  }, z.core.$strip>;
119
- readonly PAY_ORDER: z.ZodMiniObject<{
120
- orderId: z.ZodMiniString<string>;
119
+ readonly PAY_ORDER: z.ZodObject<{
120
+ orderId: z.ZodString;
121
121
  }, z.core.$strip>;
122
- readonly DELIVER_ORDER: z.ZodMiniObject<{
123
- orderId: z.ZodMiniString<string>;
122
+ readonly DELIVER_ORDER: z.ZodObject<{
123
+ orderId: z.ZodString;
124
124
  }, z.core.$strip>;
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>>;
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>;
130
130
  }, z.core.$strip>;
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>>;
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>;
136
136
  }, z.core.$strip>;
137
137
  };
138
138
  export declare const OrderManagementSchema: {
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';
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>;
142
251
  export type ActionName = keyof typeof actionValidators;
143
252
  export type Params<T extends ActionName> = z.infer<(typeof actionValidators)[T]>;
144
253
  export type Handler<T extends ActionName> = (orderModule: any, params: Params<T>) => Promise<unknown>;
@@ -1,13 +1,15 @@
1
- import { z } from 'zod/v4-mini';
2
- import { PaginationSchema, SortingSchema, SearchSchema, DateRangeSchema, OrderFilterSchema, createManagementSchemaFromValidators, } from "../../utils/sharedSchemas.js";
1
+ import { z } from 'zod';
2
+ import { PaginationSchema, SortingSchema, SearchSchema, DateRangeSchema, OrderFilterSchema, } 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.strictObject({
8
- key: z.string().check(z.minLength(1), z.describe('Field to sort by')),
9
- value: SortDirectionEnum.check(z.describe('Sort direction')),
10
- });
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();
11
13
  export const DateFilterInput = z.object(DateRangeSchema);
12
14
  export const actionValidators = {
13
15
  LIST: z.object({
@@ -15,21 +17,27 @@ export const actionValidators = {
15
17
  ...SortingSchema,
16
18
  ...SearchSchema,
17
19
  ...OrderFilterSchema,
18
- includeCarts: z.optional(z.boolean()).check(z.describe('Include cart orders in results')),
20
+ includeCarts: z.boolean().optional().describe('Include cart orders in results'),
19
21
  paymentProviderTypes: z
20
- .optional(z.array(PaymentProviderTypeEnum))
21
- .check(z.describe('Filter by payment provider types')),
22
+ .array(PaymentProviderTypeEnum)
23
+ .optional()
24
+ .describe('Filter by payment provider types'),
22
25
  deliveryProviderTypes: z
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')),
26
+ .array(DeliveryProviderTypeEnum)
27
+ .optional()
28
+ .describe('Filter by delivery provider types'),
29
+ dateRange: DateFilterInput.optional().describe('Date range filter'),
26
30
  }),
27
31
  SALES_SUMMARY: z.object({
28
32
  ...DateRangeSchema,
29
33
  ...OrderFilterSchema,
30
34
  days: z
31
- .optional(z.int().check(z.gte(1), z.lte(365)))
32
- .check(z.describe('Number of days for daily breakdown (default: 30)')),
35
+ .number()
36
+ .int()
37
+ .min(1)
38
+ .max(365)
39
+ .optional()
40
+ .describe('Number of days for daily breakdown (default: 30)'),
33
41
  }),
34
42
  MONTHLY_BREAKDOWN: z.object({
35
43
  ...DateRangeSchema,
@@ -38,48 +46,45 @@ export const actionValidators = {
38
46
  TOP_CUSTOMERS: z.object({
39
47
  ...PaginationSchema,
40
48
  ...DateRangeSchema,
41
- customerStatus: z.optional(z.string()).check(z.describe('Order status for customer analysis')),
49
+ customerStatus: z.string().optional().describe('Order status for customer analysis'),
42
50
  }),
43
51
  TOP_PRODUCTS: z.object({
44
52
  ...PaginationSchema,
45
53
  ...DateRangeSchema,
46
54
  }),
47
55
  GET_CART: z.object({
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')),
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'),
52
58
  }),
53
59
  GET: z
54
60
  .object({
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')),
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'),
59
63
  })
60
- .check(z.superRefine((data, ctx) => {
64
+ .superRefine((data, ctx) => {
61
65
  if (!data?.orderId && !data?.orderNumber) {
62
66
  ctx.addIssue({
63
- code: 'custom',
67
+ code: z.ZodIssueCode.custom,
64
68
  message: 'Either orderId or orderNumber is required',
65
69
  path: ['GET'],
66
70
  });
67
71
  }
68
- })),
72
+ }),
69
73
  PAY_ORDER: z
70
74
  .object({
71
75
  orderId: z
72
76
  .string({
73
77
  error: (issue) => issue.input ? 'orderId is required to pay an order' : 'orderId must be a string',
74
78
  })
75
- .check(z.minLength(1, 'orderId cannot be empty'), z.describe('The unique identifier of the order to mark as PAID')),
79
+ .min(1, 'orderId cannot be empty')
80
+ .describe('The unique identifier of the order to mark as PAID'),
76
81
  })
77
- .check(z.describe("This operation is used for manually marking an order's payment as PAID. " +
82
+ .describe("This operation is used for manually marking an order's payment as PAID. " +
78
83
  'The following conditions must be met:\n' +
79
84
  '- The order must already exist and must not be in OPEN (cart) status.\n' +
80
85
  '- The order must have a valid payment record.\n' +
81
86
  '- The payment status of the order must currently be OPEN.\n' +
82
- 'If these conditions are not met, an appropriate error will be thrown.')),
87
+ 'If these conditions are not met, an appropriate error will be thrown.'),
83
88
  DELIVER_ORDER: z
84
89
  .object({
85
90
  orderId: z
@@ -88,53 +93,110 @@ export const actionValidators = {
88
93
  ? 'orderId is required to mark an order as delivered'
89
94
  : 'orderId must be a string',
90
95
  })
91
- .check(z.minLength(1, 'orderId cannot be empty'), z.describe('The unique identifier of the order to mark as DELIVERED')),
96
+ .min(1, 'orderId cannot be empty')
97
+ .describe('The unique identifier of the order to mark as DELIVERED'),
92
98
  })
93
- .check(z.describe("This operation is used for manually marking an order's delivery as DELIVERED. " +
99
+ .describe("This operation is used for manually marking an order's delivery as DELIVERED. " +
94
100
  'The following conditions must be met:\n' +
95
101
  '- The order must exist and must not be in OPEN (cart) status.\n' +
96
102
  '- The order must have a valid delivery record.\n' +
97
103
  '- The delivery status of the order must currently be OPEN, if the order is confirmed.\n' +
98
- 'If these conditions are not satisfied, an appropriate error will be thrown.')),
104
+ 'If these conditions are not satisfied, an appropriate error will be thrown.'),
99
105
  CONFIRM_ORDER: z
100
106
  .object({
101
107
  orderId: z
102
108
  .string({
103
109
  error: (issue) => (issue.input ? 'orderId is required' : 'orderId must be a string'),
104
110
  })
105
- .check(z.minLength(1, 'orderId cannot be empty')),
111
+ .min(1, 'orderId cannot be empty'),
106
112
  paymentContext: z
107
- .optional(z.record(z.any(), z.any()))
108
- .check(z.describe('Optional JSON context related to payment (e.g., transaction details).')),
113
+ .record(z.any(), z.any())
114
+ .optional()
115
+ .describe('Optional JSON context related to payment (e.g., transaction details).'),
109
116
  deliveryContext: z
110
- .optional(z.record(z.any(), z.any()))
111
- .check(z.describe('Optional JSON context related to delivery (e.g., shipping info).')),
117
+ .record(z.any(), z.any())
118
+ .optional()
119
+ .describe('Optional JSON context related to delivery (e.g., shipping info).'),
112
120
  comment: z
113
- .optional(z.string())
114
- .check(z.describe('Optional comment or note to attach to the order confirmation.')),
121
+ .string()
122
+ .optional()
123
+ .describe('Optional comment or note to attach to the order confirmation.'),
115
124
  })
116
- .check(z.describe('Confirms an order. Requirements:\n' +
125
+ .describe('Confirms an order. Requirements:\n' +
117
126
  '- The order must exist.\n' +
118
127
  '- The order status must be PENDING.\n' +
119
- '- paymentContext, deliveryContext, and comment are optional additional inputs.')),
128
+ '- paymentContext, deliveryContext, and comment are optional additional inputs.'),
120
129
  REJECT_ORDER: z
121
130
  .object({
122
131
  orderId: z
123
132
  .string({
124
133
  error: (issue) => (issue.input ? 'orderId is required' : 'orderId must be a string'),
125
134
  })
126
- .check(z.minLength(1, 'orderId cannot be empty'), z.describe('The unique identifier of the order to reject.')),
135
+ .min(1, 'orderId cannot be empty')
136
+ .describe('The unique identifier of the order to reject.'),
127
137
  paymentContext: z
128
- .optional(z.record(z.any(), z.any()))
129
- .check(z.describe('Optional JSON context related to payment, e.g., transaction adjustments.')),
138
+ .record(z.any(), z.any())
139
+ .optional()
140
+ .describe('Optional JSON context related to payment, e.g., transaction adjustments.'),
130
141
  deliveryContext: z
131
- .optional(z.record(z.any(), z.any()))
132
- .check(z.describe('Optional JSON context related to delivery, e.g., shipment adjustments.')),
142
+ .record(z.any(), z.any())
143
+ .optional()
144
+ .describe('Optional JSON context related to delivery, e.g., shipment adjustments.'),
133
145
  comment: z
134
- .optional(z.string())
135
- .check(z.describe('Optional comment explaining the reason for rejecting the order.')),
146
+ .string()
147
+ .optional()
148
+ .describe('Optional comment explaining the reason for rejecting the order.'),
136
149
  })
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.')),
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)'),
139
201
  };
140
- export const OrderManagementSchema = createManagementSchemaFromValidators(actionValidators);
202
+ export const OrderManagementZodSchema = z.object(OrderManagementSchema);
@@ -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, type ProductManagementParams } from './schemas.ts';
3
- export { ProductManagementSchema };
2
+ import { ProductManagementSchema, ProductManagementZodSchema, type ProductManagementParams } from './schemas.ts';
3
+ export { ProductManagementSchema, ProductManagementZodSchema };
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, } from "./schemas.js";
2
+ import { actionValidators, ProductManagementSchema, ProductManagementZodSchema, } from "./schemas.js";
3
3
  import { actionHandlers } from "./handlers/index.js";
4
4
  import { createMcpErrorResponse, createMcpResponse } from "../../utils/sharedSchemas.js";
5
- export { ProductManagementSchema };
5
+ export { ProductManagementSchema, ProductManagementZodSchema };
6
6
  export async function productManagement(context, params) {
7
7
  const { action, ...actionParams } = params;
8
8
  log('MCP productManagement', { userId: context.userId, params });