@commercelayer/sdk 5.35.0 → 6.0.0-alfa.2
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/client.js +5 -5
- package/lib/cjs/commercelayer.d.ts +2 -2
- package/lib/cjs/commercelayer.js +3 -3
- package/lib/cjs/common.js +1 -1
- package/lib/cjs/error.js +1 -2
- package/lib/cjs/interceptor.d.ts +2 -2
- package/lib/cjs/resource.js +21 -24
- package/lib/esm/client.js +19 -30
- package/lib/esm/commercelayer.d.ts +2 -2
- package/lib/esm/commercelayer.js +260 -149
- package/lib/esm/common.js +1 -1
- package/lib/esm/error.js +10 -5
- package/lib/esm/interceptor.d.ts +2 -2
- package/lib/esm/resource.js +37 -50
- package/lib/esm/resources/addresses.js +1 -1
- package/lib/esm/resources/adjustments.js +1 -1
- package/lib/esm/resources/adyen_gateways.js +1 -1
- package/lib/esm/resources/adyen_payments.js +1 -1
- package/lib/esm/resources/application.js +1 -1
- package/lib/esm/resources/attachments.js +1 -1
- package/lib/esm/resources/authorizations.js +1 -1
- package/lib/esm/resources/avalara_accounts.js +1 -1
- package/lib/esm/resources/axerve_gateways.js +1 -1
- package/lib/esm/resources/axerve_payments.js +1 -1
- package/lib/esm/resources/billing_info_validation_rules.js +1 -1
- package/lib/esm/resources/bing_geocoders.js +1 -1
- package/lib/esm/resources/braintree_gateways.js +1 -1
- package/lib/esm/resources/braintree_payments.js +1 -1
- package/lib/esm/resources/bundles.js +1 -1
- package/lib/esm/resources/buy_x_pay_y_promotions.js +1 -1
- package/lib/esm/resources/captures.js +1 -1
- package/lib/esm/resources/carrier_accounts.js +1 -1
- package/lib/esm/resources/checkout_com_gateways.js +1 -1
- package/lib/esm/resources/checkout_com_payments.js +1 -1
- package/lib/esm/resources/cleanups.js +1 -1
- package/lib/esm/resources/coupon_codes_promotion_rules.js +1 -1
- package/lib/esm/resources/coupon_recipients.js +1 -1
- package/lib/esm/resources/coupons.js +1 -1
- package/lib/esm/resources/custom_promotion_rules.js +1 -1
- package/lib/esm/resources/customer_addresses.js +1 -1
- package/lib/esm/resources/customer_groups.js +1 -1
- package/lib/esm/resources/customer_password_resets.js +1 -1
- package/lib/esm/resources/customer_payment_sources.js +1 -1
- package/lib/esm/resources/customer_subscriptions.js +1 -1
- package/lib/esm/resources/customers.js +1 -1
- package/lib/esm/resources/delivery_lead_times.js +1 -1
- package/lib/esm/resources/event_callbacks.js +1 -1
- package/lib/esm/resources/events.js +1 -1
- package/lib/esm/resources/exports.js +1 -1
- package/lib/esm/resources/external_gateways.js +1 -1
- package/lib/esm/resources/external_payments.js +1 -1
- package/lib/esm/resources/external_promotions.js +1 -1
- package/lib/esm/resources/external_tax_calculators.js +1 -1
- package/lib/esm/resources/fixed_amount_promotions.js +1 -1
- package/lib/esm/resources/fixed_price_promotions.js +1 -1
- package/lib/esm/resources/free_gift_promotions.js +1 -1
- package/lib/esm/resources/free_shipping_promotions.js +1 -1
- package/lib/esm/resources/geocoders.js +1 -1
- package/lib/esm/resources/gift_card_recipients.js +1 -1
- package/lib/esm/resources/gift_cards.js +1 -1
- package/lib/esm/resources/google_geocoders.js +1 -1
- package/lib/esm/resources/imports.js +1 -1
- package/lib/esm/resources/in_stock_subscriptions.js +1 -1
- package/lib/esm/resources/inventory_models.js +1 -1
- package/lib/esm/resources/inventory_return_locations.js +1 -1
- package/lib/esm/resources/inventory_stock_locations.js +1 -1
- package/lib/esm/resources/klarna_gateways.js +1 -1
- package/lib/esm/resources/klarna_payments.js +1 -1
- package/lib/esm/resources/line_item_options.js +1 -1
- package/lib/esm/resources/line_items.js +1 -1
- package/lib/esm/resources/manual_gateways.js +1 -1
- package/lib/esm/resources/manual_tax_calculators.js +1 -1
- package/lib/esm/resources/markets.js +1 -1
- package/lib/esm/resources/merchants.js +1 -1
- package/lib/esm/resources/order_amount_promotion_rules.js +1 -1
- package/lib/esm/resources/order_copies.js +1 -1
- package/lib/esm/resources/order_factories.js +1 -1
- package/lib/esm/resources/order_subscription_items.js +1 -1
- package/lib/esm/resources/order_subscriptions.js +1 -1
- package/lib/esm/resources/order_validation_rules.js +1 -1
- package/lib/esm/resources/orders.js +1 -1
- package/lib/esm/resources/organization.js +1 -1
- package/lib/esm/resources/packages.js +1 -1
- package/lib/esm/resources/parcel_line_items.js +1 -1
- package/lib/esm/resources/parcels.js +1 -1
- package/lib/esm/resources/payment_gateways.js +1 -1
- package/lib/esm/resources/payment_methods.js +1 -1
- package/lib/esm/resources/payment_options.js +1 -1
- package/lib/esm/resources/paypal_gateways.js +1 -1
- package/lib/esm/resources/paypal_payments.js +1 -1
- package/lib/esm/resources/percentage_discount_promotions.js +1 -1
- package/lib/esm/resources/price_frequency_tiers.js +1 -1
- package/lib/esm/resources/price_lists.js +1 -1
- package/lib/esm/resources/price_tiers.js +1 -1
- package/lib/esm/resources/price_volume_tiers.js +1 -1
- package/lib/esm/resources/prices.js +1 -1
- package/lib/esm/resources/promotion_rules.js +1 -1
- package/lib/esm/resources/promotions.js +1 -1
- package/lib/esm/resources/recurring_order_copies.js +1 -1
- package/lib/esm/resources/refunds.js +1 -1
- package/lib/esm/resources/reserved_stocks.js +1 -1
- package/lib/esm/resources/resource_errors.js +1 -1
- package/lib/esm/resources/return_line_items.js +1 -1
- package/lib/esm/resources/returns.js +1 -1
- package/lib/esm/resources/satispay_gateways.js +1 -1
- package/lib/esm/resources/satispay_payments.js +1 -1
- package/lib/esm/resources/shipments.js +1 -1
- package/lib/esm/resources/shipping_categories.js +1 -1
- package/lib/esm/resources/shipping_method_tiers.js +1 -1
- package/lib/esm/resources/shipping_methods.js +1 -1
- package/lib/esm/resources/shipping_weight_tiers.js +1 -1
- package/lib/esm/resources/shipping_zones.js +1 -1
- package/lib/esm/resources/sku_list_items.js +1 -1
- package/lib/esm/resources/sku_list_promotion_rules.js +1 -1
- package/lib/esm/resources/sku_lists.js +1 -1
- package/lib/esm/resources/sku_options.js +1 -1
- package/lib/esm/resources/skus.js +1 -1
- package/lib/esm/resources/stock_items.js +1 -1
- package/lib/esm/resources/stock_line_items.js +1 -1
- package/lib/esm/resources/stock_locations.js +1 -1
- package/lib/esm/resources/stock_reservations.js +1 -1
- package/lib/esm/resources/stock_transfers.js +1 -1
- package/lib/esm/resources/stripe_gateways.js +1 -1
- package/lib/esm/resources/stripe_payments.js +1 -1
- package/lib/esm/resources/subscription_models.js +1 -1
- package/lib/esm/resources/tags.js +1 -1
- package/lib/esm/resources/tax_calculators.js +1 -1
- package/lib/esm/resources/tax_categories.js +1 -1
- package/lib/esm/resources/tax_rules.js +1 -1
- package/lib/esm/resources/taxjar_accounts.js +1 -1
- package/lib/esm/resources/transactions.js +1 -1
- package/lib/esm/resources/versions.js +1 -1
- package/lib/esm/resources/voids.js +1 -1
- package/lib/esm/resources/webhooks.js +1 -1
- package/lib/esm/resources/wire_transfers.js +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
package/lib/esm/commercelayer.js
CHANGED
@@ -1,15 +1,3 @@
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
6
|
-
};
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
11
|
-
};
|
12
|
-
var _CommerceLayerClient_adapter, _CommerceLayerClient_organization;
|
13
1
|
import * as api from './api';
|
14
2
|
import { CommerceLayerStatic } from './static';
|
15
3
|
import ResourceAdapter from './resource';
|
@@ -19,147 +7,271 @@ const debug = Debug('commercelayer');
|
|
19
7
|
const OPEN_API_SCHEMA_VERSION = '5.1.0';
|
20
8
|
export { OPEN_API_SCHEMA_VERSION };
|
21
9
|
class CommerceLayerClient {
|
10
|
+
// static get openApiSchemaVersion(): string { return OPEN_API_SCHEMA_VERSION }
|
11
|
+
openApiSchemaVersion = OPEN_API_SCHEMA_VERSION;
|
12
|
+
#adapter;
|
13
|
+
#organization;
|
14
|
+
// #environment: ApiMode = sdkConfig.default.environment
|
15
|
+
// ##__CL_RESOURCES_DEF_START__##
|
16
|
+
// ##__CL_RESOURCES_DEF_TEMPLATE:: ##__TAB__####__RESOURCE_TYPE__##: api.##__RESOURCE_CLASS__##
|
17
|
+
addresses;
|
18
|
+
adjustments;
|
19
|
+
adyen_gateways;
|
20
|
+
adyen_payments;
|
21
|
+
application;
|
22
|
+
attachments;
|
23
|
+
authorizations;
|
24
|
+
avalara_accounts;
|
25
|
+
axerve_gateways;
|
26
|
+
axerve_payments;
|
27
|
+
billing_info_validation_rules;
|
28
|
+
bing_geocoders;
|
29
|
+
braintree_gateways;
|
30
|
+
braintree_payments;
|
31
|
+
bundles;
|
32
|
+
buy_x_pay_y_promotions;
|
33
|
+
captures;
|
34
|
+
carrier_accounts;
|
35
|
+
checkout_com_gateways;
|
36
|
+
checkout_com_payments;
|
37
|
+
cleanups;
|
38
|
+
coupon_codes_promotion_rules;
|
39
|
+
coupon_recipients;
|
40
|
+
coupons;
|
41
|
+
custom_promotion_rules;
|
42
|
+
customer_addresses;
|
43
|
+
customer_groups;
|
44
|
+
customer_password_resets;
|
45
|
+
customer_payment_sources;
|
46
|
+
customer_subscriptions;
|
47
|
+
customers;
|
48
|
+
delivery_lead_times;
|
49
|
+
event_callbacks;
|
50
|
+
events;
|
51
|
+
exports;
|
52
|
+
external_gateways;
|
53
|
+
external_payments;
|
54
|
+
external_promotions;
|
55
|
+
external_tax_calculators;
|
56
|
+
fixed_amount_promotions;
|
57
|
+
fixed_price_promotions;
|
58
|
+
free_gift_promotions;
|
59
|
+
free_shipping_promotions;
|
60
|
+
geocoders;
|
61
|
+
gift_card_recipients;
|
62
|
+
gift_cards;
|
63
|
+
google_geocoders;
|
64
|
+
imports;
|
65
|
+
in_stock_subscriptions;
|
66
|
+
inventory_models;
|
67
|
+
inventory_return_locations;
|
68
|
+
inventory_stock_locations;
|
69
|
+
klarna_gateways;
|
70
|
+
klarna_payments;
|
71
|
+
line_item_options;
|
72
|
+
line_items;
|
73
|
+
manual_gateways;
|
74
|
+
manual_tax_calculators;
|
75
|
+
markets;
|
76
|
+
merchants;
|
77
|
+
order_amount_promotion_rules;
|
78
|
+
order_copies;
|
79
|
+
order_factories;
|
80
|
+
order_subscription_items;
|
81
|
+
order_subscriptions;
|
82
|
+
order_validation_rules;
|
83
|
+
orders;
|
84
|
+
organization;
|
85
|
+
packages;
|
86
|
+
parcel_line_items;
|
87
|
+
parcels;
|
88
|
+
payment_gateways;
|
89
|
+
payment_methods;
|
90
|
+
payment_options;
|
91
|
+
paypal_gateways;
|
92
|
+
paypal_payments;
|
93
|
+
percentage_discount_promotions;
|
94
|
+
price_frequency_tiers;
|
95
|
+
price_lists;
|
96
|
+
price_tiers;
|
97
|
+
price_volume_tiers;
|
98
|
+
prices;
|
99
|
+
promotion_rules;
|
100
|
+
promotions;
|
101
|
+
recurring_order_copies;
|
102
|
+
refunds;
|
103
|
+
reserved_stocks;
|
104
|
+
resource_errors;
|
105
|
+
return_line_items;
|
106
|
+
returns;
|
107
|
+
satispay_gateways;
|
108
|
+
satispay_payments;
|
109
|
+
shipments;
|
110
|
+
shipping_categories;
|
111
|
+
shipping_method_tiers;
|
112
|
+
shipping_methods;
|
113
|
+
shipping_weight_tiers;
|
114
|
+
shipping_zones;
|
115
|
+
sku_list_items;
|
116
|
+
sku_list_promotion_rules;
|
117
|
+
sku_lists;
|
118
|
+
sku_options;
|
119
|
+
skus;
|
120
|
+
stock_items;
|
121
|
+
stock_line_items;
|
122
|
+
stock_locations;
|
123
|
+
stock_reservations;
|
124
|
+
stock_transfers;
|
125
|
+
stripe_gateways;
|
126
|
+
stripe_payments;
|
127
|
+
subscription_models;
|
128
|
+
tags;
|
129
|
+
tax_calculators;
|
130
|
+
tax_categories;
|
131
|
+
tax_rules;
|
132
|
+
taxjar_accounts;
|
133
|
+
transactions;
|
134
|
+
versions;
|
135
|
+
voids;
|
136
|
+
webhooks;
|
137
|
+
wire_transfers;
|
22
138
|
// ##__CL_RESOURCES_DEF_STOP__##
|
23
139
|
constructor(config) {
|
24
|
-
// static get openApiSchemaVersion(): string { return OPEN_API_SCHEMA_VERSION }
|
25
|
-
this.openApiSchemaVersion = OPEN_API_SCHEMA_VERSION;
|
26
|
-
_CommerceLayerClient_adapter.set(this, void 0);
|
27
|
-
_CommerceLayerClient_organization.set(this, void 0);
|
28
140
|
debug('new commercelayer instance %O', config);
|
29
|
-
|
30
|
-
|
141
|
+
this.#adapter = new ResourceAdapter(config);
|
142
|
+
this.#organization = config.organization;
|
31
143
|
// this.#environment = 'test'
|
32
144
|
// ##__CL_RESOURCES_INIT_START__##
|
33
145
|
// ##__CL_RESOURCES_INIT_TEMPLATE:: ##__TAB__####__TAB__##this.##__RESOURCE_TYPE__## = new api.##__RESOURCE_CLASS__##(this.#adapter)
|
34
|
-
this.addresses = new api.Addresses(
|
35
|
-
this.adjustments = new api.Adjustments(
|
36
|
-
this.adyen_gateways = new api.AdyenGateways(
|
37
|
-
this.adyen_payments = new api.AdyenPayments(
|
38
|
-
this.application = new api.Applications(
|
39
|
-
this.attachments = new api.Attachments(
|
40
|
-
this.authorizations = new api.Authorizations(
|
41
|
-
this.avalara_accounts = new api.AvalaraAccounts(
|
42
|
-
this.axerve_gateways = new api.AxerveGateways(
|
43
|
-
this.axerve_payments = new api.AxervePayments(
|
44
|
-
this.billing_info_validation_rules = new api.BillingInfoValidationRules(
|
45
|
-
this.bing_geocoders = new api.BingGeocoders(
|
46
|
-
this.braintree_gateways = new api.BraintreeGateways(
|
47
|
-
this.braintree_payments = new api.BraintreePayments(
|
48
|
-
this.bundles = new api.Bundles(
|
49
|
-
this.buy_x_pay_y_promotions = new api.BuyXPayYPromotions(
|
50
|
-
this.captures = new api.Captures(
|
51
|
-
this.carrier_accounts = new api.CarrierAccounts(
|
52
|
-
this.checkout_com_gateways = new api.CheckoutComGateways(
|
53
|
-
this.checkout_com_payments = new api.CheckoutComPayments(
|
54
|
-
this.cleanups = new api.Cleanups(
|
55
|
-
this.coupon_codes_promotion_rules = new api.CouponCodesPromotionRules(
|
56
|
-
this.coupon_recipients = new api.CouponRecipients(
|
57
|
-
this.coupons = new api.Coupons(
|
58
|
-
this.custom_promotion_rules = new api.CustomPromotionRules(
|
59
|
-
this.customer_addresses = new api.CustomerAddresses(
|
60
|
-
this.customer_groups = new api.CustomerGroups(
|
61
|
-
this.customer_password_resets = new api.CustomerPasswordResets(
|
62
|
-
this.customer_payment_sources = new api.CustomerPaymentSources(
|
63
|
-
this.customer_subscriptions = new api.CustomerSubscriptions(
|
64
|
-
this.customers = new api.Customers(
|
65
|
-
this.delivery_lead_times = new api.DeliveryLeadTimes(
|
66
|
-
this.event_callbacks = new api.EventCallbacks(
|
67
|
-
this.events = new api.Events(
|
68
|
-
this.exports = new api.Exports(
|
69
|
-
this.external_gateways = new api.ExternalGateways(
|
70
|
-
this.external_payments = new api.ExternalPayments(
|
71
|
-
this.external_promotions = new api.ExternalPromotions(
|
72
|
-
this.external_tax_calculators = new api.ExternalTaxCalculators(
|
73
|
-
this.fixed_amount_promotions = new api.FixedAmountPromotions(
|
74
|
-
this.fixed_price_promotions = new api.FixedPricePromotions(
|
75
|
-
this.free_gift_promotions = new api.FreeGiftPromotions(
|
76
|
-
this.free_shipping_promotions = new api.FreeShippingPromotions(
|
77
|
-
this.geocoders = new api.Geocoders(
|
78
|
-
this.gift_card_recipients = new api.GiftCardRecipients(
|
79
|
-
this.gift_cards = new api.GiftCards(
|
80
|
-
this.google_geocoders = new api.GoogleGeocoders(
|
81
|
-
this.imports = new api.Imports(
|
82
|
-
this.in_stock_subscriptions = new api.InStockSubscriptions(
|
83
|
-
this.inventory_models = new api.InventoryModels(
|
84
|
-
this.inventory_return_locations = new api.InventoryReturnLocations(
|
85
|
-
this.inventory_stock_locations = new api.InventoryStockLocations(
|
86
|
-
this.klarna_gateways = new api.KlarnaGateways(
|
87
|
-
this.klarna_payments = new api.KlarnaPayments(
|
88
|
-
this.line_item_options = new api.LineItemOptions(
|
89
|
-
this.line_items = new api.LineItems(
|
90
|
-
this.manual_gateways = new api.ManualGateways(
|
91
|
-
this.manual_tax_calculators = new api.ManualTaxCalculators(
|
92
|
-
this.markets = new api.Markets(
|
93
|
-
this.merchants = new api.Merchants(
|
94
|
-
this.order_amount_promotion_rules = new api.OrderAmountPromotionRules(
|
95
|
-
this.order_copies = new api.OrderCopies(
|
96
|
-
this.order_factories = new api.OrderFactories(
|
97
|
-
this.order_subscription_items = new api.OrderSubscriptionItems(
|
98
|
-
this.order_subscriptions = new api.OrderSubscriptions(
|
99
|
-
this.order_validation_rules = new api.OrderValidationRules(
|
100
|
-
this.orders = new api.Orders(
|
101
|
-
this.organization = new api.Organizations(
|
102
|
-
this.packages = new api.Packages(
|
103
|
-
this.parcel_line_items = new api.ParcelLineItems(
|
104
|
-
this.parcels = new api.Parcels(
|
105
|
-
this.payment_gateways = new api.PaymentGateways(
|
106
|
-
this.payment_methods = new api.PaymentMethods(
|
107
|
-
this.payment_options = new api.PaymentOptions(
|
108
|
-
this.paypal_gateways = new api.PaypalGateways(
|
109
|
-
this.paypal_payments = new api.PaypalPayments(
|
110
|
-
this.percentage_discount_promotions = new api.PercentageDiscountPromotions(
|
111
|
-
this.price_frequency_tiers = new api.PriceFrequencyTiers(
|
112
|
-
this.price_lists = new api.PriceLists(
|
113
|
-
this.price_tiers = new api.PriceTiers(
|
114
|
-
this.price_volume_tiers = new api.PriceVolumeTiers(
|
115
|
-
this.prices = new api.Prices(
|
116
|
-
this.promotion_rules = new api.PromotionRules(
|
117
|
-
this.promotions = new api.Promotions(
|
118
|
-
this.recurring_order_copies = new api.RecurringOrderCopies(
|
119
|
-
this.refunds = new api.Refunds(
|
120
|
-
this.reserved_stocks = new api.ReservedStocks(
|
121
|
-
this.resource_errors = new api.ResourceErrors(
|
122
|
-
this.return_line_items = new api.ReturnLineItems(
|
123
|
-
this.returns = new api.Returns(
|
124
|
-
this.satispay_gateways = new api.SatispayGateways(
|
125
|
-
this.satispay_payments = new api.SatispayPayments(
|
126
|
-
this.shipments = new api.Shipments(
|
127
|
-
this.shipping_categories = new api.ShippingCategories(
|
128
|
-
this.shipping_method_tiers = new api.ShippingMethodTiers(
|
129
|
-
this.shipping_methods = new api.ShippingMethods(
|
130
|
-
this.shipping_weight_tiers = new api.ShippingWeightTiers(
|
131
|
-
this.shipping_zones = new api.ShippingZones(
|
132
|
-
this.sku_list_items = new api.SkuListItems(
|
133
|
-
this.sku_list_promotion_rules = new api.SkuListPromotionRules(
|
134
|
-
this.sku_lists = new api.SkuLists(
|
135
|
-
this.sku_options = new api.SkuOptions(
|
136
|
-
this.skus = new api.Skus(
|
137
|
-
this.stock_items = new api.StockItems(
|
138
|
-
this.stock_line_items = new api.StockLineItems(
|
139
|
-
this.stock_locations = new api.StockLocations(
|
140
|
-
this.stock_reservations = new api.StockReservations(
|
141
|
-
this.stock_transfers = new api.StockTransfers(
|
142
|
-
this.stripe_gateways = new api.StripeGateways(
|
143
|
-
this.stripe_payments = new api.StripePayments(
|
144
|
-
this.subscription_models = new api.SubscriptionModels(
|
145
|
-
this.tags = new api.Tags(
|
146
|
-
this.tax_calculators = new api.TaxCalculators(
|
147
|
-
this.tax_categories = new api.TaxCategories(
|
148
|
-
this.tax_rules = new api.TaxRules(
|
149
|
-
this.taxjar_accounts = new api.TaxjarAccounts(
|
150
|
-
this.transactions = new api.Transactions(
|
151
|
-
this.versions = new api.Versions(
|
152
|
-
this.voids = new api.Voids(
|
153
|
-
this.webhooks = new api.Webhooks(
|
154
|
-
this.wire_transfers = new api.WireTransfers(
|
146
|
+
this.addresses = new api.Addresses(this.#adapter);
|
147
|
+
this.adjustments = new api.Adjustments(this.#adapter);
|
148
|
+
this.adyen_gateways = new api.AdyenGateways(this.#adapter);
|
149
|
+
this.adyen_payments = new api.AdyenPayments(this.#adapter);
|
150
|
+
this.application = new api.Applications(this.#adapter);
|
151
|
+
this.attachments = new api.Attachments(this.#adapter);
|
152
|
+
this.authorizations = new api.Authorizations(this.#adapter);
|
153
|
+
this.avalara_accounts = new api.AvalaraAccounts(this.#adapter);
|
154
|
+
this.axerve_gateways = new api.AxerveGateways(this.#adapter);
|
155
|
+
this.axerve_payments = new api.AxervePayments(this.#adapter);
|
156
|
+
this.billing_info_validation_rules = new api.BillingInfoValidationRules(this.#adapter);
|
157
|
+
this.bing_geocoders = new api.BingGeocoders(this.#adapter);
|
158
|
+
this.braintree_gateways = new api.BraintreeGateways(this.#adapter);
|
159
|
+
this.braintree_payments = new api.BraintreePayments(this.#adapter);
|
160
|
+
this.bundles = new api.Bundles(this.#adapter);
|
161
|
+
this.buy_x_pay_y_promotions = new api.BuyXPayYPromotions(this.#adapter);
|
162
|
+
this.captures = new api.Captures(this.#adapter);
|
163
|
+
this.carrier_accounts = new api.CarrierAccounts(this.#adapter);
|
164
|
+
this.checkout_com_gateways = new api.CheckoutComGateways(this.#adapter);
|
165
|
+
this.checkout_com_payments = new api.CheckoutComPayments(this.#adapter);
|
166
|
+
this.cleanups = new api.Cleanups(this.#adapter);
|
167
|
+
this.coupon_codes_promotion_rules = new api.CouponCodesPromotionRules(this.#adapter);
|
168
|
+
this.coupon_recipients = new api.CouponRecipients(this.#adapter);
|
169
|
+
this.coupons = new api.Coupons(this.#adapter);
|
170
|
+
this.custom_promotion_rules = new api.CustomPromotionRules(this.#adapter);
|
171
|
+
this.customer_addresses = new api.CustomerAddresses(this.#adapter);
|
172
|
+
this.customer_groups = new api.CustomerGroups(this.#adapter);
|
173
|
+
this.customer_password_resets = new api.CustomerPasswordResets(this.#adapter);
|
174
|
+
this.customer_payment_sources = new api.CustomerPaymentSources(this.#adapter);
|
175
|
+
this.customer_subscriptions = new api.CustomerSubscriptions(this.#adapter);
|
176
|
+
this.customers = new api.Customers(this.#adapter);
|
177
|
+
this.delivery_lead_times = new api.DeliveryLeadTimes(this.#adapter);
|
178
|
+
this.event_callbacks = new api.EventCallbacks(this.#adapter);
|
179
|
+
this.events = new api.Events(this.#adapter);
|
180
|
+
this.exports = new api.Exports(this.#adapter);
|
181
|
+
this.external_gateways = new api.ExternalGateways(this.#adapter);
|
182
|
+
this.external_payments = new api.ExternalPayments(this.#adapter);
|
183
|
+
this.external_promotions = new api.ExternalPromotions(this.#adapter);
|
184
|
+
this.external_tax_calculators = new api.ExternalTaxCalculators(this.#adapter);
|
185
|
+
this.fixed_amount_promotions = new api.FixedAmountPromotions(this.#adapter);
|
186
|
+
this.fixed_price_promotions = new api.FixedPricePromotions(this.#adapter);
|
187
|
+
this.free_gift_promotions = new api.FreeGiftPromotions(this.#adapter);
|
188
|
+
this.free_shipping_promotions = new api.FreeShippingPromotions(this.#adapter);
|
189
|
+
this.geocoders = new api.Geocoders(this.#adapter);
|
190
|
+
this.gift_card_recipients = new api.GiftCardRecipients(this.#adapter);
|
191
|
+
this.gift_cards = new api.GiftCards(this.#adapter);
|
192
|
+
this.google_geocoders = new api.GoogleGeocoders(this.#adapter);
|
193
|
+
this.imports = new api.Imports(this.#adapter);
|
194
|
+
this.in_stock_subscriptions = new api.InStockSubscriptions(this.#adapter);
|
195
|
+
this.inventory_models = new api.InventoryModels(this.#adapter);
|
196
|
+
this.inventory_return_locations = new api.InventoryReturnLocations(this.#adapter);
|
197
|
+
this.inventory_stock_locations = new api.InventoryStockLocations(this.#adapter);
|
198
|
+
this.klarna_gateways = new api.KlarnaGateways(this.#adapter);
|
199
|
+
this.klarna_payments = new api.KlarnaPayments(this.#adapter);
|
200
|
+
this.line_item_options = new api.LineItemOptions(this.#adapter);
|
201
|
+
this.line_items = new api.LineItems(this.#adapter);
|
202
|
+
this.manual_gateways = new api.ManualGateways(this.#adapter);
|
203
|
+
this.manual_tax_calculators = new api.ManualTaxCalculators(this.#adapter);
|
204
|
+
this.markets = new api.Markets(this.#adapter);
|
205
|
+
this.merchants = new api.Merchants(this.#adapter);
|
206
|
+
this.order_amount_promotion_rules = new api.OrderAmountPromotionRules(this.#adapter);
|
207
|
+
this.order_copies = new api.OrderCopies(this.#adapter);
|
208
|
+
this.order_factories = new api.OrderFactories(this.#adapter);
|
209
|
+
this.order_subscription_items = new api.OrderSubscriptionItems(this.#adapter);
|
210
|
+
this.order_subscriptions = new api.OrderSubscriptions(this.#adapter);
|
211
|
+
this.order_validation_rules = new api.OrderValidationRules(this.#adapter);
|
212
|
+
this.orders = new api.Orders(this.#adapter);
|
213
|
+
this.organization = new api.Organizations(this.#adapter);
|
214
|
+
this.packages = new api.Packages(this.#adapter);
|
215
|
+
this.parcel_line_items = new api.ParcelLineItems(this.#adapter);
|
216
|
+
this.parcels = new api.Parcels(this.#adapter);
|
217
|
+
this.payment_gateways = new api.PaymentGateways(this.#adapter);
|
218
|
+
this.payment_methods = new api.PaymentMethods(this.#adapter);
|
219
|
+
this.payment_options = new api.PaymentOptions(this.#adapter);
|
220
|
+
this.paypal_gateways = new api.PaypalGateways(this.#adapter);
|
221
|
+
this.paypal_payments = new api.PaypalPayments(this.#adapter);
|
222
|
+
this.percentage_discount_promotions = new api.PercentageDiscountPromotions(this.#adapter);
|
223
|
+
this.price_frequency_tiers = new api.PriceFrequencyTiers(this.#adapter);
|
224
|
+
this.price_lists = new api.PriceLists(this.#adapter);
|
225
|
+
this.price_tiers = new api.PriceTiers(this.#adapter);
|
226
|
+
this.price_volume_tiers = new api.PriceVolumeTiers(this.#adapter);
|
227
|
+
this.prices = new api.Prices(this.#adapter);
|
228
|
+
this.promotion_rules = new api.PromotionRules(this.#adapter);
|
229
|
+
this.promotions = new api.Promotions(this.#adapter);
|
230
|
+
this.recurring_order_copies = new api.RecurringOrderCopies(this.#adapter);
|
231
|
+
this.refunds = new api.Refunds(this.#adapter);
|
232
|
+
this.reserved_stocks = new api.ReservedStocks(this.#adapter);
|
233
|
+
this.resource_errors = new api.ResourceErrors(this.#adapter);
|
234
|
+
this.return_line_items = new api.ReturnLineItems(this.#adapter);
|
235
|
+
this.returns = new api.Returns(this.#adapter);
|
236
|
+
this.satispay_gateways = new api.SatispayGateways(this.#adapter);
|
237
|
+
this.satispay_payments = new api.SatispayPayments(this.#adapter);
|
238
|
+
this.shipments = new api.Shipments(this.#adapter);
|
239
|
+
this.shipping_categories = new api.ShippingCategories(this.#adapter);
|
240
|
+
this.shipping_method_tiers = new api.ShippingMethodTiers(this.#adapter);
|
241
|
+
this.shipping_methods = new api.ShippingMethods(this.#adapter);
|
242
|
+
this.shipping_weight_tiers = new api.ShippingWeightTiers(this.#adapter);
|
243
|
+
this.shipping_zones = new api.ShippingZones(this.#adapter);
|
244
|
+
this.sku_list_items = new api.SkuListItems(this.#adapter);
|
245
|
+
this.sku_list_promotion_rules = new api.SkuListPromotionRules(this.#adapter);
|
246
|
+
this.sku_lists = new api.SkuLists(this.#adapter);
|
247
|
+
this.sku_options = new api.SkuOptions(this.#adapter);
|
248
|
+
this.skus = new api.Skus(this.#adapter);
|
249
|
+
this.stock_items = new api.StockItems(this.#adapter);
|
250
|
+
this.stock_line_items = new api.StockLineItems(this.#adapter);
|
251
|
+
this.stock_locations = new api.StockLocations(this.#adapter);
|
252
|
+
this.stock_reservations = new api.StockReservations(this.#adapter);
|
253
|
+
this.stock_transfers = new api.StockTransfers(this.#adapter);
|
254
|
+
this.stripe_gateways = new api.StripeGateways(this.#adapter);
|
255
|
+
this.stripe_payments = new api.StripePayments(this.#adapter);
|
256
|
+
this.subscription_models = new api.SubscriptionModels(this.#adapter);
|
257
|
+
this.tags = new api.Tags(this.#adapter);
|
258
|
+
this.tax_calculators = new api.TaxCalculators(this.#adapter);
|
259
|
+
this.tax_categories = new api.TaxCategories(this.#adapter);
|
260
|
+
this.tax_rules = new api.TaxRules(this.#adapter);
|
261
|
+
this.taxjar_accounts = new api.TaxjarAccounts(this.#adapter);
|
262
|
+
this.transactions = new api.Transactions(this.#adapter);
|
263
|
+
this.versions = new api.Versions(this.#adapter);
|
264
|
+
this.voids = new api.Voids(this.#adapter);
|
265
|
+
this.webhooks = new api.Webhooks(this.#adapter);
|
266
|
+
this.wire_transfers = new api.WireTransfers(this.#adapter);
|
155
267
|
// ##__CL_RESOURCES_INIT_STOP__##
|
156
268
|
}
|
157
|
-
get currentOrganization() { return
|
269
|
+
get currentOrganization() { return this.#organization; }
|
158
270
|
// get currentAccessToken(): string { return this.#adapter?.clientInstance?.currentAccessToken}
|
159
271
|
// get environment(): ApiMode { return this.#environment }
|
160
272
|
localConfig(config) {
|
161
273
|
if (config.organization)
|
162
|
-
|
274
|
+
this.#organization = config.organization;
|
163
275
|
}
|
164
276
|
config(config) {
|
165
277
|
debug('config %o', config);
|
@@ -169,7 +281,7 @@ class CommerceLayerClient {
|
|
169
281
|
// To rebuild baseUrl in client in case only the domain is defined
|
170
282
|
if (!config.organization)
|
171
283
|
config.organization = this.currentOrganization;
|
172
|
-
|
284
|
+
this.#adapter.config(config);
|
173
285
|
return this;
|
174
286
|
}
|
175
287
|
resources() {
|
@@ -186,13 +298,13 @@ class CommerceLayerClient {
|
|
186
298
|
return CommerceLayerStatic.isApiError(error);
|
187
299
|
}
|
188
300
|
addRequestInterceptor(onFulfilled, onRejected) {
|
189
|
-
return
|
301
|
+
return this.#adapter.interceptors.request.use(onFulfilled, onRejected);
|
190
302
|
}
|
191
303
|
addResponseInterceptor(onFulfilled, onRejected) {
|
192
|
-
return
|
304
|
+
return this.#adapter.interceptors.response.use(onFulfilled, onRejected);
|
193
305
|
}
|
194
306
|
removeInterceptor(type, id) {
|
195
|
-
|
307
|
+
this.#adapter.interceptors[type].eject(id);
|
196
308
|
}
|
197
309
|
addRawResponseReader(options) {
|
198
310
|
const reader = {
|
@@ -201,8 +313,8 @@ class CommerceLayerClient {
|
|
201
313
|
headers: undefined,
|
202
314
|
};
|
203
315
|
function rawResponseInterceptor(response) {
|
204
|
-
reader.rawResponse = response
|
205
|
-
if (options
|
316
|
+
reader.rawResponse = response?.data;
|
317
|
+
if (options?.headers)
|
206
318
|
reader.headers = response.headers;
|
207
319
|
return response;
|
208
320
|
}
|
@@ -211,12 +323,11 @@ class CommerceLayerClient {
|
|
211
323
|
return reader;
|
212
324
|
}
|
213
325
|
removeRawResponseReader(reader) {
|
214
|
-
const id = (typeof reader === 'number') ? reader : reader
|
326
|
+
const id = (typeof reader === 'number') ? reader : reader?.id;
|
215
327
|
if (id && (id >= 0))
|
216
328
|
this.removeInterceptor('response', id);
|
217
329
|
}
|
218
330
|
}
|
219
|
-
_CommerceLayerClient_adapter = new WeakMap(), _CommerceLayerClient_organization = new WeakMap();
|
220
331
|
const CommerceLayer = (config) => {
|
221
332
|
return new CommerceLayerClient(config);
|
222
333
|
};
|
package/lib/esm/common.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { resourceList } from './api';
|
2
2
|
const isResourceId = (resource) => {
|
3
|
-
return (
|
3
|
+
return (resource?.type && resource.id) && resourceList.includes(resource.type);
|
4
4
|
};
|
5
5
|
const isResourceType = (resource) => {
|
6
6
|
return resource && (typeof resource.type !== 'undefined') && resource.type && resourceList.includes(resource.type);
|
package/lib/esm/error.js
CHANGED
@@ -9,31 +9,36 @@ var ErrorType;
|
|
9
9
|
ErrorType["GENERIC"] = "generic";
|
10
10
|
})(ErrorType || (ErrorType = {}));
|
11
11
|
class SdkError extends Error {
|
12
|
+
static NAME = 'SdkError';
|
12
13
|
static isSdkError(error) {
|
13
14
|
return error && [SdkError.NAME, ApiError.NAME].includes(error.name) && Object.values(ErrorType).includes(error.type);
|
14
15
|
}
|
16
|
+
type;
|
17
|
+
code;
|
18
|
+
source;
|
19
|
+
request;
|
15
20
|
constructor(error) {
|
16
21
|
super(error.message);
|
17
22
|
this.name = SdkError.NAME; // this.constructor.name
|
18
23
|
this.type = error.type || ErrorType.GENERIC;
|
19
24
|
}
|
20
25
|
}
|
21
|
-
SdkError.NAME = 'SdkError';
|
22
26
|
class ApiError extends SdkError {
|
27
|
+
static NAME = 'ApiError';
|
23
28
|
static isApiError(error) {
|
24
29
|
return SdkError.isSdkError(error) && (error.name === ApiError.NAME) && (error.type === ErrorType.RESPONSE);
|
25
30
|
}
|
31
|
+
errors = [];
|
32
|
+
status;
|
33
|
+
statusText;
|
26
34
|
constructor(error) {
|
27
35
|
super({ ...error, type: ErrorType.RESPONSE });
|
28
|
-
this.errors = [];
|
29
36
|
this.name = ApiError.NAME; // this.constructor.name
|
30
37
|
}
|
31
38
|
first() {
|
32
|
-
|
33
|
-
return (((_a = this.errors) === null || _a === void 0 ? void 0 : _a.length) > 0) ? this.errors[0] : undefined;
|
39
|
+
return (this.errors?.length > 0) ? this.errors[0] : undefined;
|
34
40
|
}
|
35
41
|
}
|
36
|
-
ApiError.NAME = 'ApiError';
|
37
42
|
const handleError = (error) => {
|
38
43
|
let sdkError = new SdkError({ message: error.message });
|
39
44
|
if (axios.isAxiosError(error)) {
|
package/lib/esm/interceptor.d.ts
CHANGED
@@ -6,14 +6,14 @@ type InterceptorManager = {
|
|
6
6
|
type RequestObj = AxiosRequestConfig;
|
7
7
|
type RequestInterceptor = (request: RequestObj) => RequestObj | Promise<RequestObj>;
|
8
8
|
type ResponseObj = AxiosResponse;
|
9
|
-
type ResponseInterceptor = (response: ResponseObj) => ResponseObj
|
9
|
+
type ResponseInterceptor = (response: ResponseObj) => ResponseObj;
|
10
10
|
type ApiHeadersList = 'x-ratelimit-limit' | 'x-ratelimit-count' | 'x-ratelimit-period' | 'x-ratelimit-interval' | 'x-ratelimit-remaining';
|
11
11
|
type ApiHeaders = {
|
12
12
|
[key in ApiHeadersList]: string | number | boolean;
|
13
13
|
};
|
14
14
|
type HeadersObj = (AxiosResponseHeaders | RawAxiosResponseHeaders) & ApiHeaders;
|
15
15
|
type ErrorObj = AxiosError;
|
16
|
-
type ErrorInterceptor = (error: ErrorObj) => ErrorObj
|
16
|
+
type ErrorInterceptor = (error: ErrorObj) => ErrorObj;
|
17
17
|
type InterceptorType = 'request' | 'response';
|
18
18
|
export type { InterceptorManager, RequestInterceptor, ResponseInterceptor, ErrorInterceptor, InterceptorType };
|
19
19
|
export type { RequestObj, ResponseObj, ErrorObj, HeadersObj };
|