@commercelayer/sdk 5.37.0 → 5.38.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 (547) hide show
  1. package/lib/cjs/api.d.ts +1 -164
  2. package/lib/cjs/api.js +1 -387
  3. package/lib/cjs/client.d.ts +1 -39
  4. package/lib/cjs/client.js +1 -154
  5. package/lib/cjs/commercelayer.d.ts +1 -153
  6. package/lib/cjs/commercelayer.js +1 -253
  7. package/lib/cjs/common.d.ts +1 -5
  8. package/lib/cjs/common.js +1 -23
  9. package/lib/cjs/config.d.ts +1 -15
  10. package/lib/cjs/config.js +1 -19
  11. package/lib/cjs/debug.d.ts +1 -3
  12. package/lib/cjs/debug.js +1 -38
  13. package/lib/cjs/error.d.ts +1 -31
  14. package/lib/cjs/error.js +1 -77
  15. package/lib/cjs/index.d.ts +1 -7
  16. package/lib/cjs/index.js +1 -13
  17. package/lib/cjs/interceptor.d.ts +1 -25
  18. package/lib/cjs/interceptor.js +1 -2
  19. package/lib/cjs/jsonapi.d.ts +1 -6
  20. package/lib/cjs/jsonapi.js +1 -94
  21. package/lib/cjs/model.d.ts +1 -124
  22. package/lib/cjs/model.js +1 -3
  23. package/lib/cjs/query.d.ts +1 -17
  24. package/lib/cjs/query.js +1 -69
  25. package/lib/cjs/resource.d.ts +1 -89
  26. package/lib/cjs/resource.js +1 -198
  27. package/lib/cjs/resources/addresses.d.ts +1 -103
  28. package/lib/cjs/resources/addresses.js +1 -41
  29. package/lib/cjs/resources/adjustments.d.ts +1 -42
  30. package/lib/cjs/resources/adjustments.js +1 -29
  31. package/lib/cjs/resources/adyen_gateways.d.ts +1 -60
  32. package/lib/cjs/resources/adyen_gateways.js +1 -37
  33. package/lib/cjs/resources/adyen_payments.d.ts +1 -51
  34. package/lib/cjs/resources/adyen_payments.js +1 -40
  35. package/lib/cjs/resources/application.d.ts +1 -22
  36. package/lib/cjs/resources/application.js +1 -16
  37. package/lib/cjs/resources/attachments.d.ts +1 -157
  38. package/lib/cjs/resources/attachments.js +1 -25
  39. package/lib/cjs/resources/authorizations.d.ts +1 -70
  40. package/lib/cjs/resources/authorizations.js +1 -52
  41. package/lib/cjs/resources/avalara_accounts.d.ts +1 -59
  42. package/lib/cjs/resources/avalara_accounts.js +1 -41
  43. package/lib/cjs/resources/axerve_gateways.d.ts +1 -48
  44. package/lib/cjs/resources/axerve_gateways.js +1 -37
  45. package/lib/cjs/resources/axerve_payments.d.ts +1 -54
  46. package/lib/cjs/resources/axerve_payments.js +1 -40
  47. package/lib/cjs/resources/billing_info_validation_rules.d.ts +1 -39
  48. package/lib/cjs/resources/billing_info_validation_rules.js +1 -37
  49. package/lib/cjs/resources/bing_geocoders.d.ts +1 -36
  50. package/lib/cjs/resources/bing_geocoders.js +1 -33
  51. package/lib/cjs/resources/braintree_gateways.d.ts +1 -60
  52. package/lib/cjs/resources/braintree_gateways.js +1 -37
  53. package/lib/cjs/resources/braintree_payments.d.ts +1 -52
  54. package/lib/cjs/resources/braintree_payments.js +1 -37
  55. package/lib/cjs/resources/bundles.d.ts +1 -93
  56. package/lib/cjs/resources/bundles.js +1 -59
  57. package/lib/cjs/resources/buy_x_pay_y_promotions.d.ts +1 -137
  58. package/lib/cjs/resources/buy_x_pay_y_promotions.js +1 -79
  59. package/lib/cjs/resources/captures.d.ts +1 -60
  60. package/lib/cjs/resources/captures.js +1 -49
  61. package/lib/cjs/resources/carrier_accounts.d.ts +1 -30
  62. package/lib/cjs/resources/carrier_accounts.js +1 -28
  63. package/lib/cjs/resources/checkout_com_gateways.d.ts +1 -49
  64. package/lib/cjs/resources/checkout_com_gateways.js +1 -37
  65. package/lib/cjs/resources/checkout_com_payments.d.ts +1 -65
  66. package/lib/cjs/resources/checkout_com_payments.js +1 -43
  67. package/lib/cjs/resources/cleanups.d.ts +1 -40
  68. package/lib/cjs/resources/cleanups.js +1 -30
  69. package/lib/cjs/resources/coupon_codes_promotion_rules.d.ts +1 -67
  70. package/lib/cjs/resources/coupon_codes_promotion_rules.js +1 -33
  71. package/lib/cjs/resources/coupon_recipients.d.ts +1 -48
  72. package/lib/cjs/resources/coupon_recipients.js +1 -37
  73. package/lib/cjs/resources/coupons.d.ts +1 -71
  74. package/lib/cjs/resources/coupons.js +1 -45
  75. package/lib/cjs/resources/custom_promotion_rules.d.ts +1 -62
  76. package/lib/cjs/resources/custom_promotion_rules.js +1 -29
  77. package/lib/cjs/resources/customer_addresses.d.ts +1 -50
  78. package/lib/cjs/resources/customer_addresses.js +1 -41
  79. package/lib/cjs/resources/customer_groups.d.ts +1 -40
  80. package/lib/cjs/resources/customer_groups.js +1 -41
  81. package/lib/cjs/resources/customer_password_resets.d.ts +1 -38
  82. package/lib/cjs/resources/customer_password_resets.js +1 -36
  83. package/lib/cjs/resources/customer_payment_sources.d.ts +1 -86
  84. package/lib/cjs/resources/customer_payment_sources.js +1 -37
  85. package/lib/cjs/resources/customer_subscriptions.d.ts +1 -35
  86. package/lib/cjs/resources/customer_subscriptions.js +1 -37
  87. package/lib/cjs/resources/customers.d.ts +1 -76
  88. package/lib/cjs/resources/customers.js +1 -69
  89. package/lib/cjs/resources/delivery_lead_times.d.ts +1 -55
  90. package/lib/cjs/resources/delivery_lead_times.js +1 -41
  91. package/lib/cjs/resources/event_callbacks.d.ts +1 -25
  92. package/lib/cjs/resources/event_callbacks.js +1 -20
  93. package/lib/cjs/resources/events.d.ts +1 -25
  94. package/lib/cjs/resources/events.js +1 -24
  95. package/lib/cjs/resources/exports.d.ts +1 -41
  96. package/lib/cjs/resources/exports.js +1 -26
  97. package/lib/cjs/resources/external_gateways.d.ts +1 -57
  98. package/lib/cjs/resources/external_gateways.js +1 -40
  99. package/lib/cjs/resources/external_payments.d.ts +1 -48
  100. package/lib/cjs/resources/external_payments.js +1 -41
  101. package/lib/cjs/resources/external_promotions.d.ts +1 -136
  102. package/lib/cjs/resources/external_promotions.js +1 -82
  103. package/lib/cjs/resources/external_tax_calculators.d.ts +1 -45
  104. package/lib/cjs/resources/external_tax_calculators.js +1 -40
  105. package/lib/cjs/resources/fixed_amount_promotions.d.ts +1 -133
  106. package/lib/cjs/resources/fixed_amount_promotions.js +1 -79
  107. package/lib/cjs/resources/fixed_price_promotions.d.ts +1 -133
  108. package/lib/cjs/resources/fixed_price_promotions.js +1 -79
  109. package/lib/cjs/resources/free_gift_promotions.d.ts +1 -131
  110. package/lib/cjs/resources/free_gift_promotions.js +1 -79
  111. package/lib/cjs/resources/free_shipping_promotions.d.ts +1 -125
  112. package/lib/cjs/resources/free_shipping_promotions.js +1 -75
  113. package/lib/cjs/resources/geocoders.d.ts +1 -25
  114. package/lib/cjs/resources/geocoders.js +1 -24
  115. package/lib/cjs/resources/gift_card_recipients.d.ts +1 -48
  116. package/lib/cjs/resources/gift_card_recipients.js +1 -37
  117. package/lib/cjs/resources/gift_cards.d.ts +1 -104
  118. package/lib/cjs/resources/gift_cards.js +1 -61
  119. package/lib/cjs/resources/google_geocoders.d.ts +1 -36
  120. package/lib/cjs/resources/google_geocoders.js +1 -33
  121. package/lib/cjs/resources/imports.d.ts +1 -44
  122. package/lib/cjs/resources/imports.js +1 -26
  123. package/lib/cjs/resources/in_stock_subscriptions.d.ts +1 -68
  124. package/lib/cjs/resources/in_stock_subscriptions.js +1 -51
  125. package/lib/cjs/resources/inventory_models.d.ts +1 -55
  126. package/lib/cjs/resources/inventory_models.js +1 -41
  127. package/lib/cjs/resources/inventory_return_locations.d.ts +1 -47
  128. package/lib/cjs/resources/inventory_return_locations.js +1 -37
  129. package/lib/cjs/resources/inventory_stock_locations.d.ts +1 -50
  130. package/lib/cjs/resources/inventory_stock_locations.js +1 -37
  131. package/lib/cjs/resources/klarna_gateways.d.ts +1 -48
  132. package/lib/cjs/resources/klarna_gateways.js +1 -37
  133. package/lib/cjs/resources/klarna_payments.d.ts +1 -48
  134. package/lib/cjs/resources/klarna_payments.js +1 -40
  135. package/lib/cjs/resources/line_item_options.d.ts +1 -69
  136. package/lib/cjs/resources/line_item_options.js +1 -41
  137. package/lib/cjs/resources/line_items.d.ts +1 -170
  138. package/lib/cjs/resources/line_items.js +1 -66
  139. package/lib/cjs/resources/manual_gateways.d.ts +1 -34
  140. package/lib/cjs/resources/manual_gateways.js +1 -33
  141. package/lib/cjs/resources/manual_tax_calculators.d.ts +1 -45
  142. package/lib/cjs/resources/manual_tax_calculators.js +1 -41
  143. package/lib/cjs/resources/markets.d.ts +1 -107
  144. package/lib/cjs/resources/markets.js +1 -63
  145. package/lib/cjs/resources/merchants.d.ts +1 -42
  146. package/lib/cjs/resources/merchants.js +1 -37
  147. package/lib/cjs/resources/order_amount_promotion_rules.d.ts +1 -67
  148. package/lib/cjs/resources/order_amount_promotion_rules.js +1 -29
  149. package/lib/cjs/resources/order_copies.d.ts +1 -51
  150. package/lib/cjs/resources/order_copies.js +1 -41
  151. package/lib/cjs/resources/order_factories.d.ts +1 -34
  152. package/lib/cjs/resources/order_factories.js +1 -28
  153. package/lib/cjs/resources/order_subscription_items.d.ts +1 -72
  154. package/lib/cjs/resources/order_subscription_items.js +1 -33
  155. package/lib/cjs/resources/order_subscriptions.d.ts +1 -98
  156. package/lib/cjs/resources/order_subscriptions.js +1 -78
  157. package/lib/cjs/resources/order_validation_rules.d.ts +1 -27
  158. package/lib/cjs/resources/order_validation_rules.js +1 -28
  159. package/lib/cjs/resources/orders.d.ts +1 -389
  160. package/lib/cjs/resources/orders.js +1 -236
  161. package/lib/cjs/resources/organization.d.ts +1 -34
  162. package/lib/cjs/resources/organization.js +1 -16
  163. package/lib/cjs/resources/packages.d.ts +1 -60
  164. package/lib/cjs/resources/packages.js +1 -41
  165. package/lib/cjs/resources/parcel_line_items.d.ts +1 -47
  166. package/lib/cjs/resources/parcel_line_items.js +1 -37
  167. package/lib/cjs/resources/parcels.d.ts +1 -126
  168. package/lib/cjs/resources/parcels.js +1 -49
  169. package/lib/cjs/resources/payment_gateways.d.ts +1 -25
  170. package/lib/cjs/resources/payment_gateways.js +1 -24
  171. package/lib/cjs/resources/payment_methods.d.ts +1 -83
  172. package/lib/cjs/resources/payment_methods.js +1 -47
  173. package/lib/cjs/resources/payment_options.d.ts +1 -44
  174. package/lib/cjs/resources/payment_options.js +1 -33
  175. package/lib/cjs/resources/paypal_gateways.d.ts +1 -41
  176. package/lib/cjs/resources/paypal_gateways.js +1 -37
  177. package/lib/cjs/resources/paypal_payments.d.ts +1 -53
  178. package/lib/cjs/resources/paypal_payments.js +1 -37
  179. package/lib/cjs/resources/percentage_discount_promotions.d.ts +1 -131
  180. package/lib/cjs/resources/percentage_discount_promotions.js +1 -79
  181. package/lib/cjs/resources/price_frequency_tiers.d.ts +1 -53
  182. package/lib/cjs/resources/price_frequency_tiers.js +1 -41
  183. package/lib/cjs/resources/price_lists.d.ts +1 -46
  184. package/lib/cjs/resources/price_lists.js +1 -37
  185. package/lib/cjs/resources/price_tiers.d.ts +1 -32
  186. package/lib/cjs/resources/price_tiers.js +1 -28
  187. package/lib/cjs/resources/price_volume_tiers.d.ts +1 -53
  188. package/lib/cjs/resources/price_volume_tiers.js +1 -41
  189. package/lib/cjs/resources/prices.d.ts +1 -84
  190. package/lib/cjs/resources/prices.js +1 -65
  191. package/lib/cjs/resources/promotion_rules.d.ts +1 -29
  192. package/lib/cjs/resources/promotion_rules.js +1 -20
  193. package/lib/cjs/resources/promotions.d.ts +1 -63
  194. package/lib/cjs/resources/promotions.js +1 -60
  195. package/lib/cjs/resources/recurring_order_copies.d.ts +1 -53
  196. package/lib/cjs/resources/recurring_order_copies.js +1 -41
  197. package/lib/cjs/resources/refunds.d.ts +1 -44
  198. package/lib/cjs/resources/refunds.js +1 -36
  199. package/lib/cjs/resources/reserved_stocks.d.ts +1 -28
  200. package/lib/cjs/resources/reserved_stocks.js +1 -28
  201. package/lib/cjs/resources/resource_errors.d.ts +1 -22
  202. package/lib/cjs/resources/resource_errors.js +1 -16
  203. package/lib/cjs/resources/return_line_items.d.ts +1 -52
  204. package/lib/cjs/resources/return_line_items.js +1 -36
  205. package/lib/cjs/resources/returns.d.ts +1 -96
  206. package/lib/cjs/resources/returns.js +1 -92
  207. package/lib/cjs/resources/satispay_gateways.d.ts +1 -46
  208. package/lib/cjs/resources/satispay_gateways.js +1 -37
  209. package/lib/cjs/resources/satispay_payments.d.ts +1 -50
  210. package/lib/cjs/resources/satispay_payments.js +1 -40
  211. package/lib/cjs/resources/shipments.d.ts +1 -151
  212. package/lib/cjs/resources/shipments.js +1 -130
  213. package/lib/cjs/resources/shipping_categories.d.ts +1 -40
  214. package/lib/cjs/resources/shipping_categories.js +1 -37
  215. package/lib/cjs/resources/shipping_method_tiers.d.ts +1 -32
  216. package/lib/cjs/resources/shipping_method_tiers.js +1 -28
  217. package/lib/cjs/resources/shipping_methods.d.ts +1 -125
  218. package/lib/cjs/resources/shipping_methods.js +1 -70
  219. package/lib/cjs/resources/shipping_weight_tiers.d.ts +1 -50
  220. package/lib/cjs/resources/shipping_weight_tiers.js +1 -37
  221. package/lib/cjs/resources/shipping_zones.d.ts +1 -52
  222. package/lib/cjs/resources/shipping_zones.js +1 -33
  223. package/lib/cjs/resources/sku_list_items.d.ts +1 -51
  224. package/lib/cjs/resources/sku_list_items.js +1 -37
  225. package/lib/cjs/resources/sku_list_promotion_rules.d.ts +1 -76
  226. package/lib/cjs/resources/sku_list_promotion_rules.js +1 -37
  227. package/lib/cjs/resources/sku_lists.d.ts +1 -64
  228. package/lib/cjs/resources/sku_lists.js +1 -49
  229. package/lib/cjs/resources/sku_options.d.ts +1 -71
  230. package/lib/cjs/resources/sku_options.js +1 -45
  231. package/lib/cjs/resources/skus.d.ts +1 -96
  232. package/lib/cjs/resources/skus.js +1 -65
  233. package/lib/cjs/resources/stock_items.d.ts +1 -61
  234. package/lib/cjs/resources/stock_items.js +1 -52
  235. package/lib/cjs/resources/stock_line_items.d.ts +1 -73
  236. package/lib/cjs/resources/stock_line_items.js +1 -54
  237. package/lib/cjs/resources/stock_locations.d.ts +1 -64
  238. package/lib/cjs/resources/stock_locations.js +1 -53
  239. package/lib/cjs/resources/stock_reservations.d.ts +1 -51
  240. package/lib/cjs/resources/stock_reservations.js +1 -48
  241. package/lib/cjs/resources/stock_transfers.d.ts +1 -86
  242. package/lib/cjs/resources/stock_transfers.js +1 -71
  243. package/lib/cjs/resources/stripe_gateways.d.ts +1 -45
  244. package/lib/cjs/resources/stripe_gateways.js +1 -37
  245. package/lib/cjs/resources/stripe_payments.d.ts +1 -59
  246. package/lib/cjs/resources/stripe_payments.js +1 -43
  247. package/lib/cjs/resources/subscription_models.d.ts +1 -49
  248. package/lib/cjs/resources/subscription_models.js +1 -37
  249. package/lib/cjs/resources/tags.d.ts +1 -28
  250. package/lib/cjs/resources/tags.js +1 -25
  251. package/lib/cjs/resources/tax_calculators.d.ts +1 -28
  252. package/lib/cjs/resources/tax_calculators.js +1 -28
  253. package/lib/cjs/resources/tax_categories.d.ts +1 -63
  254. package/lib/cjs/resources/tax_categories.js +1 -37
  255. package/lib/cjs/resources/tax_rules.d.ts +1 -73
  256. package/lib/cjs/resources/tax_rules.js +1 -33
  257. package/lib/cjs/resources/taxjar_accounts.d.ts +1 -47
  258. package/lib/cjs/resources/taxjar_accounts.js +1 -41
  259. package/lib/cjs/resources/transactions.d.ts +1 -41
  260. package/lib/cjs/resources/transactions.js +1 -32
  261. package/lib/cjs/resources/versions.d.ts +1 -22
  262. package/lib/cjs/resources/versions.js +1 -16
  263. package/lib/cjs/resources/voids.d.ts +1 -44
  264. package/lib/cjs/resources/voids.js +1 -36
  265. package/lib/cjs/resources/webhooks.d.ts +1 -55
  266. package/lib/cjs/resources/webhooks.js +1 -42
  267. package/lib/cjs/resources/wire_transfers.d.ts +1 -37
  268. package/lib/cjs/resources/wire_transfers.js +1 -33
  269. package/lib/cjs/static.d.ts +1 -12
  270. package/lib/cjs/static.js +1 -51
  271. package/lib/cjs/util.d.ts +1 -4
  272. package/lib/cjs/util.js +1 -16
  273. package/lib/esm/api.d.ts +1 -164
  274. package/lib/esm/api.js +1 -258
  275. package/lib/esm/client.d.ts +1 -39
  276. package/lib/esm/client.js +1 -149
  277. package/lib/esm/commercelayer.d.ts +1 -153
  278. package/lib/esm/commercelayer.js +1 -224
  279. package/lib/esm/common.d.ts +1 -5
  280. package/lib/esm/common.js +1 -19
  281. package/lib/esm/config.d.ts +1 -15
  282. package/lib/esm/config.js +1 -17
  283. package/lib/esm/debug.d.ts +1 -3
  284. package/lib/esm/debug.js +1 -36
  285. package/lib/esm/error.d.ts +1 -31
  286. package/lib/esm/error.js +1 -69
  287. package/lib/esm/index.d.ts +1 -7
  288. package/lib/esm/index.js +1 -4
  289. package/lib/esm/interceptor.d.ts +1 -25
  290. package/lib/esm/interceptor.js +1 -1
  291. package/lib/esm/jsonapi.d.ts +1 -6
  292. package/lib/esm/jsonapi.js +1 -87
  293. package/lib/esm/model.d.ts +1 -124
  294. package/lib/esm/model.js +1 -2
  295. package/lib/esm/query.d.ts +1 -17
  296. package/lib/esm/query.js +1 -62
  297. package/lib/esm/resource.d.ts +1 -89
  298. package/lib/esm/resource.js +1 -191
  299. package/lib/esm/resources/addresses.d.ts +1 -103
  300. package/lib/esm/resources/addresses.js +1 -39
  301. package/lib/esm/resources/adjustments.d.ts +1 -42
  302. package/lib/esm/resources/adjustments.js +1 -27
  303. package/lib/esm/resources/adyen_gateways.d.ts +1 -60
  304. package/lib/esm/resources/adyen_gateways.js +1 -35
  305. package/lib/esm/resources/adyen_payments.d.ts +1 -51
  306. package/lib/esm/resources/adyen_payments.js +1 -38
  307. package/lib/esm/resources/application.d.ts +1 -22
  308. package/lib/esm/resources/application.js +1 -14
  309. package/lib/esm/resources/attachments.d.ts +1 -157
  310. package/lib/esm/resources/attachments.js +1 -23
  311. package/lib/esm/resources/authorizations.d.ts +1 -70
  312. package/lib/esm/resources/authorizations.js +1 -50
  313. package/lib/esm/resources/avalara_accounts.d.ts +1 -59
  314. package/lib/esm/resources/avalara_accounts.js +1 -39
  315. package/lib/esm/resources/axerve_gateways.d.ts +1 -48
  316. package/lib/esm/resources/axerve_gateways.js +1 -35
  317. package/lib/esm/resources/axerve_payments.d.ts +1 -54
  318. package/lib/esm/resources/axerve_payments.js +1 -38
  319. package/lib/esm/resources/billing_info_validation_rules.d.ts +1 -39
  320. package/lib/esm/resources/billing_info_validation_rules.js +1 -35
  321. package/lib/esm/resources/bing_geocoders.d.ts +1 -36
  322. package/lib/esm/resources/bing_geocoders.js +1 -31
  323. package/lib/esm/resources/braintree_gateways.d.ts +1 -60
  324. package/lib/esm/resources/braintree_gateways.js +1 -35
  325. package/lib/esm/resources/braintree_payments.d.ts +1 -52
  326. package/lib/esm/resources/braintree_payments.js +1 -35
  327. package/lib/esm/resources/bundles.d.ts +1 -93
  328. package/lib/esm/resources/bundles.js +1 -57
  329. package/lib/esm/resources/buy_x_pay_y_promotions.d.ts +1 -137
  330. package/lib/esm/resources/buy_x_pay_y_promotions.js +1 -77
  331. package/lib/esm/resources/captures.d.ts +1 -60
  332. package/lib/esm/resources/captures.js +1 -47
  333. package/lib/esm/resources/carrier_accounts.d.ts +1 -30
  334. package/lib/esm/resources/carrier_accounts.js +1 -26
  335. package/lib/esm/resources/checkout_com_gateways.d.ts +1 -49
  336. package/lib/esm/resources/checkout_com_gateways.js +1 -35
  337. package/lib/esm/resources/checkout_com_payments.d.ts +1 -65
  338. package/lib/esm/resources/checkout_com_payments.js +1 -41
  339. package/lib/esm/resources/cleanups.d.ts +1 -40
  340. package/lib/esm/resources/cleanups.js +1 -28
  341. package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +1 -67
  342. package/lib/esm/resources/coupon_codes_promotion_rules.js +1 -31
  343. package/lib/esm/resources/coupon_recipients.d.ts +1 -48
  344. package/lib/esm/resources/coupon_recipients.js +1 -35
  345. package/lib/esm/resources/coupons.d.ts +1 -71
  346. package/lib/esm/resources/coupons.js +1 -43
  347. package/lib/esm/resources/custom_promotion_rules.d.ts +1 -62
  348. package/lib/esm/resources/custom_promotion_rules.js +1 -27
  349. package/lib/esm/resources/customer_addresses.d.ts +1 -50
  350. package/lib/esm/resources/customer_addresses.js +1 -39
  351. package/lib/esm/resources/customer_groups.d.ts +1 -40
  352. package/lib/esm/resources/customer_groups.js +1 -39
  353. package/lib/esm/resources/customer_password_resets.d.ts +1 -38
  354. package/lib/esm/resources/customer_password_resets.js +1 -34
  355. package/lib/esm/resources/customer_payment_sources.d.ts +1 -86
  356. package/lib/esm/resources/customer_payment_sources.js +1 -35
  357. package/lib/esm/resources/customer_subscriptions.d.ts +1 -35
  358. package/lib/esm/resources/customer_subscriptions.js +1 -35
  359. package/lib/esm/resources/customers.d.ts +1 -76
  360. package/lib/esm/resources/customers.js +1 -67
  361. package/lib/esm/resources/delivery_lead_times.d.ts +1 -55
  362. package/lib/esm/resources/delivery_lead_times.js +1 -39
  363. package/lib/esm/resources/event_callbacks.d.ts +1 -25
  364. package/lib/esm/resources/event_callbacks.js +1 -18
  365. package/lib/esm/resources/events.d.ts +1 -25
  366. package/lib/esm/resources/events.js +1 -22
  367. package/lib/esm/resources/exports.d.ts +1 -41
  368. package/lib/esm/resources/exports.js +1 -24
  369. package/lib/esm/resources/external_gateways.d.ts +1 -57
  370. package/lib/esm/resources/external_gateways.js +1 -38
  371. package/lib/esm/resources/external_payments.d.ts +1 -48
  372. package/lib/esm/resources/external_payments.js +1 -39
  373. package/lib/esm/resources/external_promotions.d.ts +1 -136
  374. package/lib/esm/resources/external_promotions.js +1 -80
  375. package/lib/esm/resources/external_tax_calculators.d.ts +1 -45
  376. package/lib/esm/resources/external_tax_calculators.js +1 -38
  377. package/lib/esm/resources/fixed_amount_promotions.d.ts +1 -133
  378. package/lib/esm/resources/fixed_amount_promotions.js +1 -77
  379. package/lib/esm/resources/fixed_price_promotions.d.ts +1 -133
  380. package/lib/esm/resources/fixed_price_promotions.js +1 -77
  381. package/lib/esm/resources/free_gift_promotions.d.ts +1 -131
  382. package/lib/esm/resources/free_gift_promotions.js +1 -77
  383. package/lib/esm/resources/free_shipping_promotions.d.ts +1 -125
  384. package/lib/esm/resources/free_shipping_promotions.js +1 -73
  385. package/lib/esm/resources/geocoders.d.ts +1 -25
  386. package/lib/esm/resources/geocoders.js +1 -22
  387. package/lib/esm/resources/gift_card_recipients.d.ts +1 -48
  388. package/lib/esm/resources/gift_card_recipients.js +1 -35
  389. package/lib/esm/resources/gift_cards.d.ts +1 -104
  390. package/lib/esm/resources/gift_cards.js +1 -59
  391. package/lib/esm/resources/google_geocoders.d.ts +1 -36
  392. package/lib/esm/resources/google_geocoders.js +1 -31
  393. package/lib/esm/resources/imports.d.ts +1 -44
  394. package/lib/esm/resources/imports.js +1 -24
  395. package/lib/esm/resources/in_stock_subscriptions.d.ts +1 -68
  396. package/lib/esm/resources/in_stock_subscriptions.js +1 -49
  397. package/lib/esm/resources/inventory_models.d.ts +1 -55
  398. package/lib/esm/resources/inventory_models.js +1 -39
  399. package/lib/esm/resources/inventory_return_locations.d.ts +1 -47
  400. package/lib/esm/resources/inventory_return_locations.js +1 -35
  401. package/lib/esm/resources/inventory_stock_locations.d.ts +1 -50
  402. package/lib/esm/resources/inventory_stock_locations.js +1 -35
  403. package/lib/esm/resources/klarna_gateways.d.ts +1 -48
  404. package/lib/esm/resources/klarna_gateways.js +1 -35
  405. package/lib/esm/resources/klarna_payments.d.ts +1 -48
  406. package/lib/esm/resources/klarna_payments.js +1 -38
  407. package/lib/esm/resources/line_item_options.d.ts +1 -69
  408. package/lib/esm/resources/line_item_options.js +1 -39
  409. package/lib/esm/resources/line_items.d.ts +1 -170
  410. package/lib/esm/resources/line_items.js +1 -64
  411. package/lib/esm/resources/manual_gateways.d.ts +1 -34
  412. package/lib/esm/resources/manual_gateways.js +1 -31
  413. package/lib/esm/resources/manual_tax_calculators.d.ts +1 -45
  414. package/lib/esm/resources/manual_tax_calculators.js +1 -39
  415. package/lib/esm/resources/markets.d.ts +1 -107
  416. package/lib/esm/resources/markets.js +1 -61
  417. package/lib/esm/resources/merchants.d.ts +1 -42
  418. package/lib/esm/resources/merchants.js +1 -35
  419. package/lib/esm/resources/order_amount_promotion_rules.d.ts +1 -67
  420. package/lib/esm/resources/order_amount_promotion_rules.js +1 -27
  421. package/lib/esm/resources/order_copies.d.ts +1 -51
  422. package/lib/esm/resources/order_copies.js +1 -39
  423. package/lib/esm/resources/order_factories.d.ts +1 -34
  424. package/lib/esm/resources/order_factories.js +1 -26
  425. package/lib/esm/resources/order_subscription_items.d.ts +1 -72
  426. package/lib/esm/resources/order_subscription_items.js +1 -31
  427. package/lib/esm/resources/order_subscriptions.d.ts +1 -98
  428. package/lib/esm/resources/order_subscriptions.js +1 -76
  429. package/lib/esm/resources/order_validation_rules.d.ts +1 -27
  430. package/lib/esm/resources/order_validation_rules.js +1 -26
  431. package/lib/esm/resources/orders.d.ts +1 -389
  432. package/lib/esm/resources/orders.js +1 -234
  433. package/lib/esm/resources/organization.d.ts +1 -34
  434. package/lib/esm/resources/organization.js +1 -14
  435. package/lib/esm/resources/packages.d.ts +1 -60
  436. package/lib/esm/resources/packages.js +1 -39
  437. package/lib/esm/resources/parcel_line_items.d.ts +1 -47
  438. package/lib/esm/resources/parcel_line_items.js +1 -35
  439. package/lib/esm/resources/parcels.d.ts +1 -126
  440. package/lib/esm/resources/parcels.js +1 -47
  441. package/lib/esm/resources/payment_gateways.d.ts +1 -25
  442. package/lib/esm/resources/payment_gateways.js +1 -22
  443. package/lib/esm/resources/payment_methods.d.ts +1 -83
  444. package/lib/esm/resources/payment_methods.js +1 -45
  445. package/lib/esm/resources/payment_options.d.ts +1 -44
  446. package/lib/esm/resources/payment_options.js +1 -31
  447. package/lib/esm/resources/paypal_gateways.d.ts +1 -41
  448. package/lib/esm/resources/paypal_gateways.js +1 -35
  449. package/lib/esm/resources/paypal_payments.d.ts +1 -53
  450. package/lib/esm/resources/paypal_payments.js +1 -35
  451. package/lib/esm/resources/percentage_discount_promotions.d.ts +1 -131
  452. package/lib/esm/resources/percentage_discount_promotions.js +1 -77
  453. package/lib/esm/resources/price_frequency_tiers.d.ts +1 -53
  454. package/lib/esm/resources/price_frequency_tiers.js +1 -39
  455. package/lib/esm/resources/price_lists.d.ts +1 -46
  456. package/lib/esm/resources/price_lists.js +1 -35
  457. package/lib/esm/resources/price_tiers.d.ts +1 -32
  458. package/lib/esm/resources/price_tiers.js +1 -26
  459. package/lib/esm/resources/price_volume_tiers.d.ts +1 -53
  460. package/lib/esm/resources/price_volume_tiers.js +1 -39
  461. package/lib/esm/resources/prices.d.ts +1 -84
  462. package/lib/esm/resources/prices.js +1 -63
  463. package/lib/esm/resources/promotion_rules.d.ts +1 -29
  464. package/lib/esm/resources/promotion_rules.js +1 -18
  465. package/lib/esm/resources/promotions.d.ts +1 -63
  466. package/lib/esm/resources/promotions.js +1 -58
  467. package/lib/esm/resources/recurring_order_copies.d.ts +1 -53
  468. package/lib/esm/resources/recurring_order_copies.js +1 -39
  469. package/lib/esm/resources/refunds.d.ts +1 -44
  470. package/lib/esm/resources/refunds.js +1 -34
  471. package/lib/esm/resources/reserved_stocks.d.ts +1 -28
  472. package/lib/esm/resources/reserved_stocks.js +1 -26
  473. package/lib/esm/resources/resource_errors.d.ts +1 -22
  474. package/lib/esm/resources/resource_errors.js +1 -14
  475. package/lib/esm/resources/return_line_items.d.ts +1 -52
  476. package/lib/esm/resources/return_line_items.js +1 -34
  477. package/lib/esm/resources/returns.d.ts +1 -96
  478. package/lib/esm/resources/returns.js +1 -90
  479. package/lib/esm/resources/satispay_gateways.d.ts +1 -46
  480. package/lib/esm/resources/satispay_gateways.js +1 -35
  481. package/lib/esm/resources/satispay_payments.d.ts +1 -50
  482. package/lib/esm/resources/satispay_payments.js +1 -38
  483. package/lib/esm/resources/shipments.d.ts +1 -151
  484. package/lib/esm/resources/shipments.js +1 -128
  485. package/lib/esm/resources/shipping_categories.d.ts +1 -40
  486. package/lib/esm/resources/shipping_categories.js +1 -35
  487. package/lib/esm/resources/shipping_method_tiers.d.ts +1 -32
  488. package/lib/esm/resources/shipping_method_tiers.js +1 -26
  489. package/lib/esm/resources/shipping_methods.d.ts +1 -125
  490. package/lib/esm/resources/shipping_methods.js +1 -68
  491. package/lib/esm/resources/shipping_weight_tiers.d.ts +1 -50
  492. package/lib/esm/resources/shipping_weight_tiers.js +1 -35
  493. package/lib/esm/resources/shipping_zones.d.ts +1 -52
  494. package/lib/esm/resources/shipping_zones.js +1 -31
  495. package/lib/esm/resources/sku_list_items.d.ts +1 -51
  496. package/lib/esm/resources/sku_list_items.js +1 -35
  497. package/lib/esm/resources/sku_list_promotion_rules.d.ts +1 -76
  498. package/lib/esm/resources/sku_list_promotion_rules.js +1 -35
  499. package/lib/esm/resources/sku_lists.d.ts +1 -64
  500. package/lib/esm/resources/sku_lists.js +1 -47
  501. package/lib/esm/resources/sku_options.d.ts +1 -71
  502. package/lib/esm/resources/sku_options.js +1 -43
  503. package/lib/esm/resources/skus.d.ts +1 -96
  504. package/lib/esm/resources/skus.js +1 -63
  505. package/lib/esm/resources/stock_items.d.ts +1 -61
  506. package/lib/esm/resources/stock_items.js +1 -50
  507. package/lib/esm/resources/stock_line_items.d.ts +1 -73
  508. package/lib/esm/resources/stock_line_items.js +1 -52
  509. package/lib/esm/resources/stock_locations.d.ts +1 -64
  510. package/lib/esm/resources/stock_locations.js +1 -51
  511. package/lib/esm/resources/stock_reservations.d.ts +1 -51
  512. package/lib/esm/resources/stock_reservations.js +1 -46
  513. package/lib/esm/resources/stock_transfers.d.ts +1 -86
  514. package/lib/esm/resources/stock_transfers.js +1 -69
  515. package/lib/esm/resources/stripe_gateways.d.ts +1 -45
  516. package/lib/esm/resources/stripe_gateways.js +1 -35
  517. package/lib/esm/resources/stripe_payments.d.ts +1 -59
  518. package/lib/esm/resources/stripe_payments.js +1 -41
  519. package/lib/esm/resources/subscription_models.d.ts +1 -49
  520. package/lib/esm/resources/subscription_models.js +1 -35
  521. package/lib/esm/resources/tags.d.ts +1 -28
  522. package/lib/esm/resources/tags.js +1 -23
  523. package/lib/esm/resources/tax_calculators.d.ts +1 -28
  524. package/lib/esm/resources/tax_calculators.js +1 -26
  525. package/lib/esm/resources/tax_categories.d.ts +1 -63
  526. package/lib/esm/resources/tax_categories.js +1 -35
  527. package/lib/esm/resources/tax_rules.d.ts +1 -73
  528. package/lib/esm/resources/tax_rules.js +1 -31
  529. package/lib/esm/resources/taxjar_accounts.d.ts +1 -47
  530. package/lib/esm/resources/taxjar_accounts.js +1 -39
  531. package/lib/esm/resources/transactions.d.ts +1 -41
  532. package/lib/esm/resources/transactions.js +1 -30
  533. package/lib/esm/resources/versions.d.ts +1 -22
  534. package/lib/esm/resources/versions.js +1 -14
  535. package/lib/esm/resources/voids.d.ts +1 -44
  536. package/lib/esm/resources/voids.js +1 -34
  537. package/lib/esm/resources/webhooks.d.ts +1 -55
  538. package/lib/esm/resources/webhooks.js +1 -40
  539. package/lib/esm/resources/wire_transfers.d.ts +1 -37
  540. package/lib/esm/resources/wire_transfers.js +1 -31
  541. package/lib/esm/static.d.ts +1 -12
  542. package/lib/esm/static.js +1 -25
  543. package/lib/esm/util.d.ts +1 -4
  544. package/lib/esm/util.js +1 -37
  545. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  546. package/lib/tsconfig.tsbuildinfo +1 -1
  547. package/package.json +2 -2
