@commercelayer/sdk 7.0.0-beta.8 → 7.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -35
- package/lib/api-DDgIE2i8.d.ts +17175 -0
- package/lib/api-DmIZO_Np.d.cts +17175 -0
- package/lib/api.cjs +796 -0
- package/lib/api.cjs.map +1 -0
- package/lib/api.d.cts +4 -0
- package/lib/api.d.ts +4 -0
- package/lib/api.js +133 -0
- package/lib/api.js.map +1 -0
- package/lib/client.cjs +160 -0
- package/lib/client.cjs.map +1 -0
- package/lib/client.d.cts +36 -0
- package/lib/client.d.ts +36 -0
- package/lib/client.js +151 -0
- package/lib/client.js.map +1 -0
- package/lib/commercelayer.cjs +114 -0
- package/lib/commercelayer.cjs.map +1 -0
- package/lib/commercelayer.d.cts +36 -0
- package/lib/commercelayer.d.ts +36 -0
- package/lib/commercelayer.js +104 -0
- package/lib/commercelayer.js.map +1 -0
- package/lib/config.cjs +23 -0
- package/lib/config.cjs.map +1 -0
- package/lib/config.d.cts +19 -0
- package/lib/config.d.ts +19 -0
- package/lib/config.js +19 -0
- package/lib/config.js.map +1 -0
- package/lib/debug.cjs +21 -0
- package/lib/debug.cjs.map +1 -0
- package/lib/debug.d.cts +4 -0
- package/lib/debug.d.ts +4 -0
- package/lib/debug.js +17 -0
- package/lib/debug.js.map +1 -0
- package/lib/enum.cjs +659 -0
- package/lib/enum.cjs.map +1 -0
- package/lib/enum.d.cts +4 -0
- package/lib/enum.d.ts +4 -0
- package/lib/enum.js +643 -0
- package/lib/enum.js.map +1 -0
- package/lib/error.cjs +101 -0
- package/lib/error.cjs.map +1 -0
- package/lib/error.d.cts +38 -0
- package/lib/error.d.ts +38 -0
- package/lib/error.js +93 -0
- package/lib/error.js.map +1 -0
- package/lib/fetch.cjs +69 -0
- package/lib/fetch.cjs.map +1 -0
- package/lib/fetch.d.cts +1 -0
- package/lib/fetch.d.ts +1 -0
- package/lib/fetch.js +62 -0
- package/lib/fetch.js.map +1 -0
- package/lib/index.cjs +34 -2
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +7 -17201
- package/lib/index.d.ts +7 -17201
- package/lib/index.js +5 -2
- package/lib/index.js.map +1 -0
- package/lib/interceptor-5MISI1yn.d.cts +54 -0
- package/lib/interceptor-5MISI1yn.d.ts +54 -0
- package/lib/interceptor.cjs +4 -0
- package/lib/interceptor.cjs.map +1 -0
- package/lib/interceptor.d.cts +1 -0
- package/lib/interceptor.d.ts +1 -0
- package/lib/interceptor.js +3 -0
- package/lib/interceptor.js.map +1 -0
- package/lib/jsonapi.cjs +81 -0
- package/lib/jsonapi.cjs.map +1 -0
- package/lib/jsonapi.d.cts +11 -0
- package/lib/jsonapi.d.ts +11 -0
- package/lib/jsonapi.js +73 -0
- package/lib/jsonapi.js.map +1 -0
- package/lib/model.cjs +4 -0
- package/lib/model.cjs.map +1 -0
- package/lib/model.d.cts +4 -0
- package/lib/model.d.ts +4 -0
- package/lib/model.js +3 -0
- package/lib/model.js.map +1 -0
- package/lib/query.cjs +66 -0
- package/lib/query.cjs.map +1 -0
- package/lib/query.d.cts +4 -0
- package/lib/query.d.ts +4 -0
- package/lib/query.js +58 -0
- package/lib/query.js.map +1 -0
- package/lib/resource.cjs +218 -0
- package/lib/resource.cjs.map +1 -0
- package/lib/resource.d.cts +4 -0
- package/lib/resource.d.ts +4 -0
- package/lib/resource.js +206 -0
- package/lib/resource.js.map +1 -0
- package/lib/resources/addresses.cjs +58 -0
- package/lib/resources/addresses.cjs.map +1 -0
- package/lib/resources/addresses.d.cts +4 -0
- package/lib/resources/addresses.d.ts +4 -0
- package/lib/resources/addresses.js +54 -0
- package/lib/resources/addresses.js.map +1 -0
- package/lib/resources/adjustments.cjs +40 -0
- package/lib/resources/adjustments.cjs.map +1 -0
- package/lib/resources/adjustments.d.cts +4 -0
- package/lib/resources/adjustments.d.ts +4 -0
- package/lib/resources/adjustments.js +36 -0
- package/lib/resources/adjustments.js.map +1 -0
- package/lib/resources/adyen_gateways.cjs +48 -0
- package/lib/resources/adyen_gateways.cjs.map +1 -0
- package/lib/resources/adyen_gateways.d.cts +4 -0
- package/lib/resources/adyen_gateways.d.ts +4 -0
- package/lib/resources/adyen_gateways.js +44 -0
- package/lib/resources/adyen_gateways.js.map +1 -0
- package/lib/resources/adyen_payments.cjs +54 -0
- package/lib/resources/adyen_payments.cjs.map +1 -0
- package/lib/resources/adyen_payments.d.cts +4 -0
- package/lib/resources/adyen_payments.d.ts +4 -0
- package/lib/resources/adyen_payments.js +50 -0
- package/lib/resources/adyen_payments.js.map +1 -0
- package/lib/resources/applications.cjs +30 -0
- package/lib/resources/applications.cjs.map +1 -0
- package/lib/resources/applications.d.cts +4 -0
- package/lib/resources/applications.d.ts +4 -0
- package/lib/resources/applications.js +26 -0
- package/lib/resources/applications.js.map +1 -0
- package/lib/resources/attachments.cjs +36 -0
- package/lib/resources/attachments.cjs.map +1 -0
- package/lib/resources/attachments.d.cts +4 -0
- package/lib/resources/attachments.d.ts +4 -0
- package/lib/resources/attachments.js +32 -0
- package/lib/resources/attachments.js.map +1 -0
- package/lib/resources/authorizations.cjs +69 -0
- package/lib/resources/authorizations.cjs.map +1 -0
- package/lib/resources/authorizations.d.cts +4 -0
- package/lib/resources/authorizations.d.ts +4 -0
- package/lib/resources/authorizations.js +65 -0
- package/lib/resources/authorizations.js.map +1 -0
- package/lib/resources/avalara_accounts.cjs +56 -0
- package/lib/resources/avalara_accounts.cjs.map +1 -0
- package/lib/resources/avalara_accounts.d.cts +4 -0
- package/lib/resources/avalara_accounts.d.ts +4 -0
- package/lib/resources/avalara_accounts.js +52 -0
- package/lib/resources/avalara_accounts.js.map +1 -0
- package/lib/resources/axerve_gateways.cjs +48 -0
- package/lib/resources/axerve_gateways.cjs.map +1 -0
- package/lib/resources/axerve_gateways.d.cts +4 -0
- package/lib/resources/axerve_gateways.d.ts +4 -0
- package/lib/resources/axerve_gateways.js +44 -0
- package/lib/resources/axerve_gateways.js.map +1 -0
- package/lib/resources/axerve_payments.cjs +51 -0
- package/lib/resources/axerve_payments.cjs.map +1 -0
- package/lib/resources/axerve_payments.d.cts +4 -0
- package/lib/resources/axerve_payments.d.ts +4 -0
- package/lib/resources/axerve_payments.js +47 -0
- package/lib/resources/axerve_payments.js.map +1 -0
- package/lib/resources/bing_geocoders.cjs +48 -0
- package/lib/resources/bing_geocoders.cjs.map +1 -0
- package/lib/resources/bing_geocoders.d.cts +4 -0
- package/lib/resources/bing_geocoders.d.ts +4 -0
- package/lib/resources/bing_geocoders.js +44 -0
- package/lib/resources/bing_geocoders.js.map +1 -0
- package/lib/resources/braintree_gateways.cjs +48 -0
- package/lib/resources/braintree_gateways.cjs.map +1 -0
- package/lib/resources/braintree_gateways.d.cts +4 -0
- package/lib/resources/braintree_gateways.d.ts +4 -0
- package/lib/resources/braintree_gateways.js +44 -0
- package/lib/resources/braintree_gateways.js.map +1 -0
- package/lib/resources/braintree_payments.cjs +48 -0
- package/lib/resources/braintree_payments.cjs.map +1 -0
- package/lib/resources/braintree_payments.d.cts +4 -0
- package/lib/resources/braintree_payments.d.ts +4 -0
- package/lib/resources/braintree_payments.js +44 -0
- package/lib/resources/braintree_payments.js.map +1 -0
- package/lib/resources/bundles.cjs +76 -0
- package/lib/resources/bundles.cjs.map +1 -0
- package/lib/resources/bundles.d.cts +4 -0
- package/lib/resources/bundles.d.ts +4 -0
- package/lib/resources/bundles.js +72 -0
- package/lib/resources/bundles.js.map +1 -0
- package/lib/resources/buy_x_pay_y_promotions.cjs +96 -0
- package/lib/resources/buy_x_pay_y_promotions.cjs.map +1 -0
- package/lib/resources/buy_x_pay_y_promotions.d.cts +4 -0
- package/lib/resources/buy_x_pay_y_promotions.d.ts +4 -0
- package/lib/resources/buy_x_pay_y_promotions.js +92 -0
- package/lib/resources/buy_x_pay_y_promotions.js.map +1 -0
- package/lib/resources/captures.cjs +70 -0
- package/lib/resources/captures.cjs.map +1 -0
- package/lib/resources/captures.d.cts +4 -0
- package/lib/resources/captures.d.ts +4 -0
- package/lib/resources/captures.js +66 -0
- package/lib/resources/captures.js.map +1 -0
- package/lib/resources/carrier_accounts.cjs +48 -0
- package/lib/resources/carrier_accounts.cjs.map +1 -0
- package/lib/resources/carrier_accounts.d.cts +4 -0
- package/lib/resources/carrier_accounts.d.ts +4 -0
- package/lib/resources/carrier_accounts.js +44 -0
- package/lib/resources/carrier_accounts.js.map +1 -0
- package/lib/resources/checkout_com_gateways.cjs +48 -0
- package/lib/resources/checkout_com_gateways.cjs.map +1 -0
- package/lib/resources/checkout_com_gateways.d.cts +4 -0
- package/lib/resources/checkout_com_gateways.d.ts +4 -0
- package/lib/resources/checkout_com_gateways.js +44 -0
- package/lib/resources/checkout_com_gateways.js.map +1 -0
- package/lib/resources/checkout_com_payments.cjs +54 -0
- package/lib/resources/checkout_com_payments.cjs.map +1 -0
- package/lib/resources/checkout_com_payments.d.cts +4 -0
- package/lib/resources/checkout_com_payments.d.ts +4 -0
- package/lib/resources/checkout_com_payments.js +50 -0
- package/lib/resources/checkout_com_payments.js.map +1 -0
- package/lib/resources/cleanups.cjs +47 -0
- package/lib/resources/cleanups.cjs.map +1 -0
- package/lib/resources/cleanups.d.cts +4 -0
- package/lib/resources/cleanups.d.ts +4 -0
- package/lib/resources/cleanups.js +43 -0
- package/lib/resources/cleanups.js.map +1 -0
- package/lib/resources/coupon_codes_promotion_rules.cjs +44 -0
- package/lib/resources/coupon_codes_promotion_rules.cjs.map +1 -0
- package/lib/resources/coupon_codes_promotion_rules.d.cts +4 -0
- package/lib/resources/coupon_codes_promotion_rules.d.ts +4 -0
- package/lib/resources/coupon_codes_promotion_rules.js +40 -0
- package/lib/resources/coupon_codes_promotion_rules.js.map +1 -0
- package/lib/resources/coupon_recipients.cjs +48 -0
- package/lib/resources/coupon_recipients.cjs.map +1 -0
- package/lib/resources/coupon_recipients.d.cts +4 -0
- package/lib/resources/coupon_recipients.d.ts +4 -0
- package/lib/resources/coupon_recipients.js +44 -0
- package/lib/resources/coupon_recipients.js.map +1 -0
- package/lib/resources/coupons.cjs +62 -0
- package/lib/resources/coupons.cjs.map +1 -0
- package/lib/resources/coupons.d.cts +4 -0
- package/lib/resources/coupons.d.ts +4 -0
- package/lib/resources/coupons.js +58 -0
- package/lib/resources/coupons.js.map +1 -0
- package/lib/resources/custom_promotion_rules.cjs +40 -0
- package/lib/resources/custom_promotion_rules.cjs.map +1 -0
- package/lib/resources/custom_promotion_rules.d.cts +4 -0
- package/lib/resources/custom_promotion_rules.d.ts +4 -0
- package/lib/resources/custom_promotion_rules.js +36 -0
- package/lib/resources/custom_promotion_rules.js.map +1 -0
- package/lib/resources/customer_addresses.cjs +52 -0
- package/lib/resources/customer_addresses.cjs.map +1 -0
- package/lib/resources/customer_addresses.d.cts +4 -0
- package/lib/resources/customer_addresses.d.ts +4 -0
- package/lib/resources/customer_addresses.js +48 -0
- package/lib/resources/customer_addresses.js.map +1 -0
- package/lib/resources/customer_groups.cjs +52 -0
- package/lib/resources/customer_groups.cjs.map +1 -0
- package/lib/resources/customer_groups.d.cts +4 -0
- package/lib/resources/customer_groups.d.ts +4 -0
- package/lib/resources/customer_groups.js +48 -0
- package/lib/resources/customer_groups.js.map +1 -0
- package/lib/resources/customer_password_resets.cjs +47 -0
- package/lib/resources/customer_password_resets.cjs.map +1 -0
- package/lib/resources/customer_password_resets.d.cts +4 -0
- package/lib/resources/customer_password_resets.d.ts +4 -0
- package/lib/resources/customer_password_resets.js +43 -0
- package/lib/resources/customer_password_resets.js.map +1 -0
- package/lib/resources/customer_payment_sources.cjs +48 -0
- package/lib/resources/customer_payment_sources.cjs.map +1 -0
- package/lib/resources/customer_payment_sources.d.cts +4 -0
- package/lib/resources/customer_payment_sources.d.ts +4 -0
- package/lib/resources/customer_payment_sources.js +44 -0
- package/lib/resources/customer_payment_sources.js.map +1 -0
- package/lib/resources/customer_subscriptions.cjs +48 -0
- package/lib/resources/customer_subscriptions.cjs.map +1 -0
- package/lib/resources/customer_subscriptions.d.cts +4 -0
- package/lib/resources/customer_subscriptions.d.ts +4 -0
- package/lib/resources/customer_subscriptions.js +44 -0
- package/lib/resources/customer_subscriptions.js.map +1 -0
- package/lib/resources/customers.cjs +86 -0
- package/lib/resources/customers.cjs.map +1 -0
- package/lib/resources/customers.d.cts +4 -0
- package/lib/resources/customers.d.ts +4 -0
- package/lib/resources/customers.js +82 -0
- package/lib/resources/customers.js.map +1 -0
- package/lib/resources/delivery_lead_times.cjs +52 -0
- package/lib/resources/delivery_lead_times.cjs.map +1 -0
- package/lib/resources/delivery_lead_times.d.cts +4 -0
- package/lib/resources/delivery_lead_times.d.ts +4 -0
- package/lib/resources/delivery_lead_times.js +48 -0
- package/lib/resources/delivery_lead_times.js.map +1 -0
- package/lib/resources/discount_engine_items.cjs +35 -0
- package/lib/resources/discount_engine_items.cjs.map +1 -0
- package/lib/resources/discount_engine_items.d.cts +4 -0
- package/lib/resources/discount_engine_items.d.ts +4 -0
- package/lib/resources/discount_engine_items.js +31 -0
- package/lib/resources/discount_engine_items.js.map +1 -0
- package/lib/resources/discount_engines.cjs +43 -0
- package/lib/resources/discount_engines.cjs.map +1 -0
- package/lib/resources/discount_engines.d.cts +4 -0
- package/lib/resources/discount_engines.d.ts +4 -0
- package/lib/resources/discount_engines.js +39 -0
- package/lib/resources/discount_engines.js.map +1 -0
- package/lib/resources/easypost_pickups.cjs +51 -0
- package/lib/resources/easypost_pickups.cjs.map +1 -0
- package/lib/resources/easypost_pickups.d.cts +4 -0
- package/lib/resources/easypost_pickups.d.ts +4 -0
- package/lib/resources/easypost_pickups.js +47 -0
- package/lib/resources/easypost_pickups.js.map +1 -0
- package/lib/resources/event_callbacks.cjs +31 -0
- package/lib/resources/event_callbacks.cjs.map +1 -0
- package/lib/resources/event_callbacks.d.cts +4 -0
- package/lib/resources/event_callbacks.d.ts +4 -0
- package/lib/resources/event_callbacks.js +27 -0
- package/lib/resources/event_callbacks.js.map +1 -0
- package/lib/resources/events.cjs +41 -0
- package/lib/resources/events.cjs.map +1 -0
- package/lib/resources/events.d.cts +4 -0
- package/lib/resources/events.d.ts +4 -0
- package/lib/resources/events.js +37 -0
- package/lib/resources/events.js.map +1 -0
- package/lib/resources/exports.cjs +47 -0
- package/lib/resources/exports.cjs.map +1 -0
- package/lib/resources/exports.d.cts +4 -0
- package/lib/resources/exports.d.ts +4 -0
- package/lib/resources/exports.js +43 -0
- package/lib/resources/exports.js.map +1 -0
- package/lib/resources/external_gateways.cjs +51 -0
- package/lib/resources/external_gateways.cjs.map +1 -0
- package/lib/resources/external_gateways.d.cts +4 -0
- package/lib/resources/external_gateways.d.ts +4 -0
- package/lib/resources/external_gateways.js +47 -0
- package/lib/resources/external_gateways.js.map +1 -0
- package/lib/resources/external_payments.cjs +52 -0
- package/lib/resources/external_payments.cjs.map +1 -0
- package/lib/resources/external_payments.d.cts +4 -0
- package/lib/resources/external_payments.d.ts +4 -0
- package/lib/resources/external_payments.js +48 -0
- package/lib/resources/external_payments.js.map +1 -0
- package/lib/resources/external_promotions.cjs +99 -0
- package/lib/resources/external_promotions.cjs.map +1 -0
- package/lib/resources/external_promotions.d.cts +4 -0
- package/lib/resources/external_promotions.d.ts +4 -0
- package/lib/resources/external_promotions.js +95 -0
- package/lib/resources/external_promotions.js.map +1 -0
- package/lib/resources/external_tax_calculators.cjs +55 -0
- package/lib/resources/external_tax_calculators.cjs.map +1 -0
- package/lib/resources/external_tax_calculators.d.cts +4 -0
- package/lib/resources/external_tax_calculators.d.ts +4 -0
- package/lib/resources/external_tax_calculators.js +51 -0
- package/lib/resources/external_tax_calculators.js.map +1 -0
- package/lib/resources/fixed_amount_promotions.cjs +96 -0
- package/lib/resources/fixed_amount_promotions.cjs.map +1 -0
- package/lib/resources/fixed_amount_promotions.d.cts +4 -0
- package/lib/resources/fixed_amount_promotions.d.ts +4 -0
- package/lib/resources/fixed_amount_promotions.js +92 -0
- package/lib/resources/fixed_amount_promotions.js.map +1 -0
- package/lib/resources/fixed_price_promotions.cjs +96 -0
- package/lib/resources/fixed_price_promotions.cjs.map +1 -0
- package/lib/resources/fixed_price_promotions.d.cts +4 -0
- package/lib/resources/fixed_price_promotions.d.ts +4 -0
- package/lib/resources/fixed_price_promotions.js +92 -0
- package/lib/resources/fixed_price_promotions.js.map +1 -0
- package/lib/resources/flex_promotions.cjs +72 -0
- package/lib/resources/flex_promotions.cjs.map +1 -0
- package/lib/resources/flex_promotions.d.cts +4 -0
- package/lib/resources/flex_promotions.d.ts +4 -0
- package/lib/resources/flex_promotions.js +68 -0
- package/lib/resources/flex_promotions.js.map +1 -0
- package/lib/resources/free_gift_promotions.cjs +96 -0
- package/lib/resources/free_gift_promotions.cjs.map +1 -0
- package/lib/resources/free_gift_promotions.d.cts +4 -0
- package/lib/resources/free_gift_promotions.d.ts +4 -0
- package/lib/resources/free_gift_promotions.js +92 -0
- package/lib/resources/free_gift_promotions.js.map +1 -0
- package/lib/resources/free_shipping_promotions.cjs +92 -0
- package/lib/resources/free_shipping_promotions.cjs.map +1 -0
- package/lib/resources/free_shipping_promotions.d.cts +4 -0
- package/lib/resources/free_shipping_promotions.d.ts +4 -0
- package/lib/resources/free_shipping_promotions.js +88 -0
- package/lib/resources/free_shipping_promotions.js.map +1 -0
- package/lib/resources/geocoders.cjs +39 -0
- package/lib/resources/geocoders.cjs.map +1 -0
- package/lib/resources/geocoders.d.cts +4 -0
- package/lib/resources/geocoders.d.ts +4 -0
- package/lib/resources/geocoders.js +35 -0
- package/lib/resources/geocoders.js.map +1 -0
- package/lib/resources/gift_card_recipients.cjs +48 -0
- package/lib/resources/gift_card_recipients.cjs.map +1 -0
- package/lib/resources/gift_card_recipients.d.cts +4 -0
- package/lib/resources/gift_card_recipients.d.ts +4 -0
- package/lib/resources/gift_card_recipients.js +44 -0
- package/lib/resources/gift_card_recipients.js.map +1 -0
- package/lib/resources/gift_cards.cjs +78 -0
- package/lib/resources/gift_cards.cjs.map +1 -0
- package/lib/resources/gift_cards.d.cts +4 -0
- package/lib/resources/gift_cards.d.ts +4 -0
- package/lib/resources/gift_cards.js +74 -0
- package/lib/resources/gift_cards.js.map +1 -0
- package/lib/resources/google_geocoders.cjs +48 -0
- package/lib/resources/google_geocoders.cjs.map +1 -0
- package/lib/resources/google_geocoders.d.cts +4 -0
- package/lib/resources/google_geocoders.d.ts +4 -0
- package/lib/resources/google_geocoders.js +44 -0
- package/lib/resources/google_geocoders.js.map +1 -0
- package/lib/resources/imports.cjs +43 -0
- package/lib/resources/imports.cjs.map +1 -0
- package/lib/resources/imports.d.cts +4 -0
- package/lib/resources/imports.d.ts +4 -0
- package/lib/resources/imports.js +39 -0
- package/lib/resources/imports.js.map +1 -0
- package/lib/resources/in_stock_subscriptions.cjs +62 -0
- package/lib/resources/in_stock_subscriptions.cjs.map +1 -0
- package/lib/resources/in_stock_subscriptions.d.cts +4 -0
- package/lib/resources/in_stock_subscriptions.d.ts +4 -0
- package/lib/resources/in_stock_subscriptions.js +58 -0
- package/lib/resources/in_stock_subscriptions.js.map +1 -0
- package/lib/resources/inventory_models.cjs +52 -0
- package/lib/resources/inventory_models.cjs.map +1 -0
- package/lib/resources/inventory_models.d.cts +4 -0
- package/lib/resources/inventory_models.d.ts +4 -0
- package/lib/resources/inventory_models.js +48 -0
- package/lib/resources/inventory_models.js.map +1 -0
- package/lib/resources/inventory_return_locations.cjs +48 -0
- package/lib/resources/inventory_return_locations.cjs.map +1 -0
- package/lib/resources/inventory_return_locations.d.cts +4 -0
- package/lib/resources/inventory_return_locations.d.ts +4 -0
- package/lib/resources/inventory_return_locations.js +44 -0
- package/lib/resources/inventory_return_locations.js.map +1 -0
- package/lib/resources/inventory_stock_locations.cjs +48 -0
- package/lib/resources/inventory_stock_locations.cjs.map +1 -0
- package/lib/resources/inventory_stock_locations.d.cts +4 -0
- package/lib/resources/inventory_stock_locations.d.ts +4 -0
- package/lib/resources/inventory_stock_locations.js +44 -0
- package/lib/resources/inventory_stock_locations.js.map +1 -0
- package/lib/resources/klarna_gateways.cjs +48 -0
- package/lib/resources/klarna_gateways.cjs.map +1 -0
- package/lib/resources/klarna_gateways.d.cts +4 -0
- package/lib/resources/klarna_gateways.d.ts +4 -0
- package/lib/resources/klarna_gateways.js +44 -0
- package/lib/resources/klarna_gateways.js.map +1 -0
- package/lib/resources/klarna_payments.cjs +51 -0
- package/lib/resources/klarna_payments.cjs.map +1 -0
- package/lib/resources/klarna_payments.d.cts +4 -0
- package/lib/resources/klarna_payments.d.ts +4 -0
- package/lib/resources/klarna_payments.js +47 -0
- package/lib/resources/klarna_payments.js.map +1 -0
- package/lib/resources/line_item_options.cjs +58 -0
- package/lib/resources/line_item_options.cjs.map +1 -0
- package/lib/resources/line_item_options.d.cts +4 -0
- package/lib/resources/line_item_options.d.ts +4 -0
- package/lib/resources/line_item_options.js +54 -0
- package/lib/resources/line_item_options.js.map +1 -0
- package/lib/resources/line_items.cjs +87 -0
- package/lib/resources/line_items.cjs.map +1 -0
- package/lib/resources/line_items.d.cts +4 -0
- package/lib/resources/line_items.d.ts +4 -0
- package/lib/resources/line_items.js +83 -0
- package/lib/resources/line_items.js.map +1 -0
- package/lib/resources/links.cjs +46 -0
- package/lib/resources/links.cjs.map +1 -0
- package/lib/resources/links.d.cts +4 -0
- package/lib/resources/links.d.ts +4 -0
- package/lib/resources/links.js +42 -0
- package/lib/resources/links.js.map +1 -0
- package/lib/resources/manual_gateways.cjs +44 -0
- package/lib/resources/manual_gateways.cjs.map +1 -0
- package/lib/resources/manual_gateways.d.cts +4 -0
- package/lib/resources/manual_gateways.d.ts +4 -0
- package/lib/resources/manual_gateways.js +40 -0
- package/lib/resources/manual_gateways.js.map +1 -0
- package/lib/resources/manual_tax_calculators.cjs +56 -0
- package/lib/resources/manual_tax_calculators.cjs.map +1 -0
- package/lib/resources/manual_tax_calculators.d.cts +4 -0
- package/lib/resources/manual_tax_calculators.d.ts +4 -0
- package/lib/resources/manual_tax_calculators.js +52 -0
- package/lib/resources/manual_tax_calculators.js.map +1 -0
- package/lib/resources/markets.cjs +98 -0
- package/lib/resources/markets.cjs.map +1 -0
- package/lib/resources/markets.d.cts +4 -0
- package/lib/resources/markets.d.ts +4 -0
- package/lib/resources/markets.js +94 -0
- package/lib/resources/markets.js.map +1 -0
- package/lib/resources/merchants.cjs +48 -0
- package/lib/resources/merchants.cjs.map +1 -0
- package/lib/resources/merchants.d.cts +4 -0
- package/lib/resources/merchants.d.ts +4 -0
- package/lib/resources/merchants.js +44 -0
- package/lib/resources/merchants.js.map +1 -0
- package/lib/resources/notifications.cjs +36 -0
- package/lib/resources/notifications.cjs.map +1 -0
- package/lib/resources/notifications.d.cts +4 -0
- package/lib/resources/notifications.d.ts +4 -0
- package/lib/resources/notifications.js +32 -0
- package/lib/resources/notifications.js.map +1 -0
- package/lib/resources/order_amount_promotion_rules.cjs +40 -0
- package/lib/resources/order_amount_promotion_rules.cjs.map +1 -0
- package/lib/resources/order_amount_promotion_rules.d.cts +4 -0
- package/lib/resources/order_amount_promotion_rules.d.ts +4 -0
- package/lib/resources/order_amount_promotion_rules.js +36 -0
- package/lib/resources/order_amount_promotion_rules.js.map +1 -0
- package/lib/resources/order_copies.cjs +52 -0
- package/lib/resources/order_copies.cjs.map +1 -0
- package/lib/resources/order_copies.d.cts +4 -0
- package/lib/resources/order_copies.d.ts +4 -0
- package/lib/resources/order_copies.js +48 -0
- package/lib/resources/order_copies.js.map +1 -0
- package/lib/resources/order_factories.cjs +39 -0
- package/lib/resources/order_factories.cjs.map +1 -0
- package/lib/resources/order_factories.d.cts +4 -0
- package/lib/resources/order_factories.d.ts +4 -0
- package/lib/resources/order_factories.js +35 -0
- package/lib/resources/order_factories.js.map +1 -0
- package/lib/resources/order_subscription_items.cjs +44 -0
- package/lib/resources/order_subscription_items.cjs.map +1 -0
- package/lib/resources/order_subscription_items.d.cts +4 -0
- package/lib/resources/order_subscription_items.d.ts +4 -0
- package/lib/resources/order_subscription_items.js +40 -0
- package/lib/resources/order_subscription_items.js.map +1 -0
- package/lib/resources/order_subscriptions.cjs +102 -0
- package/lib/resources/order_subscriptions.cjs.map +1 -0
- package/lib/resources/order_subscriptions.d.cts +4 -0
- package/lib/resources/order_subscriptions.d.ts +4 -0
- package/lib/resources/order_subscriptions.js +98 -0
- package/lib/resources/order_subscriptions.js.map +1 -0
- package/lib/resources/orders.cjs +279 -0
- package/lib/resources/orders.cjs.map +1 -0
- package/lib/resources/orders.d.cts +4 -0
- package/lib/resources/orders.d.ts +4 -0
- package/lib/resources/orders.js +275 -0
- package/lib/resources/orders.js.map +1 -0
- package/lib/resources/organizations.cjs +30 -0
- package/lib/resources/organizations.cjs.map +1 -0
- package/lib/resources/organizations.d.cts +4 -0
- package/lib/resources/organizations.d.ts +4 -0
- package/lib/resources/organizations.js +26 -0
- package/lib/resources/organizations.js.map +1 -0
- package/lib/resources/packages.cjs +52 -0
- package/lib/resources/packages.cjs.map +1 -0
- package/lib/resources/packages.d.cts +4 -0
- package/lib/resources/packages.d.ts +4 -0
- package/lib/resources/packages.js +48 -0
- package/lib/resources/packages.js.map +1 -0
- package/lib/resources/parcel_line_items.cjs +48 -0
- package/lib/resources/parcel_line_items.cjs.map +1 -0
- package/lib/resources/parcel_line_items.d.cts +4 -0
- package/lib/resources/parcel_line_items.d.ts +4 -0
- package/lib/resources/parcel_line_items.js +44 -0
- package/lib/resources/parcel_line_items.js.map +1 -0
- package/lib/resources/parcels.cjs +60 -0
- package/lib/resources/parcels.cjs.map +1 -0
- package/lib/resources/parcels.d.cts +4 -0
- package/lib/resources/parcels.d.ts +4 -0
- package/lib/resources/parcels.js +56 -0
- package/lib/resources/parcels.js.map +1 -0
- package/lib/resources/payment_gateways.cjs +35 -0
- package/lib/resources/payment_gateways.cjs.map +1 -0
- package/lib/resources/payment_gateways.d.cts +4 -0
- package/lib/resources/payment_gateways.d.ts +4 -0
- package/lib/resources/payment_gateways.js +31 -0
- package/lib/resources/payment_gateways.js.map +1 -0
- package/lib/resources/payment_methods.cjs +66 -0
- package/lib/resources/payment_methods.cjs.map +1 -0
- package/lib/resources/payment_methods.d.cts +4 -0
- package/lib/resources/payment_methods.d.ts +4 -0
- package/lib/resources/payment_methods.js +62 -0
- package/lib/resources/payment_methods.js.map +1 -0
- package/lib/resources/payment_options.cjs +44 -0
- package/lib/resources/payment_options.cjs.map +1 -0
- package/lib/resources/payment_options.d.cts +4 -0
- package/lib/resources/payment_options.d.ts +4 -0
- package/lib/resources/payment_options.js +40 -0
- package/lib/resources/payment_options.js.map +1 -0
- package/lib/resources/paypal_gateways.cjs +48 -0
- package/lib/resources/paypal_gateways.cjs.map +1 -0
- package/lib/resources/paypal_gateways.d.cts +4 -0
- package/lib/resources/paypal_gateways.d.ts +4 -0
- package/lib/resources/paypal_gateways.js +44 -0
- package/lib/resources/paypal_gateways.js.map +1 -0
- package/lib/resources/paypal_payments.cjs +48 -0
- package/lib/resources/paypal_payments.cjs.map +1 -0
- package/lib/resources/paypal_payments.d.cts +4 -0
- package/lib/resources/paypal_payments.d.ts +4 -0
- package/lib/resources/paypal_payments.js +44 -0
- package/lib/resources/paypal_payments.js.map +1 -0
- package/lib/resources/percentage_discount_promotions.cjs +96 -0
- package/lib/resources/percentage_discount_promotions.cjs.map +1 -0
- package/lib/resources/percentage_discount_promotions.d.cts +4 -0
- package/lib/resources/percentage_discount_promotions.d.ts +4 -0
- package/lib/resources/percentage_discount_promotions.js +92 -0
- package/lib/resources/percentage_discount_promotions.js.map +1 -0
- package/lib/resources/pickups.cjs +39 -0
- package/lib/resources/pickups.cjs.map +1 -0
- package/lib/resources/pickups.d.cts +4 -0
- package/lib/resources/pickups.d.ts +4 -0
- package/lib/resources/pickups.js +35 -0
- package/lib/resources/pickups.js.map +1 -0
- package/lib/resources/price_frequency_tiers.cjs +52 -0
- package/lib/resources/price_frequency_tiers.cjs.map +1 -0
- package/lib/resources/price_frequency_tiers.d.cts +4 -0
- package/lib/resources/price_frequency_tiers.d.ts +4 -0
- package/lib/resources/price_frequency_tiers.js +48 -0
- package/lib/resources/price_frequency_tiers.js.map +1 -0
- package/lib/resources/price_list_schedulers.cjs +58 -0
- package/lib/resources/price_list_schedulers.cjs.map +1 -0
- package/lib/resources/price_list_schedulers.d.cts +4 -0
- package/lib/resources/price_list_schedulers.d.ts +4 -0
- package/lib/resources/price_list_schedulers.js +54 -0
- package/lib/resources/price_list_schedulers.js.map +1 -0
- package/lib/resources/price_lists.cjs +52 -0
- package/lib/resources/price_lists.cjs.map +1 -0
- package/lib/resources/price_lists.d.cts +4 -0
- package/lib/resources/price_lists.d.ts +4 -0
- package/lib/resources/price_lists.js +48 -0
- package/lib/resources/price_lists.js.map +1 -0
- package/lib/resources/price_tiers.cjs +39 -0
- package/lib/resources/price_tiers.cjs.map +1 -0
- package/lib/resources/price_tiers.d.cts +4 -0
- package/lib/resources/price_tiers.d.ts +4 -0
- package/lib/resources/price_tiers.js +35 -0
- package/lib/resources/price_tiers.js.map +1 -0
- package/lib/resources/price_volume_tiers.cjs +52 -0
- package/lib/resources/price_volume_tiers.cjs.map +1 -0
- package/lib/resources/price_volume_tiers.d.cts +4 -0
- package/lib/resources/price_volume_tiers.d.ts +4 -0
- package/lib/resources/price_volume_tiers.js +48 -0
- package/lib/resources/price_volume_tiers.js.map +1 -0
- package/lib/resources/prices.cjs +76 -0
- package/lib/resources/prices.cjs.map +1 -0
- package/lib/resources/prices.d.cts +4 -0
- package/lib/resources/prices.d.ts +4 -0
- package/lib/resources/prices.js +72 -0
- package/lib/resources/prices.js.map +1 -0
- package/lib/resources/promotion_rules.cjs +31 -0
- package/lib/resources/promotion_rules.cjs.map +1 -0
- package/lib/resources/promotion_rules.d.cts +4 -0
- package/lib/resources/promotion_rules.d.ts +4 -0
- package/lib/resources/promotion_rules.js +27 -0
- package/lib/resources/promotion_rules.js.map +1 -0
- package/lib/resources/promotions.cjs +71 -0
- package/lib/resources/promotions.cjs.map +1 -0
- package/lib/resources/promotions.d.cts +4 -0
- package/lib/resources/promotions.d.ts +4 -0
- package/lib/resources/promotions.js +67 -0
- package/lib/resources/promotions.js.map +1 -0
- package/lib/resources/recurring_order_copies.cjs +52 -0
- package/lib/resources/recurring_order_copies.cjs.map +1 -0
- package/lib/resources/recurring_order_copies.d.cts +4 -0
- package/lib/resources/recurring_order_copies.d.ts +4 -0
- package/lib/resources/recurring_order_copies.js +48 -0
- package/lib/resources/recurring_order_copies.js.map +1 -0
- package/lib/resources/refunds.cjs +57 -0
- package/lib/resources/refunds.cjs.map +1 -0
- package/lib/resources/refunds.d.cts +4 -0
- package/lib/resources/refunds.d.ts +4 -0
- package/lib/resources/refunds.js +53 -0
- package/lib/resources/refunds.js.map +1 -0
- package/lib/resources/reserved_stocks.cjs +43 -0
- package/lib/resources/reserved_stocks.cjs.map +1 -0
- package/lib/resources/reserved_stocks.d.cts +4 -0
- package/lib/resources/reserved_stocks.d.ts +4 -0
- package/lib/resources/reserved_stocks.js +39 -0
- package/lib/resources/reserved_stocks.js.map +1 -0
- package/lib/resources/resource_errors.cjs +27 -0
- package/lib/resources/resource_errors.cjs.map +1 -0
- package/lib/resources/resource_errors.d.cts +4 -0
- package/lib/resources/resource_errors.d.ts +4 -0
- package/lib/resources/resource_errors.js +23 -0
- package/lib/resources/resource_errors.js.map +1 -0
- package/lib/resources/return_line_items.cjs +47 -0
- package/lib/resources/return_line_items.cjs.map +1 -0
- package/lib/resources/return_line_items.d.cts +4 -0
- package/lib/resources/return_line_items.d.ts +4 -0
- package/lib/resources/return_line_items.js +43 -0
- package/lib/resources/return_line_items.js.map +1 -0
- package/lib/resources/returns.cjs +127 -0
- package/lib/resources/returns.cjs.map +1 -0
- package/lib/resources/returns.d.cts +4 -0
- package/lib/resources/returns.d.ts +4 -0
- package/lib/resources/returns.js +123 -0
- package/lib/resources/returns.js.map +1 -0
- package/lib/resources/satispay_gateways.cjs +48 -0
- package/lib/resources/satispay_gateways.cjs.map +1 -0
- package/lib/resources/satispay_gateways.d.cts +4 -0
- package/lib/resources/satispay_gateways.d.ts +4 -0
- package/lib/resources/satispay_gateways.js +44 -0
- package/lib/resources/satispay_gateways.js.map +1 -0
- package/lib/resources/satispay_payments.cjs +51 -0
- package/lib/resources/satispay_payments.cjs.map +1 -0
- package/lib/resources/satispay_payments.d.cts +4 -0
- package/lib/resources/satispay_payments.d.ts +4 -0
- package/lib/resources/satispay_payments.js +47 -0
- package/lib/resources/satispay_payments.js.map +1 -0
- package/lib/resources/shipments.cjs +157 -0
- package/lib/resources/shipments.cjs.map +1 -0
- package/lib/resources/shipments.d.cts +4 -0
- package/lib/resources/shipments.d.ts +4 -0
- package/lib/resources/shipments.js +153 -0
- package/lib/resources/shipments.js.map +1 -0
- package/lib/resources/shipping_categories.cjs +48 -0
- package/lib/resources/shipping_categories.cjs.map +1 -0
- package/lib/resources/shipping_categories.d.cts +4 -0
- package/lib/resources/shipping_categories.d.ts +4 -0
- package/lib/resources/shipping_categories.js +44 -0
- package/lib/resources/shipping_categories.js.map +1 -0
- package/lib/resources/shipping_method_tiers.cjs +39 -0
- package/lib/resources/shipping_method_tiers.cjs.map +1 -0
- package/lib/resources/shipping_method_tiers.d.cts +4 -0
- package/lib/resources/shipping_method_tiers.d.ts +4 -0
- package/lib/resources/shipping_method_tiers.js +35 -0
- package/lib/resources/shipping_method_tiers.js.map +1 -0
- package/lib/resources/shipping_methods.cjs +85 -0
- package/lib/resources/shipping_methods.cjs.map +1 -0
- package/lib/resources/shipping_methods.d.cts +4 -0
- package/lib/resources/shipping_methods.d.ts +4 -0
- package/lib/resources/shipping_methods.js +81 -0
- package/lib/resources/shipping_methods.js.map +1 -0
- package/lib/resources/shipping_weight_tiers.cjs +48 -0
- package/lib/resources/shipping_weight_tiers.cjs.map +1 -0
- package/lib/resources/shipping_weight_tiers.d.cts +4 -0
- package/lib/resources/shipping_weight_tiers.d.ts +4 -0
- package/lib/resources/shipping_weight_tiers.js +44 -0
- package/lib/resources/shipping_weight_tiers.js.map +1 -0
- package/lib/resources/shipping_zones.cjs +44 -0
- package/lib/resources/shipping_zones.cjs.map +1 -0
- package/lib/resources/shipping_zones.d.cts +4 -0
- package/lib/resources/shipping_zones.d.ts +4 -0
- package/lib/resources/shipping_zones.js +40 -0
- package/lib/resources/shipping_zones.js.map +1 -0
- package/lib/resources/sku_list_items.cjs +48 -0
- package/lib/resources/sku_list_items.cjs.map +1 -0
- package/lib/resources/sku_list_items.d.cts +4 -0
- package/lib/resources/sku_list_items.d.ts +4 -0
- package/lib/resources/sku_list_items.js +44 -0
- package/lib/resources/sku_list_items.js.map +1 -0
- package/lib/resources/sku_list_promotion_rules.cjs +48 -0
- package/lib/resources/sku_list_promotion_rules.cjs.map +1 -0
- package/lib/resources/sku_list_promotion_rules.d.cts +4 -0
- package/lib/resources/sku_list_promotion_rules.d.ts +4 -0
- package/lib/resources/sku_list_promotion_rules.js +44 -0
- package/lib/resources/sku_list_promotion_rules.js.map +1 -0
- package/lib/resources/sku_lists.cjs +64 -0
- package/lib/resources/sku_lists.cjs.map +1 -0
- package/lib/resources/sku_lists.d.cts +4 -0
- package/lib/resources/sku_lists.d.ts +4 -0
- package/lib/resources/sku_lists.js +60 -0
- package/lib/resources/sku_lists.js.map +1 -0
- package/lib/resources/sku_options.cjs +62 -0
- package/lib/resources/sku_options.cjs.map +1 -0
- package/lib/resources/sku_options.d.cts +4 -0
- package/lib/resources/sku_options.d.ts +4 -0
- package/lib/resources/sku_options.js +58 -0
- package/lib/resources/sku_options.js.map +1 -0
- package/lib/resources/skus.cjs +106 -0
- package/lib/resources/skus.cjs.map +1 -0
- package/lib/resources/skus.d.cts +4 -0
- package/lib/resources/skus.d.ts +4 -0
- package/lib/resources/skus.js +102 -0
- package/lib/resources/skus.js.map +1 -0
- package/lib/resources/stock_items.cjs +63 -0
- package/lib/resources/stock_items.cjs.map +1 -0
- package/lib/resources/stock_items.d.cts +4 -0
- package/lib/resources/stock_items.d.ts +4 -0
- package/lib/resources/stock_items.js +59 -0
- package/lib/resources/stock_items.js.map +1 -0
- package/lib/resources/stock_line_items.cjs +69 -0
- package/lib/resources/stock_line_items.cjs.map +1 -0
- package/lib/resources/stock_line_items.d.cts +4 -0
- package/lib/resources/stock_line_items.d.ts +4 -0
- package/lib/resources/stock_line_items.js +65 -0
- package/lib/resources/stock_line_items.js.map +1 -0
- package/lib/resources/stock_locations.cjs +68 -0
- package/lib/resources/stock_locations.cjs.map +1 -0
- package/lib/resources/stock_locations.d.cts +4 -0
- package/lib/resources/stock_locations.d.ts +4 -0
- package/lib/resources/stock_locations.js +64 -0
- package/lib/resources/stock_locations.js.map +1 -0
- package/lib/resources/stock_reservations.cjs +67 -0
- package/lib/resources/stock_reservations.cjs.map +1 -0
- package/lib/resources/stock_reservations.d.cts +4 -0
- package/lib/resources/stock_reservations.d.ts +4 -0
- package/lib/resources/stock_reservations.js +63 -0
- package/lib/resources/stock_reservations.js.map +1 -0
- package/lib/resources/stock_transfers.cjs +90 -0
- package/lib/resources/stock_transfers.cjs.map +1 -0
- package/lib/resources/stock_transfers.d.cts +4 -0
- package/lib/resources/stock_transfers.d.ts +4 -0
- package/lib/resources/stock_transfers.js +86 -0
- package/lib/resources/stock_transfers.js.map +1 -0
- package/lib/resources/stores.cjs +64 -0
- package/lib/resources/stores.cjs.map +1 -0
- package/lib/resources/stores.d.cts +4 -0
- package/lib/resources/stores.d.ts +4 -0
- package/lib/resources/stores.js +60 -0
- package/lib/resources/stores.js.map +1 -0
- package/lib/resources/stripe_gateways.cjs +48 -0
- package/lib/resources/stripe_gateways.cjs.map +1 -0
- package/lib/resources/stripe_gateways.d.cts +4 -0
- package/lib/resources/stripe_gateways.d.ts +4 -0
- package/lib/resources/stripe_gateways.js +44 -0
- package/lib/resources/stripe_gateways.js.map +1 -0
- package/lib/resources/stripe_payments.cjs +54 -0
- package/lib/resources/stripe_payments.cjs.map +1 -0
- package/lib/resources/stripe_payments.d.cts +4 -0
- package/lib/resources/stripe_payments.d.ts +4 -0
- package/lib/resources/stripe_payments.js +50 -0
- package/lib/resources/stripe_payments.js.map +1 -0
- package/lib/resources/stripe_tax_accounts.cjs +56 -0
- package/lib/resources/stripe_tax_accounts.cjs.map +1 -0
- package/lib/resources/stripe_tax_accounts.d.cts +4 -0
- package/lib/resources/stripe_tax_accounts.d.ts +4 -0
- package/lib/resources/stripe_tax_accounts.js +52 -0
- package/lib/resources/stripe_tax_accounts.js.map +1 -0
- package/lib/resources/subscription_models.cjs +48 -0
- package/lib/resources/subscription_models.cjs.map +1 -0
- package/lib/resources/subscription_models.d.cts +4 -0
- package/lib/resources/subscription_models.d.ts +4 -0
- package/lib/resources/subscription_models.js +44 -0
- package/lib/resources/subscription_models.js.map +1 -0
- package/lib/resources/tags.cjs +36 -0
- package/lib/resources/tags.cjs.map +1 -0
- package/lib/resources/tags.d.cts +4 -0
- package/lib/resources/tags.d.ts +4 -0
- package/lib/resources/tags.js +32 -0
- package/lib/resources/tags.js.map +1 -0
- package/lib/resources/talon_one_accounts.cjs +52 -0
- package/lib/resources/talon_one_accounts.cjs.map +1 -0
- package/lib/resources/talon_one_accounts.d.cts +4 -0
- package/lib/resources/talon_one_accounts.d.ts +4 -0
- package/lib/resources/talon_one_accounts.js +48 -0
- package/lib/resources/talon_one_accounts.js.map +1 -0
- package/lib/resources/tax_calculators.cjs +43 -0
- package/lib/resources/tax_calculators.cjs.map +1 -0
- package/lib/resources/tax_calculators.d.cts +4 -0
- package/lib/resources/tax_calculators.d.ts +4 -0
- package/lib/resources/tax_calculators.js +39 -0
- package/lib/resources/tax_calculators.js.map +1 -0
- package/lib/resources/tax_categories.cjs +48 -0
- package/lib/resources/tax_categories.cjs.map +1 -0
- package/lib/resources/tax_categories.d.cts +4 -0
- package/lib/resources/tax_categories.d.ts +4 -0
- package/lib/resources/tax_categories.js +44 -0
- package/lib/resources/tax_categories.js.map +1 -0
- package/lib/resources/tax_rules.cjs +44 -0
- package/lib/resources/tax_rules.cjs.map +1 -0
- package/lib/resources/tax_rules.d.cts +4 -0
- package/lib/resources/tax_rules.d.ts +4 -0
- package/lib/resources/tax_rules.js +40 -0
- package/lib/resources/tax_rules.js.map +1 -0
- package/lib/resources/taxjar_accounts.cjs +56 -0
- package/lib/resources/taxjar_accounts.cjs.map +1 -0
- package/lib/resources/taxjar_accounts.d.cts +4 -0
- package/lib/resources/taxjar_accounts.d.ts +4 -0
- package/lib/resources/taxjar_accounts.js +52 -0
- package/lib/resources/taxjar_accounts.js.map +1 -0
- package/lib/resources/transactions.cjs +43 -0
- package/lib/resources/transactions.cjs.map +1 -0
- package/lib/resources/transactions.d.cts +4 -0
- package/lib/resources/transactions.d.ts +4 -0
- package/lib/resources/transactions.js +39 -0
- package/lib/resources/transactions.js.map +1 -0
- package/lib/resources/versions.cjs +27 -0
- package/lib/resources/versions.cjs.map +1 -0
- package/lib/resources/versions.d.cts +4 -0
- package/lib/resources/versions.d.ts +4 -0
- package/lib/resources/versions.js +23 -0
- package/lib/resources/versions.js.map +1 -0
- package/lib/resources/vertex_accounts.cjs +55 -0
- package/lib/resources/vertex_accounts.cjs.map +1 -0
- package/lib/resources/vertex_accounts.d.cts +4 -0
- package/lib/resources/vertex_accounts.d.ts +4 -0
- package/lib/resources/vertex_accounts.js +51 -0
- package/lib/resources/vertex_accounts.js.map +1 -0
- package/lib/resources/voids.cjs +53 -0
- package/lib/resources/voids.cjs.map +1 -0
- package/lib/resources/voids.d.cts +4 -0
- package/lib/resources/voids.d.ts +4 -0
- package/lib/resources/voids.js +49 -0
- package/lib/resources/voids.js.map +1 -0
- package/lib/resources/webhooks.cjs +53 -0
- package/lib/resources/webhooks.cjs.map +1 -0
- package/lib/resources/webhooks.d.cts +4 -0
- package/lib/resources/webhooks.d.ts +4 -0
- package/lib/resources/webhooks.js +49 -0
- package/lib/resources/webhooks.js.map +1 -0
- package/lib/resources/wire_transfers.cjs +44 -0
- package/lib/resources/wire_transfers.cjs.map +1 -0
- package/lib/resources/wire_transfers.d.cts +4 -0
- package/lib/resources/wire_transfers.d.ts +4 -0
- package/lib/resources/wire_transfers.js +40 -0
- package/lib/resources/wire_transfers.js.map +1 -0
- package/lib/static.cjs +49 -0
- package/lib/static.cjs.map +1 -0
- package/lib/static.d.cts +22 -0
- package/lib/static.d.ts +22 -0
- package/lib/static.js +47 -0
- package/lib/static.js.map +1 -0
- package/lib/types.cjs +4 -0
- package/lib/types.cjs.map +1 -0
- package/lib/types.d.cts +7 -0
- package/lib/types.d.ts +7 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/util.cjs +39 -0
- package/lib/util.cjs.map +1 -0
- package/lib/util.d.cts +13 -0
- package/lib/util.d.ts +13 -0
- package/lib/util.js +34 -0
- package/lib/util.js.map +1 -0
- package/package.json +8 -10
package/lib/api.cjs.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"api.cjs","sourcesContent":[]}
|
package/lib/api.d.cts
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
export { E as addresses, F as adjustments, G as adyen_gateways, H as adyen_payments, I as application, J as attachments, K as authorizations, N as avalara_accounts, O as axerve_gateways, P as axerve_payments, S as bing_geocoders, W as braintree_gateways, X as braintree_payments, Y as bundles, Z as buy_x_pay_y_promotions, _ as captures, $ as carrier_accounts, a0 as checkout_com_gateways, a1 as checkout_com_payments, a2 as cleanups, a3 as coupon_codes_promotion_rules, a4 as coupon_recipients, a5 as coupons, a6 as custom_promotion_rules, a7 as customer_addresses, a8 as customer_groups, a9 as customer_password_resets, aa as customer_payment_sources, ab as customer_subscriptions, ac as customers, ad as delivery_lead_times, ae as discount_engine_items, af as discount_engines, ag as easypost_pickups, ah as event_callbacks, ai as events, aj as exports, ak as external_gateways, al as external_payments, am as external_promotions, an as external_tax_calculators, ao as fixed_amount_promotions, ap as fixed_price_promotions, aq as flex_promotions, ar as free_gift_promotions, as as free_shipping_promotions, at as geocoders, au as gift_card_recipients, av as gift_cards, aw as google_geocoders, ax as imports, ay as in_stock_subscriptions, az as inventory_models, aA as inventory_return_locations, aB as inventory_stock_locations, aC as klarna_gateways, aD as klarna_payments, aE as line_item_options, aF as line_items, aG as links, aH as manual_gateways, aI as manual_tax_calculators, aJ as markets, aK as merchants, aL as notifications, aM as order_amount_promotion_rules, aN as order_copies, aO as order_factories, aP as order_subscription_items, aQ as order_subscriptions, aR as orders, aS as organization, aT as packages, aU as parcel_line_items, aV as parcels, aW as payment_gateways, aX as payment_methods, aY as payment_options, aZ as paypal_gateways, a_ as paypal_payments, a$ as percentage_discount_promotions, b0 as pickups, b1 as price_frequency_tiers, b2 as price_list_schedulers, b3 as price_lists, b4 as price_tiers, b5 as price_volume_tiers, b6 as prices, b7 as promotion_rules, b8 as promotions, b9 as recurring_order_copies, ba as refunds, bb as reserved_stocks, bc as resource_errors, bd as return_line_items, be as returns, bf as satispay_gateways, bg as satispay_payments, bh as shipments, bi as shipping_categories, bj as shipping_method_tiers, bk as shipping_methods, bl as shipping_weight_tiers, bm as shipping_zones, bn as sku_list_items, bo as sku_list_promotion_rules, bp as sku_lists, bq as sku_options, br as skus, bs as stock_items, bt as stock_line_items, bu as stock_locations, bv as stock_reservations, bw as stock_transfers, bx as stores, by as stripe_gateways, bz as stripe_payments, bA as stripe_tax_accounts, bB as subscription_models, bC as tags, bD as talon_one_accounts, bE as tax_calculators, bF as tax_categories, bG as tax_rules, bH as taxjar_accounts, bI as transactions, bJ as versions, bK as vertex_accounts, bL as voids, bM as webhooks, bN as wire_transfers } from './api-DmIZO_Np.cjs';
|
2
|
+
import './client.cjs';
|
3
|
+
import './interceptor-5MISI1yn.cjs';
|
4
|
+
import './types.cjs';
|
package/lib/api.d.ts
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
export { E as addresses, F as adjustments, G as adyen_gateways, H as adyen_payments, I as application, J as attachments, K as authorizations, N as avalara_accounts, O as axerve_gateways, P as axerve_payments, S as bing_geocoders, W as braintree_gateways, X as braintree_payments, Y as bundles, Z as buy_x_pay_y_promotions, _ as captures, $ as carrier_accounts, a0 as checkout_com_gateways, a1 as checkout_com_payments, a2 as cleanups, a3 as coupon_codes_promotion_rules, a4 as coupon_recipients, a5 as coupons, a6 as custom_promotion_rules, a7 as customer_addresses, a8 as customer_groups, a9 as customer_password_resets, aa as customer_payment_sources, ab as customer_subscriptions, ac as customers, ad as delivery_lead_times, ae as discount_engine_items, af as discount_engines, ag as easypost_pickups, ah as event_callbacks, ai as events, aj as exports, ak as external_gateways, al as external_payments, am as external_promotions, an as external_tax_calculators, ao as fixed_amount_promotions, ap as fixed_price_promotions, aq as flex_promotions, ar as free_gift_promotions, as as free_shipping_promotions, at as geocoders, au as gift_card_recipients, av as gift_cards, aw as google_geocoders, ax as imports, ay as in_stock_subscriptions, az as inventory_models, aA as inventory_return_locations, aB as inventory_stock_locations, aC as klarna_gateways, aD as klarna_payments, aE as line_item_options, aF as line_items, aG as links, aH as manual_gateways, aI as manual_tax_calculators, aJ as markets, aK as merchants, aL as notifications, aM as order_amount_promotion_rules, aN as order_copies, aO as order_factories, aP as order_subscription_items, aQ as order_subscriptions, aR as orders, aS as organization, aT as packages, aU as parcel_line_items, aV as parcels, aW as payment_gateways, aX as payment_methods, aY as payment_options, aZ as paypal_gateways, a_ as paypal_payments, a$ as percentage_discount_promotions, b0 as pickups, b1 as price_frequency_tiers, b2 as price_list_schedulers, b3 as price_lists, b4 as price_tiers, b5 as price_volume_tiers, b6 as prices, b7 as promotion_rules, b8 as promotions, b9 as recurring_order_copies, ba as refunds, bb as reserved_stocks, bc as resource_errors, bd as return_line_items, be as returns, bf as satispay_gateways, bg as satispay_payments, bh as shipments, bi as shipping_categories, bj as shipping_method_tiers, bk as shipping_methods, bl as shipping_weight_tiers, bm as shipping_zones, bn as sku_list_items, bo as sku_list_promotion_rules, bp as sku_lists, bq as sku_options, br as skus, bs as stock_items, bt as stock_line_items, bu as stock_locations, bv as stock_reservations, bw as stock_transfers, bx as stores, by as stripe_gateways, bz as stripe_payments, bA as stripe_tax_accounts, bB as subscription_models, bC as tags, bD as talon_one_accounts, bE as tax_calculators, bF as tax_categories, bG as tax_rules, bH as taxjar_accounts, bI as transactions, bJ as versions, bK as vertex_accounts, bL as voids, bM as webhooks, bN as wire_transfers } from './api-DDgIE2i8.js';
|
2
|
+
import './client.js';
|
3
|
+
import './interceptor-5MISI1yn.js';
|
4
|
+
import './types.js';
|
package/lib/api.js
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
export { default as addresses } from './resources/addresses';
|
2
|
+
export { default as adjustments } from './resources/adjustments';
|
3
|
+
export { default as adyen_gateways } from './resources/adyen_gateways';
|
4
|
+
export { default as adyen_payments } from './resources/adyen_payments';
|
5
|
+
export { default as application } from './resources/applications';
|
6
|
+
export { default as attachments } from './resources/attachments';
|
7
|
+
export { default as authorizations } from './resources/authorizations';
|
8
|
+
export { default as avalara_accounts } from './resources/avalara_accounts';
|
9
|
+
export { default as axerve_gateways } from './resources/axerve_gateways';
|
10
|
+
export { default as axerve_payments } from './resources/axerve_payments';
|
11
|
+
export { default as bing_geocoders } from './resources/bing_geocoders';
|
12
|
+
export { default as braintree_gateways } from './resources/braintree_gateways';
|
13
|
+
export { default as braintree_payments } from './resources/braintree_payments';
|
14
|
+
export { default as bundles } from './resources/bundles';
|
15
|
+
export { default as buy_x_pay_y_promotions } from './resources/buy_x_pay_y_promotions';
|
16
|
+
export { default as captures } from './resources/captures';
|
17
|
+
export { default as carrier_accounts } from './resources/carrier_accounts';
|
18
|
+
export { default as checkout_com_gateways } from './resources/checkout_com_gateways';
|
19
|
+
export { default as checkout_com_payments } from './resources/checkout_com_payments';
|
20
|
+
export { default as cleanups } from './resources/cleanups';
|
21
|
+
export { default as coupon_codes_promotion_rules } from './resources/coupon_codes_promotion_rules';
|
22
|
+
export { default as coupon_recipients } from './resources/coupon_recipients';
|
23
|
+
export { default as coupons } from './resources/coupons';
|
24
|
+
export { default as custom_promotion_rules } from './resources/custom_promotion_rules';
|
25
|
+
export { default as customer_addresses } from './resources/customer_addresses';
|
26
|
+
export { default as customer_groups } from './resources/customer_groups';
|
27
|
+
export { default as customer_password_resets } from './resources/customer_password_resets';
|
28
|
+
export { default as customer_payment_sources } from './resources/customer_payment_sources';
|
29
|
+
export { default as customer_subscriptions } from './resources/customer_subscriptions';
|
30
|
+
export { default as customers } from './resources/customers';
|
31
|
+
export { default as delivery_lead_times } from './resources/delivery_lead_times';
|
32
|
+
export { default as discount_engine_items } from './resources/discount_engine_items';
|
33
|
+
export { default as discount_engines } from './resources/discount_engines';
|
34
|
+
export { default as easypost_pickups } from './resources/easypost_pickups';
|
35
|
+
export { default as event_callbacks } from './resources/event_callbacks';
|
36
|
+
export { default as events } from './resources/events';
|
37
|
+
export { default as exports } from './resources/exports';
|
38
|
+
export { default as external_gateways } from './resources/external_gateways';
|
39
|
+
export { default as external_payments } from './resources/external_payments';
|
40
|
+
export { default as external_promotions } from './resources/external_promotions';
|
41
|
+
export { default as external_tax_calculators } from './resources/external_tax_calculators';
|
42
|
+
export { default as fixed_amount_promotions } from './resources/fixed_amount_promotions';
|
43
|
+
export { default as fixed_price_promotions } from './resources/fixed_price_promotions';
|
44
|
+
export { default as flex_promotions } from './resources/flex_promotions';
|
45
|
+
export { default as free_gift_promotions } from './resources/free_gift_promotions';
|
46
|
+
export { default as free_shipping_promotions } from './resources/free_shipping_promotions';
|
47
|
+
export { default as geocoders } from './resources/geocoders';
|
48
|
+
export { default as gift_card_recipients } from './resources/gift_card_recipients';
|
49
|
+
export { default as gift_cards } from './resources/gift_cards';
|
50
|
+
export { default as google_geocoders } from './resources/google_geocoders';
|
51
|
+
export { default as imports } from './resources/imports';
|
52
|
+
export { default as in_stock_subscriptions } from './resources/in_stock_subscriptions';
|
53
|
+
export { default as inventory_models } from './resources/inventory_models';
|
54
|
+
export { default as inventory_return_locations } from './resources/inventory_return_locations';
|
55
|
+
export { default as inventory_stock_locations } from './resources/inventory_stock_locations';
|
56
|
+
export { default as klarna_gateways } from './resources/klarna_gateways';
|
57
|
+
export { default as klarna_payments } from './resources/klarna_payments';
|
58
|
+
export { default as line_item_options } from './resources/line_item_options';
|
59
|
+
export { default as line_items } from './resources/line_items';
|
60
|
+
export { default as links } from './resources/links';
|
61
|
+
export { default as manual_gateways } from './resources/manual_gateways';
|
62
|
+
export { default as manual_tax_calculators } from './resources/manual_tax_calculators';
|
63
|
+
export { default as markets } from './resources/markets';
|
64
|
+
export { default as merchants } from './resources/merchants';
|
65
|
+
export { default as notifications } from './resources/notifications';
|
66
|
+
export { default as order_amount_promotion_rules } from './resources/order_amount_promotion_rules';
|
67
|
+
export { default as order_copies } from './resources/order_copies';
|
68
|
+
export { default as order_factories } from './resources/order_factories';
|
69
|
+
export { default as order_subscription_items } from './resources/order_subscription_items';
|
70
|
+
export { default as order_subscriptions } from './resources/order_subscriptions';
|
71
|
+
export { default as orders } from './resources/orders';
|
72
|
+
export { default as organization } from './resources/organizations';
|
73
|
+
export { default as packages } from './resources/packages';
|
74
|
+
export { default as parcel_line_items } from './resources/parcel_line_items';
|
75
|
+
export { default as parcels } from './resources/parcels';
|
76
|
+
export { default as payment_gateways } from './resources/payment_gateways';
|
77
|
+
export { default as payment_methods } from './resources/payment_methods';
|
78
|
+
export { default as payment_options } from './resources/payment_options';
|
79
|
+
export { default as paypal_gateways } from './resources/paypal_gateways';
|
80
|
+
export { default as paypal_payments } from './resources/paypal_payments';
|
81
|
+
export { default as percentage_discount_promotions } from './resources/percentage_discount_promotions';
|
82
|
+
export { default as pickups } from './resources/pickups';
|
83
|
+
export { default as price_frequency_tiers } from './resources/price_frequency_tiers';
|
84
|
+
export { default as price_list_schedulers } from './resources/price_list_schedulers';
|
85
|
+
export { default as price_lists } from './resources/price_lists';
|
86
|
+
export { default as price_tiers } from './resources/price_tiers';
|
87
|
+
export { default as price_volume_tiers } from './resources/price_volume_tiers';
|
88
|
+
export { default as prices } from './resources/prices';
|
89
|
+
export { default as promotion_rules } from './resources/promotion_rules';
|
90
|
+
export { default as promotions } from './resources/promotions';
|
91
|
+
export { default as recurring_order_copies } from './resources/recurring_order_copies';
|
92
|
+
export { default as refunds } from './resources/refunds';
|
93
|
+
export { default as reserved_stocks } from './resources/reserved_stocks';
|
94
|
+
export { default as resource_errors } from './resources/resource_errors';
|
95
|
+
export { default as return_line_items } from './resources/return_line_items';
|
96
|
+
export { default as returns } from './resources/returns';
|
97
|
+
export { default as satispay_gateways } from './resources/satispay_gateways';
|
98
|
+
export { default as satispay_payments } from './resources/satispay_payments';
|
99
|
+
export { default as shipments } from './resources/shipments';
|
100
|
+
export { default as shipping_categories } from './resources/shipping_categories';
|
101
|
+
export { default as shipping_method_tiers } from './resources/shipping_method_tiers';
|
102
|
+
export { default as shipping_methods } from './resources/shipping_methods';
|
103
|
+
export { default as shipping_weight_tiers } from './resources/shipping_weight_tiers';
|
104
|
+
export { default as shipping_zones } from './resources/shipping_zones';
|
105
|
+
export { default as sku_list_items } from './resources/sku_list_items';
|
106
|
+
export { default as sku_list_promotion_rules } from './resources/sku_list_promotion_rules';
|
107
|
+
export { default as sku_lists } from './resources/sku_lists';
|
108
|
+
export { default as sku_options } from './resources/sku_options';
|
109
|
+
export { default as skus } from './resources/skus';
|
110
|
+
export { default as stock_items } from './resources/stock_items';
|
111
|
+
export { default as stock_line_items } from './resources/stock_line_items';
|
112
|
+
export { default as stock_locations } from './resources/stock_locations';
|
113
|
+
export { default as stock_reservations } from './resources/stock_reservations';
|
114
|
+
export { default as stock_transfers } from './resources/stock_transfers';
|
115
|
+
export { default as stores } from './resources/stores';
|
116
|
+
export { default as stripe_gateways } from './resources/stripe_gateways';
|
117
|
+
export { default as stripe_payments } from './resources/stripe_payments';
|
118
|
+
export { default as stripe_tax_accounts } from './resources/stripe_tax_accounts';
|
119
|
+
export { default as subscription_models } from './resources/subscription_models';
|
120
|
+
export { default as tags } from './resources/tags';
|
121
|
+
export { default as talon_one_accounts } from './resources/talon_one_accounts';
|
122
|
+
export { default as tax_calculators } from './resources/tax_calculators';
|
123
|
+
export { default as tax_categories } from './resources/tax_categories';
|
124
|
+
export { default as tax_rules } from './resources/tax_rules';
|
125
|
+
export { default as taxjar_accounts } from './resources/taxjar_accounts';
|
126
|
+
export { default as transactions } from './resources/transactions';
|
127
|
+
export { default as versions } from './resources/versions';
|
128
|
+
export { default as vertex_accounts } from './resources/vertex_accounts';
|
129
|
+
export { default as voids } from './resources/voids';
|
130
|
+
export { default as webhooks } from './resources/webhooks';
|
131
|
+
export { default as wire_transfers } from './resources/wire_transfers';
|
132
|
+
//# sourceMappingURL=api.js.map
|
133
|
+
//# sourceMappingURL=api.js.map
|
package/lib/api.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"api.js","sourcesContent":[]}
|
package/lib/client.cjs
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var error = require('./error');
|
4
|
+
var config = require('./config');
|
5
|
+
var fetch = require('./fetch');
|
6
|
+
var util = require('./util');
|
7
|
+
var Debug = require('./debug');
|
8
|
+
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
10
|
+
|
11
|
+
var config__default = /*#__PURE__*/_interopDefault(config);
|
12
|
+
var Debug__default = /*#__PURE__*/_interopDefault(Debug);
|
13
|
+
|
14
|
+
const debug = Debug__default.default("client");
|
15
|
+
const baseURL = (organization, domain) => {
|
16
|
+
return `https://${organization.toLowerCase()}.${domain || config__default.default.default.domain}/api`;
|
17
|
+
};
|
18
|
+
class ApiClient {
|
19
|
+
static create(options) {
|
20
|
+
if ((!options.organization || !options.domain) && options.accessToken) {
|
21
|
+
const tokenData = util.extractTokenData(options.accessToken);
|
22
|
+
if (!options.organization && tokenData?.organization) options.organization = tokenData.organization;
|
23
|
+
if (!options.domain && tokenData?.domain) options.domain = tokenData.domain;
|
24
|
+
}
|
25
|
+
for (const attr of config__default.default.client.requiredAttributes)
|
26
|
+
if (!options[attr]) throw new error.SdkError({ message: `Undefined '${attr}' parameter` });
|
27
|
+
return new ApiClient(options);
|
28
|
+
}
|
29
|
+
#baseUrl;
|
30
|
+
#accessToken;
|
31
|
+
#organization;
|
32
|
+
#domain;
|
33
|
+
#clientConfig;
|
34
|
+
#interceptors;
|
35
|
+
constructor(options) {
|
36
|
+
debug("new client instance %O", options);
|
37
|
+
this.#baseUrl = baseURL(options.organization ?? "", options.domain);
|
38
|
+
this.#accessToken = options.accessToken;
|
39
|
+
this.#organization = options.organization ?? "";
|
40
|
+
this.#domain = options.domain;
|
41
|
+
const fetchConfig = {
|
42
|
+
timeout: options.timeout || config__default.default.client.timeout,
|
43
|
+
fetch: options.fetch,
|
44
|
+
refreshToken: options.refreshToken
|
45
|
+
};
|
46
|
+
const customHeaders = this.customHeaders(options.headers);
|
47
|
+
const headers = {
|
48
|
+
...customHeaders,
|
49
|
+
"Accept": "application/vnd.api+json",
|
50
|
+
"Content-Type": "application/vnd.api+json",
|
51
|
+
"Authorization": "Bearer " + this.#accessToken
|
52
|
+
};
|
53
|
+
if (options.userAgent) headers["User-Agent"] = options.userAgent;
|
54
|
+
fetchConfig.headers = headers;
|
55
|
+
this.#clientConfig = fetchConfig;
|
56
|
+
debug("fetch config: %O", fetchConfig);
|
57
|
+
this.#interceptors = {};
|
58
|
+
}
|
59
|
+
get interceptors() {
|
60
|
+
return this.#interceptors;
|
61
|
+
}
|
62
|
+
get requestHeaders() {
|
63
|
+
if (!this.#clientConfig.headers) this.#clientConfig.headers = {};
|
64
|
+
return this.#clientConfig.headers;
|
65
|
+
}
|
66
|
+
/*
|
67
|
+
set requestHeaders(headers: RequestHeaders) {
|
68
|
+
this.#clientConfig.headers = { ...this.#clientConfig.headers, ...headers }
|
69
|
+
}
|
70
|
+
*/
|
71
|
+
config(config2) {
|
72
|
+
debug("config %o", config2);
|
73
|
+
const def = this.#clientConfig;
|
74
|
+
if (!def.headers) def.headers = {};
|
75
|
+
if (config2.timeout) def.timeout = config2.timeout;
|
76
|
+
if (config2.userAgent) this.userAgent(config2.userAgent);
|
77
|
+
if (config2.fetch) this.#clientConfig.fetch = config2.fetch;
|
78
|
+
if (config2.refreshToken) this.#clientConfig.refreshToken = config2.refreshToken;
|
79
|
+
if (config2.organization || config2.domain) this.#baseUrl = baseURL(config2.organization || this.#organization, config2.domain || this.#domain);
|
80
|
+
if (config2.organization) this.#organization = config2.organization;
|
81
|
+
if (config2.domain) this.#domain = config2.domain;
|
82
|
+
if (config2.accessToken) {
|
83
|
+
this.#accessToken = config2.accessToken;
|
84
|
+
def.headers.Authorization = "Bearer " + this.#accessToken;
|
85
|
+
}
|
86
|
+
if (config2.headers) def.headers = { ...def.headers, ...this.customHeaders(config2.headers) };
|
87
|
+
return this;
|
88
|
+
}
|
89
|
+
userAgent(userAgent) {
|
90
|
+
if (userAgent) this.requestHeaders["User-Agent"] = userAgent;
|
91
|
+
return this;
|
92
|
+
}
|
93
|
+
async request(method, path, body, options) {
|
94
|
+
debug("request %s %s, %O, %O", method, path, body || {}, options || {});
|
95
|
+
if (options?.userAgent) debug("User-Agent header ignored in request config");
|
96
|
+
const baseUrl = options?.organization ? baseURL(options.organization, options.domain) : this.#baseUrl;
|
97
|
+
const url = new URL(`${baseUrl}/${path}`);
|
98
|
+
const bodyData = body ? JSON.stringify({ data: body }) : void 0;
|
99
|
+
const headers = { ...this.requestHeaders, ...this.customHeaders(options?.headers) };
|
100
|
+
const accessToken = options?.accessToken || this.#accessToken;
|
101
|
+
if (accessToken) headers.Authorization = "Bearer " + accessToken;
|
102
|
+
const refreshToken = options?.refreshToken || this.#clientConfig.refreshToken;
|
103
|
+
const fetchFunction = options?.fetch || this.#clientConfig.fetch;
|
104
|
+
const requestOptions = { method, body: bodyData, headers };
|
105
|
+
const timeout = options?.timeout || this.#clientConfig.timeout;
|
106
|
+
if (timeout) {
|
107
|
+
if (AbortSignal?.timeout) requestOptions.signal = AbortSignal.timeout(timeout);
|
108
|
+
else debug("Timeout not set. Undefined function: %s", "AbortSignal.timeout");
|
109
|
+
}
|
110
|
+
if (options?.params) Object.entries(options?.params).forEach(([name, value]) => {
|
111
|
+
url.searchParams.append(name, String(value));
|
112
|
+
});
|
113
|
+
const clientOptions = {
|
114
|
+
interceptors: this.interceptors,
|
115
|
+
fetch: fetchFunction
|
116
|
+
};
|
117
|
+
try {
|
118
|
+
return await fetch.fetchURL(url, requestOptions, clientOptions).catch((error$1) => error.handleError(error$1));
|
119
|
+
} catch (err) {
|
120
|
+
if (error.isExpiredTokenError(err) && refreshToken && util.isTokenExpired(accessToken)) {
|
121
|
+
debug("Access token has expired");
|
122
|
+
const newAccessToken = await refreshToken(this.#accessToken).catch((e) => {
|
123
|
+
debug("Refresh token error: %s", e.message);
|
124
|
+
const tokenError = new error.SdkError({ message: "Error refreshing access token", type: error.ErrorType.TOKEN_REFRESH });
|
125
|
+
tokenError.source = e;
|
126
|
+
throw tokenError;
|
127
|
+
});
|
128
|
+
if (newAccessToken) {
|
129
|
+
debug("Access token refreshed");
|
130
|
+
this.config({ accessToken: newAccessToken });
|
131
|
+
this.#accessToken = newAccessToken;
|
132
|
+
if (requestOptions.headers) requestOptions.headers.Authorization = `Bearer ${newAccessToken}`;
|
133
|
+
const response = await fetch.fetchURL(url, requestOptions, clientOptions).catch((error$1) => error.handleError(error$1));
|
134
|
+
return response;
|
135
|
+
}
|
136
|
+
} else throw err;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
customHeaders(headers) {
|
140
|
+
const customHeaders = {};
|
141
|
+
if (headers) {
|
142
|
+
for (const [name, value] of Object.entries(headers))
|
143
|
+
if (!["accept", "content-type", "authorization", "user-agent"].includes(name.toLowerCase())) customHeaders[name] = value;
|
144
|
+
}
|
145
|
+
return customHeaders;
|
146
|
+
}
|
147
|
+
get currentAccessToken() {
|
148
|
+
return this.#accessToken;
|
149
|
+
}
|
150
|
+
get currentOrganization() {
|
151
|
+
return this.#organization;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
var client_default = ApiClient;
|
155
|
+
|
156
|
+
module.exports = client_default;
|
157
|
+
//# sourceMappingURL=client.cjs.map
|
158
|
+
|
159
|
+
module.exports = exports.default;
|
160
|
+
//# sourceMappingURL=client.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/client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A,aAAA;AAAA;AAGd;AAIA,IAAO,cAAQ,GAAA","file":"client.cjs","sourcesContent":["import { ErrorType, SdkError, handleError, isExpiredTokenError } from './error'\nimport type { InterceptorManager } from './interceptor'\nimport config from './config'\nimport type { FetchResponse, FetchRequestOptions, FetchClientOptions, Fetch } from './fetch'\nimport { fetchURL } from './fetch'\nimport { extractTokenData, isTokenExpired } from './util'\n\n\nimport Debug from './debug'\nconst debug = Debug('client')\n\n\n\nconst baseURL = (organization: string, domain?: string): string => {\n\treturn `https://${organization.toLowerCase()}.${domain || config.default.domain}/api`\n}\n\n\n\ntype RequestParams = Record<string, string | number | boolean>\ntype RequestHeaders = Record<string, string>\n\n\nexport type RefreshToken = (expiredToken: string) => Promise<string>\n\ntype RequestConfig = {\n\ttimeout?: number\n\tparams?: RequestParams\n\theaders?: RequestHeaders\n\tuserAgent?: string\n\tfetch?: Fetch\n\trefreshToken?: RefreshToken\n}\n\n\ntype ApiConfig = {\n\torganization?: string\n\tdomain?: string\n\taccessToken: string\n}\n\ntype ApiClientInitConfig = ApiConfig & RequestConfig\ntype ApiClientConfig = Partial<ApiClientInitConfig>\n\n\nexport type Method = 'GET' | 'DELETE' | 'POST' | 'PUT' | 'PATCH'\n\n\n\nclass ApiClient {\n\n\tstatic create(options: ApiClientInitConfig): ApiClient {\n\n\t\t// Take organization and domain from access token if not defined by user\n\t\tif ((!options.organization || !options.domain) && options.accessToken) {\n\t\t\tconst tokenData = extractTokenData(options.accessToken)\n\t\t\tif (!options.organization && tokenData?.organization) options.organization = tokenData.organization\n\t\t\tif (!options.domain && tokenData?.domain) options.domain = tokenData.domain\n\t\t}\n\n\t\tfor (const attr of config.client.requiredAttributes)\n\t\t\tif (!options[attr]) throw new SdkError({ message: `Undefined '${attr}' parameter` })\n\t\treturn new ApiClient(options)\n\n\t}\n\n\n\t#baseUrl: string\n\t#accessToken: string\n\t#organization: string\n\t#domain?: string\n\treadonly #clientConfig: RequestConfig\n\treadonly #interceptors: InterceptorManager\n\n\n\tprivate constructor(options: ApiClientInitConfig) {\n\n\t\tdebug('new client instance %O', options)\n\n\t\tthis.#baseUrl = baseURL(options.organization ?? '', options.domain)\n\t\tthis.#accessToken = options.accessToken\n\t\tthis.#organization = options.organization ?? ''\t// organization is always defined\n\t\tthis.#domain = options.domain\n\n\t\tconst fetchConfig: RequestConfig = {\n\t\t\ttimeout: options.timeout || config.client.timeout,\n\t\t\tfetch: options.fetch,\n\t\t\trefreshToken: options.refreshToken\n\t\t}\n\n\t\t// Set custom headers\n\t\tconst customHeaders = this.customHeaders(options.headers)\n\n\t\t// Set headers\n\t\tconst headers: RequestHeaders = {\n\t\t\t...customHeaders,\n\t\t\t'Accept': 'application/vnd.api+json',\n\t\t\t'Content-Type': 'application/vnd.api+json',\n\t\t\t'Authorization': 'Bearer ' + this.#accessToken\n\t\t}\n\n\t\t// Set User-Agent\n\t\tif (options.userAgent) headers['User-Agent'] = options.userAgent\n\n\t\tfetchConfig.headers = headers\n\n\t\tthis.#clientConfig = fetchConfig\n\n\t\tdebug('fetch config: %O', fetchConfig)\n\n\t\t// Interceptors\n\t\tthis.#interceptors = {}\n\n\t}\n\n\n\tget interceptors(): InterceptorManager { return this.#interceptors }\n\n\tget requestHeaders(): RequestHeaders {\n\t\tif (!this.#clientConfig.headers) this.#clientConfig.headers = {}\n\t\treturn this.#clientConfig.headers\n\t}\n\n\n\t/*\n\tset requestHeaders(headers: RequestHeaders) {\n\t\tthis.#clientConfig.headers = { ...this.#clientConfig.headers, ...headers }\n\t}\n\t*/\n\n\n\tconfig(config: ApiClientConfig): this {\n\n\t\tdebug('config %o', config)\n\n\t\tconst def = this.#clientConfig\n\t\tif (!def.headers) def.headers = {}\n\n\t\t// Client config\n\t\tif (config.timeout) def.timeout = config.timeout\n\n\t\tif (config.userAgent) this.userAgent(config.userAgent)\n\t\tif (config.fetch) this.#clientConfig.fetch = config.fetch\n\t\tif (config.refreshToken) this.#clientConfig.refreshToken = config.refreshToken\n\n\t\t// API Client config\n\t\tif (config.organization || config.domain) this.#baseUrl = baseURL(config.organization || this.#organization, config.domain || this.#domain)\n\t\tif (config.organization) this.#organization = config.organization\n\t\tif (config.domain) this.#domain = config.domain\n\t\tif (config.accessToken) {\n\t\t\tthis.#accessToken = config.accessToken\n\t\t\tdef.headers.Authorization = 'Bearer ' + this.#accessToken\n\t\t}\n\t\tif (config.headers) def.headers = { ...def.headers, ...this.customHeaders(config.headers) }\n\n\t\treturn this\n\n\t}\n\n\n\tuserAgent(userAgent: string): this {\n\t\tif (userAgent) this.requestHeaders['User-Agent'] = userAgent\n\t\treturn this\n\t}\n\n\n\tasync request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<FetchResponse> {\n\n\t\tdebug('request %s %s, %O, %O', method, path, body || {}, options || {})\n\n\t\t// Ignored params (in debug mode)\n\t\tif (options?.userAgent) debug('User-Agent header ignored in request config')\n\n\t\t// URL\n\t\tconst baseUrl = options?.organization ? baseURL(options.organization, options.domain) : this.#baseUrl\n\t\tconst url = new URL(`${baseUrl}/${path}`)\n\n\t\t// Body\n\t\tconst bodyData = body ? JSON.stringify({ data: body }) : undefined\n\n\t\t// Headers\n\t\tconst headers = { ...this.requestHeaders, ...this.customHeaders(options?.headers) }\n\n\t\t// Access token\n\t\tconst accessToken = options?.accessToken || this.#accessToken\n\t\tif (accessToken) headers.Authorization = 'Bearer ' + accessToken\n\n\t\tconst refreshToken = options?.refreshToken || this.#clientConfig.refreshToken\n\t\tconst fetchFunction = options?.fetch || this.#clientConfig.fetch\n\n\t\tconst requestOptions: FetchRequestOptions = { method, body: bodyData, headers }\n\n\t\t// Timeout\n\t\tconst timeout = options?.timeout || this.#clientConfig.timeout\n\t\tif (timeout) {\n\t\t\tif (AbortSignal?.timeout) requestOptions.signal = AbortSignal.timeout(timeout)\n\t\t\telse debug('Timeout not set. Undefined function: %s', 'AbortSignal.timeout')\n\t\t}\n\n\t\tif (options?.params) Object.entries(options?.params).forEach(([name, value]) => { url.searchParams.append(name, String(value)) })\n\n\t\tconst clientOptions: FetchClientOptions = {\n\t\t\tinterceptors: this.interceptors,\n\t\t\tfetch: fetchFunction\n\t\t}\n\n\t\t// const start = Date.now()\n\t\ttry {\t// Execute api call\n\t\t\treturn await fetchURL(url, requestOptions, clientOptions).catch((error: Error) => handleError(error))\n\t\t} catch (err: any) {\t// Error executing api call\n\n\t\t\tif (isExpiredTokenError(err) && refreshToken && isTokenExpired(accessToken)) {\t// If token has expired and must be refreshed\n\n\t\t\t\tdebug('Access token has expired')\n\t\t\t\tconst newAccessToken = await refreshToken(this.#accessToken)\t// Refresh access token ...\n\t\t\t\t\t.catch((e: any) => {\t// Error refreshing access token\n\t\t\t\t\t\tdebug('Refresh token error: %s', e.message)\n\t\t\t\t\t\tconst tokenError = new SdkError({ message: 'Error refreshing access token', type: ErrorType.TOKEN_REFRESH })\n\t\t\t\t\t\ttokenError.source = e\n\t\t\t\t\t\tthrow tokenError\n\t\t\t\t\t})\n\n\t\t\t\tif (newAccessToken) {\t// ... set new access token in current config and repeat call\n\t\t\t\t\tdebug('Access token refreshed')\n\t\t\t\t\tthis.config({ accessToken: newAccessToken })\n\t\t\t\t\tthis.#accessToken = newAccessToken\n\t\t\t\t\tif (requestOptions.headers) (requestOptions.headers as Record<string, string>).Authorization = `Bearer ${newAccessToken}`\n\t\t\t\t\tconst response = await fetchURL(url, requestOptions, clientOptions).catch((error: Error) => handleError(error))\n\t\t\t\t\treturn response\n\t\t\t\t}\n\n\t\t\t} else throw err\n\n\t\t}\n\t\t// .finally(() => { console.log(`<<-- ${method} ${path} ${Date.now() - start}`) })\n\n\t}\n\n\n\tprivate customHeaders(headers?: RequestHeaders): RequestHeaders {\n\t\tconst customHeaders: RequestHeaders = {}\n\t\tif (headers) {\n\t\t\tfor (const [name, value] of Object.entries(headers))\n\t\t\t\tif (!['accept', 'content-type', 'authorization', 'user-agent'].includes(name.toLowerCase())) customHeaders[name] = value\n\t\t}\n\t\treturn customHeaders\n\t}\n\n\n\tget currentAccessToken(): string {\n\t\treturn this.#accessToken\n\t}\n\n\tget currentOrganization(): string {\n\t\treturn this.#organization\n\t}\n\n}\n\n\n\nexport default ApiClient\n\nexport type { ApiClientInitConfig, ApiClientConfig, RequestConfig }\n"]}
|
package/lib/client.d.cts
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
import { F as Fetch, f as InterceptorManager, g as FetchResponse } from './interceptor-5MISI1yn.cjs';
|
2
|
+
|
3
|
+
type RequestParams = Record<string, string | number | boolean>;
|
4
|
+
type RequestHeaders = Record<string, string>;
|
5
|
+
type RefreshToken = (expiredToken: string) => Promise<string>;
|
6
|
+
type RequestConfig = {
|
7
|
+
timeout?: number;
|
8
|
+
params?: RequestParams;
|
9
|
+
headers?: RequestHeaders;
|
10
|
+
userAgent?: string;
|
11
|
+
fetch?: Fetch;
|
12
|
+
refreshToken?: RefreshToken;
|
13
|
+
};
|
14
|
+
type ApiConfig = {
|
15
|
+
organization?: string;
|
16
|
+
domain?: string;
|
17
|
+
accessToken: string;
|
18
|
+
};
|
19
|
+
type ApiClientInitConfig = ApiConfig & RequestConfig;
|
20
|
+
type ApiClientConfig = Partial<ApiClientInitConfig>;
|
21
|
+
type Method = 'GET' | 'DELETE' | 'POST' | 'PUT' | 'PATCH';
|
22
|
+
declare class ApiClient {
|
23
|
+
#private;
|
24
|
+
static create(options: ApiClientInitConfig): ApiClient;
|
25
|
+
private constructor();
|
26
|
+
get interceptors(): InterceptorManager;
|
27
|
+
get requestHeaders(): RequestHeaders;
|
28
|
+
config(config: ApiClientConfig): this;
|
29
|
+
userAgent(userAgent: string): this;
|
30
|
+
request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<FetchResponse>;
|
31
|
+
private customHeaders;
|
32
|
+
get currentAccessToken(): string;
|
33
|
+
get currentOrganization(): string;
|
34
|
+
}
|
35
|
+
|
36
|
+
export { type ApiClientConfig, type ApiClientInitConfig, type Method, type RefreshToken, type RequestConfig, ApiClient as default };
|
package/lib/client.d.ts
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
import { F as Fetch, f as InterceptorManager, g as FetchResponse } from './interceptor-5MISI1yn.js';
|
2
|
+
|
3
|
+
type RequestParams = Record<string, string | number | boolean>;
|
4
|
+
type RequestHeaders = Record<string, string>;
|
5
|
+
type RefreshToken = (expiredToken: string) => Promise<string>;
|
6
|
+
type RequestConfig = {
|
7
|
+
timeout?: number;
|
8
|
+
params?: RequestParams;
|
9
|
+
headers?: RequestHeaders;
|
10
|
+
userAgent?: string;
|
11
|
+
fetch?: Fetch;
|
12
|
+
refreshToken?: RefreshToken;
|
13
|
+
};
|
14
|
+
type ApiConfig = {
|
15
|
+
organization?: string;
|
16
|
+
domain?: string;
|
17
|
+
accessToken: string;
|
18
|
+
};
|
19
|
+
type ApiClientInitConfig = ApiConfig & RequestConfig;
|
20
|
+
type ApiClientConfig = Partial<ApiClientInitConfig>;
|
21
|
+
type Method = 'GET' | 'DELETE' | 'POST' | 'PUT' | 'PATCH';
|
22
|
+
declare class ApiClient {
|
23
|
+
#private;
|
24
|
+
static create(options: ApiClientInitConfig): ApiClient;
|
25
|
+
private constructor();
|
26
|
+
get interceptors(): InterceptorManager;
|
27
|
+
get requestHeaders(): RequestHeaders;
|
28
|
+
config(config: ApiClientConfig): this;
|
29
|
+
userAgent(userAgent: string): this;
|
30
|
+
request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<FetchResponse>;
|
31
|
+
private customHeaders;
|
32
|
+
get currentAccessToken(): string;
|
33
|
+
get currentOrganization(): string;
|
34
|
+
}
|
35
|
+
|
36
|
+
export { type ApiClientConfig, type ApiClientInitConfig, type Method, type RefreshToken, type RequestConfig, ApiClient as default };
|
package/lib/client.js
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
import { SdkError, handleError, isExpiredTokenError, ErrorType } from './error';
|
2
|
+
import config from './config';
|
3
|
+
import { fetchURL } from './fetch';
|
4
|
+
import { extractTokenData, isTokenExpired } from './util';
|
5
|
+
import Debug from './debug';
|
6
|
+
|
7
|
+
const debug = Debug("client");
|
8
|
+
const baseURL = (organization, domain) => {
|
9
|
+
return `https://${organization.toLowerCase()}.${domain || config.default.domain}/api`;
|
10
|
+
};
|
11
|
+
class ApiClient {
|
12
|
+
static create(options) {
|
13
|
+
if ((!options.organization || !options.domain) && options.accessToken) {
|
14
|
+
const tokenData = extractTokenData(options.accessToken);
|
15
|
+
if (!options.organization && tokenData?.organization) options.organization = tokenData.organization;
|
16
|
+
if (!options.domain && tokenData?.domain) options.domain = tokenData.domain;
|
17
|
+
}
|
18
|
+
for (const attr of config.client.requiredAttributes)
|
19
|
+
if (!options[attr]) throw new SdkError({ message: `Undefined '${attr}' parameter` });
|
20
|
+
return new ApiClient(options);
|
21
|
+
}
|
22
|
+
#baseUrl;
|
23
|
+
#accessToken;
|
24
|
+
#organization;
|
25
|
+
#domain;
|
26
|
+
#clientConfig;
|
27
|
+
#interceptors;
|
28
|
+
constructor(options) {
|
29
|
+
debug("new client instance %O", options);
|
30
|
+
this.#baseUrl = baseURL(options.organization ?? "", options.domain);
|
31
|
+
this.#accessToken = options.accessToken;
|
32
|
+
this.#organization = options.organization ?? "";
|
33
|
+
this.#domain = options.domain;
|
34
|
+
const fetchConfig = {
|
35
|
+
timeout: options.timeout || config.client.timeout,
|
36
|
+
fetch: options.fetch,
|
37
|
+
refreshToken: options.refreshToken
|
38
|
+
};
|
39
|
+
const customHeaders = this.customHeaders(options.headers);
|
40
|
+
const headers = {
|
41
|
+
...customHeaders,
|
42
|
+
"Accept": "application/vnd.api+json",
|
43
|
+
"Content-Type": "application/vnd.api+json",
|
44
|
+
"Authorization": "Bearer " + this.#accessToken
|
45
|
+
};
|
46
|
+
if (options.userAgent) headers["User-Agent"] = options.userAgent;
|
47
|
+
fetchConfig.headers = headers;
|
48
|
+
this.#clientConfig = fetchConfig;
|
49
|
+
debug("fetch config: %O", fetchConfig);
|
50
|
+
this.#interceptors = {};
|
51
|
+
}
|
52
|
+
get interceptors() {
|
53
|
+
return this.#interceptors;
|
54
|
+
}
|
55
|
+
get requestHeaders() {
|
56
|
+
if (!this.#clientConfig.headers) this.#clientConfig.headers = {};
|
57
|
+
return this.#clientConfig.headers;
|
58
|
+
}
|
59
|
+
/*
|
60
|
+
set requestHeaders(headers: RequestHeaders) {
|
61
|
+
this.#clientConfig.headers = { ...this.#clientConfig.headers, ...headers }
|
62
|
+
}
|
63
|
+
*/
|
64
|
+
config(config2) {
|
65
|
+
debug("config %o", config2);
|
66
|
+
const def = this.#clientConfig;
|
67
|
+
if (!def.headers) def.headers = {};
|
68
|
+
if (config2.timeout) def.timeout = config2.timeout;
|
69
|
+
if (config2.userAgent) this.userAgent(config2.userAgent);
|
70
|
+
if (config2.fetch) this.#clientConfig.fetch = config2.fetch;
|
71
|
+
if (config2.refreshToken) this.#clientConfig.refreshToken = config2.refreshToken;
|
72
|
+
if (config2.organization || config2.domain) this.#baseUrl = baseURL(config2.organization || this.#organization, config2.domain || this.#domain);
|
73
|
+
if (config2.organization) this.#organization = config2.organization;
|
74
|
+
if (config2.domain) this.#domain = config2.domain;
|
75
|
+
if (config2.accessToken) {
|
76
|
+
this.#accessToken = config2.accessToken;
|
77
|
+
def.headers.Authorization = "Bearer " + this.#accessToken;
|
78
|
+
}
|
79
|
+
if (config2.headers) def.headers = { ...def.headers, ...this.customHeaders(config2.headers) };
|
80
|
+
return this;
|
81
|
+
}
|
82
|
+
userAgent(userAgent) {
|
83
|
+
if (userAgent) this.requestHeaders["User-Agent"] = userAgent;
|
84
|
+
return this;
|
85
|
+
}
|
86
|
+
async request(method, path, body, options) {
|
87
|
+
debug("request %s %s, %O, %O", method, path, body || {}, options || {});
|
88
|
+
if (options?.userAgent) debug("User-Agent header ignored in request config");
|
89
|
+
const baseUrl = options?.organization ? baseURL(options.organization, options.domain) : this.#baseUrl;
|
90
|
+
const url = new URL(`${baseUrl}/${path}`);
|
91
|
+
const bodyData = body ? JSON.stringify({ data: body }) : void 0;
|
92
|
+
const headers = { ...this.requestHeaders, ...this.customHeaders(options?.headers) };
|
93
|
+
const accessToken = options?.accessToken || this.#accessToken;
|
94
|
+
if (accessToken) headers.Authorization = "Bearer " + accessToken;
|
95
|
+
const refreshToken = options?.refreshToken || this.#clientConfig.refreshToken;
|
96
|
+
const fetchFunction = options?.fetch || this.#clientConfig.fetch;
|
97
|
+
const requestOptions = { method, body: bodyData, headers };
|
98
|
+
const timeout = options?.timeout || this.#clientConfig.timeout;
|
99
|
+
if (timeout) {
|
100
|
+
if (AbortSignal?.timeout) requestOptions.signal = AbortSignal.timeout(timeout);
|
101
|
+
else debug("Timeout not set. Undefined function: %s", "AbortSignal.timeout");
|
102
|
+
}
|
103
|
+
if (options?.params) Object.entries(options?.params).forEach(([name, value]) => {
|
104
|
+
url.searchParams.append(name, String(value));
|
105
|
+
});
|
106
|
+
const clientOptions = {
|
107
|
+
interceptors: this.interceptors,
|
108
|
+
fetch: fetchFunction
|
109
|
+
};
|
110
|
+
try {
|
111
|
+
return await fetchURL(url, requestOptions, clientOptions).catch((error) => handleError(error));
|
112
|
+
} catch (err) {
|
113
|
+
if (isExpiredTokenError(err) && refreshToken && isTokenExpired(accessToken)) {
|
114
|
+
debug("Access token has expired");
|
115
|
+
const newAccessToken = await refreshToken(this.#accessToken).catch((e) => {
|
116
|
+
debug("Refresh token error: %s", e.message);
|
117
|
+
const tokenError = new SdkError({ message: "Error refreshing access token", type: ErrorType.TOKEN_REFRESH });
|
118
|
+
tokenError.source = e;
|
119
|
+
throw tokenError;
|
120
|
+
});
|
121
|
+
if (newAccessToken) {
|
122
|
+
debug("Access token refreshed");
|
123
|
+
this.config({ accessToken: newAccessToken });
|
124
|
+
this.#accessToken = newAccessToken;
|
125
|
+
if (requestOptions.headers) requestOptions.headers.Authorization = `Bearer ${newAccessToken}`;
|
126
|
+
const response = await fetchURL(url, requestOptions, clientOptions).catch((error) => handleError(error));
|
127
|
+
return response;
|
128
|
+
}
|
129
|
+
} else throw err;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
customHeaders(headers) {
|
133
|
+
const customHeaders = {};
|
134
|
+
if (headers) {
|
135
|
+
for (const [name, value] of Object.entries(headers))
|
136
|
+
if (!["accept", "content-type", "authorization", "user-agent"].includes(name.toLowerCase())) customHeaders[name] = value;
|
137
|
+
}
|
138
|
+
return customHeaders;
|
139
|
+
}
|
140
|
+
get currentAccessToken() {
|
141
|
+
return this.#accessToken;
|
142
|
+
}
|
143
|
+
get currentOrganization() {
|
144
|
+
return this.#organization;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
var client_default = ApiClient;
|
148
|
+
|
149
|
+
export { client_default as default };
|
150
|
+
//# sourceMappingURL=client.js.map
|
151
|
+
//# sourceMappingURL=client.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"names":["config"],"mappings":";;;;;;AASA,MAAM,KAAA,GAAQ,MAAM,QAAQ,CAAA;AAI5B,MAAM,OAAA,GAAU,CAAC,YAAA,EAAsB,MAA4B,KAAA;AAClE,EAAO,OAAA,CAAA,QAAA,EAAW,aAAa,WAAY,EAAC,IAAI,MAAU,IAAA,MAAA,CAAO,QAAQ,MAAM,CAAA,IAAA,CAAA;AAChF,CAAA;AAkCA,MAAM,SAAU,CAAA;AAAA,EAEf,OAAO,OAAO,OAAyC,EAAA;AAGtD,IAAA,IAAA,CAAK,CAAC,OAAQ,CAAA,YAAA,IAAgB,CAAC,OAAQ,CAAA,MAAA,KAAW,QAAQ,WAAa,EAAA;AACtE,MAAM,MAAA,SAAA,GAAY,gBAAiB,CAAA,OAAA,CAAQ,WAAW,CAAA;AACtD,MAAA,IAAI,CAAC,OAAQ,CAAA,YAAA,IAAgB,WAAW,YAAc,EAAA,OAAA,CAAQ,eAAe,SAAU,CAAA,YAAA;AACvF,MAAA,IAAI,CAAC,OAAQ,CAAA,MAAA,IAAU,WAAW,MAAQ,EAAA,OAAA,CAAQ,SAAS,SAAU,CAAA,MAAA;AAAA;AAGtE,IAAW,KAAA,MAAA,IAAA,IAAQ,OAAO,MAAO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,IAAA,MAAA,CAAO,QAAQ,OAAO,CAAA;AACjD,QAAA,IAAI,CAAC,CAAC,QAAU,EAAA,cAAA,EAAgB,iBAAiB,YAAY,CAAA,CAAE,QAAS,CAAA,IAAA,CAAK,WAAY,EAAC,CAAG,EAAA,aAAA,CAAc,IAAI,CAAI,GAAA,KAAA;AAAA;AAErH,IAAO,OAAA,aAAA;AAAA;AACR,EAGA,IAAI,kBAA6B,GAAA;AAChC,IAAA,OAAO,IAAK,CAAA,YAAA;AAAA;AACb,EAEA,IAAI,mBAA8B,GAAA;AACjC,IAAA,OAAO,IAAK,CAAA,aAAA;AAAA;AAGd;AAIA,IAAO,cAAQ,GAAA","file":"client.js","sourcesContent":["import { ErrorType, SdkError, handleError, isExpiredTokenError } from './error'\nimport type { InterceptorManager } from './interceptor'\nimport config from './config'\nimport type { FetchResponse, FetchRequestOptions, FetchClientOptions, Fetch } from './fetch'\nimport { fetchURL } from './fetch'\nimport { extractTokenData, isTokenExpired } from './util'\n\n\nimport Debug from './debug'\nconst debug = Debug('client')\n\n\n\nconst baseURL = (organization: string, domain?: string): string => {\n\treturn `https://${organization.toLowerCase()}.${domain || config.default.domain}/api`\n}\n\n\n\ntype RequestParams = Record<string, string | number | boolean>\ntype RequestHeaders = Record<string, string>\n\n\nexport type RefreshToken = (expiredToken: string) => Promise<string>\n\ntype RequestConfig = {\n\ttimeout?: number\n\tparams?: RequestParams\n\theaders?: RequestHeaders\n\tuserAgent?: string\n\tfetch?: Fetch\n\trefreshToken?: RefreshToken\n}\n\n\ntype ApiConfig = {\n\torganization?: string\n\tdomain?: string\n\taccessToken: string\n}\n\ntype ApiClientInitConfig = ApiConfig & RequestConfig\ntype ApiClientConfig = Partial<ApiClientInitConfig>\n\n\nexport type Method = 'GET' | 'DELETE' | 'POST' | 'PUT' | 'PATCH'\n\n\n\nclass ApiClient {\n\n\tstatic create(options: ApiClientInitConfig): ApiClient {\n\n\t\t// Take organization and domain from access token if not defined by user\n\t\tif ((!options.organization || !options.domain) && options.accessToken) {\n\t\t\tconst tokenData = extractTokenData(options.accessToken)\n\t\t\tif (!options.organization && tokenData?.organization) options.organization = tokenData.organization\n\t\t\tif (!options.domain && tokenData?.domain) options.domain = tokenData.domain\n\t\t}\n\n\t\tfor (const attr of config.client.requiredAttributes)\n\t\t\tif (!options[attr]) throw new SdkError({ message: `Undefined '${attr}' parameter` })\n\t\treturn new ApiClient(options)\n\n\t}\n\n\n\t#baseUrl: string\n\t#accessToken: string\n\t#organization: string\n\t#domain?: string\n\treadonly #clientConfig: RequestConfig\n\treadonly #interceptors: InterceptorManager\n\n\n\tprivate constructor(options: ApiClientInitConfig) {\n\n\t\tdebug('new client instance %O', options)\n\n\t\tthis.#baseUrl = baseURL(options.organization ?? '', options.domain)\n\t\tthis.#accessToken = options.accessToken\n\t\tthis.#organization = options.organization ?? ''\t// organization is always defined\n\t\tthis.#domain = options.domain\n\n\t\tconst fetchConfig: RequestConfig = {\n\t\t\ttimeout: options.timeout || config.client.timeout,\n\t\t\tfetch: options.fetch,\n\t\t\trefreshToken: options.refreshToken\n\t\t}\n\n\t\t// Set custom headers\n\t\tconst customHeaders = this.customHeaders(options.headers)\n\n\t\t// Set headers\n\t\tconst headers: RequestHeaders = {\n\t\t\t...customHeaders,\n\t\t\t'Accept': 'application/vnd.api+json',\n\t\t\t'Content-Type': 'application/vnd.api+json',\n\t\t\t'Authorization': 'Bearer ' + this.#accessToken\n\t\t}\n\n\t\t// Set User-Agent\n\t\tif (options.userAgent) headers['User-Agent'] = options.userAgent\n\n\t\tfetchConfig.headers = headers\n\n\t\tthis.#clientConfig = fetchConfig\n\n\t\tdebug('fetch config: %O', fetchConfig)\n\n\t\t// Interceptors\n\t\tthis.#interceptors = {}\n\n\t}\n\n\n\tget interceptors(): InterceptorManager { return this.#interceptors }\n\n\tget requestHeaders(): RequestHeaders {\n\t\tif (!this.#clientConfig.headers) this.#clientConfig.headers = {}\n\t\treturn this.#clientConfig.headers\n\t}\n\n\n\t/*\n\tset requestHeaders(headers: RequestHeaders) {\n\t\tthis.#clientConfig.headers = { ...this.#clientConfig.headers, ...headers }\n\t}\n\t*/\n\n\n\tconfig(config: ApiClientConfig): this {\n\n\t\tdebug('config %o', config)\n\n\t\tconst def = this.#clientConfig\n\t\tif (!def.headers) def.headers = {}\n\n\t\t// Client config\n\t\tif (config.timeout) def.timeout = config.timeout\n\n\t\tif (config.userAgent) this.userAgent(config.userAgent)\n\t\tif (config.fetch) this.#clientConfig.fetch = config.fetch\n\t\tif (config.refreshToken) this.#clientConfig.refreshToken = config.refreshToken\n\n\t\t// API Client config\n\t\tif (config.organization || config.domain) this.#baseUrl = baseURL(config.organization || this.#organization, config.domain || this.#domain)\n\t\tif (config.organization) this.#organization = config.organization\n\t\tif (config.domain) this.#domain = config.domain\n\t\tif (config.accessToken) {\n\t\t\tthis.#accessToken = config.accessToken\n\t\t\tdef.headers.Authorization = 'Bearer ' + this.#accessToken\n\t\t}\n\t\tif (config.headers) def.headers = { ...def.headers, ...this.customHeaders(config.headers) }\n\n\t\treturn this\n\n\t}\n\n\n\tuserAgent(userAgent: string): this {\n\t\tif (userAgent) this.requestHeaders['User-Agent'] = userAgent\n\t\treturn this\n\t}\n\n\n\tasync request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<FetchResponse> {\n\n\t\tdebug('request %s %s, %O, %O', method, path, body || {}, options || {})\n\n\t\t// Ignored params (in debug mode)\n\t\tif (options?.userAgent) debug('User-Agent header ignored in request config')\n\n\t\t// URL\n\t\tconst baseUrl = options?.organization ? baseURL(options.organization, options.domain) : this.#baseUrl\n\t\tconst url = new URL(`${baseUrl}/${path}`)\n\n\t\t// Body\n\t\tconst bodyData = body ? JSON.stringify({ data: body }) : undefined\n\n\t\t// Headers\n\t\tconst headers = { ...this.requestHeaders, ...this.customHeaders(options?.headers) }\n\n\t\t// Access token\n\t\tconst accessToken = options?.accessToken || this.#accessToken\n\t\tif (accessToken) headers.Authorization = 'Bearer ' + accessToken\n\n\t\tconst refreshToken = options?.refreshToken || this.#clientConfig.refreshToken\n\t\tconst fetchFunction = options?.fetch || this.#clientConfig.fetch\n\n\t\tconst requestOptions: FetchRequestOptions = { method, body: bodyData, headers }\n\n\t\t// Timeout\n\t\tconst timeout = options?.timeout || this.#clientConfig.timeout\n\t\tif (timeout) {\n\t\t\tif (AbortSignal?.timeout) requestOptions.signal = AbortSignal.timeout(timeout)\n\t\t\telse debug('Timeout not set. Undefined function: %s', 'AbortSignal.timeout')\n\t\t}\n\n\t\tif (options?.params) Object.entries(options?.params).forEach(([name, value]) => { url.searchParams.append(name, String(value)) })\n\n\t\tconst clientOptions: FetchClientOptions = {\n\t\t\tinterceptors: this.interceptors,\n\t\t\tfetch: fetchFunction\n\t\t}\n\n\t\t// const start = Date.now()\n\t\ttry {\t// Execute api call\n\t\t\treturn await fetchURL(url, requestOptions, clientOptions).catch((error: Error) => handleError(error))\n\t\t} catch (err: any) {\t// Error executing api call\n\n\t\t\tif (isExpiredTokenError(err) && refreshToken && isTokenExpired(accessToken)) {\t// If token has expired and must be refreshed\n\n\t\t\t\tdebug('Access token has expired')\n\t\t\t\tconst newAccessToken = await refreshToken(this.#accessToken)\t// Refresh access token ...\n\t\t\t\t\t.catch((e: any) => {\t// Error refreshing access token\n\t\t\t\t\t\tdebug('Refresh token error: %s', e.message)\n\t\t\t\t\t\tconst tokenError = new SdkError({ message: 'Error refreshing access token', type: ErrorType.TOKEN_REFRESH })\n\t\t\t\t\t\ttokenError.source = e\n\t\t\t\t\t\tthrow tokenError\n\t\t\t\t\t})\n\n\t\t\t\tif (newAccessToken) {\t// ... set new access token in current config and repeat call\n\t\t\t\t\tdebug('Access token refreshed')\n\t\t\t\t\tthis.config({ accessToken: newAccessToken })\n\t\t\t\t\tthis.#accessToken = newAccessToken\n\t\t\t\t\tif (requestOptions.headers) (requestOptions.headers as Record<string, string>).Authorization = `Bearer ${newAccessToken}`\n\t\t\t\t\tconst response = await fetchURL(url, requestOptions, clientOptions).catch((error: Error) => handleError(error))\n\t\t\t\t\treturn response\n\t\t\t\t}\n\n\t\t\t} else throw err\n\n\t\t}\n\t\t// .finally(() => { console.log(`<<-- ${method} ${path} ${Date.now() - start}`) })\n\n\t}\n\n\n\tprivate customHeaders(headers?: RequestHeaders): RequestHeaders {\n\t\tconst customHeaders: RequestHeaders = {}\n\t\tif (headers) {\n\t\t\tfor (const [name, value] of Object.entries(headers))\n\t\t\t\tif (!['accept', 'content-type', 'authorization', 'user-agent'].includes(name.toLowerCase())) customHeaders[name] = value\n\t\t}\n\t\treturn customHeaders\n\t}\n\n\n\tget currentAccessToken(): string {\n\t\treturn this.#accessToken\n\t}\n\n\tget currentOrganization(): string {\n\t\treturn this.#organization\n\t}\n\n}\n\n\n\nexport default ApiClient\n\nexport type { ApiClientInitConfig, ApiClientConfig, RequestConfig }\n"]}
|