@commercelayer/sdk 4.35.0 → 4.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (521) hide show
  1. package/lib/cjs/api.d.ts +37 -0
  2. package/lib/cjs/api.js +0 -13
  3. package/lib/cjs/client.d.ts +15 -8
  4. package/lib/cjs/client.js +40 -40
  5. package/lib/cjs/commercelayer.d.ts +3 -4
  6. package/lib/cjs/commercelayer.js +7 -3
  7. package/lib/cjs/common.d.ts +1 -0
  8. package/lib/cjs/common.js +11 -2
  9. package/lib/cjs/config.d.ts +1 -0
  10. package/lib/cjs/config.js +3 -0
  11. package/lib/cjs/debug.js +0 -4
  12. package/lib/cjs/error.d.ts +3 -1
  13. package/lib/cjs/error.js +40 -7
  14. package/lib/cjs/index.d.ts +1 -1
  15. package/lib/cjs/index.js +0 -16
  16. package/lib/cjs/interceptor.d.ts +6 -2
  17. package/lib/cjs/jsonapi.js +9 -2
  18. package/lib/cjs/query.d.ts +9 -15
  19. package/lib/cjs/query.js +3 -2
  20. package/lib/cjs/resource.d.ts +30 -20
  21. package/lib/cjs/resource.js +40 -9
  22. package/lib/cjs/resources/addresses.d.ts +74 -73
  23. package/lib/cjs/resources/addresses.js +3 -11
  24. package/lib/cjs/resources/adjustments.d.ts +20 -19
  25. package/lib/cjs/resources/adjustments.js +3 -11
  26. package/lib/cjs/resources/adyen_gateways.d.ts +35 -34
  27. package/lib/cjs/resources/adyen_gateways.js +3 -11
  28. package/lib/cjs/resources/adyen_payments.d.ts +29 -27
  29. package/lib/cjs/resources/adyen_payments.js +6 -11
  30. package/lib/cjs/resources/application.d.ts +14 -13
  31. package/lib/cjs/resources/application.js +1 -6
  32. package/lib/cjs/resources/attachments.d.ts +81 -80
  33. package/lib/cjs/resources/attachments.js +3 -11
  34. package/lib/cjs/resources/authorizations.d.ts +47 -43
  35. package/lib/cjs/resources/authorizations.js +10 -9
  36. package/lib/cjs/resources/avalara_accounts.d.ts +32 -31
  37. package/lib/cjs/resources/avalara_accounts.js +3 -11
  38. package/lib/cjs/resources/axerve_gateways.d.ts +24 -23
  39. package/lib/cjs/resources/axerve_gateways.js +3 -11
  40. package/lib/cjs/resources/axerve_payments.d.ts +28 -26
  41. package/lib/cjs/resources/axerve_payments.js +6 -11
  42. package/lib/cjs/resources/billing_info_validation_rules.d.ts +17 -16
  43. package/lib/cjs/resources/billing_info_validation_rules.js +3 -11
  44. package/lib/cjs/resources/bing_geocoders.d.ts +16 -15
  45. package/lib/cjs/resources/bing_geocoders.js +3 -11
  46. package/lib/cjs/resources/braintree_gateways.d.ts +34 -33
  47. package/lib/cjs/resources/braintree_gateways.js +3 -11
  48. package/lib/cjs/resources/braintree_payments.d.ts +30 -29
  49. package/lib/cjs/resources/braintree_payments.js +3 -11
  50. package/lib/cjs/resources/bundles.d.ts +57 -54
  51. package/lib/cjs/resources/bundles.js +9 -11
  52. package/lib/cjs/resources/captures.d.ts +37 -34
  53. package/lib/cjs/resources/captures.js +7 -9
  54. package/lib/cjs/resources/carrier_accounts.d.ts +16 -15
  55. package/lib/cjs/resources/carrier_accounts.js +0 -8
  56. package/lib/cjs/resources/checkout_com_gateways.d.ts +25 -24
  57. package/lib/cjs/resources/checkout_com_gateways.js +3 -11
  58. package/lib/cjs/resources/checkout_com_payments.d.ts +41 -38
  59. package/lib/cjs/resources/checkout_com_payments.js +9 -11
  60. package/lib/cjs/resources/cleanups.d.ts +24 -23
  61. package/lib/cjs/resources/cleanups.js +2 -10
  62. package/lib/cjs/resources/coupon_codes_promotion_rules.d.ts +31 -30
  63. package/lib/cjs/resources/coupon_codes_promotion_rules.js +3 -11
  64. package/lib/cjs/resources/coupon_recipients.d.ts +26 -25
  65. package/lib/cjs/resources/coupon_recipients.js +3 -11
  66. package/lib/cjs/resources/coupons.d.ts +39 -38
  67. package/lib/cjs/resources/coupons.js +3 -11
  68. package/lib/cjs/resources/customer_addresses.d.ts +23 -22
  69. package/lib/cjs/resources/customer_addresses.js +3 -11
  70. package/lib/cjs/resources/customer_groups.d.ts +17 -16
  71. package/lib/cjs/resources/customer_groups.js +3 -11
  72. package/lib/cjs/resources/customer_password_resets.d.ts +19 -17
  73. package/lib/cjs/resources/customer_password_resets.js +6 -11
  74. package/lib/cjs/resources/customer_payment_sources.d.ts +37 -36
  75. package/lib/cjs/resources/customer_payment_sources.js +3 -11
  76. package/lib/cjs/resources/customer_subscriptions.d.ts +15 -14
  77. package/lib/cjs/resources/customer_subscriptions.js +3 -11
  78. package/lib/cjs/resources/customers.d.ts +37 -36
  79. package/lib/cjs/resources/customers.js +3 -11
  80. package/lib/cjs/resources/delivery_lead_times.d.ts +27 -26
  81. package/lib/cjs/resources/delivery_lead_times.js +3 -11
  82. package/lib/cjs/resources/event_callbacks.d.ts +15 -14
  83. package/lib/cjs/resources/event_callbacks.js +0 -8
  84. package/lib/cjs/resources/events.d.ts +13 -12
  85. package/lib/cjs/resources/events.js +0 -8
  86. package/lib/cjs/resources/exports.d.ts +27 -26
  87. package/lib/cjs/resources/exports.js +2 -10
  88. package/lib/cjs/resources/external_gateways.d.ts +32 -31
  89. package/lib/cjs/resources/external_gateways.js +3 -11
  90. package/lib/cjs/resources/external_payments.d.ts +23 -22
  91. package/lib/cjs/resources/external_payments.js +3 -11
  92. package/lib/cjs/resources/external_promotions.d.ts +66 -65
  93. package/lib/cjs/resources/external_promotions.js +3 -11
  94. package/lib/cjs/resources/external_tax_calculators.d.ts +19 -18
  95. package/lib/cjs/resources/external_tax_calculators.js +3 -11
  96. package/lib/cjs/resources/fixed_amount_promotions.d.ts +67 -66
  97. package/lib/cjs/resources/fixed_amount_promotions.js +3 -11
  98. package/lib/cjs/resources/fixed_price_promotions.d.ts +71 -70
  99. package/lib/cjs/resources/fixed_price_promotions.js +3 -11
  100. package/lib/cjs/resources/free_gift_promotions.d.ts +70 -69
  101. package/lib/cjs/resources/free_gift_promotions.js +3 -11
  102. package/lib/cjs/resources/free_shipping_promotions.d.ts +63 -62
  103. package/lib/cjs/resources/free_shipping_promotions.js +3 -11
  104. package/lib/cjs/resources/geocoders.d.ts +13 -12
  105. package/lib/cjs/resources/geocoders.js +0 -8
  106. package/lib/cjs/resources/gift_card_recipients.d.ts +26 -25
  107. package/lib/cjs/resources/gift_card_recipients.js +3 -11
  108. package/lib/cjs/resources/gift_cards.d.ts +71 -66
  109. package/lib/cjs/resources/gift_cards.js +15 -11
  110. package/lib/cjs/resources/google_geocoders.d.ts +16 -15
  111. package/lib/cjs/resources/google_geocoders.js +3 -11
  112. package/lib/cjs/resources/imports.d.ts +32 -31
  113. package/lib/cjs/resources/imports.js +2 -10
  114. package/lib/cjs/resources/in_stock_subscriptions.d.ts +38 -35
  115. package/lib/cjs/resources/in_stock_subscriptions.js +9 -11
  116. package/lib/cjs/resources/inventory_models.d.ts +26 -25
  117. package/lib/cjs/resources/inventory_models.js +3 -11
  118. package/lib/cjs/resources/inventory_return_locations.d.ts +22 -21
  119. package/lib/cjs/resources/inventory_return_locations.js +3 -11
  120. package/lib/cjs/resources/inventory_stock_locations.d.ts +25 -24
  121. package/lib/cjs/resources/inventory_stock_locations.js +3 -11
  122. package/lib/cjs/resources/klarna_gateways.d.ts +23 -22
  123. package/lib/cjs/resources/klarna_gateways.js +3 -11
  124. package/lib/cjs/resources/klarna_payments.d.ts +29 -27
  125. package/lib/cjs/resources/klarna_payments.js +6 -11
  126. package/lib/cjs/resources/line_item_options.d.ts +41 -40
  127. package/lib/cjs/resources/line_item_options.js +3 -11
  128. package/lib/cjs/resources/line_items.d.ts +96 -93
  129. package/lib/cjs/resources/line_items.js +9 -11
  130. package/lib/cjs/resources/manual_gateways.d.ts +15 -14
  131. package/lib/cjs/resources/manual_gateways.js +3 -11
  132. package/lib/cjs/resources/manual_tax_calculators.d.ts +21 -20
  133. package/lib/cjs/resources/manual_tax_calculators.js +3 -11
  134. package/lib/cjs/resources/markets.d.ts +62 -59
  135. package/lib/cjs/resources/markets.js +9 -11
  136. package/lib/cjs/resources/merchants.d.ts +19 -18
  137. package/lib/cjs/resources/merchants.js +3 -11
  138. package/lib/cjs/resources/order_amount_promotion_rules.d.ts +34 -33
  139. package/lib/cjs/resources/order_amount_promotion_rules.js +3 -11
  140. package/lib/cjs/resources/order_copies.d.ts +29 -28
  141. package/lib/cjs/resources/order_copies.js +3 -11
  142. package/lib/cjs/resources/order_factories.d.ts +21 -20
  143. package/lib/cjs/resources/order_factories.js +0 -8
  144. package/lib/cjs/resources/order_subscription_items.d.ts +40 -39
  145. package/lib/cjs/resources/order_subscription_items.js +3 -11
  146. package/lib/cjs/resources/order_subscriptions.d.ts +55 -51
  147. package/lib/cjs/resources/order_subscriptions.js +12 -11
  148. package/lib/cjs/resources/order_validation_rules.d.ts +13 -12
  149. package/lib/cjs/resources/order_validation_rules.js +0 -8
  150. package/lib/cjs/resources/orders.d.ts +263 -235
  151. package/lib/cjs/resources/orders.js +84 -11
  152. package/lib/cjs/resources/organization.d.ts +25 -24
  153. package/lib/cjs/resources/organization.js +1 -6
  154. package/lib/cjs/resources/packages.d.ts +31 -30
  155. package/lib/cjs/resources/packages.js +3 -11
  156. package/lib/cjs/resources/parcel_line_items.d.ts +23 -22
  157. package/lib/cjs/resources/parcel_line_items.js +3 -11
  158. package/lib/cjs/resources/parcels.d.ts +94 -93
  159. package/lib/cjs/resources/parcels.js +3 -11
  160. package/lib/cjs/resources/payment_gateways.d.ts +13 -12
  161. package/lib/cjs/resources/payment_gateways.js +0 -8
  162. package/lib/cjs/resources/payment_methods.d.ts +51 -48
  163. package/lib/cjs/resources/payment_methods.js +9 -11
  164. package/lib/cjs/resources/paypal_gateways.d.ts +18 -17
  165. package/lib/cjs/resources/paypal_gateways.js +3 -11
  166. package/lib/cjs/resources/paypal_payments.d.ts +32 -31
  167. package/lib/cjs/resources/paypal_payments.js +3 -11
  168. package/lib/cjs/resources/percentage_discount_promotions.d.ts +70 -69
  169. package/lib/cjs/resources/percentage_discount_promotions.js +3 -11
  170. package/lib/cjs/resources/price_frequency_tiers.d.ts +27 -26
  171. package/lib/cjs/resources/price_frequency_tiers.js +3 -11
  172. package/lib/cjs/resources/price_lists.d.ts +21 -20
  173. package/lib/cjs/resources/price_lists.js +3 -11
  174. package/lib/cjs/resources/price_tiers.d.ts +18 -17
  175. package/lib/cjs/resources/price_tiers.js +0 -8
  176. package/lib/cjs/resources/price_volume_tiers.d.ts +27 -26
  177. package/lib/cjs/resources/price_volume_tiers.js +3 -11
  178. package/lib/cjs/resources/prices.d.ts +40 -39
  179. package/lib/cjs/resources/prices.js +3 -11
  180. package/lib/cjs/resources/promotion_rules.d.ts +12 -11
  181. package/lib/cjs/resources/promotion_rules.js +0 -8
  182. package/lib/cjs/resources/promotions.d.ts +28 -27
  183. package/lib/cjs/resources/promotions.js +0 -8
  184. package/lib/cjs/resources/recurring_order_copies.d.ts +29 -28
  185. package/lib/cjs/resources/recurring_order_copies.js +3 -11
  186. package/lib/cjs/resources/refunds.d.ts +26 -25
  187. package/lib/cjs/resources/refunds.js +0 -8
  188. package/lib/cjs/resources/reserved_stocks.d.ts +14 -13
  189. package/lib/cjs/resources/reserved_stocks.js +0 -8
  190. package/lib/cjs/resources/return_line_items.d.ts +29 -27
  191. package/lib/cjs/resources/return_line_items.js +6 -11
  192. package/lib/cjs/resources/returns.d.ts +59 -49
  193. package/lib/cjs/resources/returns.js +30 -11
  194. package/lib/cjs/resources/satispay_gateways.d.ts +23 -22
  195. package/lib/cjs/resources/satispay_gateways.js +3 -11
  196. package/lib/cjs/resources/satispay_payments.d.ts +31 -29
  197. package/lib/cjs/resources/satispay_payments.js +6 -11
  198. package/lib/cjs/resources/shipments.d.ts +65 -57
  199. package/lib/cjs/resources/shipments.js +22 -9
  200. package/lib/cjs/resources/shipping_categories.d.ts +16 -15
  201. package/lib/cjs/resources/shipping_categories.js +3 -11
  202. package/lib/cjs/resources/shipping_method_tiers.d.ts +18 -17
  203. package/lib/cjs/resources/shipping_method_tiers.js +0 -8
  204. package/lib/cjs/resources/shipping_methods.d.ts +80 -77
  205. package/lib/cjs/resources/shipping_methods.js +9 -11
  206. package/lib/cjs/resources/shipping_weight_tiers.d.ts +26 -25
  207. package/lib/cjs/resources/shipping_weight_tiers.js +3 -11
  208. package/lib/cjs/resources/shipping_zones.d.ts +33 -32
  209. package/lib/cjs/resources/shipping_zones.js +3 -11
  210. package/lib/cjs/resources/sku_list_items.d.ts +27 -26
  211. package/lib/cjs/resources/sku_list_items.js +3 -11
  212. package/lib/cjs/resources/sku_list_promotion_rules.d.ts +38 -37
  213. package/lib/cjs/resources/sku_list_promotion_rules.js +3 -11
  214. package/lib/cjs/resources/sku_lists.d.ts +36 -35
  215. package/lib/cjs/resources/sku_lists.js +3 -11
  216. package/lib/cjs/resources/sku_options.d.ts +44 -43
  217. package/lib/cjs/resources/sku_options.js +3 -11
  218. package/lib/cjs/resources/skus.d.ts +57 -56
  219. package/lib/cjs/resources/skus.js +3 -11
  220. package/lib/cjs/resources/stock_items.d.ts +29 -28
  221. package/lib/cjs/resources/stock_items.js +3 -11
  222. package/lib/cjs/resources/stock_line_items.d.ts +18 -17
  223. package/lib/cjs/resources/stock_line_items.js +0 -8
  224. package/lib/cjs/resources/stock_locations.d.ts +30 -29
  225. package/lib/cjs/resources/stock_locations.js +3 -11
  226. package/lib/cjs/resources/stock_reservations.d.ts +18 -17
  227. package/lib/cjs/resources/stock_reservations.js +0 -8
  228. package/lib/cjs/resources/stock_transfers.d.ts +48 -42
  229. package/lib/cjs/resources/stock_transfers.js +18 -11
  230. package/lib/cjs/resources/stripe_gateways.d.ts +23 -22
  231. package/lib/cjs/resources/stripe_gateways.js +3 -11
  232. package/lib/cjs/resources/stripe_payments.d.ts +35 -32
  233. package/lib/cjs/resources/stripe_payments.js +9 -11
  234. package/lib/cjs/resources/subscription_models.d.ts +27 -26
  235. package/lib/cjs/resources/subscription_models.js +3 -11
  236. package/lib/cjs/resources/tags.d.ts +13 -12
  237. package/lib/cjs/resources/tags.js +3 -11
  238. package/lib/cjs/resources/tax_calculators.d.ts +14 -13
  239. package/lib/cjs/resources/tax_calculators.js +0 -8
  240. package/lib/cjs/resources/tax_categories.d.ts +31 -30
  241. package/lib/cjs/resources/tax_categories.js +3 -11
  242. package/lib/cjs/resources/tax_rules.d.ts +52 -51
  243. package/lib/cjs/resources/tax_rules.js +3 -11
  244. package/lib/cjs/resources/taxjar_accounts.d.ts +22 -21
  245. package/lib/cjs/resources/taxjar_accounts.js +3 -11
  246. package/lib/cjs/resources/transactions.d.ts +24 -23
  247. package/lib/cjs/resources/transactions.js +0 -8
  248. package/lib/cjs/resources/versions.d.ts +14 -14
  249. package/lib/cjs/resources/versions.js +0 -8
  250. package/lib/cjs/resources/voids.d.ts +26 -25
  251. package/lib/cjs/resources/voids.js +0 -8
  252. package/lib/cjs/resources/webhooks.d.ts +28 -26
  253. package/lib/cjs/resources/webhooks.js +6 -11
  254. package/lib/cjs/resources/wire_transfers.d.ts +17 -16
  255. package/lib/cjs/resources/wire_transfers.js +3 -11
  256. package/lib/cjs/static.d.ts +1 -1
  257. package/lib/cjs/util.d.ts +1 -3
  258. package/lib/esm/api.d.ts +37 -0
  259. package/lib/esm/api.js +0 -13
  260. package/lib/esm/client.d.ts +15 -8
  261. package/lib/esm/client.js +40 -40
  262. package/lib/esm/commercelayer.d.ts +3 -4
  263. package/lib/esm/commercelayer.js +7 -3
  264. package/lib/esm/common.d.ts +1 -0
  265. package/lib/esm/common.js +11 -2
  266. package/lib/esm/config.d.ts +1 -0
  267. package/lib/esm/config.js +3 -0
  268. package/lib/esm/debug.js +0 -4
  269. package/lib/esm/error.d.ts +3 -1
  270. package/lib/esm/error.js +35 -5
  271. package/lib/esm/index.d.ts +1 -1
  272. package/lib/esm/index.js +0 -2
  273. package/lib/esm/interceptor.d.ts +6 -2
  274. package/lib/esm/jsonapi.js +9 -2
  275. package/lib/esm/query.d.ts +9 -15
  276. package/lib/esm/query.js +2 -2
  277. package/lib/esm/resource.d.ts +30 -20
  278. package/lib/esm/resource.js +40 -10
  279. package/lib/esm/resources/addresses.d.ts +74 -73
  280. package/lib/esm/resources/addresses.js +3 -11
  281. package/lib/esm/resources/adjustments.d.ts +20 -19
  282. package/lib/esm/resources/adjustments.js +3 -11
  283. package/lib/esm/resources/adyen_gateways.d.ts +35 -34
  284. package/lib/esm/resources/adyen_gateways.js +3 -11
  285. package/lib/esm/resources/adyen_payments.d.ts +29 -27
  286. package/lib/esm/resources/adyen_payments.js +6 -11
  287. package/lib/esm/resources/application.d.ts +14 -13
  288. package/lib/esm/resources/application.js +2 -7
  289. package/lib/esm/resources/attachments.d.ts +81 -80
  290. package/lib/esm/resources/attachments.js +3 -11
  291. package/lib/esm/resources/authorizations.d.ts +47 -43
  292. package/lib/esm/resources/authorizations.js +10 -9
  293. package/lib/esm/resources/avalara_accounts.d.ts +32 -31
  294. package/lib/esm/resources/avalara_accounts.js +3 -11
  295. package/lib/esm/resources/axerve_gateways.d.ts +24 -23
  296. package/lib/esm/resources/axerve_gateways.js +3 -11
  297. package/lib/esm/resources/axerve_payments.d.ts +28 -26
  298. package/lib/esm/resources/axerve_payments.js +6 -11
  299. package/lib/esm/resources/billing_info_validation_rules.d.ts +17 -16
  300. package/lib/esm/resources/billing_info_validation_rules.js +3 -11
  301. package/lib/esm/resources/bing_geocoders.d.ts +16 -15
  302. package/lib/esm/resources/bing_geocoders.js +3 -11
  303. package/lib/esm/resources/braintree_gateways.d.ts +34 -33
  304. package/lib/esm/resources/braintree_gateways.js +3 -11
  305. package/lib/esm/resources/braintree_payments.d.ts +30 -29
  306. package/lib/esm/resources/braintree_payments.js +3 -11
  307. package/lib/esm/resources/bundles.d.ts +57 -54
  308. package/lib/esm/resources/bundles.js +9 -11
  309. package/lib/esm/resources/captures.d.ts +37 -34
  310. package/lib/esm/resources/captures.js +7 -9
  311. package/lib/esm/resources/carrier_accounts.d.ts +16 -15
  312. package/lib/esm/resources/carrier_accounts.js +0 -8
  313. package/lib/esm/resources/checkout_com_gateways.d.ts +25 -24
  314. package/lib/esm/resources/checkout_com_gateways.js +3 -11
  315. package/lib/esm/resources/checkout_com_payments.d.ts +41 -38
  316. package/lib/esm/resources/checkout_com_payments.js +9 -11
  317. package/lib/esm/resources/cleanups.d.ts +24 -23
  318. package/lib/esm/resources/cleanups.js +2 -10
  319. package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +31 -30
  320. package/lib/esm/resources/coupon_codes_promotion_rules.js +3 -11
  321. package/lib/esm/resources/coupon_recipients.d.ts +26 -25
  322. package/lib/esm/resources/coupon_recipients.js +3 -11
  323. package/lib/esm/resources/coupons.d.ts +39 -38
  324. package/lib/esm/resources/coupons.js +3 -11
  325. package/lib/esm/resources/customer_addresses.d.ts +23 -22
  326. package/lib/esm/resources/customer_addresses.js +3 -11
  327. package/lib/esm/resources/customer_groups.d.ts +17 -16
  328. package/lib/esm/resources/customer_groups.js +3 -11
  329. package/lib/esm/resources/customer_password_resets.d.ts +19 -17
  330. package/lib/esm/resources/customer_password_resets.js +6 -11
  331. package/lib/esm/resources/customer_payment_sources.d.ts +37 -36
  332. package/lib/esm/resources/customer_payment_sources.js +3 -11
  333. package/lib/esm/resources/customer_subscriptions.d.ts +15 -14
  334. package/lib/esm/resources/customer_subscriptions.js +3 -11
  335. package/lib/esm/resources/customers.d.ts +37 -36
  336. package/lib/esm/resources/customers.js +3 -11
  337. package/lib/esm/resources/delivery_lead_times.d.ts +27 -26
  338. package/lib/esm/resources/delivery_lead_times.js +3 -11
  339. package/lib/esm/resources/event_callbacks.d.ts +15 -14
  340. package/lib/esm/resources/event_callbacks.js +0 -8
  341. package/lib/esm/resources/events.d.ts +13 -12
  342. package/lib/esm/resources/events.js +0 -8
  343. package/lib/esm/resources/exports.d.ts +27 -26
  344. package/lib/esm/resources/exports.js +2 -10
  345. package/lib/esm/resources/external_gateways.d.ts +32 -31
  346. package/lib/esm/resources/external_gateways.js +3 -11
  347. package/lib/esm/resources/external_payments.d.ts +23 -22
  348. package/lib/esm/resources/external_payments.js +3 -11
  349. package/lib/esm/resources/external_promotions.d.ts +66 -65
  350. package/lib/esm/resources/external_promotions.js +3 -11
  351. package/lib/esm/resources/external_tax_calculators.d.ts +19 -18
  352. package/lib/esm/resources/external_tax_calculators.js +3 -11
  353. package/lib/esm/resources/fixed_amount_promotions.d.ts +67 -66
  354. package/lib/esm/resources/fixed_amount_promotions.js +3 -11
  355. package/lib/esm/resources/fixed_price_promotions.d.ts +71 -70
  356. package/lib/esm/resources/fixed_price_promotions.js +3 -11
  357. package/lib/esm/resources/free_gift_promotions.d.ts +70 -69
  358. package/lib/esm/resources/free_gift_promotions.js +3 -11
  359. package/lib/esm/resources/free_shipping_promotions.d.ts +63 -62
  360. package/lib/esm/resources/free_shipping_promotions.js +3 -11
  361. package/lib/esm/resources/geocoders.d.ts +13 -12
  362. package/lib/esm/resources/geocoders.js +0 -8
  363. package/lib/esm/resources/gift_card_recipients.d.ts +26 -25
  364. package/lib/esm/resources/gift_card_recipients.js +3 -11
  365. package/lib/esm/resources/gift_cards.d.ts +71 -66
  366. package/lib/esm/resources/gift_cards.js +15 -11
  367. package/lib/esm/resources/google_geocoders.d.ts +16 -15
  368. package/lib/esm/resources/google_geocoders.js +3 -11
  369. package/lib/esm/resources/imports.d.ts +32 -31
  370. package/lib/esm/resources/imports.js +2 -10
  371. package/lib/esm/resources/in_stock_subscriptions.d.ts +38 -35
  372. package/lib/esm/resources/in_stock_subscriptions.js +9 -11
  373. package/lib/esm/resources/inventory_models.d.ts +26 -25
  374. package/lib/esm/resources/inventory_models.js +3 -11
  375. package/lib/esm/resources/inventory_return_locations.d.ts +22 -21
  376. package/lib/esm/resources/inventory_return_locations.js +3 -11
  377. package/lib/esm/resources/inventory_stock_locations.d.ts +25 -24
  378. package/lib/esm/resources/inventory_stock_locations.js +3 -11
  379. package/lib/esm/resources/klarna_gateways.d.ts +23 -22
  380. package/lib/esm/resources/klarna_gateways.js +3 -11
  381. package/lib/esm/resources/klarna_payments.d.ts +29 -27
  382. package/lib/esm/resources/klarna_payments.js +6 -11
  383. package/lib/esm/resources/line_item_options.d.ts +41 -40
  384. package/lib/esm/resources/line_item_options.js +3 -11
  385. package/lib/esm/resources/line_items.d.ts +96 -93
  386. package/lib/esm/resources/line_items.js +9 -11
  387. package/lib/esm/resources/manual_gateways.d.ts +15 -14
  388. package/lib/esm/resources/manual_gateways.js +3 -11
  389. package/lib/esm/resources/manual_tax_calculators.d.ts +21 -20
  390. package/lib/esm/resources/manual_tax_calculators.js +3 -11
  391. package/lib/esm/resources/markets.d.ts +62 -59
  392. package/lib/esm/resources/markets.js +9 -11
  393. package/lib/esm/resources/merchants.d.ts +19 -18
  394. package/lib/esm/resources/merchants.js +3 -11
  395. package/lib/esm/resources/order_amount_promotion_rules.d.ts +34 -33
  396. package/lib/esm/resources/order_amount_promotion_rules.js +3 -11
  397. package/lib/esm/resources/order_copies.d.ts +29 -28
  398. package/lib/esm/resources/order_copies.js +3 -11
  399. package/lib/esm/resources/order_factories.d.ts +21 -20
  400. package/lib/esm/resources/order_factories.js +0 -8
  401. package/lib/esm/resources/order_subscription_items.d.ts +40 -39
  402. package/lib/esm/resources/order_subscription_items.js +3 -11
  403. package/lib/esm/resources/order_subscriptions.d.ts +55 -51
  404. package/lib/esm/resources/order_subscriptions.js +12 -11
  405. package/lib/esm/resources/order_validation_rules.d.ts +13 -12
  406. package/lib/esm/resources/order_validation_rules.js +0 -8
  407. package/lib/esm/resources/orders.d.ts +263 -235
  408. package/lib/esm/resources/orders.js +84 -11
  409. package/lib/esm/resources/organization.d.ts +25 -24
  410. package/lib/esm/resources/organization.js +2 -7
  411. package/lib/esm/resources/packages.d.ts +31 -30
  412. package/lib/esm/resources/packages.js +3 -11
  413. package/lib/esm/resources/parcel_line_items.d.ts +23 -22
  414. package/lib/esm/resources/parcel_line_items.js +3 -11
  415. package/lib/esm/resources/parcels.d.ts +94 -93
  416. package/lib/esm/resources/parcels.js +3 -11
  417. package/lib/esm/resources/payment_gateways.d.ts +13 -12
  418. package/lib/esm/resources/payment_gateways.js +0 -8
  419. package/lib/esm/resources/payment_methods.d.ts +51 -48
  420. package/lib/esm/resources/payment_methods.js +9 -11
  421. package/lib/esm/resources/paypal_gateways.d.ts +18 -17
  422. package/lib/esm/resources/paypal_gateways.js +3 -11
  423. package/lib/esm/resources/paypal_payments.d.ts +32 -31
  424. package/lib/esm/resources/paypal_payments.js +3 -11
  425. package/lib/esm/resources/percentage_discount_promotions.d.ts +70 -69
  426. package/lib/esm/resources/percentage_discount_promotions.js +3 -11
  427. package/lib/esm/resources/price_frequency_tiers.d.ts +27 -26
  428. package/lib/esm/resources/price_frequency_tiers.js +3 -11
  429. package/lib/esm/resources/price_lists.d.ts +21 -20
  430. package/lib/esm/resources/price_lists.js +3 -11
  431. package/lib/esm/resources/price_tiers.d.ts +18 -17
  432. package/lib/esm/resources/price_tiers.js +0 -8
  433. package/lib/esm/resources/price_volume_tiers.d.ts +27 -26
  434. package/lib/esm/resources/price_volume_tiers.js +3 -11
  435. package/lib/esm/resources/prices.d.ts +40 -39
  436. package/lib/esm/resources/prices.js +3 -11
  437. package/lib/esm/resources/promotion_rules.d.ts +12 -11
  438. package/lib/esm/resources/promotion_rules.js +0 -8
  439. package/lib/esm/resources/promotions.d.ts +28 -27
  440. package/lib/esm/resources/promotions.js +0 -8
  441. package/lib/esm/resources/recurring_order_copies.d.ts +29 -28
  442. package/lib/esm/resources/recurring_order_copies.js +3 -11
  443. package/lib/esm/resources/refunds.d.ts +26 -25
  444. package/lib/esm/resources/refunds.js +0 -8
  445. package/lib/esm/resources/reserved_stocks.d.ts +14 -13
  446. package/lib/esm/resources/reserved_stocks.js +0 -8
  447. package/lib/esm/resources/return_line_items.d.ts +29 -27
  448. package/lib/esm/resources/return_line_items.js +6 -11
  449. package/lib/esm/resources/returns.d.ts +59 -49
  450. package/lib/esm/resources/returns.js +30 -11
  451. package/lib/esm/resources/satispay_gateways.d.ts +23 -22
  452. package/lib/esm/resources/satispay_gateways.js +3 -11
  453. package/lib/esm/resources/satispay_payments.d.ts +31 -29
  454. package/lib/esm/resources/satispay_payments.js +6 -11
  455. package/lib/esm/resources/shipments.d.ts +65 -57
  456. package/lib/esm/resources/shipments.js +22 -9
  457. package/lib/esm/resources/shipping_categories.d.ts +16 -15
  458. package/lib/esm/resources/shipping_categories.js +3 -11
  459. package/lib/esm/resources/shipping_method_tiers.d.ts +18 -17
  460. package/lib/esm/resources/shipping_method_tiers.js +0 -8
  461. package/lib/esm/resources/shipping_methods.d.ts +80 -77
  462. package/lib/esm/resources/shipping_methods.js +9 -11
  463. package/lib/esm/resources/shipping_weight_tiers.d.ts +26 -25
  464. package/lib/esm/resources/shipping_weight_tiers.js +3 -11
  465. package/lib/esm/resources/shipping_zones.d.ts +33 -32
  466. package/lib/esm/resources/shipping_zones.js +3 -11
  467. package/lib/esm/resources/sku_list_items.d.ts +27 -26
  468. package/lib/esm/resources/sku_list_items.js +3 -11
  469. package/lib/esm/resources/sku_list_promotion_rules.d.ts +38 -37
  470. package/lib/esm/resources/sku_list_promotion_rules.js +3 -11
  471. package/lib/esm/resources/sku_lists.d.ts +36 -35
  472. package/lib/esm/resources/sku_lists.js +3 -11
  473. package/lib/esm/resources/sku_options.d.ts +44 -43
  474. package/lib/esm/resources/sku_options.js +3 -11
  475. package/lib/esm/resources/skus.d.ts +57 -56
  476. package/lib/esm/resources/skus.js +3 -11
  477. package/lib/esm/resources/stock_items.d.ts +29 -28
  478. package/lib/esm/resources/stock_items.js +3 -11
  479. package/lib/esm/resources/stock_line_items.d.ts +18 -17
  480. package/lib/esm/resources/stock_line_items.js +0 -8
  481. package/lib/esm/resources/stock_locations.d.ts +30 -29
  482. package/lib/esm/resources/stock_locations.js +3 -11
  483. package/lib/esm/resources/stock_reservations.d.ts +18 -17
  484. package/lib/esm/resources/stock_reservations.js +0 -8
  485. package/lib/esm/resources/stock_transfers.d.ts +48 -42
  486. package/lib/esm/resources/stock_transfers.js +18 -11
  487. package/lib/esm/resources/stripe_gateways.d.ts +23 -22
  488. package/lib/esm/resources/stripe_gateways.js +3 -11
  489. package/lib/esm/resources/stripe_payments.d.ts +35 -32
  490. package/lib/esm/resources/stripe_payments.js +9 -11
  491. package/lib/esm/resources/subscription_models.d.ts +27 -26
  492. package/lib/esm/resources/subscription_models.js +3 -11
  493. package/lib/esm/resources/tags.d.ts +13 -12
  494. package/lib/esm/resources/tags.js +3 -11
  495. package/lib/esm/resources/tax_calculators.d.ts +14 -13
  496. package/lib/esm/resources/tax_calculators.js +0 -8
  497. package/lib/esm/resources/tax_categories.d.ts +31 -30
  498. package/lib/esm/resources/tax_categories.js +3 -11
  499. package/lib/esm/resources/tax_rules.d.ts +52 -51
  500. package/lib/esm/resources/tax_rules.js +3 -11
  501. package/lib/esm/resources/taxjar_accounts.d.ts +22 -21
  502. package/lib/esm/resources/taxjar_accounts.js +3 -11
  503. package/lib/esm/resources/transactions.d.ts +24 -23
  504. package/lib/esm/resources/transactions.js +0 -8
  505. package/lib/esm/resources/versions.d.ts +14 -14
  506. package/lib/esm/resources/versions.js +0 -8
  507. package/lib/esm/resources/voids.d.ts +26 -25
  508. package/lib/esm/resources/voids.js +0 -8
  509. package/lib/esm/resources/webhooks.d.ts +28 -26
  510. package/lib/esm/resources/webhooks.js +6 -11
  511. package/lib/esm/resources/wire_transfers.d.ts +17 -16
  512. package/lib/esm/resources/wire_transfers.js +3 -11
  513. package/lib/esm/static.d.ts +1 -1
  514. package/lib/esm/util.d.ts +1 -3
  515. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  516. package/lib/tsconfig.tsbuildinfo +1 -1
  517. package/package.json +8 -8
  518. package/lib/cjs/micro.d.ts +0 -4
  519. package/lib/cjs/micro.js +0 -13
  520. package/lib/esm/micro.d.ts +0 -4
  521. package/lib/esm/micro.js +0 -7
