@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.
Files changed (293) hide show
  1. package/lib/api.cjs +791 -7460
  2. package/lib/api.js +131 -7331
  3. package/lib/client.cjs +31 -215
  4. package/lib/client.js +23 -212
  5. package/lib/commercelayer.cjs +30 -778
  6. package/lib/commercelayer.js +22 -774
  7. package/lib/common.cjs +6 -143
  8. package/lib/common.js +4 -141
  9. package/lib/config.cjs +1 -2
  10. package/lib/config.js +1 -2
  11. package/lib/debug.cjs +5 -13
  12. package/lib/debug.js +5 -13
  13. package/lib/enum.cjs +8 -9
  14. package/lib/enum.js +8 -9
  15. package/lib/error.cjs +15 -67
  16. package/lib/error.js +14 -66
  17. package/lib/fetch.cjs +13 -72
  18. package/lib/fetch.js +11 -74
  19. package/lib/index.cjs +22 -8104
  20. package/lib/index.js +3 -7977
  21. package/lib/jsonapi.cjs +20 -188
  22. package/lib/jsonapi.js +13 -186
  23. package/lib/query.cjs +16 -75
  24. package/lib/query.js +14 -77
  25. package/lib/resource.cjs +57 -651
  26. package/lib/resource.js +37 -637
  27. package/lib/resources/addresses.cjs +11 -801
  28. package/lib/resources/addresses.js +11 -801
  29. package/lib/resources/adjustments.cjs +9 -799
  30. package/lib/resources/adjustments.js +9 -799
  31. package/lib/resources/adyen_gateways.cjs +9 -799
  32. package/lib/resources/adyen_gateways.js +9 -799
  33. package/lib/resources/adyen_payments.cjs +11 -801
  34. package/lib/resources/adyen_payments.js +11 -801
  35. package/lib/resources/applications.cjs +6 -788
  36. package/lib/resources/applications.js +6 -788
  37. package/lib/resources/attachments.cjs +9 -799
  38. package/lib/resources/attachments.js +9 -799
  39. package/lib/resources/authorizations.cjs +12 -802
  40. package/lib/resources/authorizations.js +12 -802
  41. package/lib/resources/avalara_accounts.cjs +9 -799
  42. package/lib/resources/avalara_accounts.js +9 -799
  43. package/lib/resources/axerve_gateways.cjs +9 -799
  44. package/lib/resources/axerve_gateways.js +9 -799
  45. package/lib/resources/axerve_payments.cjs +10 -800
  46. package/lib/resources/axerve_payments.js +10 -800
  47. package/lib/resources/bing_geocoders.cjs +9 -799
  48. package/lib/resources/bing_geocoders.js +9 -799
  49. package/lib/resources/braintree_gateways.cjs +9 -799
  50. package/lib/resources/braintree_gateways.js +9 -799
  51. package/lib/resources/braintree_payments.cjs +9 -799
  52. package/lib/resources/braintree_payments.js +9 -799
  53. package/lib/resources/bundles.cjs +13 -803
  54. package/lib/resources/bundles.js +13 -803
  55. package/lib/resources/buy_x_pay_y_promotions.cjs +13 -803
  56. package/lib/resources/buy_x_pay_y_promotions.js +13 -803
  57. package/lib/resources/captures.cjs +11 -801
  58. package/lib/resources/captures.js +11 -801
  59. package/lib/resources/carrier_accounts.cjs +9 -799
  60. package/lib/resources/carrier_accounts.js +9 -799
  61. package/lib/resources/checkout_com_gateways.cjs +9 -799
  62. package/lib/resources/checkout_com_gateways.js +9 -799
  63. package/lib/resources/checkout_com_payments.cjs +11 -801
  64. package/lib/resources/checkout_com_payments.js +11 -801
  65. package/lib/resources/cleanups.cjs +10 -800
  66. package/lib/resources/cleanups.js +10 -800
  67. package/lib/resources/coupon_codes_promotion_rules.cjs +9 -799
  68. package/lib/resources/coupon_codes_promotion_rules.js +9 -799
  69. package/lib/resources/coupon_recipients.cjs +9 -799
  70. package/lib/resources/coupon_recipients.js +9 -799
  71. package/lib/resources/coupons.cjs +11 -801
  72. package/lib/resources/coupons.js +11 -801
  73. package/lib/resources/custom_promotion_rules.cjs +9 -799
  74. package/lib/resources/custom_promotion_rules.js +9 -799
  75. package/lib/resources/customer_addresses.cjs +9 -799
  76. package/lib/resources/customer_addresses.js +9 -799
  77. package/lib/resources/customer_groups.cjs +9 -799
  78. package/lib/resources/customer_groups.js +9 -799
  79. package/lib/resources/customer_password_resets.cjs +10 -800
  80. package/lib/resources/customer_password_resets.js +10 -800
  81. package/lib/resources/customer_payment_sources.cjs +9 -799
  82. package/lib/resources/customer_payment_sources.js +9 -799
  83. package/lib/resources/customer_subscriptions.cjs +9 -799
  84. package/lib/resources/customer_subscriptions.js +9 -799
  85. package/lib/resources/customers.cjs +11 -801
  86. package/lib/resources/customers.js +11 -801
  87. package/lib/resources/delivery_lead_times.cjs +9 -799
  88. package/lib/resources/delivery_lead_times.js +9 -799
  89. package/lib/resources/discount_engine_items.cjs +6 -796
  90. package/lib/resources/discount_engine_items.js +6 -796
  91. package/lib/resources/discount_engines.cjs +6 -796
  92. package/lib/resources/discount_engines.js +6 -796
  93. package/lib/resources/easypost_pickups.cjs +10 -800
  94. package/lib/resources/easypost_pickups.js +10 -800
  95. package/lib/resources/event_callbacks.cjs +6 -796
  96. package/lib/resources/event_callbacks.js +6 -796
  97. package/lib/resources/events.cjs +8 -798
  98. package/lib/resources/events.js +8 -798
  99. package/lib/resources/exports.cjs +10 -800
  100. package/lib/resources/exports.js +10 -800
  101. package/lib/resources/external_gateways.cjs +10 -800
  102. package/lib/resources/external_gateways.js +10 -800
  103. package/lib/resources/external_payments.cjs +9 -799
  104. package/lib/resources/external_payments.js +9 -799
  105. package/lib/resources/external_promotions.cjs +14 -804
  106. package/lib/resources/external_promotions.js +14 -804
  107. package/lib/resources/external_tax_calculators.cjs +10 -800
  108. package/lib/resources/external_tax_calculators.js +10 -800
  109. package/lib/resources/fixed_amount_promotions.cjs +13 -803
  110. package/lib/resources/fixed_amount_promotions.js +13 -803
  111. package/lib/resources/fixed_price_promotions.cjs +13 -803
  112. package/lib/resources/fixed_price_promotions.js +13 -803
  113. package/lib/resources/flex_promotions.cjs +13 -803
  114. package/lib/resources/flex_promotions.js +13 -803
  115. package/lib/resources/free_gift_promotions.cjs +13 -803
  116. package/lib/resources/free_gift_promotions.js +13 -803
  117. package/lib/resources/free_shipping_promotions.cjs +13 -803
  118. package/lib/resources/free_shipping_promotions.js +13 -803
  119. package/lib/resources/geocoders.cjs +6 -796
  120. package/lib/resources/geocoders.js +6 -796
  121. package/lib/resources/gift_card_recipients.cjs +9 -799
  122. package/lib/resources/gift_card_recipients.js +9 -799
  123. package/lib/resources/gift_cards.cjs +15 -805
  124. package/lib/resources/gift_cards.js +15 -805
  125. package/lib/resources/google_geocoders.cjs +9 -799
  126. package/lib/resources/google_geocoders.js +9 -799
  127. package/lib/resources/imports.cjs +10 -800
  128. package/lib/resources/imports.js +10 -800
  129. package/lib/resources/in_stock_subscriptions.cjs +11 -801
  130. package/lib/resources/in_stock_subscriptions.js +11 -801
  131. package/lib/resources/inventory_models.cjs +9 -799
  132. package/lib/resources/inventory_models.js +9 -799
  133. package/lib/resources/inventory_return_locations.cjs +9 -799
  134. package/lib/resources/inventory_return_locations.js +9 -799
  135. package/lib/resources/inventory_stock_locations.cjs +9 -799
  136. package/lib/resources/inventory_stock_locations.js +9 -799
  137. package/lib/resources/klarna_gateways.cjs +9 -799
  138. package/lib/resources/klarna_gateways.js +9 -799
  139. package/lib/resources/klarna_payments.cjs +10 -800
  140. package/lib/resources/klarna_payments.js +10 -800
  141. package/lib/resources/line_item_options.cjs +11 -801
  142. package/lib/resources/line_item_options.js +11 -801
  143. package/lib/resources/line_items.cjs +14 -804
  144. package/lib/resources/line_items.js +14 -804
  145. package/lib/resources/links.cjs +11 -801
  146. package/lib/resources/links.js +11 -801
  147. package/lib/resources/manual_gateways.cjs +9 -799
  148. package/lib/resources/manual_gateways.js +9 -799
  149. package/lib/resources/manual_tax_calculators.cjs +9 -799
  150. package/lib/resources/manual_tax_calculators.js +9 -799
  151. package/lib/resources/markets.cjs +11 -801
  152. package/lib/resources/markets.js +11 -801
  153. package/lib/resources/merchants.cjs +9 -799
  154. package/lib/resources/merchants.js +9 -799
  155. package/lib/resources/notifications.cjs +9 -799
  156. package/lib/resources/notifications.js +9 -799
  157. package/lib/resources/order_amount_promotion_rules.cjs +9 -799
  158. package/lib/resources/order_amount_promotion_rules.js +9 -799
  159. package/lib/resources/order_copies.cjs +9 -799
  160. package/lib/resources/order_copies.js +9 -799
  161. package/lib/resources/order_factories.cjs +6 -796
  162. package/lib/resources/order_factories.js +6 -796
  163. package/lib/resources/order_subscription_items.cjs +9 -799
  164. package/lib/resources/order_subscription_items.js +9 -799
  165. package/lib/resources/order_subscriptions.cjs +15 -805
  166. package/lib/resources/order_subscriptions.js +15 -805
  167. package/lib/resources/orders.cjs +42 -832
  168. package/lib/resources/orders.js +42 -832
  169. package/lib/resources/organizations.cjs +6 -788
  170. package/lib/resources/organizations.js +6 -788
  171. package/lib/resources/packages.cjs +9 -799
  172. package/lib/resources/packages.js +9 -799
  173. package/lib/resources/parcel_line_items.cjs +9 -799
  174. package/lib/resources/parcel_line_items.js +9 -799
  175. package/lib/resources/parcels.cjs +9 -799
  176. package/lib/resources/parcels.js +9 -799
  177. package/lib/resources/payment_gateways.cjs +6 -796
  178. package/lib/resources/payment_gateways.js +6 -796
  179. package/lib/resources/payment_methods.cjs +11 -801
  180. package/lib/resources/payment_methods.js +11 -801
  181. package/lib/resources/payment_options.cjs +9 -799
  182. package/lib/resources/payment_options.js +9 -799
  183. package/lib/resources/paypal_gateways.cjs +9 -799
  184. package/lib/resources/paypal_gateways.js +9 -799
  185. package/lib/resources/paypal_payments.cjs +9 -799
  186. package/lib/resources/paypal_payments.js +9 -799
  187. package/lib/resources/percentage_discount_promotions.cjs +13 -803
  188. package/lib/resources/percentage_discount_promotions.js +13 -803
  189. package/lib/resources/pickups.cjs +6 -796
  190. package/lib/resources/pickups.js +6 -796
  191. package/lib/resources/price_frequency_tiers.cjs +9 -799
  192. package/lib/resources/price_frequency_tiers.js +9 -799
  193. package/lib/resources/price_list_schedulers.cjs +11 -801
  194. package/lib/resources/price_list_schedulers.js +11 -801
  195. package/lib/resources/price_lists.cjs +9 -799
  196. package/lib/resources/price_lists.js +9 -799
  197. package/lib/resources/price_tiers.cjs +6 -796
  198. package/lib/resources/price_tiers.js +6 -796
  199. package/lib/resources/price_volume_tiers.cjs +9 -799
  200. package/lib/resources/price_volume_tiers.js +9 -799
  201. package/lib/resources/prices.cjs +9 -799
  202. package/lib/resources/prices.js +9 -799
  203. package/lib/resources/promotion_rules.cjs +6 -796
  204. package/lib/resources/promotion_rules.js +6 -796
  205. package/lib/resources/promotions.cjs +6 -796
  206. package/lib/resources/promotions.js +6 -796
  207. package/lib/resources/recurring_order_copies.cjs +9 -799
  208. package/lib/resources/recurring_order_copies.js +9 -799
  209. package/lib/resources/refunds.cjs +8 -798
  210. package/lib/resources/refunds.js +8 -798
  211. package/lib/resources/reserved_stocks.cjs +6 -796
  212. package/lib/resources/reserved_stocks.js +6 -796
  213. package/lib/resources/resource_errors.cjs +6 -796
  214. package/lib/resources/resource_errors.js +6 -796
  215. package/lib/resources/return_line_items.cjs +10 -800
  216. package/lib/resources/return_line_items.js +10 -800
  217. package/lib/resources/returns.cjs +22 -812
  218. package/lib/resources/returns.js +22 -812
  219. package/lib/resources/satispay_gateways.cjs +9 -799
  220. package/lib/resources/satispay_gateways.js +9 -799
  221. package/lib/resources/satispay_payments.cjs +10 -800
  222. package/lib/resources/satispay_payments.js +10 -800
  223. package/lib/resources/shipments.cjs +24 -814
  224. package/lib/resources/shipments.js +24 -814
  225. package/lib/resources/shipping_categories.cjs +9 -799
  226. package/lib/resources/shipping_categories.js +9 -799
  227. package/lib/resources/shipping_method_tiers.cjs +6 -796
  228. package/lib/resources/shipping_method_tiers.js +6 -796
  229. package/lib/resources/shipping_methods.cjs +12 -802
  230. package/lib/resources/shipping_methods.js +12 -802
  231. package/lib/resources/shipping_weight_tiers.cjs +9 -799
  232. package/lib/resources/shipping_weight_tiers.js +9 -799
  233. package/lib/resources/shipping_zones.cjs +9 -799
  234. package/lib/resources/shipping_zones.js +9 -799
  235. package/lib/resources/sku_list_items.cjs +9 -799
  236. package/lib/resources/sku_list_items.js +9 -799
  237. package/lib/resources/sku_list_promotion_rules.cjs +9 -799
  238. package/lib/resources/sku_list_promotion_rules.js +9 -799
  239. package/lib/resources/sku_lists.cjs +9 -799
  240. package/lib/resources/sku_lists.js +9 -799
  241. package/lib/resources/sku_options.cjs +11 -801
  242. package/lib/resources/sku_options.js +11 -801
  243. package/lib/resources/skus.cjs +11 -801
  244. package/lib/resources/skus.js +11 -801
  245. package/lib/resources/stock_items.cjs +10 -800
  246. package/lib/resources/stock_items.js +10 -800
  247. package/lib/resources/stock_line_items.cjs +12 -802
  248. package/lib/resources/stock_line_items.js +12 -802
  249. package/lib/resources/stock_locations.cjs +9 -799
  250. package/lib/resources/stock_locations.js +9 -799
  251. package/lib/resources/stock_reservations.cjs +10 -800
  252. package/lib/resources/stock_reservations.js +10 -800
  253. package/lib/resources/stock_transfers.cjs +15 -805
  254. package/lib/resources/stock_transfers.js +15 -805
  255. package/lib/resources/stores.cjs +9 -799
  256. package/lib/resources/stores.js +9 -799
  257. package/lib/resources/stripe_gateways.cjs +9 -799
  258. package/lib/resources/stripe_gateways.js +9 -799
  259. package/lib/resources/stripe_payments.cjs +11 -801
  260. package/lib/resources/stripe_payments.js +11 -801
  261. package/lib/resources/stripe_tax_accounts.cjs +9 -799
  262. package/lib/resources/stripe_tax_accounts.js +9 -799
  263. package/lib/resources/subscription_models.cjs +9 -799
  264. package/lib/resources/subscription_models.js +9 -799
  265. package/lib/resources/tags.cjs +9 -799
  266. package/lib/resources/tags.js +9 -799
  267. package/lib/resources/talon_one_accounts.cjs +9 -799
  268. package/lib/resources/talon_one_accounts.js +9 -799
  269. package/lib/resources/tax_calculators.cjs +6 -796
  270. package/lib/resources/tax_calculators.js +6 -796
  271. package/lib/resources/tax_categories.cjs +9 -799
  272. package/lib/resources/tax_categories.js +9 -799
  273. package/lib/resources/tax_rules.cjs +9 -799
  274. package/lib/resources/tax_rules.js +9 -799
  275. package/lib/resources/taxjar_accounts.cjs +9 -799
  276. package/lib/resources/taxjar_accounts.js +9 -799
  277. package/lib/resources/transactions.cjs +6 -796
  278. package/lib/resources/transactions.js +6 -796
  279. package/lib/resources/versions.cjs +6 -796
  280. package/lib/resources/versions.js +6 -796
  281. package/lib/resources/vertex_accounts.cjs +10 -800
  282. package/lib/resources/vertex_accounts.js +10 -800
  283. package/lib/resources/voids.cjs +8 -798
  284. package/lib/resources/voids.js +8 -798
  285. package/lib/resources/webhooks.cjs +12 -802
  286. package/lib/resources/webhooks.js +12 -802
  287. package/lib/resources/wire_transfers.cjs +9 -799
  288. package/lib/resources/wire_transfers.js +9 -799
  289. package/lib/static.cjs +19 -753
  290. package/lib/static.js +5 -739
  291. package/lib/util.cjs +4 -5
  292. package/lib/util.js +4 -5
  293. package/package.json +4 -4
