@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.
- package/lib/acl.d.ts +2 -2
- package/lib/acl.js +36 -8
- package/lib/api-index.d.ts +3 -1
- package/lib/chat/generateImageHandler.js +6 -5
- package/lib/context.d.ts +3 -1
- package/lib/context.js +9 -4
- package/lib/events.d.ts +2 -0
- package/lib/events.js +2 -0
- package/lib/express/createMCPMiddleware.js +1 -1
- package/lib/express/index.d.ts +6 -9
- package/lib/express/index.js +53 -126
- package/lib/fastify/index.d.ts +6 -9
- package/lib/fastify/index.js +52 -118
- package/lib/fastify/mcpHandler.js +1 -1
- package/lib/loaders/buildTextMap.js +6 -3
- package/lib/loaders/index.d.ts +0 -25
- package/lib/loaders/index.js +0 -10
- package/lib/locale-context.d.ts +4 -2
- package/lib/locale-context.js +2 -6
- package/lib/mcp/tools/assortment/assortmentManagement.d.ts +2 -2
- package/lib/mcp/tools/assortment/assortmentManagement.js +2 -2
- package/lib/mcp/tools/assortment/schemas.d.ts +322 -141
- package/lib/mcp/tools/assortment/schemas.js +179 -96
- package/lib/mcp/tools/filter/filterManagement.d.ts +2 -2
- package/lib/mcp/tools/filter/filterManagement.js +2 -2
- package/lib/mcp/tools/filter/schemas.d.ts +184 -75
- package/lib/mcp/tools/filter/schemas.js +87 -51
- package/lib/mcp/tools/localization/getLocalizationsConfig.d.ts +1 -1
- package/lib/mcp/tools/localization/localizationManagement.d.ts +2 -2
- package/lib/mcp/tools/localization/localizationManagement.js +2 -2
- package/lib/mcp/tools/localization/schemas.d.ts +144 -47
- package/lib/mcp/tools/localization/schemas.js +51 -36
- package/lib/mcp/tools/order/handlers/getTopCustomers.d.ts +2 -0
- package/lib/mcp/tools/order/orderManagement.d.ts +2 -2
- package/lib/mcp/tools/order/orderManagement.js +2 -2
- package/lib/mcp/tools/order/schemas.d.ts +184 -75
- package/lib/mcp/tools/order/schemas.js +113 -51
- package/lib/mcp/tools/product/productManagement.d.ts +2 -2
- package/lib/mcp/tools/product/productManagement.js +2 -2
- package/lib/mcp/tools/product/schemas.d.ts +642 -317
- package/lib/mcp/tools/product/schemas.js +287 -191
- package/lib/mcp/tools/provider/providerManagement.d.ts +2 -2
- package/lib/mcp/tools/provider/providerManagement.js +2 -2
- package/lib/mcp/tools/provider/schemas.d.ts +142 -47
- package/lib/mcp/tools/provider/schemas.js +67 -32
- package/lib/mcp/tools/quotation/handlers/getQuotation.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/listQuotations.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/makeQuotationProposal.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/rejectQuotation.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/verifyQuotation.d.ts +2 -0
- package/lib/mcp/tools/quotation/quotationManagement.d.ts +2 -2
- package/lib/mcp/tools/quotation/quotationManagement.js +2 -2
- package/lib/mcp/tools/quotation/schemas.d.ts +111 -40
- package/lib/mcp/tools/quotation/schemas.js +54 -29
- package/lib/mcp/tools/system/handlers/countEvents.d.ts +8 -1
- package/lib/mcp/tools/system/handlers/countWork.d.ts +10 -1
- package/lib/mcp/tools/system/handlers/countWork.js +1 -0
- package/lib/mcp/tools/system/handlers/index.d.ts +4 -4
- package/lib/mcp/tools/system/handlers/listEvents.d.ts +12 -1
- package/lib/mcp/tools/system/handlers/listWork.d.ts +14 -1
- package/lib/mcp/tools/system/handlers/listWork.js +1 -0
- package/lib/mcp/tools/system/schemas.d.ts +179 -84
- package/lib/mcp/tools/system/schemas.js +188 -67
- package/lib/mcp/tools/system/systemManagement.d.ts +1 -1
- package/lib/mcp/tools/system/systemManagement.js +1 -1
- package/lib/mcp/tools/users/handlers/addUserEmail.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/createUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/enrollUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/getCurrentUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/getUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/listUsers.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/setUserTags.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/setUserUsername.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/updateUser.d.ts +2 -0
- package/lib/mcp/tools/users/schemas.d.ts +296 -163
- package/lib/mcp/tools/users/schemas.js +152 -71
- package/lib/mcp/tools/users/usersManagement.d.ts +2 -2
- package/lib/mcp/tools/users/usersManagement.js +2 -2
- package/lib/mcp/utils/getNormalizedQuotationDetails.d.ts +2 -0
- package/lib/mcp/utils/getNormalizedUserDetails.d.ts +2 -0
- package/lib/mcp/utils/normalizeMediaUrl.js +1 -1
- package/lib/mcp/utils/sanitizeLocalizationEntityData.d.ts +1 -1
- package/lib/mcp/utils/sharedSchemas.d.ts +28 -39
- package/lib/mcp/utils/sharedSchemas.js +28 -47
- package/lib/mcp/utils/validateIsoCode.d.ts +1 -1
- package/lib/middleware/createAuthMiddleware.js +1 -3
- package/lib/resolvers/mutations/accounts/changePassword.js +1 -2
- package/lib/resolvers/mutations/index.d.ts +150 -155
- package/lib/resolvers/mutations/index.js +2 -12
- package/lib/resolvers/mutations/orders/updateCart.js +7 -1
- package/lib/resolvers/mutations/users/setRoles.d.ts +1 -1
- package/lib/resolvers/mutations/users/setRoles.js +6 -4
- package/lib/resolvers/queries/events/registeredEventTypes.d.ts +1 -1
- package/lib/resolvers/queries/events/registeredEventTypes.js +1 -1
- package/lib/resolvers/queries/index.d.ts +71 -71
- package/lib/resolvers/queries/index.js +1 -1
- package/lib/resolvers/type/index.d.ts +5 -6
- package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +0 -1
- package/lib/resolvers/type/order/order-delivery-pickup-types.js +0 -7
- package/lib/resolvers/type/order/order-types.d.ts +5 -5
- package/lib/resolvers/type/order/order-types.js +27 -12
- package/lib/resolvers/type/shop-types.js +1 -1
- package/lib/resolvers/type/user-types.js +3 -3
- package/lib/roles/index.d.ts +4 -11
- package/lib/roles/index.js +16 -11
- package/lib/roles/loggedIn.js +2 -1
- package/lib/schema/mutation.js +6 -44
- package/lib/schema/query.js +5 -5
- package/lib/schema/types/index.js +2 -2
- package/lib/schema/types/order/delivery.js +0 -2
- package/package.json +14 -24
|
@@ -1,144 +1,253 @@
|
|
|
1
|
-
import { z } from 'zod
|
|
2
|
-
export declare const OrderStatusEnum: z.
|
|
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.
|
|
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.
|
|
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.
|
|
19
|
+
export declare const SortDirectionEnum: z.ZodEnum<{
|
|
20
20
|
ASC: "ASC";
|
|
21
21
|
DESC: "DESC";
|
|
22
22
|
}>;
|
|
23
|
-
export declare const SortOptionInput: z.
|
|
24
|
-
key: z.
|
|
25
|
-
value: z.
|
|
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.
|
|
31
|
-
from: z.
|
|
32
|
-
to: z.
|
|
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.
|
|
36
|
-
includeCarts: z.
|
|
37
|
-
paymentProviderTypes: z.
|
|
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.
|
|
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.
|
|
48
|
-
from: z.
|
|
49
|
-
to: z.
|
|
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.
|
|
52
|
-
deliveryProviderIds: z.
|
|
53
|
-
status: z.
|
|
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.
|
|
61
|
-
includeInactive: z.
|
|
62
|
-
sort: z.
|
|
63
|
-
key: z.
|
|
64
|
-
value: z.
|
|
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.
|
|
69
|
-
offset: z.
|
|
68
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
70
70
|
}, z.core.$strip>;
|
|
71
|
-
readonly SALES_SUMMARY: z.
|
|
72
|
-
days: z.
|
|
73
|
-
paymentProviderIds: z.
|
|
74
|
-
deliveryProviderIds: z.
|
|
75
|
-
status: z.
|
|
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.
|
|
83
|
-
to: z.
|
|
82
|
+
from: z.ZodOptional<z.ZodString>;
|
|
83
|
+
to: z.ZodOptional<z.ZodString>;
|
|
84
84
|
}, z.core.$strip>;
|
|
85
|
-
readonly MONTHLY_BREAKDOWN: z.
|
|
86
|
-
paymentProviderIds: z.
|
|
87
|
-
deliveryProviderIds: z.
|
|
88
|
-
status: z.
|
|
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.
|
|
96
|
-
to: z.
|
|
95
|
+
from: z.ZodOptional<z.ZodString>;
|
|
96
|
+
to: z.ZodOptional<z.ZodString>;
|
|
97
97
|
}, z.core.$strip>;
|
|
98
|
-
readonly TOP_CUSTOMERS: z.
|
|
99
|
-
customerStatus: z.
|
|
100
|
-
from: z.
|
|
101
|
-
to: z.
|
|
102
|
-
limit: z.
|
|
103
|
-
offset: z.
|
|
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.
|
|
106
|
-
from: z.
|
|
107
|
-
to: z.
|
|
108
|
-
limit: z.
|
|
109
|
-
offset: z.
|
|
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.
|
|
112
|
-
userId: z.
|
|
113
|
-
orderNumber: z.
|
|
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.
|
|
116
|
-
orderId: z.
|
|
117
|
-
orderNumber: z.
|
|
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.
|
|
120
|
-
orderId: z.
|
|
119
|
+
readonly PAY_ORDER: z.ZodObject<{
|
|
120
|
+
orderId: z.ZodString;
|
|
121
121
|
}, z.core.$strip>;
|
|
122
|
-
readonly DELIVER_ORDER: z.
|
|
123
|
-
orderId: z.
|
|
122
|
+
readonly DELIVER_ORDER: z.ZodObject<{
|
|
123
|
+
orderId: z.ZodString;
|
|
124
124
|
}, z.core.$strip>;
|
|
125
|
-
readonly CONFIRM_ORDER: z.
|
|
126
|
-
orderId: z.
|
|
127
|
-
paymentContext: z.
|
|
128
|
-
deliveryContext: z.
|
|
129
|
-
comment: z.
|
|
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.
|
|
132
|
-
orderId: z.
|
|
133
|
-
paymentContext: z.
|
|
134
|
-
deliveryContext: z.
|
|
135
|
-
comment: z.
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
|
2
|
-
import { PaginationSchema, SortingSchema, SearchSchema, DateRangeSchema, OrderFilterSchema,
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
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.
|
|
20
|
+
includeCarts: z.boolean().optional().describe('Include cart orders in results'),
|
|
19
21
|
paymentProviderTypes: z
|
|
20
|
-
.
|
|
21
|
-
.
|
|
22
|
+
.array(PaymentProviderTypeEnum)
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('Filter by payment provider types'),
|
|
22
25
|
deliveryProviderTypes: z
|
|
23
|
-
.
|
|
24
|
-
.
|
|
25
|
-
|
|
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
|
-
.
|
|
32
|
-
.
|
|
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.
|
|
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().
|
|
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.
|
|
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
|
-
.
|
|
64
|
+
.superRefine((data, ctx) => {
|
|
61
65
|
if (!data?.orderId && !data?.orderNumber) {
|
|
62
66
|
ctx.addIssue({
|
|
63
|
-
code:
|
|
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
|
-
.
|
|
79
|
+
.min(1, 'orderId cannot be empty')
|
|
80
|
+
.describe('The unique identifier of the order to mark as PAID'),
|
|
76
81
|
})
|
|
77
|
-
.
|
|
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
|
-
.
|
|
96
|
+
.min(1, 'orderId cannot be empty')
|
|
97
|
+
.describe('The unique identifier of the order to mark as DELIVERED'),
|
|
92
98
|
})
|
|
93
|
-
.
|
|
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
|
-
.
|
|
111
|
+
.min(1, 'orderId cannot be empty'),
|
|
106
112
|
paymentContext: z
|
|
107
|
-
.
|
|
108
|
-
.
|
|
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
|
-
.
|
|
111
|
-
.
|
|
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
|
-
.
|
|
114
|
-
.
|
|
121
|
+
.string()
|
|
122
|
+
.optional()
|
|
123
|
+
.describe('Optional comment or note to attach to the order confirmation.'),
|
|
115
124
|
})
|
|
116
|
-
.
|
|
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
|
-
.
|
|
135
|
+
.min(1, 'orderId cannot be empty')
|
|
136
|
+
.describe('The unique identifier of the order to reject.'),
|
|
127
137
|
paymentContext: z
|
|
128
|
-
.
|
|
129
|
-
.
|
|
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
|
-
.
|
|
132
|
-
.
|
|
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
|
-
.
|
|
135
|
-
.
|
|
146
|
+
.string()
|
|
147
|
+
.optional()
|
|
148
|
+
.describe('Optional comment explaining the reason for rejecting the order.'),
|
|
136
149
|
})
|
|
137
|
-
.
|
|
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
|
|
202
|
+
export const OrderManagementZodSchema = z.object(OrderManagementSchema);
|
|
@@ -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 });
|