@commercelayer/sdk 4.21.0 → 4.23.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 (479) hide show
  1. package/lib/cjs/api.d.ts +109 -1
  2. package/lib/cjs/api.js +343 -1
  3. package/lib/cjs/client.d.ts +31 -1
  4. package/lib/cjs/client.js +123 -1
  5. package/lib/cjs/commercelayer.d.ts +133 -1
  6. package/lib/cjs/commercelayer.js +224 -1
  7. package/lib/cjs/common.d.ts +4 -1
  8. package/lib/cjs/common.js +14 -1
  9. package/lib/cjs/config.d.ts +11 -1
  10. package/lib/cjs/config.js +13 -1
  11. package/lib/cjs/debug.d.ts +3 -1
  12. package/lib/cjs/debug.js +42 -1
  13. package/lib/cjs/error.d.ts +28 -1
  14. package/lib/cjs/error.js +43 -1
  15. package/lib/cjs/index.d.ts +7 -1
  16. package/lib/cjs/index.js +29 -1
  17. package/lib/cjs/interceptor.d.ts +21 -1
  18. package/lib/cjs/interceptor.js +2 -1
  19. package/lib/cjs/jsonapi.d.ts +5 -1
  20. package/lib/cjs/jsonapi.js +82 -1
  21. package/lib/cjs/model.d.ts +107 -1
  22. package/lib/cjs/model.js +3 -1
  23. package/lib/cjs/query.d.ts +23 -1
  24. package/lib/cjs/query.js +51 -1
  25. package/lib/cjs/resource.d.ts +77 -1
  26. package/lib/cjs/resource.js +145 -1
  27. package/lib/cjs/resources/addresses.d.ts +88 -1
  28. package/lib/cjs/resources/addresses.js +37 -1
  29. package/lib/cjs/resources/adjustments.d.ts +35 -1
  30. package/lib/cjs/resources/adjustments.js +33 -1
  31. package/lib/cjs/resources/adyen_gateways.d.ts +56 -1
  32. package/lib/cjs/resources/adyen_gateways.js +41 -1
  33. package/lib/cjs/resources/adyen_payments.d.ts +45 -1
  34. package/lib/cjs/resources/adyen_payments.js +41 -1
  35. package/lib/cjs/resources/application.d.ts +21 -1
  36. package/lib/cjs/resources/application.js +21 -1
  37. package/lib/cjs/resources/attachments.d.ts +156 -1
  38. package/lib/cjs/resources/attachments.js +33 -1
  39. package/lib/cjs/resources/authorizations.d.ts +60 -1
  40. package/lib/cjs/resources/authorizations.js +43 -1
  41. package/lib/cjs/resources/avalara_accounts.d.ts +55 -1
  42. package/lib/cjs/resources/avalara_accounts.js +45 -1
  43. package/lib/cjs/resources/billing_info_validation_rules.d.ts +35 -1
  44. package/lib/cjs/resources/billing_info_validation_rules.js +41 -1
  45. package/lib/cjs/resources/bing_geocoders.d.ts +35 -1
  46. package/lib/cjs/resources/bing_geocoders.js +41 -1
  47. package/lib/cjs/resources/braintree_gateways.d.ts +56 -1
  48. package/lib/cjs/resources/braintree_gateways.js +41 -1
  49. package/lib/cjs/resources/braintree_payments.d.ts +47 -1
  50. package/lib/cjs/resources/braintree_payments.js +41 -1
  51. package/lib/cjs/resources/bundles.d.ts +76 -1
  52. package/lib/cjs/resources/bundles.js +49 -1
  53. package/lib/cjs/resources/captures.d.ts +51 -1
  54. package/lib/cjs/resources/captures.js +43 -1
  55. package/lib/cjs/resources/carrier_accounts.d.ts +26 -1
  56. package/lib/cjs/resources/carrier_accounts.js +32 -1
  57. package/lib/cjs/resources/checkout_com_gateways.d.ts +45 -1
  58. package/lib/cjs/resources/checkout_com_gateways.js +41 -1
  59. package/lib/cjs/resources/checkout_com_payments.d.ts +58 -1
  60. package/lib/cjs/resources/checkout_com_payments.js +41 -1
  61. package/lib/cjs/resources/cleanups.d.ts +36 -1
  62. package/lib/cjs/resources/cleanups.js +34 -1
  63. package/lib/cjs/resources/coupon_codes_promotion_rules.d.ts +59 -1
  64. package/lib/cjs/resources/coupon_codes_promotion_rules.js +37 -1
  65. package/lib/cjs/resources/coupon_recipients.d.ts +44 -1
  66. package/lib/cjs/resources/coupon_recipients.js +41 -1
  67. package/lib/cjs/resources/coupons.d.ts +45 -1
  68. package/lib/cjs/resources/coupons.js +37 -1
  69. package/lib/cjs/resources/customer_addresses.d.ts +44 -1
  70. package/lib/cjs/resources/customer_addresses.js +45 -1
  71. package/lib/cjs/resources/customer_groups.d.ts +36 -1
  72. package/lib/cjs/resources/customer_groups.js +45 -1
  73. package/lib/cjs/resources/customer_password_resets.d.ts +36 -1
  74. package/lib/cjs/resources/customer_password_resets.js +41 -1
  75. package/lib/cjs/resources/customer_payment_sources.d.ts +70 -1
  76. package/lib/cjs/resources/customer_payment_sources.js +37 -1
  77. package/lib/cjs/resources/customer_subscriptions.d.ts +31 -1
  78. package/lib/cjs/resources/customer_subscriptions.js +41 -1
  79. package/lib/cjs/resources/customers.d.ts +66 -1
  80. package/lib/cjs/resources/customers.js +73 -1
  81. package/lib/cjs/resources/delivery_lead_times.d.ts +51 -1
  82. package/lib/cjs/resources/delivery_lead_times.js +45 -1
  83. package/lib/cjs/resources/event_callbacks.d.ts +24 -1
  84. package/lib/cjs/resources/event_callbacks.js +28 -1
  85. package/lib/cjs/resources/events.d.ts +24 -1
  86. package/lib/cjs/resources/events.js +32 -1
  87. package/lib/cjs/resources/exports.d.ts +40 -1
  88. package/lib/cjs/resources/exports.js +34 -1
  89. package/lib/cjs/resources/external_gateways.d.ts +49 -1
  90. package/lib/cjs/resources/external_gateways.js +41 -1
  91. package/lib/cjs/resources/external_payments.d.ts +43 -1
  92. package/lib/cjs/resources/external_payments.js +45 -1
  93. package/lib/cjs/resources/external_promotions.d.ts +90 -1
  94. package/lib/cjs/resources/external_promotions.js +57 -1
  95. package/lib/cjs/resources/external_tax_calculators.d.ts +37 -1
  96. package/lib/cjs/resources/external_tax_calculators.js +41 -1
  97. package/lib/cjs/resources/fixed_amount_promotions.d.ts +91 -1
  98. package/lib/cjs/resources/fixed_amount_promotions.js +57 -1
  99. package/lib/cjs/resources/fixed_price_promotions.d.ts +102 -1
  100. package/lib/cjs/resources/fixed_price_promotions.js +65 -1
  101. package/lib/cjs/resources/free_gift_promotions.d.ts +100 -1
  102. package/lib/cjs/resources/free_gift_promotions.js +65 -1
  103. package/lib/cjs/resources/free_shipping_promotions.d.ts +83 -1
  104. package/lib/cjs/resources/free_shipping_promotions.js +53 -1
  105. package/lib/cjs/resources/geocoders.d.ts +24 -1
  106. package/lib/cjs/resources/geocoders.js +32 -1
  107. package/lib/cjs/resources/gift_card_recipients.d.ts +44 -1
  108. package/lib/cjs/resources/gift_card_recipients.js +41 -1
  109. package/lib/cjs/resources/gift_cards.d.ts +85 -1
  110. package/lib/cjs/resources/gift_cards.js +49 -1
  111. package/lib/cjs/resources/google_geocoders.d.ts +35 -1
  112. package/lib/cjs/resources/google_geocoders.js +41 -1
  113. package/lib/cjs/resources/imports.d.ts +45 -1
  114. package/lib/cjs/resources/imports.js +34 -1
  115. package/lib/cjs/resources/in_stock_subscriptions.d.ts +62 -1
  116. package/lib/cjs/resources/in_stock_subscriptions.js +49 -1
  117. package/lib/cjs/resources/inventory_models.d.ts +42 -1
  118. package/lib/cjs/resources/inventory_models.js +45 -1
  119. package/lib/cjs/resources/inventory_return_locations.d.ts +43 -1
  120. package/lib/cjs/resources/inventory_return_locations.js +41 -1
  121. package/lib/cjs/resources/inventory_stock_locations.d.ts +46 -1
  122. package/lib/cjs/resources/inventory_stock_locations.js +41 -1
  123. package/lib/cjs/resources/klarna_gateways.d.ts +44 -1
  124. package/lib/cjs/resources/klarna_gateways.js +41 -1
  125. package/lib/cjs/resources/klarna_payments.d.ts +45 -1
  126. package/lib/cjs/resources/klarna_payments.js +41 -1
  127. package/lib/cjs/resources/line_item_options.d.ts +57 -1
  128. package/lib/cjs/resources/line_item_options.js +41 -1
  129. package/lib/cjs/resources/line_items.d.ts +126 -1
  130. package/lib/cjs/resources/line_items.js +49 -1
  131. package/lib/cjs/resources/manual_gateways.d.ts +33 -1
  132. package/lib/cjs/resources/manual_gateways.js +37 -1
  133. package/lib/cjs/resources/manual_tax_calculators.d.ts +41 -1
  134. package/lib/cjs/resources/manual_tax_calculators.js +45 -1
  135. package/lib/cjs/resources/markets.d.ts +88 -1
  136. package/lib/cjs/resources/markets.js +57 -1
  137. package/lib/cjs/resources/merchants.d.ts +38 -1
  138. package/lib/cjs/resources/merchants.js +41 -1
  139. package/lib/cjs/resources/order_amount_promotion_rules.d.ts +56 -1
  140. package/lib/cjs/resources/order_amount_promotion_rules.js +33 -1
  141. package/lib/cjs/resources/order_copies.d.ts +48 -1
  142. package/lib/cjs/resources/order_copies.js +46 -1
  143. package/lib/cjs/resources/order_subscriptions.d.ts +70 -1
  144. package/lib/cjs/resources/order_subscriptions.js +57 -1
  145. package/lib/cjs/resources/order_validation_rules.d.ts +23 -1
  146. package/lib/cjs/resources/order_validation_rules.js +32 -1
  147. package/lib/cjs/resources/orders.d.ts +288 -1
  148. package/lib/cjs/resources/orders.js +113 -1
  149. package/lib/cjs/resources/organization.d.ts +32 -1
  150. package/lib/cjs/resources/organization.js +21 -1
  151. package/lib/cjs/resources/packages.d.ts +56 -1
  152. package/lib/cjs/resources/packages.js +45 -1
  153. package/lib/cjs/resources/parcel_line_items.d.ts +51 -1
  154. package/lib/cjs/resources/parcel_line_items.js +41 -1
  155. package/lib/cjs/resources/parcels.d.ts +119 -1
  156. package/lib/cjs/resources/parcels.js +53 -1
  157. package/lib/cjs/resources/payment_gateways.d.ts +21 -1
  158. package/lib/cjs/resources/payment_gateways.js +28 -1
  159. package/lib/cjs/resources/payment_methods.d.ts +61 -1
  160. package/lib/cjs/resources/payment_methods.js +45 -1
  161. package/lib/cjs/resources/paypal_gateways.d.ts +37 -1
  162. package/lib/cjs/resources/paypal_gateways.js +41 -1
  163. package/lib/cjs/resources/paypal_payments.d.ts +51 -1
  164. package/lib/cjs/resources/paypal_payments.js +41 -1
  165. package/lib/cjs/resources/percentage_discount_promotions.d.ts +100 -1
  166. package/lib/cjs/resources/percentage_discount_promotions.js +65 -1
  167. package/lib/cjs/resources/price_lists.d.ts +39 -1
  168. package/lib/cjs/resources/price_lists.js +41 -1
  169. package/lib/cjs/resources/price_tiers.d.ts +28 -1
  170. package/lib/cjs/resources/price_tiers.js +32 -1
  171. package/lib/cjs/resources/price_volume_tiers.d.ts +46 -1
  172. package/lib/cjs/resources/price_volume_tiers.js +41 -1
  173. package/lib/cjs/resources/prices.d.ts +68 -1
  174. package/lib/cjs/resources/prices.js +53 -1
  175. package/lib/cjs/resources/promotion_rules.d.ts +24 -1
  176. package/lib/cjs/resources/promotion_rules.js +24 -1
  177. package/lib/cjs/resources/promotions.d.ts +41 -1
  178. package/lib/cjs/resources/promotions.js +44 -1
  179. package/lib/cjs/resources/refunds.d.ts +37 -1
  180. package/lib/cjs/resources/refunds.js +36 -1
  181. package/lib/cjs/resources/return_line_items.d.ts +49 -1
  182. package/lib/cjs/resources/return_line_items.js +41 -1
  183. package/lib/cjs/resources/returns.d.ts +75 -1
  184. package/lib/cjs/resources/returns.js +65 -1
  185. package/lib/cjs/resources/shipments.d.ts +93 -1
  186. package/lib/cjs/resources/shipments.js +83 -1
  187. package/lib/cjs/resources/shipping_categories.d.ts +33 -1
  188. package/lib/cjs/resources/shipping_categories.js +41 -1
  189. package/lib/cjs/resources/shipping_method_tiers.d.ts +28 -1
  190. package/lib/cjs/resources/shipping_method_tiers.js +32 -1
  191. package/lib/cjs/resources/shipping_methods.d.ts +107 -1
  192. package/lib/cjs/resources/shipping_methods.js +65 -1
  193. package/lib/cjs/resources/shipping_weight_tiers.d.ts +46 -1
  194. package/lib/cjs/resources/shipping_weight_tiers.js +41 -1
  195. package/lib/cjs/resources/shipping_zones.d.ts +48 -1
  196. package/lib/cjs/resources/shipping_zones.js +37 -1
  197. package/lib/cjs/resources/sku_list_items.d.ts +47 -1
  198. package/lib/cjs/resources/sku_list_items.js +41 -1
  199. package/lib/cjs/resources/sku_list_promotion_rules.d.ts +68 -1
  200. package/lib/cjs/resources/sku_list_promotion_rules.js +41 -1
  201. package/lib/cjs/resources/sku_lists.d.ts +60 -1
  202. package/lib/cjs/resources/sku_lists.js +53 -1
  203. package/lib/cjs/resources/sku_options.d.ts +56 -1
  204. package/lib/cjs/resources/sku_options.js +41 -1
  205. package/lib/cjs/resources/skus.d.ts +78 -1
  206. package/lib/cjs/resources/skus.js +57 -1
  207. package/lib/cjs/resources/stock_items.d.ts +49 -1
  208. package/lib/cjs/resources/stock_items.js +45 -1
  209. package/lib/cjs/resources/stock_line_items.d.ts +29 -1
  210. package/lib/cjs/resources/stock_line_items.js +36 -1
  211. package/lib/cjs/resources/stock_locations.d.ts +57 -1
  212. package/lib/cjs/resources/stock_locations.js +57 -1
  213. package/lib/cjs/resources/stock_transfers.d.ts +74 -1
  214. package/lib/cjs/resources/stock_transfers.js +57 -1
  215. package/lib/cjs/resources/stripe_gateways.d.ts +41 -1
  216. package/lib/cjs/resources/stripe_gateways.js +41 -1
  217. package/lib/cjs/resources/stripe_payments.d.ts +46 -1
  218. package/lib/cjs/resources/stripe_payments.js +41 -1
  219. package/lib/cjs/resources/tax_calculators.d.ts +24 -1
  220. package/lib/cjs/resources/tax_calculators.js +32 -1
  221. package/lib/cjs/resources/tax_categories.d.ts +59 -1
  222. package/lib/cjs/resources/tax_categories.js +41 -1
  223. package/lib/cjs/resources/tax_rules.d.ts +69 -1
  224. package/lib/cjs/resources/tax_rules.js +37 -1
  225. package/lib/cjs/resources/taxjar_accounts.d.ts +43 -1
  226. package/lib/cjs/resources/taxjar_accounts.js +45 -1
  227. package/lib/cjs/resources/transactions.d.ts +31 -1
  228. package/lib/cjs/resources/transactions.js +28 -1
  229. package/lib/cjs/resources/voids.d.ts +37 -1
  230. package/lib/cjs/resources/voids.js +36 -1
  231. package/lib/cjs/resources/webhooks.d.ts +43 -1
  232. package/lib/cjs/resources/webhooks.js +37 -1
  233. package/lib/cjs/resources/wire_transfers.d.ts +32 -1
  234. package/lib/cjs/resources/wire_transfers.js +37 -1
  235. package/lib/cjs/static.d.ts +8 -1
  236. package/lib/cjs/static.js +47 -1
  237. package/lib/cjs/util.d.ts +6 -1
  238. package/lib/cjs/util.js +15 -1
  239. package/lib/esm/api.d.ts +109 -1
  240. package/lib/esm/api.js +231 -1
  241. package/lib/esm/client.d.ts +31 -1
  242. package/lib/esm/client.js +118 -1
  243. package/lib/esm/commercelayer.d.ts +133 -1
  244. package/lib/esm/commercelayer.js +195 -1
  245. package/lib/esm/common.d.ts +4 -1
  246. package/lib/esm/common.js +10 -1
  247. package/lib/esm/config.d.ts +11 -1
  248. package/lib/esm/config.js +11 -1
  249. package/lib/esm/debug.d.ts +3 -1
  250. package/lib/esm/debug.js +40 -1
  251. package/lib/esm/error.d.ts +28 -1
  252. package/lib/esm/error.js +38 -1
  253. package/lib/esm/index.d.ts +7 -1
  254. package/lib/esm/index.js +6 -1
  255. package/lib/esm/interceptor.d.ts +21 -1
  256. package/lib/esm/interceptor.js +1 -1
  257. package/lib/esm/jsonapi.d.ts +5 -1
  258. package/lib/esm/jsonapi.js +75 -1
  259. package/lib/esm/model.d.ts +107 -1
  260. package/lib/esm/model.js +2 -1
  261. package/lib/esm/query.d.ts +23 -1
  262. package/lib/esm/query.js +45 -1
  263. package/lib/esm/resource.d.ts +77 -1
  264. package/lib/esm/resource.js +139 -1
  265. package/lib/esm/resources/addresses.d.ts +88 -1
  266. package/lib/esm/resources/addresses.js +35 -1
  267. package/lib/esm/resources/adjustments.d.ts +35 -1
  268. package/lib/esm/resources/adjustments.js +31 -1
  269. package/lib/esm/resources/adyen_gateways.d.ts +56 -1
  270. package/lib/esm/resources/adyen_gateways.js +39 -1
  271. package/lib/esm/resources/adyen_payments.d.ts +45 -1
  272. package/lib/esm/resources/adyen_payments.js +39 -1
  273. package/lib/esm/resources/application.d.ts +21 -1
  274. package/lib/esm/resources/application.js +19 -1
  275. package/lib/esm/resources/attachments.d.ts +156 -1
  276. package/lib/esm/resources/attachments.js +31 -1
  277. package/lib/esm/resources/authorizations.d.ts +60 -1
  278. package/lib/esm/resources/authorizations.js +41 -1
  279. package/lib/esm/resources/avalara_accounts.d.ts +55 -1
  280. package/lib/esm/resources/avalara_accounts.js +43 -1
  281. package/lib/esm/resources/billing_info_validation_rules.d.ts +35 -1
  282. package/lib/esm/resources/billing_info_validation_rules.js +39 -1
  283. package/lib/esm/resources/bing_geocoders.d.ts +35 -1
  284. package/lib/esm/resources/bing_geocoders.js +39 -1
  285. package/lib/esm/resources/braintree_gateways.d.ts +56 -1
  286. package/lib/esm/resources/braintree_gateways.js +39 -1
  287. package/lib/esm/resources/braintree_payments.d.ts +47 -1
  288. package/lib/esm/resources/braintree_payments.js +39 -1
  289. package/lib/esm/resources/bundles.d.ts +76 -1
  290. package/lib/esm/resources/bundles.js +47 -1
  291. package/lib/esm/resources/captures.d.ts +51 -1
  292. package/lib/esm/resources/captures.js +41 -1
  293. package/lib/esm/resources/carrier_accounts.d.ts +26 -1
  294. package/lib/esm/resources/carrier_accounts.js +30 -1
  295. package/lib/esm/resources/checkout_com_gateways.d.ts +45 -1
  296. package/lib/esm/resources/checkout_com_gateways.js +39 -1
  297. package/lib/esm/resources/checkout_com_payments.d.ts +58 -1
  298. package/lib/esm/resources/checkout_com_payments.js +39 -1
  299. package/lib/esm/resources/cleanups.d.ts +36 -1
  300. package/lib/esm/resources/cleanups.js +32 -1
  301. package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +59 -1
  302. package/lib/esm/resources/coupon_codes_promotion_rules.js +35 -1
  303. package/lib/esm/resources/coupon_recipients.d.ts +44 -1
  304. package/lib/esm/resources/coupon_recipients.js +39 -1
  305. package/lib/esm/resources/coupons.d.ts +45 -1
  306. package/lib/esm/resources/coupons.js +35 -1
  307. package/lib/esm/resources/customer_addresses.d.ts +44 -1
  308. package/lib/esm/resources/customer_addresses.js +43 -1
  309. package/lib/esm/resources/customer_groups.d.ts +36 -1
  310. package/lib/esm/resources/customer_groups.js +43 -1
  311. package/lib/esm/resources/customer_password_resets.d.ts +36 -1
  312. package/lib/esm/resources/customer_password_resets.js +39 -1
  313. package/lib/esm/resources/customer_payment_sources.d.ts +70 -1
  314. package/lib/esm/resources/customer_payment_sources.js +35 -1
  315. package/lib/esm/resources/customer_subscriptions.d.ts +31 -1
  316. package/lib/esm/resources/customer_subscriptions.js +39 -1
  317. package/lib/esm/resources/customers.d.ts +66 -1
  318. package/lib/esm/resources/customers.js +71 -1
  319. package/lib/esm/resources/delivery_lead_times.d.ts +51 -1
  320. package/lib/esm/resources/delivery_lead_times.js +43 -1
  321. package/lib/esm/resources/event_callbacks.d.ts +24 -1
  322. package/lib/esm/resources/event_callbacks.js +26 -1
  323. package/lib/esm/resources/events.d.ts +24 -1
  324. package/lib/esm/resources/events.js +30 -1
  325. package/lib/esm/resources/exports.d.ts +40 -1
  326. package/lib/esm/resources/exports.js +32 -1
  327. package/lib/esm/resources/external_gateways.d.ts +49 -1
  328. package/lib/esm/resources/external_gateways.js +39 -1
  329. package/lib/esm/resources/external_payments.d.ts +43 -1
  330. package/lib/esm/resources/external_payments.js +43 -1
  331. package/lib/esm/resources/external_promotions.d.ts +90 -1
  332. package/lib/esm/resources/external_promotions.js +55 -1
  333. package/lib/esm/resources/external_tax_calculators.d.ts +37 -1
  334. package/lib/esm/resources/external_tax_calculators.js +39 -1
  335. package/lib/esm/resources/fixed_amount_promotions.d.ts +91 -1
  336. package/lib/esm/resources/fixed_amount_promotions.js +55 -1
  337. package/lib/esm/resources/fixed_price_promotions.d.ts +102 -1
  338. package/lib/esm/resources/fixed_price_promotions.js +63 -1
  339. package/lib/esm/resources/free_gift_promotions.d.ts +100 -1
  340. package/lib/esm/resources/free_gift_promotions.js +63 -1
  341. package/lib/esm/resources/free_shipping_promotions.d.ts +83 -1
  342. package/lib/esm/resources/free_shipping_promotions.js +51 -1
  343. package/lib/esm/resources/geocoders.d.ts +24 -1
  344. package/lib/esm/resources/geocoders.js +30 -1
  345. package/lib/esm/resources/gift_card_recipients.d.ts +44 -1
  346. package/lib/esm/resources/gift_card_recipients.js +39 -1
  347. package/lib/esm/resources/gift_cards.d.ts +85 -1
  348. package/lib/esm/resources/gift_cards.js +47 -1
  349. package/lib/esm/resources/google_geocoders.d.ts +35 -1
  350. package/lib/esm/resources/google_geocoders.js +39 -1
  351. package/lib/esm/resources/imports.d.ts +45 -1
  352. package/lib/esm/resources/imports.js +32 -1
  353. package/lib/esm/resources/in_stock_subscriptions.d.ts +62 -1
  354. package/lib/esm/resources/in_stock_subscriptions.js +47 -1
  355. package/lib/esm/resources/inventory_models.d.ts +42 -1
  356. package/lib/esm/resources/inventory_models.js +43 -1
  357. package/lib/esm/resources/inventory_return_locations.d.ts +43 -1
  358. package/lib/esm/resources/inventory_return_locations.js +39 -1
  359. package/lib/esm/resources/inventory_stock_locations.d.ts +46 -1
  360. package/lib/esm/resources/inventory_stock_locations.js +39 -1
  361. package/lib/esm/resources/klarna_gateways.d.ts +44 -1
  362. package/lib/esm/resources/klarna_gateways.js +39 -1
  363. package/lib/esm/resources/klarna_payments.d.ts +45 -1
  364. package/lib/esm/resources/klarna_payments.js +39 -1
  365. package/lib/esm/resources/line_item_options.d.ts +57 -1
  366. package/lib/esm/resources/line_item_options.js +39 -1
  367. package/lib/esm/resources/line_items.d.ts +126 -1
  368. package/lib/esm/resources/line_items.js +47 -1
  369. package/lib/esm/resources/manual_gateways.d.ts +33 -1
  370. package/lib/esm/resources/manual_gateways.js +35 -1
  371. package/lib/esm/resources/manual_tax_calculators.d.ts +41 -1
  372. package/lib/esm/resources/manual_tax_calculators.js +43 -1
  373. package/lib/esm/resources/markets.d.ts +88 -1
  374. package/lib/esm/resources/markets.js +55 -1
  375. package/lib/esm/resources/merchants.d.ts +38 -1
  376. package/lib/esm/resources/merchants.js +39 -1
  377. package/lib/esm/resources/order_amount_promotion_rules.d.ts +56 -1
  378. package/lib/esm/resources/order_amount_promotion_rules.js +31 -1
  379. package/lib/esm/resources/order_copies.d.ts +48 -1
  380. package/lib/esm/resources/order_copies.js +44 -1
  381. package/lib/esm/resources/order_subscriptions.d.ts +70 -1
  382. package/lib/esm/resources/order_subscriptions.js +55 -1
  383. package/lib/esm/resources/order_validation_rules.d.ts +23 -1
  384. package/lib/esm/resources/order_validation_rules.js +30 -1
  385. package/lib/esm/resources/orders.d.ts +288 -1
  386. package/lib/esm/resources/orders.js +111 -1
  387. package/lib/esm/resources/organization.d.ts +32 -1
  388. package/lib/esm/resources/organization.js +19 -1
  389. package/lib/esm/resources/packages.d.ts +56 -1
  390. package/lib/esm/resources/packages.js +43 -1
  391. package/lib/esm/resources/parcel_line_items.d.ts +51 -1
  392. package/lib/esm/resources/parcel_line_items.js +39 -1
  393. package/lib/esm/resources/parcels.d.ts +119 -1
  394. package/lib/esm/resources/parcels.js +51 -1
  395. package/lib/esm/resources/payment_gateways.d.ts +21 -1
  396. package/lib/esm/resources/payment_gateways.js +26 -1
  397. package/lib/esm/resources/payment_methods.d.ts +61 -1
  398. package/lib/esm/resources/payment_methods.js +43 -1
  399. package/lib/esm/resources/paypal_gateways.d.ts +37 -1
  400. package/lib/esm/resources/paypal_gateways.js +39 -1
  401. package/lib/esm/resources/paypal_payments.d.ts +51 -1
  402. package/lib/esm/resources/paypal_payments.js +39 -1
  403. package/lib/esm/resources/percentage_discount_promotions.d.ts +100 -1
  404. package/lib/esm/resources/percentage_discount_promotions.js +63 -1
  405. package/lib/esm/resources/price_lists.d.ts +39 -1
  406. package/lib/esm/resources/price_lists.js +39 -1
  407. package/lib/esm/resources/price_tiers.d.ts +28 -1
  408. package/lib/esm/resources/price_tiers.js +30 -1
  409. package/lib/esm/resources/price_volume_tiers.d.ts +46 -1
  410. package/lib/esm/resources/price_volume_tiers.js +39 -1
  411. package/lib/esm/resources/prices.d.ts +68 -1
  412. package/lib/esm/resources/prices.js +51 -1
  413. package/lib/esm/resources/promotion_rules.d.ts +24 -1
  414. package/lib/esm/resources/promotion_rules.js +22 -1
  415. package/lib/esm/resources/promotions.d.ts +41 -1
  416. package/lib/esm/resources/promotions.js +42 -1
  417. package/lib/esm/resources/refunds.d.ts +37 -1
  418. package/lib/esm/resources/refunds.js +34 -1
  419. package/lib/esm/resources/return_line_items.d.ts +49 -1
  420. package/lib/esm/resources/return_line_items.js +39 -1
  421. package/lib/esm/resources/returns.d.ts +75 -1
  422. package/lib/esm/resources/returns.js +63 -1
  423. package/lib/esm/resources/shipments.d.ts +93 -1
  424. package/lib/esm/resources/shipments.js +81 -1
  425. package/lib/esm/resources/shipping_categories.d.ts +33 -1
  426. package/lib/esm/resources/shipping_categories.js +39 -1
  427. package/lib/esm/resources/shipping_method_tiers.d.ts +28 -1
  428. package/lib/esm/resources/shipping_method_tiers.js +30 -1
  429. package/lib/esm/resources/shipping_methods.d.ts +107 -1
  430. package/lib/esm/resources/shipping_methods.js +63 -1
  431. package/lib/esm/resources/shipping_weight_tiers.d.ts +46 -1
  432. package/lib/esm/resources/shipping_weight_tiers.js +39 -1
  433. package/lib/esm/resources/shipping_zones.d.ts +48 -1
  434. package/lib/esm/resources/shipping_zones.js +35 -1
  435. package/lib/esm/resources/sku_list_items.d.ts +47 -1
  436. package/lib/esm/resources/sku_list_items.js +39 -1
  437. package/lib/esm/resources/sku_list_promotion_rules.d.ts +68 -1
  438. package/lib/esm/resources/sku_list_promotion_rules.js +39 -1
  439. package/lib/esm/resources/sku_lists.d.ts +60 -1
  440. package/lib/esm/resources/sku_lists.js +51 -1
  441. package/lib/esm/resources/sku_options.d.ts +56 -1
  442. package/lib/esm/resources/sku_options.js +39 -1
  443. package/lib/esm/resources/skus.d.ts +78 -1
  444. package/lib/esm/resources/skus.js +55 -1
  445. package/lib/esm/resources/stock_items.d.ts +49 -1
  446. package/lib/esm/resources/stock_items.js +43 -1
  447. package/lib/esm/resources/stock_line_items.d.ts +29 -1
  448. package/lib/esm/resources/stock_line_items.js +34 -1
  449. package/lib/esm/resources/stock_locations.d.ts +57 -1
  450. package/lib/esm/resources/stock_locations.js +55 -1
  451. package/lib/esm/resources/stock_transfers.d.ts +74 -1
  452. package/lib/esm/resources/stock_transfers.js +55 -1
  453. package/lib/esm/resources/stripe_gateways.d.ts +41 -1
  454. package/lib/esm/resources/stripe_gateways.js +39 -1
  455. package/lib/esm/resources/stripe_payments.d.ts +46 -1
  456. package/lib/esm/resources/stripe_payments.js +39 -1
  457. package/lib/esm/resources/tax_calculators.d.ts +24 -1
  458. package/lib/esm/resources/tax_calculators.js +30 -1
  459. package/lib/esm/resources/tax_categories.d.ts +59 -1
  460. package/lib/esm/resources/tax_categories.js +39 -1
  461. package/lib/esm/resources/tax_rules.d.ts +69 -1
  462. package/lib/esm/resources/tax_rules.js +35 -1
  463. package/lib/esm/resources/taxjar_accounts.d.ts +43 -1
  464. package/lib/esm/resources/taxjar_accounts.js +43 -1
  465. package/lib/esm/resources/transactions.d.ts +31 -1
  466. package/lib/esm/resources/transactions.js +26 -1
  467. package/lib/esm/resources/voids.d.ts +37 -1
  468. package/lib/esm/resources/voids.js +34 -1
  469. package/lib/esm/resources/webhooks.d.ts +43 -1
  470. package/lib/esm/resources/webhooks.js +35 -1
  471. package/lib/esm/resources/wire_transfers.d.ts +32 -1
  472. package/lib/esm/resources/wire_transfers.js +35 -1
  473. package/lib/esm/static.d.ts +8 -1
  474. package/lib/esm/static.js +18 -1
  475. package/lib/esm/util.d.ts +6 -1
  476. package/lib/esm/util.js +11 -1
  477. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  478. package/lib/tsconfig.tsbuildinfo +1 -1
  479. package/package.json +13 -15
