@commercelayer/sdk 5.0.0-alpha.5 → 5.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (720) hide show
  1. package/README.md +201 -123
  2. package/lib/cjs/api.d.ts +113 -0
  3. package/lib/cjs/api.js +355 -0
  4. package/lib/cjs/client.d.ts +33 -0
  5. package/lib/cjs/client.js +122 -0
  6. package/lib/cjs/commercelayer.d.ts +139 -0
  7. package/lib/cjs/commercelayer.js +230 -0
  8. package/lib/cjs/common.d.ts +4 -0
  9. package/lib/cjs/common.js +12 -0
  10. package/lib/cjs/config.d.ts +11 -0
  11. package/lib/cjs/config.js +13 -0
  12. package/lib/cjs/debug.d.ts +3 -0
  13. package/lib/cjs/debug.js +39 -0
  14. package/lib/cjs/error.d.ts +28 -0
  15. package/lib/cjs/error.js +42 -0
  16. package/lib/cjs/index.d.ts +7 -0
  17. package/lib/cjs/index.js +29 -0
  18. package/lib/cjs/interceptor.d.ts +25 -0
  19. package/lib/cjs/interceptor.js +2 -0
  20. package/lib/cjs/jsonapi.d.ts +5 -0
  21. package/lib/cjs/jsonapi.js +82 -0
  22. package/lib/cjs/model.d.ts +111 -0
  23. package/lib/cjs/model.js +3 -0
  24. package/lib/cjs/query.d.ts +24 -0
  25. package/lib/cjs/query.js +51 -0
  26. package/lib/cjs/resource.d.ts +90 -0
  27. package/lib/cjs/resource.js +167 -0
  28. package/lib/cjs/resources/addresses.d.ts +89 -0
  29. package/lib/cjs/resources/addresses.js +33 -0
  30. package/lib/cjs/resources/adjustments.d.ts +36 -0
  31. package/lib/cjs/resources/adjustments.js +29 -0
  32. package/lib/cjs/resources/adyen_gateways.d.ts +57 -0
  33. package/lib/cjs/resources/adyen_gateways.js +37 -0
  34. package/lib/cjs/resources/adyen_payments.d.ts +47 -0
  35. package/lib/cjs/resources/adyen_payments.js +37 -0
  36. package/lib/cjs/resources/application.d.ts +21 -0
  37. package/lib/cjs/resources/application.js +17 -0
  38. package/lib/cjs/resources/attachments.d.ts +157 -0
  39. package/lib/cjs/resources/attachments.js +29 -0
  40. package/lib/cjs/resources/authorizations.d.ts +61 -0
  41. package/lib/cjs/resources/authorizations.js +39 -0
  42. package/lib/cjs/resources/avalara_accounts.d.ts +56 -0
  43. package/lib/cjs/resources/avalara_accounts.js +41 -0
  44. package/lib/cjs/resources/axerve_gateways.d.ts +44 -0
  45. package/lib/cjs/resources/axerve_gateways.js +37 -0
  46. package/lib/cjs/resources/axerve_payments.d.ts +47 -0
  47. package/lib/cjs/resources/axerve_payments.js +37 -0
  48. package/lib/cjs/resources/billing_info_validation_rules.d.ts +36 -0
  49. package/lib/cjs/resources/billing_info_validation_rules.js +37 -0
  50. package/lib/cjs/resources/bing_geocoders.d.ts +36 -0
  51. package/lib/cjs/resources/bing_geocoders.js +37 -0
  52. package/lib/cjs/resources/braintree_gateways.d.ts +57 -0
  53. package/lib/cjs/resources/braintree_gateways.js +37 -0
  54. package/lib/cjs/resources/braintree_payments.d.ts +49 -0
  55. package/lib/cjs/resources/braintree_payments.js +37 -0
  56. package/lib/cjs/resources/bundles.d.ts +77 -0
  57. package/lib/cjs/resources/bundles.js +45 -0
  58. package/lib/cjs/resources/captures.d.ts +52 -0
  59. package/lib/cjs/resources/captures.js +39 -0
  60. package/lib/cjs/resources/carrier_accounts.d.ts +27 -0
  61. package/lib/cjs/resources/carrier_accounts.js +28 -0
  62. package/lib/cjs/resources/checkout_com_gateways.d.ts +46 -0
  63. package/lib/cjs/resources/checkout_com_gateways.js +37 -0
  64. package/lib/cjs/resources/checkout_com_payments.d.ts +60 -0
  65. package/lib/cjs/resources/checkout_com_payments.js +37 -0
  66. package/lib/cjs/resources/cleanups.d.ts +37 -0
  67. package/lib/cjs/resources/cleanups.js +30 -0
  68. package/lib/cjs/resources/coupon_codes_promotion_rules.d.ts +60 -0
  69. package/lib/cjs/resources/coupon_codes_promotion_rules.js +33 -0
  70. package/lib/cjs/resources/coupon_recipients.d.ts +45 -0
  71. package/lib/cjs/resources/coupon_recipients.js +37 -0
  72. package/lib/cjs/resources/coupons.d.ts +46 -0
  73. package/lib/cjs/resources/coupons.js +33 -0
  74. package/lib/cjs/resources/customer_addresses.d.ts +45 -0
  75. package/lib/cjs/resources/customer_addresses.js +41 -0
  76. package/lib/cjs/resources/customer_groups.d.ts +37 -0
  77. package/lib/cjs/resources/customer_groups.js +41 -0
  78. package/lib/cjs/resources/customer_password_resets.d.ts +37 -0
  79. package/lib/cjs/resources/customer_password_resets.js +37 -0
  80. package/lib/cjs/resources/customer_payment_sources.d.ts +79 -0
  81. package/lib/cjs/resources/customer_payment_sources.js +33 -0
  82. package/lib/cjs/resources/customer_subscriptions.d.ts +32 -0
  83. package/lib/cjs/resources/customer_subscriptions.js +37 -0
  84. package/lib/cjs/resources/customers.d.ts +67 -0
  85. package/lib/cjs/resources/customers.js +69 -0
  86. package/lib/cjs/resources/delivery_lead_times.d.ts +52 -0
  87. package/lib/cjs/resources/delivery_lead_times.js +41 -0
  88. package/lib/cjs/resources/event_callbacks.d.ts +25 -0
  89. package/lib/cjs/resources/event_callbacks.js +24 -0
  90. package/lib/cjs/resources/events.d.ts +25 -0
  91. package/lib/cjs/resources/events.js +28 -0
  92. package/lib/cjs/resources/exports.d.ts +41 -0
  93. package/lib/cjs/resources/exports.js +30 -0
  94. package/lib/cjs/resources/external_gateways.d.ts +50 -0
  95. package/lib/cjs/resources/external_gateways.js +37 -0
  96. package/lib/cjs/resources/external_payments.d.ts +45 -0
  97. package/lib/cjs/resources/external_payments.js +41 -0
  98. package/lib/cjs/resources/external_promotions.d.ts +91 -0
  99. package/lib/cjs/resources/external_promotions.js +53 -0
  100. package/lib/cjs/resources/external_tax_calculators.d.ts +38 -0
  101. package/lib/cjs/resources/external_tax_calculators.js +37 -0
  102. package/lib/cjs/resources/fixed_amount_promotions.d.ts +92 -0
  103. package/lib/cjs/resources/fixed_amount_promotions.js +53 -0
  104. package/lib/cjs/resources/fixed_price_promotions.d.ts +103 -0
  105. package/lib/cjs/resources/fixed_price_promotions.js +61 -0
  106. package/lib/cjs/resources/free_gift_promotions.d.ts +101 -0
  107. package/lib/cjs/resources/free_gift_promotions.js +61 -0
  108. package/lib/cjs/resources/free_shipping_promotions.d.ts +84 -0
  109. package/lib/cjs/resources/free_shipping_promotions.js +49 -0
  110. package/lib/cjs/resources/geocoders.d.ts +25 -0
  111. package/lib/cjs/resources/geocoders.js +28 -0
  112. package/lib/cjs/resources/gift_card_recipients.d.ts +45 -0
  113. package/lib/cjs/resources/gift_card_recipients.js +37 -0
  114. package/lib/cjs/resources/gift_cards.d.ts +86 -0
  115. package/lib/cjs/resources/gift_cards.js +45 -0
  116. package/lib/cjs/resources/google_geocoders.d.ts +36 -0
  117. package/lib/cjs/resources/google_geocoders.js +37 -0
  118. package/lib/cjs/resources/imports.d.ts +46 -0
  119. package/lib/cjs/resources/imports.js +30 -0
  120. package/lib/cjs/resources/in_stock_subscriptions.d.ts +63 -0
  121. package/lib/cjs/resources/in_stock_subscriptions.js +45 -0
  122. package/lib/cjs/resources/inventory_models.d.ts +43 -0
  123. package/lib/cjs/resources/inventory_models.js +41 -0
  124. package/lib/cjs/resources/inventory_return_locations.d.ts +44 -0
  125. package/lib/cjs/resources/inventory_return_locations.js +37 -0
  126. package/lib/cjs/resources/inventory_stock_locations.d.ts +47 -0
  127. package/lib/cjs/resources/inventory_stock_locations.js +37 -0
  128. package/lib/cjs/resources/klarna_gateways.d.ts +45 -0
  129. package/lib/cjs/resources/klarna_gateways.js +37 -0
  130. package/lib/cjs/resources/klarna_payments.d.ts +47 -0
  131. package/lib/cjs/resources/klarna_payments.js +37 -0
  132. package/lib/cjs/resources/line_item_options.d.ts +58 -0
  133. package/lib/cjs/resources/line_item_options.js +37 -0
  134. package/lib/cjs/resources/line_items.d.ts +127 -0
  135. package/lib/cjs/resources/line_items.js +45 -0
  136. package/lib/cjs/resources/manual_gateways.d.ts +31 -0
  137. package/lib/cjs/resources/manual_gateways.js +33 -0
  138. package/lib/cjs/resources/manual_tax_calculators.d.ts +42 -0
  139. package/lib/cjs/resources/manual_tax_calculators.js +41 -0
  140. package/lib/cjs/resources/markets.d.ts +89 -0
  141. package/lib/cjs/resources/markets.js +53 -0
  142. package/lib/cjs/resources/merchants.d.ts +39 -0
  143. package/lib/cjs/resources/merchants.js +37 -0
  144. package/lib/cjs/resources/order_amount_promotion_rules.d.ts +57 -0
  145. package/lib/cjs/resources/order_amount_promotion_rules.js +29 -0
  146. package/lib/cjs/resources/order_copies.d.ts +49 -0
  147. package/lib/cjs/resources/order_copies.js +42 -0
  148. package/lib/cjs/resources/order_subscriptions.d.ts +71 -0
  149. package/lib/cjs/resources/order_subscriptions.js +53 -0
  150. package/lib/cjs/resources/order_validation_rules.d.ts +24 -0
  151. package/lib/cjs/resources/order_validation_rules.js +28 -0
  152. package/lib/cjs/resources/orders.d.ts +297 -0
  153. package/lib/cjs/resources/orders.js +109 -0
  154. package/lib/cjs/resources/organization.d.ts +32 -0
  155. package/lib/cjs/resources/organization.js +17 -0
  156. package/lib/cjs/resources/packages.d.ts +57 -0
  157. package/lib/cjs/resources/packages.js +41 -0
  158. package/lib/cjs/resources/parcel_line_items.d.ts +52 -0
  159. package/lib/cjs/resources/parcel_line_items.js +37 -0
  160. package/lib/cjs/resources/parcels.d.ts +120 -0
  161. package/lib/cjs/resources/parcels.js +49 -0
  162. package/lib/cjs/resources/payment_gateways.d.ts +22 -0
  163. package/lib/cjs/resources/payment_gateways.js +24 -0
  164. package/lib/cjs/resources/payment_methods.d.ts +73 -0
  165. package/lib/cjs/resources/payment_methods.js +41 -0
  166. package/lib/cjs/resources/paypal_gateways.d.ts +38 -0
  167. package/lib/cjs/resources/paypal_gateways.js +37 -0
  168. package/lib/cjs/resources/paypal_payments.d.ts +53 -0
  169. package/lib/cjs/resources/paypal_payments.js +37 -0
  170. package/lib/cjs/resources/percentage_discount_promotions.d.ts +101 -0
  171. package/lib/cjs/resources/percentage_discount_promotions.js +61 -0
  172. package/lib/cjs/resources/price_lists.d.ts +40 -0
  173. package/lib/cjs/resources/price_lists.js +37 -0
  174. package/lib/cjs/resources/price_tiers.d.ts +29 -0
  175. package/lib/cjs/resources/price_tiers.js +28 -0
  176. package/lib/cjs/resources/price_volume_tiers.d.ts +47 -0
  177. package/lib/cjs/resources/price_volume_tiers.js +37 -0
  178. package/lib/cjs/resources/prices.d.ts +69 -0
  179. package/lib/cjs/resources/prices.js +49 -0
  180. package/lib/cjs/resources/promotion_rules.d.ts +25 -0
  181. package/lib/cjs/resources/promotion_rules.js +20 -0
  182. package/lib/cjs/resources/promotions.d.ts +42 -0
  183. package/lib/cjs/resources/promotions.js +40 -0
  184. package/lib/cjs/resources/refunds.d.ts +38 -0
  185. package/lib/cjs/resources/refunds.js +32 -0
  186. package/lib/cjs/resources/return_line_items.d.ts +50 -0
  187. package/lib/cjs/resources/return_line_items.js +37 -0
  188. package/lib/cjs/resources/returns.d.ts +76 -0
  189. package/lib/cjs/resources/returns.js +61 -0
  190. package/lib/cjs/resources/satispay_gateways.d.ts +40 -0
  191. package/lib/cjs/resources/satispay_gateways.js +37 -0
  192. package/lib/cjs/resources/satispay_payments.d.ts +44 -0
  193. package/lib/cjs/resources/satispay_payments.js +37 -0
  194. package/lib/cjs/resources/shipments.d.ts +94 -0
  195. package/lib/cjs/resources/shipments.js +79 -0
  196. package/lib/cjs/resources/shipping_categories.d.ts +34 -0
  197. package/lib/cjs/resources/shipping_categories.js +37 -0
  198. package/lib/cjs/resources/shipping_method_tiers.d.ts +29 -0
  199. package/lib/cjs/resources/shipping_method_tiers.js +28 -0
  200. package/lib/cjs/resources/shipping_methods.d.ts +108 -0
  201. package/lib/cjs/resources/shipping_methods.js +61 -0
  202. package/lib/cjs/resources/shipping_weight_tiers.d.ts +47 -0
  203. package/lib/cjs/resources/shipping_weight_tiers.js +37 -0
  204. package/lib/cjs/resources/shipping_zones.d.ts +49 -0
  205. package/lib/cjs/resources/shipping_zones.js +33 -0
  206. package/lib/cjs/resources/sku_list_items.d.ts +48 -0
  207. package/lib/cjs/resources/sku_list_items.js +37 -0
  208. package/lib/cjs/resources/sku_list_promotion_rules.d.ts +69 -0
  209. package/lib/cjs/resources/sku_list_promotion_rules.js +37 -0
  210. package/lib/cjs/resources/sku_lists.d.ts +61 -0
  211. package/lib/cjs/resources/sku_lists.js +49 -0
  212. package/lib/cjs/resources/sku_options.d.ts +57 -0
  213. package/lib/cjs/resources/sku_options.js +37 -0
  214. package/lib/cjs/resources/skus.d.ts +79 -0
  215. package/lib/cjs/resources/skus.js +53 -0
  216. package/lib/cjs/resources/stock_items.d.ts +50 -0
  217. package/lib/cjs/resources/stock_items.js +41 -0
  218. package/lib/cjs/resources/stock_line_items.d.ts +30 -0
  219. package/lib/cjs/resources/stock_line_items.js +32 -0
  220. package/lib/cjs/resources/stock_locations.d.ts +58 -0
  221. package/lib/cjs/resources/stock_locations.js +53 -0
  222. package/lib/cjs/resources/stock_transfers.d.ts +75 -0
  223. package/lib/cjs/resources/stock_transfers.js +53 -0
  224. package/lib/cjs/resources/stripe_gateways.d.ts +42 -0
  225. package/lib/cjs/resources/stripe_gateways.js +37 -0
  226. package/lib/cjs/resources/stripe_payments.d.ts +48 -0
  227. package/lib/cjs/resources/stripe_payments.js +37 -0
  228. package/lib/cjs/resources/tax_calculators.d.ts +25 -0
  229. package/lib/cjs/resources/tax_calculators.js +28 -0
  230. package/lib/cjs/resources/tax_categories.d.ts +60 -0
  231. package/lib/cjs/resources/tax_categories.js +37 -0
  232. package/lib/cjs/resources/tax_rules.d.ts +70 -0
  233. package/lib/cjs/resources/tax_rules.js +33 -0
  234. package/lib/cjs/resources/taxjar_accounts.d.ts +44 -0
  235. package/lib/cjs/resources/taxjar_accounts.js +41 -0
  236. package/lib/cjs/resources/transactions.d.ts +32 -0
  237. package/lib/cjs/resources/transactions.js +24 -0
  238. package/lib/cjs/resources/voids.d.ts +38 -0
  239. package/lib/cjs/resources/voids.js +32 -0
  240. package/lib/cjs/resources/webhooks.d.ts +44 -0
  241. package/lib/cjs/resources/webhooks.js +33 -0
  242. package/lib/cjs/resources/wire_transfers.d.ts +34 -0
  243. package/lib/cjs/resources/wire_transfers.js +33 -0
  244. package/lib/cjs/static.d.ts +9 -0
  245. package/lib/cjs/static.js +45 -0
  246. package/lib/cjs/util.d.ts +10 -0
  247. package/lib/cjs/util.js +15 -0
  248. package/lib/esm/api.d.ts +113 -0
  249. package/lib/esm/api.js +239 -0
  250. package/lib/esm/client.d.ts +33 -0
  251. package/lib/esm/client.js +117 -0
  252. package/lib/esm/commercelayer.d.ts +139 -0
  253. package/lib/esm/commercelayer.js +201 -0
  254. package/lib/esm/common.d.ts +4 -0
  255. package/lib/esm/common.js +8 -0
  256. package/lib/esm/config.d.ts +11 -0
  257. package/lib/esm/config.js +11 -0
  258. package/lib/esm/debug.d.ts +3 -0
  259. package/lib/esm/debug.js +37 -0
  260. package/lib/esm/error.d.ts +28 -0
  261. package/lib/esm/error.js +37 -0
  262. package/lib/esm/index.d.ts +7 -0
  263. package/lib/esm/index.js +6 -0
  264. package/lib/esm/interceptor.d.ts +25 -0
  265. package/lib/esm/interceptor.js +1 -0
  266. package/lib/esm/jsonapi.d.ts +5 -0
  267. package/lib/esm/jsonapi.js +75 -0
  268. package/lib/esm/model.d.ts +111 -0
  269. package/lib/esm/model.js +2 -0
  270. package/lib/esm/query.d.ts +24 -0
  271. package/lib/esm/query.js +45 -0
  272. package/lib/esm/resource.d.ts +90 -0
  273. package/lib/esm/resource.js +160 -0
  274. package/lib/esm/resources/addresses.d.ts +89 -0
  275. package/lib/esm/resources/addresses.js +31 -0
  276. package/lib/esm/resources/adjustments.d.ts +36 -0
  277. package/lib/esm/resources/adjustments.js +27 -0
  278. package/lib/esm/resources/adyen_gateways.d.ts +57 -0
  279. package/lib/esm/resources/adyen_gateways.js +35 -0
  280. package/lib/esm/resources/adyen_payments.d.ts +47 -0
  281. package/lib/esm/resources/adyen_payments.js +35 -0
  282. package/lib/esm/resources/application.d.ts +21 -0
  283. package/lib/esm/resources/application.js +15 -0
  284. package/lib/esm/resources/attachments.d.ts +157 -0
  285. package/lib/esm/resources/attachments.js +27 -0
  286. package/lib/esm/resources/authorizations.d.ts +61 -0
  287. package/lib/esm/resources/authorizations.js +37 -0
  288. package/lib/esm/resources/avalara_accounts.d.ts +56 -0
  289. package/lib/esm/resources/avalara_accounts.js +39 -0
  290. package/lib/esm/resources/axerve_gateways.d.ts +44 -0
  291. package/lib/esm/resources/axerve_gateways.js +35 -0
  292. package/lib/esm/resources/axerve_payments.d.ts +47 -0
  293. package/lib/esm/resources/axerve_payments.js +35 -0
  294. package/lib/esm/resources/billing_info_validation_rules.d.ts +36 -0
  295. package/lib/esm/resources/billing_info_validation_rules.js +35 -0
  296. package/lib/esm/resources/bing_geocoders.d.ts +36 -0
  297. package/lib/esm/resources/bing_geocoders.js +35 -0
  298. package/lib/esm/resources/braintree_gateways.d.ts +57 -0
  299. package/lib/esm/resources/braintree_gateways.js +35 -0
  300. package/lib/esm/resources/braintree_payments.d.ts +49 -0
  301. package/lib/esm/resources/braintree_payments.js +35 -0
  302. package/lib/esm/resources/bundles.d.ts +77 -0
  303. package/lib/esm/resources/bundles.js +43 -0
  304. package/lib/esm/resources/captures.d.ts +52 -0
  305. package/lib/esm/resources/captures.js +37 -0
  306. package/lib/esm/resources/carrier_accounts.d.ts +27 -0
  307. package/lib/esm/resources/carrier_accounts.js +26 -0
  308. package/lib/esm/resources/checkout_com_gateways.d.ts +46 -0
  309. package/lib/esm/resources/checkout_com_gateways.js +35 -0
  310. package/lib/esm/resources/checkout_com_payments.d.ts +60 -0
  311. package/lib/esm/resources/checkout_com_payments.js +35 -0
  312. package/lib/esm/resources/cleanups.d.ts +37 -0
  313. package/lib/esm/resources/cleanups.js +28 -0
  314. package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +60 -0
  315. package/lib/esm/resources/coupon_codes_promotion_rules.js +31 -0
  316. package/lib/esm/resources/coupon_recipients.d.ts +45 -0
  317. package/lib/esm/resources/coupon_recipients.js +35 -0
  318. package/lib/esm/resources/coupons.d.ts +46 -0
  319. package/lib/esm/resources/coupons.js +31 -0
  320. package/lib/esm/resources/customer_addresses.d.ts +45 -0
  321. package/lib/esm/resources/customer_addresses.js +39 -0
  322. package/lib/esm/resources/customer_groups.d.ts +37 -0
  323. package/lib/esm/resources/customer_groups.js +39 -0
  324. package/lib/esm/resources/customer_password_resets.d.ts +37 -0
  325. package/lib/esm/resources/customer_password_resets.js +35 -0
  326. package/lib/esm/resources/customer_payment_sources.d.ts +79 -0
  327. package/lib/esm/resources/customer_payment_sources.js +31 -0
  328. package/lib/esm/resources/customer_subscriptions.d.ts +32 -0
  329. package/lib/esm/resources/customer_subscriptions.js +35 -0
  330. package/lib/esm/resources/customers.d.ts +67 -0
  331. package/lib/esm/resources/customers.js +67 -0
  332. package/lib/esm/resources/delivery_lead_times.d.ts +52 -0
  333. package/lib/esm/resources/delivery_lead_times.js +39 -0
  334. package/lib/esm/resources/event_callbacks.d.ts +25 -0
  335. package/lib/esm/resources/event_callbacks.js +22 -0
  336. package/lib/esm/resources/events.d.ts +25 -0
  337. package/lib/esm/resources/events.js +26 -0
  338. package/lib/esm/resources/exports.d.ts +41 -0
  339. package/lib/esm/resources/exports.js +28 -0
  340. package/lib/esm/resources/external_gateways.d.ts +50 -0
  341. package/lib/esm/resources/external_gateways.js +35 -0
  342. package/lib/esm/resources/external_payments.d.ts +45 -0
  343. package/lib/esm/resources/external_payments.js +39 -0
  344. package/lib/esm/resources/external_promotions.d.ts +91 -0
  345. package/lib/esm/resources/external_promotions.js +51 -0
  346. package/lib/esm/resources/external_tax_calculators.d.ts +38 -0
  347. package/lib/esm/resources/external_tax_calculators.js +35 -0
  348. package/lib/esm/resources/fixed_amount_promotions.d.ts +92 -0
  349. package/lib/esm/resources/fixed_amount_promotions.js +51 -0
  350. package/lib/esm/resources/fixed_price_promotions.d.ts +103 -0
  351. package/lib/esm/resources/fixed_price_promotions.js +59 -0
  352. package/lib/esm/resources/free_gift_promotions.d.ts +101 -0
  353. package/lib/esm/resources/free_gift_promotions.js +59 -0
  354. package/lib/esm/resources/free_shipping_promotions.d.ts +84 -0
  355. package/lib/esm/resources/free_shipping_promotions.js +47 -0
  356. package/lib/esm/resources/geocoders.d.ts +25 -0
  357. package/lib/esm/resources/geocoders.js +26 -0
  358. package/lib/esm/resources/gift_card_recipients.d.ts +45 -0
  359. package/lib/esm/resources/gift_card_recipients.js +35 -0
  360. package/lib/esm/resources/gift_cards.d.ts +86 -0
  361. package/lib/esm/resources/gift_cards.js +43 -0
  362. package/lib/esm/resources/google_geocoders.d.ts +36 -0
  363. package/lib/esm/resources/google_geocoders.js +35 -0
  364. package/lib/esm/resources/imports.d.ts +46 -0
  365. package/lib/esm/resources/imports.js +28 -0
  366. package/lib/esm/resources/in_stock_subscriptions.d.ts +63 -0
  367. package/lib/esm/resources/in_stock_subscriptions.js +43 -0
  368. package/lib/esm/resources/inventory_models.d.ts +43 -0
  369. package/lib/esm/resources/inventory_models.js +39 -0
  370. package/lib/esm/resources/inventory_return_locations.d.ts +44 -0
  371. package/lib/esm/resources/inventory_return_locations.js +35 -0
  372. package/lib/esm/resources/inventory_stock_locations.d.ts +47 -0
  373. package/lib/esm/resources/inventory_stock_locations.js +35 -0
  374. package/lib/esm/resources/klarna_gateways.d.ts +45 -0
  375. package/lib/esm/resources/klarna_gateways.js +35 -0
  376. package/lib/esm/resources/klarna_payments.d.ts +47 -0
  377. package/lib/esm/resources/klarna_payments.js +35 -0
  378. package/lib/esm/resources/line_item_options.d.ts +58 -0
  379. package/lib/esm/resources/line_item_options.js +35 -0
  380. package/lib/esm/resources/line_items.d.ts +127 -0
  381. package/lib/esm/resources/line_items.js +43 -0
  382. package/lib/esm/resources/manual_gateways.d.ts +31 -0
  383. package/lib/esm/resources/manual_gateways.js +31 -0
  384. package/lib/esm/resources/manual_tax_calculators.d.ts +42 -0
  385. package/lib/esm/resources/manual_tax_calculators.js +39 -0
  386. package/lib/esm/resources/markets.d.ts +89 -0
  387. package/lib/esm/resources/markets.js +51 -0
  388. package/lib/esm/resources/merchants.d.ts +39 -0
  389. package/lib/esm/resources/merchants.js +35 -0
  390. package/lib/esm/resources/order_amount_promotion_rules.d.ts +57 -0
  391. package/lib/esm/resources/order_amount_promotion_rules.js +27 -0
  392. package/lib/esm/resources/order_copies.d.ts +49 -0
  393. package/lib/esm/resources/order_copies.js +40 -0
  394. package/lib/esm/resources/order_subscriptions.d.ts +71 -0
  395. package/lib/esm/resources/order_subscriptions.js +51 -0
  396. package/lib/esm/resources/order_validation_rules.d.ts +24 -0
  397. package/lib/esm/resources/order_validation_rules.js +26 -0
  398. package/lib/esm/resources/orders.d.ts +297 -0
  399. package/lib/esm/resources/orders.js +107 -0
  400. package/lib/esm/resources/organization.d.ts +32 -0
  401. package/lib/esm/resources/organization.js +15 -0
  402. package/lib/esm/resources/packages.d.ts +57 -0
  403. package/lib/esm/resources/packages.js +39 -0
  404. package/lib/esm/resources/parcel_line_items.d.ts +52 -0
  405. package/lib/esm/resources/parcel_line_items.js +35 -0
  406. package/lib/esm/resources/parcels.d.ts +120 -0
  407. package/lib/esm/resources/parcels.js +47 -0
  408. package/lib/esm/resources/payment_gateways.d.ts +22 -0
  409. package/lib/esm/resources/payment_gateways.js +22 -0
  410. package/lib/esm/resources/payment_methods.d.ts +73 -0
  411. package/lib/esm/resources/payment_methods.js +39 -0
  412. package/lib/esm/resources/paypal_gateways.d.ts +38 -0
  413. package/lib/esm/resources/paypal_gateways.js +35 -0
  414. package/lib/esm/resources/paypal_payments.d.ts +53 -0
  415. package/lib/esm/resources/paypal_payments.js +35 -0
  416. package/lib/esm/resources/percentage_discount_promotions.d.ts +101 -0
  417. package/lib/esm/resources/percentage_discount_promotions.js +59 -0
  418. package/lib/esm/resources/price_lists.d.ts +40 -0
  419. package/lib/esm/resources/price_lists.js +35 -0
  420. package/lib/esm/resources/price_tiers.d.ts +29 -0
  421. package/lib/esm/resources/price_tiers.js +26 -0
  422. package/lib/esm/resources/price_volume_tiers.d.ts +47 -0
  423. package/lib/esm/resources/price_volume_tiers.js +35 -0
  424. package/lib/esm/resources/prices.d.ts +69 -0
  425. package/lib/esm/resources/prices.js +47 -0
  426. package/lib/esm/resources/promotion_rules.d.ts +25 -0
  427. package/lib/esm/resources/promotion_rules.js +18 -0
  428. package/lib/esm/resources/promotions.d.ts +42 -0
  429. package/lib/esm/resources/promotions.js +38 -0
  430. package/lib/esm/resources/refunds.d.ts +38 -0
  431. package/lib/esm/resources/refunds.js +30 -0
  432. package/lib/esm/resources/return_line_items.d.ts +50 -0
  433. package/lib/esm/resources/return_line_items.js +35 -0
  434. package/lib/esm/resources/returns.d.ts +76 -0
  435. package/lib/esm/resources/returns.js +59 -0
  436. package/lib/esm/resources/satispay_gateways.d.ts +40 -0
  437. package/lib/esm/resources/satispay_gateways.js +35 -0
  438. package/lib/esm/resources/satispay_payments.d.ts +44 -0
  439. package/lib/esm/resources/satispay_payments.js +35 -0
  440. package/lib/esm/resources/shipments.d.ts +94 -0
  441. package/lib/esm/resources/shipments.js +77 -0
  442. package/lib/esm/resources/shipping_categories.d.ts +34 -0
  443. package/lib/esm/resources/shipping_categories.js +35 -0
  444. package/lib/esm/resources/shipping_method_tiers.d.ts +29 -0
  445. package/lib/esm/resources/shipping_method_tiers.js +26 -0
  446. package/lib/esm/resources/shipping_methods.d.ts +108 -0
  447. package/lib/esm/resources/shipping_methods.js +59 -0
  448. package/lib/esm/resources/shipping_weight_tiers.d.ts +47 -0
  449. package/lib/esm/resources/shipping_weight_tiers.js +35 -0
  450. package/lib/esm/resources/shipping_zones.d.ts +49 -0
  451. package/lib/esm/resources/shipping_zones.js +31 -0
  452. package/lib/esm/resources/sku_list_items.d.ts +48 -0
  453. package/lib/esm/resources/sku_list_items.js +35 -0
  454. package/lib/esm/resources/sku_list_promotion_rules.d.ts +69 -0
  455. package/lib/esm/resources/sku_list_promotion_rules.js +35 -0
  456. package/lib/esm/resources/sku_lists.d.ts +61 -0
  457. package/lib/esm/resources/sku_lists.js +47 -0
  458. package/lib/esm/resources/sku_options.d.ts +57 -0
  459. package/lib/esm/resources/sku_options.js +35 -0
  460. package/lib/esm/resources/skus.d.ts +79 -0
  461. package/lib/esm/resources/skus.js +51 -0
  462. package/lib/esm/resources/stock_items.d.ts +50 -0
  463. package/lib/esm/resources/stock_items.js +39 -0
  464. package/lib/esm/resources/stock_line_items.d.ts +30 -0
  465. package/lib/esm/resources/stock_line_items.js +30 -0
  466. package/lib/esm/resources/stock_locations.d.ts +58 -0
  467. package/lib/esm/resources/stock_locations.js +51 -0
  468. package/lib/esm/resources/stock_transfers.d.ts +75 -0
  469. package/lib/esm/resources/stock_transfers.js +51 -0
  470. package/lib/esm/resources/stripe_gateways.d.ts +42 -0
  471. package/lib/esm/resources/stripe_gateways.js +35 -0
  472. package/lib/esm/resources/stripe_payments.d.ts +48 -0
  473. package/lib/esm/resources/stripe_payments.js +35 -0
  474. package/lib/esm/resources/tax_calculators.d.ts +25 -0
  475. package/lib/esm/resources/tax_calculators.js +26 -0
  476. package/lib/esm/resources/tax_categories.d.ts +60 -0
  477. package/lib/esm/resources/tax_categories.js +35 -0
  478. package/lib/esm/resources/tax_rules.d.ts +70 -0
  479. package/lib/esm/resources/tax_rules.js +31 -0
  480. package/lib/esm/resources/taxjar_accounts.d.ts +44 -0
  481. package/lib/esm/resources/taxjar_accounts.js +39 -0
  482. package/lib/esm/resources/transactions.d.ts +32 -0
  483. package/lib/esm/resources/transactions.js +22 -0
  484. package/lib/esm/resources/voids.d.ts +38 -0
  485. package/lib/esm/resources/voids.js +30 -0
  486. package/lib/esm/resources/webhooks.d.ts +44 -0
  487. package/lib/esm/resources/webhooks.js +31 -0
  488. package/lib/esm/resources/wire_transfers.d.ts +34 -0
  489. package/lib/esm/resources/wire_transfers.js +31 -0
  490. package/lib/esm/static.d.ts +9 -0
  491. package/lib/esm/static.js +19 -0
  492. package/lib/esm/util.d.ts +10 -0
  493. package/lib/esm/util.js +11 -0
  494. package/lib/tsconfig.esm.tsbuildinfo +1 -0
  495. package/lib/tsconfig.tsbuildinfo +1 -0
  496. package/package.json +27 -36
  497. package/lib/api.d.ts +0 -1
  498. package/lib/api.js +0 -1
  499. package/lib/client.d.ts +0 -2
  500. package/lib/client.js +0 -1
  501. package/lib/commercelayer.d.ts +0 -1
  502. package/lib/commercelayer.js +0 -1
  503. package/lib/common.d.ts +0 -1
  504. package/lib/common.js +0 -1
  505. package/lib/config.d.ts +0 -1
  506. package/lib/config.js +0 -1
  507. package/lib/debug.d.ts +0 -1
  508. package/lib/debug.js +0 -1
  509. package/lib/error.d.ts +0 -1
  510. package/lib/error.js +0 -1
  511. package/lib/index.d.ts +0 -1
  512. package/lib/index.js +0 -1
  513. package/lib/interceptor.d.ts +0 -1
  514. package/lib/interceptor.js +0 -1
  515. package/lib/jsonapi.d.ts +0 -1
  516. package/lib/jsonapi.js +0 -1
  517. package/lib/model.d.ts +0 -1
  518. package/lib/model.js +0 -1
  519. package/lib/query.d.ts +0 -1
  520. package/lib/query.js +0 -1
  521. package/lib/resource.d.ts +0 -1
  522. package/lib/resource.js +0 -1
  523. package/lib/resources/addresses.d.ts +0 -1
  524. package/lib/resources/addresses.js +0 -1
  525. package/lib/resources/adjustments.d.ts +0 -1
  526. package/lib/resources/adjustments.js +0 -1
  527. package/lib/resources/adyen_gateways.d.ts +0 -1
  528. package/lib/resources/adyen_gateways.js +0 -1
  529. package/lib/resources/adyen_payments.d.ts +0 -1
  530. package/lib/resources/adyen_payments.js +0 -1
  531. package/lib/resources/application.d.ts +0 -1
  532. package/lib/resources/application.js +0 -1
  533. package/lib/resources/attachments.d.ts +0 -1
  534. package/lib/resources/attachments.js +0 -1
  535. package/lib/resources/authorizations.d.ts +0 -1
  536. package/lib/resources/authorizations.js +0 -1
  537. package/lib/resources/avalara_accounts.d.ts +0 -1
  538. package/lib/resources/avalara_accounts.js +0 -1
  539. package/lib/resources/billing_info_validation_rules.d.ts +0 -1
  540. package/lib/resources/billing_info_validation_rules.js +0 -1
  541. package/lib/resources/bing_geocoders.d.ts +0 -1
  542. package/lib/resources/bing_geocoders.js +0 -1
  543. package/lib/resources/braintree_gateways.d.ts +0 -1
  544. package/lib/resources/braintree_gateways.js +0 -1
  545. package/lib/resources/braintree_payments.d.ts +0 -1
  546. package/lib/resources/braintree_payments.js +0 -1
  547. package/lib/resources/bundles.d.ts +0 -1
  548. package/lib/resources/bundles.js +0 -1
  549. package/lib/resources/captures.d.ts +0 -1
  550. package/lib/resources/captures.js +0 -1
  551. package/lib/resources/carrier_accounts.d.ts +0 -1
  552. package/lib/resources/carrier_accounts.js +0 -1
  553. package/lib/resources/checkout_com_gateways.d.ts +0 -1
  554. package/lib/resources/checkout_com_gateways.js +0 -1
  555. package/lib/resources/checkout_com_payments.d.ts +0 -1
  556. package/lib/resources/checkout_com_payments.js +0 -1
  557. package/lib/resources/coupon_codes_promotion_rules.d.ts +0 -1
  558. package/lib/resources/coupon_codes_promotion_rules.js +0 -1
  559. package/lib/resources/coupon_recipients.d.ts +0 -1
  560. package/lib/resources/coupon_recipients.js +0 -1
  561. package/lib/resources/coupons.d.ts +0 -1
  562. package/lib/resources/coupons.js +0 -1
  563. package/lib/resources/customer_addresses.d.ts +0 -1
  564. package/lib/resources/customer_addresses.js +0 -1
  565. package/lib/resources/customer_groups.d.ts +0 -1
  566. package/lib/resources/customer_groups.js +0 -1
  567. package/lib/resources/customer_password_resets.d.ts +0 -1
  568. package/lib/resources/customer_password_resets.js +0 -1
  569. package/lib/resources/customer_payment_sources.d.ts +0 -1
  570. package/lib/resources/customer_payment_sources.js +0 -1
  571. package/lib/resources/customer_subscriptions.d.ts +0 -1
  572. package/lib/resources/customer_subscriptions.js +0 -1
  573. package/lib/resources/customers.d.ts +0 -1
  574. package/lib/resources/customers.js +0 -1
  575. package/lib/resources/delivery_lead_times.d.ts +0 -1
  576. package/lib/resources/delivery_lead_times.js +0 -1
  577. package/lib/resources/event_callbacks.d.ts +0 -1
  578. package/lib/resources/event_callbacks.js +0 -1
  579. package/lib/resources/external_gateways.d.ts +0 -1
  580. package/lib/resources/external_gateways.js +0 -1
  581. package/lib/resources/external_payments.d.ts +0 -1
  582. package/lib/resources/external_payments.js +0 -1
  583. package/lib/resources/external_promotions.d.ts +0 -1
  584. package/lib/resources/external_promotions.js +0 -1
  585. package/lib/resources/external_tax_calculators.d.ts +0 -1
  586. package/lib/resources/external_tax_calculators.js +0 -1
  587. package/lib/resources/fixed_amount_promotions.d.ts +0 -1
  588. package/lib/resources/fixed_amount_promotions.js +0 -1
  589. package/lib/resources/fixed_price_promotions.d.ts +0 -1
  590. package/lib/resources/fixed_price_promotions.js +0 -1
  591. package/lib/resources/free_gift_promotions.d.ts +0 -1
  592. package/lib/resources/free_gift_promotions.js +0 -1
  593. package/lib/resources/free_shipping_promotions.d.ts +0 -1
  594. package/lib/resources/free_shipping_promotions.js +0 -1
  595. package/lib/resources/geocoders.d.ts +0 -1
  596. package/lib/resources/geocoders.js +0 -1
  597. package/lib/resources/gift_card_recipients.d.ts +0 -1
  598. package/lib/resources/gift_card_recipients.js +0 -1
  599. package/lib/resources/gift_cards.d.ts +0 -1
  600. package/lib/resources/gift_cards.js +0 -1
  601. package/lib/resources/google_geocoders.d.ts +0 -1
  602. package/lib/resources/google_geocoders.js +0 -1
  603. package/lib/resources/imports.d.ts +0 -1
  604. package/lib/resources/imports.js +0 -1
  605. package/lib/resources/in_stock_subscriptions.d.ts +0 -1
  606. package/lib/resources/in_stock_subscriptions.js +0 -1
  607. package/lib/resources/inventory_models.d.ts +0 -1
  608. package/lib/resources/inventory_models.js +0 -1
  609. package/lib/resources/inventory_return_locations.d.ts +0 -1
  610. package/lib/resources/inventory_return_locations.js +0 -1
  611. package/lib/resources/inventory_stock_locations.d.ts +0 -1
  612. package/lib/resources/inventory_stock_locations.js +0 -1
  613. package/lib/resources/klarna_gateways.d.ts +0 -1
  614. package/lib/resources/klarna_gateways.js +0 -1
  615. package/lib/resources/klarna_payments.d.ts +0 -1
  616. package/lib/resources/klarna_payments.js +0 -1
  617. package/lib/resources/line_item_options.d.ts +0 -1
  618. package/lib/resources/line_item_options.js +0 -1
  619. package/lib/resources/line_items.d.ts +0 -1
  620. package/lib/resources/line_items.js +0 -1
  621. package/lib/resources/manual_gateways.d.ts +0 -1
  622. package/lib/resources/manual_gateways.js +0 -1
  623. package/lib/resources/manual_tax_calculators.d.ts +0 -1
  624. package/lib/resources/manual_tax_calculators.js +0 -1
  625. package/lib/resources/markets.d.ts +0 -1
  626. package/lib/resources/markets.js +0 -1
  627. package/lib/resources/merchants.d.ts +0 -1
  628. package/lib/resources/merchants.js +0 -1
  629. package/lib/resources/order_amount_promotion_rules.d.ts +0 -1
  630. package/lib/resources/order_amount_promotion_rules.js +0 -1
  631. package/lib/resources/order_copies.d.ts +0 -1
  632. package/lib/resources/order_copies.js +0 -1
  633. package/lib/resources/order_subscriptions.d.ts +0 -1
  634. package/lib/resources/order_subscriptions.js +0 -1
  635. package/lib/resources/order_validation_rules.d.ts +0 -1
  636. package/lib/resources/order_validation_rules.js +0 -1
  637. package/lib/resources/orders.d.ts +0 -1
  638. package/lib/resources/orders.js +0 -1
  639. package/lib/resources/organization.d.ts +0 -1
  640. package/lib/resources/organization.js +0 -1
  641. package/lib/resources/packages.d.ts +0 -1
  642. package/lib/resources/packages.js +0 -1
  643. package/lib/resources/parcel_line_items.d.ts +0 -1
  644. package/lib/resources/parcel_line_items.js +0 -1
  645. package/lib/resources/parcels.d.ts +0 -1
  646. package/lib/resources/parcels.js +0 -1
  647. package/lib/resources/payment_gateways.d.ts +0 -1
  648. package/lib/resources/payment_gateways.js +0 -1
  649. package/lib/resources/payment_methods.d.ts +0 -1
  650. package/lib/resources/payment_methods.js +0 -1
  651. package/lib/resources/paypal_gateways.d.ts +0 -1
  652. package/lib/resources/paypal_gateways.js +0 -1
  653. package/lib/resources/paypal_payments.d.ts +0 -1
  654. package/lib/resources/paypal_payments.js +0 -1
  655. package/lib/resources/percentage_discount_promotions.d.ts +0 -1
  656. package/lib/resources/percentage_discount_promotions.js +0 -1
  657. package/lib/resources/price_lists.d.ts +0 -1
  658. package/lib/resources/price_lists.js +0 -1
  659. package/lib/resources/prices.d.ts +0 -1
  660. package/lib/resources/prices.js +0 -1
  661. package/lib/resources/promotion_rules.d.ts +0 -1
  662. package/lib/resources/promotion_rules.js +0 -1
  663. package/lib/resources/promotions.d.ts +0 -1
  664. package/lib/resources/promotions.js +0 -1
  665. package/lib/resources/refunds.d.ts +0 -1
  666. package/lib/resources/refunds.js +0 -1
  667. package/lib/resources/return_line_items.d.ts +0 -1
  668. package/lib/resources/return_line_items.js +0 -1
  669. package/lib/resources/returns.d.ts +0 -1
  670. package/lib/resources/returns.js +0 -1
  671. package/lib/resources/shipments.d.ts +0 -1
  672. package/lib/resources/shipments.js +0 -1
  673. package/lib/resources/shipping_categories.d.ts +0 -1
  674. package/lib/resources/shipping_categories.js +0 -1
  675. package/lib/resources/shipping_methods.d.ts +0 -1
  676. package/lib/resources/shipping_methods.js +0 -1
  677. package/lib/resources/shipping_zones.d.ts +0 -1
  678. package/lib/resources/shipping_zones.js +0 -1
  679. package/lib/resources/sku_list_items.d.ts +0 -1
  680. package/lib/resources/sku_list_items.js +0 -1
  681. package/lib/resources/sku_list_promotion_rules.d.ts +0 -1
  682. package/lib/resources/sku_list_promotion_rules.js +0 -1
  683. package/lib/resources/sku_lists.d.ts +0 -1
  684. package/lib/resources/sku_lists.js +0 -1
  685. package/lib/resources/sku_options.d.ts +0 -1
  686. package/lib/resources/sku_options.js +0 -1
  687. package/lib/resources/skus.d.ts +0 -1
  688. package/lib/resources/skus.js +0 -1
  689. package/lib/resources/stock_items.d.ts +0 -1
  690. package/lib/resources/stock_items.js +0 -1
  691. package/lib/resources/stock_line_items.d.ts +0 -1
  692. package/lib/resources/stock_line_items.js +0 -1
  693. package/lib/resources/stock_locations.d.ts +0 -1
  694. package/lib/resources/stock_locations.js +0 -1
  695. package/lib/resources/stock_transfers.d.ts +0 -1
  696. package/lib/resources/stock_transfers.js +0 -1
  697. package/lib/resources/stripe_gateways.d.ts +0 -1
  698. package/lib/resources/stripe_gateways.js +0 -1
  699. package/lib/resources/stripe_payments.d.ts +0 -1
  700. package/lib/resources/stripe_payments.js +0 -1
  701. package/lib/resources/tax_calculators.d.ts +0 -1
  702. package/lib/resources/tax_calculators.js +0 -1
  703. package/lib/resources/tax_categories.d.ts +0 -1
  704. package/lib/resources/tax_categories.js +0 -1
  705. package/lib/resources/tax_rules.d.ts +0 -1
  706. package/lib/resources/tax_rules.js +0 -1
  707. package/lib/resources/taxjar_accounts.d.ts +0 -1
  708. package/lib/resources/taxjar_accounts.js +0 -1
  709. package/lib/resources/transactions.d.ts +0 -1
  710. package/lib/resources/transactions.js +0 -1
  711. package/lib/resources/voids.d.ts +0 -1
  712. package/lib/resources/voids.js +0 -1
  713. package/lib/resources/webhooks.d.ts +0 -1
  714. package/lib/resources/webhooks.js +0 -1
  715. package/lib/resources/wire_transfers.d.ts +0 -1
  716. package/lib/resources/wire_transfers.js +0 -1
  717. package/lib/static.d.ts +0 -1
  718. package/lib/static.js +0 -1
  719. package/lib/util.d.ts +0 -2
  720. package/lib/util.js +0 -1