package/lib/cjs/api.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import type { Resource, ResourceRel } from './resource';
2
+ import type { TagType } from './resources/tags';
3
+ import type { VersionType } from './resources/versions';
1
4
  /**
2
5
  * ©2023 Commerce Layer Inc.
3
6
  **/
@@ -120,3 +123,37 @@ export { default as Webhooks } from './resources/webhooks';
120
123
  export { default as WireTransfers } from './resources/wire_transfers';
121
124
  export type ResourceTypeLock = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'application' | 'attachments' | 'authorizations' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'captures' | 'carrier_accounts' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'event_callbacks' | 'events' | 'exports' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'geocoders' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'imports' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_factories' | 'order_subscription_items' | 'order_subscriptions' | 'order_validation_rules' | 'orders' | 'organization' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_gateways' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_tiers' | 'price_volume_tiers' | 'prices' | 'promotion_rules' | 'promotions' | 'recurring_order_copies' | 'refunds' | 'reserved_stocks' | 'return_line_items' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipments' | 'shipping_categories' | 'shipping_method_tiers' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_line_items' | 'stock_locations' | 'stock_reservations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'subscription_models' | 'tags' | 'tax_calculators' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'transactions' | 'versions' | 'voids' | 'webhooks' | 'wire_transfers';
122
125
  export declare const resourceList: readonly ["addresses", "adjustments", "adyen_gateways", "adyen_payments", "application", "attachments", "authorizations", "avalara_accounts", "axerve_gateways", "axerve_payments", "billing_info_validation_rules", "bing_geocoders", "braintree_gateways", "braintree_payments", "bundles", "captures", "carrier_accounts", "checkout_com_gateways", "checkout_com_payments", "cleanups", "coupon_codes_promotion_rules", "coupon_recipients", "coupons", "customer_addresses", "customer_groups", "customer_password_resets", "customer_payment_sources", "customer_subscriptions", "customers", "delivery_lead_times", "event_callbacks", "events", "exports", "external_gateways", "external_payments", "external_promotions", "external_tax_calculators", "fixed_amount_promotions", "fixed_price_promotions", "free_gift_promotions", "free_shipping_promotions", "geocoders", "gift_card_recipients", "gift_cards", "google_geocoders", "imports", "in_stock_subscriptions", "inventory_models", "inventory_return_locations", "inventory_stock_locations", "klarna_gateways", "klarna_payments", "line_item_options", "line_items", "manual_gateways", "manual_tax_calculators", "markets", "merchants", "order_amount_promotion_rules", "order_copies", "order_factories", "order_subscription_items", "order_subscriptions", "order_validation_rules", "orders", "organization", "packages", "parcel_line_items", "parcels", "payment_gateways", "payment_methods", "paypal_gateways", "paypal_payments", "percentage_discount_promotions", "price_frequency_tiers", "price_lists", "price_tiers", "price_volume_tiers", "prices", "promotion_rules", "promotions", "recurring_order_copies", "refunds", "reserved_stocks", "return_line_items", "returns", "satispay_gateways", "satispay_payments", "shipments", "shipping_categories", "shipping_method_tiers", "shipping_methods", "shipping_weight_tiers", "shipping_zones", "sku_list_items", "sku_list_promotion_rules", "sku_lists", "sku_options", "skus", "stock_items", "stock_line_items", "stock_locations", "stock_reservations", "stock_transfers", "stripe_gateways", "stripe_payments", "subscription_models", "tags", "tax_calculators", "tax_categories", "tax_rules", "taxjar_accounts", "transactions", "versions", "voids", "webhooks", "wire_transfers"];