package/lib/cjs/debug.js CHANGED
@@ -1 +1,42 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const debuggerFunction=(e,...t)=>{};let debuggerFactory=e=>debuggerFunction;try{const e=require("debug");e&&typeof e=="function"&&(debuggerFactory=e)}catch{}const debugPrefix="clsdk",debug=e=>debuggerFactory(`${debugPrefix}:${e}`);exports.default=debug;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* Nope debugger */
7
+ const debuggerFunction = (_pattern, ..._args) => {
8
+ // console.log(_pattern)
9
+ };
10
+ let debuggerFactory = (_namespace) => debuggerFunction;
11
+ /* Try loading 'debug' module */
12
+ try {
13
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
14
+ const debugModule = require('debug');
15
+ if (debugModule && (typeof debugModule === 'function'))
16
+ debuggerFactory = debugModule;
17
+ }
18
+ catch (error) {
19
+ //
20
+ }
21
+ const debugPrefix = 'clsdk';
22
+ /* Retrieve the name of the caller 'module' */
23
+ /*
24
+ const caller = (): string => {
25
+
26
+ const err = new Error()
27
+
28
+ Error.prepareStackTrace = (_, stack) => stack
29
+ const stack = err.stack as unknown as NodeJS.CallSite[]
30
+ Error.prepareStackTrace = undefined
31
+
32
+ const fileName = stack[2].getFileName() || '/'
33
+
34
+ return fileName.replace(/^.*[\\/]/, '').replace('.ts', '')
35
+
36
+ }
37
+ */
38
+ /* Return a debugger for the defined namespace */
39
+ const debug = (namespace) => {
40
+ return debuggerFactory(`${debugPrefix}:${namespace}`);
41
+ };
42
+ exports.default = debug;
@@ -1 +1,28 @@
1
- declare enum ErrorType{CLIENT="client",REQUEST="request",RESPONSE="response",GENERIC="generic",CANCEL="cancel"}declare class SdkError extends Error{static NAME:string;static isSdkError(error:any):error is ApiError;type:string;code?:string;source?:Error;request?:any;constructor(error:{message:string;type?:ErrorType;});}declare class ApiError extends SdkError{static NAME:string;static isApiError(error:any):error is ApiError;errors:any[];status?:number;constructor(error:SdkError);first():any;}export{SdkError,ApiError,ErrorType};
1
+ declare enum ErrorType {
2
+ CLIENT = "client",
3
+ REQUEST = "request",
4
+ RESPONSE = "response",
5
+ GENERIC = "generic",
6
+ CANCEL = "cancel"
7
+ }
8
+ declare class SdkError extends Error {
9
+ static NAME: string;
10
+ static isSdkError(error: any): error is ApiError;
11
+ type: string;
12
+ code?: string;
13
+ source?: Error;
14
+ request?: any;
15
+ constructor(error: {
16
+ message: string;
17
+ type?: ErrorType;
18
+ });
19
+ }
20
+ declare class ApiError extends SdkError {
21
+ static NAME: string;
22
+ static isApiError(error: any): error is ApiError;
23
+ errors: any[];
24
+ status?: number;
25
+ constructor(error: SdkError);
26
+ first(): any;
27
+ }
28
+ export { SdkError, ApiError, ErrorType };
package/lib/cjs/error.js CHANGED
@@ -1 +1,43 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ErrorType=exports.ApiError=exports.SdkError=void 0;var ErrorType;(function(e){e.CLIENT="client",e.REQUEST="request",e.RESPONSE="response",e.GENERIC="generic",e.CANCEL="cancel"})(ErrorType||(ErrorType={})),exports.ErrorType=ErrorType;class SdkError extends Error{static isSdkError(r){return r&&[SdkError.NAME,ApiError.NAME].includes(r.name)&&Object.values(ErrorType).includes(r.type)}constructor(r){super(r.message),this.name=SdkError.NAME,this.type=r.type||ErrorType.GENERIC}}exports.SdkError=SdkError,SdkError.NAME="SdkError";class ApiError extends SdkError{static isApiError(r){return SdkError.isSdkError(r)&&r.name===ApiError.NAME&&r.type===ErrorType.RESPONSE}constructor(r){super(Object.assign(Object.assign({},r),{type:ErrorType.RESPONSE})),this.errors=[],this.name=ApiError.NAME}first(){var r;return((r=this.errors)===null||r===void 0?void 0:r.length)>0?this.errors[0]:void 0}}exports.ApiError=ApiError,ApiError.NAME="ApiError";
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ErrorType = exports.ApiError = exports.SdkError = void 0;
5
+ var ErrorType;
6
+ (function (ErrorType) {
7
+ ErrorType["CLIENT"] = "client";
8
+ ErrorType["REQUEST"] = "request";
9
+ ErrorType["RESPONSE"] = "response";
10
+ ErrorType["GENERIC"] = "generic";
11
+ ErrorType["CANCEL"] = "cancel";
12
+ })(ErrorType || (ErrorType = {}));
13
+ exports.ErrorType = ErrorType;
14
+ class SdkError extends Error {
15
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
16
+ static isSdkError(error) {
17
+ return error && [SdkError.NAME, ApiError.NAME].includes(error.name) && Object.values(ErrorType).includes(error.type);
18
+ }
19
+ constructor(error) {
20
+ super(error.message);
21
+ this.name = SdkError.NAME; // this.constructor.name
22
+ this.type = error.type || ErrorType.GENERIC;
23
+ }
24
+ }
25
+ exports.SdkError = SdkError;
26
+ SdkError.NAME = 'SdkError';
27
+ class ApiError extends SdkError {
28
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
29
+ static isApiError(error) {
30
+ return SdkError.isSdkError(error) && (error.name === ApiError.NAME) && (error.type === ErrorType.RESPONSE);
31
+ }
32
+ constructor(error) {
33
+ super(Object.assign(Object.assign({}, error), { type: ErrorType.RESPONSE }));
34
+ this.errors = [];
35
+ this.name = ApiError.NAME; // this.constructor.name
36
+ }
37
+ first() {
38
+ var _a;
39
+ return (((_a = this.errors) === null || _a === void 0 ? void 0 : _a.length) > 0) ? this.errors[0] : undefined;
40
+ }
41
+ }
42
+ exports.ApiError = ApiError;
43
+ ApiError.NAME = 'ApiError';
@@ -1 +1,7 @@
1
- export{default,CommerceLayer}from'./commercelayer';export type{CommerceLayerClient}from'./commercelayer';export{CommerceLayerStatic}from'./static';export type{QueryParamsRetrieve,QueryParamsList,QueryParams}from'./query';export*from'./model';export type{RequestObj,ResponseObj,ErrorObj,HeadersObj}from'./interceptor';export type{SdkError,ApiError,ErrorType}from'./error';
1
+ export { default, CommerceLayer } from './commercelayer';
2
+ export type { CommerceLayerClient } from './commercelayer';
3
+ export { CommerceLayerStatic } from './static';
4
+ export type { QueryParamsRetrieve, QueryParamsList, QueryParams } from './query';
5
+ export * from './model';
6
+ export type { RequestObj, ResponseObj, ErrorObj, HeadersObj } from './interceptor';
7
+ export type { SdkError, ApiError, ErrorType } from './error';
package/lib/cjs/index.js CHANGED
@@ -1 +1,29 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,o){o===void 0&&(o=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,i)}:function(e,t,r,o){o===void 0&&(o=r),e[o]=t[r]}),__exportStar=this&&this.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&__createBinding(t,e,r)},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommerceLayerStatic=exports.CommerceLayer=exports.default=void 0;var commercelayer_1=require("./commercelayer");Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return __importDefault(commercelayer_1).default}}),Object.defineProperty(exports,"CommerceLayer",{enumerable:!0,get:function(){return commercelayer_1.CommerceLayer}});var static_1=require("./static");Object.defineProperty(exports,"CommerceLayerStatic",{enumerable:!0,get:function(){return static_1.CommerceLayerStatic}}),__exportStar(require("./model"),exports);
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.CommerceLayerStatic = exports.CommerceLayer = exports.default = void 0;
21
+ // SDK
22
+ var commercelayer_1 = require("./commercelayer");
23
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(commercelayer_1).default; } });
24
+ Object.defineProperty(exports, "CommerceLayer", { enumerable: true, get: function () { return commercelayer_1.CommerceLayer; } });
25
+ // Commerce Layer static functions
26
+ var static_1 = require("./static");
27
+ Object.defineProperty(exports, "CommerceLayerStatic", { enumerable: true, get: function () { return static_1.CommerceLayerStatic; } });
28
+ // Resource model types
29
+ __exportStar(require("./model"), exports);
@@ -1 +1,21 @@
1
- import{AxiosError,AxiosInterceptorManager,AxiosRequestConfig,AxiosResponse,AxiosResponseHeaders,RawAxiosResponseHeaders}from'axios';type InterceptorManager={request:AxiosInterceptorManager<AxiosRequestConfig>;response:AxiosInterceptorManager<any>;};type RequestObj=AxiosRequestConfig;type RequestInterceptor=(request:RequestObj)=>RequestObj|Promise<RequestObj>;type ResponseObj=AxiosResponse;type ResponseInterceptor=(response:ResponseObj)=>ResponseObj;type HeadersObj=AxiosResponseHeaders|RawAxiosResponseHeaders;type ErrorObj=AxiosError;type ErrorInterceptor=(error:ErrorObj)=>ErrorObj;type InterceptorType='request'|'response';export type{InterceptorManager,RequestInterceptor,ResponseInterceptor,ErrorInterceptor,InterceptorType};export type{RequestObj,ResponseObj,ErrorObj,HeadersObj};type RawResponseReader={id:number|undefined;rawResponse:ResponseObj|undefined;headers:HeadersObj|undefined;};export type{RawResponseReader};
1
+ import { AxiosError, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, RawAxiosResponseHeaders } from 'axios';
2
+ type InterceptorManager = {
3
+ request: AxiosInterceptorManager<AxiosRequestConfig>;
4
+ response: AxiosInterceptorManager<any>;
5
+ };
6
+ type RequestObj = AxiosRequestConfig;
7
+ type RequestInterceptor = (request: RequestObj) => RequestObj | Promise<RequestObj>;
8
+ type ResponseObj = AxiosResponse;
9
+ type ResponseInterceptor = (response: ResponseObj) => ResponseObj;
10
+ type HeadersObj = AxiosResponseHeaders | RawAxiosResponseHeaders;
11
+ type ErrorObj = AxiosError;
12
+ type ErrorInterceptor = (error: ErrorObj) => ErrorObj;
13
+ type InterceptorType = 'request' | 'response';
14
+ export type { InterceptorManager, RequestInterceptor, ResponseInterceptor, ErrorInterceptor, InterceptorType };
15
+ export type { RequestObj, ResponseObj, ErrorObj, HeadersObj };
16
+ type RawResponseReader = {
17
+ id: number | undefined;
18
+ rawResponse: ResponseObj | undefined;
19
+ headers: HeadersObj | undefined;
20
+ };
21
+ export type { RawResponseReader };
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,5 @@
1
- import type{DocWithData,ResourceObject as JSONAPIObject}from'jsonapi-typescript';import type{ResourceCreate,ResourceUpdate,ResourceId,ResourceType,Resource}from'./resource';declare const denormalize:<R extends Resource>(response:DocWithData)=>R|R[];declare const normalize:(resource:(ResourceCreate&ResourceType)|(ResourceUpdate&ResourceId))=>JSONAPIObject;export{denormalize,normalize};
1
+ import type { DocWithData, ResourceObject as JSONAPIObject } from 'jsonapi-typescript';
2
+ import type { ResourceCreate, ResourceUpdate, ResourceId, ResourceType, Resource } from './resource';
3
+ declare const denormalize: <R extends Resource>(response: DocWithData) => R | R[];
4
+ declare const normalize: (resource: (ResourceCreate & ResourceType) | (ResourceUpdate & ResourceId)) => JSONAPIObject;
5
+ export { denormalize, normalize };
@@ -1 +1,82 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalize=exports.denormalize=void 0;const common_1=require("./common"),debug_1=__importDefault(require("./debug")),debug=(0,debug_1.default)("jsonapi"),denormalize=e=>{let t;e.links&&delete e.links;const i=e.data,o=e.included;return i?Array.isArray(i)?t=i.map(s=>denormalizeResource(s,o)):t=denormalizeResource(i,o):t=i,t};exports.denormalize=denormalize;const findIncluded=(e,t=[])=>t.find(i=>e.id===i.id&&e.type===i.type)||e,denormalizeResource=(e,t)=>{if(debug("denormalize resource: %O, %o",e,t||{}),!e)return e;const i=Object.assign({id:e.id,type:e.type},e.attributes);return e.relationships&&Object.keys(e.relationships).forEach(o=>{const s=e.relationships[o].data;s?Array.isArray(s)?i[o]=s.map(n=>denormalizeResource(findIncluded(n,t),t)):i[o]=denormalizeResource(findIncluded(s,t),t):s===null&&(i[o]=null)}),debug("denormalized resource: %O",i),i},normalize=e=>{debug("normalize resource: %O",e);const t={},i={};for(const s in e){if(["type","id"].includes(s))continue;const n=e[s];n&&(0,common_1.isResourceType)(n)&&n.id===null?i[s]={data:null}:n&&((0,common_1.isResourceId)(n)||Array.isArray(n)&&(0,common_1.isResourceId)(n[0]))?i[s]={data:n}:t[s]=n}const o={type:e.type,attributes:t,relationships:i};return(0,common_1.isResourceId)(e)&&(o.id=e.id),debug("normalized resource: %O",o),o};exports.normalize=normalize;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.normalize = exports.denormalize = void 0;
7
+ const common_1 = require("./common");
8
+ const debug_1 = __importDefault(require("./debug"));
9
+ const debug = (0, debug_1.default)('jsonapi');
10
+ // DENORMALIZATION
11
+ const denormalize = (response) => {
12
+ let denormalizedResponse;
13
+ if (response.links)
14
+ delete response.links;
15
+ const data = response.data;
16
+ const included = response.included;
17
+ if (!data)
18
+ denormalizedResponse = data;
19
+ else {
20
+ if (Array.isArray(data))
21
+ denormalizedResponse = data.map(res => denormalizeResource(res, included));
22
+ else
23
+ denormalizedResponse = denormalizeResource(data, included);
24
+ }
25
+ return denormalizedResponse;
26
+ };
27
+ exports.denormalize = denormalize;
28
+ const findIncluded = (rel, included = []) => {
29
+ const inc = included.find(inc => {
30
+ return (rel.id === inc.id) && (rel.type === inc.type);
31
+ });
32
+ return inc || rel;
33
+ };
34
+ const denormalizeResource = (res, included) => {
35
+ debug('denormalize resource: %O, %o', res, included || {});
36
+ if (!res)
37
+ return res;
38
+ const resource = Object.assign({ id: res.id, type: res.type }, res.attributes);
39
+ if (res.relationships)
40
+ Object.keys(res.relationships).forEach(key => {
41
+ const rel = res.relationships[key].data;
42
+ if (rel) {
43
+ if (Array.isArray(rel))
44
+ resource[key] = rel.map(r => denormalizeResource(findIncluded(r, included), included));
45
+ else
46
+ resource[key] = denormalizeResource(findIncluded(rel, included), included);
47
+ }
48
+ else if (rel === null)
49
+ resource[key] = null;
50
+ });
51
+ debug('denormalized resource: %O', resource);
52
+ return resource;
53
+ };
54
+ // NORMALIZATION
55
+ const normalize = (resource) => {
56
+ debug('normalize resource: %O', resource);
57
+ const attributes = {};
58
+ const relationships = {};
59
+ for (const field in resource) {
60
+ if (['type', 'id'].includes(field))
61
+ continue;
62
+ const value = resource[field];
63
+ if (value && (0, common_1.isResourceType)(value) && value.id === null) {
64
+ relationships[field] = { data: null };
65
+ }
66
+ else if (value && ((0, common_1.isResourceId)(value) || (Array.isArray(value) && (0, common_1.isResourceId)(value[0])))) {
67
+ relationships[field] = { data: value };
68
+ }
69
+ else
70
+ attributes[field] = value;
71
+ }
72
+ const normalized = {
73
+ type: resource.type,
74
+ attributes,
75
+ relationships
76
+ };
77
+ if ((0, common_1.isResourceId)(resource))
78
+ normalized.id = resource.id;
79
+ debug('normalized resource: %O', normalized);
80
+ return normalized;
81
+ };
82
+ exports.normalize = normalize;
@@ -1 +1,107 @@
1
- export type{Address,AddressCreate,AddressUpdate}from'./resources/addresses';export type{Adjustment,AdjustmentCreate,AdjustmentUpdate}from'./resources/adjustments';export type{AdyenGateway,AdyenGatewayCreate,AdyenGatewayUpdate}from'./resources/adyen_gateways';export type{AdyenPayment,AdyenPaymentCreate,AdyenPaymentUpdate}from'./resources/adyen_payments';export type{Application}from'./resources/application';export type{Attachment,AttachmentCreate,AttachmentUpdate}from'./resources/attachments';export type{Authorization,AuthorizationUpdate}from'./resources/authorizations';export type{AvalaraAccount,AvalaraAccountCreate,AvalaraAccountUpdate}from'./resources/avalara_accounts';export type{BillingInfoValidationRule,BillingInfoValidationRuleCreate,BillingInfoValidationRuleUpdate}from'./resources/billing_info_validation_rules';export type{BingGeocoder,BingGeocoderCreate,BingGeocoderUpdate}from'./resources/bing_geocoders';export type{BraintreeGateway,BraintreeGatewayCreate,BraintreeGatewayUpdate}from'./resources/braintree_gateways';export type{BraintreePayment,BraintreePaymentCreate,BraintreePaymentUpdate}from'./resources/braintree_payments';export type{Bundle,BundleCreate,BundleUpdate}from'./resources/bundles';export type{Capture,CaptureUpdate}from'./resources/captures';export type{CarrierAccount}from'./resources/carrier_accounts';export type{CheckoutComGateway,CheckoutComGatewayCreate,CheckoutComGatewayUpdate}from'./resources/checkout_com_gateways';export type{CheckoutComPayment,CheckoutComPaymentCreate,CheckoutComPaymentUpdate}from'./resources/checkout_com_payments';export type{Cleanup,CleanupCreate}from'./resources/cleanups';export type{CouponCodesPromotionRule,CouponCodesPromotionRuleCreate,CouponCodesPromotionRuleUpdate}from'./resources/coupon_codes_promotion_rules';export type{CouponRecipient,CouponRecipientCreate,CouponRecipientUpdate}from'./resources/coupon_recipients';export type{Coupon,CouponCreate,CouponUpdate}from'./resources/coupons';export type{CustomerAddress,CustomerAddressCreate,CustomerAddressUpdate}from'./resources/customer_addresses';export type{CustomerGroup,CustomerGroupCreate,CustomerGroupUpdate}from'./resources/customer_groups';export type{CustomerPasswordReset,CustomerPasswordResetCreate,CustomerPasswordResetUpdate}from'./resources/customer_password_resets';export type{CustomerPaymentSource,CustomerPaymentSourceCreate,CustomerPaymentSourceUpdate}from'./resources/customer_payment_sources';export type{CustomerSubscription,CustomerSubscriptionCreate,CustomerSubscriptionUpdate}from'./resources/customer_subscriptions';export type{Customer,CustomerCreate,CustomerUpdate}from'./resources/customers';export type{DeliveryLeadTime,DeliveryLeadTimeCreate,DeliveryLeadTimeUpdate}from'./resources/delivery_lead_times';export type{EventCallback}from'./resources/event_callbacks';export type{Event}from'./resources/events';export type{Export,ExportCreate}from'./resources/exports';export type{ExternalGateway,ExternalGatewayCreate,ExternalGatewayUpdate}from'./resources/external_gateways';export type{ExternalPayment,ExternalPaymentCreate,ExternalPaymentUpdate}from'./resources/external_payments';export type{ExternalPromotion,ExternalPromotionCreate,ExternalPromotionUpdate}from'./resources/external_promotions';export type{ExternalTaxCalculator,ExternalTaxCalculatorCreate,ExternalTaxCalculatorUpdate}from'./resources/external_tax_calculators';export type{FixedAmountPromotion,FixedAmountPromotionCreate,FixedAmountPromotionUpdate}from'./resources/fixed_amount_promotions';export type{FixedPricePromotion,FixedPricePromotionCreate,FixedPricePromotionUpdate}from'./resources/fixed_price_promotions';export type{FreeGiftPromotion,FreeGiftPromotionCreate,FreeGiftPromotionUpdate}from'./resources/free_gift_promotions';export type{FreeShippingPromotion,FreeShippingPromotionCreate,FreeShippingPromotionUpdate}from'./resources/free_shipping_promotions';export type{Geocoder}from'./resources/geocoders';export type{GiftCardRecipient,GiftCardRecipientCreate,GiftCardRecipientUpdate}from'./resources/gift_card_recipients';export type{GiftCard,GiftCardCreate,GiftCardUpdate}from'./resources/gift_cards';export type{GoogleGeocoder,GoogleGeocoderCreate,GoogleGeocoderUpdate}from'./resources/google_geocoders';export type{Import,ImportCreate}from'./resources/imports';export type{InStockSubscription,InStockSubscriptionCreate,InStockSubscriptionUpdate}from'./resources/in_stock_subscriptions';export type{InventoryModel,InventoryModelCreate,InventoryModelUpdate}from'./resources/inventory_models';export type{InventoryReturnLocation,InventoryReturnLocationCreate,InventoryReturnLocationUpdate}from'./resources/inventory_return_locations';export type{InventoryStockLocation,InventoryStockLocationCreate,InventoryStockLocationUpdate}from'./resources/inventory_stock_locations';export type{KlarnaGateway,KlarnaGatewayCreate,KlarnaGatewayUpdate}from'./resources/klarna_gateways';export type{KlarnaPayment,KlarnaPaymentCreate,KlarnaPaymentUpdate}from'./resources/klarna_payments';export type{LineItemOption,LineItemOptionCreate,LineItemOptionUpdate}from'./resources/line_item_options';export type{LineItem,LineItemCreate,LineItemUpdate}from'./resources/line_items';export type{ManualGateway,ManualGatewayCreate,ManualGatewayUpdate}from'./resources/manual_gateways';export type{ManualTaxCalculator,ManualTaxCalculatorCreate,ManualTaxCalculatorUpdate}from'./resources/manual_tax_calculators';export type{Market,MarketCreate,MarketUpdate}from'./resources/markets';export type{Merchant,MerchantCreate,MerchantUpdate}from'./resources/merchants';export type{OrderAmountPromotionRule,OrderAmountPromotionRuleCreate,OrderAmountPromotionRuleUpdate}from'./resources/order_amount_promotion_rules';export type{OrderCopy,OrderCopyCreate}from'./resources/order_copies';export type{OrderSubscription,OrderSubscriptionCreate,OrderSubscriptionUpdate}from'./resources/order_subscriptions';export type{OrderValidationRule}from'./resources/order_validation_rules';export type{Order,OrderCreate,OrderUpdate}from'./resources/orders';export type{Organization}from'./resources/organization';export type{Package,PackageCreate,PackageUpdate}from'./resources/packages';export type{ParcelLineItem,ParcelLineItemCreate,ParcelLineItemUpdate}from'./resources/parcel_line_items';export type{Parcel,ParcelCreate,ParcelUpdate}from'./resources/parcels';export type{PaymentGateway}from'./resources/payment_gateways';export type{PaymentMethod,PaymentMethodCreate,PaymentMethodUpdate}from'./resources/payment_methods';export type{PaypalGateway,PaypalGatewayCreate,PaypalGatewayUpdate}from'./resources/paypal_gateways';export type{PaypalPayment,PaypalPaymentCreate,PaypalPaymentUpdate}from'./resources/paypal_payments';export type{PercentageDiscountPromotion,PercentageDiscountPromotionCreate,PercentageDiscountPromotionUpdate}from'./resources/percentage_discount_promotions';export type{PriceList,PriceListCreate,PriceListUpdate}from'./resources/price_lists';export type{PriceTier}from'./resources/price_tiers';export type{PriceVolumeTier,PriceVolumeTierCreate,PriceVolumeTierUpdate}from'./resources/price_volume_tiers';export type{Price,PriceCreate,PriceUpdate}from'./resources/prices';export type{PromotionRule}from'./resources/promotion_rules';export type{Promotion}from'./resources/promotions';export type{Refund}from'./resources/refunds';export type{ReturnLineItem,ReturnLineItemCreate,ReturnLineItemUpdate}from'./resources/return_line_items';export type{Return,ReturnCreate,ReturnUpdate}from'./resources/returns';export type{Shipment,ShipmentUpdate}from'./resources/shipments';export type{ShippingCategory,ShippingCategoryCreate,ShippingCategoryUpdate}from'./resources/shipping_categories';export type{ShippingMethodTier}from'./resources/shipping_method_tiers';export type{ShippingMethod,ShippingMethodCreate,ShippingMethodUpdate}from'./resources/shipping_methods';export type{ShippingWeightTier,ShippingWeightTierCreate,ShippingWeightTierUpdate}from'./resources/shipping_weight_tiers';export type{ShippingZone,ShippingZoneCreate,ShippingZoneUpdate}from'./resources/shipping_zones';export type{SkuListItem,SkuListItemCreate,SkuListItemUpdate}from'./resources/sku_list_items';export type{SkuListPromotionRule,SkuListPromotionRuleCreate,SkuListPromotionRuleUpdate}from'./resources/sku_list_promotion_rules';export type{SkuList,SkuListCreate,SkuListUpdate}from'./resources/sku_lists';export type{SkuOption,SkuOptionCreate,SkuOptionUpdate}from'./resources/sku_options';export type{Sku,SkuCreate,SkuUpdate}from'./resources/skus';export type{StockItem,StockItemCreate,StockItemUpdate}from'./resources/stock_items';export type{StockLineItem}from'./resources/stock_line_items';export type{StockLocation,StockLocationCreate,StockLocationUpdate}from'./resources/stock_locations';export type{StockTransfer,StockTransferCreate,StockTransferUpdate}from'./resources/stock_transfers';export type{StripeGateway,StripeGatewayCreate,StripeGatewayUpdate}from'./resources/stripe_gateways';export type{StripePayment,StripePaymentCreate,StripePaymentUpdate}from'./resources/stripe_payments';export type{TaxCalculator}from'./resources/tax_calculators';export type{TaxCategory,TaxCategoryCreate,TaxCategoryUpdate}from'./resources/tax_categories';export type{TaxRule,TaxRuleCreate,TaxRuleUpdate}from'./resources/tax_rules';export type{TaxjarAccount,TaxjarAccountCreate,TaxjarAccountUpdate}from'./resources/taxjar_accounts';export type{Transaction}from'./resources/transactions';export type{Void}from'./resources/voids';export type{Webhook,WebhookCreate,WebhookUpdate}from'./resources/webhooks';export type{WireTransfer,WireTransferCreate,WireTransferUpdate}from'./resources/wire_transfers';
1
+ /**
2
+ * ©2023 Commerce Layer Inc.
3
+ **/
4
+ export type { Address, AddressCreate, AddressUpdate } from './resources/addresses';
5
+ export type { Adjustment, AdjustmentCreate, AdjustmentUpdate } from './resources/adjustments';
6
+ export type { AdyenGateway, AdyenGatewayCreate, AdyenGatewayUpdate } from './resources/adyen_gateways';
7
+ export type { AdyenPayment, AdyenPaymentCreate, AdyenPaymentUpdate } from './resources/adyen_payments';
8
+ export type { Application } from './resources/application';
9
+ export type { Attachment, AttachmentCreate, AttachmentUpdate } from './resources/attachments';
10
+ export type { Authorization, AuthorizationUpdate } from './resources/authorizations';
11
+ export type { AvalaraAccount, AvalaraAccountCreate, AvalaraAccountUpdate } from './resources/avalara_accounts';
12
+ export type { BillingInfoValidationRule, BillingInfoValidationRuleCreate, BillingInfoValidationRuleUpdate } from './resources/billing_info_validation_rules';
13
+ export type { BingGeocoder, BingGeocoderCreate, BingGeocoderUpdate } from './resources/bing_geocoders';
14
+ export type { BraintreeGateway, BraintreeGatewayCreate, BraintreeGatewayUpdate } from './resources/braintree_gateways';
15
+ export type { BraintreePayment, BraintreePaymentCreate, BraintreePaymentUpdate } from './resources/braintree_payments';
16
+ export type { Bundle, BundleCreate, BundleUpdate } from './resources/bundles';
17
+ export type { Capture, CaptureUpdate } from './resources/captures';
18
+ export type { CarrierAccount } from './resources/carrier_accounts';
19
+ export type { CheckoutComGateway, CheckoutComGatewayCreate, CheckoutComGatewayUpdate } from './resources/checkout_com_gateways';
20
+ export type { CheckoutComPayment, CheckoutComPaymentCreate, CheckoutComPaymentUpdate } from './resources/checkout_com_payments';
21
+ export type { Cleanup, CleanupCreate } from './resources/cleanups';
22
+ export type { CouponCodesPromotionRule, CouponCodesPromotionRuleCreate, CouponCodesPromotionRuleUpdate } from './resources/coupon_codes_promotion_rules';
23
+ export type { CouponRecipient, CouponRecipientCreate, CouponRecipientUpdate } from './resources/coupon_recipients';
24
+ export type { Coupon, CouponCreate, CouponUpdate } from './resources/coupons';
25
+ export type { CustomerAddress, CustomerAddressCreate, CustomerAddressUpdate } from './resources/customer_addresses';
26
+ export type { CustomerGroup, CustomerGroupCreate, CustomerGroupUpdate } from './resources/customer_groups';
27
+ export type { CustomerPasswordReset, CustomerPasswordResetCreate, CustomerPasswordResetUpdate } from './resources/customer_password_resets';
28
+ export type { CustomerPaymentSource, CustomerPaymentSourceCreate, CustomerPaymentSourceUpdate } from './resources/customer_payment_sources';
29
+ export type { CustomerSubscription, CustomerSubscriptionCreate, CustomerSubscriptionUpdate } from './resources/customer_subscriptions';
30
+ export type { Customer, CustomerCreate, CustomerUpdate } from './resources/customers';
31
+ export type { DeliveryLeadTime, DeliveryLeadTimeCreate, DeliveryLeadTimeUpdate } from './resources/delivery_lead_times';
32
+ export type { EventCallback } from './resources/event_callbacks';
33
+ export type { Event } from './resources/events';
34
+ export type { Export, ExportCreate } from './resources/exports';
35
+ export type { ExternalGateway, ExternalGatewayCreate, ExternalGatewayUpdate } from './resources/external_gateways';
36
+ export type { ExternalPayment, ExternalPaymentCreate, ExternalPaymentUpdate } from './resources/external_payments';
37
+ export type { ExternalPromotion, ExternalPromotionCreate, ExternalPromotionUpdate } from './resources/external_promotions';
38
+ export type { ExternalTaxCalculator, ExternalTaxCalculatorCreate, ExternalTaxCalculatorUpdate } from './resources/external_tax_calculators';
39
+ export type { FixedAmountPromotion, FixedAmountPromotionCreate, FixedAmountPromotionUpdate } from './resources/fixed_amount_promotions';
40
+ export type { FixedPricePromotion, FixedPricePromotionCreate, FixedPricePromotionUpdate } from './resources/fixed_price_promotions';
41
+ export type { FreeGiftPromotion, FreeGiftPromotionCreate, FreeGiftPromotionUpdate } from './resources/free_gift_promotions';
42
+ export type { FreeShippingPromotion, FreeShippingPromotionCreate, FreeShippingPromotionUpdate } from './resources/free_shipping_promotions';
43
+ export type { Geocoder } from './resources/geocoders';
44
+ export type { GiftCardRecipient, GiftCardRecipientCreate, GiftCardRecipientUpdate } from './resources/gift_card_recipients';
45
+ export type { GiftCard, GiftCardCreate, GiftCardUpdate } from './resources/gift_cards';
46
+ export type { GoogleGeocoder, GoogleGeocoderCreate, GoogleGeocoderUpdate } from './resources/google_geocoders';
47
+ export type { Import, ImportCreate } from './resources/imports';
48
+ export type { InStockSubscription, InStockSubscriptionCreate, InStockSubscriptionUpdate } from './resources/in_stock_subscriptions';
49
+ export type { InventoryModel, InventoryModelCreate, InventoryModelUpdate } from './resources/inventory_models';
50
+ export type { InventoryReturnLocation, InventoryReturnLocationCreate, InventoryReturnLocationUpdate } from './resources/inventory_return_locations';
51
+ export type { InventoryStockLocation, InventoryStockLocationCreate, InventoryStockLocationUpdate } from './resources/inventory_stock_locations';
52
+ export type { KlarnaGateway, KlarnaGatewayCreate, KlarnaGatewayUpdate } from './resources/klarna_gateways';
53
+ export type { KlarnaPayment, KlarnaPaymentCreate, KlarnaPaymentUpdate } from './resources/klarna_payments';
54
+ export type { LineItemOption, LineItemOptionCreate, LineItemOptionUpdate } from './resources/line_item_options';
55
+ export type { LineItem, LineItemCreate, LineItemUpdate } from './resources/line_items';
56
+ export type { ManualGateway, ManualGatewayCreate, ManualGatewayUpdate } from './resources/manual_gateways';
57
+ export type { ManualTaxCalculator, ManualTaxCalculatorCreate, ManualTaxCalculatorUpdate } from './resources/manual_tax_calculators';
58
+ export type { Market, MarketCreate, MarketUpdate } from './resources/markets';
59
+ export type { Merchant, MerchantCreate, MerchantUpdate } from './resources/merchants';
60
+ export type { OrderAmountPromotionRule, OrderAmountPromotionRuleCreate, OrderAmountPromotionRuleUpdate } from './resources/order_amount_promotion_rules';
61
+ export type { OrderCopy, OrderCopyCreate } from './resources/order_copies';
62
+ export type { OrderSubscription, OrderSubscriptionCreate, OrderSubscriptionUpdate } from './resources/order_subscriptions';
63
+ export type { OrderValidationRule } from './resources/order_validation_rules';
64
+ export type { Order, OrderCreate, OrderUpdate } from './resources/orders';
65
+ export type { Organization } from './resources/organization';
66
+ export type { Package, PackageCreate, PackageUpdate } from './resources/packages';
67
+ export type { ParcelLineItem, ParcelLineItemCreate, ParcelLineItemUpdate } from './resources/parcel_line_items';
68
+ export type { Parcel, ParcelCreate, ParcelUpdate } from './resources/parcels';
69
+ export type { PaymentGateway } from './resources/payment_gateways';
70
+ export type { PaymentMethod, PaymentMethodCreate, PaymentMethodUpdate } from './resources/payment_methods';
71
+ export type { PaypalGateway, PaypalGatewayCreate, PaypalGatewayUpdate } from './resources/paypal_gateways';
72
+ export type { PaypalPayment, PaypalPaymentCreate, PaypalPaymentUpdate } from './resources/paypal_payments';
73
+ export type { PercentageDiscountPromotion, PercentageDiscountPromotionCreate, PercentageDiscountPromotionUpdate } from './resources/percentage_discount_promotions';
74
+ export type { PriceList, PriceListCreate, PriceListUpdate } from './resources/price_lists';
75
+ export type { PriceTier } from './resources/price_tiers';
76
+ export type { PriceVolumeTier, PriceVolumeTierCreate, PriceVolumeTierUpdate } from './resources/price_volume_tiers';
77
+ export type { Price, PriceCreate, PriceUpdate } from './resources/prices';
78
+ export type { PromotionRule } from './resources/promotion_rules';
79
+ export type { Promotion } from './resources/promotions';
80
+ export type { Refund } from './resources/refunds';
81
+ export type { ReturnLineItem, ReturnLineItemCreate, ReturnLineItemUpdate } from './resources/return_line_items';
82
+ export type { Return, ReturnCreate, ReturnUpdate } from './resources/returns';
83
+ export type { Shipment, ShipmentUpdate } from './resources/shipments';
84
+ export type { ShippingCategory, ShippingCategoryCreate, ShippingCategoryUpdate } from './resources/shipping_categories';
85
+ export type { ShippingMethodTier } from './resources/shipping_method_tiers';
86
+ export type { ShippingMethod, ShippingMethodCreate, ShippingMethodUpdate } from './resources/shipping_methods';
87
+ export type { ShippingWeightTier, ShippingWeightTierCreate, ShippingWeightTierUpdate } from './resources/shipping_weight_tiers';
88
+ export type { ShippingZone, ShippingZoneCreate, ShippingZoneUpdate } from './resources/shipping_zones';
89
+ export type { SkuListItem, SkuListItemCreate, SkuListItemUpdate } from './resources/sku_list_items';
90
+ export type { SkuListPromotionRule, SkuListPromotionRuleCreate, SkuListPromotionRuleUpdate } from './resources/sku_list_promotion_rules';
91
+ export type { SkuList, SkuListCreate, SkuListUpdate } from './resources/sku_lists';
92
+ export type { SkuOption, SkuOptionCreate, SkuOptionUpdate } from './resources/sku_options';
93
+ export type { Sku, SkuCreate, SkuUpdate } from './resources/skus';
94
+ export type { StockItem, StockItemCreate, StockItemUpdate } from './resources/stock_items';
95
+ export type { StockLineItem } from './resources/stock_line_items';
96
+ export type { StockLocation, StockLocationCreate, StockLocationUpdate } from './resources/stock_locations';
97
+ export type { StockTransfer, StockTransferCreate, StockTransferUpdate } from './resources/stock_transfers';
98
+ export type { StripeGateway, StripeGatewayCreate, StripeGatewayUpdate } from './resources/stripe_gateways';
99
+ export type { StripePayment, StripePaymentCreate, StripePaymentUpdate } from './resources/stripe_payments';
100
+ export type { TaxCalculator } from './resources/tax_calculators';
101
+ export type { TaxCategory, TaxCategoryCreate, TaxCategoryUpdate } from './resources/tax_categories';
102
+ export type { TaxRule, TaxRuleCreate, TaxRuleUpdate } from './resources/tax_rules';
103
+ export type { TaxjarAccount, TaxjarAccountCreate, TaxjarAccountUpdate } from './resources/taxjar_accounts';
104
+ export type { Transaction } from './resources/transactions';
105
+ export type { Void } from './resources/voids';
106
+ export type { Webhook, WebhookCreate, WebhookUpdate } from './resources/webhooks';
107
+ export type { WireTransfer, WireTransferCreate, WireTransferUpdate } from './resources/wire_transfers';
package/lib/cjs/model.js CHANGED
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // ##__MODEL_TYPES_STOP__##
@@ -1 +1,23 @@
1
- import{ResourceType}from"./resource";interface QueryParamsRetrieve{include?:string[];fields?:string[]|{[key:string]:string[];};}interface QueryParamsList extends QueryParamsRetrieve{sort?:string[]|{[key:string]:'asc'|'desc';};filters?:{[key:string]:string|number|boolean;};pageNumber?:number;pageSize?:number;}type QueryParams=QueryParamsRetrieve|QueryParamsList;export{QueryParamsRetrieve,QueryParamsList,QueryParams};declare const generateQueryStringParams:(params:QueryParamsRetrieve|QueryParamsList|undefined,res:string|ResourceType)=>{[key:string]:string;};export{generateQueryStringParams};
1
+ import { ResourceType } from "./resource";
2
+ interface QueryParamsRetrieve {
3
+ include?: string[];
4
+ fields?: string[] | {
5
+ [key: string]: string[];
6
+ };
7
+ }
8
+ interface QueryParamsList extends QueryParamsRetrieve {
9
+ sort?: string[] | {
10
+ [key: string]: 'asc' | 'desc';
11
+ };
12
+ filters?: {
13
+ [key: string]: string | number | boolean;
14
+ };
15
+ pageNumber?: number;
16
+ pageSize?: number;
17
+ }
18
+ 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 };
package/lib/cjs/query.js CHANGED
@@ -1 +1,51 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateQueryStringParams=void 0;const debug_1=__importDefault(require("./debug")),debug=(0,debug_1.default)("query"),isParamsList=e=>e.filters||e.pageNumber||e.pageSize||e.sort,generateQueryStringParams=(e,s)=>{debug("generate query string params: %O, %O",e,s);const t={};return e&&(e.include&&(t.include=e.include.join(",")),e.fields&&(Array.isArray(e.fields)&&(e.fields={[s.type||s]:e.fields}),Object.entries(e.fields).forEach(([i,r])=>{t[`fields[${i}]`]=r.join(",")})),isParamsList(e)&&(e.sort&&(Array.isArray(e.sort)?t.sort=e.sort.join(","):t.sort=Object.entries(e.sort).map(([i,r])=>`${r==="desc"?"-":""}${i}`).join(",")),e.pageNumber&&(t["page[number]"]=String(e.pageNumber)),e.pageSize&&(t["page[size]"]=String(e.pageSize)),e.filters&&Object.entries(e.filters).forEach(([i,r])=>{t[`filter[q][${i}]`]=String(r)})),debug("query string params: %O",t)),t};exports.generateQueryStringParams=generateQueryStringParams;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateQueryStringParams = void 0;
7
+ const debug_1 = __importDefault(require("./debug"));
8
+ const debug = (0, debug_1.default)('query');
9
+ const isParamsList = (params) => {
10
+ return (params.filters || params.pageNumber || params.pageSize || params.sort);
11
+ };
12
+ const generateQueryStringParams = (params, res) => {
13
+ debug('generate query string params: %O, %O', params, res);
14
+ const qp = {};
15
+ if (!params)
16
+ return qp;
17
+ // Include
18
+ if (params.include)
19
+ qp.include = params.include.join(',');
20
+ // Fields
21
+ if (params.fields) {
22
+ if (Array.isArray(params.fields))
23
+ params.fields = { [res.type || res]: params.fields };
24
+ Object.entries(params.fields).forEach(([p, v]) => {
25
+ qp[`fields[${p}]`] = v.join(',');
26
+ });
27
+ }
28
+ if (isParamsList(params)) {
29
+ // Sort
30
+ if (params.sort) {
31
+ if (Array.isArray(params.sort))
32
+ qp.sort = params.sort.join(',');
33
+ else
34
+ qp.sort = Object.entries(params.sort).map(([k, v]) => `${v === 'desc' ? '-' : ''}${k}`).join(',');
35
+ }
36
+ // Page
37
+ if (params.pageNumber)
38
+ qp['page[number]'] = String(params.pageNumber);
39
+ if (params.pageSize)
40
+ qp['page[size]'] = String(params.pageSize);
41
+ // Filters
42
+ if (params.filters) {
43
+ Object.entries(params.filters).forEach(([p, v]) => {
44
+ qp[`filter[q][${p}]`] = String(v);
45
+ });
46
+ }
47
+ }
48
+ debug('query string params: %O', qp);
49
+ return qp;
50
+ };
51
+ exports.generateQueryStringParams = generateQueryStringParams;
@@ -1 +1,77 @@
1
- import{ApiClientInitConfig}from'./client';import{QueryParamsRetrieve,QueryParamsList}from'./query';import{ResourceTypeLock}from'./api';import{InterceptorManager}from'./interceptor';import{QueryParams}from'.';type ResourceNull={id:null;}&ResourceType;type ResourceRel=ResourceId|ResourceNull;type Metadata={[key:string]:any;};interface ResourceType{readonly type:ResourceTypeLock;}interface ResourceId extends ResourceType{readonly id:string;}interface Resource extends ResourceId{reference?:string;reference_origin?:string;metadata?:Metadata;readonly created_at:string;readonly updated_at:string;}interface ResourceCreate{reference?:string;reference_origin?:string;metadata?:Metadata;}interface ResourceUpdate{readonly id:string;reference?:string;reference_origin?:string;metadata?:Metadata;}type ListMeta={readonly pageCount:number;readonly recordCount:number;readonly currentPage:number;readonly recordsPerPage:number;};declare class ListResponse<R>extends Array<R>{readonly meta:ListMeta;constructor(meta:ListMeta,data:R[]);first():R|undefined;last():R|undefined;get(index:number):R|undefined;}export type{Metadata,ResourceType,ResourceId,Resource,ResourceCreate,ResourceUpdate,ListResponse,ResourceRel};type ResourceAdapterConfig={};type ResourcesInitConfig=ResourceAdapterConfig&ApiClientInitConfig;type ResourcesConfig=Partial<ResourcesInitConfig>;declare class ResourceAdapter{#private;constructor(config:ResourcesInitConfig);get interceptors():InterceptorManager;private localConfig;config(config:ResourcesConfig):void;singleton<R extends Resource>(resource:ResourceType,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;retrieve<R extends Resource>(resource:ResourceId,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;list<R extends Resource>(resource:ResourceType,params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<R>>;create<C extends ResourceCreate,R extends Resource>(resource:C&ResourceType,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;update<U extends ResourceUpdate,R extends Resource>(resource:U&ResourceId,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;delete(resource:ResourceId,options?:ResourcesConfig):Promise<void>;fetch<R extends Resource>(resource:string|ResourceType,path:string,params?:QueryParams,options?:ResourcesConfig):Promise<R|ListResponse<R>>;}declare abstract class ApiResource{static readonly TYPE:ResourceTypeLock;protected resources:ResourceAdapter;constructor(adapter:ResourceAdapter);abstract relationship(id:string|ResourceId|null):ResourceRel;abstract type():string;}export default ResourceAdapter;export{ApiResource,ResourcesConfig,ResourcesInitConfig};
1
+ import { ApiClientInitConfig } from './client';
2
+ import { QueryParamsRetrieve, QueryParamsList } from './query';
3
+ import { ResourceTypeLock } from './api';
4
+ import { InterceptorManager } from './interceptor';
5
+ import { QueryParams } from '.';
6
+ type ResourceNull = {
7
+ id: null;
8
+ } & ResourceType;
9
+ type ResourceRel = ResourceId | ResourceNull;
10
+ type Metadata = {
11
+ [key: string]: any;
12
+ };
13
+ interface ResourceType {
14
+ readonly type: ResourceTypeLock;
15
+ }
16
+ interface ResourceId extends ResourceType {
17
+ readonly id: string;
18
+ }
19
+ interface Resource extends ResourceId {
20
+ reference?: string;
21
+ reference_origin?: string;
22
+ metadata?: Metadata;
23
+ readonly created_at: string;
24
+ readonly updated_at: string;
25
+ }
26
+ interface ResourceCreate {
27
+ reference?: string;
28
+ reference_origin?: string;
29
+ metadata?: Metadata;
30
+ }
31
+ interface ResourceUpdate {
32
+ readonly id: string;
33
+ reference?: string;
34
+ reference_origin?: string;
35
+ metadata?: Metadata;
36
+ }
37
+ type ListMeta = {
38
+ readonly pageCount: number;
39
+ readonly recordCount: number;
40
+ readonly currentPage: number;
41
+ readonly recordsPerPage: number;
42
+ };
43
+ declare class ListResponse<R> extends Array<R> {
44
+ readonly meta: ListMeta;
45
+ constructor(meta: ListMeta, data: R[]);
46
+ first(): R | undefined;
47
+ last(): R | undefined;
48
+ get(index: number): R | undefined;
49
+ }
50
+ export type { Metadata, ResourceType, ResourceId, Resource, ResourceCreate, ResourceUpdate, ListResponse, ResourceRel };
51
+ type ResourceAdapterConfig = {};
52
+ type ResourcesInitConfig = ResourceAdapterConfig & ApiClientInitConfig;
53
+ type ResourcesConfig = Partial<ResourcesInitConfig>;
54
+ declare class ResourceAdapter {
55
+ #private;
56
+ constructor(config: ResourcesInitConfig);
57
+ get interceptors(): InterceptorManager;
58
+ private localConfig;
59
+ config(config: ResourcesConfig): void;
60
+ singleton<R extends Resource>(resource: ResourceType, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
61
+ retrieve<R extends Resource>(resource: ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
62
+ list<R extends Resource>(resource: ResourceType, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<R>>;
63
+ create<C extends ResourceCreate, R extends Resource>(resource: C & ResourceType, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
64
+ update<U extends ResourceUpdate, R extends Resource>(resource: U & ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
65
+ delete(resource: ResourceId, options?: ResourcesConfig): Promise<void>;
66
+ fetch<R extends Resource>(resource: string | ResourceType, path: string, params?: QueryParams, options?: ResourcesConfig): Promise<R | ListResponse<R>>;
67
+ }
68
+ declare abstract class ApiResource {
69
+ static readonly TYPE: ResourceTypeLock;
70
+ protected resources: ResourceAdapter;
71
+ constructor(adapter: ResourceAdapter);
72
+ abstract relationship(id: string | ResourceId | null): ResourceRel;
73
+ abstract type(): string;
74
+ update(resource: ResourceUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Resource>;
75
+ }
76
+ export default ResourceAdapter;
77
+ export { ApiResource, ResourcesConfig, ResourcesInitConfig };