@commercelayer/sdk 4.21.0 → 4.23.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 +109 -1
- package/lib/cjs/api.js +343 -1
- package/lib/cjs/client.d.ts +31 -1
- package/lib/cjs/client.js +123 -1
- package/lib/cjs/commercelayer.d.ts +133 -1
- package/lib/cjs/commercelayer.js +224 -1
- package/lib/cjs/common.d.ts +4 -1
- package/lib/cjs/common.js +14 -1
- package/lib/cjs/config.d.ts +11 -1
- package/lib/cjs/config.js +13 -1
- package/lib/cjs/debug.d.ts +3 -1
- package/lib/cjs/debug.js +42 -1
- package/lib/cjs/error.d.ts +28 -1
- package/lib/cjs/error.js +43 -1
- package/lib/cjs/index.d.ts +7 -1
- package/lib/cjs/index.js +29 -1
- package/lib/cjs/interceptor.d.ts +21 -1
- package/lib/cjs/interceptor.js +2 -1
- package/lib/cjs/jsonapi.d.ts +5 -1
- package/lib/cjs/jsonapi.js +82 -1
- package/lib/cjs/model.d.ts +107 -1
- package/lib/cjs/model.js +3 -1
- package/lib/cjs/query.d.ts +23 -1
- package/lib/cjs/query.js +51 -1
- package/lib/cjs/resource.d.ts +77 -1
- package/lib/cjs/resource.js +145 -1
- package/lib/cjs/resources/addresses.d.ts +88 -1
- package/lib/cjs/resources/addresses.js +37 -1
- package/lib/cjs/resources/adjustments.d.ts +35 -1
- package/lib/cjs/resources/adjustments.js +33 -1
- package/lib/cjs/resources/adyen_gateways.d.ts +56 -1
- package/lib/cjs/resources/adyen_gateways.js +41 -1
- package/lib/cjs/resources/adyen_payments.d.ts +45 -1
- package/lib/cjs/resources/adyen_payments.js +41 -1
- package/lib/cjs/resources/application.d.ts +21 -1
- package/lib/cjs/resources/application.js +21 -1
- package/lib/cjs/resources/attachments.d.ts +156 -1
- package/lib/cjs/resources/attachments.js +33 -1
- package/lib/cjs/resources/authorizations.d.ts +60 -1
- package/lib/cjs/resources/authorizations.js +43 -1
- package/lib/cjs/resources/avalara_accounts.d.ts +55 -1
- package/lib/cjs/resources/avalara_accounts.js +45 -1
- package/lib/cjs/resources/billing_info_validation_rules.d.ts +35 -1
- package/lib/cjs/resources/billing_info_validation_rules.js +41 -1
- package/lib/cjs/resources/bing_geocoders.d.ts +35 -1
- package/lib/cjs/resources/bing_geocoders.js +41 -1
- package/lib/cjs/resources/braintree_gateways.d.ts +56 -1
- package/lib/cjs/resources/braintree_gateways.js +41 -1
- package/lib/cjs/resources/braintree_payments.d.ts +47 -1
- package/lib/cjs/resources/braintree_payments.js +41 -1
- package/lib/cjs/resources/bundles.d.ts +76 -1
- package/lib/cjs/resources/bundles.js +49 -1
- package/lib/cjs/resources/captures.d.ts +51 -1
- package/lib/cjs/resources/captures.js +43 -1
- package/lib/cjs/resources/carrier_accounts.d.ts +26 -1
- package/lib/cjs/resources/carrier_accounts.js +32 -1
- package/lib/cjs/resources/checkout_com_gateways.d.ts +45 -1
- package/lib/cjs/resources/checkout_com_gateways.js +41 -1
- package/lib/cjs/resources/checkout_com_payments.d.ts +58 -1
- package/lib/cjs/resources/checkout_com_payments.js +41 -1
- package/lib/cjs/resources/cleanups.d.ts +36 -1
- package/lib/cjs/resources/cleanups.js +34 -1
- package/lib/cjs/resources/coupon_codes_promotion_rules.d.ts +59 -1
- package/lib/cjs/resources/coupon_codes_promotion_rules.js +37 -1
- package/lib/cjs/resources/coupon_recipients.d.ts +44 -1
- package/lib/cjs/resources/coupon_recipients.js +41 -1
- package/lib/cjs/resources/coupons.d.ts +45 -1
- package/lib/cjs/resources/coupons.js +37 -1
- package/lib/cjs/resources/customer_addresses.d.ts +44 -1
- package/lib/cjs/resources/customer_addresses.js +45 -1
- package/lib/cjs/resources/customer_groups.d.ts +36 -1
- package/lib/cjs/resources/customer_groups.js +45 -1
- package/lib/cjs/resources/customer_password_resets.d.ts +36 -1
- package/lib/cjs/resources/customer_password_resets.js +41 -1
- package/lib/cjs/resources/customer_payment_sources.d.ts +70 -1
- package/lib/cjs/resources/customer_payment_sources.js +37 -1
- package/lib/cjs/resources/customer_subscriptions.d.ts +31 -1
- package/lib/cjs/resources/customer_subscriptions.js +41 -1
- package/lib/cjs/resources/customers.d.ts +66 -1
- package/lib/cjs/resources/customers.js +73 -1
- package/lib/cjs/resources/delivery_lead_times.d.ts +51 -1
- package/lib/cjs/resources/delivery_lead_times.js +45 -1
- package/lib/cjs/resources/event_callbacks.d.ts +24 -1
- package/lib/cjs/resources/event_callbacks.js +28 -1
- package/lib/cjs/resources/events.d.ts +24 -1
- package/lib/cjs/resources/events.js +32 -1
- package/lib/cjs/resources/exports.d.ts +40 -1
- package/lib/cjs/resources/exports.js +34 -1
- package/lib/cjs/resources/external_gateways.d.ts +49 -1
- package/lib/cjs/resources/external_gateways.js +41 -1
- package/lib/cjs/resources/external_payments.d.ts +43 -1
- package/lib/cjs/resources/external_payments.js +45 -1
- package/lib/cjs/resources/external_promotions.d.ts +90 -1
- package/lib/cjs/resources/external_promotions.js +57 -1
- package/lib/cjs/resources/external_tax_calculators.d.ts +37 -1
- package/lib/cjs/resources/external_tax_calculators.js +41 -1
- package/lib/cjs/resources/fixed_amount_promotions.d.ts +91 -1
- package/lib/cjs/resources/fixed_amount_promotions.js +57 -1
- package/lib/cjs/resources/fixed_price_promotions.d.ts +102 -1
- package/lib/cjs/resources/fixed_price_promotions.js +65 -1
- package/lib/cjs/resources/free_gift_promotions.d.ts +100 -1
- package/lib/cjs/resources/free_gift_promotions.js +65 -1
- package/lib/cjs/resources/free_shipping_promotions.d.ts +83 -1
- package/lib/cjs/resources/free_shipping_promotions.js +53 -1
- package/lib/cjs/resources/geocoders.d.ts +24 -1
- package/lib/cjs/resources/geocoders.js +32 -1
- package/lib/cjs/resources/gift_card_recipients.d.ts +44 -1
- package/lib/cjs/resources/gift_card_recipients.js +41 -1
- package/lib/cjs/resources/gift_cards.d.ts +85 -1
- package/lib/cjs/resources/gift_cards.js +49 -1
- package/lib/cjs/resources/google_geocoders.d.ts +35 -1
- package/lib/cjs/resources/google_geocoders.js +41 -1
- package/lib/cjs/resources/imports.d.ts +45 -1
- package/lib/cjs/resources/imports.js +34 -1
- package/lib/cjs/resources/in_stock_subscriptions.d.ts +62 -1
- package/lib/cjs/resources/in_stock_subscriptions.js +49 -1
- package/lib/cjs/resources/inventory_models.d.ts +42 -1
- package/lib/cjs/resources/inventory_models.js +45 -1
- package/lib/cjs/resources/inventory_return_locations.d.ts +43 -1
- package/lib/cjs/resources/inventory_return_locations.js +41 -1
- package/lib/cjs/resources/inventory_stock_locations.d.ts +46 -1
- package/lib/cjs/resources/inventory_stock_locations.js +41 -1
- package/lib/cjs/resources/klarna_gateways.d.ts +44 -1
- package/lib/cjs/resources/klarna_gateways.js +41 -1
- package/lib/cjs/resources/klarna_payments.d.ts +45 -1
- package/lib/cjs/resources/klarna_payments.js +41 -1
- package/lib/cjs/resources/line_item_options.d.ts +57 -1
- package/lib/cjs/resources/line_item_options.js +41 -1
- package/lib/cjs/resources/line_items.d.ts +126 -1
- package/lib/cjs/resources/line_items.js +49 -1
- package/lib/cjs/resources/manual_gateways.d.ts +33 -1
- package/lib/cjs/resources/manual_gateways.js +37 -1
- package/lib/cjs/resources/manual_tax_calculators.d.ts +41 -1
- package/lib/cjs/resources/manual_tax_calculators.js +45 -1
- package/lib/cjs/resources/markets.d.ts +88 -1
- package/lib/cjs/resources/markets.js +57 -1
- package/lib/cjs/resources/merchants.d.ts +38 -1
- package/lib/cjs/resources/merchants.js +41 -1
- package/lib/cjs/resources/order_amount_promotion_rules.d.ts +56 -1
- package/lib/cjs/resources/order_amount_promotion_rules.js +33 -1
- package/lib/cjs/resources/order_copies.d.ts +48 -1
- package/lib/cjs/resources/order_copies.js +46 -1
- package/lib/cjs/resources/order_subscriptions.d.ts +70 -1
- package/lib/cjs/resources/order_subscriptions.js +57 -1
- package/lib/cjs/resources/order_validation_rules.d.ts +23 -1
- package/lib/cjs/resources/order_validation_rules.js +32 -1
- package/lib/cjs/resources/orders.d.ts +288 -1
- package/lib/cjs/resources/orders.js +113 -1
- package/lib/cjs/resources/organization.d.ts +32 -1
- package/lib/cjs/resources/organization.js +21 -1
- package/lib/cjs/resources/packages.d.ts +56 -1
- package/lib/cjs/resources/packages.js +45 -1
- package/lib/cjs/resources/parcel_line_items.d.ts +51 -1
- package/lib/cjs/resources/parcel_line_items.js +41 -1
- package/lib/cjs/resources/parcels.d.ts +119 -1
- package/lib/cjs/resources/parcels.js +53 -1
- package/lib/cjs/resources/payment_gateways.d.ts +21 -1
- package/lib/cjs/resources/payment_gateways.js +28 -1
- package/lib/cjs/resources/payment_methods.d.ts +61 -1
- package/lib/cjs/resources/payment_methods.js +45 -1
- package/lib/cjs/resources/paypal_gateways.d.ts +37 -1
- package/lib/cjs/resources/paypal_gateways.js +41 -1
- package/lib/cjs/resources/paypal_payments.d.ts +51 -1
- package/lib/cjs/resources/paypal_payments.js +41 -1
- package/lib/cjs/resources/percentage_discount_promotions.d.ts +100 -1
- package/lib/cjs/resources/percentage_discount_promotions.js +65 -1
- package/lib/cjs/resources/price_lists.d.ts +39 -1
- package/lib/cjs/resources/price_lists.js +41 -1
- package/lib/cjs/resources/price_tiers.d.ts +28 -1
- package/lib/cjs/resources/price_tiers.js +32 -1
- package/lib/cjs/resources/price_volume_tiers.d.ts +46 -1
- package/lib/cjs/resources/price_volume_tiers.js +41 -1
- package/lib/cjs/resources/prices.d.ts +68 -1
- package/lib/cjs/resources/prices.js +53 -1
- package/lib/cjs/resources/promotion_rules.d.ts +24 -1
- package/lib/cjs/resources/promotion_rules.js +24 -1
- package/lib/cjs/resources/promotions.d.ts +41 -1
- package/lib/cjs/resources/promotions.js +44 -1
- package/lib/cjs/resources/refunds.d.ts +37 -1
- package/lib/cjs/resources/refunds.js +36 -1
- package/lib/cjs/resources/return_line_items.d.ts +49 -1
- package/lib/cjs/resources/return_line_items.js +41 -1
- package/lib/cjs/resources/returns.d.ts +75 -1
- package/lib/cjs/resources/returns.js +65 -1
- package/lib/cjs/resources/shipments.d.ts +93 -1
- package/lib/cjs/resources/shipments.js +83 -1
- package/lib/cjs/resources/shipping_categories.d.ts +33 -1
- package/lib/cjs/resources/shipping_categories.js +41 -1
- package/lib/cjs/resources/shipping_method_tiers.d.ts +28 -1
- package/lib/cjs/resources/shipping_method_tiers.js +32 -1
- package/lib/cjs/resources/shipping_methods.d.ts +107 -1
- package/lib/cjs/resources/shipping_methods.js +65 -1
- package/lib/cjs/resources/shipping_weight_tiers.d.ts +46 -1
- package/lib/cjs/resources/shipping_weight_tiers.js +41 -1
- package/lib/cjs/resources/shipping_zones.d.ts +48 -1
- package/lib/cjs/resources/shipping_zones.js +37 -1
- package/lib/cjs/resources/sku_list_items.d.ts +47 -1
- package/lib/cjs/resources/sku_list_items.js +41 -1
- package/lib/cjs/resources/sku_list_promotion_rules.d.ts +68 -1
- package/lib/cjs/resources/sku_list_promotion_rules.js +41 -1
- package/lib/cjs/resources/sku_lists.d.ts +60 -1
- package/lib/cjs/resources/sku_lists.js +53 -1
- package/lib/cjs/resources/sku_options.d.ts +56 -1
- package/lib/cjs/resources/sku_options.js +41 -1
- package/lib/cjs/resources/skus.d.ts +78 -1
- package/lib/cjs/resources/skus.js +57 -1
- package/lib/cjs/resources/stock_items.d.ts +49 -1
- package/lib/cjs/resources/stock_items.js +45 -1
- package/lib/cjs/resources/stock_line_items.d.ts +29 -1
- package/lib/cjs/resources/stock_line_items.js +36 -1
- package/lib/cjs/resources/stock_locations.d.ts +57 -1
- package/lib/cjs/resources/stock_locations.js +57 -1
- package/lib/cjs/resources/stock_transfers.d.ts +74 -1
- package/lib/cjs/resources/stock_transfers.js +57 -1
- package/lib/cjs/resources/stripe_gateways.d.ts +41 -1
- package/lib/cjs/resources/stripe_gateways.js +41 -1
- package/lib/cjs/resources/stripe_payments.d.ts +46 -1
- package/lib/cjs/resources/stripe_payments.js +41 -1
- package/lib/cjs/resources/tax_calculators.d.ts +24 -1
- package/lib/cjs/resources/tax_calculators.js +32 -1
- package/lib/cjs/resources/tax_categories.d.ts +59 -1
- package/lib/cjs/resources/tax_categories.js +41 -1
- package/lib/cjs/resources/tax_rules.d.ts +69 -1
- package/lib/cjs/resources/tax_rules.js +37 -1
- package/lib/cjs/resources/taxjar_accounts.d.ts +43 -1
- package/lib/cjs/resources/taxjar_accounts.js +45 -1
- package/lib/cjs/resources/transactions.d.ts +31 -1
- package/lib/cjs/resources/transactions.js +28 -1
- package/lib/cjs/resources/voids.d.ts +37 -1
- package/lib/cjs/resources/voids.js +36 -1
- package/lib/cjs/resources/webhooks.d.ts +43 -1
- package/lib/cjs/resources/webhooks.js +37 -1
- package/lib/cjs/resources/wire_transfers.d.ts +32 -1
- package/lib/cjs/resources/wire_transfers.js +37 -1
- package/lib/cjs/static.d.ts +8 -1
- package/lib/cjs/static.js +47 -1
- package/lib/cjs/util.d.ts +6 -1
- package/lib/cjs/util.js +15 -1
- package/lib/esm/api.d.ts +109 -1
- package/lib/esm/api.js +231 -1
- package/lib/esm/client.d.ts +31 -1
- package/lib/esm/client.js +118 -1
- package/lib/esm/commercelayer.d.ts +133 -1
- package/lib/esm/commercelayer.js +195 -1
- package/lib/esm/common.d.ts +4 -1
- package/lib/esm/common.js +10 -1
- package/lib/esm/config.d.ts +11 -1
- package/lib/esm/config.js +11 -1
- package/lib/esm/debug.d.ts +3 -1
- package/lib/esm/debug.js +40 -1
- package/lib/esm/error.d.ts +28 -1
- package/lib/esm/error.js +38 -1
- package/lib/esm/index.d.ts +7 -1
- package/lib/esm/index.js +6 -1
- package/lib/esm/interceptor.d.ts +21 -1
- package/lib/esm/interceptor.js +1 -1
- package/lib/esm/jsonapi.d.ts +5 -1
- package/lib/esm/jsonapi.js +75 -1
- package/lib/esm/model.d.ts +107 -1
- package/lib/esm/model.js +2 -1
- package/lib/esm/query.d.ts +23 -1
- package/lib/esm/query.js +45 -1
- package/lib/esm/resource.d.ts +77 -1
- package/lib/esm/resource.js +139 -1
- package/lib/esm/resources/addresses.d.ts +88 -1
- package/lib/esm/resources/addresses.js +35 -1
- package/lib/esm/resources/adjustments.d.ts +35 -1
- package/lib/esm/resources/adjustments.js +31 -1
- package/lib/esm/resources/adyen_gateways.d.ts +56 -1
- package/lib/esm/resources/adyen_gateways.js +39 -1
- package/lib/esm/resources/adyen_payments.d.ts +45 -1
- package/lib/esm/resources/adyen_payments.js +39 -1
- package/lib/esm/resources/application.d.ts +21 -1
- package/lib/esm/resources/application.js +19 -1
- package/lib/esm/resources/attachments.d.ts +156 -1
- package/lib/esm/resources/attachments.js +31 -1
- package/lib/esm/resources/authorizations.d.ts +60 -1
- package/lib/esm/resources/authorizations.js +41 -1
- package/lib/esm/resources/avalara_accounts.d.ts +55 -1
- package/lib/esm/resources/avalara_accounts.js +43 -1
- package/lib/esm/resources/billing_info_validation_rules.d.ts +35 -1
- package/lib/esm/resources/billing_info_validation_rules.js +39 -1
- package/lib/esm/resources/bing_geocoders.d.ts +35 -1
- package/lib/esm/resources/bing_geocoders.js +39 -1
- package/lib/esm/resources/braintree_gateways.d.ts +56 -1
- package/lib/esm/resources/braintree_gateways.js +39 -1
- package/lib/esm/resources/braintree_payments.d.ts +47 -1
- package/lib/esm/resources/braintree_payments.js +39 -1
- package/lib/esm/resources/bundles.d.ts +76 -1
- package/lib/esm/resources/bundles.js +47 -1
- package/lib/esm/resources/captures.d.ts +51 -1
- package/lib/esm/resources/captures.js +41 -1
- package/lib/esm/resources/carrier_accounts.d.ts +26 -1
- package/lib/esm/resources/carrier_accounts.js +30 -1
- package/lib/esm/resources/checkout_com_gateways.d.ts +45 -1
- package/lib/esm/resources/checkout_com_gateways.js +39 -1
- package/lib/esm/resources/checkout_com_payments.d.ts +58 -1
- package/lib/esm/resources/checkout_com_payments.js +39 -1
- package/lib/esm/resources/cleanups.d.ts +36 -1
- package/lib/esm/resources/cleanups.js +32 -1
- package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +59 -1
- package/lib/esm/resources/coupon_codes_promotion_rules.js +35 -1
- package/lib/esm/resources/coupon_recipients.d.ts +44 -1
- package/lib/esm/resources/coupon_recipients.js +39 -1
- package/lib/esm/resources/coupons.d.ts +45 -1
- package/lib/esm/resources/coupons.js +35 -1
- package/lib/esm/resources/customer_addresses.d.ts +44 -1
- package/lib/esm/resources/customer_addresses.js +43 -1
- package/lib/esm/resources/customer_groups.d.ts +36 -1
- package/lib/esm/resources/customer_groups.js +43 -1
- package/lib/esm/resources/customer_password_resets.d.ts +36 -1
- package/lib/esm/resources/customer_password_resets.js +39 -1
- package/lib/esm/resources/customer_payment_sources.d.ts +70 -1
- package/lib/esm/resources/customer_payment_sources.js +35 -1
- package/lib/esm/resources/customer_subscriptions.d.ts +31 -1
- package/lib/esm/resources/customer_subscriptions.js +39 -1
- package/lib/esm/resources/customers.d.ts +66 -1
- package/lib/esm/resources/customers.js +71 -1
- package/lib/esm/resources/delivery_lead_times.d.ts +51 -1
- package/lib/esm/resources/delivery_lead_times.js +43 -1
- package/lib/esm/resources/event_callbacks.d.ts +24 -1
- package/lib/esm/resources/event_callbacks.js +26 -1
- package/lib/esm/resources/events.d.ts +24 -1
- package/lib/esm/resources/events.js +30 -1
- package/lib/esm/resources/exports.d.ts +40 -1
- package/lib/esm/resources/exports.js +32 -1
- package/lib/esm/resources/external_gateways.d.ts +49 -1
- package/lib/esm/resources/external_gateways.js +39 -1
- package/lib/esm/resources/external_payments.d.ts +43 -1
- package/lib/esm/resources/external_payments.js +43 -1
- package/lib/esm/resources/external_promotions.d.ts +90 -1
- package/lib/esm/resources/external_promotions.js +55 -1
- package/lib/esm/resources/external_tax_calculators.d.ts +37 -1
- package/lib/esm/resources/external_tax_calculators.js +39 -1
- package/lib/esm/resources/fixed_amount_promotions.d.ts +91 -1
- package/lib/esm/resources/fixed_amount_promotions.js +55 -1
- package/lib/esm/resources/fixed_price_promotions.d.ts +102 -1
- package/lib/esm/resources/fixed_price_promotions.js +63 -1
- package/lib/esm/resources/free_gift_promotions.d.ts +100 -1
- package/lib/esm/resources/free_gift_promotions.js +63 -1
- package/lib/esm/resources/free_shipping_promotions.d.ts +83 -1
- package/lib/esm/resources/free_shipping_promotions.js +51 -1
- package/lib/esm/resources/geocoders.d.ts +24 -1
- package/lib/esm/resources/geocoders.js +30 -1
- package/lib/esm/resources/gift_card_recipients.d.ts +44 -1
- package/lib/esm/resources/gift_card_recipients.js +39 -1
- package/lib/esm/resources/gift_cards.d.ts +85 -1
- package/lib/esm/resources/gift_cards.js +47 -1
- package/lib/esm/resources/google_geocoders.d.ts +35 -1
- package/lib/esm/resources/google_geocoders.js +39 -1
- package/lib/esm/resources/imports.d.ts +45 -1
- package/lib/esm/resources/imports.js +32 -1
- package/lib/esm/resources/in_stock_subscriptions.d.ts +62 -1
- package/lib/esm/resources/in_stock_subscriptions.js +47 -1
- package/lib/esm/resources/inventory_models.d.ts +42 -1
- package/lib/esm/resources/inventory_models.js +43 -1
- package/lib/esm/resources/inventory_return_locations.d.ts +43 -1
- package/lib/esm/resources/inventory_return_locations.js +39 -1
- package/lib/esm/resources/inventory_stock_locations.d.ts +46 -1
- package/lib/esm/resources/inventory_stock_locations.js +39 -1
- package/lib/esm/resources/klarna_gateways.d.ts +44 -1
- package/lib/esm/resources/klarna_gateways.js +39 -1
- package/lib/esm/resources/klarna_payments.d.ts +45 -1
- package/lib/esm/resources/klarna_payments.js +39 -1
- package/lib/esm/resources/line_item_options.d.ts +57 -1
- package/lib/esm/resources/line_item_options.js +39 -1
- package/lib/esm/resources/line_items.d.ts +126 -1
- package/lib/esm/resources/line_items.js +47 -1
- package/lib/esm/resources/manual_gateways.d.ts +33 -1
- package/lib/esm/resources/manual_gateways.js +35 -1
- package/lib/esm/resources/manual_tax_calculators.d.ts +41 -1
- package/lib/esm/resources/manual_tax_calculators.js +43 -1
- package/lib/esm/resources/markets.d.ts +88 -1
- package/lib/esm/resources/markets.js +55 -1
- package/lib/esm/resources/merchants.d.ts +38 -1
- package/lib/esm/resources/merchants.js +39 -1
- package/lib/esm/resources/order_amount_promotion_rules.d.ts +56 -1
- package/lib/esm/resources/order_amount_promotion_rules.js +31 -1
- package/lib/esm/resources/order_copies.d.ts +48 -1
- package/lib/esm/resources/order_copies.js +44 -1
- package/lib/esm/resources/order_subscriptions.d.ts +70 -1
- package/lib/esm/resources/order_subscriptions.js +55 -1
- package/lib/esm/resources/order_validation_rules.d.ts +23 -1
- package/lib/esm/resources/order_validation_rules.js +30 -1
- package/lib/esm/resources/orders.d.ts +288 -1
- package/lib/esm/resources/orders.js +111 -1
- package/lib/esm/resources/organization.d.ts +32 -1
- package/lib/esm/resources/organization.js +19 -1
- package/lib/esm/resources/packages.d.ts +56 -1
- package/lib/esm/resources/packages.js +43 -1
- package/lib/esm/resources/parcel_line_items.d.ts +51 -1
- package/lib/esm/resources/parcel_line_items.js +39 -1
- package/lib/esm/resources/parcels.d.ts +119 -1
- package/lib/esm/resources/parcels.js +51 -1
- package/lib/esm/resources/payment_gateways.d.ts +21 -1
- package/lib/esm/resources/payment_gateways.js +26 -1
- package/lib/esm/resources/payment_methods.d.ts +61 -1
- package/lib/esm/resources/payment_methods.js +43 -1
- package/lib/esm/resources/paypal_gateways.d.ts +37 -1
- package/lib/esm/resources/paypal_gateways.js +39 -1
- package/lib/esm/resources/paypal_payments.d.ts +51 -1
- package/lib/esm/resources/paypal_payments.js +39 -1
- package/lib/esm/resources/percentage_discount_promotions.d.ts +100 -1
- package/lib/esm/resources/percentage_discount_promotions.js +63 -1
- package/lib/esm/resources/price_lists.d.ts +39 -1
- package/lib/esm/resources/price_lists.js +39 -1
- package/lib/esm/resources/price_tiers.d.ts +28 -1
- package/lib/esm/resources/price_tiers.js +30 -1
- package/lib/esm/resources/price_volume_tiers.d.ts +46 -1
- package/lib/esm/resources/price_volume_tiers.js +39 -1
- package/lib/esm/resources/prices.d.ts +68 -1
- package/lib/esm/resources/prices.js +51 -1
- package/lib/esm/resources/promotion_rules.d.ts +24 -1
- package/lib/esm/resources/promotion_rules.js +22 -1
- package/lib/esm/resources/promotions.d.ts +41 -1
- package/lib/esm/resources/promotions.js +42 -1
- package/lib/esm/resources/refunds.d.ts +37 -1
- package/lib/esm/resources/refunds.js +34 -1
- package/lib/esm/resources/return_line_items.d.ts +49 -1
- package/lib/esm/resources/return_line_items.js +39 -1
- package/lib/esm/resources/returns.d.ts +75 -1
- package/lib/esm/resources/returns.js +63 -1
- package/lib/esm/resources/shipments.d.ts +93 -1
- package/lib/esm/resources/shipments.js +81 -1
- package/lib/esm/resources/shipping_categories.d.ts +33 -1
- package/lib/esm/resources/shipping_categories.js +39 -1
- package/lib/esm/resources/shipping_method_tiers.d.ts +28 -1
- package/lib/esm/resources/shipping_method_tiers.js +30 -1
- package/lib/esm/resources/shipping_methods.d.ts +107 -1
- package/lib/esm/resources/shipping_methods.js +63 -1
- package/lib/esm/resources/shipping_weight_tiers.d.ts +46 -1
- package/lib/esm/resources/shipping_weight_tiers.js +39 -1
- package/lib/esm/resources/shipping_zones.d.ts +48 -1
- package/lib/esm/resources/shipping_zones.js +35 -1
- package/lib/esm/resources/sku_list_items.d.ts +47 -1
- package/lib/esm/resources/sku_list_items.js +39 -1
- package/lib/esm/resources/sku_list_promotion_rules.d.ts +68 -1
- package/lib/esm/resources/sku_list_promotion_rules.js +39 -1
- package/lib/esm/resources/sku_lists.d.ts +60 -1
- package/lib/esm/resources/sku_lists.js +51 -1
- package/lib/esm/resources/sku_options.d.ts +56 -1
- package/lib/esm/resources/sku_options.js +39 -1
- package/lib/esm/resources/skus.d.ts +78 -1
- package/lib/esm/resources/skus.js +55 -1
- package/lib/esm/resources/stock_items.d.ts +49 -1
- package/lib/esm/resources/stock_items.js +43 -1
- package/lib/esm/resources/stock_line_items.d.ts +29 -1
- package/lib/esm/resources/stock_line_items.js +34 -1
- package/lib/esm/resources/stock_locations.d.ts +57 -1
- package/lib/esm/resources/stock_locations.js +55 -1
- package/lib/esm/resources/stock_transfers.d.ts +74 -1
- package/lib/esm/resources/stock_transfers.js +55 -1
- package/lib/esm/resources/stripe_gateways.d.ts +41 -1
- package/lib/esm/resources/stripe_gateways.js +39 -1
- package/lib/esm/resources/stripe_payments.d.ts +46 -1
- package/lib/esm/resources/stripe_payments.js +39 -1
- package/lib/esm/resources/tax_calculators.d.ts +24 -1
- package/lib/esm/resources/tax_calculators.js +30 -1
- package/lib/esm/resources/tax_categories.d.ts +59 -1
- package/lib/esm/resources/tax_categories.js +39 -1
- package/lib/esm/resources/tax_rules.d.ts +69 -1
- package/lib/esm/resources/tax_rules.js +35 -1
- package/lib/esm/resources/taxjar_accounts.d.ts +43 -1
- package/lib/esm/resources/taxjar_accounts.js +43 -1
- package/lib/esm/resources/transactions.d.ts +31 -1
- package/lib/esm/resources/transactions.js +26 -1
- package/lib/esm/resources/voids.d.ts +37 -1
- package/lib/esm/resources/voids.js +34 -1
- package/lib/esm/resources/webhooks.d.ts +43 -1
- package/lib/esm/resources/webhooks.js +35 -1
- package/lib/esm/resources/wire_transfers.d.ts +32 -1
- package/lib/esm/resources/wire_transfers.js +35 -1
- package/lib/esm/static.d.ts +8 -1
- package/lib/esm/static.js +18 -1
- package/lib/esm/util.d.ts +6 -1
- package/lib/esm/util.js +11 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -15
package/lib/esm/jsonapi.js
CHANGED
@@ -1 +1,75 @@
|
|
1
|
-
import{isResourceId
|
1
|
+
import { isResourceId, isResourceType } from './common';
|
2
|
+
import Debug from './debug';
|
3
|
+
const debug = Debug('jsonapi');
|
4
|
+
// DENORMALIZATION
|
5
|
+
const denormalize = (response) => {
|
6
|
+
let denormalizedResponse;
|
7
|
+
if (response.links)
|
8
|
+
delete response.links;
|
9
|
+
const data = response.data;
|
10
|
+
const included = response.included;
|
11
|
+
if (!data)
|
12
|
+
denormalizedResponse = data;
|
13
|
+
else {
|
14
|
+
if (Array.isArray(data))
|
15
|
+
denormalizedResponse = data.map(res => denormalizeResource(res, included));
|
16
|
+
else
|
17
|
+
denormalizedResponse = denormalizeResource(data, included);
|
18
|
+
}
|
19
|
+
return denormalizedResponse;
|
20
|
+
};
|
21
|
+
const findIncluded = (rel, included = []) => {
|
22
|
+
const inc = included.find(inc => {
|
23
|
+
return (rel.id === inc.id) && (rel.type === inc.type);
|
24
|
+
});
|
25
|
+
return inc || rel;
|
26
|
+
};
|
27
|
+
const denormalizeResource = (res, included) => {
|
28
|
+
debug('denormalize resource: %O, %o', res, included || {});
|
29
|
+
if (!res)
|
30
|
+
return res;
|
31
|
+
const resource = Object.assign({ id: res.id, type: res.type }, res.attributes);
|
32
|
+
if (res.relationships)
|
33
|
+
Object.keys(res.relationships).forEach(key => {
|
34
|
+
const rel = res.relationships[key].data;
|
35
|
+
if (rel) {
|
36
|
+
if (Array.isArray(rel))
|
37
|
+
resource[key] = rel.map(r => denormalizeResource(findIncluded(r, included), included));
|
38
|
+
else
|
39
|
+
resource[key] = denormalizeResource(findIncluded(rel, included), included);
|
40
|
+
}
|
41
|
+
else if (rel === null)
|
42
|
+
resource[key] = null;
|
43
|
+
});
|
44
|
+
debug('denormalized resource: %O', resource);
|
45
|
+
return resource;
|
46
|
+
};
|
47
|
+
// NORMALIZATION
|
48
|
+
const normalize = (resource) => {
|
49
|
+
debug('normalize resource: %O', resource);
|
50
|
+
const attributes = {};
|
51
|
+
const relationships = {};
|
52
|
+
for (const field in resource) {
|
53
|
+
if (['type', 'id'].includes(field))
|
54
|
+
continue;
|
55
|
+
const value = resource[field];
|
56
|
+
if (value && isResourceType(value) && value.id === null) {
|
57
|
+
relationships[field] = { data: null };
|
58
|
+
}
|
59
|
+
else if (value && (isResourceId(value) || (Array.isArray(value) && isResourceId(value[0])))) {
|
60
|
+
relationships[field] = { data: value };
|
61
|
+
}
|
62
|
+
else
|
63
|
+
attributes[field] = value;
|
64
|
+
}
|
65
|
+
const normalized = {
|
66
|
+
type: resource.type,
|
67
|
+
attributes,
|
68
|
+
relationships
|
69
|
+
};
|
70
|
+
if (isResourceId(resource))
|
71
|
+
normalized.id = resource.id;
|
72
|
+
debug('normalized resource: %O', normalized);
|
73
|
+
return normalized;
|
74
|
+
};
|
75
|
+
export { denormalize, normalize };
|
package/lib/esm/model.d.ts
CHANGED
@@ -1 +1,107 @@
|
|
1
|
-
|
1
|
+
/**
|
2
|
+
* ©2023 Commerce Layer Inc.
|
3
|
+
**/
|
4
|
+
export type { Address, AddressCreate, AddressUpdate } from './resources/addresses';
|
5
|
+
export type { Adjustment, AdjustmentCreate, AdjustmentUpdate } from './resources/adjustments';
|
6
|
+
export type { AdyenGateway, AdyenGatewayCreate, AdyenGatewayUpdate } from './resources/adyen_gateways';
|
7
|
+
export type { AdyenPayment, AdyenPaymentCreate, AdyenPaymentUpdate } from './resources/adyen_payments';
|
8
|
+
export type { Application } from './resources/application';
|
9
|
+
export type { Attachment, AttachmentCreate, AttachmentUpdate } from './resources/attachments';
|
10
|
+
export type { Authorization, AuthorizationUpdate } from './resources/authorizations';
|
11
|
+
export type { AvalaraAccount, AvalaraAccountCreate, AvalaraAccountUpdate } from './resources/avalara_accounts';
|
12
|
+
export type { BillingInfoValidationRule, BillingInfoValidationRuleCreate, BillingInfoValidationRuleUpdate } from './resources/billing_info_validation_rules';
|
13
|
+
export type { BingGeocoder, BingGeocoderCreate, BingGeocoderUpdate } from './resources/bing_geocoders';
|
14
|
+
export type { BraintreeGateway, BraintreeGatewayCreate, BraintreeGatewayUpdate } from './resources/braintree_gateways';
|
15
|
+
export type { BraintreePayment, BraintreePaymentCreate, BraintreePaymentUpdate } from './resources/braintree_payments';
|
16
|
+
export type { Bundle, BundleCreate, BundleUpdate } from './resources/bundles';
|
17
|
+
export type { Capture, CaptureUpdate } from './resources/captures';
|
18
|
+
export type { CarrierAccount } from './resources/carrier_accounts';
|
19
|
+
export type { CheckoutComGateway, CheckoutComGatewayCreate, CheckoutComGatewayUpdate } from './resources/checkout_com_gateways';
|
20
|
+
export type { CheckoutComPayment, CheckoutComPaymentCreate, CheckoutComPaymentUpdate } from './resources/checkout_com_payments';
|
21
|
+
export type { Cleanup, CleanupCreate } from './resources/cleanups';
|
22
|
+
export type { CouponCodesPromotionRule, CouponCodesPromotionRuleCreate, CouponCodesPromotionRuleUpdate } from './resources/coupon_codes_promotion_rules';
|
23
|
+
export type { CouponRecipient, CouponRecipientCreate, CouponRecipientUpdate } from './resources/coupon_recipients';
|
24
|
+
export type { Coupon, CouponCreate, CouponUpdate } from './resources/coupons';
|
25
|
+
export type { CustomerAddress, CustomerAddressCreate, CustomerAddressUpdate } from './resources/customer_addresses';
|
26
|
+
export type { CustomerGroup, CustomerGroupCreate, CustomerGroupUpdate } from './resources/customer_groups';
|
27
|
+
export type { CustomerPasswordReset, CustomerPasswordResetCreate, CustomerPasswordResetUpdate } from './resources/customer_password_resets';
|
28
|
+
export type { CustomerPaymentSource, CustomerPaymentSourceCreate, CustomerPaymentSourceUpdate } from './resources/customer_payment_sources';
|
29
|
+
export type { CustomerSubscription, CustomerSubscriptionCreate, CustomerSubscriptionUpdate } from './resources/customer_subscriptions';
|
30
|
+
export type { Customer, CustomerCreate, CustomerUpdate } from './resources/customers';
|
31
|
+
export type { DeliveryLeadTime, DeliveryLeadTimeCreate, DeliveryLeadTimeUpdate } from './resources/delivery_lead_times';
|
32
|
+
export type { EventCallback } from './resources/event_callbacks';
|
33
|
+
export type { Event } from './resources/events';
|
34
|
+
export type { Export, ExportCreate } from './resources/exports';
|
35
|
+
export type { ExternalGateway, ExternalGatewayCreate, ExternalGatewayUpdate } from './resources/external_gateways';
|
36
|
+
export type { ExternalPayment, ExternalPaymentCreate, ExternalPaymentUpdate } from './resources/external_payments';
|
37
|
+
export type { ExternalPromotion, ExternalPromotionCreate, ExternalPromotionUpdate } from './resources/external_promotions';
|
38
|
+
export type { ExternalTaxCalculator, ExternalTaxCalculatorCreate, ExternalTaxCalculatorUpdate } from './resources/external_tax_calculators';
|
39
|
+
export type { FixedAmountPromotion, FixedAmountPromotionCreate, FixedAmountPromotionUpdate } from './resources/fixed_amount_promotions';
|
40
|
+
export type { FixedPricePromotion, FixedPricePromotionCreate, FixedPricePromotionUpdate } from './resources/fixed_price_promotions';
|
41
|
+
export type { FreeGiftPromotion, FreeGiftPromotionCreate, FreeGiftPromotionUpdate } from './resources/free_gift_promotions';
|
42
|
+
export type { FreeShippingPromotion, FreeShippingPromotionCreate, FreeShippingPromotionUpdate } from './resources/free_shipping_promotions';
|
43
|
+
export type { Geocoder } from './resources/geocoders';
|
44
|
+
export type { GiftCardRecipient, GiftCardRecipientCreate, GiftCardRecipientUpdate } from './resources/gift_card_recipients';
|
45
|
+
export type { GiftCard, GiftCardCreate, GiftCardUpdate } from './resources/gift_cards';
|
46
|
+
export type { GoogleGeocoder, GoogleGeocoderCreate, GoogleGeocoderUpdate } from './resources/google_geocoders';
|
47
|
+
export type { Import, ImportCreate } from './resources/imports';
|
48
|
+
export type { InStockSubscription, InStockSubscriptionCreate, InStockSubscriptionUpdate } from './resources/in_stock_subscriptions';
|
49
|
+
export type { InventoryModel, InventoryModelCreate, InventoryModelUpdate } from './resources/inventory_models';
|
50
|
+
export type { InventoryReturnLocation, InventoryReturnLocationCreate, InventoryReturnLocationUpdate } from './resources/inventory_return_locations';
|
51
|
+
export type { InventoryStockLocation, InventoryStockLocationCreate, InventoryStockLocationUpdate } from './resources/inventory_stock_locations';
|
52
|
+
export type { KlarnaGateway, KlarnaGatewayCreate, KlarnaGatewayUpdate } from './resources/klarna_gateways';
|
53
|
+
export type { KlarnaPayment, KlarnaPaymentCreate, KlarnaPaymentUpdate } from './resources/klarna_payments';
|
54
|
+
export type { LineItemOption, LineItemOptionCreate, LineItemOptionUpdate } from './resources/line_item_options';
|
55
|
+
export type { LineItem, LineItemCreate, LineItemUpdate } from './resources/line_items';
|
56
|
+
export type { ManualGateway, ManualGatewayCreate, ManualGatewayUpdate } from './resources/manual_gateways';
|
57
|
+
export type { ManualTaxCalculator, ManualTaxCalculatorCreate, ManualTaxCalculatorUpdate } from './resources/manual_tax_calculators';
|
58
|
+
export type { Market, MarketCreate, MarketUpdate } from './resources/markets';
|
59
|
+
export type { Merchant, MerchantCreate, MerchantUpdate } from './resources/merchants';
|
60
|
+
export type { OrderAmountPromotionRule, OrderAmountPromotionRuleCreate, OrderAmountPromotionRuleUpdate } from './resources/order_amount_promotion_rules';
|
61
|
+
export type { OrderCopy, OrderCopyCreate } from './resources/order_copies';
|
62
|
+
export type { OrderSubscription, OrderSubscriptionCreate, OrderSubscriptionUpdate } from './resources/order_subscriptions';
|
63
|
+
export type { OrderValidationRule } from './resources/order_validation_rules';
|
64
|
+
export type { Order, OrderCreate, OrderUpdate } from './resources/orders';
|
65
|
+
export type { Organization } from './resources/organization';
|
66
|
+
export type { Package, PackageCreate, PackageUpdate } from './resources/packages';
|
67
|
+
export type { ParcelLineItem, ParcelLineItemCreate, ParcelLineItemUpdate } from './resources/parcel_line_items';
|
68
|
+
export type { Parcel, ParcelCreate, ParcelUpdate } from './resources/parcels';
|
69
|
+
export type { PaymentGateway } from './resources/payment_gateways';
|
70
|
+
export type { PaymentMethod, PaymentMethodCreate, PaymentMethodUpdate } from './resources/payment_methods';
|
71
|
+
export type { PaypalGateway, PaypalGatewayCreate, PaypalGatewayUpdate } from './resources/paypal_gateways';
|
72
|
+
export type { PaypalPayment, PaypalPaymentCreate, PaypalPaymentUpdate } from './resources/paypal_payments';
|
73
|
+
export type { PercentageDiscountPromotion, PercentageDiscountPromotionCreate, PercentageDiscountPromotionUpdate } from './resources/percentage_discount_promotions';
|
74
|
+
export type { PriceList, PriceListCreate, PriceListUpdate } from './resources/price_lists';
|
75
|
+
export type { PriceTier } from './resources/price_tiers';
|
76
|
+
export type { PriceVolumeTier, PriceVolumeTierCreate, PriceVolumeTierUpdate } from './resources/price_volume_tiers';
|
77
|
+
export type { Price, PriceCreate, PriceUpdate } from './resources/prices';
|
78
|
+
export type { PromotionRule } from './resources/promotion_rules';
|
79
|
+
export type { Promotion } from './resources/promotions';
|
80
|
+
export type { Refund } from './resources/refunds';
|
81
|
+
export type { ReturnLineItem, ReturnLineItemCreate, ReturnLineItemUpdate } from './resources/return_line_items';
|
82
|
+
export type { Return, ReturnCreate, ReturnUpdate } from './resources/returns';
|
83
|
+
export type { Shipment, ShipmentUpdate } from './resources/shipments';
|
84
|
+
export type { ShippingCategory, ShippingCategoryCreate, ShippingCategoryUpdate } from './resources/shipping_categories';
|
85
|
+
export type { ShippingMethodTier } from './resources/shipping_method_tiers';
|
86
|
+
export type { ShippingMethod, ShippingMethodCreate, ShippingMethodUpdate } from './resources/shipping_methods';
|
87
|
+
export type { ShippingWeightTier, ShippingWeightTierCreate, ShippingWeightTierUpdate } from './resources/shipping_weight_tiers';
|
88
|
+
export type { ShippingZone, ShippingZoneCreate, ShippingZoneUpdate } from './resources/shipping_zones';
|
89
|
+
export type { SkuListItem, SkuListItemCreate, SkuListItemUpdate } from './resources/sku_list_items';
|
90
|
+
export type { SkuListPromotionRule, SkuListPromotionRuleCreate, SkuListPromotionRuleUpdate } from './resources/sku_list_promotion_rules';
|
91
|
+
export type { SkuList, SkuListCreate, SkuListUpdate } from './resources/sku_lists';
|
92
|
+
export type { SkuOption, SkuOptionCreate, SkuOptionUpdate } from './resources/sku_options';
|
93
|
+
export type { Sku, SkuCreate, SkuUpdate } from './resources/skus';
|
94
|
+
export type { StockItem, StockItemCreate, StockItemUpdate } from './resources/stock_items';
|
95
|
+
export type { StockLineItem } from './resources/stock_line_items';
|
96
|
+
export type { StockLocation, StockLocationCreate, StockLocationUpdate } from './resources/stock_locations';
|
97
|
+
export type { StockTransfer, StockTransferCreate, StockTransferUpdate } from './resources/stock_transfers';
|
98
|
+
export type { StripeGateway, StripeGatewayCreate, StripeGatewayUpdate } from './resources/stripe_gateways';
|
99
|
+
export type { StripePayment, StripePaymentCreate, StripePaymentUpdate } from './resources/stripe_payments';
|
100
|
+
export type { TaxCalculator } from './resources/tax_calculators';
|
101
|
+
export type { TaxCategory, TaxCategoryCreate, TaxCategoryUpdate } from './resources/tax_categories';
|
102
|
+
export type { TaxRule, TaxRuleCreate, TaxRuleUpdate } from './resources/tax_rules';
|
103
|
+
export type { TaxjarAccount, TaxjarAccountCreate, TaxjarAccountUpdate } from './resources/taxjar_accounts';
|
104
|
+
export type { Transaction } from './resources/transactions';
|
105
|
+
export type { Void } from './resources/voids';
|
106
|
+
export type { Webhook, WebhookCreate, WebhookUpdate } from './resources/webhooks';
|
107
|
+
export type { WireTransfer, WireTransferCreate, WireTransferUpdate } from './resources/wire_transfers';
|
package/lib/esm/model.js
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
export{};
|
1
|
+
export {};
|
2
|
+
// ##__MODEL_TYPES_STOP__##
|
package/lib/esm/query.d.ts
CHANGED
@@ -1 +1,23 @@
|
|
1
|
-
import{ResourceType}from"./resource";
|
1
|
+
import { ResourceType } from "./resource";
|
2
|
+
interface QueryParamsRetrieve {
|
3
|
+
include?: string[];
|
4
|
+
fields?: string[] | {
|
5
|
+
[key: string]: string[];
|
6
|
+
};
|
7
|
+
}
|
8
|
+
interface QueryParamsList extends QueryParamsRetrieve {
|
9
|
+
sort?: string[] | {
|
10
|
+
[key: string]: 'asc' | 'desc';
|
11
|
+
};
|
12
|
+
filters?: {
|
13
|
+
[key: string]: string | number | boolean;
|
14
|
+
};
|
15
|
+
pageNumber?: number;
|
16
|
+
pageSize?: number;
|
17
|
+
}
|
18
|
+
type QueryParams = QueryParamsRetrieve | QueryParamsList;
|
19
|
+
export { QueryParamsRetrieve, QueryParamsList, QueryParams };
|
20
|
+
declare const generateQueryStringParams: (params: QueryParamsRetrieve | QueryParamsList | undefined, res: string | ResourceType) => {
|
21
|
+
[key: string]: string;
|
22
|
+
};
|
23
|
+
export { generateQueryStringParams };
|
package/lib/esm/query.js
CHANGED
@@ -1 +1,45 @@
|
|
1
|
-
import
|
1
|
+
import Debug from './debug';
|
2
|
+
const debug = Debug('query');
|
3
|
+
const isParamsList = (params) => {
|
4
|
+
return (params.filters || params.pageNumber || params.pageSize || params.sort);
|
5
|
+
};
|
6
|
+
const generateQueryStringParams = (params, res) => {
|
7
|
+
debug('generate query string params: %O, %O', params, res);
|
8
|
+
const qp = {};
|
9
|
+
if (!params)
|
10
|
+
return qp;
|
11
|
+
// Include
|
12
|
+
if (params.include)
|
13
|
+
qp.include = params.include.join(',');
|
14
|
+
// Fields
|
15
|
+
if (params.fields) {
|
16
|
+
if (Array.isArray(params.fields))
|
17
|
+
params.fields = { [res.type || res]: params.fields };
|
18
|
+
Object.entries(params.fields).forEach(([p, v]) => {
|
19
|
+
qp[`fields[${p}]`] = v.join(',');
|
20
|
+
});
|
21
|
+
}
|
22
|
+
if (isParamsList(params)) {
|
23
|
+
// Sort
|
24
|
+
if (params.sort) {
|
25
|
+
if (Array.isArray(params.sort))
|
26
|
+
qp.sort = params.sort.join(',');
|
27
|
+
else
|
28
|
+
qp.sort = Object.entries(params.sort).map(([k, v]) => `${v === 'desc' ? '-' : ''}${k}`).join(',');
|
29
|
+
}
|
30
|
+
// Page
|
31
|
+
if (params.pageNumber)
|
32
|
+
qp['page[number]'] = String(params.pageNumber);
|
33
|
+
if (params.pageSize)
|
34
|
+
qp['page[size]'] = String(params.pageSize);
|
35
|
+
// Filters
|
36
|
+
if (params.filters) {
|
37
|
+
Object.entries(params.filters).forEach(([p, v]) => {
|
38
|
+
qp[`filter[q][${p}]`] = String(v);
|
39
|
+
});
|
40
|
+
}
|
41
|
+
}
|
42
|
+
debug('query string params: %O', qp);
|
43
|
+
return qp;
|
44
|
+
};
|
45
|
+
export { generateQueryStringParams };
|
package/lib/esm/resource.d.ts
CHANGED
@@ -1 +1,77 @@
|
|
1
|
-
import{ApiClientInitConfig}from'./client';
|
1
|
+
import { ApiClientInitConfig } from './client';
|
2
|
+
import { QueryParamsRetrieve, QueryParamsList } from './query';
|
3
|
+
import { ResourceTypeLock } from './api';
|
4
|
+
import { InterceptorManager } from './interceptor';
|
5
|
+
import { QueryParams } from '.';
|
6
|
+
type ResourceNull = {
|
7
|
+
id: null;
|
8
|
+
} & ResourceType;
|
9
|
+
type ResourceRel = ResourceId | ResourceNull;
|
10
|
+
type Metadata = {
|
11
|
+
[key: string]: any;
|
12
|
+
};
|
13
|
+
interface ResourceType {
|
14
|
+
readonly type: ResourceTypeLock;
|
15
|
+
}
|
16
|
+
interface ResourceId extends ResourceType {
|
17
|
+
readonly id: string;
|
18
|
+
}
|
19
|
+
interface Resource extends ResourceId {
|
20
|
+
reference?: string;
|
21
|
+
reference_origin?: string;
|
22
|
+
metadata?: Metadata;
|
23
|
+
readonly created_at: string;
|
24
|
+
readonly updated_at: string;
|
25
|
+
}
|
26
|
+
interface ResourceCreate {
|
27
|
+
reference?: string;
|
28
|
+
reference_origin?: string;
|
29
|
+
metadata?: Metadata;
|
30
|
+
}
|
31
|
+
interface ResourceUpdate {
|
32
|
+
readonly id: string;
|
33
|
+
reference?: string;
|
34
|
+
reference_origin?: string;
|
35
|
+
metadata?: Metadata;
|
36
|
+
}
|
37
|
+
type ListMeta = {
|
38
|
+
readonly pageCount: number;
|
39
|
+
readonly recordCount: number;
|
40
|
+
readonly currentPage: number;
|
41
|
+
readonly recordsPerPage: number;
|
42
|
+
};
|
43
|
+
declare class ListResponse<R> extends Array<R> {
|
44
|
+
readonly meta: ListMeta;
|
45
|
+
constructor(meta: ListMeta, data: R[]);
|
46
|
+
first(): R | undefined;
|
47
|
+
last(): R | undefined;
|
48
|
+
get(index: number): R | undefined;
|
49
|
+
}
|
50
|
+
export type { Metadata, ResourceType, ResourceId, Resource, ResourceCreate, ResourceUpdate, ListResponse, ResourceRel };
|
51
|
+
type ResourceAdapterConfig = {};
|
52
|
+
type ResourcesInitConfig = ResourceAdapterConfig & ApiClientInitConfig;
|
53
|
+
type ResourcesConfig = Partial<ResourcesInitConfig>;
|
54
|
+
declare class ResourceAdapter {
|
55
|
+
#private;
|
56
|
+
constructor(config: ResourcesInitConfig);
|
57
|
+
get interceptors(): InterceptorManager;
|
58
|
+
private localConfig;
|
59
|
+
config(config: ResourcesConfig): void;
|
60
|
+
singleton<R extends Resource>(resource: ResourceType, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
61
|
+
retrieve<R extends Resource>(resource: ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
62
|
+
list<R extends Resource>(resource: ResourceType, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<R>>;
|
63
|
+
create<C extends ResourceCreate, R extends Resource>(resource: C & ResourceType, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
64
|
+
update<U extends ResourceUpdate, R extends Resource>(resource: U & ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
65
|
+
delete(resource: ResourceId, options?: ResourcesConfig): Promise<void>;
|
66
|
+
fetch<R extends Resource>(resource: string | ResourceType, path: string, params?: QueryParams, options?: ResourcesConfig): Promise<R | ListResponse<R>>;
|
67
|
+
}
|
68
|
+
declare abstract class ApiResource {
|
69
|
+
static readonly TYPE: ResourceTypeLock;
|
70
|
+
protected resources: ResourceAdapter;
|
71
|
+
constructor(adapter: ResourceAdapter);
|
72
|
+
abstract relationship(id: string | ResourceId | null): ResourceRel;
|
73
|
+
abstract type(): string;
|
74
|
+
update(resource: ResourceUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Resource>;
|
75
|
+
}
|
76
|
+
export default ResourceAdapter;
|
77
|
+
export { ApiResource, ResourcesConfig, ResourcesInitConfig };
|
package/lib/esm/resource.js
CHANGED
@@ -1 +1,139 @@
|
|
1
|
-
var
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
6
|
+
};
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
11
|
+
};
|
12
|
+
var _ResourceAdapter_client, _ResourceAdapter_config;
|
13
|
+
import ApiClient from './client';
|
14
|
+
import { denormalize, normalize } from './jsonapi';
|
15
|
+
import { generateQueryStringParams } from './query';
|
16
|
+
import config from './config';
|
17
|
+
import Debug from './debug';
|
18
|
+
const debug = Debug('resource');
|
19
|
+
class ListResponse extends Array {
|
20
|
+
constructor(meta, data) {
|
21
|
+
super(...(data || []));
|
22
|
+
this.meta = meta;
|
23
|
+
}
|
24
|
+
first() { return this.length ? this[0] : undefined; }
|
25
|
+
last() { return this.length ? this[this.length - 1] : undefined; }
|
26
|
+
get(index) { return (this.length && (index >= 0)) ? this[index] : undefined; }
|
27
|
+
}
|
28
|
+
class ResourceAdapter {
|
29
|
+
constructor(config) {
|
30
|
+
_ResourceAdapter_client.set(this, void 0);
|
31
|
+
_ResourceAdapter_config.set(this, {});
|
32
|
+
__classPrivateFieldSet(this, _ResourceAdapter_client, ApiClient.create(config), "f");
|
33
|
+
this.localConfig(config);
|
34
|
+
}
|
35
|
+
get interceptors() { return __classPrivateFieldGet(this, _ResourceAdapter_client, "f").interceptors; }
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
37
|
+
localConfig(config) {
|
38
|
+
// if (typeof config.xyz !== 'undefined') this.#config.xyz = config.xyz
|
39
|
+
}
|
40
|
+
config(config) {
|
41
|
+
debug('config %o', config);
|
42
|
+
// ResourceAdapter config
|
43
|
+
this.localConfig(config);
|
44
|
+
// Client config
|
45
|
+
__classPrivateFieldGet(this, _ResourceAdapter_client, "f").config(config);
|
46
|
+
}
|
47
|
+
async singleton(resource, params, options) {
|
48
|
+
debug('singleton: %o, %O, %O', resource, params || {}, options || {});
|
49
|
+
const queryParams = generateQueryStringParams(params, resource);
|
50
|
+
if (options === null || options === void 0 ? void 0 : options.params)
|
51
|
+
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
52
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}`, undefined, Object.assign(Object.assign({}, options), { params: queryParams }));
|
53
|
+
const r = denormalize(res);
|
54
|
+
return r;
|
55
|
+
}
|
56
|
+
async retrieve(resource, params, options) {
|
57
|
+
debug('retrieve: %o, %O, %O', resource, params || {}, options || {});
|
58
|
+
const queryParams = generateQueryStringParams(params, resource);
|
59
|
+
if (options === null || options === void 0 ? void 0 : options.params)
|
60
|
+
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
61
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}/${resource.id}`, undefined, Object.assign(Object.assign({}, options), { params: queryParams }));
|
62
|
+
const r = denormalize(res);
|
63
|
+
return r;
|
64
|
+
}
|
65
|
+
async list(resource, params, options) {
|
66
|
+
var _a, _b;
|
67
|
+
debug('list: %o, %O, %O', resource, params || {}, options || {});
|
68
|
+
const queryParams = generateQueryStringParams(params, resource);
|
69
|
+
if (options === null || options === void 0 ? void 0 : options.params)
|
70
|
+
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
71
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}`, undefined, Object.assign(Object.assign({}, options), { params: queryParams }));
|
72
|
+
const r = denormalize(res);
|
73
|
+
const meta = {
|
74
|
+
pageCount: Number((_a = res.meta) === null || _a === void 0 ? void 0 : _a.page_count),
|
75
|
+
recordCount: Number((_b = res.meta) === null || _b === void 0 ? void 0 : _b.record_count),
|
76
|
+
currentPage: (params === null || params === void 0 ? void 0 : params.pageNumber) || config.default.pageNumber,
|
77
|
+
recordsPerPage: (params === null || params === void 0 ? void 0 : params.pageSize) || config.default.pageSize
|
78
|
+
};
|
79
|
+
return new ListResponse(meta, r);
|
80
|
+
}
|
81
|
+
async create(resource, params, options) {
|
82
|
+
debug('create: %o, %O, %O', resource, params || {}, options || {});
|
83
|
+
const queryParams = generateQueryStringParams(params, resource);
|
84
|
+
if (options === null || options === void 0 ? void 0 : options.params)
|
85
|
+
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
86
|
+
const data = normalize(resource);
|
87
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('post', resource.type, data, Object.assign(Object.assign({}, options), { params: queryParams }));
|
88
|
+
const r = denormalize(res);
|
89
|
+
return r;
|
90
|
+
}
|
91
|
+
async update(resource, params, options) {
|
92
|
+
debug('update: %o, %O, %O', resource, params || {}, options || {});
|
93
|
+
const queryParams = generateQueryStringParams(params, resource);
|
94
|
+
if (options === null || options === void 0 ? void 0 : options.params)
|
95
|
+
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
96
|
+
const data = normalize(resource);
|
97
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('patch', `${resource.type}/${resource.id}`, data, Object.assign(Object.assign({}, options), { params: queryParams }));
|
98
|
+
const r = denormalize(res);
|
99
|
+
return r;
|
100
|
+
}
|
101
|
+
async delete(resource, options) {
|
102
|
+
debug('delete: %o, %O', resource, options || {});
|
103
|
+
await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('delete', `${resource.type}/${resource.id}`, undefined, options);
|
104
|
+
}
|
105
|
+
async fetch(resource, path, params, options) {
|
106
|
+
var _a, _b;
|
107
|
+
debug('fetch: %o, %O, %O', path, params || {}, options || {});
|
108
|
+
const queryParams = generateQueryStringParams(params, resource);
|
109
|
+
if (options === null || options === void 0 ? void 0 : options.params)
|
110
|
+
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
111
|
+
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', path, undefined, Object.assign(Object.assign({}, options), { params: queryParams }));
|
112
|
+
const r = denormalize(res);
|
113
|
+
if (Array.isArray(r)) {
|
114
|
+
const p = params;
|
115
|
+
const meta = {
|
116
|
+
pageCount: Number((_a = res.meta) === null || _a === void 0 ? void 0 : _a.page_count),
|
117
|
+
recordCount: Number((_b = res.meta) === null || _b === void 0 ? void 0 : _b.record_count),
|
118
|
+
currentPage: (p === null || p === void 0 ? void 0 : p.pageNumber) || config.default.pageNumber,
|
119
|
+
recordsPerPage: (p === null || p === void 0 ? void 0 : p.pageSize) || config.default.pageSize
|
120
|
+
};
|
121
|
+
return new ListResponse(meta, r);
|
122
|
+
}
|
123
|
+
else
|
124
|
+
return r;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
_ResourceAdapter_client = new WeakMap(), _ResourceAdapter_config = new WeakMap();
|
128
|
+
class ApiResource {
|
129
|
+
constructor(adapter) {
|
130
|
+
debug('new resource instance: %s', this.type());
|
131
|
+
this.resources = adapter;
|
132
|
+
}
|
133
|
+
// reference, reference_origin and metadata attributes are always updatable
|
134
|
+
async update(resource, params, options) {
|
135
|
+
return this.resources.update(Object.assign(Object.assign({}, resource), { type: this.type() }), params, options);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
export default ResourceAdapter;
|
139
|
+
export { ApiResource };
|
@@ -1 +1,88 @@
|
|
1
|
-
import{ApiResource,Resource,ResourceCreate,ResourceUpdate,ResourcesConfig,ResourceId,ResourceRel,ListResponse
|
1
|
+
import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourcesConfig, ResourceId, ResourceRel, ListResponse } from '../resource';
|
2
|
+
import type { QueryParamsList, QueryParamsRetrieve } from '../query';
|
3
|
+
import type { Geocoder } from './geocoders';
|
4
|
+
type AddressRel = ResourceRel & {
|
5
|
+
type: typeof Addresses.TYPE;
|
6
|
+
};
|
7
|
+
type GeocoderRel = ResourceRel & {
|
8
|
+
type: 'geocoders';
|
9
|
+
};
|
10
|
+
interface Address extends Resource {
|
11
|
+
business?: boolean;
|
12
|
+
first_name?: string;
|
13
|
+
last_name?: string;
|
14
|
+
company?: string;
|
15
|
+
full_name?: string;
|
16
|
+
line_1?: string;
|
17
|
+
line_2?: string;
|
18
|
+
city?: string;
|
19
|
+
zip_code?: string;
|
20
|
+
state_code?: string;
|
21
|
+
country_code?: string;
|
22
|
+
phone?: string;
|
23
|
+
full_address?: string;
|
24
|
+
name?: string;
|
25
|
+
email?: string;
|
26
|
+
notes?: string;
|
27
|
+
lat?: number;
|
28
|
+
lng?: number;
|
29
|
+
is_localized?: boolean;
|
30
|
+
is_geocoded?: boolean;
|
31
|
+
provider_name?: string;
|
32
|
+
map_url?: string;
|
33
|
+
static_map_url?: string;
|
34
|
+
billing_info?: string;
|
35
|
+
geocoder?: Geocoder;
|
36
|
+
}
|
37
|
+
interface AddressCreate extends ResourceCreate {
|
38
|
+
business?: boolean;
|
39
|
+
first_name?: string;
|
40
|
+
last_name?: string;
|
41
|
+
company?: string;
|
42
|
+
line_1: string;
|
43
|
+
line_2?: string;
|
44
|
+
city: string;
|
45
|
+
zip_code?: string;
|
46
|
+
state_code: string;
|
47
|
+
country_code: string;
|
48
|
+
phone: string;
|
49
|
+
email?: string;
|
50
|
+
notes?: string;
|
51
|
+
lat?: number;
|
52
|
+
lng?: number;
|
53
|
+
billing_info?: string;
|
54
|
+
geocoder?: GeocoderRel;
|
55
|
+
}
|
56
|
+
interface AddressUpdate extends ResourceUpdate {
|
57
|
+
business?: boolean;
|
58
|
+
first_name?: string;
|
59
|
+
last_name?: string;
|
60
|
+
company?: string;
|
61
|
+
line_1?: string;
|
62
|
+
line_2?: string;
|
63
|
+
city?: string;
|
64
|
+
zip_code?: string;
|
65
|
+
state_code?: string;
|
66
|
+
country_code?: string;
|
67
|
+
phone?: string;
|
68
|
+
email?: string;
|
69
|
+
notes?: string;
|
70
|
+
lat?: number;
|
71
|
+
lng?: number;
|
72
|
+
billing_info?: string;
|
73
|
+
geocoder?: GeocoderRel;
|
74
|
+
}
|
75
|
+
declare class Addresses extends ApiResource {
|
76
|
+
static readonly TYPE: 'addresses';
|
77
|
+
list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Address>>;
|
78
|
+
create(resource: AddressCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Address>;
|
79
|
+
retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Address>;
|
80
|
+
update(resource: AddressUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Address>;
|
81
|
+
delete(id: string, options?: ResourcesConfig): Promise<void>;
|
82
|
+
geocoder(addressId: string | Address, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Geocoder>;
|
83
|
+
isAddress(resource: any): resource is Address;
|
84
|
+
relationship(id: string | ResourceId | null): AddressRel;
|
85
|
+
type(): string;
|
86
|
+
}
|
87
|
+
export default Addresses;
|
88
|
+
export { Address, AddressCreate, AddressUpdate };
|