@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
|
@@ -8,16 +8,20 @@ const notFoundHandler = (res) => {
|
|
|
8
8
|
};
|
|
9
9
|
const ercMetadataHandler = async (req, res) => {
|
|
10
10
|
try {
|
|
11
|
-
const { services,
|
|
11
|
+
const { services, modules, locale, loaders } = req.unchainedContext;
|
|
12
12
|
const url = new URL(req.url, ROOT_URL);
|
|
13
13
|
if (!url.pathname.toLowerCase().endsWith('.json'))
|
|
14
14
|
throw new Error('Invalid ERC Metadata URI');
|
|
15
15
|
const { productId, localeOrTokenFilename, tokenFileName } = req.params;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
productId,
|
|
19
|
-
locale,
|
|
16
|
+
const product = await loaders.productLoader.load({ productId });
|
|
17
|
+
const [token] = await modules.warehousing.findTokens({
|
|
20
18
|
chainTokenId: (tokenFileName || localeOrTokenFilename).toLowerCase().replace('.json', ''),
|
|
19
|
+
contractAddress: product?.tokenization?.contractAddress,
|
|
20
|
+
});
|
|
21
|
+
const ercMetadata = await services.warehousing.ercMetadata({
|
|
22
|
+
product,
|
|
23
|
+
token,
|
|
24
|
+
locale: tokenFileName ? new Intl.Locale(localeOrTokenFilename) : locale,
|
|
21
25
|
});
|
|
22
26
|
if (!ercMetadata)
|
|
23
27
|
return notFoundHandler(res);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ercMetadataHandler.js","sourceRoot":"","sources":["../../src/fastify/ercMetadataHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIrD,MAAM,MAAM,GAAG,YAAY,CAAC,wBAAwB,CAAC,CAAC;AAEtD,MAAM,EAAE,QAAQ,GAAG,uBAAuB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE3D,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,EAAE;IAC9B,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACjD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChB,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAuB,KAAK,EAClD,GAAmD,EACnD,GAAG,EACH,EAAE;IACF,IAAI,CAAC;QACH,MAAM,EAAE,QA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A,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fastify/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAkB,MAAM,SAAS,CAAC;AAoF7E,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,iBAehD,CAAC;AAEF,eAAO,MAAM,OAAO,GAClB,SAAS,eAAe,EACxB,yBAGG;IACD,cAAc,EAAE,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC7C,EAAE,EAAE,OAAO,CAAC,EAAE,CAAC;IACf,YAAY,EAAE,aAAa,CAAC;CAC7B,EACD,2CAEG;IAAE,mCAAmC,CAAC,EAAE,OAAO,CAAA;CAAO,SA6G1D,CAAC"}
|
package/lib/fastify/index.js
CHANGED
|
@@ -6,7 +6,10 @@ import { emit } from '@unchainedshop/events';
|
|
|
6
6
|
import { API_EVENTS } from '../events.js';
|
|
7
7
|
import fastifySession from '@fastify/session';
|
|
8
8
|
import fastifyCookie from '@fastify/cookie';
|
|
9
|
+
import fastifyMultipart from '@fastify/multipart';
|
|
9
10
|
import { createLogger } from '@unchainedshop/logger';
|
|
11
|
+
import mcpHandler from './mcpHandler.js';
|
|
12
|
+
import tempUploadHandler from './tempUploadHandler.js';
|
|
10
13
|
const resolveUserRemoteAddress = (req) => {
|
|
11
14
|
const remoteAddress = req.headers['x-real-ip'] ||
|
|
12
15
|
req.headers['x-forwarded-for'] ||
|
|
@@ -14,7 +17,7 @@ const resolveUserRemoteAddress = (req) => {
|
|
|
14
17
|
const remotePort = req.socket?.remotePort;
|
|
15
18
|
return { remoteAddress, remotePort };
|
|
16
19
|
};
|
|
17
|
-
const { GRAPHQL_API_PATH = '/graphql', BULK_IMPORT_API_PATH = '/bulk-import', ERC_METADATA_API_PATH = '/erc-metadata/:productId/:localeOrTokenFilename/:tokenFileName?', UNCHAINED_COOKIE_NAME = 'unchained_token', UNCHAINED_COOKIE_PATH = '/', UNCHAINED_COOKIE_DOMAIN, UNCHAINED_COOKIE_SAMESITE, UNCHAINED_COOKIE_INSECURE, } = process.env;
|
|
20
|
+
const { MCP_API_PATH = '/mcp', GRAPHQL_API_PATH = '/graphql', BULK_IMPORT_API_PATH = '/bulk-import', TEMP_UPLOAD_API_PATH = '/temp-upload', ERC_METADATA_API_PATH = '/erc-metadata/:productId/:localeOrTokenFilename/:tokenFileName?', UNCHAINED_COOKIE_NAME = 'unchained_token', UNCHAINED_COOKIE_PATH = '/', UNCHAINED_COOKIE_DOMAIN, UNCHAINED_COOKIE_SAMESITE, UNCHAINED_COOKIE_INSECURE, } = process.env;
|
|
18
21
|
const middlewareHook = async function middlewareHook(req, reply) {
|
|
19
22
|
const setHeader = (key, value) => reply.header(key, value);
|
|
20
23
|
const getHeader = (key) => req.headers[key];
|
|
@@ -27,16 +30,13 @@ const middlewareHook = async function middlewareHook(req, reply) {
|
|
|
27
30
|
const tokenObject = {
|
|
28
31
|
_id: req.session.sessionId,
|
|
29
32
|
userId: user._id,
|
|
30
|
-
// eslint-disable-next-line
|
|
31
33
|
tokenExpires: new Date(req.session.cookie._expires),
|
|
32
34
|
};
|
|
33
35
|
await emit(API_EVENTS.API_LOGIN_TOKEN_CREATED, tokenObject);
|
|
34
|
-
/* eslint-disable-next-line */
|
|
35
36
|
user._inLoginMethodResponse = true;
|
|
36
37
|
return { user, ...tokenObject };
|
|
37
38
|
};
|
|
38
39
|
const logout = async function logout() {
|
|
39
|
-
/* eslint-disable-line */
|
|
40
40
|
const tokenObject = {
|
|
41
41
|
_id: req.session.sessionId,
|
|
42
42
|
userId: req.session?.userId,
|
|
@@ -82,9 +82,13 @@ export const connect = (fastify, { graphqlHandler, db, }, { allowRemoteToLocalho
|
|
|
82
82
|
fastify.addHook('preHandler', async function (request) {
|
|
83
83
|
request.headers['x-forwarded-proto'] = 'https';
|
|
84
84
|
});
|
|
85
|
-
fastify.addHook('onSend', async function (
|
|
85
|
+
fastify.addHook('onSend', async function (req, reply) {
|
|
86
86
|
reply.headers({
|
|
87
87
|
'Access-Control-Allow-Private-Network': 'true',
|
|
88
|
+
'Access-Control-Allow-Origin': req.headers.origin || '*',
|
|
89
|
+
'Access-Control-Allow-Credentials': 'true',
|
|
90
|
+
'Access-Control-Allow-Methods': ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'].join(', '),
|
|
91
|
+
'Access-Control-Allow-Headers': req.headers['access-control-request-headers'] || '*',
|
|
88
92
|
});
|
|
89
93
|
});
|
|
90
94
|
}
|
|
@@ -143,6 +147,21 @@ export const connect = (fastify, { graphqlHandler, db, }, { allowRemoteToLocalho
|
|
|
143
147
|
method: ['GET'],
|
|
144
148
|
handler: ercMetadataHandler,
|
|
145
149
|
});
|
|
150
|
+
fastify.route({
|
|
151
|
+
url: MCP_API_PATH,
|
|
152
|
+
method: ['GET', 'POST', 'DELETE'],
|
|
153
|
+
handler: mcpHandler,
|
|
154
|
+
});
|
|
155
|
+
fastify.register((s, opts, registered) => {
|
|
156
|
+
s.register(fastifyMultipart);
|
|
157
|
+
s.route({
|
|
158
|
+
url: TEMP_UPLOAD_API_PATH,
|
|
159
|
+
method: ['POST'],
|
|
160
|
+
bodyLimit: 1024 * 1024 * 35, // 35MB
|
|
161
|
+
handler: tempUploadHandler,
|
|
162
|
+
});
|
|
163
|
+
registered();
|
|
164
|
+
});
|
|
146
165
|
fastify.register((s, opts, registered) => {
|
|
147
166
|
s.removeAllContentTypeParsers();
|
|
148
167
|
s.addContentTypeParser('*', function (req, payload, done) {
|
package/lib/fastify/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fastify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAqB,MAAM,eAAe,CAAC;AAC7E,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,UAAU,MAAM,eAAe,CAAC;AAIvC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,aAAa,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fastify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAqB,MAAM,eAAe,CAAC;AAC7E,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,UAAU,MAAM,eAAe,CAAC;AAIvC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD,MAAM,wBAAwB,GAAG,CAAC,GAAmB,EAAE,EAAE;IACvD,MAAM,aAAa,GAChB,GAAG,CAAC,OAAO,CAAC,WAAW,CAAY;QACnC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAY;Q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,MAAM,CAAC;YAChB,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,EAAE,EAAE,OAAO;YACpC,OAAO,EAAE,iBAAiB;SAC3B,CAAC,CAAC;QACH,UAAU,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE;QACvC,CAAC,CAAC,2BAA2B,EAAE,CAAC;QAChC,CAAC,CAAC,oBAAoB,CAAC,GAAG,EAAE,UAAU,GAAG,EAAE,OAAO,EAAE,IAAI;YACtD,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,KAAK,CAAC;YACN,GAAG,EAAE,oBAAoB;YACzB,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM;YACzC,OAAO,EAAE,iBAAiB;SAC3B,CAAC,CAAC;QACH,UAAU,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpChatHandler.d.ts","sourceRoot":"","sources":["../../src/fastify/mcpChatHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAuB7D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,iBAAiB,KAAA,sBAgD5D"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
import { experimental_createMCPClient as createMCPClient, InvalidToolArgumentsError, NoSuchToolError, ToolExecutionError, streamText, } from 'ai';
|
|
3
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
4
|
+
const logger = createLogger('unchained:mcp-chat-handler');
|
|
5
|
+
const { ROOT_URL } = process.env;
|
|
6
|
+
const errorHandler = (error) => {
|
|
7
|
+
if (NoSuchToolError.isInstance(error))
|
|
8
|
+
return 'NoSuchToolError';
|
|
9
|
+
if (InvalidToolArgumentsError.isInstance(error))
|
|
10
|
+
return 'InvalidToolArgumentsError';
|
|
11
|
+
if (ToolExecutionError.isInstance(error))
|
|
12
|
+
return 'ToolExecutionError';
|
|
13
|
+
if (error?.message?.toLowerCase() === 'forbidden')
|
|
14
|
+
return 'NetworkError';
|
|
15
|
+
logger.error(error);
|
|
16
|
+
return `Failed to stream response: ${error?.message || 'Unknown error'}`;
|
|
17
|
+
};
|
|
18
|
+
export default function setupMCPChatHandler(chatConfiguration) {
|
|
19
|
+
let client;
|
|
20
|
+
if (!chatConfiguration || !chatConfiguration?.model)
|
|
21
|
+
return null;
|
|
22
|
+
const { tools = {}, ...restChatConfig } = chatConfiguration || {};
|
|
23
|
+
const mcpChatHandler = async (req, res) => {
|
|
24
|
+
try {
|
|
25
|
+
if (req.method === 'OPTIONS')
|
|
26
|
+
return res.send();
|
|
27
|
+
const { messages } = req.body;
|
|
28
|
+
client = await createMCPClient({
|
|
29
|
+
transport: new StreamableHTTPClientTransport(new URL(`${ROOT_URL}/mcp`), {
|
|
30
|
+
requestInit: {
|
|
31
|
+
headers: {
|
|
32
|
+
Cookie: req.headers.cookie || '',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
const defaultUnchainedTools = await client.tools();
|
|
38
|
+
const result = streamText({
|
|
39
|
+
...restChatConfig,
|
|
40
|
+
messages,
|
|
41
|
+
tools: { ...defaultUnchainedTools, ...tools },
|
|
42
|
+
onFinish: async () => {
|
|
43
|
+
await client?.close();
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
res.header('X-Vercel-AI-Data-Stream', 'v1');
|
|
47
|
+
res.header('Content-Type', 'text/plain; charset=utf-8');
|
|
48
|
+
return res.send(result.toDataStream({
|
|
49
|
+
getErrorMessage: errorHandler,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
logger.error(e.message);
|
|
54
|
+
res.status(503);
|
|
55
|
+
return res.send(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return mcpChatHandler;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=mcpChatHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpChatHandler.js","sourceRoot":"","sources":["../../src/fastify/mcpChatHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EACL,4BAA4B,IAAI,eAAe,EAC/C,yBAAyB,EACzB,eAAe,EACf,kBAAkB,EAClB,UAAU,GACX,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,MAAM,MAAM,GAAG,YAAY,CAAC,4BAA4B,CAAC,CAAC;AAE1D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEjC,MAAM,YAAY,GAAG,CAAC,KAAU,EAAU,EAAE;IAC1C,IAAI,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,iBAAiB,CAAC;IAChE,IAAI,yBAAyB,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,2BAA2B,CAAC;IACpF,IAAI,kBAAkB,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,oBAAoB,CAAC;IACtE,IAAI,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW;QAAE,OAAO,cAAc,CAAC;IACzE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpB,OAAO,8BAA8B,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,CAAC;AAC3E,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU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E,YAAY;aAC9B,CAAC,CACH,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACxB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChB,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACtF,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpHandler copy.d.ts","sourceRoot":"","sources":["../../src/fastify/mcpHandler copy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAS7D,QAAA,MAAM,UAAU,EAAE,kBAsEjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
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
|
+
const logger = createLogger('unchained:mcp-handler');
|
|
6
|
+
const transports = {};
|
|
7
|
+
const mcpHandler = async (req, res) => {
|
|
8
|
+
try {
|
|
9
|
+
if (req.method === 'POST') {
|
|
10
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
11
|
+
let transport;
|
|
12
|
+
if (sessionId && transports[sessionId]) {
|
|
13
|
+
// Reuse existing transport
|
|
14
|
+
transport = transports[sessionId];
|
|
15
|
+
}
|
|
16
|
+
else if (!sessionId && isInitializeRequest(req.body)) {
|
|
17
|
+
// New initialization request
|
|
18
|
+
transport = new StreamableHTTPServerTransport({
|
|
19
|
+
sessionIdGenerator: () => crypto.randomUUID(),
|
|
20
|
+
onsessioninitialized: (sessionId) => {
|
|
21
|
+
// Store the transport by session ID
|
|
22
|
+
transports[sessionId] = transport;
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
// Clean up transport when closed
|
|
26
|
+
transport.onclose = () => {
|
|
27
|
+
if (transport.sessionId) {
|
|
28
|
+
delete transports[transport.sessionId];
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const server = createMcpServer(req.unchainedContext);
|
|
32
|
+
await server.connect(transport);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Invalid request
|
|
36
|
+
res.status(400);
|
|
37
|
+
return res.send(JSON.stringify({
|
|
38
|
+
jsonrpc: '2.0',
|
|
39
|
+
error: {
|
|
40
|
+
code: -32000,
|
|
41
|
+
message: 'Bad Request: No valid session ID provided',
|
|
42
|
+
},
|
|
43
|
+
id: null,
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
// Handle the request
|
|
47
|
+
// TODO: Fix
|
|
48
|
+
await transport.handleRequest(req, res, req.body);
|
|
49
|
+
return res;
|
|
50
|
+
}
|
|
51
|
+
else if (req.method === 'GET' || req.method === 'DELETE') {
|
|
52
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
53
|
+
if (!sessionId || !transports[sessionId]) {
|
|
54
|
+
res.status(400).send('Invalid or missing session ID');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const transport = transports[sessionId];
|
|
58
|
+
// TODO: Fix
|
|
59
|
+
await transport.handleRequest(req, res);
|
|
60
|
+
return res;
|
|
61
|
+
}
|
|
62
|
+
res.status(405);
|
|
63
|
+
return res.send('Method Not Allowed');
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
logger.error(e.message);
|
|
67
|
+
res.status(503);
|
|
68
|
+
return res.send(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
export default mcpHandler;
|
|
72
|
+
//# sourceMappingURL=mcpHandler%20copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpHandler copy.js","sourceRoot":"","sources":["../../src/fastify/mcpHandler copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,eAAe,MAAM,iBAAiB,CAAC;AAE9C,MAAM,MAAM,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAErD,MAAM,UAAU,GAAkD,EAAE,CAAC;AAErE,MAAM,UAAU,GAAuB,KAAK,EAC1C,GAAmD,EACnD,GAAG,EACH,EAAE;IACF,IAAI,CAAC;QACH,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC1B,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAuB,CAAC;YAEtE,IAAI,SAAwC,CAAC;YAE7C,IAAI,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;gBACvC,2BAA2B;gBAC3B,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;YACpC,CAAC;iBAAM,IAAI,CAAC,SAAS,IAAI,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvD,6BAA6B;gBAC7B,SAAS,GAAG,IAAI,6BAA6B,CAAC;oBAC5C,kBAAkB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE;oBAC7C,oBAAoB,EAAE,CAAC,SAAS,EAAE,EAAE;wBAClC,oCAAoC;wBACpC,UAAU,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;oBACpC,CAAC;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CAAC,GAAU,EAAE,GAAU,CAAC,CAAC;YACtD,OAAO,GAAG,CAAC;QACb,CAAC;QAED,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACxB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACtF,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpHandler.d.ts","sourceRoot":"","sources":["../../src/fastify/mcpHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAS7D,QAAA,MAAM,UAAU,EAAE,kBAmFjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
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
|
+
const logger = createLogger('unchained:mcp-handler');
|
|
6
|
+
const transports = {};
|
|
7
|
+
const mcpHandler = async (req, res) => {
|
|
8
|
+
if (!req.unchainedContext.user) {
|
|
9
|
+
res.status(401);
|
|
10
|
+
res.header('WWW-Authenticate', `Bearer realm="Unchained MCP", error="invalid_token", resource="${process.env.ROOT_URL || 'http://localhost:4010'}",`);
|
|
11
|
+
return res.send(JSON.stringify({
|
|
12
|
+
error: 'invalid_token',
|
|
13
|
+
resource_metadata: `${process.env.ROOT_URL || 'http://localhost:4010'}/.well-known/oauth-protected-resource`,
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
if (req.method === 'POST') {
|
|
18
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
19
|
+
let transport;
|
|
20
|
+
if (sessionId && transports[sessionId]) {
|
|
21
|
+
// Reuse existing transport
|
|
22
|
+
transport = transports[sessionId];
|
|
23
|
+
}
|
|
24
|
+
else if (!sessionId && isInitializeRequest(req.body)) {
|
|
25
|
+
// New initialization request
|
|
26
|
+
transport = new StreamableHTTPServerTransport({
|
|
27
|
+
sessionIdGenerator: () => crypto.randomUUID(),
|
|
28
|
+
onsessioninitialized: (sessionId) => {
|
|
29
|
+
// Store the transport by session ID
|
|
30
|
+
transports[sessionId] = transport;
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
// Clean up transport when closed
|
|
34
|
+
transport.onclose = () => {
|
|
35
|
+
if (transport.sessionId) {
|
|
36
|
+
delete transports[transport.sessionId];
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const roles = req.unchainedContext.user.roles || [];
|
|
40
|
+
const server = createMcpServer(req.unchainedContext, roles);
|
|
41
|
+
await server.connect(transport);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Invalid request
|
|
45
|
+
res.status(400);
|
|
46
|
+
return res.send(JSON.stringify({
|
|
47
|
+
jsonrpc: '2.0',
|
|
48
|
+
error: {
|
|
49
|
+
code: -32000,
|
|
50
|
+
message: 'Bad Request: No valid session ID provided',
|
|
51
|
+
},
|
|
52
|
+
id: null,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
await transport.handleRequest(req.raw, res.raw, req.body);
|
|
56
|
+
return res;
|
|
57
|
+
}
|
|
58
|
+
else if (req.method === 'GET' || req.method === 'DELETE') {
|
|
59
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
60
|
+
if (!sessionId || !transports[sessionId]) {
|
|
61
|
+
res.status(400).send('Invalid or missing session ID');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const transport = transports[sessionId];
|
|
65
|
+
await transport.handleRequest(req.raw, res.raw);
|
|
66
|
+
return res;
|
|
67
|
+
}
|
|
68
|
+
res.status(405);
|
|
69
|
+
return res.send('Method Not Allowed');
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
logger.error(e.message);
|
|
73
|
+
res.status(503);
|
|
74
|
+
return res.send(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
export default mcpHandler;
|
|
78
|
+
//# sourceMappingURL=mcpHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpHandler.js","sourceRoot":"","sources":["../../src/fastify/mcpHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,eAAe,MAAM,iBAAiB,CAAC;AAE9C,MAAM,MAAM,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAErD,MAAM,UAAU,GAAkD,EAAE,CAAC;AAErE,MAAM,UAAU,GAAuB,KAAK,EAC1C,GAAmD,EACnD,GAAG,EACH,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAC/B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,GAAG,CAAC,MAAM,CACR,kBAAkB,EAClB,kEAAkE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,uBAAuB,IAAI,CACtH,CAAC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G,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACtF,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempUploadHandler.d.ts","sourceRoot":"","sources":["../../src/fastify/tempUploadHandler.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAI7D,QAAA,MAAM,iBAAiB,EAAE,kBAwCxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
import { getFileAdapter } from '@unchainedshop/core-files';
|
|
3
|
+
import { checkAction } from '../acl.js';
|
|
4
|
+
import { actions } from '../roles/index.js';
|
|
5
|
+
const logger = createLogger('unchained:temp-upload');
|
|
6
|
+
const tempUploadHandler = async (req, res) => {
|
|
7
|
+
try {
|
|
8
|
+
const context = req.unchainedContext;
|
|
9
|
+
await checkAction(context, actions.uploadTempFile);
|
|
10
|
+
const data = await req.file();
|
|
11
|
+
const file = await context.services.files.uploadFileFromStream({
|
|
12
|
+
directoryName: 'temp-uploads',
|
|
13
|
+
rawFile: Promise.resolve({
|
|
14
|
+
filename: data.filename,
|
|
15
|
+
createReadStream: () => data.file,
|
|
16
|
+
mimetype: data.mimetype,
|
|
17
|
+
}),
|
|
18
|
+
meta: { fieldname: data.fieldname, encoding: data.encoding },
|
|
19
|
+
});
|
|
20
|
+
// Add an expiration date to this file manually!
|
|
21
|
+
const expires = new Date(Date.now() + 24 * 60 * 60 * 1000);
|
|
22
|
+
await context.modules.files.update(file._id, {
|
|
23
|
+
expires, // Default to 1 hour
|
|
24
|
+
});
|
|
25
|
+
const fileUploadAdapter = getFileAdapter();
|
|
26
|
+
const rawUrl = await fileUploadAdapter.createDownloadURL(file);
|
|
27
|
+
const url = context.modules.files.normalizeUrl(rawUrl, {});
|
|
28
|
+
const body = JSON.stringify({ fileId: file._id, url, expires: expires.toISOString() });
|
|
29
|
+
res.status(200);
|
|
30
|
+
res.header('Content-Length', Buffer.byteLength(body));
|
|
31
|
+
res.header('Content-Type', 'application/json');
|
|
32
|
+
return res.send(body);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
logger.error(e.message);
|
|
36
|
+
res.status(503);
|
|
37
|
+
return res.send(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export default tempUploadHandler;
|
|
41
|
+
//# sourceMappingURL=tempUploadHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempUploadHandler.js","sourceRoot":"","sources":["../../src/fastify/tempUploadHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAI5C,MAAM,MAAM,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAErD,MAAM,iBAAiB,GAAuB,KAAK,EACjD,GAA8D,EAC9D,GAAG,EACH,EAAE;IACF,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,GAAG,CAAC,gBAAgB,CAAC;QAErC,MAAM,WAAW,CAAC,OAAO,EAAG,OAAe,CAAC,cAAc,CAAC,CAAC;QAE5D,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAE9B,MAAM,IAAI,GA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AE,kBAAkB,CAAC,CAAC;QAC/C,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACxB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACtF,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export default function buildLocaleMap(queries:
|
|
2
|
-
locale:
|
|
3
|
-
}
|
|
1
|
+
export default function buildLocaleMap(queries: readonly {
|
|
2
|
+
locale: Intl.Locale;
|
|
3
|
+
}[], texts: readonly {
|
|
4
4
|
locale?: string;
|
|
5
|
-
}
|
|
5
|
+
}[]): Record<string, string[]>;
|
|
6
6
|
//# sourceMappingURL=buildLocaleMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildLocaleMap.d.ts","sourceRoot":"","sources":["../../src/loaders/buildLocaleMap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildLocaleMap.d.ts","sourceRoot":"","sources":["../../src/loaders/buildLocaleMap.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,EAAE,SAAS;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE,EAAE,EAC3C,KAAK,EAAE,SAAS;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,GACpC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAe1B"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { systemLocale } from '@unchainedshop/utils';
|
|
2
2
|
function getLocaleStrings(locale) {
|
|
3
3
|
try {
|
|
4
|
-
const localeObj = new Intl.Locale(locale);
|
|
5
|
-
// Optimized Set creation and spread
|
|
6
4
|
const locales = new Set();
|
|
7
|
-
locales.add(
|
|
8
|
-
locales.add(
|
|
5
|
+
locales.add(locale.baseName);
|
|
6
|
+
locales.add(locale.language);
|
|
9
7
|
locales.add(systemLocale.baseName);
|
|
10
8
|
locales.add(systemLocale.language);
|
|
11
9
|
return Array.from(locales);
|
|
@@ -30,9 +28,40 @@ export default function buildLocaleMap(queries, texts) {
|
|
|
30
28
|
for (const match of matches) {
|
|
31
29
|
if (!localeMap[match])
|
|
32
30
|
localeMap[match] = [];
|
|
33
|
-
localeMap[match].push(queryLocale);
|
|
31
|
+
localeMap[match].push(queryLocale.toString());
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
return localeMap;
|
|
37
35
|
}
|
|
36
|
+
// import { systemLocale } from '@unchainedshop/utils';
|
|
37
|
+
// export function getLocaleStrings(locale: Intl.Locale) {
|
|
38
|
+
// try {
|
|
39
|
+
// return [
|
|
40
|
+
// ...new Set([locale.baseName, locale.language, systemLocale.baseName, systemLocale.language]),
|
|
41
|
+
// ];
|
|
42
|
+
// } catch {
|
|
43
|
+
// return [...new Set([systemLocale.baseName, systemLocale.language])];
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
|
+
// export function buildLocaleMap(
|
|
47
|
+
// queries: readonly { locale: Intl.Locale }[],
|
|
48
|
+
// texts: readonly { locale?: string }[],
|
|
49
|
+
// ): Record<string, string[]> {
|
|
50
|
+
// // key = texts.locale
|
|
51
|
+
// // value = input query locale
|
|
52
|
+
// const queryLocales = Object.values(
|
|
53
|
+
// Object.fromEntries(queries.map((q) => [q.locale.baseName, q.locale])),
|
|
54
|
+
// );
|
|
55
|
+
// const textLocales: string[] = [...new Set(texts.map((t) => t.locale))];
|
|
56
|
+
// const localeMap = {};
|
|
57
|
+
// for (const queryLocale of queryLocales) {
|
|
58
|
+
// const potentialMatches = getLocaleStrings(queryLocale);
|
|
59
|
+
// const matches = potentialMatches.filter((l) => textLocales.includes(l));
|
|
60
|
+
// for (const match of matches) {
|
|
61
|
+
// if (!localeMap[match]) localeMap[match] = [];
|
|
62
|
+
// localeMap[match].push(queryLocale);
|
|
63
|
+
// }
|
|
64
|
+
// }
|
|
65
|
+
// return localeMap;
|
|
66
|
+
// }
|
|
38
67
|
//# sourceMappingURL=buildLocaleMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildLocaleMap.js","sourceRoot":"","sources":["../../src/loaders/buildLocaleMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,SAAS,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"buildLocaleMap.js","sourceRoot":"","sources":["../../src/loaders/buildLocaleMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,SAAS,gBAAgB,CAAC,MAAmB;IAC3C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,oCAAoC;QACpC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,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2CAA2C;AAC3C,gCAAgC;AAChC,0BAA0B;AAC1B,kCAAkC;AAElC,wCAAwC;AACxC,6EAA6E;AAC7E,OAAO;AAEP,4EAA4E;AAC5E,0BAA0B;AAC1B,8CAA8C;AAC9C,8DAA8D;AAC9D,+EAA+E;AAC/E,qCAAqC;AACrC,sDAAsD;AACtD,4CAA4C;AAC5C,QAAQ;AACR,MAAM;AACN,sBAAsB;AACtB,IAAI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type ArrayElement<T> = T extends (infer U)[] ? U : never;
|
|
2
|
-
export default function buildTextMap<T extends
|
|
2
|
+
export default function buildTextMap<T extends {
|
|
3
3
|
locale?: string;
|
|
4
|
-
}
|
|
4
|
+
}[]>(localeMap: Record<string, string[]>, texts: Readonly<T>, buildId: (item: ArrayElement<T>) => string): Record<string, ArrayElement<T>>;
|
|
5
5
|
export {};
|
|
6
6
|
//# sourceMappingURL=buildTextMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTextMap.d.ts","sourceRoot":"","sources":["../../src/loaders/buildTextMap.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAIzD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,SAAS
|
|
1
|
+
{"version":3,"file":"buildTextMap.d.ts","sourceRoot":"","sources":["../../src/loaders/buildTextMap.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAIzD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,SAAS;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EAClE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACnC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,MAAM,mCA8B3C"}
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
export default function buildTextMap(localeMap, texts, buildId) {
|
|
3
3
|
const textsMap = {}; // Added type for textsMap
|
|
4
4
|
const localeMapKeys = Object.keys(localeMap);
|
|
5
|
+
// eslint-disable-next-line
|
|
5
6
|
for (let i = 0; i < localeMapKeys.length; i++) {
|
|
6
7
|
const originLocale = localeMapKeys[i];
|
|
7
8
|
const localesForText = localeMap[originLocale];
|
|
9
|
+
// eslint-disable-next-line
|
|
8
10
|
for (let j = 0; j < texts.length; j++) {
|
|
9
11
|
const text = texts[j];
|
|
10
12
|
if (originLocale !== text.locale)
|
|
11
13
|
continue;
|
|
12
14
|
const idPart = buildId(text); // Ensured correct type for buildId argument
|
|
15
|
+
// eslint-disable-next-line
|
|
13
16
|
for (let k = 0; k < localesForText.length; k++) {
|
|
14
17
|
const locale = localesForText[k];
|
|
15
18
|
const key = locale + idPart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTextMap.js","sourceRoot":"","sources":["../../src/loaders/buildTextMap.ts"],"names":[],"mappings":"AAEA,oFAAoF;AAEpF,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,SAAmC,EACnC,KAAkB,EAClB,OAA0C;IAE1C,MAAM,QAAQ,GAAoC,EAAE,CAAC,CAAC,0BAA0B;IAChF,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,cAAc,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;QAE/C,KAAK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