@djust-b2b/djust-front-sdk 3.0.0-beta.8 → 3.0.0
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 +43 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +274 -64
- 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/definitions.d.ts +3 -1
- package/dist/services/quote/definitions.d.ts.map +1 -1
- package/dist/services/quote/index.d.ts +2 -1
- package/dist/services/quote/index.d.ts.map +1 -1
- package/dist/services/quote/quote.service.d.ts +1 -0
- package/dist/services/quote/quote.service.d.ts.map +1 -1
- package/dist/services/quote/types.d.ts +2 -0
- package/dist/services/quote/types.d.ts.map +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,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DJUST SDK Server Error
|
|
4
|
+
* Errors for server-side failures (5xx).
|
|
5
|
+
*
|
|
6
|
+
* @module errors/classes/server
|
|
7
|
+
* @since 2.17.0
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ServerError = void 0;
|
|
11
|
+
const base_1 = require("../base");
|
|
12
|
+
const codes_1 = require("../codes");
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when the server returns a 5xx error.
|
|
15
|
+
*
|
|
16
|
+
* Server errors are typically retriable, as they often indicate
|
|
17
|
+
* temporary issues like overload or maintenance.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { ServerError } from '@djust-b2b/djust-front-sdk';
|
|
22
|
+
*
|
|
23
|
+
* try {
|
|
24
|
+
* await sdk.checkout();
|
|
25
|
+
* } catch (error) {
|
|
26
|
+
* if (error instanceof ServerError) {
|
|
27
|
+
* if (error.retriable) {
|
|
28
|
+
* // Retry with exponential backoff
|
|
29
|
+
* await retryWithBackoff(() => sdk.checkout());
|
|
30
|
+
* } else {
|
|
31
|
+
* // Show error page
|
|
32
|
+
* showErrorPage('Service temporarily unavailable');
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
class ServerError extends base_1.SDKError {
|
|
39
|
+
constructor(message, httpStatus = 500, code = codes_1.SDKErrorCode.SERVER_ERROR, details, metadata) {
|
|
40
|
+
super({
|
|
41
|
+
code,
|
|
42
|
+
message,
|
|
43
|
+
httpStatus,
|
|
44
|
+
details,
|
|
45
|
+
retriable: true, // Server errors are typically retriable
|
|
46
|
+
metadata,
|
|
47
|
+
});
|
|
48
|
+
this.name = "ServerError";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a ServerError for Internal Server Error (500).
|
|
52
|
+
*/
|
|
53
|
+
static internalError(message, metadata) {
|
|
54
|
+
return new ServerError(message || "Internal server error", 500, codes_1.SDKErrorCode.INTERNAL_ERROR, {}, metadata);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a ServerError for Bad Gateway (502).
|
|
58
|
+
*/
|
|
59
|
+
static badGateway(metadata) {
|
|
60
|
+
return new ServerError("Bad gateway", 502, codes_1.SDKErrorCode.BAD_GATEWAY, {}, metadata);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates a ServerError for Service Unavailable (503).
|
|
64
|
+
*/
|
|
65
|
+
static serviceUnavailable(retryAfterMs, metadata) {
|
|
66
|
+
const error = new ServerError("Service temporarily unavailable", 503, codes_1.SDKErrorCode.SERVICE_UNAVAILABLE, retryAfterMs ? { retryAfterMs } : {}, metadata);
|
|
67
|
+
if (retryAfterMs) {
|
|
68
|
+
error.retryAfterMs = retryAfterMs;
|
|
69
|
+
}
|
|
70
|
+
return error;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a ServerError for Gateway Timeout (504).
|
|
74
|
+
*/
|
|
75
|
+
static gatewayTimeout(metadata) {
|
|
76
|
+
return new ServerError("Gateway timeout", 504, codes_1.SDKErrorCode.GATEWAY_TIMEOUT, {}, metadata);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates a ServerError from HTTP 5xx response.
|
|
80
|
+
*/
|
|
81
|
+
static fromResponse(statusCode, body, headers, metadata) {
|
|
82
|
+
// Try to parse body for error details
|
|
83
|
+
let parsed = {};
|
|
84
|
+
try {
|
|
85
|
+
parsed = JSON.parse(body);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// Not JSON
|
|
89
|
+
}
|
|
90
|
+
const message = parsed.message || parsed.error || getDefaultMessageForStatus(statusCode);
|
|
91
|
+
const code = mapStatusToCode(statusCode);
|
|
92
|
+
// Check for Retry-After header
|
|
93
|
+
let retryAfterMs;
|
|
94
|
+
if (headers) {
|
|
95
|
+
const retryAfter = headers.get("Retry-After");
|
|
96
|
+
if (retryAfter) {
|
|
97
|
+
const seconds = parseInt(retryAfter, 10);
|
|
98
|
+
if (!isNaN(seconds)) {
|
|
99
|
+
retryAfterMs = seconds * 1000;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const error = new ServerError(message, statusCode, code, { rawBody: body.substring(0, 500) }, // Truncate large bodies
|
|
104
|
+
metadata);
|
|
105
|
+
if (retryAfterMs) {
|
|
106
|
+
error.retryAfterMs = retryAfterMs;
|
|
107
|
+
}
|
|
108
|
+
return error;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Checks if this is a transient error that will likely resolve on retry.
|
|
112
|
+
*/
|
|
113
|
+
isTransient() {
|
|
114
|
+
return [502, 503, 504].includes(this.httpStatus);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.ServerError = ServerError;
|
|
118
|
+
/**
|
|
119
|
+
* Maps HTTP status code to SDK error code.
|
|
120
|
+
*/
|
|
121
|
+
function mapStatusToCode(status) {
|
|
122
|
+
switch (status) {
|
|
123
|
+
case 500:
|
|
124
|
+
return codes_1.SDKErrorCode.INTERNAL_ERROR;
|
|
125
|
+
case 502:
|
|
126
|
+
return codes_1.SDKErrorCode.BAD_GATEWAY;
|
|
127
|
+
case 503:
|
|
128
|
+
return codes_1.SDKErrorCode.SERVICE_UNAVAILABLE;
|
|
129
|
+
case 504:
|
|
130
|
+
return codes_1.SDKErrorCode.GATEWAY_TIMEOUT;
|
|
131
|
+
default:
|
|
132
|
+
return codes_1.SDKErrorCode.SERVER_ERROR;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Gets default error message for HTTP status code.
|
|
137
|
+
*/
|
|
138
|
+
function getDefaultMessageForStatus(status) {
|
|
139
|
+
switch (status) {
|
|
140
|
+
case 500:
|
|
141
|
+
return "Internal server error";
|
|
142
|
+
case 501:
|
|
143
|
+
return "Not implemented";
|
|
144
|
+
case 502:
|
|
145
|
+
return "Bad gateway";
|
|
146
|
+
case 503:
|
|
147
|
+
return "Service unavailable";
|
|
148
|
+
case 504:
|
|
149
|
+
return "Gateway timeout";
|
|
150
|
+
case 505:
|
|
151
|
+
return "HTTP version not supported";
|
|
152
|
+
default:
|
|
153
|
+
return `Server error (${status})`;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=server.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.error.js","sourceRoot":"","sources":["../../../src/errors/classes/server.error.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,kCAAmC;AACnC,oCAA+D;AAG/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,WAAY,SAAQ,eAAQ;IACvC,YACE,OAAe,EACf,aAAqB,GAAG,EACxB,OAAyB,oBAAY,CAAC,YAAY,EAClD,OAAiC,EACjC,QAA0B;QAE1B,KAAK,CAAC;YACJ,IAAI;YACJ,OAAO;YACP,UAAU;YACV,OAAO;YACP,SAAS,EAAE,IAAI,EAAE,wCAAwC;YACzD,QAAQ;SACT,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAClB,OAAgB,EAChB,QAA0B;QAE1B,OAAO,IAAI,WAAW,CACpB,OAAO,IAAI,uBAAuB,EAClC,GAAG,EACH,oBAAY,CAAC,cAAc,EAC3B,EAAE,EACF,QAAQ,CACT,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,QAA0B;QAC1C,OAAO,IAAI,WAAW,CACpB,aAAa,EACb,GAAG,EACH,oBAAY,CAAC,WAAW,EACxB,EAAE,EACF,QAAQ,CACT,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,kBAAkB,CACvB,YAAqB,EACrB,QAA0B;QAE1B,MAAM,KAAK,GAAG,IAAI,WAAW,CAC3B,iCAAiC,EACjC,GAAG,EACH,oBAAY,CAAC,mBAAmB,EAChC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,EACpC,QAAQ,CACT,CAAC;QAEF,IAAI,YAAY,EAAE,CAAC;YAChB,KAAa,CAAC,YAAY,GAAG,YAAY,CAAC;QAC7C,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,QAA0B;QAC9C,OAAO,IAAI,WAAW,CACpB,iBAAiB,EACjB,GAAG,EACH,oBAAY,CAAC,eAAe,EAC5B,EAAE,EACF,QAAQ,CACT,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY,CACjB,UAAkB,EAClB,IAAY,EACZ,OAAiB,EACjB,QAA0B;QAE1B,sCAAsC;QACtC,IAAI,MAAM,GAAwD,EAAE,CAAC;QACrE,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,WAAW;QACb,CAAC;QAED,MAAM,OAAO,GACX,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,IAAI,0BAA0B,CAAC,UAAU,CAAC,CAAC;QAC3E,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;QAEzC,+BAA+B;QAC/B,IAAI,YAAgC,CAAC;QACrC,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YAC9C,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBACzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;oBACpB,YAAY,GAAG,OAAO,GAAG,IAAI,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,WAAW,CAC3B,OAAO,EACP,UAAU,EACV,IAAI,EACJ,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,wBAAwB;QAC7D,QAAQ,CACT,CAAC;QAEF,IAAI,YAAY,EAAE,CAAC;YAChB,KAAa,CAAC,YAAY,GAAG,YAAY,CAAC;QAC7C,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;CACF;AA1ID,kCA0IC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,MAAc;IACrC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,oBAAY,CAAC,cAAc,CAAC;QACrC,KAAK,GAAG;YACN,OAAO,oBAAY,CAAC,WAAW,CAAC;QAClC,KAAK,GAAG;YACN,OAAO,oBAAY,CAAC,mBAAmB,CAAC;QAC1C,KAAK,GAAG;YACN,OAAO,oBAAY,CAAC,eAAe,CAAC;QACtC;YACE,OAAO,oBAAY,CAAC,YAAY,CAAC;IACrC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,0BAA0B,CAAC,MAAc;IAChD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,uBAAuB,CAAC;QACjC,KAAK,GAAG;YACN,OAAO,iBAAiB,CAAC;QAC3B,KAAK,GAAG;YACN,OAAO,aAAa,CAAC;QACvB,KAAK,GAAG;YACN,OAAO,qBAAqB,CAAC;QAC/B,KAAK,GAAG;YACN,OAAO,iBAAiB,CAAC;QAC3B,KAAK,GAAG;YACN,OAAO,4BAA4B,CAAC;QACtC;YACE,OAAO,iBAAiB,MAAM,GAAG,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DJUST SDK Timeout Error
|
|
3
|
+
* Errors for request timeouts.
|
|
4
|
+
*
|
|
5
|
+
* @module errors/classes/timeout
|
|
6
|
+
* @since 2.17.0
|
|
7
|
+
*/
|
|
8
|
+
import { SDKError } from "../base";
|
|
9
|
+
import type { RequestMetadata } from "../types";
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when a request times out.
|
|
12
|
+
*
|
|
13
|
+
* Timeout errors are retriable, as the server may be temporarily
|
|
14
|
+
* overloaded or the network may be slow.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { TimeoutError } from '@djust-b2b/djust-front-sdk';
|
|
19
|
+
*
|
|
20
|
+
* const client = createDjustClient({
|
|
21
|
+
* baseUrl: 'https://api.djust.io',
|
|
22
|
+
* clientId: 'xxx',
|
|
23
|
+
* apiKey: 'yyy',
|
|
24
|
+
* timeout: 5000, // 5 seconds
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* try {
|
|
28
|
+
* await client.getProducts();
|
|
29
|
+
* } catch (error) {
|
|
30
|
+
* if (error instanceof TimeoutError) {
|
|
31
|
+
* console.log(`Request timed out after ${error.timeoutMs}ms`);
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class TimeoutError extends SDKError {
|
|
37
|
+
/** The timeout value that was exceeded (in milliseconds) */
|
|
38
|
+
readonly timeoutMs: number;
|
|
39
|
+
constructor(timeoutMs: number, metadata?: RequestMetadata);
|
|
40
|
+
/**
|
|
41
|
+
* Returns the timeout value in seconds.
|
|
42
|
+
*/
|
|
43
|
+
getTimeoutSeconds(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a TimeoutError for a client-side timeout.
|
|
46
|
+
*
|
|
47
|
+
* @param timeoutMs - The timeout value that was exceeded
|
|
48
|
+
* @param metadata - Optional request metadata
|
|
49
|
+
*/
|
|
50
|
+
static clientTimeout(timeoutMs: number, metadata?: RequestMetadata): TimeoutError;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a TimeoutError from a server 408 response.
|
|
53
|
+
*
|
|
54
|
+
* @param metadata - Optional request metadata
|
|
55
|
+
*/
|
|
56
|
+
static serverTimeout(metadata?: RequestMetadata): TimeoutError;
|
|
57
|
+
/**
|
|
58
|
+
* Suggests a longer timeout for retry.
|
|
59
|
+
*
|
|
60
|
+
* @param multiplier - Factor to multiply the original timeout (default: 2)
|
|
61
|
+
*/
|
|
62
|
+
suggestRetryTimeout(multiplier?: number): number;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=timeout.error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeout.error.d.ts","sourceRoot":"","sources":["../../../src/errors/classes/timeout.error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,YAAa,SAAQ,QAAQ;IACxC,4DAA4D;IAC5D,SAAgB,SAAS,EAAE,MAAM,CAAC;gBAEtB,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe;IAczD;;OAEG;IACH,iBAAiB,IAAI,MAAM;IAI3B;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,eAAe,GACzB,YAAY;IAIf;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,eAAe,GAAG,YAAY;IAS9D;;;;OAIG;IACH,mBAAmB,CAAC,UAAU,GAAE,MAAU,GAAG,MAAM;CAGpD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DJUST SDK Timeout Error
|
|
4
|
+
* Errors for request timeouts.
|
|
5
|
+
*
|
|
6
|
+
* @module errors/classes/timeout
|
|
7
|
+
* @since 2.17.0
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.TimeoutError = void 0;
|
|
11
|
+
const base_1 = require("../base");
|
|
12
|
+
const codes_1 = require("../codes");
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when a request times out.
|
|
15
|
+
*
|
|
16
|
+
* Timeout errors are retriable, as the server may be temporarily
|
|
17
|
+
* overloaded or the network may be slow.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { TimeoutError } from '@djust-b2b/djust-front-sdk';
|
|
22
|
+
*
|
|
23
|
+
* const client = createDjustClient({
|
|
24
|
+
* baseUrl: 'https://api.djust.io',
|
|
25
|
+
* clientId: 'xxx',
|
|
26
|
+
* apiKey: 'yyy',
|
|
27
|
+
* timeout: 5000, // 5 seconds
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* try {
|
|
31
|
+
* await client.getProducts();
|
|
32
|
+
* } catch (error) {
|
|
33
|
+
* if (error instanceof TimeoutError) {
|
|
34
|
+
* console.log(`Request timed out after ${error.timeoutMs}ms`);
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
class TimeoutError extends base_1.SDKError {
|
|
40
|
+
constructor(timeoutMs, metadata) {
|
|
41
|
+
super({
|
|
42
|
+
code: codes_1.SDKErrorCode.TIMEOUT,
|
|
43
|
+
message: `Request timed out after ${timeoutMs}ms`,
|
|
44
|
+
httpStatus: 0,
|
|
45
|
+
details: { timeoutMs },
|
|
46
|
+
retriable: true,
|
|
47
|
+
metadata,
|
|
48
|
+
});
|
|
49
|
+
this.name = "TimeoutError";
|
|
50
|
+
this.timeoutMs = timeoutMs;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns the timeout value in seconds.
|
|
54
|
+
*/
|
|
55
|
+
getTimeoutSeconds() {
|
|
56
|
+
return Math.ceil(this.timeoutMs / 1000);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates a TimeoutError for a client-side timeout.
|
|
60
|
+
*
|
|
61
|
+
* @param timeoutMs - The timeout value that was exceeded
|
|
62
|
+
* @param metadata - Optional request metadata
|
|
63
|
+
*/
|
|
64
|
+
static clientTimeout(timeoutMs, metadata) {
|
|
65
|
+
return new TimeoutError(timeoutMs, metadata);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a TimeoutError from a server 408 response.
|
|
69
|
+
*
|
|
70
|
+
* @param metadata - Optional request metadata
|
|
71
|
+
*/
|
|
72
|
+
static serverTimeout(metadata) {
|
|
73
|
+
// Server timeouts don't have a specific timeout value
|
|
74
|
+
// Use a placeholder
|
|
75
|
+
const error = new TimeoutError(0, metadata);
|
|
76
|
+
// Override message
|
|
77
|
+
error.message = "Server request timeout";
|
|
78
|
+
return error;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Suggests a longer timeout for retry.
|
|
82
|
+
*
|
|
83
|
+
* @param multiplier - Factor to multiply the original timeout (default: 2)
|
|
84
|
+
*/
|
|
85
|
+
suggestRetryTimeout(multiplier = 2) {
|
|
86
|
+
return Math.min(this.timeoutMs * multiplier, 120000); // Max 2 minutes
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.TimeoutError = TimeoutError;
|
|
90
|
+
//# sourceMappingURL=timeout.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeout.error.js","sourceRoot":"","sources":["../../../src/errors/classes/timeout.error.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,kCAAmC;AACnC,oCAAwC;AAGxC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,YAAa,SAAQ,eAAQ;IAIxC,YAAY,SAAiB,EAAE,QAA0B;QACvD,KAAK,CAAC;YACJ,IAAI,EAAE,oBAAY,CAAC,OAAO;YAC1B,OAAO,EAAE,2BAA2B,SAAS,IAAI;YACjD,UAAU,EAAE,CAAC;YACb,OAAO,EAAE,EAAE,SAAS,EAAE;YACtB,SAAS,EAAE,IAAI;YACf,QAAQ;SACT,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAClB,SAAiB,EACjB,QAA0B;QAE1B,OAAO,IAAI,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,QAA0B;QAC7C,sDAAsD;QACtD,oBAAoB;QACpB,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC5C,mBAAmB;QAClB,KAAa,CAAC,OAAO,GAAG,wBAAwB,CAAC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,aAAqB,CAAC;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,GAAG,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,gBAAgB;IACxE,CAAC;CACF;AA5DD,oCA4DC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DJUST SDK Unexpected Error
|
|
3
|
+
* Errors for unknown or unexpected failures.
|
|
4
|
+
*
|
|
5
|
+
* @module errors/classes/unexpected
|
|
6
|
+
* @since 2.17.0
|
|
7
|
+
*/
|
|
8
|
+
import { SDKError } from "../base";
|
|
9
|
+
import type { RequestMetadata } from "../types";
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when an unexpected condition occurs.
|
|
12
|
+
*
|
|
13
|
+
* This typically indicates:
|
|
14
|
+
* - A bug in the SDK
|
|
15
|
+
* - An unknown error type
|
|
16
|
+
* - An unexpected server response format
|
|
17
|
+
*
|
|
18
|
+
* These errors should be logged for investigation.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { UnexpectedError } from '@djust-b2b/djust-front-sdk';
|
|
23
|
+
*
|
|
24
|
+
* try {
|
|
25
|
+
* await sdk.doSomething();
|
|
26
|
+
* } catch (error) {
|
|
27
|
+
* if (error instanceof UnexpectedError) {
|
|
28
|
+
* // Log for investigation
|
|
29
|
+
* logger.error('Unexpected SDK error', {
|
|
30
|
+
* error: error.toJSON(),
|
|
31
|
+
* cause: error.cause?.stack,
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* // Show generic error to user
|
|
35
|
+
* showError('An unexpected error occurred. Please try again.');
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare class UnexpectedError extends SDKError {
|
|
41
|
+
constructor(message: string, cause?: Error, metadata?: RequestMetadata);
|
|
42
|
+
/**
|
|
43
|
+
* Creates an UnexpectedError from an unknown error.
|
|
44
|
+
*
|
|
45
|
+
* @param error - The unknown error
|
|
46
|
+
* @param metadata - Optional request metadata
|
|
47
|
+
*/
|
|
48
|
+
static from(error: unknown, metadata?: RequestMetadata): UnexpectedError;
|
|
49
|
+
/**
|
|
50
|
+
* Creates an UnexpectedError for an invalid response.
|
|
51
|
+
*
|
|
52
|
+
* @param reason - Why the response was invalid
|
|
53
|
+
* @param metadata - Optional request metadata
|
|
54
|
+
*/
|
|
55
|
+
static invalidResponse(reason: string, metadata?: RequestMetadata): UnexpectedError;
|
|
56
|
+
/**
|
|
57
|
+
* Creates an UnexpectedError for a configuration issue.
|
|
58
|
+
*
|
|
59
|
+
* @param message - Description of the configuration issue
|
|
60
|
+
*/
|
|
61
|
+
static configuration(message: string): UnexpectedError;
|
|
62
|
+
/**
|
|
63
|
+
* Creates an UnexpectedError indicating a bug.
|
|
64
|
+
*
|
|
65
|
+
* @param message - Description of the bug
|
|
66
|
+
* @param metadata - Optional context
|
|
67
|
+
*/
|
|
68
|
+
static bug(message: string, metadata?: RequestMetadata): UnexpectedError;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=unexpected.error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unexpected.error.d.ts","sourceRoot":"","sources":["../../../src/errors/classes/unexpected.error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,eAAe;IAatE;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,eAAe;IAwBxE;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CACpB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,eAAe,GACzB,eAAe;IAQlB;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe;IAItD;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,eAAe;CAOzE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DJUST SDK Unexpected Error
|
|
4
|
+
* Errors for unknown or unexpected failures.
|
|
5
|
+
*
|
|
6
|
+
* @module errors/classes/unexpected
|
|
7
|
+
* @since 2.17.0
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.UnexpectedError = void 0;
|
|
11
|
+
const base_1 = require("../base");
|
|
12
|
+
const codes_1 = require("../codes");
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when an unexpected condition occurs.
|
|
15
|
+
*
|
|
16
|
+
* This typically indicates:
|
|
17
|
+
* - A bug in the SDK
|
|
18
|
+
* - An unknown error type
|
|
19
|
+
* - An unexpected server response format
|
|
20
|
+
*
|
|
21
|
+
* These errors should be logged for investigation.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { UnexpectedError } from '@djust-b2b/djust-front-sdk';
|
|
26
|
+
*
|
|
27
|
+
* try {
|
|
28
|
+
* await sdk.doSomething();
|
|
29
|
+
* } catch (error) {
|
|
30
|
+
* if (error instanceof UnexpectedError) {
|
|
31
|
+
* // Log for investigation
|
|
32
|
+
* logger.error('Unexpected SDK error', {
|
|
33
|
+
* error: error.toJSON(),
|
|
34
|
+
* cause: error.cause?.stack,
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Show generic error to user
|
|
38
|
+
* showError('An unexpected error occurred. Please try again.');
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
class UnexpectedError extends base_1.SDKError {
|
|
44
|
+
constructor(message, cause, metadata) {
|
|
45
|
+
super({
|
|
46
|
+
code: codes_1.SDKErrorCode.UNEXPECTED_ERROR,
|
|
47
|
+
message,
|
|
48
|
+
httpStatus: 0,
|
|
49
|
+
cause,
|
|
50
|
+
retriable: false, // Unknown errors shouldn't be auto-retried
|
|
51
|
+
metadata,
|
|
52
|
+
});
|
|
53
|
+
this.name = "UnexpectedError";
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates an UnexpectedError from an unknown error.
|
|
57
|
+
*
|
|
58
|
+
* @param error - The unknown error
|
|
59
|
+
* @param metadata - Optional request metadata
|
|
60
|
+
*/
|
|
61
|
+
static from(error, metadata) {
|
|
62
|
+
if (error instanceof base_1.SDKError) {
|
|
63
|
+
// Already an SDK error - wrap it
|
|
64
|
+
return new UnexpectedError(`Unexpected SDK error: ${error.message}`, error, metadata);
|
|
65
|
+
}
|
|
66
|
+
if (error instanceof Error) {
|
|
67
|
+
return new UnexpectedError(error.message, error, metadata);
|
|
68
|
+
}
|
|
69
|
+
if (typeof error === "string") {
|
|
70
|
+
return new UnexpectedError(error, undefined, metadata);
|
|
71
|
+
}
|
|
72
|
+
return new UnexpectedError("An unexpected error occurred", undefined, {
|
|
73
|
+
...metadata,
|
|
74
|
+
rawError: String(error),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates an UnexpectedError for an invalid response.
|
|
79
|
+
*
|
|
80
|
+
* @param reason - Why the response was invalid
|
|
81
|
+
* @param metadata - Optional request metadata
|
|
82
|
+
*/
|
|
83
|
+
static invalidResponse(reason, metadata) {
|
|
84
|
+
return new UnexpectedError(`Invalid response: ${reason}`, undefined, metadata);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Creates an UnexpectedError for a configuration issue.
|
|
88
|
+
*
|
|
89
|
+
* @param message - Description of the configuration issue
|
|
90
|
+
*/
|
|
91
|
+
static configuration(message) {
|
|
92
|
+
return new UnexpectedError(`Configuration error: ${message}`);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Creates an UnexpectedError indicating a bug.
|
|
96
|
+
*
|
|
97
|
+
* @param message - Description of the bug
|
|
98
|
+
* @param metadata - Optional context
|
|
99
|
+
*/
|
|
100
|
+
static bug(message, metadata) {
|
|
101
|
+
return new UnexpectedError(`SDK Bug: ${message}. Please report this issue.`, undefined, metadata);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.UnexpectedError = UnexpectedError;
|
|
105
|
+
//# sourceMappingURL=unexpected.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unexpected.error.js","sourceRoot":"","sources":["../../../src/errors/classes/unexpected.error.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,kCAAmC;AACnC,oCAAwC;AAGxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,eAAgB,SAAQ,eAAQ;IAC3C,YAAY,OAAe,EAAE,KAAa,EAAE,QAA0B;QACpE,KAAK,CAAC;YACJ,IAAI,EAAE,oBAAY,CAAC,gBAAgB;YACnC,OAAO;YACP,UAAU,EAAE,CAAC;YACb,KAAK;YACL,SAAS,EAAE,KAAK,EAAE,2CAA2C;YAC7D,QAAQ;SACT,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,KAAc,EAAE,QAA0B;QACpD,IAAI,KAAK,YAAY,eAAQ,EAAE,CAAC;YAC9B,iCAAiC;YACjC,OAAO,IAAI,eAAe,CACxB,yBAAyB,KAAK,CAAC,OAAO,EAAE,EACxC,KAAK,EACL,QAAQ,CACT,CAAC;QACJ,CAAC;QAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,IAAI,eAAe,CAAC,8BAA8B,EAAE,SAAS,EAAE;YACpE,GAAG,QAAQ;YACX,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC;SACjB,CAAC,CAAC;IACZ,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CACpB,MAAc,EACd,QAA0B;QAE1B,OAAO,IAAI,eAAe,CACxB,qBAAqB,MAAM,EAAE,EAC7B,SAAS,EACT,QAAQ,CACT,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,OAAe;QAClC,OAAO,IAAI,eAAe,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,OAAe,EAAE,QAA0B;QACpD,OAAO,IAAI,eAAe,CACxB,YAAY,OAAO,6BAA6B,EAChD,SAAS,EACT,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AAnFD,0CAmFC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DJUST SDK Validation Error
|
|
3
|
+
* Errors related to invalid input parameters.
|
|
4
|
+
*
|
|
5
|
+
* @module errors/classes/validation
|
|
6
|
+
* @since 2.17.0
|
|
7
|
+
*/
|
|
8
|
+
import { SDKError } from "../base";
|
|
9
|
+
import type { RequestMetadata } from "../types";
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when input validation fails.
|
|
12
|
+
*
|
|
13
|
+
* This includes:
|
|
14
|
+
* - Missing required parameters
|
|
15
|
+
* - Invalid parameter values
|
|
16
|
+
* - Type mismatches
|
|
17
|
+
* - Business rule violations
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { ValidationError } from '@djust-b2b/djust-front-sdk';
|
|
22
|
+
*
|
|
23
|
+
* // The SDK throws this automatically
|
|
24
|
+
* await sdk.getCart({ currency: 'EUR' }); // Missing cartId
|
|
25
|
+
* // Throws: ValidationError: Required parameter 'cartId' is missing
|
|
26
|
+
*
|
|
27
|
+
* // Or create manually
|
|
28
|
+
* throw ValidationError.invalidParameter('email', 'must be a valid email address');
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class ValidationError extends SDKError {
|
|
32
|
+
constructor(message: string, details?: Record<string, unknown>, metadata?: RequestMetadata);
|
|
33
|
+
/**
|
|
34
|
+
* Creates a ValidationError for a missing required parameter.
|
|
35
|
+
*
|
|
36
|
+
* @param param - Name of the missing parameter
|
|
37
|
+
* @param metadata - Optional request metadata
|
|
38
|
+
*/
|
|
39
|
+
static missingParameter(param: string, metadata?: RequestMetadata): ValidationError;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a ValidationError for an invalid parameter value.
|
|
42
|
+
*
|
|
43
|
+
* @param param - Name of the invalid parameter
|
|
44
|
+
* @param reason - Why the value is invalid
|
|
45
|
+
* @param metadata - Optional request metadata
|
|
46
|
+
*/
|
|
47
|
+
static invalidParameter(param: string, reason: string, metadata?: RequestMetadata): ValidationError;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a ValidationError for a type mismatch.
|
|
50
|
+
*
|
|
51
|
+
* @param param - Name of the parameter
|
|
52
|
+
* @param expected - Expected type
|
|
53
|
+
* @param actual - Actual type received
|
|
54
|
+
* @param metadata - Optional request metadata
|
|
55
|
+
*/
|
|
56
|
+
static typeMismatch(param: string, expected: string, actual: string, metadata?: RequestMetadata): ValidationError;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a ValidationError from API validation response.
|
|
59
|
+
*
|
|
60
|
+
* @param errors - Array of validation errors from API
|
|
61
|
+
* @param metadata - Optional request metadata
|
|
62
|
+
*/
|
|
63
|
+
static fromApiResponse(errors: Array<{
|
|
64
|
+
field?: string;
|
|
65
|
+
message?: string;
|
|
66
|
+
}>, metadata?: RequestMetadata): ValidationError;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=validation.error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.error.d.ts","sourceRoot":"","sources":["../../../src/errors/classes/validation.error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;gBAEzC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,QAAQ,CAAC,EAAE,eAAe;IAa5B;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CACrB,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,eAAe,GACzB,eAAe;IAWlB;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,eAAe,GACzB,eAAe;IAYlB;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,eAAe,GACzB,eAAe;IAalB;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CACpB,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EACnD,QAAQ,CAAC,EAAE,eAAe,GACzB,eAAe;CAYnB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DJUST SDK Validation Error
|
|
4
|
+
* Errors related to invalid input parameters.
|
|
5
|
+
*
|
|
6
|
+
* @module errors/classes/validation
|
|
7
|
+
* @since 2.17.0
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ValidationError = void 0;
|
|
11
|
+
const base_1 = require("../base");
|
|
12
|
+
const codes_1 = require("../codes");
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when input validation fails.
|
|
15
|
+
*
|
|
16
|
+
* This includes:
|
|
17
|
+
* - Missing required parameters
|
|
18
|
+
* - Invalid parameter values
|
|
19
|
+
* - Type mismatches
|
|
20
|
+
* - Business rule violations
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { ValidationError } from '@djust-b2b/djust-front-sdk';
|
|
25
|
+
*
|
|
26
|
+
* // The SDK throws this automatically
|
|
27
|
+
* await sdk.getCart({ currency: 'EUR' }); // Missing cartId
|
|
28
|
+
* // Throws: ValidationError: Required parameter 'cartId' is missing
|
|
29
|
+
*
|
|
30
|
+
* // Or create manually
|
|
31
|
+
* throw ValidationError.invalidParameter('email', 'must be a valid email address');
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
class ValidationError extends base_1.SDKError {
|
|
35
|
+
constructor(message, details, metadata) {
|
|
36
|
+
super({
|
|
37
|
+
code: codes_1.SDKErrorCode.VALIDATION_ERROR,
|
|
38
|
+
message,
|
|
39
|
+
httpStatus: 400,
|
|
40
|
+
details,
|
|
41
|
+
retriable: false, // Validation errors are never retriable
|
|
42
|
+
metadata,
|
|
43
|
+
});
|
|
44
|
+
this.name = "ValidationError";
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a ValidationError for a missing required parameter.
|
|
48
|
+
*
|
|
49
|
+
* @param param - Name of the missing parameter
|
|
50
|
+
* @param metadata - Optional request metadata
|
|
51
|
+
*/
|
|
52
|
+
static missingParameter(param, metadata) {
|
|
53
|
+
return new ValidationError(`Required parameter '${param}' is missing`, {
|
|
54
|
+
parameter: param,
|
|
55
|
+
code: codes_1.SDKErrorCode.MISSING_PARAMETER,
|
|
56
|
+
}, metadata);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates a ValidationError for an invalid parameter value.
|
|
60
|
+
*
|
|
61
|
+
* @param param - Name of the invalid parameter
|
|
62
|
+
* @param reason - Why the value is invalid
|
|
63
|
+
* @param metadata - Optional request metadata
|
|
64
|
+
*/
|
|
65
|
+
static invalidParameter(param, reason, metadata) {
|
|
66
|
+
return new ValidationError(`Invalid parameter '${param}': ${reason}`, {
|
|
67
|
+
parameter: param,
|
|
68
|
+
reason,
|
|
69
|
+
code: codes_1.SDKErrorCode.INVALID_PARAMETER,
|
|
70
|
+
}, metadata);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a ValidationError for a type mismatch.
|
|
74
|
+
*
|
|
75
|
+
* @param param - Name of the parameter
|
|
76
|
+
* @param expected - Expected type
|
|
77
|
+
* @param actual - Actual type received
|
|
78
|
+
* @param metadata - Optional request metadata
|
|
79
|
+
*/
|
|
80
|
+
static typeMismatch(param, expected, actual, metadata) {
|
|
81
|
+
return new ValidationError(`Parameter '${param}' must be ${expected}, got ${actual}`, {
|
|
82
|
+
parameter: param,
|
|
83
|
+
expected,
|
|
84
|
+
actual,
|
|
85
|
+
code: codes_1.SDKErrorCode.INVALID_PARAMETER,
|
|
86
|
+
}, metadata);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Creates a ValidationError from API validation response.
|
|
90
|
+
*
|
|
91
|
+
* @param errors - Array of validation errors from API
|
|
92
|
+
* @param metadata - Optional request metadata
|
|
93
|
+
*/
|
|
94
|
+
static fromApiResponse(errors, metadata) {
|
|
95
|
+
const messages = errors
|
|
96
|
+
.map((e) => (e.field ? `${e.field}: ${e.message}` : e.message))
|
|
97
|
+
.filter(Boolean)
|
|
98
|
+
.join("; ");
|
|
99
|
+
return new ValidationError(messages || "Validation failed", { validationErrors: errors }, metadata);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.ValidationError = ValidationError;
|
|
103
|
+
//# sourceMappingURL=validation.error.js.map
|