126
+ export type RetrievableResourceType = ResourceTypeLock;
127
+ export type RetrievableResource = Resource & {
128
+ type: RetrievableResourceType;
129
+ };
130
+ export type ListableResourceType = Exclude<ResourceTypeLock, 'application' | 'organization'>;
131
+ export type ListableResource = Resource & {
132
+ type: ListableResourceType;
133
+ };
134
+ export type CreatableResourceType = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'attachments' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'exports' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'imports' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_subscription_items' | 'order_subscriptions' | 'orders' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_volume_tiers' | 'prices' | 'recurring_order_copies' | 'return_line_items' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipping_categories' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_locations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'subscription_models' | 'tags' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'webhooks' | 'wire_transfers';
135
+ export type CreatableResource = Resource & {
136
+ type: CreatableResourceType;
137
+ };
138
+ export type UpdatableResourceType = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'attachments' | 'authorizations' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'captures' | 'checkout_com_gateways' | 'checkout_com_payments' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_subscription_items' | 'order_subscriptions' | 'orders' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_volume_tiers' | 'prices' | 'recurring_order_copies' | 'return_line_items' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipments' | 'shipping_categories' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_locations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'subscription_models' | 'tags' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'webhooks' | 'wire_transfers';
139
+ export type UpdatableResource = Resource & {
140
+ type: UpdatableResourceType;
141
+ };
142
+ export type DeletableResourceType = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'attachments' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'exports' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'imports' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_subscription_items' | 'order_subscriptions' | 'orders' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_volume_tiers' | 'prices' | 'recurring_order_copies' | 'return_line_items' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipping_categories' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_locations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'subscription_models' | 'tags' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'webhooks' | 'wire_transfers';
143
+ export type DeletableResource = Resource & {
144
+ type: DeletableResourceType;
145
+ };
146
+ export type TaggableResourceType = 'addresses' | 'bundles' | 'coupons' | 'customers' | 'external_promotions' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_cards' | 'line_item_options' | 'line_items' | 'orders' | 'percentage_discount_promotions' | 'promotions' | 'returns' | 'sku_options' | 'skus';
147
+ export type TaggableResource = Resource & {
148
+ type: TaggableResourceType;
149
+ tags?: Array<ResourceRel & {
150
+ type: TagType;
151
+ }> | null;
152
+ };
153
+ export type VersionableResourceType = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'authorizations' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'captures' | 'carrier_accounts' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_payment_sources' | 'customer_subscriptions' | 'delivery_lead_times' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_card_recipients' | 'gift_cards' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_subscriptions' | 'order_validation_rules' | 'orders' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_gateways' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_tiers' | 'price_volume_tiers' | 'prices' | 'promotion_rules' | 'promotions' | 'refunds' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipments' | 'shipping_categories' | 'shipping_method_tiers' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_line_items' | 'stock_locations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'tax_calculators' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'transactions' | 'voids' | 'webhooks' | 'wire_transfers';
154
+ export type VersionableResource = Resource & {
155
+ type: VersionableResourceType;
156
+ versions?: Array<ResourceRel & {
157
+ type: VersionType;
158
+ }> | null;
159
+ };
package/lib/cjs/api.js CHANGED
@@ -367,16 +367,3 @@ exports.resourceList = [
367
367
  'wire_transfers'
368
368
  // ##__API_RESOURCE_LIST_STOP__##
369
369
  ];
