@unchainedshop/api 4.8.4 → 5.0.0-alpha.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.d.ts +2 -2
- package/lib/acl.js +36 -8
- package/lib/api-index.d.ts +3 -1
- package/lib/chat/generateImageHandler.js +6 -5
- package/lib/context.d.ts +4 -1
- package/lib/context.js +9 -3
- package/lib/events.d.ts +2 -0
- package/lib/events.js +2 -0
- package/lib/express/createMCPMiddleware.js +1 -1
- package/lib/express/index.d.ts +6 -9
- package/lib/express/index.js +52 -125
- package/lib/fastify/index.d.ts +6 -9
- package/lib/fastify/index.js +51 -117
- package/lib/fastify/mcpHandler.js +1 -1
- package/lib/loaders/buildTextMap.js +6 -3
- package/lib/locale-context.d.ts +4 -2
- package/lib/locale-context.js +2 -6
- package/lib/mcp/tools/assortment/assortmentManagement.d.ts +2 -2
- package/lib/mcp/tools/assortment/assortmentManagement.js +2 -2
- package/lib/mcp/tools/assortment/handlers/getAssortment.js +1 -1
- package/lib/mcp/tools/assortment/schemas.d.ts +322 -141
- package/lib/mcp/tools/assortment/schemas.js +179 -96
- package/lib/mcp/tools/filter/filterManagement.d.ts +2 -2
- package/lib/mcp/tools/filter/filterManagement.js +2 -2
- package/lib/mcp/tools/filter/schemas.d.ts +184 -75
- package/lib/mcp/tools/filter/schemas.js +87 -51
- package/lib/mcp/tools/localization/getLocalizationsConfig.d.ts +1 -1
- package/lib/mcp/tools/localization/localizationManagement.d.ts +2 -2
- package/lib/mcp/tools/localization/localizationManagement.js +2 -2
- package/lib/mcp/tools/localization/schemas.d.ts +144 -47
- package/lib/mcp/tools/localization/schemas.js +51 -36
- package/lib/mcp/tools/order/handlers/getTopCustomers.d.ts +2 -0
- package/lib/mcp/tools/order/orderManagement.d.ts +2 -2
- package/lib/mcp/tools/order/orderManagement.js +2 -2
- package/lib/mcp/tools/order/schemas.d.ts +184 -75
- package/lib/mcp/tools/order/schemas.js +113 -51
- package/lib/mcp/tools/product/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 +642 -317
- package/lib/mcp/tools/product/schemas.js +287 -191
- package/lib/mcp/tools/provider/providerManagement.d.ts +2 -2
- package/lib/mcp/tools/provider/providerManagement.js +2 -2
- package/lib/mcp/tools/provider/schemas.d.ts +142 -47
- package/lib/mcp/tools/provider/schemas.js +67 -32
- package/lib/mcp/tools/quotation/handlers/getQuotation.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/listQuotations.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/makeQuotationProposal.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/rejectQuotation.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/verifyQuotation.d.ts +2 -0
- package/lib/mcp/tools/quotation/quotationManagement.d.ts +2 -2
- package/lib/mcp/tools/quotation/quotationManagement.js +2 -2
- package/lib/mcp/tools/quotation/schemas.d.ts +111 -40
- package/lib/mcp/tools/quotation/schemas.js +54 -29
- package/lib/mcp/tools/system/handlers/countEvents.d.ts +8 -1
- package/lib/mcp/tools/system/handlers/countWork.d.ts +10 -1
- package/lib/mcp/tools/system/handlers/countWork.js +1 -0
- package/lib/mcp/tools/system/handlers/index.d.ts +4 -4
- package/lib/mcp/tools/system/handlers/listEvents.d.ts +12 -1
- package/lib/mcp/tools/system/handlers/listWork.d.ts +14 -1
- package/lib/mcp/tools/system/handlers/listWork.js +1 -0
- package/lib/mcp/tools/system/schemas.d.ts +179 -84
- package/lib/mcp/tools/system/schemas.js +188 -67
- package/lib/mcp/tools/system/systemManagement.d.ts +1 -1
- package/lib/mcp/tools/system/systemManagement.js +1 -1
- package/lib/mcp/tools/users/handlers/addUserEmail.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/createUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/enrollUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/getCurrentUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/getUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/listUsers.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/setUserTags.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/setUserUsername.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/updateUser.d.ts +2 -0
- package/lib/mcp/tools/users/schemas.d.ts +296 -163
- package/lib/mcp/tools/users/schemas.js +152 -71
- package/lib/mcp/tools/users/usersManagement.d.ts +2 -2
- package/lib/mcp/tools/users/usersManagement.js +2 -2
- package/lib/mcp/utils/getNormalizedQuotationDetails.d.ts +2 -0
- package/lib/mcp/utils/getNormalizedUserDetails.d.ts +2 -0
- package/lib/mcp/utils/normalizeMediaUrl.js +1 -1
- package/lib/mcp/utils/sanitizeLocalizationEntityData.d.ts +1 -1
- package/lib/mcp/utils/sharedSchemas.d.ts +28 -39
- package/lib/mcp/utils/sharedSchemas.js +28 -47
- package/lib/mcp/utils/validateIsoCode.d.ts +1 -1
- package/lib/resolvers/mutations/accounts/changePassword.js +1 -2
- package/lib/resolvers/mutations/index.d.ts +150 -155
- package/lib/resolvers/mutations/index.js +2 -12
- package/lib/resolvers/mutations/orders/updateCart.js +7 -1
- package/lib/resolvers/mutations/users/setRoles.d.ts +1 -1
- package/lib/resolvers/mutations/users/setRoles.js +8 -1
- package/lib/resolvers/queries/events/registeredEventTypes.d.ts +1 -1
- package/lib/resolvers/queries/events/registeredEventTypes.js +1 -1
- package/lib/resolvers/queries/index.d.ts +71 -71
- package/lib/resolvers/queries/index.js +1 -1
- package/lib/resolvers/type/index.d.ts +0 -1
- package/lib/resolvers/type/login-method-response-types.js +2 -1
- package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +0 -1
- package/lib/resolvers/type/order/order-delivery-pickup-types.js +0 -7
- package/lib/resolvers/type/shop-types.js +1 -1
- package/lib/resolvers/type/user-types.js +3 -3
- package/lib/roles/all.js +5 -3
- package/lib/roles/index.d.ts +4 -11
- package/lib/roles/index.js +16 -11
- package/lib/roles/loggedIn.js +2 -0
- package/lib/schema/mutation.js +6 -44
- package/lib/schema/query.js +5 -5
- package/lib/schema/types/index.js +2 -2
- package/lib/schema/types/order/delivery.js +0 -2
- package/package.json +13 -23
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { z } from 'zod
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
import { SortDirection } from '@unchainedshop/utils';
|
|
3
3
|
import { ProductType, ProductVariationType } from '@unchainedshop/core-products';
|
|
4
|
-
import { PaginationSchema, SortingSchema, SearchSchema, LocalizationTextSchema,
|
|
4
|
+
import { PaginationSchema, SortingSchema, SearchSchema, LocalizationTextSchema, } from "../../utils/sharedSchemas.js";
|
|
5
5
|
export const productTypeKeys = Object.keys(ProductType);
|
|
6
6
|
export const productVariationTypeKeys = Object.keys(ProductVariationType);
|
|
7
7
|
export const sortDirectionKeys = Object.keys(SortDirection);
|
|
@@ -14,299 +14,395 @@ export const ProductPlanConfigurationIntervalEnum = z.enum([
|
|
|
14
14
|
'YEARS',
|
|
15
15
|
]);
|
|
16
16
|
export const UpdateProductPlanInputSchema = z.object({
|
|
17
|
-
usageCalculationType: ProductPlanUsageCalculationTypeEnum.
|
|
18
|
-
billingInterval: ProductPlanConfigurationIntervalEnum.
|
|
19
|
-
billingIntervalCount: z.
|
|
20
|
-
trialInterval:
|
|
21
|
-
|
|
22
|
-
.check(z.describe('Optional trial period interval')),
|
|
23
|
-
trialIntervalCount: z
|
|
24
|
-
.optional(z.int().check(z.positive()))
|
|
25
|
-
.check(z.describe('Number of trial intervals')),
|
|
17
|
+
usageCalculationType: ProductPlanUsageCalculationTypeEnum.describe('The billing usage calculation method'),
|
|
18
|
+
billingInterval: ProductPlanConfigurationIntervalEnum.describe('The interval unit for billing cycles'),
|
|
19
|
+
billingIntervalCount: z.number().int().positive().describe('Number of billing intervals per cycle'),
|
|
20
|
+
trialInterval: ProductPlanConfigurationIntervalEnum.optional().describe('Optional trial period interval'),
|
|
21
|
+
trialIntervalCount: z.number().int().positive().optional().describe('Number of trial intervals'),
|
|
26
22
|
});
|
|
27
|
-
export const ProductTextInputSchema =
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export const ProductVariationTextInputSchema = LocalizationTextSchema.check(z.describe('Product variation localized text data'));
|
|
37
|
-
export const ProductMediaTextInputSchema = LocalizationTextSchema.check(z.describe('Product media localized text data'));
|
|
23
|
+
export const ProductTextInputSchema = LocalizationTextSchema.extend({
|
|
24
|
+
slug: z.string().optional().describe('URL slug'),
|
|
25
|
+
description: z.string().optional().describe('Markdown description'),
|
|
26
|
+
vendor: z.string().optional().describe('Vendor name'),
|
|
27
|
+
brand: z.string().optional().describe('Brand name'),
|
|
28
|
+
labels: z.array(z.string()).optional().describe('Labels or tags'),
|
|
29
|
+
}).describe('Product localized text data');
|
|
30
|
+
export const ProductVariationTextInputSchema = LocalizationTextSchema.describe('Product variation localized text data');
|
|
31
|
+
export const ProductMediaTextInputSchema = LocalizationTextSchema.describe('Product media localized text data');
|
|
38
32
|
export const ProductAssignmentVectorSchema = z.object({
|
|
39
|
-
key: z.string().
|
|
40
|
-
value: z.string().
|
|
33
|
+
key: z.string().min(1).describe('Attribute key (e.g., "Color", "Size")'),
|
|
34
|
+
value: z.string().min(1).describe('Attribute value (e.g., "Red", "M")'),
|
|
41
35
|
});
|
|
42
36
|
export const ProductSchema = z.object({
|
|
43
|
-
type: z.
|
|
44
|
-
tags: z
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
meta: z.optional(z.record(z.any(), z.any())).check(z.describe('Custom metadata as key-value pairs')),
|
|
49
|
-
plan: z
|
|
50
|
-
.optional(UpdateProductPlanInputSchema)
|
|
51
|
-
.check(z.describe('Plan configuration - ONLY for PLAN_PRODUCT')),
|
|
37
|
+
type: z.enum(productTypeKeys).optional().describe('Product type (required for CREATE)'),
|
|
38
|
+
tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Tags (lowercased strings)'),
|
|
39
|
+
sequence: z.number().int().optional().describe('Sorting sequence'),
|
|
40
|
+
meta: z.record(z.any(), z.any()).optional().describe('Custom metadata as key-value pairs'),
|
|
41
|
+
plan: UpdateProductPlanInputSchema.optional().describe('Plan configuration - ONLY for PLAN_PRODUCT'),
|
|
52
42
|
warehousing: z
|
|
53
|
-
.
|
|
54
|
-
sku: z.
|
|
55
|
-
baseUnit: z
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.check(z.describe('Warehousing details - ONLY for SIMPLE_PRODUCT')),
|
|
43
|
+
.object({
|
|
44
|
+
sku: z.string().min(1).optional().describe('Stock keeping unit'),
|
|
45
|
+
baseUnit: z.string().min(1).optional().describe('Base unit (e.g., "piece", "kg")'),
|
|
46
|
+
})
|
|
47
|
+
.optional()
|
|
48
|
+
.describe('Warehousing details - ONLY for SIMPLE_PRODUCT'),
|
|
60
49
|
supply: z
|
|
61
|
-
.
|
|
62
|
-
weightInGram: z.
|
|
63
|
-
heightInMillimeters: z
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
widthInMillimeters: z
|
|
70
|
-
.optional(z.int().check(z.positive()))
|
|
71
|
-
.check(z.describe('Width in millimeters')),
|
|
72
|
-
}))
|
|
73
|
-
.check(z.describe('Supply attributes - ONLY for SIMPLE_PRODUCT')),
|
|
50
|
+
.object({
|
|
51
|
+
weightInGram: z.number().int().positive().optional().describe('Weight in grams'),
|
|
52
|
+
heightInMillimeters: z.number().int().positive().optional().describe('Height in millimeters'),
|
|
53
|
+
lengthInMillimeters: z.number().int().positive().optional().describe('Length in millimeters'),
|
|
54
|
+
widthInMillimeters: z.number().int().positive().optional().describe('Width in millimeters'),
|
|
55
|
+
})
|
|
56
|
+
.optional()
|
|
57
|
+
.describe('Supply attributes - ONLY for SIMPLE_PRODUCT'),
|
|
74
58
|
tokenization: z
|
|
75
|
-
.
|
|
76
|
-
contractAddress: z.string().
|
|
77
|
-
contractStandard: z.string().
|
|
78
|
-
tokenId: z.string().
|
|
79
|
-
supply: z.
|
|
59
|
+
.object({
|
|
60
|
+
contractAddress: z.string().min(1).describe('Blockchain contract address'),
|
|
61
|
+
contractStandard: z.string().describe('Smart contract standard (e.g., ERC-721)'),
|
|
62
|
+
tokenId: z.string().min(1).describe('Unique token identifier'),
|
|
63
|
+
supply: z.number().int().positive().describe('Total supply of the token'),
|
|
80
64
|
ercMetadataProperties: z
|
|
81
|
-
.
|
|
82
|
-
.
|
|
83
|
-
|
|
84
|
-
|
|
65
|
+
.record(z.any(), z.any())
|
|
66
|
+
.optional()
|
|
67
|
+
.describe('Optional ERC metadata properties'),
|
|
68
|
+
})
|
|
69
|
+
.optional()
|
|
70
|
+
.describe('Tokenization details - ONLY for TOKENIZED_PRODUCT'),
|
|
85
71
|
commerce: z
|
|
86
|
-
.
|
|
72
|
+
.object({
|
|
87
73
|
pricing: z
|
|
88
74
|
.array(z.object({
|
|
89
|
-
amount: z.
|
|
75
|
+
amount: z.number().int().describe('Price amount in smallest currency unit.'),
|
|
90
76
|
maxQuantity: z
|
|
91
|
-
.
|
|
92
|
-
.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
77
|
+
.number()
|
|
78
|
+
.int()
|
|
79
|
+
.optional()
|
|
80
|
+
.describe('Optional maximum quantity for this price tier'),
|
|
81
|
+
isTaxable: z.boolean().optional().describe('Whether tax applies to this price'),
|
|
82
|
+
isNetPrice: z.boolean().optional().describe('Whether this is a net price (without tax)'),
|
|
97
83
|
currencyCode: z
|
|
98
84
|
.string()
|
|
99
|
-
.
|
|
85
|
+
.min(3)
|
|
86
|
+
.max(3)
|
|
87
|
+
.describe('ISO currency code (e.g., USD, EUR). Must match an available currency from the shop currencies resource. If it does not exist, prompt the user to add the currency. NEVER add it automatically unless explicitly specified by the user.'),
|
|
100
88
|
countryCode: z
|
|
101
89
|
.string()
|
|
102
|
-
.
|
|
90
|
+
.min(2)
|
|
91
|
+
.max(2)
|
|
92
|
+
.describe('ISO country code (e.g., US, DE). Must match an available country from the shop countries resource. If it does not exist, prompt the user to add the country. NEVER add it automatically unless explicitly specified by the user.'),
|
|
103
93
|
}))
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
|
|
94
|
+
.nonempty()
|
|
95
|
+
.describe('List of price configurations. Use only countryCode and currencyCode values from the shop resources.'),
|
|
96
|
+
})
|
|
97
|
+
.optional()
|
|
98
|
+
.describe('Commerce info - Available for ALL except CONFIGURABLE_PRODUCT. Use only registered countries and currencies from shop resources.'),
|
|
107
99
|
});
|
|
108
100
|
export const actionValidators = {
|
|
109
101
|
CREATE: z.object({
|
|
110
|
-
product:
|
|
111
|
-
.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
.check(z.describe('Product data with type required')),
|
|
115
|
-
texts: z
|
|
116
|
-
.optional(z.array(ProductTextInputSchema))
|
|
117
|
-
.check(z.describe('Localized product text entries')),
|
|
102
|
+
product: ProductSchema.extend({
|
|
103
|
+
type: z.enum(productTypeKeys).describe('Product type (required for CREATE)'),
|
|
104
|
+
}).describe('Product data with type required'),
|
|
105
|
+
texts: z.array(ProductTextInputSchema).optional().describe('Localized product text entries'),
|
|
118
106
|
}),
|
|
119
107
|
UPDATE: z.object({
|
|
120
|
-
productId: z.string().
|
|
121
|
-
product: ProductSchema.
|
|
108
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
109
|
+
product: ProductSchema.describe('Product data to update'),
|
|
122
110
|
}),
|
|
123
111
|
REMOVE: z.object({
|
|
124
112
|
productId: z
|
|
125
113
|
.string()
|
|
126
|
-
.
|
|
114
|
+
.min(1)
|
|
115
|
+
.describe('Product ID, (the product status to remove must be inactive or in DRAFT state other wise it will throw error) so if it is active please unpublish it first before removing the product'),
|
|
127
116
|
}),
|
|
128
117
|
GET: z
|
|
129
118
|
.object({
|
|
130
|
-
productId: z.
|
|
131
|
-
slug: z.
|
|
132
|
-
sku: z.
|
|
119
|
+
productId: z.string().min(1).optional().describe('Product ID'),
|
|
120
|
+
slug: z.string().optional().describe('Product slug'),
|
|
121
|
+
sku: z.string().optional().describe('Product SKU'),
|
|
133
122
|
})
|
|
134
|
-
.
|
|
123
|
+
.refine((data) => data.productId || data.slug || data.sku, {
|
|
135
124
|
message: 'Either productId, slug, or sku is required',
|
|
136
|
-
})
|
|
125
|
+
}),
|
|
137
126
|
LIST: z.object({
|
|
138
127
|
...PaginationSchema,
|
|
139
128
|
...SortingSchema,
|
|
140
129
|
...SearchSchema,
|
|
141
|
-
tags: z
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
slugs: z
|
|
145
|
-
.optional(z.array(z.string().check(z.minLength(1))))
|
|
146
|
-
.check(z.describe('Filter by product slugs')),
|
|
147
|
-
includeDrafts: z.optional(z.boolean()).check(z.describe('Include draft/unpublished products')),
|
|
130
|
+
tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Filter by tags'),
|
|
131
|
+
slugs: z.array(z.string().min(1)).optional().describe('Filter by product slugs'),
|
|
132
|
+
includeDrafts: z.boolean().optional().describe('Include draft/unpublished products'),
|
|
148
133
|
}),
|
|
149
134
|
COUNT: z.object({
|
|
150
135
|
...SearchSchema,
|
|
151
|
-
tags: z
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
slugs: z
|
|
155
|
-
.optional(z.array(z.string().check(z.minLength(1))))
|
|
156
|
-
.check(z.describe('Filter by product slugs')),
|
|
157
|
-
includeDrafts: z.optional(z.boolean()).check(z.describe('Include draft/unpublished products')),
|
|
136
|
+
tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Filter by tags'),
|
|
137
|
+
slugs: z.array(z.string().min(1)).optional().describe('Filter by product slugs'),
|
|
138
|
+
includeDrafts: z.boolean().optional().describe('Include draft/unpublished products'),
|
|
158
139
|
}),
|
|
159
140
|
UPDATE_STATUS: z.object({
|
|
160
|
-
productId: z.string().
|
|
161
|
-
statusAction: z.enum(['PUBLISH', 'UNPUBLISH']).
|
|
141
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
142
|
+
statusAction: z.enum(['PUBLISH', 'UNPUBLISH']).describe('Status action'),
|
|
162
143
|
}),
|
|
163
144
|
ADD_MEDIA: z.object({
|
|
164
|
-
productId: z.string().
|
|
165
|
-
mediaName: z.string().
|
|
166
|
-
url: z.
|
|
145
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
146
|
+
mediaName: z.string().min(1).describe('Media file name'),
|
|
147
|
+
url: z.string().url().describe('Media URL'),
|
|
167
148
|
}),
|
|
168
149
|
REMOVE_MEDIA: z.object({
|
|
169
|
-
productMediaId: z.string().
|
|
150
|
+
productMediaId: z.string().min(1).describe('Product media ID'),
|
|
170
151
|
}),
|
|
171
152
|
REORDER_MEDIA: z.object({
|
|
172
153
|
sortKeys: z
|
|
173
154
|
.array(z.object({
|
|
174
|
-
productMediaId: z.string().
|
|
175
|
-
sortKey: z.
|
|
155
|
+
productMediaId: z.string().min(1).describe('Media asset ID'),
|
|
156
|
+
sortKey: z.number().int().describe('New sort position'),
|
|
176
157
|
}))
|
|
177
|
-
.
|
|
158
|
+
.nonempty()
|
|
159
|
+
.describe('Sort keys'),
|
|
178
160
|
}),
|
|
179
161
|
GET_MEDIA: z.object({
|
|
180
|
-
productId: z.string().
|
|
181
|
-
tags: z
|
|
182
|
-
.optional(z.array(z.string().check(z.minLength(1), z.toLowerCase())))
|
|
183
|
-
.check(z.describe('Filter by tags')),
|
|
162
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
163
|
+
tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Filter by tags'),
|
|
184
164
|
...PaginationSchema,
|
|
185
165
|
}),
|
|
186
166
|
UPDATE_MEDIA_TEXTS: z.object({
|
|
187
|
-
productMediaId: z.string().
|
|
188
|
-
mediaTexts: z.array(ProductMediaTextInputSchema).
|
|
167
|
+
productMediaId: z.string().min(1).describe('Product media ID'),
|
|
168
|
+
mediaTexts: z.array(ProductMediaTextInputSchema).describe('Media texts'),
|
|
189
169
|
}),
|
|
190
170
|
CREATE_VARIATION: z.object({
|
|
191
|
-
productId: z.string().
|
|
171
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
192
172
|
variation: z
|
|
193
173
|
.object({
|
|
194
|
-
key: z
|
|
195
|
-
|
|
196
|
-
.check(z.minLength(1), z.describe('Unique variation key (e.g., "Color", "Size")')),
|
|
197
|
-
type: z.enum(productVariationTypeKeys).check(z.describe('Variation type')),
|
|
174
|
+
key: z.string().min(1).describe('Unique variation key (e.g., "Color", "Size")'),
|
|
175
|
+
type: z.enum(productVariationTypeKeys).describe('Variation type'),
|
|
198
176
|
})
|
|
199
|
-
.
|
|
200
|
-
variationTexts: z
|
|
201
|
-
.optional(z.array(ProductVariationTextInputSchema))
|
|
202
|
-
.check(z.describe('Variation texts')),
|
|
177
|
+
.describe('Variation definition'),
|
|
178
|
+
variationTexts: z.array(ProductVariationTextInputSchema).optional().describe('Variation texts'),
|
|
203
179
|
}),
|
|
204
180
|
REMOVE_VARIATION: z.object({
|
|
205
|
-
productVariationId: z.string().
|
|
181
|
+
productVariationId: z.string().min(1).describe('Product variation ID'),
|
|
206
182
|
}),
|
|
207
183
|
ADD_VARIATION_OPTION: z.object({
|
|
208
|
-
productVariationId: z.string().
|
|
209
|
-
option: z.string().
|
|
210
|
-
variationTexts: z
|
|
211
|
-
.optional(z.array(ProductVariationTextInputSchema))
|
|
212
|
-
.check(z.describe('Variation texts')),
|
|
184
|
+
productVariationId: z.string().min(1).describe('Product variation ID'),
|
|
185
|
+
option: z.string().min(1).describe('Option value'),
|
|
186
|
+
variationTexts: z.array(ProductVariationTextInputSchema).optional().describe('Variation texts'),
|
|
213
187
|
}),
|
|
214
188
|
REMOVE_VARIATION_OPTION: z.object({
|
|
215
|
-
productVariationId: z.string().
|
|
216
|
-
productVariationOptionValue: z.string().
|
|
189
|
+
productVariationId: z.string().min(1).describe('Product variation ID'),
|
|
190
|
+
productVariationOptionValue: z.string().min(1).describe('Option value'),
|
|
217
191
|
}),
|
|
218
192
|
UPDATE_VARIATION_TEXTS: z.object({
|
|
219
|
-
productVariationId: z.string().
|
|
220
|
-
variationTexts: z.array(ProductVariationTextInputSchema).
|
|
221
|
-
productVariationOptionValue: z
|
|
222
|
-
.optional(z.string().check(z.minLength(1)))
|
|
223
|
-
.check(z.describe('Option value')),
|
|
193
|
+
productVariationId: z.string().min(1).describe('Product variation ID'),
|
|
194
|
+
variationTexts: z.array(ProductVariationTextInputSchema).describe('Variation texts'),
|
|
195
|
+
productVariationOptionValue: z.string().min(1).optional().describe('Option value'),
|
|
224
196
|
}),
|
|
225
197
|
GET_VARIATION_PRODUCTS: z.object({
|
|
226
|
-
productId: z.string().
|
|
227
|
-
vectors: z.array(ProductAssignmentVectorSchema).
|
|
228
|
-
includeInactive: z.
|
|
198
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
199
|
+
vectors: z.array(ProductAssignmentVectorSchema).describe('Variation vectors'),
|
|
200
|
+
includeInactive: z.boolean().optional().default(true).describe('Include inactive products'),
|
|
229
201
|
}),
|
|
230
202
|
GET_ASSIGNMENTS: z.object({
|
|
231
|
-
productId: z.string().
|
|
232
|
-
includeInactive: z.
|
|
203
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
204
|
+
includeInactive: z.boolean().optional().describe('Include inactive assignments'),
|
|
233
205
|
}),
|
|
234
206
|
ADD_ASSIGNMENT: z.object({
|
|
235
|
-
proxyId: z.string().
|
|
236
|
-
assignProductId: z.string().
|
|
237
|
-
vectors: z.array(ProductAssignmentVectorSchema).
|
|
207
|
+
proxyId: z.string().min(1).describe('Proxy product ID'),
|
|
208
|
+
assignProductId: z.string().min(1).describe('Product to assign'),
|
|
209
|
+
vectors: z.array(ProductAssignmentVectorSchema).describe('Variation vectors'),
|
|
238
210
|
}),
|
|
239
211
|
REMOVE_ASSIGNMENT: z.object({
|
|
240
|
-
proxyId: z.string().
|
|
241
|
-
vectors: z.array(ProductAssignmentVectorSchema).
|
|
212
|
+
proxyId: z.string().min(1).describe('Proxy product ID'),
|
|
213
|
+
vectors: z.array(ProductAssignmentVectorSchema).describe('Variation vectors'),
|
|
242
214
|
}),
|
|
243
215
|
ADD_BUNDLE_ITEM: z.object({
|
|
244
|
-
bundleId: z.string().
|
|
245
|
-
bundleProductId: z.string().
|
|
246
|
-
quantity: z.
|
|
216
|
+
bundleId: z.string().min(1).describe('Bundle product ID'),
|
|
217
|
+
bundleProductId: z.string().min(1).describe('Product to add to bundle'),
|
|
218
|
+
quantity: z.number().int().positive().default(1).describe('Quantity'),
|
|
247
219
|
}),
|
|
248
220
|
REMOVE_BUNDLE_ITEM: z.object({
|
|
249
|
-
bundleId: z.string().
|
|
250
|
-
index: z.
|
|
221
|
+
bundleId: z.string().min(1).describe('Bundle product ID'),
|
|
222
|
+
index: z.number().int().min(0).describe('Bundle item index'),
|
|
251
223
|
}),
|
|
252
224
|
GET_BUNDLE_ITEMS: z.object({
|
|
253
|
-
bundleId: z.string().
|
|
225
|
+
bundleId: z.string().min(1).describe('Bundle product ID'),
|
|
254
226
|
}),
|
|
255
227
|
GET_CATALOG_PRICE: z.object({
|
|
256
|
-
productId: z.string().
|
|
257
|
-
quantity: z.
|
|
258
|
-
currencyCode: z
|
|
259
|
-
.optional(z.string().check(z.minLength(3), z.maxLength(3)))
|
|
260
|
-
.check(z.describe('ISO currency code')),
|
|
228
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
229
|
+
quantity: z.number().int().positive().optional().describe('Quantity'),
|
|
230
|
+
currencyCode: z.string().min(3).max(3).optional().describe('ISO currency code'),
|
|
261
231
|
}),
|
|
262
232
|
SIMULATE_PRICE: z.object({
|
|
263
|
-
productId: z.string().
|
|
264
|
-
vectors: z.
|
|
265
|
-
quantity: z.
|
|
266
|
-
currencyCode: z
|
|
267
|
-
|
|
268
|
-
.check(z.describe('ISO currency code')),
|
|
269
|
-
useNetPrice: z.optional(z.boolean()).check(z.describe('Whether to use net price')),
|
|
233
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
234
|
+
vectors: z.array(ProductAssignmentVectorSchema).optional().describe('Variation vectors'),
|
|
235
|
+
quantity: z.number().int().positive().optional().describe('Quantity'),
|
|
236
|
+
currencyCode: z.string().min(3).max(3).optional().describe('ISO currency code'),
|
|
237
|
+
useNetPrice: z.boolean().optional().describe('Whether to use net price'),
|
|
270
238
|
}),
|
|
271
239
|
SIMULATE_PRICE_RANGE: z.object({
|
|
272
|
-
productId: z.string().
|
|
273
|
-
vectors: z.
|
|
274
|
-
quantity: z.
|
|
275
|
-
currencyCode: z
|
|
276
|
-
|
|
277
|
-
.check(z.describe('ISO currency code')),
|
|
278
|
-
useNetPrice: z.optional(z.boolean()).check(z.describe('Whether to use net price')),
|
|
240
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
241
|
+
vectors: z.array(ProductAssignmentVectorSchema).optional().describe('Variation vectors'),
|
|
242
|
+
quantity: z.number().int().positive().optional().describe('Quantity'),
|
|
243
|
+
currencyCode: z.string().min(3).max(3).optional().describe('ISO currency code'),
|
|
244
|
+
useNetPrice: z.boolean().optional().describe('Whether to use net price'),
|
|
279
245
|
}),
|
|
280
246
|
GET_PRODUCT_TEXTS: z.object({
|
|
281
|
-
productId: z.string().
|
|
247
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
282
248
|
}),
|
|
283
249
|
GET_VARIATION_TEXTS: z.object({
|
|
284
|
-
productVariationId: z.string().
|
|
285
|
-
productVariationOptionValue: z
|
|
286
|
-
.optional(z.string().check(z.minLength(1)))
|
|
287
|
-
.check(z.describe('Option value')),
|
|
250
|
+
productVariationId: z.string().min(1).describe('Product variation ID'),
|
|
251
|
+
productVariationOptionValue: z.string().min(1).optional().describe('Option value'),
|
|
288
252
|
}),
|
|
289
253
|
GET_MEDIA_TEXTS: z.object({
|
|
290
|
-
productMediaId: z.string().
|
|
254
|
+
productMediaId: z.string().min(1).describe('Product media ID'),
|
|
291
255
|
}),
|
|
292
256
|
GET_REVIEWS: z.object({
|
|
293
|
-
productId: z.string().
|
|
257
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
294
258
|
...PaginationSchema,
|
|
295
259
|
...SortingSchema,
|
|
296
260
|
...SearchSchema,
|
|
297
261
|
}),
|
|
298
262
|
COUNT_REVIEWS: z.object({
|
|
299
|
-
productId: z.string().
|
|
263
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
300
264
|
...SearchSchema,
|
|
301
265
|
}),
|
|
302
266
|
GET_SIBLINGS: z.object({
|
|
303
|
-
productId: z.string().
|
|
304
|
-
assortmentId: z.
|
|
305
|
-
includeInactive: z.
|
|
267
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
268
|
+
assortmentId: z.string().optional().describe('Assortment ID'),
|
|
269
|
+
includeInactive: z.boolean().optional().describe('Include inactive products'),
|
|
306
270
|
}),
|
|
307
271
|
UPDATE_PRODUCT_TEXTS: z.object({
|
|
308
|
-
productId: z.string().
|
|
309
|
-
texts: z.array(ProductTextInputSchema).
|
|
272
|
+
productId: z.string().min(1).describe('Product ID'),
|
|
273
|
+
texts: z.array(ProductTextInputSchema).describe('Product texts to update'),
|
|
310
274
|
}),
|
|
311
275
|
};
|
|
312
|
-
export const ProductManagementSchema =
|
|
276
|
+
export const ProductManagementSchema = {
|
|
277
|
+
action: z
|
|
278
|
+
.enum([
|
|
279
|
+
'CREATE',
|
|
280
|
+
'UPDATE',
|
|
281
|
+
'REMOVE',
|
|
282
|
+
'GET',
|
|
283
|
+
'LIST',
|
|
284
|
+
'COUNT',
|
|
285
|
+
'UPDATE_STATUS',
|
|
286
|
+
'ADD_MEDIA',
|
|
287
|
+
'REMOVE_MEDIA',
|
|
288
|
+
'REORDER_MEDIA',
|
|
289
|
+
'GET_MEDIA',
|
|
290
|
+
'UPDATE_MEDIA_TEXTS',
|
|
291
|
+
'CREATE_VARIATION',
|
|
292
|
+
'REMOVE_VARIATION',
|
|
293
|
+
'ADD_VARIATION_OPTION',
|
|
294
|
+
'REMOVE_VARIATION_OPTION',
|
|
295
|
+
'ADD_ASSIGNMENT',
|
|
296
|
+
'REMOVE_ASSIGNMENT',
|
|
297
|
+
'GET_ASSIGNMENTS',
|
|
298
|
+
'GET_VARIATION_PRODUCTS',
|
|
299
|
+
'UPDATE_VARIATION_TEXTS',
|
|
300
|
+
'ADD_BUNDLE_ITEM',
|
|
301
|
+
'REMOVE_BUNDLE_ITEM',
|
|
302
|
+
'GET_BUNDLE_ITEMS',
|
|
303
|
+
'SIMULATE_PRICE',
|
|
304
|
+
'SIMULATE_PRICE_RANGE',
|
|
305
|
+
'GET_CATALOG_PRICE',
|
|
306
|
+
'GET_PRODUCT_TEXTS',
|
|
307
|
+
'GET_MEDIA_TEXTS',
|
|
308
|
+
'GET_VARIATION_TEXTS',
|
|
309
|
+
'GET_REVIEWS',
|
|
310
|
+
'COUNT_REVIEWS',
|
|
311
|
+
'GET_SIBLINGS',
|
|
312
|
+
'UPDATE_PRODUCT_TEXTS',
|
|
313
|
+
])
|
|
314
|
+
.describe('Product management action to perform'),
|
|
315
|
+
productId: z
|
|
316
|
+
.string()
|
|
317
|
+
.min(1)
|
|
318
|
+
.optional()
|
|
319
|
+
.describe('Product ID (required for most actions except CREATE, LIST, COUNT)'),
|
|
320
|
+
slug: z.string().optional().describe('Product slug (alternative to productId for GET action)'),
|
|
321
|
+
sku: z.string().optional().describe('Product SKU (alternative to productId for GET action)'),
|
|
322
|
+
productMediaId: z
|
|
323
|
+
.string()
|
|
324
|
+
.min(1)
|
|
325
|
+
.optional()
|
|
326
|
+
.describe('Product media ID (required for media-specific actions)'),
|
|
327
|
+
productVariationId: z
|
|
328
|
+
.string()
|
|
329
|
+
.min(1)
|
|
330
|
+
.optional()
|
|
331
|
+
.describe('Product variation ID (required for variation-specific actions)'),
|
|
332
|
+
product: ProductSchema.optional().describe('Product data object for CREATE/UPDATE actions'),
|
|
333
|
+
texts: z
|
|
334
|
+
.array(ProductTextInputSchema)
|
|
335
|
+
.optional()
|
|
336
|
+
.describe('Localized product text entries for CREATE action'),
|
|
337
|
+
statusAction: z
|
|
338
|
+
.enum(['PUBLISH', 'UNPUBLISH'])
|
|
339
|
+
.optional()
|
|
340
|
+
.describe('Status action for UPDATE_STATUS action'),
|
|
341
|
+
mediaName: z.string().min(1).optional().describe('Media file name for ADD_MEDIA action'),
|
|
342
|
+
url: z.string().url().optional().describe('Media URL for ADD_MEDIA action'),
|
|
343
|
+
sortKeys: z
|
|
344
|
+
.array(z.object({
|
|
345
|
+
productMediaId: z.string().min(1).describe('Media asset ID'),
|
|
346
|
+
sortKey: z.number().int().describe('New sort position'),
|
|
347
|
+
}))
|
|
348
|
+
.optional()
|
|
349
|
+
.describe('Sort keys for REORDER_MEDIA action'),
|
|
350
|
+
mediaTexts: z
|
|
351
|
+
.array(ProductMediaTextInputSchema)
|
|
352
|
+
.optional()
|
|
353
|
+
.describe('Media text updates for UPDATE_MEDIA_TEXTS action'),
|
|
354
|
+
tags: z.array(z.string()).optional().describe('Media tags filter for GET_MEDIA action'),
|
|
355
|
+
variation: z
|
|
356
|
+
.object({
|
|
357
|
+
key: z.string().min(1).describe('Unique variation key (e.g., "Color", "Size")'),
|
|
358
|
+
type: z.enum(productVariationTypeKeys).describe('Variation type from ProductVariationType enum'),
|
|
359
|
+
})
|
|
360
|
+
.optional()
|
|
361
|
+
.describe('Variation definition for CREATE_VARIATION action'),
|
|
362
|
+
option: z
|
|
363
|
+
.string()
|
|
364
|
+
.min(1)
|
|
365
|
+
.optional()
|
|
366
|
+
.describe('Option value for ADD_VARIATION_OPTION action (e.g., "Red", "Large")'),
|
|
367
|
+
productVariationOptionValue: z
|
|
368
|
+
.string()
|
|
369
|
+
.min(1)
|
|
370
|
+
.optional()
|
|
371
|
+
.describe('Option value for REMOVE_VARIATION_OPTION action'),
|
|
372
|
+
variationTexts: z
|
|
373
|
+
.array(ProductVariationTextInputSchema)
|
|
374
|
+
.optional()
|
|
375
|
+
.describe('Variation text updates for UPDATE_VARIATION_TEXTS action'),
|
|
376
|
+
assignProductId: z
|
|
377
|
+
.string()
|
|
378
|
+
.min(1)
|
|
379
|
+
.optional()
|
|
380
|
+
.describe('Product to assign (ADD_ASSIGNMENT/REMOVE_ASSIGNMENT actions)'),
|
|
381
|
+
proxyId: z.string().min(1).optional().describe('CONFIGURABLE_PRODUCT ID for assignments'),
|
|
382
|
+
vectors: z
|
|
383
|
+
.array(ProductAssignmentVectorSchema)
|
|
384
|
+
.optional()
|
|
385
|
+
.describe('Complete variation combination vectors'),
|
|
386
|
+
includeInactive: z.boolean().optional().describe('Include inactive variants in results'),
|
|
387
|
+
bundleId: z
|
|
388
|
+
.string()
|
|
389
|
+
.min(1)
|
|
390
|
+
.optional()
|
|
391
|
+
.describe('Bundle product ID for ADD_BUNDLE_ITEM/REMOVE_BUNDLE_ITEM actions'),
|
|
392
|
+
bundleProductId: z
|
|
393
|
+
.string()
|
|
394
|
+
.min(1)
|
|
395
|
+
.optional()
|
|
396
|
+
.describe('Product to add to bundle for ADD_BUNDLE_ITEM action'),
|
|
397
|
+
index: z.number().int().min(0).optional().describe('Bundle item index for REMOVE_BUNDLE_ITEM action'),
|
|
398
|
+
quantity: z.number().int().positive().optional().describe('Quantity for pricing calculations'),
|
|
399
|
+
currencyCode: z.string().min(3).max(3).optional().describe('ISO currency code for pricing'),
|
|
400
|
+
useNetPrice: z.boolean().optional().describe('Whether to use net price in calculations'),
|
|
401
|
+
...PaginationSchema,
|
|
402
|
+
...SortingSchema,
|
|
403
|
+
...SearchSchema,
|
|
404
|
+
includeDrafts: z.boolean().optional().describe('Include draft products in results'),
|
|
405
|
+
productIds: z.array(z.string()).optional().describe('Filter by specific product IDs'),
|
|
406
|
+
assortmentId: z.string().optional().describe('Filter by assortment ID (for GET_SIBLINGS action)'),
|
|
407
|
+
};
|
|
408
|
+
export const ProductManagementZodSchema = z.object(ProductManagementSchema);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from '../../../context.ts';
|
|
2
|
-
import { ProviderManagementSchema, type ProviderManagementParams } from './schemas.ts';
|
|
3
|
-
export { ProviderManagementSchema };
|
|
2
|
+
import { ProviderManagementSchema, ProviderManagementZodSchema, type ProviderManagementParams } from './schemas.ts';
|
|
3
|
+
export { ProviderManagementSchema, ProviderManagementZodSchema };
|
|
4
4
|
export type { ProviderManagementParams };
|
|
5
5
|
export declare function providerManagement(context: Context, params: ProviderManagementParams): Promise<{
|
|
6
6
|
content: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
-
import { actionValidators, ProviderManagementSchema, } from "./schemas.js";
|
|
2
|
+
import { actionValidators, ProviderManagementSchema, ProviderManagementZodSchema, } from "./schemas.js";
|
|
3
3
|
import actionHandlers from "./handlers/index.js";
|
|
4
4
|
import { createMcpErrorResponse, createMcpResponse } from "../../utils/sharedSchemas.js";
|
|
5
|
-
export { ProviderManagementSchema };
|
|
5
|
+
export { ProviderManagementSchema, ProviderManagementZodSchema };
|
|
6
6
|
export async function providerManagement(context, params) {
|
|
7
7
|
const { action, ...actionParams } = params;
|
|
8
8
|
log('MCP providerManagement', { userId: context.userId, params });
|