@commercelayer/sdk 4.34.0 → 4.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/api.d.ts +37 -0
- package/lib/cjs/api.js +0 -13
- package/lib/cjs/client.d.ts +15 -8
- package/lib/cjs/client.js +40 -40
- package/lib/cjs/commercelayer.d.ts +5 -6
- package/lib/cjs/commercelayer.js +8 -4
- package/lib/cjs/common.d.ts +1 -0
- package/lib/cjs/common.js +11 -2
- package/lib/cjs/config.d.ts +1 -0
- package/lib/cjs/config.js +3 -0
- package/lib/cjs/debug.js +0 -4
- package/lib/cjs/error.d.ts +3 -1
- package/lib/cjs/error.js +40 -7
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js +0 -16
- package/lib/cjs/interceptor.d.ts +6 -2
- package/lib/cjs/jsonapi.js +9 -2
- package/lib/cjs/query.d.ts +9 -15
- package/lib/cjs/query.js +3 -2
- package/lib/cjs/resource.d.ts +30 -20
- package/lib/cjs/resource.js +40 -9
- package/lib/cjs/resources/addresses.d.ts +74 -73
- package/lib/cjs/resources/addresses.js +3 -11
- package/lib/cjs/resources/adjustments.d.ts +20 -19
- package/lib/cjs/resources/adjustments.js +3 -11
- package/lib/cjs/resources/adyen_gateways.d.ts +35 -34
- package/lib/cjs/resources/adyen_gateways.js +3 -11
- package/lib/cjs/resources/adyen_payments.d.ts +29 -27
- package/lib/cjs/resources/adyen_payments.js +6 -11
- package/lib/cjs/resources/application.d.ts +14 -13
- package/lib/cjs/resources/application.js +1 -6
- package/lib/cjs/resources/attachments.d.ts +81 -80
- package/lib/cjs/resources/attachments.js +3 -11
- package/lib/cjs/resources/authorizations.d.ts +47 -43
- package/lib/cjs/resources/authorizations.js +10 -9
- package/lib/cjs/resources/avalara_accounts.d.ts +32 -31
- package/lib/cjs/resources/avalara_accounts.js +3 -11
- package/lib/cjs/resources/axerve_gateways.d.ts +24 -23
- package/lib/cjs/resources/axerve_gateways.js +3 -11
- package/lib/cjs/resources/axerve_payments.d.ts +28 -26
- package/lib/cjs/resources/axerve_payments.js +6 -11
- package/lib/cjs/resources/billing_info_validation_rules.d.ts +17 -16
- package/lib/cjs/resources/billing_info_validation_rules.js +3 -11
- package/lib/cjs/resources/bing_geocoders.d.ts +16 -15
- package/lib/cjs/resources/bing_geocoders.js +3 -11
- package/lib/cjs/resources/braintree_gateways.d.ts +34 -33
- package/lib/cjs/resources/braintree_gateways.js +3 -11
- package/lib/cjs/resources/braintree_payments.d.ts +30 -29
- package/lib/cjs/resources/braintree_payments.js +3 -11
- package/lib/cjs/resources/bundles.d.ts +57 -54
- package/lib/cjs/resources/bundles.js +9 -11
- package/lib/cjs/resources/captures.d.ts +37 -34
- package/lib/cjs/resources/captures.js +7 -9
- package/lib/cjs/resources/carrier_accounts.d.ts +16 -15
- package/lib/cjs/resources/carrier_accounts.js +0 -8
- package/lib/cjs/resources/checkout_com_gateways.d.ts +25 -24
- package/lib/cjs/resources/checkout_com_gateways.js +3 -11
- package/lib/cjs/resources/checkout_com_payments.d.ts +41 -38
- package/lib/cjs/resources/checkout_com_payments.js +9 -11
- package/lib/cjs/resources/cleanups.d.ts +24 -23
- package/lib/cjs/resources/cleanups.js +2 -10
- package/lib/cjs/resources/coupon_codes_promotion_rules.d.ts +31 -30
- package/lib/cjs/resources/coupon_codes_promotion_rules.js +3 -11
- package/lib/cjs/resources/coupon_recipients.d.ts +26 -25
- package/lib/cjs/resources/coupon_recipients.js +3 -11
- package/lib/cjs/resources/coupons.d.ts +39 -38
- package/lib/cjs/resources/coupons.js +3 -11
- package/lib/cjs/resources/customer_addresses.d.ts +23 -22
- package/lib/cjs/resources/customer_addresses.js +3 -11
- package/lib/cjs/resources/customer_groups.d.ts +17 -16
- package/lib/cjs/resources/customer_groups.js +3 -11
- package/lib/cjs/resources/customer_password_resets.d.ts +19 -17
- package/lib/cjs/resources/customer_password_resets.js +6 -11
- package/lib/cjs/resources/customer_payment_sources.d.ts +37 -36
- package/lib/cjs/resources/customer_payment_sources.js +3 -11
- package/lib/cjs/resources/customer_subscriptions.d.ts +15 -14
- package/lib/cjs/resources/customer_subscriptions.js +3 -11
- package/lib/cjs/resources/customers.d.ts +37 -36
- package/lib/cjs/resources/customers.js +3 -11
- package/lib/cjs/resources/delivery_lead_times.d.ts +27 -26
- package/lib/cjs/resources/delivery_lead_times.js +3 -11
- package/lib/cjs/resources/event_callbacks.d.ts +15 -14
- package/lib/cjs/resources/event_callbacks.js +0 -8
- package/lib/cjs/resources/events.d.ts +13 -12
- package/lib/cjs/resources/events.js +0 -8
- package/lib/cjs/resources/exports.d.ts +27 -26
- package/lib/cjs/resources/exports.js +2 -10
- package/lib/cjs/resources/external_gateways.d.ts +32 -31
- package/lib/cjs/resources/external_gateways.js +3 -11
- package/lib/cjs/resources/external_payments.d.ts +23 -22
- package/lib/cjs/resources/external_payments.js +3 -11
- package/lib/cjs/resources/external_promotions.d.ts +69 -60
- package/lib/cjs/resources/external_promotions.js +7 -11
- package/lib/cjs/resources/external_tax_calculators.d.ts +19 -18
- package/lib/cjs/resources/external_tax_calculators.js +3 -11
- package/lib/cjs/resources/fixed_amount_promotions.d.ts +70 -61
- package/lib/cjs/resources/fixed_amount_promotions.js +7 -11
- package/lib/cjs/resources/fixed_price_promotions.d.ts +74 -65
- package/lib/cjs/resources/fixed_price_promotions.js +7 -11
- package/lib/cjs/resources/free_gift_promotions.d.ts +73 -64
- package/lib/cjs/resources/free_gift_promotions.js +7 -11
- package/lib/cjs/resources/free_shipping_promotions.d.ts +66 -57
- package/lib/cjs/resources/free_shipping_promotions.js +7 -11
- package/lib/cjs/resources/geocoders.d.ts +13 -12
- package/lib/cjs/resources/geocoders.js +0 -8
- package/lib/cjs/resources/gift_card_recipients.d.ts +26 -25
- package/lib/cjs/resources/gift_card_recipients.js +3 -11
- package/lib/cjs/resources/gift_cards.d.ts +71 -66
- package/lib/cjs/resources/gift_cards.js +15 -11
- package/lib/cjs/resources/google_geocoders.d.ts +16 -15
- package/lib/cjs/resources/google_geocoders.js +3 -11
- package/lib/cjs/resources/imports.d.ts +32 -28
- package/lib/cjs/resources/imports.js +2 -10
- package/lib/cjs/resources/in_stock_subscriptions.d.ts +38 -35
- package/lib/cjs/resources/in_stock_subscriptions.js +9 -11
- package/lib/cjs/resources/inventory_models.d.ts +26 -25
- package/lib/cjs/resources/inventory_models.js +3 -11
- package/lib/cjs/resources/inventory_return_locations.d.ts +22 -21
- package/lib/cjs/resources/inventory_return_locations.js +3 -11
- package/lib/cjs/resources/inventory_stock_locations.d.ts +25 -24
- package/lib/cjs/resources/inventory_stock_locations.js +3 -11
- package/lib/cjs/resources/klarna_gateways.d.ts +23 -22
- package/lib/cjs/resources/klarna_gateways.js +3 -11
- package/lib/cjs/resources/klarna_payments.d.ts +29 -27
- package/lib/cjs/resources/klarna_payments.js +6 -11
- package/lib/cjs/resources/line_item_options.d.ts +41 -40
- package/lib/cjs/resources/line_item_options.js +3 -11
- package/lib/cjs/resources/line_items.d.ts +96 -89
- package/lib/cjs/resources/line_items.js +9 -11
- package/lib/cjs/resources/manual_gateways.d.ts +15 -14
- package/lib/cjs/resources/manual_gateways.js +3 -11
- package/lib/cjs/resources/manual_tax_calculators.d.ts +21 -20
- package/lib/cjs/resources/manual_tax_calculators.js +3 -11
- package/lib/cjs/resources/markets.d.ts +62 -59
- package/lib/cjs/resources/markets.js +9 -11
- package/lib/cjs/resources/merchants.d.ts +19 -18
- package/lib/cjs/resources/merchants.js +3 -11
- package/lib/cjs/resources/order_amount_promotion_rules.d.ts +34 -33
- package/lib/cjs/resources/order_amount_promotion_rules.js +3 -11
- package/lib/cjs/resources/order_copies.d.ts +29 -28
- package/lib/cjs/resources/order_copies.js +3 -11
- package/lib/cjs/resources/order_factories.d.ts +21 -20
- package/lib/cjs/resources/order_factories.js +0 -8
- package/lib/cjs/resources/order_subscription_items.d.ts +40 -35
- package/lib/cjs/resources/order_subscription_items.js +3 -11
- package/lib/cjs/resources/order_subscriptions.d.ts +55 -51
- package/lib/cjs/resources/order_subscriptions.js +12 -11
- package/lib/cjs/resources/order_validation_rules.d.ts +13 -12
- package/lib/cjs/resources/order_validation_rules.js +0 -8
- package/lib/cjs/resources/orders.d.ts +263 -233
- package/lib/cjs/resources/orders.js +84 -11
- package/lib/cjs/resources/organization.d.ts +25 -24
- package/lib/cjs/resources/organization.js +1 -6
- package/lib/cjs/resources/packages.d.ts +31 -30
- package/lib/cjs/resources/packages.js +3 -11
- package/lib/cjs/resources/parcel_line_items.d.ts +23 -22
- package/lib/cjs/resources/parcel_line_items.js +3 -11
- package/lib/cjs/resources/parcels.d.ts +94 -93
- package/lib/cjs/resources/parcels.js +3 -11
- package/lib/cjs/resources/payment_gateways.d.ts +13 -12
- package/lib/cjs/resources/payment_gateways.js +0 -8
- package/lib/cjs/resources/payment_methods.d.ts +51 -48
- package/lib/cjs/resources/payment_methods.js +9 -11
- package/lib/cjs/resources/paypal_gateways.d.ts +18 -17
- package/lib/cjs/resources/paypal_gateways.js +3 -11
- package/lib/cjs/resources/paypal_payments.d.ts +32 -31
- package/lib/cjs/resources/paypal_payments.js +3 -11
- package/lib/cjs/resources/percentage_discount_promotions.d.ts +73 -64
- package/lib/cjs/resources/percentage_discount_promotions.js +7 -11
- package/lib/cjs/resources/price_frequency_tiers.d.ts +27 -26
- package/lib/cjs/resources/price_frequency_tiers.js +3 -11
- package/lib/cjs/resources/price_lists.d.ts +21 -20
- package/lib/cjs/resources/price_lists.js +3 -11
- package/lib/cjs/resources/price_tiers.d.ts +18 -17
- package/lib/cjs/resources/price_tiers.js +0 -8
- package/lib/cjs/resources/price_volume_tiers.d.ts +27 -26
- package/lib/cjs/resources/price_volume_tiers.js +3 -11
- package/lib/cjs/resources/prices.d.ts +40 -39
- package/lib/cjs/resources/prices.js +3 -11
- package/lib/cjs/resources/promotion_rules.d.ts +12 -11
- package/lib/cjs/resources/promotion_rules.js +0 -8
- package/lib/cjs/resources/promotions.d.ts +30 -26
- package/lib/cjs/resources/promotions.js +4 -8
- package/lib/cjs/resources/recurring_order_copies.d.ts +29 -28
- package/lib/cjs/resources/recurring_order_copies.js +3 -11
- package/lib/cjs/resources/refunds.d.ts +26 -25
- package/lib/cjs/resources/refunds.js +0 -8
- package/lib/cjs/resources/reserved_stocks.d.ts +14 -13
- package/lib/cjs/resources/reserved_stocks.js +0 -8
- package/lib/cjs/resources/return_line_items.d.ts +29 -27
- package/lib/cjs/resources/return_line_items.js +6 -11
- package/lib/cjs/resources/returns.d.ts +59 -49
- package/lib/cjs/resources/returns.js +30 -11
- package/lib/cjs/resources/satispay_gateways.d.ts +23 -22
- package/lib/cjs/resources/satispay_gateways.js +3 -11
- package/lib/cjs/resources/satispay_payments.d.ts +31 -29
- package/lib/cjs/resources/satispay_payments.js +6 -11
- package/lib/cjs/resources/shipments.d.ts +65 -57
- package/lib/cjs/resources/shipments.js +22 -9
- package/lib/cjs/resources/shipping_categories.d.ts +16 -15
- package/lib/cjs/resources/shipping_categories.js +3 -11
- package/lib/cjs/resources/shipping_method_tiers.d.ts +18 -17
- package/lib/cjs/resources/shipping_method_tiers.js +0 -8
- package/lib/cjs/resources/shipping_methods.d.ts +80 -77
- package/lib/cjs/resources/shipping_methods.js +9 -11
- package/lib/cjs/resources/shipping_weight_tiers.d.ts +26 -25
- package/lib/cjs/resources/shipping_weight_tiers.js +3 -11
- package/lib/cjs/resources/shipping_zones.d.ts +33 -32
- package/lib/cjs/resources/shipping_zones.js +3 -11
- package/lib/cjs/resources/sku_list_items.d.ts +27 -26
- package/lib/cjs/resources/sku_list_items.js +3 -11
- package/lib/cjs/resources/sku_list_promotion_rules.d.ts +38 -37
- package/lib/cjs/resources/sku_list_promotion_rules.js +3 -11
- package/lib/cjs/resources/sku_lists.d.ts +36 -35
- package/lib/cjs/resources/sku_lists.js +3 -11
- package/lib/cjs/resources/sku_options.d.ts +44 -43
- package/lib/cjs/resources/sku_options.js +3 -11
- package/lib/cjs/resources/skus.d.ts +57 -56
- package/lib/cjs/resources/skus.js +3 -11
- package/lib/cjs/resources/stock_items.d.ts +29 -28
- package/lib/cjs/resources/stock_items.js +3 -11
- package/lib/cjs/resources/stock_line_items.d.ts +18 -17
- package/lib/cjs/resources/stock_line_items.js +0 -8
- package/lib/cjs/resources/stock_locations.d.ts +30 -29
- package/lib/cjs/resources/stock_locations.js +3 -11
- package/lib/cjs/resources/stock_reservations.d.ts +18 -17
- package/lib/cjs/resources/stock_reservations.js +0 -8
- package/lib/cjs/resources/stock_transfers.d.ts +48 -42
- package/lib/cjs/resources/stock_transfers.js +18 -11
- package/lib/cjs/resources/stripe_gateways.d.ts +23 -22
- package/lib/cjs/resources/stripe_gateways.js +3 -11
- package/lib/cjs/resources/stripe_payments.d.ts +35 -32
- package/lib/cjs/resources/stripe_payments.js +9 -11
- package/lib/cjs/resources/subscription_models.d.ts +27 -26
- package/lib/cjs/resources/subscription_models.js +3 -11
- package/lib/cjs/resources/tags.d.ts +13 -12
- package/lib/cjs/resources/tags.js +3 -11
- package/lib/cjs/resources/tax_calculators.d.ts +14 -13
- package/lib/cjs/resources/tax_calculators.js +0 -8
- package/lib/cjs/resources/tax_categories.d.ts +31 -30
- package/lib/cjs/resources/tax_categories.js +3 -11
- package/lib/cjs/resources/tax_rules.d.ts +52 -51
- package/lib/cjs/resources/tax_rules.js +3 -11
- package/lib/cjs/resources/taxjar_accounts.d.ts +22 -21
- package/lib/cjs/resources/taxjar_accounts.js +3 -11
- package/lib/cjs/resources/transactions.d.ts +24 -23
- package/lib/cjs/resources/transactions.js +0 -8
- package/lib/cjs/resources/versions.d.ts +14 -14
- package/lib/cjs/resources/versions.js +0 -8
- package/lib/cjs/resources/voids.d.ts +26 -25
- package/lib/cjs/resources/voids.js +0 -8
- package/lib/cjs/resources/webhooks.d.ts +28 -26
- package/lib/cjs/resources/webhooks.js +6 -11
- package/lib/cjs/resources/wire_transfers.d.ts +17 -16
- package/lib/cjs/resources/wire_transfers.js +3 -11
- package/lib/cjs/static.d.ts +1 -1
- package/lib/cjs/util.d.ts +1 -3
- package/lib/esm/api.d.ts +37 -0
- package/lib/esm/api.js +0 -13
- package/lib/esm/client.d.ts +15 -8
- package/lib/esm/client.js +40 -40
- package/lib/esm/commercelayer.d.ts +5 -6
- package/lib/esm/commercelayer.js +8 -4
- package/lib/esm/common.d.ts +1 -0
- package/lib/esm/common.js +11 -2
- package/lib/esm/config.d.ts +1 -0
- package/lib/esm/config.js +3 -0
- package/lib/esm/debug.js +0 -4
- package/lib/esm/error.d.ts +3 -1
- package/lib/esm/error.js +35 -5
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +0 -2
- package/lib/esm/interceptor.d.ts +6 -2
- package/lib/esm/jsonapi.js +9 -2
- package/lib/esm/query.d.ts +9 -15
- package/lib/esm/query.js +2 -2
- package/lib/esm/resource.d.ts +30 -20
- package/lib/esm/resource.js +40 -10
- package/lib/esm/resources/addresses.d.ts +74 -73
- package/lib/esm/resources/addresses.js +3 -11
- package/lib/esm/resources/adjustments.d.ts +20 -19
- package/lib/esm/resources/adjustments.js +3 -11
- package/lib/esm/resources/adyen_gateways.d.ts +35 -34
- package/lib/esm/resources/adyen_gateways.js +3 -11
- package/lib/esm/resources/adyen_payments.d.ts +29 -27
- package/lib/esm/resources/adyen_payments.js +6 -11
- package/lib/esm/resources/application.d.ts +14 -13
- package/lib/esm/resources/application.js +2 -7
- package/lib/esm/resources/attachments.d.ts +81 -80
- package/lib/esm/resources/attachments.js +3 -11
- package/lib/esm/resources/authorizations.d.ts +47 -43
- package/lib/esm/resources/authorizations.js +10 -9
- package/lib/esm/resources/avalara_accounts.d.ts +32 -31
- package/lib/esm/resources/avalara_accounts.js +3 -11
- package/lib/esm/resources/axerve_gateways.d.ts +24 -23
- package/lib/esm/resources/axerve_gateways.js +3 -11
- package/lib/esm/resources/axerve_payments.d.ts +28 -26
- package/lib/esm/resources/axerve_payments.js +6 -11
- package/lib/esm/resources/billing_info_validation_rules.d.ts +17 -16
- package/lib/esm/resources/billing_info_validation_rules.js +3 -11
- package/lib/esm/resources/bing_geocoders.d.ts +16 -15
- package/lib/esm/resources/bing_geocoders.js +3 -11
- package/lib/esm/resources/braintree_gateways.d.ts +34 -33
- package/lib/esm/resources/braintree_gateways.js +3 -11
- package/lib/esm/resources/braintree_payments.d.ts +30 -29
- package/lib/esm/resources/braintree_payments.js +3 -11
- package/lib/esm/resources/bundles.d.ts +57 -54
- package/lib/esm/resources/bundles.js +9 -11
- package/lib/esm/resources/captures.d.ts +37 -34
- package/lib/esm/resources/captures.js +7 -9
- package/lib/esm/resources/carrier_accounts.d.ts +16 -15
- package/lib/esm/resources/carrier_accounts.js +0 -8
- package/lib/esm/resources/checkout_com_gateways.d.ts +25 -24
- package/lib/esm/resources/checkout_com_gateways.js +3 -11
- package/lib/esm/resources/checkout_com_payments.d.ts +41 -38
- package/lib/esm/resources/checkout_com_payments.js +9 -11
- package/lib/esm/resources/cleanups.d.ts +24 -23
- package/lib/esm/resources/cleanups.js +2 -10
- package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +31 -30
- package/lib/esm/resources/coupon_codes_promotion_rules.js +3 -11
- package/lib/esm/resources/coupon_recipients.d.ts +26 -25
- package/lib/esm/resources/coupon_recipients.js +3 -11
- package/lib/esm/resources/coupons.d.ts +39 -38
- package/lib/esm/resources/coupons.js +3 -11
- package/lib/esm/resources/customer_addresses.d.ts +23 -22
- package/lib/esm/resources/customer_addresses.js +3 -11
- package/lib/esm/resources/customer_groups.d.ts +17 -16
- package/lib/esm/resources/customer_groups.js +3 -11
- package/lib/esm/resources/customer_password_resets.d.ts +19 -17
- package/lib/esm/resources/customer_password_resets.js +6 -11
- package/lib/esm/resources/customer_payment_sources.d.ts +37 -36
- package/lib/esm/resources/customer_payment_sources.js +3 -11
- package/lib/esm/resources/customer_subscriptions.d.ts +15 -14
- package/lib/esm/resources/customer_subscriptions.js +3 -11
- package/lib/esm/resources/customers.d.ts +37 -36
- package/lib/esm/resources/customers.js +3 -11
- package/lib/esm/resources/delivery_lead_times.d.ts +27 -26
- package/lib/esm/resources/delivery_lead_times.js +3 -11
- package/lib/esm/resources/event_callbacks.d.ts +15 -14
- package/lib/esm/resources/event_callbacks.js +0 -8
- package/lib/esm/resources/events.d.ts +13 -12
- package/lib/esm/resources/events.js +0 -8
- package/lib/esm/resources/exports.d.ts +27 -26
- package/lib/esm/resources/exports.js +2 -10
- package/lib/esm/resources/external_gateways.d.ts +32 -31
- package/lib/esm/resources/external_gateways.js +3 -11
- package/lib/esm/resources/external_payments.d.ts +23 -22
- package/lib/esm/resources/external_payments.js +3 -11
- package/lib/esm/resources/external_promotions.d.ts +69 -60
- package/lib/esm/resources/external_promotions.js +7 -11
- package/lib/esm/resources/external_tax_calculators.d.ts +19 -18
- package/lib/esm/resources/external_tax_calculators.js +3 -11
- package/lib/esm/resources/fixed_amount_promotions.d.ts +70 -61
- package/lib/esm/resources/fixed_amount_promotions.js +7 -11
- package/lib/esm/resources/fixed_price_promotions.d.ts +74 -65
- package/lib/esm/resources/fixed_price_promotions.js +7 -11
- package/lib/esm/resources/free_gift_promotions.d.ts +73 -64
- package/lib/esm/resources/free_gift_promotions.js +7 -11
- package/lib/esm/resources/free_shipping_promotions.d.ts +66 -57
- package/lib/esm/resources/free_shipping_promotions.js +7 -11
- package/lib/esm/resources/geocoders.d.ts +13 -12
- package/lib/esm/resources/geocoders.js +0 -8
- package/lib/esm/resources/gift_card_recipients.d.ts +26 -25
- package/lib/esm/resources/gift_card_recipients.js +3 -11
- package/lib/esm/resources/gift_cards.d.ts +71 -66
- package/lib/esm/resources/gift_cards.js +15 -11
- package/lib/esm/resources/google_geocoders.d.ts +16 -15
- package/lib/esm/resources/google_geocoders.js +3 -11
- package/lib/esm/resources/imports.d.ts +32 -28
- package/lib/esm/resources/imports.js +2 -10
- package/lib/esm/resources/in_stock_subscriptions.d.ts +38 -35
- package/lib/esm/resources/in_stock_subscriptions.js +9 -11
- package/lib/esm/resources/inventory_models.d.ts +26 -25
- package/lib/esm/resources/inventory_models.js +3 -11
- package/lib/esm/resources/inventory_return_locations.d.ts +22 -21
- package/lib/esm/resources/inventory_return_locations.js +3 -11
- package/lib/esm/resources/inventory_stock_locations.d.ts +25 -24
- package/lib/esm/resources/inventory_stock_locations.js +3 -11
- package/lib/esm/resources/klarna_gateways.d.ts +23 -22
- package/lib/esm/resources/klarna_gateways.js +3 -11
- package/lib/esm/resources/klarna_payments.d.ts +29 -27
- package/lib/esm/resources/klarna_payments.js +6 -11
- package/lib/esm/resources/line_item_options.d.ts +41 -40
- package/lib/esm/resources/line_item_options.js +3 -11
- package/lib/esm/resources/line_items.d.ts +96 -89
- package/lib/esm/resources/line_items.js +9 -11
- package/lib/esm/resources/manual_gateways.d.ts +15 -14
- package/lib/esm/resources/manual_gateways.js +3 -11
- package/lib/esm/resources/manual_tax_calculators.d.ts +21 -20
- package/lib/esm/resources/manual_tax_calculators.js +3 -11
- package/lib/esm/resources/markets.d.ts +62 -59
- package/lib/esm/resources/markets.js +9 -11
- package/lib/esm/resources/merchants.d.ts +19 -18
- package/lib/esm/resources/merchants.js +3 -11
- package/lib/esm/resources/order_amount_promotion_rules.d.ts +34 -33
- package/lib/esm/resources/order_amount_promotion_rules.js +3 -11
- package/lib/esm/resources/order_copies.d.ts +29 -28
- package/lib/esm/resources/order_copies.js +3 -11
- package/lib/esm/resources/order_factories.d.ts +21 -20
- package/lib/esm/resources/order_factories.js +0 -8
- package/lib/esm/resources/order_subscription_items.d.ts +40 -35
- package/lib/esm/resources/order_subscription_items.js +3 -11
- package/lib/esm/resources/order_subscriptions.d.ts +55 -51
- package/lib/esm/resources/order_subscriptions.js +12 -11
- package/lib/esm/resources/order_validation_rules.d.ts +13 -12
- package/lib/esm/resources/order_validation_rules.js +0 -8
- package/lib/esm/resources/orders.d.ts +263 -233
- package/lib/esm/resources/orders.js +84 -11
- package/lib/esm/resources/organization.d.ts +25 -24
- package/lib/esm/resources/organization.js +2 -7
- package/lib/esm/resources/packages.d.ts +31 -30
- package/lib/esm/resources/packages.js +3 -11
- package/lib/esm/resources/parcel_line_items.d.ts +23 -22
- package/lib/esm/resources/parcel_line_items.js +3 -11
- package/lib/esm/resources/parcels.d.ts +94 -93
- package/lib/esm/resources/parcels.js +3 -11
- package/lib/esm/resources/payment_gateways.d.ts +13 -12
- package/lib/esm/resources/payment_gateways.js +0 -8
- package/lib/esm/resources/payment_methods.d.ts +51 -48
- package/lib/esm/resources/payment_methods.js +9 -11
- package/lib/esm/resources/paypal_gateways.d.ts +18 -17
- package/lib/esm/resources/paypal_gateways.js +3 -11
- package/lib/esm/resources/paypal_payments.d.ts +32 -31
- package/lib/esm/resources/paypal_payments.js +3 -11
- package/lib/esm/resources/percentage_discount_promotions.d.ts +73 -64
- package/lib/esm/resources/percentage_discount_promotions.js +7 -11
- package/lib/esm/resources/price_frequency_tiers.d.ts +27 -26
- package/lib/esm/resources/price_frequency_tiers.js +3 -11
- package/lib/esm/resources/price_lists.d.ts +21 -20
- package/lib/esm/resources/price_lists.js +3 -11
- package/lib/esm/resources/price_tiers.d.ts +18 -17
- package/lib/esm/resources/price_tiers.js +0 -8
- package/lib/esm/resources/price_volume_tiers.d.ts +27 -26
- package/lib/esm/resources/price_volume_tiers.js +3 -11
- package/lib/esm/resources/prices.d.ts +40 -39
- package/lib/esm/resources/prices.js +3 -11
- package/lib/esm/resources/promotion_rules.d.ts +12 -11
- package/lib/esm/resources/promotion_rules.js +0 -8
- package/lib/esm/resources/promotions.d.ts +30 -26
- package/lib/esm/resources/promotions.js +4 -8
- package/lib/esm/resources/recurring_order_copies.d.ts +29 -28
- package/lib/esm/resources/recurring_order_copies.js +3 -11
- package/lib/esm/resources/refunds.d.ts +26 -25
- package/lib/esm/resources/refunds.js +0 -8
- package/lib/esm/resources/reserved_stocks.d.ts +14 -13
- package/lib/esm/resources/reserved_stocks.js +0 -8
- package/lib/esm/resources/return_line_items.d.ts +29 -27
- package/lib/esm/resources/return_line_items.js +6 -11
- package/lib/esm/resources/returns.d.ts +59 -49
- package/lib/esm/resources/returns.js +30 -11
- package/lib/esm/resources/satispay_gateways.d.ts +23 -22
- package/lib/esm/resources/satispay_gateways.js +3 -11
- package/lib/esm/resources/satispay_payments.d.ts +31 -29
- package/lib/esm/resources/satispay_payments.js +6 -11
- package/lib/esm/resources/shipments.d.ts +65 -57
- package/lib/esm/resources/shipments.js +22 -9
- package/lib/esm/resources/shipping_categories.d.ts +16 -15
- package/lib/esm/resources/shipping_categories.js +3 -11
- package/lib/esm/resources/shipping_method_tiers.d.ts +18 -17
- package/lib/esm/resources/shipping_method_tiers.js +0 -8
- package/lib/esm/resources/shipping_methods.d.ts +80 -77
- package/lib/esm/resources/shipping_methods.js +9 -11
- package/lib/esm/resources/shipping_weight_tiers.d.ts +26 -25
- package/lib/esm/resources/shipping_weight_tiers.js +3 -11
- package/lib/esm/resources/shipping_zones.d.ts +33 -32
- package/lib/esm/resources/shipping_zones.js +3 -11
- package/lib/esm/resources/sku_list_items.d.ts +27 -26
- package/lib/esm/resources/sku_list_items.js +3 -11
- package/lib/esm/resources/sku_list_promotion_rules.d.ts +38 -37
- package/lib/esm/resources/sku_list_promotion_rules.js +3 -11
- package/lib/esm/resources/sku_lists.d.ts +36 -35
- package/lib/esm/resources/sku_lists.js +3 -11
- package/lib/esm/resources/sku_options.d.ts +44 -43
- package/lib/esm/resources/sku_options.js +3 -11
- package/lib/esm/resources/skus.d.ts +57 -56
- package/lib/esm/resources/skus.js +3 -11
- package/lib/esm/resources/stock_items.d.ts +29 -28
- package/lib/esm/resources/stock_items.js +3 -11
- package/lib/esm/resources/stock_line_items.d.ts +18 -17
- package/lib/esm/resources/stock_line_items.js +0 -8
- package/lib/esm/resources/stock_locations.d.ts +30 -29
- package/lib/esm/resources/stock_locations.js +3 -11
- package/lib/esm/resources/stock_reservations.d.ts +18 -17
- package/lib/esm/resources/stock_reservations.js +0 -8
- package/lib/esm/resources/stock_transfers.d.ts +48 -42
- package/lib/esm/resources/stock_transfers.js +18 -11
- package/lib/esm/resources/stripe_gateways.d.ts +23 -22
- package/lib/esm/resources/stripe_gateways.js +3 -11
- package/lib/esm/resources/stripe_payments.d.ts +35 -32
- package/lib/esm/resources/stripe_payments.js +9 -11
- package/lib/esm/resources/subscription_models.d.ts +27 -26
- package/lib/esm/resources/subscription_models.js +3 -11
- package/lib/esm/resources/tags.d.ts +13 -12
- package/lib/esm/resources/tags.js +3 -11
- package/lib/esm/resources/tax_calculators.d.ts +14 -13
- package/lib/esm/resources/tax_calculators.js +0 -8
- package/lib/esm/resources/tax_categories.d.ts +31 -30
- package/lib/esm/resources/tax_categories.js +3 -11
- package/lib/esm/resources/tax_rules.d.ts +52 -51
- package/lib/esm/resources/tax_rules.js +3 -11
- package/lib/esm/resources/taxjar_accounts.d.ts +22 -21
- package/lib/esm/resources/taxjar_accounts.js +3 -11
- package/lib/esm/resources/transactions.d.ts +24 -23
- package/lib/esm/resources/transactions.js +0 -8
- package/lib/esm/resources/versions.d.ts +14 -14
- package/lib/esm/resources/versions.js +0 -8
- package/lib/esm/resources/voids.d.ts +26 -25
- package/lib/esm/resources/voids.js +0 -8
- package/lib/esm/resources/webhooks.d.ts +28 -26
- package/lib/esm/resources/webhooks.js +6 -11
- package/lib/esm/resources/wire_transfers.d.ts +17 -16
- package/lib/esm/resources/wire_transfers.js +3 -11
- package/lib/esm/static.d.ts +1 -1
- package/lib/esm/util.d.ts +1 -3
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/lib/cjs/micro.d.ts +0 -4
- package/lib/cjs/micro.js +0 -13
- package/lib/esm/micro.d.ts +0 -4
- package/lib/esm/micro.js +0 -7
package/lib/cjs/api.d.ts
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
import type { Resource, ResourceRel } from './resource';
|
2
|
+
import type { TagType } from './resources/tags';
|
3
|
+
import type { VersionType } from './resources/versions';
|
1
4
|
/**
|
2
5
|
* ©2023 Commerce Layer Inc.
|
3
6
|
**/
|
@@ -120,3 +123,37 @@ export { default as Webhooks } from './resources/webhooks';
|
|
120
123
|
export { default as WireTransfers } from './resources/wire_transfers';
|
121
124
|
export type ResourceTypeLock = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'application' | 'attachments' | 'authorizations' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'captures' | 'carrier_accounts' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'event_callbacks' | 'events' | 'exports' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'geocoders' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'imports' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_factories' | 'order_subscription_items' | 'order_subscriptions' | 'order_validation_rules' | 'orders' | 'organization' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_gateways' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_tiers' | 'price_volume_tiers' | 'prices' | 'promotion_rules' | 'promotions' | 'recurring_order_copies' | 'refunds' | 'reserved_stocks' | 'return_line_items' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipments' | 'shipping_categories' | 'shipping_method_tiers' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_line_items' | 'stock_locations' | 'stock_reservations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'subscription_models' | 'tags' | 'tax_calculators' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'transactions' | 'versions' | 'voids' | 'webhooks' | 'wire_transfers';
|
122
125
|
export declare const resourceList: readonly ["addresses", "adjustments", "adyen_gateways", "adyen_payments", "application", "attachments", "authorizations", "avalara_accounts", "axerve_gateways", "axerve_payments", "billing_info_validation_rules", "bing_geocoders", "braintree_gateways", "braintree_payments", "bundles", "captures", "carrier_accounts", "checkout_com_gateways", "checkout_com_payments", "cleanups", "coupon_codes_promotion_rules", "coupon_recipients", "coupons", "customer_addresses", "customer_groups", "customer_password_resets", "customer_payment_sources", "customer_subscriptions", "customers", "delivery_lead_times", "event_callbacks", "events", "exports", "external_gateways", "external_payments", "external_promotions", "external_tax_calculators", "fixed_amount_promotions", "fixed_price_promotions", "free_gift_promotions", "free_shipping_promotions", "geocoders", "gift_card_recipients", "gift_cards", "google_geocoders", "imports", "in_stock_subscriptions", "inventory_models", "inventory_return_locations", "inventory_stock_locations", "klarna_gateways", "klarna_payments", "line_item_options", "line_items", "manual_gateways", "manual_tax_calculators", "markets", "merchants", "order_amount_promotion_rules", "order_copies", "order_factories", "order_subscription_items", "order_subscriptions", "order_validation_rules", "orders", "organization", "packages", "parcel_line_items", "parcels", "payment_gateways", "payment_methods", "paypal_gateways", "paypal_payments", "percentage_discount_promotions", "price_frequency_tiers", "price_lists", "price_tiers", "price_volume_tiers", "prices", "promotion_rules", "promotions", "recurring_order_copies", "refunds", "reserved_stocks", "return_line_items", "returns", "satispay_gateways", "satispay_payments", "shipments", "shipping_categories", "shipping_method_tiers", "shipping_methods", "shipping_weight_tiers", "shipping_zones", "sku_list_items", "sku_list_promotion_rules", "sku_lists", "sku_options", "skus", "stock_items", "stock_line_items", "stock_locations", "stock_reservations", "stock_transfers", "stripe_gateways", "stripe_payments", "subscription_models", "tags", "tax_calculators", "tax_categories", "tax_rules", "taxjar_accounts", "transactions", "versions", "voids", "webhooks", "wire_transfers"];
|
126
|
+
export type RetrievableResourceType = ResourceTypeLock;
|
127
|
+
export type RetrievableResource = Resource & {
|
128
|
+
type: RetrievableResourceType;
|
129
|
+
};
|
130
|
+
export type ListableResourceType = Exclude<ResourceTypeLock, 'application' | 'organization'>;
|
131
|
+
export type ListableResource = Resource & {
|
132
|
+
type: ListableResourceType;
|
133
|
+
};
|
134
|
+
export type CreatableResourceType = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'attachments' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'exports' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'imports' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_subscription_items' | 'order_subscriptions' | 'orders' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_volume_tiers' | 'prices' | 'recurring_order_copies' | 'return_line_items' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipping_categories' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_locations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'subscription_models' | 'tags' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'webhooks' | 'wire_transfers';
|
135
|
+
export type CreatableResource = Resource & {
|
136
|
+
type: CreatableResourceType;
|
137
|
+
};
|
138
|
+
export type UpdatableResourceType = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'attachments' | 'authorizations' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'captures' | 'checkout_com_gateways' | 'checkout_com_payments' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_subscription_items' | 'order_subscriptions' | 'orders' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_volume_tiers' | 'prices' | 'recurring_order_copies' | 'return_line_items' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipments' | 'shipping_categories' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_locations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'subscription_models' | 'tags' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'webhooks' | 'wire_transfers';
|
139
|
+
export type UpdatableResource = Resource & {
|
140
|
+
type: UpdatableResourceType;
|
141
|
+
};
|
142
|
+
export type DeletableResourceType = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'attachments' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'exports' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'imports' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_subscription_items' | 'order_subscriptions' | 'orders' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_volume_tiers' | 'prices' | 'recurring_order_copies' | 'return_line_items' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipping_categories' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_locations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'subscription_models' | 'tags' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'webhooks' | 'wire_transfers';
|
143
|
+
export type DeletableResource = Resource & {
|
144
|
+
type: DeletableResourceType;
|
145
|
+
};
|
146
|
+
export type TaggableResourceType = 'addresses' | 'bundles' | 'coupons' | 'customers' | 'external_promotions' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_cards' | 'line_item_options' | 'line_items' | 'orders' | 'percentage_discount_promotions' | 'promotions' | 'returns' | 'sku_options' | 'skus';
|
147
|
+
export type TaggableResource = Resource & {
|
148
|
+
type: TaggableResourceType;
|
149
|
+
tags?: Array<ResourceRel & {
|
150
|
+
type: TagType;
|
151
|
+
}> | null;
|
152
|
+
};
|
153
|
+
export type VersionableResourceType = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'authorizations' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'captures' | 'carrier_accounts' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_payment_sources' | 'customer_subscriptions' | 'delivery_lead_times' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_card_recipients' | 'gift_cards' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_subscriptions' | 'order_validation_rules' | 'orders' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_gateways' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_tiers' | 'price_volume_tiers' | 'prices' | 'promotion_rules' | 'promotions' | 'refunds' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipments' | 'shipping_categories' | 'shipping_method_tiers' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_line_items' | 'stock_locations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'tax_calculators' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'transactions' | 'voids' | 'webhooks' | 'wire_transfers';
|
154
|
+
export type VersionableResource = Resource & {
|
155
|
+
type: VersionableResourceType;
|
156
|
+
versions?: Array<ResourceRel & {
|
157
|
+
type: VersionType;
|
158
|
+
}> | null;
|
159
|
+
};
|
package/lib/cjs/api.js
CHANGED
@@ -367,16 +367,3 @@ exports.resourceList = [
|
|
367
367
|
'wire_transfers'
|
368
368
|
// ##__API_RESOURCE_LIST_STOP__##
|
369
369
|
];
|
370
|
-
/*
|
371
|
-
type ResourceInfo = {
|
372
|
-
name: string;
|
373
|
-
type: string;
|
374
|
-
api: string;
|
375
|
-
}
|
376
|
-
|
377
|
-
|
378
|
-
export const resourceMap: { [res: string]: ResourceInfo } = {
|
379
|
-
// ##__API_RESOURCE_MAP_START__##
|
380
|
-
// ##__API_RESOURCE_MAP_STOP__##
|
381
|
-
} as const
|
382
|
-
*/
|
package/lib/cjs/client.d.ts
CHANGED
@@ -1,24 +1,29 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
/// <reference types="node" />
|
3
|
-
import { AxiosProxyConfig, Method } from 'axios';
|
3
|
+
import type { AxiosAdapter, AxiosProxyConfig, Method } from 'axios';
|
4
4
|
import type { InterceptorManager } from './interceptor';
|
5
5
|
import type { Agent as HttpAgent } from 'http';
|
6
6
|
import type { Agent as HttpsAgent } from 'https';
|
7
7
|
type ProxyConfig = AxiosProxyConfig | false;
|
8
|
+
type Adapter = AxiosAdapter;
|
9
|
+
type RequestParams = Record<string, string | number | boolean>;
|
10
|
+
type RequestHeaders = Record<string, string>;
|
8
11
|
type RequestConfig = {
|
9
12
|
timeout?: number;
|
10
|
-
params?:
|
11
|
-
[key: string]: string | number | boolean;
|
12
|
-
};
|
13
|
+
params?: RequestParams;
|
13
14
|
httpAgent?: HttpAgent;
|
14
15
|
httpsAgent?: HttpsAgent;
|
15
16
|
proxy?: ProxyConfig;
|
17
|
+
headers?: RequestHeaders;
|
16
18
|
};
|
17
|
-
type
|
19
|
+
type ApiConfig = {
|
18
20
|
organization: string;
|
19
21
|
domain?: string;
|
20
22
|
accessToken: string;
|
21
|
-
}
|
23
|
+
};
|
24
|
+
type ApiClientInitConfig = ApiConfig & RequestConfig & {
|
25
|
+
adapter?: Adapter;
|
26
|
+
};
|
22
27
|
type ApiClientConfig = Partial<ApiClientInitConfig>;
|
23
28
|
declare class ApiClient {
|
24
29
|
#private;
|
@@ -26,8 +31,10 @@ declare class ApiClient {
|
|
26
31
|
baseUrl: string;
|
27
32
|
interceptors: InterceptorManager;
|
28
33
|
private constructor();
|
29
|
-
config(config: ApiClientConfig):
|
34
|
+
config(config: ApiClientConfig): ApiClient;
|
35
|
+
adapter(adapter: Adapter): ApiClient;
|
30
36
|
request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<any>;
|
37
|
+
private customHeaders;
|
31
38
|
}
|
32
39
|
export default ApiClient;
|
33
|
-
export { ApiClientInitConfig, ApiClientConfig, RequestConfig };
|
40
|
+
export type { ApiClientInitConfig, ApiClientConfig, RequestConfig };
|
package/lib/cjs/client.js
CHANGED
@@ -15,7 +15,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
15
|
};
|
16
16
|
var _ApiClient_accessToken, _ApiClient_client;
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
19
18
|
const axios_1 = __importDefault(require("axios"));
|
20
19
|
const error_1 = require("./error");
|
21
20
|
const config_1 = __importDefault(require("./config"));
|
@@ -24,41 +23,11 @@ const debug = (0, debug_1.default)('client');
|
|
24
23
|
const baseURL = (organization, domain) => {
|
25
24
|
return `https://${organization.toLowerCase()}.${domain || config_1.default.default.domain}/api`;
|
26
25
|
};
|
27
|
-
const handleError = (error) => {
|
28
|
-
let sdkError = new error_1.SdkError({ message: error.message });
|
29
|
-
if (axios_1.default.isAxiosError(error)) {
|
30
|
-
if (error.response) {
|
31
|
-
// The request was made and the server responded with a status code that falls out of the range of 2xx
|
32
|
-
const apiError = new error_1.ApiError(sdkError);
|
33
|
-
apiError.type = error_1.ErrorType.RESPONSE;
|
34
|
-
apiError.status = error.response.status;
|
35
|
-
apiError.code = String(apiError.status);
|
36
|
-
apiError.errors = error.response.data.errors;
|
37
|
-
sdkError = apiError;
|
38
|
-
}
|
39
|
-
else if (error.request) {
|
40
|
-
// The request was made but no response was received
|
41
|
-
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in node.js
|
42
|
-
sdkError.type = error_1.ErrorType.REQUEST;
|
43
|
-
sdkError.request = error.request;
|
44
|
-
}
|
45
|
-
else {
|
46
|
-
// Something happened in setting up the request that triggered an Error
|
47
|
-
sdkError.type = error_1.ErrorType.CLIENT;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
else if (axios_1.default.isCancel(error))
|
51
|
-
sdkError.type = error_1.ErrorType.CANCEL;
|
52
|
-
else
|
53
|
-
sdkError.source = error;
|
54
|
-
throw sdkError;
|
55
|
-
};
|
56
26
|
class ApiClient {
|
57
27
|
static create(options) {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
throw new Error("Undefined 'accessToken' parameter");
|
28
|
+
for (const attr of config_1.default.client.requiredAttributes)
|
29
|
+
if (!options || !options[attr])
|
30
|
+
throw new error_1.SdkError({ message: `Undefined '${attr}' parameter` });
|
62
31
|
return new ApiClient(options);
|
63
32
|
}
|
64
33
|
constructor(options) {
|
@@ -73,11 +42,21 @@ class ApiClient {
|
|
73
42
|
httpAgent: options.httpAgent,
|
74
43
|
httpsAgent: options.httpsAgent,
|
75
44
|
};
|
76
|
-
|
45
|
+
// Set custom headers
|
46
|
+
const customHeaders = this.customHeaders(options.headers);
|
47
|
+
const axiosOptions = {
|
48
|
+
baseURL: this.baseUrl,
|
49
|
+
timeout: config_1.default.client.timeout,
|
50
|
+
headers: {
|
51
|
+
...customHeaders,
|
77
52
|
'Accept': 'application/vnd.api+json',
|
78
53
|
'Content-Type': 'application/vnd.api+json',
|
79
|
-
'Authorization': 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f")
|
80
|
-
}
|
54
|
+
'Authorization': 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f")
|
55
|
+
},
|
56
|
+
...axiosConfig
|
57
|
+
};
|
58
|
+
if (options.adapter)
|
59
|
+
axiosOptions.adapter = options.adapter;
|
81
60
|
debug('axios options: %O', axiosOptions);
|
82
61
|
__classPrivateFieldSet(this, _ApiClient_client, axios_1.default.create(axiosOptions), "f");
|
83
62
|
this.interceptors = __classPrivateFieldGet(this, _ApiClient_client, "f").interceptors;
|
@@ -101,6 +80,16 @@ class ApiClient {
|
|
101
80
|
__classPrivateFieldSet(this, _ApiClient_accessToken, config.accessToken, "f");
|
102
81
|
def.headers.common.Authorization = 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f");
|
103
82
|
}
|
83
|
+
if (config.headers)
|
84
|
+
def.headers.common = this.customHeaders(config.headers);
|
85
|
+
if (config.adapter)
|
86
|
+
this.adapter(config.adapter);
|
87
|
+
return this;
|
88
|
+
}
|
89
|
+
adapter(adapter) {
|
90
|
+
if (adapter)
|
91
|
+
__classPrivateFieldGet(this, _ApiClient_client, "f").defaults.adapter = adapter;
|
92
|
+
return this;
|
104
93
|
}
|
105
94
|
async request(method, path, body, options) {
|
106
95
|
debug('request %s %s, %O, %O', method, path, body || {}, options || {});
|
@@ -109,15 +98,26 @@ class ApiClient {
|
|
109
98
|
// Runtime request parameters
|
110
99
|
const baseUrl = (options === null || options === void 0 ? void 0 : options.organization) ? baseURL(options.organization, options.domain) : undefined;
|
111
100
|
const accessToken = (options === null || options === void 0 ? void 0 : options.accessToken) || __classPrivateFieldGet(this, _ApiClient_accessToken, "f");
|
112
|
-
const headers =
|
113
|
-
|
101
|
+
const headers = this.customHeaders(options === null || options === void 0 ? void 0 : options.headers);
|
102
|
+
if (accessToken)
|
103
|
+
headers.Authorization = 'Bearer ' + accessToken;
|
104
|
+
const requestParams = { method, baseURL: baseUrl, url, data, ...options, headers };
|
114
105
|
debug('request params: %O', requestParams);
|
115
106
|
// const start = Date.now()
|
116
107
|
return __classPrivateFieldGet(this, _ApiClient_client, "f").request(requestParams)
|
117
108
|
.then(response => response.data)
|
118
|
-
.catch(error => handleError(error));
|
109
|
+
.catch(error => (0, error_1.handleError)(error));
|
119
110
|
// .finally(() => console.log(`<<-- ${method} ${path} ${Date.now() - start}`))
|
120
111
|
}
|
112
|
+
customHeaders(headers) {
|
113
|
+
const customHeaders = {};
|
114
|
+
if (headers) {
|
115
|
+
for (const [name, value] of Object.entries(headers))
|
116
|
+
if (!['accept', 'content-type', 'authorization'].includes(name.toLowerCase()))
|
117
|
+
customHeaders[name] = value;
|
118
|
+
}
|
119
|
+
return customHeaders;
|
120
|
+
}
|
121
121
|
}
|
122
122
|
_ApiClient_accessToken = new WeakMap(), _ApiClient_client = new WeakMap();
|
123
123
|
exports.default = ApiClient;
|
@@ -1,16 +1,15 @@
|
|
1
1
|
import * as api from './api';
|
2
|
-
import { ApiError } from './error';
|
2
|
+
import type { ApiError } from './error';
|
3
3
|
import type { ErrorInterceptor, InterceptorType, RawResponseReader, RequestInterceptor, ResponseInterceptor } from './interceptor';
|
4
|
-
import { ResourcesInitConfig } from './resource';
|
5
|
-
declare const OPEN_API_SCHEMA_VERSION = "4.
|
4
|
+
import { type ResourcesInitConfig } from './resource';
|
5
|
+
declare const OPEN_API_SCHEMA_VERSION = "4.12.0";
|
6
6
|
export { OPEN_API_SCHEMA_VERSION };
|
7
7
|
type SdkConfig = {};
|
8
8
|
type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig;
|
9
9
|
type CommerceLayerConfig = Partial<CommerceLayerInitConfig>;
|
10
10
|
declare class CommerceLayerClient {
|
11
11
|
#private;
|
12
|
-
|
13
|
-
readonly openApiSchemaVersion = "4.11.0";
|
12
|
+
readonly openApiSchemaVersion = "4.12.0";
|
14
13
|
addresses: api.Addresses;
|
15
14
|
adjustments: api.Adjustments;
|
16
15
|
adyen_gateways: api.AdyenGateways;
|
@@ -131,7 +130,7 @@ declare class CommerceLayerClient {
|
|
131
130
|
constructor(config: CommerceLayerInitConfig);
|
132
131
|
get currentOrganization(): string;
|
133
132
|
private localConfig;
|
134
|
-
config(config: CommerceLayerConfig):
|
133
|
+
config(config: CommerceLayerConfig): CommerceLayerClient;
|
135
134
|
resources(): readonly string[];
|
136
135
|
isApiError(error: any): error is ApiError;
|
137
136
|
addRequestInterceptor(onFulfilled?: RequestInterceptor, onRejected?: ErrorInterceptor): number;
|
package/lib/cjs/commercelayer.js
CHANGED
@@ -45,18 +45,19 @@ const resource_1 = __importDefault(require("./resource"));
|
|
45
45
|
const debug_1 = __importDefault(require("./debug"));
|
46
46
|
const debug = (0, debug_1.default)('commercelayer');
|
47
47
|
// Autogenerated schema version number, do not remove this line
|
48
|
-
const OPEN_API_SCHEMA_VERSION = '4.
|
48
|
+
const OPEN_API_SCHEMA_VERSION = '4.12.0';
|
49
49
|
exports.OPEN_API_SCHEMA_VERSION = OPEN_API_SCHEMA_VERSION;
|
50
50
|
class CommerceLayerClient {
|
51
|
-
static get openApiSchemaVersion() { return OPEN_API_SCHEMA_VERSION; }
|
52
51
|
// ##__CL_RESOURCES_DEF_STOP__##
|
53
52
|
constructor(config) {
|
53
|
+
// static get openApiSchemaVersion(): string { return OPEN_API_SCHEMA_VERSION }
|
54
54
|
this.openApiSchemaVersion = OPEN_API_SCHEMA_VERSION;
|
55
55
|
_CommerceLayerClient_adapter.set(this, void 0);
|
56
56
|
_CommerceLayerClient_organization.set(this, void 0);
|
57
57
|
debug('new commercelayer instance %O', config);
|
58
58
|
__classPrivateFieldSet(this, _CommerceLayerClient_adapter, new resource_1.default(config), "f");
|
59
59
|
__classPrivateFieldSet(this, _CommerceLayerClient_organization, config.organization, "f");
|
60
|
+
// this.#environment = 'test'
|
60
61
|
// ##__CL_RESOURCES_INIT_START__##
|
61
62
|
// ##__CL_RESOURCES_INIT_TEMPLATE:: ##__TAB__####__TAB__##this.##__RESOURCE_TYPE__## = new api.##__RESOURCE_CLASS__##(this.#adapter)
|
62
63
|
this.addresses = new api.Addresses(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
@@ -179,6 +180,8 @@ class CommerceLayerClient {
|
|
179
180
|
// ##__CL_RESOURCES_INIT_STOP__##
|
180
181
|
}
|
181
182
|
get currentOrganization() { return __classPrivateFieldGet(this, _CommerceLayerClient_organization, "f"); }
|
183
|
+
// get currentAccessToken(): string { return this.#adapter?.clientInstance?.currentAccessToken}
|
184
|
+
// get environment(): ApiMode { return this.#environment }
|
182
185
|
localConfig(config) {
|
183
186
|
if (config.organization)
|
184
187
|
__classPrivateFieldSet(this, _CommerceLayerClient_organization, config.organization, "f");
|
@@ -192,6 +195,7 @@ class CommerceLayerClient {
|
|
192
195
|
if (!config.organization)
|
193
196
|
config.organization = this.currentOrganization;
|
194
197
|
__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f").config(config);
|
198
|
+
return this;
|
195
199
|
}
|
196
200
|
resources() {
|
197
201
|
return static_1.CommerceLayerStatic.resources();
|
@@ -207,7 +211,7 @@ class CommerceLayerClient {
|
|
207
211
|
return __classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f").interceptors.response.use(onFulfilled, onRejected);
|
208
212
|
}
|
209
213
|
removeInterceptor(type, id) {
|
210
|
-
|
214
|
+
__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f").interceptors[type].eject(id);
|
211
215
|
}
|
212
216
|
addRawResponseReader(options) {
|
213
217
|
const reader = {
|
@@ -228,7 +232,7 @@ class CommerceLayerClient {
|
|
228
232
|
removeRawResponseReader(reader) {
|
229
233
|
const id = (typeof reader === 'number') ? reader : reader === null || reader === void 0 ? void 0 : reader.id;
|
230
234
|
if (id && (id >= 0))
|
231
|
-
|
235
|
+
this.removeInterceptor('response', id);
|
232
236
|
}
|
233
237
|
}
|
234
238
|
_CommerceLayerClient_adapter = new WeakMap(), _CommerceLayerClient_organization = new WeakMap();
|
package/lib/cjs/common.d.ts
CHANGED
@@ -2,3 +2,4 @@ import type { ResourceId, ResourceType } from './resource';
|
|
2
2
|
declare const isResourceId: (resource: any) => resource is ResourceId;
|
3
3
|
declare const isResourceType: (resource: any) => resource is ResourceType;
|
4
4
|
export { isResourceId, isResourceType };
|
5
|
+
export type ObjectType = Record<string, any>;
|
package/lib/cjs/common.js
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
3
|
-
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
4
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5
3
|
exports.isResourceType = exports.isResourceId = void 0;
|
6
4
|
const api_1 = require("./api");
|
@@ -12,3 +10,14 @@ const isResourceType = (resource) => {
|
|
12
10
|
return resource && (typeof resource.type !== 'undefined') && resource.type && api_1.resourceList.includes(resource.type);
|
13
11
|
};
|
14
12
|
exports.isResourceType = isResourceType;
|
13
|
+
/*
|
14
|
+
// Nullable types
|
15
|
+
type StringNullable = string | null
|
16
|
+
type NumberNullable = number | null
|
17
|
+
type BooleanNullable = boolean | null
|
18
|
+
type ResourceNullable<R extends Resource> = R | null
|
19
|
+
type ResourceArrayNullable<R extends Resource> = R[] | null
|
20
|
+
|
21
|
+
|
22
|
+
export type { StringNullable, NumberNullable, BooleanNullable, ResourceNullable, ResourceArrayNullable }
|
23
|
+
*/
|
package/lib/cjs/config.d.ts
CHANGED
package/lib/cjs/config.js
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
"use strict";
|
2
|
+
// export type ApiMode = 'test' | 'live'
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
4
|
const config = {
|
4
5
|
default: {
|
6
|
+
// environment: 'test',
|
5
7
|
domain: 'commercelayer.io',
|
6
8
|
pageNumber: 1,
|
7
9
|
pageSize: 10,
|
8
10
|
},
|
9
11
|
client: {
|
10
12
|
timeout: 15000,
|
13
|
+
requiredAttributes: ['organization', 'accessToken'],
|
11
14
|
}
|
12
15
|
};
|
13
16
|
exports.default = config;
|
package/lib/cjs/debug.js
CHANGED
@@ -1,7 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
4
|
-
// import Debug from 'debug'
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
/* Nope debugger */
|
7
4
|
const debuggerFunction = (_pattern, ..._args) => {
|
@@ -10,7 +7,6 @@ const debuggerFunction = (_pattern, ..._args) => {
|
|
10
7
|
let debuggerFactory = (_namespace) => debuggerFunction;
|
11
8
|
/* Try loading 'debug' module */
|
12
9
|
try {
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
14
10
|
const debugModule = require('debug');
|
15
11
|
if (debugModule && (typeof debugModule === 'function'))
|
16
12
|
debuggerFactory = debugModule;
|
package/lib/cjs/error.d.ts
CHANGED
@@ -22,7 +22,9 @@ declare class ApiError extends SdkError {
|
|
22
22
|
static isApiError(error: any): error is ApiError;
|
23
23
|
errors: any[];
|
24
24
|
status?: number;
|
25
|
+
statusText?: string;
|
25
26
|
constructor(error: SdkError);
|
26
27
|
first(): any;
|
27
28
|
}
|
28
|
-
|
29
|
+
declare const handleError: (error: Error) => never;
|
30
|
+
export { SdkError, ApiError, ErrorType, handleError };
|
package/lib/cjs/error.js
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
3
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.ErrorType = exports.ApiError = exports.SdkError = void 0;
|
6
|
+
exports.handleError = exports.ErrorType = exports.ApiError = exports.SdkError = void 0;
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
5
8
|
var ErrorType;
|
6
9
|
(function (ErrorType) {
|
7
10
|
ErrorType["CLIENT"] = "client";
|
@@ -9,10 +12,8 @@ var ErrorType;
|
|
9
12
|
ErrorType["RESPONSE"] = "response";
|
10
13
|
ErrorType["GENERIC"] = "generic";
|
11
14
|
ErrorType["CANCEL"] = "cancel";
|
12
|
-
})(ErrorType || (ErrorType = {}));
|
13
|
-
exports.ErrorType = ErrorType;
|
15
|
+
})(ErrorType || (exports.ErrorType = ErrorType = {}));
|
14
16
|
class SdkError extends Error {
|
15
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
16
17
|
static isSdkError(error) {
|
17
18
|
return error && [SdkError.NAME, ApiError.NAME].includes(error.name) && Object.values(ErrorType).includes(error.type);
|
18
19
|
}
|
@@ -25,12 +26,11 @@ class SdkError extends Error {
|
|
25
26
|
exports.SdkError = SdkError;
|
26
27
|
SdkError.NAME = 'SdkError';
|
27
28
|
class ApiError extends SdkError {
|
28
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
29
29
|
static isApiError(error) {
|
30
30
|
return SdkError.isSdkError(error) && (error.name === ApiError.NAME) && (error.type === ErrorType.RESPONSE);
|
31
31
|
}
|
32
32
|
constructor(error) {
|
33
|
-
super(
|
33
|
+
super({ ...error, type: ErrorType.RESPONSE });
|
34
34
|
this.errors = [];
|
35
35
|
this.name = ApiError.NAME; // this.constructor.name
|
36
36
|
}
|
@@ -41,3 +41,36 @@ class ApiError extends SdkError {
|
|
41
41
|
}
|
42
42
|
exports.ApiError = ApiError;
|
43
43
|
ApiError.NAME = 'ApiError';
|
44
|
+
const handleError = (error) => {
|
45
|
+
let sdkError = new SdkError({ message: error.message });
|
46
|
+
if (axios_1.default.isAxiosError(error)) {
|
47
|
+
if (error.response) {
|
48
|
+
// The request was made and the server responded with a status code that falls out of the range of 2xx
|
49
|
+
const apiError = new ApiError(sdkError);
|
50
|
+
apiError.type = ErrorType.RESPONSE;
|
51
|
+
apiError.status = error.response.status;
|
52
|
+
apiError.statusText = error.response.statusText;
|
53
|
+
apiError.code = String(apiError.status);
|
54
|
+
apiError.errors = error.response.data.errors;
|
55
|
+
if (!apiError.message && apiError.statusText)
|
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
|
+
}
|
69
|
+
}
|
70
|
+
else if (axios_1.default.isCancel(error))
|
71
|
+
sdkError.type = ErrorType.CANCEL;
|
72
|
+
else
|
73
|
+
sdkError.source = error;
|
74
|
+
throw sdkError;
|
75
|
+
};
|
76
|
+
exports.handleError = handleError;
|
package/lib/cjs/index.d.ts
CHANGED
@@ -2,6 +2,6 @@ export { default, CommerceLayer } from './commercelayer';
|
|
2
2
|
export type { CommerceLayerClient } from './commercelayer';
|
3
3
|
export { CommerceLayerStatic } from './static';
|
4
4
|
export type { QueryParamsRetrieve, QueryParamsList, QueryParams } from './query';
|
5
|
-
export * from './model';
|
5
|
+
export type * from './model';
|
6
6
|
export type { RequestObj, ResponseObj, ErrorObj, HeadersObj } from './interceptor';
|
7
7
|
export type { SdkError, ApiError, ErrorType } from './error';
|
package/lib/cjs/index.js
CHANGED
@@ -1,18 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
17
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
4
|
};
|
@@ -25,5 +11,3 @@ Object.defineProperty(exports, "CommerceLayer", { enumerable: true, get: functio
|
|
25
11
|
// Commerce Layer static functions
|
26
12
|
var static_1 = require("./static");
|
27
13
|
Object.defineProperty(exports, "CommerceLayerStatic", { enumerable: true, get: function () { return static_1.CommerceLayerStatic; } });
|
28
|
-
// Resource model types
|
29
|
-
__exportStar(require("./model"), exports);
|
package/lib/cjs/interceptor.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { AxiosError, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, RawAxiosResponseHeaders } from 'axios';
|
1
|
+
import type { AxiosError, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, RawAxiosResponseHeaders } from 'axios';
|
2
2
|
type InterceptorManager = {
|
3
3
|
request: AxiosInterceptorManager<AxiosRequestConfig>;
|
4
4
|
response: AxiosInterceptorManager<any>;
|
@@ -7,7 +7,11 @@ type RequestObj = AxiosRequestConfig;
|
|
7
7
|
type RequestInterceptor = (request: RequestObj) => RequestObj | Promise<RequestObj>;
|
8
8
|
type ResponseObj = AxiosResponse;
|
9
9
|
type ResponseInterceptor = (response: ResponseObj) => ResponseObj;
|
10
|
-
type
|
10
|
+
type ApiHeadersList = 'x-ratelimit-limit' | 'x-ratelimit-count' | 'x-ratelimit-period' | 'x-ratelimit-interval' | 'x-ratelimit-remaining';
|
11
|
+
type ApiHeaders = {
|
12
|
+
[key in ApiHeadersList]: string | number | boolean;
|
13
|
+
};
|
14
|
+
type HeadersObj = (AxiosResponseHeaders | RawAxiosResponseHeaders) & ApiHeaders;
|
11
15
|
type ErrorObj = AxiosError;
|
12
16
|
type ErrorInterceptor = (error: ErrorObj) => ErrorObj;
|
13
17
|
type InterceptorType = 'request' | 'response';
|
package/lib/cjs/jsonapi.js
CHANGED
@@ -35,7 +35,11 @@ const denormalizeResource = (res, included) => {
|
|
35
35
|
debug('denormalize resource: %O, %o', res, included || {});
|
36
36
|
if (!res)
|
37
37
|
return res;
|
38
|
-
const resource =
|
38
|
+
const resource = {
|
39
|
+
id: res.id,
|
40
|
+
type: res.type,
|
41
|
+
...res.attributes,
|
42
|
+
};
|
39
43
|
if (res.relationships)
|
40
44
|
Object.keys(res.relationships).forEach(key => {
|
41
45
|
const rel = res.relationships[key].data;
|
@@ -60,7 +64,10 @@ const normalize = (resource) => {
|
|
60
64
|
if (['type', 'id'].includes(field))
|
61
65
|
continue;
|
62
66
|
const value = resource[field];
|
63
|
-
if (value && (0, common_1.isResourceType)(value) && value.id === null) {
|
67
|
+
if (Array.isArray(value) && (value.length === 1) && (0, common_1.isResourceType)(value[0]) && (value[0].id === null)) {
|
68
|
+
relationships[field] = { data: [] };
|
69
|
+
}
|
70
|
+
else if (value && (0, common_1.isResourceType)(value) && (value.id === null)) {
|
64
71
|
relationships[field] = { data: null };
|
65
72
|
}
|
66
73
|
else if (value && ((0, common_1.isResourceId)(value) || (Array.isArray(value) && (0, common_1.isResourceId)(value[0])))) {
|
package/lib/cjs/query.d.ts
CHANGED
@@ -1,23 +1,17 @@
|
|
1
|
-
import { ResourceType } from "./resource";
|
1
|
+
import type { ResourceType } from "./resource";
|
2
|
+
type QueryFilter = Record<string, string | number | boolean>;
|
2
3
|
interface QueryParamsRetrieve {
|
3
4
|
include?: string[];
|
4
|
-
fields?: string[] |
|
5
|
-
[key: string]: string[];
|
6
|
-
};
|
5
|
+
fields?: string[] | Record<string, string[]>;
|
7
6
|
}
|
8
7
|
interface QueryParamsList extends QueryParamsRetrieve {
|
9
|
-
sort?: string[] |
|
10
|
-
|
11
|
-
};
|
12
|
-
filters?: {
|
13
|
-
[key: string]: string | number | boolean;
|
14
|
-
};
|
8
|
+
sort?: string[] | Record<string, 'asc' | 'desc'>;
|
9
|
+
filters?: QueryFilter;
|
15
10
|
pageNumber?: number;
|
16
11
|
pageSize?: number;
|
17
12
|
}
|
18
13
|
type QueryParams = QueryParamsRetrieve | QueryParamsList;
|
19
|
-
export { QueryParamsRetrieve, QueryParamsList, QueryParams };
|
20
|
-
declare const
|
21
|
-
|
22
|
-
};
|
23
|
-
export { generateQueryStringParams };
|
14
|
+
export type { QueryParamsRetrieve, QueryParamsList, QueryParams, QueryFilter };
|
15
|
+
declare const isParamsList: (params: any) => params is QueryParamsList;
|
16
|
+
declare const generateQueryStringParams: (params: QueryParamsRetrieve | QueryParamsList | undefined, res: string | ResourceType) => Record<string, string>;
|
17
|
+
export { generateQueryStringParams, isParamsList };
|