370
- /*
371
- type ResourceInfo = {
372
- name: string;
373
- type: string;
374
- api: string;
375
- }
376
-
377
-
378
- export const resourceMap: { [res: string]: ResourceInfo } = {
379
- // ##__API_RESOURCE_MAP_START__##
380
- // ##__API_RESOURCE_MAP_STOP__##
381
- } as const
382
- */
@@ -1,24 +1,29 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { AxiosProxyConfig, Method } from 'axios';
3
+ import type { AxiosAdapter, AxiosProxyConfig, Method } from 'axios';
4
4
  import type { InterceptorManager } from './interceptor';
5
5
  import type { Agent as HttpAgent } from 'http';
6
6
  import type { Agent as HttpsAgent } from 'https';
7
7
  type ProxyConfig = AxiosProxyConfig | false;
8
+ type Adapter = AxiosAdapter;
9
+ type RequestParams = Record<string, string | number | boolean>;
10
+ type RequestHeaders = Record<string, string>;
8
11
  type RequestConfig = {
9
12
  timeout?: number;
10
- params?: {
11
- [key: string]: string | number | boolean;
12
- };
13
+ params?: RequestParams;
13
14
  httpAgent?: HttpAgent;
14
15
  httpsAgent?: HttpsAgent;
15
16
  proxy?: ProxyConfig;
17
+ headers?: RequestHeaders;
16
18
  };
