@commercelayer/sdk 7.0.0-beta.18 → 7.0.0-beta.19
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/api.cjs +791 -7460
- package/lib/api.js +131 -7331
- package/lib/client.cjs +31 -215
- package/lib/client.js +23 -212
- package/lib/commercelayer.cjs +30 -778
- package/lib/commercelayer.js +22 -774
- package/lib/common.cjs +6 -143
- package/lib/common.js +4 -141
- package/lib/config.cjs +1 -2
- package/lib/config.js +1 -2
- package/lib/debug.cjs +5 -13
- package/lib/debug.js +5 -13
- package/lib/enum.cjs +8 -9
- package/lib/enum.js +8 -9
- package/lib/error.cjs +15 -67
- package/lib/error.js +14 -66
- package/lib/fetch.cjs +13 -72
- package/lib/fetch.js +11 -74
- package/lib/index.cjs +22 -8104
- package/lib/index.js +3 -7977
- package/lib/jsonapi.cjs +20 -188
- package/lib/jsonapi.js +13 -186
- package/lib/query.cjs +16 -75
- package/lib/query.js +14 -77
- package/lib/resource.cjs +57 -651
- package/lib/resource.js +37 -637
- package/lib/resources/addresses.cjs +11 -801
- package/lib/resources/addresses.js +11 -801
- package/lib/resources/adjustments.cjs +9 -799
- package/lib/resources/adjustments.js +9 -799
- package/lib/resources/adyen_gateways.cjs +9 -799
- package/lib/resources/adyen_gateways.js +9 -799
- package/lib/resources/adyen_payments.cjs +11 -801
- package/lib/resources/adyen_payments.js +11 -801
- package/lib/resources/applications.cjs +6 -788
- package/lib/resources/applications.js +6 -788
- package/lib/resources/attachments.cjs +9 -799
- package/lib/resources/attachments.js +9 -799
- package/lib/resources/authorizations.cjs +12 -802
- package/lib/resources/authorizations.js +12 -802
- package/lib/resources/avalara_accounts.cjs +9 -799
- package/lib/resources/avalara_accounts.js +9 -799
- package/lib/resources/axerve_gateways.cjs +9 -799
- package/lib/resources/axerve_gateways.js +9 -799
- package/lib/resources/axerve_payments.cjs +10 -800
- package/lib/resources/axerve_payments.js +10 -800
- package/lib/resources/bing_geocoders.cjs +9 -799
- package/lib/resources/bing_geocoders.js +9 -799
- package/lib/resources/braintree_gateways.cjs +9 -799
- package/lib/resources/braintree_gateways.js +9 -799
- package/lib/resources/braintree_payments.cjs +9 -799
- package/lib/resources/braintree_payments.js +9 -799
- package/lib/resources/bundles.cjs +13 -803
- package/lib/resources/bundles.js +13 -803
- package/lib/resources/buy_x_pay_y_promotions.cjs +13 -803
- package/lib/resources/buy_x_pay_y_promotions.js +13 -803
- package/lib/resources/captures.cjs +11 -801
- package/lib/resources/captures.js +11 -801
- package/lib/resources/carrier_accounts.cjs +9 -799
- package/lib/resources/carrier_accounts.js +9 -799
- package/lib/resources/checkout_com_gateways.cjs +9 -799
- package/lib/resources/checkout_com_gateways.js +9 -799
- package/lib/resources/checkout_com_payments.cjs +11 -801
- package/lib/resources/checkout_com_payments.js +11 -801
- package/lib/resources/cleanups.cjs +10 -800
- package/lib/resources/cleanups.js +10 -800
- package/lib/resources/coupon_codes_promotion_rules.cjs +9 -799
- package/lib/resources/coupon_codes_promotion_rules.js +9 -799
- package/lib/resources/coupon_recipients.cjs +9 -799
- package/lib/resources/coupon_recipients.js +9 -799
- package/lib/resources/coupons.cjs +11 -801
- package/lib/resources/coupons.js +11 -801
- package/lib/resources/custom_promotion_rules.cjs +9 -799
- package/lib/resources/custom_promotion_rules.js +9 -799
- package/lib/resources/customer_addresses.cjs +9 -799
- package/lib/resources/customer_addresses.js +9 -799
- package/lib/resources/customer_groups.cjs +9 -799
- package/lib/resources/customer_groups.js +9 -799
- package/lib/resources/customer_password_resets.cjs +10 -800
- package/lib/resources/customer_password_resets.js +10 -800
- package/lib/resources/customer_payment_sources.cjs +9 -799
- package/lib/resources/customer_payment_sources.js +9 -799
- package/lib/resources/customer_subscriptions.cjs +9 -799
- package/lib/resources/customer_subscriptions.js +9 -799
- package/lib/resources/customers.cjs +11 -801
- package/lib/resources/customers.js +11 -801
- package/lib/resources/delivery_lead_times.cjs +9 -799
- package/lib/resources/delivery_lead_times.js +9 -799
- package/lib/resources/discount_engine_items.cjs +6 -796
- package/lib/resources/discount_engine_items.js +6 -796
- package/lib/resources/discount_engines.cjs +6 -796
- package/lib/resources/discount_engines.js +6 -796
- package/lib/resources/easypost_pickups.cjs +10 -800
- package/lib/resources/easypost_pickups.js +10 -800
- package/lib/resources/event_callbacks.cjs +6 -796
- package/lib/resources/event_callbacks.js +6 -796
- package/lib/resources/events.cjs +8 -798
- package/lib/resources/events.js +8 -798
- package/lib/resources/exports.cjs +10 -800
- package/lib/resources/exports.js +10 -800
- package/lib/resources/external_gateways.cjs +10 -800
- package/lib/resources/external_gateways.js +10 -800
- package/lib/resources/external_payments.cjs +9 -799
- package/lib/resources/external_payments.js +9 -799
- package/lib/resources/external_promotions.cjs +14 -804
- package/lib/resources/external_promotions.js +14 -804
- package/lib/resources/external_tax_calculators.cjs +10 -800
- package/lib/resources/external_tax_calculators.js +10 -800
- package/lib/resources/fixed_amount_promotions.cjs +13 -803
- package/lib/resources/fixed_amount_promotions.js +13 -803
- package/lib/resources/fixed_price_promotions.cjs +13 -803
- package/lib/resources/fixed_price_promotions.js +13 -803
- package/lib/resources/flex_promotions.cjs +13 -803
- package/lib/resources/flex_promotions.js +13 -803
- package/lib/resources/free_gift_promotions.cjs +13 -803
- package/lib/resources/free_gift_promotions.js +13 -803
- package/lib/resources/free_shipping_promotions.cjs +13 -803
- package/lib/resources/free_shipping_promotions.js +13 -803
- package/lib/resources/geocoders.cjs +6 -796
- package/lib/resources/geocoders.js +6 -796
- package/lib/resources/gift_card_recipients.cjs +9 -799
- package/lib/resources/gift_card_recipients.js +9 -799
- package/lib/resources/gift_cards.cjs +15 -805
- package/lib/resources/gift_cards.js +15 -805
- package/lib/resources/google_geocoders.cjs +9 -799
- package/lib/resources/google_geocoders.js +9 -799
- package/lib/resources/imports.cjs +10 -800
- package/lib/resources/imports.js +10 -800
- package/lib/resources/in_stock_subscriptions.cjs +11 -801
- package/lib/resources/in_stock_subscriptions.js +11 -801
- package/lib/resources/inventory_models.cjs +9 -799
- package/lib/resources/inventory_models.js +9 -799
- package/lib/resources/inventory_return_locations.cjs +9 -799
- package/lib/resources/inventory_return_locations.js +9 -799
- package/lib/resources/inventory_stock_locations.cjs +9 -799
- package/lib/resources/inventory_stock_locations.js +9 -799
- package/lib/resources/klarna_gateways.cjs +9 -799
- package/lib/resources/klarna_gateways.js +9 -799
- package/lib/resources/klarna_payments.cjs +10 -800
- package/lib/resources/klarna_payments.js +10 -800
- package/lib/resources/line_item_options.cjs +11 -801
- package/lib/resources/line_item_options.js +11 -801
- package/lib/resources/line_items.cjs +14 -804
- package/lib/resources/line_items.js +14 -804
- package/lib/resources/links.cjs +11 -801
- package/lib/resources/links.js +11 -801
- package/lib/resources/manual_gateways.cjs +9 -799
- package/lib/resources/manual_gateways.js +9 -799
- package/lib/resources/manual_tax_calculators.cjs +9 -799
- package/lib/resources/manual_tax_calculators.js +9 -799
- package/lib/resources/markets.cjs +11 -801
- package/lib/resources/markets.js +11 -801
- package/lib/resources/merchants.cjs +9 -799
- package/lib/resources/merchants.js +9 -799
- package/lib/resources/notifications.cjs +9 -799
- package/lib/resources/notifications.js +9 -799
- package/lib/resources/order_amount_promotion_rules.cjs +9 -799
- package/lib/resources/order_amount_promotion_rules.js +9 -799
- package/lib/resources/order_copies.cjs +9 -799
- package/lib/resources/order_copies.js +9 -799
- package/lib/resources/order_factories.cjs +6 -796
- package/lib/resources/order_factories.js +6 -796
- package/lib/resources/order_subscription_items.cjs +9 -799
- package/lib/resources/order_subscription_items.js +9 -799
- package/lib/resources/order_subscriptions.cjs +15 -805
- package/lib/resources/order_subscriptions.js +15 -805
- package/lib/resources/orders.cjs +42 -832
- package/lib/resources/orders.js +42 -832
- package/lib/resources/organizations.cjs +6 -788
- package/lib/resources/organizations.js +6 -788
- package/lib/resources/packages.cjs +9 -799
- package/lib/resources/packages.js +9 -799
- package/lib/resources/parcel_line_items.cjs +9 -799
- package/lib/resources/parcel_line_items.js +9 -799
- package/lib/resources/parcels.cjs +9 -799
- package/lib/resources/parcels.js +9 -799
- package/lib/resources/payment_gateways.cjs +6 -796
- package/lib/resources/payment_gateways.js +6 -796
- package/lib/resources/payment_methods.cjs +11 -801
- package/lib/resources/payment_methods.js +11 -801
- package/lib/resources/payment_options.cjs +9 -799
- package/lib/resources/payment_options.js +9 -799
- package/lib/resources/paypal_gateways.cjs +9 -799
- package/lib/resources/paypal_gateways.js +9 -799
- package/lib/resources/paypal_payments.cjs +9 -799
- package/lib/resources/paypal_payments.js +9 -799
- package/lib/resources/percentage_discount_promotions.cjs +13 -803
- package/lib/resources/percentage_discount_promotions.js +13 -803
- package/lib/resources/pickups.cjs +6 -796
- package/lib/resources/pickups.js +6 -796
- package/lib/resources/price_frequency_tiers.cjs +9 -799
- package/lib/resources/price_frequency_tiers.js +9 -799
- package/lib/resources/price_list_schedulers.cjs +11 -801
- package/lib/resources/price_list_schedulers.js +11 -801
- package/lib/resources/price_lists.cjs +9 -799
- package/lib/resources/price_lists.js +9 -799
- package/lib/resources/price_tiers.cjs +6 -796
- package/lib/resources/price_tiers.js +6 -796
- package/lib/resources/price_volume_tiers.cjs +9 -799
- package/lib/resources/price_volume_tiers.js +9 -799
- package/lib/resources/prices.cjs +9 -799
- package/lib/resources/prices.js +9 -799
- package/lib/resources/promotion_rules.cjs +6 -796
- package/lib/resources/promotion_rules.js +6 -796
- package/lib/resources/promotions.cjs +6 -796
- package/lib/resources/promotions.js +6 -796
- package/lib/resources/recurring_order_copies.cjs +9 -799
- package/lib/resources/recurring_order_copies.js +9 -799
- package/lib/resources/refunds.cjs +8 -798
- package/lib/resources/refunds.js +8 -798
- package/lib/resources/reserved_stocks.cjs +6 -796
- package/lib/resources/reserved_stocks.js +6 -796
- package/lib/resources/resource_errors.cjs +6 -796
- package/lib/resources/resource_errors.js +6 -796
- package/lib/resources/return_line_items.cjs +10 -800
- package/lib/resources/return_line_items.js +10 -800
- package/lib/resources/returns.cjs +22 -812
- package/lib/resources/returns.js +22 -812
- package/lib/resources/satispay_gateways.cjs +9 -799
- package/lib/resources/satispay_gateways.js +9 -799
- package/lib/resources/satispay_payments.cjs +10 -800
- package/lib/resources/satispay_payments.js +10 -800
- package/lib/resources/shipments.cjs +24 -814
- package/lib/resources/shipments.js +24 -814
- package/lib/resources/shipping_categories.cjs +9 -799
- package/lib/resources/shipping_categories.js +9 -799
- package/lib/resources/shipping_method_tiers.cjs +6 -796
- package/lib/resources/shipping_method_tiers.js +6 -796
- package/lib/resources/shipping_methods.cjs +12 -802
- package/lib/resources/shipping_methods.js +12 -802
- package/lib/resources/shipping_weight_tiers.cjs +9 -799
- package/lib/resources/shipping_weight_tiers.js +9 -799
- package/lib/resources/shipping_zones.cjs +9 -799
- package/lib/resources/shipping_zones.js +9 -799
- package/lib/resources/sku_list_items.cjs +9 -799
- package/lib/resources/sku_list_items.js +9 -799
- package/lib/resources/sku_list_promotion_rules.cjs +9 -799
- package/lib/resources/sku_list_promotion_rules.js +9 -799
- package/lib/resources/sku_lists.cjs +9 -799
- package/lib/resources/sku_lists.js +9 -799
- package/lib/resources/sku_options.cjs +11 -801
- package/lib/resources/sku_options.js +11 -801
- package/lib/resources/skus.cjs +11 -801
- package/lib/resources/skus.js +11 -801
- package/lib/resources/stock_items.cjs +10 -800
- package/lib/resources/stock_items.js +10 -800
- package/lib/resources/stock_line_items.cjs +12 -802
- package/lib/resources/stock_line_items.js +12 -802
- package/lib/resources/stock_locations.cjs +9 -799
- package/lib/resources/stock_locations.js +9 -799
- package/lib/resources/stock_reservations.cjs +10 -800
- package/lib/resources/stock_reservations.js +10 -800
- package/lib/resources/stock_transfers.cjs +15 -805
- package/lib/resources/stock_transfers.js +15 -805
- package/lib/resources/stores.cjs +9 -799
- package/lib/resources/stores.js +9 -799
- package/lib/resources/stripe_gateways.cjs +9 -799
- package/lib/resources/stripe_gateways.js +9 -799
- package/lib/resources/stripe_payments.cjs +11 -801
- package/lib/resources/stripe_payments.js +11 -801
- package/lib/resources/stripe_tax_accounts.cjs +9 -799
- package/lib/resources/stripe_tax_accounts.js +9 -799
- package/lib/resources/subscription_models.cjs +9 -799
- package/lib/resources/subscription_models.js +9 -799
- package/lib/resources/tags.cjs +9 -799
- package/lib/resources/tags.js +9 -799
- package/lib/resources/talon_one_accounts.cjs +9 -799
- package/lib/resources/talon_one_accounts.js +9 -799
- package/lib/resources/tax_calculators.cjs +6 -796
- package/lib/resources/tax_calculators.js +6 -796
- package/lib/resources/tax_categories.cjs +9 -799
- package/lib/resources/tax_categories.js +9 -799
- package/lib/resources/tax_rules.cjs +9 -799
- package/lib/resources/tax_rules.js +9 -799
- package/lib/resources/taxjar_accounts.cjs +9 -799
- package/lib/resources/taxjar_accounts.js +9 -799
- package/lib/resources/transactions.cjs +6 -796
- package/lib/resources/transactions.js +6 -796
- package/lib/resources/versions.cjs +6 -796
- package/lib/resources/versions.js +6 -796
- package/lib/resources/vertex_accounts.cjs +10 -800
- package/lib/resources/vertex_accounts.js +10 -800
- package/lib/resources/voids.cjs +8 -798
- package/lib/resources/voids.js +8 -798
- package/lib/resources/webhooks.cjs +12 -802
- package/lib/resources/webhooks.js +12 -802
- package/lib/resources/wire_transfers.cjs +9 -799
- package/lib/resources/wire_transfers.js +9 -799
- package/lib/static.cjs +19 -753
- package/lib/static.js +5 -739
- package/lib/util.cjs +4 -5
- package/lib/util.js +4 -5
- package/package.json +4 -4
package/lib/common.cjs
CHANGED
@@ -1,151 +1,14 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
var apiResources = [
|
5
|
-
// ##__API_RESOURCE_LIST_START__##
|
6
|
-
"addresses",
|
7
|
-
"adjustments",
|
8
|
-
"adyen_gateways",
|
9
|
-
"adyen_payments",
|
10
|
-
"applications",
|
11
|
-
"attachments",
|
12
|
-
"authorizations",
|
13
|
-
"avalara_accounts",
|
14
|
-
"axerve_gateways",
|
15
|
-
"axerve_payments",
|
16
|
-
"bing_geocoders",
|
17
|
-
"braintree_gateways",
|
18
|
-
"braintree_payments",
|
19
|
-
"bundles",
|
20
|
-
"buy_x_pay_y_promotions",
|
21
|
-
"captures",
|
22
|
-
"carrier_accounts",
|
23
|
-
"checkout_com_gateways",
|
24
|
-
"checkout_com_payments",
|
25
|
-
"cleanups",
|
26
|
-
"coupon_codes_promotion_rules",
|
27
|
-
"coupon_recipients",
|
28
|
-
"coupons",
|
29
|
-
"custom_promotion_rules",
|
30
|
-
"customer_addresses",
|
31
|
-
"customer_groups",
|
32
|
-
"customer_password_resets",
|
33
|
-
"customer_payment_sources",
|
34
|
-
"customer_subscriptions",
|
35
|
-
"customers",
|
36
|
-
"delivery_lead_times",
|
37
|
-
"discount_engine_items",
|
38
|
-
"discount_engines",
|
39
|
-
"easypost_pickups",
|
40
|
-
"event_callbacks",
|
41
|
-
"events",
|
42
|
-
"exports",
|
43
|
-
"external_gateways",
|
44
|
-
"external_payments",
|
45
|
-
"external_promotions",
|
46
|
-
"external_tax_calculators",
|
47
|
-
"fixed_amount_promotions",
|
48
|
-
"fixed_price_promotions",
|
49
|
-
"flex_promotions",
|
50
|
-
"free_gift_promotions",
|
51
|
-
"free_shipping_promotions",
|
52
|
-
"geocoders",
|
53
|
-
"gift_card_recipients",
|
54
|
-
"gift_cards",
|
55
|
-
"google_geocoders",
|
56
|
-
"imports",
|
57
|
-
"in_stock_subscriptions",
|
58
|
-
"inventory_models",
|
59
|
-
"inventory_return_locations",
|
60
|
-
"inventory_stock_locations",
|
61
|
-
"klarna_gateways",
|
62
|
-
"klarna_payments",
|
63
|
-
"line_item_options",
|
64
|
-
"line_items",
|
65
|
-
"links",
|
66
|
-
"manual_gateways",
|
67
|
-
"manual_tax_calculators",
|
68
|
-
"markets",
|
69
|
-
"merchants",
|
70
|
-
"notifications",
|
71
|
-
"order_amount_promotion_rules",
|
72
|
-
"order_copies",
|
73
|
-
"order_factories",
|
74
|
-
"order_subscription_items",
|
75
|
-
"order_subscriptions",
|
76
|
-
"orders",
|
77
|
-
"organizations",
|
78
|
-
"packages",
|
79
|
-
"parcel_line_items",
|
80
|
-
"parcels",
|
81
|
-
"payment_gateways",
|
82
|
-
"payment_methods",
|
83
|
-
"payment_options",
|
84
|
-
"paypal_gateways",
|
85
|
-
"paypal_payments",
|
86
|
-
"percentage_discount_promotions",
|
87
|
-
"pickups",
|
88
|
-
"price_frequency_tiers",
|
89
|
-
"price_list_schedulers",
|
90
|
-
"price_lists",
|
91
|
-
"price_tiers",
|
92
|
-
"price_volume_tiers",
|
93
|
-
"prices",
|
94
|
-
"promotion_rules",
|
95
|
-
"promotions",
|
96
|
-
"recurring_order_copies",
|
97
|
-
"refunds",
|
98
|
-
"reserved_stocks",
|
99
|
-
"resource_errors",
|
100
|
-
"return_line_items",
|
101
|
-
"returns",
|
102
|
-
"satispay_gateways",
|
103
|
-
"satispay_payments",
|
104
|
-
"shipments",
|
105
|
-
"shipping_categories",
|
106
|
-
"shipping_method_tiers",
|
107
|
-
"shipping_methods",
|
108
|
-
"shipping_weight_tiers",
|
109
|
-
"shipping_zones",
|
110
|
-
"sku_list_items",
|
111
|
-
"sku_list_promotion_rules",
|
112
|
-
"sku_lists",
|
113
|
-
"sku_options",
|
114
|
-
"skus",
|
115
|
-
"stock_items",
|
116
|
-
"stock_line_items",
|
117
|
-
"stock_locations",
|
118
|
-
"stock_reservations",
|
119
|
-
"stock_transfers",
|
120
|
-
"stores",
|
121
|
-
"stripe_gateways",
|
122
|
-
"stripe_payments",
|
123
|
-
"stripe_tax_accounts",
|
124
|
-
"subscription_models",
|
125
|
-
"tags",
|
126
|
-
"talon_one_accounts",
|
127
|
-
"tax_calculators",
|
128
|
-
"tax_categories",
|
129
|
-
"tax_rules",
|
130
|
-
"taxjar_accounts",
|
131
|
-
"transactions",
|
132
|
-
"versions",
|
133
|
-
"vertex_accounts",
|
134
|
-
"voids",
|
135
|
-
"webhooks",
|
136
|
-
"wire_transfers"
|
137
|
-
// ##__API_RESOURCE_LIST_STOP__##
|
138
|
-
];
|
139
|
-
var resourceList = apiResources;
|
3
|
+
var _enum = require('./enum');
|
140
4
|
|
141
|
-
|
142
|
-
|
143
|
-
return resource?.type && resource.id && resourceList.includes(resource.type);
|
5
|
+
const isResourceId = (resource) => {
|
6
|
+
return resource?.type && resource.id && _enum.resourceList.includes(resource.type);
|
144
7
|
};
|
145
|
-
|
146
|
-
return resource && typeof resource.type !== "undefined" && resource.type && resourceList.includes(resource.type);
|
8
|
+
const isResourceType = (resource) => {
|
9
|
+
return resource && typeof resource.type !== "undefined" && resource.type && _enum.resourceList.includes(resource.type);
|
147
10
|
};
|
148
|
-
|
11
|
+
const DBG = {
|
149
12
|
verbose: false
|
150
13
|
};
|
151
14
|
|
package/lib/common.js
CHANGED
@@ -1,149 +1,12 @@
|
|
1
|
-
|
2
|
-
var apiResources = [
|
3
|
-
// ##__API_RESOURCE_LIST_START__##
|
4
|
-
"addresses",
|
5
|
-
"adjustments",
|
6
|
-
"adyen_gateways",
|
7
|
-
"adyen_payments",
|
8
|
-
"applications",
|
9
|
-
"attachments",
|
10
|
-
"authorizations",
|
11
|
-
"avalara_accounts",
|
12
|
-
"axerve_gateways",
|
13
|
-
"axerve_payments",
|
14
|
-
"bing_geocoders",
|
15
|
-
"braintree_gateways",
|
16
|
-
"braintree_payments",
|
17
|
-
"bundles",
|
18
|
-
"buy_x_pay_y_promotions",
|
19
|
-
"captures",
|
20
|
-
"carrier_accounts",
|
21
|
-
"checkout_com_gateways",
|
22
|
-
"checkout_com_payments",
|
23
|
-
"cleanups",
|
24
|
-
"coupon_codes_promotion_rules",
|
25
|
-
"coupon_recipients",
|
26
|
-
"coupons",
|
27
|
-
"custom_promotion_rules",
|
28
|
-
"customer_addresses",
|
29
|
-
"customer_groups",
|
30
|
-
"customer_password_resets",
|
31
|
-
"customer_payment_sources",
|
32
|
-
"customer_subscriptions",
|
33
|
-
"customers",
|
34
|
-
"delivery_lead_times",
|
35
|
-
"discount_engine_items",
|
36
|
-
"discount_engines",
|
37
|
-
"easypost_pickups",
|
38
|
-
"event_callbacks",
|
39
|
-
"events",
|
40
|
-
"exports",
|
41
|
-
"external_gateways",
|
42
|
-
"external_payments",
|
43
|
-
"external_promotions",
|
44
|
-
"external_tax_calculators",
|
45
|
-
"fixed_amount_promotions",
|
46
|
-
"fixed_price_promotions",
|
47
|
-
"flex_promotions",
|
48
|
-
"free_gift_promotions",
|
49
|
-
"free_shipping_promotions",
|
50
|
-
"geocoders",
|
51
|
-
"gift_card_recipients",
|
52
|
-
"gift_cards",
|
53
|
-
"google_geocoders",
|
54
|
-
"imports",
|
55
|
-
"in_stock_subscriptions",
|
56
|
-
"inventory_models",
|
57
|
-
"inventory_return_locations",
|
58
|
-
"inventory_stock_locations",
|
59
|
-
"klarna_gateways",
|
60
|
-
"klarna_payments",
|
61
|
-
"line_item_options",
|
62
|
-
"line_items",
|
63
|
-
"links",
|
64
|
-
"manual_gateways",
|
65
|
-
"manual_tax_calculators",
|
66
|
-
"markets",
|
67
|
-
"merchants",
|
68
|
-
"notifications",
|
69
|
-
"order_amount_promotion_rules",
|
70
|
-
"order_copies",
|
71
|
-
"order_factories",
|
72
|
-
"order_subscription_items",
|
73
|
-
"order_subscriptions",
|
74
|
-
"orders",
|
75
|
-
"organizations",
|
76
|
-
"packages",
|
77
|
-
"parcel_line_items",
|
78
|
-
"parcels",
|
79
|
-
"payment_gateways",
|
80
|
-
"payment_methods",
|
81
|
-
"payment_options",
|
82
|
-
"paypal_gateways",
|
83
|
-
"paypal_payments",
|
84
|
-
"percentage_discount_promotions",
|
85
|
-
"pickups",
|
86
|
-
"price_frequency_tiers",
|
87
|
-
"price_list_schedulers",
|
88
|
-
"price_lists",
|
89
|
-
"price_tiers",
|
90
|
-
"price_volume_tiers",
|
91
|
-
"prices",
|
92
|
-
"promotion_rules",
|
93
|
-
"promotions",
|
94
|
-
"recurring_order_copies",
|
95
|
-
"refunds",
|
96
|
-
"reserved_stocks",
|
97
|
-
"resource_errors",
|
98
|
-
"return_line_items",
|
99
|
-
"returns",
|
100
|
-
"satispay_gateways",
|
101
|
-
"satispay_payments",
|
102
|
-
"shipments",
|
103
|
-
"shipping_categories",
|
104
|
-
"shipping_method_tiers",
|
105
|
-
"shipping_methods",
|
106
|
-
"shipping_weight_tiers",
|
107
|
-
"shipping_zones",
|
108
|
-
"sku_list_items",
|
109
|
-
"sku_list_promotion_rules",
|
110
|
-
"sku_lists",
|
111
|
-
"sku_options",
|
112
|
-
"skus",
|
113
|
-
"stock_items",
|
114
|
-
"stock_line_items",
|
115
|
-
"stock_locations",
|
116
|
-
"stock_reservations",
|
117
|
-
"stock_transfers",
|
118
|
-
"stores",
|
119
|
-
"stripe_gateways",
|
120
|
-
"stripe_payments",
|
121
|
-
"stripe_tax_accounts",
|
122
|
-
"subscription_models",
|
123
|
-
"tags",
|
124
|
-
"talon_one_accounts",
|
125
|
-
"tax_calculators",
|
126
|
-
"tax_categories",
|
127
|
-
"tax_rules",
|
128
|
-
"taxjar_accounts",
|
129
|
-
"transactions",
|
130
|
-
"versions",
|
131
|
-
"vertex_accounts",
|
132
|
-
"voids",
|
133
|
-
"webhooks",
|
134
|
-
"wire_transfers"
|
135
|
-
// ##__API_RESOURCE_LIST_STOP__##
|
136
|
-
];
|
137
|
-
var resourceList = apiResources;
|
1
|
+
import { resourceList } from './enum';
|
138
2
|
|
139
|
-
|
140
|
-
var isResourceId = (resource) => {
|
3
|
+
const isResourceId = (resource) => {
|
141
4
|
return resource?.type && resource.id && resourceList.includes(resource.type);
|
142
5
|
};
|
143
|
-
|
6
|
+
const isResourceType = (resource) => {
|
144
7
|
return resource && typeof resource.type !== "undefined" && resource.type && resourceList.includes(resource.type);
|
145
8
|
};
|
146
|
-
|
9
|
+
const DBG = {
|
147
10
|
verbose: false
|
148
11
|
};
|
149
12
|
|
package/lib/config.cjs
CHANGED
package/lib/config.js
CHANGED
package/lib/debug.cjs
CHANGED
@@ -1,23 +1,15 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
5
|
-
}) : x)(function(x) {
|
6
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
7
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
8
|
-
});
|
9
|
-
|
10
|
-
// src/debug.ts
|
11
|
-
var debuggerFunction = (_pattern, ..._args) => {
|
3
|
+
const debuggerFunction = (_pattern, ..._args) => {
|
12
4
|
};
|
13
|
-
|
5
|
+
let debuggerFactory = (_namespace) => debuggerFunction;
|
14
6
|
try {
|
15
|
-
const debugModule =
|
7
|
+
const debugModule = require("debug");
|
16
8
|
if (debugModule && typeof debugModule === "function") debuggerFactory = debugModule;
|
17
9
|
} catch (error) {
|
18
10
|
}
|
19
|
-
|
20
|
-
|
11
|
+
const debugPrefix = "clsdk";
|
12
|
+
const debug = (namespace) => {
|
21
13
|
return debuggerFactory(`${debugPrefix}:${namespace}`);
|
22
14
|
};
|
23
15
|
var debug_default = debug;
|
package/lib/debug.js
CHANGED
@@ -1,21 +1,13 @@
|
|
1
|
-
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
3
|
-
}) : x)(function(x) {
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
6
|
-
});
|
7
|
-
|
8
|
-
// src/debug.ts
|
9
|
-
var debuggerFunction = (_pattern, ..._args) => {
|
1
|
+
const debuggerFunction = (_pattern, ..._args) => {
|
10
2
|
};
|
11
|
-
|
3
|
+
let debuggerFactory = (_namespace) => debuggerFunction;
|
12
4
|
try {
|
13
|
-
const debugModule =
|
5
|
+
const debugModule = require("debug");
|
14
6
|
if (debugModule && typeof debugModule === "function") debuggerFactory = debugModule;
|
15
7
|
} catch (error) {
|
16
8
|
}
|
17
|
-
|
18
|
-
|
9
|
+
const debugPrefix = "clsdk";
|
10
|
+
const debug = (namespace) => {
|
19
11
|
return debuggerFactory(`${debugPrefix}:${namespace}`);
|
20
12
|
};
|
21
13
|
var debug_default = debug;
|
package/lib/enum.cjs
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
var apiResources = [
|
3
|
+
const apiResources = [
|
5
4
|
// ##__API_RESOURCE_LIST_START__##
|
6
5
|
"addresses",
|
7
6
|
"adjustments",
|
@@ -136,14 +135,14 @@ var apiResources = [
|
|
136
135
|
"wire_transfers"
|
137
136
|
// ##__API_RESOURCE_LIST_STOP__##
|
138
137
|
];
|
139
|
-
|
140
|
-
|
138
|
+
const resourceList = apiResources;
|
139
|
+
const singletonList = [
|
141
140
|
// ##__API_RESOURCE_SINGLETON_START__##
|
142
141
|
"applications",
|
143
142
|
"organizations"
|
144
143
|
// ##__API_RESOURCE_SINGLETON_STOP__##
|
145
144
|
];
|
146
|
-
|
145
|
+
const creatableResources = [
|
147
146
|
// ##__API_RESOURCE_CREATABLE_START__##
|
148
147
|
"addresses",
|
149
148
|
"adjustments",
|
@@ -255,7 +254,7 @@ var creatableResources = [
|
|
255
254
|
"wire_transfers"
|
256
255
|
// ##__API_RESOURCE_CREATABLE_STOP__##
|
257
256
|
];
|
258
|
-
|
257
|
+
const updatableResources = [
|
259
258
|
// ##__API_RESOURCE_UPDATABLE_START__##
|
260
259
|
"addresses",
|
261
260
|
"adjustments",
|
@@ -372,7 +371,7 @@ var updatableResources = [
|
|
372
371
|
"wire_transfers"
|
373
372
|
// ##__API_RESOURCE_UPDATABLE_STOP__##
|
374
373
|
];
|
375
|
-
|
374
|
+
const deletableResources = [
|
376
375
|
// ##__API_RESOURCE_DELETABLE_START__##
|
377
376
|
"addresses",
|
378
377
|
"adjustments",
|
@@ -484,7 +483,7 @@ var deletableResources = [
|
|
484
483
|
"wire_transfers"
|
485
484
|
// ##__API_RESOURCE_DELETABLE_STOP__##
|
486
485
|
];
|
487
|
-
|
486
|
+
const taggableResources = [
|
488
487
|
// ##__API_RESOURCE_TAGGABLE_START__##
|
489
488
|
"addresses",
|
490
489
|
"bundles",
|
@@ -510,7 +509,7 @@ var taggableResources = [
|
|
510
509
|
"skus"
|
511
510
|
// ##__API_RESOURCE_TAGGABLE_STOP__##
|
512
511
|
];
|
513
|
-
|
512
|
+
const versionableResources = [
|
514
513
|
// ##__API_RESOURCE_VERSIONABLE_START__##
|
515
514
|
"addresses",
|
516
515
|
"adjustments",
|
package/lib/enum.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
var apiResources = [
|
1
|
+
const apiResources = [
|
3
2
|
// ##__API_RESOURCE_LIST_START__##
|
4
3
|
"addresses",
|
5
4
|
"adjustments",
|
@@ -134,14 +133,14 @@ var apiResources = [
|
|
134
133
|
"wire_transfers"
|
135
134
|
// ##__API_RESOURCE_LIST_STOP__##
|
136
135
|
];
|
137
|
-
|
138
|
-
|
136
|
+
const resourceList = apiResources;
|
137
|
+
const singletonList = [
|
139
138
|
// ##__API_RESOURCE_SINGLETON_START__##
|
140
139
|
"applications",
|
141
140
|
"organizations"
|
142
141
|
// ##__API_RESOURCE_SINGLETON_STOP__##
|
143
142
|
];
|
144
|
-
|
143
|
+
const creatableResources = [
|
145
144
|
// ##__API_RESOURCE_CREATABLE_START__##
|
146
145
|
"addresses",
|
147
146
|
"adjustments",
|
@@ -253,7 +252,7 @@ var creatableResources = [
|
|
253
252
|
"wire_transfers"
|
254
253
|
// ##__API_RESOURCE_CREATABLE_STOP__##
|
255
254
|
];
|
256
|
-
|
255
|
+
const updatableResources = [
|
257
256
|
// ##__API_RESOURCE_UPDATABLE_START__##
|
258
257
|
"addresses",
|
259
258
|
"adjustments",
|
@@ -370,7 +369,7 @@ var updatableResources = [
|
|
370
369
|
"wire_transfers"
|
371
370
|
// ##__API_RESOURCE_UPDATABLE_STOP__##
|
372
371
|
];
|
373
|
-
|
372
|
+
const deletableResources = [
|
374
373
|
// ##__API_RESOURCE_DELETABLE_START__##
|
375
374
|
"addresses",
|
376
375
|
"adjustments",
|
@@ -482,7 +481,7 @@ var deletableResources = [
|
|
482
481
|
"wire_transfers"
|
483
482
|
// ##__API_RESOURCE_DELETABLE_STOP__##
|
484
483
|
];
|
485
|
-
|
484
|
+
const taggableResources = [
|
486
485
|
// ##__API_RESOURCE_TAGGABLE_START__##
|
487
486
|
"addresses",
|
488
487
|
"bundles",
|
@@ -508,7 +507,7 @@ var taggableResources = [
|
|
508
507
|
"skus"
|
509
508
|
// ##__API_RESOURCE_TAGGABLE_STOP__##
|
510
509
|
];
|
511
|
-
|
510
|
+
const versionableResources = [
|
512
511
|
// ##__API_RESOURCE_VERSIONABLE_START__##
|
513
512
|
"addresses",
|
514
513
|
"adjustments",
|
package/lib/error.cjs
CHANGED
@@ -1,59 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var
|
4
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
5
|
-
}) : x)(function(x) {
|
6
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
7
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
8
|
-
});
|
3
|
+
var fetch = require('./fetch');
|
9
4
|
|
10
|
-
// src/debug.ts
|
11
|
-
var debuggerFunction = (_pattern, ..._args) => {
|
12
|
-
};
|
13
|
-
var debuggerFactory = (_namespace) => debuggerFunction;
|
14
|
-
try {
|
15
|
-
const debugModule = __require("debug");
|
16
|
-
if (debugModule && typeof debugModule === "function") debuggerFactory = debugModule;
|
17
|
-
} catch (error) {
|
18
|
-
}
|
19
|
-
var debugPrefix = "clsdk";
|
20
|
-
var debug = (namespace) => {
|
21
|
-
return debuggerFactory(`${debugPrefix}:${namespace}`);
|
22
|
-
};
|
23
|
-
var debug_default = debug;
|
24
|
-
|
25
|
-
// src/fetch.ts
|
26
|
-
debug_default("fetch");
|
27
|
-
var FetchError = class _FetchError extends Error {
|
28
|
-
static isFetchError = (error) => {
|
29
|
-
return error instanceof _FetchError;
|
30
|
-
};
|
31
|
-
#errors;
|
32
|
-
#status;
|
33
|
-
#statusText;
|
34
|
-
#request;
|
35
|
-
constructor(status, statusText, body, request) {
|
36
|
-
super(statusText);
|
37
|
-
this.#status = status;
|
38
|
-
this.#statusText = statusText;
|
39
|
-
if (body) this.#errors = body.errors;
|
40
|
-
if (request) this.#request = request;
|
41
|
-
}
|
42
|
-
get errors() {
|
43
|
-
return this.#errors;
|
44
|
-
}
|
45
|
-
get status() {
|
46
|
-
return this.#status;
|
47
|
-
}
|
48
|
-
get statusText() {
|
49
|
-
return this.#statusText;
|
50
|
-
}
|
51
|
-
get request() {
|
52
|
-
return this.#request;
|
53
|
-
}
|
54
|
-
};
|
55
|
-
|
56
|
-
// src/error.ts
|
57
5
|
var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
|
58
6
|
ErrorType2["CLIENT"] = "client";
|
59
7
|
ErrorType2["REQUEST"] = "request";
|
@@ -64,24 +12,24 @@ var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
|
|
64
12
|
ErrorType2["TOKEN_REFRESH"] = "token-refresh";
|
65
13
|
return ErrorType2;
|
66
14
|
})(ErrorType || {});
|
67
|
-
|
15
|
+
class SdkError extends Error {
|
68
16
|
static NAME = "SdkError";
|
69
17
|
static isSdkError(error) {
|
70
|
-
return error && [
|
18
|
+
return error && [SdkError.NAME, ApiError.NAME].includes(error.name) && Object.values(ErrorType).includes(error.type);
|
71
19
|
}
|
72
20
|
type;
|
73
21
|
code;
|
74
22
|
source;
|
75
23
|
constructor(error) {
|
76
24
|
super(error.message);
|
77
|
-
this.name =
|
25
|
+
this.name = SdkError.NAME;
|
78
26
|
this.type = error.type || "client" /* CLIENT */;
|
79
27
|
}
|
80
|
-
}
|
81
|
-
|
28
|
+
}
|
29
|
+
class ApiError extends SdkError {
|
82
30
|
static NAME = "ApiError";
|
83
31
|
static isApiError(error) {
|
84
|
-
return SdkError.isSdkError(error) && error.name ===
|
32
|
+
return SdkError.isSdkError(error) && error.name === ApiError.NAME && error.type === "response" /* RESPONSE */;
|
85
33
|
}
|
86
34
|
errors = [];
|
87
35
|
status;
|
@@ -89,32 +37,32 @@ var ApiError = class _ApiError extends SdkError {
|
|
89
37
|
// constructor(error: SdkError)
|
90
38
|
constructor(error) {
|
91
39
|
super({ ...error, type: "response" /* RESPONSE */ });
|
92
|
-
this.name =
|
40
|
+
this.name = ApiError.NAME;
|
93
41
|
}
|
94
42
|
first() {
|
95
43
|
return this.errors?.length > 0 ? this.errors[0] : void 0;
|
96
44
|
}
|
97
|
-
}
|
98
|
-
|
45
|
+
}
|
46
|
+
const isRequestError = (error) => {
|
99
47
|
return error instanceof TypeError && error.message !== "fetch failed";
|
100
48
|
};
|
101
|
-
|
49
|
+
const isCancelError = (error) => {
|
102
50
|
return error instanceof DOMException && error.name === "AbortError";
|
103
51
|
};
|
104
|
-
|
52
|
+
const isTimeoutError = (error) => {
|
105
53
|
return error instanceof DOMException && error.name === "TimeoutError";
|
106
54
|
};
|
107
|
-
|
55
|
+
const isExpiredTokenError = (error) => {
|
108
56
|
const invalidTokenCodes = [
|
109
57
|
"INVALID_TOKEN"
|
110
58
|
/*, 'UNAUTHORIZED' */
|
111
59
|
];
|
112
60
|
return ApiError.isApiError(error) && error.status === 401 && (invalidTokenCodes.includes(error.code || "") || error.errors && error.errors.length > 0 && invalidTokenCodes.includes(error.errors[0].code));
|
113
61
|
};
|
114
|
-
|
62
|
+
const handleError = (error) => {
|
115
63
|
if (SdkError.isSdkError(error) || ApiError.isApiError(error)) throw error;
|
116
64
|
let sdkError = new SdkError({ message: error.message });
|
117
|
-
if (FetchError.isFetchError(error)) {
|
65
|
+
if (fetch.FetchError.isFetchError(error)) {
|
118
66
|
const apiError = new ApiError(sdkError);
|
119
67
|
apiError.type = "response" /* RESPONSE */;
|
120
68
|
apiError.status = error.status;
|