@unchainedshop/api 3.1.11 → 3.1.13
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/errors.d.ts +1 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -0
- package/lib/errors.js.map +1 -1
- package/lib/express/chatRouter.d.ts +3 -0
- package/lib/express/chatRouter.d.ts.map +1 -0
- package/lib/express/chatRouter.js +86 -0
- package/lib/express/chatRouter.js.map +1 -0
- package/lib/express/createApolloMiddleware.d.ts +4 -0
- package/lib/express/createApolloMiddleware.d.ts.map +1 -0
- package/lib/express/createApolloMiddleware.js +36 -0
- package/lib/express/createApolloMiddleware.js.map +1 -0
- package/lib/express/createMCPMiddleware.d.ts +4 -0
- package/lib/express/createMCPMiddleware.d.ts.map +1 -0
- package/lib/express/createMCPMiddleware.js +68 -0
- package/lib/express/createMCPMiddleware.js.map +1 -0
- package/lib/express/createSingleSignOnMiddleware.d.ts +5 -0
- package/lib/express/createSingleSignOnMiddleware.d.ts.map +1 -0
- package/lib/express/createSingleSignOnMiddleware.js +71 -0
- package/lib/express/createSingleSignOnMiddleware.js.map +1 -0
- package/lib/hashPassword.d.ts +2 -0
- package/lib/hashPassword.d.ts.map +1 -0
- package/lib/hashPassword.js +5 -0
- package/lib/hashPassword.js.map +1 -0
- package/lib/loaders/assortmentLinkLoader.d.ts +12 -0
- package/lib/loaders/assortmentLinkLoader.d.ts.map +1 -0
- package/lib/loaders/assortmentLinkLoader.js +23 -0
- package/lib/loaders/assortmentLinkLoader.js.map +1 -0
- package/lib/loaders/assortmentLinksLoader.d.ts +14 -0
- package/lib/loaders/assortmentLinksLoader.d.ts.map +1 -0
- package/lib/loaders/assortmentLinksLoader.js +38 -0
- package/lib/loaders/assortmentLinksLoader.js.map +1 -0
- package/lib/loaders/assortmentLoader.d.ts +10 -0
- package/lib/loaders/assortmentLoader.d.ts.map +1 -0
- package/lib/loaders/assortmentLoader.js +15 -0
- package/lib/loaders/assortmentLoader.js.map +1 -0
- package/lib/loaders/assortmentMediaTextLoader.d.ts +12 -0
- package/lib/loaders/assortmentMediaTextLoader.d.ts.map +1 -0
- package/lib/loaders/assortmentMediaTextLoader.js +15 -0
- package/lib/loaders/assortmentMediaTextLoader.js.map +1 -0
- package/lib/loaders/assortmentMediasLoader.d.ts +10 -0
- package/lib/loaders/assortmentMediasLoader.d.ts.map +1 -0
- package/lib/loaders/assortmentMediasLoader.js +18 -0
- package/lib/loaders/assortmentMediasLoader.js.map +1 -0
- package/lib/loaders/assortmentProductLoader.d.ts +12 -0
- package/lib/loaders/assortmentProductLoader.d.ts.map +1 -0
- package/lib/loaders/assortmentProductLoader.js +14 -0
- package/lib/loaders/assortmentProductLoader.js.map +1 -0
- package/lib/loaders/assortmentProductsLoader.d.ts +10 -0
- package/lib/loaders/assortmentProductsLoader.d.ts.map +1 -0
- package/lib/loaders/assortmentProductsLoader.js +18 -0
- package/lib/loaders/assortmentProductsLoader.js.map +1 -0
- package/lib/loaders/assortmentTextLoader.d.ts +12 -0
- package/lib/loaders/assortmentTextLoader.d.ts.map +1 -0
- package/lib/loaders/assortmentTextLoader.js +15 -0
- package/lib/loaders/assortmentTextLoader.js.map +1 -0
- package/lib/loaders/buildLocaleMap.d.ts +6 -0
- package/lib/loaders/buildLocaleMap.d.ts.map +1 -0
- package/lib/loaders/buildLocaleMap.js +38 -0
- package/lib/loaders/buildLocaleMap.js.map +1 -0
- package/lib/loaders/buildTextMap.d.ts +1 -1
- package/lib/loaders/buildTextMap.d.ts.map +1 -1
- package/lib/loaders/buildTextMap.js +16 -6
- package/lib/loaders/buildTextMap.js.map +1 -1
- package/lib/loaders/countryLoader.d.ts +10 -0
- package/lib/loaders/countryLoader.d.ts.map +1 -0
- package/lib/loaders/countryLoader.js +14 -0
- package/lib/loaders/countryLoader.js.map +1 -0
- package/lib/loaders/currencyLoader.d.ts +10 -0
- package/lib/loaders/currencyLoader.d.ts.map +1 -0
- package/lib/loaders/currencyLoader.js +14 -0
- package/lib/loaders/currencyLoader.js.map +1 -0
- package/lib/loaders/deliveryProviderLoader.d.ts +10 -0
- package/lib/loaders/deliveryProviderLoader.d.ts.map +1 -0
- package/lib/loaders/deliveryProviderLoader.js +13 -0
- package/lib/loaders/deliveryProviderLoader.js.map +1 -0
- package/lib/loaders/fileLoader.d.ts +10 -0
- package/lib/loaders/fileLoader.d.ts.map +1 -0
- package/lib/loaders/fileLoader.js +13 -0
- package/lib/loaders/fileLoader.js.map +1 -0
- package/lib/loaders/filterLoader.d.ts +10 -0
- package/lib/loaders/filterLoader.d.ts.map +1 -0
- package/lib/loaders/filterLoader.js +14 -0
- package/lib/loaders/filterLoader.js.map +1 -0
- package/lib/loaders/filterTextLoader.d.ts +14 -0
- package/lib/loaders/filterTextLoader.d.ts.map +1 -0
- package/lib/loaders/filterTextLoader.js +15 -0
- package/lib/loaders/filterTextLoader.js.map +1 -0
- package/lib/loaders/index.d.ts.map +1 -1
- package/lib/loaders/index.js +1 -29
- package/lib/loaders/index.js.map +1 -1
- package/lib/loaders/languageLoader.d.ts +10 -0
- package/lib/loaders/languageLoader.d.ts.map +1 -0
- package/lib/loaders/languageLoader.js +14 -0
- package/lib/loaders/languageLoader.js.map +1 -0
- package/lib/loaders/orderLoader.d.ts +10 -0
- package/lib/loaders/orderLoader.d.ts.map +1 -0
- package/lib/loaders/orderLoader.js +16 -0
- package/lib/loaders/orderLoader.js.map +1 -0
- package/lib/loaders/paymentProviderLoader.d.ts +10 -0
- package/lib/loaders/paymentProviderLoader.d.ts.map +1 -0
- package/lib/loaders/paymentProviderLoader.js +13 -0
- package/lib/loaders/paymentProviderLoader.js.map +1 -0
- package/lib/loaders/productLoader.d.ts +10 -0
- package/lib/loaders/productLoader.d.ts.map +1 -0
- package/lib/loaders/productLoader.js +16 -0
- package/lib/loaders/productLoader.js.map +1 -0
- package/lib/loaders/productLoaderBySKU.d.ts +10 -0
- package/lib/loaders/productLoaderBySKU.d.ts.map +1 -0
- package/lib/loaders/productLoaderBySKU.js +16 -0
- package/lib/loaders/productLoaderBySKU.js.map +1 -0
- package/lib/loaders/productMediaTextLoader.d.ts +12 -0
- package/lib/loaders/productMediaTextLoader.d.ts.map +1 -0
- package/lib/loaders/productMediaTextLoader.js +15 -0
- package/lib/loaders/productMediaTextLoader.js.map +1 -0
- package/lib/loaders/productMediasLoader.d.ts +10 -0
- package/lib/loaders/productMediasLoader.d.ts.map +1 -0
- package/lib/loaders/productMediasLoader.js +18 -0
- package/lib/loaders/productMediasLoader.js.map +1 -0
- package/lib/loaders/productTextLoader.d.ts +12 -0
- package/lib/loaders/productTextLoader.d.ts.map +1 -0
- package/lib/loaders/productTextLoader.js +15 -0
- package/lib/loaders/productTextLoader.js.map +1 -0
- package/lib/loaders/userLoader.d.ts +10 -0
- package/lib/loaders/userLoader.d.ts.map +1 -0
- package/lib/loaders/userLoader.js +17 -0
- package/lib/loaders/userLoader.js.map +1 -0
- package/lib/loaders/utils.d.ts +7 -0
- package/lib/loaders/utils.d.ts.map +1 -0
- package/lib/loaders/utils.js +29 -0
- package/lib/loaders/utils.js.map +1 -0
- package/lib/mcp/index.d.ts +4 -0
- package/lib/mcp/index.d.ts.map +1 -0
- package/lib/mcp/index.js +12 -0
- package/lib/mcp/index.js.map +1 -0
- package/lib/mcp/tools/addProductAssignmentHandler.d.ts +52 -0
- package/lib/mcp/tools/addProductAssignmentHandler.d.ts.map +1 -0
- package/lib/mcp/tools/addProductAssignmentHandler.js +97 -0
- package/lib/mcp/tools/addProductAssignmentHandler.js.map +1 -0
- package/lib/mcp/tools/countriesHandler.d.ts +60 -0
- package/lib/mcp/tools/countriesHandler.d.ts.map +1 -0
- package/lib/mcp/tools/countriesHandler.js +48 -0
- package/lib/mcp/tools/countriesHandler.js.map +1 -0
- package/lib/mcp/tools/countryHandler.d.ts +20 -0
- package/lib/mcp/tools/countryHandler.d.ts.map +1 -0
- package/lib/mcp/tools/countryHandler.js +34 -0
- package/lib/mcp/tools/countryHandler.js.map +1 -0
- package/lib/mcp/tools/createProduct.d.ts +138 -0
- package/lib/mcp/tools/createProduct.d.ts.map +1 -0
- package/lib/mcp/tools/createProduct.js +60 -0
- package/lib/mcp/tools/createProduct.js.map +1 -0
- package/lib/mcp/tools/createProductVariationHandler.d.ts +84 -0
- package/lib/mcp/tools/createProductVariationHandler.d.ts.map +1 -0
- package/lib/mcp/tools/createProductVariationHandler.js +67 -0
- package/lib/mcp/tools/createProductVariationHandler.js.map +1 -0
- package/lib/mcp/tools/currenciesHandler.d.ts +60 -0
- package/lib/mcp/tools/currenciesHandler.d.ts.map +1 -0
- package/lib/mcp/tools/currenciesHandler.js +50 -0
- package/lib/mcp/tools/currenciesHandler.js.map +1 -0
- package/lib/mcp/tools/currencyHandler.d.ts +20 -0
- package/lib/mcp/tools/currencyHandler.d.ts.map +1 -0
- package/lib/mcp/tools/currencyHandler.js +34 -0
- package/lib/mcp/tools/currencyHandler.js.map +1 -0
- package/lib/mcp/tools/getProduct.d.ts +48 -0
- package/lib/mcp/tools/getProduct.d.ts.map +1 -0
- package/lib/mcp/tools/getProduct.js +104 -0
- package/lib/mcp/tools/getProduct.js.map +1 -0
- package/lib/mcp/tools/index.d.ts +6 -0
- package/lib/mcp/tools/index.d.ts.map +1 -0
- package/lib/mcp/tools/index.js +6 -0
- package/lib/mcp/tools/index.js.map +1 -0
- package/lib/mcp/tools/languageHandler.d.ts +20 -0
- package/lib/mcp/tools/languageHandler.d.ts.map +1 -0
- package/lib/mcp/tools/languageHandler.js +31 -0
- package/lib/mcp/tools/languageHandler.js.map +1 -0
- package/lib/mcp/tools/languagesHandler.d.ts +60 -0
- package/lib/mcp/tools/languagesHandler.d.ts.map +1 -0
- package/lib/mcp/tools/languagesHandler.js +42 -0
- package/lib/mcp/tools/languagesHandler.js.map +1 -0
- package/lib/mcp/tools/listProducts.d.ts +112 -0
- package/lib/mcp/tools/listProducts.d.ts.map +1 -0
- package/lib/mcp/tools/listProducts.js +98 -0
- package/lib/mcp/tools/listProducts.js.map +1 -0
- package/lib/mcp/tools/normalizeMediaUrl.d.ts +3 -0
- package/lib/mcp/tools/normalizeMediaUrl.d.ts.map +1 -0
- package/lib/mcp/tools/normalizeMediaUrl.js +21 -0
- package/lib/mcp/tools/normalizeMediaUrl.js.map +1 -0
- package/lib/mcp/tools/productsCountHandler.d.ts +32 -0
- package/lib/mcp/tools/productsCountHandler.d.ts.map +1 -0
- package/lib/mcp/tools/productsCountHandler.js +33 -0
- package/lib/mcp/tools/productsCountHandler.js.map +1 -0
- package/lib/mcp/tools/publishProduct.d.ts +20 -0
- package/lib/mcp/tools/publishProduct.d.ts.map +1 -0
- package/lib/mcp/tools/publishProduct.js +40 -0
- package/lib/mcp/tools/publishProduct.js.map +1 -0
- package/lib/mcp/tools/removeProduct.d.ts +20 -0
- package/lib/mcp/tools/removeProduct.d.ts.map +1 -0
- package/lib/mcp/tools/removeProduct.js +34 -0
- package/lib/mcp/tools/removeProduct.js.map +1 -0
- package/lib/mcp/tools/removeProductVariationHandler.d.ts +20 -0
- package/lib/mcp/tools/removeProductVariationHandler.d.ts.map +1 -0
- package/lib/mcp/tools/removeProductVariationHandler.js +43 -0
- package/lib/mcp/tools/removeProductVariationHandler.js.map +1 -0
- package/lib/mcp/tools/unPublishProduct.d.ts +20 -0
- package/lib/mcp/tools/unPublishProduct.d.ts.map +1 -0
- package/lib/mcp/tools/unPublishProduct.js +40 -0
- package/lib/mcp/tools/unPublishProduct.js.map +1 -0
- package/lib/mcp/tools/updateProduct.d.ts +56 -0
- package/lib/mcp/tools/updateProduct.d.ts.map +1 -0
- package/lib/mcp/tools/updateProduct.js +44 -0
- package/lib/mcp/tools/updateProduct.js.map +1 -0
- package/lib/mcp/tools/updateProductCommerceHandler.d.ts +166 -0
- package/lib/mcp/tools/updateProductCommerceHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductCommerceHandler.js +64 -0
- package/lib/mcp/tools/updateProductCommerceHandler.js.map +1 -0
- package/lib/mcp/tools/updateProductPlanHandler.d.ts +72 -0
- package/lib/mcp/tools/updateProductPlanHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductPlanHandler.js +51 -0
- package/lib/mcp/tools/updateProductPlanHandler.js.map +1 -0
- package/lib/mcp/tools/updateProductSupplyHandler.d.ts +64 -0
- package/lib/mcp/tools/updateProductSupplyHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductSupplyHandler.js +52 -0
- package/lib/mcp/tools/updateProductSupplyHandler.js.map +1 -0
- package/lib/mcp/tools/updateProductTextsHandler.d.ts +114 -0
- package/lib/mcp/tools/updateProductTextsHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductTextsHandler.js +50 -0
- package/lib/mcp/tools/updateProductTextsHandler.js.map +1 -0
- package/lib/mcp/tools/updateProductTokenizationHandler.d.ts +72 -0
- package/lib/mcp/tools/updateProductTokenizationHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductTokenizationHandler.js +49 -0
- package/lib/mcp/tools/updateProductTokenizationHandler.js.map +1 -0
- package/lib/mcp/tools/updateProductWarehousingHandler.d.ts +48 -0
- package/lib/mcp/tools/updateProductWarehousingHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductWarehousingHandler.js +45 -0
- package/lib/mcp/tools/updateProductWarehousingHandler.js.map +1 -0
- package/lib/mcp/utils/getNormalizedProductDetails.d.ts +26 -0
- package/lib/mcp/utils/getNormalizedProductDetails.d.ts.map +1 -0
- package/lib/mcp/utils/getNormalizedProductDetails.js +36 -0
- package/lib/mcp/utils/getNormalizedProductDetails.js.map +1 -0
- package/lib/mcp/utils/normalizeMediaUrl.d.ts +3 -0
- package/lib/mcp/utils/normalizeMediaUrl.d.ts.map +1 -0
- package/lib/mcp/utils/normalizeMediaUrl.js +21 -0
- package/lib/mcp/utils/normalizeMediaUrl.js.map +1 -0
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.d.ts +3 -0
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.js +6 -0
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.js.map +1 -0
- package/lib/resolvers/mutations/accounts/disableTOTP.d.ts +6 -0
- package/lib/resolvers/mutations/accounts/disableTOTP.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/disableTOTP.js +27 -0
- package/lib/resolvers/mutations/accounts/disableTOTP.js.map +1 -0
- package/lib/resolvers/mutations/accounts/enableTOTP.d.ts +6 -0
- package/lib/resolvers/mutations/accounts/enableTOTP.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/enableTOTP.js +20 -0
- package/lib/resolvers/mutations/accounts/enableTOTP.js.map +1 -0
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.d.ts +7 -0
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.js +30 -0
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.js.map +1 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.d.ts +8 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.js +25 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.js.map +1 -0
- package/lib/resolvers/mutations/accounts/logoutAllSessions.d.ts +5 -0
- package/lib/resolvers/mutations/accounts/logoutAllSessions.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/logoutAllSessions.js +20 -0
- package/lib/resolvers/mutations/accounts/logoutAllSessions.js.map +1 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.d.ts +6 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.js +13 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.js.map +1 -0
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.d.ts +6 -0
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.d.ts.map +1 -0
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.js +18 -0
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.js.map +1 -0
- package/lib/resolvers/mutations/products/addProductAssignment.d.ts.map +1 -1
- package/lib/resolvers/mutations/products/addProductAssignment.js +3 -1
- package/lib/resolvers/mutations/products/addProductAssignment.js.map +1 -1
- package/lib/resolvers/mutations/products/addProductMedia.d.ts +6 -0
- package/lib/resolvers/mutations/products/addProductMedia.d.ts.map +1 -0
- package/lib/resolvers/mutations/products/addProductMedia.js +18 -0
- package/lib/resolvers/mutations/products/addProductMedia.js.map +1 -0
- package/lib/resolvers/mutations/users/updateUserAvatar.d.ts +6 -0
- package/lib/resolvers/mutations/users/updateUserAvatar.d.ts.map +1 -0
- package/lib/resolvers/mutations/users/updateUserAvatar.js +22 -0
- package/lib/resolvers/mutations/users/updateUserAvatar.js.map +1 -0
- package/lib/resolvers/mutations/utils/getOrderCart.d.ts +7 -0
- package/lib/resolvers/mutations/utils/getOrderCart.d.ts.map +1 -0
- package/lib/resolvers/mutations/utils/getOrderCart.js +13 -0
- package/lib/resolvers/mutations/utils/getOrderCart.js.map +1 -0
- package/lib/resolvers/type/dispatch-types.d.ts +15 -0
- package/lib/resolvers/type/dispatch-types.d.ts.map +1 -0
- package/lib/resolvers/type/dispatch-types.js +16 -0
- package/lib/resolvers/type/dispatch-types.js.map +1 -0
- package/lib/resolvers/type/oauth-account.d.ts +6 -0
- package/lib/resolvers/type/oauth-account.d.ts.map +1 -0
- package/lib/resolvers/type/oauth-account.js +7 -0
- package/lib/resolvers/type/oauth-account.js.map +1 -0
- package/lib/resolvers/type/oauth-provider.d.ts +6 -0
- package/lib/resolvers/type/oauth-provider.d.ts.map +1 -0
- package/lib/resolvers/type/oauth-provider.js +6 -0
- package/lib/resolvers/type/oauth-provider.js.map +1 -0
- package/lib/resolvers/type/stock-types.d.ts +14 -0
- package/lib/resolvers/type/stock-types.d.ts.map +1 -0
- package/lib/resolvers/type/stock-types.js +15 -0
- package/lib/resolvers/type/stock-types.js.map +1 -0
- package/lib/user-context.d.ts +7 -0
- package/lib/user-context.d.ts.map +1 -0
- package/lib/user-context.js +76 -0
- package/lib/user-context.js.map +1 -0
- package/package.json +13 -13
- package/src/errors.ts +5 -0
- package/src/loaders/buildLocaleMap.test.ts +61 -0
- package/src/loaders/buildLocaleMap.ts +39 -0
- package/src/loaders/buildTextMap.test.ts +54 -0
- package/src/loaders/buildTextMap.ts +22 -6
- package/src/loaders/index.ts +1 -32
- package/src/resolvers/mutations/products/addProductAssignment.ts +8 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CurrencyNotFoundError } from '../../errors.js';
|
|
3
|
+
export const CurrencySchema = {
|
|
4
|
+
currencyId: z.string().min(1).describe('The ID of the currency to fetch'),
|
|
5
|
+
};
|
|
6
|
+
export const CurrencyZodSchema = z.object(CurrencySchema);
|
|
7
|
+
export async function currencyHandler(context, params) {
|
|
8
|
+
const { currencyId } = params;
|
|
9
|
+
const { modules } = context;
|
|
10
|
+
try {
|
|
11
|
+
const currency = await modules.currencies.findCurrency({ currencyId });
|
|
12
|
+
if (!currency)
|
|
13
|
+
throw new CurrencyNotFoundError({ currencyId });
|
|
14
|
+
return {
|
|
15
|
+
content: [
|
|
16
|
+
{
|
|
17
|
+
type: 'text',
|
|
18
|
+
text: JSON.stringify({ currency }),
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return {
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: 'text',
|
|
28
|
+
text: `Error retrieving currency: ${error.message}`,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=currencyHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currencyHandler.js","sourceRoot":"","sources":["../../../src/mcp/tools/currencyHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC;CAC1E,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAI1D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAgB,EAAE,MAAsB;IAC5E,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC9B,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE5B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QAEvE,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,qBAAqB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QAE/D,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;iBACnC;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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for the get_product tool (as raw object for MCP)
|
|
5
|
+
*/
|
|
6
|
+
export declare const GetProductSchema: {
|
|
7
|
+
productId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
9
|
+
sku: z.ZodOptional<z.ZodString>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Zod object schema for type inference and validation
|
|
13
|
+
*/
|
|
14
|
+
export declare const GetProductZodSchema: z.ZodEffects<z.ZodObject<{
|
|
15
|
+
productId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
17
|
+
sku: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
productId?: string;
|
|
20
|
+
slug?: string;
|
|
21
|
+
sku?: string;
|
|
22
|
+
}, {
|
|
23
|
+
productId?: string;
|
|
24
|
+
slug?: string;
|
|
25
|
+
sku?: string;
|
|
26
|
+
}>, {
|
|
27
|
+
productId?: string;
|
|
28
|
+
slug?: string;
|
|
29
|
+
sku?: string;
|
|
30
|
+
}, {
|
|
31
|
+
productId?: string;
|
|
32
|
+
slug?: string;
|
|
33
|
+
sku?: string;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Interface for the get_product tool parameters
|
|
37
|
+
*/
|
|
38
|
+
export type GetProductParams = z.infer<typeof GetProductZodSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* Implementation of the get_product tool
|
|
41
|
+
*/
|
|
42
|
+
export declare function getProductHandler(context: Context, params: GetProductParams): Promise<{
|
|
43
|
+
content: {
|
|
44
|
+
type: "text";
|
|
45
|
+
text: string;
|
|
46
|
+
}[];
|
|
47
|
+
}>;
|
|
48
|
+
//# sourceMappingURL=getProduct.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getProduct.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/getProduct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;EAK7B,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEnE;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB;;;;;GA4FjF"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for the get_product tool (as raw object for MCP)
|
|
4
|
+
*/
|
|
5
|
+
export const GetProductSchema = {
|
|
6
|
+
productId: z.string().optional().describe('Product ID for lookup'),
|
|
7
|
+
slug: z.string().optional().describe('Product slug for lookup'),
|
|
8
|
+
sku: z.string().optional().describe('Product SKU for lookup'),
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Zod object schema for type inference and validation
|
|
12
|
+
*/
|
|
13
|
+
export const GetProductZodSchema = z
|
|
14
|
+
.object(GetProductSchema)
|
|
15
|
+
.refine((data) => data.productId || data.slug || data.sku, 'At least one of productId, slug, or sku must be provided');
|
|
16
|
+
/**
|
|
17
|
+
* Implementation of the get_product tool
|
|
18
|
+
*/
|
|
19
|
+
export async function getProductHandler(context, params) {
|
|
20
|
+
const { productId, slug, sku } = params;
|
|
21
|
+
try {
|
|
22
|
+
// Find the product
|
|
23
|
+
const product = await context.modules.products.findProduct({
|
|
24
|
+
productId,
|
|
25
|
+
slug,
|
|
26
|
+
sku,
|
|
27
|
+
});
|
|
28
|
+
if (!product) {
|
|
29
|
+
return {
|
|
30
|
+
content: [
|
|
31
|
+
{
|
|
32
|
+
type: 'text',
|
|
33
|
+
text: `Product not found with ${productId ? `ID: ${productId}` : slug ? `slug: ${slug}` : `SKU: ${sku}`}`,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Get product texts for localization
|
|
39
|
+
const productTexts = await context.loaders.productTextLoader.load({
|
|
40
|
+
productId: product._id,
|
|
41
|
+
locale: context.locale,
|
|
42
|
+
});
|
|
43
|
+
// Get media
|
|
44
|
+
const media = await context.modules.products.media.findProductMedias({
|
|
45
|
+
productId: product._id,
|
|
46
|
+
});
|
|
47
|
+
// Get pricing information
|
|
48
|
+
let pricing = null;
|
|
49
|
+
try {
|
|
50
|
+
pricing = await context.modules.products.prices.price(product, {
|
|
51
|
+
countryCode: context.countryCode,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Pricing might not be available for all products
|
|
56
|
+
console.warn('Pricing not available for product:', product._id);
|
|
57
|
+
}
|
|
58
|
+
// Get variations if it's a configurable product
|
|
59
|
+
const variations = await context.modules.products.variations.findProductVariations({
|
|
60
|
+
productId: product._id,
|
|
61
|
+
});
|
|
62
|
+
// Get bundle items if it's a bundle product
|
|
63
|
+
// const bundleItems =
|
|
64
|
+
// product.type === 'BUNDLE_PRODUCT'
|
|
65
|
+
// ? await context.modules.products.bundleItems.findBundleItems({
|
|
66
|
+
// productId: product._id,
|
|
67
|
+
// })
|
|
68
|
+
// : [];
|
|
69
|
+
// Get assortment memberships
|
|
70
|
+
// const assortmentLinks = await context.modules.assortments.links.findLinks({
|
|
71
|
+
// productId: product._id,
|
|
72
|
+
// });
|
|
73
|
+
// Get reviews count
|
|
74
|
+
const reviewsCount = await context.modules.products.reviews.count({
|
|
75
|
+
productId: product._id,
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
content: [
|
|
79
|
+
{
|
|
80
|
+
type: 'text',
|
|
81
|
+
text: JSON.stringify({
|
|
82
|
+
product,
|
|
83
|
+
productTexts,
|
|
84
|
+
media,
|
|
85
|
+
pricing,
|
|
86
|
+
variations,
|
|
87
|
+
reviewsCount,
|
|
88
|
+
}),
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return {
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: 'text',
|
|
98
|
+
text: `Error getting product: ${error.message}`,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=getProduct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getProduct.js","sourceRoot":"","sources":["../../../src/mcp/tools/getProduct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IAClE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;IAC/D,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;CAC9D,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC,gBAAgB,CAAC;KACxB,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,EACjD,0DAA0D,CAC3D,CAAC;AAOJ;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAgB,EAAE,MAAwB;IAChF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QAED,gDAAgD;QAChD,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,qBAAqB,CAAC;YACjF,SAAS,EAAE,OAAO,CAAC,GAAG;SACvB,CAAC,CAAC;QAEH,4CAA4C;QAC5C,sBAAsB;QACtB,sCAAsC;QACtC,qEAAqE;QACrE,kCAAkC;QAClC,WAAW;QACX,YAAY;QAEZ,6BAA6B;QAC7B,8EAA8E;QAC9E,4BAA4B;QAC5B,MAAM;QAEN,oBAAoB;QACpB,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;YAChE,SAAS,EAAE,OAAO,CAAC,GAAG;SACvB,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,OAAO;wBACP,YAAY;wBACZ,KAAK;wBACL,OAAO;wBACP,UAAU;wBACV,YAAY;qBACb,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,0BAA2B,KAAe,CAAC,OAAO,EAAE;iBAC3D;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
export declare const LanguageSchema: {
|
|
4
|
+
languageId: z.ZodString;
|
|
5
|
+
};
|
|
6
|
+
export declare const LanguageZodSchema: z.ZodObject<{
|
|
7
|
+
languageId: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
languageId?: string;
|
|
10
|
+
}, {
|
|
11
|
+
languageId?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type LanguageParams = z.infer<typeof LanguageZodSchema>;
|
|
14
|
+
export declare function languageHandler(context: Context, params: LanguageParams): Promise<{
|
|
15
|
+
content: {
|
|
16
|
+
type: "text";
|
|
17
|
+
text: string;
|
|
18
|
+
}[];
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=languageHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languageHandler.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/languageHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,eAAO,MAAM,cAAc;;CAE1B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;EAA2B,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE/D,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc;;;;;GAyB7E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const LanguageSchema = {
|
|
3
|
+
languageId: z.string().min(1).describe('The ID of the language to fetch'),
|
|
4
|
+
};
|
|
5
|
+
export const LanguageZodSchema = z.object(LanguageSchema);
|
|
6
|
+
export async function languageHandler(context, params) {
|
|
7
|
+
const { languageId } = params;
|
|
8
|
+
const { modules } = context;
|
|
9
|
+
try {
|
|
10
|
+
const language = await modules.languages.findLanguage({ languageId });
|
|
11
|
+
return {
|
|
12
|
+
content: [
|
|
13
|
+
{
|
|
14
|
+
type: 'text',
|
|
15
|
+
text: JSON.stringify({ language }),
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: 'text',
|
|
25
|
+
text: `Error retrieving language: ${error.message}`,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=languageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languageHandler.js","sourceRoot":"","sources":["../../../src/mcp/tools/languageHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC;CAC1E,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAI1D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAgB,EAAE,MAAsB;IAC5E,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC9B,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE5B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QAEtE,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;iBACnC;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"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
export declare const ListLanguagesSchema: {
|
|
4
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
6
|
+
includeInactive: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
8
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
9
|
+
key: z.ZodString;
|
|
10
|
+
value: z.ZodEnum<["ASC" | "DESC", ...("ASC" | "DESC")[]]>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
key?: string;
|
|
13
|
+
value?: "ASC" | "DESC";
|
|
14
|
+
}, {
|
|
15
|
+
key?: string;
|
|
16
|
+
value?: "ASC" | "DESC";
|
|
17
|
+
}>, "many">>;
|
|
18
|
+
};
|
|
19
|
+
export declare const ListLanguagesZodSchema: z.ZodObject<{
|
|
20
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
includeInactive: z.ZodDefault<z.ZodBoolean>;
|
|
23
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
24
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
25
|
+
key: z.ZodString;
|
|
26
|
+
value: z.ZodEnum<["ASC" | "DESC", ...("ASC" | "DESC")[]]>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
key?: string;
|
|
29
|
+
value?: "ASC" | "DESC";
|
|
30
|
+
}, {
|
|
31
|
+
key?: string;
|
|
32
|
+
value?: "ASC" | "DESC";
|
|
33
|
+
}>, "many">>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
sort?: {
|
|
36
|
+
key?: string;
|
|
37
|
+
value?: "ASC" | "DESC";
|
|
38
|
+
}[];
|
|
39
|
+
includeInactive?: boolean;
|
|
40
|
+
queryString?: string;
|
|
41
|
+
limit?: number;
|
|
42
|
+
offset?: number;
|
|
43
|
+
}, {
|
|
44
|
+
sort?: {
|
|
45
|
+
key?: string;
|
|
46
|
+
value?: "ASC" | "DESC";
|
|
47
|
+
}[];
|
|
48
|
+
includeInactive?: boolean;
|
|
49
|
+
queryString?: string;
|
|
50
|
+
limit?: number;
|
|
51
|
+
offset?: number;
|
|
52
|
+
}>;
|
|
53
|
+
export type ListLanguagesParams = z.infer<typeof ListLanguagesZodSchema>;
|
|
54
|
+
export declare function languagesHandler(context: Context, params: ListLanguagesParams): Promise<{
|
|
55
|
+
content: {
|
|
56
|
+
type: "text";
|
|
57
|
+
text: string;
|
|
58
|
+
}[];
|
|
59
|
+
}>;
|
|
60
|
+
//# sourceMappingURL=languagesHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languagesHandler.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/languagesHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAQ3C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;CAa/B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAgC,CAAC;AAEpE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEzE,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,mBAAmB;;;;;GAyBnF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SortDirection } from '@unchainedshop/utils';
|
|
3
|
+
const sortDirectionKeys = Object.keys(SortDirection);
|
|
4
|
+
export const ListLanguagesSchema = {
|
|
5
|
+
limit: z.number().int().min(1).max(100).default(50),
|
|
6
|
+
offset: z.number().int().min(0).default(0),
|
|
7
|
+
includeInactive: z.boolean().default(false),
|
|
8
|
+
queryString: z.string().min(1).optional(),
|
|
9
|
+
sort: z
|
|
10
|
+
.array(z.object({
|
|
11
|
+
key: z.string().min(1),
|
|
12
|
+
value: z.enum(sortDirectionKeys).describe("Sort direction, e.g., 'ASC' or 'DESC'"),
|
|
13
|
+
}))
|
|
14
|
+
.optional(),
|
|
15
|
+
};
|
|
16
|
+
export const ListLanguagesZodSchema = z.object(ListLanguagesSchema);
|
|
17
|
+
export async function languagesHandler(context, params) {
|
|
18
|
+
const { sort, ...restParams } = params;
|
|
19
|
+
const { modules } = context;
|
|
20
|
+
try {
|
|
21
|
+
const languages = await modules.languages.findLanguages({ ...restParams, sort: sort });
|
|
22
|
+
return {
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: 'text',
|
|
26
|
+
text: JSON.stringify({ languages }),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return {
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: 'text',
|
|
36
|
+
text: `Error retrieving languages: ${error.message}`,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=languagesHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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,EAAE,GAAG,OAAO,CAAC;IAE5B,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,IAAa,EAAE,CAAC,CAAC;QAEhG,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC;iBACpC;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"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for the list_products tool (as raw object for MCP)
|
|
5
|
+
*/
|
|
6
|
+
export declare const ListProductsSchema: {
|
|
7
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
8
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
productIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
filterQuery: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
11
|
+
key: z.ZodString;
|
|
12
|
+
value: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
key?: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
}, {
|
|
17
|
+
key?: string;
|
|
18
|
+
value?: string;
|
|
19
|
+
}>, "many">>;
|
|
20
|
+
assortmentId: z.ZodOptional<z.ZodString>;
|
|
21
|
+
includeInactive: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
25
|
+
key: z.ZodString;
|
|
26
|
+
value: z.ZodEnum<["ASC", "DESC"]>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
key?: string;
|
|
29
|
+
value?: "ASC" | "DESC";
|
|
30
|
+
}, {
|
|
31
|
+
key?: string;
|
|
32
|
+
value?: "ASC" | "DESC";
|
|
33
|
+
}>, "many">>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Zod object schema for type inference
|
|
37
|
+
*/
|
|
38
|
+
export declare const ListProductsZodSchema: z.ZodObject<{
|
|
39
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
40
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
41
|
+
productIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
42
|
+
filterQuery: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
43
|
+
key: z.ZodString;
|
|
44
|
+
value: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
key?: string;
|
|
47
|
+
value?: string;
|
|
48
|
+
}, {
|
|
49
|
+
key?: string;
|
|
50
|
+
value?: string;
|
|
51
|
+
}>, "many">>;
|
|
52
|
+
assortmentId: z.ZodOptional<z.ZodString>;
|
|
53
|
+
includeInactive: z.ZodDefault<z.ZodBoolean>;
|
|
54
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
55
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
56
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
57
|
+
key: z.ZodString;
|
|
58
|
+
value: z.ZodEnum<["ASC", "DESC"]>;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
key?: string;
|
|
61
|
+
value?: "ASC" | "DESC";
|
|
62
|
+
}, {
|
|
63
|
+
key?: string;
|
|
64
|
+
value?: "ASC" | "DESC";
|
|
65
|
+
}>, "many">>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
tags?: string[];
|
|
68
|
+
sort?: {
|
|
69
|
+
key?: string;
|
|
70
|
+
value?: "ASC" | "DESC";
|
|
71
|
+
}[];
|
|
72
|
+
assortmentId?: string;
|
|
73
|
+
includeInactive?: boolean;
|
|
74
|
+
queryString?: string;
|
|
75
|
+
limit?: number;
|
|
76
|
+
offset?: number;
|
|
77
|
+
productIds?: string[];
|
|
78
|
+
filterQuery?: {
|
|
79
|
+
key?: string;
|
|
80
|
+
value?: string;
|
|
81
|
+
}[];
|
|
82
|
+
}, {
|
|
83
|
+
tags?: string[];
|
|
84
|
+
sort?: {
|
|
85
|
+
key?: string;
|
|
86
|
+
value?: "ASC" | "DESC";
|
|
87
|
+
}[];
|
|
88
|
+
assortmentId?: string;
|
|
89
|
+
includeInactive?: boolean;
|
|
90
|
+
queryString?: string;
|
|
91
|
+
limit?: number;
|
|
92
|
+
offset?: number;
|
|
93
|
+
productIds?: string[];
|
|
94
|
+
filterQuery?: {
|
|
95
|
+
key?: string;
|
|
96
|
+
value?: string;
|
|
97
|
+
}[];
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Interface for the list_products tool parameters
|
|
101
|
+
*/
|
|
102
|
+
export type ListProductsParams = z.infer<typeof ListProductsZodSchema>;
|
|
103
|
+
/**
|
|
104
|
+
* Implementation of the list_products tool
|
|
105
|
+
*/
|
|
106
|
+
export declare function listProductsHandler(context: Context, params: ListProductsParams): Promise<{
|
|
107
|
+
content: {
|
|
108
|
+
type: "text";
|
|
109
|
+
text: string;
|
|
110
|
+
}[];
|
|
111
|
+
}>;
|
|
112
|
+
//# sourceMappingURL=listProducts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listProducts.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/listProducts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+B9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA+B,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEvE;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB;;;;;GAgFrF"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for the list_products tool (as raw object for MCP)
|
|
4
|
+
*/
|
|
5
|
+
export const ListProductsSchema = {
|
|
6
|
+
// Search & Filter
|
|
7
|
+
queryString: z.string().optional().describe('Text search across product fields'),
|
|
8
|
+
tags: z.array(z.string()).optional().describe('Filter by product tags'),
|
|
9
|
+
productIds: z.array(z.string()).optional().describe('Filter by specific product IDs'),
|
|
10
|
+
filterQuery: z
|
|
11
|
+
.array(z.object({
|
|
12
|
+
key: z.string().describe('Filter key'),
|
|
13
|
+
value: z.string().optional().describe('Filter value'),
|
|
14
|
+
}))
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('Key-value filter pairs'),
|
|
17
|
+
assortmentId: z.string().optional().describe('Filter by assortment'),
|
|
18
|
+
includeInactive: z.boolean().default(false).describe('Include inactive products'),
|
|
19
|
+
// Pagination
|
|
20
|
+
limit: z.number().min(1).max(100).default(20).describe('Results per page'),
|
|
21
|
+
offset: z.number().min(0).default(0).describe('Skip results for pagination'),
|
|
22
|
+
// Sorting
|
|
23
|
+
sort: z
|
|
24
|
+
.array(z.object({
|
|
25
|
+
key: z.string().describe('Sort field'),
|
|
26
|
+
value: z.enum(['ASC', 'DESC']).describe('Sort direction'),
|
|
27
|
+
}))
|
|
28
|
+
.optional()
|
|
29
|
+
.describe('Sort options'),
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Zod object schema for type inference
|
|
33
|
+
*/
|
|
34
|
+
export const ListProductsZodSchema = z.object(ListProductsSchema);
|
|
35
|
+
/**
|
|
36
|
+
* Implementation of the list_products tool
|
|
37
|
+
*/
|
|
38
|
+
export async function listProductsHandler(context, params) {
|
|
39
|
+
const { queryString, tags, productIds, filterQuery, assortmentId, includeInactive = false, limit = 20, offset = 0, sort, } = params;
|
|
40
|
+
try {
|
|
41
|
+
let filteredProductIds = productIds;
|
|
42
|
+
// If assortmentId is provided, get product IDs from assortment
|
|
43
|
+
if (assortmentId) {
|
|
44
|
+
const assortmentProductIds = await context.modules.assortments.products.findProductIds({
|
|
45
|
+
assortmentId,
|
|
46
|
+
});
|
|
47
|
+
if (filteredProductIds) {
|
|
48
|
+
// Intersection of both sets
|
|
49
|
+
filteredProductIds = filteredProductIds.filter((id) => assortmentProductIds.includes(id));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
filteredProductIds = assortmentProductIds;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const searchResult = await context.services.filters.searchProducts({
|
|
56
|
+
queryString,
|
|
57
|
+
productIds: filteredProductIds,
|
|
58
|
+
includeInactive,
|
|
59
|
+
filterQuery: filterQuery?.filter((f) => f.key),
|
|
60
|
+
}, {
|
|
61
|
+
locale: context.locale,
|
|
62
|
+
});
|
|
63
|
+
const products = await context.modules.products.findProducts({
|
|
64
|
+
productIds: searchResult.aggregatedFilteredProductIds,
|
|
65
|
+
tags,
|
|
66
|
+
limit,
|
|
67
|
+
offset,
|
|
68
|
+
sort: sort?.filter((s) => s.key),
|
|
69
|
+
});
|
|
70
|
+
const productTexts = await context.loaders.productTextLoader.loadMany(searchResult.aggregatedFilteredProductIds.map((productId) => ({
|
|
71
|
+
productId,
|
|
72
|
+
locale: context.locale,
|
|
73
|
+
})));
|
|
74
|
+
// iterate all products and add texts
|
|
75
|
+
products.forEach((product) => {
|
|
76
|
+
const texts = productTexts.filter((text) => text.productId === product._id);
|
|
77
|
+
product.texts = texts;
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
content: [
|
|
81
|
+
{
|
|
82
|
+
type: 'text',
|
|
83
|
+
text: JSON.stringify({
|
|
84
|
+
products,
|
|
85
|
+
total: searchResult.aggregatedTotalProductIds.length,
|
|
86
|
+
filtered: searchResult.aggregatedFilteredProductIds.length,
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return {
|
|
94
|
+
content: [{ type: 'text', text: `Error listing products: ${error.message}` }],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=listProducts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listProducts.js","sourceRoot":"","sources":["../../../src/mcp/tools/listProducts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,kBAAkB;IAClB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAChF,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IACvE,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gCAAg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AO,mBAqBpD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getFileAdapter } from '@unchainedshop/core-files';
|
|
2
|
+
const normalizeMediaUrl = async (medias = [], context) => {
|
|
3
|
+
if (medias?.length) {
|
|
4
|
+
const normalizedMedias = await Promise.all(medias.map(async (media) => {
|
|
5
|
+
const file = await context.loaders.fileLoader.load({
|
|
6
|
+
fileId: media.mediaId,
|
|
7
|
+
});
|
|
8
|
+
const fileUploadAdapter = getFileAdapter();
|
|
9
|
+
const url = await fileUploadAdapter.createDownloadURL(file);
|
|
10
|
+
file.url = context.modules.files.normalizeUrl(url, {});
|
|
11
|
+
return {
|
|
12
|
+
...media,
|
|
13
|
+
file,
|
|
14
|
+
};
|
|
15
|
+
}));
|
|
16
|
+
return normalizedMedias.filter(Boolean);
|
|
17
|
+
}
|
|
18
|
+
return medias;
|
|
19
|
+
};
|
|
20
|
+
export default normalizeMediaUrl;
|
|
21
|
+
//# sourceMappingURL=normalizeMediaUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeMediaUrl.js","sourceRoot":"","sources":["../../../src/mcp/tools/normalizeMediaUrl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,iBAAiB,GAAG,KAAK,EAAE,MAAM,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE;IACvD,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC,GAAG,CACxC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YACzB,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;gBACjD,MAAM,EAAE,KAAK,CAAC,OAAO;aACtB,CAAC,CAAC;YACH,MAAM,iBAAiB,GAAG,cAAc,EAAE,CAAC;YAC3C,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAC5D,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAEvD,OAAO;gBACL,GAAG,KAAK;gBACR,IAAI;aACL,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|