@medusajs/medusa 1.1.64 → 1.2.1

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 (374) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/api/index.d.ts +2 -0
  3. package/dist/api/index.js +2 -0
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/api/routes/admin/collections/add-products.d.ts +32 -0
  6. package/dist/api/routes/admin/collections/add-products.js +107 -0
  7. package/dist/api/routes/admin/collections/add-products.js.map +1 -0
  8. package/dist/api/routes/admin/collections/index.d.ts +2 -0
  9. package/dist/api/routes/admin/collections/index.js +11 -1
  10. package/dist/api/routes/admin/collections/index.js.map +1 -1
  11. package/dist/api/routes/admin/collections/remove-products.d.ts +32 -0
  12. package/dist/api/routes/admin/collections/remove-products.js +111 -0
  13. package/dist/api/routes/admin/collections/remove-products.js.map +1 -0
  14. package/dist/api/routes/admin/customer-groups/create-customer-group.d.ts +27 -0
  15. package/dist/api/routes/admin/customer-groups/create-customer-group.js +103 -0
  16. package/dist/api/routes/admin/customer-groups/create-customer-group.js.map +1 -0
  17. package/dist/api/routes/admin/customer-groups/delete-customer-group.d.ts +28 -0
  18. package/dist/api/routes/admin/customer-groups/delete-customer-group.js +84 -0
  19. package/dist/api/routes/admin/customer-groups/delete-customer-group.js.map +1 -0
  20. package/dist/api/routes/admin/customer-groups/delete-customers-batch.d.ts +27 -0
  21. package/dist/api/routes/admin/customer-groups/delete-customers-batch.js +106 -0
  22. package/dist/api/routes/admin/customer-groups/delete-customers-batch.js.map +1 -0
  23. package/dist/api/routes/admin/customer-groups/get-customer-group.d.ts +25 -0
  24. package/dist/api/routes/admin/customer-groups/get-customer-group.js +113 -0
  25. package/dist/api/routes/admin/customer-groups/get-customer-group.js.map +1 -0
  26. package/dist/api/routes/admin/customer-groups/index.d.ts +13 -0
  27. package/dist/api/routes/admin/customer-groups/index.js +31 -0
  28. package/dist/api/routes/admin/customer-groups/index.js.map +1 -0
  29. package/dist/api/routes/admin/customer-groups/update-customer-group.d.ts +28 -0
  30. package/dist/api/routes/admin/customer-groups/update-customer-group.js +124 -0
  31. package/dist/api/routes/admin/customer-groups/update-customer-group.js.map +1 -0
  32. package/dist/api/routes/admin/customers/get-customer.js +18 -5
  33. package/dist/api/routes/admin/customers/get-customer.js.map +1 -1
  34. package/dist/api/routes/admin/customers/index.d.ts +1 -0
  35. package/dist/api/routes/admin/customers/index.js +2 -0
  36. package/dist/api/routes/admin/customers/index.js.map +1 -1
  37. package/dist/api/routes/admin/customers/update-customer.d.ts +14 -0
  38. package/dist/api/routes/admin/customers/update-customer.js +49 -10
  39. package/dist/api/routes/admin/customers/update-customer.js.map +1 -1
  40. package/dist/api/routes/admin/draft-orders/create-draft-order.d.ts +3 -3
  41. package/dist/api/routes/admin/draft-orders/create-draft-order.js.map +1 -1
  42. package/dist/api/routes/admin/draft-orders/create-line-item.d.ts +1 -1
  43. package/dist/api/routes/admin/draft-orders/create-line-item.js.map +1 -1
  44. package/dist/api/routes/admin/draft-orders/update-line-item.d.ts +1 -1
  45. package/dist/api/routes/admin/draft-orders/update-line-item.js.map +1 -1
  46. package/dist/api/routes/admin/index.js +6 -0
  47. package/dist/api/routes/admin/index.js.map +1 -1
  48. package/dist/api/routes/admin/orders/add-shipping-method.d.ts +1 -1
  49. package/dist/api/routes/admin/orders/add-shipping-method.js.map +1 -1
  50. package/dist/api/routes/admin/orders/create-claim.js +9 -1
  51. package/dist/api/routes/admin/orders/create-claim.js.map +1 -1
  52. package/dist/api/routes/admin/orders/create-swap-shipment.js +1 -0
  53. package/dist/api/routes/admin/orders/create-swap-shipment.js.map +1 -1
  54. package/dist/api/routes/admin/orders/create-swap.js +7 -1
  55. package/dist/api/routes/admin/orders/create-swap.js.map +1 -1
  56. package/dist/api/routes/admin/orders/index.d.ts +0 -1
  57. package/dist/api/routes/admin/orders/index.js +2 -5
  58. package/dist/api/routes/admin/orders/index.js.map +1 -1
  59. package/dist/api/routes/admin/product-types/index.d.ts +15 -0
  60. package/dist/api/routes/admin/product-types/index.js +40 -0
  61. package/dist/api/routes/admin/product-types/index.js.map +1 -0
  62. package/dist/api/routes/admin/product-types/list-product-types.d.ts +39 -0
  63. package/dist/api/routes/admin/product-types/list-product-types.js +211 -0
  64. package/dist/api/routes/admin/product-types/list-product-types.js.map +1 -0
  65. package/dist/api/routes/admin/regions/index.js +3 -0
  66. package/dist/api/routes/admin/regions/index.js.map +1 -1
  67. package/dist/api/routes/admin/regions/list-regions.d.ts +27 -3
  68. package/dist/api/routes/admin/regions/list-regions.js +91 -11
  69. package/dist/api/routes/admin/regions/list-regions.js.map +1 -1
  70. package/dist/api/routes/admin/regions/update-region.d.ts +12 -0
  71. package/dist/api/routes/admin/regions/update-region.js +24 -0
  72. package/dist/api/routes/admin/regions/update-region.js.map +1 -1
  73. package/dist/api/routes/admin/shipping-options/index.d.ts +2 -2
  74. package/dist/api/routes/admin/shipping-options/list-shipping-options.js +23 -7
  75. package/dist/api/routes/admin/shipping-options/list-shipping-options.js.map +1 -1
  76. package/dist/api/routes/admin/store/index.d.ts +4 -1
  77. package/dist/api/routes/admin/store/index.js +1 -0
  78. package/dist/api/routes/admin/store/index.js.map +1 -1
  79. package/dist/api/routes/admin/store/list-tax-providers.d.ts +22 -0
  80. package/dist/api/routes/admin/store/list-tax-providers.js +73 -0
  81. package/dist/api/routes/admin/store/list-tax-providers.js.map +1 -0
  82. package/dist/api/routes/admin/swaps/index.js +0 -6
  83. package/dist/api/routes/admin/swaps/index.js.map +1 -1
  84. package/dist/api/routes/admin/tax-rates/add-to-product-types.d.ts +29 -0
  85. package/dist/api/routes/admin/tax-rates/add-to-product-types.js +122 -0
  86. package/dist/api/routes/admin/tax-rates/add-to-product-types.js.map +1 -0
  87. package/dist/api/routes/admin/tax-rates/add-to-products.d.ts +29 -0
  88. package/dist/api/routes/admin/tax-rates/add-to-products.js +122 -0
  89. package/dist/api/routes/admin/tax-rates/add-to-products.js.map +1 -0
  90. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.d.ts +29 -0
  91. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js +122 -0
  92. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js.map +1 -0
  93. package/dist/api/routes/admin/tax-rates/create-tax-rate.d.ts +35 -0
  94. package/dist/api/routes/admin/tax-rates/create-tax-rate.js +187 -0
  95. package/dist/api/routes/admin/tax-rates/create-tax-rate.js.map +1 -0
  96. package/dist/api/routes/admin/tax-rates/delete-tax-rate.d.ts +28 -0
  97. package/dist/api/routes/admin/tax-rates/delete-tax-rate.js +84 -0
  98. package/dist/api/routes/admin/tax-rates/delete-tax-rate.js.map +1 -0
  99. package/dist/api/routes/admin/tax-rates/get-tax-rate.d.ts +26 -0
  100. package/dist/api/routes/admin/tax-rates/get-tax-rate.js +106 -0
  101. package/dist/api/routes/admin/tax-rates/get-tax-rate.js.map +1 -0
  102. package/dist/api/routes/admin/tax-rates/index.d.ts +24 -0
  103. package/dist/api/routes/admin/tax-rates/index.js +89 -0
  104. package/dist/api/routes/admin/tax-rates/index.js.map +1 -0
  105. package/dist/api/routes/admin/tax-rates/list-tax-rates.d.ts +44 -0
  106. package/dist/api/routes/admin/tax-rates/list-tax-rates.js +178 -0
  107. package/dist/api/routes/admin/tax-rates/list-tax-rates.js.map +1 -0
  108. package/dist/api/routes/admin/tax-rates/remove-from-product-types.d.ts +29 -0
  109. package/dist/api/routes/admin/tax-rates/remove-from-product-types.js +122 -0
  110. package/dist/api/routes/admin/tax-rates/remove-from-product-types.js.map +1 -0
  111. package/dist/api/routes/admin/tax-rates/remove-from-products.d.ts +29 -0
  112. package/dist/api/routes/admin/tax-rates/remove-from-products.js +122 -0
  113. package/dist/api/routes/admin/tax-rates/remove-from-products.js.map +1 -0
  114. package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.d.ts +29 -0
  115. package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.js +122 -0
  116. package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.js.map +1 -0
  117. package/dist/api/routes/admin/tax-rates/update-tax-rate.d.ts +35 -0
  118. package/dist/api/routes/admin/tax-rates/update-tax-rate.js +185 -0
  119. package/dist/api/routes/admin/tax-rates/update-tax-rate.js.map +1 -0
  120. package/dist/api/routes/admin/tax-rates/utils/get-query-config.d.ts +7 -0
  121. package/dist/api/routes/admin/tax-rates/utils/get-query-config.js +91 -0
  122. package/dist/api/routes/admin/tax-rates/utils/get-query-config.js.map +1 -0
  123. package/dist/api/routes/store/carts/add-shipping-method.d.ts +1 -1
  124. package/dist/api/routes/store/carts/add-shipping-method.js.map +1 -1
  125. package/dist/api/routes/store/carts/calculate-taxes.d.ts +24 -0
  126. package/dist/api/routes/store/carts/calculate-taxes.js +153 -0
  127. package/dist/api/routes/store/carts/calculate-taxes.js.map +1 -0
  128. package/dist/api/routes/store/carts/complete-cart.js +11 -247
  129. package/dist/api/routes/store/carts/complete-cart.js.map +1 -1
  130. package/dist/api/routes/store/carts/index.js +2 -0
  131. package/dist/api/routes/store/carts/index.js.map +1 -1
  132. package/dist/api/routes/store/swaps/create-swap.js +7 -1
  133. package/dist/api/routes/store/swaps/create-swap.js.map +1 -1
  134. package/dist/db-subscribers/region.d.ts +6 -0
  135. package/dist/db-subscribers/region.js +84 -0
  136. package/dist/db-subscribers/region.js.map +1 -0
  137. package/dist/entity-subscribers/region.d.ts +6 -0
  138. package/dist/entity-subscribers/region.js +27 -0
  139. package/dist/entity-subscribers/region.js.map +1 -0
  140. package/dist/helpers/test-request.js +2 -0
  141. package/dist/helpers/test-request.js.map +1 -1
  142. package/dist/index.d.ts +59 -50
  143. package/dist/index.js +60 -101
  144. package/dist/index.js.map +1 -1
  145. package/dist/interfaces/cart-completion-strategy.d.ts +20 -0
  146. package/dist/interfaces/cart-completion-strategy.js +10 -0
  147. package/dist/interfaces/cart-completion-strategy.js.map +1 -0
  148. package/dist/interfaces/index.d.ts +3 -0
  149. package/dist/interfaces/index.js +16 -0
  150. package/dist/interfaces/index.js.map +1 -0
  151. package/dist/interfaces/tax-calculation-strategy.d.ts +16 -0
  152. package/dist/interfaces/tax-calculation-strategy.js +10 -0
  153. package/dist/interfaces/tax-calculation-strategy.js.map +1 -0
  154. package/dist/interfaces/tax-service.d.ts +51 -0
  155. package/dist/interfaces/tax-service.js +3 -0
  156. package/dist/interfaces/tax-service.js.map +1 -0
  157. package/dist/loaders/db-subscribers.d.ts +6 -0
  158. package/dist/loaders/db-subscribers.js +53 -0
  159. package/dist/loaders/db-subscribers.js.map +1 -0
  160. package/dist/loaders/index.d.ts +2 -1
  161. package/dist/loaders/index.js +17 -4
  162. package/dist/loaders/index.js.map +1 -1
  163. package/dist/loaders/models.js.map +1 -1
  164. package/dist/loaders/passport.js.map +1 -1
  165. package/dist/loaders/plugins.js +26 -0
  166. package/dist/loaders/plugins.js.map +1 -1
  167. package/dist/loaders/services.d.ts +2 -1
  168. package/dist/loaders/services.js +9 -7
  169. package/dist/loaders/services.js.map +1 -1
  170. package/dist/loaders/strategies.d.ts +12 -0
  171. package/dist/loaders/strategies.js +32 -0
  172. package/dist/loaders/strategies.js.map +1 -0
  173. package/dist/migrations/1641636508055-new_tax_system.d.ts +6 -0
  174. package/dist/migrations/1641636508055-new_tax_system.js +248 -0
  175. package/dist/migrations/1641636508055-new_tax_system.js.map +1 -0
  176. package/dist/migrations/1644943746861-customer_groups.d.ts +6 -0
  177. package/dist/migrations/1644943746861-customer_groups.js +107 -0
  178. package/dist/migrations/1644943746861-customer_groups.js.map +1 -0
  179. package/dist/models/cart.d.ts +2 -1
  180. package/dist/models/cart.js +1 -0
  181. package/dist/models/cart.js.map +1 -1
  182. package/dist/models/customer-group.d.ts +11 -0
  183. package/dist/models/customer-group.js +81 -0
  184. package/dist/models/customer-group.js.map +1 -0
  185. package/dist/models/customer.d.ts +2 -0
  186. package/dist/models/customer.js +18 -1
  187. package/dist/models/customer.js.map +1 -1
  188. package/dist/models/line-item-tax-line.d.ts +7 -0
  189. package/dist/models/line-item-tax-line.js +65 -0
  190. package/dist/models/line-item-tax-line.js.map +1 -0
  191. package/dist/models/line-item.d.ts +3 -0
  192. package/dist/models/line-item.js +9 -0
  193. package/dist/models/line-item.js.map +1 -1
  194. package/dist/models/order.d.ts +2 -1
  195. package/dist/models/order.js +3 -2
  196. package/dist/models/order.js.map +1 -1
  197. package/dist/models/product-tax-rate.d.ts +39 -0
  198. package/dist/models/product-tax-rate.js +86 -0
  199. package/dist/models/product-tax-rate.js.map +1 -0
  200. package/dist/models/product-type-tax-rate.d.ts +39 -0
  201. package/dist/models/product-type-tax-rate.js +84 -0
  202. package/dist/models/product-type-tax-rate.js.map +1 -0
  203. package/dist/models/product.d.ts +1 -1
  204. package/dist/models/product.js +2 -2
  205. package/dist/models/product.js.map +1 -1
  206. package/dist/models/region.d.ts +7 -0
  207. package/dist/models/region.js +31 -2
  208. package/dist/models/region.js.map +1 -1
  209. package/dist/models/shipping-method-tax-line.d.ts +7 -0
  210. package/dist/models/shipping-method-tax-line.js +65 -0
  211. package/dist/models/shipping-method-tax-line.js.map +1 -0
  212. package/dist/models/shipping-method.d.ts +2 -0
  213. package/dist/models/shipping-method.js +7 -0
  214. package/dist/models/shipping-method.js.map +1 -1
  215. package/dist/models/shipping-tax-rate.d.ts +39 -0
  216. package/dist/models/shipping-tax-rate.js +84 -0
  217. package/dist/models/shipping-tax-rate.js.map +1 -0
  218. package/dist/models/swap.d.ts +1 -1
  219. package/dist/models/swap.js +1 -1
  220. package/dist/models/swap.js.map +1 -1
  221. package/dist/models/tax-line.d.ts +39 -0
  222. package/dist/models/tax-line.js +79 -0
  223. package/dist/models/tax-line.js.map +1 -0
  224. package/dist/models/tax-provider.d.ts +17 -0
  225. package/dist/models/tax-provider.js +44 -0
  226. package/dist/models/tax-provider.js.map +1 -0
  227. package/dist/models/tax-rate.d.ts +58 -0
  228. package/dist/models/tax-rate.js +159 -0
  229. package/dist/models/tax-rate.js.map +1 -0
  230. package/dist/repositories/customer-group.d.ts +5 -0
  231. package/dist/repositories/customer-group.js +91 -0
  232. package/dist/repositories/customer-group.js.map +1 -0
  233. package/dist/repositories/line-item-tax-line.d.ts +4 -0
  234. package/dist/repositories/line-item-tax-line.js +38 -0
  235. package/dist/repositories/line-item-tax-line.js.map +1 -0
  236. package/dist/repositories/line-item.d.ts +12 -0
  237. package/dist/repositories/line-item.js +61 -0
  238. package/dist/repositories/line-item.js.map +1 -1
  239. package/dist/repositories/money-amount.d.ts +6 -0
  240. package/dist/repositories/money-amount.js +97 -0
  241. package/dist/repositories/money-amount.js.map +1 -1
  242. package/dist/repositories/product-tax-rate.d.ts +4 -0
  243. package/dist/repositories/product-tax-rate.js +38 -0
  244. package/dist/repositories/product-tax-rate.js.map +1 -0
  245. package/dist/repositories/product.d.ts +2 -0
  246. package/dist/repositories/product.js +32 -0
  247. package/dist/repositories/product.js.map +1 -1
  248. package/dist/repositories/shipping-method-tax-line.d.ts +4 -0
  249. package/dist/repositories/shipping-method-tax-line.js +38 -0
  250. package/dist/repositories/shipping-method-tax-line.js.map +1 -0
  251. package/dist/repositories/shipping-tax-rate.d.ts +4 -0
  252. package/dist/repositories/shipping-tax-rate.js +38 -0
  253. package/dist/repositories/shipping-tax-rate.js.map +1 -0
  254. package/dist/repositories/tax-provider.d.ts +4 -0
  255. package/dist/repositories/tax-provider.js +38 -0
  256. package/dist/repositories/tax-provider.js.map +1 -0
  257. package/dist/repositories/tax-rate.d.ts +21 -0
  258. package/dist/repositories/tax-rate.js +434 -0
  259. package/dist/repositories/tax-rate.js.map +1 -0
  260. package/dist/services/cart.d.ts +92 -114
  261. package/dist/services/cart.js +142 -144
  262. package/dist/services/cart.js.map +1 -1
  263. package/dist/services/claim.d.ts +22 -33
  264. package/dist/services/claim.js +106 -95
  265. package/dist/services/claim.js.map +1 -1
  266. package/dist/services/customer-group.d.ts +54 -0
  267. package/dist/services/customer-group.js +265 -0
  268. package/dist/services/customer-group.js.map +1 -0
  269. package/dist/services/customer.d.ts +3 -1
  270. package/dist/services/customer.js +28 -17
  271. package/dist/services/customer.js.map +1 -1
  272. package/dist/services/fulfillment.js +1 -1
  273. package/dist/services/fulfillment.js.map +1 -1
  274. package/dist/services/gift-card.js +1 -1
  275. package/dist/services/gift-card.js.map +1 -1
  276. package/dist/services/index.d.ts +4 -0
  277. package/dist/services/index.js +9 -1
  278. package/dist/services/index.js.map +1 -1
  279. package/dist/services/invite.d.ts +3 -3
  280. package/dist/services/invite.js +4 -2
  281. package/dist/services/invite.js.map +1 -1
  282. package/dist/services/line-item.d.ts +12 -1
  283. package/dist/services/line-item.js +49 -1
  284. package/dist/services/line-item.js.map +1 -1
  285. package/dist/services/order.d.ts +6 -2
  286. package/dist/services/order.js +186 -80
  287. package/dist/services/order.js.map +1 -1
  288. package/dist/services/product-collection.d.ts +2 -0
  289. package/dist/services/product-collection.js +49 -0
  290. package/dist/services/product-collection.js.map +1 -1
  291. package/dist/services/product-tax-rate.d.ts +25 -0
  292. package/dist/services/product-tax-rate.js +104 -0
  293. package/dist/services/product-tax-rate.js.map +1 -0
  294. package/dist/services/product-type.d.ts +42 -0
  295. package/dist/services/product-type.js +156 -0
  296. package/dist/services/product-type.js.map +1 -0
  297. package/dist/services/product-variant.d.ts +2 -1
  298. package/dist/services/product-variant.js +96 -85
  299. package/dist/services/product-variant.js.map +1 -1
  300. package/dist/services/product.js +3 -1
  301. package/dist/services/product.js.map +1 -1
  302. package/dist/services/region.d.ts +4 -1
  303. package/dist/services/region.js +26 -10
  304. package/dist/services/region.js.map +1 -1
  305. package/dist/services/return.d.ts +3 -1
  306. package/dist/services/return.js +37 -26
  307. package/dist/services/return.js.map +1 -1
  308. package/dist/services/shipping-option.d.ts +7 -4
  309. package/dist/services/shipping-option.js +22 -5
  310. package/dist/services/shipping-option.js.map +1 -1
  311. package/dist/services/shipping-tax-rate.d.ts +26 -0
  312. package/dist/services/shipping-tax-rate.js +105 -0
  313. package/dist/services/shipping-tax-rate.js.map +1 -0
  314. package/dist/services/swap.d.ts +5 -22
  315. package/dist/services/swap.js +308 -454
  316. package/dist/services/swap.js.map +1 -1
  317. package/dist/services/system-tax.d.ts +9 -0
  318. package/dist/services/system-tax.js +89 -0
  319. package/dist/services/system-tax.js.map +1 -0
  320. package/dist/services/tax-provider.d.ts +108 -0
  321. package/dist/services/tax-provider.js +465 -0
  322. package/dist/services/tax-provider.js.map +1 -0
  323. package/dist/services/tax-rate.d.ts +38 -0
  324. package/dist/services/tax-rate.js +599 -0
  325. package/dist/services/tax-rate.js.map +1 -0
  326. package/dist/services/totals.d.ts +194 -59
  327. package/dist/services/totals.js +581 -106
  328. package/dist/services/totals.js.map +1 -1
  329. package/dist/strategies/cart-completion.d.ts +17 -0
  330. package/dist/strategies/cart-completion.js +336 -0
  331. package/dist/strategies/cart-completion.js.map +1 -0
  332. package/dist/strategies/tax-calculation.d.ts +11 -0
  333. package/dist/strategies/tax-calculation.js +147 -0
  334. package/dist/strategies/tax-calculation.js.map +1 -0
  335. package/dist/subscribers/region.d.ts +14 -0
  336. package/dist/subscribers/region.js +65 -0
  337. package/dist/subscribers/region.js.map +1 -0
  338. package/dist/types/cart.d.ts +2 -1
  339. package/dist/types/cart.js +6 -1
  340. package/dist/types/cart.js.map +1 -1
  341. package/dist/types/common.d.ts +5 -1
  342. package/dist/types/common.js +22 -7
  343. package/dist/types/common.js.map +1 -1
  344. package/dist/types/customer-groups.d.ts +11 -0
  345. package/dist/types/customer-groups.js +43 -0
  346. package/dist/types/customer-groups.js.map +1 -0
  347. package/dist/types/orders.d.ts +2 -0
  348. package/dist/types/orders.js +6 -1
  349. package/dist/types/orders.js.map +1 -1
  350. package/dist/types/product-tax-rate.d.ts +10 -0
  351. package/dist/types/product-tax-rate.js +13 -0
  352. package/dist/types/product-tax-rate.js.map +1 -0
  353. package/dist/types/product.d.ts +6 -0
  354. package/dist/types/product.js +25 -1
  355. package/dist/types/product.js.map +1 -1
  356. package/dist/types/request.d.ts +3 -0
  357. package/dist/types/request.js +3 -0
  358. package/dist/types/request.js.map +1 -0
  359. package/dist/types/shipping-tax-rate.d.ts +10 -0
  360. package/dist/types/shipping-tax-rate.js +13 -0
  361. package/dist/types/shipping-tax-rate.js.map +1 -0
  362. package/dist/types/tax-rate.d.ts +25 -0
  363. package/dist/types/tax-rate.js +3 -0
  364. package/dist/types/tax-rate.js.map +1 -0
  365. package/dist/types/tax-service.d.ts +34 -0
  366. package/dist/types/tax-service.js +3 -0
  367. package/dist/types/tax-service.js.map +1 -0
  368. package/dist/types/totals.d.ts +42 -0
  369. package/dist/types/totals.js +3 -0
  370. package/dist/types/totals.js.map +1 -0
  371. package/dist/utils/format-registration-name.js +3 -0
  372. package/dist/utils/format-registration-name.js.map +1 -1
  373. package/package.json +5 -4
  374. package/yarn-error.log +5 -79
