@commercelayer/sdk 5.35.0 → 6.0.0-alfa.10
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/lib/cjs/api.d.ts +0 -3
- package/lib/cjs/api.js +0 -10
- package/lib/cjs/client.d.ts +6 -14
- package/lib/cjs/client.js +41 -75
- package/lib/cjs/commercelayer.d.ts +126 -125
- package/lib/cjs/commercelayer.js +267 -155
- package/lib/cjs/common.js +1 -12
- package/lib/cjs/config.js +0 -2
- package/lib/cjs/debug.js +0 -21
- package/lib/cjs/error.d.ts +6 -7
- package/lib/cjs/error.js +36 -35
- package/lib/cjs/fetch.d.ts +13 -0
- package/lib/cjs/fetch.js +67 -0
- package/lib/cjs/index.js +0 -2
- package/lib/cjs/interceptor.d.ts +22 -10
- package/lib/cjs/jsonapi.js +0 -2
- package/lib/cjs/model.d.ts +0 -3
- package/lib/cjs/model.js +0 -1
- package/lib/cjs/query.d.ts +2 -1
- package/lib/cjs/query.js +8 -7
- package/lib/cjs/resource.d.ts +2 -5
- package/lib/cjs/resource.js +32 -58
- package/lib/cjs/resources/addresses.d.ts +1 -0
- package/lib/cjs/resources/addresses.js +4 -1
- package/lib/cjs/resources/adjustments.d.ts +1 -0
- package/lib/cjs/resources/adjustments.js +4 -1
- package/lib/cjs/resources/adyen_gateways.d.ts +1 -0
- package/lib/cjs/resources/adyen_gateways.js +4 -1
- package/lib/cjs/resources/adyen_payments.d.ts +1 -0
- package/lib/cjs/resources/adyen_payments.js +4 -1
- package/lib/cjs/resources/application.d.ts +1 -0
- package/lib/cjs/resources/application.js +4 -1
- package/lib/cjs/resources/attachments.d.ts +1 -0
- package/lib/cjs/resources/attachments.js +4 -1
- package/lib/cjs/resources/authorizations.d.ts +1 -0
- package/lib/cjs/resources/authorizations.js +4 -1
- package/lib/cjs/resources/avalara_accounts.d.ts +1 -0
- package/lib/cjs/resources/avalara_accounts.js +4 -1
- package/lib/cjs/resources/axerve_gateways.d.ts +1 -0
- package/lib/cjs/resources/axerve_gateways.js +4 -1
- package/lib/cjs/resources/axerve_payments.d.ts +1 -0
- package/lib/cjs/resources/axerve_payments.js +4 -1
- package/lib/cjs/resources/billing_info_validation_rules.d.ts +1 -0
- package/lib/cjs/resources/billing_info_validation_rules.js +4 -1
- package/lib/cjs/resources/bing_geocoders.d.ts +1 -0
- package/lib/cjs/resources/bing_geocoders.js +4 -1
- package/lib/cjs/resources/braintree_gateways.d.ts +1 -0
- package/lib/cjs/resources/braintree_gateways.js +4 -1
- package/lib/cjs/resources/braintree_payments.d.ts +1 -0
- package/lib/cjs/resources/braintree_payments.js +4 -1
- package/lib/cjs/resources/bundles.d.ts +1 -0
- package/lib/cjs/resources/bundles.js +4 -1
- package/lib/cjs/resources/buy_x_pay_y_promotions.d.ts +1 -0
- package/lib/cjs/resources/buy_x_pay_y_promotions.js +4 -1
- package/lib/cjs/resources/captures.d.ts +1 -0
- package/lib/cjs/resources/captures.js +4 -1
- package/lib/cjs/resources/carrier_accounts.d.ts +1 -0
- package/lib/cjs/resources/carrier_accounts.js +4 -1
- package/lib/cjs/resources/checkout_com_gateways.d.ts +1 -0
- package/lib/cjs/resources/checkout_com_gateways.js +4 -1
- package/lib/cjs/resources/checkout_com_payments.d.ts +1 -0
- package/lib/cjs/resources/checkout_com_payments.js +4 -1
- package/lib/cjs/resources/cleanups.d.ts +1 -0
- package/lib/cjs/resources/cleanups.js +4 -1
- package/lib/cjs/resources/coupon_codes_promotion_rules.d.ts +1 -0
- package/lib/cjs/resources/coupon_codes_promotion_rules.js +4 -1
- package/lib/cjs/resources/coupon_recipients.d.ts +1 -0
- package/lib/cjs/resources/coupon_recipients.js +4 -1
- package/lib/cjs/resources/coupons.d.ts +1 -0
- package/lib/cjs/resources/coupons.js +4 -1
- package/lib/cjs/resources/custom_promotion_rules.d.ts +1 -0
- package/lib/cjs/resources/custom_promotion_rules.js +4 -1
- package/lib/cjs/resources/customer_addresses.d.ts +1 -0
- package/lib/cjs/resources/customer_addresses.js +4 -1
- package/lib/cjs/resources/customer_groups.d.ts +1 -0
- package/lib/cjs/resources/customer_groups.js +4 -1
- package/lib/cjs/resources/customer_password_resets.d.ts +1 -0
- package/lib/cjs/resources/customer_password_resets.js +4 -1
- package/lib/cjs/resources/customer_payment_sources.d.ts +1 -0
- package/lib/cjs/resources/customer_payment_sources.js +4 -1
- package/lib/cjs/resources/customer_subscriptions.d.ts +1 -0
- package/lib/cjs/resources/customer_subscriptions.js +4 -1
- package/lib/cjs/resources/customers.d.ts +1 -0
- package/lib/cjs/resources/customers.js +4 -1
- package/lib/cjs/resources/delivery_lead_times.d.ts +1 -0
- package/lib/cjs/resources/delivery_lead_times.js +4 -1
- package/lib/cjs/resources/event_callbacks.d.ts +1 -0
- package/lib/cjs/resources/event_callbacks.js +4 -1
- package/lib/cjs/resources/events.d.ts +1 -0
- package/lib/cjs/resources/events.js +4 -1
- package/lib/cjs/resources/exports.d.ts +1 -0
- package/lib/cjs/resources/exports.js +4 -1
- package/lib/cjs/resources/external_gateways.d.ts +1 -0
- package/lib/cjs/resources/external_gateways.js +4 -1
- package/lib/cjs/resources/external_payments.d.ts +1 -0
- package/lib/cjs/resources/external_payments.js +4 -1
- package/lib/cjs/resources/external_promotions.d.ts +1 -0
- package/lib/cjs/resources/external_promotions.js +4 -1
- package/lib/cjs/resources/external_tax_calculators.d.ts +1 -0
- package/lib/cjs/resources/external_tax_calculators.js +4 -1
- package/lib/cjs/resources/fixed_amount_promotions.d.ts +1 -0
- package/lib/cjs/resources/fixed_amount_promotions.js +4 -1
- package/lib/cjs/resources/fixed_price_promotions.d.ts +1 -0
- package/lib/cjs/resources/fixed_price_promotions.js +4 -1
- package/lib/cjs/resources/free_gift_promotions.d.ts +1 -0
- package/lib/cjs/resources/free_gift_promotions.js +4 -1
- package/lib/cjs/resources/free_shipping_promotions.d.ts +1 -0
- package/lib/cjs/resources/free_shipping_promotions.js +4 -1
- package/lib/cjs/resources/geocoders.d.ts +1 -0
- package/lib/cjs/resources/geocoders.js +4 -1
- package/lib/cjs/resources/gift_card_recipients.d.ts +1 -0
- package/lib/cjs/resources/gift_card_recipients.js +4 -1
- package/lib/cjs/resources/gift_cards.d.ts +1 -0
- package/lib/cjs/resources/gift_cards.js +4 -1
- package/lib/cjs/resources/google_geocoders.d.ts +1 -0
- package/lib/cjs/resources/google_geocoders.js +4 -1
- package/lib/cjs/resources/imports.d.ts +1 -0
- package/lib/cjs/resources/imports.js +4 -1
- package/lib/cjs/resources/in_stock_subscriptions.d.ts +1 -0
- package/lib/cjs/resources/in_stock_subscriptions.js +4 -1
- package/lib/cjs/resources/inventory_models.d.ts +1 -0
- package/lib/cjs/resources/inventory_models.js +4 -1
- package/lib/cjs/resources/inventory_return_locations.d.ts +1 -0
- package/lib/cjs/resources/inventory_return_locations.js +4 -1
- package/lib/cjs/resources/inventory_stock_locations.d.ts +1 -0
- package/lib/cjs/resources/inventory_stock_locations.js +4 -1
- package/lib/cjs/resources/klarna_gateways.d.ts +1 -0
- package/lib/cjs/resources/klarna_gateways.js +4 -1
- package/lib/cjs/resources/klarna_payments.d.ts +1 -0
- package/lib/cjs/resources/klarna_payments.js +4 -1
- package/lib/cjs/resources/line_item_options.d.ts +1 -0
- package/lib/cjs/resources/line_item_options.js +4 -1
- package/lib/cjs/resources/line_items.d.ts +1 -0
- package/lib/cjs/resources/line_items.js +4 -1
- package/lib/cjs/resources/manual_gateways.d.ts +1 -0
- package/lib/cjs/resources/manual_gateways.js +4 -1
- package/lib/cjs/resources/manual_tax_calculators.d.ts +1 -0
- package/lib/cjs/resources/manual_tax_calculators.js +4 -1
- package/lib/cjs/resources/markets.d.ts +1 -0
- package/lib/cjs/resources/markets.js +4 -1
- package/lib/cjs/resources/merchants.d.ts +1 -0
- package/lib/cjs/resources/merchants.js +4 -1
- package/lib/cjs/resources/order_amount_promotion_rules.d.ts +1 -0
- package/lib/cjs/resources/order_amount_promotion_rules.js +4 -1
- package/lib/cjs/resources/order_copies.d.ts +1 -0
- package/lib/cjs/resources/order_copies.js +4 -1
- package/lib/cjs/resources/order_factories.d.ts +1 -0
- package/lib/cjs/resources/order_factories.js +4 -1
- package/lib/cjs/resources/order_subscription_items.d.ts +1 -0
- package/lib/cjs/resources/order_subscription_items.js +4 -1
- package/lib/cjs/resources/order_subscriptions.d.ts +1 -0
- package/lib/cjs/resources/order_subscriptions.js +4 -1
- package/lib/cjs/resources/order_validation_rules.d.ts +1 -0
- package/lib/cjs/resources/order_validation_rules.js +4 -1
- package/lib/cjs/resources/orders.d.ts +1 -0
- package/lib/cjs/resources/orders.js +4 -1
- package/lib/cjs/resources/organization.d.ts +1 -0
- package/lib/cjs/resources/organization.js +4 -1
- package/lib/cjs/resources/packages.d.ts +1 -0
- package/lib/cjs/resources/packages.js +4 -1
- package/lib/cjs/resources/parcel_line_items.d.ts +1 -0
- package/lib/cjs/resources/parcel_line_items.js +4 -1
- package/lib/cjs/resources/parcels.d.ts +1 -0
- package/lib/cjs/resources/parcels.js +4 -1
- package/lib/cjs/resources/payment_gateways.d.ts +1 -0
- package/lib/cjs/resources/payment_gateways.js +4 -1
- package/lib/cjs/resources/payment_methods.d.ts +1 -0
- package/lib/cjs/resources/payment_methods.js +4 -1
- package/lib/cjs/resources/payment_options.d.ts +1 -0
- package/lib/cjs/resources/payment_options.js +4 -1
- package/lib/cjs/resources/paypal_gateways.d.ts +1 -0
- package/lib/cjs/resources/paypal_gateways.js +4 -1
- package/lib/cjs/resources/paypal_payments.d.ts +1 -0
- package/lib/cjs/resources/paypal_payments.js +4 -1
- package/lib/cjs/resources/percentage_discount_promotions.d.ts +1 -0
- package/lib/cjs/resources/percentage_discount_promotions.js +4 -1
- package/lib/cjs/resources/price_frequency_tiers.d.ts +1 -0
- package/lib/cjs/resources/price_frequency_tiers.js +4 -1
- package/lib/cjs/resources/price_lists.d.ts +1 -0
- package/lib/cjs/resources/price_lists.js +4 -1
- package/lib/cjs/resources/price_tiers.d.ts +1 -0
- package/lib/cjs/resources/price_tiers.js +4 -1
- package/lib/cjs/resources/price_volume_tiers.d.ts +1 -0
- package/lib/cjs/resources/price_volume_tiers.js +4 -1
- package/lib/cjs/resources/prices.d.ts +1 -0
- package/lib/cjs/resources/prices.js +4 -1
- package/lib/cjs/resources/promotion_rules.d.ts +1 -0
- package/lib/cjs/resources/promotion_rules.js +4 -1
- package/lib/cjs/resources/promotions.d.ts +1 -0
- package/lib/cjs/resources/promotions.js +4 -1
- package/lib/cjs/resources/recurring_order_copies.d.ts +1 -0
- package/lib/cjs/resources/recurring_order_copies.js +4 -1
- package/lib/cjs/resources/refunds.d.ts +1 -0
- package/lib/cjs/resources/refunds.js +4 -1
- package/lib/cjs/resources/reserved_stocks.d.ts +1 -0
- package/lib/cjs/resources/reserved_stocks.js +4 -1
- package/lib/cjs/resources/resource_errors.d.ts +1 -0
- package/lib/cjs/resources/resource_errors.js +4 -1
- package/lib/cjs/resources/return_line_items.d.ts +1 -0
- package/lib/cjs/resources/return_line_items.js +4 -1
- package/lib/cjs/resources/returns.d.ts +1 -0
- package/lib/cjs/resources/returns.js +4 -1
- package/lib/cjs/resources/satispay_gateways.d.ts +1 -0
- package/lib/cjs/resources/satispay_gateways.js +4 -1
- package/lib/cjs/resources/satispay_payments.d.ts +1 -0
- package/lib/cjs/resources/satispay_payments.js +4 -1
- package/lib/cjs/resources/shipments.d.ts +1 -0
- package/lib/cjs/resources/shipments.js +4 -1
- package/lib/cjs/resources/shipping_categories.d.ts +1 -0
- package/lib/cjs/resources/shipping_categories.js +4 -1
- package/lib/cjs/resources/shipping_method_tiers.d.ts +1 -0
- package/lib/cjs/resources/shipping_method_tiers.js +4 -1
- package/lib/cjs/resources/shipping_methods.d.ts +1 -0
- package/lib/cjs/resources/shipping_methods.js +4 -1
- package/lib/cjs/resources/shipping_weight_tiers.d.ts +1 -0
- package/lib/cjs/resources/shipping_weight_tiers.js +4 -1
- package/lib/cjs/resources/shipping_zones.d.ts +1 -0
- package/lib/cjs/resources/shipping_zones.js +4 -1
- package/lib/cjs/resources/sku_list_items.d.ts +1 -0
- package/lib/cjs/resources/sku_list_items.js +4 -1
- package/lib/cjs/resources/sku_list_promotion_rules.d.ts +1 -0
- package/lib/cjs/resources/sku_list_promotion_rules.js +4 -1
- package/lib/cjs/resources/sku_lists.d.ts +1 -0
- package/lib/cjs/resources/sku_lists.js +4 -1
- package/lib/cjs/resources/sku_options.d.ts +1 -0
- package/lib/cjs/resources/sku_options.js +4 -1
- package/lib/cjs/resources/skus.d.ts +1 -0
- package/lib/cjs/resources/skus.js +4 -1
- package/lib/cjs/resources/stock_items.d.ts +1 -0
- package/lib/cjs/resources/stock_items.js +4 -1
- package/lib/cjs/resources/stock_line_items.d.ts +1 -0
- package/lib/cjs/resources/stock_line_items.js +4 -1
- package/lib/cjs/resources/stock_locations.d.ts +1 -0
- package/lib/cjs/resources/stock_locations.js +4 -1
- package/lib/cjs/resources/stock_reservations.d.ts +1 -0
- package/lib/cjs/resources/stock_reservations.js +4 -1
- package/lib/cjs/resources/stock_transfers.d.ts +1 -0
- package/lib/cjs/resources/stock_transfers.js +4 -1
- package/lib/cjs/resources/stripe_gateways.d.ts +1 -0
- package/lib/cjs/resources/stripe_gateways.js +4 -1
- package/lib/cjs/resources/stripe_payments.d.ts +1 -0
- package/lib/cjs/resources/stripe_payments.js +4 -1
- package/lib/cjs/resources/subscription_models.d.ts +1 -0
- package/lib/cjs/resources/subscription_models.js +4 -1
- package/lib/cjs/resources/tags.d.ts +1 -0
- package/lib/cjs/resources/tags.js +4 -1
- package/lib/cjs/resources/tax_calculators.d.ts +1 -0
- package/lib/cjs/resources/tax_calculators.js +4 -1
- package/lib/cjs/resources/tax_categories.d.ts +1 -0
- package/lib/cjs/resources/tax_categories.js +4 -1
- package/lib/cjs/resources/tax_rules.d.ts +1 -0
- package/lib/cjs/resources/tax_rules.js +4 -1
- package/lib/cjs/resources/taxjar_accounts.d.ts +1 -0
- package/lib/cjs/resources/taxjar_accounts.js +4 -1
- package/lib/cjs/resources/transactions.d.ts +1 -0
- package/lib/cjs/resources/transactions.js +4 -1
- package/lib/cjs/resources/versions.d.ts +1 -0
- package/lib/cjs/resources/versions.js +4 -1
- package/lib/cjs/resources/voids.d.ts +1 -0
- package/lib/cjs/resources/voids.js +4 -1
- package/lib/cjs/resources/webhooks.d.ts +1 -0
- package/lib/cjs/resources/webhooks.js +4 -1
- package/lib/cjs/resources/wire_transfers.d.ts +1 -0
- package/lib/cjs/resources/wire_transfers.js +4 -1
- package/lib/cjs/static.js +0 -1
- package/lib/cjs/util.js +0 -1
- package/lib/esm/api.d.ts +0 -3
- package/lib/esm/api.js +0 -10
- package/lib/esm/client.d.ts +6 -14
- package/lib/esm/client.js +43 -90
- package/lib/esm/commercelayer.d.ts +126 -125
- package/lib/esm/commercelayer.js +270 -171
- package/lib/esm/common.js +1 -12
- package/lib/esm/config.js +0 -2
- package/lib/esm/debug.js +0 -21
- package/lib/esm/error.d.ts +6 -7
- package/lib/esm/error.js +44 -35
- package/lib/esm/fetch.d.ts +13 -0
- package/lib/esm/fetch.js +46 -0
- package/lib/esm/index.js +0 -2
- package/lib/esm/interceptor.d.ts +22 -10
- package/lib/esm/jsonapi.js +0 -2
- package/lib/esm/model.d.ts +0 -3
- package/lib/esm/model.js +0 -1
- package/lib/esm/query.d.ts +2 -1
- package/lib/esm/query.js +7 -7
- package/lib/esm/resource.d.ts +2 -5
- package/lib/esm/resource.js +40 -76
- package/lib/esm/resources/addresses.d.ts +1 -0
- package/lib/esm/resources/addresses.js +5 -2
- package/lib/esm/resources/adjustments.d.ts +1 -0
- package/lib/esm/resources/adjustments.js +5 -2
- package/lib/esm/resources/adyen_gateways.d.ts +1 -0
- package/lib/esm/resources/adyen_gateways.js +5 -2
- package/lib/esm/resources/adyen_payments.d.ts +1 -0
- package/lib/esm/resources/adyen_payments.js +5 -2
- package/lib/esm/resources/application.d.ts +1 -0
- package/lib/esm/resources/application.js +5 -2
- package/lib/esm/resources/attachments.d.ts +1 -0
- package/lib/esm/resources/attachments.js +5 -2
- package/lib/esm/resources/authorizations.d.ts +1 -0
- package/lib/esm/resources/authorizations.js +5 -2
- package/lib/esm/resources/avalara_accounts.d.ts +1 -0
- package/lib/esm/resources/avalara_accounts.js +5 -2
- package/lib/esm/resources/axerve_gateways.d.ts +1 -0
- package/lib/esm/resources/axerve_gateways.js +5 -2
- package/lib/esm/resources/axerve_payments.d.ts +1 -0
- package/lib/esm/resources/axerve_payments.js +5 -2
- package/lib/esm/resources/billing_info_validation_rules.d.ts +1 -0
- package/lib/esm/resources/billing_info_validation_rules.js +5 -2
- package/lib/esm/resources/bing_geocoders.d.ts +1 -0
- package/lib/esm/resources/bing_geocoders.js +5 -2
- package/lib/esm/resources/braintree_gateways.d.ts +1 -0
- package/lib/esm/resources/braintree_gateways.js +5 -2
- package/lib/esm/resources/braintree_payments.d.ts +1 -0
- package/lib/esm/resources/braintree_payments.js +5 -2
- package/lib/esm/resources/bundles.d.ts +1 -0
- package/lib/esm/resources/bundles.js +5 -2
- package/lib/esm/resources/buy_x_pay_y_promotions.d.ts +1 -0
- package/lib/esm/resources/buy_x_pay_y_promotions.js +5 -2
- package/lib/esm/resources/captures.d.ts +1 -0
- package/lib/esm/resources/captures.js +5 -2
- package/lib/esm/resources/carrier_accounts.d.ts +1 -0
- package/lib/esm/resources/carrier_accounts.js +5 -2
- package/lib/esm/resources/checkout_com_gateways.d.ts +1 -0
- package/lib/esm/resources/checkout_com_gateways.js +5 -2
- package/lib/esm/resources/checkout_com_payments.d.ts +1 -0
- package/lib/esm/resources/checkout_com_payments.js +5 -2
- package/lib/esm/resources/cleanups.d.ts +1 -0
- package/lib/esm/resources/cleanups.js +5 -2
- package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +1 -0
- package/lib/esm/resources/coupon_codes_promotion_rules.js +5 -2
- package/lib/esm/resources/coupon_recipients.d.ts +1 -0
- package/lib/esm/resources/coupon_recipients.js +5 -2
- package/lib/esm/resources/coupons.d.ts +1 -0
- package/lib/esm/resources/coupons.js +5 -2
- package/lib/esm/resources/custom_promotion_rules.d.ts +1 -0
- package/lib/esm/resources/custom_promotion_rules.js +5 -2
- package/lib/esm/resources/customer_addresses.d.ts +1 -0
- package/lib/esm/resources/customer_addresses.js +5 -2
- package/lib/esm/resources/customer_groups.d.ts +1 -0
- package/lib/esm/resources/customer_groups.js +5 -2
- package/lib/esm/resources/customer_password_resets.d.ts +1 -0
- package/lib/esm/resources/customer_password_resets.js +5 -2
- package/lib/esm/resources/customer_payment_sources.d.ts +1 -0
- package/lib/esm/resources/customer_payment_sources.js +5 -2
- package/lib/esm/resources/customer_subscriptions.d.ts +1 -0
- package/lib/esm/resources/customer_subscriptions.js +5 -2
- package/lib/esm/resources/customers.d.ts +1 -0
- package/lib/esm/resources/customers.js +5 -2
- package/lib/esm/resources/delivery_lead_times.d.ts +1 -0
- package/lib/esm/resources/delivery_lead_times.js +5 -2
- package/lib/esm/resources/event_callbacks.d.ts +1 -0
- package/lib/esm/resources/event_callbacks.js +5 -2
- package/lib/esm/resources/events.d.ts +1 -0
- package/lib/esm/resources/events.js +5 -2
- package/lib/esm/resources/exports.d.ts +1 -0
- package/lib/esm/resources/exports.js +5 -2
- package/lib/esm/resources/external_gateways.d.ts +1 -0
- package/lib/esm/resources/external_gateways.js +5 -2
- package/lib/esm/resources/external_payments.d.ts +1 -0
- package/lib/esm/resources/external_payments.js +5 -2
- package/lib/esm/resources/external_promotions.d.ts +1 -0
- package/lib/esm/resources/external_promotions.js +5 -2
- package/lib/esm/resources/external_tax_calculators.d.ts +1 -0
- package/lib/esm/resources/external_tax_calculators.js +5 -2
- package/lib/esm/resources/fixed_amount_promotions.d.ts +1 -0
- package/lib/esm/resources/fixed_amount_promotions.js +5 -2
- package/lib/esm/resources/fixed_price_promotions.d.ts +1 -0
- package/lib/esm/resources/fixed_price_promotions.js +5 -2
- package/lib/esm/resources/free_gift_promotions.d.ts +1 -0
- package/lib/esm/resources/free_gift_promotions.js +5 -2
- package/lib/esm/resources/free_shipping_promotions.d.ts +1 -0
- package/lib/esm/resources/free_shipping_promotions.js +5 -2
- package/lib/esm/resources/geocoders.d.ts +1 -0
- package/lib/esm/resources/geocoders.js +5 -2
- package/lib/esm/resources/gift_card_recipients.d.ts +1 -0
- package/lib/esm/resources/gift_card_recipients.js +5 -2
- package/lib/esm/resources/gift_cards.d.ts +1 -0
- package/lib/esm/resources/gift_cards.js +5 -2
- package/lib/esm/resources/google_geocoders.d.ts +1 -0
- package/lib/esm/resources/google_geocoders.js +5 -2
- package/lib/esm/resources/imports.d.ts +1 -0
- package/lib/esm/resources/imports.js +5 -2
- package/lib/esm/resources/in_stock_subscriptions.d.ts +1 -0
- package/lib/esm/resources/in_stock_subscriptions.js +5 -2
- package/lib/esm/resources/inventory_models.d.ts +1 -0
- package/lib/esm/resources/inventory_models.js +5 -2
- package/lib/esm/resources/inventory_return_locations.d.ts +1 -0
- package/lib/esm/resources/inventory_return_locations.js +5 -2
- package/lib/esm/resources/inventory_stock_locations.d.ts +1 -0
- package/lib/esm/resources/inventory_stock_locations.js +5 -2
- package/lib/esm/resources/klarna_gateways.d.ts +1 -0
- package/lib/esm/resources/klarna_gateways.js +5 -2
- package/lib/esm/resources/klarna_payments.d.ts +1 -0
- package/lib/esm/resources/klarna_payments.js +5 -2
- package/lib/esm/resources/line_item_options.d.ts +1 -0
- package/lib/esm/resources/line_item_options.js +5 -2
- package/lib/esm/resources/line_items.d.ts +1 -0
- package/lib/esm/resources/line_items.js +5 -2
- package/lib/esm/resources/manual_gateways.d.ts +1 -0
- package/lib/esm/resources/manual_gateways.js +5 -2
- package/lib/esm/resources/manual_tax_calculators.d.ts +1 -0
- package/lib/esm/resources/manual_tax_calculators.js +5 -2
- package/lib/esm/resources/markets.d.ts +1 -0
- package/lib/esm/resources/markets.js +5 -2
- package/lib/esm/resources/merchants.d.ts +1 -0
- package/lib/esm/resources/merchants.js +5 -2
- package/lib/esm/resources/order_amount_promotion_rules.d.ts +1 -0
- package/lib/esm/resources/order_amount_promotion_rules.js +5 -2
- package/lib/esm/resources/order_copies.d.ts +1 -0
- package/lib/esm/resources/order_copies.js +5 -2
- package/lib/esm/resources/order_factories.d.ts +1 -0
- package/lib/esm/resources/order_factories.js +5 -2
- package/lib/esm/resources/order_subscription_items.d.ts +1 -0
- package/lib/esm/resources/order_subscription_items.js +5 -2
- package/lib/esm/resources/order_subscriptions.d.ts +1 -0
- package/lib/esm/resources/order_subscriptions.js +5 -2
- package/lib/esm/resources/order_validation_rules.d.ts +1 -0
- package/lib/esm/resources/order_validation_rules.js +5 -2
- package/lib/esm/resources/orders.d.ts +1 -0
- package/lib/esm/resources/orders.js +5 -2
- package/lib/esm/resources/organization.d.ts +1 -0
- package/lib/esm/resources/organization.js +5 -2
- package/lib/esm/resources/packages.d.ts +1 -0
- package/lib/esm/resources/packages.js +5 -2
- package/lib/esm/resources/parcel_line_items.d.ts +1 -0
- package/lib/esm/resources/parcel_line_items.js +5 -2
- package/lib/esm/resources/parcels.d.ts +1 -0
- package/lib/esm/resources/parcels.js +5 -2
- package/lib/esm/resources/payment_gateways.d.ts +1 -0
- package/lib/esm/resources/payment_gateways.js +5 -2
- package/lib/esm/resources/payment_methods.d.ts +1 -0
- package/lib/esm/resources/payment_methods.js +5 -2
- package/lib/esm/resources/payment_options.d.ts +1 -0
- package/lib/esm/resources/payment_options.js +5 -2
- package/lib/esm/resources/paypal_gateways.d.ts +1 -0
- package/lib/esm/resources/paypal_gateways.js +5 -2
- package/lib/esm/resources/paypal_payments.d.ts +1 -0
- package/lib/esm/resources/paypal_payments.js +5 -2
- package/lib/esm/resources/percentage_discount_promotions.d.ts +1 -0
- package/lib/esm/resources/percentage_discount_promotions.js +5 -2
- package/lib/esm/resources/price_frequency_tiers.d.ts +1 -0
- package/lib/esm/resources/price_frequency_tiers.js +5 -2
- package/lib/esm/resources/price_lists.d.ts +1 -0
- package/lib/esm/resources/price_lists.js +5 -2
- package/lib/esm/resources/price_tiers.d.ts +1 -0
- package/lib/esm/resources/price_tiers.js +5 -2
- package/lib/esm/resources/price_volume_tiers.d.ts +1 -0
- package/lib/esm/resources/price_volume_tiers.js +5 -2
- package/lib/esm/resources/prices.d.ts +1 -0
- package/lib/esm/resources/prices.js +5 -2
- package/lib/esm/resources/promotion_rules.d.ts +1 -0
- package/lib/esm/resources/promotion_rules.js +5 -2
- package/lib/esm/resources/promotions.d.ts +1 -0
- package/lib/esm/resources/promotions.js +5 -2
- package/lib/esm/resources/recurring_order_copies.d.ts +1 -0
- package/lib/esm/resources/recurring_order_copies.js +5 -2
- package/lib/esm/resources/refunds.d.ts +1 -0
- package/lib/esm/resources/refunds.js +5 -2
- package/lib/esm/resources/reserved_stocks.d.ts +1 -0
- package/lib/esm/resources/reserved_stocks.js +5 -2
- package/lib/esm/resources/resource_errors.d.ts +1 -0
- package/lib/esm/resources/resource_errors.js +5 -2
- package/lib/esm/resources/return_line_items.d.ts +1 -0
- package/lib/esm/resources/return_line_items.js +5 -2
- package/lib/esm/resources/returns.d.ts +1 -0
- package/lib/esm/resources/returns.js +5 -2
- package/lib/esm/resources/satispay_gateways.d.ts +1 -0
- package/lib/esm/resources/satispay_gateways.js +5 -2
- package/lib/esm/resources/satispay_payments.d.ts +1 -0
- package/lib/esm/resources/satispay_payments.js +5 -2
- package/lib/esm/resources/shipments.d.ts +1 -0
- package/lib/esm/resources/shipments.js +5 -2
- package/lib/esm/resources/shipping_categories.d.ts +1 -0
- package/lib/esm/resources/shipping_categories.js +5 -2
- package/lib/esm/resources/shipping_method_tiers.d.ts +1 -0
- package/lib/esm/resources/shipping_method_tiers.js +5 -2
- package/lib/esm/resources/shipping_methods.d.ts +1 -0
- package/lib/esm/resources/shipping_methods.js +5 -2
- package/lib/esm/resources/shipping_weight_tiers.d.ts +1 -0
- package/lib/esm/resources/shipping_weight_tiers.js +5 -2
- package/lib/esm/resources/shipping_zones.d.ts +1 -0
- package/lib/esm/resources/shipping_zones.js +5 -2
- package/lib/esm/resources/sku_list_items.d.ts +1 -0
- package/lib/esm/resources/sku_list_items.js +5 -2
- package/lib/esm/resources/sku_list_promotion_rules.d.ts +1 -0
- package/lib/esm/resources/sku_list_promotion_rules.js +5 -2
- package/lib/esm/resources/sku_lists.d.ts +1 -0
- package/lib/esm/resources/sku_lists.js +5 -2
- package/lib/esm/resources/sku_options.d.ts +1 -0
- package/lib/esm/resources/sku_options.js +5 -2
- package/lib/esm/resources/skus.d.ts +1 -0
- package/lib/esm/resources/skus.js +5 -2
- package/lib/esm/resources/stock_items.d.ts +1 -0
- package/lib/esm/resources/stock_items.js +5 -2
- package/lib/esm/resources/stock_line_items.d.ts +1 -0
- package/lib/esm/resources/stock_line_items.js +5 -2
- package/lib/esm/resources/stock_locations.d.ts +1 -0
- package/lib/esm/resources/stock_locations.js +5 -2
- package/lib/esm/resources/stock_reservations.d.ts +1 -0
- package/lib/esm/resources/stock_reservations.js +5 -2
- package/lib/esm/resources/stock_transfers.d.ts +1 -0
- package/lib/esm/resources/stock_transfers.js +5 -2
- package/lib/esm/resources/stripe_gateways.d.ts +1 -0
- package/lib/esm/resources/stripe_gateways.js +5 -2
- package/lib/esm/resources/stripe_payments.d.ts +1 -0
- package/lib/esm/resources/stripe_payments.js +5 -2
- package/lib/esm/resources/subscription_models.d.ts +1 -0
- package/lib/esm/resources/subscription_models.js +5 -2
- package/lib/esm/resources/tags.d.ts +1 -0
- package/lib/esm/resources/tags.js +5 -2
- package/lib/esm/resources/tax_calculators.d.ts +1 -0
- package/lib/esm/resources/tax_calculators.js +5 -2
- package/lib/esm/resources/tax_categories.d.ts +1 -0
- package/lib/esm/resources/tax_categories.js +5 -2
- package/lib/esm/resources/tax_rules.d.ts +1 -0
- package/lib/esm/resources/tax_rules.js +5 -2
- package/lib/esm/resources/taxjar_accounts.d.ts +1 -0
- package/lib/esm/resources/taxjar_accounts.js +5 -2
- package/lib/esm/resources/transactions.d.ts +1 -0
- package/lib/esm/resources/transactions.js +5 -2
- package/lib/esm/resources/versions.d.ts +1 -0
- package/lib/esm/resources/versions.js +5 -2
- package/lib/esm/resources/voids.d.ts +1 -0
- package/lib/esm/resources/voids.js +5 -2
- package/lib/esm/resources/webhooks.d.ts +1 -0
- package/lib/esm/resources/webhooks.js +5 -2
- package/lib/esm/resources/wire_transfers.d.ts +1 -0
- package/lib/esm/resources/wire_transfers.js +5 -2
- package/lib/esm/static.js +0 -1
- package/lib/esm/util.js +1 -27
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -17
@@ -22,6 +22,7 @@ declare class TaxCalculators extends ApiResource<TaxCalculator> {
|
|
22
22
|
versions(taxCalculatorId: string | TaxCalculator, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
23
23
|
isTaxCalculator(resource: any): resource is TaxCalculator;
|
24
24
|
relationship(id: string | ResourceId | null): TaxCalculatorRel;
|
25
|
+
relationshipToMany(...ids: string[]): TaxCalculatorRel[];
|
25
26
|
type(): TaxCalculatorType;
|
26
27
|
}
|
27
28
|
export default TaxCalculators;
|
@@ -18,7 +18,10 @@ class TaxCalculators extends resource_1.ApiResource {
|
|
18
18
|
return resource.type && (resource.type === TaxCalculators.TYPE);
|
19
19
|
}
|
20
20
|
relationship(id) {
|
21
|
-
return (
|
21
|
+
return super.relationshipOneToOne(id);
|
22
|
+
}
|
23
|
+
relationshipToMany(...ids) {
|
24
|
+
return super.relationshipOneToMany(...ids);
|
22
25
|
}
|
23
26
|
type() {
|
24
27
|
return TaxCalculators.TYPE;
|
@@ -57,6 +57,7 @@ declare class TaxCategories extends ApiResource<TaxCategory> {
|
|
57
57
|
versions(taxCategoryId: string | TaxCategory, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
58
58
|
isTaxCategory(resource: any): resource is TaxCategory;
|
59
59
|
relationship(id: string | ResourceId | null): TaxCategoryRel;
|
60
|
+
relationshipToMany(...ids: string[]): TaxCategoryRel[];
|
60
61
|
type(): TaxCategoryType;
|
61
62
|
}
|
62
63
|
export default TaxCategories;
|
@@ -27,7 +27,10 @@ class TaxCategories extends resource_1.ApiResource {
|
|
27
27
|
return resource.type && (resource.type === TaxCategories.TYPE);
|
28
28
|
}
|
29
29
|
relationship(id) {
|
30
|
-
return (
|
30
|
+
return super.relationshipOneToOne(id);
|
31
|
+
}
|
32
|
+
relationshipToMany(...ids) {
|
33
|
+
return super.relationshipOneToMany(...ids);
|
31
34
|
}
|
32
35
|
type() {
|
33
36
|
return TaxCategories.TYPE;
|
@@ -67,6 +67,7 @@ declare class TaxRules extends ApiResource<TaxRule> {
|
|
67
67
|
versions(taxRuleId: string | TaxRule, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
68
68
|
isTaxRule(resource: any): resource is TaxRule;
|
69
69
|
relationship(id: string | ResourceId | null): TaxRuleRel;
|
70
|
+
relationshipToMany(...ids: string[]): TaxRuleRel[];
|
70
71
|
type(): TaxRuleType;
|
71
72
|
}
|
72
73
|
export default TaxRules;
|
@@ -23,7 +23,10 @@ class TaxRules extends resource_1.ApiResource {
|
|
23
23
|
return resource.type && (resource.type === TaxRules.TYPE);
|
24
24
|
}
|
25
25
|
relationship(id) {
|
26
|
-
return (
|
26
|
+
return super.relationshipOneToOne(id);
|
27
|
+
}
|
28
|
+
relationshipToMany(...ids) {
|
29
|
+
return super.relationshipOneToMany(...ids);
|
27
30
|
}
|
28
31
|
type() {
|
29
32
|
return TaxRules.TYPE;
|
@@ -41,6 +41,7 @@ declare class TaxjarAccounts extends ApiResource<TaxjarAccount> {
|
|
41
41
|
tax_categories(taxjarAccountId: string | TaxjarAccount, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<TaxCategory>>;
|
42
42
|
isTaxjarAccount(resource: any): resource is TaxjarAccount;
|
43
43
|
relationship(id: string | ResourceId | null): TaxjarAccountRel;
|
44
|
+
relationshipToMany(...ids: string[]): TaxjarAccountRel[];
|
44
45
|
type(): TaxjarAccountType;
|
45
46
|
}
|
46
47
|
export default TaxjarAccounts;
|
@@ -31,7 +31,10 @@ class TaxjarAccounts extends resource_1.ApiResource {
|
|
31
31
|
return resource.type && (resource.type === TaxjarAccounts.TYPE);
|
32
32
|
}
|
33
33
|
relationship(id) {
|
34
|
-
return (
|
34
|
+
return super.relationshipOneToOne(id);
|
35
|
+
}
|
36
|
+
relationshipToMany(...ids) {
|
37
|
+
return super.relationshipOneToMany(...ids);
|
35
38
|
}
|
36
39
|
type() {
|
37
40
|
return TaxjarAccounts.TYPE;
|
@@ -35,6 +35,7 @@ declare class Transactions extends ApiResource<Transaction> {
|
|
35
35
|
versions(transactionId: string | Transaction, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
36
36
|
isTransaction(resource: any): resource is Transaction;
|
37
37
|
relationship(id: string | ResourceId | null): TransactionRel;
|
38
|
+
relationshipToMany(...ids: string[]): TransactionRel[];
|
38
39
|
type(): TransactionType;
|
39
40
|
}
|
40
41
|
export default Transactions;
|
@@ -22,7 +22,10 @@ class Transactions extends resource_1.ApiResource {
|
|
22
22
|
return resource.type && (resource.type === Transactions.TYPE);
|
23
23
|
}
|
24
24
|
relationship(id) {
|
25
|
-
return (
|
25
|
+
return super.relationshipOneToOne(id);
|
26
|
+
}
|
27
|
+
relationshipToMany(...ids) {
|
28
|
+
return super.relationshipOneToMany(...ids);
|
26
29
|
}
|
27
30
|
type() {
|
28
31
|
return Transactions.TYPE;
|
@@ -16,6 +16,7 @@ declare class Versions extends ApiResource<Version> {
|
|
16
16
|
static readonly TYPE: VersionType;
|
17
17
|
isVersion(resource: any): resource is Version;
|
18
18
|
relationship(id: string | ResourceId | null): VersionRel;
|
19
|
+
relationshipToMany(...ids: string[]): VersionRel[];
|
19
20
|
type(): VersionType;
|
20
21
|
}
|
21
22
|
export default Versions;
|
@@ -6,7 +6,10 @@ class Versions extends resource_1.ApiResource {
|
|
6
6
|
return resource.type && (resource.type === Versions.TYPE);
|
7
7
|
}
|
8
8
|
relationship(id) {
|
9
|
-
return (
|
9
|
+
return super.relationshipOneToOne(id);
|
10
|
+
}
|
11
|
+
relationshipToMany(...ids) {
|
12
|
+
return super.relationshipOneToMany(...ids);
|
10
13
|
}
|
11
14
|
type() {
|
12
15
|
return Versions.TYPE;
|
@@ -38,6 +38,7 @@ declare class Voids extends ApiResource<Void> {
|
|
38
38
|
reference_authorization(voidId: string | Void, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Authorization>;
|
39
39
|
isVoid(resource: any): resource is Void;
|
40
40
|
relationship(id: string | ResourceId | null): VoidRel;
|
41
|
+
relationshipToMany(...ids: string[]): VoidRel[];
|
41
42
|
type(): VoidType;
|
42
43
|
}
|
43
44
|
export default Voids;
|
@@ -26,7 +26,10 @@ class Voids extends resource_1.ApiResource {
|
|
26
26
|
return resource.type && (resource.type === Voids.TYPE);
|
27
27
|
}
|
28
28
|
relationship(id) {
|
29
|
-
return (
|
29
|
+
return super.relationshipOneToOne(id);
|
30
|
+
}
|
31
|
+
relationshipToMany(...ids) {
|
32
|
+
return super.relationshipOneToMany(...ids);
|
30
33
|
}
|
31
34
|
type() {
|
32
35
|
return Voids.TYPE;
|
@@ -49,6 +49,7 @@ declare class Webhooks extends ApiResource<Webhook> {
|
|
49
49
|
_reset_circuit(id: string | Webhook, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Webhook>;
|
50
50
|
isWebhook(resource: any): resource is Webhook;
|
51
51
|
relationship(id: string | ResourceId | null): WebhookRel;
|
52
|
+
relationshipToMany(...ids: string[]): WebhookRel[];
|
52
53
|
type(): WebhookType;
|
53
54
|
}
|
54
55
|
export default Webhooks;
|
@@ -32,7 +32,10 @@ class Webhooks extends resource_1.ApiResource {
|
|
32
32
|
return resource.type && (resource.type === Webhooks.TYPE);
|
33
33
|
}
|
34
34
|
relationship(id) {
|
35
|
-
return (
|
35
|
+
return super.relationshipOneToOne(id);
|
36
|
+
}
|
37
|
+
relationshipToMany(...ids) {
|
38
|
+
return super.relationshipOneToMany(...ids);
|
36
39
|
}
|
37
40
|
type() {
|
38
41
|
return Webhooks.TYPE;
|
@@ -31,6 +31,7 @@ declare class WireTransfers extends ApiResource<WireTransfer> {
|
|
31
31
|
versions(wireTransferId: string | WireTransfer, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
32
32
|
isWireTransfer(resource: any): resource is WireTransfer;
|
33
33
|
relationship(id: string | ResourceId | null): WireTransferRel;
|
34
|
+
relationshipToMany(...ids: string[]): WireTransferRel[];
|
34
35
|
type(): WireTransferType;
|
35
36
|
}
|
36
37
|
export default WireTransfers;
|
@@ -23,7 +23,10 @@ class WireTransfers extends resource_1.ApiResource {
|
|
23
23
|
return resource.type && (resource.type === WireTransfers.TYPE);
|
24
24
|
}
|
25
25
|
relationship(id) {
|
26
|
-
return (
|
26
|
+
return super.relationshipOneToOne(id);
|
27
|
+
}
|
28
|
+
relationshipToMany(...ids) {
|
29
|
+
return super.relationshipOneToMany(...ids);
|
27
30
|
}
|
28
31
|
type() {
|
29
32
|
return WireTransfers.TYPE;
|
package/lib/cjs/static.js
CHANGED
@@ -27,7 +27,6 @@ exports.CommerceLayerStatic = void 0;
|
|
27
27
|
const api = __importStar(require("./api"));
|
28
28
|
const error_1 = require("./error");
|
29
29
|
const commercelayer_1 = __importStar(require("./commercelayer"));
|
30
|
-
/* Static functions */
|
31
30
|
exports.CommerceLayerStatic = {
|
32
31
|
resources: (sort) => {
|
33
32
|
return sort ? [...api.resourceList].sort() : api.resourceList;
|
package/lib/cjs/util.js
CHANGED
package/lib/esm/api.d.ts
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
import type { Resource, ResourceRel } from './resource';
|
2
2
|
import type { TagType } from './resources/tags';
|
3
3
|
import type { VersionType } from './resources/versions';
|
4
|
-
/**
|
5
|
-
* ©2024 Commerce Layer Inc.
|
6
|
-
**/
|
7
4
|
export { default as Addresses } from './resources/addresses';
|
8
5
|
export { default as Adjustments } from './resources/adjustments';
|
9
6
|
export { default as AdyenGateways } from './resources/adyen_gateways';
|
package/lib/esm/api.js
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
// ##__API_RESOURCES_START__##
|
2
|
-
// ##__API_RESOURCES_TEMPLATE:: export { default as ##__RESOURCE_CLASS__## } from './resources/##__RESOURCE_TYPE__##'
|
3
|
-
/**
|
4
|
-
* ©2024 Commerce Layer Inc.
|
5
|
-
**/
|
6
1
|
export { default as Addresses } from './resources/addresses';
|
7
2
|
export { default as Adjustments } from './resources/adjustments';
|
8
3
|
export { default as AdyenGateways } from './resources/adyen_gateways';
|
@@ -124,9 +119,7 @@ export { default as Versions } from './resources/versions';
|
|
124
119
|
export { default as Voids } from './resources/voids';
|
125
120
|
export { default as Webhooks } from './resources/webhooks';
|
126
121
|
export { default as WireTransfers } from './resources/wire_transfers';
|
127
|
-
// ##__API_RESOURCE_TYPES_STOP__##
|
128
122
|
export const resourceList = [
|
129
|
-
// ##__API_RESOURCE_LIST_START__##
|
130
123
|
'addresses',
|
131
124
|
'adjustments',
|
132
125
|
'adyen_gateways',
|
@@ -248,11 +241,8 @@ export const resourceList = [
|
|
248
241
|
'voids',
|
249
242
|
'webhooks',
|
250
243
|
'wire_transfers'
|
251
|
-
// ##__API_RESOURCE_LIST_STOP__##
|
252
244
|
];
|
253
245
|
export const singletonList = [
|
254
|
-
// ##__API_RESOURCE_SINGLETON_START__##
|
255
246
|
'application',
|
256
247
|
'organization'
|
257
|
-
// ##__API_RESOURCE_SINGLETON_STOP__##
|
258
248
|
];
|
package/lib/esm/client.d.ts
CHANGED
@@ -1,19 +1,11 @@
|
|
1
|
-
import type { AxiosAdapter, AxiosProxyConfig, Method } from 'axios';
|
2
1
|
import type { InterceptorManager } from './interceptor';
|
3
|
-
type
|
4
|
-
type Adapter = AxiosAdapter;
|
2
|
+
import { type FetchResponse } from './fetch';
|
5
3
|
type RequestParams = Record<string, string | number | boolean>;
|
6
4
|
type RequestHeaders = Record<string, string>;
|
7
5
|
type RequestConfig = {
|
8
6
|
timeout?: number;
|
9
7
|
params?: RequestParams;
|
10
|
-
httpAgent?: any;
|
11
|
-
httpsAgent?: any;
|
12
|
-
proxy?: ProxyConfig;
|
13
8
|
headers?: RequestHeaders;
|
14
|
-
};
|
15
|
-
type RequestConfigExtra = {
|
16
|
-
adapter?: Adapter;
|
17
9
|
userAgent?: string;
|
18
10
|
};
|
19
11
|
type ApiConfig = {
|
@@ -21,18 +13,18 @@ type ApiConfig = {
|
|
21
13
|
domain?: string;
|
22
14
|
accessToken: string;
|
23
15
|
};
|
24
|
-
type ApiClientInitConfig = ApiConfig & RequestConfig
|
16
|
+
type ApiClientInitConfig = ApiConfig & RequestConfig;
|
25
17
|
type ApiClientConfig = Partial<ApiClientInitConfig>;
|
18
|
+
export type Method = 'GET' | 'DELETE' | 'POST' | 'PUT' | 'PATCH';
|
26
19
|
declare class ApiClient {
|
27
20
|
#private;
|
28
21
|
static create(options: ApiClientInitConfig): ApiClient;
|
29
|
-
baseUrl: string;
|
30
|
-
interceptors: InterceptorManager;
|
31
22
|
private constructor();
|
23
|
+
get interceptors(): InterceptorManager;
|
24
|
+
get requestHeaders(): RequestHeaders;
|
32
25
|
config(config: ApiClientConfig): ApiClient;
|
33
26
|
userAgent(userAgent: string): ApiClient;
|
34
|
-
|
35
|
-
request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<any>;
|
27
|
+
request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<FetchResponse>;
|
36
28
|
private customHeaders;
|
37
29
|
}
|
38
30
|
export default ApiClient;
|
package/lib/esm/client.js
CHANGED
@@ -1,21 +1,6 @@
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
6
|
-
};
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
11
|
-
};
|
12
|
-
var _ApiClient_accessToken, _ApiClient_client;
|
13
|
-
import axios from 'axios';
|
14
1
|
import { SdkError, handleError } from './error';
|
15
2
|
import config from './config';
|
16
|
-
|
17
|
-
// import type { Agent as HttpsAgent } from 'https'
|
18
|
-
// import { packageInfo } from './util'
|
3
|
+
import { fetchURL } from './fetch';
|
19
4
|
import Debug from './debug';
|
20
5
|
const debug = Debug('client');
|
21
6
|
const baseURL = (organization, domain) => {
|
@@ -28,112 +13,81 @@ class ApiClient {
|
|
28
13
|
throw new SdkError({ message: `Undefined '${attr}' parameter` });
|
29
14
|
return new ApiClient(options);
|
30
15
|
}
|
16
|
+
#baseUrl;
|
17
|
+
#accessToken;
|
18
|
+
#clientConfig;
|
19
|
+
#interceptors;
|
31
20
|
constructor(options) {
|
32
|
-
_ApiClient_accessToken.set(this, void 0);
|
33
|
-
_ApiClient_client.set(this, void 0);
|
34
21
|
debug('new client instance %O', options);
|
35
|
-
this
|
36
|
-
|
37
|
-
const
|
22
|
+
this.#baseUrl = baseURL(options.organization, options.domain);
|
23
|
+
this.#accessToken = options.accessToken;
|
24
|
+
const fetchConfig = {
|
38
25
|
timeout: options.timeout || config.client.timeout,
|
39
|
-
proxy: options.proxy,
|
40
|
-
httpAgent: options.httpAgent,
|
41
|
-
httpsAgent: options.httpsAgent
|
42
26
|
};
|
43
|
-
// Set custom headers
|
44
27
|
const customHeaders = this.customHeaders(options.headers);
|
45
|
-
// Set headers
|
46
28
|
const headers = {
|
47
29
|
...customHeaders,
|
48
30
|
'Accept': 'application/vnd.api+json',
|
49
31
|
'Content-Type': 'application/vnd.api+json',
|
50
|
-
'Authorization': 'Bearer ' +
|
32
|
+
'Authorization': 'Bearer ' + this.#accessToken
|
51
33
|
};
|
52
|
-
|
53
|
-
|
54
|
-
if (userAgent) {
|
55
|
-
if (!userAgent.includes('axios/'))
|
56
|
-
userAgent += ` axios/${axios.VERSION}`;
|
34
|
+
const userAgent = options.userAgent;
|
35
|
+
if (userAgent)
|
57
36
|
headers['User-Agent'] = userAgent;
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
if (
|
66
|
-
|
67
|
-
|
68
|
-
__classPrivateFieldSet(this, _ApiClient_client, axios.create(axiosOptions), "f");
|
69
|
-
this.interceptors = __classPrivateFieldGet(this, _ApiClient_client, "f").interceptors;
|
37
|
+
fetchConfig.headers = headers;
|
38
|
+
this.#clientConfig = fetchConfig;
|
39
|
+
debug('fetch config: %O', fetchConfig);
|
40
|
+
this.#interceptors = {};
|
41
|
+
}
|
42
|
+
get interceptors() { return this.#interceptors; }
|
43
|
+
get requestHeaders() {
|
44
|
+
if (!this.#clientConfig.headers)
|
45
|
+
this.#clientConfig.headers = {};
|
46
|
+
return this.#clientConfig.headers;
|
70
47
|
}
|
71
48
|
config(config) {
|
72
49
|
debug('config %o', config);
|
73
|
-
const def =
|
74
|
-
|
50
|
+
const def = this.#clientConfig;
|
51
|
+
if (!def.headers)
|
52
|
+
def.headers = {};
|
75
53
|
if (config.timeout)
|
76
54
|
def.timeout = config.timeout;
|
77
|
-
if (config.proxy)
|
78
|
-
def.proxy = config.proxy;
|
79
|
-
if (config.httpAgent)
|
80
|
-
def.httpAgent = config.httpAgent;
|
81
|
-
if (config.httpsAgent)
|
82
|
-
def.httpsAgent = config.httpsAgent;
|
83
|
-
if (config.adapter)
|
84
|
-
this.adapter(config.adapter);
|
85
55
|
if (config.userAgent)
|
86
56
|
this.userAgent(config.userAgent);
|
87
|
-
// API Client config
|
88
57
|
if (config.organization)
|
89
|
-
this
|
58
|
+
this.#baseUrl = baseURL(config.organization, config.domain);
|
90
59
|
if (config.accessToken) {
|
91
|
-
|
92
|
-
def.headers.
|
60
|
+
this.#accessToken = config.accessToken;
|
61
|
+
def.headers.Authorization = 'Bearer ' + this.#accessToken;
|
93
62
|
}
|
94
63
|
if (config.headers)
|
95
|
-
def.headers
|
64
|
+
def.headers = { ...def.headers, ...this.customHeaders(config.headers) };
|
96
65
|
return this;
|
97
66
|
}
|
98
67
|
userAgent(userAgent) {
|
99
|
-
if (userAgent)
|
100
|
-
|
101
|
-
if (!ua.includes('axios/')) {
|
102
|
-
// const axiosVer = packageInfo(['dependencies.axios'], { nestedName: true })
|
103
|
-
if (axios.VERSION)
|
104
|
-
ua += ` axios/${axios.VERSION}`;
|
105
|
-
}
|
106
|
-
__classPrivateFieldGet(this, _ApiClient_client, "f").defaults.headers['User-Agent'] = ua;
|
107
|
-
}
|
108
|
-
return this;
|
109
|
-
}
|
110
|
-
adapter(adapter) {
|
111
|
-
if (adapter)
|
112
|
-
__classPrivateFieldGet(this, _ApiClient_client, "f").defaults.adapter = adapter;
|
68
|
+
if (userAgent)
|
69
|
+
this.requestHeaders['User-Agent'] = userAgent;
|
113
70
|
return this;
|
114
71
|
}
|
115
72
|
async request(method, path, body, options) {
|
116
73
|
debug('request %s %s, %O, %O', method, path, body || {}, options || {});
|
117
|
-
|
118
|
-
if (options === null || options === void 0 ? void 0 : options.adapter)
|
119
|
-
debug('Adapter ignored in request config');
|
120
|
-
if (options === null || options === void 0 ? void 0 : options.userAgent)
|
74
|
+
if (options?.userAgent)
|
121
75
|
debug('User-Agent header ignored in request config');
|
122
|
-
const
|
123
|
-
const url = path;
|
124
|
-
|
125
|
-
const
|
126
|
-
const accessToken =
|
127
|
-
const headers = this.customHeaders(options === null || options === void 0 ? void 0 : options.headers);
|
76
|
+
const baseUrl = options?.organization ? baseURL(options.organization, options.domain) : this.#baseUrl;
|
77
|
+
const url = new URL(`${baseUrl}/${path}`);
|
78
|
+
const bodyData = body ? JSON.stringify({ data: body }) : undefined;
|
79
|
+
const headers = { ...this.requestHeaders, ...this.customHeaders(options?.headers) };
|
80
|
+
const accessToken = options?.accessToken || this.#accessToken;
|
128
81
|
if (accessToken)
|
129
82
|
headers.Authorization = 'Bearer ' + accessToken;
|
130
|
-
const
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
83
|
+
const fetchOptions = { method, body: bodyData, headers };
|
84
|
+
const timeout = options?.timeout || this.#clientConfig.timeout;
|
85
|
+
if (timeout)
|
86
|
+
fetchOptions.signal = AbortSignal.timeout(timeout);
|
87
|
+
if (options?.params)
|
88
|
+
Object.entries(options?.params).forEach(([name, value]) => { url.searchParams.append(name, String(value)); });
|
89
|
+
return await fetchURL(url, fetchOptions, this.interceptors)
|
135
90
|
.catch((error) => handleError(error));
|
136
|
-
// .finally(() => console.log(`<<-- ${method} ${path} ${Date.now() - start}`))
|
137
91
|
}
|
138
92
|
customHeaders(headers) {
|
139
93
|
const customHeaders = {};
|
@@ -145,5 +99,4 @@ class ApiClient {
|
|
145
99
|
return customHeaders;
|
146
100
|
}
|
147
101
|
}
|
148
|
-
_ApiClient_accessToken = new WeakMap(), _ApiClient_client = new WeakMap();
|
149
102
|
export default ApiClient;
|