@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,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
4
|
+
|
|
5
|
+
export const UpdateProductCommerceSchema = {
|
|
6
|
+
productId: z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.describe('ID of the product of all type except for CONFIGURABLE_PRODUCT to update commerce info'),
|
|
10
|
+
commerce: z
|
|
11
|
+
.object({
|
|
12
|
+
pricing: z
|
|
13
|
+
.array(
|
|
14
|
+
z.object({
|
|
15
|
+
amount: z.number().int().describe('Price amount in smallest currency unit (e.g., cents)'),
|
|
16
|
+
maxQuantity: z
|
|
17
|
+
.number()
|
|
18
|
+
.int()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Optional maximum quantity for this price tier'),
|
|
21
|
+
isTaxable: z.boolean().optional().describe('Whether tax applies to this price'),
|
|
22
|
+
isNetPrice: z.boolean().optional().describe('Whether this is a net price (without tax)'),
|
|
23
|
+
currencyCode: z
|
|
24
|
+
.string()
|
|
25
|
+
.min(3)
|
|
26
|
+
.max(3)
|
|
27
|
+
.describe(
|
|
28
|
+
'ISO currency code (e.g., USD, EUR) always use values registered in the system and if explicitly provided check if it exists',
|
|
29
|
+
),
|
|
30
|
+
countryCode: z
|
|
31
|
+
.string()
|
|
32
|
+
.min(2)
|
|
33
|
+
.max(2)
|
|
34
|
+
.describe(
|
|
35
|
+
'ISO country code (e.g., US, DE) always use values registered in the system and if explicitly provided check if it exists',
|
|
36
|
+
),
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
.nonempty()
|
|
40
|
+
.describe('List of price configurations'),
|
|
41
|
+
})
|
|
42
|
+
.describe('Commerce info to update'),
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const UpdateProductCommerceZodSchema = z.object(UpdateProductCommerceSchema);
|
|
46
|
+
|
|
47
|
+
export type UpdateProductCommerceParams = z.infer<typeof UpdateProductCommerceZodSchema>;
|
|
48
|
+
|
|
49
|
+
export async function updateProductCommerceHandler(
|
|
50
|
+
context: Context,
|
|
51
|
+
params: UpdateProductCommerceParams,
|
|
52
|
+
) {
|
|
53
|
+
const { productId, commerce } = params;
|
|
54
|
+
const { modules } = context;
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
await modules.products.update(productId, { commerce });
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text' as const,
|
|
63
|
+
text: JSON.stringify({
|
|
64
|
+
product: await getNormalizedProductDetails(productId, context),
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
} catch (error) {
|
|
70
|
+
return {
|
|
71
|
+
content: [
|
|
72
|
+
{
|
|
73
|
+
type: 'text' as const,
|
|
74
|
+
text: `Error updating product commerce info: ${(error as Error).message}`,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { ProductMediaNotFoundError } from '../../errors.js';
|
|
4
|
+
|
|
5
|
+
export const UpdateProductMediaTextsSchema = {
|
|
6
|
+
productMediaId: z.string().min(1).describe('ID of the media asset to update'),
|
|
7
|
+
texts: z
|
|
8
|
+
.array(
|
|
9
|
+
z.object({
|
|
10
|
+
locale: z.string().min(2).describe('Locale of the text, e.g. "en", "fr", etc.'),
|
|
11
|
+
title: z.string().optional().describe('Title in the given locale'),
|
|
12
|
+
subtitle: z.string().optional().describe('Subtitle in the given locale'),
|
|
13
|
+
}),
|
|
14
|
+
)
|
|
15
|
+
.min(1)
|
|
16
|
+
.describe('List of localized texts to update'),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const UpdateProductMediaTextsZodSchema = z.object(UpdateProductMediaTextsSchema);
|
|
20
|
+
|
|
21
|
+
export type UpdateProductMediaTextsParams = z.infer<typeof UpdateProductMediaTextsZodSchema>;
|
|
22
|
+
|
|
23
|
+
export async function updateProductMediaTextsHandler(
|
|
24
|
+
context: Context,
|
|
25
|
+
params: UpdateProductMediaTextsParams,
|
|
26
|
+
) {
|
|
27
|
+
const { productMediaId, texts } = params;
|
|
28
|
+
const { modules } = context;
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const productMedia = await modules.products.media.findProductMedia({
|
|
32
|
+
productMediaId,
|
|
33
|
+
});
|
|
34
|
+
if (!productMedia) throw new ProductMediaNotFoundError({ productMediaId });
|
|
35
|
+
|
|
36
|
+
const updatedTexts = await modules.products.media.texts.updateMediaTexts(productMediaId, texts);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'text' as const,
|
|
42
|
+
text: JSON.stringify({ texts: updatedTexts }),
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: 'text' as const,
|
|
51
|
+
text: `Error updating product media texts: ${(error as Error).message}`,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { ProductNotFoundError, ProductWrongStatusError } from '../../errors.js';
|
|
4
|
+
import { ProductTypes } from '@unchainedshop/core-products';
|
|
5
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
6
|
+
|
|
7
|
+
export const UpdateProductPlanSchema = {
|
|
8
|
+
productId: z.string().min(1).describe('ID of the product of type PLAN_PRODUCT to update only'),
|
|
9
|
+
plan: z.object({
|
|
10
|
+
usageCalculationType: z.string(),
|
|
11
|
+
billingInterval: z.string(),
|
|
12
|
+
billingIntervalCount: z.number().int().positive().optional(),
|
|
13
|
+
trialInterval: z.string().optional(),
|
|
14
|
+
trialIntervalCount: z.number().int().positive().optional(),
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const UpdateProductPlanZodSchema = z.object(UpdateProductPlanSchema);
|
|
19
|
+
|
|
20
|
+
export type UpdateProductPlanParams = z.infer<typeof UpdateProductPlanZodSchema>;
|
|
21
|
+
|
|
22
|
+
export async function updateProductPlanHandler(context: Context, params: UpdateProductPlanParams) {
|
|
23
|
+
const { productId, plan } = params;
|
|
24
|
+
const { modules } = context;
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const product = await modules.products.findProduct({ productId });
|
|
28
|
+
if (!product) throw new ProductNotFoundError({ productId });
|
|
29
|
+
|
|
30
|
+
if (product?.type !== ProductTypes.PlanProduct)
|
|
31
|
+
throw new ProductWrongStatusError({
|
|
32
|
+
received: product?.type,
|
|
33
|
+
required: ProductTypes.PlanProduct,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await modules.products.update(productId, { plan });
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'text' as const,
|
|
42
|
+
text: JSON.stringify({
|
|
43
|
+
product: await getNormalizedProductDetails(productId, context),
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
content: [
|
|
51
|
+
{
|
|
52
|
+
type: 'text' as const,
|
|
53
|
+
text: `Error updating product plan: ${(error as Error).message}`,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { ProductWrongTypeError } from '../../errors.js';
|
|
4
|
+
import { ProductTypes } from '@unchainedshop/core-products';
|
|
5
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
6
|
+
|
|
7
|
+
export const UpdateProductSupplySchema = {
|
|
8
|
+
productId: z
|
|
9
|
+
.string()
|
|
10
|
+
.min(1)
|
|
11
|
+
.describe('Product ID of a SIMPLE_PRODUCT only to update supply details for'),
|
|
12
|
+
supply: z
|
|
13
|
+
.object({
|
|
14
|
+
weightInGram: z.number().int().positive().optional(),
|
|
15
|
+
heightInMillimeters: z.number().int().positive().optional(),
|
|
16
|
+
lengthInMillimeters: z.number().int().positive().optional(),
|
|
17
|
+
widthInMillimeters: z.number().int().positive().optional(),
|
|
18
|
+
})
|
|
19
|
+
.describe('Supply (delivery) attributes of the product'),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const UpdateProductSupplyZodSchema = z.object(UpdateProductSupplySchema);
|
|
23
|
+
|
|
24
|
+
export type UpdateProductSupplyParams = z.infer<typeof UpdateProductSupplyZodSchema>;
|
|
25
|
+
|
|
26
|
+
export async function updateProductSupplyHandler(context: Context, params: UpdateProductSupplyParams) {
|
|
27
|
+
const { productId, supply } = params;
|
|
28
|
+
const { modules } = context;
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const product = await modules.products.findProduct({ productId });
|
|
32
|
+
if (product?.type !== ProductTypes.SimpleProduct)
|
|
33
|
+
throw new ProductWrongTypeError({
|
|
34
|
+
productId,
|
|
35
|
+
received: product?.type,
|
|
36
|
+
required: ProductTypes.SimpleProduct,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await modules.products.update(productId, { supply });
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: 'text' as const,
|
|
45
|
+
text: JSON.stringify({ product: await getNormalizedProductDetails(productId, context) }),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
} catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: 'text' as const,
|
|
54
|
+
text: `Error updating product supply: ${(error as Error).message}`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
4
|
+
|
|
5
|
+
export const UpdateProductTextsSchema = {
|
|
6
|
+
productId: z.string().min(1).describe('ID of the product to update texts for'),
|
|
7
|
+
texts: z
|
|
8
|
+
.array(
|
|
9
|
+
z.object({
|
|
10
|
+
locale: z
|
|
11
|
+
.string()
|
|
12
|
+
.min(2)
|
|
13
|
+
.describe(
|
|
14
|
+
'Locale code like "en", "de" always use locales registered in the system languages, if explicitly provided check if it exists',
|
|
15
|
+
),
|
|
16
|
+
slug: z.string().optional().describe('URL slug'),
|
|
17
|
+
title: z.string().optional().describe('Product title'),
|
|
18
|
+
subtitle: z.string().optional().describe('Product subtitle'),
|
|
19
|
+
description: z.string().optional().describe('Markdown description'),
|
|
20
|
+
vendor: z.string().optional().describe('Vendor name'),
|
|
21
|
+
brand: z.string().optional().describe('Brand name'),
|
|
22
|
+
labels: z.array(z.string()).optional().describe('Labels or tags'),
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
25
|
+
.nonempty()
|
|
26
|
+
.describe('Localized product text entries'),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const UpdateProductTextsZodSchema = z.object(UpdateProductTextsSchema);
|
|
30
|
+
|
|
31
|
+
export type UpdateProductTextsParams = z.infer<typeof UpdateProductTextsZodSchema>;
|
|
32
|
+
|
|
33
|
+
export async function updateProductTextsHandler(context: Context, params: UpdateProductTextsParams) {
|
|
34
|
+
const { productId, texts } = params;
|
|
35
|
+
const { modules } = context;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
await modules.products.texts.updateTexts(productId, texts as any[]);
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: 'text' as const,
|
|
43
|
+
text: JSON.stringify({
|
|
44
|
+
product: await getNormalizedProductDetails(productId, context),
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
} catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: 'text' as const,
|
|
54
|
+
text: `Error updating product texts: ${(error as Error).message}`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { ProductTypes } from '@unchainedshop/core-products';
|
|
4
|
+
import { ProductNotFoundError, ProductWrongStatusError } from '../../errors.js';
|
|
5
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
6
|
+
|
|
7
|
+
export const UpdateProductTokenizationSchema = {
|
|
8
|
+
productId: z.string().min(1).describe('ID of the product of type TOKENIZED_PRODUCT to tokenize only'),
|
|
9
|
+
tokenization: z.object({
|
|
10
|
+
contractAddress: z.string().min(1),
|
|
11
|
+
contractStandard: z.string(),
|
|
12
|
+
tokenId: z.string().min(1),
|
|
13
|
+
supply: z.number().int().positive(),
|
|
14
|
+
ercMetadataProperties: z.record(z.any()).optional(),
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const UpdateProductTokenizationZodSchema = z.object(UpdateProductTokenizationSchema);
|
|
19
|
+
export type UpdateProductTokenizationParams = z.infer<typeof UpdateProductTokenizationZodSchema>;
|
|
20
|
+
|
|
21
|
+
export async function updateProductTokenizationHandler(
|
|
22
|
+
context: Context,
|
|
23
|
+
params: UpdateProductTokenizationParams,
|
|
24
|
+
) {
|
|
25
|
+
const { productId, tokenization } = params;
|
|
26
|
+
const { modules } = context;
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const product = await modules.products.findProduct({ productId });
|
|
30
|
+
if (!product) throw new ProductNotFoundError({ productId });
|
|
31
|
+
|
|
32
|
+
if (product?.type !== ProductTypes.TokenizedProduct)
|
|
33
|
+
throw new ProductWrongStatusError({
|
|
34
|
+
received: product?.type,
|
|
35
|
+
required: ProductTypes.TokenizedProduct,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await modules.products.update(productId, { tokenization });
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
content: [
|
|
42
|
+
{
|
|
43
|
+
type: 'text' as const,
|
|
44
|
+
text: JSON.stringify({ product: await getNormalizedProductDetails(productId, context) }),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
content: [
|
|
51
|
+
{
|
|
52
|
+
type: 'text' as const,
|
|
53
|
+
text: `Error updating product tokenization: ${(error as Error).message}`,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { ProductWrongTypeError } from '../../errors.js';
|
|
4
|
+
import { ProductTypes } from '@unchainedshop/core-products';
|
|
5
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
6
|
+
|
|
7
|
+
export const UpdateProductWarehousingSchema = {
|
|
8
|
+
productId: z.string().min(1).describe('ID of the SIMPLE_PRODUCT product type to update to be updated'),
|
|
9
|
+
warehousing: z.object({
|
|
10
|
+
sku: z.string().min(1).optional().describe('Stock keeping unit'),
|
|
11
|
+
baseUnit: z.string().min(1).optional().describe('Base unit of the product (e.g., "piece", "kg")'),
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const UpdateProductWarehousingZodSchema = z.object(UpdateProductWarehousingSchema);
|
|
16
|
+
|
|
17
|
+
export type UpdateProductWarehousingParams = z.infer<typeof UpdateProductWarehousingZodSchema>;
|
|
18
|
+
|
|
19
|
+
export async function updateProductWarehousingHandler(
|
|
20
|
+
context: Context,
|
|
21
|
+
params: UpdateProductWarehousingParams,
|
|
22
|
+
) {
|
|
23
|
+
const { productId, warehousing } = params;
|
|
24
|
+
const { modules } = context;
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const product = await modules.products.findProduct({ productId });
|
|
28
|
+
if (product?.type !== ProductTypes.SimpleProduct)
|
|
29
|
+
throw new ProductWrongTypeError({
|
|
30
|
+
productId,
|
|
31
|
+
received: product.type,
|
|
32
|
+
required: ProductTypes.SimpleProduct,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
await modules.products.update(productId, { warehousing });
|
|
36
|
+
return {
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
type: 'text' as const,
|
|
40
|
+
text: JSON.stringify({ product: await getNormalizedProductDetails(productId, context) }),
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
} catch (error) {
|
|
45
|
+
return {
|
|
46
|
+
content: [
|
|
47
|
+
{
|
|
48
|
+
type: 'text' as const,
|
|
49
|
+
text: `Error updating product warehousing: ${(error as Error).message}`,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ProductTypes } from '@unchainedshop/core-products';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import normalizeMediaUrl from './normalizeMediaUrl.js';
|
|
4
|
+
|
|
5
|
+
export async function getNormalizedProductDetails(productId: string, context: Context) {
|
|
6
|
+
const { modules, locale, loaders } = context;
|
|
7
|
+
const product = await modules.products.findProduct({ productId });
|
|
8
|
+
|
|
9
|
+
if (!product) return null;
|
|
10
|
+
|
|
11
|
+
const texts = await loaders.productTextLoader.load({
|
|
12
|
+
productId,
|
|
13
|
+
locale,
|
|
14
|
+
});
|
|
15
|
+
let variations = [];
|
|
16
|
+
if (product.type === ProductTypes.ConfigurableProduct)
|
|
17
|
+
variations = await context.modules.products.variations.findProductVariations({
|
|
18
|
+
productId: product._id,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Get pricing information
|
|
22
|
+
let pricing = null;
|
|
23
|
+
try {
|
|
24
|
+
pricing = await context.modules.products.prices.price(product, {
|
|
25
|
+
countryCode: context.countryCode,
|
|
26
|
+
});
|
|
27
|
+
} catch {
|
|
28
|
+
// Pricing might not be available for all products
|
|
29
|
+
console.warn('Pricing not available for product:', product._id);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const productMedias = await modules.products.media.findProductMedias({ productId });
|
|
33
|
+
const media = await normalizeMediaUrl(productMedias, context);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
...product,
|
|
37
|
+
texts,
|
|
38
|
+
media,
|
|
39
|
+
variations,
|
|
40
|
+
pricing,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getFileAdapter } from '@unchainedshop/core-files';
|
|
2
|
+
|
|
3
|
+
const normalizeMediaUrl = async (medias = [], context) => {
|
|
4
|
+
if (medias?.length) {
|
|
5
|
+
const normalizedMedias = await Promise.all(
|
|
6
|
+
medias.map(async (media) => {
|
|
7
|
+
const file = await context.loaders.fileLoader.load({
|
|
8
|
+
fileId: media.mediaId,
|
|
9
|
+
});
|
|
10
|
+
const fileUploadAdapter = getFileAdapter();
|
|
11
|
+
const url = await fileUploadAdapter.createDownloadURL(file);
|
|
12
|
+
file.url = context.modules.files.normalizeUrl(url, {});
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
...media,
|
|
16
|
+
file,
|
|
17
|
+
};
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
return normalizedMedias.filter(Boolean);
|
|
22
|
+
}
|
|
23
|
+
return medias;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default normalizeMediaUrl;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
ProductWrongTypeError,
|
|
10
10
|
ProductVariationVectorInvalid,
|
|
11
11
|
ProductVariationVectorAlreadySet,
|
|
12
|
+
ProductVariationInfinityLoop,
|
|
12
13
|
} from '../../../errors.js';
|
|
13
14
|
const extractVariationMatrix = (variations = []) => {
|
|
14
15
|
const cartesianProduct = (arrays) => {
|
|
@@ -61,6 +62,8 @@ export default async function addProductAssignment(
|
|
|
61
62
|
});
|
|
62
63
|
if (!proxyProduct) throw new ProductNotFoundError({ proxyId });
|
|
63
64
|
|
|
65
|
+
if (productId === proxyId) throw new ProductVariationInfinityLoop({ productId });
|
|
66
|
+
|
|
64
67
|
if (proxyProduct.type !== ProductTypes.ConfigurableProduct)
|
|
65
68
|
throw new ProductWrongTypeError({
|
|
66
69
|
proxyId,
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { Context } from '../../../context.js';
|
|
2
2
|
import { SearchQuery } from '@unchainedshop/core-filters';
|
|
3
3
|
import { log } from '@unchainedshop/logger';
|
|
4
|
-
import { QueryStringRequiredError } from '../../../errors.js';
|
|
5
4
|
|
|
6
5
|
export default async function searchAssortments(root: never, query: SearchQuery, context: Context) {
|
|
7
6
|
const { services, userId, locale } = context;
|
|
8
|
-
const forceLiveCollection = false;
|
|
9
7
|
|
|
10
8
|
log(`query search assortments ${JSON.stringify(query)}`, { userId });
|
|
11
9
|
|
|
12
|
-
if (!query.queryString && !query.assortmentIds?.length) throw new QueryStringRequiredError({});
|
|
13
|
-
|
|
14
10
|
return services.filters.searchAssortments(query, {
|
|
15
|
-
forceLiveCollection,
|
|
16
11
|
locale,
|
|
17
12
|
});
|
|
18
13
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
2
|
import { SearchFilterQuery } from '@unchainedshop/core-filters';
|
|
3
|
-
import { QueryStringRequiredError } from '../../../errors.js';
|
|
4
3
|
import { Context } from '../../../context.js';
|
|
5
4
|
|
|
6
5
|
export default async function searchProducts(
|
|
@@ -16,7 +15,6 @@ export default async function searchProducts(
|
|
|
16
15
|
context: Context,
|
|
17
16
|
) {
|
|
18
17
|
const { modules, services, userId, locale } = context;
|
|
19
|
-
const forceLiveCollection = false;
|
|
20
18
|
const { queryString, includeInactive, filterQuery, assortmentId, ignoreChildAssortments, ...rest } =
|
|
21
19
|
query;
|
|
22
20
|
|
|
@@ -25,7 +23,6 @@ export default async function searchProducts(
|
|
|
25
23
|
if (assortmentId) {
|
|
26
24
|
const productIds = await modules.assortments.findProductIds({
|
|
27
25
|
assortmentId,
|
|
28
|
-
forceLiveCollection,
|
|
29
26
|
ignoreChildAssortments,
|
|
30
27
|
});
|
|
31
28
|
const filterIds = await modules.assortments.filters.findFilterIds({
|
|
@@ -33,14 +30,12 @@ export default async function searchProducts(
|
|
|
33
30
|
});
|
|
34
31
|
return services.filters.searchProducts(
|
|
35
32
|
{ queryString, includeInactive, filterQuery, productIds, filterIds, ...rest },
|
|
36
|
-
{
|
|
33
|
+
{ locale: locale },
|
|
37
34
|
);
|
|
38
35
|
}
|
|
39
36
|
|
|
40
|
-
if (!queryString) throw new QueryStringRequiredError({});
|
|
41
|
-
|
|
42
37
|
return services.filters.searchProducts(
|
|
43
38
|
{ queryString, includeInactive, filterQuery, ...rest },
|
|
44
|
-
{
|
|
39
|
+
{ locale: locale },
|
|
45
40
|
);
|
|
46
41
|
}
|
package/src/roles/all.ts
CHANGED
|
@@ -101,6 +101,7 @@ export const all = (role, actions) => {
|
|
|
101
101
|
role.allow(actions.viewTokens, () => false);
|
|
102
102
|
role.allow(actions.viewStatistics, () => false);
|
|
103
103
|
role.allow(actions.uploadUserAvatar, () => false);
|
|
104
|
+
role.allow(actions.uploadTempFile, () => false);
|
|
104
105
|
role.allow(actions.impersonate, () => false);
|
|
105
106
|
|
|
106
107
|
// special case: when doing a login mutation, the user is not logged in technically yet,
|
package/src/roles/index.ts
CHANGED
package/src/roles/loggedIn.ts
CHANGED
|
@@ -248,4 +248,5 @@ export const loggedIn = (role: any, actions: Record<string, string>) => {
|
|
|
248
248
|
role.allow(actions.confirmMediaUpload, () => true);
|
|
249
249
|
role.allow(actions.downloadFile, isFileAccessible);
|
|
250
250
|
role.allow(actions.uploadUserAvatar, canUpdateAvatar);
|
|
251
|
+
role.allow(actions.uploadTempFile, canUpdateAvatar);
|
|
251
252
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcpHandler.d.ts","sourceRoot":"","sources":["../../src/express/mcpHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA4DzC,QAAA,MAAM,UAAU,EAAE,cAOjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
|
-
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
-
import createMcpServer from '../mcp/index.js';
|
|
5
|
-
// Map to store transports by session ID
|
|
6
|
-
const transports = {};
|
|
7
|
-
const handlePostRequest = async (req, res) => {
|
|
8
|
-
// Check for existing session ID
|
|
9
|
-
const sessionId = req.headers['mcp-session-id'];
|
|
10
|
-
let transport;
|
|
11
|
-
if (sessionId && transports[sessionId]) {
|
|
12
|
-
// Reuse existing transport
|
|
13
|
-
transport = transports[sessionId];
|
|
14
|
-
}
|
|
15
|
-
else if (!sessionId && isInitializeRequest(req.body)) {
|
|
16
|
-
// New initialization request
|
|
17
|
-
transport = new StreamableHTTPServerTransport({
|
|
18
|
-
sessionIdGenerator: () => randomUUID(),
|
|
19
|
-
onsessioninitialized: (sessionId) => {
|
|
20
|
-
// Store the transport by session ID
|
|
21
|
-
transports[sessionId] = transport;
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
// Clean up transport when closed
|
|
25
|
-
transport.onclose = () => {
|
|
26
|
-
if (transport.sessionId) {
|
|
27
|
-
delete transports[transport.sessionId];
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const server = createMcpServer();
|
|
31
|
-
await server.connect(transport);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
// Invalid request
|
|
35
|
-
res.status(400).json({
|
|
36
|
-
jsonrpc: '2.0',
|
|
37
|
-
error: {
|
|
38
|
-
code: -32000,
|
|
39
|
-
message: 'Bad Request: No valid session ID provided',
|
|
40
|
-
},
|
|
41
|
-
id: null,
|
|
42
|
-
});
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
// Handle the request
|
|
46
|
-
await transport.handleRequest(req, res, req.body);
|
|
47
|
-
};
|
|
48
|
-
// Reusable handler for GET and DELETE requests
|
|
49
|
-
const handleSessionRequest = async (req, res) => {
|
|
50
|
-
const sessionId = req.headers['mcp-session-id'];
|
|
51
|
-
if (!sessionId || !transports[sessionId]) {
|
|
52
|
-
res.status(400).send('Invalid or missing session ID');
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const transport = transports[sessionId];
|
|
56
|
-
await transport.handleRequest(req, res);
|
|
57
|
-
};
|
|
58
|
-
const mcpHandler = (req, res, next) => {
|
|
59
|
-
if (req.method === 'POST') {
|
|
60
|
-
return handlePostRequest(req, res, next);
|
|
61
|
-
}
|
|
62
|
-
else if (req.method === 'GET' || req.method === 'DELETE') {
|
|
63
|
-
return handleSessionRequest(req, res, next);
|
|
64
|
-
}
|
|
65
|
-
res.status(405).send('Method Not Allowed');
|
|
66
|
-
};
|
|
67
|
-
export default mcpHandler;
|
|
68
|
-
//# sourceMappingURL=mcpHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcpHandler.js","sourceRoot":"","sources":["../../src/express/mcpHandler.ts"],"names":[],"mappings":"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"}
|