@commercelayer/sdk 6.0.0-alfa.1 → 6.0.0-alfa.11
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 +39 -73
- package/lib/cjs/commercelayer.d.ts +128 -127
- package/lib/cjs/commercelayer.js +268 -156
- package/lib/cjs/common.js +0 -11
- package/lib/cjs/config.d.ts +3 -0
- package/lib/cjs/config.js +3 -2
- package/lib/cjs/debug.js +0 -21
- package/lib/cjs/error.d.ts +6 -7
- package/lib/cjs/error.js +35 -33
- 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 +24 -12
- package/lib/cjs/jsonapi.js +10 -7
- package/lib/cjs/model.d.ts +0 -3
- package/lib/cjs/model.js +0 -1
- package/lib/cjs/query.d.ts +3 -2
- package/lib/cjs/query.js +25 -7
- package/lib/cjs/resource.d.ts +4 -4
- package/lib/cjs/resource.js +14 -30
- 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 +4 -3
- package/lib/cjs/resources/events.js +8 -5
- 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 +2 -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 +4 -0
- package/lib/cjs/resources/shipments.js +8 -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 +37 -73
- package/lib/esm/commercelayer.d.ts +128 -127
- package/lib/esm/commercelayer.js +266 -278
- package/lib/esm/common.js +0 -11
- package/lib/esm/config.d.ts +3 -0
- package/lib/esm/config.js +3 -2
- package/lib/esm/debug.js +0 -21
- package/lib/esm/error.d.ts +6 -7
- package/lib/esm/error.js +35 -31
- 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 +24 -12
- package/lib/esm/jsonapi.js +10 -7
- package/lib/esm/model.d.ts +0 -3
- package/lib/esm/model.js +0 -1
- package/lib/esm/query.d.ts +3 -2
- package/lib/esm/query.js +24 -7
- package/lib/esm/resource.d.ts +4 -4
- package/lib/esm/resource.js +14 -30
- package/lib/esm/resources/addresses.d.ts +1 -0
- package/lib/esm/resources/addresses.js +4 -1
- package/lib/esm/resources/adjustments.d.ts +1 -0
- package/lib/esm/resources/adjustments.js +4 -1
- package/lib/esm/resources/adyen_gateways.d.ts +1 -0
- package/lib/esm/resources/adyen_gateways.js +4 -1
- package/lib/esm/resources/adyen_payments.d.ts +1 -0
- package/lib/esm/resources/adyen_payments.js +4 -1
- package/lib/esm/resources/application.d.ts +1 -0
- package/lib/esm/resources/application.js +4 -1
- package/lib/esm/resources/attachments.d.ts +1 -0
- package/lib/esm/resources/attachments.js +4 -1
- package/lib/esm/resources/authorizations.d.ts +1 -0
- package/lib/esm/resources/authorizations.js +4 -1
- package/lib/esm/resources/avalara_accounts.d.ts +1 -0
- package/lib/esm/resources/avalara_accounts.js +4 -1
- package/lib/esm/resources/axerve_gateways.d.ts +1 -0
- package/lib/esm/resources/axerve_gateways.js +4 -1
- package/lib/esm/resources/axerve_payments.d.ts +1 -0
- package/lib/esm/resources/axerve_payments.js +4 -1
- package/lib/esm/resources/billing_info_validation_rules.d.ts +1 -0
- package/lib/esm/resources/billing_info_validation_rules.js +4 -1
- package/lib/esm/resources/bing_geocoders.d.ts +1 -0
- package/lib/esm/resources/bing_geocoders.js +4 -1
- package/lib/esm/resources/braintree_gateways.d.ts +1 -0
- package/lib/esm/resources/braintree_gateways.js +4 -1
- package/lib/esm/resources/braintree_payments.d.ts +1 -0
- package/lib/esm/resources/braintree_payments.js +4 -1
- package/lib/esm/resources/bundles.d.ts +1 -0
- package/lib/esm/resources/bundles.js +4 -1
- package/lib/esm/resources/buy_x_pay_y_promotions.d.ts +1 -0
- package/lib/esm/resources/buy_x_pay_y_promotions.js +4 -1
- package/lib/esm/resources/captures.d.ts +1 -0
- package/lib/esm/resources/captures.js +4 -1
- package/lib/esm/resources/carrier_accounts.d.ts +1 -0
- package/lib/esm/resources/carrier_accounts.js +4 -1
- package/lib/esm/resources/checkout_com_gateways.d.ts +1 -0
- package/lib/esm/resources/checkout_com_gateways.js +4 -1
- package/lib/esm/resources/checkout_com_payments.d.ts +1 -0
- package/lib/esm/resources/checkout_com_payments.js +4 -1
- package/lib/esm/resources/cleanups.d.ts +1 -0
- package/lib/esm/resources/cleanups.js +4 -1
- package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +1 -0
- package/lib/esm/resources/coupon_codes_promotion_rules.js +4 -1
- package/lib/esm/resources/coupon_recipients.d.ts +1 -0
- package/lib/esm/resources/coupon_recipients.js +4 -1
- package/lib/esm/resources/coupons.d.ts +1 -0
- package/lib/esm/resources/coupons.js +4 -1
- package/lib/esm/resources/custom_promotion_rules.d.ts +1 -0
- package/lib/esm/resources/custom_promotion_rules.js +4 -1
- package/lib/esm/resources/customer_addresses.d.ts +1 -0
- package/lib/esm/resources/customer_addresses.js +4 -1
- package/lib/esm/resources/customer_groups.d.ts +1 -0
- package/lib/esm/resources/customer_groups.js +4 -1
- package/lib/esm/resources/customer_password_resets.d.ts +1 -0
- package/lib/esm/resources/customer_password_resets.js +4 -1
- package/lib/esm/resources/customer_payment_sources.d.ts +1 -0
- package/lib/esm/resources/customer_payment_sources.js +4 -1
- package/lib/esm/resources/customer_subscriptions.d.ts +1 -0
- package/lib/esm/resources/customer_subscriptions.js +4 -1
- package/lib/esm/resources/customers.d.ts +1 -0
- package/lib/esm/resources/customers.js +4 -1
- package/lib/esm/resources/delivery_lead_times.d.ts +1 -0
- package/lib/esm/resources/delivery_lead_times.js +4 -1
- package/lib/esm/resources/event_callbacks.d.ts +1 -0
- package/lib/esm/resources/event_callbacks.js +4 -1
- package/lib/esm/resources/events.d.ts +4 -3
- package/lib/esm/resources/events.js +8 -5
- package/lib/esm/resources/exports.d.ts +1 -0
- package/lib/esm/resources/exports.js +4 -1
- package/lib/esm/resources/external_gateways.d.ts +1 -0
- package/lib/esm/resources/external_gateways.js +4 -1
- package/lib/esm/resources/external_payments.d.ts +1 -0
- package/lib/esm/resources/external_payments.js +4 -1
- package/lib/esm/resources/external_promotions.d.ts +1 -0
- package/lib/esm/resources/external_promotions.js +4 -1
- package/lib/esm/resources/external_tax_calculators.d.ts +1 -0
- package/lib/esm/resources/external_tax_calculators.js +4 -1
- package/lib/esm/resources/fixed_amount_promotions.d.ts +1 -0
- package/lib/esm/resources/fixed_amount_promotions.js +4 -1
- package/lib/esm/resources/fixed_price_promotions.d.ts +1 -0
- package/lib/esm/resources/fixed_price_promotions.js +4 -1
- package/lib/esm/resources/free_gift_promotions.d.ts +1 -0
- package/lib/esm/resources/free_gift_promotions.js +4 -1
- package/lib/esm/resources/free_shipping_promotions.d.ts +1 -0
- package/lib/esm/resources/free_shipping_promotions.js +4 -1
- package/lib/esm/resources/geocoders.d.ts +1 -0
- package/lib/esm/resources/geocoders.js +4 -1
- package/lib/esm/resources/gift_card_recipients.d.ts +1 -0
- package/lib/esm/resources/gift_card_recipients.js +4 -1
- package/lib/esm/resources/gift_cards.d.ts +1 -0
- package/lib/esm/resources/gift_cards.js +4 -1
- package/lib/esm/resources/google_geocoders.d.ts +1 -0
- package/lib/esm/resources/google_geocoders.js +4 -1
- package/lib/esm/resources/imports.d.ts +1 -0
- package/lib/esm/resources/imports.js +4 -1
- package/lib/esm/resources/in_stock_subscriptions.d.ts +1 -0
- package/lib/esm/resources/in_stock_subscriptions.js +4 -1
- package/lib/esm/resources/inventory_models.d.ts +1 -0
- package/lib/esm/resources/inventory_models.js +4 -1
- package/lib/esm/resources/inventory_return_locations.d.ts +1 -0
- package/lib/esm/resources/inventory_return_locations.js +4 -1
- package/lib/esm/resources/inventory_stock_locations.d.ts +1 -0
- package/lib/esm/resources/inventory_stock_locations.js +4 -1
- package/lib/esm/resources/klarna_gateways.d.ts +1 -0
- package/lib/esm/resources/klarna_gateways.js +4 -1
- package/lib/esm/resources/klarna_payments.d.ts +1 -0
- package/lib/esm/resources/klarna_payments.js +4 -1
- package/lib/esm/resources/line_item_options.d.ts +1 -0
- package/lib/esm/resources/line_item_options.js +4 -1
- package/lib/esm/resources/line_items.d.ts +1 -0
- package/lib/esm/resources/line_items.js +4 -1
- package/lib/esm/resources/manual_gateways.d.ts +1 -0
- package/lib/esm/resources/manual_gateways.js +4 -1
- package/lib/esm/resources/manual_tax_calculators.d.ts +1 -0
- package/lib/esm/resources/manual_tax_calculators.js +4 -1
- package/lib/esm/resources/markets.d.ts +1 -0
- package/lib/esm/resources/markets.js +4 -1
- package/lib/esm/resources/merchants.d.ts +1 -0
- package/lib/esm/resources/merchants.js +4 -1
- package/lib/esm/resources/order_amount_promotion_rules.d.ts +1 -0
- package/lib/esm/resources/order_amount_promotion_rules.js +4 -1
- package/lib/esm/resources/order_copies.d.ts +1 -0
- package/lib/esm/resources/order_copies.js +4 -1
- package/lib/esm/resources/order_factories.d.ts +1 -0
- package/lib/esm/resources/order_factories.js +4 -1
- package/lib/esm/resources/order_subscription_items.d.ts +1 -0
- package/lib/esm/resources/order_subscription_items.js +4 -1
- package/lib/esm/resources/order_subscriptions.d.ts +1 -0
- package/lib/esm/resources/order_subscriptions.js +4 -1
- package/lib/esm/resources/order_validation_rules.d.ts +1 -0
- package/lib/esm/resources/order_validation_rules.js +4 -1
- package/lib/esm/resources/orders.d.ts +1 -0
- package/lib/esm/resources/orders.js +4 -1
- package/lib/esm/resources/organization.d.ts +2 -0
- package/lib/esm/resources/organization.js +4 -1
- package/lib/esm/resources/packages.d.ts +1 -0
- package/lib/esm/resources/packages.js +4 -1
- package/lib/esm/resources/parcel_line_items.d.ts +1 -0
- package/lib/esm/resources/parcel_line_items.js +4 -1
- package/lib/esm/resources/parcels.d.ts +1 -0
- package/lib/esm/resources/parcels.js +4 -1
- package/lib/esm/resources/payment_gateways.d.ts +1 -0
- package/lib/esm/resources/payment_gateways.js +4 -1
- package/lib/esm/resources/payment_methods.d.ts +1 -0
- package/lib/esm/resources/payment_methods.js +4 -1
- package/lib/esm/resources/payment_options.d.ts +1 -0
- package/lib/esm/resources/payment_options.js +4 -1
- package/lib/esm/resources/paypal_gateways.d.ts +1 -0
- package/lib/esm/resources/paypal_gateways.js +4 -1
- package/lib/esm/resources/paypal_payments.d.ts +1 -0
- package/lib/esm/resources/paypal_payments.js +4 -1
- package/lib/esm/resources/percentage_discount_promotions.d.ts +1 -0
- package/lib/esm/resources/percentage_discount_promotions.js +4 -1
- package/lib/esm/resources/price_frequency_tiers.d.ts +1 -0
- package/lib/esm/resources/price_frequency_tiers.js +4 -1
- package/lib/esm/resources/price_lists.d.ts +1 -0
- package/lib/esm/resources/price_lists.js +4 -1
- package/lib/esm/resources/price_tiers.d.ts +1 -0
- package/lib/esm/resources/price_tiers.js +4 -1
- package/lib/esm/resources/price_volume_tiers.d.ts +1 -0
- package/lib/esm/resources/price_volume_tiers.js +4 -1
- package/lib/esm/resources/prices.d.ts +1 -0
- package/lib/esm/resources/prices.js +4 -1
- package/lib/esm/resources/promotion_rules.d.ts +1 -0
- package/lib/esm/resources/promotion_rules.js +4 -1
- package/lib/esm/resources/promotions.d.ts +1 -0
- package/lib/esm/resources/promotions.js +4 -1
- package/lib/esm/resources/recurring_order_copies.d.ts +1 -0
- package/lib/esm/resources/recurring_order_copies.js +4 -1
- package/lib/esm/resources/refunds.d.ts +1 -0
- package/lib/esm/resources/refunds.js +4 -1
- package/lib/esm/resources/reserved_stocks.d.ts +1 -0
- package/lib/esm/resources/reserved_stocks.js +4 -1
- package/lib/esm/resources/resource_errors.d.ts +1 -0
- package/lib/esm/resources/resource_errors.js +4 -1
- package/lib/esm/resources/return_line_items.d.ts +1 -0
- package/lib/esm/resources/return_line_items.js +4 -1
- package/lib/esm/resources/returns.d.ts +1 -0
- package/lib/esm/resources/returns.js +4 -1
- package/lib/esm/resources/satispay_gateways.d.ts +1 -0
- package/lib/esm/resources/satispay_gateways.js +4 -1
- package/lib/esm/resources/satispay_payments.d.ts +1 -0
- package/lib/esm/resources/satispay_payments.js +4 -1
- package/lib/esm/resources/shipments.d.ts +4 -0
- package/lib/esm/resources/shipments.js +8 -1
- package/lib/esm/resources/shipping_categories.d.ts +1 -0
- package/lib/esm/resources/shipping_categories.js +4 -1
- package/lib/esm/resources/shipping_method_tiers.d.ts +1 -0
- package/lib/esm/resources/shipping_method_tiers.js +4 -1
- package/lib/esm/resources/shipping_methods.d.ts +1 -0
- package/lib/esm/resources/shipping_methods.js +4 -1
- package/lib/esm/resources/shipping_weight_tiers.d.ts +1 -0
- package/lib/esm/resources/shipping_weight_tiers.js +4 -1
- package/lib/esm/resources/shipping_zones.d.ts +1 -0
- package/lib/esm/resources/shipping_zones.js +4 -1
- package/lib/esm/resources/sku_list_items.d.ts +1 -0
- package/lib/esm/resources/sku_list_items.js +4 -1
- package/lib/esm/resources/sku_list_promotion_rules.d.ts +1 -0
- package/lib/esm/resources/sku_list_promotion_rules.js +4 -1
- package/lib/esm/resources/sku_lists.d.ts +1 -0
- package/lib/esm/resources/sku_lists.js +4 -1
- package/lib/esm/resources/sku_options.d.ts +1 -0
- package/lib/esm/resources/sku_options.js +4 -1
- package/lib/esm/resources/skus.d.ts +1 -0
- package/lib/esm/resources/skus.js +4 -1
- package/lib/esm/resources/stock_items.d.ts +1 -0
- package/lib/esm/resources/stock_items.js +4 -1
- package/lib/esm/resources/stock_line_items.d.ts +1 -0
- package/lib/esm/resources/stock_line_items.js +4 -1
- package/lib/esm/resources/stock_locations.d.ts +1 -0
- package/lib/esm/resources/stock_locations.js +4 -1
- package/lib/esm/resources/stock_reservations.d.ts +1 -0
- package/lib/esm/resources/stock_reservations.js +4 -1
- package/lib/esm/resources/stock_transfers.d.ts +1 -0
- package/lib/esm/resources/stock_transfers.js +4 -1
- package/lib/esm/resources/stripe_gateways.d.ts +1 -0
- package/lib/esm/resources/stripe_gateways.js +4 -1
- package/lib/esm/resources/stripe_payments.d.ts +1 -0
- package/lib/esm/resources/stripe_payments.js +4 -1
- package/lib/esm/resources/subscription_models.d.ts +1 -0
- package/lib/esm/resources/subscription_models.js +4 -1
- package/lib/esm/resources/tags.d.ts +1 -0
- package/lib/esm/resources/tags.js +4 -1
- package/lib/esm/resources/tax_calculators.d.ts +1 -0
- package/lib/esm/resources/tax_calculators.js +4 -1
- package/lib/esm/resources/tax_categories.d.ts +1 -0
- package/lib/esm/resources/tax_categories.js +4 -1
- package/lib/esm/resources/tax_rules.d.ts +1 -0
- package/lib/esm/resources/tax_rules.js +4 -1
- package/lib/esm/resources/taxjar_accounts.d.ts +1 -0
- package/lib/esm/resources/taxjar_accounts.js +4 -1
- package/lib/esm/resources/transactions.d.ts +1 -0
- package/lib/esm/resources/transactions.js +4 -1
- package/lib/esm/resources/versions.d.ts +1 -0
- package/lib/esm/resources/versions.js +4 -1
- package/lib/esm/resources/voids.d.ts +1 -0
- package/lib/esm/resources/voids.js +4 -1
- package/lib/esm/resources/webhooks.d.ts +1 -0
- package/lib/esm/resources/webhooks.js +4 -1
- package/lib/esm/resources/wire_transfers.d.ts +1 -0
- package/lib/esm/resources/wire_transfers.js +4 -1
- 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 +10 -14
package/lib/cjs/debug.js
CHANGED
@@ -1,37 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
/* Nope debugger */
|
4
3
|
const debuggerFunction = (_pattern, ..._args) => {
|
5
|
-
// console.log(_pattern)
|
6
4
|
};
|
7
5
|
let debuggerFactory = (_namespace) => debuggerFunction;
|
8
|
-
/* Try loading 'debug' module */
|
9
6
|
try {
|
10
7
|
const debugModule = require('debug');
|
11
8
|
if (debugModule && (typeof debugModule === 'function'))
|
12
9
|
debuggerFactory = debugModule;
|
13
10
|
}
|
14
11
|
catch (error) {
|
15
|
-
//
|
16
12
|
}
|
17
13
|
const debugPrefix = 'clsdk';
|
18
|
-
/* Retrieve the name of the caller 'module' */
|
19
|
-
/*
|
20
|
-
const caller = (): string => {
|
21
|
-
|
22
|
-
const err = new Error()
|
23
|
-
|
24
|
-
Error.prepareStackTrace = (_, stack) => stack
|
25
|
-
const stack = err.stack as unknown as NodeJS.CallSite[]
|
26
|
-
Error.prepareStackTrace = undefined
|
27
|
-
|
28
|
-
const fileName = stack[2].getFileName() || '/'
|
29
|
-
|
30
|
-
return fileName.replace(/^.*[\\/]/, '').replace('.ts', '')
|
31
|
-
|
32
|
-
}
|
33
|
-
*/
|
34
|
-
/* Return a debugger for the defined namespace */
|
35
14
|
const debug = (namespace) => {
|
36
15
|
return debuggerFactory(`${debugPrefix}:${namespace}`);
|
37
16
|
};
|
package/lib/cjs/error.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
declare enum ErrorType {
|
2
|
-
CLIENT = "client"
|
3
|
-
REQUEST = "request"
|
4
|
-
RESPONSE = "response"
|
5
|
-
CANCEL = "cancel"
|
6
|
-
PARSE = "parse"
|
7
|
-
|
2
|
+
CLIENT = "client",
|
3
|
+
REQUEST = "request",
|
4
|
+
RESPONSE = "response",
|
5
|
+
CANCEL = "cancel",
|
6
|
+
PARSE = "parse",
|
7
|
+
TIMEOUT = "timeout"
|
8
8
|
}
|
9
9
|
declare class SdkError extends Error {
|
10
10
|
static NAME: string;
|
@@ -12,7 +12,6 @@ declare class SdkError extends Error {
|
|
12
12
|
type: ErrorType;
|
13
13
|
code?: string;
|
14
14
|
source?: Error;
|
15
|
-
request?: any;
|
16
15
|
constructor(error: {
|
17
16
|
message: string;
|
18
17
|
type?: ErrorType;
|
package/lib/cjs/error.js
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
exports.handleError = exports.ErrorType = exports.ApiError = exports.SdkError = void 0;
|
7
|
-
const
|
4
|
+
const fetch_1 = require("./fetch");
|
8
5
|
var ErrorType;
|
9
6
|
(function (ErrorType) {
|
10
7
|
ErrorType["CLIENT"] = "client";
|
@@ -12,7 +9,7 @@ var ErrorType;
|
|
12
9
|
ErrorType["RESPONSE"] = "response";
|
13
10
|
ErrorType["CANCEL"] = "cancel";
|
14
11
|
ErrorType["PARSE"] = "parse";
|
15
|
-
ErrorType["
|
12
|
+
ErrorType["TIMEOUT"] = "timeout";
|
16
13
|
})(ErrorType || (exports.ErrorType = ErrorType = {}));
|
17
14
|
class SdkError extends Error {
|
18
15
|
static isSdkError(error) {
|
@@ -20,8 +17,8 @@ class SdkError extends Error {
|
|
20
17
|
}
|
21
18
|
constructor(error) {
|
22
19
|
super(error.message);
|
23
|
-
this.name = SdkError.NAME;
|
24
|
-
this.type = error.type || ErrorType.
|
20
|
+
this.name = SdkError.NAME;
|
21
|
+
this.type = error.type || ErrorType.CLIENT;
|
25
22
|
}
|
26
23
|
}
|
27
24
|
exports.SdkError = SdkError;
|
@@ -33,7 +30,7 @@ class ApiError extends SdkError {
|
|
33
30
|
constructor(error) {
|
34
31
|
super({ ...error, type: ErrorType.RESPONSE });
|
35
32
|
this.errors = [];
|
36
|
-
this.name = ApiError.NAME;
|
33
|
+
this.name = ApiError.NAME;
|
37
34
|
}
|
38
35
|
first() {
|
39
36
|
return (this.errors?.length > 0) ? this.errors[0] : undefined;
|
@@ -41,36 +38,41 @@ class ApiError extends SdkError {
|
|
41
38
|
}
|
42
39
|
exports.ApiError = ApiError;
|
43
40
|
ApiError.NAME = 'ApiError';
|
41
|
+
const isRequestError = (error) => {
|
42
|
+
return error instanceof TypeError;
|
43
|
+
};
|
44
|
+
const isCancelError = (error) => {
|
45
|
+
return (error instanceof DOMException) && (error.name === 'AbortError');
|
46
|
+
};
|
47
|
+
const isTimeoutError = (error) => {
|
48
|
+
return (error instanceof DOMException) && (error.name === 'TimeoutError');
|
49
|
+
};
|
44
50
|
const handleError = (error) => {
|
45
51
|
let sdkError = new SdkError({ message: error.message });
|
46
|
-
if (
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
apiError.
|
55
|
-
|
56
|
-
apiError.message = apiError.statusText;
|
57
|
-
sdkError = apiError;
|
58
|
-
}
|
59
|
-
else if (error.request) {
|
60
|
-
// The request was made but no response was received
|
61
|
-
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in node.js
|
62
|
-
sdkError.type = ErrorType.REQUEST;
|
63
|
-
sdkError.request = error.request;
|
64
|
-
}
|
65
|
-
else {
|
66
|
-
// Something happened in setting up the request that triggered an Error
|
67
|
-
sdkError.type = ErrorType.CLIENT;
|
68
|
-
}
|
52
|
+
if (fetch_1.FetchError.isFetchError(error)) {
|
53
|
+
const apiError = new ApiError(sdkError);
|
54
|
+
apiError.type = ErrorType.RESPONSE;
|
55
|
+
apiError.status = error.status;
|
56
|
+
apiError.statusText = error.statusText;
|
57
|
+
apiError.code = String(apiError.status);
|
58
|
+
apiError.errors = error.errors || [];
|
59
|
+
if (!apiError.message && apiError.statusText)
|
60
|
+
apiError.message = apiError.statusText;
|
61
|
+
sdkError = apiError;
|
69
62
|
}
|
70
|
-
else if (
|
63
|
+
else if (isRequestError(error)) {
|
64
|
+
sdkError.type = ErrorType.REQUEST;
|
65
|
+
}
|
66
|
+
else if (isCancelError(error)) {
|
71
67
|
sdkError.type = ErrorType.CANCEL;
|
72
|
-
|
68
|
+
}
|
69
|
+
else if (isTimeoutError(error)) {
|
70
|
+
sdkError.type = ErrorType.TIMEOUT;
|
71
|
+
}
|
72
|
+
else {
|
73
|
+
sdkError.type = ErrorType.CLIENT;
|
73
74
|
sdkError.source = error;
|
75
|
+
}
|
74
76
|
throw sdkError;
|
75
77
|
};
|
76
78
|
exports.handleError = handleError;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { DocWithData } from 'jsonapi-typescript';
|
2
|
+
import type { InterceptorManager } from './interceptor';
|
3
|
+
export type FetchResponse = DocWithData;
|
4
|
+
export type FetchOptions = RequestInit;
|
5
|
+
export declare class FetchError extends Error {
|
6
|
+
#private;
|
7
|
+
static isFetchError: (error: any) => error is FetchError;
|
8
|
+
constructor(status: number, statusText: string, body?: any);
|
9
|
+
get errors(): any[] | undefined;
|
10
|
+
get status(): number;
|
11
|
+
get statusText(): string;
|
12
|
+
}
|
13
|
+
export declare const fetchURL: (url: URL, options: FetchOptions, interceptors?: InterceptorManager) => Promise<FetchResponse>;
|
package/lib/cjs/fetch.js
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
5
|
+
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");
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
7
|
+
};
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
10
|
+
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");
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
12
|
+
};
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
|
+
};
|
16
|
+
var _FetchError_errors, _FetchError_status, _FetchError_statusText;
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
+
exports.fetchURL = exports.FetchError = void 0;
|
19
|
+
const debug_1 = __importDefault(require("./debug"));
|
20
|
+
const debug = (0, debug_1.default)('fetch');
|
21
|
+
class FetchError extends Error {
|
22
|
+
constructor(status, statusText, body) {
|
23
|
+
super(statusText);
|
24
|
+
_FetchError_errors.set(this, void 0);
|
25
|
+
_FetchError_status.set(this, void 0);
|
26
|
+
_FetchError_statusText.set(this, void 0);
|
27
|
+
__classPrivateFieldSet(this, _FetchError_status, status, "f");
|
28
|
+
__classPrivateFieldSet(this, _FetchError_statusText, statusText, "f");
|
29
|
+
if (body)
|
30
|
+
__classPrivateFieldSet(this, _FetchError_errors, body.errors, "f");
|
31
|
+
}
|
32
|
+
get errors() { return __classPrivateFieldGet(this, _FetchError_errors, "f"); }
|
33
|
+
get status() { return __classPrivateFieldGet(this, _FetchError_status, "f"); }
|
34
|
+
get statusText() { return __classPrivateFieldGet(this, _FetchError_statusText, "f"); }
|
35
|
+
}
|
36
|
+
exports.FetchError = FetchError;
|
37
|
+
_FetchError_errors = new WeakMap(), _FetchError_status = new WeakMap(), _FetchError_statusText = new WeakMap();
|
38
|
+
FetchError.isFetchError = (error) => {
|
39
|
+
return error instanceof FetchError;
|
40
|
+
};
|
41
|
+
const fetchURL = async (url, options, interceptors) => {
|
42
|
+
debug('fetch: %s, %O', url, options || {});
|
43
|
+
if (interceptors?.request?.onSuccess)
|
44
|
+
({ url, options } = await interceptors.request.onSuccess({ url, options }));
|
45
|
+
const request = new Request(url, options);
|
46
|
+
let response = await fetch(request);
|
47
|
+
if (response.ok) {
|
48
|
+
if (interceptors?.rawReader?.onSuccess)
|
49
|
+
await interceptors.rawReader.onSuccess(response);
|
50
|
+
if (interceptors?.response?.onSuccess)
|
51
|
+
response = await interceptors.response.onSuccess(response);
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
if (interceptors?.rawReader?.onFailure)
|
55
|
+
await interceptors.rawReader.onFailure(response);
|
56
|
+
}
|
57
|
+
const responseBody = await response.json().catch(() => { });
|
58
|
+
if (!response.ok) {
|
59
|
+
let error = new FetchError(response.status, response.statusText, responseBody);
|
60
|
+
if (interceptors?.response?.onFailure)
|
61
|
+
error = await interceptors.response.onFailure(error);
|
62
|
+
if (error)
|
63
|
+
throw error;
|
64
|
+
}
|
65
|
+
return responseBody;
|
66
|
+
};
|
67
|
+
exports.fetchURL = fetchURL;
|
package/lib/cjs/index.js
CHANGED
@@ -4,10 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.CommerceLayerStatic = exports.CommerceLayer = exports.default = void 0;
|
7
|
-
// SDK
|
8
7
|
var commercelayer_1 = require("./commercelayer");
|
9
8
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(commercelayer_1).default; } });
|
10
9
|
Object.defineProperty(exports, "CommerceLayer", { enumerable: true, get: function () { return commercelayer_1.CommerceLayer; } });
|
11
|
-
// Commerce Layer static functions
|
12
10
|
var static_1 = require("./static");
|
13
11
|
Object.defineProperty(exports, "CommerceLayerStatic", { enumerable: true, get: function () { return static_1.CommerceLayerStatic; } });
|
package/lib/cjs/interceptor.d.ts
CHANGED
@@ -1,25 +1,37 @@
|
|
1
|
-
import type {
|
1
|
+
import type { FetchError, FetchOptions } from "./fetch";
|
2
|
+
type InterceptorEventManager<S extends (RequestInterceptor | ResponseInterceptor), F extends (ErrorInterceptor | ResponseInterceptor)> = {
|
3
|
+
onSuccess?: S;
|
4
|
+
onFailure?: F;
|
5
|
+
};
|
6
|
+
type RequestEventManager = InterceptorEventManager<RequestInterceptor, ErrorInterceptor>;
|
7
|
+
type ResponseEventManager = InterceptorEventManager<ResponseInterceptor, ErrorInterceptor>;
|
8
|
+
type ErrorEventManager = InterceptorEventManager<ResponseInterceptor, ResponseInterceptor>;
|
2
9
|
type InterceptorManager = {
|
3
|
-
request
|
4
|
-
response
|
10
|
+
request?: RequestEventManager;
|
11
|
+
response?: ResponseEventManager;
|
12
|
+
rawReader?: ErrorEventManager;
|
13
|
+
};
|
14
|
+
type RequestObj = {
|
15
|
+
url: URL;
|
16
|
+
options: FetchOptions;
|
5
17
|
};
|
6
|
-
type RequestObj = AxiosRequestConfig;
|
7
18
|
type RequestInterceptor = (request: RequestObj) => RequestObj | Promise<RequestObj>;
|
8
|
-
type ResponseObj =
|
9
|
-
type ResponseInterceptor = (response: ResponseObj) => ResponseObj
|
19
|
+
type ResponseObj = Response;
|
20
|
+
type ResponseInterceptor = (response: ResponseObj) => ResponseObj | Promise<ResponseObj>;
|
10
21
|
type ApiHeadersList = 'x-ratelimit-limit' | 'x-ratelimit-count' | 'x-ratelimit-period' | 'x-ratelimit-interval' | 'x-ratelimit-remaining';
|
11
22
|
type ApiHeaders = {
|
12
23
|
[key in ApiHeadersList]: string | number | boolean;
|
13
24
|
};
|
14
|
-
type HeadersObj =
|
15
|
-
type ErrorObj =
|
16
|
-
type ErrorInterceptor = (error: ErrorObj) => ErrorObj
|
25
|
+
type HeadersObj = Record<string, string> | ApiHeaders;
|
26
|
+
type ErrorObj = FetchError;
|
27
|
+
type ErrorInterceptor = (error: ErrorObj) => ErrorObj | Promise<ErrorObj>;
|
17
28
|
type InterceptorType = 'request' | 'response';
|
18
29
|
export type { InterceptorManager, RequestInterceptor, ResponseInterceptor, ErrorInterceptor, InterceptorType };
|
19
30
|
export type { RequestObj, ResponseObj, ErrorObj, HeadersObj };
|
20
31
|
type RawResponseReader = {
|
21
|
-
id
|
22
|
-
rawResponse
|
23
|
-
headers
|
32
|
+
id?: number;
|
33
|
+
rawResponse?: any;
|
34
|
+
headers?: HeadersObj;
|
35
|
+
ok: boolean;
|
24
36
|
};
|
25
37
|
export type { RawResponseReader };
|
package/lib/cjs/jsonapi.js
CHANGED
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.normalize = exports.denormalize = void 0;
|
7
7
|
const common_1 = require("./common");
|
8
|
+
const config_1 = __importDefault(require("./config"));
|
8
9
|
const debug_1 = __importDefault(require("./debug"));
|
9
10
|
const debug = (0, debug_1.default)('jsonapi');
|
10
|
-
// DENORMALIZATION
|
11
11
|
const denormalize = (response) => {
|
12
12
|
let denormalizedResponse;
|
13
13
|
if (response.links)
|
@@ -31,7 +31,7 @@ const findIncluded = (rel, included = []) => {
|
|
31
31
|
});
|
32
32
|
return inc || rel;
|
33
33
|
};
|
34
|
-
const denormalizeResource = (res, included) => {
|
34
|
+
const denormalizeResource = (res, included, chain = []) => {
|
35
35
|
debug('denormalize resource: %O, %o', res, included || {});
|
36
36
|
if (!res)
|
37
37
|
return res;
|
@@ -44,10 +44,14 @@ const denormalizeResource = (res, included) => {
|
|
44
44
|
Object.keys(res.relationships).forEach(key => {
|
45
45
|
const rel = res.relationships[key].data;
|
46
46
|
if (rel) {
|
47
|
-
if (
|
48
|
-
resource[key] = rel
|
49
|
-
else
|
50
|
-
|
47
|
+
if (chain.filter(r => (r.id === rel.id) && (r.type === rel.type)).length >= config_1.default.jsonapi.maxResourceIncluded)
|
48
|
+
resource[key] = rel;
|
49
|
+
else {
|
50
|
+
if (Array.isArray(rel))
|
51
|
+
resource[key] = rel.map((r) => denormalizeResource(findIncluded(r, included), included, [...chain, r]));
|
52
|
+
else
|
53
|
+
resource[key] = denormalizeResource(findIncluded(rel, included), included, [...chain, rel]);
|
54
|
+
}
|
51
55
|
}
|
52
56
|
else if (rel === null)
|
53
57
|
resource[key] = null;
|
@@ -55,7 +59,6 @@ const denormalizeResource = (res, included) => {
|
|
55
59
|
debug('denormalized resource: %O', resource);
|
56
60
|
return resource;
|
57
61
|
};
|
58
|
-
// NORMALIZATION
|
59
62
|
const normalize = (resource) => {
|
60
63
|
debug('normalize resource: %O', resource);
|
61
64
|
const attributes = {};
|
package/lib/cjs/model.d.ts
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* ©2024 Commerce Layer Inc.
|
3
|
-
**/
|
4
1
|
export type { Address, AddressCreate, AddressUpdate } from './resources/addresses';
|
5
2
|
export type { Adjustment, AdjustmentCreate, AdjustmentUpdate } from './resources/adjustments';
|
6
3
|
export type { AdyenGateway, AdyenGatewayCreate, AdyenGatewayUpdate } from './resources/adyen_gateways';
|
package/lib/cjs/model.js
CHANGED
package/lib/cjs/query.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { ResourceType } from "./resource";
|
2
|
-
type QueryFilter = Record<string, string | number | boolean | object
|
2
|
+
type QueryFilter = Record<string, string | number | boolean | object | Array<string | number>>;
|
3
3
|
interface QueryParamsRetrieve {
|
4
4
|
include?: string[];
|
5
5
|
fields?: string[] | Record<string, string[]>;
|
@@ -14,4 +14,5 @@ type QueryParams = QueryParamsRetrieve | QueryParamsList;
|
|
14
14
|
export type { QueryParamsRetrieve, QueryParamsList, QueryParams, QueryFilter };
|
15
15
|
declare const isParamsList: (params: any) => params is QueryParamsList;
|
16
16
|
declare const generateQueryStringParams: (params: QueryParamsRetrieve | QueryParamsList | undefined, res: string | ResourceType) => Record<string, string>;
|
17
|
-
|
17
|
+
declare const generateSearchString: (params?: QueryParams, questionMark?: boolean) => string;
|
18
|
+
export { generateQueryStringParams, isParamsList, generateSearchString };
|
package/lib/cjs/query.js
CHANGED
@@ -3,9 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.isParamsList = exports.generateQueryStringParams = void 0;
|
6
|
+
exports.generateSearchString = exports.isParamsList = exports.generateQueryStringParams = void 0;
|
7
|
+
const error_1 = require("./error");
|
7
8
|
const debug_1 = __importDefault(require("./debug"));
|
8
9
|
const debug = (0, debug_1.default)('query');
|
10
|
+
const arrayFilters = ['_any', '_all', '_in'];
|
11
|
+
const objectFilters = ['_jcont'];
|
9
12
|
const isParamsList = (params) => {
|
10
13
|
return params && (params.filters || params.pageNumber || params.pageSize || params.sort);
|
11
14
|
};
|
@@ -15,10 +18,8 @@ const generateQueryStringParams = (params, res) => {
|
|
15
18
|
const qp = {};
|
16
19
|
if (!params)
|
17
20
|
return qp;
|
18
|
-
// Include
|
19
21
|
if (params.include)
|
20
22
|
qp.include = params.include.join(',');
|
21
|
-
// Fields
|
22
23
|
if (params.fields) {
|
23
24
|
if (Array.isArray(params.fields))
|
24
25
|
params.fields = { [res.type || res]: params.fields };
|
@@ -27,22 +28,33 @@ const generateQueryStringParams = (params, res) => {
|
|
27
28
|
});
|
28
29
|
}
|
29
30
|
if (isParamsList(params)) {
|
30
|
-
// Sort
|
31
31
|
if (params.sort) {
|
32
32
|
if (Array.isArray(params.sort))
|
33
33
|
qp.sort = params.sort.join(',');
|
34
34
|
else
|
35
35
|
qp.sort = Object.entries(params.sort).map(([k, v]) => `${v === 'desc' ? '-' : ''}${k}`).join(',');
|
36
36
|
}
|
37
|
-
// Page
|
38
37
|
if (params.pageNumber)
|
39
38
|
qp['page[number]'] = String(params.pageNumber);
|
40
39
|
if (params.pageSize)
|
41
40
|
qp['page[size]'] = String(params.pageSize);
|
42
|
-
// Filters
|
43
41
|
if (params.filters) {
|
44
42
|
Object.entries(params.filters).forEach(([p, v]) => {
|
45
|
-
|
43
|
+
const filter = p.substring(p.lastIndexOf('_'));
|
44
|
+
let val;
|
45
|
+
if (Array.isArray(v)) {
|
46
|
+
if (!arrayFilters.includes(filter))
|
47
|
+
throw new error_1.SdkError({ message: `Wrong ${filter} filter: Array value is supported only for the following filters: ${arrayFilters.join(', ')}`, type: error_1.ErrorType.REQUEST });
|
48
|
+
val = v.join(',');
|
49
|
+
}
|
50
|
+
else if (typeof v === 'object') {
|
51
|
+
if (!objectFilters.includes(filter))
|
52
|
+
throw new error_1.SdkError({ message: `Wrong ${filter} filter: Object value is supported only for the following filters: ${objectFilters.join(', ')}`, type: error_1.ErrorType.REQUEST });
|
53
|
+
val = JSON.stringify(v);
|
54
|
+
}
|
55
|
+
else
|
56
|
+
val = String(v);
|
57
|
+
qp[`filter[q][${p}]`] = val;
|
46
58
|
});
|
47
59
|
}
|
48
60
|
}
|
@@ -50,3 +62,9 @@ const generateQueryStringParams = (params, res) => {
|
|
50
62
|
return qp;
|
51
63
|
};
|
52
64
|
exports.generateQueryStringParams = generateQueryStringParams;
|
65
|
+
const generateSearchString = (params, questionMark = true) => {
|
66
|
+
if (!params || (Object.keys(params).length === 0))
|
67
|
+
return '';
|
68
|
+
return `${questionMark ? '?' : ''}${Object.entries(params).map(([key, val]) => `${key}=${String(val)}`).join('&')}`;
|
69
|
+
};
|
70
|
+
exports.generateSearchString = generateSearchString;
|
package/lib/cjs/resource.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { type ApiClientInitConfig } from './client';
|
1
|
+
import ApiClient, { type ApiClientInitConfig } from './client';
|
2
2
|
import type { QueryParamsRetrieve, QueryParamsList, QueryFilter, QueryParams } from './query';
|
3
3
|
import type { ResourceTypeLock } from './api';
|
4
|
-
import type { InterceptorManager } from './interceptor';
|
5
4
|
type ResourceNull = {
|
6
5
|
id: null;
|
7
6
|
} & ResourceType;
|
@@ -53,9 +52,9 @@ type ResourcesConfig = Partial<ResourcesInitConfig>;
|
|
53
52
|
declare class ResourceAdapter {
|
54
53
|
#private;
|
55
54
|
constructor(config: ResourcesInitConfig);
|
56
|
-
get interceptors(): InterceptorManager;
|
57
55
|
private localConfig;
|
58
56
|
config(config: ResourcesConfig): ResourceAdapter;
|
57
|
+
get client(): Readonly<ApiClient>;
|
59
58
|
singleton<R extends Resource>(resource: ResourceType, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
60
59
|
retrieve<R extends Resource>(resource: ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
61
60
|
list<R extends Resource>(resource: ResourceType, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<R>>;
|
@@ -69,8 +68,9 @@ declare abstract class ApiResourceBase<R extends Resource> {
|
|
69
68
|
protected readonly resources: ResourceAdapter;
|
70
69
|
constructor(adapter: ResourceAdapter);
|
71
70
|
abstract relationship(id: string | ResourceId | null): ResourceRel;
|
71
|
+
protected relationshipOneToOne<RR extends ResourceRel>(id: string | ResourceId | null): RR;
|
72
|
+
protected relationshipOneToMany<RR extends ResourceRel>(...ids: string[]): RR[];
|
72
73
|
abstract type(): ResourceTypeLock;
|
73
|
-
parse(resource: string): R | R[];
|
74
74
|
update(resource: ResourceUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
75
75
|
}
|
76
76
|
declare abstract class ApiResource<R extends Resource> extends ApiResourceBase<R> {
|
package/lib/cjs/resource.js
CHANGED
@@ -20,7 +20,6 @@ const client_1 = __importDefault(require("./client"));
|
|
20
20
|
const jsonapi_1 = require("./jsonapi");
|
21
21
|
const query_1 = require("./query");
|
22
22
|
const config_1 = __importDefault(require("./config"));
|
23
|
-
const error_1 = require("./error");
|
24
23
|
const debug_1 = __importDefault(require("./debug"));
|
25
24
|
const debug = (0, debug_1.default)('resource');
|
26
25
|
class ListResponse extends Array {
|
@@ -45,29 +44,23 @@ class ResourceAdapter {
|
|
45
44
|
__classPrivateFieldSet(this, _ResourceAdapter_client, client_1.default.create(config), "f");
|
46
45
|
this.localConfig(config);
|
47
46
|
}
|
48
|
-
get interceptors() { return __classPrivateFieldGet(this, _ResourceAdapter_client, "f").interceptors; }
|
49
47
|
localConfig(config) {
|
50
|
-
// if (typeof config.xyz !== 'undefined') this.#config.xyz = config.xyz
|
51
48
|
}
|
52
49
|
config(config) {
|
53
50
|
debug('config %o', config);
|
54
|
-
// ResourceAdapter config
|
55
51
|
this.localConfig(config);
|
56
|
-
// Client config
|
57
52
|
__classPrivateFieldGet(this, _ResourceAdapter_client, "f").config(config);
|
58
53
|
return this;
|
59
54
|
}
|
60
|
-
|
61
|
-
|
62
|
-
return this.#client
|
55
|
+
get client() {
|
56
|
+
return __classPrivateFieldGet(this, _ResourceAdapter_client, "f");
|
63
57
|
}
|
64
|
-
*/
|
65
58
|
async singleton(resource, params, options) {
|
66
59
|
debug('singleton: %o, %O, %O', resource, params || {}, options || {});
|
67
60
|
const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
|
68
61
|
if (options?.params)
|
69
62
|
Object.assign(queryParams, options?.params);
|
70
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('
|
63
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('GET', `${resource.type}`, undefined, { ...options, params: queryParams });
|
71
64
|
const r = (0, jsonapi_1.denormalize)(res);
|
72
65
|
return r;
|
73
66
|
}
|
@@ -76,7 +69,7 @@ class ResourceAdapter {
|
|
76
69
|
const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
|
77
70
|
if (options?.params)
|
78
71
|
Object.assign(queryParams, options?.params);
|
79
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('
|
72
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('GET', `${resource.type}/${resource.id}`, undefined, { ...options, params: queryParams });
|
80
73
|
const r = (0, jsonapi_1.denormalize)(res);
|
81
74
|
return r;
|
82
75
|
}
|
@@ -85,7 +78,7 @@ class ResourceAdapter {
|
|
85
78
|
const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
|
86
79
|
if (options?.params)
|
87
80
|
Object.assign(queryParams, options?.params);
|
88
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('
|
81
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('GET', `${resource.type}`, undefined, { ...options, params: queryParams });
|
89
82
|
const r = (0, jsonapi_1.denormalize)(res);
|
90
83
|
const meta = {
|
91
84
|
pageCount: Number(res.meta?.page_count),
|
@@ -101,7 +94,7 @@ class ResourceAdapter {
|
|
101
94
|
if (options?.params)
|
102
95
|
Object.assign(queryParams, options?.params);
|
103
96
|
const data = (0, jsonapi_1.normalize)(resource);
|
104
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('
|
97
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('POST', resource.type, data, { ...options, params: queryParams });
|
105
98
|
const r = (0, jsonapi_1.denormalize)(res);
|
106
99
|
return r;
|
107
100
|
}
|
@@ -111,20 +104,20 @@ class ResourceAdapter {
|
|
111
104
|
if (options?.params)
|
112
105
|
Object.assign(queryParams, options?.params);
|
113
106
|
const data = (0, jsonapi_1.normalize)(resource);
|
114
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('
|
107
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('PATCH', `${resource.type}/${resource.id}`, data, { ...options, params: queryParams });
|
115
108
|
const r = (0, jsonapi_1.denormalize)(res);
|
116
109
|
return r;
|
117
110
|
}
|
118
111
|
async delete(resource, options) {
|
119
112
|
debug('delete: %o, %O', resource, options || {});
|
120
|
-
await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('
|
113
|
+
await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('DELETE', `${resource.type}/${resource.id}`, undefined, options);
|
121
114
|
}
|
122
115
|
async fetch(resource, path, params, options) {
|
123
116
|
debug('fetch: %o, %O, %O', path, params || {}, options || {});
|
124
117
|
const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
|
125
118
|
if (options?.params)
|
126
119
|
Object.assign(queryParams, options?.params);
|
127
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('
|
120
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('GET', path, undefined, { ...options, params: queryParams });
|
128
121
|
const r = (0, jsonapi_1.denormalize)(res);
|
129
122
|
if (Array.isArray(r)) {
|
130
123
|
const p = params;
|
@@ -146,21 +139,12 @@ class ApiResourceBase {
|
|
146
139
|
debug('new resource instance: %s', this.type());
|
147
140
|
this.resources = adapter;
|
148
141
|
}
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
return (0, jsonapi_1.denormalize)(res);
|
155
|
-
}
|
156
|
-
catch (error) {
|
157
|
-
if (error_1.SdkError.isSdkError(error))
|
158
|
-
throw error;
|
159
|
-
else
|
160
|
-
throw new error_1.SdkError({ message: `Payload parse error [${error.message}]`, type: error_1.ErrorType.PARSE });
|
161
|
-
}
|
142
|
+
relationshipOneToOne(id) {
|
143
|
+
return (((id === null) || (typeof id === 'string')) ? { id, type: this.type() } : { id: id.id, type: this.type() });
|
144
|
+
}
|
145
|
+
relationshipOneToMany(...ids) {
|
146
|
+
return (((ids === null) || (ids.length === 0) || (ids[0] === null)) ? [{ id: null, type: this.type() }] : ids.map(id => { return { id, type: this.type() }; }));
|
162
147
|
}
|
163
|
-
// reference, reference_origin and metadata attributes are always updatable
|
164
148
|
async update(resource, params, options) {
|
165
149
|
return this.resources.update({ ...resource, type: this.type() }, params, options);
|
166
150
|
}
|
@@ -97,6 +97,7 @@ declare class Addresses extends ApiResource<Address> {
|
|
97
97
|
versions(addressId: string | Address, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
98
98
|
isAddress(resource: any): resource is Address;
|
99
99
|
relationship(id: string | ResourceId | null): AddressRel;
|
100
|
+
relationshipToMany(...ids: string[]): AddressRel[];
|
100
101
|
type(): AddressType;
|
101
102
|
}
|
102
103
|
export default Addresses;
|
@@ -31,7 +31,10 @@ class Addresses extends resource_1.ApiResource {
|
|
31
31
|
return resource.type && (resource.type === Addresses.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 Addresses.TYPE;
|
@@ -36,6 +36,7 @@ declare class Adjustments extends ApiResource<Adjustment> {
|
|
36
36
|
versions(adjustmentId: string | Adjustment, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
37
37
|
isAdjustment(resource: any): resource is Adjustment;
|
38
38
|
relationship(id: string | ResourceId | null): AdjustmentRel;
|
39
|
+
relationshipToMany(...ids: string[]): AdjustmentRel[];
|
39
40
|
type(): AdjustmentType;
|
40
41
|
}
|
41
42
|
export default Adjustments;
|