@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/http.ts
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type Fetcher = (
|
|
6
|
+
input: RequestInfo | URL,
|
|
7
|
+
init?: RequestInit,
|
|
8
|
+
) => Promise<Response>;
|
|
9
|
+
|
|
10
|
+
export type Awaitable<T> = T | Promise<T>;
|
|
11
|
+
|
|
12
|
+
const DEFAULT_FETCHER: Fetcher = (input, init) => {
|
|
13
|
+
// If input is a Request and init is undefined, Bun will discard the method,
|
|
14
|
+
// headers, body and other options that were set on the request object.
|
|
15
|
+
// Node.js and browers would ignore an undefined init value. This check is
|
|
16
|
+
// therefore needed for interop with Bun.
|
|
17
|
+
if (init == null) {
|
|
18
|
+
return fetch(input);
|
|
19
|
+
} else {
|
|
20
|
+
return fetch(input, init);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type RequestInput = {
|
|
25
|
+
/**
|
|
26
|
+
* The URL the request will use.
|
|
27
|
+
*/
|
|
28
|
+
url: URL;
|
|
29
|
+
/**
|
|
30
|
+
* Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request).
|
|
31
|
+
*/
|
|
32
|
+
options?: RequestInit | undefined;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export interface HTTPClientOptions {
|
|
36
|
+
fetcher?: Fetcher;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type BeforeRequestHook = (req: Request) => Awaitable<Request | void>;
|
|
40
|
+
export type RequestErrorHook = (err: unknown, req: Request) => Awaitable<void>;
|
|
41
|
+
export type ResponseHook = (res: Response, req: Request) => Awaitable<void>;
|
|
42
|
+
|
|
43
|
+
export class HTTPClient {
|
|
44
|
+
private fetcher: Fetcher;
|
|
45
|
+
private requestHooks: BeforeRequestHook[] = [];
|
|
46
|
+
private requestErrorHooks: RequestErrorHook[] = [];
|
|
47
|
+
private responseHooks: ResponseHook[] = [];
|
|
48
|
+
|
|
49
|
+
constructor(private options: HTTPClientOptions = {}) {
|
|
50
|
+
this.fetcher = options.fetcher || DEFAULT_FETCHER;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async request(request: Request): Promise<Response> {
|
|
54
|
+
let req = request;
|
|
55
|
+
for (const hook of this.requestHooks) {
|
|
56
|
+
const nextRequest = await hook(req);
|
|
57
|
+
if (nextRequest) {
|
|
58
|
+
req = nextRequest;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const res = await this.fetcher(req);
|
|
64
|
+
|
|
65
|
+
for (const hook of this.responseHooks) {
|
|
66
|
+
await hook(res, req);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return res;
|
|
70
|
+
} catch (err) {
|
|
71
|
+
for (const hook of this.requestErrorHooks) {
|
|
72
|
+
await hook(err, req);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
throw err;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Registers a hook that is called before a request is made. The hook function
|
|
81
|
+
* can mutate the request or return a new request. This may be useful to add
|
|
82
|
+
* additional information to request such as request IDs and tracing headers.
|
|
83
|
+
*/
|
|
84
|
+
addHook(hook: "beforeRequest", fn: BeforeRequestHook): this;
|
|
85
|
+
/**
|
|
86
|
+
* Registers a hook that is called when a request cannot be made due to a
|
|
87
|
+
* network error.
|
|
88
|
+
*/
|
|
89
|
+
addHook(hook: "requestError", fn: RequestErrorHook): this;
|
|
90
|
+
/**
|
|
91
|
+
* Registers a hook that is called when a response has been received from the
|
|
92
|
+
* server.
|
|
93
|
+
*/
|
|
94
|
+
addHook(hook: "response", fn: ResponseHook): this;
|
|
95
|
+
addHook(
|
|
96
|
+
...args:
|
|
97
|
+
| [hook: "beforeRequest", fn: BeforeRequestHook]
|
|
98
|
+
| [hook: "requestError", fn: RequestErrorHook]
|
|
99
|
+
| [hook: "response", fn: ResponseHook]
|
|
100
|
+
) {
|
|
101
|
+
if (args[0] === "beforeRequest") {
|
|
102
|
+
this.requestHooks.push(args[1]);
|
|
103
|
+
} else if (args[0] === "requestError") {
|
|
104
|
+
this.requestErrorHooks.push(args[1]);
|
|
105
|
+
} else if (args[0] === "response") {
|
|
106
|
+
this.responseHooks.push(args[1]);
|
|
107
|
+
} else {
|
|
108
|
+
throw new Error(`Invalid hook type: ${args[0]}`);
|
|
109
|
+
}
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Removes a hook that was previously registered with `addHook`. */
|
|
114
|
+
removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this;
|
|
115
|
+
/** Removes a hook that was previously registered with `addHook`. */
|
|
116
|
+
removeHook(hook: "requestError", fn: RequestErrorHook): this;
|
|
117
|
+
/** Removes a hook that was previously registered with `addHook`. */
|
|
118
|
+
removeHook(hook: "response", fn: ResponseHook): this;
|
|
119
|
+
removeHook(
|
|
120
|
+
...args:
|
|
121
|
+
| [hook: "beforeRequest", fn: BeforeRequestHook]
|
|
122
|
+
| [hook: "requestError", fn: RequestErrorHook]
|
|
123
|
+
| [hook: "response", fn: ResponseHook]
|
|
124
|
+
): this {
|
|
125
|
+
let target: unknown[];
|
|
126
|
+
if (args[0] === "beforeRequest") {
|
|
127
|
+
target = this.requestHooks;
|
|
128
|
+
} else if (args[0] === "requestError") {
|
|
129
|
+
target = this.requestErrorHooks;
|
|
130
|
+
} else if (args[0] === "response") {
|
|
131
|
+
target = this.responseHooks;
|
|
132
|
+
} else {
|
|
133
|
+
throw new Error(`Invalid hook type: ${args[0]}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const index = target.findIndex((v) => v === args[1]);
|
|
137
|
+
if (index >= 0) {
|
|
138
|
+
target.splice(index, 1);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
clone(): HTTPClient {
|
|
145
|
+
const child = new HTTPClient(this.options);
|
|
146
|
+
child.requestHooks = this.requestHooks.slice();
|
|
147
|
+
child.requestErrorHooks = this.requestErrorHooks.slice();
|
|
148
|
+
child.responseHooks = this.responseHooks.slice();
|
|
149
|
+
|
|
150
|
+
return child;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type StatusCodePredicate = number | string | (number | string)[];
|
|
155
|
+
|
|
156
|
+
// A semicolon surrounded by optional whitespace characters is used to separate
|
|
157
|
+
// segments in a media type string.
|
|
158
|
+
const mediaParamSeparator = /\s*;\s*/g;
|
|
159
|
+
|
|
160
|
+
export function matchContentType(response: Response, pattern: string): boolean {
|
|
161
|
+
// `*` is a special case which means anything is acceptable.
|
|
162
|
+
if (pattern === "*") {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let contentType =
|
|
167
|
+
response.headers.get("content-type")?.trim() || "application/octet-stream";
|
|
168
|
+
contentType = contentType.toLowerCase();
|
|
169
|
+
|
|
170
|
+
const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator);
|
|
171
|
+
const [wantType = "", ...wantParams] = wantParts;
|
|
172
|
+
|
|
173
|
+
if (wantType.split("/").length !== 2) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const gotParts = contentType.split(mediaParamSeparator);
|
|
178
|
+
const [gotType = "", ...gotParams] = gotParts;
|
|
179
|
+
|
|
180
|
+
const [type = "", subtype = ""] = gotType.split("/");
|
|
181
|
+
if (!type || !subtype) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (
|
|
186
|
+
wantType !== "*/*" &&
|
|
187
|
+
gotType !== wantType &&
|
|
188
|
+
`${type}/*` !== wantType &&
|
|
189
|
+
`*/${subtype}` !== wantType
|
|
190
|
+
) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (gotParams.length < wantParams.length) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const params = new Set(gotParams);
|
|
199
|
+
for (const wantParam of wantParams) {
|
|
200
|
+
if (!params.has(wantParam)) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const codeRangeRE = new RegExp("^[0-9]xx$", "i");
|
|
209
|
+
|
|
210
|
+
export function matchStatusCode(
|
|
211
|
+
response: Response,
|
|
212
|
+
codes: StatusCodePredicate,
|
|
213
|
+
): boolean {
|
|
214
|
+
const actual = `${response.status}`;
|
|
215
|
+
const expectedCodes = Array.isArray(codes) ? codes : [codes];
|
|
216
|
+
if (!expectedCodes.length) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return expectedCodes.some((ec) => {
|
|
221
|
+
const code = `${ec}`;
|
|
222
|
+
|
|
223
|
+
if (code === "default") {
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (!codeRangeRE.test(`${code}`)) {
|
|
228
|
+
return code === actual;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const expectFamily = code.charAt(0);
|
|
232
|
+
if (!expectFamily) {
|
|
233
|
+
throw new Error("Invalid status code range");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const actualFamily = actual.charAt(0);
|
|
237
|
+
if (!actualFamily) {
|
|
238
|
+
throw new Error(`Invalid response status code: ${actual}`);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return actualFamily === expectFamily;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function matchResponse(
|
|
246
|
+
response: Response,
|
|
247
|
+
code: StatusCodePredicate,
|
|
248
|
+
contentTypePattern: string,
|
|
249
|
+
): boolean {
|
|
250
|
+
return (
|
|
251
|
+
matchStatusCode(response, code) &&
|
|
252
|
+
matchContentType(response, contentTypePattern)
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Uses various heurisitics to determine if an error is a connection error.
|
|
258
|
+
*/
|
|
259
|
+
export function isConnectionError(err: unknown): boolean {
|
|
260
|
+
if (typeof err !== "object" || err == null) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Covers fetch in Deno as well
|
|
265
|
+
const isBrowserErr =
|
|
266
|
+
err instanceof TypeError &&
|
|
267
|
+
err.message.toLowerCase().startsWith("failed to fetch");
|
|
268
|
+
|
|
269
|
+
const isNodeErr =
|
|
270
|
+
err instanceof TypeError &&
|
|
271
|
+
err.message.toLowerCase().startsWith("fetch failed");
|
|
272
|
+
|
|
273
|
+
const isBunErr = "name" in err && err.name === "ConnectionError";
|
|
274
|
+
|
|
275
|
+
const isGenericErr =
|
|
276
|
+
"code" in err &&
|
|
277
|
+
typeof err.code === "string" &&
|
|
278
|
+
err.code.toLowerCase() === "econnreset";
|
|
279
|
+
|
|
280
|
+
return isBrowserErr || isNodeErr || isGenericErr || isBunErr;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Uses various heurisitics to determine if an error is a timeout error.
|
|
285
|
+
*/
|
|
286
|
+
export function isTimeoutError(err: unknown): boolean {
|
|
287
|
+
if (typeof err !== "object" || err == null) {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Fetch in browser, Node.js, Bun, Deno
|
|
292
|
+
const isNative = "name" in err && err.name === "TimeoutError";
|
|
293
|
+
const isLegacyNative = "code" in err && err.code === 23;
|
|
294
|
+
|
|
295
|
+
// Node.js HTTP client and Axios
|
|
296
|
+
const isGenericErr =
|
|
297
|
+
"code" in err &&
|
|
298
|
+
typeof err.code === "string" &&
|
|
299
|
+
err.code.toLowerCase() === "econnaborted";
|
|
300
|
+
|
|
301
|
+
return isNative || isLegacyNative || isGenericErr;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Uses various heurisitics to determine if an error is a abort error.
|
|
306
|
+
*/
|
|
307
|
+
export function isAbortError(err: unknown): boolean {
|
|
308
|
+
if (typeof err !== "object" || err == null) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Fetch in browser, Node.js, Bun, Deno
|
|
313
|
+
const isNative = "name" in err && err.name === "AbortError";
|
|
314
|
+
const isLegacyNative = "code" in err && err.code === 20;
|
|
315
|
+
|
|
316
|
+
// Node.js HTTP client and Axios
|
|
317
|
+
const isGenericErr =
|
|
318
|
+
"code" in err &&
|
|
319
|
+
typeof err.code === "string" &&
|
|
320
|
+
err.code.toLowerCase() === "econnaborted";
|
|
321
|
+
|
|
322
|
+
return isNative || isLegacyNative || isGenericErr;
|
|
323
|
+
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { QuickshopsDefaultError } from "../models/errors/quickshops-default-error.js";
|
|
6
|
+
import { ResponseValidationError } from "../models/errors/response-validation-error.js";
|
|
7
|
+
import { ERR, OK, Result } from "../types/fp.js";
|
|
8
|
+
import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
|
|
9
|
+
import { isPlainObject } from "./primitives.js";
|
|
10
|
+
|
|
11
|
+
export type Encoding =
|
|
12
|
+
| "jsonl"
|
|
13
|
+
| "json"
|
|
14
|
+
| "text"
|
|
15
|
+
| "bytes"
|
|
16
|
+
| "stream"
|
|
17
|
+
| "sse"
|
|
18
|
+
| "nil"
|
|
19
|
+
| "fail";
|
|
20
|
+
|
|
21
|
+
const DEFAULT_CONTENT_TYPES: Record<Encoding, string> = {
|
|
22
|
+
jsonl: "application/jsonl",
|
|
23
|
+
json: "application/json",
|
|
24
|
+
text: "text/plain",
|
|
25
|
+
bytes: "application/octet-stream",
|
|
26
|
+
stream: "application/octet-stream",
|
|
27
|
+
sse: "text/event-stream",
|
|
28
|
+
nil: "*",
|
|
29
|
+
fail: "*",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type Schema<T> = { parse(raw: unknown): T };
|
|
33
|
+
|
|
34
|
+
type MatchOptions = {
|
|
35
|
+
ctype?: string;
|
|
36
|
+
hdrs?: boolean;
|
|
37
|
+
key?: string;
|
|
38
|
+
sseSentinel?: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type ValueMatcher<V> = MatchOptions & {
|
|
42
|
+
enc: Encoding;
|
|
43
|
+
codes: StatusCodePredicate;
|
|
44
|
+
schema: Schema<V>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type ErrorMatcher<E> = MatchOptions & {
|
|
48
|
+
enc: Encoding;
|
|
49
|
+
codes: StatusCodePredicate;
|
|
50
|
+
schema: Schema<E>;
|
|
51
|
+
err: true;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type FailMatcher = {
|
|
55
|
+
enc: "fail";
|
|
56
|
+
codes: StatusCodePredicate;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type Matcher<T, E> = ValueMatcher<T> | ErrorMatcher<E> | FailMatcher;
|
|
60
|
+
|
|
61
|
+
export function jsonErr<E>(
|
|
62
|
+
codes: StatusCodePredicate,
|
|
63
|
+
schema: Schema<E>,
|
|
64
|
+
options?: MatchOptions,
|
|
65
|
+
): ErrorMatcher<E> {
|
|
66
|
+
return { ...options, err: true, enc: "json", codes, schema };
|
|
67
|
+
}
|
|
68
|
+
export function json<T>(
|
|
69
|
+
codes: StatusCodePredicate,
|
|
70
|
+
schema: Schema<T>,
|
|
71
|
+
options?: MatchOptions,
|
|
72
|
+
): ValueMatcher<T> {
|
|
73
|
+
return { ...options, enc: "json", codes, schema };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function jsonl<T>(
|
|
77
|
+
codes: StatusCodePredicate,
|
|
78
|
+
schema: Schema<T>,
|
|
79
|
+
options?: MatchOptions,
|
|
80
|
+
): ValueMatcher<T> {
|
|
81
|
+
return { ...options, enc: "jsonl", codes, schema };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function jsonlErr<E>(
|
|
85
|
+
codes: StatusCodePredicate,
|
|
86
|
+
schema: Schema<E>,
|
|
87
|
+
options?: MatchOptions,
|
|
88
|
+
): ErrorMatcher<E> {
|
|
89
|
+
return { ...options, err: true, enc: "jsonl", codes, schema };
|
|
90
|
+
}
|
|
91
|
+
export function textErr<E>(
|
|
92
|
+
codes: StatusCodePredicate,
|
|
93
|
+
schema: Schema<E>,
|
|
94
|
+
options?: MatchOptions,
|
|
95
|
+
): ErrorMatcher<E> {
|
|
96
|
+
return { ...options, err: true, enc: "text", codes, schema };
|
|
97
|
+
}
|
|
98
|
+
export function text<T>(
|
|
99
|
+
codes: StatusCodePredicate,
|
|
100
|
+
schema: Schema<T>,
|
|
101
|
+
options?: MatchOptions,
|
|
102
|
+
): ValueMatcher<T> {
|
|
103
|
+
return { ...options, enc: "text", codes, schema };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function bytesErr<E>(
|
|
107
|
+
codes: StatusCodePredicate,
|
|
108
|
+
schema: Schema<E>,
|
|
109
|
+
options?: MatchOptions,
|
|
110
|
+
): ErrorMatcher<E> {
|
|
111
|
+
return { ...options, err: true, enc: "bytes", codes, schema };
|
|
112
|
+
}
|
|
113
|
+
export function bytes<T>(
|
|
114
|
+
codes: StatusCodePredicate,
|
|
115
|
+
schema: Schema<T>,
|
|
116
|
+
options?: MatchOptions,
|
|
117
|
+
): ValueMatcher<T> {
|
|
118
|
+
return { ...options, enc: "bytes", codes, schema };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function streamErr<E>(
|
|
122
|
+
codes: StatusCodePredicate,
|
|
123
|
+
schema: Schema<E>,
|
|
124
|
+
options?: MatchOptions,
|
|
125
|
+
): ErrorMatcher<E> {
|
|
126
|
+
return { ...options, err: true, enc: "stream", codes, schema };
|
|
127
|
+
}
|
|
128
|
+
export function stream<T>(
|
|
129
|
+
codes: StatusCodePredicate,
|
|
130
|
+
schema: Schema<T>,
|
|
131
|
+
options?: MatchOptions,
|
|
132
|
+
): ValueMatcher<T> {
|
|
133
|
+
return { ...options, enc: "stream", codes, schema };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function sseErr<E>(
|
|
137
|
+
codes: StatusCodePredicate,
|
|
138
|
+
schema: Schema<E>,
|
|
139
|
+
options?: MatchOptions,
|
|
140
|
+
): ErrorMatcher<E> {
|
|
141
|
+
return { ...options, err: true, enc: "sse", codes, schema };
|
|
142
|
+
}
|
|
143
|
+
export function sse<T>(
|
|
144
|
+
codes: StatusCodePredicate,
|
|
145
|
+
schema: Schema<T>,
|
|
146
|
+
options?: MatchOptions,
|
|
147
|
+
): ValueMatcher<T> {
|
|
148
|
+
return { ...options, enc: "sse", codes, schema };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function nilErr<E>(
|
|
152
|
+
codes: StatusCodePredicate,
|
|
153
|
+
schema: Schema<E>,
|
|
154
|
+
options?: MatchOptions,
|
|
155
|
+
): ErrorMatcher<E> {
|
|
156
|
+
return { ...options, err: true, enc: "nil", codes, schema };
|
|
157
|
+
}
|
|
158
|
+
export function nil<T>(
|
|
159
|
+
codes: StatusCodePredicate,
|
|
160
|
+
schema: Schema<T>,
|
|
161
|
+
options?: MatchOptions,
|
|
162
|
+
): ValueMatcher<T> {
|
|
163
|
+
return { ...options, enc: "nil", codes, schema };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function fail(codes: StatusCodePredicate): FailMatcher {
|
|
167
|
+
return { enc: "fail", codes };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type MatchedValue<Matchers> = Matchers extends Matcher<infer T, any>[]
|
|
171
|
+
? T
|
|
172
|
+
: never;
|
|
173
|
+
export type MatchedError<Matchers> = Matchers extends Matcher<any, infer E>[]
|
|
174
|
+
? E
|
|
175
|
+
: never;
|
|
176
|
+
export type MatchFunc<T, E> = (
|
|
177
|
+
response: Response,
|
|
178
|
+
request: Request,
|
|
179
|
+
options?: { resultKey?: string; extraFields?: Record<string, unknown> },
|
|
180
|
+
) => Promise<[result: Result<T, E>, raw: unknown]>;
|
|
181
|
+
|
|
182
|
+
export function match<T, E>(
|
|
183
|
+
...matchers: Array<Matcher<T, E>>
|
|
184
|
+
): MatchFunc<T, E | QuickshopsDefaultError | ResponseValidationError> {
|
|
185
|
+
return async function matchFunc(
|
|
186
|
+
response: Response,
|
|
187
|
+
request: Request,
|
|
188
|
+
options?: { resultKey?: string; extraFields?: Record<string, unknown> },
|
|
189
|
+
): Promise<
|
|
190
|
+
[
|
|
191
|
+
result: Result<T, E | QuickshopsDefaultError | ResponseValidationError>,
|
|
192
|
+
raw: unknown,
|
|
193
|
+
]
|
|
194
|
+
> {
|
|
195
|
+
let raw: unknown;
|
|
196
|
+
let matcher: Matcher<T, E> | undefined;
|
|
197
|
+
for (const match of matchers) {
|
|
198
|
+
const { codes } = match;
|
|
199
|
+
const ctpattern = "ctype" in match
|
|
200
|
+
? match.ctype
|
|
201
|
+
: DEFAULT_CONTENT_TYPES[match.enc];
|
|
202
|
+
if (ctpattern && matchResponse(response, codes, ctpattern)) {
|
|
203
|
+
matcher = match;
|
|
204
|
+
break;
|
|
205
|
+
} else if (!ctpattern && matchStatusCode(response, codes)) {
|
|
206
|
+
matcher = match;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (!matcher) {
|
|
212
|
+
return [{
|
|
213
|
+
ok: false,
|
|
214
|
+
error: new QuickshopsDefaultError("Unexpected Status or Content-Type", {
|
|
215
|
+
response,
|
|
216
|
+
request,
|
|
217
|
+
body: await response.text().catch(() => ""),
|
|
218
|
+
}),
|
|
219
|
+
}, raw];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const encoding = matcher.enc;
|
|
223
|
+
let body = "";
|
|
224
|
+
switch (encoding) {
|
|
225
|
+
case "json":
|
|
226
|
+
body = await response.text();
|
|
227
|
+
raw = JSON.parse(body);
|
|
228
|
+
break;
|
|
229
|
+
case "jsonl":
|
|
230
|
+
raw = response.body;
|
|
231
|
+
break;
|
|
232
|
+
case "bytes":
|
|
233
|
+
raw = new Uint8Array(await response.arrayBuffer());
|
|
234
|
+
break;
|
|
235
|
+
case "stream":
|
|
236
|
+
raw = response.body;
|
|
237
|
+
break;
|
|
238
|
+
case "text":
|
|
239
|
+
body = await response.text();
|
|
240
|
+
raw = body;
|
|
241
|
+
break;
|
|
242
|
+
case "sse":
|
|
243
|
+
raw = response.body;
|
|
244
|
+
break;
|
|
245
|
+
case "nil":
|
|
246
|
+
body = await response.text();
|
|
247
|
+
raw = undefined;
|
|
248
|
+
break;
|
|
249
|
+
case "fail":
|
|
250
|
+
body = await response.text();
|
|
251
|
+
raw = body;
|
|
252
|
+
break;
|
|
253
|
+
default:
|
|
254
|
+
throw new Error(
|
|
255
|
+
`Unsupported response type: ${encoding satisfies never}`,
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (matcher.enc === "fail") {
|
|
260
|
+
return [{
|
|
261
|
+
ok: false,
|
|
262
|
+
error: new QuickshopsDefaultError("API error occurred", {
|
|
263
|
+
request,
|
|
264
|
+
response,
|
|
265
|
+
body,
|
|
266
|
+
}),
|
|
267
|
+
}, raw];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const resultKey = matcher.key || options?.resultKey;
|
|
271
|
+
let data: unknown;
|
|
272
|
+
|
|
273
|
+
if ("err" in matcher) {
|
|
274
|
+
data = {
|
|
275
|
+
...options?.extraFields,
|
|
276
|
+
...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
|
|
277
|
+
...(isPlainObject(raw) ? raw : null),
|
|
278
|
+
request$: request,
|
|
279
|
+
response$: response,
|
|
280
|
+
body$: body,
|
|
281
|
+
};
|
|
282
|
+
} else if (resultKey) {
|
|
283
|
+
data = {
|
|
284
|
+
...options?.extraFields,
|
|
285
|
+
...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
|
|
286
|
+
[resultKey]: raw,
|
|
287
|
+
};
|
|
288
|
+
} else if (matcher.hdrs) {
|
|
289
|
+
data = {
|
|
290
|
+
...options?.extraFields,
|
|
291
|
+
...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
|
|
292
|
+
...(isPlainObject(raw) ? raw : null),
|
|
293
|
+
};
|
|
294
|
+
} else {
|
|
295
|
+
data = raw;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if ("err" in matcher) {
|
|
299
|
+
const result = safeParseResponse(
|
|
300
|
+
data,
|
|
301
|
+
(v: unknown) => matcher.schema.parse(v),
|
|
302
|
+
"Response validation failed",
|
|
303
|
+
{ request, response, body },
|
|
304
|
+
);
|
|
305
|
+
return [result.ok ? { ok: false, error: result.value } : result, raw];
|
|
306
|
+
} else {
|
|
307
|
+
return [
|
|
308
|
+
safeParseResponse(
|
|
309
|
+
data,
|
|
310
|
+
(v: unknown) => matcher.schema.parse(v),
|
|
311
|
+
"Response validation failed",
|
|
312
|
+
{ request, response, body },
|
|
313
|
+
),
|
|
314
|
+
raw,
|
|
315
|
+
];
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const headerValRE = /, */;
|
|
321
|
+
/**
|
|
322
|
+
* Iterates over a Headers object and returns an object with all the header
|
|
323
|
+
* entries. Values are represented as an array to account for repeated headers.
|
|
324
|
+
*/
|
|
325
|
+
export function unpackHeaders(headers: Headers): Record<string, string[]> {
|
|
326
|
+
const out: Record<string, string[]> = {};
|
|
327
|
+
|
|
328
|
+
for (const [k, v] of headers.entries()) {
|
|
329
|
+
out[k] = v.split(headerValRE);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return out;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function safeParseResponse<Inp, Out>(
|
|
336
|
+
rawValue: Inp,
|
|
337
|
+
fn: (value: Inp) => Out,
|
|
338
|
+
errorMessage: string,
|
|
339
|
+
httpMeta: { response: Response; request: Request; body: string },
|
|
340
|
+
): Result<Out, ResponseValidationError> {
|
|
341
|
+
try {
|
|
342
|
+
return OK(fn(rawValue));
|
|
343
|
+
} catch (err) {
|
|
344
|
+
return ERR(
|
|
345
|
+
new ResponseValidationError(errorMessage, {
|
|
346
|
+
cause: err,
|
|
347
|
+
rawValue,
|
|
348
|
+
rawMessage: errorMessage,
|
|
349
|
+
...httpMeta,
|
|
350
|
+
}),
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
}
|