@unchainedshop/api 3.1.13 → 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/context.d.ts +2 -2
- package/lib/context.d.ts.map +1 -1
- package/lib/context.js +1 -1
- package/lib/context.js.map +1 -1
- package/lib/createGraphQLServer.d.ts +2 -2
- package/lib/createGraphQLServer.d.ts.map +1 -1
- package/lib/errors.d.ts +2 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +2 -1
- package/lib/errors.js.map +1 -1
- 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/createERCMetadataMiddleware.d.ts.map +1 -1
- package/lib/express/createERCMetadataMiddleware.js +9 -5
- package/lib/express/createERCMetadataMiddleware.js.map +1 -1
- package/lib/express/createMCPMiddleware.d.ts.map +1 -1
- package/lib/express/createMCPMiddleware.js +12 -3
- package/lib/express/createMCPMiddleware.js.map +1 -1
- 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 -6
- 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/ercMetadataHandler.d.ts.map +1 -1
- package/lib/fastify/ercMetadataHandler.js +9 -5
- package/lib/fastify/ercMetadataHandler.js.map +1 -1
- package/lib/fastify/index.d.ts.map +1 -1
- package/lib/fastify/index.js +24 -5
- 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 +4 -0
- package/lib/fastify/mcpHandler.d.ts.map +1 -0
- package/lib/fastify/mcpHandler.js +78 -0
- package/lib/fastify/mcpHandler.js.map +1 -0
- 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/loaders/buildLocaleMap.d.ts +4 -4
- package/lib/loaders/buildLocaleMap.d.ts.map +1 -1
- package/lib/loaders/buildLocaleMap.js +34 -5
- package/lib/loaders/buildLocaleMap.js.map +1 -1
- package/lib/loaders/buildTextMap.d.ts +2 -2
- package/lib/loaders/buildTextMap.d.ts.map +1 -1
- package/lib/loaders/buildTextMap.js +3 -0
- package/lib/loaders/buildTextMap.js.map +1 -1
- package/lib/loaders/index.d.ts +79 -49
- package/lib/loaders/index.d.ts.map +1 -1
- package/lib/loaders/index.js +47 -240
- package/lib/loaders/index.js.map +1 -1
- package/lib/locale-context.d.ts +3 -3
- package/lib/locale-context.d.ts.map +1 -1
- package/lib/locale-context.js +9 -10
- package/lib/locale-context.js.map +1 -1
- package/lib/mcp/index.d.ts +1 -1
- package/lib/mcp/index.d.ts.map +1 -1
- package/lib/mcp/index.js +38 -2
- package/lib/mcp/index.js.map +1 -1
- package/lib/mcp/tools/addProductAssignmentHandler.js.map +1 -1
- 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/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/createProductVariationHandler.d.ts +2 -2
- package/lib/mcp/tools/createProductVariationHandler.d.ts.map +1 -1
- package/lib/mcp/tools/createProductVariationHandler.js +10 -4
- package/lib/mcp/tools/createProductVariationHandler.js.map +1 -1
- 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/getProduct.d.ts.map +1 -1
- package/lib/mcp/tools/getProduct.js +2 -45
- package/lib/mcp/tools/getProduct.js.map +1 -1
- package/lib/mcp/tools/index.d.ts +33 -0
- package/lib/mcp/tools/index.d.ts.map +1 -1
- package/lib/mcp/tools/index.js +33 -0
- package/lib/mcp/tools/index.js.map +1 -1
- package/lib/mcp/tools/listProducts.d.ts.map +1 -1
- package/lib/mcp/tools/listProducts.js +29 -17
- package/lib/mcp/tools/listProducts.js.map +1 -1
- 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/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/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/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/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/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/utils/getNormalizedProductDetails.d.ts.map +1 -1
- package/lib/mcp/utils/getNormalizedProductDetails.js +2 -0
- package/lib/mcp/utils/getNormalizedProductDetails.js.map +1 -1
- package/lib/resolvers/mutations/accounts/createUser.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/createUser.js +4 -5
- package/lib/resolvers/mutations/accounts/createUser.js.map +1 -1
- package/lib/resolvers/mutations/accounts/impersonate.js +1 -1
- package/lib/resolvers/mutations/accounts/impersonate.js.map +1 -1
- package/lib/resolvers/mutations/accounts/loginAsGuest.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/loginAsGuest.js +4 -5
- package/lib/resolvers/mutations/accounts/loginAsGuest.js.map +1 -1
- package/lib/resolvers/mutations/accounts/loginWithPassword.js +3 -3
- package/lib/resolvers/mutations/accounts/loginWithPassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js +3 -3
- package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js.map +1 -1
- package/lib/resolvers/mutations/accounts/resetPassword.js +3 -3
- package/lib/resolvers/mutations/accounts/resetPassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/stopImpersonation.js +1 -1
- package/lib/resolvers/mutations/accounts/stopImpersonation.js.map +1 -1
- package/lib/resolvers/mutations/accounts/verifyEmail.js +3 -3
- package/lib/resolvers/mutations/accounts/verifyEmail.js.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentFilters.d.ts +2 -2
- package/lib/resolvers/mutations/assortments/reorderAssortmentFilters.d.ts.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentFilters.js.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentLinks.d.ts +2 -2
- package/lib/resolvers/mutations/assortments/reorderAssortmentLinks.d.ts.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentLinks.js.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentMedia.d.ts +2 -2
- package/lib/resolvers/mutations/assortments/reorderAssortmentMedia.d.ts.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentMedia.js.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentProducts.d.ts +2 -2
- package/lib/resolvers/mutations/assortments/reorderAssortmentProducts.d.ts.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentProducts.js.map +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortmentMediaTexts.d.ts +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortmentMediaTexts.d.ts.map +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortmentMediaTexts.js.map +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortmentTexts.d.ts +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortmentTexts.d.ts.map +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortmentTexts.js.map +1 -1
- package/lib/resolvers/mutations/enrollments/createEnrollment.js +3 -3
- package/lib/resolvers/mutations/enrollments/createEnrollment.js.map +1 -1
- package/lib/resolvers/mutations/enrollments/updateEnrollment.d.ts +2 -2
- package/lib/resolvers/mutations/enrollments/updateEnrollment.d.ts.map +1 -1
- package/lib/resolvers/mutations/filters/createFilter.d.ts.map +1 -1
- package/lib/resolvers/mutations/filters/createFilter.js +2 -6
- package/lib/resolvers/mutations/filters/createFilter.js.map +1 -1
- package/lib/resolvers/mutations/filters/updateFilterTexts.d.ts +2 -2
- package/lib/resolvers/mutations/filters/updateFilterTexts.d.ts.map +1 -1
- package/lib/resolvers/mutations/orders/addCartDiscount.js +1 -1
- package/lib/resolvers/mutations/orders/addCartDiscount.js.map +1 -1
- package/lib/resolvers/mutations/orders/addCartProduct.js +1 -1
- package/lib/resolvers/mutations/orders/addCartProduct.js.map +1 -1
- package/lib/resolvers/mutations/orders/addCartQuotation.d.ts +2 -2
- package/lib/resolvers/mutations/orders/addCartQuotation.d.ts.map +1 -1
- package/lib/resolvers/mutations/orders/addCartQuotation.js +1 -1
- package/lib/resolvers/mutations/orders/addCartQuotation.js.map +1 -1
- package/lib/resolvers/mutations/orders/addMultipleCartProducts.d.ts +4 -4
- package/lib/resolvers/mutations/orders/addMultipleCartProducts.d.ts.map +1 -1
- package/lib/resolvers/mutations/orders/addMultipleCartProducts.js +1 -1
- package/lib/resolvers/mutations/orders/addMultipleCartProducts.js.map +1 -1
- package/lib/resolvers/mutations/orders/checkoutCart.js +1 -1
- package/lib/resolvers/mutations/orders/checkoutCart.js.map +1 -1
- package/lib/resolvers/mutations/orders/createCart.js +1 -1
- package/lib/resolvers/mutations/orders/createCart.js.map +1 -1
- package/lib/resolvers/mutations/orders/emptyCart.js +1 -1
- package/lib/resolvers/mutations/orders/emptyCart.js.map +1 -1
- package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js +1 -1
- package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js.map +1 -1
- package/lib/resolvers/mutations/orders/updateCart.js +1 -1
- package/lib/resolvers/mutations/orders/updateCart.js.map +1 -1
- package/lib/resolvers/mutations/orders/updateCartItem.d.ts +2 -2
- package/lib/resolvers/mutations/orders/updateCartItem.d.ts.map +1 -1
- package/lib/resolvers/mutations/products/addProductAssignment.d.ts +1 -1
- package/lib/resolvers/mutations/products/addProductAssignment.d.ts.map +1 -1
- package/lib/resolvers/mutations/products/addProductAssignment.js +35 -2
- package/lib/resolvers/mutations/products/addProductAssignment.js.map +1 -1
- package/lib/resolvers/mutations/products/createProductVariation.d.ts +2 -2
- package/lib/resolvers/mutations/products/createProductVariation.d.ts.map +1 -1
- package/lib/resolvers/mutations/products/createProductVariation.js.map +1 -1
- package/lib/resolvers/mutations/products/removeProductAssignment.d.ts +1 -1
- package/lib/resolvers/mutations/products/removeProductAssignment.d.ts.map +1 -1
- package/lib/resolvers/mutations/products/removeProductAssignment.js.map +1 -1
- package/lib/resolvers/mutations/products/reorderProductMedia.d.ts +2 -2
- package/lib/resolvers/mutations/products/reorderProductMedia.d.ts.map +1 -1
- package/lib/resolvers/mutations/products/reorderProductMedia.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductMediaTexts.d.ts +1 -1
- package/lib/resolvers/mutations/products/updateProductMediaTexts.d.ts.map +1 -1
- package/lib/resolvers/mutations/products/updateProductMediaTexts.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductVariationTexts.d.ts +1 -1
- package/lib/resolvers/mutations/products/updateProductVariationTexts.d.ts.map +1 -1
- package/lib/resolvers/mutations/quotations/requestQuotation.d.ts +2 -2
- package/lib/resolvers/mutations/quotations/requestQuotation.d.ts.map +1 -1
- package/lib/resolvers/mutations/quotations/requestQuotation.js +3 -3
- package/lib/resolvers/mutations/quotations/requestQuotation.js.map +1 -1
- package/lib/resolvers/mutations/users/heartbeat.d.ts +1 -1
- package/lib/resolvers/mutations/users/heartbeat.d.ts.map +1 -1
- package/lib/resolvers/mutations/users/heartbeat.js +3 -3
- package/lib/resolvers/mutations/users/heartbeat.js.map +1 -1
- package/lib/resolvers/mutations/users/setRoles.d.ts +1 -1
- package/lib/resolvers/mutations/users/setRoles.d.ts.map +1 -1
- package/lib/resolvers/mutations/users/setRoles.js.map +1 -1
- package/lib/resolvers/mutations/users/setUserTags.d.ts +1 -1
- package/lib/resolvers/mutations/users/setUserTags.d.ts.map +1 -1
- package/lib/resolvers/mutations/users/setUserTags.js.map +1 -1
- package/lib/resolvers/mutations/warehousing/invalidateToken.js +1 -3
- package/lib/resolvers/mutations/warehousing/invalidateToken.js.map +1 -1
- package/lib/resolvers/mutations/worker/allocateWork.d.ts +1 -1
- package/lib/resolvers/mutations/worker/allocateWork.d.ts.map +1 -1
- package/lib/resolvers/mutations/worker/allocateWork.js.map +1 -1
- package/lib/resolvers/queries/assortments/assortments.d.ts +1 -1
- package/lib/resolvers/queries/assortments/assortments.d.ts.map +1 -1
- package/lib/resolvers/queries/countries/countries.d.ts +1 -1
- package/lib/resolvers/queries/countries/countries.d.ts.map +1 -1
- package/lib/resolvers/queries/countries/countries.js.map +1 -1
- package/lib/resolvers/queries/currencies/currencies.d.ts +1 -1
- package/lib/resolvers/queries/currencies/currencies.d.ts.map +1 -1
- package/lib/resolvers/queries/currencies/currencies.js.map +1 -1
- package/lib/resolvers/queries/enrollments/enrollments.d.ts +1 -1
- package/lib/resolvers/queries/enrollments/enrollments.d.ts.map +1 -1
- package/lib/resolvers/queries/filters/filters.d.ts +1 -1
- package/lib/resolvers/queries/filters/filters.d.ts.map +1 -1
- package/lib/resolvers/queries/filters/searchAssortments.d.ts.map +1 -1
- package/lib/resolvers/queries/filters/searchAssortments.js +2 -7
- 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 +3 -8
- package/lib/resolvers/queries/filters/searchProducts.js.map +1 -1
- package/lib/resolvers/queries/languages/languages.d.ts +1 -1
- package/lib/resolvers/queries/languages/languages.d.ts.map +1 -1
- package/lib/resolvers/queries/languages/languages.js.map +1 -1
- package/lib/resolvers/queries/orders/orders.d.ts +1 -1
- package/lib/resolvers/queries/orders/orders.d.ts.map +1 -1
- package/lib/resolvers/queries/orders/orders.js.map +1 -1
- package/lib/resolvers/queries/products/productReviews.d.ts +1 -1
- package/lib/resolvers/queries/products/productReviews.d.ts.map +1 -1
- package/lib/resolvers/queries/products/products.d.ts +1 -1
- package/lib/resolvers/queries/products/products.d.ts.map +1 -1
- package/lib/resolvers/queries/quotations/quotations.d.ts +1 -1
- package/lib/resolvers/queries/quotations/quotations.d.ts.map +1 -1
- package/lib/resolvers/queries/quotations/quotations.js.map +1 -1
- package/lib/resolvers/queries/users/impersonator.d.ts.map +1 -1
- package/lib/resolvers/queries/users/impersonator.js +1 -1
- package/lib/resolvers/queries/users/impersonator.js.map +1 -1
- package/lib/resolvers/queries/users/user.d.ts.map +1 -1
- package/lib/resolvers/queries/users/user.js.map +1 -1
- package/lib/resolvers/queries/users/users.d.ts +1 -1
- package/lib/resolvers/queries/users/users.d.ts.map +1 -1
- package/lib/resolvers/queries/worker/workQueue.d.ts +3 -3
- package/lib/resolvers/queries/worker/workQueue.d.ts.map +1 -1
- package/lib/resolvers/type/assortment/assortment-filter-types.d.ts +4 -8
- package/lib/resolvers/type/assortment/assortment-filter-types.d.ts.map +1 -1
- package/lib/resolvers/type/assortment/assortment-filter-types.js +4 -6
- package/lib/resolvers/type/assortment/assortment-filter-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-link-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-link-types.d.ts.map +1 -1
- package/lib/resolvers/type/assortment/assortment-media-types.js +2 -2
- package/lib/resolvers/type/assortment/assortment-media-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-path-link-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-path-link-types.d.ts.map +1 -1
- package/lib/resolvers/type/assortment/assortment-path-link-types.js +2 -2
- package/lib/resolvers/type/assortment/assortment-path-link-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-product-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-product-types.d.ts.map +1 -1
- package/lib/resolvers/type/assortment/assortment-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-types.d.ts.map +1 -1
- package/lib/resolvers/type/assortment/assortment-types.js +5 -5
- package/lib/resolvers/type/assortment/assortment-types.js.map +1 -1
- package/lib/resolvers/type/bookmark-types.d.ts.map +1 -1
- package/lib/resolvers/type/bookmark-types.js +2 -3
- package/lib/resolvers/type/bookmark-types.js.map +1 -1
- package/lib/resolvers/type/country-types.d.ts +1 -1
- package/lib/resolvers/type/country-types.d.ts.map +1 -1
- package/lib/resolvers/type/country-types.js +4 -7
- package/lib/resolvers/type/country-types.js.map +1 -1
- package/lib/resolvers/type/delivery-provider-types.d.ts +10 -13
- package/lib/resolvers/type/delivery-provider-types.d.ts.map +1 -1
- package/lib/resolvers/type/delivery-provider-types.js +8 -9
- package/lib/resolvers/type/delivery-provider-types.js.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-delivery-types.d.ts +2 -6
- package/lib/resolvers/type/enrollment/enrollment-delivery-types.d.ts.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-delivery-types.js +4 -3
- package/lib/resolvers/type/enrollment/enrollment-delivery-types.js.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-payment-types.d.ts +2 -6
- package/lib/resolvers/type/enrollment/enrollment-payment-types.d.ts.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-payment-types.js +2 -3
- package/lib/resolvers/type/enrollment/enrollment-payment-types.js.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-period-types.d.ts +2 -6
- package/lib/resolvers/type/enrollment/enrollment-period-types.d.ts.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-period-types.js +2 -3
- package/lib/resolvers/type/enrollment/enrollment-period-types.js.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.d.ts +2 -6
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.d.ts.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.js +2 -3
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.js.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-types.d.ts +15 -14
- package/lib/resolvers/type/enrollment/enrollment-types.d.ts.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-types.js +3 -6
- package/lib/resolvers/type/enrollment/enrollment-types.js.map +1 -1
- package/lib/resolvers/type/filter/filter-option-types.d.ts +6 -9
- package/lib/resolvers/type/filter/filter-option-types.d.ts.map +1 -1
- package/lib/resolvers/type/filter/filter-option-types.js +2 -3
- package/lib/resolvers/type/filter/filter-option-types.js.map +1 -1
- package/lib/resolvers/type/filter/filter-types.d.ts +16 -8
- package/lib/resolvers/type/filter/filter-types.d.ts.map +1 -1
- package/lib/resolvers/type/filter/filter-types.js +2 -3
- package/lib/resolvers/type/filter/filter-types.js.map +1 -1
- package/lib/resolvers/type/filter/loaded-filter-types.d.ts +2 -3
- package/lib/resolvers/type/filter/loaded-filter-types.d.ts.map +1 -1
- package/lib/resolvers/type/index.d.ts +273 -261
- package/lib/resolvers/type/index.d.ts.map +1 -1
- package/lib/resolvers/type/login-method-response-types.js +1 -1
- package/lib/resolvers/type/login-method-response-types.js.map +1 -1
- package/lib/resolvers/type/order/order-delivery-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-delivery-discount-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-delivery-discount-types.js +1 -2
- package/lib/resolvers/type/order/order-delivery-discount-types.js.map +1 -1
- package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +13 -12
- package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-delivery-pickup-types.js +10 -14
- package/lib/resolvers/type/order/order-delivery-pickup-types.js.map +1 -1
- package/lib/resolvers/type/order/order-delivery-shipping-types.d.ts +12 -12
- package/lib/resolvers/type/order/order-delivery-shipping-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-delivery-shipping-types.js +7 -10
- package/lib/resolvers/type/order/order-delivery-shipping-types.js.map +1 -1
- package/lib/resolvers/type/order/order-delivery-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-delivery-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-delivery-types.js +2 -3
- package/lib/resolvers/type/order/order-delivery-types.js.map +1 -1
- package/lib/resolvers/type/order/order-discount-types.d.ts +11 -13
- package/lib/resolvers/type/order/order-discount-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-discount-types.js +9 -16
- package/lib/resolvers/type/order/order-discount-types.js.map +1 -1
- package/lib/resolvers/type/order/order-global-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-global-discount-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-global-discount-types.js +1 -2
- package/lib/resolvers/type/order/order-global-discount-types.js.map +1 -1
- package/lib/resolvers/type/order/order-item-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-discount-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-item-discount-types.js +1 -2
- package/lib/resolvers/type/order/order-item-discount-types.js.map +1 -1
- package/lib/resolvers/type/order/order-item-types.d.ts +5 -5
- package/lib/resolvers/type/order/order-item-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-item-types.js +14 -17
- package/lib/resolvers/type/order/order-item-types.js.map +1 -1
- package/lib/resolvers/type/order/order-payment-card-types.d.ts +11 -10
- package/lib/resolvers/type/order/order-payment-card-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-payment-card-types.js +6 -9
- package/lib/resolvers/type/order/order-payment-card-types.js.map +1 -1
- package/lib/resolvers/type/order/order-payment-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-discount-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-payment-discount-types.js +2 -4
- package/lib/resolvers/type/order/order-payment-discount-types.js.map +1 -1
- package/lib/resolvers/type/order/order-payment-generic-types.d.ts +11 -10
- package/lib/resolvers/type/order/order-payment-generic-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-payment-generic-types.js +6 -9
- package/lib/resolvers/type/order/order-payment-generic-types.js.map +1 -1
- package/lib/resolvers/type/order/order-payment-invoice-types.d.ts +11 -10
- package/lib/resolvers/type/order/order-payment-invoice-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-payment-invoice-types.js +6 -9
- package/lib/resolvers/type/order/order-payment-invoice-types.js.map +1 -1
- package/lib/resolvers/type/order/order-payment-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-payment-types.js +2 -3
- package/lib/resolvers/type/order/order-payment-types.js.map +1 -1
- package/lib/resolvers/type/order/order-types.d.ts +6 -6
- package/lib/resolvers/type/order/order-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-types.js +7 -15
- package/lib/resolvers/type/order/order-types.js.map +1 -1
- package/lib/resolvers/type/payment/payment-credentials-types.d.ts.map +1 -1
- package/lib/resolvers/type/payment/payment-credentials-types.js +6 -9
- package/lib/resolvers/type/payment/payment-credentials-types.js.map +1 -1
- package/lib/resolvers/type/payment/payment-provider-types.d.ts +2 -2
- package/lib/resolvers/type/payment/payment-provider-types.d.ts.map +1 -1
- package/lib/resolvers/type/payment/payment-provider-types.js +8 -9
- package/lib/resolvers/type/payment/payment-provider-types.js.map +1 -1
- package/lib/resolvers/type/price-types.d.ts +3 -4
- package/lib/resolvers/type/price-types.d.ts.map +1 -1
- package/lib/resolvers/type/price-types.js +2 -2
- package/lib/resolvers/type/price-types.js.map +1 -1
- package/lib/resolvers/type/product/product-assortment-path-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-assortment-path-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-bundle-types.d.ts +10 -10
- package/lib/resolvers/type/product/product-bundle-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-catalog-price-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-catalog-price-types.js +4 -6
- package/lib/resolvers/type/product/product-catalog-price-types.js.map +1 -1
- package/lib/resolvers/type/product/product-configurable-types.d.ts +20 -20
- package/lib/resolvers/type/product/product-configurable-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-configurable-types.js +10 -12
- package/lib/resolvers/type/product/product-configurable-types.js.map +1 -1
- package/lib/resolvers/type/product/product-discount.d.ts +1 -1
- package/lib/resolvers/type/product/product-discount.js +1 -1
- package/lib/resolvers/type/product/product-discount.js.map +1 -1
- package/lib/resolvers/type/product/product-media-types.js +2 -2
- package/lib/resolvers/type/product/product-media-types.js.map +1 -1
- package/lib/resolvers/type/product/product-plan-types.d.ts +18 -18
- package/lib/resolvers/type/product/product-plan-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-plan-types.js +16 -16
- package/lib/resolvers/type/product/product-plan-types.js.map +1 -1
- package/lib/resolvers/type/product/product-review-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-review-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-review-types.js +2 -3
- package/lib/resolvers/type/product/product-review-types.js.map +1 -1
- package/lib/resolvers/type/product/product-simple-types.d.ts +22 -22
- package/lib/resolvers/type/product/product-simple-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-simple-types.js +3 -11
- package/lib/resolvers/type/product/product-simple-types.js.map +1 -1
- package/lib/resolvers/type/product/product-tokenized-types.d.ts +20 -20
- package/lib/resolvers/type/product/product-tokenized-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-tokenized-types.js +1 -5
- package/lib/resolvers/type/product/product-tokenized-types.js.map +1 -1
- package/lib/resolvers/type/product/product-types.d.ts +9 -9
- package/lib/resolvers/type/product/product-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-types.js +2 -5
- package/lib/resolvers/type/product/product-types.js.map +1 -1
- package/lib/resolvers/type/product/product-variation-assignment-types.d.ts +2 -2
- package/lib/resolvers/type/product/product-variation-assignment-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-variation-assignment-types.js +1 -1
- package/lib/resolvers/type/product/product-variation-assignment-types.js.map +1 -1
- package/lib/resolvers/type/product/product-variation-assignment-vector.js +2 -2
- package/lib/resolvers/type/product/product-variation-assignment-vector.js.map +1 -1
- package/lib/resolvers/type/product/product-variation-option-types.js +3 -3
- package/lib/resolvers/type/product/product-variation-option-types.js.map +1 -1
- package/lib/resolvers/type/product/product-variation-types.d.ts +2 -2
- package/lib/resolvers/type/product/product-variation-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-variation-types.js +3 -3
- package/lib/resolvers/type/product/product-variation-types.js.map +1 -1
- package/lib/resolvers/type/product-search-result-types.d.ts +5 -6
- package/lib/resolvers/type/product-search-result-types.d.ts.map +1 -1
- package/lib/resolvers/type/quotation-types.d.ts +8 -15
- package/lib/resolvers/type/quotation-types.d.ts.map +1 -1
- package/lib/resolvers/type/quotation-types.js +3 -6
- package/lib/resolvers/type/quotation-types.js.map +1 -1
- package/lib/resolvers/type/shop-types.d.ts +1 -1
- package/lib/resolvers/type/shop-types.d.ts.map +1 -1
- package/lib/resolvers/type/shop-types.js +4 -6
- package/lib/resolvers/type/shop-types.js.map +1 -1
- package/lib/resolvers/type/token-types.d.ts +2 -2
- package/lib/resolvers/type/token-types.d.ts.map +1 -1
- package/lib/resolvers/type/token-types.js +12 -26
- package/lib/resolvers/type/token-types.js.map +1 -1
- package/lib/resolvers/type/user-types.d.ts +22 -22
- package/lib/resolvers/type/user-types.d.ts.map +1 -1
- package/lib/resolvers/type/user-types.js +5 -16
- package/lib/resolvers/type/user-types.js.map +1 -1
- package/lib/resolvers/type/work-types.d.ts.map +1 -1
- package/lib/resolvers/type/work-types.js +0 -1
- package/lib/resolvers/type/work-types.js.map +1 -1
- package/lib/roles/all.js +1 -1
- 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/schema/types/assortment.js +5 -5
- package/lib/schema/types/country.js +1 -1
- package/lib/schema/types/delivery.d.ts.map +1 -1
- package/lib/schema/types/delivery.js +6 -2
- package/lib/schema/types/delivery.js.map +1 -1
- package/lib/schema/types/filter.js +3 -3
- package/lib/schema/types/payment.d.ts.map +1 -1
- package/lib/schema/types/payment.js +6 -2
- package/lib/schema/types/payment.js.map +1 -1
- package/lib/schema/types/price.js +1 -1
- package/lib/schema/types/product/bundle-product.js +1 -1
- package/lib/schema/types/product/configurable-product.js +6 -6
- package/lib/schema/types/product/plan-product.js +5 -5
- package/lib/schema/types/product/product.js +4 -4
- package/lib/schema/types/product/simple-product.js +4 -4
- package/lib/schema/types/product/tokenized-product.js +5 -5
- package/lib/schema/types/warehousing.js +1 -1
- package/package.json +32 -16
- package/src/api-index.ts +4 -1
- package/src/context.ts +3 -3
- package/src/createGraphQLServer.ts +2 -2
- package/src/errors.ts +10 -4
- package/src/express/createERCMetadataMiddleware.ts +11 -5
- package/src/express/createMCPMiddleware.ts +91 -0
- package/src/express/createTempUploadMiddleware.ts +60 -0
- package/src/express/index.ts +37 -9
- package/src/fastify/ercMetadataHandler.ts +11 -5
- package/src/fastify/index.ts +34 -5
- package/src/fastify/mcpHandler.ts +97 -0
- package/src/fastify/tempUploadHandler.ts +52 -0
- package/src/loaders/assortmentLinkLoader.ts +32 -0
- package/src/loaders/assortmentLinksLoader.ts +46 -0
- package/src/loaders/assortmentLoader.ts +20 -0
- package/src/loaders/assortmentMediaTextLoader.ts +26 -0
- package/src/loaders/assortmentMediasLoader.ts +21 -0
- package/src/loaders/assortmentProductLoader.ts +19 -0
- package/src/loaders/assortmentProductsLoader.ts +22 -0
- package/src/loaders/assortmentTextLoader.ts +24 -0
- package/src/loaders/buildLocaleMap.test.ts +9 -5
- package/src/loaders/buildLocaleMap.ts +43 -9
- package/src/loaders/buildTextMap.ts +4 -1
- package/src/loaders/countryLoader.ts +20 -0
- package/src/loaders/currencyLoader.ts +20 -0
- package/src/loaders/deliveryProviderLoader.ts +19 -0
- package/src/loaders/fileLoader.ts +19 -0
- package/src/loaders/filterLoader.ts +20 -0
- package/src/loaders/filterTextLoader.ts +26 -0
- package/src/loaders/index.ts +48 -329
- package/src/loaders/languageLoader.ts +20 -0
- package/src/loaders/orderLoader.ts +22 -0
- package/src/loaders/paymentProviderLoader.ts +19 -0
- package/src/loaders/productLoader.ts +22 -0
- package/src/loaders/productLoaderBySKU.ts +22 -0
- package/src/loaders/productMediaTextLoader.ts +24 -0
- package/src/loaders/productMediasLoader.ts +21 -0
- package/src/loaders/productTextLoader.ts +22 -0
- package/src/loaders/userLoader.ts +23 -0
- package/src/loaders/utils.ts +35 -0
- package/src/locale-context.ts +16 -22
- 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/accounts/createUser.ts +4 -6
- package/src/resolvers/mutations/accounts/impersonate.ts +1 -1
- package/src/resolvers/mutations/accounts/loginAsGuest.ts +4 -6
- package/src/resolvers/mutations/accounts/loginWithPassword.ts +3 -3
- package/src/resolvers/mutations/accounts/loginWithWebAuthn.ts +3 -3
- package/src/resolvers/mutations/accounts/resetPassword.ts +3 -3
- package/src/resolvers/mutations/accounts/stopImpersonation.ts +1 -1
- package/src/resolvers/mutations/accounts/verifyEmail.ts +3 -3
- package/src/resolvers/mutations/assortments/reorderAssortmentFilters.ts +1 -1
- package/src/resolvers/mutations/assortments/reorderAssortmentLinks.ts +1 -1
- package/src/resolvers/mutations/assortments/reorderAssortmentMedia.ts +1 -1
- package/src/resolvers/mutations/assortments/reorderAssortmentProducts.ts +1 -1
- package/src/resolvers/mutations/assortments/updateAssortmentMediaTexts.ts +1 -1
- package/src/resolvers/mutations/assortments/updateAssortmentTexts.ts +1 -1
- package/src/resolvers/mutations/enrollments/createEnrollment.ts +3 -3
- package/src/resolvers/mutations/enrollments/updateEnrollment.ts +2 -2
- package/src/resolvers/mutations/filters/createFilter.ts +2 -6
- package/src/resolvers/mutations/filters/updateFilterTexts.ts +1 -1
- package/src/resolvers/mutations/orders/addCartDiscount.ts +1 -1
- package/src/resolvers/mutations/orders/addCartProduct.ts +1 -1
- package/src/resolvers/mutations/orders/addCartQuotation.ts +2 -2
- package/src/resolvers/mutations/orders/addMultipleCartProducts.ts +4 -4
- package/src/resolvers/mutations/orders/checkoutCart.ts +1 -1
- package/src/resolvers/mutations/orders/createCart.ts +1 -1
- package/src/resolvers/mutations/orders/emptyCart.ts +1 -1
- package/src/resolvers/mutations/orders/signPaymentProviderForCheckout.ts +1 -1
- package/src/resolvers/mutations/orders/updateCart.ts +1 -1
- package/src/resolvers/mutations/orders/updateCartItem.ts +1 -1
- package/src/resolvers/mutations/products/addProductAssignment.ts +45 -2
- package/src/resolvers/mutations/products/createProductVariation.ts +5 -1
- package/src/resolvers/mutations/products/removeProductAssignment.ts +1 -1
- package/src/resolvers/mutations/products/reorderProductMedia.ts +1 -1
- package/src/resolvers/mutations/products/updateProductMediaTexts.ts +1 -1
- package/src/resolvers/mutations/products/updateProductVariationTexts.ts +1 -1
- package/src/resolvers/mutations/quotations/requestQuotation.ts +4 -4
- package/src/resolvers/mutations/users/heartbeat.ts +3 -3
- package/src/resolvers/mutations/users/setRoles.ts +1 -1
- package/src/resolvers/mutations/users/setUserTags.ts +1 -1
- package/src/resolvers/mutations/warehousing/invalidateToken.ts +3 -3
- package/src/resolvers/mutations/worker/allocateWork.ts +1 -1
- package/src/resolvers/queries/assortments/assortments.ts +1 -1
- package/src/resolvers/queries/countries/countries.ts +1 -1
- package/src/resolvers/queries/currencies/currencies.ts +1 -1
- package/src/resolvers/queries/enrollments/enrollments.ts +1 -1
- package/src/resolvers/queries/filters/filters.ts +1 -1
- package/src/resolvers/queries/filters/searchAssortments.ts +2 -7
- package/src/resolvers/queries/filters/searchProducts.ts +3 -8
- package/src/resolvers/queries/languages/languages.ts +1 -1
- package/src/resolvers/queries/orders/orders.ts +1 -1
- package/src/resolvers/queries/products/productReviews.ts +1 -1
- package/src/resolvers/queries/products/products.ts +1 -1
- package/src/resolvers/queries/quotations/quotations.ts +1 -1
- package/src/resolvers/queries/users/impersonator.ts +2 -1
- package/src/resolvers/queries/users/user.ts +1 -0
- package/src/resolvers/queries/users/users.ts +1 -1
- package/src/resolvers/queries/worker/workQueue.ts +3 -3
- package/src/resolvers/type/assortment/assortment-filter-types.ts +6 -16
- package/src/resolvers/type/assortment/assortment-link-types.ts +2 -2
- package/src/resolvers/type/assortment/assortment-media-types.ts +2 -2
- package/src/resolvers/type/assortment/assortment-path-link-types.ts +3 -3
- package/src/resolvers/type/assortment/assortment-product-types.ts +2 -2
- package/src/resolvers/type/assortment/assortment-types.ts +6 -6
- package/src/resolvers/type/bookmark-types.ts +2 -3
- package/src/resolvers/type/country-types.ts +5 -8
- package/src/resolvers/type/delivery-provider-types.ts +26 -47
- package/src/resolvers/type/enrollment/enrollment-delivery-types.ts +5 -11
- package/src/resolvers/type/enrollment/enrollment-payment-types.ts +3 -11
- package/src/resolvers/type/enrollment/enrollment-period-types.ts +3 -11
- package/src/resolvers/type/enrollment/enrollment-plan-tyes.ts +3 -11
- package/src/resolvers/type/enrollment/enrollment-types.ts +10 -25
- package/src/resolvers/type/filter/filter-option-types.ts +10 -15
- package/src/resolvers/type/filter/filter-types.ts +5 -13
- package/src/resolvers/type/filter/loaded-filter-types.ts +2 -2
- package/src/resolvers/type/login-method-response-types.ts +1 -1
- package/src/resolvers/type/order/order-delivery-discount-types.ts +1 -2
- package/src/resolvers/type/order/order-delivery-pickup-types.ts +12 -28
- package/src/resolvers/type/order/order-delivery-shipping-types.ts +9 -23
- package/src/resolvers/type/order/order-delivery-types.ts +2 -3
- package/src/resolvers/type/order/order-discount-types.ts +12 -39
- package/src/resolvers/type/order/order-global-discount-types.ts +1 -2
- package/src/resolvers/type/order/order-item-discount-types.ts +1 -2
- package/src/resolvers/type/order/order-item-types.ts +19 -27
- package/src/resolvers/type/order/order-payment-card-types.ts +8 -21
- package/src/resolvers/type/order/order-payment-discount-types.ts +1 -2
- package/src/resolvers/type/order/order-payment-generic-types.ts +8 -20
- package/src/resolvers/type/order/order-payment-invoice-types.ts +8 -20
- package/src/resolvers/type/order/order-payment-types.ts +2 -3
- package/src/resolvers/type/order/order-types.ts +10 -22
- package/src/resolvers/type/payment/payment-credentials-types.ts +6 -10
- package/src/resolvers/type/payment/payment-provider-types.ts +9 -10
- package/src/resolvers/type/price-types.ts +4 -4
- package/src/resolvers/type/product/product-assortment-path-types.ts +1 -1
- package/src/resolvers/type/product/product-bundle-types.ts +1 -1
- package/src/resolvers/type/product/product-catalog-price-types.ts +4 -6
- package/src/resolvers/type/product/product-configurable-types.ts +20 -21
- package/src/resolvers/type/product/product-discount.ts +1 -1
- package/src/resolvers/type/product/product-media-types.ts +2 -2
- package/src/resolvers/type/product/product-plan-types.ts +22 -22
- package/src/resolvers/type/product/product-review-types.ts +3 -4
- package/src/resolvers/type/product/product-simple-types.ts +7 -19
- package/src/resolvers/type/product/product-tokenized-types.ts +3 -10
- package/src/resolvers/type/product/product-types.ts +10 -13
- package/src/resolvers/type/product/product-variation-assignment-types.ts +2 -2
- package/src/resolvers/type/product/product-variation-assignment-vector.ts +2 -2
- package/src/resolvers/type/product/product-variation-option-types.ts +3 -3
- package/src/resolvers/type/product/product-variation-types.ts +5 -5
- package/src/resolvers/type/product-search-result-types.ts +5 -5
- package/src/resolvers/type/quotation-types.ts +11 -25
- package/src/resolvers/type/shop-types.ts +5 -7
- package/src/resolvers/type/token-types.ts +15 -32
- package/src/resolvers/type/user-types.ts +27 -39
- package/src/resolvers/type/work-types.ts +0 -2
- package/src/roles/all.ts +1 -1
- package/src/roles/index.ts +1 -0
- package/src/roles/loggedIn.ts +1 -0
- package/src/schema/types/assortment.ts +5 -5
- package/src/schema/types/country.ts +1 -1
- package/src/schema/types/delivery.ts +6 -2
- package/src/schema/types/filter.ts +3 -3
- package/src/schema/types/payment.ts +6 -2
- package/src/schema/types/price.ts +1 -1
- package/src/schema/types/product/bundle-product.ts +1 -1
- package/src/schema/types/product/configurable-product.ts +6 -6
- package/src/schema/types/product/plan-product.ts +5 -5
- package/src/schema/types/product/product.ts +4 -4
- package/src/schema/types/product/simple-product.ts +4 -4
- package/src/schema/types/product/tokenized-product.ts +5 -5
- package/src/schema/types/warehousing.ts +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import DataLoader from 'dataloader';
|
|
3
|
+
import { ProductText } from '@unchainedshop/core-products';
|
|
4
|
+
import buildTextMap from './buildTextMap.js';
|
|
5
|
+
import buildLocaleMap from './buildLocaleMap.js';
|
|
6
|
+
|
|
7
|
+
export default (unchainedAPI: UnchainedCore) =>
|
|
8
|
+
new DataLoader<{ productId: string; locale: Intl.Locale }, ProductText>(async (queries) => {
|
|
9
|
+
const productIds = [...new Set(queries.map((q) => q.productId))].filter(Boolean);
|
|
10
|
+
const texts = await unchainedAPI.modules.products.texts.findTexts(
|
|
11
|
+
{ productId: { $in: productIds } },
|
|
12
|
+
{
|
|
13
|
+
sort: {
|
|
14
|
+
productId: 1,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
const localeMap = buildLocaleMap(queries, texts);
|
|
19
|
+
const textsMap = buildTextMap(localeMap, texts, (text) => text.productId);
|
|
20
|
+
|
|
21
|
+
return queries.map((q) => textsMap[q.locale + q.productId]);
|
|
22
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import { User } from '@unchainedshop/core-users';
|
|
3
|
+
import DataLoader from 'dataloader';
|
|
4
|
+
|
|
5
|
+
export default (unchainedAPI: UnchainedCore) =>
|
|
6
|
+
new DataLoader<{ userId: string }, User>(async (queries) => {
|
|
7
|
+
const userIds = [...new Set(queries.map((q) => q.userId).filter(Boolean))];
|
|
8
|
+
|
|
9
|
+
// It's important to also fetch deleted with the loader,
|
|
10
|
+
// because the loader fetches entities by id.
|
|
11
|
+
const users = await unchainedAPI.modules.users.findUsers({
|
|
12
|
+
includeGuests: true,
|
|
13
|
+
includeDeleted: true,
|
|
14
|
+
_id: { $in: userIds },
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const userMap = {};
|
|
18
|
+
for (const user of users) {
|
|
19
|
+
userMap[user._id] = user;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return queries.map((q) => userMap[q.userId]);
|
|
23
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { systemLocale } from '@unchainedshop/utils';
|
|
2
|
+
|
|
3
|
+
export function getLocaleStrings(locale: Intl.Locale) {
|
|
4
|
+
try {
|
|
5
|
+
return [
|
|
6
|
+
...new Set([locale.baseName, locale.language, systemLocale.baseName, systemLocale.language]),
|
|
7
|
+
];
|
|
8
|
+
} catch {
|
|
9
|
+
return [...new Set([systemLocale.baseName, systemLocale.language])];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function buildLocaleMap(
|
|
14
|
+
queries: readonly { locale: Intl.Locale }[],
|
|
15
|
+
texts: readonly { locale?: string }[],
|
|
16
|
+
): Record<string, string[]> {
|
|
17
|
+
// key = texts.locale
|
|
18
|
+
// value = input query locale
|
|
19
|
+
|
|
20
|
+
const queryLocales = Object.values(
|
|
21
|
+
Object.fromEntries(queries.map((q) => [q.locale.baseName, q.locale])),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const textLocales: string[] = [...new Set(texts.map((t) => t.locale))];
|
|
25
|
+
const localeMap = {};
|
|
26
|
+
for (const queryLocale of queryLocales) {
|
|
27
|
+
const potentialMatches = getLocaleStrings(queryLocale);
|
|
28
|
+
const matches = potentialMatches.filter((l) => textLocales.includes(l));
|
|
29
|
+
for (const match of matches) {
|
|
30
|
+
if (!localeMap[match]) localeMap[match] = [];
|
|
31
|
+
localeMap[match].push(queryLocale);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return localeMap;
|
|
35
|
+
}
|
package/src/locale-context.ts
CHANGED
|
@@ -12,15 +12,13 @@ import { createLogger } from '@unchainedshop/logger';
|
|
|
12
12
|
const logger = createLogger('unchained:api');
|
|
13
13
|
|
|
14
14
|
export interface UnchainedLocaleContext {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
countryCode: string;
|
|
16
|
+
locale: Intl.Locale;
|
|
17
|
+
currencyCode: string;
|
|
18
18
|
}
|
|
19
|
-
const { NODE_ENV } = process.env;
|
|
20
|
-
|
|
21
19
|
export type GetHeaderFn = (key: string) => string | string[];
|
|
22
20
|
|
|
23
|
-
const memoizeCache = new ExpiryMap(NODE_ENV === 'production' ? 1000 * 60 :
|
|
21
|
+
const memoizeCache = new ExpiryMap(process.env.NODE_ENV === 'production' ? 1000 * 60 : 1); // Cached values expire after 10 seconds
|
|
24
22
|
|
|
25
23
|
export const resolveDefaultContext = pMemoize(
|
|
26
24
|
async ({ acceptLang, acceptCountry }, unchainedAPI) => {
|
|
@@ -36,31 +34,27 @@ export const resolveDefaultContext = pMemoize(
|
|
|
36
34
|
|
|
37
35
|
const currencies = await unchainedAPI.modules.currencies.findCurrencies({ includeInactive: false });
|
|
38
36
|
|
|
39
|
-
const
|
|
37
|
+
const defaultCurrencyCodes = Object.fromEntries(
|
|
38
|
+
countries.map((c) => [c.isoCode, c.defaultCurrencyCode]),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const supportedLocaleStrings: string[] = languages.reduce((accumulator, language) => {
|
|
40
42
|
const added = countries.map((country) => {
|
|
41
43
|
return `${language.isoCode}-${country.isoCode}`;
|
|
42
44
|
});
|
|
43
45
|
return accumulator.concat(added);
|
|
44
46
|
}, []);
|
|
45
47
|
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
systemLocale.baseName,
|
|
50
|
-
);
|
|
51
|
-
const countryContext = resolveBestCountry(localeContext.region, acceptCountry, countries);
|
|
52
|
-
|
|
53
|
-
const countryObject = countries.find((country) => country.isoCode === countryContext);
|
|
54
|
-
const currencyContext = resolveBestCurrency(countryObject.defaultCurrencyCode, currencies);
|
|
48
|
+
const locale = resolveBestSupported(acceptLang, supportedLocaleStrings, systemLocale.baseName);
|
|
49
|
+
const countryCode = resolveBestCountry(locale.region, acceptCountry, countries);
|
|
50
|
+
const currencyCode = resolveBestCurrency(defaultCurrencyCodes[countryCode], currencies);
|
|
55
51
|
|
|
56
|
-
logger.debug(
|
|
57
|
-
`Locale Context: Resolved ${localeContext.baseName} ${countryContext} ${currencyContext}`,
|
|
58
|
-
);
|
|
52
|
+
logger.debug(`Locale Context: Resolved ${locale.baseName} ${countryCode} ${currencyCode}`);
|
|
59
53
|
|
|
60
54
|
const newContext: UnchainedLocaleContext = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
locale,
|
|
56
|
+
countryCode,
|
|
57
|
+
currencyCode,
|
|
64
58
|
};
|
|
65
59
|
|
|
66
60
|
return newContext;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# MCP Server
|
|
2
|
+
|
|
3
|
+
This directory contains the Model Context Protocol (MCP) server implementation for Unchained Commerce.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
mcp/
|
|
9
|
+
├── index.ts # Main MCP server setup
|
|
10
|
+
├── types.ts # Shared type definitions
|
|
11
|
+
├── tools/ # Individual tool implementations
|
|
12
|
+
│ ├── index.ts # Re-exports for all tools
|
|
13
|
+
│ └── listProducts.ts # List products tool
|
|
14
|
+
└── utils/ # Shared utilities
|
|
15
|
+
└── html.ts # HTML generation utilities
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Adding New Tools
|
|
19
|
+
|
|
20
|
+
To add a new tool:
|
|
21
|
+
|
|
22
|
+
1. Create a new file in the `tools/` directory
|
|
23
|
+
2. Export the schema and handler from the file
|
|
24
|
+
3. Add the exports to `tools/index.ts`
|
|
25
|
+
4. Register the tool in the main `index.ts` file
|
package/src/mcp/index.ts
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { Context } from '../context.js';
|
|
3
|
+
import {
|
|
4
|
+
listProductsHandler,
|
|
5
|
+
ListProductsSchema,
|
|
6
|
+
getProductHandler,
|
|
7
|
+
GetProductSchema,
|
|
8
|
+
createProductHandler,
|
|
9
|
+
CreateProductSchema,
|
|
10
|
+
RemoveProductSchema,
|
|
11
|
+
removeProductHandler,
|
|
12
|
+
PublishProductSchema,
|
|
13
|
+
publishProductHandler,
|
|
14
|
+
UnpublishProductSchema,
|
|
15
|
+
unpublishProductHandler,
|
|
16
|
+
UpdateProductSchema,
|
|
17
|
+
updateProductHandler,
|
|
18
|
+
UpdateProductTextsSchema,
|
|
19
|
+
updateProductTextsHandler,
|
|
20
|
+
UpdateProductCommerceSchema,
|
|
21
|
+
updateProductCommerceHandler,
|
|
22
|
+
ListCurrenciesSchema,
|
|
23
|
+
currenciesHandler,
|
|
24
|
+
CurrencySchema,
|
|
25
|
+
currencyHandler,
|
|
26
|
+
ListCountriesSchema,
|
|
27
|
+
countriesHandler,
|
|
28
|
+
CountrySchema,
|
|
29
|
+
countryHandler,
|
|
30
|
+
ListLanguagesSchema,
|
|
31
|
+
languagesHandler,
|
|
32
|
+
LanguageSchema,
|
|
33
|
+
languageHandler,
|
|
34
|
+
UpdateProductSupplySchema,
|
|
35
|
+
updateProductSupplyHandler,
|
|
36
|
+
UpdateProductPlanSchema,
|
|
37
|
+
updateProductPlanHandler,
|
|
38
|
+
UpdateProductTokenizationSchema,
|
|
39
|
+
updateProductTokenizationHandler,
|
|
40
|
+
ProductsCountSchema,
|
|
41
|
+
productsCountHandler,
|
|
42
|
+
CreateProductVariationSchema,
|
|
43
|
+
createProductVariationHandler,
|
|
44
|
+
RemoveProductVariationSchema,
|
|
45
|
+
removeProductVariationHandler,
|
|
46
|
+
AssignProductVariationSchema,
|
|
47
|
+
addProductAssignmentHandler,
|
|
48
|
+
CreateProductVariationOptionSchema,
|
|
49
|
+
createProductVariationOptionHandler,
|
|
50
|
+
removeProductAssignmentHandler,
|
|
51
|
+
RemoveProductVariationOptionSchema,
|
|
52
|
+
removeProductVariationOptionHandler,
|
|
53
|
+
RemoveProductAssignmentSchema,
|
|
54
|
+
CreateLanguageSchema,
|
|
55
|
+
createLanguageHandler,
|
|
56
|
+
UpdateLanguageSchema,
|
|
57
|
+
updateLanguageHandler,
|
|
58
|
+
RemoveLanguageSchema,
|
|
59
|
+
removeLanguageHandler,
|
|
60
|
+
AddProductMediaUploadSchema,
|
|
61
|
+
addProductMediaUploadHandler,
|
|
62
|
+
RemoveProductMediaSchema,
|
|
63
|
+
removeProductMediaHandler,
|
|
64
|
+
UpdateProductMediaTextsSchema,
|
|
65
|
+
updateProductMediaTextsHandler,
|
|
66
|
+
ReorderProductMediaSchema,
|
|
67
|
+
reorderProductMediaHandler,
|
|
68
|
+
ProductReviewsCountSchema,
|
|
69
|
+
productReviewsCountHandler,
|
|
70
|
+
ProductReviewsSchema,
|
|
71
|
+
productReviewsHandler,
|
|
72
|
+
} from './tools/index.js';
|
|
73
|
+
|
|
74
|
+
export default function createMcpServer(context: Context, roles) {
|
|
75
|
+
const server = new McpServer({
|
|
76
|
+
name: 'Unchained MCP Server',
|
|
77
|
+
version: '1.0.0',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (!roles?.includes('admin')) {
|
|
81
|
+
return server;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
server.tool(
|
|
85
|
+
'list_products',
|
|
86
|
+
'Search and list products with comprehensive filtering and pagination support',
|
|
87
|
+
ListProductsSchema,
|
|
88
|
+
async (params) => listProductsHandler(context, params),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
server.tool(
|
|
92
|
+
'products_count',
|
|
93
|
+
'Search and returns total number of products registered in the system with comprehensive filtering if provided',
|
|
94
|
+
ProductsCountSchema,
|
|
95
|
+
async (params) => productsCountHandler(context, params),
|
|
96
|
+
);
|
|
97
|
+
server.tool('get_product', 'Get detailed product information', GetProductSchema, async (params) =>
|
|
98
|
+
getProductHandler(context, params),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
server.tool(
|
|
102
|
+
'create_product',
|
|
103
|
+
'Adds or create new product the product will be in DRAFT/unpublish status',
|
|
104
|
+
CreateProductSchema,
|
|
105
|
+
async (params) => createProductHandler(context, params),
|
|
106
|
+
);
|
|
107
|
+
server.tool(
|
|
108
|
+
'remove_product',
|
|
109
|
+
'Removed or deletes a product by its id changing its status to DELETED and removing it from sale',
|
|
110
|
+
RemoveProductSchema,
|
|
111
|
+
async (params) => removeProductHandler(context, params),
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
server.tool(
|
|
115
|
+
'publish_product',
|
|
116
|
+
'Publish a product by its id changing it to active and available for sale',
|
|
117
|
+
PublishProductSchema,
|
|
118
|
+
async (params) => publishProductHandler(context, params),
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
server.tool(
|
|
122
|
+
'unpublish_product',
|
|
123
|
+
'Deactivates or Unpublishes product by its id changing it to DRAFT and not available for sale',
|
|
124
|
+
UnpublishProductSchema,
|
|
125
|
+
async (params) => unpublishProductHandler(context, params),
|
|
126
|
+
);
|
|
127
|
+
server.tool(
|
|
128
|
+
'update_product',
|
|
129
|
+
'Modify/Update generic infos of a product (tags for ex.)',
|
|
130
|
+
UpdateProductSchema,
|
|
131
|
+
async (params) => updateProductHandler(context, params),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
server.tool(
|
|
135
|
+
'update_product_texts',
|
|
136
|
+
'Modify/update localized texts of a product',
|
|
137
|
+
UpdateProductTextsSchema,
|
|
138
|
+
async (params) => updateProductTextsHandler(context, params),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
server.tool(
|
|
142
|
+
'update_product_commerce',
|
|
143
|
+
'Modify/update products commerce info like prices, taxes, etc. for all product types except CONFIGURABLE_PRODUCT. for currency value always use registered currency in the system and not a custom one, it should not be called for CONFIGURABLE_PRODUCT type products',
|
|
144
|
+
UpdateProductCommerceSchema,
|
|
145
|
+
async (params) => updateProductCommerceHandler(context, params),
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
server.tool(
|
|
149
|
+
'update_product_warehousing',
|
|
150
|
+
'Modify/update products commerce info like prices, taxes, etc. for SIMPLE_PRODUCT product type only. it is only available for SIMPLE_PRODUCT type products',
|
|
151
|
+
UpdateProductCommerceSchema,
|
|
152
|
+
async (params) => updateProductCommerceHandler(context, params),
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
server.tool(
|
|
156
|
+
'update_product_supply',
|
|
157
|
+
'Modify/update products supply of SIMPLE_PRODUCT type info like prices, taxes, etc. it is only available for SIMPLE_PRODUCT type products',
|
|
158
|
+
UpdateProductSupplySchema,
|
|
159
|
+
async (params) => updateProductSupplyHandler(context, params),
|
|
160
|
+
);
|
|
161
|
+
server.tool(
|
|
162
|
+
'update_tokenized_product',
|
|
163
|
+
'Modify/update products supply of TOKENIZED_PRODUCT type info like contractAddress, contractStandard, tokenId, supply, ercMetadataProperties etc. it is only available for TOKENIZED_PRODUCT type products',
|
|
164
|
+
UpdateProductTokenizationSchema,
|
|
165
|
+
async (params) => updateProductTokenizationHandler(context, params),
|
|
166
|
+
);
|
|
167
|
+
server.tool(
|
|
168
|
+
'update_product_plan',
|
|
169
|
+
'Modify/update products subscription/plan information of PLAN_PRODUCT type info like billing period, trial period and usage calculation, etc. it is only available for PLAN_PRODUCT type products',
|
|
170
|
+
UpdateProductPlanSchema,
|
|
171
|
+
async (params) => updateProductPlanHandler(context, params),
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
server.tool(
|
|
175
|
+
'list_currencies',
|
|
176
|
+
'List all available currencies in the system, when currency is required and not implicitly provided use this tool to get the list of available currencies also if non existing currency is provided to you by a user inform them it does not exist and to create it first before they can use it',
|
|
177
|
+
ListCurrenciesSchema,
|
|
178
|
+
async (params) => currenciesHandler(context, params),
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
server.tool(
|
|
182
|
+
'get_currency',
|
|
183
|
+
'Gets a single currency registered in the system',
|
|
184
|
+
CurrencySchema,
|
|
185
|
+
async (params) => currencyHandler(context, params),
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
server.tool(
|
|
189
|
+
'list_countries',
|
|
190
|
+
'List all available countries in the system, when country is required and not implicitly provided use this tool to get the list of available countries also if non existing country is provided to you by a user inform them it does not exist and to create it first before they can use it',
|
|
191
|
+
ListCountriesSchema,
|
|
192
|
+
async (params) => countriesHandler(context, params),
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
server.tool(
|
|
196
|
+
'get_country',
|
|
197
|
+
'Gets a single country registered in the system',
|
|
198
|
+
CountrySchema,
|
|
199
|
+
async (params) => countryHandler(context, params),
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
server.tool(
|
|
203
|
+
'list_languages',
|
|
204
|
+
'List all available languages in the system, when language is required and not implicitly provided use this tool to get the list of available languages also if non existing language is provided to you by a user inform them it does not exist and to create it first before they can use it',
|
|
205
|
+
ListLanguagesSchema,
|
|
206
|
+
async (params) => languagesHandler(context, params),
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
server.tool(
|
|
210
|
+
'get_language',
|
|
211
|
+
'Gets a single language registered in the system',
|
|
212
|
+
LanguageSchema,
|
|
213
|
+
async (params) => languageHandler(context, params),
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
server.tool(
|
|
217
|
+
'create_product_variation',
|
|
218
|
+
'Adds/create a variation of a product, it is only available for CONFIGURABLE_PRODUCT type products',
|
|
219
|
+
CreateProductVariationSchema,
|
|
220
|
+
async (params) => createProductVariationHandler(context, params),
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
server.tool(
|
|
224
|
+
'remove_product_variation',
|
|
225
|
+
'removes a variation of a product',
|
|
226
|
+
RemoveProductVariationSchema,
|
|
227
|
+
async (params) => removeProductVariationHandler(context, params),
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
server.tool(
|
|
231
|
+
'assign_product_variation',
|
|
232
|
+
'Link a product to a ConfigurableProduct variation option by providing a vector combination that uniquely identifies the variation option',
|
|
233
|
+
AssignProductVariationSchema,
|
|
234
|
+
async (params) => addProductAssignmentHandler(context, params),
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
server.tool(
|
|
238
|
+
'add_variation_options',
|
|
239
|
+
'Adds variation option to an existing product variations',
|
|
240
|
+
CreateProductVariationOptionSchema,
|
|
241
|
+
async (params) => createProductVariationOptionHandler(context, params),
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
server.tool(
|
|
245
|
+
'remove_variation_options',
|
|
246
|
+
'Removes product option value for product variation with the provided variation option value',
|
|
247
|
+
RemoveProductVariationOptionSchema,
|
|
248
|
+
async (params) => removeProductVariationOptionHandler(context, params),
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
server.tool(
|
|
252
|
+
'remove_product_variation_assignment',
|
|
253
|
+
'Unlinks a product from a ConfigurableProduct by providing a configuration combination that uniquely identifies a row in the assignment matrix',
|
|
254
|
+
RemoveProductAssignmentSchema,
|
|
255
|
+
async (params) => removeProductAssignmentHandler(context, params),
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
server.tool('add_language', 'Adds new language', CreateLanguageSchema, async (params) =>
|
|
259
|
+
createLanguageHandler(context, params),
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
server.tool('update_language', 'Updates language', UpdateLanguageSchema, async (params) =>
|
|
263
|
+
updateLanguageHandler(context, params),
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
server.tool('remove_language', 'Deletes a language', RemoveLanguageSchema, async (params) =>
|
|
267
|
+
removeLanguageHandler(context, params),
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
server.tool(
|
|
271
|
+
'add_product_media',
|
|
272
|
+
'Adds media to a product',
|
|
273
|
+
AddProductMediaUploadSchema,
|
|
274
|
+
async (params) => addProductMediaUploadHandler(context, params),
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
server.tool(
|
|
278
|
+
'remove_product_media',
|
|
279
|
+
"Remove a media asset from a product's visualization",
|
|
280
|
+
RemoveProductMediaSchema,
|
|
281
|
+
async (params) => removeProductMediaHandler(context, params),
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
server.tool(
|
|
285
|
+
'update_product_media_texts',
|
|
286
|
+
"Modify localized texts part of a product's media asset",
|
|
287
|
+
UpdateProductMediaTextsSchema,
|
|
288
|
+
async (params) => updateProductMediaTextsHandler(context, params),
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
server.tool(
|
|
292
|
+
'reorder_product_media',
|
|
293
|
+
'Reorder a media asset (first is primary)',
|
|
294
|
+
ReorderProductMediaSchema,
|
|
295
|
+
async (params) => reorderProductMediaHandler(context, params),
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
server.tool(
|
|
299
|
+
'product_review_count',
|
|
300
|
+
'Returns total number of product reviews',
|
|
301
|
+
ProductReviewsCountSchema,
|
|
302
|
+
async (params) => productReviewsCountHandler(context, params),
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
server.tool(
|
|
306
|
+
'product_reviews',
|
|
307
|
+
' Get all product reviews, by default sorted by creation date (descending)',
|
|
308
|
+
ProductReviewsSchema,
|
|
309
|
+
async (params) => productReviewsHandler(context, params),
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
return server;
|
|
313
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
4
|
+
import {
|
|
5
|
+
ProductNotFoundError,
|
|
6
|
+
ProductVariationVectorAlreadySet,
|
|
7
|
+
ProductVariationVectorInvalid,
|
|
8
|
+
ProductWrongTypeError,
|
|
9
|
+
} from '../../errors.js';
|
|
10
|
+
import { ProductConfiguration, ProductTypes } from '@unchainedshop/core-products';
|
|
11
|
+
|
|
12
|
+
const extractVariationMatrix = (variations = []) => {
|
|
13
|
+
const cartesianProduct = (arrays) => {
|
|
14
|
+
return arrays.reduce(
|
|
15
|
+
(acc, array) => acc.flatMap((item) => array.map((value) => [...item, value])),
|
|
16
|
+
[[]],
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
const keys = variations.map((item) => item.key);
|
|
20
|
+
const options = variations.map((item) => item.options);
|
|
21
|
+
const combinations = cartesianProduct(options);
|
|
22
|
+
return combinations.map((combination) =>
|
|
23
|
+
combination.reduce((acc, value, index) => {
|
|
24
|
+
acc[keys[index]] = value;
|
|
25
|
+
return acc;
|
|
26
|
+
}, {}),
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const combinationExists = (matrix, combination) => {
|
|
31
|
+
return matrix.some((variation) => {
|
|
32
|
+
return (
|
|
33
|
+
Object.keys(variation).length === Object.keys(combination).length && // Ensure both have the same number of keys
|
|
34
|
+
Object.entries(combination).every(([key, value]) => variation[key] === value)
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Zod schema for ProductAssignmentVectorInput
|
|
40
|
+
const ProductAssignmentVectorSchema = z.object({
|
|
41
|
+
key: z.string().min(1).describe('Attribute key (e.g., "Color", "Size")'),
|
|
42
|
+
value: z.string().min(1).describe('Attribute value (e.g., "Red", "M")'),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const AssignProductVariationSchema = {
|
|
46
|
+
proxyId: z.string().min(1).describe('should be ID of the CONFIGURABLE_PRODUCT (parent) only'),
|
|
47
|
+
productId: z
|
|
48
|
+
.string()
|
|
49
|
+
.min(1)
|
|
50
|
+
.describe('ID of the product being assigned. can not be a CONFIGURABLE_PRODUCT product'),
|
|
51
|
+
vectors: z
|
|
52
|
+
.array(ProductAssignmentVectorSchema)
|
|
53
|
+
.min(1)
|
|
54
|
+
.describe('Combination of attributes uniquely identifying the variant'),
|
|
55
|
+
};
|
|
56
|
+
// Full schema for the mutation
|
|
57
|
+
export const AddProductAssignmentZodSchema = z.object(AssignProductVariationSchema);
|
|
58
|
+
|
|
59
|
+
export type AddProductAssignmentParams = z.infer<typeof AddProductAssignmentZodSchema>;
|
|
60
|
+
|
|
61
|
+
export async function addProductAssignmentHandler(context: Context, params: AddProductAssignmentParams) {
|
|
62
|
+
const { proxyId, productId, vectors } = params;
|
|
63
|
+
const { modules } = context;
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const proxyProduct = await modules.products.findProduct({
|
|
67
|
+
productId: proxyId,
|
|
68
|
+
});
|
|
69
|
+
if (!proxyProduct) throw new ProductNotFoundError({ proxyId });
|
|
70
|
+
|
|
71
|
+
if (proxyProduct.type !== ProductTypes.ConfigurableProduct)
|
|
72
|
+
throw new ProductWrongTypeError({
|
|
73
|
+
proxyId,
|
|
74
|
+
received: proxyProduct.type,
|
|
75
|
+
required: ProductTypes.ConfigurableProduct,
|
|
76
|
+
});
|
|
77
|
+
const variations = await modules.products.variations.findProductVariations({
|
|
78
|
+
productId: proxyId,
|
|
79
|
+
});
|
|
80
|
+
const variationMatrix = extractVariationMatrix(variations);
|
|
81
|
+
const normalizedVectors = vectors?.reduce((prev, { key, value }) => {
|
|
82
|
+
return {
|
|
83
|
+
...prev,
|
|
84
|
+
[key]: value,
|
|
85
|
+
};
|
|
86
|
+
}, {});
|
|
87
|
+
if (!combinationExists(variationMatrix, normalizedVectors))
|
|
88
|
+
throw new ProductVariationVectorInvalid({ proxyId, vectors });
|
|
89
|
+
|
|
90
|
+
const added = await modules.products.assignments.addProxyAssignment({
|
|
91
|
+
productId,
|
|
92
|
+
proxyId,
|
|
93
|
+
vectors: vectors as ProductConfiguration[],
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (!added) throw new ProductVariationVectorAlreadySet({ proxyId, vectors });
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{
|
|
101
|
+
type: 'text' as const,
|
|
102
|
+
text: JSON.stringify({
|
|
103
|
+
product: await getNormalizedProductDetails(proxyId, context),
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return {
|
|
110
|
+
content: [
|
|
111
|
+
{
|
|
112
|
+
type: 'text' as const,
|
|
113
|
+
text: `Error assigning product: ${(error as Error).message}`,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
import { log } from '@unchainedshop/logger';
|
|
4
|
+
import { FileNotFoundError, FileUploadExpiredError } from '../../errors.js';
|
|
5
|
+
|
|
6
|
+
export const AddProductMediaUploadSchema = {
|
|
7
|
+
mediaName: z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.describe('Name of the media file (e.g. "image.png") use random name if not provided'),
|
|
11
|
+
productId: z.string().min(1).describe('ID of the product to link media to'),
|
|
12
|
+
url: z.string().describe('Anonymously fetchable URL of the source media, can be a data URL too'),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const AddProductMediaUploadZodSchema = z.object(AddProductMediaUploadSchema);
|
|
16
|
+
|
|
17
|
+
export type AddProductMediaUploadParams = z.infer<typeof AddProductMediaUploadZodSchema>;
|
|
18
|
+
|
|
19
|
+
export async function addProductMediaUploadHandler(
|
|
20
|
+
context: Context,
|
|
21
|
+
params: AddProductMediaUploadParams,
|
|
22
|
+
) {
|
|
23
|
+
const { mediaName, productId, url } = params;
|
|
24
|
+
const { modules, services, userId } = context;
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
log('addProductMediaUploadHandler', { mediaName, productId, userId, url });
|
|
28
|
+
const {
|
|
29
|
+
_id: fileId,
|
|
30
|
+
putURL,
|
|
31
|
+
type,
|
|
32
|
+
size,
|
|
33
|
+
} = await services.files.createSignedURL({
|
|
34
|
+
directoryName: 'product-media',
|
|
35
|
+
fileName: mediaName,
|
|
36
|
+
meta: { productId },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const sourceResponse = await fetch(url);
|
|
40
|
+
const uploadUrl = new URL(putURL, process.env.ROOT_URL || 'http://localhost:4010');
|
|
41
|
+
const uploadResponse = await fetch(uploadUrl, {
|
|
42
|
+
method: 'PUT',
|
|
43
|
+
body: sourceResponse.body,
|
|
44
|
+
duplex: 'half',
|
|
45
|
+
} as RequestInit);
|
|
46
|
+
|
|
47
|
+
if (!uploadResponse.ok) {
|
|
48
|
+
throw new Error(`Upload failed: ${uploadResponse.status} ${uploadResponse.statusText}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const file = await modules.files.findFile({ fileId });
|
|
52
|
+
if (!file) throw new FileNotFoundError({ fileId });
|
|
53
|
+
|
|
54
|
+
if (file.expires && new Date(file.expires).getTime() < Date.now()) {
|
|
55
|
+
throw new FileUploadExpiredError({ fileId });
|
|
56
|
+
}
|
|
57
|
+
const linked = await services.files.linkFile({ fileId, size, type });
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text' as const,
|
|
63
|
+
text: JSON.stringify({
|
|
64
|
+
file: linked,
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
} catch (error) {
|
|
70
|
+
return {
|
|
71
|
+
content: [
|
|
72
|
+
{
|
|
73
|
+
type: 'text' as const,
|
|
74
|
+
text: `Error uploading product media: ${(error as Error).message}`,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|