@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,14 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
|
+
const isoCodes = [...new Set(queries.map((q) => q.isoCode).filter(Boolean))];
|
|
4
|
+
const languages = await unchainedAPI.modules.languages.findLanguages({
|
|
5
|
+
isoCode: { $in: isoCodes },
|
|
6
|
+
includeInactive: true,
|
|
7
|
+
});
|
|
8
|
+
const languageMap = {};
|
|
9
|
+
for (const language of languages) {
|
|
10
|
+
languageMap[language.isoCode] = language;
|
|
11
|
+
}
|
|
12
|
+
return queries.map((q) => languageMap[q.isoCode]);
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=languageLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languageLoader.js","sourceRoot":"","sources":["../../src/loaders/languageLoader.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,eAAe,CAAC,YAA2B,EAAE,EAAE,CAC7C,IAAI,UAAU,CAAgC,KAAK,EAAE,OAAO,EAAE,EAAE;IAC9D,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE7E,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC;QACnE,OAAO,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;QAC1B,eAAe,EAAE,IAAI;KACtB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,EAAE,CAAC;IACvB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;IAC3C,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import { Order } from '@unchainedshop/core-orders';
|
|
3
|
+
import DataLoader from 'dataloader';
|
|
4
|
+
declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
|
|
5
|
+
orderId: string;
|
|
6
|
+
}, Order, {
|
|
7
|
+
orderId: string;
|
|
8
|
+
}>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=orderLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/orderLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,UAAU,MAAM,YAAY,CAAC;yBAEpB,cAAc,aAAa;aACf,MAAM;;aAAN,MAAM;;AADlC,wBAiBK"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
|
+
const orderIds = [...new Set(queries.map((q) => q.orderId).filter(Boolean))];
|
|
4
|
+
// It's important to also fetch deleted with the loader,
|
|
5
|
+
// because the loader fetches entities by id.
|
|
6
|
+
const orders = await unchainedAPI.modules.orders.findOrders({
|
|
7
|
+
includeCarts: true,
|
|
8
|
+
_id: { $in: orderIds },
|
|
9
|
+
});
|
|
10
|
+
const orderMap = {};
|
|
11
|
+
for (const order of orders) {
|
|
12
|
+
orderMap[order._id] = order;
|
|
13
|
+
}
|
|
14
|
+
return queries.map((q) => orderMap[q.orderId]);
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=orderLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderLoader.js","sourceRoot":"","sources":["../../src/loaders/orderLoader.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,eAAe,CAAC,YAA2B,EAAE,EAAE,CAC7C,IAAI,UAAU,CAA6B,KAAK,EAAE,OAAO,EAAE,EAAE;IAC3D,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE7E,wDAAwD;IACxD,6CAA6C;IAC7C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;QAC1D,YAAY,EAAE,IAAI;QAClB,GAAG,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;KACvB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import { PaymentProvider } from '@unchainedshop/core-payment';
|
|
3
|
+
import DataLoader from 'dataloader';
|
|
4
|
+
declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
|
|
5
|
+
paymentProviderId: string;
|
|
6
|
+
}, PaymentProvider, {
|
|
7
|
+
paymentProviderId: string;
|
|
8
|
+
}>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=paymentProviderLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paymentProviderLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/paymentProviderLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,UAAU,MAAM,YAAY,CAAC;yBAEpB,cAAc,aAAa;uBACL,MAAM;;uBAAN,MAAM;;AAD5C,wBAcK"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
|
+
const paymentProviderIds = [...new Set(queries.map((q) => q.paymentProviderId).filter(Boolean))];
|
|
4
|
+
const paymentProviders = await unchainedAPI.modules.payment.paymentProviders.findProviders({
|
|
5
|
+
_id: { $in: paymentProviderIds },
|
|
6
|
+
});
|
|
7
|
+
const paymentProviderMap = {};
|
|
8
|
+
for (const paymentProvider of paymentProviders) {
|
|
9
|
+
paymentProviderMap[paymentProvider._id] = paymentProvider;
|
|
10
|
+
}
|
|
11
|
+
return queries.map((q) => paymentProviderMap[q.paymentProviderId]);
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=paymentProviderLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paymentProviderLoader.js","sourceRoot":"","sources":["../../src/loaders/paymentProviderLoader.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,eAAe,CAAC,YAA2B,EAAE,EAAE,CAC7C,IAAI,UAAU,CAAiD,KAAK,EAAE,OAAO,EAAE,EAAE;IAC/E,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAEjG,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC;QACzF,GAAG,EAAE,EAAE,GAAG,EAAE,kBAAkB,EAAE;KACjC,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,EAAE,CAAC;IAC9B,KAAK,MAAM,eAAe,IAAI,gBAAgB,EAAE,CAAC;QAC/C,kBAAkB,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC;IAC5D,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import { Product } from '@unchainedshop/core-products';
|
|
3
|
+
import DataLoader from 'dataloader';
|
|
4
|
+
declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
|
|
5
|
+
productId: string;
|
|
6
|
+
}, Product, {
|
|
7
|
+
productId: string;
|
|
8
|
+
}>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=productLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/productLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,UAAU,MAAM,YAAY,CAAC;yBAEpB,cAAc,aAAa;eACb,MAAM;;eAAN,MAAM;;AADpC,wBAiBK"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
|
+
const productIds = [...new Set(queries.map((q) => q.productId).filter(Boolean))];
|
|
4
|
+
const products = await unchainedAPI.modules.products.findProducts({
|
|
5
|
+
productIds,
|
|
6
|
+
productSelector: {
|
|
7
|
+
status: { $exists: true },
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
const productMap = {};
|
|
11
|
+
for (const product of products) {
|
|
12
|
+
productMap[product._id] = product;
|
|
13
|
+
}
|
|
14
|
+
return queries.map((q) => productMap[q.productId]);
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=productLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productLoader.js","sourceRoot":"","sources":["../../src/loaders/productLoader.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,eAAe,CAAC,YAA2B,EAAE,EAAE,CAC7C,IAAI,UAAU,CAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;IAC/D,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAEjF,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;QAChE,UAAU;QACV,eAAe,EAAE;YACf,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SAC1B;KACF,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;IACpC,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import { Product } from '@unchainedshop/core-products';
|
|
3
|
+
import DataLoader from 'dataloader';
|
|
4
|
+
declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
|
|
5
|
+
sku: string;
|
|
6
|
+
}, Product, {
|
|
7
|
+
sku: string;
|
|
8
|
+
}>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=productLoaderBySKU.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productLoaderBySKU.d.ts","sourceRoot":"","sources":["../../src/loaders/productLoaderBySKU.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,UAAU,MAAM,YAAY,CAAC;yBAEpB,cAAc,aAAa;SACnB,MAAM;;SAAN,MAAM;;AAD9B,wBAiBK"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
|
+
const skus = [...new Set(queries.map((q) => q.sku).filter(Boolean))];
|
|
4
|
+
const products = await unchainedAPI.modules.products.findProducts({
|
|
5
|
+
productSelector: {
|
|
6
|
+
'warehousing.sku': { $in: skus },
|
|
7
|
+
status: { $exists: true },
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
const productMap = {};
|
|
11
|
+
for (const product of products) {
|
|
12
|
+
productMap[product.warehousing.sku] = product;
|
|
13
|
+
}
|
|
14
|
+
return queries.map((q) => productMap[q.sku]);
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=productLoaderBySKU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productLoaderBySKU.js","sourceRoot":"","sources":["../../src/loaders/productLoaderBySKU.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,eAAe,CAAC,YAA2B,EAAE,EAAE,CAC7C,IAAI,UAAU,CAA2B,KAAK,EAAE,OAAO,EAAE,EAAE;IACzD,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAErE,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;QAChE,eAAe,EAAE;YACf,iBAAiB,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;YAChC,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SAC1B;KACF,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,UAAU,CAAC,OAAO,CAAC,WAAY,CAAC,GAAI,CAAC,GAAG,OAAO,CAAC;IAClD,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import DataLoader from 'dataloader';
|
|
3
|
+
import { ProductMediaText } from '@unchainedshop/core-products';
|
|
4
|
+
declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
|
|
5
|
+
productMediaId: string;
|
|
6
|
+
locale: Intl.Locale;
|
|
7
|
+
}, ProductMediaText, {
|
|
8
|
+
productMediaId: string;
|
|
9
|
+
locale: Intl.Locale;
|
|
10
|
+
}>;
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=productMediaTextLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productMediaTextLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/productMediaTextLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;yBAIhD,cAAc,aAAa;oBACR,MAAM;YAAU,IAAI,CAAC,MAAM;;oBAA3B,MAAM;YAAU,IAAI,CAAC,MAAM;;AAD9D,wBAiBK"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
import buildLocaleMap from './buildLocaleMap.js';
|
|
3
|
+
import buildTextMap from './buildTextMap.js';
|
|
4
|
+
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
5
|
+
const productMediaIds = [...new Set(queries.map((q) => q.productMediaId).filter(Boolean))];
|
|
6
|
+
const texts = await unchainedAPI.modules.products.media.texts.findMediaTexts({ productMediaId: { $in: productMediaIds } }, {
|
|
7
|
+
sort: {
|
|
8
|
+
productMediaId: 1,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
const localeMap = buildLocaleMap(queries, texts);
|
|
12
|
+
const textsMap = buildTextMap(localeMap, texts, (text) => text.productMediaId);
|
|
13
|
+
return queries.map((q) => textsMap[q.locale + q.productMediaId]);
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=productMediaTextLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productMediaTextLoader.js","sourceRoot":"","sources":["../../src/loaders/productMediaTextLoader.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C,eAAe,CAAC,YAA2B,EAAE,EAAE,CAC7C,IAAI,UAAU,CAAoE,KAAK,EAAE,OAAO,EAAE,EAAE;IAClG,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE3F,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAC1E,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,EAAE,EAC5C;QACE,IAAI,EAAE;YACJ,cAAc,EAAE,CAAC;SAClB;KACF,CACF,CAAC;IAEF,MAAM,SAAS,GAAG,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAE/E,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;AACnE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import { ProductMedia } from '@unchainedshop/core-products';
|
|
3
|
+
import DataLoader from 'dataloader';
|
|
4
|
+
declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
|
|
5
|
+
productId?: string;
|
|
6
|
+
}, ProductMedia[], {
|
|
7
|
+
productId?: string;
|
|
8
|
+
}>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=productMediasLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productMediasLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/productMediasLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,UAAU,MAAM,YAAY,CAAC;yBAEpB,cAAc,aAAa;gBACZ,MAAM;;gBAAN,MAAM;;AADrC,wBAgBK"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
|
+
const productIds = [...new Set(queries.map((q) => q.productId).filter(Boolean))];
|
|
4
|
+
const productMediaItems = await unchainedAPI.modules.products.media.findProductMedias({
|
|
5
|
+
productId: { $in: productIds },
|
|
6
|
+
});
|
|
7
|
+
const productMediaMap = {};
|
|
8
|
+
for (const productMedia of productMediaItems) {
|
|
9
|
+
if (!productMediaMap[productMedia.productId]) {
|
|
10
|
+
productMediaMap[productMedia.productId] = [productMedia];
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
productMediaMap[productMedia.productId].push(productMedia);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return queries.map((q) => productMediaMap[q.productId] || []);
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=productMediasLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productMediasLoader.js","sourceRoot":"","sources":["../../src/loaders/productMediasLoader.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,eAAe,CAAC,YAA2B,EAAE,EAAE,CAC7C,IAAI,UAAU,CAAyC,KAAK,EAAE,OAAO,EAAE,EAAE;IACvE,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACjF,MAAM,iBAAiB,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC;QACpF,SAAS,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE;KAC/B,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,EAAE,CAAC;IAC3B,KAAK,MAAM,YAAY,IAAI,iBAAiB,EAAE,CAAC;QAC7C,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7C,eAAe,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,eAAe,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import DataLoader from 'dataloader';
|
|
3
|
+
import { ProductText } from '@unchainedshop/core-products';
|
|
4
|
+
declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
|
|
5
|
+
productId: string;
|
|
6
|
+
locale: Intl.Locale;
|
|
7
|
+
}, ProductText, {
|
|
8
|
+
productId: string;
|
|
9
|
+
locale: Intl.Locale;
|
|
10
|
+
}>;
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=productTextLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productTextLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/productTextLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;yBAI3C,cAAc,aAAa;eACb,MAAM;YAAU,IAAI,CAAC,MAAM;;eAA3B,MAAM;YAAU,IAAI,CAAC,MAAM;;AADzD,wBAeK"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
import buildTextMap from './buildTextMap.js';
|
|
3
|
+
import buildLocaleMap from './buildLocaleMap.js';
|
|
4
|
+
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
5
|
+
const productIds = [...new Set(queries.map((q) => q.productId))].filter(Boolean);
|
|
6
|
+
const texts = await unchainedAPI.modules.products.texts.findTexts({ productId: { $in: productIds } }, {
|
|
7
|
+
sort: {
|
|
8
|
+
productId: 1,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
const localeMap = buildLocaleMap(queries, texts);
|
|
12
|
+
const textsMap = buildTextMap(localeMap, texts, (text) => text.productId);
|
|
13
|
+
return queries.map((q) => textsMap[q.locale + q.productId]);
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=productTextLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productTextLoader.js","sourceRoot":"","sources":["../../src/loaders/productTextLoader.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,eAAe,CAAC,YAA2B,EAAE,EAAE,CAC7C,IAAI,UAAU,CAA0D,KAAK,EAAE,OAAO,EAAE,EAAE;IACxF,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjF,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAC/D,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAClC;QACE,IAAI,EAAE;YACJ,SAAS,EAAE,CAAC;SACb;KACF,CACF,CAAC;IACF,MAAM,SAAS,GAAG,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE1E,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import { User } from '@unchainedshop/core-users';
|
|
3
|
+
import DataLoader from 'dataloader';
|
|
4
|
+
declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
|
|
5
|
+
userId: string;
|
|
6
|
+
}, User, {
|
|
7
|
+
userId: string;
|
|
8
|
+
}>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=userLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/userLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,UAAU,MAAM,YAAY,CAAC;yBAEpB,cAAc,aAAa;YAChB,MAAM;;YAAN,MAAM;;AADjC,wBAkBK"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
|
+
const userIds = [...new Set(queries.map((q) => q.userId).filter(Boolean))];
|
|
4
|
+
// It's important to also fetch deleted with the loader,
|
|
5
|
+
// because the loader fetches entities by id.
|
|
6
|
+
const users = await unchainedAPI.modules.users.findUsers({
|
|
7
|
+
includeGuests: true,
|
|
8
|
+
includeDeleted: true,
|
|
9
|
+
_id: { $in: userIds },
|
|
10
|
+
});
|
|
11
|
+
const userMap = {};
|
|
12
|
+
for (const user of users) {
|
|
13
|
+
userMap[user._id] = user;
|
|
14
|
+
}
|
|
15
|
+
return queries.map((q) => userMap[q.userId]);
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=userLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userLoader.js","sourceRoot":"","sources":["../../src/loaders/userLoader.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,eAAe,CAAC,YAA2B,EAAE,EAAE,CAC7C,IAAI,UAAU,CAA2B,KAAK,EAAE,OAAO,EAAE,EAAE;IACzD,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE3E,wDAAwD;IACxD,6CAA6C;IAC7C,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;QACvD,aAAa,EAAE,IAAI;QACnB,cAAc,EAAE,IAAI;QACpB,GAAG,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;KACtB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function getLocaleStrings(locale: Intl.Locale): string[];
|
|
2
|
+
export declare function buildLocaleMap(queries: readonly {
|
|
3
|
+
locale: Intl.Locale;
|
|
4
|
+
}[], texts: readonly {
|
|
5
|
+
locale?: string;
|
|
6
|
+
}[]): Record<string, string[]>;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/loaders/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,YAQnD;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,SAAS;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE,EAAE,EAC3C,KAAK,EAAE,SAAS;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,GACpC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAmB1B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { systemLocale } from '@unchainedshop/utils';
|
|
2
|
+
export function getLocaleStrings(locale) {
|
|
3
|
+
try {
|
|
4
|
+
return [
|
|
5
|
+
...new Set([locale.baseName, locale.language, systemLocale.baseName, systemLocale.language]),
|
|
6
|
+
];
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return [...new Set([systemLocale.baseName, systemLocale.language])];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function buildLocaleMap(queries, texts) {
|
|
13
|
+
// key = texts.locale
|
|
14
|
+
// value = input query locale
|
|
15
|
+
const queryLocales = Object.values(Object.fromEntries(queries.map((q) => [q.locale.baseName, q.locale])));
|
|
16
|
+
const textLocales = [...new Set(texts.map((t) => t.locale))];
|
|
17
|
+
const localeMap = {};
|
|
18
|
+
for (const queryLocale of queryLocales) {
|
|
19
|
+
const potentialMatches = getLocaleStrings(queryLocale);
|
|
20
|
+
const matches = potentialMatches.filter((l) => textLocales.includes(l));
|
|
21
|
+
for (const match of matches) {
|
|
22
|
+
if (!localeMap[match])
|
|
23
|
+
localeMap[match] = [];
|
|
24
|
+
localeMap[match].push(queryLocale);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return localeMap;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/loaders/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,UAAU,gBAAgB,CAAC,MAAmB;IAClD,IAAI,CAAC;QACH,OAAO;YACL,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;SAC7F,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,OAA2C,EAC3C,KAAqC;IAErC,qBAAqB;IACrB,6BAA6B;IAE7B,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAChC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CACtE,CAAC;IAEF,MAAM,WAAW,GAAa,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvE,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACxE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;gBAAE,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YAC7C,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAQxC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,OAAO,aAkBvD"}
|
package/lib/mcp/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { listProductsHandler, ListProductsSchema, getProductHandler, GetProductSchema, } from './tools/index.js';
|
|
3
|
+
export default function createMcpServer(context) {
|
|
4
|
+
const server = new McpServer({
|
|
5
|
+
name: 'Unchained MCP Server',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
});
|
|
8
|
+
server.tool('list_products', 'Search and list products with comprehensive filtering and pagination support', ListProductsSchema, async (params) => listProductsHandler(context, params));
|
|
9
|
+
server.tool('get_product', 'Get detailed product information', GetProductSchema, async (params) => getProductHandler(context, params));
|
|
10
|
+
return server;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAgB;IACtD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,sBAAsB;QAC5B,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CACT,eAAe,EACf,8EAA8E,EAC9E,kBAAkB,EAClB,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CACvD,CAAC;IAEF,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,kCAAkC,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAChG,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CACnC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
export declare const AssignProductVariationSchema: {
|
|
4
|
+
proxyId: z.ZodString;
|
|
5
|
+
productId: z.ZodString;
|
|
6
|
+
vectors: z.ZodArray<z.ZodObject<{
|
|
7
|
+
key: z.ZodString;
|
|
8
|
+
value: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
key?: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
}, {
|
|
13
|
+
key?: string;
|
|
14
|
+
value?: string;
|
|
15
|
+
}>, "many">;
|
|
16
|
+
};
|
|
17
|
+
export declare const AddProductAssignmentZodSchema: z.ZodObject<{
|
|
18
|
+
proxyId: z.ZodString;
|
|
19
|
+
productId: z.ZodString;
|
|
20
|
+
vectors: z.ZodArray<z.ZodObject<{
|
|
21
|
+
key: z.ZodString;
|
|
22
|
+
value: z.ZodString;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
key?: string;
|
|
25
|
+
value?: string;
|
|
26
|
+
}, {
|
|
27
|
+
key?: string;
|
|
28
|
+
value?: string;
|
|
29
|
+
}>, "many">;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
productId?: string;
|
|
32
|
+
proxyId?: string;
|
|
33
|
+
vectors?: {
|
|
34
|
+
key?: string;
|
|
35
|
+
value?: string;
|
|
36
|
+
}[];
|
|
37
|
+
}, {
|
|
38
|
+
productId?: string;
|
|
39
|
+
proxyId?: string;
|
|
40
|
+
vectors?: {
|
|
41
|
+
key?: string;
|
|
42
|
+
value?: string;
|
|
43
|
+
}[];
|
|
44
|
+
}>;
|
|
45
|
+
export type AddProductAssignmentParams = z.infer<typeof AddProductAssignmentZodSchema>;
|
|
46
|
+
export declare function addProductAssignmentHandler(context: Context, params: AddProductAssignmentParams): Promise<{
|
|
47
|
+
content: {
|
|
48
|
+
type: "text";
|
|
49
|
+
text: string;
|
|
50
|
+
}[];
|
|
51
|
+
}>;
|
|
52
|
+
//# sourceMappingURL=addProductAssignmentHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addProductAssignmentHandler.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/addProductAssignmentHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AA2C3C,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;CAUxC,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAyC,CAAC;AAEpF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEvF,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,0BAA0B;;;;;GAyDrG"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
3
|
+
import { ProductNotFoundError, ProductVariationVectorAlreadySet, ProductVariationVectorInvalid, ProductWrongTypeError, } from '../../errors.js';
|
|
4
|
+
import { ProductTypes } from '@unchainedshop/core-products';
|
|
5
|
+
const extractVariationMatrix = (variations = []) => {
|
|
6
|
+
const cartesianProduct = (arrays) => {
|
|
7
|
+
return arrays.reduce((acc, array) => acc.flatMap((item) => array.map((value) => [...item, value])), [[]]);
|
|
8
|
+
};
|
|
9
|
+
const keys = variations.map((item) => item.key);
|
|
10
|
+
const options = variations.map((item) => item.options);
|
|
11
|
+
const combinations = cartesianProduct(options);
|
|
12
|
+
return combinations.map((combination) => combination.reduce((acc, value, index) => {
|
|
13
|
+
acc[keys[index]] = value;
|
|
14
|
+
return acc;
|
|
15
|
+
}, {}));
|
|
16
|
+
};
|
|
17
|
+
const combinationExists = (matrix, combination) => {
|
|
18
|
+
return matrix.some((variation) => {
|
|
19
|
+
return (Object.keys(variation).length === Object.keys(combination).length && // Ensure both have the same number of keys
|
|
20
|
+
Object.entries(combination).every(([key, value]) => variation[key] === value));
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
// Zod schema for ProductAssignmentVectorInput
|
|
24
|
+
const ProductAssignmentVectorSchema = z.object({
|
|
25
|
+
key: z.string().min(1).describe('Attribute key (e.g., "Color", "Size")'),
|
|
26
|
+
value: z.string().min(1).describe('Attribute value (e.g., "Red", "M")'),
|
|
27
|
+
});
|
|
28
|
+
export const AssignProductVariationSchema = {
|
|
29
|
+
proxyId: z.string().min(1).describe('should be ID of the CONFIGURABLE_PRODUCT (parent) only'),
|
|
30
|
+
productId: z
|
|
31
|
+
.string()
|
|
32
|
+
.min(1)
|
|
33
|
+
.describe('ID of the product being assigned. can not be a CONFIGURABLE_PRODUCT product'),
|
|
34
|
+
vectors: z
|
|
35
|
+
.array(ProductAssignmentVectorSchema)
|
|
36
|
+
.min(1)
|
|
37
|
+
.describe('Combination of attributes uniquely identifying the variant'),
|
|
38
|
+
};
|
|
39
|
+
// Full schema for the mutation
|
|
40
|
+
export const AddProductAssignmentZodSchema = z.object(AssignProductVariationSchema);
|
|
41
|
+
export async function addProductAssignmentHandler(context, params) {
|
|
42
|
+
const { proxyId, productId, vectors } = params;
|
|
43
|
+
const { modules } = context;
|
|
44
|
+
try {
|
|
45
|
+
const proxyProduct = await modules.products.findProduct({
|
|
46
|
+
productId: proxyId,
|
|
47
|
+
});
|
|
48
|
+
if (!proxyProduct)
|
|
49
|
+
throw new ProductNotFoundError({ proxyId });
|
|
50
|
+
if (proxyProduct.type !== ProductTypes.ConfigurableProduct)
|
|
51
|
+
throw new ProductWrongTypeError({
|
|
52
|
+
proxyId,
|
|
53
|
+
received: proxyProduct.type,
|
|
54
|
+
required: ProductTypes.ConfigurableProduct,
|
|
55
|
+
});
|
|
56
|
+
const variations = await modules.products.variations.findProductVariations({
|
|
57
|
+
productId: proxyId,
|
|
58
|
+
});
|
|
59
|
+
const variationMatrix = extractVariationMatrix(variations);
|
|
60
|
+
const normalizedVectors = vectors?.reduce((prev, { key, value }) => {
|
|
61
|
+
return {
|
|
62
|
+
...prev,
|
|
63
|
+
[key]: value,
|
|
64
|
+
};
|
|
65
|
+
}, {});
|
|
66
|
+
if (!combinationExists(variationMatrix, normalizedVectors))
|
|
67
|
+
throw new ProductVariationVectorInvalid({ proxyId, vectors });
|
|
68
|
+
const added = await modules.products.assignments.addProxyAssignment({
|
|
69
|
+
productId,
|
|
70
|
+
proxyId,
|
|
71
|
+
vectors: vectors,
|
|
72
|
+
});
|
|
73
|
+
if (!added)
|
|
74
|
+
throw new ProductVariationVectorAlreadySet({ proxyId, vectors });
|
|
75
|
+
return {
|
|
76
|
+
content: [
|
|
77
|
+
{
|
|
78
|
+
type: 'text',
|
|
79
|
+
text: JSON.stringify({
|
|
80
|
+
product: await getNormalizedProductDetails(proxyId, context),
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return {
|
|
88
|
+
content: [
|
|
89
|
+
{
|
|
90
|
+
type: 'text',
|
|
91
|
+
text: `Error assigning product: ${error.message}`,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=addProductAssignmentHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addProductAssignmentHandler.js","sourceRoot":"","sources":["../../../src/mcp/tools/addProductAssignmentHandler.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
export declare const ListCountriesSchema: {
|
|
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 ListCountriesZodSchema: 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 ListCountriesParams = z.infer<typeof ListCountriesZodSchema>;
|
|
54
|
+
export declare function countriesHandler(context: Context, params: ListCountriesParams): Promise<{
|
|
55
|
+
content: {
|
|
56
|
+
type: "text";
|
|
57
|
+
text: string;
|
|
58
|
+
}[];
|
|
59
|
+
}>;
|
|
60
|
+
//# sourceMappingURL=countriesHandler.d.ts.map
|