package/lib/cjs/query.js CHANGED
@@ -1,69 +1 @@
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.isParamsList = exports.generateQueryStringParams = void 0;
7
- const debug_1 = __importDefault(require("./debug"));
8
- const error_1 = require("./error");
9
- const debug = (0, debug_1.default)('query');
10
- const arrayFilters = ['_any', '_all', '_in'];
11
- const objectFilters = ['_jcont'];
12
- const isParamsList = (params) => {
13
- return params && (params.filters || params.pageNumber || params.pageSize || params.sort);
14
- };
15
- exports.isParamsList = isParamsList;
16
- const generateQueryStringParams = (params, res) => {
17
- debug('generate query string params: %O, %O', params, res);
18
- const qp = {};
19
- if (!params)
20
- return qp;
21
- // Include
22
- if (params.include)
23
- qp.include = params.include.join(',');
24
- // Fields
25
- if (params.fields) {
26
- if (Array.isArray(params.fields))
27
- params.fields = { [res.type || res]: params.fields };
28
- Object.entries(params.fields).forEach(([p, v]) => {
29
- qp[`fields[${p}]`] = v.join(',');
30
- });
31
- }
32
- if (isParamsList(params)) {
33
- // Sort
34
- if (params.sort) {
35
- if (Array.isArray(params.sort))
36
- qp.sort = params.sort.join(',');
37
- else
38
- qp.sort = Object.entries(params.sort).map(([k, v]) => `${v === 'desc' ? '-' : ''}${k}`).join(',');
39
- }
40
- // Page
41
- if (params.pageNumber)
42
- qp['page[number]'] = String(params.pageNumber);
43
- if (params.pageSize)
44
- qp['page[size]'] = String(params.pageSize);
45
- // Filters
46
- if (params.filters) {
47
- Object.entries(params.filters).forEach(([p, v]) => {
48
- const filter = p.substring(p.lastIndexOf('_'));
49
- let val;
50
- if (Array.isArray(v)) {
51
- if (!arrayFilters.includes(filter))
52
- throw new error_1.SdkError({ message: `Wrong ${filter} filter: Array value is supported only for the following filters: ${arrayFilters.join(', ')}`, type: error_1.ErrorType.REQUEST });
53
- val = v.join(',');
54
- }
55
- else if (typeof v === 'object') {
56
- if (!objectFilters.includes(filter))
57
- throw new error_1.SdkError({ message: `Wrong ${filter} filter: Object value is supported only for the following filters: ${objectFilters.join(', ')}`, type: error_1.ErrorType.REQUEST });
58
- val = JSON.stringify(v);
59
- }
60
- else
61
- val = String(v);
62
- qp[`filter[q][${p}]`] = val;
63
- });
64
- }
65
- }
66
- debug('query string params: %O', qp);
67
- return qp;
68
- };
69
- exports.generateQueryStringParams = generateQueryStringParams;
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.isParamsList=exports.generateQueryStringParams=void 0;const debug_1=__importDefault(require("./debug")),error_1=require("./error"),debug=(0,debug_1.default)("query"),arrayFilters=["_any","_all","_in"],objectFilters=["_jcont"],isParamsList=e=>e&&(e.filters||e.pageNumber||e.pageSize||e.sort);exports.isParamsList=isParamsList;const generateQueryStringParams=(e,s)=>{debug("generate query string params: %O, %O",e,s);const r={};return e&&(e.include&&(r.include=e.include.join(",")),e.fields&&(Array.isArray(e.fields)&&(e.fields={[s.type||s]:e.fields}),Object.entries(e.fields).forEach(([i,t])=>{r[`fields[${i}]`]=t.join(",")})),isParamsList(e)&&(e.sort&&(Array.isArray(e.sort)?r.sort=e.sort.join(","):r.sort=Object.entries(e.sort).map(([i,t])=>`${t==="desc"?"-":""}${i}`).join(",")),e.pageNumber&&(r["page[number]"]=String(e.pageNumber)),e.pageSize&&(r["page[size]"]=String(e.pageSize)),e.filters&&Object.entries(e.filters).forEach(([i,t])=>{const n=i.substring(i.lastIndexOf("_"));let o;if(Array.isArray(t)){if(!arrayFilters.includes(n))throw new error_1.SdkError({message:`Wrong ${n} filter: Array value is supported only for the following filters: ${arrayFilters.join(", ")}`,type:error_1.ErrorType.REQUEST});o=t.join(",")}else if(typeof t=="object"){if(!objectFilters.includes(n))throw new error_1.SdkError({message:`Wrong ${n} filter: Object value is supported only for the following filters: ${objectFilters.join(", ")}`,type:error_1.ErrorType.REQUEST});o=JSON.stringify(t)}else o=String(t);r[`filter[q][${i}]`]=o})),debug("query string params: %O",r)),r};exports.generateQueryStringParams=generateQueryStringParams;
@@ -1,89 +1 @@
1
- import ApiClient, { type ApiClientInitConfig } from './client';
2
- import type { QueryParamsRetrieve, QueryParamsList, QueryFilter, QueryParams } from './query';
3
- import type { ResourceTypeLock } from './api';
4
- import type { InterceptorManager } from './interceptor';
5
- type ResourceNull = {
6
- id: null;
7
- } & ResourceType;
8
- type ResourceRel = ResourceId | ResourceNull;
9
- type Metadata = Record<string, any>;
10
- interface ResourceType {
11
- readonly type: ResourceTypeLock;
12
- }
13
- interface ResourceId extends ResourceType {
14
- readonly id: string;
15
- }
16
- interface ResourceBase {
17
- reference?: string | null;
18
- reference_origin?: string | null;
19
- metadata?: Metadata;
20
- }
21
- interface Resource extends ResourceBase, ResourceId {
22
- readonly created_at: string;
23
- readonly updated_at: string;
24
- }
25
- interface ResourceCreate extends ResourceBase {
26
- }
27
- interface ResourceUpdate extends ResourceBase {
28
- readonly id: string;
29
- }
30
- type ListMeta = {
31
- readonly pageCount: number;
32
- readonly recordCount: number;
33
- readonly currentPage: number;
34
- readonly recordsPerPage: number;
35
- };
36
- declare class ListResponse<R> extends Array<R> {
37
- readonly meta: ListMeta;
38
- constructor(meta: ListMeta, data: R[]);
39
- first(): R | undefined;
40
- last(): R | undefined;
41
- get(index: number): R | undefined;
42
- hasNextPage(): boolean;
43
- hasPrevPage(): boolean;
44
- getRecordCount(): number;
45
- getPageCount(): number;
46
- get recordCount(): number;
47
- get pageCount(): number;
48
- }
49
- export type { Metadata, ResourceType, ResourceId, Resource, ResourceCreate, ResourceUpdate, ListResponse, ListMeta, ResourceRel };
50
- type ResourceAdapterConfig = {};
51
- type ResourcesInitConfig = ResourceAdapterConfig & ApiClientInitConfig;
52
- type ResourcesConfig = Partial<ResourcesInitConfig>;
53
- declare class ResourceAdapter {
54
- #private;
55
- constructor(config: ResourcesInitConfig);
56
- get interceptors(): InterceptorManager;
57
- private localConfig;
58
- config(config: ResourcesConfig): ResourceAdapter;
59
- get client(): Readonly<ApiClient>;
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 ApiResourceBase<R extends Resource> {
69
- static readonly TYPE: ResourceTypeLock;
70
- protected readonly resources: ResourceAdapter;
71
- constructor(adapter: ResourceAdapter);
72
- abstract relationship(id: string | ResourceId | null): ResourceRel;
73
- abstract type(): ResourceTypeLock;
74
- parse(resource: string, options?: {
75
- ignoreSlug?: boolean;
76
- }): R | R[];
77
- update(resource: ResourceUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
78
- }
79
- declare abstract class ApiResource<R extends Resource> extends ApiResourceBase<R> {
80
- retrieve(id: string | ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
81
- list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<R>>;
82
- count(filter?: QueryFilter | QueryParamsList, options?: ResourcesConfig): Promise<number>;
83
- }
84
- declare abstract class ApiSingleton<R extends Resource> extends ApiResourceBase<R> {
85
- retrieve(params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
86
- }
87
- export default ResourceAdapter;
88
- export { ApiResource, ApiSingleton };
89
- export type { ResourcesConfig, ResourcesInitConfig };
1
+ import ApiClient,{type ApiClientInitConfig}from'./client';import type{QueryParamsRetrieve,QueryParamsList,QueryFilter,QueryParams}from'./query';import type{ResourceTypeLock}from'./api';import type{InterceptorManager}from'./interceptor';type ResourceNull={id:null;}&ResourceType;type ResourceRel=ResourceId|ResourceNull;type Metadata=Record<string,any>;interface ResourceType{readonly type:ResourceTypeLock;}interface ResourceId extends ResourceType{readonly id:string;}interface ResourceBase{reference?:string|null;reference_origin?:string|null;metadata?:Metadata;}interface Resource extends ResourceBase,ResourceId{readonly created_at:string;readonly updated_at:string;}interface ResourceCreate extends ResourceBase{}interface ResourceUpdate extends ResourceBase{readonly id:string;}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;hasNextPage():boolean;hasPrevPage():boolean;getRecordCount():number;getPageCount():number;get recordCount():number;get pageCount():number;}export type{Metadata,ResourceType,ResourceId,Resource,ResourceCreate,ResourceUpdate,ListResponse,ListMeta,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):ResourceAdapter;get client():Readonly<ApiClient>;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 ApiResourceBase<R extends Resource>{static readonly TYPE:ResourceTypeLock;protected readonly resources:ResourceAdapter;constructor(adapter:ResourceAdapter);abstract relationship(id:string|ResourceId|null):ResourceRel;abstract type():ResourceTypeLock;parse(resource:string,options?:{ignoreSlug?:boolean;}):R|R[];update(resource:ResourceUpdate,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;}declare abstract class ApiResource<R extends Resource>extends ApiResourceBase<R>{retrieve(id:string|ResourceId,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;list(params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<R>>;count(filter?:QueryFilter|QueryParamsList,options?:ResourcesConfig):Promise<number>;}declare abstract class ApiSingleton<R extends Resource>extends ApiResourceBase<R>{retrieve(params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<R>;}export default ResourceAdapter;export{ApiResource,ApiSingleton};export type{ResourcesConfig,ResourcesInitConfig};
@@ -1,198 +1 @@
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 error_1 = require("./error");
24
- const debug_1 = __importDefault(require("./debug"));
25
- const debug = (0, debug_1.default)('resource');
26
- class ListResponse extends Array {
27
- constructor(meta, data) {
28
- super(...(data || []));
29
- this.meta = meta;
30
- }
31
- first() { return this.length ? this[0] : undefined; }
32
- last() { return this.length ? this[this.length - 1] : undefined; }
33
- get(index) { return (this.length && (index >= 0)) ? this[index] : undefined; }
34
- hasNextPage() { return (this.meta.currentPage < this.meta.pageCount); }
35
- hasPrevPage() { return (this.meta.currentPage > 1); }
36
- getRecordCount() { return this.meta.recordCount; }
37
- getPageCount() { return this.meta.pageCount; }
38
- get recordCount() { return this.meta.recordCount; }
39
- get pageCount() { return this.meta.pageCount; }
40
- }
41
- class ResourceAdapter {
42
- constructor(config) {
43
- _ResourceAdapter_client.set(this, void 0);
44
- _ResourceAdapter_config.set(this, {});
45
- __classPrivateFieldSet(this, _ResourceAdapter_client, client_1.default.create(config), "f");
46
- this.localConfig(config);
47
- }
48
- get interceptors() { return __classPrivateFieldGet(this, _ResourceAdapter_client, "f").interceptors; }
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
- return this;
59
- }
60
- get client() {
61
- return __classPrivateFieldGet(this, _ResourceAdapter_client, "f");
62
- }
63
- async singleton(resource, params, options) {
64
- debug('singleton: %o, %O, %O', resource, params || {}, options || {});
65
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
66
- if (options === null || options === void 0 ? void 0 : options.params)
67
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
68
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}`, undefined, { ...options, params: queryParams });
69
- const r = (0, jsonapi_1.denormalize)(res);
70
- return r;
71
- }
72
- async retrieve(resource, params, options) {
73
- debug('retrieve: %o, %O, %O', resource, params || {}, options || {});
74
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
75
- if (options === null || options === void 0 ? void 0 : options.params)
76
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
77
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}/${resource.id}`, undefined, { ...options, params: queryParams });
78
- const r = (0, jsonapi_1.denormalize)(res);
79
- return r;
80
- }
81
- async list(resource, params, options) {
82
- var _a, _b;
83
- debug('list: %o, %O, %O', resource, params || {}, options || {});
84
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
85
- if (options === null || options === void 0 ? void 0 : options.params)
86
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
87
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}`, undefined, { ...options, params: queryParams });
88
- const r = (0, jsonapi_1.denormalize)(res);
89
- const meta = {
90
- pageCount: Number((_a = res.meta) === null || _a === void 0 ? void 0 : _a.page_count),
91
- recordCount: Number((_b = res.meta) === null || _b === void 0 ? void 0 : _b.record_count),
92
- currentPage: (params === null || params === void 0 ? void 0 : params.pageNumber) || config_1.default.default.pageNumber,
93
- recordsPerPage: (params === null || params === void 0 ? void 0 : params.pageSize) || config_1.default.default.pageSize
94
- };
95
- return new ListResponse(meta, r);
96
- }
97
- async create(resource, params, options) {
98
- debug('create: %o, %O, %O', resource, params || {}, options || {});
99
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
100
- if (options === null || options === void 0 ? void 0 : options.params)
101
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
102
- const data = (0, jsonapi_1.normalize)(resource);
103
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('post', resource.type, data, { ...options, params: queryParams });
104
- const r = (0, jsonapi_1.denormalize)(res);
105
- return r;
106
- }
107
- async update(resource, params, options) {
108
- debug('update: %o, %O, %O', resource, params || {}, options || {});
109
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
110
- if (options === null || options === void 0 ? void 0 : options.params)
111
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
112
- const data = (0, jsonapi_1.normalize)(resource);
113
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('patch', `${resource.type}/${resource.id}`, data, { ...options, params: queryParams });
114
- const r = (0, jsonapi_1.denormalize)(res);
115
- return r;
116
- }
117
- async delete(resource, options) {
118
- debug('delete: %o, %O', resource, options || {});
119
- await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('delete', `${resource.type}/${resource.id}`, undefined, options);
120
- }
121
- async fetch(resource, path, params, options) {
122
- var _a, _b;
123
- debug('fetch: %o, %O, %O', path, params || {}, options || {});
124
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
125
- if (options === null || options === void 0 ? void 0 : options.params)
126
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
127
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', path, undefined, { ...options, params: queryParams });
128
- const r = (0, jsonapi_1.denormalize)(res);
129
- if (Array.isArray(r)) {
130
- const p = params;
131
- const meta = {
132
- pageCount: Number((_a = res.meta) === null || _a === void 0 ? void 0 : _a.page_count),
133
- recordCount: Number((_b = res.meta) === null || _b === void 0 ? void 0 : _b.record_count),
134
- currentPage: (p === null || p === void 0 ? void 0 : p.pageNumber) || config_1.default.default.pageNumber,
135
- recordsPerPage: (p === null || p === void 0 ? void 0 : p.pageSize) || config_1.default.default.pageSize
136
- };
137
- return new ListResponse(meta, r);
138
- }
139
- else
140
- return r;
141
- }
142
- }
143
- _ResourceAdapter_client = new WeakMap(), _ResourceAdapter_config = new WeakMap();
144
- class ApiResourceBase {
145
- constructor(adapter) {
146
- debug('new resource instance: %s', this.type());
147
- this.resources = adapter;
148
- }
149
- parse(resource, options) {
150
- var _a;
151
- try {
152
- const res = JSON.parse(resource);
153
- // Resource type always checked
154
- const rtype = (_a = res.data) === null || _a === void 0 ? void 0 : _a.type;
155
- if (rtype !== this.type())
156
- throw new error_1.SdkError({ message: `Invalid resource type [${rtype}]`, type: error_1.ErrorType.PARSE });
157
- // Parse options
158
- const { ignoreSlug } = options || {};
159
- if (!ignoreSlug) {
160
- const links = res.data.links.self;
161
- if (!links || !String(links).match(`^${this.resources.client.baseUrl}/${this.type()}/*`))
162
- throw new error_1.SdkError({ message: `Resource contains invalid links [${links}]`, type: error_1.ErrorType.PARSE });
163
- }
164
- return (0, jsonapi_1.denormalize)(res);
165
- }
166
- catch (error) {
167
- if (error_1.SdkError.isSdkError(error))
168
- throw error;
169
- else
170
- throw new error_1.SdkError({ message: `Payload parse error [${error.message}]`, type: error_1.ErrorType.PARSE });
171
- }
172
- }
173
- // reference, reference_origin and metadata attributes are always updatable
174
- async update(resource, params, options) {
175
- return this.resources.update({ ...resource, type: this.type() }, params, options);
176
- }
177
- }
178
- class ApiResource extends ApiResourceBase {
179
- async retrieve(id, params, options) {
180
- return this.resources.retrieve((typeof id === 'string') ? { type: this.type(), id } : id, params, options);
181
- }
182
- async list(params, options) {
183
- return this.resources.list({ type: this.type() }, params, options);
184
- }
185
- async count(filter, options) {
186
- const params = { filters: (0, query_1.isParamsList)(filter) ? filter.filters : filter, pageNumber: 1, pageSize: 1 };
187
- const response = await this.list(params, options);
188
- return Promise.resolve(response.meta.recordCount);
189
- }
190
- }
191
- exports.ApiResource = ApiResource;
192
- class ApiSingleton extends ApiResourceBase {
193
- async retrieve(params, options) {
194
- return this.resources.singleton({ type: this.type() }, params, options);
195
- }
196
- }
197
- exports.ApiSingleton = ApiSingleton;
198
- exports.default = ResourceAdapter;
1
+ "use strict";var __classPrivateFieldSet=this&&this.__classPrivateFieldSet||function(s,e,r,t,a){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!a:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?a.call(s,r):a?a.value=r:e.set(s,r),r},__classPrivateFieldGet=this&&this.__classPrivateFieldGet||function(s,e,r,t){if(r==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!t:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?t:r==="a"?t.call(s):t?t.value:e.get(s)},__importDefault=this&&this.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},_ResourceAdapter_client,_ResourceAdapter_config;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApiSingleton=exports.ApiResource=void 0;const client_1=__importDefault(require("./client")),jsonapi_1=require("./jsonapi"),query_1=require("./query"),config_1=__importDefault(require("./config")),error_1=require("./error"),debug_1=__importDefault(require("./debug")),debug=(0,debug_1.default)("resource");class ListResponse extends Array{constructor(e,r){super(...r||[]),this.meta=e}first(){return this.length?this[0]:void 0}last(){return this.length?this[this.length-1]:void 0}get(e){return this.length&&e>=0?this[e]:void 0}hasNextPage(){return this.meta.currentPage<this.meta.pageCount}hasPrevPage(){return this.meta.currentPage>1}getRecordCount(){return this.meta.recordCount}getPageCount(){return this.meta.pageCount}get recordCount(){return this.meta.recordCount}get pageCount(){return this.meta.pageCount}}class ResourceAdapter{constructor(e){_ResourceAdapter_client.set(this,void 0),_ResourceAdapter_config.set(this,{}),__classPrivateFieldSet(this,_ResourceAdapter_client,client_1.default.create(e),"f"),this.localConfig(e)}get interceptors(){return __classPrivateFieldGet(this,_ResourceAdapter_client,"f").interceptors}localConfig(e){}config(e){return debug("config %o",e),this.localConfig(e),__classPrivateFieldGet(this,_ResourceAdapter_client,"f").config(e),this}get client(){return __classPrivateFieldGet(this,_ResourceAdapter_client,"f")}async singleton(e,r,t){debug("singleton: %o, %O, %O",e,r||{},t||{});const a=(0,query_1.generateQueryStringParams)(r,e);t?.params&&Object.assign(a,t?.params);const n=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("get",`${e.type}`,void 0,{...t,params:a});return(0,jsonapi_1.denormalize)(n)}async retrieve(e,r,t){debug("retrieve: %o, %O, %O",e,r||{},t||{});const a=(0,query_1.generateQueryStringParams)(r,e);t?.params&&Object.assign(a,t?.params);const n=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("get",`${e.type}/${e.id}`,void 0,{...t,params:a});return(0,jsonapi_1.denormalize)(n)}async list(e,r,t){var a,n;debug("list: %o, %O, %O",e,r||{},t||{});const i=(0,query_1.generateQueryStringParams)(r,e);t?.params&&Object.assign(i,t?.params);const u=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("get",`${e.type}`,void 0,{...t,params:i}),l=(0,jsonapi_1.denormalize)(u),d={pageCount:Number((a=u.meta)===null||a===void 0?void 0:a.page_count),recordCount:Number((n=u.meta)===null||n===void 0?void 0:n.record_count),currentPage:r?.pageNumber||config_1.default.default.pageNumber,recordsPerPage:r?.pageSize||config_1.default.default.pageSize};return new ListResponse(d,l)}async create(e,r,t){debug("create: %o, %O, %O",e,r||{},t||{});const a=(0,query_1.generateQueryStringParams)(r,e);t?.params&&Object.assign(a,t?.params);const n=(0,jsonapi_1.normalize)(e),i=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("post",e.type,n,{...t,params:a});return(0,jsonapi_1.denormalize)(i)}async update(e,r,t){debug("update: %o, %O, %O",e,r||{},t||{});const a=(0,query_1.generateQueryStringParams)(r,e);t?.params&&Object.assign(a,t?.params);const n=(0,jsonapi_1.normalize)(e),i=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("patch",`${e.type}/${e.id}`,n,{...t,params:a});return(0,jsonapi_1.denormalize)(i)}async delete(e,r){debug("delete: %o, %O",e,r||{}),await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("delete",`${e.type}/${e.id}`,void 0,r)}async fetch(e,r,t,a){var n,i;debug("fetch: %o, %O, %O",r,t||{},a||{});const u=(0,query_1.generateQueryStringParams)(t,e);a?.params&&Object.assign(u,a?.params);const l=await __classPrivateFieldGet(this,_ResourceAdapter_client,"f").request("get",r,void 0,{...a,params:u}),d=(0,jsonapi_1.denormalize)(l);if(Array.isArray(d)){const o=t,c={pageCount:Number((n=l.meta)===null||n===void 0?void 0:n.page_count),recordCount:Number((i=l.meta)===null||i===void 0?void 0:i.record_count),currentPage:o?.pageNumber||config_1.default.default.pageNumber,recordsPerPage:o?.pageSize||config_1.default.default.pageSize};return new ListResponse(c,d)}else return d}}_ResourceAdapter_client=new WeakMap,_ResourceAdapter_config=new WeakMap;class ApiResourceBase{constructor(e){debug("new resource instance: %s",this.type()),this.resources=e}parse(e,r){var t;try{const a=JSON.parse(e),n=(t=a.data)===null||t===void 0?void 0:t.type;if(n!==this.type())throw new error_1.SdkError({message:`Invalid resource type [${n}]`,type:error_1.ErrorType.PARSE});const{ignoreSlug:i}=r||{};if(!i){const u=a.data.links.self;if(!u||!String(u).match(`^${this.resources.client.baseUrl}/${this.type()}/*`))throw new error_1.SdkError({message:`Resource contains invalid links [${u}]`,type:error_1.ErrorType.PARSE})}return(0,jsonapi_1.denormalize)(a)}catch(a){throw error_1.SdkError.isSdkError(a)?a:new error_1.SdkError({message:`Payload parse error [${a.message}]`,type:error_1.ErrorType.PARSE})}}async update(e,r,t){return this.resources.update({...e,type:this.type()},r,t)}}class ApiResource extends ApiResourceBase{async retrieve(e,r,t){return this.resources.retrieve(typeof e=="string"?{type:this.type(),id:e}:e,r,t)}async list(e,r){return this.resources.list({type:this.type()},e,r)}async count(e,r){const t={filters:(0,query_1.isParamsList)(e)?e.filters:e,pageNumber:1,pageSize:1},a=await this.list(t,r);return Promise.resolve(a.meta.recordCount)}}exports.ApiResource=ApiResource;class ApiSingleton extends ApiResourceBase{async retrieve(e,r){return this.resources.singleton({type:this.type()},e,r)}}exports.ApiSingleton=ApiSingleton,exports.default=ResourceAdapter;
@@ -1,103 +1 @@
1
- import { ApiResource } from '../resource';
2
- import type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
3
- import type { QueryParamsRetrieve, QueryParamsList } from '../query';
4
- import type { Geocoder, GeocoderType } from './geocoders';
5
- import type { Event } from './events';
6
- import type { Tag, TagType } from './tags';
7
- import type { Version } from './versions';
8
- type AddressType = 'addresses';
9
- type AddressRel = ResourceRel & {
10
- type: AddressType;
11
- };
12
- type GeocoderRel = ResourceRel & {
13
- type: GeocoderType;
14
- };
15
- type TagRel = ResourceRel & {
16
- type: TagType;
17
- };
18
- interface Address extends Resource {
19
- readonly type: AddressType;
20
- business?: boolean | null;
21
- first_name?: string | null;
22
- last_name?: string | null;
23
- company?: string | null;
24
- full_name?: string | null;
25
- line_1: string;
26
- line_2?: string | null;
27
- city: string;
28
- zip_code?: string | null;
29
- state_code: string;
30
- country_code: string;
31
- phone: string;
32
- full_address?: string | null;
33
- name?: string | null;
34
- email?: string | null;
35
- notes?: string | null;
36
- lat?: number | null;
37
- lng?: number | null;
38
- is_localized?: boolean | null;
39
- is_geocoded?: boolean | null;
40
- provider_name?: string | null;
41
- map_url?: string | null;
42
- static_map_url?: string | null;
43
- billing_info?: string | null;
44
- geocoder?: Geocoder | null;
45
- events?: Event[] | null;
46
- tags?: Tag[] | null;
47
- versions?: Version[] | null;
48
- }
49
- interface AddressCreate extends ResourceCreate {
50
- business?: boolean | null;
51
- first_name?: string | null;
52
- last_name?: string | null;
53
- company?: string | null;
54
- line_1: string;
55
- line_2?: string | null;
56
- city: string;
57
- zip_code?: string | null;
58
- state_code: string;
59
- country_code: string;
60
- phone: string;
61
- email?: string | null;
62
- notes?: string | null;
63
- lat?: number | null;
64
- lng?: number | null;
65
- billing_info?: string | null;
66
- geocoder?: GeocoderRel | null;
67
- tags?: TagRel[] | null;
68
- }
69
- interface AddressUpdate extends ResourceUpdate {
70
- business?: boolean | null;
71
- first_name?: string | null;
72
- last_name?: string | null;
73
- company?: string | null;
74
- line_1?: string | null;
75
- line_2?: string | null;
76
- city?: string | null;
77
- zip_code?: string | null;
78
- state_code?: string | null;
79
- country_code?: string | null;
80
- phone?: string | null;
81
- email?: string | null;
82
- notes?: string | null;
83
- lat?: number | null;
84
- lng?: number | null;
85
- billing_info?: string | null;
86
- geocoder?: GeocoderRel | null;
87
- tags?: TagRel[] | null;
88
- }
89
- declare class Addresses extends ApiResource<Address> {
90
- static readonly TYPE: AddressType;
91
- create(resource: AddressCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Address>;
92
- update(resource: AddressUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Address>;
93
- delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
94
- geocoder(addressId: string | Address, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Geocoder>;
95
- events(addressId: string | Address, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
96
- tags(addressId: string | Address, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Tag>>;
97
- versions(addressId: string | Address, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
98
- isAddress(resource: any): resource is Address;
99
- relationship(id: string | ResourceId | null): AddressRel;
100
- type(): AddressType;
101
- }
102
- export default Addresses;
103
- export type { Address, AddressCreate, AddressUpdate, AddressType };
1
+ import{ApiResource}from'../resource';import type{Resource,ResourceCreate,ResourceUpdate,ResourceId,ResourcesConfig,ResourceRel,ListResponse}from'../resource';import type{QueryParamsRetrieve,QueryParamsList}from'../query';import type{Geocoder,GeocoderType}from'./geocoders';import type{Event}from'./events';import type{Tag,TagType}from'./tags';import type{Version}from'./versions';type AddressType='addresses';type AddressRel=ResourceRel&{type:AddressType;};type GeocoderRel=ResourceRel&{type:GeocoderType;};type TagRel=ResourceRel&{type:TagType;};interface Address extends Resource{readonly type:AddressType;business?:boolean|null;first_name?:string|null;last_name?:string|null;company?:string|null;full_name?:string|null;line_1:string;line_2?:string|null;city:string;zip_code?:string|null;state_code:string;country_code:string;phone:string;full_address?:string|null;name?:string|null;email?:string|null;notes?:string|null;lat?:number|null;lng?:number|null;is_localized?:boolean|null;is_geocoded?:boolean|null;provider_name?:string|null;map_url?:string|null;static_map_url?:string|null;billing_info?:string|null;geocoder?:Geocoder|null;events?:Event[]|null;tags?:Tag[]|null;versions?:Version[]|null;}interface AddressCreate extends ResourceCreate{business?:boolean|null;first_name?:string|null;last_name?:string|null;company?:string|null;line_1:string;line_2?:string|null;city:string;zip_code?:string|null;state_code:string;country_code:string;phone:string;email?:string|null;notes?:string|null;lat?:number|null;lng?:number|null;billing_info?:string|null;geocoder?:GeocoderRel|null;tags?:TagRel[]|null;}interface AddressUpdate extends ResourceUpdate{business?:boolean|null;first_name?:string|null;last_name?:string|null;company?:string|null;line_1?:string|null;line_2?:string|null;city?:string|null;zip_code?:string|null;state_code?:string|null;country_code?:string|null;phone?:string|null;email?:string|null;notes?:string|null;lat?:number|null;lng?:number|null;billing_info?:string|null;geocoder?:GeocoderRel|null;tags?:TagRel[]|null;}declare class Addresses extends ApiResource<Address>{static readonly TYPE:AddressType;create(resource:AddressCreate,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<Address>;update(resource:AddressUpdate,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<Address>;delete(id:string|ResourceId,options?:ResourcesConfig):Promise<void>;geocoder(addressId:string|Address,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<Geocoder>;events(addressId:string|Address,params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<Event>>;tags(addressId:string|Address,params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<Tag>>;versions(addressId:string|Address,params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<Version>>;isAddress(resource:any):resource is Address;relationship(id:string|ResourceId|null):AddressRel;type():AddressType;}export default Addresses;export type{Address,AddressCreate,AddressUpdate,AddressType};
@@ -1,41 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resource_1 = require("../resource");
4
- class Addresses extends resource_1.ApiResource {
5
- async create(resource, params, options) {
6
- return this.resources.create({ ...resource, type: Addresses.TYPE }, params, options);
7
- }
8
- async update(resource, params, options) {
9
- return this.resources.update({ ...resource, type: Addresses.TYPE }, params, options);
10
- }
11
- async delete(id, options) {
12
- await this.resources.delete((typeof id === 'string') ? { id, type: Addresses.TYPE } : id, options);
13
- }
14
- async geocoder(addressId, params, options) {
15
- const _addressId = addressId.id || addressId;
16
- return this.resources.fetch({ type: 'geocoders' }, `addresses/${_addressId}/geocoder`, params, options);
17
- }
18
- async events(addressId, params, options) {
19
- const _addressId = addressId.id || addressId;
20
- return this.resources.fetch({ type: 'events' }, `addresses/${_addressId}/events`, params, options);
21
- }
22
- async tags(addressId, params, options) {
23
- const _addressId = addressId.id || addressId;
24
- return this.resources.fetch({ type: 'tags' }, `addresses/${_addressId}/tags`, params, options);
25
- }
26
- async versions(addressId, params, options) {
27
- const _addressId = addressId.id || addressId;
28
- return this.resources.fetch({ type: 'versions' }, `addresses/${_addressId}/versions`, params, options);
29
- }
30
- isAddress(resource) {
31
- return resource.type && (resource.type === Addresses.TYPE);
32
- }
33
- relationship(id) {
34
- return ((id === null) || (typeof id === 'string')) ? { id, type: Addresses.TYPE } : { id: id.id, type: Addresses.TYPE };
35
- }
36
- type() {
37
- return Addresses.TYPE;
38
- }
39
- }
40
- Addresses.TYPE = 'addresses';
41
- exports.default = Addresses;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const resource_1=require("../resource");class Addresses extends resource_1.ApiResource{async create(e,t,s){return this.resources.create({...e,type:Addresses.TYPE},t,s)}async update(e,t,s){return this.resources.update({...e,type:Addresses.TYPE},t,s)}async delete(e,t){await this.resources.delete(typeof e=="string"?{id:e,type:Addresses.TYPE}:e,t)}async geocoder(e,t,s){const r=e.id||e;return this.resources.fetch({type:"geocoders"},`addresses/${r}/geocoder`,t,s)}async events(e,t,s){const r=e.id||e;return this.resources.fetch({type:"events"},`addresses/${r}/events`,t,s)}async tags(e,t,s){const r=e.id||e;return this.resources.fetch({type:"tags"},`addresses/${r}/tags`,t,s)}async versions(e,t,s){const r=e.id||e;return this.resources.fetch({type:"versions"},`addresses/${r}/versions`,t,s)}isAddress(e){return e.type&&e.type===Addresses.TYPE}relationship(e){return e===null||typeof e=="string"?{id:e,type:Addresses.TYPE}:{id:e.id,type:Addresses.TYPE}}type(){return Addresses.TYPE}}Addresses.TYPE="addresses",exports.default=Addresses;
@@ -1,42 +1 @@
1
- import { ApiResource } from '../resource';
2
- import type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
3
- import type { QueryParamsRetrieve, QueryParamsList } from '../query';
4
- import type { Version } from './versions';
5
- type AdjustmentType = 'adjustments';
6
- type AdjustmentRel = ResourceRel & {
7
- type: AdjustmentType;
8
- };
9
- interface Adjustment extends Resource {
10
- readonly type: AdjustmentType;
11
- name: string;
12
- currency_code: string;
13
- amount_cents: number;
14
- amount_float: number;
15
- formatted_amount: string;
16
- distribute_discount?: boolean | null;
17
- versions?: Version[] | null;
18
- }
19
- interface AdjustmentCreate extends ResourceCreate {
20
- name: string;
21
- currency_code: string;
22
- amount_cents: number;
23
- distribute_discount?: boolean | null;
24
- }
25
- interface AdjustmentUpdate extends ResourceUpdate {
26
- name?: string | null;
27
- currency_code?: string | null;
28
- amount_cents?: number | null;
29
- distribute_discount?: boolean | null;
30
- }
31
- declare class Adjustments extends ApiResource<Adjustment> {
32
- static readonly TYPE: AdjustmentType;
33
- create(resource: AdjustmentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Adjustment>;
34
- update(resource: AdjustmentUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Adjustment>;
35
- delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
36
- versions(adjustmentId: string | Adjustment, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
37
- isAdjustment(resource: any): resource is Adjustment;
38
- relationship(id: string | ResourceId | null): AdjustmentRel;
39
- type(): AdjustmentType;
40
- }
41
- export default Adjustments;
42
- export type { Adjustment, AdjustmentCreate, AdjustmentUpdate, AdjustmentType };
1
+ import{ApiResource}from'../resource';import type{Resource,ResourceCreate,ResourceUpdate,ResourceId,ResourcesConfig,ResourceRel,ListResponse}from'../resource';import type{QueryParamsRetrieve,QueryParamsList}from'../query';import type{Version}from'./versions';type AdjustmentType='adjustments';type AdjustmentRel=ResourceRel&{type:AdjustmentType;};interface Adjustment extends Resource{readonly type:AdjustmentType;name:string;currency_code:string;amount_cents:number;amount_float:number;formatted_amount:string;distribute_discount?:boolean|null;versions?:Version[]|null;}interface AdjustmentCreate extends ResourceCreate{name:string;currency_code:string;amount_cents:number;distribute_discount?:boolean|null;}interface AdjustmentUpdate extends ResourceUpdate{name?:string|null;currency_code?:string|null;amount_cents?:number|null;distribute_discount?:boolean|null;}declare class Adjustments extends ApiResource<Adjustment>{static readonly TYPE:AdjustmentType;create(resource:AdjustmentCreate,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<Adjustment>;update(resource:AdjustmentUpdate,params?:QueryParamsRetrieve,options?:ResourcesConfig):Promise<Adjustment>;delete(id:string|ResourceId,options?:ResourcesConfig):Promise<void>;versions(adjustmentId:string|Adjustment,params?:QueryParamsList,options?:ResourcesConfig):Promise<ListResponse<Version>>;isAdjustment(resource:any):resource is Adjustment;relationship(id:string|ResourceId|null):AdjustmentRel;type():AdjustmentType;}export default Adjustments;export type{Adjustment,AdjustmentCreate,AdjustmentUpdate,AdjustmentType};
@@ -1,29 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resource_1 = require("../resource");
4
- class Adjustments extends resource_1.ApiResource {
5
- async create(resource, params, options) {
6
- return this.resources.create({ ...resource, type: Adjustments.TYPE }, params, options);
7
- }
8
- async update(resource, params, options) {
9
- return this.resources.update({ ...resource, type: Adjustments.TYPE }, params, options);
10
- }
11
- async delete(id, options) {
12
- await this.resources.delete((typeof id === 'string') ? { id, type: Adjustments.TYPE } : id, options);
13
- }
14
- async versions(adjustmentId, params, options) {
15
- const _adjustmentId = adjustmentId.id || adjustmentId;
16
- return this.resources.fetch({ type: 'versions' }, `adjustments/${_adjustmentId}/versions`, params, options);
17
- }
18
- isAdjustment(resource) {
19
- return resource.type && (resource.type === Adjustments.TYPE);
20
- }
21
- relationship(id) {
22
- return ((id === null) || (typeof id === 'string')) ? { id, type: Adjustments.TYPE } : { id: id.id, type: Adjustments.TYPE };
23
- }
24
- type() {
25
- return Adjustments.TYPE;
26
- }
27
- }
28
- Adjustments.TYPE = 'adjustments';
29
- exports.default = Adjustments;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const resource_1=require("../resource");class Adjustments extends resource_1.ApiResource{async create(e,r,t){return this.resources.create({...e,type:Adjustments.TYPE},r,t)}async update(e,r,t){return this.resources.update({...e,type:Adjustments.TYPE},r,t)}async delete(e,r){await this.resources.delete(typeof e=="string"?{id:e,type:Adjustments.TYPE}:e,r)}async versions(e,r,t){const s=e.id||e;return this.resources.fetch({type:"versions"},`adjustments/${s}/versions`,r,t)}isAdjustment(e){return e.type&&e.type===Adjustments.TYPE}relationship(e){return e===null||typeof e=="string"?{id:e,type:Adjustments.TYPE}:{id:e.id,type:Adjustments.TYPE}}type(){return Adjustments.TYPE}}Adjustments.TYPE="adjustments",exports.default=Adjustments;