@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/query.js
CHANGED
@@ -1,83 +1,20 @@
|
|
1
|
-
|
2
|
-
|
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
|
-
});
|
1
|
+
import { SdkError, ErrorType } from './error';
|
2
|
+
import Debug from './debug';
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
var debuggerFactory = (_namespace) => debuggerFunction;
|
12
|
-
try {
|
13
|
-
const debugModule = __require("debug");
|
14
|
-
if (debugModule && typeof debugModule === "function") debuggerFactory = debugModule;
|
15
|
-
} catch (error) {
|
16
|
-
}
|
17
|
-
var debugPrefix = "clsdk";
|
18
|
-
var debug = (namespace) => {
|
19
|
-
return debuggerFactory(`${debugPrefix}:${namespace}`);
|
20
|
-
};
|
21
|
-
var debug_default = debug;
|
22
|
-
|
23
|
-
// src/error.ts
|
24
|
-
var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
|
25
|
-
ErrorType2["CLIENT"] = "client";
|
26
|
-
ErrorType2["REQUEST"] = "request";
|
27
|
-
ErrorType2["RESPONSE"] = "response";
|
28
|
-
ErrorType2["CANCEL"] = "cancel";
|
29
|
-
ErrorType2["PARSE"] = "parse";
|
30
|
-
ErrorType2["TIMEOUT"] = "timeout";
|
31
|
-
ErrorType2["TOKEN_REFRESH"] = "token-refresh";
|
32
|
-
return ErrorType2;
|
33
|
-
})(ErrorType || {});
|
34
|
-
var SdkError = class _SdkError extends Error {
|
35
|
-
static NAME = "SdkError";
|
36
|
-
static isSdkError(error) {
|
37
|
-
return error && [_SdkError.NAME, ApiError.NAME].includes(error.name) && Object.values(ErrorType).includes(error.type);
|
38
|
-
}
|
39
|
-
type;
|
40
|
-
code;
|
41
|
-
source;
|
42
|
-
constructor(error) {
|
43
|
-
super(error.message);
|
44
|
-
this.name = _SdkError.NAME;
|
45
|
-
this.type = error.type || "client" /* CLIENT */;
|
46
|
-
}
|
47
|
-
};
|
48
|
-
var ApiError = class _ApiError extends SdkError {
|
49
|
-
static NAME = "ApiError";
|
50
|
-
static isApiError(error) {
|
51
|
-
return SdkError.isSdkError(error) && error.name === _ApiError.NAME && error.type === "response" /* RESPONSE */;
|
52
|
-
}
|
53
|
-
errors = [];
|
54
|
-
status;
|
55
|
-
statusText;
|
56
|
-
// constructor(error: SdkError)
|
57
|
-
constructor(error) {
|
58
|
-
super({ ...error, type: "response" /* RESPONSE */ });
|
59
|
-
this.name = _ApiError.NAME;
|
60
|
-
}
|
61
|
-
first() {
|
62
|
-
return this.errors?.length > 0 ? this.errors[0] : void 0;
|
63
|
-
}
|
64
|
-
};
|
65
|
-
|
66
|
-
// src/query.ts
|
67
|
-
var debug2 = debug_default("query");
|
68
|
-
var arrayFilters = ["_any", "_all", "_in", "_not_in_or_null"];
|
69
|
-
var isArrayFilter = (filter) => {
|
4
|
+
const debug = Debug("query");
|
5
|
+
const arrayFilters = ["_any", "_all", "_in", "_not_in_or_null"];
|
6
|
+
const isArrayFilter = (filter) => {
|
70
7
|
return arrayFilters.some((f) => filter.endsWith(f));
|
71
8
|
};
|
72
|
-
|
73
|
-
|
9
|
+
const objectFilters = ["_jcont"];
|
10
|
+
const isObjectFilter = (filter) => {
|
74
11
|
return objectFilters.some((f) => filter.endsWith(f));
|
75
12
|
};
|
76
|
-
|
13
|
+
const isParamsList = (params) => {
|
77
14
|
return params && (params.filters || params.pageNumber || params.pageSize || params.sort);
|
78
15
|
};
|
79
|
-
|
80
|
-
|
16
|
+
const generateQueryStringParams = (params, res) => {
|
17
|
+
debug("generate query string params: %O, %O", params, res);
|
81
18
|
const qp = {};
|
82
19
|
if (!params) return qp;
|
83
20
|
if (params.include) qp.include = params.include.join(",");
|
@@ -98,20 +35,20 @@ var generateQueryStringParams = (params, res) => {
|
|
98
35
|
Object.entries(params.filters).forEach(([p, v]) => {
|
99
36
|
let val;
|
100
37
|
if (Array.isArray(v)) {
|
101
|
-
if (!isArrayFilter(p)) throw new SdkError({ message: `Incorrect filter [${p}]: Array value is supported only for the following filters: ${arrayFilters.join(", ")}`, type:
|
38
|
+
if (!isArrayFilter(p)) throw new SdkError({ message: `Incorrect filter [${p}]: Array value is supported only for the following filters: ${arrayFilters.join(", ")}`, type: ErrorType.REQUEST });
|
102
39
|
val = v.join(",");
|
103
40
|
} else if (typeof v === "object") {
|
104
|
-
if (!isObjectFilter(p)) throw new SdkError({ message: `Incorrect filter [${p}]: Object value is supported only for the following filters: ${objectFilters.join(", ")}`, type:
|
41
|
+
if (!isObjectFilter(p)) throw new SdkError({ message: `Incorrect filter [${p}]: Object value is supported only for the following filters: ${objectFilters.join(", ")}`, type: ErrorType.REQUEST });
|
105
42
|
val = JSON.stringify(v);
|
106
43
|
} else val = String(v);
|
107
44
|
qp[`filter[q][${p}]`] = val;
|
108
45
|
});
|
109
46
|
}
|
110
47
|
}
|
111
|
-
|
48
|
+
debug("query string params: %O", qp);
|
112
49
|
return qp;
|
113
50
|
};
|
114
|
-
|
51
|
+
const generateSearchString = (params, questionMark = true) => {
|
115
52
|
if (!params || Object.keys(params).length === 0) return "";
|
116
53
|
return `${questionMark ? "?" : ""}${Object.entries(params).map(([key, val]) => `${key}=${String(val)}`).join("&")}`;
|
117
54
|
};
|