@djust-b2b/djust-front-sdk 3.0.0-beta.9 → 3.0.1
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/README.md +34 -30
- package/dist/.tsbuildinfo +1 -1
- package/dist/.tsbuildinfo-esm +1 -1
- package/dist/client/create-client.d.ts +18 -0
- package/dist/client/create-client.d.ts.map +1 -1
- package/dist/client/transport.d.ts +5 -0
- package/dist/client/transport.d.ts.map +1 -1
- package/dist/errors/classes/not-found.error.d.ts +1 -1
- package/dist/errors/classes/not-found.error.d.ts.map +1 -1
- package/dist/errors/factory.d.ts.map +1 -1
- package/dist/errors/helpers/djust-api-error.d.ts +29 -0
- package/dist/errors/helpers/djust-api-error.d.ts.map +1 -0
- package/dist/errors/types.d.ts +4 -0
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/index.d.ts +42 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +269 -63
- package/dist/interfaces/index.d.ts +15 -3
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/services/base.service.d.ts +2 -0
- package/dist/services/base.service.d.ts.map +1 -1
- package/dist/services/commercial-order/commercial-order.service.d.ts +8 -5
- package/dist/services/commercial-order/commercial-order.service.d.ts.map +1 -1
- package/dist/services/commercial-order/definitions.d.ts +13 -0
- package/dist/services/commercial-order/definitions.d.ts.map +1 -1
- package/dist/services/commercial-order/index.d.ts +30 -19
- package/dist/services/commercial-order/index.d.ts.map +1 -1
- package/dist/services/commercial-order/module.d.ts +1 -1
- package/dist/services/commercial-order/module.d.ts.map +1 -1
- package/dist/services/commercial-order/types.d.ts +1 -0
- package/dist/services/commercial-order/types.d.ts.map +1 -1
- package/dist/services/logistic-order/definitions.d.ts +23 -1
- package/dist/services/logistic-order/definitions.d.ts.map +1 -1
- package/dist/services/logistic-order/endpoints.d.ts +1 -0
- package/dist/services/logistic-order/endpoints.d.ts.map +1 -1
- package/dist/services/logistic-order/index.d.ts +77 -1
- package/dist/services/logistic-order/index.d.ts.map +1 -1
- package/dist/services/logistic-order/logistic-order.service.d.ts +6 -1
- package/dist/services/logistic-order/logistic-order.service.d.ts.map +1 -1
- package/dist/services/logistic-order/module.d.ts +1 -1
- package/dist/services/logistic-order/module.d.ts.map +1 -1
- package/dist/services/logistic-order/types.d.ts +9 -0
- package/dist/services/logistic-order/types.d.ts.map +1 -1
- package/dist/services/operation/definitions.d.ts +1 -18
- package/dist/services/operation/definitions.d.ts.map +1 -1
- package/dist/services/payment/definitions.d.ts +0 -10
- package/dist/services/payment/definitions.d.ts.map +1 -1
- package/dist/services/product/definitions.d.ts +1 -0
- package/dist/services/product/definitions.d.ts.map +1 -1
- package/dist/services/product/index.d.ts +6 -5
- package/dist/services/product/index.d.ts.map +1 -1
- package/dist/services/product-variant/definitions.d.ts +3 -142
- package/dist/services/product-variant/definitions.d.ts.map +1 -1
- package/dist/services/quote/index.d.ts +1 -1
- package/dist/settings/fetch-instance.d.ts.map +1 -1
- package/dist/settings/sdk-version.d.ts +3 -0
- package/dist/settings/sdk-version.d.ts.map +1 -0
- package/lib/.tsbuildinfo +1 -0
- package/lib/client/create-client.d.ts +251 -0
- package/lib/client/create-client.d.ts.map +1 -0
- package/lib/client/create-client.js +233 -0
- package/lib/client/create-client.js.map +1 -0
- package/lib/client/index.d.ts +14 -0
- package/lib/client/index.d.ts.map +1 -0
- package/lib/client/index.js +91 -0
- package/lib/client/index.js.map +1 -0
- package/lib/client/performance.d.ts +203 -0
- package/lib/client/performance.d.ts.map +1 -0
- package/lib/client/performance.js +409 -0
- package/lib/client/performance.js.map +1 -0
- package/lib/client/transport.d.ts +372 -0
- package/lib/client/transport.d.ts.map +1 -0
- package/lib/client/transport.js +735 -0
- package/lib/client/transport.js.map +1 -0
- package/lib/errors/base.d.ts +101 -0
- package/lib/errors/base.d.ts.map +1 -0
- package/lib/errors/base.js +145 -0
- package/lib/errors/base.js.map +1 -0
- package/lib/errors/classes/auth.error.d.ts +64 -0
- package/lib/errors/classes/auth.error.d.ts.map +1 -0
- package/lib/errors/classes/auth.error.js +116 -0
- package/lib/errors/classes/auth.error.js.map +1 -0
- package/lib/errors/classes/forbidden.error.d.ts +52 -0
- package/lib/errors/classes/forbidden.error.d.ts.map +1 -0
- package/lib/errors/classes/forbidden.error.js +90 -0
- package/lib/errors/classes/forbidden.error.js.map +1 -0
- package/lib/errors/classes/index.d.ts +17 -0
- package/lib/errors/classes/index.d.ts.map +1 -0
- package/lib/errors/classes/index.js +29 -0
- package/lib/errors/classes/index.js.map +1 -0
- package/lib/errors/classes/network.error.d.ts +63 -0
- package/lib/errors/classes/network.error.d.ts.map +1 -0
- package/lib/errors/classes/network.error.js +122 -0
- package/lib/errors/classes/network.error.js.map +1 -0
- package/lib/errors/classes/not-found.error.d.ts +58 -0
- package/lib/errors/classes/not-found.error.d.ts.map +1 -0
- package/lib/errors/classes/not-found.error.js +120 -0
- package/lib/errors/classes/not-found.error.js.map +1 -0
- package/lib/errors/classes/rate-limit.error.d.ts +49 -0
- package/lib/errors/classes/rate-limit.error.d.ts.map +1 -0
- package/lib/errors/classes/rate-limit.error.js +107 -0
- package/lib/errors/classes/rate-limit.error.js.map +1 -0
- package/lib/errors/classes/server.error.d.ts +63 -0
- package/lib/errors/classes/server.error.d.ts.map +1 -0
- package/lib/errors/classes/server.error.js +156 -0
- package/lib/errors/classes/server.error.js.map +1 -0
- package/lib/errors/classes/timeout.error.d.ts +64 -0
- package/lib/errors/classes/timeout.error.d.ts.map +1 -0
- package/lib/errors/classes/timeout.error.js +90 -0
- package/lib/errors/classes/timeout.error.js.map +1 -0
- package/lib/errors/classes/unexpected.error.d.ts +70 -0
- package/lib/errors/classes/unexpected.error.d.ts.map +1 -0
- package/lib/errors/classes/unexpected.error.js +105 -0
- package/lib/errors/classes/unexpected.error.js.map +1 -0
- package/lib/errors/classes/validation.error.d.ts +68 -0
- package/lib/errors/classes/validation.error.d.ts.map +1 -0
- package/lib/errors/classes/validation.error.js +103 -0
- package/lib/errors/classes/validation.error.js.map +1 -0
- package/lib/errors/codes.d.ts +111 -0
- package/lib/errors/codes.d.ts.map +1 -0
- package/lib/errors/codes.js +143 -0
- package/lib/errors/codes.js.map +1 -0
- package/lib/errors/compat.d.ts +99 -0
- package/lib/errors/compat.d.ts.map +1 -0
- package/lib/errors/compat.js +280 -0
- package/lib/errors/compat.js.map +1 -0
- package/lib/errors/factory.d.ts +33 -0
- package/lib/errors/factory.d.ts.map +1 -0
- package/lib/errors/factory.js +298 -0
- package/lib/errors/factory.js.map +1 -0
- package/lib/errors/guards.d.ts +142 -0
- package/lib/errors/guards.d.ts.map +1 -0
- package/lib/errors/guards.js +281 -0
- package/lib/errors/guards.js.map +1 -0
- package/lib/errors/helpers/djust-api-error.d.ts +29 -0
- package/lib/errors/helpers/djust-api-error.d.ts.map +1 -0
- package/lib/errors/helpers/djust-api-error.js +49 -0
- package/lib/errors/helpers/djust-api-error.js.map +1 -0
- package/lib/errors/index.d.ts +25 -0
- package/lib/errors/index.d.ts.map +1 -0
- package/lib/errors/index.js +89 -0
- package/lib/errors/index.js.map +1 -0
- package/lib/errors/types.d.ts +104 -0
- package/lib/errors/types.d.ts.map +1 -0
- package/lib/errors/types.js +10 -0
- package/lib/errors/types.js.map +1 -0
- package/lib/helpers/index.d.ts +42 -0
- package/lib/helpers/index.d.ts.map +1 -0
- package/lib/helpers/index.js +102 -0
- package/lib/helpers/index.js.map +1 -0
- package/lib/helpers/parameters-validation.d.ts +3 -0
- package/lib/helpers/parameters-validation.d.ts.map +1 -0
- package/lib/helpers/parameters-validation.js +22 -0
- package/lib/helpers/parameters-validation.js.map +1 -0
- package/lib/helpers/utils.d.ts +5 -0
- package/lib/helpers/utils.d.ts.map +1 -0
- package/lib/helpers/utils.js +30 -0
- package/lib/helpers/utils.js.map +1 -0
- package/lib/index.d.ts +267 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +182 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/index.d.ts +43 -0
- package/lib/interfaces/index.d.ts.map +1 -0
- package/lib/interfaces/index.js +36 -0
- package/lib/interfaces/index.js.map +1 -0
- package/lib/interfaces/models/address.d.ts +61 -0
- package/lib/interfaces/models/address.d.ts.map +1 -0
- package/lib/interfaces/models/address.js +3 -0
- package/lib/interfaces/models/address.js.map +1 -0
- package/lib/interfaces/models/attribute.d.ts +31 -0
- package/lib/interfaces/models/attribute.d.ts.map +1 -0
- package/lib/interfaces/models/attribute.js +3 -0
- package/lib/interfaces/models/attribute.js.map +1 -0
- package/lib/interfaces/models/auth.d.ts +37 -0
- package/lib/interfaces/models/auth.d.ts.map +1 -0
- package/lib/interfaces/models/auth.js +3 -0
- package/lib/interfaces/models/auth.js.map +1 -0
- package/lib/interfaces/models/cart.d.ts +64 -0
- package/lib/interfaces/models/cart.d.ts.map +1 -0
- package/lib/interfaces/models/cart.js +3 -0
- package/lib/interfaces/models/cart.js.map +1 -0
- package/lib/interfaces/models/common.d.ts +68 -0
- package/lib/interfaces/models/common.d.ts.map +1 -0
- package/lib/interfaces/models/common.js +3 -0
- package/lib/interfaces/models/common.js.map +1 -0
- package/lib/interfaces/models/custom-field.d.ts +57 -0
- package/lib/interfaces/models/custom-field.d.ts.map +1 -0
- package/lib/interfaces/models/custom-field.js +3 -0
- package/lib/interfaces/models/custom-field.js.map +1 -0
- package/lib/interfaces/models/customer-account.d.ts +52 -0
- package/lib/interfaces/models/customer-account.d.ts.map +1 -0
- package/lib/interfaces/models/customer-account.js +3 -0
- package/lib/interfaces/models/customer-account.js.map +1 -0
- package/lib/interfaces/models/customer-organisation.d.ts +14 -0
- package/lib/interfaces/models/customer-organisation.d.ts.map +1 -0
- package/lib/interfaces/models/customer-organisation.js +3 -0
- package/lib/interfaces/models/customer-organisation.js.map +1 -0
- package/lib/interfaces/models/customer-user.d.ts +114 -0
- package/lib/interfaces/models/customer-user.d.ts.map +1 -0
- package/lib/interfaces/models/customer-user.js +3 -0
- package/lib/interfaces/models/customer-user.js.map +1 -0
- package/lib/interfaces/models/incident.d.ts +37 -0
- package/lib/interfaces/models/incident.d.ts.map +1 -0
- package/lib/interfaces/models/incident.js +3 -0
- package/lib/interfaces/models/incident.js.map +1 -0
- package/lib/interfaces/models/navigation-category.d.ts +22 -0
- package/lib/interfaces/models/navigation-category.d.ts.map +1 -0
- package/lib/interfaces/models/navigation-category.js +3 -0
- package/lib/interfaces/models/navigation-category.js.map +1 -0
- package/lib/interfaces/models/offer.d.ts +151 -0
- package/lib/interfaces/models/offer.d.ts.map +1 -0
- package/lib/interfaces/models/offer.js +3 -0
- package/lib/interfaces/models/offer.js.map +1 -0
- package/lib/interfaces/models/order.d.ts +701 -0
- package/lib/interfaces/models/order.d.ts.map +1 -0
- package/lib/interfaces/models/order.js +3 -0
- package/lib/interfaces/models/order.js.map +1 -0
- package/lib/interfaces/models/payment.d.ts +20 -0
- package/lib/interfaces/models/payment.d.ts.map +1 -0
- package/lib/interfaces/models/payment.js +3 -0
- package/lib/interfaces/models/payment.js.map +1 -0
- package/lib/interfaces/models/price.d.ts +6 -0
- package/lib/interfaces/models/price.d.ts.map +1 -0
- package/lib/interfaces/models/price.js +3 -0
- package/lib/interfaces/models/price.js.map +1 -0
- package/lib/interfaces/models/product.d.ts +243 -0
- package/lib/interfaces/models/product.d.ts.map +1 -0
- package/lib/interfaces/models/product.js +3 -0
- package/lib/interfaces/models/product.js.map +1 -0
- package/lib/interfaces/models/quote.d.ts +77 -0
- package/lib/interfaces/models/quote.d.ts.map +1 -0
- package/lib/interfaces/models/quote.js +3 -0
- package/lib/interfaces/models/quote.js.map +1 -0
- package/lib/interfaces/models/searchProduct.d.ts +128 -0
- package/lib/interfaces/models/searchProduct.d.ts.map +1 -0
- package/lib/interfaces/models/searchProduct.js +3 -0
- package/lib/interfaces/models/searchProduct.js.map +1 -0
- package/lib/interfaces/models/supplier.d.ts +72 -0
- package/lib/interfaces/models/supplier.d.ts.map +1 -0
- package/lib/interfaces/models/supplier.js +3 -0
- package/lib/interfaces/models/supplier.js.map +1 -0
- package/lib/services/attributes/attributes.service.d.ts +18 -0
- package/lib/services/attributes/attributes.service.d.ts.map +1 -0
- package/lib/services/attributes/attributes.service.js +37 -0
- package/lib/services/attributes/attributes.service.js.map +1 -0
- package/lib/services/attributes/definitions.d.ts +28 -0
- package/lib/services/attributes/definitions.d.ts.map +1 -0
- package/lib/services/attributes/definitions.js +3 -0
- package/lib/services/attributes/definitions.js.map +1 -0
- package/lib/services/attributes/endpoints.d.ts +12 -0
- package/lib/services/attributes/endpoints.d.ts.map +1 -0
- package/lib/services/attributes/endpoints.js +14 -0
- package/lib/services/attributes/endpoints.js.map +1 -0
- package/lib/services/attributes/index.d.ts +33 -0
- package/lib/services/attributes/index.d.ts.map +1 -0
- package/lib/services/attributes/index.js +50 -0
- package/lib/services/attributes/index.js.map +1 -0
- package/lib/services/attributes/module.d.ts +11 -0
- package/lib/services/attributes/module.d.ts.map +1 -0
- package/lib/services/attributes/module.js +15 -0
- package/lib/services/attributes/module.js.map +1 -0
- package/lib/services/attributes/types.d.ts +35 -0
- package/lib/services/attributes/types.d.ts.map +1 -0
- package/lib/services/attributes/types.js +10 -0
- package/lib/services/attributes/types.js.map +1 -0
- package/lib/services/auth/__mocks__/auth.mocks.d.ts +249 -0
- package/lib/services/auth/__mocks__/auth.mocks.d.ts.map +1 -0
- package/lib/services/auth/__mocks__/auth.mocks.js +221 -0
- package/lib/services/auth/__mocks__/auth.mocks.js.map +1 -0
- package/lib/services/auth/auth.service.d.ts +286 -0
- package/lib/services/auth/auth.service.d.ts.map +1 -0
- package/lib/services/auth/auth.service.js +423 -0
- package/lib/services/auth/auth.service.js.map +1 -0
- package/lib/services/auth/definitions.d.ts +69 -0
- package/lib/services/auth/definitions.d.ts.map +1 -0
- package/lib/services/auth/definitions.js +3 -0
- package/lib/services/auth/definitions.js.map +1 -0
- package/lib/services/auth/definitions.requests.d.ts +25 -0
- package/lib/services/auth/definitions.requests.d.ts.map +1 -0
- package/lib/services/auth/definitions.requests.js +6 -0
- package/lib/services/auth/definitions.requests.js.map +1 -0
- package/lib/services/auth/endpoints.d.ts +30 -0
- package/lib/services/auth/endpoints.d.ts.map +1 -0
- package/lib/services/auth/endpoints.js +32 -0
- package/lib/services/auth/endpoints.js.map +1 -0
- package/lib/services/auth/index.d.ts +232 -0
- package/lib/services/auth/index.d.ts.map +1 -0
- package/lib/services/auth/index.js +310 -0
- package/lib/services/auth/index.js.map +1 -0
- package/lib/services/auth/module.d.ts +11 -0
- package/lib/services/auth/module.d.ts.map +1 -0
- package/lib/services/auth/module.js +17 -0
- package/lib/services/auth/module.js.map +1 -0
- package/lib/services/auth/types.d.ts +124 -0
- package/lib/services/auth/types.d.ts.map +1 -0
- package/lib/services/auth/types.js +10 -0
- package/lib/services/auth/types.js.map +1 -0
- package/lib/services/base.service.d.ts +83 -0
- package/lib/services/base.service.d.ts.map +1 -0
- package/lib/services/base.service.js +121 -0
- package/lib/services/base.service.js.map +1 -0
- package/lib/services/cart/cart.service.d.ts +443 -0
- package/lib/services/cart/cart.service.d.ts.map +1 -0
- package/lib/services/cart/cart.service.js +551 -0
- package/lib/services/cart/cart.service.js.map +1 -0
- package/lib/services/cart/definitions.d.ts +84 -0
- package/lib/services/cart/definitions.d.ts.map +1 -0
- package/lib/services/cart/definitions.js +3 -0
- package/lib/services/cart/definitions.js.map +1 -0
- package/lib/services/cart/endpoints.d.ts +24 -0
- package/lib/services/cart/endpoints.d.ts.map +1 -0
- package/lib/services/cart/endpoints.js +26 -0
- package/lib/services/cart/endpoints.js.map +1 -0
- package/lib/services/cart/index.d.ts +330 -0
- package/lib/services/cart/index.d.ts.map +1 -0
- package/lib/services/cart/index.js +464 -0
- package/lib/services/cart/index.js.map +1 -0
- package/lib/services/cart/module.d.ts +11 -0
- package/lib/services/cart/module.d.ts.map +1 -0
- package/lib/services/cart/module.js +17 -0
- package/lib/services/cart/module.js.map +1 -0
- package/lib/services/cart/types.d.ts +236 -0
- package/lib/services/cart/types.d.ts.map +1 -0
- package/lib/services/cart/types.js +10 -0
- package/lib/services/cart/types.js.map +1 -0
- package/lib/services/commercial-order/commercial-order.service.d.ts +435 -0
- package/lib/services/commercial-order/commercial-order.service.d.ts.map +1 -0
- package/lib/services/commercial-order/commercial-order.service.js +690 -0
- package/lib/services/commercial-order/commercial-order.service.js.map +1 -0
- package/lib/services/commercial-order/definitions.d.ts +182 -0
- package/lib/services/commercial-order/definitions.d.ts.map +1 -0
- package/lib/services/commercial-order/definitions.js +3 -0
- package/lib/services/commercial-order/definitions.js.map +1 -0
- package/lib/services/commercial-order/endpoints.d.ts +28 -0
- package/lib/services/commercial-order/endpoints.d.ts.map +1 -0
- package/lib/services/commercial-order/endpoints.js +33 -0
- package/lib/services/commercial-order/endpoints.js.map +1 -0
- package/lib/services/commercial-order/index.d.ts +721 -0
- package/lib/services/commercial-order/index.d.ts.map +1 -0
- package/lib/services/commercial-order/index.js +986 -0
- package/lib/services/commercial-order/index.js.map +1 -0
- package/lib/services/commercial-order/module.d.ts +11 -0
- package/lib/services/commercial-order/module.d.ts.map +1 -0
- package/lib/services/commercial-order/module.js +15 -0
- package/lib/services/commercial-order/module.js.map +1 -0
- package/lib/services/commercial-order/types.d.ts +244 -0
- package/lib/services/commercial-order/types.d.ts.map +1 -0
- package/lib/services/commercial-order/types.js +10 -0
- package/lib/services/commercial-order/types.js.map +1 -0
- package/lib/services/custom-field/custom-field.service.d.ts +23 -0
- package/lib/services/custom-field/custom-field.service.d.ts.map +1 -0
- package/lib/services/custom-field/custom-field.service.js +64 -0
- package/lib/services/custom-field/custom-field.service.js.map +1 -0
- package/lib/services/custom-field/definitions.d.ts +107 -0
- package/lib/services/custom-field/definitions.d.ts.map +1 -0
- package/lib/services/custom-field/definitions.js +61 -0
- package/lib/services/custom-field/definitions.js.map +1 -0
- package/lib/services/custom-field/endpoints.d.ts +13 -0
- package/lib/services/custom-field/endpoints.d.ts.map +1 -0
- package/lib/services/custom-field/endpoints.js +15 -0
- package/lib/services/custom-field/endpoints.js.map +1 -0
- package/lib/services/custom-field/index.d.ts +115 -0
- package/lib/services/custom-field/index.d.ts.map +1 -0
- package/lib/services/custom-field/index.js +144 -0
- package/lib/services/custom-field/index.js.map +1 -0
- package/lib/services/custom-field/module.d.ts +11 -0
- package/lib/services/custom-field/module.d.ts.map +1 -0
- package/lib/services/custom-field/module.js +15 -0
- package/lib/services/custom-field/module.js.map +1 -0
- package/lib/services/custom-field/types.d.ts +51 -0
- package/lib/services/custom-field/types.d.ts.map +1 -0
- package/lib/services/custom-field/types.js +10 -0
- package/lib/services/custom-field/types.js.map +1 -0
- package/lib/services/customer-account/customer-account.service.d.ts +387 -0
- package/lib/services/customer-account/customer-account.service.d.ts.map +1 -0
- package/lib/services/customer-account/customer-account.service.js +579 -0
- package/lib/services/customer-account/customer-account.service.js.map +1 -0
- package/lib/services/customer-account/definitions.d.ts +164 -0
- package/lib/services/customer-account/definitions.d.ts.map +1 -0
- package/lib/services/customer-account/definitions.js +3 -0
- package/lib/services/customer-account/definitions.js.map +1 -0
- package/lib/services/customer-account/endpoints.d.ts +25 -0
- package/lib/services/customer-account/endpoints.d.ts.map +1 -0
- package/lib/services/customer-account/endpoints.js +33 -0
- package/lib/services/customer-account/endpoints.js.map +1 -0
- package/lib/services/customer-account/index.d.ts +656 -0
- package/lib/services/customer-account/index.d.ts.map +1 -0
- package/lib/services/customer-account/index.js +929 -0
- package/lib/services/customer-account/index.js.map +1 -0
- package/lib/services/customer-account/module.d.ts +11 -0
- package/lib/services/customer-account/module.d.ts.map +1 -0
- package/lib/services/customer-account/module.js +15 -0
- package/lib/services/customer-account/module.js.map +1 -0
- package/lib/services/customer-account/types.d.ts +253 -0
- package/lib/services/customer-account/types.d.ts.map +1 -0
- package/lib/services/customer-account/types.js +10 -0
- package/lib/services/customer-account/types.js.map +1 -0
- package/lib/services/customer-user/customer-user.service.d.ts +280 -0
- package/lib/services/customer-user/customer-user.service.d.ts.map +1 -0
- package/lib/services/customer-user/customer-user.service.js +402 -0
- package/lib/services/customer-user/customer-user.service.js.map +1 -0
- package/lib/services/customer-user/definitions.d.ts +84 -0
- package/lib/services/customer-user/definitions.d.ts.map +1 -0
- package/lib/services/customer-user/definitions.js +3 -0
- package/lib/services/customer-user/definitions.js.map +1 -0
- package/lib/services/customer-user/endpoints.d.ts +19 -0
- package/lib/services/customer-user/endpoints.d.ts.map +1 -0
- package/lib/services/customer-user/endpoints.js +21 -0
- package/lib/services/customer-user/endpoints.js.map +1 -0
- package/lib/services/customer-user/index.d.ts +394 -0
- package/lib/services/customer-user/index.d.ts.map +1 -0
- package/lib/services/customer-user/index.js +528 -0
- package/lib/services/customer-user/index.js.map +1 -0
- package/lib/services/customer-user/module.d.ts +11 -0
- package/lib/services/customer-user/module.d.ts.map +1 -0
- package/lib/services/customer-user/module.js +15 -0
- package/lib/services/customer-user/module.js.map +1 -0
- package/lib/services/customer-user/types.d.ts +118 -0
- package/lib/services/customer-user/types.d.ts.map +1 -0
- package/lib/services/customer-user/types.js +10 -0
- package/lib/services/customer-user/types.js.map +1 -0
- package/lib/services/factory.d.ts +104 -0
- package/lib/services/factory.d.ts.map +1 -0
- package/lib/services/factory.js +89 -0
- package/lib/services/factory.js.map +1 -0
- package/lib/services/incident/definitions.d.ts +85 -0
- package/lib/services/incident/definitions.d.ts.map +1 -0
- package/lib/services/incident/definitions.js +3 -0
- package/lib/services/incident/definitions.js.map +1 -0
- package/lib/services/incident/endpoints.d.ts +17 -0
- package/lib/services/incident/endpoints.d.ts.map +1 -0
- package/lib/services/incident/endpoints.js +19 -0
- package/lib/services/incident/endpoints.js.map +1 -0
- package/lib/services/incident/incident.service.d.ts +24 -0
- package/lib/services/incident/incident.service.d.ts.map +1 -0
- package/lib/services/incident/incident.service.js +141 -0
- package/lib/services/incident/incident.service.js.map +1 -0
- package/lib/services/incident/index.d.ts +270 -0
- package/lib/services/incident/index.d.ts.map +1 -0
- package/lib/services/incident/index.js +389 -0
- package/lib/services/incident/index.js.map +1 -0
- package/lib/services/incident/module.d.ts +11 -0
- package/lib/services/incident/module.d.ts.map +1 -0
- package/lib/services/incident/module.js +15 -0
- package/lib/services/incident/module.js.map +1 -0
- package/lib/services/incident/types.d.ts +116 -0
- package/lib/services/incident/types.d.ts.map +1 -0
- package/lib/services/incident/types.js +10 -0
- package/lib/services/incident/types.js.map +1 -0
- package/lib/services/logistic-order/definitions.d.ts +315 -0
- package/lib/services/logistic-order/definitions.d.ts.map +1 -0
- package/lib/services/logistic-order/definitions.js +3 -0
- package/lib/services/logistic-order/definitions.js.map +1 -0
- package/lib/services/logistic-order/endpoints.d.ts +44 -0
- package/lib/services/logistic-order/endpoints.d.ts.map +1 -0
- package/lib/services/logistic-order/endpoints.js +57 -0
- package/lib/services/logistic-order/endpoints.js.map +1 -0
- package/lib/services/logistic-order/index.d.ts +1376 -0
- package/lib/services/logistic-order/index.d.ts.map +1 -0
- package/lib/services/logistic-order/index.js +1823 -0
- package/lib/services/logistic-order/index.js.map +1 -0
- package/lib/services/logistic-order/logistic-order.service.d.ts +62 -0
- package/lib/services/logistic-order/logistic-order.service.d.ts.map +1 -0
- package/lib/services/logistic-order/logistic-order.service.js +499 -0
- package/lib/services/logistic-order/logistic-order.service.js.map +1 -0
- package/lib/services/logistic-order/module.d.ts +11 -0
- package/lib/services/logistic-order/module.d.ts.map +1 -0
- package/lib/services/logistic-order/module.js +15 -0
- package/lib/services/logistic-order/module.js.map +1 -0
- package/lib/services/logistic-order/types.d.ts +411 -0
- package/lib/services/logistic-order/types.d.ts.map +1 -0
- package/lib/services/logistic-order/types.js +10 -0
- package/lib/services/logistic-order/types.js.map +1 -0
- package/lib/services/module.d.ts +64 -0
- package/lib/services/module.d.ts.map +1 -0
- package/lib/services/module.js +147 -0
- package/lib/services/module.js.map +1 -0
- package/lib/services/navigation-category/definitions.d.ts +31 -0
- package/lib/services/navigation-category/definitions.d.ts.map +1 -0
- package/lib/services/navigation-category/definitions.js +3 -0
- package/lib/services/navigation-category/definitions.js.map +1 -0
- package/lib/services/navigation-category/endpoints.d.ts +15 -0
- package/lib/services/navigation-category/endpoints.d.ts.map +1 -0
- package/lib/services/navigation-category/endpoints.js +17 -0
- package/lib/services/navigation-category/endpoints.js.map +1 -0
- package/lib/services/navigation-category/index.d.ts +114 -0
- package/lib/services/navigation-category/index.d.ts.map +1 -0
- package/lib/services/navigation-category/index.js +160 -0
- package/lib/services/navigation-category/index.js.map +1 -0
- package/lib/services/navigation-category/module.d.ts +11 -0
- package/lib/services/navigation-category/module.d.ts.map +1 -0
- package/lib/services/navigation-category/module.js +15 -0
- package/lib/services/navigation-category/module.js.map +1 -0
- package/lib/services/navigation-category/navigation-category.service.d.ts +148 -0
- package/lib/services/navigation-category/navigation-category.service.d.ts.map +1 -0
- package/lib/services/navigation-category/navigation-category.service.js +191 -0
- package/lib/services/navigation-category/navigation-category.service.js.map +1 -0
- package/lib/services/navigation-category/types.d.ts +51 -0
- package/lib/services/navigation-category/types.d.ts.map +1 -0
- package/lib/services/navigation-category/types.js +10 -0
- package/lib/services/navigation-category/types.js.map +1 -0
- package/lib/services/offer-inventories/definitions.d.ts +73 -0
- package/lib/services/offer-inventories/definitions.d.ts.map +1 -0
- package/lib/services/offer-inventories/definitions.js +3 -0
- package/lib/services/offer-inventories/definitions.js.map +1 -0
- package/lib/services/offer-inventories/endpoints.d.ts +16 -0
- package/lib/services/offer-inventories/endpoints.d.ts.map +1 -0
- package/lib/services/offer-inventories/endpoints.js +18 -0
- package/lib/services/offer-inventories/endpoints.js.map +1 -0
- package/lib/services/offer-inventories/index.d.ts +120 -0
- package/lib/services/offer-inventories/index.d.ts.map +1 -0
- package/lib/services/offer-inventories/index.js +175 -0
- package/lib/services/offer-inventories/index.js.map +1 -0
- package/lib/services/offer-inventories/module.d.ts +11 -0
- package/lib/services/offer-inventories/module.d.ts.map +1 -0
- package/lib/services/offer-inventories/module.js +15 -0
- package/lib/services/offer-inventories/module.js.map +1 -0
- package/lib/services/offer-inventories/offer-inventories.service.d.ts +26 -0
- package/lib/services/offer-inventories/offer-inventories.service.d.ts.map +1 -0
- package/lib/services/offer-inventories/offer-inventories.service.js +80 -0
- package/lib/services/offer-inventories/offer-inventories.service.js.map +1 -0
- package/lib/services/offer-inventories/types.d.ts +85 -0
- package/lib/services/offer-inventories/types.d.ts.map +1 -0
- package/lib/services/offer-inventories/types.js +10 -0
- package/lib/services/offer-inventories/types.js.map +1 -0
- package/lib/services/offer-prices/__mocks__/offer-prices.mocks.d.ts +109 -0
- package/lib/services/offer-prices/__mocks__/offer-prices.mocks.d.ts.map +1 -0
- package/lib/services/offer-prices/__mocks__/offer-prices.mocks.js +201 -0
- package/lib/services/offer-prices/__mocks__/offer-prices.mocks.js.map +1 -0
- package/lib/services/offer-prices/definitions.d.ts +24 -0
- package/lib/services/offer-prices/definitions.d.ts.map +1 -0
- package/lib/services/offer-prices/definitions.js +3 -0
- package/lib/services/offer-prices/definitions.js.map +1 -0
- package/lib/services/offer-prices/endpoints.d.ts +12 -0
- package/lib/services/offer-prices/endpoints.d.ts.map +1 -0
- package/lib/services/offer-prices/endpoints.js +14 -0
- package/lib/services/offer-prices/endpoints.js.map +1 -0
- package/lib/services/offer-prices/index.d.ts +36 -0
- package/lib/services/offer-prices/index.d.ts.map +1 -0
- package/lib/services/offer-prices/index.js +53 -0
- package/lib/services/offer-prices/index.js.map +1 -0
- package/lib/services/offer-prices/module.d.ts +11 -0
- package/lib/services/offer-prices/module.d.ts.map +1 -0
- package/lib/services/offer-prices/module.js +15 -0
- package/lib/services/offer-prices/module.js.map +1 -0
- package/lib/services/offer-prices/offer-prices.service.d.ts +18 -0
- package/lib/services/offer-prices/offer-prices.service.d.ts.map +1 -0
- package/lib/services/offer-prices/offer-prices.service.js +36 -0
- package/lib/services/offer-prices/offer-prices.service.js.map +1 -0
- package/lib/services/offer-prices/types.d.ts +33 -0
- package/lib/services/offer-prices/types.d.ts.map +1 -0
- package/lib/services/offer-prices/types.js +10 -0
- package/lib/services/offer-prices/types.js.map +1 -0
- package/lib/services/operation/definitions.d.ts +263 -0
- package/lib/services/operation/definitions.d.ts.map +1 -0
- package/lib/services/operation/definitions.js +18 -0
- package/lib/services/operation/definitions.js.map +1 -0
- package/lib/services/operation/endpoints.d.ts +18 -0
- package/lib/services/operation/endpoints.d.ts.map +1 -0
- package/lib/services/operation/endpoints.js +22 -0
- package/lib/services/operation/endpoints.js.map +1 -0
- package/lib/services/operation/index.d.ts +520 -0
- package/lib/services/operation/index.d.ts.map +1 -0
- package/lib/services/operation/index.js +704 -0
- package/lib/services/operation/index.js.map +1 -0
- package/lib/services/operation/module.d.ts +11 -0
- package/lib/services/operation/module.d.ts.map +1 -0
- package/lib/services/operation/module.js +15 -0
- package/lib/services/operation/module.js.map +1 -0
- package/lib/services/operation/operation.service.d.ts +32 -0
- package/lib/services/operation/operation.service.d.ts.map +1 -0
- package/lib/services/operation/operation.service.js +206 -0
- package/lib/services/operation/operation.service.js.map +1 -0
- package/lib/services/operation/types.d.ts +174 -0
- package/lib/services/operation/types.d.ts.map +1 -0
- package/lib/services/operation/types.js +10 -0
- package/lib/services/operation/types.js.map +1 -0
- package/lib/services/payment/definitions.d.ts +69 -0
- package/lib/services/payment/definitions.d.ts.map +1 -0
- package/lib/services/payment/definitions.js +3 -0
- package/lib/services/payment/definitions.js.map +1 -0
- package/lib/services/payment/endpoints.d.ts +16 -0
- package/lib/services/payment/endpoints.d.ts.map +1 -0
- package/lib/services/payment/endpoints.js +18 -0
- package/lib/services/payment/endpoints.js.map +1 -0
- package/lib/services/payment/index.d.ts +150 -0
- package/lib/services/payment/index.d.ts.map +1 -0
- package/lib/services/payment/index.js +220 -0
- package/lib/services/payment/index.js.map +1 -0
- package/lib/services/payment/module.d.ts +11 -0
- package/lib/services/payment/module.d.ts.map +1 -0
- package/lib/services/payment/module.js +15 -0
- package/lib/services/payment/module.js.map +1 -0
- package/lib/services/payment/payment.service.d.ts +224 -0
- package/lib/services/payment/payment.service.d.ts.map +1 -0
- package/lib/services/payment/payment.service.js +288 -0
- package/lib/services/payment/payment.service.js.map +1 -0
- package/lib/services/payment/types.d.ts +93 -0
- package/lib/services/payment/types.d.ts.map +1 -0
- package/lib/services/payment/types.js +10 -0
- package/lib/services/payment/types.js.map +1 -0
- package/lib/services/product/definitions.d.ts +150 -0
- package/lib/services/product/definitions.d.ts.map +1 -0
- package/lib/services/product/definitions.js +9 -0
- package/lib/services/product/definitions.js.map +1 -0
- package/lib/services/product/endpoints.d.ts +40 -0
- package/lib/services/product/endpoints.d.ts.map +1 -0
- package/lib/services/product/endpoints.js +42 -0
- package/lib/services/product/endpoints.js.map +1 -0
- package/lib/services/product/index.d.ts +388 -0
- package/lib/services/product/index.d.ts.map +1 -0
- package/lib/services/product/index.js +564 -0
- package/lib/services/product/index.js.map +1 -0
- package/lib/services/product/module.d.ts +11 -0
- package/lib/services/product/module.d.ts.map +1 -0
- package/lib/services/product/module.js +17 -0
- package/lib/services/product/module.js.map +1 -0
- package/lib/services/product/product.service.d.ts +452 -0
- package/lib/services/product/product.service.d.ts.map +1 -0
- package/lib/services/product/product.service.js +624 -0
- package/lib/services/product/product.service.js.map +1 -0
- package/lib/services/product/types.d.ts +344 -0
- package/lib/services/product/types.d.ts.map +1 -0
- package/lib/services/product/types.js +10 -0
- package/lib/services/product/types.js.map +1 -0
- package/lib/services/product-variant/definitions.d.ts +33 -0
- package/lib/services/product-variant/definitions.d.ts.map +1 -0
- package/lib/services/product-variant/definitions.js +7 -0
- package/lib/services/product-variant/definitions.js.map +1 -0
- package/lib/services/product-variant/endpoints.d.ts +15 -0
- package/lib/services/product-variant/endpoints.d.ts.map +1 -0
- package/lib/services/product-variant/endpoints.js +17 -0
- package/lib/services/product-variant/endpoints.js.map +1 -0
- package/lib/services/product-variant/index.d.ts +123 -0
- package/lib/services/product-variant/index.d.ts.map +1 -0
- package/lib/services/product-variant/index.js +172 -0
- package/lib/services/product-variant/index.js.map +1 -0
- package/lib/services/product-variant/module.d.ts +11 -0
- package/lib/services/product-variant/module.d.ts.map +1 -0
- package/lib/services/product-variant/module.js +15 -0
- package/lib/services/product-variant/module.js.map +1 -0
- package/lib/services/product-variant/product-variant.service.d.ts +21 -0
- package/lib/services/product-variant/product-variant.service.d.ts.map +1 -0
- package/lib/services/product-variant/product-variant.service.js +69 -0
- package/lib/services/product-variant/product-variant.service.js.map +1 -0
- package/lib/services/product-variant/types.d.ts +73 -0
- package/lib/services/product-variant/types.d.ts.map +1 -0
- package/lib/services/product-variant/types.js +10 -0
- package/lib/services/product-variant/types.js.map +1 -0
- package/lib/services/quote/definitions.d.ts +102 -0
- package/lib/services/quote/definitions.d.ts.map +1 -0
- package/lib/services/quote/definitions.js +3 -0
- package/lib/services/quote/definitions.js.map +1 -0
- package/lib/services/quote/endpoints.d.ts +20 -0
- package/lib/services/quote/endpoints.d.ts.map +1 -0
- package/lib/services/quote/endpoints.js +24 -0
- package/lib/services/quote/endpoints.js.map +1 -0
- package/lib/services/quote/index.d.ts +378 -0
- package/lib/services/quote/index.d.ts.map +1 -0
- package/lib/services/quote/index.js +506 -0
- package/lib/services/quote/index.js.map +1 -0
- package/lib/services/quote/module.d.ts +11 -0
- package/lib/services/quote/module.d.ts.map +1 -0
- package/lib/services/quote/module.js +15 -0
- package/lib/services/quote/module.js.map +1 -0
- package/lib/services/quote/quote.service.d.ts +346 -0
- package/lib/services/quote/quote.service.d.ts.map +1 -0
- package/lib/services/quote/quote.service.js +479 -0
- package/lib/services/quote/quote.service.js.map +1 -0
- package/lib/services/quote/types.d.ts +160 -0
- package/lib/services/quote/types.d.ts.map +1 -0
- package/lib/services/quote/types.js +10 -0
- package/lib/services/quote/types.js.map +1 -0
- package/lib/services/supplier/__mocks__/supplier-mocks.d.ts +49 -0
- package/lib/services/supplier/__mocks__/supplier-mocks.d.ts.map +1 -0
- package/lib/services/supplier/__mocks__/supplier-mocks.js +168 -0
- package/lib/services/supplier/__mocks__/supplier-mocks.js.map +1 -0
- package/lib/services/supplier/definitions.d.ts +30 -0
- package/lib/services/supplier/definitions.d.ts.map +1 -0
- package/lib/services/supplier/definitions.js +3 -0
- package/lib/services/supplier/definitions.js.map +1 -0
- package/lib/services/supplier/endpoints.d.ts +14 -0
- package/lib/services/supplier/endpoints.d.ts.map +1 -0
- package/lib/services/supplier/endpoints.js +16 -0
- package/lib/services/supplier/endpoints.js.map +1 -0
- package/lib/services/supplier/index.d.ts +102 -0
- package/lib/services/supplier/index.d.ts.map +1 -0
- package/lib/services/supplier/index.js +146 -0
- package/lib/services/supplier/index.js.map +1 -0
- package/lib/services/supplier/module.d.ts +11 -0
- package/lib/services/supplier/module.d.ts.map +1 -0
- package/lib/services/supplier/module.js +15 -0
- package/lib/services/supplier/module.js.map +1 -0
- package/lib/services/supplier/supplier.service.d.ts +20 -0
- package/lib/services/supplier/supplier.service.d.ts.map +1 -0
- package/lib/services/supplier/supplier.service.js +63 -0
- package/lib/services/supplier/supplier.service.js.map +1 -0
- package/lib/services/supplier/types.d.ts +58 -0
- package/lib/services/supplier/types.d.ts.map +1 -0
- package/lib/services/supplier/types.js +10 -0
- package/lib/services/supplier/types.js.map +1 -0
- package/lib/services/types.d.ts +81 -0
- package/lib/services/types.d.ts.map +1 -0
- package/lib/services/types.js +10 -0
- package/lib/services/types.js.map +1 -0
- package/lib/settings/fetch-instance.d.ts +30 -0
- package/lib/settings/fetch-instance.d.ts.map +1 -0
- package/lib/settings/fetch-instance.js +223 -0
- package/lib/settings/fetch-instance.js.map +1 -0
- package/lib/settings/sdk-version.d.ts +3 -0
- package/lib/settings/sdk-version.d.ts.map +1 -0
- package/lib/settings/sdk-version.js +6 -0
- package/lib/settings/sdk-version.js.map +1 -0
- package/package.json +27 -8
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DJUST SDK Transport Layer
|
|
4
|
+
* Production-grade HTTP transport with timeout, retry, caching, and performance optimizations.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Request deduplication (prevents duplicate concurrent requests)
|
|
8
|
+
* - Response caching with TTL and ETag support
|
|
9
|
+
* - Performance monitoring and metrics
|
|
10
|
+
* - Retry with exponential backoff
|
|
11
|
+
* - Request timeout
|
|
12
|
+
* - Connection keep-alive
|
|
13
|
+
* - Compression support
|
|
14
|
+
*
|
|
15
|
+
* @since 2.17.0
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.Transport = void 0;
|
|
19
|
+
exports.createTransport = createTransport;
|
|
20
|
+
const tslib_1 = require("tslib");
|
|
21
|
+
const qs = tslib_1.__importStar(require("query-string"));
|
|
22
|
+
const base_1 = require("../errors/base");
|
|
23
|
+
const network_error_1 = require("../errors/classes/network.error");
|
|
24
|
+
const timeout_error_1 = require("../errors/classes/timeout.error");
|
|
25
|
+
const rate_limit_error_1 = require("../errors/classes/rate-limit.error");
|
|
26
|
+
const factory_1 = require("../errors/factory");
|
|
27
|
+
const compat_1 = require("../errors/compat");
|
|
28
|
+
const guards_1 = require("../errors/guards");
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// DEFAULT VALUES
|
|
31
|
+
// ============================================================================
|
|
32
|
+
const DEFAULT_TIMEOUT_MS = 30000;
|
|
33
|
+
const DEFAULT_RETRY_CONFIG = {
|
|
34
|
+
enabled: false,
|
|
35
|
+
maxAttempts: 3,
|
|
36
|
+
initialDelayMs: 1000,
|
|
37
|
+
maxDelayMs: 30000,
|
|
38
|
+
jitter: 0.1,
|
|
39
|
+
retryableStatuses: [408, 429, 500, 502, 503, 504],
|
|
40
|
+
};
|
|
41
|
+
const DEFAULT_PERFORMANCE_CONFIG = {
|
|
42
|
+
deduplication: true,
|
|
43
|
+
deduplicationWindowMs: 100,
|
|
44
|
+
cache: false,
|
|
45
|
+
cacheMaxSize: 100,
|
|
46
|
+
cacheTTL: 60000,
|
|
47
|
+
staleWhileRevalidate: true,
|
|
48
|
+
monitoring: false,
|
|
49
|
+
compression: true,
|
|
50
|
+
keepAlive: true,
|
|
51
|
+
};
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// TRANSPORT CLASS
|
|
54
|
+
// ============================================================================
|
|
55
|
+
/**
|
|
56
|
+
* Production-grade HTTP transport for DJUST SDK.
|
|
57
|
+
* Includes built-in performance optimizations and auth lifecycle hooks.
|
|
58
|
+
*/
|
|
59
|
+
class Transport {
|
|
60
|
+
constructor(config) {
|
|
61
|
+
// Performance internals
|
|
62
|
+
this.cache = new Map();
|
|
63
|
+
this.pendingRequests = new Map();
|
|
64
|
+
this.metrics = {
|
|
65
|
+
requestCount: 0,
|
|
66
|
+
cacheHits: 0,
|
|
67
|
+
cacheMisses: 0,
|
|
68
|
+
dedupedRequests: 0,
|
|
69
|
+
totalDurationMs: 0,
|
|
70
|
+
errors: 0,
|
|
71
|
+
};
|
|
72
|
+
this.config = config;
|
|
73
|
+
this.retryConfig = { ...DEFAULT_RETRY_CONFIG, ...(config.retry || {}) };
|
|
74
|
+
this.perfConfig = {
|
|
75
|
+
...DEFAULT_PERFORMANCE_CONFIG,
|
|
76
|
+
...(config.performance || {}),
|
|
77
|
+
};
|
|
78
|
+
this.hooks = config.hooks || {};
|
|
79
|
+
this.authHooks = config.authHooks || {};
|
|
80
|
+
}
|
|
81
|
+
// ==========================================================================
|
|
82
|
+
// AUTH HOOKS API
|
|
83
|
+
// ==========================================================================
|
|
84
|
+
/**
|
|
85
|
+
* Triggers the onLogin hook after successful login.
|
|
86
|
+
* Called by AuthService.login()
|
|
87
|
+
*/
|
|
88
|
+
async triggerLoginHook(context) {
|
|
89
|
+
if (this.authHooks.onLogin) {
|
|
90
|
+
try {
|
|
91
|
+
await this.authHooks.onLogin(context);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (this.config.debug) {
|
|
95
|
+
console.error("[DJUST SDK] onLogin hook error:", error);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Triggers the onTokenRefresh hook after successful token refresh.
|
|
102
|
+
* Called by AuthService.refreshToken()
|
|
103
|
+
*/
|
|
104
|
+
async triggerTokenRefreshHook(context) {
|
|
105
|
+
if (this.authHooks.onTokenRefresh) {
|
|
106
|
+
try {
|
|
107
|
+
await this.authHooks.onTokenRefresh(context);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (this.config.debug) {
|
|
111
|
+
console.error("[DJUST SDK] onTokenRefresh hook error:", error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Triggers the onLogout hook after logout attempt.
|
|
118
|
+
* Called by AuthService.logout()
|
|
119
|
+
*/
|
|
120
|
+
async triggerLogoutHook(context) {
|
|
121
|
+
if (this.authHooks.onLogout) {
|
|
122
|
+
try {
|
|
123
|
+
await this.authHooks.onLogout(context);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (this.config.debug) {
|
|
127
|
+
console.error("[DJUST SDK] onLogout hook error:", error);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Triggers the onAuthFailure hook when authentication fails.
|
|
134
|
+
* Called on 401 errors or refresh token failures.
|
|
135
|
+
*/
|
|
136
|
+
async triggerAuthFailureHook(context) {
|
|
137
|
+
if (this.authHooks.onAuthFailure) {
|
|
138
|
+
try {
|
|
139
|
+
await this.authHooks.onAuthFailure(context);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
if (this.config.debug) {
|
|
143
|
+
console.error("[DJUST SDK] onAuthFailure hook error:", error);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Calls the onBeforeAuthenticatedRequest hook to potentially refresh tokens.
|
|
150
|
+
* Returns a new token if provided by the hook.
|
|
151
|
+
*/
|
|
152
|
+
async callBeforeAuthRequestHook(context) {
|
|
153
|
+
if (this.authHooks.onBeforeAuthenticatedRequest) {
|
|
154
|
+
try {
|
|
155
|
+
return await this.authHooks.onBeforeAuthenticatedRequest(context);
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
if (this.config.debug) {
|
|
159
|
+
console.error("[DJUST SDK] onBeforeAuthenticatedRequest hook error:", error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Checks if auth hooks are configured.
|
|
167
|
+
*/
|
|
168
|
+
hasAuthHooks() {
|
|
169
|
+
return Object.keys(this.authHooks).length > 0;
|
|
170
|
+
}
|
|
171
|
+
// ==========================================================================
|
|
172
|
+
// PUBLIC API
|
|
173
|
+
// ==========================================================================
|
|
174
|
+
/**
|
|
175
|
+
* Executes an HTTP request with full error handling, caching, and retry support.
|
|
176
|
+
*/
|
|
177
|
+
async request(request, context = {}) {
|
|
178
|
+
const requestId = context.requestId || this.generateRequestId();
|
|
179
|
+
const startTime = Date.now();
|
|
180
|
+
const url = this.buildUrl(request.path, request.params);
|
|
181
|
+
const cacheKey = request.cacheKey || this.buildCacheKey(request.method, url, context);
|
|
182
|
+
this.metrics.requestCount++;
|
|
183
|
+
// 1. Check cache first (GET requests only)
|
|
184
|
+
if (this.shouldUseCache(request, context)) {
|
|
185
|
+
const cached = this.getFromCache(cacheKey);
|
|
186
|
+
if (cached) {
|
|
187
|
+
const age = Date.now() - cached.timestamp;
|
|
188
|
+
const isStale = age > (context.cacheTTL || this.perfConfig.cacheTTL);
|
|
189
|
+
this.metrics.cacheHits++;
|
|
190
|
+
await this.hooks.onCacheHit?.({
|
|
191
|
+
requestId,
|
|
192
|
+
url,
|
|
193
|
+
cacheKey,
|
|
194
|
+
stale: isStale,
|
|
195
|
+
age,
|
|
196
|
+
});
|
|
197
|
+
if (!isStale || this.perfConfig.staleWhileRevalidate) {
|
|
198
|
+
// Return cached data
|
|
199
|
+
if (isStale && this.perfConfig.staleWhileRevalidate) {
|
|
200
|
+
// Revalidate in background
|
|
201
|
+
this.revalidateInBackground(request, context, cacheKey);
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
data: cached.data,
|
|
205
|
+
headers: new Headers(),
|
|
206
|
+
status: 200,
|
|
207
|
+
durationMs: Date.now() - startTime,
|
|
208
|
+
requestId,
|
|
209
|
+
cached: true,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
this.metrics.cacheMisses++;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// 2. Check for pending dedup request (GET requests only)
|
|
218
|
+
if (this.shouldDedupe(request, context)) {
|
|
219
|
+
const pending = this.pendingRequests.get(cacheKey);
|
|
220
|
+
if (pending &&
|
|
221
|
+
Date.now() - pending.timestamp < this.perfConfig.deduplicationWindowMs) {
|
|
222
|
+
this.metrics.dedupedRequests++;
|
|
223
|
+
if (this.config.debug) {
|
|
224
|
+
console.log(`[DJUST SDK] Deduped request: ${request.method} ${url}`);
|
|
225
|
+
}
|
|
226
|
+
const response = await pending.promise;
|
|
227
|
+
return { ...response, deduped: true };
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// 3. Execute the actual request
|
|
231
|
+
const executePromise = this.executeWithRetry(request, context, requestId, startTime);
|
|
232
|
+
// Store pending request for deduplication
|
|
233
|
+
if (this.shouldDedupe(request, context)) {
|
|
234
|
+
// Create a "safe" promise that won't cause unhandled rejection warnings
|
|
235
|
+
// when stored in the map but not immediately awaited
|
|
236
|
+
const safePromise = executePromise.catch((error) => {
|
|
237
|
+
// Re-throw so callers still get the error, but this catch prevents
|
|
238
|
+
// Node.js unhandled rejection warnings when the promise is stored
|
|
239
|
+
throw error;
|
|
240
|
+
});
|
|
241
|
+
this.pendingRequests.set(cacheKey, {
|
|
242
|
+
promise: safePromise,
|
|
243
|
+
timestamp: Date.now(),
|
|
244
|
+
});
|
|
245
|
+
// Cleanup after completion
|
|
246
|
+
safePromise
|
|
247
|
+
.finally(() => {
|
|
248
|
+
setTimeout(() => {
|
|
249
|
+
const current = this.pendingRequests.get(cacheKey);
|
|
250
|
+
if (current?.promise === safePromise) {
|
|
251
|
+
this.pendingRequests.delete(cacheKey);
|
|
252
|
+
}
|
|
253
|
+
}, 10);
|
|
254
|
+
})
|
|
255
|
+
.catch(() => {
|
|
256
|
+
// Silent catch for cleanup - errors are handled by callers
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
const response = await executePromise;
|
|
260
|
+
// 4. Store in cache if applicable
|
|
261
|
+
if (this.shouldUseCache(request, context) && response.status === 200) {
|
|
262
|
+
const etag = response.headers.get("etag") || undefined;
|
|
263
|
+
const cacheControl = response.headers.get("cache-control");
|
|
264
|
+
const maxAge = this.parseCacheMaxAge(cacheControl);
|
|
265
|
+
this.setCache(cacheKey, response.data, etag, maxAge);
|
|
266
|
+
}
|
|
267
|
+
this.metrics.totalDurationMs += response.durationMs;
|
|
268
|
+
return response;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Gets performance metrics
|
|
272
|
+
*/
|
|
273
|
+
getMetrics() {
|
|
274
|
+
const total = this.metrics.cacheHits + this.metrics.cacheMisses;
|
|
275
|
+
return {
|
|
276
|
+
...this.metrics,
|
|
277
|
+
cacheHitRate: total > 0 ? this.metrics.cacheHits / total : 0,
|
|
278
|
+
avgDurationMs: this.metrics.requestCount > 0
|
|
279
|
+
? Math.round(this.metrics.totalDurationMs / this.metrics.requestCount)
|
|
280
|
+
: 0,
|
|
281
|
+
cacheSize: this.cache.size,
|
|
282
|
+
pendingRequests: this.pendingRequests.size,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Clears the response cache
|
|
287
|
+
*/
|
|
288
|
+
clearCache() {
|
|
289
|
+
this.cache.clear();
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Invalidates cache entries matching a pattern
|
|
293
|
+
*/
|
|
294
|
+
invalidateCache(pattern) {
|
|
295
|
+
let count = 0;
|
|
296
|
+
const regex = typeof pattern === "string" ? new RegExp(pattern) : pattern;
|
|
297
|
+
const keys = Array.from(this.cache.keys());
|
|
298
|
+
for (const key of keys) {
|
|
299
|
+
if (regex.test(key)) {
|
|
300
|
+
this.cache.delete(key);
|
|
301
|
+
count++;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return count;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Resets performance metrics
|
|
308
|
+
*/
|
|
309
|
+
resetMetrics() {
|
|
310
|
+
this.metrics.requestCount = 0;
|
|
311
|
+
this.metrics.cacheHits = 0;
|
|
312
|
+
this.metrics.cacheMisses = 0;
|
|
313
|
+
this.metrics.dedupedRequests = 0;
|
|
314
|
+
this.metrics.totalDurationMs = 0;
|
|
315
|
+
this.metrics.errors = 0;
|
|
316
|
+
}
|
|
317
|
+
// ==========================================================================
|
|
318
|
+
// PRIVATE - EXECUTION
|
|
319
|
+
// ==========================================================================
|
|
320
|
+
async executeWithRetry(request, context, requestId, startTime) {
|
|
321
|
+
const timeout = request.timeout ?? this.config.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
322
|
+
const serializedBody = this.serializeBody(request.body);
|
|
323
|
+
let lastError;
|
|
324
|
+
let attempt = 0;
|
|
325
|
+
const maxAttempts = this.retryConfig.enabled
|
|
326
|
+
? this.retryConfig.maxAttempts
|
|
327
|
+
: 1;
|
|
328
|
+
while (attempt < maxAttempts) {
|
|
329
|
+
attempt++;
|
|
330
|
+
try {
|
|
331
|
+
return await this.executeRequest({ ...request, body: serializedBody }, context, requestId, timeout, attempt, startTime);
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
lastError = error;
|
|
335
|
+
this.metrics.errors++;
|
|
336
|
+
const durationMs = Date.now() - startTime;
|
|
337
|
+
const shouldRetry = this.shouldRetry(lastError, attempt, maxAttempts);
|
|
338
|
+
await this.hooks.onError?.({
|
|
339
|
+
requestId,
|
|
340
|
+
method: request.method,
|
|
341
|
+
url: this.buildUrl(request.path, request.params),
|
|
342
|
+
headers: this.buildHeadersObject(context, requestId),
|
|
343
|
+
body: serializedBody,
|
|
344
|
+
attempt,
|
|
345
|
+
startTime,
|
|
346
|
+
error: lastError,
|
|
347
|
+
durationMs,
|
|
348
|
+
willRetry: shouldRetry,
|
|
349
|
+
});
|
|
350
|
+
if (shouldRetry) {
|
|
351
|
+
const delayMs = this.calculateRetryDelay(lastError, attempt);
|
|
352
|
+
await this.hooks.onRetry?.({
|
|
353
|
+
requestId,
|
|
354
|
+
attempt,
|
|
355
|
+
maxAttempts,
|
|
356
|
+
delayMs,
|
|
357
|
+
error: lastError,
|
|
358
|
+
reason: this.getRetryReason(lastError),
|
|
359
|
+
});
|
|
360
|
+
if (this.config.debug) {
|
|
361
|
+
console.log(`[DJUST SDK] Retry ${attempt}/${maxAttempts} after ${delayMs}ms`);
|
|
362
|
+
}
|
|
363
|
+
await this.sleep(delayMs);
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (lastError instanceof base_1.SDKError && !this.config.strictErrors) {
|
|
370
|
+
throw (0, compat_1.toLegacyError)(lastError);
|
|
371
|
+
}
|
|
372
|
+
throw lastError;
|
|
373
|
+
}
|
|
374
|
+
async executeRequest(request, context, requestId, timeout, attempt, startTime) {
|
|
375
|
+
const url = this.buildUrl(request.path, request.params);
|
|
376
|
+
const headers = this.buildHeaders(context, requestId);
|
|
377
|
+
const headersObject = this.buildHeadersObject(context, requestId);
|
|
378
|
+
await this.hooks.onRequestStart?.({
|
|
379
|
+
requestId,
|
|
380
|
+
method: request.method,
|
|
381
|
+
url,
|
|
382
|
+
headers: headersObject,
|
|
383
|
+
body: request.body,
|
|
384
|
+
attempt,
|
|
385
|
+
startTime,
|
|
386
|
+
});
|
|
387
|
+
if (this.config.debug) {
|
|
388
|
+
console.log(`[DJUST SDK] ${request.method} ${url} (attempt ${attempt})`);
|
|
389
|
+
}
|
|
390
|
+
const controller = new AbortController();
|
|
391
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
392
|
+
if (request.signal) {
|
|
393
|
+
request.signal.addEventListener("abort", () => controller.abort());
|
|
394
|
+
}
|
|
395
|
+
try {
|
|
396
|
+
const fetchOptions = {
|
|
397
|
+
method: request.method,
|
|
398
|
+
headers,
|
|
399
|
+
body: request.body,
|
|
400
|
+
signal: controller.signal,
|
|
401
|
+
};
|
|
402
|
+
// Add keep-alive hint (browser support varies)
|
|
403
|
+
if (this.perfConfig.keepAlive) {
|
|
404
|
+
fetchOptions.keepalive = true;
|
|
405
|
+
}
|
|
406
|
+
const response = await fetch(url, fetchOptions);
|
|
407
|
+
clearTimeout(timeoutId);
|
|
408
|
+
const durationMs = Date.now() - startTime;
|
|
409
|
+
if (!response.ok) {
|
|
410
|
+
const errorBody = await response.text();
|
|
411
|
+
// Parse request body if it's a JSON string
|
|
412
|
+
let parsedRequestBody = undefined;
|
|
413
|
+
if (request.body) {
|
|
414
|
+
try {
|
|
415
|
+
if (typeof request.body === "string") {
|
|
416
|
+
parsedRequestBody = JSON.parse(request.body);
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
parsedRequestBody = request.body;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
catch {
|
|
423
|
+
// If parsing fails, keep as string
|
|
424
|
+
parsedRequestBody = request.body;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
throw (0, factory_1.createErrorFromResponse)({
|
|
428
|
+
statusCode: response.status,
|
|
429
|
+
body: errorBody,
|
|
430
|
+
url,
|
|
431
|
+
method: request.method,
|
|
432
|
+
durationMs,
|
|
433
|
+
requestId,
|
|
434
|
+
queryParams: request.params,
|
|
435
|
+
requestBody: parsedRequestBody,
|
|
436
|
+
requestHeaders: headersObject,
|
|
437
|
+
sdkMethod: context.sdkMethod,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
// Parse response
|
|
441
|
+
const contentType = response.headers.get("content-type");
|
|
442
|
+
const isJson = contentType?.includes("application/json");
|
|
443
|
+
const responseText = await response.text();
|
|
444
|
+
let data;
|
|
445
|
+
if (isJson && responseText) {
|
|
446
|
+
data = JSON.parse(responseText);
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
data = responseText;
|
|
450
|
+
}
|
|
451
|
+
await this.hooks.onRequestEnd?.({
|
|
452
|
+
requestId,
|
|
453
|
+
method: request.method,
|
|
454
|
+
url,
|
|
455
|
+
headers: headersObject,
|
|
456
|
+
body: request.body,
|
|
457
|
+
attempt,
|
|
458
|
+
startTime,
|
|
459
|
+
status: response.status,
|
|
460
|
+
durationMs,
|
|
461
|
+
responseHeaders: response.headers,
|
|
462
|
+
});
|
|
463
|
+
return {
|
|
464
|
+
data,
|
|
465
|
+
headers: response.headers,
|
|
466
|
+
status: response.status,
|
|
467
|
+
durationMs,
|
|
468
|
+
requestId,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
catch (error) {
|
|
472
|
+
clearTimeout(timeoutId);
|
|
473
|
+
if (error instanceof base_1.SDKError) {
|
|
474
|
+
throw error;
|
|
475
|
+
}
|
|
476
|
+
const err = error;
|
|
477
|
+
if (err.name === "AbortError") {
|
|
478
|
+
if (request.signal?.aborted) {
|
|
479
|
+
throw network_error_1.NetworkError.aborted({
|
|
480
|
+
requestId,
|
|
481
|
+
endpoint: request.path,
|
|
482
|
+
method: request.method,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
throw new timeout_error_1.TimeoutError(timeout, {
|
|
486
|
+
requestId,
|
|
487
|
+
endpoint: request.path,
|
|
488
|
+
method: request.method,
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
throw (0, factory_1.createErrorFromException)(err, {
|
|
492
|
+
requestId,
|
|
493
|
+
endpoint: request.path,
|
|
494
|
+
method: request.method,
|
|
495
|
+
durationMs: Date.now() - startTime,
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
// ==========================================================================
|
|
500
|
+
// PRIVATE - CACHE
|
|
501
|
+
// ==========================================================================
|
|
502
|
+
shouldUseCache(request, context) {
|
|
503
|
+
return (this.perfConfig.cache && request.method === "GET" && !context.skipCache);
|
|
504
|
+
}
|
|
505
|
+
getFromCache(key) {
|
|
506
|
+
return this.cache.get(key);
|
|
507
|
+
}
|
|
508
|
+
setCache(key, data, etag, maxAge) {
|
|
509
|
+
// Evict oldest if at capacity
|
|
510
|
+
if (this.cache.size >= this.perfConfig.cacheMaxSize &&
|
|
511
|
+
!this.cache.has(key)) {
|
|
512
|
+
const firstKey = this.cache.keys().next().value;
|
|
513
|
+
if (firstKey !== undefined) {
|
|
514
|
+
this.cache.delete(firstKey);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
this.cache.set(key, {
|
|
518
|
+
data,
|
|
519
|
+
timestamp: Date.now(),
|
|
520
|
+
etag,
|
|
521
|
+
maxAge,
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
buildCacheKey(method, url, context) {
|
|
525
|
+
// Include relevant context in cache key
|
|
526
|
+
const parts = [method, url];
|
|
527
|
+
if (context.accessToken)
|
|
528
|
+
parts.push(`token:${context.accessToken.slice(-8)}`);
|
|
529
|
+
if (context.customerAccountId)
|
|
530
|
+
parts.push(`account:${context.customerAccountId}`);
|
|
531
|
+
if (context.locale)
|
|
532
|
+
parts.push(`locale:${context.locale}`);
|
|
533
|
+
return parts.join("|");
|
|
534
|
+
}
|
|
535
|
+
parseCacheMaxAge(cacheControl) {
|
|
536
|
+
if (!cacheControl)
|
|
537
|
+
return undefined;
|
|
538
|
+
const match = cacheControl.match(/max-age=(\d+)/);
|
|
539
|
+
return match ? parseInt(match[1], 10) * 1000 : undefined;
|
|
540
|
+
}
|
|
541
|
+
revalidateInBackground(request, context, cacheKey) {
|
|
542
|
+
// Fire and forget revalidation
|
|
543
|
+
this.executeWithRetry(request, { ...context, skipCache: true }, this.generateRequestId(), Date.now())
|
|
544
|
+
.then((response) => {
|
|
545
|
+
if (response.status === 200) {
|
|
546
|
+
this.setCache(cacheKey, response.data);
|
|
547
|
+
}
|
|
548
|
+
})
|
|
549
|
+
.catch(() => {
|
|
550
|
+
// Ignore revalidation errors
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
// ==========================================================================
|
|
554
|
+
// PRIVATE - DEDUPLICATION
|
|
555
|
+
// ==========================================================================
|
|
556
|
+
shouldDedupe(request, context) {
|
|
557
|
+
return (this.perfConfig.deduplication &&
|
|
558
|
+
request.method === "GET" &&
|
|
559
|
+
!context.skipDedup);
|
|
560
|
+
}
|
|
561
|
+
// ==========================================================================
|
|
562
|
+
// PRIVATE - RETRY
|
|
563
|
+
// ==========================================================================
|
|
564
|
+
shouldRetry(error, attempt, maxAttempts) {
|
|
565
|
+
if (!this.retryConfig.enabled)
|
|
566
|
+
return false;
|
|
567
|
+
if (attempt >= maxAttempts)
|
|
568
|
+
return false;
|
|
569
|
+
if (error instanceof base_1.SDKError) {
|
|
570
|
+
if (error.retriable)
|
|
571
|
+
return true;
|
|
572
|
+
if (this.retryConfig.retryableStatuses.includes(error.httpStatus))
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
if (error instanceof network_error_1.NetworkError)
|
|
576
|
+
return true;
|
|
577
|
+
return (0, guards_1.isRetryable)(error);
|
|
578
|
+
}
|
|
579
|
+
calculateRetryDelay(error, attempt) {
|
|
580
|
+
if (error instanceof rate_limit_error_1.RateLimitError && error.retryAfterMs) {
|
|
581
|
+
return Math.min(error.retryAfterMs, this.retryConfig.maxDelayMs);
|
|
582
|
+
}
|
|
583
|
+
const exponentialDelay = this.retryConfig.initialDelayMs * Math.pow(2, attempt - 1);
|
|
584
|
+
const jitterMultiplier = 1 + (Math.random() * 2 - 1) * this.retryConfig.jitter;
|
|
585
|
+
const delayWithJitter = exponentialDelay * jitterMultiplier;
|
|
586
|
+
return Math.min(Math.round(delayWithJitter), this.retryConfig.maxDelayMs);
|
|
587
|
+
}
|
|
588
|
+
getRetryReason(error) {
|
|
589
|
+
if (error instanceof rate_limit_error_1.RateLimitError)
|
|
590
|
+
return "rate_limit";
|
|
591
|
+
if (error instanceof timeout_error_1.TimeoutError)
|
|
592
|
+
return "timeout";
|
|
593
|
+
if (error instanceof network_error_1.NetworkError)
|
|
594
|
+
return "network";
|
|
595
|
+
if (error instanceof base_1.SDKError)
|
|
596
|
+
return `http_${error.httpStatus}`;
|
|
597
|
+
return "unknown";
|
|
598
|
+
}
|
|
599
|
+
// ==========================================================================
|
|
600
|
+
// PRIVATE - UTILITIES
|
|
601
|
+
// ==========================================================================
|
|
602
|
+
buildUrl(path, params) {
|
|
603
|
+
let url = `${this.config.baseUrl}${path}`;
|
|
604
|
+
if (params && Object.keys(params).length > 0) {
|
|
605
|
+
const filteredParams = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
|
|
606
|
+
const useRepeatFormat = path.includes("search") || path.includes("/customer-accounts/orders");
|
|
607
|
+
const queryString = useRepeatFormat
|
|
608
|
+
? this.stringifyParamsRepeat(filteredParams)
|
|
609
|
+
: qs.stringify(filteredParams, {
|
|
610
|
+
arrayFormat: "bracket",
|
|
611
|
+
skipNull: true,
|
|
612
|
+
});
|
|
613
|
+
if (queryString) {
|
|
614
|
+
url += `?${queryString}`;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return url;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Serializes params so that arrays become repeated keys: &brand=1664&brand=1664+BLANC
|
|
621
|
+
* (API search and customer-accounts/orders expect this format, not comma or bracket).
|
|
622
|
+
*/
|
|
623
|
+
stringifyParamsRepeat(params) {
|
|
624
|
+
const pairs = [];
|
|
625
|
+
for (const [key, value] of Object.entries(params)) {
|
|
626
|
+
if (value === undefined || value === null)
|
|
627
|
+
continue;
|
|
628
|
+
if (Array.isArray(value)) {
|
|
629
|
+
for (const item of value) {
|
|
630
|
+
if (item === undefined || item === null)
|
|
631
|
+
continue;
|
|
632
|
+
pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(item))}`);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return pairs.join("&");
|
|
640
|
+
}
|
|
641
|
+
buildHeaders(context, requestId) {
|
|
642
|
+
const headers = new Headers({
|
|
643
|
+
"dj-client": this.config.clientId,
|
|
644
|
+
"dj-api-key": this.config.apiKey,
|
|
645
|
+
"Content-Type": "application/json",
|
|
646
|
+
"x-request-id": requestId,
|
|
647
|
+
});
|
|
648
|
+
// Compression support
|
|
649
|
+
if (this.perfConfig.compression) {
|
|
650
|
+
headers.append("Accept-Encoding", "gzip, deflate, br");
|
|
651
|
+
}
|
|
652
|
+
// Keep-alive hint
|
|
653
|
+
if (this.perfConfig.keepAlive) {
|
|
654
|
+
headers.append("Connection", "keep-alive");
|
|
655
|
+
}
|
|
656
|
+
if (context.accessToken) {
|
|
657
|
+
headers.append("Authorization", `Bearer ${context.accessToken}`);
|
|
658
|
+
}
|
|
659
|
+
if (context.locale) {
|
|
660
|
+
headers.append("locale", context.locale);
|
|
661
|
+
}
|
|
662
|
+
if (context.customerAccountId) {
|
|
663
|
+
headers.append("customer-account-id", context.customerAccountId);
|
|
664
|
+
}
|
|
665
|
+
if (context.storeId) {
|
|
666
|
+
headers.append("dj-store", context.storeId);
|
|
667
|
+
}
|
|
668
|
+
if (context.storeViewId) {
|
|
669
|
+
headers.append("dj-store-view", context.storeViewId);
|
|
670
|
+
}
|
|
671
|
+
if (context.headers) {
|
|
672
|
+
Object.entries(context.headers).forEach(([key, value]) => {
|
|
673
|
+
headers.append(key, value);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
return headers;
|
|
677
|
+
}
|
|
678
|
+
buildHeadersObject(context, requestId) {
|
|
679
|
+
const headers = {
|
|
680
|
+
"dj-client": this.config.clientId,
|
|
681
|
+
"Content-Type": "application/json",
|
|
682
|
+
};
|
|
683
|
+
if (this.config.apiKey) {
|
|
684
|
+
headers["dj-api-key"] = "[REDACTED]";
|
|
685
|
+
}
|
|
686
|
+
if (requestId) {
|
|
687
|
+
headers["x-request-id"] = requestId;
|
|
688
|
+
}
|
|
689
|
+
if (context.accessToken) {
|
|
690
|
+
headers["Authorization"] = "Bearer [REDACTED]";
|
|
691
|
+
}
|
|
692
|
+
if (context.locale)
|
|
693
|
+
headers["locale"] = context.locale;
|
|
694
|
+
if (context.customerAccountId)
|
|
695
|
+
headers["customer-account-id"] = context.customerAccountId;
|
|
696
|
+
// Always expose store headers in debug metadata (even when omitted from the request)
|
|
697
|
+
headers["dj-store"] = context.storeId || "(not sent)";
|
|
698
|
+
headers["dj-store-view"] = context.storeViewId || "(not sent)";
|
|
699
|
+
if (context.headers) {
|
|
700
|
+
for (const [key, value] of Object.entries(context.headers)) {
|
|
701
|
+
headers[key] = value;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
return headers;
|
|
705
|
+
}
|
|
706
|
+
serializeBody(body) {
|
|
707
|
+
if (body === undefined || body === null)
|
|
708
|
+
return undefined;
|
|
709
|
+
if (typeof body === "string")
|
|
710
|
+
return body;
|
|
711
|
+
return JSON.stringify(body);
|
|
712
|
+
}
|
|
713
|
+
generateRequestId() {
|
|
714
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
715
|
+
return crypto.randomUUID();
|
|
716
|
+
}
|
|
717
|
+
return `dj-${Date.now().toString(36)}-${Math.random()
|
|
718
|
+
.toString(36)
|
|
719
|
+
.substr(2, 9)}`;
|
|
720
|
+
}
|
|
721
|
+
sleep(ms) {
|
|
722
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
exports.Transport = Transport;
|
|
726
|
+
// ============================================================================
|
|
727
|
+
// FACTORY FUNCTION
|
|
728
|
+
// ============================================================================
|
|
729
|
+
/**
|
|
730
|
+
* Creates a new Transport instance with performance optimizations.
|
|
731
|
+
*/
|
|
732
|
+
function createTransport(config) {
|
|
733
|
+
return new Transport(config);
|
|
734
|
+
}
|
|
735
|
+
//# sourceMappingURL=transport.js.map
|