@@ -0,0 +1,465 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ var medusa_core_utils_1 = require("medusa-core-utils");
55
+ var medusa_interfaces_1 = require("medusa-interfaces");
56
+ var cart_1 = require("../types/cart");
57
+ var CACHE_TIME = 30; // seconds
58
+ /**
59
+ * Finds tax providers and assists in tax related operations.
60
+ */
61
+ var TaxProviderService = /** @class */ (function (_super) {
62
+ __extends(TaxProviderService, _super);
63
+ function TaxProviderService(container) {
64
+ var _this = _super.call(this) || this;
65
+ _this.container_ = container;
66
+ _this.taxLineRepo_ = container["lineItemTaxLineRepository"];
67
+ _this.smTaxLineRepo_ = container["shippingMethodTaxLineRepository"];
68
+ _this.taxRateService_ = container["taxRateService"];
69
+ _this.eventBus_ = container["eventBusService"];
70
+ _this.taxProviderRepo_ = container["taxProviderRepository"];
71
+ _this.manager_ = container["manager"];
72
+ _this.redis_ = container["redisClient"];
73
+ return _this;
74
+ }
75
+ TaxProviderService.prototype.withTransaction = function (transactionManager) {
76
+ if (!transactionManager) {
77
+ return this;
78
+ }
79
+ var cloned = new TaxProviderService(this.container_);
80
+ cloned.transactionManager_ = transactionManager;
81
+ cloned.manager_ = transactionManager;
82
+ return cloned;
83
+ };
84
+ TaxProviderService.prototype.list = function () {
85
+ return __awaiter(this, void 0, void 0, function () {
86
+ var tpRepo;
87
+ return __generator(this, function (_a) {
88
+ tpRepo = this.manager_.getCustomRepository(this.taxProviderRepo_);
89
+ return [2 /*return*/, tpRepo.find({})];
90
+ });
91
+ });
92
+ };
93
+ /**
94
+ * Retrieves the relevant tax provider for the given region.
95
+ * @param region - the region to get tax provider for.
96
+ * @return the region specific tax provider
97
+ */
98
+ TaxProviderService.prototype.retrieveProvider = function (region) {
99
+ var provider;
100
+ if (region.tax_provider_id) {
101
+ provider = this.container_["tp_".concat(region.tax_provider_id)];
102
+ }
103
+ else {
104
+ provider = this.container_["systemTaxService"];
105
+ }
106
+ if (!provider) {
107
+ throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Could not find a tax provider with id: ".concat(region.tax_provider_id));
108
+ }
109
+ return provider;
110
+ };
111
+ /**
112
+ * Persists the tax lines relevant for an order to the database.
113
+ * @param cartOrLineItems - the cart or line items to create tax lines for
114
+ * @param calculationContext - the calculation context to get tax lines by
115
+ * @return the newly created tax lines
116
+ */
117
+ TaxProviderService.prototype.createTaxLines = function (cartOrLineItems, calculationContext) {
118
+ return __awaiter(this, void 0, void 0, function () {
119
+ var taxLines;
120
+ return __generator(this, function (_a) {
121
+ switch (_a.label) {
122
+ case 0:
123
+ taxLines = [];
124
+ if (!(0, cart_1.isCart)(cartOrLineItems)) return [3 /*break*/, 2];
125
+ return [4 /*yield*/, this.getTaxLines(cartOrLineItems.items, calculationContext)];
126
+ case 1:
127
+ taxLines = _a.sent();
128
+ return [3 /*break*/, 4];
129
+ case 2: return [4 /*yield*/, this.getTaxLines(cartOrLineItems, calculationContext)];
130
+ case 3:
131
+ taxLines = _a.sent();
132
+ _a.label = 4;
133
+ case 4: return [2 /*return*/, this.manager_.save(taxLines)];
134
+ }
135
+ });
136
+ });
137
+ };
138
+ /**
139
+ * Persists the tax lines relevant for a shipping method to the database. Used
140
+ * for return shipping methods.
141
+ * @param shippingMethod - the shipping method to create tax lines for
142
+ * @param calculationContext - the calculation context to get tax lines by
143
+ * @return the newly created tax lines
144
+ */
145
+ TaxProviderService.prototype.createShippingTaxLines = function (shippingMethod, calculationContext) {
146
+ return __awaiter(this, void 0, void 0, function () {
147
+ var taxLines;
148
+ return __generator(this, function (_a) {
149
+ switch (_a.label) {
150
+ case 0: return [4 /*yield*/, this.getShippingTaxLines(shippingMethod, calculationContext)];
151
+ case 1:
152
+ taxLines = _a.sent();
153
+ return [2 /*return*/, this.manager_.save(taxLines)];
154
+ }
155
+ });
156
+ });
157
+ };
158
+ /**
159
+ * Gets the relevant tax lines for a shipping method. Note: this method
160
+ * doesn't persist the tax lines. Use createShippingTaxLines if you wish to
161
+ * persist the tax lines to the DB layer.
162
+ * @param shippingMethod - the shipping method to get tax lines for
163
+ * @param calculationContext - the calculation context to get tax lines by
164
+ * @return the computed tax lines
165
+ */
166
+ TaxProviderService.prototype.getShippingTaxLines = function (shippingMethod, calculationContext) {
167
+ return __awaiter(this, void 0, void 0, function () {
168
+ var calculationLines, taxProvider, providerLines, smTaxLineRepo;
169
+ var _a;
170
+ return __generator(this, function (_b) {
171
+ switch (_b.label) {
172
+ case 0:
173
+ _a = {
174
+ shipping_method: shippingMethod
175
+ };
176
+ return [4 /*yield*/, this.getRegionRatesForShipping(shippingMethod.shipping_option_id, calculationContext.region)];
177
+ case 1:
178
+ calculationLines = [
179
+ (_a.rates = _b.sent(),
180
+ _a)
181
+ ];
182
+ taxProvider = this.retrieveProvider(calculationContext.region);
183
+ return [4 /*yield*/, taxProvider.getTaxLines([], calculationLines, calculationContext)];
184
+ case 2:
185
+ providerLines = _b.sent();
186
+ smTaxLineRepo = this.manager_.getCustomRepository(this.smTaxLineRepo_);
187
+ // .create only creates entities nothing is persisted in DB
188
+ return [2 /*return*/, providerLines.map(function (pl) {
189
+ if (!("shipping_method_id" in pl)) {
190
+ throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.UNEXPECTED_STATE, "Expected only shipping method tax lines");
191
+ }
192
+ return smTaxLineRepo.create({
193
+ shipping_method_id: pl.shipping_method_id,
194
+ rate: pl.rate,
195
+ name: pl.name,
196
+ code: pl.code,
197
+ metadata: pl.metadata,
198
+ });
199
+ })];
200
+ }
201
+ });
202
+ });
203
+ };
204
+ /**
205
+ * Gets the relevant tax lines for an order or cart. If an order is provided
206
+ * the order's tax lines will be returned. If a cart is provided the tax lines
207
+ * will be computed from the tax rules and potentially a 3rd party tax plugin.
208
+ * Note: this method doesn't persist the tax lines. Use createTaxLines if you
209
+ * wish to persist the tax lines to the DB layer.
210
+ * @param lineItems - the cart or order to get tax lines for
211
+ * @param calculationContext - the calculation context to get tax lines by
212
+ * @return the computed tax lines
213
+ */
214
+ TaxProviderService.prototype.getTaxLines = function (lineItems, calculationContext) {
215
+ return __awaiter(this, void 0, void 0, function () {
216
+ var calculationLines, shippingCalculationLines, taxProvider, providerLines, liTaxLineRepo, smTaxLineRepo;
217
+ var _this = this;
218
+ return __generator(this, function (_a) {
219
+ switch (_a.label) {
220
+ case 0: return [4 /*yield*/, Promise.all(lineItems.map(function (l) { return __awaiter(_this, void 0, void 0, function () {
221
+ var _a;
222
+ return __generator(this, function (_b) {
223
+ switch (_b.label) {
224
+ case 0:
225
+ if (l.is_return) {
226
+ return [2 /*return*/, null];
227
+ }
228
+ if (!(l.variant && l.variant.product_id)) return [3 /*break*/, 2];
229
+ _a = {
230
+ item: l
231
+ };
232
+ return [4 /*yield*/, this.getRegionRatesForProduct(l.variant.product_id, calculationContext.region)];
233
+ case 1: return [2 /*return*/, (_a.rates = _b.sent(),
234
+ _a)];
235
+ case 2:
236
+ /*
237
+ * If the line item is custom and therefore not associated with a
238
+ * product we assume no taxes - we should consider adding rate overrides
239
+ * to custom lines at some point
240
+ */
241
+ return [2 /*return*/, {
242
+ item: l,
243
+ rates: [],
244
+ }];
245
+ }
246
+ });
247
+ }); }))];
248
+ case 1:
249
+ calculationLines = _a.sent();
250
+ return [4 /*yield*/, Promise.all(calculationContext.shipping_methods.map(function (sm) { return __awaiter(_this, void 0, void 0, function () {
251
+ var _a;
252
+ return __generator(this, function (_b) {
253
+ switch (_b.label) {
254
+ case 0:
255
+ _a = {
256
+ shipping_method: sm
257
+ };
258
+ return [4 /*yield*/, this.getRegionRatesForShipping(sm.shipping_option_id, calculationContext.region)];
259
+ case 1: return [2 /*return*/, (_a.rates = _b.sent(),
260
+ _a)];
261
+ }
262
+ });
263
+ }); }))];
264
+ case 2:
265
+ shippingCalculationLines = _a.sent();
266
+ taxProvider = this.retrieveProvider(calculationContext.region);
267
+ return [4 /*yield*/, taxProvider.getTaxLines(calculationLines.filter(function (v) { return v !== null; }), shippingCalculationLines, calculationContext)];
268
+ case 3:
269
+ providerLines = _a.sent();
270
+ liTaxLineRepo = this.manager_.getCustomRepository(this.taxLineRepo_);
271
+ smTaxLineRepo = this.manager_.getCustomRepository(this.smTaxLineRepo_);
272
+ // .create only creates entities nothing is persisted in DB
273
+ return [2 /*return*/, providerLines.map(function (pl) {
274
+ if ("shipping_method_id" in pl) {
275
+ return smTaxLineRepo.create({
276
+ shipping_method_id: pl.shipping_method_id,
277
+ rate: pl.rate,
278
+ name: pl.name,
279
+ code: pl.code,
280
+ metadata: pl.metadata,
281
+ });
282
+ }
283
+ if (!("item_id" in pl)) {
284
+ throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.UNEXPECTED_STATE, "Tax Provider returned invalid tax lines");
285
+ }
286
+ return liTaxLineRepo.create({
287
+ item_id: pl.item_id,
288
+ rate: pl.rate,
289
+ name: pl.name,
290
+ code: pl.code,
291
+ metadata: pl.metadata,
292
+ });
293
+ })];
294
+ }
295
+ });
296
+ });
297
+ };
298
+ /**
299
+ * Gets the tax rates configured for a shipping option. The rates are cached
300
+ * between calls.
301
+ * @param optionId - the option id of the shipping method.
302
+ * @param region - the region to get configured rates for.
303
+ * @return the tax rates configured for the shipping option.
304
+ */
305
+ TaxProviderService.prototype.getRegionRatesForShipping = function (optionId, region) {
306
+ return __awaiter(this, void 0, void 0, function () {
307
+ var cacheHit, toReturn, optionRates;
308
+ return __generator(this, function (_a) {
309
+ switch (_a.label) {
310
+ case 0: return [4 /*yield*/, this.getCacheEntry(optionId, region.id)];
311
+ case 1:
312
+ cacheHit = _a.sent();
313
+ if (cacheHit) {
314
+ return [2 /*return*/, cacheHit];
315
+ }
316
+ toReturn = [];
317
+ return [4 /*yield*/, this.taxRateService_.listByShippingOption(optionId, { region_id: region.id })];
318
+ case 2:
319
+ optionRates = _a.sent();
320
+ if (optionRates.length > 0) {
321
+ toReturn = optionRates.map(function (pr) {
322
+ return {
323
+ rate: pr.rate,
324
+ name: pr.name,
325
+ code: pr.code,
326
+ };
327
+ });
328
+ }
329
+ if (toReturn.length === 0) {
330
+ toReturn = [
331
+ {
332
+ rate: region.tax_rate,
333
+ name: "default",
334
+ code: "default",
335
+ },
336
+ ];
337
+ }
338
+ return [4 /*yield*/, this.setCache(optionId, region.id, toReturn)];
339
+ case 3:
340
+ _a.sent();
341
+ return [2 /*return*/, toReturn];
342
+ }
343
+ });
344
+ });
345
+ };
346
+ /**
347
+ * Gets the tax rates configured for a product. The rates are cached between
348
+ * calls.
349
+ * @param productId - the product id to get rates for
350
+ * @param region - the region to get configured rates for.
351
+ * @return the tax rates configured for the shipping option.
352
+ */
353
+ TaxProviderService.prototype.getRegionRatesForProduct = function (productId, region) {
354
+ return __awaiter(this, void 0, void 0, function () {
355
+ var cacheHit, toReturn, productRates;
356
+ return __generator(this, function (_a) {
357
+ switch (_a.label) {
358
+ case 0: return [4 /*yield*/, this.getCacheEntry(productId, region.id)];
359
+ case 1:
360
+ cacheHit = _a.sent();
361
+ if (cacheHit) {
362
+ return [2 /*return*/, cacheHit];
363
+ }
364
+ toReturn = [];
365
+ return [4 /*yield*/, this.taxRateService_.listByProduct(productId, {
366
+ region_id: region.id,
367
+ })];
368
+ case 2:
369
+ productRates = _a.sent();
370
+ if (productRates.length > 0) {
371
+ toReturn = productRates.map(function (pr) {
372
+ return {
373
+ rate: pr.rate,
374
+ name: pr.name,
375
+ code: pr.code,
376
+ };
377
+ });
378
+ }
379
+ if (toReturn.length === 0) {
380
+ toReturn = [
381
+ {
382
+ rate: region.tax_rate,
383
+ name: "default",
384
+ code: "default",
385
+ },
386
+ ];
387
+ }
388
+ return [4 /*yield*/, this.setCache(productId, region.id, toReturn)];
389
+ case 3:
390
+ _a.sent();
391
+ return [2 /*return*/, toReturn];
392
+ }
393
+ });
394
+ });
395
+ };
396
+ /**
397
+ * The cache key to get cache hits by.
398
+ * @param productId - the product id to cache
399
+ * @param regionId - the region id to cache
400
+ * @return the cache key to use for the id set
401
+ */
402
+ TaxProviderService.prototype.getCacheKey = function (productId, regionId) {
403
+ return "txrtcache:".concat(productId, ":").concat(regionId);
404
+ };
405
+ /**
406
+ * Sets the cache results for a set of ids
407
+ * @param productId - the product id to cache
408
+ * @param regionId - the region id to cache
409
+ * @param value - tax rates to cache
410
+ * @return promise that resolves after the cache has been set
411
+ */
412
+ TaxProviderService.prototype.setCache = function (productId, regionId, value) {
413
+ return __awaiter(this, void 0, void 0, function () {
414
+ var cacheKey;
415
+ return __generator(this, function (_a) {
416
+ switch (_a.label) {
417
+ case 0:
418
+ cacheKey = this.getCacheKey(productId, regionId);
419
+ return [4 /*yield*/, this.redis_.set(cacheKey, JSON.stringify(value), "EX", CACHE_TIME)];
420
+ case 1: return [2 /*return*/, _a.sent()];
421
+ }
422
+ });
423
+ });
424
+ };
425
+ /**
426
+ * Gets the cache results for a set of ids
427
+ * @param productId - the product id to cache
428
+ * @param regionId - the region id to cache
429
+ * @return the cached result or null
430
+ */
431
+ TaxProviderService.prototype.getCacheEntry = function (productId, regionId) {
432
+ return __awaiter(this, void 0, void 0, function () {
433
+ var cacheKey, cacheHit, parsedResults, _1;
434
+ return __generator(this, function (_a) {
435
+ switch (_a.label) {
436
+ case 0:
437
+ cacheKey = this.getCacheKey(productId, regionId);
438
+ _a.label = 1;
439
+ case 1:
440
+ _a.trys.push([1, 3, , 5]);
441
+ return [4 /*yield*/, this.redis_.get(cacheKey)];
442
+ case 2:
443
+ cacheHit = _a.sent();
444
+ if (cacheHit) {
445
+ parsedResults = JSON.parse(cacheHit);
446
+ return [2 /*return*/, parsedResults];
447
+ }
448
+ return [3 /*break*/, 5];
449
+ case 3:
450
+ _1 = _a.sent();
451
+ // noop - cache parse failed
452
+ return [4 /*yield*/, this.redis_.del(cacheKey)];
453
+ case 4:
454
+ // noop - cache parse failed
455
+ _a.sent();
456
+ return [3 /*break*/, 5];
457
+ case 5: return [2 /*return*/, null];
458
+ }
459
+ });
460
+ });
461
+ };
462
+ return TaxProviderService;
463
+ }(medusa_interfaces_1.BaseService));
464
+ exports.default = TaxProviderService;
465
+ //# sourceMappingURL=tax-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tax-provider.js","sourceRoot":"","sources":["../../src/services/tax-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAE/C,uDAA+C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D,CAAC,AA9YD,CAAiC,+BAAW,GA8Y3C;AAED,kBAAe,kBAAkB,CAAA"}
@@ -0,0 +1,38 @@
1
+ import { BaseService } from "medusa-interfaces";
2
+ import { EntityManager } from "typeorm";
3
+ import { TaxRate } from "../models/tax-rate";
4
+ import { ShippingTaxRate } from "../models/shipping-tax-rate";
5
+ import { ProductTaxRate } from "../models/product-tax-rate";
6
+ import { ProductTypeTaxRate } from "../models/product-type-tax-rate";
7
+ import { FindConfig } from "../types/common";
8
+ import { CreateTaxRateInput, UpdateTaxRateInput, TaxRateListByConfig, FilterableTaxRateProps } from "../types/tax-rate";
9
+ declare class TaxRateService extends BaseService {
10
+ private manager_;
11
+ private productService_;
12
+ private productTypeService_;
13
+ private shippingOptionService_;
14
+ private taxRateRepository_;
15
+ constructor({ manager, productService, productTypeService, shippingOptionService, taxRateRepository, }: {
16
+ manager: any;
17
+ productService: any;
18
+ productTypeService: any;
19
+ shippingOptionService: any;
20
+ taxRateRepository: any;
21
+ });
22
+ withTransaction(transactionManager: EntityManager): TaxRateService;
23
+ list(selector: FilterableTaxRateProps, config?: FindConfig<TaxRate>): Promise<TaxRate[]>;
24
+ listAndCount(selector: FilterableTaxRateProps, config?: FindConfig<TaxRate>): Promise<[TaxRate[], number]>;
25
+ retrieve(id: string, config?: FindConfig<TaxRate>): Promise<TaxRate>;
26
+ create(data: CreateTaxRateInput): Promise<TaxRate>;
27
+ update(id: string, data: UpdateTaxRateInput): Promise<TaxRate>;
28
+ delete(id: string | string[]): Promise<void>;
29
+ removeFromProduct(id: string, productIds: string | string[]): Promise<void>;
30
+ removeFromProductType(id: string, typeIds: string | string[]): Promise<void>;
31
+ removeFromShippingOption(id: string, optionIds: string | string[]): Promise<void>;
32
+ addToProduct(id: string, productIds: string | string[], replace?: boolean): Promise<ProductTaxRate | ProductTaxRate[]>;
33
+ addToProductType(id: string, productTypeIds: string | string[], replace?: boolean): Promise<ProductTypeTaxRate[]>;
34
+ addToShippingOption(id: string, optionIds: string | string[], replace?: boolean): Promise<ShippingTaxRate>;
35
+ listByProduct(productId: string, config: TaxRateListByConfig): Promise<TaxRate[]>;
36
+ listByShippingOption(shippingOptionId: string, config: TaxRateListByConfig): Promise<TaxRate[]>;
37
+ }
38
+ export default TaxRateService;