@@ -2,766 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
6
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
7
- }) : x)(function(x) {
8
- if (typeof require !== "undefined") return require.apply(this, arguments);
9
- throw Error('Dynamic require of "' + x + '" is not supported');
10
- });
5
+ var _enum = require('./enum');
6
+ var error = require('./error');
7
+ var resource = require('./resource');
8
+ var Debug = require('./debug');
11
9
 
12
- // src/enum.ts
13
- var apiResources = [
14
- // ##__API_RESOURCE_LIST_START__##
15
- "addresses",
16
- "adjustments",
17
- "adyen_gateways",
18
- "adyen_payments",
19
- "applications",
20
- "attachments",
21
- "authorizations",
22
- "avalara_accounts",
23
- "axerve_gateways",
24
- "axerve_payments",
25
- "bing_geocoders",
26
- "braintree_gateways",
27
- "braintree_payments",
28
- "bundles",
29
- "buy_x_pay_y_promotions",
30
- "captures",
31
- "carrier_accounts",
32
- "checkout_com_gateways",
33
- "checkout_com_payments",
34
- "cleanups",
35
- "coupon_codes_promotion_rules",
36
- "coupon_recipients",
37
- "coupons",
38
- "custom_promotion_rules",
39
- "customer_addresses",
40
- "customer_groups",
41
- "customer_password_resets",
42
- "customer_payment_sources",
43
- "customer_subscriptions",
44
- "customers",
45
- "delivery_lead_times",
46
- "discount_engine_items",
47
- "discount_engines",
48
- "easypost_pickups",
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
- "flex_promotions",
59
- "free_gift_promotions",
60
- "free_shipping_promotions",
61
- "geocoders",
62
- "gift_card_recipients",
63
- "gift_cards",
64
- "google_geocoders",
65
- "imports",
66
- "in_stock_subscriptions",
67
- "inventory_models",
68
- "inventory_return_locations",
69
- "inventory_stock_locations",
70
- "klarna_gateways",
71
- "klarna_payments",
72
- "line_item_options",
73
- "line_items",
74
- "links",
75
- "manual_gateways",
76
- "manual_tax_calculators",
77
- "markets",
78
- "merchants",
79
- "notifications",
80
- "order_amount_promotion_rules",
81
- "order_copies",
82
- "order_factories",
83
- "order_subscription_items",
84
- "order_subscriptions",
85
- "orders",
86
- "organizations",
87
- "packages",
88
- "parcel_line_items",
89
- "parcels",
90
- "payment_gateways",
91
- "payment_methods",
92
- "payment_options",
93
- "paypal_gateways",
94
- "paypal_payments",
95
- "percentage_discount_promotions",
96
- "pickups",
97
- "price_frequency_tiers",
98
- "price_list_schedulers",
99
- "price_lists",
100
- "price_tiers",
101
- "price_volume_tiers",
102
- "prices",
103
- "promotion_rules",
104
- "promotions",
105
- "recurring_order_copies",
106
- "refunds",
107
- "reserved_stocks",
108
- "resource_errors",
109
- "return_line_items",
110
- "returns",
111
- "satispay_gateways",
112
- "satispay_payments",
113
- "shipments",
114
- "shipping_categories",
115
- "shipping_method_tiers",
116
- "shipping_methods",
117
- "shipping_weight_tiers",
118
- "shipping_zones",
119
- "sku_list_items",
120
- "sku_list_promotion_rules",
121
- "sku_lists",
122
- "sku_options",
123
- "skus",
124
- "stock_items",
125
- "stock_line_items",
126
- "stock_locations",
127
- "stock_reservations",
128
- "stock_transfers",
129
- "stores",
130
- "stripe_gateways",
131
- "stripe_payments",
132
- "stripe_tax_accounts",
133
- "subscription_models",
134
- "tags",
135
- "talon_one_accounts",
136
- "tax_calculators",
137
- "tax_categories",
138
- "tax_rules",
139
- "taxjar_accounts",
140
- "transactions",
141
- "versions",
142
- "vertex_accounts",
143
- "voids",
144
- "webhooks",
145
- "wire_transfers"
146
- // ##__API_RESOURCE_LIST_STOP__##
147
- ];
148
- var resourceList = apiResources;
149
- function getResources(sort) {
150
- return sort ? [...resourceList].sort() : resourceList;
151
- }
152
-
153
- // src/debug.ts
154
- var debuggerFunction = (_pattern, ..._args) => {
155
- };
156
- var debuggerFactory = (_namespace) => debuggerFunction;
157
- try {
158
- const debugModule = __require("debug");
159
- if (debugModule && typeof debugModule === "function") debuggerFactory = debugModule;
160
- } catch (error) {
161
- }
162
- var debugPrefix = "clsdk";
163
- var debug = (namespace) => {
164
- return debuggerFactory(`${debugPrefix}:${namespace}`);
165
- };
166
- var debug_default = debug;
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
167
11
 
