@commercelayer/sdk 5.37.0 → 5.38.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 +1 -164
- package/lib/cjs/api.js +1 -387
- package/lib/cjs/client.d.ts +1 -39
- package/lib/cjs/client.js +1 -154
- package/lib/cjs/commercelayer.d.ts +1 -153
- package/lib/cjs/commercelayer.js +1 -253
- package/lib/cjs/common.d.ts +1 -5
- package/lib/cjs/common.js +1 -23
- package/lib/cjs/config.d.ts +1 -15
- package/lib/cjs/config.js +1 -19
- package/lib/cjs/debug.d.ts +1 -3
- package/lib/cjs/debug.js +1 -38
- package/lib/cjs/error.d.ts +1 -31
- package/lib/cjs/error.js +1 -77
- package/lib/cjs/index.d.ts +1 -7
- package/lib/cjs/index.js +1 -13
- package/lib/cjs/interceptor.d.ts +1 -25
- package/lib/cjs/interceptor.js +1 -2
- package/lib/cjs/jsonapi.d.ts +1 -6
- package/lib/cjs/jsonapi.js +1 -94
- package/lib/cjs/model.d.ts +1 -124
- package/lib/cjs/model.js +1 -3
- package/lib/cjs/query.d.ts +1 -17
- package/lib/cjs/query.js +1 -69
- package/lib/cjs/resource.d.ts +1 -89
- package/lib/cjs/resource.js +1 -198
- package/lib/cjs/resources/addresses.d.ts +1 -103
- package/lib/cjs/resources/addresses.js +1 -41
- package/lib/cjs/resources/adjustments.d.ts +1 -42
- package/lib/cjs/resources/adjustments.js +1 -29
- package/lib/cjs/resources/adyen_gateways.d.ts +1 -60
- package/lib/cjs/resources/adyen_gateways.js +1 -37
- package/lib/cjs/resources/adyen_payments.d.ts +1 -51
- package/lib/cjs/resources/adyen_payments.js +1 -40
- package/lib/cjs/resources/application.d.ts +1 -22
- package/lib/cjs/resources/application.js +1 -16
- package/lib/cjs/resources/attachments.d.ts +1 -157
- package/lib/cjs/resources/attachments.js +1 -25
- package/lib/cjs/resources/authorizations.d.ts +1 -70
- package/lib/cjs/resources/authorizations.js +1 -52
- package/lib/cjs/resources/avalara_accounts.d.ts +1 -59
- package/lib/cjs/resources/avalara_accounts.js +1 -41
- package/lib/cjs/resources/axerve_gateways.d.ts +1 -48
- package/lib/cjs/resources/axerve_gateways.js +1 -37
- package/lib/cjs/resources/axerve_payments.d.ts +1 -54
- package/lib/cjs/resources/axerve_payments.js +1 -40
- package/lib/cjs/resources/billing_info_validation_rules.d.ts +1 -39
- package/lib/cjs/resources/billing_info_validation_rules.js +1 -37
- package/lib/cjs/resources/bing_geocoders.d.ts +1 -36
- package/lib/cjs/resources/bing_geocoders.js +1 -33
- package/lib/cjs/resources/braintree_gateways.d.ts +1 -60
- package/lib/cjs/resources/braintree_gateways.js +1 -37
- package/lib/cjs/resources/braintree_payments.d.ts +1 -52
- package/lib/cjs/resources/braintree_payments.js +1 -37
- package/lib/cjs/resources/bundles.d.ts +1 -93
- package/lib/cjs/resources/bundles.js +1 -59
- package/lib/cjs/resources/buy_x_pay_y_promotions.d.ts +1 -137
- package/lib/cjs/resources/buy_x_pay_y_promotions.js +1 -79
- package/lib/cjs/resources/captures.d.ts +1 -60
- package/lib/cjs/resources/captures.js +1 -49
- package/lib/cjs/resources/carrier_accounts.d.ts +1 -30
- package/lib/cjs/resources/carrier_accounts.js +1 -28
- package/lib/cjs/resources/checkout_com_gateways.d.ts +1 -49
- package/lib/cjs/resources/checkout_com_gateways.js +1 -37
- package/lib/cjs/resources/checkout_com_payments.d.ts +1 -65
- package/lib/cjs/resources/checkout_com_payments.js +1 -43
- package/lib/cjs/resources/cleanups.d.ts +1 -40
- package/lib/cjs/resources/cleanups.js +1 -30
- package/lib/cjs/resources/coupon_codes_promotion_rules.d.ts +1 -67
- package/lib/cjs/resources/coupon_codes_promotion_rules.js +1 -33
- package/lib/cjs/resources/coupon_recipients.d.ts +1 -48
- package/lib/cjs/resources/coupon_recipients.js +1 -37
- package/lib/cjs/resources/coupons.d.ts +1 -71
- package/lib/cjs/resources/coupons.js +1 -45
- package/lib/cjs/resources/custom_promotion_rules.d.ts +1 -62
- package/lib/cjs/resources/custom_promotion_rules.js +1 -29
- package/lib/cjs/resources/customer_addresses.d.ts +1 -50
- package/lib/cjs/resources/customer_addresses.js +1 -41
- package/lib/cjs/resources/customer_groups.d.ts +1 -40
- package/lib/cjs/resources/customer_groups.js +1 -41
- package/lib/cjs/resources/customer_password_resets.d.ts +1 -38
- package/lib/cjs/resources/customer_password_resets.js +1 -36
- package/lib/cjs/resources/customer_payment_sources.d.ts +1 -86
- package/lib/cjs/resources/customer_payment_sources.js +1 -37
- package/lib/cjs/resources/customer_subscriptions.d.ts +1 -35
- package/lib/cjs/resources/customer_subscriptions.js +1 -37
- package/lib/cjs/resources/customers.d.ts +1 -76
- package/lib/cjs/resources/customers.js +1 -69
- package/lib/cjs/resources/delivery_lead_times.d.ts +1 -55
- package/lib/cjs/resources/delivery_lead_times.js +1 -41
- package/lib/cjs/resources/event_callbacks.d.ts +1 -25
- package/lib/cjs/resources/event_callbacks.js +1 -20
- package/lib/cjs/resources/events.d.ts +1 -25
- package/lib/cjs/resources/events.js +1 -24
- package/lib/cjs/resources/exports.d.ts +1 -41
- package/lib/cjs/resources/exports.js +1 -26
- package/lib/cjs/resources/external_gateways.d.ts +1 -57
- package/lib/cjs/resources/external_gateways.js +1 -40
- package/lib/cjs/resources/external_payments.d.ts +1 -48
- package/lib/cjs/resources/external_payments.js +1 -41
- package/lib/cjs/resources/external_promotions.d.ts +1 -136
- package/lib/cjs/resources/external_promotions.js +1 -82
- package/lib/cjs/resources/external_tax_calculators.d.ts +1 -45
- package/lib/cjs/resources/external_tax_calculators.js +1 -40
- package/lib/cjs/resources/fixed_amount_promotions.d.ts +1 -133
- package/lib/cjs/resources/fixed_amount_promotions.js +1 -79
- package/lib/cjs/resources/fixed_price_promotions.d.ts +1 -133
- package/lib/cjs/resources/fixed_price_promotions.js +1 -79
- package/lib/cjs/resources/free_gift_promotions.d.ts +1 -131
- package/lib/cjs/resources/free_gift_promotions.js +1 -79
- package/lib/cjs/resources/free_shipping_promotions.d.ts +1 -125
- package/lib/cjs/resources/free_shipping_promotions.js +1 -75
- package/lib/cjs/resources/geocoders.d.ts +1 -25
- package/lib/cjs/resources/geocoders.js +1 -24
- package/lib/cjs/resources/gift_card_recipients.d.ts +1 -48
- package/lib/cjs/resources/gift_card_recipients.js +1 -37
- package/lib/cjs/resources/gift_cards.d.ts +1 -104
- package/lib/cjs/resources/gift_cards.js +1 -61
- package/lib/cjs/resources/google_geocoders.d.ts +1 -36
- package/lib/cjs/resources/google_geocoders.js +1 -33
- package/lib/cjs/resources/imports.d.ts +1 -44
- package/lib/cjs/resources/imports.js +1 -26
- package/lib/cjs/resources/in_stock_subscriptions.d.ts +1 -68
- package/lib/cjs/resources/in_stock_subscriptions.js +1 -51
- package/lib/cjs/resources/inventory_models.d.ts +1 -55
- package/lib/cjs/resources/inventory_models.js +1 -41
- package/lib/cjs/resources/inventory_return_locations.d.ts +1 -47
- package/lib/cjs/resources/inventory_return_locations.js +1 -37
- package/lib/cjs/resources/inventory_stock_locations.d.ts +1 -50
- package/lib/cjs/resources/inventory_stock_locations.js +1 -37
- package/lib/cjs/resources/klarna_gateways.d.ts +1 -48
- package/lib/cjs/resources/klarna_gateways.js +1 -37
- package/lib/cjs/resources/klarna_payments.d.ts +1 -48
- package/lib/cjs/resources/klarna_payments.js +1 -40
- package/lib/cjs/resources/line_item_options.d.ts +1 -69
- package/lib/cjs/resources/line_item_options.js +1 -41
- package/lib/cjs/resources/line_items.d.ts +1 -170
- package/lib/cjs/resources/line_items.js +1 -66
- package/lib/cjs/resources/manual_gateways.d.ts +1 -34
- package/lib/cjs/resources/manual_gateways.js +1 -33
- package/lib/cjs/resources/manual_tax_calculators.d.ts +1 -45
- package/lib/cjs/resources/manual_tax_calculators.js +1 -41
- package/lib/cjs/resources/markets.d.ts +1 -107
- package/lib/cjs/resources/markets.js +1 -63
- package/lib/cjs/resources/merchants.d.ts +1 -42
- package/lib/cjs/resources/merchants.js +1 -37
- package/lib/cjs/resources/order_amount_promotion_rules.d.ts +1 -67
- package/lib/cjs/resources/order_amount_promotion_rules.js +1 -29
- package/lib/cjs/resources/order_copies.d.ts +1 -51
- package/lib/cjs/resources/order_copies.js +1 -41
- package/lib/cjs/resources/order_factories.d.ts +1 -34
- package/lib/cjs/resources/order_factories.js +1 -28
- package/lib/cjs/resources/order_subscription_items.d.ts +1 -72
- package/lib/cjs/resources/order_subscription_items.js +1 -33
- package/lib/cjs/resources/order_subscriptions.d.ts +1 -98
- package/lib/cjs/resources/order_subscriptions.js +1 -78
- package/lib/cjs/resources/order_validation_rules.d.ts +1 -27
- package/lib/cjs/resources/order_validation_rules.js +1 -28
- package/lib/cjs/resources/orders.d.ts +1 -389
- package/lib/cjs/resources/orders.js +1 -236
- package/lib/cjs/resources/organization.d.ts +1 -34
- package/lib/cjs/resources/organization.js +1 -16
- package/lib/cjs/resources/packages.d.ts +1 -60
- package/lib/cjs/resources/packages.js +1 -41
- package/lib/cjs/resources/parcel_line_items.d.ts +1 -47
- package/lib/cjs/resources/parcel_line_items.js +1 -37
- package/lib/cjs/resources/parcels.d.ts +1 -126
- package/lib/cjs/resources/parcels.js +1 -49
- package/lib/cjs/resources/payment_gateways.d.ts +1 -25
- package/lib/cjs/resources/payment_gateways.js +1 -24
- package/lib/cjs/resources/payment_methods.d.ts +1 -83
- package/lib/cjs/resources/payment_methods.js +1 -47
- package/lib/cjs/resources/payment_options.d.ts +1 -44
- package/lib/cjs/resources/payment_options.js +1 -33
- package/lib/cjs/resources/paypal_gateways.d.ts +1 -41
- package/lib/cjs/resources/paypal_gateways.js +1 -37
- package/lib/cjs/resources/paypal_payments.d.ts +1 -53
- package/lib/cjs/resources/paypal_payments.js +1 -37
- package/lib/cjs/resources/percentage_discount_promotions.d.ts +1 -131
- package/lib/cjs/resources/percentage_discount_promotions.js +1 -79
- package/lib/cjs/resources/price_frequency_tiers.d.ts +1 -53
- package/lib/cjs/resources/price_frequency_tiers.js +1 -41
- package/lib/cjs/resources/price_lists.d.ts +1 -46
- package/lib/cjs/resources/price_lists.js +1 -37
- package/lib/cjs/resources/price_tiers.d.ts +1 -32
- package/lib/cjs/resources/price_tiers.js +1 -28
- package/lib/cjs/resources/price_volume_tiers.d.ts +1 -53
- package/lib/cjs/resources/price_volume_tiers.js +1 -41
- package/lib/cjs/resources/prices.d.ts +1 -84
- package/lib/cjs/resources/prices.js +1 -65
- package/lib/cjs/resources/promotion_rules.d.ts +1 -29
- package/lib/cjs/resources/promotion_rules.js +1 -20
- package/lib/cjs/resources/promotions.d.ts +1 -63
- package/lib/cjs/resources/promotions.js +1 -60
- package/lib/cjs/resources/recurring_order_copies.d.ts +1 -53
- package/lib/cjs/resources/recurring_order_copies.js +1 -41
- package/lib/cjs/resources/refunds.d.ts +1 -44
- package/lib/cjs/resources/refunds.js +1 -36
- package/lib/cjs/resources/reserved_stocks.d.ts +1 -28
- package/lib/cjs/resources/reserved_stocks.js +1 -28
- package/lib/cjs/resources/resource_errors.d.ts +1 -22
- package/lib/cjs/resources/resource_errors.js +1 -16
- package/lib/cjs/resources/return_line_items.d.ts +1 -52
- package/lib/cjs/resources/return_line_items.js +1 -36
- package/lib/cjs/resources/returns.d.ts +1 -96
- package/lib/cjs/resources/returns.js +1 -92
- package/lib/cjs/resources/satispay_gateways.d.ts +1 -46
- package/lib/cjs/resources/satispay_gateways.js +1 -37
- package/lib/cjs/resources/satispay_payments.d.ts +1 -50
- package/lib/cjs/resources/satispay_payments.js +1 -40
- package/lib/cjs/resources/shipments.d.ts +1 -151
- package/lib/cjs/resources/shipments.js +1 -130
- package/lib/cjs/resources/shipping_categories.d.ts +1 -40
- package/lib/cjs/resources/shipping_categories.js +1 -37
- package/lib/cjs/resources/shipping_method_tiers.d.ts +1 -32
- package/lib/cjs/resources/shipping_method_tiers.js +1 -28
- package/lib/cjs/resources/shipping_methods.d.ts +1 -125
- package/lib/cjs/resources/shipping_methods.js +1 -70
- package/lib/cjs/resources/shipping_weight_tiers.d.ts +1 -50
- package/lib/cjs/resources/shipping_weight_tiers.js +1 -37
- package/lib/cjs/resources/shipping_zones.d.ts +1 -52
- package/lib/cjs/resources/shipping_zones.js +1 -33
- package/lib/cjs/resources/sku_list_items.d.ts +1 -51
- package/lib/cjs/resources/sku_list_items.js +1 -37
- package/lib/cjs/resources/sku_list_promotion_rules.d.ts +1 -76
- package/lib/cjs/resources/sku_list_promotion_rules.js +1 -37
- package/lib/cjs/resources/sku_lists.d.ts +1 -64
- package/lib/cjs/resources/sku_lists.js +1 -49
- package/lib/cjs/resources/sku_options.d.ts +1 -71
- package/lib/cjs/resources/sku_options.js +1 -45
- package/lib/cjs/resources/skus.d.ts +1 -96
- package/lib/cjs/resources/skus.js +1 -65
- package/lib/cjs/resources/stock_items.d.ts +1 -61
- package/lib/cjs/resources/stock_items.js +1 -52
- package/lib/cjs/resources/stock_line_items.d.ts +1 -73
- package/lib/cjs/resources/stock_line_items.js +1 -54
- package/lib/cjs/resources/stock_locations.d.ts +1 -64
- package/lib/cjs/resources/stock_locations.js +1 -53
- package/lib/cjs/resources/stock_reservations.d.ts +1 -51
- package/lib/cjs/resources/stock_reservations.js +1 -48
- package/lib/cjs/resources/stock_transfers.d.ts +1 -86
- package/lib/cjs/resources/stock_transfers.js +1 -71
- package/lib/cjs/resources/stripe_gateways.d.ts +1 -45
- package/lib/cjs/resources/stripe_gateways.js +1 -37
- package/lib/cjs/resources/stripe_payments.d.ts +1 -59
- package/lib/cjs/resources/stripe_payments.js +1 -43
- package/lib/cjs/resources/subscription_models.d.ts +1 -49
- package/lib/cjs/resources/subscription_models.js +1 -37
- package/lib/cjs/resources/tags.d.ts +1 -28
- package/lib/cjs/resources/tags.js +1 -25
- package/lib/cjs/resources/tax_calculators.d.ts +1 -28
- package/lib/cjs/resources/tax_calculators.js +1 -28
- package/lib/cjs/resources/tax_categories.d.ts +1 -63
- package/lib/cjs/resources/tax_categories.js +1 -37
- package/lib/cjs/resources/tax_rules.d.ts +1 -73
- package/lib/cjs/resources/tax_rules.js +1 -33
- package/lib/cjs/resources/taxjar_accounts.d.ts +1 -47
- package/lib/cjs/resources/taxjar_accounts.js +1 -41
- package/lib/cjs/resources/transactions.d.ts +1 -41
- package/lib/cjs/resources/transactions.js +1 -32
- package/lib/cjs/resources/versions.d.ts +1 -22
- package/lib/cjs/resources/versions.js +1 -16
- package/lib/cjs/resources/voids.d.ts +1 -44
- package/lib/cjs/resources/voids.js +1 -36
- package/lib/cjs/resources/webhooks.d.ts +1 -55
- package/lib/cjs/resources/webhooks.js +1 -42
- package/lib/cjs/resources/wire_transfers.d.ts +1 -37
- package/lib/cjs/resources/wire_transfers.js +1 -33
- package/lib/cjs/static.d.ts +1 -12
- package/lib/cjs/static.js +1 -51
- package/lib/cjs/util.d.ts +1 -4
- package/lib/cjs/util.js +1 -16
- package/lib/esm/api.d.ts +1 -164
- package/lib/esm/api.js +1 -258
- package/lib/esm/client.d.ts +1 -39
- package/lib/esm/client.js +1 -149
- package/lib/esm/commercelayer.d.ts +1 -153
- package/lib/esm/commercelayer.js +1 -224
- package/lib/esm/common.d.ts +1 -5
- package/lib/esm/common.js +1 -19
- package/lib/esm/config.d.ts +1 -15
- package/lib/esm/config.js +1 -17
- package/lib/esm/debug.d.ts +1 -3
- package/lib/esm/debug.js +1 -36
- package/lib/esm/error.d.ts +1 -31
- package/lib/esm/error.js +1 -69
- package/lib/esm/index.d.ts +1 -7
- package/lib/esm/index.js +1 -4
- package/lib/esm/interceptor.d.ts +1 -25
- package/lib/esm/interceptor.js +1 -1
- package/lib/esm/jsonapi.d.ts +1 -6
- package/lib/esm/jsonapi.js +1 -87
- package/lib/esm/model.d.ts +1 -124
- package/lib/esm/model.js +1 -2
- package/lib/esm/query.d.ts +1 -17
- package/lib/esm/query.js +1 -62
- package/lib/esm/resource.d.ts +1 -89
- package/lib/esm/resource.js +1 -191
- package/lib/esm/resources/addresses.d.ts +1 -103
- package/lib/esm/resources/addresses.js +1 -39
- package/lib/esm/resources/adjustments.d.ts +1 -42
- package/lib/esm/resources/adjustments.js +1 -27
- package/lib/esm/resources/adyen_gateways.d.ts +1 -60
- package/lib/esm/resources/adyen_gateways.js +1 -35
- package/lib/esm/resources/adyen_payments.d.ts +1 -51
- package/lib/esm/resources/adyen_payments.js +1 -38
- package/lib/esm/resources/application.d.ts +1 -22
- package/lib/esm/resources/application.js +1 -14
- package/lib/esm/resources/attachments.d.ts +1 -157
- package/lib/esm/resources/attachments.js +1 -23
- package/lib/esm/resources/authorizations.d.ts +1 -70
- package/lib/esm/resources/authorizations.js +1 -50
- package/lib/esm/resources/avalara_accounts.d.ts +1 -59
- package/lib/esm/resources/avalara_accounts.js +1 -39
- package/lib/esm/resources/axerve_gateways.d.ts +1 -48
- package/lib/esm/resources/axerve_gateways.js +1 -35
- package/lib/esm/resources/axerve_payments.d.ts +1 -54
- package/lib/esm/resources/axerve_payments.js +1 -38
- package/lib/esm/resources/billing_info_validation_rules.d.ts +1 -39
- package/lib/esm/resources/billing_info_validation_rules.js +1 -35
- package/lib/esm/resources/bing_geocoders.d.ts +1 -36
- package/lib/esm/resources/bing_geocoders.js +1 -31
- package/lib/esm/resources/braintree_gateways.d.ts +1 -60
- package/lib/esm/resources/braintree_gateways.js +1 -35
- package/lib/esm/resources/braintree_payments.d.ts +1 -52
- package/lib/esm/resources/braintree_payments.js +1 -35
- package/lib/esm/resources/bundles.d.ts +1 -93
- package/lib/esm/resources/bundles.js +1 -57
- package/lib/esm/resources/buy_x_pay_y_promotions.d.ts +1 -137
- package/lib/esm/resources/buy_x_pay_y_promotions.js +1 -77
- package/lib/esm/resources/captures.d.ts +1 -60
- package/lib/esm/resources/captures.js +1 -47
- package/lib/esm/resources/carrier_accounts.d.ts +1 -30
- package/lib/esm/resources/carrier_accounts.js +1 -26
- package/lib/esm/resources/checkout_com_gateways.d.ts +1 -49
- package/lib/esm/resources/checkout_com_gateways.js +1 -35
- package/lib/esm/resources/checkout_com_payments.d.ts +1 -65
- package/lib/esm/resources/checkout_com_payments.js +1 -41
- package/lib/esm/resources/cleanups.d.ts +1 -40
- package/lib/esm/resources/cleanups.js +1 -28
- package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +1 -67
- package/lib/esm/resources/coupon_codes_promotion_rules.js +1 -31
- package/lib/esm/resources/coupon_recipients.d.ts +1 -48
- package/lib/esm/resources/coupon_recipients.js +1 -35
- package/lib/esm/resources/coupons.d.ts +1 -71
- package/lib/esm/resources/coupons.js +1 -43
- package/lib/esm/resources/custom_promotion_rules.d.ts +1 -62
- package/lib/esm/resources/custom_promotion_rules.js +1 -27
- package/lib/esm/resources/customer_addresses.d.ts +1 -50
- package/lib/esm/resources/customer_addresses.js +1 -39
- package/lib/esm/resources/customer_groups.d.ts +1 -40
- package/lib/esm/resources/customer_groups.js +1 -39
- package/lib/esm/resources/customer_password_resets.d.ts +1 -38
- package/lib/esm/resources/customer_password_resets.js +1 -34
- package/lib/esm/resources/customer_payment_sources.d.ts +1 -86
- package/lib/esm/resources/customer_payment_sources.js +1 -35
- package/lib/esm/resources/customer_subscriptions.d.ts +1 -35
- package/lib/esm/resources/customer_subscriptions.js +1 -35
- package/lib/esm/resources/customers.d.ts +1 -76
- package/lib/esm/resources/customers.js +1 -67
- package/lib/esm/resources/delivery_lead_times.d.ts +1 -55
- package/lib/esm/resources/delivery_lead_times.js +1 -39
- package/lib/esm/resources/event_callbacks.d.ts +1 -25
- package/lib/esm/resources/event_callbacks.js +1 -18
- package/lib/esm/resources/events.d.ts +1 -25
- package/lib/esm/resources/events.js +1 -22
- package/lib/esm/resources/exports.d.ts +1 -41
- package/lib/esm/resources/exports.js +1 -24
- package/lib/esm/resources/external_gateways.d.ts +1 -57
- package/lib/esm/resources/external_gateways.js +1 -38
- package/lib/esm/resources/external_payments.d.ts +1 -48
- package/lib/esm/resources/external_payments.js +1 -39
- package/lib/esm/resources/external_promotions.d.ts +1 -136
- package/lib/esm/resources/external_promotions.js +1 -80
- package/lib/esm/resources/external_tax_calculators.d.ts +1 -45
- package/lib/esm/resources/external_tax_calculators.js +1 -38
- package/lib/esm/resources/fixed_amount_promotions.d.ts +1 -133
- package/lib/esm/resources/fixed_amount_promotions.js +1 -77
- package/lib/esm/resources/fixed_price_promotions.d.ts +1 -133
- package/lib/esm/resources/fixed_price_promotions.js +1 -77
- package/lib/esm/resources/free_gift_promotions.d.ts +1 -131
- package/lib/esm/resources/free_gift_promotions.js +1 -77
- package/lib/esm/resources/free_shipping_promotions.d.ts +1 -125
- package/lib/esm/resources/free_shipping_promotions.js +1 -73
- package/lib/esm/resources/geocoders.d.ts +1 -25
- package/lib/esm/resources/geocoders.js +1 -22
- package/lib/esm/resources/gift_card_recipients.d.ts +1 -48
- package/lib/esm/resources/gift_card_recipients.js +1 -35
- package/lib/esm/resources/gift_cards.d.ts +1 -104
- package/lib/esm/resources/gift_cards.js +1 -59
- package/lib/esm/resources/google_geocoders.d.ts +1 -36
- package/lib/esm/resources/google_geocoders.js +1 -31
- package/lib/esm/resources/imports.d.ts +1 -44
- package/lib/esm/resources/imports.js +1 -24
- package/lib/esm/resources/in_stock_subscriptions.d.ts +1 -68
- package/lib/esm/resources/in_stock_subscriptions.js +1 -49
- package/lib/esm/resources/inventory_models.d.ts +1 -55
- package/lib/esm/resources/inventory_models.js +1 -39
- package/lib/esm/resources/inventory_return_locations.d.ts +1 -47
- package/lib/esm/resources/inventory_return_locations.js +1 -35
- package/lib/esm/resources/inventory_stock_locations.d.ts +1 -50
- package/lib/esm/resources/inventory_stock_locations.js +1 -35
- package/lib/esm/resources/klarna_gateways.d.ts +1 -48
- package/lib/esm/resources/klarna_gateways.js +1 -35
- package/lib/esm/resources/klarna_payments.d.ts +1 -48
- package/lib/esm/resources/klarna_payments.js +1 -38
- package/lib/esm/resources/line_item_options.d.ts +1 -69
- package/lib/esm/resources/line_item_options.js +1 -39
- package/lib/esm/resources/line_items.d.ts +1 -170
- package/lib/esm/resources/line_items.js +1 -64
- package/lib/esm/resources/manual_gateways.d.ts +1 -34
- package/lib/esm/resources/manual_gateways.js +1 -31
- package/lib/esm/resources/manual_tax_calculators.d.ts +1 -45
- package/lib/esm/resources/manual_tax_calculators.js +1 -39
- package/lib/esm/resources/markets.d.ts +1 -107
- package/lib/esm/resources/markets.js +1 -61
- package/lib/esm/resources/merchants.d.ts +1 -42
- package/lib/esm/resources/merchants.js +1 -35
- package/lib/esm/resources/order_amount_promotion_rules.d.ts +1 -67
- package/lib/esm/resources/order_amount_promotion_rules.js +1 -27
- package/lib/esm/resources/order_copies.d.ts +1 -51
- package/lib/esm/resources/order_copies.js +1 -39
- package/lib/esm/resources/order_factories.d.ts +1 -34
- package/lib/esm/resources/order_factories.js +1 -26
- package/lib/esm/resources/order_subscription_items.d.ts +1 -72
- package/lib/esm/resources/order_subscription_items.js +1 -31
- package/lib/esm/resources/order_subscriptions.d.ts +1 -98
- package/lib/esm/resources/order_subscriptions.js +1 -76
- package/lib/esm/resources/order_validation_rules.d.ts +1 -27
- package/lib/esm/resources/order_validation_rules.js +1 -26
- package/lib/esm/resources/orders.d.ts +1 -389
- package/lib/esm/resources/orders.js +1 -234
- package/lib/esm/resources/organization.d.ts +1 -34
- package/lib/esm/resources/organization.js +1 -14
- package/lib/esm/resources/packages.d.ts +1 -60
- package/lib/esm/resources/packages.js +1 -39
- package/lib/esm/resources/parcel_line_items.d.ts +1 -47
- package/lib/esm/resources/parcel_line_items.js +1 -35
- package/lib/esm/resources/parcels.d.ts +1 -126
- package/lib/esm/resources/parcels.js +1 -47
- package/lib/esm/resources/payment_gateways.d.ts +1 -25
- package/lib/esm/resources/payment_gateways.js +1 -22
- package/lib/esm/resources/payment_methods.d.ts +1 -83
- package/lib/esm/resources/payment_methods.js +1 -45
- package/lib/esm/resources/payment_options.d.ts +1 -44
- package/lib/esm/resources/payment_options.js +1 -31
- package/lib/esm/resources/paypal_gateways.d.ts +1 -41
- package/lib/esm/resources/paypal_gateways.js +1 -35
- package/lib/esm/resources/paypal_payments.d.ts +1 -53
- package/lib/esm/resources/paypal_payments.js +1 -35
- package/lib/esm/resources/percentage_discount_promotions.d.ts +1 -131
- package/lib/esm/resources/percentage_discount_promotions.js +1 -77
- package/lib/esm/resources/price_frequency_tiers.d.ts +1 -53
- package/lib/esm/resources/price_frequency_tiers.js +1 -39
- package/lib/esm/resources/price_lists.d.ts +1 -46
- package/lib/esm/resources/price_lists.js +1 -35
- package/lib/esm/resources/price_tiers.d.ts +1 -32
- package/lib/esm/resources/price_tiers.js +1 -26
- package/lib/esm/resources/price_volume_tiers.d.ts +1 -53
- package/lib/esm/resources/price_volume_tiers.js +1 -39
- package/lib/esm/resources/prices.d.ts +1 -84
- package/lib/esm/resources/prices.js +1 -63
- package/lib/esm/resources/promotion_rules.d.ts +1 -29
- package/lib/esm/resources/promotion_rules.js +1 -18
- package/lib/esm/resources/promotions.d.ts +1 -63
- package/lib/esm/resources/promotions.js +1 -58
- package/lib/esm/resources/recurring_order_copies.d.ts +1 -53
- package/lib/esm/resources/recurring_order_copies.js +1 -39
- package/lib/esm/resources/refunds.d.ts +1 -44
- package/lib/esm/resources/refunds.js +1 -34
- package/lib/esm/resources/reserved_stocks.d.ts +1 -28
- package/lib/esm/resources/reserved_stocks.js +1 -26
- package/lib/esm/resources/resource_errors.d.ts +1 -22
- package/lib/esm/resources/resource_errors.js +1 -14
- package/lib/esm/resources/return_line_items.d.ts +1 -52
- package/lib/esm/resources/return_line_items.js +1 -34
- package/lib/esm/resources/returns.d.ts +1 -96
- package/lib/esm/resources/returns.js +1 -90
- package/lib/esm/resources/satispay_gateways.d.ts +1 -46
- package/lib/esm/resources/satispay_gateways.js +1 -35
- package/lib/esm/resources/satispay_payments.d.ts +1 -50
- package/lib/esm/resources/satispay_payments.js +1 -38
- package/lib/esm/resources/shipments.d.ts +1 -151
- package/lib/esm/resources/shipments.js +1 -128
- package/lib/esm/resources/shipping_categories.d.ts +1 -40
- package/lib/esm/resources/shipping_categories.js +1 -35
- package/lib/esm/resources/shipping_method_tiers.d.ts +1 -32
- package/lib/esm/resources/shipping_method_tiers.js +1 -26
- package/lib/esm/resources/shipping_methods.d.ts +1 -125
- package/lib/esm/resources/shipping_methods.js +1 -68
- package/lib/esm/resources/shipping_weight_tiers.d.ts +1 -50
- package/lib/esm/resources/shipping_weight_tiers.js +1 -35
- package/lib/esm/resources/shipping_zones.d.ts +1 -52
- package/lib/esm/resources/shipping_zones.js +1 -31
- package/lib/esm/resources/sku_list_items.d.ts +1 -51
- package/lib/esm/resources/sku_list_items.js +1 -35
- package/lib/esm/resources/sku_list_promotion_rules.d.ts +1 -76
- package/lib/esm/resources/sku_list_promotion_rules.js +1 -35
- package/lib/esm/resources/sku_lists.d.ts +1 -64
- package/lib/esm/resources/sku_lists.js +1 -47
- package/lib/esm/resources/sku_options.d.ts +1 -71
- package/lib/esm/resources/sku_options.js +1 -43
- package/lib/esm/resources/skus.d.ts +1 -96
- package/lib/esm/resources/skus.js +1 -63
- package/lib/esm/resources/stock_items.d.ts +1 -61
- package/lib/esm/resources/stock_items.js +1 -50
- package/lib/esm/resources/stock_line_items.d.ts +1 -73
- package/lib/esm/resources/stock_line_items.js +1 -52
- package/lib/esm/resources/stock_locations.d.ts +1 -64
- package/lib/esm/resources/stock_locations.js +1 -51
- package/lib/esm/resources/stock_reservations.d.ts +1 -51
- package/lib/esm/resources/stock_reservations.js +1 -46
- package/lib/esm/resources/stock_transfers.d.ts +1 -86
- package/lib/esm/resources/stock_transfers.js +1 -69
- package/lib/esm/resources/stripe_gateways.d.ts +1 -45
- package/lib/esm/resources/stripe_gateways.js +1 -35
- package/lib/esm/resources/stripe_payments.d.ts +1 -59
- package/lib/esm/resources/stripe_payments.js +1 -41
- package/lib/esm/resources/subscription_models.d.ts +1 -49
- package/lib/esm/resources/subscription_models.js +1 -35
- package/lib/esm/resources/tags.d.ts +1 -28
- package/lib/esm/resources/tags.js +1 -23
- package/lib/esm/resources/tax_calculators.d.ts +1 -28
- package/lib/esm/resources/tax_calculators.js +1 -26
- package/lib/esm/resources/tax_categories.d.ts +1 -63
- package/lib/esm/resources/tax_categories.js +1 -35
- package/lib/esm/resources/tax_rules.d.ts +1 -73
- package/lib/esm/resources/tax_rules.js +1 -31
- package/lib/esm/resources/taxjar_accounts.d.ts +1 -47
- package/lib/esm/resources/taxjar_accounts.js +1 -39
- package/lib/esm/resources/transactions.d.ts +1 -41
- package/lib/esm/resources/transactions.js +1 -30
- package/lib/esm/resources/versions.d.ts +1 -22
- package/lib/esm/resources/versions.js +1 -14
- package/lib/esm/resources/voids.d.ts +1 -44
- package/lib/esm/resources/voids.js +1 -34
- package/lib/esm/resources/webhooks.d.ts +1 -55
- package/lib/esm/resources/webhooks.js +1 -40
- package/lib/esm/resources/wire_transfers.d.ts +1 -37
- package/lib/esm/resources/wire_transfers.js +1 -31
- package/lib/esm/static.d.ts +1 -12
- package/lib/esm/static.js +1 -25
- package/lib/esm/util.d.ts +1 -4
- package/lib/esm/util.js +1 -37
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/lib/cjs/query.js
CHANGED
@@ -1,69 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.isParamsList = exports.generateQueryStringParams = void 0;
|
7
|
-
const debug_1 = __importDefault(require("./debug"));
|
8
|
-
const error_1 = require("./error");
|
9
|
-
const debug = (0, debug_1.default)('query');
|
10
|
-
const arrayFilters = ['_any', '_all', '_in'];
|
11
|
-
const objectFilters = ['_jcont'];
|
12
|
-
const isParamsList = (params) => {
|
13
|
-
return params && (params.filters || params.pageNumber || params.pageSize || params.sort);
|
14
|
-
};
|
15
|
-
exports.isParamsList = isParamsList;
|
16
|
-
const generateQueryStringParams = (params, res) => {
|
17
|
-
debug('generate query string params: %O, %O', params, res);
|
18
|
-
const qp = {};
|
19
|
-
if (!params)
|
20
|
-
return qp;
|
21
|
-
// Include
|
22
|
-
if (params.include)
|
23
|
-
qp.include = params.include.join(',');
|
24
|
-
// Fields
|
25
|
-
if (params.fields) {
|
26
|
-
if (Array.isArray(params.fields))
|
27
|
-
params.fields = { [res.type || res]: params.fields };
|
28
|
-
Object.entries(params.fields).forEach(([p, v]) => {
|
29
|
-
qp[`fields[${p}]`] = v.join(',');
|
30
|
-
});
|
31
|
-
}
|
32
|
-
if (isParamsList(params)) {
|
33
|
-
// Sort
|
34
|
-
if (params.sort) {
|
35
|
-
if (Array.isArray(params.sort))
|
36
|
-
qp.sort = params.sort.join(',');
|
37
|
-
else
|
38
|
-
qp.sort = Object.entries(params.sort).map(([k, v]) => `${v === 'desc' ? '-' : ''}${k}`).join(',');
|
39
|
-
}
|
40
|
-
// Page
|
41
|
-
if (params.pageNumber)
|
42
|
-
qp['page[number]'] = String(params.pageNumber);
|
43
|
-
if (params.pageSize)
|
44
|
-
qp['page[size]'] = String(params.pageSize);
|
45
|
-
// Filters
|
46
|
-
if (params.filters) {
|
47
|
-
Object.entries(params.filters).forEach(([p, v]) => {
|
48
|
-
const filter = p.substring(p.lastIndexOf('_'));
|
49
|
-
let val;
|
50
|
-
if (Array.isArray(v)) {
|
51
|
-
if (!arrayFilters.includes(filter))
|
52
|
-
throw new error_1.SdkError({ message: `Wrong ${filter} filter: Array value is supported only for the following filters: ${arrayFilters.join(', ')}`, type: error_1.ErrorType.REQUEST });
|
53
|
-
val = v.join(',');
|
54
|
-
}
|
55
|
-
else if (typeof v === 'object') {
|
56
|
-
if (!objectFilters.includes(filter))
|
57
|
-
throw new error_1.SdkError({ message: `Wrong ${filter} filter: Object value is supported only for the following filters: ${objectFilters.join(', ')}`, type: error_1.ErrorType.REQUEST });
|
58
|
-
val = JSON.stringify(v);
|
59
|
-
}
|
60
|
-
else
|
61
|
-
val = String(v);
|
62
|
-
qp[`filter[q][${p}]`] = val;
|
63
|
-
});
|
64
|
-
}
|
65
|
-
}
|
66
|
-
debug('query string params: %O', qp);
|
67
|
-
return qp;
|
68
|
-
};
|
69
|
-
exports.generateQueryStringParams = generateQueryStringParams;
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.isParamsList=exports.generateQueryStringParams=void 0;const debug_1=__importDefault(require("./debug")),error_1=require("./error"),debug=(0,debug_1.default)("query"),arrayFilters=["_any","_all","_in"],objectFilters=["_jcont"],isParamsList=e=>e&&(e.filters||e.pageNumber||e.pageSize||e.sort);exports.isParamsList=isParamsList;const generateQueryStringParams=(e,s)=>{debug("generate query string params: %O, %O",e,s);const r={};return e&&(e.include&&(r.include=e.include.join(",")),e.fields&&(Array.isArray(e.fields)&&(e.fields={[s.type||s]:e.fields}),Object.entries(e.fields).forEach(([i,t])=>{r[`fields[${i}]`]=t.join(",")})),isParamsList(e)&&(e.sort&&(Array.isArray(e.sort)?r.sort=e.sort.join(","):r.sort=Object.entries(e.sort).map(([i,t])=>`${t==="desc"?"-":""}${i}`).join(",")),e.pageNumber&&(r["page[number]"]=String(e.pageNumber)),e.pageSize&&(r["page[size]"]=String(e.pageSize)),e.filters&&Object.entries(e.filters).forEach(([i,t])=>{const n=i.substring(i.lastIndexOf("_"));let o;if(Array.isArray(t)){if(!arrayFilters.includes(n))throw new error_1.SdkError({message:`Wrong ${n} filter: Array value is supported only for the following filters: ${arrayFilters.join(", ")}`,type:error_1.ErrorType.REQUEST});o=t.join(",")}else if(typeof t=="object"){if(!objectFilters.includes(n))throw new error_1.SdkError({message:`Wrong ${n} filter: Object value is supported only for the following filters: ${objectFilters.join(", ")}`,type:error_1.ErrorType.REQUEST});o=JSON.stringify(t)}else o=String(t);r[`filter[q][${i}]`]=o})),debug("query string params: %O",r)),r};exports.generateQueryStringParams=generateQueryStringParams;
|
package/lib/cjs/resource.d.ts
CHANGED
@@ -1,89 +1 @@
|
|
1
|
-
import ApiClient,
|
2
|
-
import type { QueryParamsRetrieve, QueryParamsList, QueryFilter, QueryParams } from './query';
|
3
|
-
import type { ResourceTypeLock } from './api';
|
4
|
-
import type { InterceptorManager } from './interceptor';
|
5
|
-
type ResourceNull = {
|
6
|
-
id: null;
|
7
|
-
} & ResourceType;
|
8
|
-
type ResourceRel = ResourceId | ResourceNull;
|
9
|
-
type Metadata = Record<string, any>;
|
10
|
-
interface ResourceType {
|
11
|
-
readonly type: ResourceTypeLock;
|
12
|
-
}
|
13
|
-
interface ResourceId extends ResourceType {
|
14
|
-
readonly id: string;
|
15
|
-
}
|
16
|
-
interface ResourceBase {
|
17
|
-
reference?: string | null;
|
18
|
-
reference_origin?: string | null;
|
19
|
-
metadata?: Metadata;
|
20
|
-
}
|
21
|
-
interface Resource extends ResourceBase, ResourceId {
|
22
|
-
readonly created_at: string;
|
23
|
-
readonly updated_at: string;
|
24
|
-
}
|
25
|
-
interface ResourceCreate extends ResourceBase {
|
26
|
-
}
|
27
|
-
interface ResourceUpdate extends ResourceBase {
|
28
|
-
readonly id: string;
|
29
|
-
}
|
30
|
-
type ListMeta = {
|
31
|
-
readonly pageCount: number;
|
32
|
-
readonly recordCount: number;
|
33
|
-
readonly currentPage: number;
|
34
|
-
readonly recordsPerPage: number;
|
35
|
-
};
|
36
|
-
declare class ListResponse<R> extends Array<R> {
|
37
|
-
readonly meta: ListMeta;
|
38
|
-
constructor(meta: ListMeta, data: R[]);
|
39
|
-
first(): R | undefined;
|
40
|
-
last(): R | undefined;
|
41
|
-
get(index: number): R | undefined;
|
42
|
-
hasNextPage(): boolean;
|
43
|
-
hasPrevPage(): boolean;
|
44
|
-
getRecordCount(): number;
|
45
|
-
getPageCount(): number;
|
46
|
-
get recordCount(): number;
|
47
|
-
get pageCount(): number;
|
48
|
-
}
|
49
|
-
export type { Metadata, ResourceType, ResourceId, Resource, ResourceCreate, ResourceUpdate, ListResponse, ListMeta, ResourceRel };
|
50
|
-
type ResourceAdapterConfig = {};
|
51
|
-
type ResourcesInitConfig = ResourceAdapterConfig & ApiClientInitConfig;
|
52
|
-
type ResourcesConfig = Partial<ResourcesInitConfig>;
|
53
|
-
declare class ResourceAdapter {
|
54
|
-
#private;
|
55
|
-
constructor(config: ResourcesInitConfig);
|
56
|
-
get interceptors(): InterceptorManager;
|
57
|
-
private localConfig;
|
58
|
-
config(config: ResourcesConfig): ResourceAdapter;
|
59
|
-
get client(): Readonly<ApiClient>;
|
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 ApiResourceBase<R extends Resource> {
|
69
|
-
static readonly TYPE: ResourceTypeLock;
|
70
|
-
protected readonly resources: ResourceAdapter;
|
71
|
-
constructor(adapter: ResourceAdapter);
|
72
|
-
abstract relationship(id: string | ResourceId | null): ResourceRel;
|
73
|
-
abstract type(): ResourceTypeLock;
|
74
|
-
parse(resource: string, options?: {
|
75
|
-
ignoreSlug?: boolean;
|
76
|
-
}): R | R[];
|
77
|
-
update(resource: ResourceUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
78
|
-
}
|
79
|
-
declare abstract class ApiResource<R extends Resource> extends ApiResourceBase<R> {
|
80
|
-
retrieve(id: string | ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
81
|
-
list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<R>>;
|
82
|
-
count(filter?: QueryFilter | QueryParamsList, options?: ResourcesConfig): Promise<number>;
|
83
|
-
}
|
84
|
-
declare abstract class ApiSingleton<R extends Resource> extends ApiResourceBase<R> {
|
85
|
-
retrieve(params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
86
|
-
}
|
87
|
-
export default ResourceAdapter;
|
88
|
-
export { ApiResource, ApiSingleton };
|
89
|
-
export type { ResourcesConfig, ResourcesInitConfig };
|
1
|
+
import ApiClient,{type ApiClientInitConfig}from'./client';import type{QueryParamsRetrieve,QueryParamsList,QueryFilter,QueryParams}from'./query';import type{ResourceTypeLock}from'./api';import type{InterceptorManager}from'./interceptor';type ResourceNull={id:null;}&ResourceType;type ResourceRel=ResourceId|ResourceNull;type Metadata=Record<string,any>;interface ResourceType{readonly type:ResourceTypeLock;}interface ResourceId extends ResourceType{readonly id:string;}interface ResourceBase{reference?:string|null;reference_origin?:string|null;metadata?:Metadata;}interface Resource extends ResourceBase,ResourceId{readonly created_at:string;readonly updated_at:string;}interface ResourceCreate extends ResourceBase{}interface ResourceUpdate extends ResourceBase{readonly id:string;}type ListMeta={readonly pageCount:number;readonly recordCount:number;readonly currentPage:number;readonly recordsPerPage:number;};declare class ListResponse<R>extends Array<R>{readonly meta:ListMeta;constructor(meta:ListMeta,data:R[]);first():R|undefined;last():R|undefined;get(index:number):R|undefined;hasNextPage():boolean;hasPrevPage():boolean;getRecordCount():number;getPageCount():number;get recordCount():number;get pageCount():number;}export type{Metadata,ResourceType,ResourceId,Resource,ResourceCreate,ResourceUpdate,ListResponse,ListMeta,ResourceRel};type ResourceAdapterConfig={};type ResourcesInitConfig=ResourceAdapterConfig&ApiClientInitConfig;type ResourcesConfig=Partial<ResourcesInitConfig>;declare class ResourceAdapter{#private;constructor(config:ResourcesInitConfig);get interceptors():InterceptorManager;private localConfig;config(config:ResourcesConfig):ResourceAdapter;get client():Readonly<ApiClient>;singleton<R extends Resource>(resource:ResourceType,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;retrieve<R extends Resource>(resource:ResourceId,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;list<R extends Resource>(resource:ResourceType,params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<R>>;create<C extends ResourceCreate,R extends Resource>(resource:C&ResourceType,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;update<U extends ResourceUpdate,R extends Resource>(resource:U&ResourceId,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;delete(resource:ResourceId,options?:ResourcesConfig):Promise<void>;fetch<R extends Resource>(resource:string|ResourceType,path:string,params?:QueryParams,options?:ResourcesConfig):Promise<R|ListResponse<R>>;}declare abstract class ApiResourceBase<R extends Resource>{static readonly TYPE:ResourceTypeLock;protected readonly resources:ResourceAdapter;constructor(adapter:ResourceAdapter);abstract relationship(id:string|ResourceId|null):ResourceRel;abstract type():ResourceTypeLock;parse(resource:string,options?:{ignoreSlug?:boolean;}):R|R[];update(resource:ResourceUpdate,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;}declare abstract class ApiResource<R extends Resource>extends ApiResourceBase<R>{retrieve(id:string|ResourceId,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;list(params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<R>>;count(filter?:QueryFilter|QueryParamsList,options?:ResourcesConfig):Promise<number>;}declare abstract class ApiSingleton<R extends Resource>extends ApiResourceBase<R>{retrieve(params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;}export default ResourceAdapter;export{ApiResource,ApiSingleton};export type{ResourcesConfig,ResourcesInitConfig};
|
package/lib/cjs/resource.js
CHANGED
@@ -1,198 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
7
|
-
};
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
12
|
-
};
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
|
-
};
|
16
|
-
var _ResourceAdapter_client, _ResourceAdapter_config;
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
-
exports.ApiSingleton = exports.ApiResource = void 0;
|
19
|
-
const client_1 = __importDefault(require("./client"));
|
20
|
-
const jsonapi_1 = require("./jsonapi");
|
21
|
-
const query_1 = require("./query");
|
22
|
-
const config_1 = __importDefault(require("./config"));
|
23
|
-
const error_1 = require("./error");
|
24
|
-
const debug_1 = __importDefault(require("./debug"));
|
25
|
-
const debug = (0, debug_1.default)('resource');
|
26
|
-
class ListResponse extends Array {
|
27
|
-
constructor(meta, data) {
|
28
|
-
super(...(data || []));
|
29
|
-
this.meta = meta;
|
30
|
-
}
|
31
|
-
first() { return this.length ? this[0] : undefined; }
|
32
|
-
last() { return this.length ? this[this.length - 1] : undefined; }
|
33
|
-
get(index) { return (this.length && (index >= 0)) ? this[index] : undefined; }
|
34
|
-
hasNextPage() { return (this.meta.currentPage < this.meta.pageCount); }
|
35
|
-
hasPrevPage() { return (this.meta.currentPage > 1); }
|
36
|
-
getRecordCount() { return this.meta.recordCount; }
|
37
|
-
getPageCount() { return this.meta.pageCount; }
|
38
|
-
get recordCount() { return this.meta.recordCount; }
|
39
|
-
get pageCount() { return this.meta.pageCount; }
|
40
|
-
}
|
41
|
-
class ResourceAdapter {
|
42
|
-
constructor(config) {
|
43
|
-
_ResourceAdapter_client.set(this, void 0);
|
44
|
-
_ResourceAdapter_config.set(this, {});
|
45
|
-
__classPrivateFieldSet(this, _ResourceAdapter_client, client_1.default.create(config), "f");
|
46
|
-
this.localConfig(config);
|
47
|
-
}
|
48
|
-
get interceptors() { return __classPrivateFieldGet(this, _ResourceAdapter_client, "f").interceptors; }
|
49
|
-
localConfig(config) {
|
50
|
-
// if (typeof config.xyz !== 'undefined') this.#config.xyz = config.xyz
|
51
|
-
}
|
52
|
-
config(config) {
|
53
|
-
debug('config %o', config);
|
54
|
-
// ResourceAdapter config
|
55
|
-
this.localConfig(config);
|
56
|
-
// Client config
|
57
|
-
__classPrivateFieldGet(this, _ResourceAdapter_client, "f").config(config);
|
58
|
-
return this;
|
59
|
-
}
|
60
|
-
get client() {
|
61
|
-
return __classPrivateFieldGet(this, _ResourceAdapter_client, "f");
|
62
|
-
}
|
63
|
-
async singleton(resource, params, options) {
|
64
|
-
debug('singleton: %o, %O, %O', resource, params || {}, options || {});
|
65
|
-
const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
|
66
|
-
if (options === null || options === void 0 ? void 0 : options.params)
|
67
|
-
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
68
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}`, undefined, { ...options, params: queryParams });
|
69
|
-
const r = (0, jsonapi_1.denormalize)(res);
|
70
|
-
return r;
|
71
|
-
}
|
72
|
-
async retrieve(resource, params, options) {
|
73
|
-
debug('retrieve: %o, %O, %O', resource, params || {}, options || {});
|
74
|
-
const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
|
75
|
-
if (options === null || options === void 0 ? void 0 : options.params)
|
76
|
-
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
77
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}/${resource.id}`, undefined, { ...options, params: queryParams });
|
78
|
-
const r = (0, jsonapi_1.denormalize)(res);
|
79
|
-
return r;
|
80
|
-
}
|
81
|
-
async list(resource, params, options) {
|
82
|
-
var _a, _b;
|
83
|
-
debug('list: %o, %O, %O', resource, params || {}, options || {});
|
84
|
-
const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
|
85
|
-
if (options === null || options === void 0 ? void 0 : options.params)
|
86
|
-
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
87
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}`, undefined, { ...options, params: queryParams });
|
88
|
-
const r = (0, jsonapi_1.denormalize)(res);
|
89
|
-
const meta = {
|
90
|
-
pageCount: Number((_a = res.meta) === null || _a === void 0 ? void 0 : _a.page_count),
|
91
|
-
recordCount: Number((_b = res.meta) === null || _b === void 0 ? void 0 : _b.record_count),
|
92
|
-
currentPage: (params === null || params === void 0 ? void 0 : params.pageNumber) || config_1.default.default.pageNumber,
|
93
|
-
recordsPerPage: (params === null || params === void 0 ? void 0 : params.pageSize) || config_1.default.default.pageSize
|
94
|
-
};
|
95
|
-
return new ListResponse(meta, r);
|
96
|
-
}
|
97
|
-
async create(resource, params, options) {
|
98
|
-
debug('create: %o, %O, %O', resource, params || {}, options || {});
|
99
|
-
const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
|
100
|
-
if (options === null || options === void 0 ? void 0 : options.params)
|
101
|
-
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
102
|
-
const data = (0, jsonapi_1.normalize)(resource);
|
103
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('post', resource.type, data, { ...options, params: queryParams });
|
104
|
-
const r = (0, jsonapi_1.denormalize)(res);
|
105
|
-
return r;
|
106
|
-
}
|
107
|
-
async update(resource, params, options) {
|
108
|
-
debug('update: %o, %O, %O', resource, params || {}, options || {});
|
109
|
-
const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
|
110
|
-
if (options === null || options === void 0 ? void 0 : options.params)
|
111
|
-
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
112
|
-
const data = (0, jsonapi_1.normalize)(resource);
|
113
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('patch', `${resource.type}/${resource.id}`, data, { ...options, params: queryParams });
|
114
|
-
const r = (0, jsonapi_1.denormalize)(res);
|
115
|
-
return r;
|
116
|
-
}
|
117
|
-
async delete(resource, options) {
|
118
|
-
debug('delete: %o, %O', resource, options || {});
|
119
|
-
await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('delete', `${resource.type}/${resource.id}`, undefined, options);
|
120
|
-
}
|
121
|
-
async fetch(resource, path, params, options) {
|
122
|
-
var _a, _b;
|
123
|
-
debug('fetch: %o, %O, %O', path, params || {}, options || {});
|
124
|
-
const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
|
125
|
-
if (options === null || options === void 0 ? void 0 : options.params)
|
126
|
-
Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
|
127
|
-
const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', path, undefined, { ...options, params: queryParams });
|
128
|
-
const r = (0, jsonapi_1.denormalize)(res);
|
129
|
-
if (Array.isArray(r)) {
|
130
|
-
const p = params;
|
131
|
-
const meta = {
|
132
|
-
pageCount: Number((_a = res.meta) === null || _a === void 0 ? void 0 : _a.page_count),
|
133
|
-
recordCount: Number((_b = res.meta) === null || _b === void 0 ? void 0 : _b.record_count),
|
134
|
-
currentPage: (p === null || p === void 0 ? void 0 : p.pageNumber) || config_1.default.default.pageNumber,
|
135
|
-
recordsPerPage: (p === null || p === void 0 ? void 0 : p.pageSize) || config_1.default.default.pageSize
|
136
|
-
};
|
137
|
-
return new ListResponse(meta, r);
|
138
|
-
}
|
139
|
-
else
|
140
|
-
return r;
|
141
|
-
}
|
142
|
-
}
|
143
|
-
_ResourceAdapter_client = new WeakMap(), _ResourceAdapter_config = new WeakMap();
|
144
|
-
class ApiResourceBase {
|
145
|
-
constructor(adapter) {
|
146
|
-
debug('new resource instance: %s', this.type());
|
147
|
-
this.resources = adapter;
|
148
|
-
}
|
149
|
-
parse(resource, options) {
|
150
|
-
var _a;
|
151
|
-
try {
|
152
|
-
const res = JSON.parse(resource);
|
153
|
-
// Resource type always checked
|
154
|
-
const rtype = (_a = res.data) === null || _a === void 0 ? void 0 : _a.type;
|
155
|
-
if (rtype !== this.type())
|
156
|
-
throw new error_1.SdkError({ message: `Invalid resource type [${rtype}]`, type: error_1.ErrorType.PARSE });
|
157
|
-
// Parse options
|
158
|
-
const { ignoreSlug } = options || {};
|
159
|
-
if (!ignoreSlug) {
|
160
|
-
const links = res.data.links.self;
|
161
|
-
if (!links || !String(links).match(`^${this.resources.client.baseUrl}/${this.type()}/*`))
|
162
|
-
throw new error_1.SdkError({ message: `Resource contains invalid links [${links}]`, type: error_1.ErrorType.PARSE });
|
163
|
-
}
|
164
|
-
return (0, jsonapi_1.denormalize)(res);
|
165
|
-
}
|
166
|
-
catch (error) {
|
167
|
-
if (error_1.SdkError.isSdkError(error))
|
168
|
-
throw error;
|
169
|
-
else
|
170
|
-
throw new error_1.SdkError({ message: `Payload parse error [${error.message}]`, type: error_1.ErrorType.PARSE });
|
171
|
-
}
|
172
|
-
}
|
173
|
-
// reference, reference_origin and metadata attributes are always updatable
|
174
|
-
async update(resource, params, options) {
|
175
|
-
return this.resources.update({ ...resource, type: this.type() }, params, options);
|
176
|
-
}
|
177
|
-
}
|
178
|
-
class ApiResource extends ApiResourceBase {
|
179
|
-
async retrieve(id, params, options) {
|
180
|
-
return this.resources.retrieve((typeof id === 'string') ? { type: this.type(), id } : id, params, options);
|
181
|
-
}
|
182
|
-
async list(params, options) {
|
183
|
-
return this.resources.list({ type: this.type() }, params, options);
|
184
|
-
}
|
185
|
-
async count(filter, options) {
|
186
|
-
const params = { filters: (0, query_1.isParamsList)(filter) ? filter.filters : filter, pageNumber: 1, pageSize: 1 };
|
187
|
-
const response = await this.list(params, options);
|
188
|
-
return Promise.resolve(response.meta.recordCount);
|
189
|
-
}
|
190
|
-
}
|
191
|
-
exports.ApiResource = ApiResource;
|
192
|
-
class ApiSingleton extends ApiResourceBase {
|
193
|
-
async retrieve(params, options) {
|
194
|
-
return this.resources.singleton({ type: this.type() }, params, options);
|
195
|
-
}
|
196
|
-
}
|
197
|
-
exports.ApiSingleton = ApiSingleton;
|
198
|
-
exports.default = ResourceAdapter;
|
1
|
+
"use strict";var __classPrivateFieldSet=this&&this.__classPrivateFieldSet||function(s,e,r,t,a){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!a:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?a.call(s,r):a?a.value=r:e.set(s,r),r},__classPrivateFieldGet=this&&this.__classPrivateFieldGet||function(s,e,r,t){if(r==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!t:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?t:r==="a"?t.call(s):t?t.value:e.get(s)},__importDefault=this&&this.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},_ResourceAdapter_client,_ResourceAdapter_config;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApiSingleton=exports.ApiResource=void 0;const client_1=__importDefault(require("./client")),jsonapi_1=require("./jsonapi"),query_1=require("./query"),config_1=__importDefault(require("./config")),error_1=require("./error"),debug_1=__importDefault(require("./debug")),debug=(0,debug_1.default)("resource");class ListResponse extends Array{constructor(e,r){super(...r||[]),this.meta=e}first(){return this.length?this[0]:void 0}last(){return this.length?this[this.length-1]:void 0}get(e){return this.length&&e>=0?this[e]:void 0}hasNextPage(){return this.meta.currentPage<this.meta.pageCount}hasPrevPage(){return this.meta.currentPage>1}getRecordCount(){return this.meta.recordCount}getPageCount(){return this.meta.pageCount}get recordCount(){return this.meta.recordCount}get pageCount(){return this.meta.pageCount}}class ResourceAdapter{constructor(e){_ResourceAdapter_client.set(this,void 0),_ResourceAdapter_config.set(this,{}),__classPrivateFieldSet(this,_ResourceAdapter_client,client_1.default.create(e),"f"),this.localConfig(e)}get interceptors(){return __classPrivateFieldGet(this,_ResourceAdapter_client,"f").interceptors}localConfig(e){}config(e){return debug("config %o",e),this.localConfig(e),__classPrivateFieldGet(this,_ResourceAdapter_client,"f").config(e),this}get client(){return __classPrivateFieldGet(this,_ResourceAdapter_client,"f")}async singleton(e,r,t){debug("singleton: %o, %O, %O",e,r||{},t||{});const a=(0,query_1.generateQueryStringParams)(r,e);t?.params&&Object.assign(a,t?.params);const n=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("get",`${e.type}`,void 0,{...t,params:a});return(0,jsonapi_1.denormalize)(n)}async retrieve(e,r,t){debug("retrieve: %o, %O, %O",e,r||{},t||{});const a=(0,query_1.generateQueryStringParams)(r,e);t?.params&&Object.assign(a,t?.params);const n=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("get",`${e.type}/${e.id}`,void 0,{...t,params:a});return(0,jsonapi_1.denormalize)(n)}async list(e,r,t){var a,n;debug("list: %o, %O, %O",e,r||{},t||{});const i=(0,query_1.generateQueryStringParams)(r,e);t?.params&&Object.assign(i,t?.params);const u=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("get",`${e.type}`,void 0,{...t,params:i}),l=(0,jsonapi_1.denormalize)(u),d={pageCount:Number((a=u.meta)===null||a===void 0?void 0:a.page_count),recordCount:Number((n=u.meta)===null||n===void 0?void 0:n.record_count),currentPage:r?.pageNumber||config_1.default.default.pageNumber,recordsPerPage:r?.pageSize||config_1.default.default.pageSize};return new ListResponse(d,l)}async create(e,r,t){debug("create: %o, %O, %O",e,r||{},t||{});const a=(0,query_1.generateQueryStringParams)(r,e);t?.params&&Object.assign(a,t?.params);const n=(0,jsonapi_1.normalize)(e),i=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("post",e.type,n,{...t,params:a});return(0,jsonapi_1.denormalize)(i)}async update(e,r,t){debug("update: %o, %O, %O",e,r||{},t||{});const a=(0,query_1.generateQueryStringParams)(r,e);t?.params&&Object.assign(a,t?.params);const n=(0,jsonapi_1.normalize)(e),i=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("patch",`${e.type}/${e.id}`,n,{...t,params:a});return(0,jsonapi_1.denormalize)(i)}async delete(e,r){debug("delete: %o, %O",e,r||{}),await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("delete",`${e.type}/${e.id}`,void 0,r)}async fetch(e,r,t,a){var n,i;debug("fetch: %o, %O, %O",r,t||{},a||{});const u=(0,query_1.generateQueryStringParams)(t,e);a?.params&&Object.assign(u,a?.params);const l=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("get",r,void 0,{...a,params:u}),d=(0,jsonapi_1.denormalize)(l);if(Array.isArray(d)){const o=t,c={pageCount:Number((n=l.meta)===null||n===void 0?void 0:n.page_count),recordCount:Number((i=l.meta)===null||i===void 0?void 0:i.record_count),currentPage:o?.pageNumber||config_1.default.default.pageNumber,recordsPerPage:o?.pageSize||config_1.default.default.pageSize};return new ListResponse(c,d)}else return d}}_ResourceAdapter_client=new WeakMap,_ResourceAdapter_config=new WeakMap;class ApiResourceBase{constructor(e){debug("new resource instance: %s",this.type()),this.resources=e}parse(e,r){var t;try{const a=JSON.parse(e),n=(t=a.data)===null||t===void 0?void 0:t.type;if(n!==this.type())throw new error_1.SdkError({message:`Invalid resource type [${n}]`,type:error_1.ErrorType.PARSE});const{ignoreSlug:i}=r||{};if(!i){const u=a.data.links.self;if(!u||!String(u).match(`^${this.resources.client.baseUrl}/${this.type()}/*`))throw new error_1.SdkError({message:`Resource contains invalid links [${u}]`,type:error_1.ErrorType.PARSE})}return(0,jsonapi_1.denormalize)(a)}catch(a){throw error_1.SdkError.isSdkError(a)?a:new error_1.SdkError({message:`Payload parse error [${a.message}]`,type:error_1.ErrorType.PARSE})}}async update(e,r,t){return this.resources.update({...e,type:this.type()},r,t)}}class ApiResource extends ApiResourceBase{async retrieve(e,r,t){return this.resources.retrieve(typeof e=="string"?{type:this.type(),id:e}:e,r,t)}async list(e,r){return this.resources.list({type:this.type()},e,r)}async count(e,r){const t={filters:(0,query_1.isParamsList)(e)?e.filters:e,pageNumber:1,pageSize:1},a=await this.list(t,r);return Promise.resolve(a.meta.recordCount)}}exports.ApiResource=ApiResource;class ApiSingleton extends ApiResourceBase{async retrieve(e,r){return this.resources.singleton({type:this.type()},e,r)}}exports.ApiSingleton=ApiSingleton,exports.default=ResourceAdapter;
|
@@ -1,103 +1 @@
|
|
1
|
-
import {
|
2
|
-
import type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
|
3
|
-
import type { QueryParamsRetrieve, QueryParamsList } from '../query';
|
4
|
-
import type { Geocoder, GeocoderType } from './geocoders';
|
5
|
-
import type { Event } from './events';
|
6
|
-
import type { Tag, TagType } from './tags';
|
7
|
-
import type { Version } from './versions';
|
8
|
-
type AddressType = 'addresses';
|
9
|
-
type AddressRel = ResourceRel & {
|
10
|
-
type: AddressType;
|
11
|
-
};
|
12
|
-
type GeocoderRel = ResourceRel & {
|
13
|
-
type: GeocoderType;
|
14
|
-
};
|
15
|
-
type TagRel = ResourceRel & {
|
16
|
-
type: TagType;
|
17
|
-
};
|
18
|
-
interface Address extends Resource {
|
19
|
-
readonly type: AddressType;
|
20
|
-
business?: boolean | null;
|
21
|
-
first_name?: string | null;
|
22
|
-
last_name?: string | null;
|
23
|
-
company?: string | null;
|
24
|
-
full_name?: string | null;
|
25
|
-
line_1: string;
|
26
|
-
line_2?: string | null;
|
27
|
-
city: string;
|
28
|
-
zip_code?: string | null;
|
29
|
-
state_code: string;
|
30
|
-
country_code: string;
|
31
|
-
phone: string;
|
32
|
-
full_address?: string | null;
|
33
|
-
name?: string | null;
|
34
|
-
email?: string | null;
|
35
|
-
notes?: string | null;
|
36
|
-
lat?: number | null;
|
37
|
-
lng?: number | null;
|
38
|
-
is_localized?: boolean | null;
|
39
|
-
is_geocoded?: boolean | null;
|
40
|
-
provider_name?: string | null;
|
41
|
-
map_url?: string | null;
|
42
|
-
static_map_url?: string | null;
|
43
|
-
billing_info?: string | null;
|
44
|
-
geocoder?: Geocoder | null;
|
45
|
-
events?: Event[] | null;
|
46
|
-
tags?: Tag[] | null;
|
47
|
-
versions?: Version[] | null;
|
48
|
-
}
|
49
|
-
interface AddressCreate extends ResourceCreate {
|
50
|
-
business?: boolean | null;
|
51
|
-
first_name?: string | null;
|
52
|
-
last_name?: string | null;
|
53
|
-
company?: string | null;
|
54
|
-
line_1: string;
|
55
|
-
line_2?: string | null;
|
56
|
-
city: string;
|
57
|
-
zip_code?: string | null;
|
58
|
-
state_code: string;
|
59
|
-
country_code: string;
|
60
|
-
phone: string;
|
61
|
-
email?: string | null;
|
62
|
-
notes?: string | null;
|
63
|
-
lat?: number | null;
|
64
|
-
lng?: number | null;
|
65
|
-
billing_info?: string | null;
|
66
|
-
geocoder?: GeocoderRel | null;
|
67
|
-
tags?: TagRel[] | null;
|
68
|
-
}
|
69
|
-
interface AddressUpdate extends ResourceUpdate {
|
70
|
-
business?: boolean | null;
|
71
|
-
first_name?: string | null;
|
72
|
-
last_name?: string | null;
|
73
|
-
company?: string | null;
|
74
|
-
line_1?: string | null;
|
75
|
-
line_2?: string | null;
|
76
|
-
city?: string | null;
|
77
|
-
zip_code?: string | null;
|
78
|
-
state_code?: string | null;
|
79
|
-
country_code?: string | null;
|
80
|
-
phone?: string | null;
|
81
|
-
email?: string | null;
|
82
|
-
notes?: string | null;
|
83
|
-
lat?: number | null;
|
84
|
-
lng?: number | null;
|
85
|
-
billing_info?: string | null;
|
86
|
-
geocoder?: GeocoderRel | null;
|
87
|
-
tags?: TagRel[] | null;
|
88
|
-
}
|
89
|
-
declare class Addresses extends ApiResource<Address> {
|
90
|
-
static readonly TYPE: AddressType;
|
91
|
-
create(resource: AddressCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Address>;
|
92
|
-
update(resource: AddressUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Address>;
|
93
|
-
delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
|
94
|
-
geocoder(addressId: string | Address, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Geocoder>;
|
95
|
-
events(addressId: string | Address, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
|
96
|
-
tags(addressId: string | Address, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Tag>>;
|
97
|
-
versions(addressId: string | Address, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
98
|
-
isAddress(resource: any): resource is Address;
|
99
|
-
relationship(id: string | ResourceId | null): AddressRel;
|
100
|
-
type(): AddressType;
|
101
|
-
}
|
102
|
-
export default Addresses;
|
103
|
-
export type { Address, AddressCreate, AddressUpdate, AddressType };
|
1
|
+
import{ApiResource}from'../resource';import type{Resource,ResourceCreate,ResourceUpdate,ResourceId,ResourcesConfig,ResourceRel,ListResponse}from'../resource';import type{QueryParamsRetrieve,QueryParamsList}from'../query';import type{Geocoder,GeocoderType}from'./geocoders';import type{Event}from'./events';import type{Tag,TagType}from'./tags';import type{Version}from'./versions';type AddressType='addresses';type AddressRel=ResourceRel&{type:AddressType;};type GeocoderRel=ResourceRel&{type:GeocoderType;};type TagRel=ResourceRel&{type:TagType;};interface Address extends Resource{readonly type:AddressType;business?:boolean|null;first_name?:string|null;last_name?:string|null;company?:string|null;full_name?:string|null;line_1:string;line_2?:string|null;city:string;zip_code?:string|null;state_code:string;country_code:string;phone:string;full_address?:string|null;name?:string|null;email?:string|null;notes?:string|null;lat?:number|null;lng?:number|null;is_localized?:boolean|null;is_geocoded?:boolean|null;provider_name?:string|null;map_url?:string|null;static_map_url?:string|null;billing_info?:string|null;geocoder?:Geocoder|null;events?:Event[]|null;tags?:Tag[]|null;versions?:Version[]|null;}interface AddressCreate extends ResourceCreate{business?:boolean|null;first_name?:string|null;last_name?:string|null;company?:string|null;line_1:string;line_2?:string|null;city:string;zip_code?:string|null;state_code:string;country_code:string;phone:string;email?:string|null;notes?:string|null;lat?:number|null;lng?:number|null;billing_info?:string|null;geocoder?:GeocoderRel|null;tags?:TagRel[]|null;}interface AddressUpdate extends ResourceUpdate{business?:boolean|null;first_name?:string|null;last_name?:string|null;company?:string|null;line_1?:string|null;line_2?:string|null;city?:string|null;zip_code?:string|null;state_code?:string|null;country_code?:string|null;phone?:string|null;email?:string|null;notes?:string|null;lat?:number|null;lng?:number|null;billing_info?:string|null;geocoder?:GeocoderRel|null;tags?:TagRel[]|null;}declare class Addresses extends ApiResource<Address>{static readonly TYPE:AddressType;create(resource:AddressCreate,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<Address>;update(resource:AddressUpdate,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<Address>;delete(id:string|ResourceId,options?:ResourcesConfig):Promise<void>;geocoder(addressId:string|Address,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<Geocoder>;events(addressId:string|Address,params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<Event>>;tags(addressId:string|Address,params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<Tag>>;versions(addressId:string|Address,params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<Version>>;isAddress(resource:any):resource is Address;relationship(id:string|ResourceId|null):AddressRel;type():AddressType;}export default Addresses;export type{Address,AddressCreate,AddressUpdate,AddressType};
|
@@ -1,41 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const resource_1 = require("../resource");
|
4
|
-
class Addresses extends resource_1.ApiResource {
|
5
|
-
async create(resource, params, options) {
|
6
|
-
return this.resources.create({ ...resource, type: Addresses.TYPE }, params, options);
|
7
|
-
}
|
8
|
-
async update(resource, params, options) {
|
9
|
-
return this.resources.update({ ...resource, type: Addresses.TYPE }, params, options);
|
10
|
-
}
|
11
|
-
async delete(id, options) {
|
12
|
-
await this.resources.delete((typeof id === 'string') ? { id, type: Addresses.TYPE } : id, options);
|
13
|
-
}
|
14
|
-
async geocoder(addressId, params, options) {
|
15
|
-
const _addressId = addressId.id || addressId;
|
16
|
-
return this.resources.fetch({ type: 'geocoders' }, `addresses/${_addressId}/geocoder`, params, options);
|
17
|
-
}
|
18
|
-
async events(addressId, params, options) {
|
19
|
-
const _addressId = addressId.id || addressId;
|
20
|
-
return this.resources.fetch({ type: 'events' }, `addresses/${_addressId}/events`, params, options);
|
21
|
-
}
|
22
|
-
async tags(addressId, params, options) {
|
23
|
-
const _addressId = addressId.id || addressId;
|
24
|
-
return this.resources.fetch({ type: 'tags' }, `addresses/${_addressId}/tags`, params, options);
|
25
|
-
}
|
26
|
-
async versions(addressId, params, options) {
|
27
|
-
const _addressId = addressId.id || addressId;
|
28
|
-
return this.resources.fetch({ type: 'versions' }, `addresses/${_addressId}/versions`, params, options);
|
29
|
-
}
|
30
|
-
isAddress(resource) {
|
31
|
-
return resource.type && (resource.type === Addresses.TYPE);
|
32
|
-
}
|
33
|
-
relationship(id) {
|
34
|
-
return ((id === null) || (typeof id === 'string')) ? { id, type: Addresses.TYPE } : { id: id.id, type: Addresses.TYPE };
|
35
|
-
}
|
36
|
-
type() {
|
37
|
-
return Addresses.TYPE;
|
38
|
-
}
|
39
|
-
}
|
40
|
-
Addresses.TYPE = 'addresses';
|
41
|
-
exports.default = Addresses;
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const resource_1=require("../resource");class Addresses extends resource_1.ApiResource{async create(e,t,s){return this.resources.create({...e,type:Addresses.TYPE},t,s)}async update(e,t,s){return this.resources.update({...e,type:Addresses.TYPE},t,s)}async delete(e,t){await this.resources.delete(typeof e=="string"?{id:e,type:Addresses.TYPE}:e,t)}async geocoder(e,t,s){const r=e.id||e;return this.resources.fetch({type:"geocoders"},`addresses/${r}/geocoder`,t,s)}async events(e,t,s){const r=e.id||e;return this.resources.fetch({type:"events"},`addresses/${r}/events`,t,s)}async tags(e,t,s){const r=e.id||e;return this.resources.fetch({type:"tags"},`addresses/${r}/tags`,t,s)}async versions(e,t,s){const r=e.id||e;return this.resources.fetch({type:"versions"},`addresses/${r}/versions`,t,s)}isAddress(e){return e.type&&e.type===Addresses.TYPE}relationship(e){return e===null||typeof e=="string"?{id:e,type:Addresses.TYPE}:{id:e.id,type:Addresses.TYPE}}type(){return Addresses.TYPE}}Addresses.TYPE="addresses",exports.default=Addresses;
|
@@ -1,42 +1 @@
|
|
1
|
-
import
|
2
|
-
import type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
|
3
|
-
import type { QueryParamsRetrieve, QueryParamsList } from '../query';
|
4
|
-
import type { Version } from './versions';
|
5
|
-
type AdjustmentType = 'adjustments';
|
6
|
-
type AdjustmentRel = ResourceRel & {
|
7
|
-
type: AdjustmentType;
|
8
|
-
};
|
9
|
-
interface Adjustment extends Resource {
|
10
|
-
readonly type: AdjustmentType;
|
11
|
-
name: string;
|
12
|
-
currency_code: string;
|
13
|
-
amount_cents: number;
|
14
|
-
amount_float: number;
|
15
|
-
formatted_amount: string;
|
16
|
-
distribute_discount?: boolean | null;
|
17
|
-
versions?: Version[] | null;
|
18
|
-
}
|
19
|
-
interface AdjustmentCreate extends ResourceCreate {
|
20
|
-
name: string;
|
21
|
-
currency_code: string;
|
22
|
-
amount_cents: number;
|
23
|
-
distribute_discount?: boolean | null;
|
24
|
-
}
|
25
|
-
interface AdjustmentUpdate extends ResourceUpdate {
|
26
|
-
name?: string | null;
|
27
|
-
currency_code?: string | null;
|
28
|
-
amount_cents?: number | null;
|
29
|
-
distribute_discount?: boolean | null;
|
30
|
-
}
|
31
|
-
declare class Adjustments extends ApiResource<Adjustment> {
|
32
|
-
static readonly TYPE: AdjustmentType;
|
33
|
-
create(resource: AdjustmentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Adjustment>;
|
34
|
-
update(resource: AdjustmentUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Adjustment>;
|
35
|
-
delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
|
36
|
-
versions(adjustmentId: string | Adjustment, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
37
|
-
isAdjustment(resource: any): resource is Adjustment;
|
38
|
-
relationship(id: string | ResourceId | null): AdjustmentRel;
|
39
|
-
type(): AdjustmentType;
|
40
|
-
}
|
41
|
-
export default Adjustments;
|
42
|
-
export type { Adjustment, AdjustmentCreate, AdjustmentUpdate, AdjustmentType };
|
1
|
+
import{ApiResource}from'../resource';import type{Resource,ResourceCreate,ResourceUpdate,ResourceId,ResourcesConfig,ResourceRel,ListResponse}from'../resource';import type{QueryParamsRetrieve,QueryParamsList}from'../query';import type{Version}from'./versions';type AdjustmentType='adjustments';type AdjustmentRel=ResourceRel&{type:AdjustmentType;};interface Adjustment extends Resource{readonly type:AdjustmentType;name:string;currency_code:string;amount_cents:number;amount_float:number;formatted_amount:string;distribute_discount?:boolean|null;versions?:Version[]|null;}interface AdjustmentCreate extends ResourceCreate{name:string;currency_code:string;amount_cents:number;distribute_discount?:boolean|null;}interface AdjustmentUpdate extends ResourceUpdate{name?:string|null;currency_code?:string|null;amount_cents?:number|null;distribute_discount?:boolean|null;}declare class Adjustments extends ApiResource<Adjustment>{static readonly TYPE:AdjustmentType;create(resource:AdjustmentCreate,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<Adjustment>;update(resource:AdjustmentUpdate,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<Adjustment>;delete(id:string|ResourceId,options?:ResourcesConfig):Promise<void>;versions(adjustmentId:string|Adjustment,params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<Version>>;isAdjustment(resource:any):resource is Adjustment;relationship(id:string|ResourceId|null):AdjustmentRel;type():AdjustmentType;}export default Adjustments;export type{Adjustment,AdjustmentCreate,AdjustmentUpdate,AdjustmentType};
|
@@ -1,29 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const resource_1 = require("../resource");
|
4
|
-
class Adjustments extends resource_1.ApiResource {
|
5
|
-
async create(resource, params, options) {
|
6
|
-
return this.resources.create({ ...resource, type: Adjustments.TYPE }, params, options);
|
7
|
-
}
|
8
|
-
async update(resource, params, options) {
|
9
|
-
return this.resources.update({ ...resource, type: Adjustments.TYPE }, params, options);
|
10
|
-
}
|
11
|
-
async delete(id, options) {
|
12
|
-
await this.resources.delete((typeof id === 'string') ? { id, type: Adjustments.TYPE } : id, options);
|
13
|
-
}
|
14
|
-
async versions(adjustmentId, params, options) {
|
15
|
-
const _adjustmentId = adjustmentId.id || adjustmentId;
|
16
|
-
return this.resources.fetch({ type: 'versions' }, `adjustments/${_adjustmentId}/versions`, params, options);
|
17
|
-
}
|
18
|
-
isAdjustment(resource) {
|
19
|
-
return resource.type && (resource.type === Adjustments.TYPE);
|
20
|
-
}
|
21
|
-
relationship(id) {
|
22
|
-
return ((id === null) || (typeof id === 'string')) ? { id, type: Adjustments.TYPE } : { id: id.id, type: Adjustments.TYPE };
|
23
|
-
}
|
24
|
-
type() {
|
25
|
-
return Adjustments.TYPE;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
Adjustments.TYPE = 'adjustments';
|
29
|
-
exports.default = Adjustments;
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const resource_1=require("../resource");class Adjustments extends resource_1.ApiResource{async create(e,r,t){return this.resources.create({...e,type:Adjustments.TYPE},r,t)}async update(e,r,t){return this.resources.update({...e,type:Adjustments.TYPE},r,t)}async delete(e,r){await this.resources.delete(typeof e=="string"?{id:e,type:Adjustments.TYPE}:e,r)}async versions(e,r,t){const s=e.id||e;return this.resources.fetch({type:"versions"},`adjustments/${s}/versions`,r,t)}isAdjustment(e){return e.type&&e.type===Adjustments.TYPE}relationship(e){return e===null||typeof e=="string"?{id:e,type:Adjustments.TYPE}:{id:e.id,type:Adjustments.TYPE}}type(){return Adjustments.TYPE}}Adjustments.TYPE="adjustments",exports.default=Adjustments;
|