@unchainedshop/api 4.7.2 → 4.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/acl.js +1 -29
- package/lib/api-index.d.ts +0 -1
- package/lib/chat/generateImageHandler.js +5 -6
- package/lib/context.d.ts +0 -1
- package/lib/context.js +3 -8
- package/lib/events.d.ts +0 -2
- package/lib/events.js +0 -2
- package/lib/express/createMCPMiddleware.js +1 -1
- package/lib/express/index.d.ts +9 -6
- package/lib/express/index.js +125 -52
- package/lib/fastify/index.d.ts +9 -6
- package/lib/fastify/index.js +113 -51
- 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/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 +47 -144
- package/lib/mcp/tools/localization/schemas.js +36 -51
- package/lib/mcp/tools/order/handlers/getTopCustomers.d.ts +0 -2
- 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/handlers/getQuotation.d.ts +0 -2
- package/lib/mcp/tools/quotation/handlers/listQuotations.d.ts +0 -2
- package/lib/mcp/tools/quotation/handlers/makeQuotationProposal.d.ts +0 -2
- package/lib/mcp/tools/quotation/handlers/rejectQuotation.d.ts +0 -2
- package/lib/mcp/tools/quotation/handlers/verifyQuotation.d.ts +0 -2
- 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/handlers/countEvents.d.ts +1 -8
- package/lib/mcp/tools/system/handlers/countWork.d.ts +1 -10
- package/lib/mcp/tools/system/handlers/countWork.js +0 -1
- package/lib/mcp/tools/system/handlers/index.d.ts +4 -4
- package/lib/mcp/tools/system/handlers/listEvents.d.ts +1 -12
- package/lib/mcp/tools/system/handlers/listWork.d.ts +1 -14
- package/lib/mcp/tools/system/handlers/listWork.js +0 -1
- 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/handlers/addUserEmail.d.ts +0 -2
- package/lib/mcp/tools/users/handlers/createUser.d.ts +0 -2
- package/lib/mcp/tools/users/handlers/enrollUser.d.ts +0 -2
- package/lib/mcp/tools/users/handlers/getCurrentUser.d.ts +0 -2
- package/lib/mcp/tools/users/handlers/getUser.d.ts +0 -2
- package/lib/mcp/tools/users/handlers/listUsers.d.ts +0 -2
- package/lib/mcp/tools/users/handlers/setUserTags.d.ts +0 -2
- package/lib/mcp/tools/users/handlers/setUserUsername.d.ts +0 -2
- package/lib/mcp/tools/users/handlers/updateUser.d.ts +0 -2
- 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/getNormalizedQuotationDetails.d.ts +0 -2
- package/lib/mcp/utils/getNormalizedUserDetails.d.ts +0 -2
- package/lib/mcp/utils/normalizeMediaUrl.js +1 -1
- package/lib/mcp/utils/sanitizeLocalizationEntityData.d.ts +1 -1
- package/lib/mcp/utils/sharedSchemas.d.ts +39 -28
- package/lib/mcp/utils/sharedSchemas.js +47 -28
- package/lib/mcp/utils/validateIsoCode.d.ts +1 -1
- package/lib/resolvers/mutations/accounts/changePassword.js +1 -4
- package/lib/resolvers/mutations/index.d.ts +6 -1
- package/lib/resolvers/mutations/index.js +12 -2
- package/lib/resolvers/mutations/orders/updateCart.js +1 -7
- package/lib/resolvers/queries/orders/orders.js +2 -2
- package/lib/resolvers/type/index.d.ts +1 -0
- package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +1 -0
- package/lib/resolvers/type/order/order-delivery-pickup-types.js +7 -0
- package/lib/roles/index.js +0 -1
- package/lib/roles/loggedIn.js +0 -1
- package/lib/schema/mutation.js +44 -6
- package/lib/schema/types/index.js +2 -2
- package/lib/schema/types/order/delivery.js +2 -0
- package/package.json +17 -8
|
@@ -1,119 +1,85 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import { z } from 'zod/v4-mini';
|
|
2
2
|
import { SortDirection } from '@unchainedshop/utils';
|
|
3
|
-
export type LocalizationType = 'COUNTRY' | 'CURRENCY' | 'LANGUAGE';
|
|
4
|
-
export interface LocalizationModuleConfig {
|
|
5
|
-
module: any;
|
|
6
|
-
NotFoundError: any;
|
|
7
|
-
entityName: string;
|
|
8
|
-
idField: string;
|
|
9
|
-
existsMethod: any;
|
|
10
|
-
findMethod: any;
|
|
11
|
-
findMultipleMethod: any;
|
|
12
|
-
}
|
|
13
|
-
export interface LocalizationEntity {
|
|
14
|
-
isoCode: string;
|
|
15
|
-
contractAddress?: string;
|
|
16
|
-
decimals?: number;
|
|
17
|
-
}
|
|
18
|
-
export interface LocalizationUpdateEntity {
|
|
19
|
-
isoCode?: string;
|
|
20
|
-
contractAddress?: string;
|
|
21
|
-
decimals?: number;
|
|
22
|
-
}
|
|
23
|
-
export interface LocalizationListOptions {
|
|
24
|
-
limit?: number;
|
|
25
|
-
offset?: number;
|
|
26
|
-
includeInactive?: boolean;
|
|
27
|
-
queryString?: string;
|
|
28
|
-
sort?: {
|
|
29
|
-
key: string;
|
|
30
|
-
value: 'ASC' | 'DESC';
|
|
31
|
-
}[];
|
|
32
|
-
}
|
|
33
|
-
export interface LocalizationCountOptions {
|
|
34
|
-
includeInactive?: boolean;
|
|
35
|
-
queryString?: string;
|
|
36
|
-
}
|
|
37
3
|
export declare const sortDirectionKeys: [keyof typeof SortDirection, ...(keyof typeof SortDirection)[]];
|
|
38
|
-
export declare const LocalizationTypeEnum: z.
|
|
4
|
+
export declare const LocalizationTypeEnum: z.ZodMiniEnum<{
|
|
39
5
|
COUNTRY: "COUNTRY";
|
|
40
6
|
CURRENCY: "CURRENCY";
|
|
41
7
|
LANGUAGE: "LANGUAGE";
|
|
42
8
|
}>;
|
|
43
|
-
export declare const LocalizationEntitySchema: z.
|
|
44
|
-
isoCode: z.
|
|
45
|
-
isActive: z.
|
|
46
|
-
defaultCurrencyCode: z.
|
|
47
|
-
contractAddress: z.
|
|
48
|
-
decimals: z.
|
|
9
|
+
export declare const LocalizationEntitySchema: z.ZodMiniObject<{
|
|
10
|
+
isoCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
11
|
+
isActive: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
12
|
+
defaultCurrencyCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
13
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
14
|
+
decimals: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
|
|
49
15
|
}, z.core.$strip>;
|
|
50
16
|
export declare const actionValidators: {
|
|
51
|
-
readonly CREATE: z.
|
|
52
|
-
localizationType: z.
|
|
17
|
+
readonly CREATE: z.ZodMiniObject<{
|
|
18
|
+
localizationType: z.ZodMiniEnum<{
|
|
53
19
|
COUNTRY: "COUNTRY";
|
|
54
20
|
CURRENCY: "CURRENCY";
|
|
55
21
|
LANGUAGE: "LANGUAGE";
|
|
56
22
|
}>;
|
|
57
|
-
entity: z.
|
|
58
|
-
isActive: z.
|
|
59
|
-
defaultCurrencyCode: z.
|
|
60
|
-
contractAddress: z.
|
|
61
|
-
decimals: z.
|
|
62
|
-
isoCode: z.
|
|
23
|
+
entity: z.ZodMiniObject<{
|
|
24
|
+
isActive: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
25
|
+
defaultCurrencyCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
26
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
27
|
+
decimals: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
|
|
28
|
+
isoCode: z.ZodMiniString<string>;
|
|
63
29
|
}, z.core.$strip>;
|
|
64
30
|
}, z.core.$strip>;
|
|
65
|
-
readonly UPDATE: z.
|
|
66
|
-
localizationType: z.
|
|
31
|
+
readonly UPDATE: z.ZodMiniObject<{
|
|
32
|
+
localizationType: z.ZodMiniEnum<{
|
|
67
33
|
COUNTRY: "COUNTRY";
|
|
68
34
|
CURRENCY: "CURRENCY";
|
|
69
35
|
LANGUAGE: "LANGUAGE";
|
|
70
36
|
}>;
|
|
71
|
-
entityId: z.
|
|
72
|
-
entity: z.
|
|
73
|
-
isoCode: z.
|
|
74
|
-
isActive: z.
|
|
75
|
-
defaultCurrencyCode: z.
|
|
76
|
-
contractAddress: z.
|
|
77
|
-
decimals: z.
|
|
37
|
+
entityId: z.ZodMiniString<string>;
|
|
38
|
+
entity: z.ZodMiniObject<{
|
|
39
|
+
isoCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
40
|
+
isActive: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
41
|
+
defaultCurrencyCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
42
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
43
|
+
decimals: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
|
|
78
44
|
}, z.core.$strip>;
|
|
79
45
|
}, z.core.$strip>;
|
|
80
|
-
readonly REMOVE: z.
|
|
81
|
-
localizationType: z.
|
|
46
|
+
readonly REMOVE: z.ZodMiniObject<{
|
|
47
|
+
localizationType: z.ZodMiniEnum<{
|
|
82
48
|
COUNTRY: "COUNTRY";
|
|
83
49
|
CURRENCY: "CURRENCY";
|
|
84
50
|
LANGUAGE: "LANGUAGE";
|
|
85
51
|
}>;
|
|
86
|
-
entityId: z.
|
|
52
|
+
entityId: z.ZodMiniString<string>;
|
|
87
53
|
}, z.core.$strip>;
|
|
88
|
-
readonly GET: z.
|
|
89
|
-
localizationType: z.
|
|
54
|
+
readonly GET: z.ZodMiniObject<{
|
|
55
|
+
localizationType: z.ZodMiniEnum<{
|
|
90
56
|
COUNTRY: "COUNTRY";
|
|
91
57
|
CURRENCY: "CURRENCY";
|
|
92
58
|
LANGUAGE: "LANGUAGE";
|
|
93
59
|
}>;
|
|
94
|
-
entityId: z.
|
|
60
|
+
entityId: z.ZodMiniString<string>;
|
|
95
61
|
}, z.core.$strip>;
|
|
96
|
-
readonly LIST: z.
|
|
97
|
-
queryString: z.
|
|
98
|
-
includeInactive: z.
|
|
99
|
-
sort: z.
|
|
100
|
-
key: z.
|
|
101
|
-
value: z.
|
|
62
|
+
readonly LIST: z.ZodMiniObject<{
|
|
63
|
+
queryString: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
64
|
+
includeInactive: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
|
|
65
|
+
sort: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
66
|
+
key: z.ZodMiniString<string>;
|
|
67
|
+
value: z.ZodMiniEnum<{
|
|
102
68
|
[x: string]: string;
|
|
103
69
|
}>;
|
|
104
70
|
}, z.core.$strip>>>;
|
|
105
|
-
limit: z.
|
|
106
|
-
offset: z.
|
|
107
|
-
localizationType: z.
|
|
71
|
+
limit: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
|
|
72
|
+
offset: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
|
|
73
|
+
localizationType: z.ZodMiniEnum<{
|
|
108
74
|
COUNTRY: "COUNTRY";
|
|
109
75
|
CURRENCY: "CURRENCY";
|
|
110
76
|
LANGUAGE: "LANGUAGE";
|
|
111
77
|
}>;
|
|
112
78
|
}, z.core.$strip>;
|
|
113
|
-
readonly COUNT: z.
|
|
114
|
-
queryString: z.
|
|
115
|
-
includeInactive: z.
|
|
116
|
-
localizationType: z.
|
|
79
|
+
readonly COUNT: z.ZodMiniObject<{
|
|
80
|
+
queryString: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
81
|
+
includeInactive: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
|
|
82
|
+
localizationType: z.ZodMiniEnum<{
|
|
117
83
|
COUNTRY: "COUNTRY";
|
|
118
84
|
CURRENCY: "CURRENCY";
|
|
119
85
|
LANGUAGE: "LANGUAGE";
|
|
@@ -121,72 +87,9 @@ export declare const actionValidators: {
|
|
|
121
87
|
}, z.core.$strip>;
|
|
122
88
|
};
|
|
123
89
|
export declare const LocalizationManagementSchema: {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
key: z.ZodString;
|
|
128
|
-
value: z.ZodEnum<{
|
|
129
|
-
[x: string]: string;
|
|
130
|
-
}>;
|
|
131
|
-
}, z.core.$strip>>>;
|
|
132
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
133
|
-
offset: z.ZodOptional<z.ZodNumber>;
|
|
134
|
-
action: z.ZodEnum<{
|
|
135
|
-
GET: "GET";
|
|
136
|
-
CREATE: "CREATE";
|
|
137
|
-
UPDATE: "UPDATE";
|
|
138
|
-
REMOVE: "REMOVE";
|
|
139
|
-
LIST: "LIST";
|
|
140
|
-
COUNT: "COUNT";
|
|
141
|
-
}>;
|
|
142
|
-
localizationType: z.ZodEnum<{
|
|
143
|
-
COUNTRY: "COUNTRY";
|
|
144
|
-
CURRENCY: "CURRENCY";
|
|
145
|
-
LANGUAGE: "LANGUAGE";
|
|
146
|
-
}>;
|
|
147
|
-
entity: z.ZodOptional<z.ZodObject<{
|
|
148
|
-
isoCode: z.ZodOptional<z.ZodString>;
|
|
149
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
-
defaultCurrencyCode: z.ZodOptional<z.ZodString>;
|
|
151
|
-
contractAddress: z.ZodOptional<z.ZodString>;
|
|
152
|
-
decimals: z.ZodOptional<z.ZodNumber>;
|
|
153
|
-
}, z.core.$strip>>;
|
|
154
|
-
entityId: z.ZodOptional<z.ZodString>;
|
|
155
|
-
};
|
|
156
|
-
export declare const LocalizationManagementZodSchema: z.ZodObject<{
|
|
157
|
-
queryString: z.ZodOptional<z.ZodString>;
|
|
158
|
-
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
159
|
-
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
160
|
-
key: z.ZodString;
|
|
161
|
-
value: z.ZodEnum<{
|
|
162
|
-
[x: string]: string;
|
|
163
|
-
}>;
|
|
164
|
-
}, z.core.$strip>>>;
|
|
165
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
166
|
-
offset: z.ZodOptional<z.ZodNumber>;
|
|
167
|
-
action: z.ZodEnum<{
|
|
168
|
-
GET: "GET";
|
|
169
|
-
CREATE: "CREATE";
|
|
170
|
-
UPDATE: "UPDATE";
|
|
171
|
-
REMOVE: "REMOVE";
|
|
172
|
-
LIST: "LIST";
|
|
173
|
-
COUNT: "COUNT";
|
|
174
|
-
}>;
|
|
175
|
-
localizationType: z.ZodEnum<{
|
|
176
|
-
COUNTRY: "COUNTRY";
|
|
177
|
-
CURRENCY: "CURRENCY";
|
|
178
|
-
LANGUAGE: "LANGUAGE";
|
|
179
|
-
}>;
|
|
180
|
-
entity: z.ZodOptional<z.ZodObject<{
|
|
181
|
-
isoCode: z.ZodOptional<z.ZodString>;
|
|
182
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
183
|
-
defaultCurrencyCode: z.ZodOptional<z.ZodString>;
|
|
184
|
-
contractAddress: z.ZodOptional<z.ZodString>;
|
|
185
|
-
decimals: z.ZodOptional<z.ZodNumber>;
|
|
186
|
-
}, z.core.$strip>>;
|
|
187
|
-
entityId: z.ZodOptional<z.ZodString>;
|
|
188
|
-
}, z.core.$strip>;
|
|
189
|
-
export type LocalizationManagementParams = z.infer<typeof LocalizationManagementZodSchema>;
|
|
90
|
+
action: z.core.$ZodType<string>;
|
|
91
|
+
} & Record<string, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
92
|
+
export type { ManagementParams as LocalizationManagementParams } from '../../utils/sharedSchemas.ts';
|
|
190
93
|
export type ActionName = keyof typeof actionValidators;
|
|
191
94
|
export type Params<T extends ActionName> = z.infer<(typeof actionValidators)[T]>;
|
|
192
95
|
export type Handler<T extends ActionName> = (localizationModule: any, params: Params<T>) => Promise<unknown>;
|
|
@@ -1,83 +1,68 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import { z } from 'zod/v4-mini';
|
|
2
2
|
import { SortDirection } from '@unchainedshop/utils';
|
|
3
|
-
import { PaginationSchema, SortingSchema, SearchSchema } from "../../utils/sharedSchemas.js";
|
|
3
|
+
import { PaginationSchema, SortingSchema, SearchSchema, createManagementSchemaFromValidators, } from "../../utils/sharedSchemas.js";
|
|
4
4
|
export const sortDirectionKeys = Object.keys(SortDirection);
|
|
5
5
|
export const LocalizationTypeEnum = z
|
|
6
6
|
.enum(['COUNTRY', 'CURRENCY', 'LANGUAGE'])
|
|
7
|
-
.describe('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)');
|
|
7
|
+
.check(z.describe('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)'));
|
|
8
8
|
export const LocalizationEntitySchema = z.object({
|
|
9
9
|
isoCode: z
|
|
10
|
-
.string()
|
|
11
|
-
.
|
|
12
|
-
.optional()
|
|
13
|
-
.describe('ISO identifier: Countries need 2-letter codes (US, DE), Currencies need 3-letter codes (USD, EUR), Languages accept 2-10 characters (en, de-CH). isoCode is required for both CREATE and UPDATE operations'),
|
|
10
|
+
.optional(z.string().check(z.minLength(1)))
|
|
11
|
+
.check(z.describe('ISO identifier: Countries need 2-letter codes (US, DE), Currencies need 3-letter codes (USD, EUR), Languages accept 2-10 characters (en, de-CH). isoCode is required for both CREATE and UPDATE operations')),
|
|
14
12
|
isActive: z
|
|
15
|
-
.boolean()
|
|
16
|
-
.
|
|
17
|
-
.describe('Active status for the entity - used for all localization types (COUNTRY, CURRENCY, LANGUAGE)'),
|
|
13
|
+
.optional(z.boolean())
|
|
14
|
+
.check(z.describe('Active status for the entity - used for all localization types (COUNTRY, CURRENCY, LANGUAGE)')),
|
|
18
15
|
defaultCurrencyCode: z
|
|
19
|
-
.string()
|
|
20
|
-
.
|
|
21
|
-
.describe('Default currency code for the country - only used when localizationType is COUNTRY, ignored otherwise'),
|
|
16
|
+
.optional(z.string())
|
|
17
|
+
.check(z.describe('Default currency code for the country - only used when localizationType is COUNTRY, ignored otherwise')),
|
|
22
18
|
contractAddress: z
|
|
19
|
+
.optional(z
|
|
23
20
|
.string()
|
|
24
|
-
.regex(/^0x[a-fA-F0-9]{40}$/, 'Must be a valid 42-character blockchain address starting with 0x')
|
|
25
|
-
.
|
|
26
|
-
.describe('Blockchain contract address for tokenized currencies - only used when localizationType is CURRENCY, ignored otherwise'),
|
|
21
|
+
.check(z.regex(/^0x[a-fA-F0-9]{40}$/, 'Must be a valid 42-character blockchain address starting with 0x')))
|
|
22
|
+
.check(z.describe('Blockchain contract address for tokenized currencies - only used when localizationType is CURRENCY, ignored otherwise')),
|
|
27
23
|
decimals: z
|
|
28
|
-
.
|
|
29
|
-
.
|
|
30
|
-
.nonnegative()
|
|
31
|
-
.optional()
|
|
32
|
-
.describe('Decimal precision for currency calculations - only used when localizationType is CURRENCY (2 for traditional currencies like USD, 18 for crypto tokens), ignored otherwise'),
|
|
24
|
+
.optional(z.int().check(z.nonnegative()))
|
|
25
|
+
.check(z.describe('Decimal precision for currency calculations - only used when localizationType is CURRENCY (2 for traditional currencies like USD, 18 for crypto tokens), ignored otherwise')),
|
|
33
26
|
});
|
|
34
27
|
export const actionValidators = {
|
|
35
28
|
CREATE: z.object({
|
|
36
|
-
localizationType: LocalizationTypeEnum.describe('Type of localization system to operate on'),
|
|
37
|
-
entity:
|
|
29
|
+
localizationType: LocalizationTypeEnum.check(z.describe('Type of localization system to operate on')),
|
|
30
|
+
entity: z
|
|
31
|
+
.extend(LocalizationEntitySchema, {
|
|
38
32
|
isoCode: z
|
|
39
33
|
.string()
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
.check(z.minLength(1), z.describe('ISO identifier: Countries need 2-letter codes (US, DE), Currencies need 3-letter codes (USD, EUR), Languages accept 2-10 characters (en, de-CH)')),
|
|
35
|
+
})
|
|
36
|
+
.check(z.describe('Entity configuration data (required for CREATE)')),
|
|
43
37
|
}),
|
|
44
38
|
UPDATE: z.object({
|
|
45
|
-
localizationType: LocalizationTypeEnum.describe('Type of localization system to operate on, wj'),
|
|
46
|
-
entityId: z
|
|
47
|
-
|
|
39
|
+
localizationType: LocalizationTypeEnum.check(z.describe('Type of localization system to operate on, wj')),
|
|
40
|
+
entityId: z
|
|
41
|
+
.string()
|
|
42
|
+
.check(z.minLength(1), z.describe('Database ID of the specific entity instance')),
|
|
43
|
+
entity: LocalizationEntitySchema.check(z.describe('Entity data to update')),
|
|
48
44
|
}),
|
|
49
45
|
REMOVE: z.object({
|
|
50
|
-
localizationType: LocalizationTypeEnum.describe('Type of localization system to operate on'),
|
|
51
|
-
entityId: z
|
|
46
|
+
localizationType: LocalizationTypeEnum.check(z.describe('Type of localization system to operate on')),
|
|
47
|
+
entityId: z
|
|
48
|
+
.string()
|
|
49
|
+
.check(z.minLength(1), z.describe('Database ID of the specific entity instance')),
|
|
52
50
|
}),
|
|
53
51
|
GET: z.object({
|
|
54
|
-
localizationType: LocalizationTypeEnum.describe('Type of localization system to operate on'),
|
|
55
|
-
entityId: z
|
|
52
|
+
localizationType: LocalizationTypeEnum.check(z.describe('Type of localization system to operate on')),
|
|
53
|
+
entityId: z
|
|
54
|
+
.string()
|
|
55
|
+
.check(z.minLength(1), z.describe('Database ID of the specific entity instance')),
|
|
56
56
|
}),
|
|
57
57
|
LIST: z.object({
|
|
58
|
-
localizationType: LocalizationTypeEnum.describe('Type of localization system to operate on'),
|
|
58
|
+
localizationType: LocalizationTypeEnum.check(z.describe('Type of localization system to operate on')),
|
|
59
59
|
...PaginationSchema,
|
|
60
60
|
...SortingSchema,
|
|
61
61
|
...SearchSchema,
|
|
62
62
|
}),
|
|
63
63
|
COUNT: z.object({
|
|
64
|
-
localizationType: LocalizationTypeEnum.describe('Type of localization system to operate on'),
|
|
64
|
+
localizationType: LocalizationTypeEnum.check(z.describe('Type of localization system to operate on')),
|
|
65
65
|
...SearchSchema,
|
|
66
66
|
}),
|
|
67
67
|
};
|
|
68
|
-
export const LocalizationManagementSchema =
|
|
69
|
-
action: z
|
|
70
|
-
.enum(['CREATE', 'UPDATE', 'REMOVE', 'GET', 'LIST', 'COUNT'])
|
|
71
|
-
.describe('Localization action: CREATE (new entity), UPDATE (modify existing), REMOVE (soft delete), GET (retrieve single), LIST (find multiple with pagination), COUNT (get totals for analytics)'),
|
|
72
|
-
localizationType: LocalizationTypeEnum.describe('Type of localization system to operate on'),
|
|
73
|
-
entity: LocalizationEntitySchema.optional().describe('Entity configuration data (required for CREATE, optional for UPDATE)'),
|
|
74
|
-
entityId: z
|
|
75
|
-
.string()
|
|
76
|
-
.min(1)
|
|
77
|
-
.optional()
|
|
78
|
-
.describe('Database ID of the specific entity instance (required for UPDATE, REMOVE, GET actions)'),
|
|
79
|
-
...PaginationSchema,
|
|
80
|
-
...SortingSchema,
|
|
81
|
-
...SearchSchema,
|
|
82
|
-
};
|
|
83
|
-
export const LocalizationManagementZodSchema = z.object(LocalizationManagementSchema);
|
|
68
|
+
export const LocalizationManagementSchema = createManagementSchemaFromValidators(actionValidators);
|
|
@@ -22,8 +22,6 @@ export default function getTopCustomers(context: Context, params: Params<'TOP_CU
|
|
|
22
22
|
services: any;
|
|
23
23
|
pushSubscriptions: import("@unchainedshop/core-users").PushSubscriptionObject[];
|
|
24
24
|
username?: string | undefined;
|
|
25
|
-
tokenVersion?: number | undefined;
|
|
26
|
-
oidcLogoutAt?: Date | undefined;
|
|
27
25
|
_id: string;
|
|
28
26
|
} | null;
|
|
29
27
|
currencyCode: string | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from '../../../context.ts';
|
|
2
|
-
import { OrderManagementSchema,
|
|
3
|
-
export { OrderManagementSchema
|
|
2
|
+
import { OrderManagementSchema, type OrderManagementParams } from './schemas.ts';
|
|
3
|
+
export { OrderManagementSchema };
|
|
4
4
|
export type { OrderManagementParams };
|
|
5
5
|
export declare function orderManagement(context: Context, params: OrderManagementParams): Promise<{
|
|
6
6
|
content: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
-
import { actionValidators, OrderManagementSchema,
|
|
2
|
+
import { actionValidators, OrderManagementSchema, } from "./schemas.js";
|
|
3
3
|
import actionHandlers from "./handlers/index.js";
|
|
4
4
|
import { createMcpResponse, createMcpErrorResponse } from "../../utils/sharedSchemas.js";
|
|
5
|
-
export { OrderManagementSchema
|
|
5
|
+
export { OrderManagementSchema };
|
|
6
6
|
export async function orderManagement(context, params) {
|
|
7
7
|
const { action, ...actionParams } = params;
|
|
8
8
|
log('MCP handler orderManagement ', { userId: context.userId, params });
|