@unchainedshop/api 4.0.0-rc.15 → 4.0.0-rc.16
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/defaultSystemPrompt.d.ts +3 -0
- package/lib/chat/defaultSystemPrompt.d.ts.map +1 -0
- package/lib/chat/defaultSystemPrompt.js +7 -0
- package/lib/chat/defaultSystemPrompt.js.map +1 -0
- package/lib/chat/generateImageHandler.d.ts +7 -0
- package/lib/chat/generateImageHandler.d.ts.map +1 -0
- package/lib/chat/generateImageHandler.js +64 -0
- package/lib/chat/generateImageHandler.js.map +1 -0
- package/lib/chat/normalizeToolsIndex.d.ts +7 -0
- package/lib/chat/normalizeToolsIndex.d.ts.map +1 -0
- package/lib/chat/normalizeToolsIndex.js +11 -0
- package/lib/chat/normalizeToolsIndex.js.map +1 -0
- package/lib/chat/utils.d.ts +13 -0
- package/lib/chat/utils.d.ts.map +1 -0
- package/lib/chat/utils.js +32 -0
- package/lib/chat/utils.js.map +1 -0
- package/lib/context.d.ts +3 -0
- package/lib/context.d.ts.map +1 -1
- package/lib/context.js.map +1 -1
- package/lib/express/chatHandler.d.ts +5 -0
- package/lib/express/chatHandler.d.ts.map +1 -0
- package/lib/express/chatHandler.js +116 -0
- package/lib/express/chatHandler.js.map +1 -0
- package/lib/express/createBulkImportMiddleware.d.ts.map +1 -1
- package/lib/express/createBulkImportMiddleware.js +6 -7
- package/lib/express/createBulkImportMiddleware.js.map +1 -1
- package/lib/express/createERCMetadataMiddleware.d.ts.map +1 -1
- package/lib/express/createERCMetadataMiddleware.js +5 -9
- package/lib/express/createERCMetadataMiddleware.js.map +1 -1
- package/lib/express/createTempUploadMiddleware.d.ts.map +1 -1
- package/lib/express/createTempUploadMiddleware.js +4 -8
- package/lib/express/createTempUploadMiddleware.js.map +1 -1
- package/lib/express/index.d.ts +1 -0
- package/lib/express/index.d.ts.map +1 -1
- package/lib/express/index.js +1 -0
- package/lib/express/index.js.map +1 -1
- package/lib/fastify/bulkImportHandler.js +5 -6
- package/lib/fastify/bulkImportHandler.js.map +1 -1
- package/lib/fastify/chatHandler.d.ts +4 -0
- package/lib/fastify/chatHandler.d.ts.map +1 -0
- package/lib/fastify/chatHandler.js +110 -0
- package/lib/fastify/chatHandler.js.map +1 -0
- package/lib/fastify/ercMetadataHandler.d.ts.map +1 -1
- package/lib/fastify/ercMetadataHandler.js +3 -6
- package/lib/fastify/ercMetadataHandler.js.map +1 -1
- package/lib/fastify/index.d.ts +6 -1
- package/lib/fastify/index.d.ts.map +1 -1
- package/lib/fastify/index.js +28 -0
- package/lib/fastify/index.js.map +1 -1
- package/lib/fastify/mcpHandler.js +2 -2
- package/lib/fastify/mcpHandler.js.map +1 -1
- package/lib/fastify/tempUploadHandler.d.ts.map +1 -1
- package/lib/fastify/tempUploadHandler.js +3 -6
- package/lib/fastify/tempUploadHandler.js.map +1 -1
- package/lib/mcp/tools/product/handlers/addProductMedia.d.ts +26 -1
- package/lib/mcp/tools/product/handlers/addProductMedia.d.ts.map +1 -1
- package/lib/mcp/tools/product/handlers/addProductMedia.js +4 -4
- package/lib/mcp/tools/product/handlers/addProductMedia.js.map +1 -1
- package/lib/mcp/tools/product/handlers/updateProduct.d.ts.map +1 -1
- package/lib/mcp/tools/product/handlers/updateProduct.js +10 -2
- package/lib/mcp/tools/product/handlers/updateProduct.js.map +1 -1
- package/lib/mcp/tools/product/schemas.d.ts.map +1 -1
- package/lib/mcp/tools/product/schemas.js +3 -3
- package/lib/mcp/tools/product/schemas.js.map +1 -1
- package/lib/mcp/tools/users/schemas.d.ts +14 -14
- package/lib/mcp/utils/getNormalizedProductDetails.d.ts.map +1 -1
- package/lib/mcp/utils/getNormalizedProductDetails.js +3 -1
- package/lib/mcp/utils/getNormalizedProductDetails.js.map +1 -1
- package/lib/resolvers/mutations/orders/checkoutCart.js +1 -1
- package/lib/resolvers/mutations/orders/checkoutCart.js.map +1 -1
- package/lib/resolvers/queries/shopInfo.d.ts.map +1 -1
- package/lib/resolvers/queries/shopInfo.js +49 -3
- package/lib/resolvers/queries/shopInfo.js.map +1 -1
- package/lib/resolvers/type/index.d.ts +1 -1
- package/lib/resolvers/type/media-types.d.ts.map +1 -1
- package/lib/resolvers/type/media-types.js +3 -1
- package/lib/resolvers/type/media-types.js.map +1 -1
- package/lib/resolvers/type/price-types.d.ts +1 -1
- package/lib/resolvers/type/price-types.d.ts.map +1 -1
- package/lib/resolvers/type/price-types.js +5 -2
- package/lib/resolvers/type/price-types.js.map +1 -1
- package/lib/resolvers/type/shop-types.d.ts.map +1 -1
- package/lib/resolvers/type/shop-types.js.map +1 -1
- package/lib/schema/query.d.ts.map +1 -1
- package/lib/schema/query.js +2 -0
- package/lib/schema/query.js.map +1 -1
- package/lib/schema/types/shop.d.ts.map +1 -1
- package/lib/schema/types/shop.js +3 -0
- package/lib/schema/types/shop.js.map +1 -1
- package/package.json +13 -3
- package/src/chat/defaultSystemPrompt.ts +7 -0
- package/src/chat/generateImageHandler.ts +78 -0
- package/src/chat/normalizeToolsIndex.ts +11 -0
- package/src/chat/utils.ts +31 -0
- package/src/context.ts +3 -0
- package/src/express/chatHandler.ts +147 -0
- package/src/express/createBulkImportMiddleware.ts +7 -7
- package/src/express/createERCMetadataMiddleware.ts +5 -9
- package/src/express/createTempUploadMiddleware.ts +4 -9
- package/src/express/index.ts +2 -0
- package/src/fastify/bulkImportHandler.ts +6 -6
- package/src/fastify/chatHandler.ts +140 -0
- package/src/fastify/ercMetadataHandler.ts +3 -6
- package/src/fastify/index.ts +37 -1
- package/src/fastify/mcpHandler.ts +2 -2
- package/src/fastify/tempUploadHandler.ts +3 -6
- package/src/mcp/tools/product/handlers/addProductMedia.ts +4 -5
- package/src/mcp/tools/product/handlers/updateProduct.ts +12 -1
- package/src/mcp/tools/product/schemas.ts +7 -3
- package/src/mcp/utils/getNormalizedProductDetails.ts +4 -1
- package/src/resolvers/mutations/orders/checkoutCart.ts +1 -1
- package/src/resolvers/queries/shopInfo.ts +49 -3
- package/src/resolvers/type/media-types.ts +4 -1
- package/src/resolvers/type/price-types.ts +5 -3
- package/src/resolvers/type/shop-types.ts +0 -1
- package/src/schema/query.ts +2 -0
- package/src/schema/types/shop.ts +3 -0
|
@@ -68,11 +68,11 @@ export declare const actionValidators: {
|
|
|
68
68
|
start: z.ZodOptional<z.ZodString>;
|
|
69
69
|
end: z.ZodOptional<z.ZodString>;
|
|
70
70
|
}, "strip", z.ZodTypeAny, {
|
|
71
|
-
end?: string;
|
|
72
71
|
start?: string;
|
|
73
|
-
}, {
|
|
74
72
|
end?: string;
|
|
73
|
+
}, {
|
|
75
74
|
start?: string;
|
|
75
|
+
end?: string;
|
|
76
76
|
}>>;
|
|
77
77
|
queryString: z.ZodOptional<z.ZodString>;
|
|
78
78
|
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -94,8 +94,8 @@ export declare const actionValidators: {
|
|
|
94
94
|
value?: string;
|
|
95
95
|
}[];
|
|
96
96
|
lastLogin?: {
|
|
97
|
-
end?: string;
|
|
98
97
|
start?: string;
|
|
98
|
+
end?: string;
|
|
99
99
|
};
|
|
100
100
|
includeGuests?: boolean;
|
|
101
101
|
includeInactive?: boolean;
|
|
@@ -109,8 +109,8 @@ export declare const actionValidators: {
|
|
|
109
109
|
value?: string;
|
|
110
110
|
}[];
|
|
111
111
|
lastLogin?: {
|
|
112
|
-
end?: string;
|
|
113
112
|
start?: string;
|
|
113
|
+
end?: string;
|
|
114
114
|
};
|
|
115
115
|
includeGuests?: boolean;
|
|
116
116
|
includeInactive?: boolean;
|
|
@@ -126,18 +126,18 @@ export declare const actionValidators: {
|
|
|
126
126
|
start: z.ZodOptional<z.ZodString>;
|
|
127
127
|
end: z.ZodOptional<z.ZodString>;
|
|
128
128
|
}, "strip", z.ZodTypeAny, {
|
|
129
|
-
end?: string;
|
|
130
129
|
start?: string;
|
|
131
|
-
}, {
|
|
132
130
|
end?: string;
|
|
131
|
+
}, {
|
|
133
132
|
start?: string;
|
|
133
|
+
end?: string;
|
|
134
134
|
}>>;
|
|
135
135
|
queryString: z.ZodOptional<z.ZodString>;
|
|
136
136
|
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
137
137
|
}, "strip", z.ZodTypeAny, {
|
|
138
138
|
lastLogin?: {
|
|
139
|
-
end?: string;
|
|
140
139
|
start?: string;
|
|
140
|
+
end?: string;
|
|
141
141
|
};
|
|
142
142
|
includeGuests?: boolean;
|
|
143
143
|
includeInactive?: boolean;
|
|
@@ -145,8 +145,8 @@ export declare const actionValidators: {
|
|
|
145
145
|
emailVerified?: boolean;
|
|
146
146
|
}, {
|
|
147
147
|
lastLogin?: {
|
|
148
|
-
end?: string;
|
|
149
148
|
start?: string;
|
|
149
|
+
end?: string;
|
|
150
150
|
};
|
|
151
151
|
includeGuests?: boolean;
|
|
152
152
|
includeInactive?: boolean;
|
|
@@ -725,11 +725,11 @@ export declare const UsersManagementSchema: {
|
|
|
725
725
|
start: z.ZodOptional<z.ZodString>;
|
|
726
726
|
end: z.ZodOptional<z.ZodString>;
|
|
727
727
|
}, "strip", z.ZodTypeAny, {
|
|
728
|
-
end?: string;
|
|
729
728
|
start?: string;
|
|
730
|
-
}, {
|
|
731
729
|
end?: string;
|
|
730
|
+
}, {
|
|
732
731
|
start?: string;
|
|
732
|
+
end?: string;
|
|
733
733
|
}>>;
|
|
734
734
|
includeCarts: z.ZodOptional<z.ZodBoolean>;
|
|
735
735
|
status: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -825,11 +825,11 @@ export declare const UsersManagementZodSchema: z.ZodObject<{
|
|
|
825
825
|
start: z.ZodOptional<z.ZodString>;
|
|
826
826
|
end: z.ZodOptional<z.ZodString>;
|
|
827
827
|
}, "strip", z.ZodTypeAny, {
|
|
828
|
-
end?: string;
|
|
829
828
|
start?: string;
|
|
830
|
-
}, {
|
|
831
829
|
end?: string;
|
|
830
|
+
}, {
|
|
832
831
|
start?: string;
|
|
832
|
+
end?: string;
|
|
833
833
|
}>>;
|
|
834
834
|
includeCarts: z.ZodOptional<z.ZodBoolean>;
|
|
835
835
|
status: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -925,8 +925,8 @@ export declare const UsersManagementZodSchema: z.ZodObject<{
|
|
|
925
925
|
}[];
|
|
926
926
|
status?: string[];
|
|
927
927
|
lastLogin?: {
|
|
928
|
-
end?: string;
|
|
929
928
|
start?: string;
|
|
929
|
+
end?: string;
|
|
930
930
|
};
|
|
931
931
|
profile?: {
|
|
932
932
|
address?: {
|
|
@@ -966,8 +966,8 @@ export declare const UsersManagementZodSchema: z.ZodObject<{
|
|
|
966
966
|
}[];
|
|
967
967
|
status?: string[];
|
|
968
968
|
lastLogin?: {
|
|
969
|
-
end?: string;
|
|
970
969
|
start?: string;
|
|
970
|
+
end?: string;
|
|
971
971
|
};
|
|
972
972
|
profile?: {
|
|
973
973
|
address?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNormalizedProductDetails.d.ts","sourceRoot":"","sources":["../../../src/mcp/utils/getNormalizedProductDetails.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"getNormalizedProductDetails.d.ts","sourceRoot":"","sources":["../../../src/mcp/utils/getNormalizedProductDetails.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3C,wBAAsB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;GAkGpF"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ProductTypes } from '@unchainedshop/core-products';
|
|
2
2
|
import normalizeMediaUrl from './normalizeMediaUrl.js';
|
|
3
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
4
|
+
const logger = createLogger('unchained:api:mcp');
|
|
3
5
|
export async function getNormalizedProductDetails(productId, context) {
|
|
4
6
|
const { modules, locale, loaders } = context;
|
|
5
7
|
const product = await modules.products.findProduct({ productId });
|
|
@@ -75,7 +77,7 @@ export async function getNormalizedProductDetails(productId, context) {
|
|
|
75
77
|
}
|
|
76
78
|
catch {
|
|
77
79
|
// Pricing might not be available for all products
|
|
78
|
-
|
|
80
|
+
logger.warn('Pricing not available for product:', product._id);
|
|
79
81
|
}
|
|
80
82
|
const productMedias = await modules.products.media.findProductMedias({ productId });
|
|
81
83
|
const media = await normalizeMediaUrl(productMedias, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNormalizedProductDetails.js","sourceRoot":"","sources":["../../../src/mcp/utils/getNormalizedProductDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"getNormalizedProductDetails.js","sourceRoot":"","sources":["../../../src/mcp/utils/getNormalizedProductDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,SAAiB,EAAE,OAAgB;IACnF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC7C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAElE,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC;QACjD,SAAS;Q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AAa,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IACpF,MAAM,KAAK,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAE9D,OAAO;QACL,GAAG,OAAO;QACV,KAAK;QACL,KAAK;QACL,WAAW;QACX,UAAU;QACV,WAAW;QACX,OAAO;QACP,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -18,7 +18,7 @@ export default async function checkoutCart(root, params, context) {
|
|
|
18
18
|
return checkedOutOrder;
|
|
19
19
|
}
|
|
20
20
|
catch (error) {
|
|
21
|
-
logger.error(error
|
|
21
|
+
logger.error(error, { userId, orderId: order._id });
|
|
22
22
|
throw new OrderCheckoutError({
|
|
23
23
|
userId,
|
|
24
24
|
orderId: order._id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkoutCart.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/orders/checkoutCart.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,MAAM,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AAE7C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CACxC,IAAW,EACX,MAIC,EACD,OAAgB;IAEhB,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3C,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,kBAAkB,EAAE,GAAG,MAAM,CAAC;IAEhE,GAAG,CAAC,uBAAuB,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;IAEhE,+EAA+E;IAC/E,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC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;IACH,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,kBAAkB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;IAEpE,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;QAC3F,OAAO,eAAe,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QACpD,MAAM,IAAI,kBAAkB,CAAC;YAC3B,MAAM;YACN,OAAO,EAAE,KAAK,CAAC,GAAG;YAClB,GAAG,kBAAkB;YACrB,UAAU,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI;YACpC,aAAa,EAAE,KAAK,CAAC,OAAO;SAC7B,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopInfo.d.ts","sourceRoot":"","sources":["../../../src/resolvers/queries/shopInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shopInfo.d.ts","sourceRoot":"","sources":["../../../src/resolvers/queries/shopInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,IAAI,EAAE,KAAK,EACX,CAAC,EAAE,KAAK,EACR,OAAO,EAAE,OAAO,GACf;IACD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAiEA"}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
1
2
|
import { log } from '@unchainedshop/logger';
|
|
2
3
|
export default function shopInfo(root, _, context) {
|
|
3
|
-
const { adminUiConfig } = context;
|
|
4
|
+
const { adminUiConfig, modules } = context;
|
|
4
5
|
log('query shopInfo', { userId: context.userId });
|
|
5
6
|
return {
|
|
6
7
|
version: context.version,
|
|
7
8
|
adminUiConfig: {
|
|
8
|
-
customProperties:
|
|
9
|
-
|
|
9
|
+
customProperties: async () => {
|
|
10
|
+
try {
|
|
11
|
+
const raw = await readFile(process.env.UNCHAINED_ADMIN_UI_CUSTOM_PROPERTIES, 'utf-8');
|
|
12
|
+
const parsed = JSON.parse(raw);
|
|
13
|
+
return parsed;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return adminUiConfig?.customProperties ?? [];
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
singleSignOnURL: process.env.UNCHAINED_ADMIN_UI_SINGLE_SIGN_ON_URL || adminUiConfig?.singleSignOnURL,
|
|
10
20
|
externalLinks: () => {
|
|
11
21
|
try {
|
|
12
22
|
const parsed = JSON.parse(process.env.EXTERNAL_LINKS);
|
|
@@ -16,6 +26,42 @@ export default function shopInfo(root, _, context) {
|
|
|
16
26
|
return [];
|
|
17
27
|
}
|
|
18
28
|
},
|
|
29
|
+
productTags: async () => {
|
|
30
|
+
const existingProductTags = await modules.products.existingTags();
|
|
31
|
+
const envTags = (process.env.UNCHAINED_ADMIN_UI_DEFAULT_PRODUCT_TAGS || '')
|
|
32
|
+
.split(',')
|
|
33
|
+
.map((t) => t.trim())
|
|
34
|
+
.filter(Boolean);
|
|
35
|
+
const normalizedDefaultTags = envTags?.length
|
|
36
|
+
? envTags
|
|
37
|
+
: (adminUiConfig?.defaultProductTags || []).filter(Boolean);
|
|
38
|
+
const normalizedTags = Array.from(new Set(normalizedDefaultTags.concat(existingProductTags)));
|
|
39
|
+
return normalizedTags;
|
|
40
|
+
},
|
|
41
|
+
assortmentTags: async () => {
|
|
42
|
+
const existingAssortmentTags = await modules.assortments.existingTags();
|
|
43
|
+
const envTags = (process.env.UNCHAINED_ADMIN_UI_DEFAULT_ASSORTMENT_TAGS || '')
|
|
44
|
+
.split(',')
|
|
45
|
+
.map((t) => t.trim())
|
|
46
|
+
.filter(Boolean);
|
|
47
|
+
const normalizedDefaultTags = envTags?.length
|
|
48
|
+
? envTags
|
|
49
|
+
: (adminUiConfig?.defaultAssortmentTags || []).filter(Boolean);
|
|
50
|
+
const normalizedTags = Array.from(new Set(normalizedDefaultTags.concat(existingAssortmentTags)));
|
|
51
|
+
return normalizedTags;
|
|
52
|
+
},
|
|
53
|
+
userTags: async () => {
|
|
54
|
+
const existingUserTags = await modules.users.existingTags();
|
|
55
|
+
const envTags = (process.env.UNCHAINED_ADMIN_UI_DEFAULT_USER_TAGS || '')
|
|
56
|
+
.split(',')
|
|
57
|
+
.map((t) => t.trim())
|
|
58
|
+
.filter(Boolean);
|
|
59
|
+
const normalizedDefaultTags = envTags?.length
|
|
60
|
+
? envTags
|
|
61
|
+
: (adminUiConfig?.defaultUserTags || []).filter(Boolean);
|
|
62
|
+
const normalizedTags = Array.from(new Set(normalizedDefaultTags.concat(existingUserTags)));
|
|
63
|
+
return normalizedTags;
|
|
64
|
+
},
|
|
19
65
|
},
|
|
20
66
|
vapidPublicKey: process.env?.PUSH_NOTIFICATION_PUBLIC_KEY,
|
|
21
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopInfo.js","sourceRoot":"","sources":["../../../src/resolvers/queries/shopInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shopInfo.js","sourceRoot":"","sources":["../../../src/resolvers/queries/shopInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,IAAW,EACX,CAAQ,EACR,OAAgB;I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AAC;qBACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;qBACpB,MAAM,CAAC,OAAO,CAAC,CAAC;gBACnB,MAAM,qBAAqB,GAAG,OAAO,EAAE,MAAM;oBAC3C,CAAC,CAAC,OAAO;oBACT,CAAC,CAAC,CAAC,aAAa,EAAE,eAAe,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;gBAC3F,OAAO,cAAc,CAAC;YACxB,CAAC;SACF;QACD,cAAc,EAAE,OAAO,CAAC,GAAG,EAAE,4BAA4B;KAC1D,CAAC;AACJ,CAAC;AAED,EAAE"}
|
|
@@ -555,7 +555,7 @@ declare const types: {
|
|
|
555
555
|
isTaxable({ isTaxable }: import("./price-types.js").PriceType): boolean;
|
|
556
556
|
isNetPrice({ isNetPrice }: import("./price-types.js").PriceType): boolean;
|
|
557
557
|
currencyCode(obj: import("./price-types.js").PriceType): string;
|
|
558
|
-
amount(obj: import("./price-types.js").PriceType):
|
|
558
|
+
amount(obj: import("./price-types.js").PriceType): string | 0;
|
|
559
559
|
};
|
|
560
560
|
Product: {
|
|
561
561
|
__resolveType: (product: import("@unchainedshop/core-products").Product) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-types.d.ts","sourceRoot":"","sources":["../../../src/resolvers/type/media-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAkB,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"media-types.d.ts","sourceRoot":"","sources":["../../../src/resolvers/type/media-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAkB,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3C,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7F;AAED,eAAO,MAAM,KAAK,EAAE,gBAcnB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { getFileAdapter } from '@unchainedshop/core-files';
|
|
2
2
|
import { checkAction } from '../../acl.js';
|
|
3
3
|
import { actions } from '../../roles/index.js';
|
|
4
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
5
|
+
const logger = createLogger('unchained:api');
|
|
4
6
|
export const Media = {
|
|
5
7
|
url: async (file, params, context) => {
|
|
6
8
|
const { modules } = context;
|
|
@@ -13,7 +15,7 @@ export const Media = {
|
|
|
13
15
|
return modules.files.normalizeUrl(url, params);
|
|
14
16
|
}
|
|
15
17
|
catch (e) {
|
|
16
|
-
|
|
18
|
+
logger.error(e);
|
|
17
19
|
return null;
|
|
18
20
|
}
|
|
19
21
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/media-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"media-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/media-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AAK7C,MAAM,CAAC,MAAM,KAAK,GAAqB;IACrC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QACnC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAC5B,IAAI,CAAC;YACH,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;YACjE,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAC;YACvB,MAAM,iBAAiB,GAAG,cAAc,EAAE,CAAC;YAC3C,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YAC7E,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAChB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -10,6 +10,6 @@ export declare const Price: {
|
|
|
10
10
|
isTaxable({ isTaxable }: PriceType): boolean;
|
|
11
11
|
isNetPrice({ isNetPrice }: PriceType): boolean;
|
|
12
12
|
currencyCode(obj: PriceType): string;
|
|
13
|
-
amount(obj: PriceType):
|
|
13
|
+
amount(obj: PriceType): string | 0;
|
|
14
14
|
};
|
|
15
15
|
//# sourceMappingURL=price-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price-types.d.ts","sourceRoot":"","sources":["../../../src/resolvers/type/price-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"price-types.d.ts","sourceRoot":"","sources":["../../../src/resolvers/type/price-types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,KAAK;6BACS,SAAS;+BAGP,SAAS;sBAGlB,SAAS;gBAGf,SAAS;CAUtB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import accounting from 'accounting';
|
|
2
1
|
export const Price = {
|
|
3
2
|
isTaxable({ isTaxable }) {
|
|
4
3
|
return isTaxable || false;
|
|
@@ -11,7 +10,11 @@ export const Price = {
|
|
|
11
10
|
},
|
|
12
11
|
amount(obj) {
|
|
13
12
|
if (obj.amount) {
|
|
14
|
-
return
|
|
13
|
+
return Number(obj.amount).toLocaleString(undefined, {
|
|
14
|
+
minimumFractionDigits: 0,
|
|
15
|
+
maximumFractionDigits: 0,
|
|
16
|
+
useGrouping: false,
|
|
17
|
+
});
|
|
15
18
|
}
|
|
16
19
|
return 0;
|
|
17
20
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/price-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"price-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/price-types.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,SAAS,CAAC,EAAE,SAAS,EAAa;QAChC,OAAO,SAAS,IAAI,KAAK,CAAC;IAC5B,CAAC;IACD,UAAU,CAAC,EAAE,UAAU,EAAa;QAClC,OAAO,UAAU,IAAI,KAAK,CAAC;IAC7B,CAAC;IACD,YAAY,CAAC,GAAc;QACzB,OAAO,GAAG,EAAE,YAAY,CAAC;IAC3B,CAAC;IACD,MAAM,CAAC,GAAc;QACnB,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YACf,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE;gBAClD,qBAAqB,EAAE,CAAC;gBACxB,qBAAqB,EAAE,CAAC;gBACxB,WAAW,EAAE,KAAK;aACnB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shop-types.d.ts","sourceRoot":"","sources":["../../../src/resolvers/type/shop-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAIzD,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"shop-types.d.ts","sourceRoot":"","sources":["../../../src/resolvers/type/shop-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAIzD,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAClF,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC/B,SAAS,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;CACjC;AAED,eAAO,MAAM,IAAI,EAAE,eAkBlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shop-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/shop-types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"shop-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/shop-types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAUzD,MAAM,CAAC,MAAM,IAAI,GAAoB;IACnC,GAAG;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QACtD,OAAO,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1D,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QAC3C,MAAM,WAAW,CAAC,OAAO,EAAG,OAAe,CAAC,WAAW,CAAC,CAAC;QACzD,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;aAC3B,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;aACvB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IACrD,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/schema/query.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/schema/query.ts"],"names":[],"mappings":";AAAA,wBAqgBE"}
|
package/lib/schema/query.js
CHANGED
|
@@ -22,6 +22,7 @@ export default [
|
|
|
22
22
|
sort: [SortOptionInput!]
|
|
23
23
|
emailVerified: Boolean
|
|
24
24
|
lastLogin: DateFilterInput
|
|
25
|
+
tags: [LowerCaseString!]
|
|
25
26
|
): [User!]!
|
|
26
27
|
|
|
27
28
|
"""
|
|
@@ -32,6 +33,7 @@ export default [
|
|
|
32
33
|
queryString: String
|
|
33
34
|
emailVerified: Boolean
|
|
34
35
|
lastLogin: DateFilterInput
|
|
36
|
+
tags: [LowerCaseString!]
|
|
35
37
|
): Int!
|
|
36
38
|
|
|
37
39
|
"""
|
package/lib/schema/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/schema/query.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/schema/query.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmgBb;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shop.d.ts","sourceRoot":"","sources":["../../../src/schema/types/shop.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"shop.d.ts","sourceRoot":"","sources":["../../../src/schema/types/shop.ts"],"names":[],"mappings":";AAAA,wBA0CE"}
|
package/lib/schema/types/shop.js
CHANGED
|
@@ -25,6 +25,9 @@ export default [
|
|
|
25
25
|
customProperties: [AdminUiConfigCustomEntityInterface!]!
|
|
26
26
|
externalLinks: [AdminUiLink!]!
|
|
27
27
|
singleSignOnURL: String
|
|
28
|
+
productTags: [String!]!
|
|
29
|
+
assortmentTags: [String!]!
|
|
30
|
+
userTags: [String!]!
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
type Shop @cacheControl(maxAge: 180) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shop.js","sourceRoot":"","sources":["../../../src/schema/types/shop.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"shop.js","sourceRoot":"","sources":["../../../src/schema/types/shop.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCb;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/api",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.16",
|
|
4
4
|
"main": "lib/api-index.js",
|
|
5
5
|
"types": "lib/api-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -35,8 +35,10 @@
|
|
|
35
35
|
"@fastify/cookie": ">= 11 < 12",
|
|
36
36
|
"@fastify/session": ">= 11 < 12",
|
|
37
37
|
"@fastify/multipart": ">= 9 < 10",
|
|
38
|
+
"@fastify/static": ">= 8 < 9",
|
|
38
39
|
"connect-mongo": ">= 5.1 < 6",
|
|
39
40
|
"@modelcontextprotocol/sdk": ">= 1 < 2",
|
|
41
|
+
"ai": ">= 5 < 6",
|
|
40
42
|
"express": ">= 5 < 6",
|
|
41
43
|
"express-session": ">= 1.18 < 2",
|
|
42
44
|
"multer": ">= 2 < 3",
|
|
@@ -49,6 +51,9 @@
|
|
|
49
51
|
"@modelcontextprotocol/sdk": {
|
|
50
52
|
"optional": false
|
|
51
53
|
},
|
|
54
|
+
"ai": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
52
57
|
"graphql-yoga": {
|
|
53
58
|
"optional": false
|
|
54
59
|
},
|
|
@@ -67,6 +72,9 @@
|
|
|
67
72
|
"@fastify/session": {
|
|
68
73
|
"optional": true
|
|
69
74
|
},
|
|
75
|
+
"@fastify/static": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
70
78
|
"express": {
|
|
71
79
|
"optional": true
|
|
72
80
|
},
|
|
@@ -92,20 +100,22 @@
|
|
|
92
100
|
"@unchainedshop/logger": "^4.0.0-rc.15",
|
|
93
101
|
"@unchainedshop/roles": "^4.0.0-rc.15",
|
|
94
102
|
"@unchainedshop/utils": "^4.0.0-rc.15",
|
|
95
|
-
"
|
|
103
|
+
"file-type": "^21.0.0",
|
|
96
104
|
"dataloader": "^2.2.3",
|
|
97
105
|
"expiry-map": "^2.0.0",
|
|
98
106
|
"graphql-scalars": "^1.24.2",
|
|
99
107
|
"moniker": "0.1.2",
|
|
100
108
|
"p-memoize": "^8.0.0",
|
|
101
|
-
"zod": "^3.25.76"
|
|
109
|
+
"zod": "^3.25.76 || ^4"
|
|
102
110
|
},
|
|
103
111
|
"devDependencies": {
|
|
112
|
+
"ai": "^5.0.5",
|
|
104
113
|
"@noble/curves": "^2.0.0",
|
|
105
114
|
"@noble/hashes": "^2.0.0",
|
|
106
115
|
"@fastify/cookie": "^11.0.2",
|
|
107
116
|
"@fastify/multipart": "^9.0.3",
|
|
108
117
|
"@fastify/session": "^11.1.0",
|
|
118
|
+
"@fastify/static": "^8.2.0",
|
|
109
119
|
"@modelcontextprotocol/sdk": "^1.15.1",
|
|
110
120
|
"@types/express": "^5.0.3",
|
|
111
121
|
"@types/node": "^24.0.13",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const defaultSystemPrompt = `Use tools when requested but do not provide summaries or explanations after tool calls. Only return the direct tool results. Do not include the data in your summary, just write a summary about it in one short paragraph and never list all the fields of a result, just summarize paragraph about your findings, if necessary.
|
|
2
|
+
Rules for using the Unchained MCP tools:
|
|
3
|
+
- All prices are integer type and to correctly determine the currency decimal points you need to check currencies.
|
|
4
|
+
- Determine the currently used language / locale for creating and updating products, filters and assortments by checking Shop Info.
|
|
5
|
+
`;
|
|
6
|
+
|
|
7
|
+
export default defaultSystemPrompt;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { experimental_generateImage, ImageModel, tool } from 'ai';
|
|
2
|
+
import { fileTypeFromBuffer } from 'file-type';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
const inputSchema = z.object({
|
|
6
|
+
prompt: z.string().describe('The prompt to generate the image from'),
|
|
7
|
+
size: z
|
|
8
|
+
.enum([
|
|
9
|
+
'512x512',
|
|
10
|
+
'768x768',
|
|
11
|
+
'1024x1024',
|
|
12
|
+
'512x896',
|
|
13
|
+
'640x1120',
|
|
14
|
+
'768x1344',
|
|
15
|
+
'1024x1792',
|
|
16
|
+
'896x512',
|
|
17
|
+
'1120x640',
|
|
18
|
+
'1344x768',
|
|
19
|
+
'1792x1024',
|
|
20
|
+
])
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('The size of the image (default is 1024x1024).'),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const generateImageHandler =
|
|
26
|
+
(req: any) =>
|
|
27
|
+
({
|
|
28
|
+
model,
|
|
29
|
+
uploadUrl = `${process.env.ROOT_URL}/temp-upload`,
|
|
30
|
+
}: {
|
|
31
|
+
model: ImageModel;
|
|
32
|
+
uploadUrl?: string;
|
|
33
|
+
}) => {
|
|
34
|
+
return tool<any>({
|
|
35
|
+
description: 'Generate an image based on the prompt',
|
|
36
|
+
inputSchema: inputSchema as any,
|
|
37
|
+
name: 'generate_image',
|
|
38
|
+
execute: async ({ prompt, size = '1024x1024' }) => {
|
|
39
|
+
try {
|
|
40
|
+
const { image } = await experimental_generateImage({
|
|
41
|
+
model,
|
|
42
|
+
prompt,
|
|
43
|
+
size: size as any,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const buffer = Buffer.from(image.base64, 'base64');
|
|
47
|
+
const fileType = await fileTypeFromBuffer(buffer);
|
|
48
|
+
const extension = fileType?.ext || 'png';
|
|
49
|
+
const mime = fileType?.mime || 'image/png';
|
|
50
|
+
|
|
51
|
+
const filename = `image-${Date.now()}.${extension}`;
|
|
52
|
+
const file = new File([buffer], filename, { type: mime });
|
|
53
|
+
const formData = new FormData();
|
|
54
|
+
formData.append('image', file);
|
|
55
|
+
|
|
56
|
+
const uploadRes = await fetch(uploadUrl, {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
body: formData,
|
|
59
|
+
credentials: 'include',
|
|
60
|
+
headers: {
|
|
61
|
+
Cookie: req?.headers?.cookie || req?.headers?.get('cookie') || '',
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (!uploadRes.ok) {
|
|
66
|
+
throw new Error(`Image upload failed: ${uploadRes.statusText}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const { url } = await uploadRes.json();
|
|
70
|
+
return { imageUrl: url, prompt };
|
|
71
|
+
} catch (error) {
|
|
72
|
+
return `Error Generating image: ${(error as Error).message}`;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default generateImageHandler;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { categorizeTools } from './utils.js';
|
|
2
|
+
|
|
3
|
+
export default function normalizeToolsIndex(mcpTools: any) {
|
|
4
|
+
const tools = Object.entries(mcpTools).map(([name, tool]: any) => ({
|
|
5
|
+
name,
|
|
6
|
+
description: tool.description || '',
|
|
7
|
+
parameters: tool.parameters || {},
|
|
8
|
+
category: categorizeTools(name),
|
|
9
|
+
}));
|
|
10
|
+
return tools;
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ImageModel, NoSuchToolError, InvalidArgumentError, streamText } from 'ai';
|
|
2
|
+
|
|
3
|
+
type StreamTextParams = Parameters<typeof streamText>[0];
|
|
4
|
+
|
|
5
|
+
export type ChatConfiguration = Omit<StreamTextParams, 'messages'> & {
|
|
6
|
+
unchainedMCPUrl?: string;
|
|
7
|
+
imageGenerationTool?: { model: ImageModel; uploadUrl?: string };
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const errorHandler = (error: any): string => {
|
|
11
|
+
if (NoSuchToolError.isInstance(error)) return 'NoSuchToolError';
|
|
12
|
+
if (InvalidArgumentError.isInstance(error)) return 'InvalidToolArgumentsError';
|
|
13
|
+
/* if (ToolExecutionError.isInstance(error)) return 'ToolExecutionError'; */
|
|
14
|
+
if (error?.message?.toLowerCase()?.includes('forbidden')) return 'NetworkError';
|
|
15
|
+
if (error?.message?.toLowerCase()?.includes('limit')) return 'LimitExceeded';
|
|
16
|
+
return `Failed to stream response: ${error?.message || 'Unknown error'}`;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const categorizeTools = (toolName: string): string => {
|
|
20
|
+
const name = toolName.toLowerCase();
|
|
21
|
+
|
|
22
|
+
if (name.includes('product')) return 'Product Management';
|
|
23
|
+
if (name.includes('order')) return 'Order Management';
|
|
24
|
+
if (name.includes('customer') || name.includes('user')) return 'Customer Management';
|
|
25
|
+
if (name.includes('shop') || name.includes('settings')) return 'Shop Configuration';
|
|
26
|
+
if (name.includes('assortment')) return 'Assortments';
|
|
27
|
+
if (name.includes('filter')) return 'Filters';
|
|
28
|
+
if (name.includes('image') || name.includes('generate')) return 'Media & Content';
|
|
29
|
+
|
|
30
|
+
return 'Other Tools';
|
|
31
|
+
};
|
package/src/context.ts
CHANGED
|
@@ -29,6 +29,9 @@ export interface CustomAdminUiProperties {
|
|
|
29
29
|
export interface AdminUiConfig {
|
|
30
30
|
customProperties?: CustomAdminUiProperties[];
|
|
31
31
|
singleSignOnURL?: string;
|
|
32
|
+
defaultProductTags?: string[];
|
|
33
|
+
defaultAssortmentTags?: string[];
|
|
34
|
+
defaultUserTags?: string[];
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
export interface UnchainedHTTPServerContext {
|