@@ -0,0 +1,82 @@
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;
@@ -0,0 +1,111 @@
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 { AxerveGateway, AxerveGatewayCreate, AxerveGatewayUpdate } from './resources/axerve_gateways';
13
+ export type { AxervePayment, AxervePaymentCreate, AxervePaymentUpdate } from './resources/axerve_payments';
14
+ export type { BillingInfoValidationRule, BillingInfoValidationRuleCreate, BillingInfoValidationRuleUpdate } from './resources/billing_info_validation_rules';
15
+ export type { BingGeocoder, BingGeocoderCreate, BingGeocoderUpdate } from './resources/bing_geocoders';
16
+ export type { BraintreeGateway, BraintreeGatewayCreate, BraintreeGatewayUpdate } from './resources/braintree_gateways';
17
+ export type { BraintreePayment, BraintreePaymentCreate, BraintreePaymentUpdate } from './resources/braintree_payments';
18
+ export type { Bundle, BundleCreate, BundleUpdate } from './resources/bundles';
19
+ export type { Capture, CaptureUpdate } from './resources/captures';
20
+ export type { CarrierAccount } from './resources/carrier_accounts';
21
+ export type { CheckoutComGateway, CheckoutComGatewayCreate, CheckoutComGatewayUpdate } from './resources/checkout_com_gateways';
22
+ export type { CheckoutComPayment, CheckoutComPaymentCreate, CheckoutComPaymentUpdate } from './resources/checkout_com_payments';
23
+ export type { Cleanup, CleanupCreate } from './resources/cleanups';
24
+ export type { CouponCodesPromotionRule, CouponCodesPromotionRuleCreate, CouponCodesPromotionRuleUpdate } from './resources/coupon_codes_promotion_rules';
25
+ export type { CouponRecipient, CouponRecipientCreate, CouponRecipientUpdate } from './resources/coupon_recipients';
26
+ export type { Coupon, CouponCreate, CouponUpdate } from './resources/coupons';
27
+ export type { CustomerAddress, CustomerAddressCreate, CustomerAddressUpdate } from './resources/customer_addresses';
28
+ export type { CustomerGroup, CustomerGroupCreate, CustomerGroupUpdate } from './resources/customer_groups';
29
+ export type { CustomerPasswordReset, CustomerPasswordResetCreate, CustomerPasswordResetUpdate } from './resources/customer_password_resets';
30
+ export type { CustomerPaymentSource, CustomerPaymentSourceCreate, CustomerPaymentSourceUpdate } from './resources/customer_payment_sources';
31
+ export type { CustomerSubscription, CustomerSubscriptionCreate, CustomerSubscriptionUpdate } from './resources/customer_subscriptions';
32
+ export type { Customer, CustomerCreate, CustomerUpdate } from './resources/customers';
33
+ export type { DeliveryLeadTime, DeliveryLeadTimeCreate, DeliveryLeadTimeUpdate } from './resources/delivery_lead_times';
34
+ export type { EventCallback } from './resources/event_callbacks';
35
+ export type { Event } from './resources/events';
36
+ export type { Export, ExportCreate } from './resources/exports';
37
+ export type { ExternalGateway, ExternalGatewayCreate, ExternalGatewayUpdate } from './resources/external_gateways';
38
+ export type { ExternalPayment, ExternalPaymentCreate, ExternalPaymentUpdate } from './resources/external_payments';
39
+ export type { ExternalPromotion, ExternalPromotionCreate, ExternalPromotionUpdate } from './resources/external_promotions';
40
+ export type { ExternalTaxCalculator, ExternalTaxCalculatorCreate, ExternalTaxCalculatorUpdate } from './resources/external_tax_calculators';
41
+ export type { FixedAmountPromotion, FixedAmountPromotionCreate, FixedAmountPromotionUpdate } from './resources/fixed_amount_promotions';
42
+ export type { FixedPricePromotion, FixedPricePromotionCreate, FixedPricePromotionUpdate } from './resources/fixed_price_promotions';
43
+ export type { FreeGiftPromotion, FreeGiftPromotionCreate, FreeGiftPromotionUpdate } from './resources/free_gift_promotions';
44
+ export type { FreeShippingPromotion, FreeShippingPromotionCreate, FreeShippingPromotionUpdate } from './resources/free_shipping_promotions';
45
+ export type { Geocoder } from './resources/geocoders';
46
+ export type { GiftCardRecipient, GiftCardRecipientCreate, GiftCardRecipientUpdate } from './resources/gift_card_recipients';
47
+ export type { GiftCard, GiftCardCreate, GiftCardUpdate } from './resources/gift_cards';
48
+ export type { GoogleGeocoder, GoogleGeocoderCreate, GoogleGeocoderUpdate } from './resources/google_geocoders';
49
+ export type { Import, ImportCreate } from './resources/imports';
50
+ export type { InStockSubscription, InStockSubscriptionCreate, InStockSubscriptionUpdate } from './resources/in_stock_subscriptions';
51
+ export type { InventoryModel, InventoryModelCreate, InventoryModelUpdate } from './resources/inventory_models';
52
+ export type { InventoryReturnLocation, InventoryReturnLocationCreate, InventoryReturnLocationUpdate } from './resources/inventory_return_locations';
53
+ export type { InventoryStockLocation, InventoryStockLocationCreate, InventoryStockLocationUpdate } from './resources/inventory_stock_locations';
54
+ export type { KlarnaGateway, KlarnaGatewayCreate, KlarnaGatewayUpdate } from './resources/klarna_gateways';
55
+ export type { KlarnaPayment, KlarnaPaymentCreate, KlarnaPaymentUpdate } from './resources/klarna_payments';
56
+ export type { LineItemOption, LineItemOptionCreate, LineItemOptionUpdate } from './resources/line_item_options';
57
+ export type { LineItem, LineItemCreate, LineItemUpdate } from './resources/line_items';
58
+ export type { ManualGateway, ManualGatewayCreate, ManualGatewayUpdate } from './resources/manual_gateways';
59
+ export type { ManualTaxCalculator, ManualTaxCalculatorCreate, ManualTaxCalculatorUpdate } from './resources/manual_tax_calculators';
60
+ export type { Market, MarketCreate, MarketUpdate } from './resources/markets';
61
+ export type { Merchant, MerchantCreate, MerchantUpdate } from './resources/merchants';
62
+ export type { OrderAmountPromotionRule, OrderAmountPromotionRuleCreate, OrderAmountPromotionRuleUpdate } from './resources/order_amount_promotion_rules';
63
+ export type { OrderCopy, OrderCopyCreate } from './resources/order_copies';
64
+ export type { OrderSubscription, OrderSubscriptionCreate, OrderSubscriptionUpdate } from './resources/order_subscriptions';
65
+ export type { OrderValidationRule } from './resources/order_validation_rules';
66
+ export type { Order, OrderCreate, OrderUpdate } from './resources/orders';
67
+ export type { Organization } from './resources/organization';
68
+ export type { Package, PackageCreate, PackageUpdate } from './resources/packages';
69
+ export type { ParcelLineItem, ParcelLineItemCreate, ParcelLineItemUpdate } from './resources/parcel_line_items';
70
+ export type { Parcel, ParcelCreate, ParcelUpdate } from './resources/parcels';
71
+ export type { PaymentGateway } from './resources/payment_gateways';
72
+ export type { PaymentMethod, PaymentMethodCreate, PaymentMethodUpdate } from './resources/payment_methods';
73
+ export type { PaypalGateway, PaypalGatewayCreate, PaypalGatewayUpdate } from './resources/paypal_gateways';
74
+ export type { PaypalPayment, PaypalPaymentCreate, PaypalPaymentUpdate } from './resources/paypal_payments';
75
+ export type { PercentageDiscountPromotion, PercentageDiscountPromotionCreate, PercentageDiscountPromotionUpdate } from './resources/percentage_discount_promotions';
76
+ export type { PriceList, PriceListCreate, PriceListUpdate } from './resources/price_lists';
77
+ export type { PriceTier } from './resources/price_tiers';
78
+ export type { PriceVolumeTier, PriceVolumeTierCreate, PriceVolumeTierUpdate } from './resources/price_volume_tiers';
79
+ export type { Price, PriceCreate, PriceUpdate } from './resources/prices';
80
+ export type { PromotionRule } from './resources/promotion_rules';
81
+ export type { Promotion } from './resources/promotions';
82
+ export type { Refund } from './resources/refunds';
83
+ export type { ReturnLineItem, ReturnLineItemCreate, ReturnLineItemUpdate } from './resources/return_line_items';
84
+ export type { Return, ReturnCreate, ReturnUpdate } from './resources/returns';
85
+ export type { SatispayGateway, SatispayGatewayCreate, SatispayGatewayUpdate } from './resources/satispay_gateways';
86
+ export type { SatispayPayment, SatispayPaymentCreate, SatispayPaymentUpdate } from './resources/satispay_payments';
87
+ export type { Shipment, ShipmentUpdate } from './resources/shipments';
88
+ export type { ShippingCategory, ShippingCategoryCreate, ShippingCategoryUpdate } from './resources/shipping_categories';
89
+ export type { ShippingMethodTier } from './resources/shipping_method_tiers';
90
+ export type { ShippingMethod, ShippingMethodCreate, ShippingMethodUpdate } from './resources/shipping_methods';
91
+ export type { ShippingWeightTier, ShippingWeightTierCreate, ShippingWeightTierUpdate } from './resources/shipping_weight_tiers';
92
+ export type { ShippingZone, ShippingZoneCreate, ShippingZoneUpdate } from './resources/shipping_zones';
93
+ export type { SkuListItem, SkuListItemCreate, SkuListItemUpdate } from './resources/sku_list_items';
94
+ export type { SkuListPromotionRule, SkuListPromotionRuleCreate, SkuListPromotionRuleUpdate } from './resources/sku_list_promotion_rules';
95
+ export type { SkuList, SkuListCreate, SkuListUpdate } from './resources/sku_lists';
96
+ export type { SkuOption, SkuOptionCreate, SkuOptionUpdate } from './resources/sku_options';
97
+ export type { Sku, SkuCreate, SkuUpdate } from './resources/skus';
98
+ export type { StockItem, StockItemCreate, StockItemUpdate } from './resources/stock_items';
99
+ export type { StockLineItem } from './resources/stock_line_items';
100
+ export type { StockLocation, StockLocationCreate, StockLocationUpdate } from './resources/stock_locations';
101
+ export type { StockTransfer, StockTransferCreate, StockTransferUpdate } from './resources/stock_transfers';
102
+ export type { StripeGateway, StripeGatewayCreate, StripeGatewayUpdate } from './resources/stripe_gateways';
103
+ export type { StripePayment, StripePaymentCreate, StripePaymentUpdate } from './resources/stripe_payments';
104
+ export type { TaxCalculator } from './resources/tax_calculators';
105
+ export type { TaxCategory, TaxCategoryCreate, TaxCategoryUpdate } from './resources/tax_categories';
106
+ export type { TaxRule, TaxRuleCreate, TaxRuleUpdate } from './resources/tax_rules';
107
+ export type { TaxjarAccount, TaxjarAccountCreate, TaxjarAccountUpdate } from './resources/taxjar_accounts';
108
+ export type { Transaction } from './resources/transactions';
109
+ export type { Void } from './resources/voids';
110
+ export type { Webhook, WebhookCreate, WebhookUpdate } from './resources/webhooks';
111
+ export type { WireTransfer, WireTransferCreate, WireTransferUpdate } from './resources/wire_transfers';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // ##__MODEL_TYPES_STOP__##
@@ -0,0 +1,24 @@
1
+ import { ResourceType } from "./resource";
2
+ type QueryFilter = {
3
+ [key: string]: string | number | boolean;
4
+ };
5
+ interface QueryParamsRetrieve {
6
+ include?: string[];
7
+ fields?: string[] | {
8
+ [key: string]: string[];
9
+ };
10
+ }
11
+ interface QueryParamsList extends QueryParamsRetrieve {
12
+ sort?: string[] | {
13
+ [key: string]: 'asc' | 'desc';
14
+ };
15
+ filters?: QueryFilter;
16
+ pageNumber?: number;
17
+ pageSize?: number;
18
+ }
19
+ type QueryParams = QueryParamsRetrieve | QueryParamsList;
20
+ export { QueryParamsRetrieve, QueryParamsList, QueryParams, QueryFilter };
21
+ declare const generateQueryStringParams: (params: QueryParamsRetrieve | QueryParamsList | undefined, res: string | ResourceType) => {
22
+ [key: string]: string;
23
+ };
24
+ export { generateQueryStringParams };
@@ -0,0 +1,51 @@
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;
@@ -0,0 +1,90 @@
1
+ import { ApiClientInitConfig } from './client';
2
+ import { QueryParamsRetrieve, QueryParamsList, QueryFilter } 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
+ hasNextPage(): boolean;
50
+ hasPrevPage(): boolean;
51
+ getRecordCount(): number;
52
+ getPageCount(): number;
53
+ get recordCount(): number;
54
+ get pageCount(): number;
55
+ }
56
+ export type { Metadata, ResourceType, ResourceId, Resource, ResourceCreate, ResourceUpdate, ListResponse, ResourceRel };
57
+ type ResourceAdapterConfig = {};
58
+ type ResourcesInitConfig = ResourceAdapterConfig & ApiClientInitConfig;
59
+ type ResourcesConfig = Partial<ResourcesInitConfig>;
60
+ declare class ResourceAdapter {
61
+ #private;
62
+ constructor(config: ResourcesInitConfig);
63
+ get interceptors(): InterceptorManager;
64
+ private localConfig;
65
+ config(config: ResourcesConfig): void;
66
+ singleton<R extends Resource>(resource: ResourceType, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
67
+ retrieve<R extends Resource>(resource: ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
68
+ list<R extends Resource>(resource: ResourceType, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<R>>;
69
+ create<C extends ResourceCreate, R extends Resource>(resource: C & ResourceType, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
70
+ update<U extends ResourceUpdate, R extends Resource>(resource: U & ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
71
+ delete(resource: ResourceId, options?: ResourcesConfig): Promise<void>;
72
+ fetch<R extends Resource>(resource: string | ResourceType, path: string, params?: QueryParams, options?: ResourcesConfig): Promise<R | ListResponse<R>>;
73
+ }
74
+ declare abstract class ApiResourceBase<R extends Resource> {
75
+ static readonly TYPE: ResourceTypeLock;
76
+ protected resources: ResourceAdapter;
77
+ constructor(adapter: ResourceAdapter);
78
+ abstract relationship(id: string | ResourceId | null): ResourceRel;
79
+ abstract type(): ResourceTypeLock;
80
+ update(resource: ResourceUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
81
+ count(filter?: QueryFilter, options?: ResourcesConfig): Promise<number>;
82
+ }
83
+ declare abstract class ApiResource<R extends Resource> extends ApiResourceBase<R> {
84
+ retrieve(id: string | ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
85
+ }
86
+ declare abstract class ApiSingleton<R extends Resource> extends ApiResourceBase<R> {
87
+ retrieve(params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
88
+ }
89
+ export default ResourceAdapter;
90
+ export { ApiResource, ApiSingleton, ResourcesConfig, ResourcesInitConfig };
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ var _ResourceAdapter_client, _ResourceAdapter_config;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ApiSingleton = exports.ApiResource = void 0;
19
+ const client_1 = __importDefault(require("./client"));
20
+ const jsonapi_1 = require("./jsonapi");
21
+ const query_1 = require("./query");
22
+ const config_1 = __importDefault(require("./config"));
23
+ const debug_1 = __importDefault(require("./debug"));
24
+ const debug = (0, debug_1.default)('resource');
25
+ class ListResponse extends Array {
26
+ constructor(meta, data) {
27
+ super(...(data || []));
28
+ this.meta = meta;
29
+ }
30
+ first() { return this.length ? this[0] : undefined; }
31
+ last() { return this.length ? this[this.length - 1] : undefined; }
32
+ get(index) { return (this.length && (index >= 0)) ? this[index] : undefined; }
33
+ hasNextPage() { return (this.meta.currentPage < this.meta.pageCount); }
34
+ hasPrevPage() { return (this.meta.currentPage > 1); }
35
+ getRecordCount() { return this.meta.recordCount; }
36
+ getPageCount() { return this.meta.pageCount; }
37
+ get recordCount() { return this.meta.recordCount; }
38
+ get pageCount() { return this.meta.pageCount; }
39
+ }
40
+ class ResourceAdapter {
41
+ constructor(config) {
42
+ _ResourceAdapter_client.set(this, void 0);
43
+ _ResourceAdapter_config.set(this, {});
44
+ __classPrivateFieldSet(this, _ResourceAdapter_client, client_1.default.create(config), "f");
45
+ this.localConfig(config);
46
+ }
47
+ get interceptors() { return __classPrivateFieldGet(this, _ResourceAdapter_client, "f").interceptors; }
48
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
49
+ localConfig(config) {
50
+ // if (typeof config.xyz !== 'undefined') this.#config.xyz = config.xyz
51
+ }
52
+ config(config) {
53
+ debug('config %o', config);
54
+ // ResourceAdapter config
55
+ this.localConfig(config);
56
+ // Client config
57
+ __classPrivateFieldGet(this, _ResourceAdapter_client, "f").config(config);
58
+ }
59
+ async singleton(resource, params, options) {
60
+ debug('singleton: %o, %O, %O', resource, params || {}, options || {});
61
+ const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
62
+ if (options === null || options === void 0 ? void 0 : options.params)
63
+ Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
64
+ const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}`, undefined, Object.assign(Object.assign({}, options), { params: queryParams }));
65
+ const r = (0, jsonapi_1.denormalize)(res);
66
+ return r;
67
+ }
68
+ async retrieve(resource, params, options) {
69
+ debug('retrieve: %o, %O, %O', resource, params || {}, options || {});
70
+ const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
71
+ if (options === null || options === void 0 ? void 0 : options.params)
72
+ Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
73
+ const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}/${resource.id}`, undefined, Object.assign(Object.assign({}, options), { params: queryParams }));
74
+ const r = (0, jsonapi_1.denormalize)(res);
75
+ return r;
76
+ }
77
+ async list(resource, params, options) {
78
+ var _a, _b;
79
+ debug('list: %o, %O, %O', resource, params || {}, options || {});
80
+ const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
81
+ if (options === null || options === void 0 ? void 0 : options.params)
82
+ Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
83
+ const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}`, undefined, Object.assign(Object.assign({}, options), { params: queryParams }));
84
+ const r = (0, jsonapi_1.denormalize)(res);
85
+ const meta = {
86
+ pageCount: Number((_a = res.meta) === null || _a === void 0 ? void 0 : _a.page_count),
87
+ recordCount: Number((_b = res.meta) === null || _b === void 0 ? void 0 : _b.record_count),
88
+ currentPage: (params === null || params === void 0 ? void 0 : params.pageNumber) || config_1.default.default.pageNumber,
89
+ recordsPerPage: (params === null || params === void 0 ? void 0 : params.pageSize) || config_1.default.default.pageSize
90
+ };
91
+ return new ListResponse(meta, r);
92
+ }
93
+ async create(resource, params, options) {
94
+ debug('create: %o, %O, %O', resource, params || {}, options || {});
95
+ const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
96
+ if (options === null || options === void 0 ? void 0 : options.params)
97
+ Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
98
+ const data = (0, jsonapi_1.normalize)(resource);
99
+ const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('post', resource.type, data, Object.assign(Object.assign({}, options), { params: queryParams }));
100
+ const r = (0, jsonapi_1.denormalize)(res);
101
+ return r;
102
+ }
103
+ async update(resource, params, options) {
104
+ debug('update: %o, %O, %O', resource, params || {}, options || {});
105
+ const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
106
+ if (options === null || options === void 0 ? void 0 : options.params)
107
+ Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
108
+ const data = (0, jsonapi_1.normalize)(resource);
109
+ const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('patch', `${resource.type}/${resource.id}`, data, Object.assign(Object.assign({}, options), { params: queryParams }));
110
+ const r = (0, jsonapi_1.denormalize)(res);
111
+ return r;
112
+ }
113
+ async delete(resource, options) {
114
+ debug('delete: %o, %O', resource, options || {});
115
+ await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('delete', `${resource.type}/${resource.id}`, undefined, options);
116
+ }
117
+ async fetch(resource, path, params, options) {
118
+ var _a, _b;
119
+ debug('fetch: %o, %O, %O', path, params || {}, options || {});
120
+ const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
121
+ if (options === null || options === void 0 ? void 0 : options.params)
122
+ Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
123
+ const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', path, undefined, Object.assign(Object.assign({}, options), { params: queryParams }));
124
+ const r = (0, jsonapi_1.denormalize)(res);
125
+ if (Array.isArray(r)) {
126
+ const p = params;
127
+ const meta = {
128
+ pageCount: Number((_a = res.meta) === null || _a === void 0 ? void 0 : _a.page_count),
129
+ recordCount: Number((_b = res.meta) === null || _b === void 0 ? void 0 : _b.record_count),
130
+ currentPage: (p === null || p === void 0 ? void 0 : p.pageNumber) || config_1.default.default.pageNumber,
131
+ recordsPerPage: (p === null || p === void 0 ? void 0 : p.pageSize) || config_1.default.default.pageSize
132
+ };
133
+ return new ListResponse(meta, r);
134
+ }
135
+ else
136
+ return r;
137
+ }
138
+ }
139
+ _ResourceAdapter_client = new WeakMap(), _ResourceAdapter_config = new WeakMap();
140
+ class ApiResourceBase {
141
+ constructor(adapter) {
142
+ debug('new resource instance: %s', this.type());
143
+ this.resources = adapter;
144
+ }
145
+ // reference, reference_origin and metadata attributes are always updatable
146
+ async update(resource, params, options) {
147
+ return this.resources.update(Object.assign(Object.assign({}, resource), { type: this.type() }), params, options);
148
+ }
149
+ async count(filter, options) {
150
+ const params = { filters: filter, pageNumber: 1, pageSize: 1 };
151
+ const response = await this.resources.list({ type: this.type() }, params, options);
152
+ return Promise.resolve(response.meta.recordCount);
153
+ }
154
+ }
155
+ class ApiResource extends ApiResourceBase {
156
+ async retrieve(id, params, options) {
157
+ return this.resources.retrieve((typeof id === 'string') ? { type: this.type(), id } : id, params, options);
158
+ }
159
+ }
160
+ exports.ApiResource = ApiResource;
161
+ class ApiSingleton extends ApiResourceBase {
162
+ async retrieve(params, options) {
163
+ return this.resources.singleton({ type: this.type() }, params, options);
164
+ }
165
+ }
166
+ exports.ApiSingleton = ApiSingleton;
167
+ exports.default = ResourceAdapter;
@@ -0,0 +1,89 @@
1
+ import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
2
+ import type { QueryParamsRetrieve, QueryParamsList } from '../query';
3
+ import type { Geocoder, GeocoderType } from './geocoders';
4
+ type AddressType = 'addresses';
5
+ type AddressRel = ResourceRel & {
6
+ type: AddressType;
7
+ };
8
+ type GeocoderRel = ResourceRel & {
9
+ type: GeocoderType;
10
+ };
11
+ interface Address extends Resource {
12
+ readonly type: AddressType;
13
+ business?: boolean;
14
+ first_name?: string;
15
+ last_name?: string;
16
+ company?: string;
17
+ full_name?: string;
18
+ line_1: string;
19
+ line_2?: string;
20
+ city: string;
21
+ zip_code?: string;
22
+ state_code: string;
23
+ country_code: string;
24
+ phone: string;
25
+ full_address?: string;
26
+ name?: string;
27
+ email?: string;
28
+ notes?: string;
29
+ lat?: number;
30
+ lng?: number;
31
+ is_localized?: boolean;
32
+ is_geocoded?: boolean;
33
+ provider_name?: string;
34
+ map_url?: string;
35
+ static_map_url?: string;
36
+ billing_info?: string;
37
+ geocoder?: Geocoder;
38
+ }
39
+ interface AddressCreate extends ResourceCreate {
40
+ business?: boolean;
41
+ first_name?: string;
42
+ last_name?: string;
43
+ company?: string;
44
+ line_1: string;
45
+ line_2?: string;
46
+ city: string;
47
+ zip_code?: string;
48
+ state_code: string;
49
+ country_code: string;
50
+ phone: string;
51
+ email?: string;
52
+ notes?: string;
53
+ lat?: number;
54
+ lng?: number;
55
+ billing_info?: string;
56
+ geocoder?: GeocoderRel;
57
+ }
58
+ interface AddressUpdate extends ResourceUpdate {
59
+ business?: boolean;
60
+ first_name?: string;
61
+ last_name?: string;
62
+ company?: string;
63
+ line_1: string;
64
+ line_2?: string;
65
+ city: string;
66
+ zip_code?: string;
67
+ state_code: string;
68
+ country_code: string;
69
+ phone: string;
70
+ email?: string;
71
+ notes?: string;
72
+ lat?: number;
73
+ lng?: number;
74
+ billing_info?: string;
75
+ geocoder?: GeocoderRel;
76
+ }
77
+ declare class Addresses extends ApiResource<Address> {
78
+ static readonly TYPE: AddressType;
79
+ list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Address>>;
80
+ create(resource: AddressCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Address>;
81
+ update(resource: AddressUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Address>;
82
+ delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
83
+ geocoder(addressId: string | Address, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Geocoder>;
84
+ isAddress(resource: any): resource is Address;
85
+ relationship(id: string | ResourceId | null): AddressRel;
86
+ type(): AddressType;
87
+ }
88
+ export default Addresses;
89
+ export type { Address, AddressCreate, AddressUpdate, AddressType };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const resource_1 = require("../resource");
4
+ class Addresses extends resource_1.ApiResource {
5
+ // static readonly PATH = 'addresses'
6
+ async list(params, options) {
7
+ return this.resources.list({ type: Addresses.TYPE }, params, options);
8
+ }
9
+ async create(resource, params, options) {
10
+ return this.resources.create(Object.assign(Object.assign({}, resource), { type: Addresses.TYPE }), params, options);
11
+ }
12
+ async update(resource, params, options) {
13
+ return this.resources.update(Object.assign(Object.assign({}, resource), { type: Addresses.TYPE }), params, options);
14
+ }
15
+ async delete(id, options) {
16
+ await this.resources.delete((typeof id === 'string') ? { id, type: Addresses.TYPE } : id, options);
17
+ }
18
+ async geocoder(addressId, params, options) {
19
+ const _addressId = addressId.id || addressId;
20
+ return this.resources.fetch({ type: 'geocoders' }, `addresses/${_addressId}/geocoder`, params, options);
21
+ }
22
+ isAddress(resource) {
23
+ return resource.type && (resource.type === Addresses.TYPE);
24
+ }
25
+ relationship(id) {
26
+ return ((id === null) || (typeof id === 'string')) ? { id, type: Addresses.TYPE } : { id: id.id, type: Addresses.TYPE };
27
+ }
28
+ type() {
29
+ return Addresses.TYPE;
30
+ }
31
+ }
32
+ Addresses.TYPE = 'addresses';
33
+ exports.default = Addresses;