168
- // src/fetch.ts
169
- var debug2 = debug_default("fetch");
170
- var FetchError = class _FetchError extends Error {
171
- static isFetchError = (error) => {
172
- return error instanceof _FetchError;
173
- };
174
- #errors;
175
- #status;
176
- #statusText;
177
- #request;
178
- constructor(status, statusText, body, request) {
179
- super(statusText);
180
- this.#status = status;
181
- this.#statusText = statusText;
182
- if (body) this.#errors = body.errors;
183
- if (request) this.#request = request;
184
- }
185
- get errors() {
186
- return this.#errors;
187
- }
188
- get status() {
189
- return this.#status;
190
- }
191
- get statusText() {
192
- return this.#statusText;
193
- }
194
- get request() {
195
- return this.#request;
196
- }
197
- };
198
- var fetchURL = async (url, requestOptions, clientOptions) => {
199
- debug2("fetch: %s, %O, native[%s]", url, requestOptions || {}, clientOptions?.fetch ? "no" : "yes");
200
- const interceptors = clientOptions?.interceptors;
201
- if (interceptors?.request?.onSuccess) ({ url, options: requestOptions } = await interceptors.request.onSuccess({ url, options: requestOptions }));
202
- const fetchClient = clientOptions?.fetch || fetch;
203
- let response = await fetchClient(url, requestOptions);
204
- if (response.ok) {
205
- if (interceptors?.rawReader?.onSuccess) await interceptors.rawReader.onSuccess(response);
206
- if (interceptors?.response?.onSuccess) response = await interceptors.response.onSuccess(response);
207
- } else {
208
- if (interceptors?.rawReader?.onFailure) await interceptors.rawReader.onFailure(response);
209
- }
210
- const responseBody = response.body && response.status !== 204 ? await response.json().then((json) => {
211
- debug2("response: %O", json);
212
- return json;
213
- }).catch((err) => {
214
- debug2("error: %s", err.message);
215
- if (response.ok) throw new SdkError({ message: "Error parsing API response body", type: "parse" /* PARSE */ });
216
- }) : void 0;
217
- if (!response.ok) {
218
- let error = new FetchError(response.status, response.statusText, responseBody, requestOptions);
219
- if (interceptors?.response?.onFailure) error = await interceptors.response.onFailure(error);
220
- if (error) throw error;
221
- }
222
- return responseBody;
223
- };
12
+ var Debug__default = /*#__PURE__*/_interopDefault(Debug);
224
13
 
