@unchainedshop/api 4.0.0-rc.5 → 4.0.0-rc.7

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.
Files changed (205) hide show
  1. package/README.md +3 -1
  2. package/lib/errors.d.ts +2 -0
  3. package/lib/errors.d.ts.map +1 -1
  4. package/lib/errors.js +2 -0
  5. package/lib/errors.js.map +1 -1
  6. package/lib/loaders/index.d.ts +5 -0
  7. package/lib/loaders/index.d.ts.map +1 -1
  8. package/lib/loaders/index.js +2 -0
  9. package/lib/loaders/index.js.map +1 -1
  10. package/lib/loaders/productProxiesLoader.d.ts +10 -0
  11. package/lib/loaders/productProxiesLoader.d.ts.map +1 -0
  12. package/lib/loaders/productProxiesLoader.js +30 -0
  13. package/lib/loaders/productProxiesLoader.js.map +1 -0
  14. package/lib/mcp/tools/assortment/addAssortmentMediaUploadHandler.d.ts.map +1 -1
  15. package/lib/mcp/tools/assortment/addAssortmentMediaUploadHandler.js +2 -1
  16. package/lib/mcp/tools/assortment/addAssortmentMediaUploadHandler.js.map +1 -1
  17. package/lib/mcp/tools/assortment/assortmentMediaHandler.d.ts +32 -0
  18. package/lib/mcp/tools/assortment/assortmentMediaHandler.d.ts.map +1 -0
  19. package/lib/mcp/tools/assortment/assortmentMediaHandler.js +48 -0
  20. package/lib/mcp/tools/assortment/assortmentMediaHandler.js.map +1 -0
  21. package/lib/mcp/tools/assortment/index.d.ts.map +1 -1
  22. package/lib/mcp/tools/assortment/index.js +3 -1
  23. package/lib/mcp/tools/assortment/index.js.map +1 -1
  24. package/lib/mcp/tools/assortment/removeAssortmentMediaHandler.d.ts.map +1 -1
  25. package/lib/mcp/tools/assortment/removeAssortmentMediaHandler.js +3 -1
  26. package/lib/mcp/tools/assortment/removeAssortmentMediaHandler.js.map +1 -1
  27. package/lib/mcp/tools/assortment/reorderAssortmentMediaHandler.js +2 -2
  28. package/lib/mcp/tools/assortment/reorderAssortmentMediaHandler.js.map +1 -1
  29. package/lib/mcp/tools/assortment/translatedAssortmentMediaTextsHandler.d.ts.map +1 -1
  30. package/lib/mcp/tools/assortment/translatedAssortmentMediaTextsHandler.js +7 -1
  31. package/lib/mcp/tools/assortment/translatedAssortmentMediaTextsHandler.js.map +1 -1
  32. package/lib/mcp/tools/assortment/updateAssortmentMediaTextsHandler.d.ts.map +1 -1
  33. package/lib/mcp/tools/assortment/updateAssortmentMediaTextsHandler.js +4 -1
  34. package/lib/mcp/tools/assortment/updateAssortmentMediaTextsHandler.js.map +1 -1
  35. package/lib/mcp/tools/product/addProductAssignmentHandler.d.ts.map +1 -1
  36. package/lib/mcp/tools/product/addProductAssignmentHandler.js +1 -1
  37. package/lib/mcp/tools/product/addProductAssignmentHandler.js.map +1 -1
  38. package/lib/mcp/tools/product/addProductBundleItemHandler.d.ts +48 -0
  39. package/lib/mcp/tools/product/addProductBundleItemHandler.d.ts.map +1 -0
  40. package/lib/mcp/tools/product/addProductBundleItemHandler.js +52 -0
  41. package/lib/mcp/tools/product/addProductBundleItemHandler.js.map +1 -0
  42. package/lib/mcp/tools/product/addProductMediaUploadHandler.d.ts.map +1 -1
  43. package/lib/mcp/tools/product/addProductMediaUploadHandler.js +3 -2
  44. package/lib/mcp/tools/product/addProductMediaUploadHandler.js.map +1 -1
  45. package/lib/mcp/tools/product/catalogPriceHandler.d.ts +28 -0
  46. package/lib/mcp/tools/product/catalogPriceHandler.d.ts.map +1 -0
  47. package/lib/mcp/tools/product/catalogPriceHandler.js +57 -0
  48. package/lib/mcp/tools/product/catalogPriceHandler.js.map +1 -0
  49. package/lib/mcp/tools/product/index.d.ts.map +1 -1
  50. package/lib/mcp/tools/product/index.js +27 -3
  51. package/lib/mcp/tools/product/index.js.map +1 -1
  52. package/lib/mcp/tools/product/productAssignmentsHandler.d.ts +24 -0
  53. package/lib/mcp/tools/product/productAssignmentsHandler.d.ts.map +1 -0
  54. package/lib/mcp/tools/product/productAssignmentsHandler.js +79 -0
  55. package/lib/mcp/tools/product/productAssignmentsHandler.js.map +1 -0
  56. package/lib/mcp/tools/product/productBundleItemsHandler.d.ts +20 -0
  57. package/lib/mcp/tools/product/productBundleItemsHandler.d.ts.map +1 -0
  58. package/lib/mcp/tools/product/productBundleItemsHandler.js +45 -0
  59. package/lib/mcp/tools/product/productBundleItemsHandler.js.map +1 -0
  60. package/lib/mcp/tools/product/productMediaHandler.d.ts +32 -0
  61. package/lib/mcp/tools/product/productMediaHandler.d.ts.map +1 -0
  62. package/lib/mcp/tools/product/productMediaHandler.js +46 -0
  63. package/lib/mcp/tools/product/productMediaHandler.js.map +1 -0
  64. package/lib/mcp/tools/product/productSiblingsHandler.d.ts +36 -0
  65. package/lib/mcp/tools/product/productSiblingsHandler.d.ts.map +1 -0
  66. package/lib/mcp/tools/product/productSiblingsHandler.js +66 -0
  67. package/lib/mcp/tools/product/productSiblingsHandler.js.map +1 -0
  68. package/lib/mcp/tools/product/productVariationsHandler.d.ts +20 -0
  69. package/lib/mcp/tools/product/productVariationsHandler.d.ts.map +1 -0
  70. package/lib/mcp/tools/product/productVariationsHandler.js +47 -0
  71. package/lib/mcp/tools/product/productVariationsHandler.js.map +1 -0
  72. package/lib/mcp/tools/product/removeProductBundleItemHandler.d.ts +24 -0
  73. package/lib/mcp/tools/product/removeProductBundleItemHandler.d.ts.map +1 -0
  74. package/lib/mcp/tools/product/removeProductBundleItemHandler.js +46 -0
  75. package/lib/mcp/tools/product/removeProductBundleItemHandler.js.map +1 -0
  76. package/lib/mcp/tools/product/removeProductMediaHandler.js +1 -1
  77. package/lib/mcp/tools/product/removeProductMediaHandler.js.map +1 -1
  78. package/lib/mcp/tools/product/reorderProductMediaHandler.js +2 -2
  79. package/lib/mcp/tools/product/reorderProductMediaHandler.js.map +1 -1
  80. package/lib/mcp/tools/product/simulatedPriceHandler.d.ts +70 -0
  81. package/lib/mcp/tools/product/simulatedPriceHandler.d.ts.map +1 -0
  82. package/lib/mcp/tools/product/simulatedPriceHandler.js +74 -0
  83. package/lib/mcp/tools/product/simulatedPriceHandler.js.map +1 -0
  84. package/lib/mcp/tools/product/simulatedPriceRangeHandler.d.ts +74 -0
  85. package/lib/mcp/tools/product/simulatedPriceRangeHandler.d.ts.map +1 -0
  86. package/lib/mcp/tools/product/simulatedPriceRangeHandler.js +103 -0
  87. package/lib/mcp/tools/product/simulatedPriceRangeHandler.js.map +1 -0
  88. package/lib/mcp/tools/product/translatedProductMediaTextsHandler.d.ts.map +1 -1
  89. package/lib/mcp/tools/product/translatedProductMediaTextsHandler.js +7 -1
  90. package/lib/mcp/tools/product/translatedProductMediaTextsHandler.js.map +1 -1
  91. package/lib/mcp/tools/product/translatedProductVariationTextsHandler.d.ts.map +1 -1
  92. package/lib/mcp/tools/product/translatedProductVariationTextsHandler.js +7 -1
  93. package/lib/mcp/tools/product/translatedProductVariationTextsHandler.js.map +1 -1
  94. package/lib/mcp/tools/product/updateProductMediaTextsHandler.js +1 -1
  95. package/lib/mcp/tools/product/updateProductMediaTextsHandler.js.map +1 -1
  96. package/lib/mcp/tools/product/updateProductPlanHandler.d.ts +47 -26
  97. package/lib/mcp/tools/product/updateProductPlanHandler.d.ts.map +1 -1
  98. package/lib/mcp/tools/product/updateProductPlanHandler.js +23 -7
  99. package/lib/mcp/tools/product/updateProductPlanHandler.js.map +1 -1
  100. package/lib/mcp/tools/product/updateProductVariationTextsHandler.d.ts +73 -0
  101. package/lib/mcp/tools/product/updateProductVariationTextsHandler.d.ts.map +1 -0
  102. package/lib/mcp/tools/product/updateProductVariationTextsHandler.js +52 -0
  103. package/lib/mcp/tools/product/updateProductVariationTextsHandler.js.map +1 -0
  104. package/lib/mcp/tools/product/variationProductsHandler.d.ts +52 -0
  105. package/lib/mcp/tools/product/variationProductsHandler.d.ts.map +1 -0
  106. package/lib/mcp/tools/product/variationProductsHandler.js +54 -0
  107. package/lib/mcp/tools/product/variationProductsHandler.js.map +1 -0
  108. package/lib/mcp/tools/shopInfoHandler.d.ts.map +1 -1
  109. package/lib/mcp/tools/shopInfoHandler.js +4 -2
  110. package/lib/mcp/tools/shopInfoHandler.js.map +1 -1
  111. package/lib/mcp/utils/getNormalizedProductDetails.d.ts +1 -1
  112. package/lib/mcp/utils/getNormalizedProductDetails.d.ts.map +1 -1
  113. package/lib/mcp/utils/getNormalizedProductDetails.js +25 -0
  114. package/lib/mcp/utils/getNormalizedProductDetails.js.map +1 -1
  115. package/lib/resolvers/mutations/filters/createFilter.d.ts.map +1 -1
  116. package/lib/resolvers/mutations/filters/createFilter.js +14 -5
  117. package/lib/resolvers/mutations/filters/createFilter.js.map +1 -1
  118. package/lib/resolvers/mutations/products/createProductBundleItem.d.ts.map +1 -1
  119. package/lib/resolvers/mutations/products/createProductBundleItem.js +7 -2
  120. package/lib/resolvers/mutations/products/createProductBundleItem.js.map +1 -1
  121. package/lib/resolvers/type/index.d.ts +9 -0
  122. package/lib/resolvers/type/index.d.ts.map +1 -1
  123. package/lib/resolvers/type/index.js +2 -0
  124. package/lib/resolvers/type/index.js.map +1 -1
  125. package/lib/resolvers/type/product/product-bundle-types.d.ts +1 -0
  126. package/lib/resolvers/type/product/product-bundle-types.d.ts.map +1 -1
  127. package/lib/resolvers/type/product/product-configurable-or-bundle-product-types.d.ts +5 -0
  128. package/lib/resolvers/type/product/product-configurable-or-bundle-product-types.d.ts.map +1 -0
  129. package/lib/resolvers/type/product/product-configurable-or-bundle-product-types.js +9 -0
  130. package/lib/resolvers/type/product/product-configurable-or-bundle-product-types.js.map +1 -0
  131. package/lib/resolvers/type/product/product-configurable-types.d.ts +1 -0
  132. package/lib/resolvers/type/product/product-configurable-types.d.ts.map +1 -1
  133. package/lib/resolvers/type/product/product-plan-types.d.ts +1 -0
  134. package/lib/resolvers/type/product/product-plan-types.d.ts.map +1 -1
  135. package/lib/resolvers/type/product/product-simple-types.d.ts +1 -0
  136. package/lib/resolvers/type/product/product-simple-types.d.ts.map +1 -1
  137. package/lib/resolvers/type/product/product-tokenized-types.d.ts +1 -0
  138. package/lib/resolvers/type/product/product-tokenized-types.d.ts.map +1 -1
  139. package/lib/resolvers/type/product/product-types.d.ts +1 -0
  140. package/lib/resolvers/type/product/product-types.d.ts.map +1 -1
  141. package/lib/resolvers/type/product/product-types.js +3 -0
  142. package/lib/resolvers/type/product/product-types.js.map +1 -1
  143. package/lib/schema/types/product/bundle-product.d.ts.map +1 -1
  144. package/lib/schema/types/product/bundle-product.js +2 -1
  145. package/lib/schema/types/product/bundle-product.js.map +1 -1
  146. package/lib/schema/types/product/configurable-product.d.ts.map +1 -1
  147. package/lib/schema/types/product/configurable-product.js +1 -0
  148. package/lib/schema/types/product/configurable-product.js.map +1 -1
  149. package/lib/schema/types/product/plan-product.d.ts.map +1 -1
  150. package/lib/schema/types/product/plan-product.js +1 -0
  151. package/lib/schema/types/product/plan-product.js.map +1 -1
  152. package/lib/schema/types/product/product.d.ts.map +1 -1
  153. package/lib/schema/types/product/product.js +3 -0
  154. package/lib/schema/types/product/product.js.map +1 -1
  155. package/lib/schema/types/product/simple-product.d.ts.map +1 -1
  156. package/lib/schema/types/product/simple-product.js +1 -0
  157. package/lib/schema/types/product/simple-product.js.map +1 -1
  158. package/lib/schema/types/product/tokenized-product.d.ts.map +1 -1
  159. package/lib/schema/types/product/tokenized-product.js +1 -0
  160. package/lib/schema/types/product/tokenized-product.js.map +1 -1
  161. package/package.json +6 -6
  162. package/src/errors.ts +10 -0
  163. package/src/loaders/index.ts +2 -0
  164. package/src/loaders/productProxiesLoader.ts +37 -0
  165. package/src/mcp/tools/assortment/addAssortmentMediaUploadHandler.ts +2 -1
  166. package/src/mcp/tools/assortment/assortmentMediaHandler.ts +57 -0
  167. package/src/mcp/tools/assortment/index.ts +9 -1
  168. package/src/mcp/tools/assortment/removeAssortmentMediaHandler.ts +3 -1
  169. package/src/mcp/tools/assortment/reorderAssortmentMediaHandler.ts +2 -2
  170. package/src/mcp/tools/assortment/translatedAssortmentMediaTextsHandler.ts +8 -1
  171. package/src/mcp/tools/assortment/updateAssortmentMediaTextsHandler.ts +4 -1
  172. package/src/mcp/tools/product/addProductAssignmentHandler.ts +3 -1
  173. package/src/mcp/tools/product/addProductBundleItemHandler.ts +64 -0
  174. package/src/mcp/tools/product/addProductMediaUploadHandler.ts +3 -2
  175. package/src/mcp/tools/product/catalogPriceHandler.ts +61 -0
  176. package/src/mcp/tools/product/index.ts +104 -3
  177. package/src/mcp/tools/product/productAssignmentsHandler.ts +86 -0
  178. package/src/mcp/tools/product/productBundleItemsHandler.ts +50 -0
  179. package/src/mcp/tools/product/productMediaHandler.ts +53 -0
  180. package/src/mcp/tools/product/productSiblingsHandler.ts +82 -0
  181. package/src/mcp/tools/product/productVariationsHandler.ts +53 -0
  182. package/src/mcp/tools/product/removeProductBundleItemHandler.ts +55 -0
  183. package/src/mcp/tools/product/removeProductMediaHandler.ts +1 -1
  184. package/src/mcp/tools/product/reorderProductMediaHandler.ts +2 -2
  185. package/src/mcp/tools/product/simulatedPriceHandler.ts +82 -0
  186. package/src/mcp/tools/product/simulatedPriceRangeHandler.ts +126 -0
  187. package/src/mcp/tools/product/translatedProductMediaTextsHandler.ts +6 -2
  188. package/src/mcp/tools/product/translatedProductVariationTextsHandler.ts +6 -1
  189. package/src/mcp/tools/product/updateProductMediaTextsHandler.ts +1 -1
  190. package/src/mcp/tools/product/updateProductPlanHandler.ts +37 -7
  191. package/src/mcp/tools/product/updateProductVariationTextsHandler.ts +65 -0
  192. package/src/mcp/tools/product/variationProductsHandler.ts +61 -0
  193. package/src/mcp/tools/shopInfoHandler.ts +4 -2
  194. package/src/mcp/utils/getNormalizedProductDetails.ts +28 -0
  195. package/src/resolvers/mutations/filters/createFilter.ts +11 -6
  196. package/src/resolvers/mutations/products/createProductBundleItem.ts +13 -3
  197. package/src/resolvers/type/index.ts +2 -0
  198. package/src/resolvers/type/product/product-configurable-or-bundle-product-types.ts +10 -0
  199. package/src/resolvers/type/product/product-types.ts +4 -0
  200. package/src/schema/types/product/bundle-product.ts +2 -1
  201. package/src/schema/types/product/configurable-product.ts +1 -0
  202. package/src/schema/types/product/plan-product.ts +1 -0
  203. package/src/schema/types/product/product.ts +3 -0
  204. package/src/schema/types/product/simple-product.ts +1 -0
  205. package/src/schema/types/product/tokenized-product.ts +1 -0
