@unchainedshop/api 4.3.4 → 4.3.6
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/chat/generateImageHandler.js +1 -1
- package/lib/chat/generateImageHandler.js.map +1 -1
- package/lib/chat/utils.js +1 -1
- package/lib/chat/utils.js.map +1 -1
- package/lib/express/chatHandler.d.ts.map +1 -1
- package/lib/express/chatHandler.js +7 -3
- package/lib/express/chatHandler.js.map +1 -1
- package/lib/express/createMCPMiddleware.d.ts +1 -1
- package/lib/express/createMCPMiddleware.d.ts.map +1 -1
- package/lib/express/createMCPMiddleware.js +21 -4
- package/lib/express/createMCPMiddleware.js.map +1 -1
- package/lib/fastify/chatHandler.d.ts.map +1 -1
- package/lib/fastify/chatHandler.js +7 -3
- package/lib/fastify/chatHandler.js.map +1 -1
- package/lib/fastify/index.d.ts.map +1 -1
- package/lib/fastify/index.js +1 -4
- package/lib/fastify/index.js.map +1 -1
- package/lib/fastify/mcpHandler.d.ts +1 -1
- package/lib/fastify/mcpHandler.d.ts.map +1 -1
- package/lib/fastify/mcpHandler.js +20 -5
- package/lib/fastify/mcpHandler.js.map +1 -1
- package/lib/mcp/index.d.ts +2 -2
- package/lib/mcp/index.d.ts.map +1 -1
- package/lib/mcp/index.js +1 -6
- package/lib/mcp/index.js.map +1 -1
- package/lib/mcp/resources/localization.d.ts +2 -2
- package/lib/mcp/resources/localization.d.ts.map +1 -1
- package/lib/mcp/tools/assortment/index.d.ts +2 -2
- package/lib/mcp/tools/assortment/index.d.ts.map +1 -1
- package/lib/mcp/tools/assortment/schemas.d.ts +167 -724
- package/lib/mcp/tools/assortment/schemas.d.ts.map +1 -1
- package/lib/mcp/tools/assortment/schemas.js +1 -1
- package/lib/mcp/tools/assortment/schemas.js.map +1 -1
- package/lib/mcp/tools/filter/index.d.ts +2 -2
- package/lib/mcp/tools/filter/index.d.ts.map +1 -1
- package/lib/mcp/tools/filter/schemas.d.ts +100 -413
- package/lib/mcp/tools/filter/schemas.d.ts.map +1 -1
- package/lib/mcp/tools/localization/index.d.ts +2 -2
- package/lib/mcp/tools/localization/index.d.ts.map +1 -1
- package/lib/mcp/tools/localization/schemas.d.ts +85 -224
- package/lib/mcp/tools/localization/schemas.d.ts.map +1 -1
- package/lib/mcp/tools/localization/schemas.js +3 -3
- package/lib/mcp/tools/localization/schemas.js.map +1 -1
- package/lib/mcp/tools/order/index.d.ts +1 -1
- package/lib/mcp/tools/order/index.d.ts.map +1 -1
- package/lib/mcp/tools/order/schemas.d.ts +160 -290
- package/lib/mcp/tools/order/schemas.d.ts.map +1 -1
- package/lib/mcp/tools/order/schemas.js +16 -10
- package/lib/mcp/tools/order/schemas.js.map +1 -1
- package/lib/mcp/tools/product/index.d.ts +1 -1
- package/lib/mcp/tools/product/index.d.ts.map +1 -1
- package/lib/mcp/tools/product/schemas.d.ts +373 -2153
- package/lib/mcp/tools/product/schemas.d.ts.map +1 -1
- package/lib/mcp/tools/product/schemas.js +5 -2
- package/lib/mcp/tools/product/schemas.js.map +1 -1
- package/lib/mcp/tools/provider/index.d.ts +1 -1
- package/lib/mcp/tools/provider/index.d.ts.map +1 -1
- package/lib/mcp/tools/provider/schemas.d.ts +193 -194
- package/lib/mcp/tools/provider/schemas.d.ts.map +1 -1
- package/lib/mcp/tools/provider/schemas.js +4 -4
- package/lib/mcp/tools/provider/schemas.js.map +1 -1
- package/lib/mcp/tools/quotation/index.d.ts +1 -1
- package/lib/mcp/tools/quotation/index.d.ts.map +1 -1
- package/lib/mcp/tools/quotation/schemas.d.ts +78 -172
- package/lib/mcp/tools/quotation/schemas.d.ts.map +1 -1
- package/lib/mcp/tools/quotation/schemas.js +4 -4
- package/lib/mcp/tools/quotation/schemas.js.map +1 -1
- package/lib/mcp/tools/system/index.d.ts +1 -1
- package/lib/mcp/tools/system/index.d.ts.map +1 -1
- package/lib/mcp/tools/system/schemas.d.ts +96 -346
- package/lib/mcp/tools/system/schemas.d.ts.map +1 -1
- package/lib/mcp/tools/users/index.d.ts +1 -1
- package/lib/mcp/tools/users/index.d.ts.map +1 -1
- package/lib/mcp/tools/users/schemas.d.ts +125 -789
- package/lib/mcp/tools/users/schemas.d.ts.map +1 -1
- package/lib/mcp/utils/sharedSchemas.d.ts +21 -29
- package/lib/mcp/utils/sharedSchemas.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/verifyWeb3Address.js.map +1 -1
- package/package.json +6 -6
- package/src/chat/generateImageHandler.ts +1 -1
- package/src/chat/utils.ts +1 -1
- package/src/express/chatHandler.ts +12 -3
- package/src/express/createMCPMiddleware.ts +36 -8
- package/src/fastify/chatHandler.ts +10 -3
- package/src/fastify/index.ts +2 -4
- package/src/fastify/mcpHandler.ts +33 -9
- package/src/mcp/index.ts +3 -9
- package/src/mcp/resources/localization.ts +2 -2
- package/src/mcp/tools/assortment/index.ts +2 -2
- package/src/mcp/tools/assortment/schemas.ts +1 -1
- package/src/mcp/tools/filter/index.ts +2 -2
- package/src/mcp/tools/localization/index.ts +2 -2
- package/src/mcp/tools/localization/schemas.ts +4 -3
- package/src/mcp/tools/order/index.ts +1 -1
- package/src/mcp/tools/order/schemas.ts +18 -10
- package/src/mcp/tools/product/index.ts +1 -1
- package/src/mcp/tools/product/schemas.ts +5 -2
- package/src/mcp/tools/provider/index.ts +1 -1
- package/src/mcp/tools/provider/schemas.ts +5 -4
- package/src/mcp/tools/quotation/index.ts +1 -1
- package/src/mcp/tools/quotation/schemas.ts +4 -4
- package/src/mcp/tools/system/index.ts +1 -1
- package/src/mcp/tools/users/index.ts +1 -1
- package/src/resolvers/mutations/accounts/verifyWeb3Address.ts +3 -3
- package/lib/express/createApolloMiddleware.d.ts +0 -4
- package/lib/express/createApolloMiddleware.d.ts.map +0 -1
- package/lib/express/createApolloMiddleware.js +0 -36
- package/lib/express/createApolloMiddleware.js.map +0 -1
- package/lib/express/createSingleSignOnMiddleware.d.ts +0 -5
- package/lib/express/createSingleSignOnMiddleware.d.ts.map +0 -1
- package/lib/express/createSingleSignOnMiddleware.js +0 -71
- package/lib/express/createSingleSignOnMiddleware.js.map +0 -1
- package/lib/hashPassword.d.ts +0 -2
- package/lib/hashPassword.d.ts.map +0 -1
- package/lib/hashPassword.js +0 -5
- package/lib/hashPassword.js.map +0 -1
- package/lib/loaders/productLoaderBySKU.d.ts +0 -10
- package/lib/loaders/productLoaderBySKU.d.ts.map +0 -1
- package/lib/loaders/productLoaderBySKU.js +0 -16
- package/lib/loaders/productLoaderBySKU.js.map +0 -1
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.d.ts +0 -3
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.d.ts.map +0 -1
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.js +0 -6
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.js.map +0 -1
- package/lib/resolvers/mutations/accounts/disableTOTP.d.ts +0 -6
- package/lib/resolvers/mutations/accounts/disableTOTP.d.ts.map +0 -1
- package/lib/resolvers/mutations/accounts/disableTOTP.js +0 -27
- package/lib/resolvers/mutations/accounts/disableTOTP.js.map +0 -1
- package/lib/resolvers/mutations/accounts/enableTOTP.d.ts +0 -6
- package/lib/resolvers/mutations/accounts/enableTOTP.d.ts.map +0 -1
- package/lib/resolvers/mutations/accounts/enableTOTP.js +0 -20
- package/lib/resolvers/mutations/accounts/enableTOTP.js.map +0 -1
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.d.ts +0 -7
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.d.ts.map +0 -1
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.js +0 -30
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.js.map +0 -1
- package/lib/resolvers/mutations/accounts/loginWithOAuth.d.ts +0 -8
- package/lib/resolvers/mutations/accounts/loginWithOAuth.d.ts.map +0 -1
- package/lib/resolvers/mutations/accounts/loginWithOAuth.js +0 -25
- package/lib/resolvers/mutations/accounts/loginWithOAuth.js.map +0 -1
- package/lib/resolvers/mutations/accounts/logoutAllSessions.d.ts +0 -5
- package/lib/resolvers/mutations/accounts/logoutAllSessions.d.ts.map +0 -1
- package/lib/resolvers/mutations/accounts/logoutAllSessions.js +0 -20
- package/lib/resolvers/mutations/accounts/logoutAllSessions.js.map +0 -1
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.d.ts +0 -6
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.d.ts.map +0 -1
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.js +0 -13
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.js.map +0 -1
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.d.ts +0 -6
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.d.ts.map +0 -1
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.js +0 -18
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.js.map +0 -1
- package/lib/resolvers/mutations/orders/updateOrderPaymentCard.d.ts +0 -6
- package/lib/resolvers/mutations/orders/updateOrderPaymentCard.d.ts.map +0 -1
- package/lib/resolvers/mutations/orders/updateOrderPaymentCard.js +0 -26
- package/lib/resolvers/mutations/orders/updateOrderPaymentCard.js.map +0 -1
- package/lib/resolvers/mutations/products/addProductMedia.d.ts +0 -6
- package/lib/resolvers/mutations/products/addProductMedia.d.ts.map +0 -1
- package/lib/resolvers/mutations/products/addProductMedia.js +0 -18
- package/lib/resolvers/mutations/products/addProductMedia.js.map +0 -1
- package/lib/resolvers/mutations/users/updateUserAvatar.d.ts +0 -6
- package/lib/resolvers/mutations/users/updateUserAvatar.d.ts.map +0 -1
- package/lib/resolvers/mutations/users/updateUserAvatar.js +0 -22
- package/lib/resolvers/mutations/users/updateUserAvatar.js.map +0 -1
- package/lib/resolvers/mutations/utils/getOrderCart.d.ts +0 -7
- package/lib/resolvers/mutations/utils/getOrderCart.d.ts.map +0 -1
- package/lib/resolvers/mutations/utils/getOrderCart.js +0 -13
- package/lib/resolvers/mutations/utils/getOrderCart.js.map +0 -1
- package/lib/resolvers/type/color-types.d.ts +0 -18
- package/lib/resolvers/type/color-types.d.ts.map +0 -1
- package/lib/resolvers/type/color-types.js +0 -31
- package/lib/resolvers/type/color-types.js.map +0 -1
- package/lib/resolvers/type/dispatch-types.d.ts +0 -15
- package/lib/resolvers/type/dispatch-types.d.ts.map +0 -1
- package/lib/resolvers/type/dispatch-types.js +0 -16
- package/lib/resolvers/type/dispatch-types.js.map +0 -1
- package/lib/resolvers/type/oauth-account.d.ts +0 -6
- package/lib/resolvers/type/oauth-account.d.ts.map +0 -1
- package/lib/resolvers/type/oauth-account.js +0 -7
- package/lib/resolvers/type/oauth-account.js.map +0 -1
- package/lib/resolvers/type/oauth-provider.d.ts +0 -6
- package/lib/resolvers/type/oauth-provider.d.ts.map +0 -1
- package/lib/resolvers/type/oauth-provider.js +0 -6
- package/lib/resolvers/type/oauth-provider.js.map +0 -1
- package/lib/resolvers/type/stock-types.d.ts +0 -14
- package/lib/resolvers/type/stock-types.d.ts.map +0 -1
- package/lib/resolvers/type/stock-types.js +0 -15
- package/lib/resolvers/type/stock-types.js.map +0 -1
- package/lib/user-context.d.ts +0 -7
- package/lib/user-context.d.ts.map +0 -1
- package/lib/user-context.js +0 -76
- package/lib/user-context.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/users/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/users/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;iBAiB5B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0InB,CAAC;AAEX,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyGjC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAkC,CAAC;AACxE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE7E,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,gBAAgB,CAAC;AACvD,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjF,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -6,14 +6,10 @@ export declare const PaginationSchema: {
|
|
|
6
6
|
export declare const SortingSchema: {
|
|
7
7
|
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
8
8
|
key: z.ZodString;
|
|
9
|
-
value: z.ZodEnum<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}, {
|
|
14
|
-
key: string;
|
|
15
|
-
value: string;
|
|
16
|
-
}>, "many">>;
|
|
9
|
+
value: z.ZodEnum<{
|
|
10
|
+
[x: string]: string;
|
|
11
|
+
}>;
|
|
12
|
+
}, z.core.$strip>>>;
|
|
17
13
|
};
|
|
18
14
|
export declare const SearchSchema: {
|
|
19
15
|
queryString: z.ZodOptional<z.ZodString>;
|
|
@@ -23,23 +19,21 @@ export declare const LocalizationTextSchema: z.ZodObject<{
|
|
|
23
19
|
locale: z.ZodString;
|
|
24
20
|
title: z.ZodString;
|
|
25
21
|
subtitle: z.ZodOptional<z.ZodString>;
|
|
26
|
-
},
|
|
27
|
-
locale: string;
|
|
28
|
-
title: string;
|
|
29
|
-
subtitle?: string | undefined;
|
|
30
|
-
}, {
|
|
31
|
-
locale: string;
|
|
32
|
-
title: string;
|
|
33
|
-
subtitle?: string | undefined;
|
|
34
|
-
}>;
|
|
22
|
+
}, z.core.$strip>;
|
|
35
23
|
export declare const DateRangeSchema: {
|
|
36
24
|
from: z.ZodOptional<z.ZodString>;
|
|
37
25
|
to: z.ZodOptional<z.ZodString>;
|
|
38
26
|
};
|
|
39
27
|
export declare const OrderFilterSchema: {
|
|
40
|
-
paymentProviderIds: z.ZodOptional<z.ZodArray<z.ZodString
|
|
41
|
-
deliveryProviderIds: z.ZodOptional<z.ZodArray<z.ZodString
|
|
42
|
-
status: z.ZodOptional<z.ZodArray<z.ZodEnum<
|
|
28
|
+
paymentProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
+
deliveryProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
|
+
status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
31
|
+
PENDING: "PENDING";
|
|
32
|
+
CONFIRMED: "CONFIRMED";
|
|
33
|
+
SHIPPED: "SHIPPED";
|
|
34
|
+
DELIVERED: "DELIVERED";
|
|
35
|
+
CANCELLED: "CANCELLED";
|
|
36
|
+
}>>>;
|
|
43
37
|
};
|
|
44
38
|
export declare const EntityIdSchema: {
|
|
45
39
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -52,17 +46,15 @@ export declare function createManagementSchema<T extends readonly string[]>(acti
|
|
|
52
46
|
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
53
47
|
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
54
48
|
key: z.ZodString;
|
|
55
|
-
value: z.ZodEnum<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, {
|
|
60
|
-
key: string;
|
|
61
|
-
value: string;
|
|
62
|
-
}>, "many">>;
|
|
49
|
+
value: z.ZodEnum<{
|
|
50
|
+
[x: string]: string;
|
|
51
|
+
}>;
|
|
52
|
+
}, z.core.$strip>>>;
|
|
63
53
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
64
54
|
offset: z.ZodOptional<z.ZodNumber>;
|
|
65
|
-
action: z.ZodEnum<
|
|
55
|
+
action: z.ZodEnum<{
|
|
56
|
+
[x: string]: any;
|
|
57
|
+
}>;
|
|
66
58
|
};
|
|
67
59
|
export declare function createMcpResponse(response: any): {
|
|
68
60
|
content: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSchemas.d.ts","sourceRoot":"","sources":["../../../src/mcp/utils/sharedSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,gBAAgB;;;CAG5B,CAAC;AAEF,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"sharedSchemas.d.ts","sourceRoot":"","sources":["../../../src/mcp/utils/sharedSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,gBAAgB;;;CAG5B,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;CAUzB,CAAC;AAEF,eAAO,MAAM,YAAY;;;CAOxB,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;iBASjC,CAAC;AAEH,eAAO,MAAM,eAAe;;;CAG3B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;CAO7B,CAAC;AAEF,eAAO,MAAM,cAAc;;CAE1B,CAAC;AAEF,eAAO,MAAM,cAAc;;CAE1B,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,EAChE,OAAO,EAAE,CAAC,EACV,gBAAgB,GAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAM;;;;;;;;;;;;;;EASjD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,KAAA;;;;;EASzC;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;;;;;EASlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyWeb3Address.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/verifyWeb3Address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAOjG,iDAAiD;AACjD,IAAI,SAA+B,CAAC;AACpC,IAAI,UAAgC,CAAC;AACrC,IAAI,UAA6B,CAAC;AAClC,IAAI,UAA6B,CAAC;AAElC,KAAK,UAAU,iBAAiB;IAC9B,IAAI,CAAC;QACH,2BAA2B;
|
|
1
|
+
{"version":3,"file":"verifyWeb3Address.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/verifyWeb3Address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAOjG,iDAAiD;AACjD,IAAI,SAA+B,CAAC;AACpC,IAAI,UAAgC,CAAC;AACrC,IAAI,UAA6B,CAAC;AAClC,IAAI,UAA6B,CAAC;AAElC,KAAK,UAAU,iBAAiB;IAC9B,IAAI,CAAC;QACH,2BAA2B;QAC3B,aAAa;QACb,M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AAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/api",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.6",
|
|
4
4
|
"main": "lib/api-index.js",
|
|
5
5
|
"types": "lib/api-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@ai-sdk/mcp": "^0.0.
|
|
59
|
+
"@ai-sdk/mcp": "^0.0.11",
|
|
60
60
|
"@fastify/cookie": ">= 11 < 12",
|
|
61
61
|
"@fastify/multipart": ">= 9 < 10",
|
|
62
62
|
"@fastify/session": ">= 11 < 12",
|
|
@@ -73,15 +73,15 @@
|
|
|
73
73
|
"passport": ">= 0.7 < 1"
|
|
74
74
|
},
|
|
75
75
|
"peerDependenciesMeta": {
|
|
76
|
-
"@modelcontextprotocol/sdk": {
|
|
77
|
-
"optional": false
|
|
78
|
-
},
|
|
79
76
|
"graphql-yoga": {
|
|
80
77
|
"optional": false
|
|
81
78
|
},
|
|
82
79
|
"express-session": {
|
|
83
80
|
"optional": false
|
|
84
81
|
},
|
|
82
|
+
"@modelcontextprotocol/sdk": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
85
|
"ai": {
|
|
86
86
|
"optional": true
|
|
87
87
|
},
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"zod": "^3.25.76 || ^4"
|
|
135
135
|
},
|
|
136
136
|
"devDependencies": {
|
|
137
|
-
"@ai-sdk/mcp": "^0.0.
|
|
137
|
+
"@ai-sdk/mcp": "^0.0.11",
|
|
138
138
|
"@fastify/cookie": "^11.0.2",
|
|
139
139
|
"@fastify/multipart": "^9.0.3",
|
|
140
140
|
"@fastify/session": "^11.1.0",
|
package/src/chat/utils.ts
CHANGED
|
@@ -2,8 +2,8 @@ import express from 'express';
|
|
|
2
2
|
import type { Express, Request, RequestHandler, Response } from 'express';
|
|
3
3
|
import type * as aiTypes from 'ai';
|
|
4
4
|
import type * as mcpTypes from '@ai-sdk/mcp';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import type * as mcpSDKClientLibraryTypes from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
6
|
+
import type * as mcpSDKClientTypes from '@modelcontextprotocol/sdk/client/index.js';
|
|
7
7
|
import { ChatConfiguration, errorHandler } from '../chat/utils.js';
|
|
8
8
|
import generateImageHandler from '../chat/generateImageHandler.js';
|
|
9
9
|
import defaultSystemPrompt from '../chat/defaultSystemPrompt.js';
|
|
@@ -16,16 +16,25 @@ let convertToModelMessages: typeof aiTypes.convertToModelMessages;
|
|
|
16
16
|
let stepCountIs: typeof aiTypes.stepCountIs;
|
|
17
17
|
let streamText: typeof aiTypes.streamText;
|
|
18
18
|
let createMCPClient: typeof mcpTypes.experimental_createMCPClient;
|
|
19
|
+
let StreamableHTTPClientTransport: typeof mcpSDKClientLibraryTypes.StreamableHTTPClientTransport;
|
|
20
|
+
let Client: typeof mcpSDKClientTypes.Client;
|
|
19
21
|
|
|
20
22
|
try {
|
|
21
23
|
const aiTools = await import('ai');
|
|
22
24
|
const mcpTools = await import('@ai-sdk/mcp');
|
|
25
|
+
const mcpSDKClientLibrary = await import('@modelcontextprotocol/sdk/client/streamableHttp.js');
|
|
26
|
+
const mcpSDKClient = await import('@modelcontextprotocol/sdk/client/index.js');
|
|
27
|
+
|
|
28
|
+
StreamableHTTPClientTransport = mcpSDKClientLibrary.StreamableHTTPClientTransport;
|
|
29
|
+
Client = mcpSDKClient.Client;
|
|
23
30
|
convertToModelMessages = aiTools.convertToModelMessages;
|
|
24
31
|
stepCountIs = aiTools.stepCountIs;
|
|
25
32
|
streamText = aiTools.streamText;
|
|
26
33
|
createMCPClient = mcpTools.experimental_createMCPClient;
|
|
27
34
|
} catch {
|
|
28
|
-
|
|
35
|
+
logger.warn(
|
|
36
|
+
`optional peer npm packages 'ai', '@ai-sdk/mcp' and '@modelcontextprotocol/sdk' not installed, chat will not work`,
|
|
37
|
+
);
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
const setupMCPChatHandler = (chatConfiguration: ChatConfiguration & any): RequestHandler => {
|
|
@@ -1,18 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type * as mcpSDKServerLibraryTypes from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
2
|
+
import type * as mcpSDKClientTypes from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type * as mcpSDKServerTypes from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
+
import type { Context } from '../context.js';
|
|
5
|
+
import type { Request, RequestHandler } from 'express';
|
|
6
|
+
import initMCPServer from '../mcp/index.js';
|
|
7
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
8
|
+
|
|
9
|
+
const logger = createLogger('unchained:api:mcp');
|
|
10
|
+
|
|
11
|
+
let StreamableHTTPServerTransport: typeof mcpSDKServerLibraryTypes.StreamableHTTPServerTransport;
|
|
12
|
+
let isInitializeRequest: typeof mcpSDKClientTypes.isInitializeRequest;
|
|
13
|
+
let McpServer: typeof mcpSDKServerTypes.McpServer;
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const mcpSDKServerLibrary = await import('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
17
|
+
const mcpSDKClient = await import('@modelcontextprotocol/sdk/types.js');
|
|
18
|
+
const mcpSDKServer = await import('@modelcontextprotocol/sdk/server/mcp.js');
|
|
19
|
+
|
|
20
|
+
McpServer = mcpSDKServer.McpServer;
|
|
21
|
+
StreamableHTTPServerTransport = mcpSDKServerLibrary.StreamableHTTPServerTransport;
|
|
22
|
+
isInitializeRequest = mcpSDKClient.isInitializeRequest;
|
|
23
|
+
} catch {
|
|
24
|
+
logger.warn(`optional peer npm package '@modelcontextprotocol/sdk' not installed, mcp will not work`);
|
|
25
|
+
}
|
|
6
26
|
|
|
7
27
|
// Map to store transports by session ID
|
|
8
|
-
const transports: Record<string, StreamableHTTPServerTransport> = {};
|
|
28
|
+
const transports: Record<string, mcpSDKServerLibraryTypes.StreamableHTTPServerTransport> = {};
|
|
9
29
|
|
|
10
30
|
const handlePostRequest: RequestHandler = async (req: Request & { unchainedContext: Context }, res) => {
|
|
11
31
|
// Check for existing session ID
|
|
12
32
|
|
|
13
33
|
const sessionId = req.headers['mcp-session-id'] as string | undefined;
|
|
14
34
|
|
|
15
|
-
let transport: StreamableHTTPServerTransport;
|
|
35
|
+
let transport: mcpSDKServerLibraryTypes.StreamableHTTPServerTransport;
|
|
16
36
|
|
|
17
37
|
if (sessionId && transports[sessionId]) {
|
|
18
38
|
// Reuse existing transport
|
|
@@ -35,7 +55,15 @@ const handlePostRequest: RequestHandler = async (req: Request & { unchainedConte
|
|
|
35
55
|
};
|
|
36
56
|
|
|
37
57
|
const roles = req.unchainedContext.user?.roles || [];
|
|
38
|
-
|
|
58
|
+
|
|
59
|
+
const server = initMCPServer(
|
|
60
|
+
new McpServer({
|
|
61
|
+
name: 'Unchained MCP Server',
|
|
62
|
+
version: '1.0.0',
|
|
63
|
+
}),
|
|
64
|
+
req.unchainedContext,
|
|
65
|
+
roles,
|
|
66
|
+
);
|
|
39
67
|
await server.connect(transport);
|
|
40
68
|
} else {
|
|
41
69
|
// Invalid request
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FastifyInstance, RouteHandlerMethod, FastifyRequest } from 'fastify';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import type * as mcpSDKClientLibraryTypes from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
3
|
+
import type * as mcpSDKClientTypes from '@modelcontextprotocol/sdk/client/index.js';
|
|
4
4
|
import type * as aiTypes from 'ai';
|
|
5
5
|
import type * as mcpTypes from '@ai-sdk/mcp';
|
|
6
6
|
import generateImageHandler from '../chat/generateImageHandler.js';
|
|
@@ -15,16 +15,23 @@ let convertToModelMessages: typeof aiTypes.convertToModelMessages;
|
|
|
15
15
|
let stepCountIs: typeof aiTypes.stepCountIs;
|
|
16
16
|
let streamText: typeof aiTypes.streamText;
|
|
17
17
|
let createMCPClient: typeof mcpTypes.experimental_createMCPClient;
|
|
18
|
+
let StreamableHTTPClientTransport: typeof mcpSDKClientLibraryTypes.StreamableHTTPClientTransport;
|
|
19
|
+
let Client: typeof mcpSDKClientTypes.Client;
|
|
18
20
|
|
|
19
21
|
try {
|
|
20
22
|
const aiTools = await import('ai');
|
|
21
23
|
const mcpTools = await import('@ai-sdk/mcp');
|
|
24
|
+
const mcpSDKClientLibrary = await import('@modelcontextprotocol/sdk/client/streamableHttp.js');
|
|
25
|
+
const mcpSDKClient = await import('@modelcontextprotocol/sdk/client/index.js');
|
|
26
|
+
|
|
27
|
+
StreamableHTTPClientTransport = mcpSDKClientLibrary.StreamableHTTPClientTransport;
|
|
28
|
+
Client = mcpSDKClient.Client;
|
|
22
29
|
convertToModelMessages = aiTools.convertToModelMessages;
|
|
23
30
|
stepCountIs = aiTools.stepCountIs;
|
|
24
31
|
streamText = aiTools.streamText;
|
|
25
32
|
createMCPClient = mcpTools.experimental_createMCPClient;
|
|
26
33
|
} catch {
|
|
27
|
-
|
|
34
|
+
logger.warn(`optional peer npm packages 'ai' and '@ai-sdk/mcp' not installed, chat will not work`);
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
const setupMCPChatHandler = (chatConfiguration: ChatConfiguration & any) => {
|
package/src/fastify/index.ts
CHANGED
|
@@ -298,12 +298,10 @@ export const adminUIRouter: FastifyPluginAsync<AdminUIRouterOptions> = async (
|
|
|
298
298
|
const fastifyStaticModule = await import('@fastify/static');
|
|
299
299
|
fastifyStatic = fastifyStaticModule.default;
|
|
300
300
|
} catch {
|
|
301
|
-
|
|
301
|
+
fastify.log.warn("npm dependency @fastify/static is not installed, can't serve admin-ui");
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
if (
|
|
305
|
-
fastify.log.warn("npm dependency @fastify/static is not installed, can't serve admin-ui");
|
|
306
|
-
} else {
|
|
304
|
+
if (fastifyStatic) {
|
|
307
305
|
const adminUIPath = resolveAdminUIPath();
|
|
308
306
|
if (adminUIPath) {
|
|
309
307
|
await fastify.register(fastifyStatic, {
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
+
import type * as mcpSDKServerLibraryTypes from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
2
|
+
import type * as mcpSDKClientTypes from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type * as mcpSDKServerTypes from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
+
import type { Context } from '../context.js';
|
|
5
|
+
import type { FastifyRequest, RouteHandlerMethod } from 'fastify';
|
|
6
|
+
import initMCPServer from '../mcp/index.js';
|
|
1
7
|
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
-
import { Context } from '../context.js';
|
|
3
|
-
import { FastifyRequest, RouteHandlerMethod } from 'fastify';
|
|
4
|
-
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
|
-
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
-
import createMcpServer from '../mcp/index.js';
|
|
7
8
|
|
|
8
|
-
const logger = createLogger('unchained:mcp
|
|
9
|
+
const logger = createLogger('unchained:api:mcp');
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
let StreamableHTTPServerTransport: typeof mcpSDKServerLibraryTypes.StreamableHTTPServerTransport;
|
|
12
|
+
let isInitializeRequest: typeof mcpSDKClientTypes.isInitializeRequest;
|
|
13
|
+
let McpServer: typeof mcpSDKServerTypes.McpServer;
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const mcpSDKServerLibrary = await import('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
17
|
+
const mcpSDKClient = await import('@modelcontextprotocol/sdk/types.js');
|
|
18
|
+
const mcpSDKServer = await import('@modelcontextprotocol/sdk/server/mcp.js');
|
|
19
|
+
|
|
20
|
+
StreamableHTTPServerTransport = mcpSDKServerLibrary.StreamableHTTPServerTransport;
|
|
21
|
+
isInitializeRequest = mcpSDKClient.isInitializeRequest;
|
|
22
|
+
McpServer = mcpSDKServer.McpServer;
|
|
23
|
+
} catch {
|
|
24
|
+
logger.warn(`optional peer npm package '@modelcontextprotocol/sdk' not installed, mcp will not work`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const transports: Record<string, mcpSDKServerLibraryTypes.StreamableHTTPServerTransport> = {};
|
|
11
28
|
|
|
12
29
|
const mcpHandler: RouteHandlerMethod = async (
|
|
13
30
|
req: FastifyRequest & { unchainedContext: Context },
|
|
@@ -31,7 +48,7 @@ const mcpHandler: RouteHandlerMethod = async (
|
|
|
31
48
|
if (req.method === 'POST') {
|
|
32
49
|
const sessionId = req.headers['mcp-session-id'] as string | undefined;
|
|
33
50
|
|
|
34
|
-
let transport: StreamableHTTPServerTransport;
|
|
51
|
+
let transport: mcpSDKServerLibraryTypes.StreamableHTTPServerTransport;
|
|
35
52
|
|
|
36
53
|
if (sessionId && transports[sessionId]) {
|
|
37
54
|
// Reuse existing transport
|
|
@@ -54,7 +71,14 @@ const mcpHandler: RouteHandlerMethod = async (
|
|
|
54
71
|
};
|
|
55
72
|
|
|
56
73
|
const roles = req.unchainedContext.user.roles || [];
|
|
57
|
-
const server =
|
|
74
|
+
const server = initMCPServer(
|
|
75
|
+
new McpServer({
|
|
76
|
+
name: 'Unchained MCP Server',
|
|
77
|
+
version: '1.0.0',
|
|
78
|
+
}),
|
|
79
|
+
req.unchainedContext,
|
|
80
|
+
roles,
|
|
81
|
+
);
|
|
58
82
|
await server.connect(transport);
|
|
59
83
|
} else {
|
|
60
84
|
// Invalid request
|
package/src/mcp/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
1
|
+
import type { McpServer as McpServerType } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { Context } from '../context.js';
|
|
3
3
|
import { registerFilterTools } from './tools/filter/index.js';
|
|
4
4
|
import { registerProductTools } from './tools/product/index.js';
|
|
5
|
-
|
|
6
5
|
import { registerLocalizationTools } from './tools/localization/index.js';
|
|
7
6
|
import { registerProviderTools } from './tools/provider/index.js';
|
|
8
7
|
import { registerOrderTools } from './tools/order/index.js';
|
|
@@ -12,18 +11,12 @@ import { registerUsersTools } from './tools/users/index.js';
|
|
|
12
11
|
import { registerSystemTools } from './tools/system/index.js';
|
|
13
12
|
import { registerLocalizationResources } from './resources/localization.js';
|
|
14
13
|
|
|
15
|
-
export default function createMcpServer(context: Context, roles) {
|
|
16
|
-
const server = new McpServer({
|
|
17
|
-
name: 'Unchained MCP Server',
|
|
18
|
-
version: '1.0.0',
|
|
19
|
-
});
|
|
20
|
-
|
|
14
|
+
export default function createMcpServer(server: McpServerType, context: Context, roles) {
|
|
21
15
|
if (!roles?.includes('admin')) {
|
|
22
16
|
return server;
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
registerLocalizationResources(server, context);
|
|
26
|
-
|
|
27
20
|
registerFilterTools(server, context);
|
|
28
21
|
registerProductTools(server, context);
|
|
29
22
|
registerAssortmentTools(server, context);
|
|
@@ -33,5 +26,6 @@ export default function createMcpServer(context: Context, roles) {
|
|
|
33
26
|
registerOrderTools(server, context);
|
|
34
27
|
registerQuotationTools(server, context);
|
|
35
28
|
registerUsersTools(server, context);
|
|
29
|
+
|
|
36
30
|
return server;
|
|
37
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { Context } from '../../context.js';
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { Context } from '../../context.js';
|
|
3
3
|
|
|
4
4
|
export const registerLocalizationResources = (server: McpServer, context: Context) => {
|
|
5
5
|
server.resource(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { Context } from '../../../context.js';
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { Context } from '../../../context.js';
|
|
3
3
|
import { assortmentManagement, AssortmentManagementSchema } from './assortmentManagement.js';
|
|
4
4
|
|
|
5
5
|
export const registerAssortmentTools = (server: McpServer, context: Context) => {
|
|
@@ -23,7 +23,7 @@ export const AssortmentSchema = z.object({
|
|
|
23
23
|
isActive: z.boolean().optional().describe('Whether this assortment is active'),
|
|
24
24
|
tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Tags (lowercased strings)'),
|
|
25
25
|
sequence: z.number().int().optional().describe('Sorting sequence'),
|
|
26
|
-
meta: z.record(z.
|
|
26
|
+
meta: z.record(z.any(), z.any()).optional().describe('Custom metadata as key-value pairs'),
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
export const actionValidators = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { Context } from '../../../context.js';
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { Context } from '../../../context.js';
|
|
3
3
|
import { filterManagement, FilterManagementSchema } from './filterManagement.js';
|
|
4
4
|
|
|
5
5
|
export const registerFilterTools = (server: McpServer, context: Context) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { Context } from '../../../context.js';
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { Context } from '../../../context.js';
|
|
3
3
|
import { localizationManagement, LocalizationManagementSchema } from './localizationManagement.js';
|
|
4
4
|
|
|
5
5
|
export const registerLocalizationTools = (server: McpServer, context: Context) => {
|
|
@@ -7,10 +7,11 @@ export const sortDirectionKeys = Object.keys(SortDirection) as [
|
|
|
7
7
|
...(keyof typeof SortDirection)[],
|
|
8
8
|
];
|
|
9
9
|
|
|
10
|
-
export const LocalizationTypeEnum = z
|
|
11
|
-
|
|
10
|
+
export const LocalizationTypeEnum = z
|
|
11
|
+
.enum(['COUNTRY', 'CURRENCY', 'LANGUAGE'])
|
|
12
|
+
.describe(
|
|
12
13
|
'Type of localization entity - COUNTRY for geographic regions (US, DE, CH), CURRENCY for monetary units (USD, EUR, CHF), LANGUAGE for locale support (en, de, fr)',
|
|
13
|
-
|
|
14
|
+
);
|
|
14
15
|
|
|
15
16
|
export const LocalizationEntitySchema = z.object({
|
|
16
17
|
isoCode: z
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { Context } from '../../../context.js';
|
|
3
3
|
import { orderManagement, OrderManagementSchema } from './orderManagement.js';
|
|
4
4
|
|
|
@@ -88,8 +88,8 @@ export const actionValidators = {
|
|
|
88
88
|
.object({
|
|
89
89
|
orderId: z
|
|
90
90
|
.string({
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
error: (issue) =>
|
|
92
|
+
issue.input ? 'orderId is required to pay an order' : 'orderId must be a string',
|
|
93
93
|
})
|
|
94
94
|
.min(1, 'orderId cannot be empty')
|
|
95
95
|
.describe('The unique identifier of the order to mark as PAID'),
|
|
@@ -106,8 +106,10 @@ export const actionValidators = {
|
|
|
106
106
|
.object({
|
|
107
107
|
orderId: z
|
|
108
108
|
.string({
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
error: (issue) =>
|
|
110
|
+
issue.input
|
|
111
|
+
? 'orderId is required to mark an order as delivered'
|
|
112
|
+
: 'orderId must be a string',
|
|
111
113
|
})
|
|
112
114
|
.min(1, 'orderId cannot be empty')
|
|
113
115
|
.describe('The unique identifier of the order to mark as DELIVERED'),
|
|
@@ -122,13 +124,17 @@ export const actionValidators = {
|
|
|
122
124
|
),
|
|
123
125
|
CONFIRM_ORDER: z
|
|
124
126
|
.object({
|
|
125
|
-
orderId: z
|
|
127
|
+
orderId: z
|
|
128
|
+
.string({
|
|
129
|
+
error: (issue) => (issue.input ? 'orderId is required' : 'orderId must be a string'),
|
|
130
|
+
})
|
|
131
|
+
.min(1, 'orderId cannot be empty'),
|
|
126
132
|
paymentContext: z
|
|
127
|
-
.record(z.any())
|
|
133
|
+
.record(z.any(), z.any())
|
|
128
134
|
.optional()
|
|
129
135
|
.describe('Optional JSON context related to payment (e.g., transaction details).'),
|
|
130
136
|
deliveryContext: z
|
|
131
|
-
.record(z.any())
|
|
137
|
+
.record(z.any(), z.any())
|
|
132
138
|
.optional()
|
|
133
139
|
.describe('Optional JSON context related to delivery (e.g., shipping info).'),
|
|
134
140
|
comment: z
|
|
@@ -145,15 +151,17 @@ export const actionValidators = {
|
|
|
145
151
|
REJECT_ORDER: z
|
|
146
152
|
.object({
|
|
147
153
|
orderId: z
|
|
148
|
-
.string({
|
|
154
|
+
.string({
|
|
155
|
+
error: (issue) => (issue.input ? 'orderId is required' : 'orderId must be a string'),
|
|
156
|
+
})
|
|
149
157
|
.min(1, 'orderId cannot be empty')
|
|
150
158
|
.describe('The unique identifier of the order to reject.'),
|
|
151
159
|
paymentContext: z
|
|
152
|
-
.record(z.any())
|
|
160
|
+
.record(z.any(), z.any())
|
|
153
161
|
.optional()
|
|
154
162
|
.describe('Optional JSON context related to payment, e.g., transaction adjustments.'),
|
|
155
163
|
deliveryContext: z
|
|
156
|
-
.record(z.any())
|
|
164
|
+
.record(z.any(), z.any())
|
|
157
165
|
.optional()
|
|
158
166
|
.describe('Optional JSON context related to delivery, e.g., shipment adjustments.'),
|
|
159
167
|
comment: z
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { Context } from '../../../context.js';
|
|
3
3
|
import { productManagement, ProductManagementSchema } from './productManagement.js';
|
|
4
4
|
|
|
@@ -58,7 +58,7 @@ export const ProductSchema = z.object({
|
|
|
58
58
|
type: z.enum(productTypeKeys).optional().describe('Product type (required for CREATE)'),
|
|
59
59
|
tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Tags (lowercased strings)'),
|
|
60
60
|
sequence: z.number().int().optional().describe('Sorting sequence'),
|
|
61
|
-
meta: z.record(z.
|
|
61
|
+
meta: z.record(z.any(), z.any()).optional().describe('Custom metadata as key-value pairs'),
|
|
62
62
|
plan: UpdateProductPlanInputSchema.optional().describe('Plan configuration - ONLY for PLAN_PRODUCT'),
|
|
63
63
|
warehousing: z
|
|
64
64
|
.object({
|
|
@@ -82,7 +82,10 @@ export const ProductSchema = z.object({
|
|
|
82
82
|
contractStandard: z.string().describe('Smart contract standard (e.g., ERC-721)'),
|
|
83
83
|
tokenId: z.string().min(1).describe('Unique token identifier'),
|
|
84
84
|
supply: z.number().int().positive().describe('Total supply of the token'),
|
|
85
|
-
ercMetadataProperties: z
|
|
85
|
+
ercMetadataProperties: z
|
|
86
|
+
.record(z.any(), z.any())
|
|
87
|
+
.optional()
|
|
88
|
+
.describe('Optional ERC metadata properties'),
|
|
86
89
|
})
|
|
87
90
|
.optional()
|
|
88
91
|
.describe('Tokenization details - ONLY for TOKENIZED_PRODUCT'),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { Context } from '../../../context.js';
|
|
3
3
|
import { providerManagement, ProviderManagementSchema } from './providerManagement.js';
|
|
4
4
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { SearchSchema } from '../../utils/sharedSchemas.js';
|
|
3
3
|
|
|
4
|
-
export const ProviderTypeEnum = z
|
|
5
|
-
|
|
4
|
+
export const ProviderTypeEnum = z
|
|
5
|
+
.enum(['PAYMENT', 'DELIVERY', 'WAREHOUSING'])
|
|
6
|
+
.describe(
|
|
6
7
|
'Type of provider - PAYMENT for payment processing (cards, invoices), DELIVERY for shipping/pickup methods, WAREHOUSING for inventory management',
|
|
7
|
-
|
|
8
|
+
);
|
|
8
9
|
|
|
9
10
|
export const PaymentProviderTypeEnum = z.enum(['CARD', 'INVOICE', 'GENERIC']);
|
|
10
11
|
export const DeliveryProviderTypeEnum = z.enum(['PICKUP', 'SHIPPING', 'LOCAL']);
|
|
@@ -17,7 +18,7 @@ export const ConfigurationEntry = z
|
|
|
17
18
|
.min(1)
|
|
18
19
|
.describe('Configuration parameter name (e.g., "apiKey", "webhookUrl", "sandbox")'),
|
|
19
20
|
value: z
|
|
20
|
-
.union([z.string(), z.number(), z.boolean(), z.record(z.any())])
|
|
21
|
+
.union([z.string(), z.number(), z.boolean(), z.record(z.any(), z.any())])
|
|
21
22
|
.describe(
|
|
22
23
|
'Configuration parameter value (string, number, boolean, or object depending on the setting)',
|
|
23
24
|
),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { Context } from '../../../context.js';
|
|
3
3
|
import { quotationManagement, QuotationManagementSchema } from './quotationManagement.js';
|
|
4
4
|
|