225
- // src/error.ts
226
- var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
227
- ErrorType2["CLIENT"] = "client";
228
- ErrorType2["REQUEST"] = "request";
229
- ErrorType2["RESPONSE"] = "response";
230
- ErrorType2["CANCEL"] = "cancel";
231
- ErrorType2["PARSE"] = "parse";
232
- ErrorType2["TIMEOUT"] = "timeout";
233
- ErrorType2["TOKEN_REFRESH"] = "token-refresh";
234
- return ErrorType2;
235
- })(ErrorType || {});
236
- var SdkError = class _SdkError extends Error {
237
- static NAME = "SdkError";
238
- static isSdkError(error) {
239
- return error && [_SdkError.NAME, ApiError.NAME].includes(error.name) && Object.values(ErrorType).includes(error.type);
240
- }
241
- type;
242
- code;
243
- source;
244
- constructor(error) {
245
- super(error.message);
246
- this.name = _SdkError.NAME;
247
- this.type = error.type || "client" /* CLIENT */;
248
- }
249
- };
250
- var ApiError = class _ApiError extends SdkError {
251
- static NAME = "ApiError";
252
- static isApiError(error) {
253
- return SdkError.isSdkError(error) && error.name === _ApiError.NAME && error.type === "response" /* RESPONSE */;
254
- }
255
- errors = [];
256
- status;
257
- statusText;
258
- // constructor(error: SdkError)
259
- constructor(error) {
260
- super({ ...error, type: "response" /* RESPONSE */ });
261
- this.name = _ApiError.NAME;
262
- }
263
- first() {
264
- return this.errors?.length > 0 ? this.errors[0] : void 0;
265
- }
266
- };
267
- var isRequestError = (error) => {
268
- return error instanceof TypeError && error.message !== "fetch failed";
269
- };
270
- var isCancelError = (error) => {
271
- return error instanceof DOMException && error.name === "AbortError";
272
- };
273
- var isTimeoutError = (error) => {
274
- return error instanceof DOMException && error.name === "TimeoutError";
275
- };
276
- var isExpiredTokenError = (error) => {
277
- const invalidTokenCodes = [
278
- "INVALID_TOKEN"
279
- /*, 'UNAUTHORIZED' */
280
- ];
281
- return ApiError.isApiError(error) && error.status === 401 && (invalidTokenCodes.includes(error.code || "") || error.errors && error.errors.length > 0 && invalidTokenCodes.includes(error.errors[0].code));
282
- };
283
- var handleError = (error) => {
284
- if (SdkError.isSdkError(error) || ApiError.isApiError(error)) throw error;
285
- let sdkError = new SdkError({ message: error.message });
286
- if (FetchError.isFetchError(error)) {
287
- const apiError = new ApiError(sdkError);
288
- apiError.type = "response" /* RESPONSE */;
289
- apiError.status = error.status;
290
- apiError.statusText = error.statusText;
291
- apiError.code = String(apiError.status);
292
- apiError.errors = error.errors || [];
293
- if (!apiError.message && apiError.statusText) apiError.message = apiError.statusText;
294
- sdkError = apiError;
295
- } else if (isRequestError(error)) {
296
- sdkError.type = "request" /* REQUEST */;
297
- } else if (isCancelError(error)) {
298
- sdkError.type = "cancel" /* CANCEL */;
299
- } else if (isTimeoutError(error)) {
300
- sdkError.type = "timeout" /* TIMEOUT */;
301
- } else {
302
- sdkError.type = "client" /* CLIENT */;
303
- sdkError.source = error;
304
- }
305
- throw sdkError;
306
- };
307
- function isApiError(error) {
308
- return ApiError.isApiError(error);
309
- }
310
-
311
- // src/config.ts
312
- var config = {
313
- default: {
314
- domain: "commercelayer.io",
315
- pageNumber: 1,
316
- pageSize: 10
317
- },
318
- client: {
319
- timeout: 15e3,
320
- requiredAttributes: ["organization", "accessToken"]
321
- },
322
- jsonapi: {
323
- maxResourceIncluded: 2
324
- }
325
- };
326
- var config_default = config;
327
-
328
- // src/util.ts
329
- var extractTokenData = (token) => {
330
- try {
331
- const data = JSON.parse(atob(token.split(".")[1]));
332
- return {
333
- organization: data.organization.slug,
334
- domain: data.iss ? String(data.iss).replace("https://auth.", "") : void 0,
335
- expiration: data.exp
336
- };
337
- } catch (err) {
338
- return void 0;
339
- }
340
- };
341
- var isTokenExpired = (token) => {
342
- try {
343
- const tokenData = extractTokenData(token);
344
- return tokenData?.expiration ? tokenData.expiration * 1e3 - Date.now() < 0 : false;
345
- } catch (err) {
346
- return false;
347
- }
348
- };
349
-
350
- // src/client.ts
351
- var debug3 = debug_default("client");
352
- var baseURL = (organization, domain) => {
353
- return `https://${organization.toLowerCase()}.${domain || config_default.default.domain}/api`;
354
- };
355
- var ApiClient = class _ApiClient {
356
- static create(options) {
357
- if ((!options.organization || !options.domain) && options.accessToken) {
358
- const tokenData = extractTokenData(options.accessToken);
359
- if (!options.organization && tokenData?.organization) options.organization = tokenData.organization;
360
- if (!options.domain && tokenData?.domain) options.domain = tokenData.domain;
361
- }
362
- for (const attr of config_default.client.requiredAttributes)
363
- if (!options[attr]) throw new SdkError({ message: `Undefined '${attr}' parameter` });
364
- return new _ApiClient(options);
365
- }
366
- #baseUrl;
367
- #accessToken;
368
- #organization;
369
- #domain;
370
- #clientConfig;
371
- #interceptors;
372
- constructor(options) {
373
- debug3("new client instance %O", options);
374
- this.#baseUrl = baseURL(options.organization ?? "", options.domain);
375
- this.#accessToken = options.accessToken;
376
- this.#organization = options.organization ?? "";
377
- this.#domain = options.domain;
378
- const fetchConfig = {
379
- timeout: options.timeout || config_default.client.timeout,
380
- fetch: options.fetch,
381
- refreshToken: options.refreshToken
382
- };
383
- const customHeaders = this.customHeaders(options.headers);
384
- const headers = {
385
- ...customHeaders,
386
- "Accept": "application/vnd.api+json",
387
- "Content-Type": "application/vnd.api+json",
388
- "Authorization": "Bearer " + this.#accessToken
389
- };
390
- if (options.userAgent) headers["User-Agent"] = options.userAgent;
391
- fetchConfig.headers = headers;
392
- this.#clientConfig = fetchConfig;
393
- debug3("fetch config: %O", fetchConfig);
394
- this.#interceptors = {};
395
- }
396
- get interceptors() {
397
- return this.#interceptors;
398
- }
399
- get requestHeaders() {
400
- if (!this.#clientConfig.headers) this.#clientConfig.headers = {};
401
- return this.#clientConfig.headers;
402
- }
403
- /*
404
- set requestHeaders(headers: RequestHeaders) {
405
- this.#clientConfig.headers = { ...this.#clientConfig.headers, ...headers }
406
- }
407
- */
408
- config(config2) {
409
- debug3("config %o", config2);
410
- const def = this.#clientConfig;
411
- if (!def.headers) def.headers = {};
412
- if (config2.timeout) def.timeout = config2.timeout;
413
- if (config2.userAgent) this.userAgent(config2.userAgent);
414
- if (config2.fetch) this.#clientConfig.fetch = config2.fetch;
415
- if (config2.refreshToken) this.#clientConfig.refreshToken = config2.refreshToken;
416
- if (config2.organization || config2.domain) this.#baseUrl = baseURL(config2.organization || this.#organization, config2.domain || this.#domain);
417
- if (config2.organization) this.#organization = config2.organization;
418
- if (config2.domain) this.#domain = config2.domain;
419
- if (config2.accessToken) {
420
- this.#accessToken = config2.accessToken;
421
- def.headers.Authorization = "Bearer " + this.#accessToken;
422
- }
423
- if (config2.headers) def.headers = { ...def.headers, ...this.customHeaders(config2.headers) };
424
- return this;
425
- }
426
- userAgent(userAgent) {
427
- if (userAgent) this.requestHeaders["User-Agent"] = userAgent;
428
- return this;
429
- }
430
- async request(method, path, body, options) {
431
- debug3("request %s %s, %O, %O", method, path, body || {}, options || {});
432
- if (options?.userAgent) debug3("User-Agent header ignored in request config");
433
- const baseUrl = options?.organization ? baseURL(options.organization, options.domain) : this.#baseUrl;
434
- const url = new URL(`${baseUrl}/${path}`);
435
- const bodyData = body ? JSON.stringify({ data: body }) : void 0;
436
- const headers = { ...this.requestHeaders, ...this.customHeaders(options?.headers) };
437
- const accessToken = options?.accessToken || this.#accessToken;
438
- if (accessToken) headers.Authorization = "Bearer " + accessToken;
439
- const refreshToken = options?.refreshToken || this.#clientConfig.refreshToken;
440
- const fetchFunction = options?.fetch || this.#clientConfig.fetch;
441
- const requestOptions = { method, body: bodyData, headers };
442
- const timeout = options?.timeout || this.#clientConfig.timeout;
443
- if (timeout) {
444
- if (AbortSignal?.timeout) requestOptions.signal = AbortSignal.timeout(timeout);
445
- else debug3("Timeout not set. Undefined function: %s", "AbortSignal.timeout");
446
- }
447
- if (options?.params) Object.entries(options?.params).forEach(([name, value]) => {
448
- url.searchParams.append(name, String(value));
449
- });
450
- const clientOptions = {
451
- interceptors: this.interceptors,
452
- fetch: fetchFunction
453
- };
454
- try {
455
- return await fetchURL(url, requestOptions, clientOptions).catch((error) => handleError(error));
456
- } catch (err) {
457
- if (isExpiredTokenError(err) && refreshToken && isTokenExpired(accessToken)) {
458
- debug3("Access token has expired");
459
- const newAccessToken = await refreshToken(this.#accessToken).catch((e) => {
460
- debug3("Refresh token error: %s", e.message);
461
- const tokenError = new SdkError({ message: "Error refreshing access token", type: "token-refresh" /* TOKEN_REFRESH */ });
462
- tokenError.source = e;
463
- throw tokenError;
464
- });
465
- if (newAccessToken) {
466
- debug3("Access token refreshed");
467
- this.config({ accessToken: newAccessToken });
468
- this.#accessToken = newAccessToken;
469
- if (requestOptions.headers) requestOptions.headers.Authorization = `Bearer ${newAccessToken}`;
470
- const response = await fetchURL(url, requestOptions, clientOptions).catch((error) => handleError(error));
471
- return response;
472
- }
473
- } else throw err;
474
- }
475
- }
476
- customHeaders(headers) {
477
- const customHeaders = {};
478
- if (headers) {
479
- for (const [name, value] of Object.entries(headers))
480
- if (!["accept", "content-type", "authorization", "user-agent"].includes(name.toLowerCase())) customHeaders[name] = value;
481
- }
482
- return customHeaders;
483
- }
484
- get currentAccessToken() {
485
- return this.#accessToken;
486
- }
487
- get currentOrganization() {
488
- return this.#organization;
489
- }
490
- };
491
- var client_default = ApiClient;
492
-
493
- // src/common.ts
494
- var isResourceId = (resource) => {
495
- return resource?.type && resource.id && resourceList.includes(resource.type);
496
- };
497
- var isResourceType = (resource) => {
498
- return resource && typeof resource.type !== "undefined" && resource.type && resourceList.includes(resource.type);
499
- };
500
-
501
- // src/jsonapi.ts
502
- var debug4 = debug_default("jsonapi");
503
- var denormalize = (response) => {
504
- if (!response) return response;
505
- let denormalizedResponse;
506
- if (response.links) delete response.links;
507
- const data = response.data;
508
- const included = response.included;
509
- if (!data) denormalizedResponse = data;
510
- else {
511
- if (Array.isArray(data)) denormalizedResponse = data.map((res) => denormalizeResource(res, included));
512
- else denormalizedResponse = denormalizeResource(data, included);
513
- }
514
- return denormalizedResponse;
515
- };
516
- var findIncluded = (rel, included = []) => {
517
- const inc = included.find((inc2) => {
518
- return rel.id === inc2.id && rel.type === inc2.type;
519
- });
520
- return inc || rel;
521
- };
522
- var denormalizeResource = (res, included, chain = []) => {
523
- debug4("denormalize resource: %O, %o", res, included || {});
524
- if (!res) return res;
525
- const resource = {
526
- id: res.id,
527
- type: res.type,
528
- ...res.attributes
529
- };
530
- if (res.relationships) Object.keys(res.relationships).forEach((key) => {
531
- const rel = res.relationships[key].data;
532
- if (rel) {
533
- if (chain.filter((r) => r.id === rel.id && r.type === rel.type).length >= config_default.jsonapi.maxResourceIncluded) resource[key] = rel;
534
- else {
535
- if (Array.isArray(rel)) resource[key] = rel.map((r) => denormalizeResource(findIncluded(r, included), included, [...chain, r]));
536
- else resource[key] = denormalizeResource(findIncluded(rel, included), included, [...chain, rel]);
537
- }
538
- } else if (rel === null) resource[key] = null;
539
- });
540
- debug4("denormalized resource: %O", resource);
541
- return resource;
542
- };
543
- var normalize = (resource) => {
544
- debug4("normalize resource: %O", resource);
545
- const attributes = {};
546
- const relationships = {};
547
- for (const field in resource) {
548
- if (["type", "id"].includes(field)) continue;
549
- const value = resource[field];
550
- if (Array.isArray(value) && value.length === 1 && isResourceType(value[0]) && value[0].id === null) {
551
- relationships[field] = { data: [] };
552
- } else if (value && isResourceType(value) && value.id === null) {
553
- relationships[field] = { data: null };
554
- } else if (value && (isResourceId(value) || Array.isArray(value) && isResourceId(value[0]))) {
555
- relationships[field] = { data: value };
556
- } else attributes[field] = value;
557
- }
558
- const normalized = {
559
- type: resource.type,
560
- attributes,
561
- relationships
562
- };
563
- if (isResourceId(resource)) normalized.id = resource.id;
564
- debug4("normalized resource: %O", normalized);
565
- return normalized;
566
- };
567
-
568
- // src/query.ts
569
- var debug5 = debug_default("query");
570
- var arrayFilters = ["_any", "_all", "_in", "_not_in_or_null"];
571
- var isArrayFilter = (filter) => {
572
- return arrayFilters.some((f) => filter.endsWith(f));
573
- };
574
- var objectFilters = ["_jcont"];
575
- var isObjectFilter = (filter) => {
576
- return objectFilters.some((f) => filter.endsWith(f));
577
- };
578
- var isParamsList = (params) => {
579
- return params && (params.filters || params.pageNumber || params.pageSize || params.sort);
580
- };
581
- var generateQueryStringParams = (params, res) => {
582
- debug5("generate query string params: %O, %O", params, res);
583
- const qp = {};
584
- if (!params) return qp;
585
- if (params.include) qp.include = params.include.join(",");
586
- if (params.fields) {
587
- if (Array.isArray(params.fields)) params.fields = { [res.type || res]: params.fields };
588
- Object.entries(params.fields).forEach(([p, v]) => {
589
- qp[`fields[${p}]`] = v.join(",");
590
- });
591
- }
592
- if (isParamsList(params)) {
593
- if (params.sort) {
594
- if (Array.isArray(params.sort)) qp.sort = params.sort.join(",");
595
- else qp.sort = Object.entries(params.sort).map(([k, v]) => `${v === "desc" ? "-" : ""}${k}`).join(",");
596
- }
597
- if (params.pageNumber) qp["page[number]"] = String(params.pageNumber);
598
- if (params.pageSize) qp["page[size]"] = String(params.pageSize);
599
- if (params.filters) {
600
- Object.entries(params.filters).forEach(([p, v]) => {
601
- let val;
602
- if (Array.isArray(v)) {
603
- if (!isArrayFilter(p)) throw new SdkError({ message: `Incorrect filter [${p}]: Array value is supported only for the following filters: ${arrayFilters.join(", ")}`, type: "request" /* REQUEST */ });
604
- val = v.join(",");
605
- } else if (typeof v === "object") {
606
- if (!isObjectFilter(p)) throw new SdkError({ message: `Incorrect filter [${p}]: Object value is supported only for the following filters: ${objectFilters.join(", ")}`, type: "request" /* REQUEST */ });
607
- val = JSON.stringify(v);
608
- } else val = String(v);
609
- qp[`filter[q][${p}]`] = val;
610
- });
611
- }
612
- }
613
- debug5("query string params: %O", qp);
614
- return qp;
615
- };
616
-
617
- // src/resource.ts
618
- var debug6 = debug_default("resource");
619
- var ListResponse = class extends Array {
620
- meta;
621
- constructor(meta, data) {
622
- super(...data || []);
623
- this.meta = meta;
624
- }
625
- first() {
626
- return this.length ? this[0] : void 0;
627
- }
628
- last() {
629
- return this.length ? this[this.length - 1] : void 0;
630
- }
631
- get(index) {
632
- return this.length && index >= 0 ? this[index] : void 0;
633
- }
634
- hasNextPage() {
635
- return this.meta.currentPage < this.meta.pageCount;
636
- }
637
- hasPrevPage() {
638
- return this.meta.currentPage > 1;
639
- }
640
- getRecordCount() {
641
- return this.meta.recordCount;
642
- }
643
- getPageCount() {
644
- return this.meta.pageCount;
645
- }
646
- get recordCount() {
647
- return this.meta.recordCount;
648
- }
649
- get pageCount() {
650
- return this.meta.pageCount;
651
- }
652
- };
653
- var ApiResourceAdapter = class _ApiResourceAdapter {
654
- static adapter;
655
- constructor() {
656
- }
657
- static init(config2) {
658
- return _ApiResourceAdapter.adapter = new ResourceAdapter(config2);
659
- }
660
- static get(config2) {
661
- if (config2) return _ApiResourceAdapter.init(config2);
662
- else {
663
- if (_ApiResourceAdapter.adapter) return _ApiResourceAdapter.adapter;
664
- else throw new SdkError({ message: "Commerce Layer not initialized" });
665
- }
666
- }
667
- static config(config2) {
668
- _ApiResourceAdapter.get().config(config2);
669
- }
670
- };
671
- var ResourceAdapter = class {
672
- #client;
673
- #config = {};
674
- constructor(config2) {
675
- this.#client = client_default.create(config2);
676
- this.localConfig(config2);
677
- }
678
- localConfig(config2) {
679
- }
680
- config(config2) {
681
- debug6("config %o", config2);
682
- this.localConfig(config2);
683
- this.#client.config(config2);
684
- return this;
685
- }
686
- get client() {
687
- return this.#client;
688
- }
689
- async singleton(resource, params, options, path) {
690
- debug6("singleton: %o, %O, %O", resource, params || {}, options || {});
691
- const queryParams = generateQueryStringParams(params, resource);
692
- if (options?.params) Object.assign(queryParams, options?.params);
693
- const res = await this.#client.request("GET", `${path || resource.type}`, void 0, { ...options, params: queryParams });
694
- const r = denormalize(res);
695
- return r;
696
- }
697
- async retrieve(resource, params, options) {
698
- debug6("retrieve: %o, %O, %O", resource, params || {}, options || {});
699
- const queryParams = generateQueryStringParams(params, resource);
700
- if (options?.params) Object.assign(queryParams, options?.params);
701
- const res = await this.#client.request("GET", `${resource.type}/${resource.id}`, void 0, { ...options, params: queryParams });
702
- const r = denormalize(res);
703
- return r;
704
- }
705
- async list(resource, params, options) {
706
- debug6("list: %o, %O, %O", resource, params || {}, options || {});
707
- const queryParams = generateQueryStringParams(params, resource);
708
- if (options?.params) Object.assign(queryParams, options?.params);
709
- if (!queryParams["page[number]"]) queryParams["page[number]"] = "1";
710
- const res = await this.#client.request("GET", `${resource.type}`, void 0, { ...options, params: queryParams });
711
- const r = denormalize(res);
712
- const meta = {
713
- pageCount: Number(res.meta?.page_count),
714
- recordCount: Number(res.meta?.record_count),
715
- currentPage: params?.pageNumber || config_default.default.pageNumber,
716
- recordsPerPage: params?.pageSize || config_default.default.pageSize
717
- };
718
- return new ListResponse(meta, r);
719
- }
720
- async create(resource, params, options) {
721
- debug6("create: %o, %O, %O", resource, params || {}, options || {});
722
- const queryParams = generateQueryStringParams(params, resource);
723
- if (options?.params) Object.assign(queryParams, options?.params);
724
- const data = normalize(resource);
725
- const res = await this.#client.request("POST", resource.type, data, { ...options, params: queryParams });
726
- const r = denormalize(res);
727
- return r;
728
- }
729
- async update(resource, params, options) {
730
- debug6("update: %o, %O, %O", resource, params || {}, options || {});
731
- const queryParams = generateQueryStringParams(params, resource);
732
- if (options?.params) Object.assign(queryParams, options?.params);
733
- const data = normalize(resource);
734
- const res = await this.#client.request("PATCH", `${resource.type}/${resource.id}`, data, { ...options, params: queryParams });
735
- const r = denormalize(res);
736
- return r;
737
- }
738
- async delete(resource, options) {
739
- debug6("delete: %o, %O", resource, options || {});
740
- await this.#client.request("DELETE", `${resource.type}/${resource.id}`, void 0, options);
741
- }
742
- async fetch(resource, path, params, options) {
743
- debug6("fetch: %o, %O, %O", path, params || {}, options || {});
744
- const queryParams = generateQueryStringParams(params, resource);
745
- if (options?.params) Object.assign(queryParams, options?.params);
746
- const res = await this.#client.request("GET", path, void 0, { ...options, params: queryParams });
747
- const r = denormalize(res);
748
- if (Array.isArray(r)) {
749
- const p = params;
750
- const meta = {
751
- pageCount: Number(res.meta?.page_count),
752
- recordCount: Number(res.meta?.record_count),
753
- currentPage: p?.pageNumber || config_default.default.pageNumber,
754
- recordsPerPage: p?.pageSize || config_default.default.pageSize
755
- };
756
- return new ListResponse(meta, r);
757
- } else return r;
758
- }
759
- };
760
-
761
- // src/commercelayer.ts
762
- var debug7 = debug_default("commercelayer");
763
- var OPEN_API_SCHEMA_VERSION = "7.8.3";
764
- var CommerceLayerClient = class _CommerceLayerClient {
14
+ const debug = Debug__default.default("commercelayer");
15
+ const OPEN_API_SCHEMA_VERSION = "7.8.3";
16
+ class CommerceLayerClient {
765
17
  static get openApiSchemaVersion() {
766
18
  return OPEN_API_SCHEMA_VERSION;
767
19
  }
@@ -770,41 +22,41 @@ var CommerceLayerClient = class _CommerceLayerClient {
770
22
  // ##__CL_RESOURCES_DEF_START__##
771
23
  // ##__CL_RESOURCES_DEF_TEMPLATE:: ##__TAB__#####__RESOURCE_TYPE__##?: api.##__RESOURCE_CLASS__##
772
24
  // ##__CL_RESOURCES_DEF_STOP__##
773
- static get(config2) {
774
- if (config2) return _CommerceLayerClient.cl = new _CommerceLayerClient(config2);
775
- else if (!_CommerceLayerClient.cl) throw new Error("CommerceLayer client not initialized");
776
- return _CommerceLayerClient.cl;
25
+ static get(config) {
26
+ if (config) return CommerceLayerClient.cl = new CommerceLayerClient(config);
27
+ else if (!CommerceLayerClient.cl) throw new Error("CommerceLayer client not initialized");
28
+ return CommerceLayerClient.cl;
777
29
  }
778
- constructor(config2) {
779
- debug7("new commercelayer instance %O", config2);
780
- ApiResourceAdapter.init(config2);
30
+ constructor(config) {
31
+ debug("new commercelayer instance %O", config);
32
+ resource.ApiResourceAdapter.init(config);
781
33
  }
782
34
  // ##__CL_RESOURCES_LEAZY_LOADING_START__##
783
35
  // ##__CL_RESOURCES_LEAZY_LOADING_TEMPLATE:: ##__TAB__##get ##__RESOURCE_TYPE__##(): api.##__RESOURCE_CLASS__## { return this.###__RESOURCE_TYPE__## || (this.###__RESOURCE_TYPE__## = new api.##__RESOURCE_CLASS__##(this.#adapter)) }
784
36
  // ##__CL_RESOURCES_LEAZY_LOADING_STOP__##
785
37
  // private get adapter(): ResourceAdapter { return ApiResourceAdapter.get() }
786
38
  get currentOrganization() {
787
- return ApiResourceAdapter.get().client?.currentOrganization;
39
+ return resource.ApiResourceAdapter.get().client?.currentOrganization;
788
40
  }
789
41
  get currentAccessToken() {
790
- return ApiResourceAdapter.get().client?.currentAccessToken;
42
+ return resource.ApiResourceAdapter.get().client?.currentAccessToken;
791
43
  }
792
44
  get interceptors() {
793
- return ApiResourceAdapter.get().client?.interceptors;
45
+ return resource.ApiResourceAdapter.get().client?.interceptors;
794
46
  }
795
- localConfig(config2) {
47
+ localConfig(config) {
796
48
  }
797
- config(config2) {
798
- debug7("config %o", config2);
799
- this.localConfig(config2);
800
- ApiResourceAdapter.config(config2);
49
+ config(config) {
50
+ debug("config %o", config);
51
+ this.localConfig(config);
52
+ resource.ApiResourceAdapter.config(config);
801
53
  return this;
802
54
  }
803
55
  resources(sort) {
804
- return getResources(sort);
56
+ return _enum.getResources(sort);
805
57
  }
806
- isApiError(error) {
807
- return isApiError(error);
58
+ isApiError(error$1) {
59
+ return error.isApiError(error$1);
808
60
  }
809
61
  addRequestInterceptor(onSuccess, onFailure) {
810
62
  this.interceptors.request = { onSuccess, onFailure };
@@ -849,9 +101,9 @@ var CommerceLayerClient = class _CommerceLayerClient {
849
101
  removeRawResponseReader() {
850
102
  this.interceptors.rawReader = void 0;
851
103
  }
852
- };
853
- var CommerceLayer = (config2) => {
854
- return CommerceLayerClient.get(config2);
104
+ }
105
+ const CommerceLayer = (config) => {
106
+ return CommerceLayerClient.get(config);
855
107
  };
856
108
  var commercelayer_default = CommerceLayer;
857
109