@unchainedshop/api 4.0.0-rc.2 → 4.0.0-rc.3
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/api-index.d.ts.map +1 -1
- package/lib/api-index.js +4 -1
- package/lib/api-index.js.map +1 -1
- package/lib/errors.d.ts +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- 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/createBulkImportMiddleware copy.d.ts +6 -0
- package/lib/express/createBulkImportMiddleware copy.d.ts.map +1 -0
- package/lib/express/createBulkImportMiddleware copy.js +49 -0
- package/lib/express/createBulkImportMiddleware copy.js.map +1 -0
- package/lib/express/createMCPMiddleware.d.ts +2 -6
- package/lib/express/createMCPMiddleware.d.ts.map +1 -1
- package/lib/express/createMCPMiddleware.js +73 -42
- package/lib/express/createMCPMiddleware.js.map +1 -1
- 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/express/createTempUploadMiddleware.d.ts +7 -0
- package/lib/express/createTempUploadMiddleware.d.ts.map +1 -0
- package/lib/express/createTempUploadMiddleware.js +48 -0
- package/lib/express/createTempUploadMiddleware.js.map +1 -0
- package/lib/express/index.d.ts.map +1 -1
- package/lib/express/index.js +17 -4
- package/lib/express/index.js.map +1 -1
- package/lib/express/setupMCPChatHandler.d.ts +3 -0
- package/lib/express/setupMCPChatHandler.d.ts.map +1 -0
- package/lib/express/setupMCPChatHandler.js +57 -0
- package/lib/express/setupMCPChatHandler.js.map +1 -0
- package/lib/fastify/index.d.ts.map +1 -1
- package/lib/fastify/index.js +24 -2
- package/lib/fastify/index.js.map +1 -1
- package/lib/fastify/mcpChatHandler.d.ts +3 -0
- package/lib/fastify/mcpChatHandler.d.ts.map +1 -0
- package/lib/fastify/mcpChatHandler.js +60 -0
- package/lib/fastify/mcpChatHandler.js.map +1 -0
- package/lib/fastify/mcpHandler copy.d.ts +4 -0
- package/lib/fastify/mcpHandler copy.d.ts.map +1 -0
- package/lib/fastify/mcpHandler copy.js +72 -0
- package/lib/fastify/mcpHandler copy.js.map +1 -0
- package/lib/fastify/mcpHandler.d.ts +3 -7
- package/lib/fastify/mcpHandler.d.ts.map +1 -1
- package/lib/fastify/mcpHandler.js +71 -39
- package/lib/fastify/mcpHandler.js.map +1 -1
- package/lib/fastify/tempUploadHandler.d.ts +4 -0
- package/lib/fastify/tempUploadHandler.d.ts.map +1 -0
- package/lib/fastify/tempUploadHandler.js +41 -0
- package/lib/fastify/tempUploadHandler.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/assortmentMediaTextLoader.js +1 -1
- package/lib/loaders/assortmentMediaTextLoader.js.map +1 -1
- package/lib/loaders/assortmentTextLoader.js +1 -1
- package/lib/loaders/assortmentTextLoader.js.map +1 -1
- package/lib/loaders/buildLocaleMap.d.ts +6 -0
- package/lib/loaders/buildLocaleMap.d.ts.map +1 -0
- package/lib/loaders/buildLocaleMap.js +67 -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 +19 -6
- package/lib/loaders/buildTextMap.js.map +1 -1
- package/lib/loaders/filterTextLoader.js +1 -1
- package/lib/loaders/filterTextLoader.js.map +1 -1
- package/lib/loaders/productMediaTextLoader.d.ts.map +1 -1
- package/lib/loaders/productMediaTextLoader.js +1 -1
- package/lib/loaders/productMediaTextLoader.js.map +1 -1
- package/lib/loaders/productTextLoader.d.ts.map +1 -1
- package/lib/loaders/productTextLoader.js +1 -1
- package/lib/loaders/productTextLoader.js.map +1 -1
- package/lib/mcp/index.d.ts +3 -94
- package/lib/mcp/index.d.ts.map +1 -1
- package/lib/mcp/index.js +45 -135
- package/lib/mcp/index.js.map +1 -1
- 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/addProductMediaUploadHandler.d.ts +28 -0
- package/lib/mcp/tools/addProductMediaUploadHandler.d.ts.map +1 -0
- package/lib/mcp/tools/addProductMediaUploadHandler.js +62 -0
- package/lib/mcp/tools/addProductMediaUploadHandler.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/createLanguageHandler.d.ts +36 -0
- package/lib/mcp/tools/createLanguageHandler.d.ts.map +1 -0
- package/lib/mcp/tools/createLanguageHandler.js +39 -0
- package/lib/mcp/tools/createLanguageHandler.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 +73 -0
- package/lib/mcp/tools/createProductVariationHandler.js.map +1 -0
- package/lib/mcp/tools/createProductVariationOptionHandler.d.ts +60 -0
- package/lib/mcp/tools/createProductVariationOptionHandler.d.ts.map +1 -0
- package/lib/mcp/tools/createProductVariationOptionHandler.js +59 -0
- package/lib/mcp/tools/createProductVariationOptionHandler.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 +61 -0
- package/lib/mcp/tools/getProduct.js.map +1 -0
- package/lib/mcp/tools/index.d.ts +39 -0
- package/lib/mcp/tools/index.d.ts.map +1 -0
- package/lib/mcp/tools/index.js +39 -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 +110 -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/productReviewsCountHandler.d.ts +20 -0
- package/lib/mcp/tools/productReviewsCountHandler.d.ts.map +1 -0
- package/lib/mcp/tools/productReviewsCountHandler.js +30 -0
- package/lib/mcp/tools/productReviewsCountHandler.js.map +1 -0
- package/lib/mcp/tools/productReviewsHandler.d.ts +56 -0
- package/lib/mcp/tools/productReviewsHandler.d.ts.map +1 -0
- package/lib/mcp/tools/productReviewsHandler.js +45 -0
- package/lib/mcp/tools/productReviewsHandler.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/removeLanguageHandler.d.ts +20 -0
- package/lib/mcp/tools/removeLanguageHandler.d.ts.map +1 -0
- package/lib/mcp/tools/removeLanguageHandler.js +35 -0
- package/lib/mcp/tools/removeLanguageHandler.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/removeProductAssignmentHandler.d.ts +48 -0
- package/lib/mcp/tools/removeProductAssignmentHandler.d.ts.map +1 -0
- package/lib/mcp/tools/removeProductAssignmentHandler.js +51 -0
- package/lib/mcp/tools/removeProductAssignmentHandler.js.map +1 -0
- package/lib/mcp/tools/removeProductHandler.d.ts +20 -0
- package/lib/mcp/tools/removeProductHandler.d.ts.map +1 -0
- package/lib/mcp/tools/removeProductHandler.js +34 -0
- package/lib/mcp/tools/removeProductHandler.js.map +1 -0
- package/lib/mcp/tools/removeProductMediaHandler.d.ts +20 -0
- package/lib/mcp/tools/removeProductMediaHandler.d.ts.map +1 -0
- package/lib/mcp/tools/removeProductMediaHandler.js +42 -0
- package/lib/mcp/tools/removeProductMediaHandler.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/removeProductVariationOptionHandler.d.ts +24 -0
- package/lib/mcp/tools/removeProductVariationOptionHandler.d.ts.map +1 -0
- package/lib/mcp/tools/removeProductVariationOptionHandler.js +47 -0
- package/lib/mcp/tools/removeProductVariationOptionHandler.js.map +1 -0
- package/lib/mcp/tools/reorderProductMediaHandler.d.ts +44 -0
- package/lib/mcp/tools/reorderProductMediaHandler.d.ts.map +1 -0
- package/lib/mcp/tools/reorderProductMediaHandler.js +39 -0
- package/lib/mcp/tools/reorderProductMediaHandler.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/updateLanguageHandler.d.ts +48 -0
- package/lib/mcp/tools/updateLanguageHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateLanguageHandler.js +40 -0
- package/lib/mcp/tools/updateLanguageHandler.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/updateProductMediaTextsHandler.d.ts +56 -0
- package/lib/mcp/tools/updateProductMediaTextsHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductMediaTextsHandler.js +45 -0
- package/lib/mcp/tools/updateProductMediaTextsHandler.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 +38 -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/queries/filters/searchAssortments.d.ts.map +1 -1
- package/lib/resolvers/queries/filters/searchAssortments.js +0 -5
- package/lib/resolvers/queries/filters/searchAssortments.js.map +1 -1
- package/lib/resolvers/queries/filters/searchProducts.d.ts.map +1 -1
- package/lib/resolvers/queries/filters/searchProducts.js +2 -7
- package/lib/resolvers/queries/filters/searchProducts.js.map +1 -1
- 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/roles/all.d.ts.map +1 -1
- package/lib/roles/all.js +1 -0
- package/lib/roles/all.js.map +1 -1
- package/lib/roles/index.d.ts.map +1 -1
- package/lib/roles/index.js +1 -0
- package/lib/roles/index.js.map +1 -1
- package/lib/roles/loggedIn.d.ts.map +1 -1
- package/lib/roles/loggedIn.js +1 -0
- package/lib/roles/loggedIn.js.map +1 -1
- 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 +34 -18
- package/src/api-index.ts +4 -1
- package/src/errors.ts +5 -4
- package/src/express/createMCPMiddleware.ts +91 -0
- package/src/express/createTempUploadMiddleware.ts +60 -0
- package/src/express/index.ts +35 -6
- package/src/fastify/index.ts +32 -2
- package/src/fastify/mcpHandler.ts +97 -0
- package/src/fastify/tempUploadHandler.ts +52 -0
- package/src/loaders/assortmentMediaTextLoader.ts +1 -1
- package/src/loaders/assortmentTextLoader.ts +1 -1
- package/src/loaders/buildLocaleMap.test.ts +65 -0
- package/src/loaders/buildLocaleMap.ts +73 -0
- package/src/loaders/buildTextMap.test.ts +54 -0
- package/src/loaders/buildTextMap.ts +25 -6
- package/src/loaders/filterTextLoader.ts +1 -1
- package/src/loaders/productMediaTextLoader.ts +1 -1
- package/src/loaders/productTextLoader.ts +1 -1
- package/src/mcp/README.md +25 -0
- package/src/mcp/index.ts +313 -0
- package/src/mcp/tools/addProductAssignmentHandler.ts +118 -0
- package/src/mcp/tools/addProductMediaUploadHandler.ts +79 -0
- package/src/mcp/tools/countriesHandler.ts +60 -0
- package/src/mcp/tools/countryHandler.ts +40 -0
- package/src/mcp/tools/createLanguageHandler.ts +46 -0
- package/src/mcp/tools/createProduct.ts +75 -0
- package/src/mcp/tools/createProductVariationHandler.ts +93 -0
- package/src/mcp/tools/createProductVariationOptionHandler.ts +73 -0
- package/src/mcp/tools/currenciesHandler.ts +63 -0
- package/src/mcp/tools/currencyHandler.ts +40 -0
- package/src/mcp/tools/getProduct.ts +74 -0
- package/src/mcp/tools/index.ts +39 -0
- package/src/mcp/tools/languageHandler.ts +37 -0
- package/src/mcp/tools/languagesHandler.ts +54 -0
- package/src/mcp/tools/listProducts.ts +148 -0
- package/src/mcp/tools/productReviewsCountHandler.ts +36 -0
- package/src/mcp/tools/productReviewsHandler.ts +54 -0
- package/src/mcp/tools/productsCountHandler.ts +38 -0
- package/src/mcp/tools/publishProduct.ts +45 -0
- package/src/mcp/tools/removeLanguageHandler.ts +42 -0
- package/src/mcp/tools/removeProductAssignmentHandler.ts +61 -0
- package/src/mcp/tools/removeProductHandler.ts +40 -0
- package/src/mcp/tools/removeProductMediaHandler.ts +49 -0
- package/src/mcp/tools/removeProductVariationHandler.ts +51 -0
- package/src/mcp/tools/removeProductVariationOptionHandler.ts +58 -0
- package/src/mcp/tools/reorderProductMediaHandler.ts +48 -0
- package/src/mcp/tools/unPublishProduct.ts +46 -0
- package/src/mcp/tools/updateLanguageHandler.ts +47 -0
- package/src/mcp/tools/updateProduct.ts +51 -0
- package/src/mcp/tools/updateProductCommerceHandler.ts +79 -0
- package/src/mcp/tools/updateProductMediaTextsHandler.ts +56 -0
- package/src/mcp/tools/updateProductPlanHandler.ts +58 -0
- package/src/mcp/tools/updateProductSupplyHandler.ts +59 -0
- package/src/mcp/tools/updateProductTextsHandler.ts +59 -0
- package/src/mcp/tools/updateProductTokenizationHandler.ts +58 -0
- package/src/mcp/tools/updateProductWarehousingHandler.ts +54 -0
- package/src/mcp/utils/getNormalizedProductDetails.ts +42 -0
- package/src/mcp/utils/normalizeMediaUrl.ts +26 -0
- package/src/resolvers/mutations/products/addProductAssignment.ts +3 -0
- package/src/resolvers/queries/filters/searchAssortments.ts +0 -5
- package/src/resolvers/queries/filters/searchProducts.ts +2 -7
- package/src/roles/all.ts +1 -0
- package/src/roles/index.ts +1 -0
- package/src/roles/loggedIn.ts +1 -0
- package/lib/express/mcpHandler.d.ts.map +0 -1
- package/lib/express/mcpHandler.js +0 -68
- package/lib/express/mcpHandler.js.map +0 -1
- package/lib/fastify/index copy.d.ts.map +0 -1
- package/lib/fastify/index copy.js +0 -157
- package/lib/fastify/index copy.js.map +0 -1
- package/lib/mcp/server.d.ts +0 -4
- package/lib/mcp/server.d.ts.map +0 -1
- package/lib/mcp/server.js +0 -60
- package/lib/mcp/server.js.map +0 -1
- package/lib/mcp/types.d.ts +0 -28
- package/lib/mcp/types.d.ts.map +0 -1
- package/lib/mcp/types.js +0 -2
- package/lib/mcp/types.js.map +0 -1
- package/lib/middleware/accountLockout.d.ts.map +0 -1
- package/lib/middleware/accountLockout.js +0 -84
- package/lib/middleware/accountLockout.js.map +0 -1
- package/lib/middleware/rateLimiter.d.ts.map +0 -1
- package/lib/middleware/rateLimiter.js +0 -91
- package/lib/middleware/rateLimiter.js.map +0 -1
- package/lib/plugins/inputValidation.d.ts.map +0 -1
- package/lib/plugins/inputValidation.js +0 -95
- package/lib/plugins/inputValidation.js.map +0 -1
- package/lib/utils/inputValidation.d.ts.map +0 -1
- package/lib/utils/inputValidation.js +0 -51
- package/lib/utils/inputValidation.js.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { Product, ProductText, ProductTypes } from '@unchainedshop/core-products';
|
|
4
|
+
const productTypeKeys = Object.keys(ProductTypes) as [
|
|
5
|
+
keyof typeof ProductTypes,
|
|
6
|
+
...(keyof typeof ProductTypes)[],
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
export const CreateProductSchema = {
|
|
10
|
+
product: z.object({
|
|
11
|
+
type: z.enum(productTypeKeys).describe('Product type (e.g., "SIMPLE_PRODUCT")'),
|
|
12
|
+
tags: z.array(z.string().min(1).toLowerCase()).optional().describe('Tags (lowercased strings)'),
|
|
13
|
+
}),
|
|
14
|
+
texts: z
|
|
15
|
+
.array(
|
|
16
|
+
z.object({
|
|
17
|
+
locale: z
|
|
18
|
+
.string()
|
|
19
|
+
.min(2)
|
|
20
|
+
.describe(
|
|
21
|
+
'Locale code like "en", "de" always use locales registered in the system languages, if language explicitly provided check if it exists',
|
|
22
|
+
),
|
|
23
|
+
slug: z.string().optional().describe('URL slug'),
|
|
24
|
+
title: z.string().optional().describe('Product title'),
|
|
25
|
+
subtitle: z.string().optional().describe('Product subtitle'),
|
|
26
|
+
description: z.string().optional().describe('Markdown description'),
|
|
27
|
+
vendor: z.string().optional().describe('Vendor name'),
|
|
28
|
+
brand: z.string().optional().describe('Brand name'),
|
|
29
|
+
labels: z.array(z.string()).optional().describe('Labels or tags'),
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
.nonempty()
|
|
33
|
+
.describe('Localized product text entries'),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const CreateProductZodSchema = z.object(CreateProductSchema);
|
|
37
|
+
|
|
38
|
+
export type CreateProductParams = z.infer<typeof CreateProductZodSchema>;
|
|
39
|
+
|
|
40
|
+
export async function createProductHandler(context: Context, params: CreateProductParams) {
|
|
41
|
+
const { product, texts } = params;
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const newProduct = await context.modules.products.create(product as Product);
|
|
45
|
+
let productTexts: any[] = texts;
|
|
46
|
+
if (texts) {
|
|
47
|
+
productTexts = await context.modules.products.texts.updateTexts(
|
|
48
|
+
newProduct._id,
|
|
49
|
+
texts as unknown as ProductText[],
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: 'text' as const,
|
|
56
|
+
text: JSON.stringify({
|
|
57
|
+
product: {
|
|
58
|
+
...newProduct,
|
|
59
|
+
texts: productTexts,
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return {
|
|
67
|
+
content: [
|
|
68
|
+
{
|
|
69
|
+
type: 'text' as const,
|
|
70
|
+
text: `Error creating product: ${(error as Error).message}`,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { ProductTypes, ProductVariationType } from '@unchainedshop/core-products';
|
|
4
|
+
import { ProductNotFoundError, ProductWrongTypeError } from '../../errors.js';
|
|
5
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
6
|
+
|
|
7
|
+
const productVariationTypeKeys = Object.keys(ProductVariationType) as [
|
|
8
|
+
keyof typeof ProductVariationType,
|
|
9
|
+
...(keyof typeof ProductVariationType)[],
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export const CreateProductVariationSchema = {
|
|
13
|
+
productId: z
|
|
14
|
+
.string()
|
|
15
|
+
.min(1)
|
|
16
|
+
.describe(
|
|
17
|
+
'Product ID for which to create the variation. it should only be CONFIGURABLE_PRODUCT type product id',
|
|
18
|
+
),
|
|
19
|
+
variation: z.object({
|
|
20
|
+
key: z
|
|
21
|
+
.string()
|
|
22
|
+
.min(1)
|
|
23
|
+
.describe('unique value that is not already used as key for the products variations vector'),
|
|
24
|
+
type: z.enum(productVariationTypeKeys).describe('Product variation types'),
|
|
25
|
+
}),
|
|
26
|
+
texts: z
|
|
27
|
+
.array(
|
|
28
|
+
z.object({
|
|
29
|
+
locale: z
|
|
30
|
+
.string()
|
|
31
|
+
.min(2)
|
|
32
|
+
.describe(
|
|
33
|
+
'Locale code like "en", "de" always use locales registered in the system languages, if language explicitly provided check if it exists',
|
|
34
|
+
),
|
|
35
|
+
title: z.string().describe('variation title'),
|
|
36
|
+
subtitle: z.string().optional().describe('variation additional description'),
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
.optional(),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const CreateProductVariationZodSchema = z.object(CreateProductVariationSchema);
|
|
43
|
+
export type CreateProductVariationParams = z.infer<typeof CreateProductVariationZodSchema>;
|
|
44
|
+
|
|
45
|
+
export async function createProductVariationHandler(
|
|
46
|
+
context: Context,
|
|
47
|
+
params: CreateProductVariationParams,
|
|
48
|
+
) {
|
|
49
|
+
const { productId, variation, texts } = params;
|
|
50
|
+
const { modules } = context;
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const product = await modules.products.findProduct({ productId });
|
|
54
|
+
if (!product) throw new ProductNotFoundError({ productId });
|
|
55
|
+
|
|
56
|
+
if (product.type !== ProductTypes.ConfigurableProduct)
|
|
57
|
+
throw new ProductWrongTypeError({
|
|
58
|
+
productId,
|
|
59
|
+
received: product.type,
|
|
60
|
+
required: ProductTypes.ConfigurableProduct,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const newVariation = await modules.products.variations.create({
|
|
64
|
+
options: [],
|
|
65
|
+
productId,
|
|
66
|
+
...variation,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (texts) {
|
|
70
|
+
await modules.products.variations.texts.updateVariationTexts(newVariation._id, texts as any);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
content: [
|
|
75
|
+
{
|
|
76
|
+
type: 'text' as const,
|
|
77
|
+
text: JSON.stringify({
|
|
78
|
+
product: await getNormalizedProductDetails(productId, context),
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return {
|
|
85
|
+
content: [
|
|
86
|
+
{
|
|
87
|
+
type: 'text' as const,
|
|
88
|
+
text: `Error creating product variation: ${(error as Error).message}`,
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
4
|
+
import { ProductVariationNotFoundError } from '../../errors.js';
|
|
5
|
+
|
|
6
|
+
const ProductVariationTextInputSchema = z.object({
|
|
7
|
+
locale: z
|
|
8
|
+
.string()
|
|
9
|
+
.min(2)
|
|
10
|
+
.describe(
|
|
11
|
+
'Locale code like "en", "de" always use locales registered in the system languages, if language explicitly provided check if it exists',
|
|
12
|
+
),
|
|
13
|
+
title: z.string().describe('variation option title in the specified locale'),
|
|
14
|
+
subtitle: z.string().optional().describe('variation option subtitle in the specified locale'),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const CreateProductVariationOptionSchema = {
|
|
18
|
+
productVariationId: z
|
|
19
|
+
.string()
|
|
20
|
+
.min(1)
|
|
21
|
+
.describe('ID of the product variation, it should only be a CONFIGURABLE_PRODUCT type ID'),
|
|
22
|
+
option: z.string().min(1).describe('Name of the new option (e.g., "Red")'),
|
|
23
|
+
texts: z.array(ProductVariationTextInputSchema),
|
|
24
|
+
};
|
|
25
|
+
export const CreateProductVariationOptionZodSchema = z.object(CreateProductVariationOptionSchema);
|
|
26
|
+
export type CreateProductVariationOptionParams = z.infer<typeof CreateProductVariationOptionZodSchema>;
|
|
27
|
+
|
|
28
|
+
export async function createProductVariationOptionHandler(
|
|
29
|
+
context: Context,
|
|
30
|
+
params: CreateProductVariationOptionParams,
|
|
31
|
+
) {
|
|
32
|
+
const { productVariationId, option, texts } = params;
|
|
33
|
+
const { modules } = context;
|
|
34
|
+
try {
|
|
35
|
+
const variation = await modules.products.variations.findProductVariation({
|
|
36
|
+
productVariationId,
|
|
37
|
+
});
|
|
38
|
+
if (!variation) throw new ProductVariationNotFoundError({ productVariationId });
|
|
39
|
+
|
|
40
|
+
const newOption = await modules.products.variations.addVariationOption(productVariationId, {
|
|
41
|
+
value: option,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (texts) {
|
|
45
|
+
await modules.products.variations.texts.updateVariationTexts(
|
|
46
|
+
productVariationId,
|
|
47
|
+
texts as any,
|
|
48
|
+
option,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: 'text' as const,
|
|
56
|
+
text: JSON.stringify({
|
|
57
|
+
variation: newOption,
|
|
58
|
+
product: await getNormalizedProductDetails(newOption?.productId, context),
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return {
|
|
65
|
+
content: [
|
|
66
|
+
{
|
|
67
|
+
type: 'text' as const,
|
|
68
|
+
text: `Error creating variation option: ${(error as Error).message}`,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { SortDirection } from '@unchainedshop/utils';
|
|
4
|
+
|
|
5
|
+
const sortDirectionKeys = Object.keys(SortDirection) as [
|
|
6
|
+
keyof typeof SortDirection,
|
|
7
|
+
...(keyof typeof SortDirection)[],
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export const ListCurrenciesSchema = {
|
|
11
|
+
limit: z.number().int().min(1).max(100).default(50),
|
|
12
|
+
offset: z.number().int().min(0).default(0),
|
|
13
|
+
includeInactive: z.boolean().default(false),
|
|
14
|
+
queryString: z.string().min(1).optional(),
|
|
15
|
+
sort: z
|
|
16
|
+
.array(
|
|
17
|
+
z.object({
|
|
18
|
+
key: z.string().min(1),
|
|
19
|
+
value: z.enum(sortDirectionKeys).describe("Sort direction, e.g., 'ASC' or 'DESC'"),
|
|
20
|
+
}),
|
|
21
|
+
)
|
|
22
|
+
.optional(),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const ListCurrenciesZodSchema = z.object(ListCurrenciesSchema);
|
|
26
|
+
|
|
27
|
+
export type ListCurrenciesParams = z.infer<typeof ListCurrenciesZodSchema>;
|
|
28
|
+
|
|
29
|
+
export async function currenciesHandler(context: Context, params: ListCurrenciesParams) {
|
|
30
|
+
const { limit, offset, includeInactive, queryString, sort } = params;
|
|
31
|
+
|
|
32
|
+
const { modules } = context;
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const currencies = await modules.currencies.findCurrencies({
|
|
36
|
+
limit,
|
|
37
|
+
offset,
|
|
38
|
+
includeInactive,
|
|
39
|
+
queryString,
|
|
40
|
+
sort: sort as any[],
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
content: [
|
|
45
|
+
{
|
|
46
|
+
type: 'text' as const,
|
|
47
|
+
text: JSON.stringify({
|
|
48
|
+
currencies,
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: 'text' as const,
|
|
58
|
+
text: `Error retrieving currencies: ${(error as Error).message}`,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { CurrencyNotFoundError } from '../../errors.js';
|
|
4
|
+
|
|
5
|
+
export const CurrencySchema = {
|
|
6
|
+
currencyId: z.string().min(1).describe('The ID of the currency to fetch'),
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const CurrencyZodSchema = z.object(CurrencySchema);
|
|
10
|
+
|
|
11
|
+
export type CurrencyParams = z.infer<typeof CurrencyZodSchema>;
|
|
12
|
+
|
|
13
|
+
export async function currencyHandler(context: Context, params: CurrencyParams) {
|
|
14
|
+
const { currencyId } = params;
|
|
15
|
+
const { modules } = context;
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const currency = await modules.currencies.findCurrency({ currencyId });
|
|
19
|
+
|
|
20
|
+
if (!currency) throw new CurrencyNotFoundError({ currencyId });
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: 'text' as const,
|
|
26
|
+
text: JSON.stringify({ currency }),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
content: [
|
|
33
|
+
{
|
|
34
|
+
type: 'text' as const,
|
|
35
|
+
text: `Error retrieving currency: ${(error as Error).message}`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Zod schema for the get_product tool (as raw object for MCP)
|
|
7
|
+
*/
|
|
8
|
+
export const GetProductSchema = {
|
|
9
|
+
productId: z.string().optional().describe('Product ID for lookup'),
|
|
10
|
+
slug: z.string().optional().describe('Product slug for lookup'),
|
|
11
|
+
sku: z.string().optional().describe('Product SKU for lookup'),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Zod object schema for type inference and validation
|
|
16
|
+
*/
|
|
17
|
+
export const GetProductZodSchema = z
|
|
18
|
+
.object(GetProductSchema)
|
|
19
|
+
.refine(
|
|
20
|
+
(data) => data.productId || data.slug || data.sku,
|
|
21
|
+
'At least one of productId, slug, or sku must be provided',
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Interface for the get_product tool parameters
|
|
26
|
+
*/
|
|
27
|
+
export type GetProductParams = z.infer<typeof GetProductZodSchema>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Implementation of the get_product tool
|
|
31
|
+
*/
|
|
32
|
+
export async function getProductHandler(context: Context, params: GetProductParams) {
|
|
33
|
+
const { productId, slug, sku } = params;
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
// Find the product
|
|
37
|
+
const product = await context.modules.products.findProduct({
|
|
38
|
+
productId,
|
|
39
|
+
slug,
|
|
40
|
+
sku,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (!product) {
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: 'text' as const,
|
|
48
|
+
text: `Product not found with ${productId ? `ID: ${productId}` : slug ? `slug: ${slug}` : `SKU: ${sku}`}`,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: 'text' as const,
|
|
58
|
+
text: JSON.stringify({
|
|
59
|
+
product: await getNormalizedProductDetails(productId, context),
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
content: [
|
|
67
|
+
{
|
|
68
|
+
type: 'text' as const,
|
|
69
|
+
text: `Error getting product: ${(error as Error).message}`,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export all MCP tools
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from './listProducts.js';
|
|
6
|
+
export * from './getProduct.js';
|
|
7
|
+
export * from './createProduct.js';
|
|
8
|
+
export * from './removeProductHandler.js';
|
|
9
|
+
export * from './publishProduct.js';
|
|
10
|
+
export * from './unPublishProduct.js';
|
|
11
|
+
export * from './updateProduct.js';
|
|
12
|
+
export * from './updateProductTextsHandler.js';
|
|
13
|
+
export * from './updateProductCommerceHandler.js';
|
|
14
|
+
export * from './updateProductSupplyHandler.js';
|
|
15
|
+
export * from './updateProductWarehousingHandler.js';
|
|
16
|
+
export * from './currenciesHandler.js';
|
|
17
|
+
export * from './currencyHandler.js';
|
|
18
|
+
export * from './countriesHandler.js';
|
|
19
|
+
export * from './countryHandler.js';
|
|
20
|
+
export * from './languagesHandler.js';
|
|
21
|
+
export * from './languageHandler.js';
|
|
22
|
+
export * from './updateProductPlanHandler.js';
|
|
23
|
+
export * from './updateProductTokenizationHandler.js';
|
|
24
|
+
export * from './productsCountHandler.js';
|
|
25
|
+
export * from './createProductVariationHandler.js';
|
|
26
|
+
export * from './removeProductVariationHandler.js';
|
|
27
|
+
export * from './addProductAssignmentHandler.js';
|
|
28
|
+
export * from './createProductVariationOptionHandler.js';
|
|
29
|
+
export * from './removeProductAssignmentHandler.js';
|
|
30
|
+
export * from './removeProductVariationOptionHandler.js';
|
|
31
|
+
export * from './createLanguageHandler.js';
|
|
32
|
+
export * from './updateLanguageHandler.js';
|
|
33
|
+
export * from './removeLanguageHandler.js';
|
|
34
|
+
export * from './addProductMediaUploadHandler.js';
|
|
35
|
+
export * from './removeProductMediaHandler.js';
|
|
36
|
+
export * from './updateProductMediaTextsHandler.js';
|
|
37
|
+
export * from './reorderProductMediaHandler.js';
|
|
38
|
+
export * from './productReviewsCountHandler.js';
|
|
39
|
+
export * from './productReviewsHandler.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
|
|
4
|
+
export const LanguageSchema = {
|
|
5
|
+
languageId: z.string().min(1).describe('The ID of the language to fetch'),
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const LanguageZodSchema = z.object(LanguageSchema);
|
|
9
|
+
|
|
10
|
+
export type LanguageParams = z.infer<typeof LanguageZodSchema>;
|
|
11
|
+
|
|
12
|
+
export async function languageHandler(context: Context, params: LanguageParams) {
|
|
13
|
+
const { languageId } = params;
|
|
14
|
+
const { modules } = context;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const language = await modules.languages.findLanguage({ languageId });
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
content: [
|
|
21
|
+
{
|
|
22
|
+
type: 'text' as const,
|
|
23
|
+
text: JSON.stringify({ language }),
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return {
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: 'text' as const,
|
|
32
|
+
text: `Error retrieving language: ${(error as Error).message}`,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { SortDirection } from '@unchainedshop/utils';
|
|
4
|
+
|
|
5
|
+
const sortDirectionKeys = Object.keys(SortDirection) as [
|
|
6
|
+
keyof typeof SortDirection,
|
|
7
|
+
...(keyof typeof SortDirection)[],
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export const ListLanguagesSchema = {
|
|
11
|
+
limit: z.number().int().min(1).max(100).default(50),
|
|
12
|
+
offset: z.number().int().min(0).default(0),
|
|
13
|
+
includeInactive: z.boolean().default(false),
|
|
14
|
+
queryString: z.string().min(1).optional(),
|
|
15
|
+
sort: z
|
|
16
|
+
.array(
|
|
17
|
+
z.object({
|
|
18
|
+
key: z.string().min(1),
|
|
19
|
+
value: z.enum(sortDirectionKeys).describe("Sort direction, e.g., 'ASC' or 'DESC'"),
|
|
20
|
+
}),
|
|
21
|
+
)
|
|
22
|
+
.optional(),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const ListLanguagesZodSchema = z.object(ListLanguagesSchema);
|
|
26
|
+
|
|
27
|
+
export type ListLanguagesParams = z.infer<typeof ListLanguagesZodSchema>;
|
|
28
|
+
|
|
29
|
+
export async function languagesHandler(context: Context, params: ListLanguagesParams) {
|
|
30
|
+
const { sort, ...restParams } = params;
|
|
31
|
+
const { modules } = context;
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const languages = await modules.languages.findLanguages({ ...restParams, sort: sort as any[] });
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
type: 'text' as const,
|
|
40
|
+
text: JSON.stringify({ languages }),
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
} catch (error) {
|
|
45
|
+
return {
|
|
46
|
+
content: [
|
|
47
|
+
{
|
|
48
|
+
type: 'text' as const,
|
|
49
|
+
text: `Error retrieving languages: ${(error as Error).message}`,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SortDirection } from '@unchainedshop/utils';
|
|
3
|
+
import { Context } from '../../context.js';
|
|
4
|
+
import { ProductText } from '@unchainedshop/core-products';
|
|
5
|
+
import normalizeMediaUrl from '../utils/normalizeMediaUrl.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Zod schema for the list_products tool (as raw object for MCP)
|
|
9
|
+
*/
|
|
10
|
+
export const ListProductsSchema = {
|
|
11
|
+
// Search & Filter
|
|
12
|
+
queryString: z.string().optional().describe('Text search across product fields'),
|
|
13
|
+
tags: z.array(z.string()).optional().describe('Filter by product tags'),
|
|
14
|
+
productIds: z.array(z.string()).optional().describe('Filter by specific product IDs'),
|
|
15
|
+
filterQuery: z
|
|
16
|
+
.array(
|
|
17
|
+
z.object({
|
|
18
|
+
key: z.string().describe('Filter key'),
|
|
19
|
+
value: z.string().optional().describe('Filter value'),
|
|
20
|
+
}),
|
|
21
|
+
)
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Key-value filter pairs'),
|
|
24
|
+
assortmentId: z.string().optional().describe('Filter by assortment'),
|
|
25
|
+
includeInactive: z.boolean().default(false).describe('Include inactive products'),
|
|
26
|
+
|
|
27
|
+
// Pagination
|
|
28
|
+
limit: z.number().min(1).max(100).default(20).describe('Results per page'),
|
|
29
|
+
offset: z.number().min(0).default(0).describe('Skip results for pagination'),
|
|
30
|
+
|
|
31
|
+
// Sorting
|
|
32
|
+
sort: z
|
|
33
|
+
.array(
|
|
34
|
+
z.object({
|
|
35
|
+
key: z.string().describe('Sort field'),
|
|
36
|
+
value: z.enum(['ASC', 'DESC']).describe('Sort direction'),
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
.optional()
|
|
40
|
+
.describe('Sort options'),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Zod object schema for type inference
|
|
45
|
+
*/
|
|
46
|
+
export const ListProductsZodSchema = z.object(ListProductsSchema);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Interface for the list_products tool parameters
|
|
50
|
+
*/
|
|
51
|
+
export type ListProductsParams = z.infer<typeof ListProductsZodSchema>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Implementation of the list_products tool
|
|
55
|
+
*/
|
|
56
|
+
export async function listProductsHandler(context: Context, params: ListProductsParams) {
|
|
57
|
+
const {
|
|
58
|
+
queryString,
|
|
59
|
+
tags,
|
|
60
|
+
productIds,
|
|
61
|
+
filterQuery,
|
|
62
|
+
assortmentId,
|
|
63
|
+
includeInactive = false,
|
|
64
|
+
limit = 20,
|
|
65
|
+
offset = 0,
|
|
66
|
+
sort,
|
|
67
|
+
} = params;
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
let filteredProductIds = productIds;
|
|
71
|
+
|
|
72
|
+
// If assortmentId is provided, get product IDs from assortment
|
|
73
|
+
if (assortmentId) {
|
|
74
|
+
const assortmentProductIds = await context.modules.assortments.products.findProductIds({
|
|
75
|
+
assortmentId,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (filteredProductIds) {
|
|
79
|
+
// Intersection of both sets
|
|
80
|
+
filteredProductIds = filteredProductIds.filter((id) => assortmentProductIds.includes(id));
|
|
81
|
+
} else {
|
|
82
|
+
filteredProductIds = assortmentProductIds;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let searchResult: any = {};
|
|
87
|
+
if (queryString)
|
|
88
|
+
searchResult = await context.services.filters.searchProducts(
|
|
89
|
+
{
|
|
90
|
+
queryString,
|
|
91
|
+
productIds: filteredProductIds,
|
|
92
|
+
includeInactive,
|
|
93
|
+
filterQuery: filterQuery?.filter((f) => f.key) as { key: string; value?: string }[],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
locale: context.locale,
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
const products = await context.modules.products.findProducts({
|
|
100
|
+
productIds: searchResult?.aggregatedFilteredProductIds,
|
|
101
|
+
tags,
|
|
102
|
+
limit,
|
|
103
|
+
offset,
|
|
104
|
+
includeDrafts: includeInactive,
|
|
105
|
+
sort: sort?.filter((s) => s.key) as { key: string; value: SortDirection }[],
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const productTexts = await context.loaders.productTextLoader.loadMany(
|
|
109
|
+
products.map(({ _id }) => ({
|
|
110
|
+
productId: _id,
|
|
111
|
+
locale: context.locale,
|
|
112
|
+
})),
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// iterate all products and add texts
|
|
116
|
+
const normalizedProducts = await Promise.all(
|
|
117
|
+
products.map(async (product) => {
|
|
118
|
+
const texts = productTexts.filter((text) => (text as ProductText).productId === product._id);
|
|
119
|
+
const productMedias = await context.modules.products.media.findProductMedias({
|
|
120
|
+
productId: product._id,
|
|
121
|
+
});
|
|
122
|
+
const media = await normalizeMediaUrl(productMedias, context);
|
|
123
|
+
return {
|
|
124
|
+
...product,
|
|
125
|
+
texts,
|
|
126
|
+
media,
|
|
127
|
+
};
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
content: [
|
|
133
|
+
{
|
|
134
|
+
type: 'text' as const,
|
|
135
|
+
text: JSON.stringify({
|
|
136
|
+
products: normalizedProducts,
|
|
137
|
+
total: searchResult?.aggregatedTotalProductIds?.length,
|
|
138
|
+
filtered: searchResult?.aggregatedFilteredProductIds?.length || products?.length,
|
|
139
|
+
}),
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
} catch (error) {
|
|
144
|
+
return {
|
|
145
|
+
content: [{ type: 'text' as const, text: `Error listing products: ${(error as Error).message}` }],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|