@quickshops/sdk 1.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/FUNCTIONS.md +88 -0
- package/README.md +486 -0
- package/RUNTIMES.md +48 -0
- package/esm/core.d.ts +10 -0
- package/esm/core.d.ts.map +1 -0
- package/esm/core.js +13 -0
- package/esm/core.js.map +1 -0
- package/esm/funcs/cart-cart-add-line.d.ts +15 -0
- package/esm/funcs/cart-cart-add-line.d.ts.map +1 -0
- package/esm/funcs/cart-cart-add-line.js +87 -0
- package/esm/funcs/cart-cart-add-line.js.map +1 -0
- package/esm/funcs/cart-cart-clear.d.ts +15 -0
- package/esm/funcs/cart-cart-clear.d.ts.map +1 -0
- package/esm/funcs/cart-cart-clear.js +86 -0
- package/esm/funcs/cart-cart-clear.js.map +1 -0
- package/esm/funcs/cart-cart-create.d.ts +15 -0
- package/esm/funcs/cart-cart-create.d.ts.map +1 -0
- package/esm/funcs/cart-cart-create.js +70 -0
- package/esm/funcs/cart-cart-create.js.map +1 -0
- package/esm/funcs/cart-cart-get.d.ts +15 -0
- package/esm/funcs/cart-cart-get.d.ts.map +1 -0
- package/esm/funcs/cart-cart-get.js +86 -0
- package/esm/funcs/cart-cart-get.js.map +1 -0
- package/esm/funcs/cart-cart-remove-line.d.ts +15 -0
- package/esm/funcs/cart-cart-remove-line.d.ts.map +1 -0
- package/esm/funcs/cart-cart-remove-line.js +90 -0
- package/esm/funcs/cart-cart-remove-line.js.map +1 -0
- package/esm/funcs/cart-cart-update-line.d.ts +15 -0
- package/esm/funcs/cart-cart-update-line.d.ts.map +1 -0
- package/esm/funcs/cart-cart-update-line.js +91 -0
- package/esm/funcs/cart-cart-update-line.js.map +1 -0
- package/esm/funcs/checkout-checkout-create-session.d.ts +15 -0
- package/esm/funcs/checkout-checkout-create-session.d.ts.map +1 -0
- package/esm/funcs/checkout-checkout-create-session.js +81 -0
- package/esm/funcs/checkout-checkout-create-session.js.map +1 -0
- package/esm/funcs/health-health-check.d.ts +15 -0
- package/esm/funcs/health-health-check.d.ts.map +1 -0
- package/esm/funcs/health-health-check.js +70 -0
- package/esm/funcs/health-health-check.js.map +1 -0
- package/esm/funcs/products-products-get-all.d.ts +15 -0
- package/esm/funcs/products-products-get-all.d.ts.map +1 -0
- package/esm/funcs/products-products-get-all.js +70 -0
- package/esm/funcs/products-products-get-all.js.map +1 -0
- package/esm/funcs/products-products-get-by-id.d.ts +15 -0
- package/esm/funcs/products-products-get-by-id.d.ts.map +1 -0
- package/esm/funcs/products-products-get-by-id.js +86 -0
- package/esm/funcs/products-products-get-by-id.js.map +1 -0
- package/esm/funcs/store-store-get.d.ts +15 -0
- package/esm/funcs/store-store-get.d.ts.map +1 -0
- package/esm/funcs/store-store-get.js +70 -0
- package/esm/funcs/store-store-get.js.map +1 -0
- package/esm/funcs/subscription-subscription-create-portal-session.d.ts +15 -0
- package/esm/funcs/subscription-subscription-create-portal-session.d.ts.map +1 -0
- package/esm/funcs/subscription-subscription-create-portal-session.js +81 -0
- package/esm/funcs/subscription-subscription-create-portal-session.js.map +1 -0
- package/esm/hooks/hooks.d.ts +25 -0
- package/esm/hooks/hooks.d.ts.map +1 -0
- package/esm/hooks/hooks.js +80 -0
- package/esm/hooks/hooks.js.map +1 -0
- package/esm/hooks/index.d.ts +3 -0
- package/esm/hooks/index.d.ts.map +1 -0
- package/esm/hooks/index.js +6 -0
- package/esm/hooks/index.js.map +1 -0
- package/esm/hooks/types.d.ts +77 -0
- package/esm/hooks/types.d.ts.map +1 -0
- package/esm/hooks/types.js +5 -0
- package/esm/hooks/types.js.map +1 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +8 -0
- package/esm/index.js.map +1 -0
- package/esm/lib/base64.d.ts +10 -0
- package/esm/lib/base64.d.ts.map +1 -0
- package/esm/lib/base64.js +31 -0
- package/esm/lib/base64.js.map +1 -0
- package/esm/lib/config.d.ts +30 -0
- package/esm/lib/config.d.ts.map +1 -0
- package/esm/lib/config.js +21 -0
- package/esm/lib/config.js.map +1 -0
- package/esm/lib/encodings.d.ts +54 -0
- package/esm/lib/encodings.d.ts.map +1 -0
- package/esm/lib/encodings.js +391 -0
- package/esm/lib/encodings.js.map +1 -0
- package/esm/lib/env.d.ts +15 -0
- package/esm/lib/env.d.ts.map +1 -0
- package/esm/lib/env.js +44 -0
- package/esm/lib/env.js.map +1 -0
- package/esm/lib/files.d.ts +26 -0
- package/esm/lib/files.d.ts.map +1 -0
- package/esm/lib/files.js +91 -0
- package/esm/lib/files.js.map +1 -0
- package/esm/lib/http.d.ts +67 -0
- package/esm/lib/http.d.ts.map +1 -0
- package/esm/lib/http.js +209 -0
- package/esm/lib/http.js.map +1 -0
- package/esm/lib/logger.d.ts +6 -0
- package/esm/lib/logger.d.ts.map +1 -0
- package/esm/lib/logger.js +5 -0
- package/esm/lib/logger.js.map +1 -0
- package/esm/lib/matchers.d.ts +59 -0
- package/esm/lib/matchers.d.ts.map +1 -0
- package/esm/lib/matchers.js +202 -0
- package/esm/lib/matchers.js.map +1 -0
- package/esm/lib/primitives.d.ts +27 -0
- package/esm/lib/primitives.d.ts.map +1 -0
- package/esm/lib/primitives.js +120 -0
- package/esm/lib/primitives.js.map +1 -0
- package/esm/lib/retries.d.ts +38 -0
- package/esm/lib/retries.d.ts.map +1 -0
- package/esm/lib/retries.js +150 -0
- package/esm/lib/retries.js.map +1 -0
- package/esm/lib/schemas.d.ts +21 -0
- package/esm/lib/schemas.d.ts.map +1 -0
- package/esm/lib/schemas.js +57 -0
- package/esm/lib/schemas.js.map +1 -0
- package/esm/lib/sdks.d.ts +63 -0
- package/esm/lib/sdks.d.ts.map +1 -0
- package/esm/lib/sdks.js +294 -0
- package/esm/lib/sdks.js.map +1 -0
- package/esm/lib/security.d.ts +83 -0
- package/esm/lib/security.d.ts.map +1 -0
- package/esm/lib/security.js +149 -0
- package/esm/lib/security.js.map +1 -0
- package/esm/lib/url.d.ts +5 -0
- package/esm/lib/url.d.ts.map +1 -0
- package/esm/lib/url.js +24 -0
- package/esm/lib/url.js.map +1 -0
- package/esm/models/errors/cart-add-line.d.ts +141 -0
- package/esm/models/errors/cart-add-line.d.ts.map +1 -0
- package/esm/models/errors/cart-add-line.js +205 -0
- package/esm/models/errors/cart-add-line.js.map +1 -0
- package/esm/models/errors/cart-clear.d.ts +118 -0
- package/esm/models/errors/cart-clear.d.ts.map +1 -0
- package/esm/models/errors/cart-clear.js +172 -0
- package/esm/models/errors/cart-clear.js.map +1 -0
- package/esm/models/errors/cart-create.d.ts +118 -0
- package/esm/models/errors/cart-create.d.ts.map +1 -0
- package/esm/models/errors/cart-create.js +172 -0
- package/esm/models/errors/cart-create.js.map +1 -0
- package/esm/models/errors/cart-get.d.ts +95 -0
- package/esm/models/errors/cart-get.d.ts.map +1 -0
- package/esm/models/errors/cart-get.js +139 -0
- package/esm/models/errors/cart-get.js.map +1 -0
- package/esm/models/errors/cart-remove-line.d.ts +141 -0
- package/esm/models/errors/cart-remove-line.d.ts.map +1 -0
- package/esm/models/errors/cart-remove-line.js +205 -0
- package/esm/models/errors/cart-remove-line.js.map +1 -0
- package/esm/models/errors/cart-update-line.d.ts +141 -0
- package/esm/models/errors/cart-update-line.d.ts.map +1 -0
- package/esm/models/errors/cart-update-line.js +205 -0
- package/esm/models/errors/cart-update-line.js.map +1 -0
- package/esm/models/errors/checkout-create-session.d.ts +118 -0
- package/esm/models/errors/checkout-create-session.d.ts.map +1 -0
- package/esm/models/errors/checkout-create-session.js +172 -0
- package/esm/models/errors/checkout-create-session.js.map +1 -0
- package/esm/models/errors/health-check.d.ts +72 -0
- package/esm/models/errors/health-check.d.ts.map +1 -0
- package/esm/models/errors/health-check.js +106 -0
- package/esm/models/errors/health-check.js.map +1 -0
- package/esm/models/errors/http-client-errors.d.ts +44 -0
- package/esm/models/errors/http-client-errors.d.ts.map +1 -0
- package/esm/models/errors/http-client-errors.js +56 -0
- package/esm/models/errors/http-client-errors.js.map +1 -0
- package/esm/models/errors/index.d.ts +18 -0
- package/esm/models/errors/index.d.ts.map +1 -0
- package/esm/models/errors/index.js +21 -0
- package/esm/models/errors/index.js.map +1 -0
- package/esm/models/errors/products-get-all.d.ts +72 -0
- package/esm/models/errors/products-get-all.d.ts.map +1 -0
- package/esm/models/errors/products-get-all.js +106 -0
- package/esm/models/errors/products-get-all.js.map +1 -0
- package/esm/models/errors/products-get-by-id.d.ts +95 -0
- package/esm/models/errors/products-get-by-id.d.ts.map +1 -0
- package/esm/models/errors/products-get-by-id.js +139 -0
- package/esm/models/errors/products-get-by-id.js.map +1 -0
- package/esm/models/errors/quickshops-default-error.d.ts +10 -0
- package/esm/models/errors/quickshops-default-error.d.ts.map +1 -0
- package/esm/models/errors/quickshops-default-error.js +30 -0
- package/esm/models/errors/quickshops-default-error.js.map +1 -0
- package/esm/models/errors/quickshops-error.d.ts +19 -0
- package/esm/models/errors/quickshops-error.d.ts.map +1 -0
- package/esm/models/errors/quickshops-error.js +26 -0
- package/esm/models/errors/quickshops-error.js.map +1 -0
- package/esm/models/errors/response-validation-error.d.ts +26 -0
- package/esm/models/errors/response-validation-error.d.ts.map +1 -0
- package/esm/models/errors/response-validation-error.js +37 -0
- package/esm/models/errors/response-validation-error.js.map +1 -0
- package/esm/models/errors/sdk-validation-error.d.ts +21 -0
- package/esm/models/errors/sdk-validation-error.d.ts.map +1 -0
- package/esm/models/errors/sdk-validation-error.js +52 -0
- package/esm/models/errors/sdk-validation-error.js.map +1 -0
- package/esm/models/errors/store-get.d.ts +95 -0
- package/esm/models/errors/store-get.d.ts.map +1 -0
- package/esm/models/errors/store-get.js +139 -0
- package/esm/models/errors/store-get.js.map +1 -0
- package/esm/models/errors/subscription-create-portal-session.d.ts +118 -0
- package/esm/models/errors/subscription-create-portal-session.d.ts.map +1 -0
- package/esm/models/errors/subscription-create-portal-session.js +175 -0
- package/esm/models/errors/subscription-create-portal-session.js.map +1 -0
- package/esm/models/index.d.ts +2 -0
- package/esm/models/index.d.ts.map +1 -0
- package/esm/models/index.js +5 -0
- package/esm/models/index.js.map +1 -0
- package/esm/models/operations/cart-add-line.d.ts +61 -0
- package/esm/models/operations/cart-add-line.d.ts.map +1 -0
- package/esm/models/operations/cart-add-line.js +57 -0
- package/esm/models/operations/cart-add-line.js.map +1 -0
- package/esm/models/operations/cart-clear.d.ts +47 -0
- package/esm/models/operations/cart-clear.d.ts.map +1 -0
- package/esm/models/operations/cart-clear.js +48 -0
- package/esm/models/operations/cart-clear.js.map +1 -0
- package/esm/models/operations/cart-create.d.ts +37 -0
- package/esm/models/operations/cart-create.d.ts.map +1 -0
- package/esm/models/operations/cart-create.js +41 -0
- package/esm/models/operations/cart-create.js.map +1 -0
- package/esm/models/operations/cart-get.d.ts +47 -0
- package/esm/models/operations/cart-get.d.ts.map +1 -0
- package/esm/models/operations/cart-get.js +50 -0
- package/esm/models/operations/cart-get.js.map +1 -0
- package/esm/models/operations/cart-remove-line.d.ts +49 -0
- package/esm/models/operations/cart-remove-line.d.ts.map +1 -0
- package/esm/models/operations/cart-remove-line.js +49 -0
- package/esm/models/operations/cart-remove-line.js.map +1 -0
- package/esm/models/operations/cart-update-line.d.ts +61 -0
- package/esm/models/operations/cart-update-line.d.ts.map +1 -0
- package/esm/models/operations/cart-update-line.js +57 -0
- package/esm/models/operations/cart-update-line.js.map +1 -0
- package/esm/models/operations/checkout-create-session.d.ts +29 -0
- package/esm/models/operations/checkout-create-session.d.ts.map +1 -0
- package/esm/models/operations/checkout-create-session.js +28 -0
- package/esm/models/operations/checkout-create-session.js.map +1 -0
- package/esm/models/operations/health-check.d.ts +13 -0
- package/esm/models/operations/health-check.d.ts.map +1 -0
- package/esm/models/operations/health-check.js +14 -0
- package/esm/models/operations/health-check.js.map +1 -0
- package/esm/models/operations/index.d.ts +13 -0
- package/esm/models/operations/index.d.ts.map +1 -0
- package/esm/models/operations/index.js +16 -0
- package/esm/models/operations/index.js.map +1 -0
- package/esm/models/operations/products-get-all.d.ts +45 -0
- package/esm/models/operations/products-get-all.d.ts.map +1 -0
- package/esm/models/operations/products-get-all.js +50 -0
- package/esm/models/operations/products-get-all.js.map +1 -0
- package/esm/models/operations/products-get-by-id.d.ts +55 -0
- package/esm/models/operations/products-get-by-id.d.ts.map +1 -0
- package/esm/models/operations/products-get-by-id.js +57 -0
- package/esm/models/operations/products-get-by-id.js.map +1 -0
- package/esm/models/operations/store-get.d.ts +31 -0
- package/esm/models/operations/store-get.d.ts.map +1 -0
- package/esm/models/operations/store-get.js +39 -0
- package/esm/models/operations/store-get.js.map +1 -0
- package/esm/models/operations/subscription-create-portal-session.d.ts +29 -0
- package/esm/models/operations/subscription-create-portal-session.d.ts.map +1 -0
- package/esm/models/operations/subscription-create-portal-session.js +28 -0
- package/esm/models/operations/subscription-create-portal-session.js.map +1 -0
- package/esm/models/security.d.ts +12 -0
- package/esm/models/security.d.ts.map +1 -0
- package/esm/models/security.js +17 -0
- package/esm/models/security.js.map +1 -0
- package/esm/sdk/cart.d.ts +29 -0
- package/esm/sdk/cart.d.ts.map +1 -0
- package/esm/sdk/cart.js +50 -0
- package/esm/sdk/cart.js.map +1 -0
- package/esm/sdk/checkout.d.ts +9 -0
- package/esm/sdk/checkout.d.ts.map +1 -0
- package/esm/sdk/checkout.js +15 -0
- package/esm/sdk/checkout.js.map +1 -0
- package/esm/sdk/health.d.ts +9 -0
- package/esm/sdk/health.d.ts.map +1 -0
- package/esm/sdk/health.js +15 -0
- package/esm/sdk/health.js.map +1 -0
- package/esm/sdk/index.d.ts +2 -0
- package/esm/sdk/index.d.ts.map +1 -0
- package/esm/sdk/index.js +5 -0
- package/esm/sdk/index.js.map +1 -0
- package/esm/sdk/products.d.ts +13 -0
- package/esm/sdk/products.d.ts.map +1 -0
- package/esm/sdk/products.js +22 -0
- package/esm/sdk/products.js.map +1 -0
- package/esm/sdk/sdk.d.ts +22 -0
- package/esm/sdk/sdk.d.ts.map +1 -0
- package/esm/sdk/sdk.js +37 -0
- package/esm/sdk/sdk.js.map +1 -0
- package/esm/sdk/store.d.ts +9 -0
- package/esm/sdk/store.d.ts.map +1 -0
- package/esm/sdk/store.js +15 -0
- package/esm/sdk/store.js.map +1 -0
- package/esm/sdk/subscription.d.ts +9 -0
- package/esm/sdk/subscription.d.ts.map +1 -0
- package/esm/sdk/subscription.js +15 -0
- package/esm/sdk/subscription.js.map +1 -0
- package/esm/types/async.d.ts +23 -0
- package/esm/types/async.d.ts.map +1 -0
- package/esm/types/async.js +28 -0
- package/esm/types/async.js.map +1 -0
- package/esm/types/blobs.d.ts +4 -0
- package/esm/types/blobs.d.ts.map +1 -0
- package/esm/types/blobs.js +25 -0
- package/esm/types/blobs.js.map +1 -0
- package/esm/types/const-date-time.d.ts +3 -0
- package/esm/types/const-date-time.d.ts.map +1 -0
- package/esm/types/const-date-time.js +10 -0
- package/esm/types/const-date-time.js.map +1 -0
- package/esm/types/default-to-zero-value.d.ts +12 -0
- package/esm/types/default-to-zero-value.d.ts.map +1 -0
- package/esm/types/default-to-zero-value.js +31 -0
- package/esm/types/default-to-zero-value.js.map +1 -0
- package/esm/types/enums.d.ts +9 -0
- package/esm/types/enums.d.ts.map +1 -0
- package/esm/types/enums.js +27 -0
- package/esm/types/enums.js.map +1 -0
- package/esm/types/fp.d.ts +31 -0
- package/esm/types/fp.d.ts.map +1 -0
- package/esm/types/fp.js +31 -0
- package/esm/types/fp.js.map +1 -0
- package/esm/types/index.d.ts +10 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/index.js +10 -0
- package/esm/types/index.js.map +1 -0
- package/esm/types/operations.d.ts +27 -0
- package/esm/types/operations.d.ts.map +1 -0
- package/esm/types/operations.js +77 -0
- package/esm/types/operations.js.map +1 -0
- package/esm/types/primitives.d.ts +9 -0
- package/esm/types/primitives.d.ts.map +1 -0
- package/esm/types/primitives.js +109 -0
- package/esm/types/primitives.js.map +1 -0
- package/esm/types/rfcdate.d.ts +21 -0
- package/esm/types/rfcdate.d.ts.map +1 -0
- package/esm/types/rfcdate.js +43 -0
- package/esm/types/rfcdate.js.map +1 -0
- package/esm/types/smart-union.d.ts +7 -0
- package/esm/types/smart-union.d.ts.map +1 -0
- package/esm/types/smart-union.js +117 -0
- package/esm/types/smart-union.js.map +1 -0
- package/esm/types/streams.d.ts +2 -0
- package/esm/types/streams.d.ts.map +1 -0
- package/esm/types/streams.js +15 -0
- package/esm/types/streams.js.map +1 -0
- package/esm/types/unrecognized.d.ts +16 -0
- package/esm/types/unrecognized.d.ts.map +1 -0
- package/esm/types/unrecognized.js +31 -0
- package/esm/types/unrecognized.js.map +1 -0
- package/examples/healthHealthCheck.example.ts +27 -0
- package/examples/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/examples/node_modules/@types/node/assert.d.ts +1062 -0
- package/examples/node_modules/@types/node/async_hooks.d.ts +605 -0
- package/examples/node_modules/@types/node/buffer.buffer.d.ts +471 -0
- package/examples/node_modules/@types/node/buffer.d.ts +1936 -0
- package/examples/node_modules/@types/node/child_process.d.ts +1475 -0
- package/examples/node_modules/@types/node/cluster.d.ts +577 -0
- package/examples/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/examples/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/examples/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/examples/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/examples/node_modules/@types/node/console.d.ts +452 -0
- package/examples/node_modules/@types/node/constants.d.ts +21 -0
- package/examples/node_modules/@types/node/crypto.d.ts +4590 -0
- package/examples/node_modules/@types/node/dgram.d.ts +597 -0
- package/examples/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
- package/examples/node_modules/@types/node/dns/promises.d.ts +479 -0
- package/examples/node_modules/@types/node/dns.d.ts +871 -0
- package/examples/node_modules/@types/node/domain.d.ts +170 -0
- package/examples/node_modules/@types/node/events.d.ts +977 -0
- package/examples/node_modules/@types/node/fs/promises.d.ts +1270 -0
- package/examples/node_modules/@types/node/fs.d.ts +4375 -0
- package/examples/node_modules/@types/node/globals.d.ts +172 -0
- package/examples/node_modules/@types/node/globals.typedarray.d.ts +38 -0
- package/examples/node_modules/@types/node/http.d.ts +2049 -0
- package/examples/node_modules/@types/node/http2.d.ts +2712 -0
- package/examples/node_modules/@types/node/https.d.ts +578 -0
- package/examples/node_modules/@types/node/index.d.ts +93 -0
- package/examples/node_modules/@types/node/inspector.generated.d.ts +3966 -0
- package/examples/node_modules/@types/node/module.d.ts +539 -0
- package/examples/node_modules/@types/node/net.d.ts +1031 -0
- package/examples/node_modules/@types/node/os.d.ts +506 -0
- package/examples/node_modules/@types/node/path.d.ts +200 -0
- package/examples/node_modules/@types/node/perf_hooks.d.ts +961 -0
- package/examples/node_modules/@types/node/process.d.ts +1961 -0
- package/examples/node_modules/@types/node/punycode.d.ts +117 -0
- package/examples/node_modules/@types/node/querystring.d.ts +152 -0
- package/examples/node_modules/@types/node/readline/promises.d.ts +162 -0
- package/examples/node_modules/@types/node/readline.d.ts +589 -0
- package/examples/node_modules/@types/node/repl.d.ts +430 -0
- package/examples/node_modules/@types/node/sea.d.ts +153 -0
- package/examples/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/examples/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/examples/node_modules/@types/node/stream/web.d.ts +533 -0
- package/examples/node_modules/@types/node/stream.d.ts +1698 -0
- package/examples/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/examples/node_modules/@types/node/test.d.ts +1787 -0
- package/examples/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/examples/node_modules/@types/node/timers.d.ts +286 -0
- package/examples/node_modules/@types/node/tls.d.ts +1259 -0
- package/examples/node_modules/@types/node/trace_events.d.ts +197 -0
- package/examples/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
- package/examples/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
- package/examples/node_modules/@types/node/ts5.6/index.d.ts +93 -0
- package/examples/node_modules/@types/node/tty.d.ts +208 -0
- package/examples/node_modules/@types/node/url.d.ts +964 -0
- package/examples/node_modules/@types/node/util.d.ts +2331 -0
- package/examples/node_modules/@types/node/v8.d.ts +809 -0
- package/examples/node_modules/@types/node/vm.d.ts +1001 -0
- package/examples/node_modules/@types/node/wasi.d.ts +181 -0
- package/examples/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
- package/examples/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/examples/node_modules/@types/node/web-globals/events.d.ts +97 -0
- package/examples/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
- package/examples/node_modules/@types/node/worker_threads.d.ts +715 -0
- package/examples/node_modules/@types/node/zlib.d.ts +598 -0
- package/examples/node_modules/dotenv/config.d.ts +1 -0
- package/examples/node_modules/dotenv/config.js +9 -0
- package/examples/node_modules/dotenv/lib/cli-options.js +17 -0
- package/examples/node_modules/dotenv/lib/env-options.js +28 -0
- package/examples/node_modules/dotenv/lib/main.d.ts +162 -0
- package/examples/node_modules/dotenv/lib/main.js +386 -0
- package/examples/node_modules/esbuild/install.js +300 -0
- package/examples/node_modules/esbuild/lib/main.d.ts +716 -0
- package/examples/node_modules/esbuild/lib/main.js +2532 -0
- package/examples/node_modules/fsevents/fsevents.d.ts +46 -0
- package/examples/node_modules/fsevents/fsevents.js +83 -0
- package/examples/node_modules/tsx/dist/cjs/api/index.mjs +1 -0
- package/examples/node_modules/tsx/dist/cjs/index.mjs +1 -0
- package/examples/node_modules/tsx/dist/cli.mjs +55 -0
- package/examples/node_modules/tsx/dist/client-D_mPDF5S.mjs +1 -0
- package/examples/node_modules/tsx/dist/esm/api/index.mjs +1 -0
- package/examples/node_modules/tsx/dist/esm/index.mjs +1 -0
- package/examples/node_modules/tsx/dist/get-pipe-path-_tAJyU_v.mjs +1 -0
- package/examples/node_modules/tsx/dist/index-XurvG3JN.mjs +14 -0
- package/examples/node_modules/tsx/dist/index-gbaejti9.mjs +1 -0
- package/examples/node_modules/tsx/dist/lexer-DQCqS3nf.mjs +3 -0
- package/examples/node_modules/tsx/dist/loader.mjs +1 -0
- package/examples/node_modules/tsx/dist/node-features-B9BBLzwu.mjs +1 -0
- package/examples/node_modules/tsx/dist/package-Bj47PlGH.mjs +1 -0
- package/examples/node_modules/tsx/dist/patch-repl.mjs +1 -0
- package/examples/node_modules/tsx/dist/preflight.mjs +1 -0
- package/examples/node_modules/tsx/dist/register-BnTWPeIB.mjs +10 -0
- package/examples/node_modules/tsx/dist/register-CqMfTiWi.mjs +2 -0
- package/examples/node_modules/tsx/dist/repl.mjs +3 -0
- package/examples/node_modules/tsx/dist/require-DzmC1hVr.mjs +1 -0
- package/examples/node_modules/tsx/dist/suppress-warnings.mjs +1 -0
- package/examples/node_modules/tsx/dist/temporary-directory-BDDVQOvU.mjs +1 -0
- package/examples/node_modules/tsx/dist/types-Cxp8y2TL.d.ts +5 -0
- package/examples/node_modules/undici-types/agent.d.ts +31 -0
- package/examples/node_modules/undici-types/api.d.ts +43 -0
- package/examples/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/examples/node_modules/undici-types/cache.d.ts +36 -0
- package/examples/node_modules/undici-types/client.d.ts +108 -0
- package/examples/node_modules/undici-types/connector.d.ts +34 -0
- package/examples/node_modules/undici-types/content-type.d.ts +21 -0
- package/examples/node_modules/undici-types/cookies.d.ts +28 -0
- package/examples/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/examples/node_modules/undici-types/dispatcher.d.ts +256 -0
- package/examples/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/examples/node_modules/undici-types/errors.d.ts +149 -0
- package/examples/node_modules/undici-types/eventsource.d.ts +61 -0
- package/examples/node_modules/undici-types/fetch.d.ts +209 -0
- package/examples/node_modules/undici-types/file.d.ts +39 -0
- package/examples/node_modules/undici-types/filereader.d.ts +54 -0
- package/examples/node_modules/undici-types/formdata.d.ts +108 -0
- package/examples/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/examples/node_modules/undici-types/global-origin.d.ts +7 -0
- package/examples/node_modules/undici-types/handlers.d.ts +15 -0
- package/examples/node_modules/undici-types/header.d.ts +4 -0
- package/examples/node_modules/undici-types/index.d.ts +71 -0
- package/examples/node_modules/undici-types/interceptors.d.ts +17 -0
- package/examples/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/examples/node_modules/undici-types/mock-client.d.ts +25 -0
- package/examples/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/examples/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/examples/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/examples/node_modules/undici-types/patch.d.ts +33 -0
- package/examples/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/examples/node_modules/undici-types/pool.d.ts +39 -0
- package/examples/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/examples/node_modules/undici-types/readable.d.ts +65 -0
- package/examples/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/examples/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/examples/node_modules/undici-types/util.d.ts +18 -0
- package/examples/node_modules/undici-types/webidl.d.ts +228 -0
- package/examples/node_modules/undici-types/websocket.d.ts +150 -0
- package/jsr.json +27 -0
- package/package.json +63 -0
- package/src/core.ts +13 -0
- package/src/funcs/cart-cart-add-line.ts +195 -0
- package/src/funcs/cart-cart-clear.ts +190 -0
- package/src/funcs/cart-cart-create.ts +166 -0
- package/src/funcs/cart-cart-get.ts +186 -0
- package/src/funcs/cart-cart-remove-line.ts +198 -0
- package/src/funcs/cart-cart-update-line.ts +199 -0
- package/src/funcs/checkout-checkout-create-session.ts +189 -0
- package/src/funcs/health-health-check.ts +158 -0
- package/src/funcs/products-products-get-all.ts +158 -0
- package/src/funcs/products-products-get-by-id.ts +186 -0
- package/src/funcs/store-store-get.ts +162 -0
- package/src/funcs/subscription-subscription-create-portal-session.ts +207 -0
- package/src/hooks/hooks.ts +129 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/types.ts +108 -0
- package/src/index.ts +9 -0
- package/src/lib/base64.ts +39 -0
- package/src/lib/config.ts +49 -0
- package/src/lib/encodings.ts +529 -0
- package/src/lib/env.ts +61 -0
- package/src/lib/files.ts +104 -0
- package/src/lib/http.ts +323 -0
- package/src/lib/logger.ts +9 -0
- package/src/lib/matchers.ts +353 -0
- package/src/lib/primitives.ts +166 -0
- package/src/lib/retries.ts +218 -0
- package/src/lib/schemas.ts +94 -0
- package/src/lib/sdks.ts +442 -0
- package/src/lib/security.ts +275 -0
- package/src/lib/url.ts +35 -0
- package/src/models/errors/cart-add-line.ts +337 -0
- package/src/models/errors/cart-clear.ts +282 -0
- package/src/models/errors/cart-create.ts +282 -0
- package/src/models/errors/cart-get.ts +227 -0
- package/src/models/errors/cart-remove-line.ts +337 -0
- package/src/models/errors/cart-update-line.ts +337 -0
- package/src/models/errors/checkout-create-session.ts +278 -0
- package/src/models/errors/health-check.ts +172 -0
- package/src/models/errors/http-client-errors.ts +62 -0
- package/src/models/errors/index.ts +21 -0
- package/src/models/errors/products-get-all.ts +172 -0
- package/src/models/errors/products-get-by-id.ts +227 -0
- package/src/models/errors/quickshops-default-error.ts +40 -0
- package/src/models/errors/quickshops-error.ts +35 -0
- package/src/models/errors/response-validation-error.ts +50 -0
- package/src/models/errors/sdk-validation-error.ts +54 -0
- package/src/models/errors/store-get.ts +227 -0
- package/src/models/errors/subscription-create-portal-session.ts +286 -0
- package/src/models/index.ts +5 -0
- package/src/models/operations/cart-add-line.ts +168 -0
- package/src/models/operations/cart-clear.ts +137 -0
- package/src/models/operations/cart-create.ts +112 -0
- package/src/models/operations/cart-get.ts +129 -0
- package/src/models/operations/cart-remove-line.ts +140 -0
- package/src/models/operations/cart-update-line.ts +168 -0
- package/src/models/operations/checkout-create-session.ts +83 -0
- package/src/models/operations/health-check.ts +34 -0
- package/src/models/operations/index.ts +16 -0
- package/src/models/operations/products-get-all.ts +116 -0
- package/src/models/operations/products-get-by-id.ts +141 -0
- package/src/models/operations/store-get.ts +96 -0
- package/src/models/operations/subscription-create-portal-session.ts +90 -0
- package/src/models/security.ts +34 -0
- package/src/sdk/cart.ts +97 -0
- package/src/sdk/checkout.ts +24 -0
- package/src/sdk/health.ts +22 -0
- package/src/sdk/index.ts +5 -0
- package/src/sdk/products.ts +37 -0
- package/src/sdk/sdk.ts +43 -0
- package/src/sdk/store.ts +22 -0
- package/src/sdk/subscription.ts +24 -0
- package/src/types/async.ts +69 -0
- package/src/types/blobs.ts +33 -0
- package/src/types/const-date-time.ts +15 -0
- package/src/types/default-to-zero-value.ts +33 -0
- package/src/types/enums.ts +45 -0
- package/src/types/fp.ts +50 -0
- package/src/types/index.ts +13 -0
- package/src/types/operations.ts +105 -0
- package/src/types/primitives.ts +140 -0
- package/src/types/rfcdate.ts +54 -0
- package/src/types/smart-union.ts +153 -0
- package/src/types/streams.ts +21 -0
- package/src/types/unrecognized.ts +35 -0
package/src/lib/sdks.ts
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { SDKHooks } from "../hooks/hooks.js";
|
|
6
|
+
import { HookContext } from "../hooks/types.js";
|
|
7
|
+
import {
|
|
8
|
+
ConnectionError,
|
|
9
|
+
InvalidRequestError,
|
|
10
|
+
RequestAbortedError,
|
|
11
|
+
RequestTimeoutError,
|
|
12
|
+
UnexpectedClientError,
|
|
13
|
+
} from "../models/errors/http-client-errors.js";
|
|
14
|
+
import { ERR, OK, Result } from "../types/fp.js";
|
|
15
|
+
import { stringToBase64 } from "./base64.js";
|
|
16
|
+
import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "./config.js";
|
|
17
|
+
import { encodeForm } from "./encodings.js";
|
|
18
|
+
import { env } from "./env.js";
|
|
19
|
+
import {
|
|
20
|
+
HTTPClient,
|
|
21
|
+
isAbortError,
|
|
22
|
+
isConnectionError,
|
|
23
|
+
isTimeoutError,
|
|
24
|
+
matchContentType,
|
|
25
|
+
} from "./http.js";
|
|
26
|
+
import { Logger } from "./logger.js";
|
|
27
|
+
import { combineSignals } from "./primitives.js";
|
|
28
|
+
import { retry, RetryConfig } from "./retries.js";
|
|
29
|
+
import { SecurityState } from "./security.js";
|
|
30
|
+
|
|
31
|
+
export type RequestOptions = {
|
|
32
|
+
/**
|
|
33
|
+
* Sets a timeout, in milliseconds, on HTTP requests made by an SDK method. If
|
|
34
|
+
* `fetchOptions.signal` is set then it will take precedence over this option.
|
|
35
|
+
*/
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Set or override a retry policy on HTTP calls.
|
|
39
|
+
*/
|
|
40
|
+
retries?: RetryConfig;
|
|
41
|
+
/**
|
|
42
|
+
* Specifies the status codes which should be retried using the given retry policy.
|
|
43
|
+
*/
|
|
44
|
+
retryCodes?: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Overrides the base server URL that will be used by an operation.
|
|
47
|
+
*/
|
|
48
|
+
serverURL?: string | URL;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated `fetchOptions` has been flattened into `RequestOptions`.
|
|
51
|
+
*
|
|
52
|
+
* Sets various request options on the `fetch` call made by an SDK method.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request}
|
|
55
|
+
*/
|
|
56
|
+
fetchOptions?: Omit<RequestInit, "method" | "body">;
|
|
57
|
+
} & Omit<RequestInit, "method" | "body">;
|
|
58
|
+
|
|
59
|
+
type RequestConfig = {
|
|
60
|
+
method: string;
|
|
61
|
+
path: string;
|
|
62
|
+
baseURL?: string | URL | undefined;
|
|
63
|
+
query?: string;
|
|
64
|
+
body?: RequestInit["body"];
|
|
65
|
+
headers?: HeadersInit;
|
|
66
|
+
security?: SecurityState | null;
|
|
67
|
+
uaHeader?: string;
|
|
68
|
+
userAgent?: string | undefined;
|
|
69
|
+
timeoutMs?: number;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const gt: unknown = typeof globalThis === "undefined" ? null : globalThis;
|
|
73
|
+
const webWorkerLike = typeof gt === "object"
|
|
74
|
+
&& gt != null
|
|
75
|
+
&& "importScripts" in gt
|
|
76
|
+
&& typeof gt["importScripts"] === "function";
|
|
77
|
+
const isBrowserLike = webWorkerLike
|
|
78
|
+
|| (typeof navigator !== "undefined" && "serviceWorker" in navigator)
|
|
79
|
+
|| (typeof window === "object" && typeof window.document !== "undefined");
|
|
80
|
+
|
|
81
|
+
export class ClientSDK {
|
|
82
|
+
readonly #httpClient: HTTPClient;
|
|
83
|
+
readonly #hooks: SDKHooks;
|
|
84
|
+
readonly #logger?: Logger | undefined;
|
|
85
|
+
public readonly _baseURL: URL | null;
|
|
86
|
+
public readonly _options: SDKOptions & { hooks?: SDKHooks };
|
|
87
|
+
|
|
88
|
+
constructor(options: SDKOptions) {
|
|
89
|
+
const opt = options as unknown;
|
|
90
|
+
if (
|
|
91
|
+
typeof opt === "object"
|
|
92
|
+
&& opt != null
|
|
93
|
+
&& "hooks" in opt
|
|
94
|
+
&& opt.hooks instanceof SDKHooks
|
|
95
|
+
) {
|
|
96
|
+
this.#hooks = opt.hooks;
|
|
97
|
+
} else {
|
|
98
|
+
this.#hooks = new SDKHooks();
|
|
99
|
+
}
|
|
100
|
+
const defaultHttpClient = new HTTPClient();
|
|
101
|
+
options.httpClient = options.httpClient || defaultHttpClient;
|
|
102
|
+
options = this.#hooks.sdkInit(options);
|
|
103
|
+
|
|
104
|
+
const url = serverURLFromOptions(options);
|
|
105
|
+
if (url) {
|
|
106
|
+
url.pathname = url.pathname.replace(/\/+$/, "") + "/";
|
|
107
|
+
}
|
|
108
|
+
this._baseURL = url;
|
|
109
|
+
this.#httpClient = options.httpClient || defaultHttpClient;
|
|
110
|
+
|
|
111
|
+
this._options = { ...options, hooks: this.#hooks };
|
|
112
|
+
|
|
113
|
+
this.#logger = this._options.debugLogger;
|
|
114
|
+
if (!this.#logger && env().QUICKSHOPS_DEBUG) {
|
|
115
|
+
this.#logger = console;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public _createRequest(
|
|
120
|
+
context: HookContext,
|
|
121
|
+
conf: RequestConfig,
|
|
122
|
+
options?: RequestOptions,
|
|
123
|
+
): Result<Request, InvalidRequestError | UnexpectedClientError> {
|
|
124
|
+
const { method, path, query, headers: opHeaders, security } = conf;
|
|
125
|
+
|
|
126
|
+
const base = conf.baseURL ?? this._baseURL;
|
|
127
|
+
if (!base) {
|
|
128
|
+
return ERR(new InvalidRequestError("No base URL provided for operation"));
|
|
129
|
+
}
|
|
130
|
+
const baseURL = new URL(base);
|
|
131
|
+
let reqURL: URL;
|
|
132
|
+
if (path) {
|
|
133
|
+
baseURL.pathname = baseURL.pathname.replace(/\/+$/, "") + "/";
|
|
134
|
+
reqURL = new URL(path, baseURL);
|
|
135
|
+
if (!reqURL.search && baseURL.search) {
|
|
136
|
+
reqURL.search = baseURL.search;
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
reqURL = baseURL;
|
|
140
|
+
}
|
|
141
|
+
reqURL.hash = "";
|
|
142
|
+
|
|
143
|
+
// Appends already-encoded query pairs to a query string, replacing any
|
|
144
|
+
// existing pairs with the same key so later sources take precedence.
|
|
145
|
+
const mergeQuery = (current: string, additions: string): string => {
|
|
146
|
+
if (!additions) {
|
|
147
|
+
return current;
|
|
148
|
+
}
|
|
149
|
+
const additionKeys = new Set(
|
|
150
|
+
additions
|
|
151
|
+
.split("&")
|
|
152
|
+
.filter((pair) => pair !== "")
|
|
153
|
+
.map((pair) => pair.split("=")[0] ?? ""),
|
|
154
|
+
);
|
|
155
|
+
const kept = current.split("&").filter((pair) => {
|
|
156
|
+
return pair !== "" && !additionKeys.has(pair.split("=")[0] ?? "");
|
|
157
|
+
});
|
|
158
|
+
return [...kept, additions].join("&");
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const encodeQueryRecord = (record: Record<string, unknown>): string => {
|
|
162
|
+
return Object.entries(record)
|
|
163
|
+
.map(([k, v]) => {
|
|
164
|
+
if (v == null) {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
const value = v;
|
|
168
|
+
return encodeForm(k, value, {
|
|
169
|
+
explode: Array.isArray(value),
|
|
170
|
+
charEncoding: "percent",
|
|
171
|
+
});
|
|
172
|
+
})
|
|
173
|
+
.filter((pair): pair is string => typeof pair !== "undefined")
|
|
174
|
+
.join("&");
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const finalQuery = [
|
|
178
|
+
query || "",
|
|
179
|
+
encodeQueryRecord(security?.queryParams || {}),
|
|
180
|
+
].reduce(mergeQuery, reqURL.search.slice(1));
|
|
181
|
+
|
|
182
|
+
if (finalQuery) {
|
|
183
|
+
reqURL.search = `?${finalQuery}`;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const headers = new Headers(opHeaders);
|
|
187
|
+
|
|
188
|
+
const username = security?.basic.username;
|
|
189
|
+
const password = security?.basic.password;
|
|
190
|
+
if (username != null || password != null) {
|
|
191
|
+
const encoded = stringToBase64(
|
|
192
|
+
[username || "", password || ""].join(":"),
|
|
193
|
+
);
|
|
194
|
+
headers.set("Authorization", `Basic ${encoded}`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const securityHeaders = new Headers(security?.headers || {});
|
|
198
|
+
for (const [k, v] of securityHeaders) {
|
|
199
|
+
headers.set(k, v);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
let cookie = headers.get("cookie") || "";
|
|
203
|
+
for (const [k, v] of Object.entries(security?.cookies || {})) {
|
|
204
|
+
cookie += `; ${k}=${v}`;
|
|
205
|
+
}
|
|
206
|
+
cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie;
|
|
207
|
+
headers.set("cookie", cookie);
|
|
208
|
+
|
|
209
|
+
const userHeaders = new Headers(
|
|
210
|
+
options?.headers ?? options?.fetchOptions?.headers,
|
|
211
|
+
);
|
|
212
|
+
for (const [k, v] of userHeaders) {
|
|
213
|
+
headers.set(k, v);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Only set user agent header in non-browser-like environments since CORS
|
|
217
|
+
// policy disallows setting it in browsers e.g. Chrome throws an error.
|
|
218
|
+
if (!isBrowserLike) {
|
|
219
|
+
headers.set(
|
|
220
|
+
conf.uaHeader ?? "user-agent",
|
|
221
|
+
conf.userAgent ?? SDK_METADATA.userAgent,
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const fetchOptions: Omit<RequestInit, "method" | "body"> = {
|
|
226
|
+
...options?.fetchOptions,
|
|
227
|
+
...options,
|
|
228
|
+
};
|
|
229
|
+
if (!fetchOptions?.signal && conf.timeoutMs != null && conf.timeoutMs > 0) {
|
|
230
|
+
context.timeoutMs = conf.timeoutMs;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (conf.body instanceof ReadableStream) {
|
|
234
|
+
Object.assign(fetchOptions, { duplex: "half" });
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
let input;
|
|
238
|
+
try {
|
|
239
|
+
input = this.#hooks.beforeCreateRequest(context, {
|
|
240
|
+
url: reqURL,
|
|
241
|
+
options: {
|
|
242
|
+
...fetchOptions,
|
|
243
|
+
body: conf.body ?? null,
|
|
244
|
+
headers,
|
|
245
|
+
method,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
} catch (err: unknown) {
|
|
249
|
+
return ERR(
|
|
250
|
+
new UnexpectedClientError("Create request hook failed to execute", {
|
|
251
|
+
cause: err,
|
|
252
|
+
}),
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return OK(new Request(input.url, input.options));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
public async _do(
|
|
260
|
+
request: Request,
|
|
261
|
+
options: {
|
|
262
|
+
context: HookContext;
|
|
263
|
+
isErrorStatusCode: (statusCode: number) => boolean;
|
|
264
|
+
retryConfig: RetryConfig;
|
|
265
|
+
retryCodes: string[];
|
|
266
|
+
},
|
|
267
|
+
): Promise<
|
|
268
|
+
Result<
|
|
269
|
+
Response,
|
|
270
|
+
| RequestAbortedError
|
|
271
|
+
| RequestTimeoutError
|
|
272
|
+
| ConnectionError
|
|
273
|
+
| UnexpectedClientError
|
|
274
|
+
>
|
|
275
|
+
> {
|
|
276
|
+
const { context, isErrorStatusCode } = options;
|
|
277
|
+
const timeoutMs = context.timeoutMs;
|
|
278
|
+
|
|
279
|
+
return retry(
|
|
280
|
+
async () => {
|
|
281
|
+
const cloned = request.clone();
|
|
282
|
+
let attempt = cloned;
|
|
283
|
+
if (timeoutMs != null && timeoutMs > 0) {
|
|
284
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
285
|
+
const combined = combineSignals(cloned.signal, timeoutSignal)
|
|
286
|
+
?? timeoutSignal;
|
|
287
|
+
attempt = new Request(cloned, { signal: combined });
|
|
288
|
+
}
|
|
289
|
+
const req = await this.#hooks.beforeRequest(context, attempt);
|
|
290
|
+
await logRequest(this.#logger, req).catch((e) =>
|
|
291
|
+
this.#logger?.log("Failed to log request:", e)
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
let response = await this.#httpClient.request(req);
|
|
295
|
+
|
|
296
|
+
try {
|
|
297
|
+
if (isErrorStatusCode(response.status)) {
|
|
298
|
+
const result = await this.#hooks.afterError(
|
|
299
|
+
context,
|
|
300
|
+
response,
|
|
301
|
+
null,
|
|
302
|
+
);
|
|
303
|
+
if (result.error) {
|
|
304
|
+
throw result.error;
|
|
305
|
+
}
|
|
306
|
+
response = result.response || response;
|
|
307
|
+
} else {
|
|
308
|
+
response = await this.#hooks.afterSuccess(context, response);
|
|
309
|
+
}
|
|
310
|
+
} finally {
|
|
311
|
+
await logResponse(this.#logger, response, req)
|
|
312
|
+
.catch(e => this.#logger?.log("Failed to log response:", e));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return response;
|
|
316
|
+
},
|
|
317
|
+
{ config: options.retryConfig, statusCodes: options.retryCodes },
|
|
318
|
+
).then(
|
|
319
|
+
(r) => OK(r),
|
|
320
|
+
(err) => {
|
|
321
|
+
switch (true) {
|
|
322
|
+
case isAbortError(err):
|
|
323
|
+
return ERR(
|
|
324
|
+
new RequestAbortedError("Request aborted by client", {
|
|
325
|
+
cause: err,
|
|
326
|
+
}),
|
|
327
|
+
);
|
|
328
|
+
case isTimeoutError(err):
|
|
329
|
+
return ERR(
|
|
330
|
+
new RequestTimeoutError("Request timed out", { cause: err }),
|
|
331
|
+
);
|
|
332
|
+
case isConnectionError(err):
|
|
333
|
+
return ERR(
|
|
334
|
+
new ConnectionError("Unable to make request", { cause: err }),
|
|
335
|
+
);
|
|
336
|
+
default:
|
|
337
|
+
return ERR(
|
|
338
|
+
new UnexpectedClientError("Unexpected HTTP client error", {
|
|
339
|
+
cause: err,
|
|
340
|
+
}),
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const jsonLikeContentTypeRE = /^(application|text)\/([^+]+\+)*json.*/;
|
|
349
|
+
const jsonlLikeContentTypeRE =
|
|
350
|
+
/^(application|text)\/([^+]+\+)*(jsonl|x-ndjson)\b.*/;
|
|
351
|
+
async function logRequest(logger: Logger | undefined, req: Request) {
|
|
352
|
+
if (!logger) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const contentType = req.headers.get("content-type");
|
|
357
|
+
const ct = contentType?.split(";")[0] || "";
|
|
358
|
+
|
|
359
|
+
logger.group(`> Request: ${req.method} ${req.url}`);
|
|
360
|
+
|
|
361
|
+
logger.group("Headers:");
|
|
362
|
+
for (const [k, v] of req.headers.entries()) {
|
|
363
|
+
logger.log(`${k}: ${v}`);
|
|
364
|
+
}
|
|
365
|
+
logger.groupEnd();
|
|
366
|
+
|
|
367
|
+
logger.group("Body:");
|
|
368
|
+
switch (true) {
|
|
369
|
+
case jsonLikeContentTypeRE.test(ct):
|
|
370
|
+
logger.log(await req.clone().json());
|
|
371
|
+
break;
|
|
372
|
+
case ct.startsWith("text/"):
|
|
373
|
+
logger.log(await req.clone().text());
|
|
374
|
+
break;
|
|
375
|
+
case ct === "multipart/form-data": {
|
|
376
|
+
const body = await req.clone().formData();
|
|
377
|
+
for (const [k, v] of body) {
|
|
378
|
+
const vlabel = v instanceof Blob ? "<Blob>" : v;
|
|
379
|
+
logger.log(`${k}: ${vlabel}`);
|
|
380
|
+
}
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
default:
|
|
384
|
+
logger.log(`<${contentType}>`);
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
logger.groupEnd();
|
|
388
|
+
|
|
389
|
+
logger.groupEnd();
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
async function logResponse(
|
|
393
|
+
logger: Logger | undefined,
|
|
394
|
+
res: Response,
|
|
395
|
+
req: Request,
|
|
396
|
+
) {
|
|
397
|
+
if (!logger) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const contentType = res.headers.get("content-type");
|
|
402
|
+
const ct = contentType?.split(";")[0] || "";
|
|
403
|
+
|
|
404
|
+
logger.group(`< Response: ${req.method} ${req.url}`);
|
|
405
|
+
logger.log("Status Code:", res.status, res.statusText);
|
|
406
|
+
|
|
407
|
+
logger.group("Headers:");
|
|
408
|
+
for (const [k, v] of res.headers.entries()) {
|
|
409
|
+
logger.log(`${k}: ${v}`);
|
|
410
|
+
}
|
|
411
|
+
logger.groupEnd();
|
|
412
|
+
|
|
413
|
+
logger.group("Body:");
|
|
414
|
+
switch (true) {
|
|
415
|
+
case matchContentType(res, "application/json")
|
|
416
|
+
|| jsonLikeContentTypeRE.test(ct) && !jsonlLikeContentTypeRE.test(ct):
|
|
417
|
+
logger.log(await res.clone().json());
|
|
418
|
+
break;
|
|
419
|
+
case matchContentType(res, "application/jsonl")
|
|
420
|
+
|| jsonlLikeContentTypeRE.test(ct):
|
|
421
|
+
case matchContentType(res, "text/event-stream"):
|
|
422
|
+
logger.log(`<${contentType}>`);
|
|
423
|
+
break;
|
|
424
|
+
case matchContentType(res, "text/*"):
|
|
425
|
+
logger.log(await res.clone().text());
|
|
426
|
+
break;
|
|
427
|
+
case matchContentType(res, "multipart/form-data"): {
|
|
428
|
+
const body = await res.clone().formData();
|
|
429
|
+
for (const [k, v] of body) {
|
|
430
|
+
const vlabel = v instanceof Blob ? "<Blob>" : v;
|
|
431
|
+
logger.log(`${k}: ${vlabel}`);
|
|
432
|
+
}
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
default:
|
|
436
|
+
logger.log(`<${contentType}>`);
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
logger.groupEnd();
|
|
440
|
+
|
|
441
|
+
logger.groupEnd();
|
|
442
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as models from "../models/index.js";
|
|
6
|
+
import { env } from "./env.js";
|
|
7
|
+
|
|
8
|
+
type OAuth2PasswordFlow = {
|
|
9
|
+
username: string;
|
|
10
|
+
password: string;
|
|
11
|
+
clientID?: string | undefined;
|
|
12
|
+
clientSecret?: string | undefined;
|
|
13
|
+
tokenURL: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export enum SecurityErrorCode {
|
|
17
|
+
Incomplete = "incomplete",
|
|
18
|
+
UnrecognisedSecurityType = "unrecognized_security_type",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class SecurityError extends Error {
|
|
22
|
+
constructor(
|
|
23
|
+
public code: SecurityErrorCode,
|
|
24
|
+
message: string,
|
|
25
|
+
) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "SecurityError";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static incomplete(): SecurityError {
|
|
31
|
+
return new SecurityError(
|
|
32
|
+
SecurityErrorCode.Incomplete,
|
|
33
|
+
"Security requirements not met in order to perform the operation",
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
static unrecognizedType(type: string): SecurityError {
|
|
37
|
+
return new SecurityError(
|
|
38
|
+
SecurityErrorCode.UnrecognisedSecurityType,
|
|
39
|
+
`Unrecognised security type: ${type}`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type SecurityState = {
|
|
45
|
+
basic: { username?: string | undefined; password?: string | undefined };
|
|
46
|
+
headers: Record<string, string>;
|
|
47
|
+
queryParams: Record<string, string>;
|
|
48
|
+
cookies: Record<string, string>;
|
|
49
|
+
oauth2: ({ type: "password" } & OAuth2PasswordFlow) | { type: "none" };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type SecurityInputBasic = {
|
|
53
|
+
type: "http:basic";
|
|
54
|
+
value:
|
|
55
|
+
| { username?: string | undefined; password?: string | undefined }
|
|
56
|
+
| null
|
|
57
|
+
| undefined;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type SecurityInputBearer = {
|
|
61
|
+
type: "http:bearer";
|
|
62
|
+
value: string | null | undefined;
|
|
63
|
+
fieldName: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type SecurityInputAPIKey = {
|
|
67
|
+
type: "apiKey:header" | "apiKey:query" | "apiKey:cookie";
|
|
68
|
+
value: string | null | undefined;
|
|
69
|
+
fieldName: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type SecurityInputOIDC = {
|
|
73
|
+
type: "openIdConnect";
|
|
74
|
+
value: string | null | undefined;
|
|
75
|
+
fieldName: string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
type SecurityInputOAuth2 = {
|
|
79
|
+
type: "oauth2";
|
|
80
|
+
value: string | null | undefined;
|
|
81
|
+
fieldName: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
type SecurityInputOAuth2ClientCredentials = {
|
|
85
|
+
type: "oauth2:client_credentials";
|
|
86
|
+
value:
|
|
87
|
+
| {
|
|
88
|
+
clientID?: string | undefined;
|
|
89
|
+
clientSecret?: string | undefined;
|
|
90
|
+
}
|
|
91
|
+
| null
|
|
92
|
+
| string
|
|
93
|
+
| undefined;
|
|
94
|
+
fieldName?: string;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
type SecurityInputOAuth2PasswordCredentials = {
|
|
98
|
+
type: "oauth2:password";
|
|
99
|
+
value:
|
|
100
|
+
| string
|
|
101
|
+
| null
|
|
102
|
+
| undefined;
|
|
103
|
+
fieldName?: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
type SecurityInputCustom = {
|
|
107
|
+
type: "http:custom";
|
|
108
|
+
value: any | null | undefined;
|
|
109
|
+
fieldName?: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type SecurityInput =
|
|
113
|
+
| SecurityInputBasic
|
|
114
|
+
| SecurityInputBearer
|
|
115
|
+
| SecurityInputAPIKey
|
|
116
|
+
| SecurityInputOAuth2
|
|
117
|
+
| SecurityInputOAuth2ClientCredentials
|
|
118
|
+
| SecurityInputOAuth2PasswordCredentials
|
|
119
|
+
| SecurityInputOIDC
|
|
120
|
+
| SecurityInputCustom;
|
|
121
|
+
|
|
122
|
+
export function resolveSecurity(
|
|
123
|
+
...options: SecurityInput[][]
|
|
124
|
+
): SecurityState | null {
|
|
125
|
+
const state: SecurityState = {
|
|
126
|
+
basic: {},
|
|
127
|
+
headers: {},
|
|
128
|
+
queryParams: {},
|
|
129
|
+
cookies: {},
|
|
130
|
+
oauth2: { type: "none" },
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const option = options.find((opts) => {
|
|
134
|
+
return opts.every((o) => {
|
|
135
|
+
if (o.value == null) {
|
|
136
|
+
return false;
|
|
137
|
+
} else if (o.type === "http:basic") {
|
|
138
|
+
return o.value.username != null || o.value.password != null;
|
|
139
|
+
} else if (o.type === "http:custom") {
|
|
140
|
+
return null;
|
|
141
|
+
} else if (o.type === "oauth2:password") {
|
|
142
|
+
return (
|
|
143
|
+
typeof o.value === "string" && !!o.value
|
|
144
|
+
);
|
|
145
|
+
} else if (o.type === "oauth2:client_credentials") {
|
|
146
|
+
if (typeof o.value == "string") {
|
|
147
|
+
return !!o.value;
|
|
148
|
+
}
|
|
149
|
+
return o.value.clientID != null || o.value.clientSecret != null;
|
|
150
|
+
} else if (typeof o.value === "string") {
|
|
151
|
+
return !!o.value;
|
|
152
|
+
} else {
|
|
153
|
+
throw new Error(
|
|
154
|
+
`Unrecognized security type: ${o.type} (value type: ${typeof o
|
|
155
|
+
.value})`,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
if (option == null) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
option.forEach((spec) => {
|
|
165
|
+
if (spec.value == null) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const { type } = spec;
|
|
170
|
+
|
|
171
|
+
switch (type) {
|
|
172
|
+
case "apiKey:header":
|
|
173
|
+
state.headers[spec.fieldName] = spec.value;
|
|
174
|
+
break;
|
|
175
|
+
case "apiKey:query":
|
|
176
|
+
state.queryParams[spec.fieldName] = spec.value;
|
|
177
|
+
break;
|
|
178
|
+
case "apiKey:cookie":
|
|
179
|
+
state.cookies[spec.fieldName] = spec.value;
|
|
180
|
+
break;
|
|
181
|
+
case "http:basic":
|
|
182
|
+
applyBasic(state, spec);
|
|
183
|
+
break;
|
|
184
|
+
case "http:custom":
|
|
185
|
+
break;
|
|
186
|
+
case "http:bearer":
|
|
187
|
+
applyBearer(state, spec);
|
|
188
|
+
break;
|
|
189
|
+
case "oauth2":
|
|
190
|
+
applyBearer(state, spec);
|
|
191
|
+
break;
|
|
192
|
+
case "oauth2:password":
|
|
193
|
+
applyBearer(state, spec);
|
|
194
|
+
break;
|
|
195
|
+
case "oauth2:client_credentials":
|
|
196
|
+
break;
|
|
197
|
+
case "openIdConnect":
|
|
198
|
+
applyBearer(state, spec);
|
|
199
|
+
break;
|
|
200
|
+
default:
|
|
201
|
+
throw SecurityError.unrecognizedType((spec satisfies never, type));
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
return state;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function applyBasic(
|
|
209
|
+
state: SecurityState,
|
|
210
|
+
spec: SecurityInputBasic,
|
|
211
|
+
) {
|
|
212
|
+
if (spec.value == null) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
state.basic = spec.value;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function applyBearer(
|
|
220
|
+
state: SecurityState,
|
|
221
|
+
spec:
|
|
222
|
+
| SecurityInputBearer
|
|
223
|
+
| SecurityInputOAuth2
|
|
224
|
+
| SecurityInputOIDC
|
|
225
|
+
| SecurityInputOAuth2PasswordCredentials,
|
|
226
|
+
) {
|
|
227
|
+
if (typeof spec.value !== "string" || !spec.value) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
let value = spec.value;
|
|
232
|
+
if (value.slice(0, 7).toLowerCase() !== "bearer ") {
|
|
233
|
+
value = `Bearer ${value}`;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (spec.fieldName !== undefined) {
|
|
237
|
+
state.headers[spec.fieldName] = value;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function resolveGlobalSecurity(
|
|
242
|
+
security: Partial<models.Security> | null | undefined,
|
|
243
|
+
allowedFields?: number[],
|
|
244
|
+
): SecurityState | null {
|
|
245
|
+
let inputs: SecurityInput[][] = [
|
|
246
|
+
[
|
|
247
|
+
{
|
|
248
|
+
fieldName: "Authorization",
|
|
249
|
+
type: "http:bearer",
|
|
250
|
+
value: security?.bearerAuth ?? env().QUICKSHOPS_BEARER_AUTH,
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
];
|
|
254
|
+
|
|
255
|
+
if (allowedFields) {
|
|
256
|
+
inputs = allowedFields.map((i) => {
|
|
257
|
+
if (i < 0 || i >= inputs.length) {
|
|
258
|
+
throw new RangeError(`invalid allowedFields index ${i}`);
|
|
259
|
+
}
|
|
260
|
+
return inputs[i]!;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return resolveSecurity(...inputs);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export async function extractSecurity<
|
|
268
|
+
T extends string | Record<string, unknown>,
|
|
269
|
+
>(sec: T | (() => Promise<T>) | undefined): Promise<T | undefined> {
|
|
270
|
+
if (sec == null) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return typeof sec === "function" ? sec() : sec;
|
|
275
|
+
}
|