@@ -0,0 +1,36 @@
1
+ import { Context } from '../../../context.js';
2
+ import { z } from 'zod';
3
+ export declare const ProductSiblingsSchema: {
4
+ productId: z.ZodString;
5
+ assortmentId: z.ZodOptional<z.ZodString>;
6
+ limit: z.ZodDefault<z.ZodNumber>;
7
+ offset: z.ZodDefault<z.ZodNumber>;
8
+ includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
9
+ };
10
+ export declare const ProductSiblingsZodSchema: z.ZodObject<{
11
+ productId: z.ZodString;
12
+ assortmentId: z.ZodOptional<z.ZodString>;
13
+ limit: z.ZodDefault<z.ZodNumber>;
14
+ offset: z.ZodDefault<z.ZodNumber>;
15
+ includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ assortmentId?: string;
18
+ productId?: string;
19
+ includeInactive?: boolean;
20
+ limit?: number;
21
+ offset?: number;
22
+ }, {
23
+ assortmentId?: string;
24
+ productId?: string;
25
+ includeInactive?: boolean;
26
+ limit?: number;
27
+ offset?: number;
28
+ }>;
29
+ export type ProductSiblingsParams = z.infer<typeof ProductSiblingsZodSchema>;
30
+ export declare function productSiblingsHandler(context: Context, params: ProductSiblingsParams): Promise<{
31
+ content: {
32
+ type: "text";
33
+ text: string;
34
+ }[];
35
+ }>;
36
+ //# sourceMappingURL=productSiblingsHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"productSiblingsHandler.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/product/productSiblingsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,qBAAqB;;;;;;CAUjC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;EAIlC,CAAC;AAEJ,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE7E,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,qBAAqB;;;;;GAuD3F"}
@@ -0,0 +1,66 @@
1
+ import { log } from '@unchainedshop/logger';
2
+ import { z } from 'zod';
3
+ import { getNormalizedProductDetails } from '../../utils/getNormalizedProductDetails.js';
4
+ export const ProductSiblingsSchema = {
5
+ productId: z.string().describe('Product ID to get siblings of'),
6
+ assortmentId: z.string().optional().describe('Assortment ID to filter siblings (optional)'),
7
+ limit: z.number().int().min(1).max(100).default(10).describe('Number of siblings to return'),
8
+ offset: z.number().int().min(0).default(0).describe('Pagination offset'),
9
+ includeInactive: z
10
+ .boolean()
11
+ .optional()
12
+ .default(false)
13
+ .describe('Whether to include inactive sibling products'),
14
+ };
15
+ export const ProductSiblingsZodSchema = z
16
+ .object(ProductSiblingsSchema)
17
+ .describe('Retrieve sibling products of a given product, optionally filtered by assortment ID, with support for pagination and inclusion of inactive products.');
18
+ export async function productSiblingsHandler(context, params) {
19
+ const { modules, userId } = context;
20
+ const { productId, assortmentId, limit, offset, includeInactive } = params;
21
+ try {
22
+ log('handler productSiblingsHandler', { userId, params });
23
+ const assortmentIds = assortmentId
24
+ ? [assortmentId]
25
+ : await modules.assortments.products.findAssortmentIds({ productId });
26
+ if (!assortmentIds.length)
27
+ return {
28
+ content: [
29
+ {
30
+ type: 'text',
31
+ text: JSON.stringify({ products: [] }),
32
+ },
33
+ ],
34
+ };
35
+ const productIds = await modules.assortments.products.findSiblings({
36
+ productId,
37
+ assortmentIds,
38
+ });
39
+ const products = await modules.products.findProducts({
40
+ productIds,
41
+ includeDrafts: includeInactive,
42
+ limit,
43
+ offset,
44
+ });
45
+ const normalizedProducts = (await Promise.allSettled(products.map(({ _id }) => getNormalizedProductDetails(_id, context)))).flatMap((r) => (r.status === 'fulfilled' ? [r.value] : []));
46
+ return {
47
+ content: [
48
+ {
49
+ type: 'text',
50
+ text: JSON.stringify({ products: normalizedProducts }),
51
+ },
52
+ ],
53
+ };
54
+ }
55
+ catch (error) {
56
+ return {
57
+ content: [
58
+ {
59
+ type: 'text',
60
+ text: `Error retrieving product siblings: ${error.message}`,
61
+ },
62
+ ],
63
+ };
64
+ }
65
+ }
66
+ //# sourceMappingURL=productSiblingsHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"productSiblingsHandler.js","sourceRoot":"","sources":["../../../../src/mcp/tools/product/productSiblingsHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IAC/D,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;IAC3F,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IAC5F,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IACxE,eAAe,EAAE,CAAC;SACf,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,C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AAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAC/F,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE9D,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC;iBACvD;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,sCAAuC,KAAe,CAAC,OAAO,EAAE;iBACvE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { Context } from '../../../context.js';
3
+ export declare const ProductVariationsSchema: {
4
+ productId: z.ZodString;
5
+ };
6
+ export declare const ProductVariationsZodSchema: z.ZodObject<{
7
+ productId: z.ZodString;
8
+ }, "strip", z.ZodTypeAny, {
9
+ productId?: string;
10
+ }, {
11
+ productId?: string;
12
+ }>;
13
+ export type ProductVariationsParams = z.infer<typeof ProductVariationsZodSchema>;
14
+ export declare const productVariationsHandler: (context: Context, params: ProductVariationsParams) => Promise<{
15
+ content: {
16
+ type: "text";
17
+ text: string;
18
+ }[];
19
+ }>;
20
+ //# sourceMappingURL=productVariationsHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"productVariationsHandler.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/product/productVariationsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAK9C,eAAO,MAAM,uBAAuB;;CAEnC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;EAAoC,CAAC;AAC5E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEjF,eAAO,MAAM,wBAAwB,GAAU,SAAS,OAAO,EAAE,QAAQ,uBAAuB;;;;;EAuC/F,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ import { ProductNotFoundError, ProductWrongTypeError } from '../../../errors.js';
3
+ import { log } from '@unchainedshop/logger';
4
+ import { getNormalizedProductDetails } from '../../utils/getNormalizedProductDetails.js';
5
+ export const ProductVariationsSchema = {
6
+ productId: z.string().min(1).describe('ID of the CONFIGURABLE_PRODUCT to retrieve variations from'),
7
+ };
8
+ export const ProductVariationsZodSchema = z.object(ProductVariationsSchema);
9
+ export const productVariationsHandler = async (context, params) => {
10
+ const { productId } = params;
11
+ const { modules, userId } = context;
12
+ try {
13
+ log('handler productVariationsHandler', { userId, productId });
14
+ const product = await getNormalizedProductDetails(productId, context);
15
+ if (!product)
16
+ throw new ProductNotFoundError({ productId });
17
+ if (product.type !== 'CONFIGURABLE_PRODUCT') {
18
+ throw new ProductWrongTypeError({
19
+ productId,
20
+ received: product.type,
21
+ required: 'CONFIGURABLE_PRODUCT',
22
+ });
23
+ }
24
+ const variations = await modules.products.variations.findProductVariations({
25
+ productId,
26
+ });
27
+ return {
28
+ content: [
29
+ {
30
+ type: 'text',
31
+ text: JSON.stringify({ product, variations }),
32
+ },
33
+ ],
34
+ };
35
+ }
36
+ catch (error) {
37
+ return {
38
+ content: [
39
+ {
40
+ type: 'text',
41
+ text: `Error fetching variations: ${error.message}`,
42
+ },
43
+ ],
44
+ };
45
+ }
46
+ };
47
+ //# sourceMappingURL=productVariationsHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"productVariationsHandler.js","sourceRoot":"","sources":["../../../../src/mcp/tools/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S;SACV,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;iBAC9C;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,8BAA+B,KAAe,CAAC,OAAO,EAAE;iBAC/D;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { Context } from '../../../context.js';
3
+ export declare const RemoveProductBundleItemSchema: {
4
+ productId: z.ZodString;
5
+ index: z.ZodNumber;
6
+ };
7
+ export declare const RemoveProductBundleItemZodSchema: z.ZodObject<{
8
+ productId: z.ZodString;
9
+ index: z.ZodNumber;
10
+ }, "strip", z.ZodTypeAny, {
11
+ index?: number;
12
+ productId?: string;
13
+ }, {
14
+ index?: number;
15
+ productId?: string;
16
+ }>;
17
+ export type RemoveProductBundleItemParams = z.infer<typeof RemoveProductBundleItemZodSchema>;
18
+ export declare const removeProductBundleItemHandler: (context: Context, params: RemoveProductBundleItemParams) => Promise<{
19
+ content: {
20
+ type: "text";
21
+ text: string;
22
+ }[];
23
+ }>;
24
+ //# sourceMappingURL=removeProductBundleItemHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeProductBundleItemHandler.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/product/removeProductBundleItemHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAM9C,eAAO,MAAM,6BAA6B;;;CAGzC,CAAC;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;EAA0C,CAAC;AAExF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE7F,eAAO,MAAM,8BAA8B,GACzC,SAAS,OAAO,EAChB,QAAQ,6BAA6B;;;;;EAoCtC,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ import { ProductNotFoundError, ProductWrongTypeError } from '../../../errors.js';
3
+ import { log } from '@unchainedshop/logger';
4
+ import { getNormalizedProductDetails } from '../../utils/getNormalizedProductDetails.js';
5
+ import { ProductTypes } from '@unchainedshop/core-products';
6
+ export const RemoveProductBundleItemSchema = {
7
+ productId: z.string().min(1).describe('ID of the BUNDLE_PRODUCT from which the item will be removed'),
8
+ index: z.number().int().min(0).describe('0-based index of the bundle item to remove'),
9
+ };
10
+ export const RemoveProductBundleItemZodSchema = z.object(RemoveProductBundleItemSchema);
11
+ export const removeProductBundleItemHandler = async (context, params) => {
12
+ const { modules, userId } = context;
13
+ const { productId, index } = params;
14
+ log('handler removeProductBundleItemHandler', { userId, params });
15
+ try {
16
+ const product = await modules.products.findProduct({ productId });
17
+ if (!product)
18
+ throw new ProductNotFoundError({ productId });
19
+ if (product.type !== ProductTypes.BundleProduct)
20
+ throw new ProductWrongTypeError({
21
+ productId,
22
+ received: product.type,
23
+ required: ProductTypes.BundleProduct,
24
+ });
25
+ await modules.products.bundleItems.removeBundleItem(productId, index);
26
+ return {
27
+ content: [
28
+ {
29
+ type: 'text',
30
+ text: JSON.stringify({ product: await getNormalizedProductDetails(productId, context) }),
31
+ },
32
+ ],
33
+ };
34
+ }
35
+ catch (error) {
36
+ return {
37
+ content: [
38
+ {
39
+ type: 'text',
40
+ text: `Error removing bundle item: ${error.message}`,
41
+ },
42
+ ],
43
+ };
44
+ }
45
+ };
46
+ //# sourceMappingURL=removeProductBundleItemHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeProductBundleItemHandler.js","sourceRoot":"","sources":["../../../../src/mcp/tools/product/removeProductBundleIt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AC9B,SAAS;gBACT,QAAQ,EAAE,OAAO,CAAC,IAAI;gBACtB,QAAQ,EAAE,YAAY,CAAC,aAAa;aACrC,CAAC,CAAC;QAEL,MAAM,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACtE,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;iBACzF;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,+BAAgC,KAAe,CAAC,OAAO,EAAE;iBAChE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
@@ -22,7 +22,7 @@ export async function removeProductMediaHandler(context, params) {
22
22
  {
23
23
  type: 'text',
24
24
  text: JSON.stringify({
25
- media: productMedia,
25
+ success: true,
26
26
  }),
27
27
  },
28
28
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"removeProductMediaHandler.js","sourceRoot":"","sources":["../../../../src/mcp/tools/product/removeProductMediaHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,uCAAuC,CAAC;CACpF,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAI9E,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,OAAgB,EAAE,MAAgC;IAChG,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IAClC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEpC,IAAI,CAAC;QACH,GAAG,CAAC,mCAAmC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAE7D,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC;YACjE,cAAc;SACf,CAAC,CAAC;QACH,IAAI,CAAC,YAAY;YAAE,MAAM,IAAI,yBAAyB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;QAE3E,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAEpD,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,KAAK,EAAE,YAAY;qBACpB,CAAC;iBACH;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,iCAAkC,KAAe,CAAC,OAAO,EAAE;iBAClE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"removeProductMediaHandler.js","sourceRoot":"","sources":["../../../../src/mcp/tools/product/removeProductMediaHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,M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AACH,CAAC"}
@@ -15,12 +15,12 @@ export async function reorderProductMediaHandler(context, params) {
15
15
  const { modules, userId } = context;
16
16
  try {
17
17
  log('handler reorderProductMediaHandler', { userId, params });
18
- const reorderedMedia = await modules.products.media.updateManualOrder({ sortKeys: sortKeys });
18
+ const media = await modules.products.media.updateManualOrder({ sortKeys: sortKeys });
19
19
  return {
20
20
  content: [
21
21
  {
22
22
  type: 'text',
23
- text: JSON.stringify({ reorderedMedia }, null, 2),
23
+ text: JSON.stringify({ media }, null, 2),
24
24
  },
25
25
  ],
26
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"reorderProductMediaHandler.js","sourceRoot":"","sources":["../../../../src/mcp/tools/product/reorderProductMediaHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,QAAQ,EAAE,CAAC;SACR,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;QACP,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC;QACnE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;KAChE,CAAC,CACH;SACA,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,kDAAkD,CAAC;CAChE,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAIhF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,OAAgB,EAAE,MAAiC;IAClG,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEpC,IAAI,CAAC;QACH,GAAG,CAAC,oCAAoC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAE9D,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,QAAe,EAAE,CAAC,CAAC;QAErG,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;iBAClD;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,mCAAoC,KAAe,CAAC,OAAO,EAAE;iBACpE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"reorderProductMediaHandler.js","sourceRoot":"","sources":["../../../../src/mcp/tools/product/reorderProductMediaHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,QAAQ,EAAE,CAAC;SACR,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;QACP,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC;QACnE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;KAChE,CAAC,CACH;SACA,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,kDAAkD,CAAC;CAChE,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAIhF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,OAAgB,EAAE,MAAiC;IAClG,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEpC,IAAI,CAAC;QACH,GAAG,CAAC,oCAAoC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAE9D,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,QAAe,EAAE,CAAC,CAAC;QAE5F,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;iBACzC;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,mCAAoC,KAAe,CAAC,OAAO,EAAE;iBACpE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { Context } from '../../../context.js';
2
+ import { z } from 'zod';
3
+ export declare const ProductConfigurationParameterInputSchema: z.ZodObject<{
4
+ key: z.ZodString;
5
+ value: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ key?: string;
8
+ value?: string;
9
+ }, {
10
+ key?: string;
11
+ value?: string;
12
+ }>;
13
+ export declare const SimulatedPriceSchema: {
14
+ productId: z.ZodString;
15
+ quantity: z.ZodDefault<z.ZodNumber>;
16
+ currencyCode: z.ZodOptional<z.ZodString>;
17
+ useNetPrice: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
18
+ configuration: z.ZodOptional<z.ZodArray<z.ZodObject<{
19
+ key: z.ZodString;
20
+ value: z.ZodString;
21
+ }, "strip", z.ZodTypeAny, {
22
+ key?: string;
23
+ value?: string;
24
+ }, {
25
+ key?: string;
26
+ value?: string;
27
+ }>, "many">>;
28
+ };
29
+ export declare const SimulatedPriceZodSchema: z.ZodObject<{
30
+ productId: z.ZodString;
31
+ quantity: z.ZodDefault<z.ZodNumber>;
32
+ currencyCode: z.ZodOptional<z.ZodString>;
33
+ useNetPrice: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
34
+ configuration: z.ZodOptional<z.ZodArray<z.ZodObject<{
35
+ key: z.ZodString;
36
+ value: z.ZodString;
37
+ }, "strip", z.ZodTypeAny, {
38
+ key?: string;
39
+ value?: string;
40
+ }, {
41
+ key?: string;
42
+ value?: string;
43
+ }>, "many">>;
44
+ }, "strip", z.ZodTypeAny, {
45
+ productId?: string;
46
+ configuration?: {
47
+ key?: string;
48
+ value?: string;
49
+ }[];
50
+ currencyCode?: string;
51
+ quantity?: number;
52
+ useNetPrice?: boolean;
53
+ }, {
54
+ productId?: string;
55
+ configuration?: {
56
+ key?: string;
57
+ value?: string;
58
+ }[];
59
+ currencyCode?: string;
60
+ quantity?: number;
61
+ useNetPrice?: boolean;
62
+ }>;
63
+ export type SimulatedPriceParams = z.infer<typeof SimulatedPriceZodSchema>;
64
+ export declare function simulatedPriceHandler(context: Context, params: SimulatedPriceParams): Promise<{
65
+ content: {
66
+ type: "text";
67
+ text: string;
68
+ }[];
69
+ }>;
70
+ //# sourceMappingURL=simulatedPriceHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulatedPriceHandler.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/product/simulatedPriceHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,wCAAwC;;;;;;;;;EAGnD,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;CAkBhC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiC,CAAC;AAEtE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE3E,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB;;;;;GA8CzF"}
@@ -0,0 +1,74 @@
1
+ import { ProductNotFoundError } from '../../../errors.js';
2
+ import { log } from '@unchainedshop/logger';
3
+ import { z } from 'zod';
4
+ import { getNormalizedProductDetails } from '../../utils/getNormalizedProductDetails.js';
5
+ export const ProductConfigurationParameterInputSchema = z.object({
6
+ key: z.string().min(1).describe('Configuration attribute key'),
7
+ value: z.string().min(1).describe('Configuration attribute value'),
8
+ });
9
+ export const SimulatedPriceSchema = {
10
+ productId: z.string().min(1).describe('ID of the product for which to simulate pricing'),
11
+ quantity: z
12
+ .number()
13
+ .int()
14
+ .positive()
15
+ .default(1)
16
+ .describe('Quantity to simulate price for (default is 1)'),
17
+ currencyCode: z.string().optional().describe('Currency code for price simulation (e.g., "USD")'),
18
+ useNetPrice: z
19
+ .boolean()
20
+ .optional()
21
+ .default(false)
22
+ .describe('If true, returns net price; otherwise, returns gross price'),
23
+ configuration: z
24
+ .array(ProductConfigurationParameterInputSchema)
25
+ .optional()
26
+ .describe('Complete configuration vector (e.g., Color: Red, Size: M)'),
27
+ };
28
+ export const SimulatedPriceZodSchema = z.object(SimulatedPriceSchema);
29
+ export async function simulatedPriceHandler(context, params) {
30
+ const { userId, countryCode, user, services } = context;
31
+ const { productId, quantity, configuration, currencyCode: forcedCurrencyCode, useNetPrice } = params;
32
+ try {
33
+ log('handler simulatedPriceHandler', { userId, params });
34
+ const product = await getNormalizedProductDetails(productId, context);
35
+ if (!product)
36
+ throw new ProductNotFoundError({ productId });
37
+ const currencyCode = forcedCurrencyCode || context.currencyCode;
38
+ const pricingContext = {
39
+ product,
40
+ user,
41
+ countryCode,
42
+ currencyCode,
43
+ quantity,
44
+ configuration,
45
+ };
46
+ const pricing = await services.products.simulateProductPricing(pricingContext);
47
+ const unitPrice = pricing.unitPrice({ useNetPrice });
48
+ const price = {
49
+ ...unitPrice,
50
+ isNetPrice: useNetPrice,
51
+ isTaxable: pricing.taxSum() > 0,
52
+ currencyCode: pricing.currencyCode,
53
+ };
54
+ return {
55
+ content: [
56
+ {
57
+ type: 'text',
58
+ text: JSON.stringify({ product, price }),
59
+ },
60
+ ],
61
+ };
62
+ }
63
+ catch (error) {
64
+ return {
65
+ content: [
66
+ {
67
+ type: 'text',
68
+ text: `Error simulating price: ${error.message}`,
69
+ },
70
+ ],
71
+ };
72
+ }
73
+ }
74
+ //# sourceMappingURL=simulatedPriceHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulatedPriceHandler.js","sourceRoot":"","sources":["../../../../src/mcp/tools/product/simulatedPriceHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,MAAM,CAAC,MAAM,wCAAwC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/D,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IAC9D,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC;CACnE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG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IAAI;YACJ,WAAW;YACX,YAAY;YACZ,QAAQ;YACR,aAAa;SACd,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,sBAAsB,CAAC,cAAqB,CAAC,CAAC;QACtF,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;QAErD,MAAM,KAAK,GAAG;YACZ,GAAG,SAAS;YACZ,UAAU,EAAE,WAAW;YACvB,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;YAC/B,YAAY,EAAE,OAAO,CAAC,YAAY;SACnC,CAAC;QAEF,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;iBACzC;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,2BAA4B,KAAe,CAAC,OAAO,EAAE;iBAC5D;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { Context } from '../../../context.js';
2
+ import { z } from 'zod';
3
+ export declare const ProductAssignmentVectorInputSchema: z.ZodObject<{
4
+ key: z.ZodString;
5
+ value: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ key?: string;
8
+ value?: string;
9
+ }, {
10
+ key?: string;
11
+ value?: string;
12
+ }>;
13
+ export declare const SimulatedPriceRangeSchema: {
14
+ productId: z.ZodString;
15
+ quantity: z.ZodOptional<z.ZodNumber>;
16
+ vectors: z.ZodOptional<z.ZodArray<z.ZodObject<{
17
+ key: z.ZodString;
18
+ value: z.ZodString;
19
+ }, "strip", z.ZodTypeAny, {
20
+ key?: string;
21
+ value?: string;
22
+ }, {
23
+ key?: string;
24
+ value?: string;
25
+ }>, "many">>;
26
+ includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
27
+ currencyCode: z.ZodOptional<z.ZodString>;
28
+ useNetPrice: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
29
+ };
30
+ export declare const SimulatedPriceRangeZodSchema: z.ZodObject<{
31
+ productId: z.ZodString;
32
+ quantity: z.ZodOptional<z.ZodNumber>;
33
+ vectors: z.ZodOptional<z.ZodArray<z.ZodObject<{
34
+ key: z.ZodString;
35
+ value: z.ZodString;
36
+ }, "strip", z.ZodTypeAny, {
37
+ key?: string;
38
+ value?: string;
39
+ }, {
40
+ key?: string;
41
+ value?: string;
42
+ }>, "many">>;
43
+ includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
44
+ currencyCode: z.ZodOptional<z.ZodString>;
45
+ useNetPrice: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ productId?: string;
48
+ includeInactive?: boolean;
49
+ currencyCode?: string;
50
+ quantity?: number;
51
+ vectors?: {
52
+ key?: string;
53
+ value?: string;
54
+ }[];
55
+ useNetPrice?: boolean;
56
+ }, {
57
+ productId?: string;
58
+ includeInactive?: boolean;
59
+ currencyCode?: string;
60
+ quantity?: number;
61
+ vectors?: {
62
+ key?: string;
63
+ value?: string;
64
+ }[];
65
+ useNetPrice?: boolean;
66
+ }>;
67
+ export type SimulatedPriceRangeParams = z.infer<typeof SimulatedPriceRangeZodSchema>;
68
+ export declare function simulatedPriceRangeHandler(context: Context, params: SimulatedPriceRangeParams): Promise<{
69
+ content: {
70
+ type: "text";
71
+ text: string;
72
+ }[];
73
+ }>;
74
+ //# sourceMappingURL=simulatedPriceRangeHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulatedPriceRangeHandler.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/product/simulatedPriceRangeHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,kCAAkC;;;;;;;;;EAG7C,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;CA0BrC,CAAC;AAEF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAsC,CAAC;AAEhF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAErF,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,yBAAyB;;;;;GAkFnG"}
@@ -0,0 +1,103 @@
1
+ import { log } from '@unchainedshop/logger';
2
+ import { z } from 'zod';
3
+ import { ProductWrongTypeError } from '../../../errors.js';
4
+ import { getNormalizedProductDetails } from '../../utils/getNormalizedProductDetails.js';
5
+ export const ProductAssignmentVectorInputSchema = z.object({
6
+ key: z.string().min(1).describe('Variation attribute key (e.g., "Color")'),
7
+ value: z.string().min(1).describe('Variation attribute value (e.g., "Red")'),
8
+ });
9
+ export const SimulatedPriceRangeSchema = {
10
+ productId: z.string().min(1).describe('ID of the CONFIGURABLE_PRODUCT to simulate price range for'),
11
+ quantity: z
12
+ .number()
13
+ .int()
14
+ .positive()
15
+ .optional()
16
+ .describe('Desired quantity for price simulation (default is 1)'),
17
+ vectors: z
18
+ .array(ProductAssignmentVectorInputSchema)
19
+ .optional()
20
+ .describe('Optional variation key-value pairs (e.g., Color: Red) to simulate specific variant'),
21
+ includeInactive: z
22
+ .boolean()
23
+ .optional()
24
+ .default(false)
25
+ .describe('Whether to include inactive variants'),
26
+ currencyCode: z
27
+ .string()
28
+ .optional()
29
+ .describe('Currency code to simulate pricing with (e.g., "USD", "EUR")'),
30
+ useNetPrice: z
31
+ .boolean()
32
+ .optional()
33
+ .default(false)
34
+ .describe('Return net price if true, otherwise gross price'),
35
+ };
36
+ export const SimulatedPriceRangeZodSchema = z.object(SimulatedPriceRangeSchema);
37
+ export async function simulatedPriceRangeHandler(context, params) {
38
+ const { productId, quantity, vectors, includeInactive, currencyCode: forcedCurrencyCode, useNetPrice, } = params;
39
+ const { modules, userId, countryCode, services } = context;
40
+ try {
41
+ log('handler simulatedPriceRangeHandler', { userId, params });
42
+ const currencyCode = forcedCurrencyCode || context.currencyCode;
43
+ const product = await getNormalizedProductDetails(productId, context);
44
+ if (product.type !== 'CONFIGURABLE_PRODUCT') {
45
+ throw new ProductWrongTypeError({
46
+ productId,
47
+ received: product.type,
48
+ required: 'CONFIGURABLE_PRODUCT',
49
+ });
50
+ }
51
+ const products = await modules.products.proxyProducts(product, vectors, {
52
+ includeInactive,
53
+ });
54
+ const filteredPrices = (await Promise.all(products.map(async (proxyProduct) => {
55
+ const pricingContext = {
56
+ product: proxyProduct,
57
+ user: context.user,
58
+ countryCode,
59
+ currencyCode,
60
+ quantity,
61
+ };
62
+ const pricing = await services.products.simulateProductPricing(pricingContext);
63
+ if (!pricing)
64
+ return null;
65
+ const unitPrice = pricing.unitPrice({ useNetPrice });
66
+ return {
67
+ ...unitPrice,
68
+ isNetPrice: useNetPrice,
69
+ isTaxable: pricing.taxSum() > 0,
70
+ currencyCode: pricing.currencyCode,
71
+ };
72
+ }))).filter(Boolean);
73
+ if (!filteredPrices.length)
74
+ return null;
75
+ const { minPrice, maxPrice } = modules.products.prices.priceRange({
76
+ productId: product._id,
77
+ prices: filteredPrices,
78
+ });
79
+ const priceRange = {
80
+ minPrice,
81
+ maxPrice,
82
+ };
83
+ return {
84
+ content: [
85
+ {
86
+ type: 'text',
87
+ text: JSON.stringify({ product, priceRange }),
88
+ },
89
+ ],
90
+ };
91
+ }
92
+ catch (error) {
93
+ return {
94
+ content: [
95
+ {
96
+ type: 'text',
97
+ text: `Error simulating price range: ${error.message}`,
98
+ },
99
+ ],
100
+ };
101
+ }
102
+ }
103
+ //# sourceMappingURL=simulatedPriceRangeHandler.js.map