@unchainedshop/api 4.8.0 → 4.8.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/chat/generateImageHandler.js +5 -6
- package/lib/express/createBulkImportMiddleware.js +3 -2
- package/lib/express/createMCPMiddleware.js +1 -1
- package/lib/fastify/bulkImportHandler.js +3 -2
- package/lib/fastify/mcpHandler.js +1 -1
- package/lib/loaders/buildTextMap.js +13 -15
- package/lib/mcp/tools/assortment/assortmentManagement.d.ts +2 -2
- package/lib/mcp/tools/assortment/assortmentManagement.js +2 -2
- package/lib/mcp/tools/assortment/handlers/getAssortment.js +1 -1
- package/lib/mcp/tools/assortment/schemas.d.ts +141 -322
- package/lib/mcp/tools/assortment/schemas.js +96 -179
- 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 +75 -184
- package/lib/mcp/tools/filter/schemas.js +51 -87
- 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 +47 -110
- package/lib/mcp/tools/localization/schemas.js +36 -51
- 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 +75 -184
- package/lib/mcp/tools/order/schemas.js +51 -113
- package/lib/mcp/tools/product/handlers/getProduct.js +1 -1
- 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 +317 -642
- package/lib/mcp/tools/product/schemas.js +191 -287
- 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 +47 -142
- package/lib/mcp/tools/provider/schemas.js +32 -67
- 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 +40 -111
- package/lib/mcp/tools/quotation/schemas.js +29 -54
- package/lib/mcp/tools/system/schemas.d.ts +84 -179
- package/lib/mcp/tools/system/schemas.js +67 -188
- package/lib/mcp/tools/system/systemManagement.d.ts +1 -1
- package/lib/mcp/tools/system/systemManagement.js +1 -1
- package/lib/mcp/tools/users/schemas.d.ts +163 -296
- package/lib/mcp/tools/users/schemas.js +71 -152
- package/lib/mcp/tools/users/usersManagement.d.ts +2 -2
- package/lib/mcp/tools/users/usersManagement.js +2 -2
- package/lib/mcp/utils/sharedSchemas.d.ts +39 -28
- package/lib/mcp/utils/sharedSchemas.js +47 -28
- package/lib/resolvers/mutations/accounts/changePassword.js +1 -4
- package/lib/resolvers/mutations/worker/addWork.js +2 -2
- package/lib/resolvers/queries/events/registeredEventTypes.d.ts +1 -0
- package/lib/resolvers/queries/events/registeredEventTypes.js +4 -0
- package/lib/resolvers/queries/index.d.ts +1 -0
- package/lib/resolvers/queries/index.js +2 -0
- package/lib/schema/query.js +5 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import { z } from 'zod/v4-mini';
|
|
2
2
|
import mime from 'mime/lite';
|
|
3
3
|
import { createLogger } from '@unchainedshop/logger';
|
|
4
4
|
const logger = createLogger('unchained:api:mcp');
|
|
@@ -12,9 +12,9 @@ try {
|
|
|
12
12
|
catch {
|
|
13
13
|
}
|
|
14
14
|
const inputSchema = z.object({
|
|
15
|
-
prompt: z.string().describe('The prompt to generate the image from'),
|
|
15
|
+
prompt: z.string().check(z.describe('The prompt to generate the image from')),
|
|
16
16
|
size: z
|
|
17
|
-
.enum([
|
|
17
|
+
.optional(z.enum([
|
|
18
18
|
'512x512',
|
|
19
19
|
'768x768',
|
|
20
20
|
'1024x1024',
|
|
@@ -26,9 +26,8 @@ const inputSchema = z.object({
|
|
|
26
26
|
'1120x640',
|
|
27
27
|
'1344x768',
|
|
28
28
|
'1792x1024',
|
|
29
|
-
])
|
|
30
|
-
.
|
|
31
|
-
.describe('The size of the image (default is 1024x1024).'),
|
|
29
|
+
]))
|
|
30
|
+
.check(z.describe('The size of the image (default is 1024x1024).')),
|
|
32
31
|
});
|
|
33
32
|
const generateImageHandler = (req) => ({ model, uploadUrl = `${process.env.ROOT_URL}/temp-upload`, }) => {
|
|
34
33
|
return tool({
|
|
@@ -43,8 +43,9 @@ export default async function bulkImportMiddleware(req, res) {
|
|
|
43
43
|
res.status(200).send(work);
|
|
44
44
|
}
|
|
45
45
|
catch (e) {
|
|
46
|
-
logger.error(e);
|
|
47
|
-
|
|
46
|
+
logger.error(e.message);
|
|
47
|
+
const cause = e.cause?.issues || e.cause;
|
|
48
|
+
res.status(503).send({ name: e.name, code: e.code, message: e.message, cause });
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import initMCPServer from "../mcp/index.js";
|
|
2
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
2
|
const logger = createLogger('unchained:api:mcp');
|
|
4
3
|
let StreamableHTTPServerTransport;
|
|
@@ -35,6 +34,7 @@ const handlePostRequest = async (req, res) => {
|
|
|
35
34
|
}
|
|
36
35
|
};
|
|
37
36
|
const roles = req.unchainedContext.user?.roles || [];
|
|
37
|
+
const { default: initMCPServer } = await import("../mcp/index.js");
|
|
38
38
|
const server = initMCPServer(new McpServer({
|
|
39
39
|
name: 'Unchained MCP Server',
|
|
40
40
|
version: '1.0.0',
|
|
@@ -37,9 +37,10 @@ const bulkImportHandler = async (req, res) => {
|
|
|
37
37
|
return res.send(work);
|
|
38
38
|
}
|
|
39
39
|
catch (e) {
|
|
40
|
-
logger.error(e);
|
|
40
|
+
logger.error(e.message);
|
|
41
41
|
res.status(503);
|
|
42
|
-
|
|
42
|
+
const cause = e.cause?.issues || e.cause;
|
|
43
|
+
return res.send({ name: e.name, code: e.code, message: e.message, cause });
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
46
|
export default bulkImportHandler;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import initMCPServer from "../mcp/index.js";
|
|
2
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
2
|
const logger = createLogger('unchained:api:mcp');
|
|
4
3
|
let StreamableHTTPServerTransport;
|
|
@@ -45,6 +44,7 @@ const mcpHandler = async (req, res) => {
|
|
|
45
44
|
}
|
|
46
45
|
};
|
|
47
46
|
const roles = req.unchainedContext.user.roles || [];
|
|
47
|
+
const { default: initMCPServer } = await import("../mcp/index.js");
|
|
48
48
|
const server = initMCPServer(new McpServer({
|
|
49
49
|
name: 'Unchained MCP Server',
|
|
50
50
|
version: '1.0.0',
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
export default function buildTextMap(localeMap, texts, buildId) {
|
|
2
2
|
const textsMap = {};
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
for (let j = 0; j < texts.length; j++) {
|
|
4
|
+
const text = texts[j];
|
|
5
|
+
if (!text.locale)
|
|
6
|
+
continue;
|
|
7
|
+
const localesForText = localeMap[text.locale];
|
|
8
|
+
if (!localesForText)
|
|
9
|
+
continue;
|
|
10
|
+
const idPart = buildId(text);
|
|
11
|
+
for (let k = 0; k < localesForText.length; k++) {
|
|
12
|
+
const locale = localesForText[k];
|
|
13
|
+
const key = locale + idPart;
|
|
14
|
+
if (textsMap[key] && locale !== text.locale) {
|
|
10
15
|
continue;
|
|
11
|
-
const idPart = buildId(text);
|
|
12
|
-
for (let k = 0; k < localesForText.length; k++) {
|
|
13
|
-
const locale = localesForText[k];
|
|
14
|
-
const key = locale + idPart;
|
|
15
|
-
if (textsMap[key] && locale !== text.locale) {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
textsMap[key] = text;
|
|
19
16
|
}
|
|
17
|
+
textsMap[key] = text;
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
return textsMap;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from '../../../context.ts';
|
|
2
|
-
import { AssortmentManagementSchema,
|
|
3
|
-
export { AssortmentManagementSchema
|
|
2
|
+
import { AssortmentManagementSchema, type AssortmentManagementParams } from './schemas.ts';
|
|
3
|
+
export { AssortmentManagementSchema };
|
|
4
4
|
export type { AssortmentManagementParams };
|
|
5
5
|
export declare function assortmentManagement(context: Context, params: AssortmentManagementParams): Promise<{
|
|
6
6
|
content: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
-
import { actionValidators, AssortmentManagementSchema,
|
|
2
|
+
import { actionValidators, AssortmentManagementSchema, } from "./schemas.js";
|
|
3
3
|
import actionHandlers from "./handlers/index.js";
|
|
4
4
|
import { createMcpResponse, createMcpErrorResponse } from "../../utils/sharedSchemas.js";
|
|
5
|
-
export { AssortmentManagementSchema
|
|
5
|
+
export { AssortmentManagementSchema };
|
|
6
6
|
export async function assortmentManagement(context, params) {
|
|
7
7
|
const { action, ...actionParams } = params;
|
|
8
8
|
log('MCP assortmentManagement', { userId: context.userId, params });
|
|
@@ -3,7 +3,7 @@ import { getNormalizedAssortmentDetails } from "../../../utils/getNormalizedAsso
|
|
|
3
3
|
export default async function getAssortment(context, params) {
|
|
4
4
|
const { modules } = context;
|
|
5
5
|
const { assortmentId, slug } = params;
|
|
6
|
-
let query
|
|
6
|
+
let query;
|
|
7
7
|
if (assortmentId)
|
|
8
8
|
query = { assortmentId };
|
|
9
9
|
else if (slug)
|