17
- type ApiClientInitConfig = {
19
+ type ApiConfig = {
18
20
  organization: string;
19
21
  domain?: string;
20
22
  accessToken: string;
21
- } & RequestConfig;
23
+ };
24
+ type ApiClientInitConfig = ApiConfig & RequestConfig & {
25
+ adapter?: Adapter;
26
+ };
22
27
  type ApiClientConfig = Partial<ApiClientInitConfig>;
23
28
  declare class ApiClient {
24
29
  #private;
@@ -26,8 +31,10 @@ declare class ApiClient {
26
31
  baseUrl: string;
27
32
  interceptors: InterceptorManager;
28
33
  private constructor();
29
- config(config: ApiClientConfig): void;
34
+ config(config: ApiClientConfig): ApiClient;
35
+ adapter(adapter: Adapter): ApiClient;
30
36
  request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<any>;
37
+ private customHeaders;
31
38
  }
32
39
  export default ApiClient;
33
- export { ApiClientInitConfig, ApiClientConfig, RequestConfig };
40
+ export type { ApiClientInitConfig, ApiClientConfig, RequestConfig };
package/lib/cjs/client.js CHANGED
@@ -15,7 +15,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  var _ApiClient_accessToken, _ApiClient_client;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- /* eslint-disable @typescript-eslint/no-explicit-any */
19
18
  const axios_1 = __importDefault(require("axios"));
20
19
  const error_1 = require("./error");
21
20
  const config_1 = __importDefault(require("./config"));
@@ -24,41 +23,11 @@ const debug = (0, debug_1.default)('client');
24
23
  const baseURL = (organization, domain) => {
25
24
  return `https://${organization.toLowerCase()}.${domain || config_1.default.default.domain}/api`;
26
25
  };
27
- const handleError = (error) => {
28
- let sdkError = new error_1.SdkError({ message: error.message });
29
- if (axios_1.default.isAxiosError(error)) {
30
- if (error.response) {
31
- // The request was made and the server responded with a status code that falls out of the range of 2xx
32
- const apiError = new error_1.ApiError(sdkError);
33
- apiError.type = error_1.ErrorType.RESPONSE;
34
- apiError.status = error.response.status;
35
- apiError.code = String(apiError.status);
36
- apiError.errors = error.response.data.errors;
37
- sdkError = apiError;
38
- }
39
- else if (error.request) {
40
- // The request was made but no response was received
41
- // `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in node.js
42
- sdkError.type = error_1.ErrorType.REQUEST;
43
- sdkError.request = error.request;
44
- }
45
- else {
46
- // Something happened in setting up the request that triggered an Error
47
- sdkError.type = error_1.ErrorType.CLIENT;
48
- }
49
- }
50
- else if (axios_1.default.isCancel(error))
51
- sdkError.type = error_1.ErrorType.CANCEL;
52
- else
53
- sdkError.source = error;
54
- throw sdkError;
55
- };
56
26
  class ApiClient {
57
27
  static create(options) {
58
- if (!(options === null || options === void 0 ? void 0 : options.organization))
59
- throw new Error("Undefined 'organization' parameter");
60
- if (!(options === null || options === void 0 ? void 0 : options.accessToken))
61
- throw new Error("Undefined 'accessToken' parameter");
28
+ for (const attr of config_1.default.client.requiredAttributes)
29
+ if (!options || !options[attr])
30
+ throw new error_1.SdkError({ message: `Undefined '${attr}' parameter` });
62
31
  return new ApiClient(options);
63
32
  }
64
33
  constructor(options) {
@@ -73,11 +42,21 @@ class ApiClient {
73
42
  httpAgent: options.httpAgent,
74
43
  httpsAgent: options.httpsAgent,
75
44
  };
76
- const axiosOptions = Object.assign({ baseURL: this.baseUrl, timeout: config_1.default.client.timeout, headers: {
45
+ // Set custom headers
46
+ const customHeaders = this.customHeaders(options.headers);
47
+ const axiosOptions = {
48
+ baseURL: this.baseUrl,
49
+ timeout: config_1.default.client.timeout,
50
+ headers: {
51
+ ...customHeaders,
77
52
  'Accept': 'application/vnd.api+json',
78
53
  'Content-Type': 'application/vnd.api+json',
79
- 'Authorization': 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f"),
80
- } }, axiosConfig);
54
+ 'Authorization': 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f")
55
+ },
56
+ ...axiosConfig
57
+ };
58
+ if (options.adapter)
59
+ axiosOptions.adapter = options.adapter;
81
60
  debug('axios options: %O', axiosOptions);
82
61
  __classPrivateFieldSet(this, _ApiClient_client, axios_1.default.create(axiosOptions), "f");
83
62
  this.interceptors = __classPrivateFieldGet(this, _ApiClient_client, "f").interceptors;
@@ -101,6 +80,16 @@ class ApiClient {
101
80
  __classPrivateFieldSet(this, _ApiClient_accessToken, config.accessToken, "f");
102
81
  def.headers.common.Authorization = 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f");
103
82
  }
83
+ if (config.headers)
84
+ def.headers.common = this.customHeaders(config.headers);
85
+ if (config.adapter)
86
+ this.adapter(config.adapter);
87
+ return this;
88
+ }
89
+ adapter(adapter) {
90
+ if (adapter)
91
+ __classPrivateFieldGet(this, _ApiClient_client, "f").defaults.adapter = adapter;
92
+ return this;
104
93
  }
105
94
  async request(method, path, body, options) {
106
95
  debug('request %s %s, %O, %O', method, path, body || {}, options || {});
@@ -109,15 +98,26 @@ class ApiClient {
109
98
  // Runtime request parameters
110
99
  const baseUrl = (options === null || options === void 0 ? void 0 : options.organization) ? baseURL(options.organization, options.domain) : undefined;
111
100
  const accessToken = (options === null || options === void 0 ? void 0 : options.accessToken) || __classPrivateFieldGet(this, _ApiClient_accessToken, "f");
112
- const headers = accessToken ? { 'Authorization': 'Bearer ' + accessToken } : undefined;
113
- const requestParams = Object.assign({ method, baseURL: baseUrl, url, data, headers }, options);
101
+ const headers = this.customHeaders(options === null || options === void 0 ? void 0 : options.headers);
102
+ if (accessToken)
103
+ headers.Authorization = 'Bearer ' + accessToken;
104
+ const requestParams = { method, baseURL: baseUrl, url, data, ...options, headers };
114
105
  debug('request params: %O', requestParams);
115
106
  // const start = Date.now()
116
107
  return __classPrivateFieldGet(this, _ApiClient_client, "f").request(requestParams)
117
108
  .then(response => response.data)
118
- .catch(error => handleError(error));
109
+ .catch(error => (0, error_1.handleError)(error));
119
110
  // .finally(() => console.log(`<<-- ${method} ${path} ${Date.now() - start}`))
120
111
  }
112
+ customHeaders(headers) {
113
+ const customHeaders = {};
114
+ if (headers) {
115
+ for (const [name, value] of Object.entries(headers))
116
+ if (!['accept', 'content-type', 'authorization'].includes(name.toLowerCase()))
117
+ customHeaders[name] = value;
118
+ }
119
+ return customHeaders;
120
+ }
121
121
  }
122
122
  _ApiClient_accessToken = new WeakMap(), _ApiClient_client = new WeakMap();
123
123
  exports.default = ApiClient;
@@ -1,7 +1,7 @@
1
1
  import * as api from './api';
2
- import { ApiError } from './error';
2
+ import type { ApiError } from './error';
3
3
  import type { ErrorInterceptor, InterceptorType, RawResponseReader, RequestInterceptor, ResponseInterceptor } from './interceptor';
4
- import { ResourcesInitConfig } from './resource';
4
+ import { type ResourcesInitConfig } from './resource';
5
5
  declare const OPEN_API_SCHEMA_VERSION = "4.12.0";
6
6
  export { OPEN_API_SCHEMA_VERSION };
7
7
  type SdkConfig = {};
@@ -9,7 +9,6 @@ type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig;
9
9
  type CommerceLayerConfig = Partial<CommerceLayerInitConfig>;
10
10
  declare class CommerceLayerClient {
11
11
  #private;
12
- static get openApiSchemaVersion(): string;
13
12
  readonly openApiSchemaVersion = "4.12.0";
14
13
  addresses: api.Addresses;
15
14
  adjustments: api.Adjustments;
@@ -131,7 +130,7 @@ declare class CommerceLayerClient {
131
130
  constructor(config: CommerceLayerInitConfig);
132
131
  get currentOrganization(): string;
133
132
  private localConfig;
134
- config(config: CommerceLayerConfig): void;
133
+ config(config: CommerceLayerConfig): CommerceLayerClient;
135
134
  resources(): readonly string[];
136
135
  isApiError(error: any): error is ApiError;
137
136
  addRequestInterceptor(onFulfilled?: RequestInterceptor, onRejected?: ErrorInterceptor): number;
@@ -48,15 +48,16 @@ const debug = (0, debug_1.default)('commercelayer');
48
48
  const OPEN_API_SCHEMA_VERSION = '4.12.0';
49
49
  exports.OPEN_API_SCHEMA_VERSION = OPEN_API_SCHEMA_VERSION;
50
50
  class CommerceLayerClient {
51
- static get openApiSchemaVersion() { return OPEN_API_SCHEMA_VERSION; }
52
51
  // ##__CL_RESOURCES_DEF_STOP__##
53
52
  constructor(config) {
53
+ // static get openApiSchemaVersion(): string { return OPEN_API_SCHEMA_VERSION }
54
54
  this.openApiSchemaVersion = OPEN_API_SCHEMA_VERSION;
55
55
  _CommerceLayerClient_adapter.set(this, void 0);
56
56
  _CommerceLayerClient_organization.set(this, void 0);
57
57
  debug('new commercelayer instance %O', config);
58
58
  __classPrivateFieldSet(this, _CommerceLayerClient_adapter, new resource_1.default(config), "f");
59
59
  __classPrivateFieldSet(this, _CommerceLayerClient_organization, config.organization, "f");
60
+ // this.#environment = 'test'
60
61
  // ##__CL_RESOURCES_INIT_START__##
61
62
  // ##__CL_RESOURCES_INIT_TEMPLATE:: ##__TAB__####__TAB__##this.##__RESOURCE_TYPE__## = new api.##__RESOURCE_CLASS__##(this.#adapter)
62
63
  this.addresses = new api.Addresses(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
@@ -179,6 +180,8 @@ class CommerceLayerClient {
179
180
  // ##__CL_RESOURCES_INIT_STOP__##
180
181
  }
181
182
  get currentOrganization() { return __classPrivateFieldGet(this, _CommerceLayerClient_organization, "f"); }
183
+ // get currentAccessToken(): string { return this.#adapter?.clientInstance?.currentAccessToken}
184
+ // get environment(): ApiMode { return this.#environment }
182
185
  localConfig(config) {
183
186
  if (config.organization)
184
187
  __classPrivateFieldSet(this, _CommerceLayerClient_organization, config.organization, "f");
@@ -192,6 +195,7 @@ class CommerceLayerClient {
192
195
  if (!config.organization)
193
196
  config.organization = this.currentOrganization;
194
197
  __classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f").config(config);
198
+ return this;
195
199
  }
196
200
  resources() {
197
201
  return static_1.CommerceLayerStatic.resources();
@@ -207,7 +211,7 @@ class CommerceLayerClient {
207
211
  return __classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f").interceptors.response.use(onFulfilled, onRejected);
208
212
  }
209
213
  removeInterceptor(type, id) {
210
- return __classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f").interceptors[type].eject(id);
214
+ __classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f").interceptors[type].eject(id);
211
215
  }
212
216
  addRawResponseReader(options) {
213
217
  const reader = {
@@ -228,7 +232,7 @@ class CommerceLayerClient {
228
232
  removeRawResponseReader(reader) {
229
233
  const id = (typeof reader === 'number') ? reader : reader === null || reader === void 0 ? void 0 : reader.id;
230
234
  if (id && (id >= 0))
231
- return this.removeInterceptor('response', id);
235
+ this.removeInterceptor('response', id);
232
236
  }
233
237
  }
234
238
  _CommerceLayerClient_adapter = new WeakMap(), _CommerceLayerClient_organization = new WeakMap();
@@ -2,3 +2,4 @@ import type { ResourceId, ResourceType } from './resource';
2
2
  declare const isResourceId: (resource: any) => resource is ResourceId;
3
3
  declare const isResourceType: (resource: any) => resource is ResourceType;
4
4
  export { isResourceId, isResourceType };
5
+ export type ObjectType = Record<string, any>;
package/lib/cjs/common.js CHANGED
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
5
3
  exports.isResourceType = exports.isResourceId = void 0;
6
4
  const api_1 = require("./api");
@@ -12,3 +10,14 @@ const isResourceType = (resource) => {
12
10
  return resource && (typeof resource.type !== 'undefined') && resource.type && api_1.resourceList.includes(resource.type);
13
11
  };
14
12
  exports.isResourceType = isResourceType;
13
+ /*
14
+ // Nullable types
15
+ type StringNullable = string | null
16
+ type NumberNullable = number | null
17
+ type BooleanNullable = boolean | null
18
+ type ResourceNullable<R extends Resource> = R | null
19
+ type ResourceArrayNullable<R extends Resource> = R[] | null
20
+
21
+
22
+ export type { StringNullable, NumberNullable, BooleanNullable, ResourceNullable, ResourceArrayNullable }
23
+ */
@@ -6,6 +6,7 @@ declare const config: {
6
6
  };
7
7
  readonly client: {
8
8
  readonly timeout: 15000;
9
+ readonly requiredAttributes: readonly ["organization", "accessToken"];
9
10
  };
10
11
  };
11
12
  export default config;
package/lib/cjs/config.js CHANGED
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
+ // export type ApiMode = 'test' | 'live'
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const config = {
4
5
  default: {
6
+ // environment: 'test',
5
7
  domain: 'commercelayer.io',
6
8
  pageNumber: 1,
7
9
  pageSize: 10,
8
10
  },
9
11
  client: {
10
12
  timeout: 15000,
13
+ requiredAttributes: ['organization', 'accessToken'],
11
14
  }
12
15
  };
13
16
  exports.default = config;
package/lib/cjs/debug.js CHANGED
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- /* eslint-disable @typescript-eslint/no-unused-vars */
4
- // import Debug from 'debug'
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  /* Nope debugger */
7
4
  const debuggerFunction = (_pattern, ..._args) => {
@@ -10,7 +7,6 @@ const debuggerFunction = (_pattern, ..._args) => {
10
7
  let debuggerFactory = (_namespace) => debuggerFunction;
11
8
  /* Try loading 'debug' module */
12
9
  try {
13
- // eslint-disable-next-line @typescript-eslint/no-var-requires
14
10
  const debugModule = require('debug');
15
11
  if (debugModule && (typeof debugModule === 'function'))
16
12
  debuggerFactory = debugModule;
@@ -22,7 +22,9 @@ declare class ApiError extends SdkError {
22
22
  static isApiError(error: any): error is ApiError;
23
23
  errors: any[];
24
24
  status?: number;
25
+ statusText?: string;
25
26
  constructor(error: SdkError);
26
27
  first(): any;
27
28
  }
28
- export { SdkError, ApiError, ErrorType };
29
+ declare const handleError: (error: Error) => never;
30
+ export { SdkError, ApiError, ErrorType, handleError };
package/lib/cjs/error.js CHANGED
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
3
5
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ErrorType = exports.ApiError = exports.SdkError = void 0;
6
+ exports.handleError = exports.ErrorType = exports.ApiError = exports.SdkError = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
5
8
  var ErrorType;
6
9
  (function (ErrorType) {
7
10
  ErrorType["CLIENT"] = "client";
@@ -9,10 +12,8 @@ var ErrorType;
9
12
  ErrorType["RESPONSE"] = "response";
10
13
  ErrorType["GENERIC"] = "generic";
11
14
  ErrorType["CANCEL"] = "cancel";
12
- })(ErrorType || (ErrorType = {}));
13
- exports.ErrorType = ErrorType;
15
+ })(ErrorType || (exports.ErrorType = ErrorType = {}));
14
16
  class SdkError extends Error {
15
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
16
17
  static isSdkError(error) {
17
18
  return error && [SdkError.NAME, ApiError.NAME].includes(error.name) && Object.values(ErrorType).includes(error.type);
18
19
  }
@@ -25,12 +26,11 @@ class SdkError extends Error {
25
26
  exports.SdkError = SdkError;
26
27
  SdkError.NAME = 'SdkError';
27
28
  class ApiError extends SdkError {
28
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
29
29
  static isApiError(error) {
30
30
  return SdkError.isSdkError(error) && (error.name === ApiError.NAME) && (error.type === ErrorType.RESPONSE);
31
31
  }
32
32
  constructor(error) {
33
- super(Object.assign(Object.assign({}, error), { type: ErrorType.RESPONSE }));
33
+ super({ ...error, type: ErrorType.RESPONSE });
34
34
  this.errors = [];
35
35
  this.name = ApiError.NAME; // this.constructor.name
36
36
  }
@@ -41,3 +41,36 @@ class ApiError extends SdkError {
41
41
  }
42
42
  exports.ApiError = ApiError;
43
43
  ApiError.NAME = 'ApiError';
44
+ const handleError = (error) => {
45
+ let sdkError = new SdkError({ message: error.message });
46
+ if (axios_1.default.isAxiosError(error)) {
47
+ if (error.response) {
48
+ // The request was made and the server responded with a status code that falls out of the range of 2xx
49
+ const apiError = new ApiError(sdkError);
50
+ apiError.type = ErrorType.RESPONSE;
51
+ apiError.status = error.response.status;
52
+ apiError.statusText = error.response.statusText;
53
+ apiError.code = String(apiError.status);
54
+ apiError.errors = error.response.data.errors;
55
+ if (!apiError.message && apiError.statusText)
56
+ apiError.message = apiError.statusText;
57
+ sdkError = apiError;
58
+ }
59
+ else if (error.request) {
60
+ // The request was made but no response was received
61
+ // `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in node.js
62
+ sdkError.type = ErrorType.REQUEST;
63
+ sdkError.request = error.request;
64
+ }
65
+ else {
66
+ // Something happened in setting up the request that triggered an Error
67
+ sdkError.type = ErrorType.CLIENT;
68
+ }
69
+ }
70
+ else if (axios_1.default.isCancel(error))
71
+ sdkError.type = ErrorType.CANCEL;
72
+ else
73
+ sdkError.source = error;
74
+ throw sdkError;
75
+ };
76
+ exports.handleError = handleError;
@@ -2,6 +2,6 @@ export { default, CommerceLayer } from './commercelayer';
2
2
  export type { CommerceLayerClient } from './commercelayer';
3
3
  export { CommerceLayerStatic } from './static';
4
4
  export type { QueryParamsRetrieve, QueryParamsList, QueryParams } from './query';
5
- export * from './model';
5
+ export type * from './model';
6
6
  export type { RequestObj, ResponseObj, ErrorObj, HeadersObj } from './interceptor';
7
7
  export type { SdkError, ApiError, ErrorType } from './error';
package/lib/cjs/index.js CHANGED
@@ -1,18 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
17
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
4
  };
@@ -25,5 +11,3 @@ Object.defineProperty(exports, "CommerceLayer", { enumerable: true, get: functio
25
11
  // Commerce Layer static functions
26
12
  var static_1 = require("./static");
27
13
  Object.defineProperty(exports, "CommerceLayerStatic", { enumerable: true, get: function () { return static_1.CommerceLayerStatic; } });
28
- // Resource model types
29
- __exportStar(require("./model"), exports);
@@ -1,4 +1,4 @@
1
- import { AxiosError, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, RawAxiosResponseHeaders } from 'axios';
1
+ import type { AxiosError, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, RawAxiosResponseHeaders } from 'axios';
2
2
  type InterceptorManager = {
3
3
  request: AxiosInterceptorManager<AxiosRequestConfig>;
4
4
  response: AxiosInterceptorManager<any>;
@@ -7,7 +7,11 @@ type RequestObj = AxiosRequestConfig;
7
7
  type RequestInterceptor = (request: RequestObj) => RequestObj | Promise<RequestObj>;
8
8
  type ResponseObj = AxiosResponse;
9
9
  type ResponseInterceptor = (response: ResponseObj) => ResponseObj;
10
- type HeadersObj = AxiosResponseHeaders | RawAxiosResponseHeaders;
10
+ type ApiHeadersList = 'x-ratelimit-limit' | 'x-ratelimit-count' | 'x-ratelimit-period' | 'x-ratelimit-interval' | 'x-ratelimit-remaining';
11
+ type ApiHeaders = {
12
+ [key in ApiHeadersList]: string | number | boolean;
13
+ };
14
+ type HeadersObj = (AxiosResponseHeaders | RawAxiosResponseHeaders) & ApiHeaders;
11
15
  type ErrorObj = AxiosError;
12
16
  type ErrorInterceptor = (error: ErrorObj) => ErrorObj;
13
17
  type InterceptorType = 'request' | 'response';
@@ -35,7 +35,11 @@ const denormalizeResource = (res, included) => {
35
35
  debug('denormalize resource: %O, %o', res, included || {});
36
36
  if (!res)
37
37
  return res;
38
- const resource = Object.assign({ id: res.id, type: res.type }, res.attributes);
38
+ const resource = {
39
+ id: res.id,
40
+ type: res.type,
41
+ ...res.attributes,
42
+ };
39
43
  if (res.relationships)
40
44
  Object.keys(res.relationships).forEach(key => {
41
45
  const rel = res.relationships[key].data;
@@ -60,7 +64,10 @@ const normalize = (resource) => {
60
64
  if (['type', 'id'].includes(field))
61
65
  continue;
62
66
  const value = resource[field];
63
- if (value && (0, common_1.isResourceType)(value) && value.id === null) {
67
+ if (Array.isArray(value) && (value.length === 1) && (0, common_1.isResourceType)(value[0]) && (value[0].id === null)) {
68
+ relationships[field] = { data: [] };
69
+ }
70
+ else if (value && (0, common_1.isResourceType)(value) && (value.id === null)) {
64
71
  relationships[field] = { data: null };
65
72
  }
66
73
  else if (value && ((0, common_1.isResourceId)(value) || (Array.isArray(value) && (0, common_1.isResourceId)(value[0])))) {
@@ -1,23 +1,17 @@
1
- import { ResourceType } from "./resource";
1
+ import type { ResourceType } from "./resource";
2
+ type QueryFilter = Record<string, string | number | boolean>;
2
3
  interface QueryParamsRetrieve {
3
4
  include?: string[];
4
- fields?: string[] | {
5
- [key: string]: string[];
6
- };
5
+ fields?: string[] | Record<string, string[]>;
7
6
  }
8
7
  interface QueryParamsList extends QueryParamsRetrieve {
9
- sort?: string[] | {
10
- [key: string]: 'asc' | 'desc';
11
- };
12
- filters?: {
13
- [key: string]: string | number | boolean;
14
- };
8
+ sort?: string[] | Record<string, 'asc' | 'desc'>;
9
+ filters?: QueryFilter;
15
10
  pageNumber?: number;
16
11
  pageSize?: number;
17
12
  }
18
13
  type QueryParams = QueryParamsRetrieve | QueryParamsList;
19
- export { QueryParamsRetrieve, QueryParamsList, QueryParams };
20
- declare const generateQueryStringParams: (params: QueryParamsRetrieve | QueryParamsList | undefined, res: string | ResourceType) => {
21
- [key: string]: string;
22
- };
23
- export { generateQueryStringParams };
14
+ export type { QueryParamsRetrieve, QueryParamsList, QueryParams, QueryFilter };
15
+ declare const isParamsList: (params: any) => params is QueryParamsList;
16
+ declare const generateQueryStringParams: (params: QueryParamsRetrieve | QueryParamsList | undefined, res: string | ResourceType) => Record<string, string>;
17
+ export { generateQueryStringParams, isParamsList };
package/lib/cjs/query.js CHANGED
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateQueryStringParams = void 0;
6
+ exports.isParamsList = exports.generateQueryStringParams = void 0;
7
7
  const debug_1 = __importDefault(require("./debug"));
8
8
  const debug = (0, debug_1.default)('query');
9
9
  const isParamsList = (params) => {
10
- return (params.filters || params.pageNumber || params.pageSize || params.sort);
10
+ return params && (params.filters || params.pageNumber || params.pageSize || params.sort);
11
11
  };
12
+ exports.isParamsList = isParamsList;
12
13
  const generateQueryStringParams = (params, res) => {
13
14
  debug('generate query string params: %O, %O', params, res);
14
15
  const qp = {};