@medusajs/medusa 1.1.63 → 1.2.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 (293) hide show
  1. package/CHANGELOG.md +31 -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/{product-tags/update-collection.js → collections/add-products.js} +25 -45
  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/{product-tags/create-collection.js → collections/remove-products.js} +35 -49
  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/{product-tags/delete-collection.js → customer-groups/delete-customer-group.js} +25 -25
  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-tags/list-collections.js → product-types/list-product-types.js} +72 -76
  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/{product-tags/get-collection.js → store/list-tax-providers.js} +21 -22
  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 +1 -1
  85. package/dist/api/routes/admin/tax-rates/add-to-product-types.js +4 -59
  86. package/dist/api/routes/admin/tax-rates/add-to-product-types.js.map +1 -1
  87. package/dist/api/routes/admin/tax-rates/add-to-products.d.ts +1 -1
  88. package/dist/api/routes/admin/tax-rates/add-to-products.js +4 -55
  89. package/dist/api/routes/admin/tax-rates/add-to-products.js.map +1 -1
  90. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.d.ts +1 -1
  91. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js +4 -59
  92. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js.map +1 -1
  93. package/dist/api/routes/admin/tax-rates/create-tax-rate.js +14 -113
  94. package/dist/api/routes/admin/tax-rates/create-tax-rate.js.map +1 -1
  95. package/dist/api/routes/admin/tax-rates/index.d.ts +3 -0
  96. package/dist/api/routes/admin/tax-rates/index.js +18 -3
  97. package/dist/api/routes/admin/tax-rates/index.js.map +1 -1
  98. package/dist/api/routes/admin/tax-rates/list-tax-rates.d.ts +2 -2
  99. package/dist/api/routes/admin/tax-rates/list-tax-rates.js.map +1 -1
  100. package/dist/api/routes/admin/tax-rates/remove-from-product-types.d.ts +29 -0
  101. package/dist/api/routes/admin/tax-rates/remove-from-product-types.js +122 -0
  102. package/dist/api/routes/admin/tax-rates/remove-from-product-types.js.map +1 -0
  103. package/dist/api/routes/admin/tax-rates/remove-from-products.d.ts +29 -0
  104. package/dist/api/routes/admin/tax-rates/remove-from-products.js +122 -0
  105. package/dist/api/routes/admin/tax-rates/remove-from-products.js.map +1 -0
  106. package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.d.ts +29 -0
  107. package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.js +122 -0
  108. package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.js.map +1 -0
  109. package/dist/api/routes/admin/tax-rates/update-tax-rate.js +15 -116
  110. package/dist/api/routes/admin/tax-rates/update-tax-rate.js.map +1 -1
  111. package/dist/api/routes/store/carts/add-shipping-method.d.ts +1 -1
  112. package/dist/api/routes/store/carts/add-shipping-method.js.map +1 -1
  113. package/dist/api/routes/store/carts/complete-cart.js +11 -247
  114. package/dist/api/routes/store/carts/complete-cart.js.map +1 -1
  115. package/dist/api/routes/store/carts/index.js +2 -0
  116. package/dist/api/routes/store/carts/index.js.map +1 -1
  117. package/dist/api/routes/store/swaps/create-swap.js +7 -1
  118. package/dist/api/routes/store/swaps/create-swap.js.map +1 -1
  119. package/dist/db-subscribers/region.d.ts +6 -0
  120. package/dist/db-subscribers/region.js +84 -0
  121. package/dist/db-subscribers/region.js.map +1 -0
  122. package/dist/entity-subscribers/region.d.ts +6 -0
  123. package/dist/entity-subscribers/region.js +27 -0
  124. package/dist/entity-subscribers/region.js.map +1 -0
  125. package/dist/helpers/test-request.js +2 -0
  126. package/dist/helpers/test-request.js.map +1 -1
  127. package/dist/index.d.ts +59 -50
  128. package/dist/index.js +60 -101
  129. package/dist/index.js.map +1 -1
  130. package/dist/loaders/db-subscribers.d.ts +6 -0
  131. package/dist/loaders/db-subscribers.js +53 -0
  132. package/dist/loaders/db-subscribers.js.map +1 -0
  133. package/dist/loaders/index.d.ts +2 -1
  134. package/dist/loaders/index.js +17 -4
  135. package/dist/loaders/index.js.map +1 -1
  136. package/dist/loaders/models.js.map +1 -1
  137. package/dist/loaders/passport.js.map +1 -1
  138. package/dist/loaders/plugins.js +26 -0
  139. package/dist/loaders/plugins.js.map +1 -1
  140. package/dist/loaders/services.d.ts +2 -1
  141. package/dist/loaders/services.js +9 -7
  142. package/dist/loaders/services.js.map +1 -1
  143. package/dist/migrations/1641636508055-new_tax_system.js +9 -9
  144. package/dist/migrations/1641636508055-new_tax_system.js.map +1 -1
  145. package/dist/migrations/1644943746861-customer_groups.d.ts +6 -0
  146. package/dist/migrations/1644943746861-customer_groups.js +107 -0
  147. package/dist/migrations/1644943746861-customer_groups.js.map +1 -0
  148. package/dist/models/cart.d.ts +2 -1
  149. package/dist/models/cart.js +1 -0
  150. package/dist/models/cart.js.map +1 -1
  151. package/dist/models/customer-group.d.ts +11 -0
  152. package/dist/models/customer-group.js +81 -0
  153. package/dist/models/customer-group.js.map +1 -0
  154. package/dist/models/customer.d.ts +2 -0
  155. package/dist/models/customer.js +18 -1
  156. package/dist/models/customer.js.map +1 -1
  157. package/dist/models/line-item.d.ts +3 -0
  158. package/dist/models/line-item.js +9 -0
  159. package/dist/models/line-item.js.map +1 -1
  160. package/dist/models/order.d.ts +2 -1
  161. package/dist/models/order.js +3 -2
  162. package/dist/models/order.js.map +1 -1
  163. package/dist/models/product-tax-rate.d.ts +0 -1
  164. package/dist/models/product-tax-rate.js +5 -7
  165. package/dist/models/product-tax-rate.js.map +1 -1
  166. package/dist/models/product-type-tax-rate.d.ts +0 -1
  167. package/dist/models/product-type-tax-rate.js +2 -6
  168. package/dist/models/product-type-tax-rate.js.map +1 -1
  169. package/dist/models/product.d.ts +1 -1
  170. package/dist/models/product.js +2 -2
  171. package/dist/models/product.js.map +1 -1
  172. package/dist/models/region.d.ts +7 -0
  173. package/dist/models/region.js +31 -2
  174. package/dist/models/region.js.map +1 -1
  175. package/dist/models/shipping-method.d.ts +2 -0
  176. package/dist/models/shipping-method.js +7 -0
  177. package/dist/models/shipping-method.js.map +1 -1
  178. package/dist/models/shipping-tax-rate.d.ts +0 -1
  179. package/dist/models/shipping-tax-rate.js +2 -6
  180. package/dist/models/shipping-tax-rate.js.map +1 -1
  181. package/dist/models/swap.d.ts +1 -1
  182. package/dist/models/swap.js +1 -1
  183. package/dist/models/swap.js.map +1 -1
  184. package/dist/repositories/customer-group.d.ts +5 -0
  185. package/dist/repositories/customer-group.js +91 -0
  186. package/dist/repositories/customer-group.js.map +1 -0
  187. package/dist/repositories/line-item.d.ts +12 -0
  188. package/dist/repositories/line-item.js +61 -0
  189. package/dist/repositories/line-item.js.map +1 -1
  190. package/dist/repositories/money-amount.d.ts +6 -0
  191. package/dist/repositories/money-amount.js +97 -0
  192. package/dist/repositories/money-amount.js.map +1 -1
  193. package/dist/repositories/product.d.ts +2 -0
  194. package/dist/repositories/product.js +32 -0
  195. package/dist/repositories/product.js.map +1 -1
  196. package/dist/repositories/tax-provider.d.ts +4 -0
  197. package/dist/repositories/tax-provider.js +38 -0
  198. package/dist/repositories/tax-provider.js.map +1 -0
  199. package/dist/repositories/tax-rate.d.ts +7 -4
  200. package/dist/repositories/tax-rate.js +96 -21
  201. package/dist/repositories/tax-rate.js.map +1 -1
  202. package/dist/services/cart.d.ts +92 -114
  203. package/dist/services/cart.js +142 -144
  204. package/dist/services/cart.js.map +1 -1
  205. package/dist/services/claim.d.ts +22 -33
  206. package/dist/services/claim.js +106 -95
  207. package/dist/services/claim.js.map +1 -1
  208. package/dist/services/customer-group.d.ts +54 -0
  209. package/dist/services/customer-group.js +265 -0
  210. package/dist/services/customer-group.js.map +1 -0
  211. package/dist/services/customer.d.ts +3 -1
  212. package/dist/services/customer.js +28 -17
  213. package/dist/services/customer.js.map +1 -1
  214. package/dist/services/fulfillment.js +1 -1
  215. package/dist/services/fulfillment.js.map +1 -1
  216. package/dist/services/gift-card.js +1 -1
  217. package/dist/services/gift-card.js.map +1 -1
  218. package/dist/services/index.d.ts +4 -0
  219. package/dist/services/index.js +9 -1
  220. package/dist/services/index.js.map +1 -1
  221. package/dist/services/invite.d.ts +3 -3
  222. package/dist/services/invite.js +4 -2
  223. package/dist/services/invite.js.map +1 -1
  224. package/dist/services/line-item.d.ts +12 -1
  225. package/dist/services/line-item.js +49 -1
  226. package/dist/services/line-item.js.map +1 -1
  227. package/dist/services/order.d.ts +6 -2
  228. package/dist/services/order.js +186 -80
  229. package/dist/services/order.js.map +1 -1
  230. package/dist/services/product-collection.d.ts +2 -0
  231. package/dist/services/product-collection.js +49 -0
  232. package/dist/services/product-collection.js.map +1 -1
  233. package/dist/services/product-type.d.ts +15 -0
  234. package/dist/services/product-type.js +44 -0
  235. package/dist/services/product-type.js.map +1 -1
  236. package/dist/services/product-variant.d.ts +2 -1
  237. package/dist/services/product-variant.js +96 -85
  238. package/dist/services/product-variant.js.map +1 -1
  239. package/dist/services/product.js +3 -1
  240. package/dist/services/product.js.map +1 -1
  241. package/dist/services/region.d.ts +4 -1
  242. package/dist/services/region.js +25 -10
  243. package/dist/services/region.js.map +1 -1
  244. package/dist/services/return.d.ts +3 -1
  245. package/dist/services/return.js +37 -26
  246. package/dist/services/return.js.map +1 -1
  247. package/dist/services/shipping-option.d.ts +7 -4
  248. package/dist/services/shipping-option.js +22 -5
  249. package/dist/services/shipping-option.js.map +1 -1
  250. package/dist/services/swap.d.ts +5 -22
  251. package/dist/services/swap.js +308 -454
  252. package/dist/services/swap.js.map +1 -1
  253. package/dist/services/tax-provider.d.ts +3 -0
  254. package/dist/services/tax-provider.js +10 -0
  255. package/dist/services/tax-provider.js.map +1 -1
  256. package/dist/services/tax-rate.d.ts +13 -6
  257. package/dist/services/tax-rate.js +235 -41
  258. package/dist/services/tax-rate.js.map +1 -1
  259. package/dist/services/totals.d.ts +194 -59
  260. package/dist/services/totals.js +581 -106
  261. package/dist/services/totals.js.map +1 -1
  262. package/dist/subscribers/region.d.ts +14 -0
  263. package/dist/subscribers/region.js +65 -0
  264. package/dist/subscribers/region.js.map +1 -0
  265. package/dist/types/cart.d.ts +2 -1
  266. package/dist/types/cart.js +6 -1
  267. package/dist/types/cart.js.map +1 -1
  268. package/dist/types/common.d.ts +5 -1
  269. package/dist/types/common.js +22 -7
  270. package/dist/types/common.js.map +1 -1
  271. package/dist/types/customer-groups.d.ts +11 -0
  272. package/dist/types/customer-groups.js +43 -0
  273. package/dist/types/customer-groups.js.map +1 -0
  274. package/dist/types/orders.d.ts +2 -0
  275. package/dist/types/orders.js +6 -1
  276. package/dist/types/orders.js.map +1 -1
  277. package/dist/types/product.d.ts +6 -0
  278. package/dist/types/product.js +25 -1
  279. package/dist/types/product.js.map +1 -1
  280. package/dist/utils/format-registration-name.js +3 -0
  281. package/dist/utils/format-registration-name.js.map +1 -1
  282. package/package.json +5 -4
  283. package/yarn-error.log +5 -79
  284. package/dist/api/routes/admin/product-tags/create-collection.d.ts +0 -41
  285. package/dist/api/routes/admin/product-tags/create-collection.js.map +0 -1
  286. package/dist/api/routes/admin/product-tags/delete-collection.d.ts +0 -28
  287. package/dist/api/routes/admin/product-tags/delete-collection.js.map +0 -1
  288. package/dist/api/routes/admin/product-tags/get-collection.d.ts +0 -22
  289. package/dist/api/routes/admin/product-tags/get-collection.js.map +0 -1
  290. package/dist/api/routes/admin/product-tags/list-collections.d.ts +0 -40
  291. package/dist/api/routes/admin/product-tags/list-collections.js.map +0 -1
  292. package/dist/api/routes/admin/product-tags/update-collection.d.ts +0 -41
  293. package/dist/api/routes/admin/product-tags/update-collection.js.map +0 -1
@@ -110,44 +110,27 @@ var medusa_interfaces_1 = require("medusa-interfaces");
110
110
  var CartService = /** @class */ (function (_super) {
111
111
  __extends(CartService, _super);
112
112
  function CartService(_a) {
113
- var manager = _a.manager, cartRepository = _a.cartRepository, shippingMethodRepository = _a.shippingMethodRepository, eventBusService = _a.eventBusService, paymentProviderService = _a.paymentProviderService, productService = _a.productService, productVariantService = _a.productVariantService, regionService = _a.regionService, lineItemService = _a.lineItemService, shippingOptionService = _a.shippingOptionService, customerService = _a.customerService, discountService = _a.discountService, giftCardService = _a.giftCardService, totalsService = _a.totalsService, addressRepository = _a.addressRepository, paymentSessionRepository = _a.paymentSessionRepository, inventoryService = _a.inventoryService, customShippingOptionService = _a.customShippingOptionService;
113
+ var manager = _a.manager, cartRepository = _a.cartRepository, shippingMethodRepository = _a.shippingMethodRepository, eventBusService = _a.eventBusService, paymentProviderService = _a.paymentProviderService, productService = _a.productService, productVariantService = _a.productVariantService, taxProviderService = _a.taxProviderService, regionService = _a.regionService, lineItemService = _a.lineItemService, shippingOptionService = _a.shippingOptionService, customerService = _a.customerService, discountService = _a.discountService, giftCardService = _a.giftCardService, totalsService = _a.totalsService, addressRepository = _a.addressRepository, paymentSessionRepository = _a.paymentSessionRepository, inventoryService = _a.inventoryService, customShippingOptionService = _a.customShippingOptionService;
114
114
  var _this = _super.call(this) || this;
115
- /** @private @const {EntityManager} */
116
115
  _this.manager_ = manager;
117
- /** @private @const {ShippingMethodRepository} */
118
116
  _this.shippingMethodRepository_ = shippingMethodRepository;
119
- /** @private @const {CartRepository} */
120
117
  _this.cartRepository_ = cartRepository;
121
- /** @private @const {EventBus} */
122
118
  _this.eventBus_ = eventBusService;
123
- /** @private @const {ProductVariantService} */
124
119
  _this.productVariantService_ = productVariantService;
125
- /** @private @const {ProductService} */
126
120
  _this.productService_ = productService;
127
- /** @private @const {RegionService} */
128
121
  _this.regionService_ = regionService;
129
- /** @private @const {LineItemService} */
130
122
  _this.lineItemService_ = lineItemService;
131
- /** @private @const {PaymentProviderService} */
132
123
  _this.paymentProviderService_ = paymentProviderService;
133
- /** @private @const {CustomerService} */
134
124
  _this.customerService_ = customerService;
135
- /** @private @const {ShippingOptionService} */
136
125
  _this.shippingOptionService_ = shippingOptionService;
137
- /** @private @const {DiscountService} */
138
126
  _this.discountService_ = discountService;
139
- /** @private @const {GiftCardService} */
140
127
  _this.giftCardService_ = giftCardService;
141
- /** @private @const {TotalsService} */
142
128
  _this.totalsService_ = totalsService;
143
- /** @private @const {AddressRepository} */
144
129
  _this.addressRepository_ = addressRepository;
145
- /** @private @const {PaymentSessionRepository} */
146
130
  _this.paymentSessionRepository_ = paymentSessionRepository;
147
- /** @private @const {InventoryService} */
148
131
  _this.inventoryService_ = inventoryService;
149
- /** @private @const {CustomShippingOptionService} */
150
132
  _this.customShippingOptionService_ = customShippingOptionService;
133
+ _this.taxProviderService_ = taxProviderService;
151
134
  return _this;
152
135
  }
153
136
  CartService.prototype.withTransaction = function (transactionManager) {
@@ -156,6 +139,7 @@ var CartService = /** @class */ (function (_super) {
156
139
  }
157
140
  var cloned = new CartService({
158
141
  manager: transactionManager,
142
+ taxProviderService: this.taxProviderService_,
159
143
  cartRepository: this.cartRepository_,
160
144
  eventBusService: this.eventBus_,
161
145
  paymentProviderService: this.paymentProviderService_,
@@ -177,23 +161,6 @@ var CartService = /** @class */ (function (_super) {
177
161
  cloned.transactionManager_ = transactionManager;
178
162
  return cloned;
179
163
  };
180
- /**
181
- * Used to validate cart ids. Throws an error if the cast fails
182
- * @param {string} rawId - the raw cart id to validate.
183
- * @return {string} the validated id
184
- */
185
- /**
186
- * Contents of a line item
187
- * @typedef {(object | array)} LineItemContent
188
- * @property {number} unit_price - the price of the content
189
- * @property {object} variant - the product variant of the content
190
- * @property {object} product - the product of the content
191
- * @property {number} quantity - the quantity of the content
192
- */
193
- /**
194
- * A collection of contents grouped in the same line item
195
- * @typedef {LineItemContent[]} LineItemContentArray
196
- */
197
164
  CartService.prototype.transformQueryForTotals_ = function (config) {
198
165
  var select = config.select, relations = config.relations;
199
166
  if (!select) {
@@ -217,6 +184,7 @@ var CartService = /** @class */ (function (_super) {
217
184
  if (totalsToSelect.length > 0) {
218
185
  var relationSet = new Set(relations);
219
186
  relationSet.add("items");
187
+ relationSet.add("items.tax_lines");
220
188
  relationSet.add("gift_cards");
221
189
  relationSet.add("discounts");
222
190
  relationSet.add("discounts.rule");
@@ -226,6 +194,7 @@ var CartService = /** @class */ (function (_super) {
226
194
  // relationSet.add("discounts.parent_discount.regions")
227
195
  relationSet.add("shipping_methods");
228
196
  relationSet.add("region");
197
+ relationSet.add("region.tax_rates");
229
198
  relations = Array.from(relationSet.values());
230
199
  select = select.filter(function (v) { return !totalFields.includes(v); });
231
200
  }
@@ -235,7 +204,8 @@ var CartService = /** @class */ (function (_super) {
235
204
  totalsToSelect: totalsToSelect,
236
205
  };
237
206
  };
238
- CartService.prototype.decorateTotals_ = function (cart, totalsToSelect) {
207
+ CartService.prototype.decorateTotals_ = function (cart, totalsToSelect, options) {
208
+ if (options === void 0) { options = { force_taxes: false }; }
239
209
  return __awaiter(this, void 0, void 0, function () {
240
210
  var totals, totalsToSelect_1, totalsToSelect_1_1, key, _a, _b, _c, e_1_1;
241
211
  var e_1, _d;
@@ -263,7 +233,9 @@ var CartService = /** @class */ (function (_super) {
263
233
  return [3 /*break*/, 11];
264
234
  case 3:
265
235
  _b = totals;
266
- return [4 /*yield*/, this.totalsService_.getTotal(cart)];
236
+ return [4 /*yield*/, this.totalsService_.getTotal(cart, {
237
+ force_taxes: options.force_taxes,
238
+ })];
267
239
  case 4:
268
240
  _b.total = _e.sent();
269
241
  return [3 /*break*/, 12];
@@ -278,7 +250,7 @@ var CartService = /** @class */ (function (_super) {
278
250
  return [3 /*break*/, 12];
279
251
  case 7:
280
252
  _c = totals;
281
- return [4 /*yield*/, this.totalsService_.getTaxTotal(cart)];
253
+ return [4 /*yield*/, this.totalsService_.getTaxTotal(cart, options.force_taxes)];
282
254
  case 8:
283
255
  _c.tax_total = _e.sent();
284
256
  return [3 /*break*/, 12];
@@ -309,9 +281,9 @@ var CartService = /** @class */ (function (_super) {
309
281
  });
310
282
  };
311
283
  /**
312
- * @param {Object} selector - the query object for find
313
- * @param {Object} config - config object
314
- * @return {Promise} the result of the find operation
284
+ * @param selector - the query object for find
285
+ * @param config - config object
286
+ * @return the result of the find operation
315
287
  */
316
288
  CartService.prototype.list = function (selector, config) {
317
289
  if (config === void 0) { config = {}; }
@@ -330,12 +302,14 @@ var CartService = /** @class */ (function (_super) {
330
302
  };
331
303
  /**
332
304
  * Gets a cart by id.
333
- * @param {string} cartId - the id of the cart to get.
334
- * @param {Object} options - the options to get a cart
335
- * @return {Promise<Cart>} the cart document.
305
+ * @param cartId - the id of the cart to get.
306
+ * @param options - the options to get a cart
307
+ * @param totalsConfig - configuration for retrieval of totals
308
+ * @return the cart document.
336
309
  */
337
- CartService.prototype.retrieve = function (cartId, options) {
310
+ CartService.prototype.retrieve = function (cartId, options, totalsConfig) {
338
311
  if (options === void 0) { options = {}; }
312
+ if (totalsConfig === void 0) { totalsConfig = {}; }
339
313
  return __awaiter(this, void 0, void 0, function () {
340
314
  var cartRepo, validatedId, _a, select, relations, totalsToSelect, query, rels, raw;
341
315
  return __generator(this, function (_b) {
@@ -362,7 +336,7 @@ var CartService = /** @class */ (function (_super) {
362
336
  if (!raw) {
363
337
  throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Cart with ".concat(cartId, " was not found"));
364
338
  }
365
- return [4 /*yield*/, this.decorateTotals_(raw, totalsToSelect)];
339
+ return [4 /*yield*/, this.decorateTotals_(raw, totalsToSelect, totalsConfig)];
366
340
  case 2: return [2 /*return*/, _b.sent()];
367
341
  }
368
342
  });
@@ -370,8 +344,8 @@ var CartService = /** @class */ (function (_super) {
370
344
  };
371
345
  /**
372
346
  * Creates a cart.
373
- * @param {Object} data - the data to create the cart with
374
- * @return {Promise} the result of the create operation
347
+ * @param data - the data to create the cart with
348
+ * @return the result of the create operation
375
349
  */
376
350
  CartService.prototype.create = function (data) {
377
351
  return __awaiter(this, void 0, void 0, function () {
@@ -445,7 +419,7 @@ var CartService = /** @class */ (function (_super) {
445
419
  try {
446
420
  for (remainingFields_1 = __values(remainingFields), remainingFields_1_1 = remainingFields_1.next(); !remainingFields_1_1.done; remainingFields_1_1 = remainingFields_1.next()) {
447
421
  k = remainingFields_1_1.value;
448
- if (typeof data[k] !== "undefined") {
422
+ if (typeof data[k] !== "undefined" && k !== "object") {
449
423
  toCreate[k] = data[k];
450
424
  }
451
425
  }
@@ -477,9 +451,9 @@ var CartService = /** @class */ (function (_super) {
477
451
  };
478
452
  /**
479
453
  * Removes a line item from the cart.
480
- * @param {string} cartId - the id of the cart that we will remove from
481
- * @param {LineItem} lineItemId - the line item to remove.
482
- * @return {Promise} the result of the update operation
454
+ * @param cartId - the id of the cart that we will remove from
455
+ * @param lineItemId - the line item to remove.
456
+ * @return the result of the update operation
483
457
  */
484
458
  CartService.prototype.removeLineItem = function (cartId, lineItemId) {
485
459
  return __awaiter(this, void 0, void 0, function () {
@@ -588,9 +562,9 @@ var CartService = /** @class */ (function (_super) {
588
562
  * Checks if a given line item has a shipping method that can fulfill it.
589
563
  * Returns true if all products in the cart can be fulfilled with the current
590
564
  * shipping methods.
591
- * @param {ShippingMethod[]} shippingMethods - the set of shipping methods to check from
592
- * @param {LineItem} lineItem - the line item
593
- * @return {boolean}
565
+ * @param shippingMethods - the set of shipping methods to check from
566
+ * @param lineItem - the line item
567
+ * @return boolean representing wheter shipping method is validated
594
568
  */
595
569
  CartService.prototype.validateLineItemShipping_ = function (shippingMethods, lineItem) {
596
570
  if (!lineItem.variant_id) {
@@ -611,9 +585,9 @@ var CartService = /** @class */ (function (_super) {
611
585
  };
612
586
  /**
613
587
  * Adds a line item to the cart.
614
- * @param {string} cartId - the id of the cart that we will add to
615
- * @param {LineItem} lineItem - the line item to add.
616
- * @return {Promise} the result of the update operation
588
+ * @param cartId - the id of the cart that we will add to
589
+ * @param lineItem - the line item to add.
590
+ * @return the result of the update operation
617
591
  */
618
592
  CartService.prototype.addLineItem = function (cartId, lineItem) {
619
593
  return __awaiter(this, void 0, void 0, function () {
@@ -746,11 +720,10 @@ var CartService = /** @class */ (function (_super) {
746
720
  };
747
721
  /**
748
722
  * Updates a cart's existing line item.
749
- * @param {string} cartId - the id of the cart to update
750
- * @param {string} lineItemId - the id of the line item to update.
751
- * @param {LineItemUpdate} lineItemUpdate - the line item to update. Must
752
- * include an id field.
753
- * @return {Promise} the result of the update operation
723
+ * @param cartId - the id of the cart to update
724
+ * @param lineItemId - the id of the line item to update.
725
+ * @param lineItemUpdate - the line item to update. Must include an id field.
726
+ * @return the result of the update operation
754
727
  */
755
728
  CartService.prototype.updateLineItem = function (cartId, lineItemId, lineItemUpdate) {
756
729
  return __awaiter(this, void 0, void 0, function () {
@@ -808,8 +781,9 @@ var CartService = /** @class */ (function (_super) {
808
781
  * shipping discount
809
782
  * If a free shipping is present, we set shipping methods price to 0
810
783
  * if a free shipping was present, we set shipping methods to original amount
811
- * @param {Cart} cart - the the cart to adjust free shipping for
812
- * @param {boolean} shouldAdd - flag to indicate, if we should add or remove
784
+ * @param cart - the the cart to adjust free shipping for
785
+ * @param shouldAdd - flag to indicate, if we should add or remove
786
+ * @return void
813
787
  */
814
788
  CartService.prototype.adjustFreeShipping_ = function (cart, shouldAdd) {
815
789
  var _a;
@@ -1071,9 +1045,9 @@ var CartService = /** @class */ (function (_super) {
1071
1045
  };
1072
1046
  /**
1073
1047
  * Sets the customer id of a cart
1074
- * @param {Cart} cart - the cart to add email to
1075
- * @param {string} customerId - the customer to add to cart
1076
- * @return {Promise} the result of the update operation
1048
+ * @param cart - the cart to add email to
1049
+ * @param customerId - the customer to add to cart
1050
+ * @return the result of the update operation
1077
1051
  */
1078
1052
  CartService.prototype.updateCustomerId_ = function (cart, customerId) {
1079
1053
  return __awaiter(this, void 0, void 0, function () {
@@ -1095,8 +1069,8 @@ var CartService = /** @class */ (function (_super) {
1095
1069
  };
1096
1070
  /**
1097
1071
  * Creates or fetches a user based on an email.
1098
- * @param {string} email - the email to use
1099
- * @return {Promise} the resultign customer object
1072
+ * @param email - the email to use
1073
+ * @return the resultign customer object
1100
1074
  */
1101
1075
  CartService.prototype.createOrFetchUserFromEmail_ = function (email) {
1102
1076
  return __awaiter(this, void 0, void 0, function () {
@@ -1129,12 +1103,10 @@ var CartService = /** @class */ (function (_super) {
1129
1103
  };
1130
1104
  /**
1131
1105
  * Updates the cart's billing address.
1132
- * @param {Cart} cart - the cart to update
1133
- * @param {Address | string} addressOrId - the value to set the billing
1134
- * address to
1135
- * @param {AddressRepository} addrRepo - the repository to use for address
1136
- * updates
1137
- * @return {Promise} the result of the update operation
1106
+ * @param cart - the cart to update
1107
+ * @param addressOrId - the value to set the billing address to
1108
+ * @param addrRepo - the repository to use for address updates
1109
+ * @return the result of the update operation
1138
1110
  */
1139
1111
  CartService.prototype.updateBillingAddress_ = function (cart, addressOrId, addrRepo) {
1140
1112
  var _a, _b;
@@ -1183,12 +1155,10 @@ var CartService = /** @class */ (function (_super) {
1183
1155
  };
1184
1156
  /**
1185
1157
  * Updates the cart's shipping address.
1186
- * @param {Cart} cart - the cart to update
1187
- * @param {Address | string} addressOrId - the value to set the shipping
1188
- * address to
1189
- * @param {AddressRepository} addrRepo - the repository to use for address
1190
- * updates
1191
- * @return {Promise} the result of the update operation
1158
+ * @param cart - the cart to update
1159
+ * @param addressOrId - the value to set the shipping address to
1160
+ * @param addrRepo - the repository to use for address updates
1161
+ * @return the result of the update operation
1192
1162
  */
1193
1163
  CartService.prototype.updateShippingAddress_ = function (cart, addressOrId, addrRepo) {
1194
1164
  var _a, _b;
@@ -1278,9 +1248,9 @@ var CartService = /** @class */ (function (_super) {
1278
1248
  * If discount besides free shipping is already applied, this
1279
1249
  * will be overwritten
1280
1250
  * Throws if discount regions does not include the cart region
1281
- * @param {Cart} cart - the cart to update
1282
- * @param {string} discountCode - the discount code
1283
- * @return {Promise} the result of the update operation
1251
+ * @param cart - the cart to update
1252
+ * @param discountCode - the discount code
1253
+ * @return the result of the update operation
1284
1254
  */
1285
1255
  CartService.prototype.applyDiscount = function (cart, discountCode) {
1286
1256
  return __awaiter(this, void 0, void 0, function () {
@@ -1364,9 +1334,9 @@ var CartService = /** @class */ (function (_super) {
1364
1334
  };
1365
1335
  /**
1366
1336
  * Removes a discount based on a discount code.
1367
- * @param {string} cartId - the id of the cart to remove from
1368
- * @param {string} discountCode - the discount code to remove
1369
- * @return {Promise<Cart>} the resulting cart
1337
+ * @param cartId - the id of the cart to remove from
1338
+ * @param discountCode - the discount code to remove
1339
+ * @return the resulting cart
1370
1340
  */
1371
1341
  CartService.prototype.removeDiscount = function (cartId, discountCode) {
1372
1342
  return __awaiter(this, void 0, void 0, function () {
@@ -1419,18 +1389,11 @@ var CartService = /** @class */ (function (_super) {
1419
1389
  });
1420
1390
  });
1421
1391
  };
1422
- /**
1423
- * A payment method represents a way for the customer to pay. The payment
1424
- * method will typically come from one of the payment sessions.
1425
- * @typedef {object} PaymentMethod
1426
- * @property {string} provider_id - the identifier of the payment method's
1427
- * provider
1428
- * @property {object} data - the data associated with the payment method
1429
- */
1430
1392
  /**
1431
1393
  * Updates the currently selected payment session.
1432
- * @param {string} cartId - the id of the cart to update the payment session for
1433
- * @param {object} update - the data to update the payment session with
1394
+ * @param cartId - the id of the cart to update the payment session for
1395
+ * @param update - the data to update the payment session with
1396
+ * @return the resulting cart
1434
1397
  */
1435
1398
  CartService.prototype.updatePaymentSession = function (cartId, update) {
1436
1399
  return __awaiter(this, void 0, void 0, function () {
@@ -1471,11 +1434,11 @@ var CartService = /** @class */ (function (_super) {
1471
1434
  * a payment object, that we will use to update our cart payment with.
1472
1435
  * Additionally, if the payment does not require more or fails, we will
1473
1436
  * set the payment on the cart.
1474
- * @param {string} cartId - the id of the cart to authorize payment for
1475
- * @param {object} context - object containing whatever is relevant for
1437
+ * @param cartId - the id of the cart to authorize payment for
1438
+ * @param context - object containing whatever is relevant for
1476
1439
  * authorizing the payment with the payment provider. As an example,
1477
1440
  * this could be IP address or similar for fraud handling.
1478
- * @return {Promise<Cart>} the resulting cart
1441
+ * @return the resulting cart
1479
1442
  */
1480
1443
  CartService.prototype.authorizePayment = function (cartId, context) {
1481
1444
  if (context === void 0) { context = {}; }
@@ -1539,9 +1502,9 @@ var CartService = /** @class */ (function (_super) {
1539
1502
  };
1540
1503
  /**
1541
1504
  * Sets a payment method for a cart.
1542
- * @param {string} cartId - the id of the cart to add payment method to
1543
- * @param {string} providerId - the id of the provider to be set to the cart
1544
- * @return {Promise} result of update operation
1505
+ * @param cartId - the id of the cart to add payment method to
1506
+ * @param providerId - the id of the provider to be set to the cart
1507
+ * @return result of update operation
1545
1508
  */
1546
1509
  CartService.prototype.setPaymentSession = function (cartId, providerId) {
1547
1510
  return __awaiter(this, void 0, void 0, function () {
@@ -1616,16 +1579,15 @@ var CartService = /** @class */ (function (_super) {
1616
1579
  * provider. Additional calls will ensure that payment sessions have correct
1617
1580
  * amounts, currencies, etc. as well as make sure to filter payment sessions
1618
1581
  * that are not available for the cart's region.
1619
- * @param {Cart | string} cartOrCartId - the id of the cart to set payment
1620
- * session for
1621
- * @return {Promise} the result of the update operation.
1582
+ * @param cartOrCartId - the id of the cart to set payment session for
1583
+ * @return the result of the update operation.
1622
1584
  */
1623
1585
  CartService.prototype.setPaymentSessions = function (cartOrCartId) {
1624
1586
  return __awaiter(this, void 0, void 0, function () {
1625
1587
  var _this = this;
1626
1588
  return __generator(this, function (_a) {
1627
1589
  return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
1628
- var psRepo, cartId, cart, region, seen, _loop_1, this_1, _a, _b, session, e_9_1, p, sess, _c, _d, provider, e_10_1;
1590
+ var psRepo, cartId, cart, total, region, seen, _loop_1, this_1, _a, _b, session, e_9_1, p, sess, _c, _d, provider, e_10_1;
1629
1591
  var e_9, _e, e_10, _f;
1630
1592
  return __generator(this, function (_g) {
1631
1593
  switch (_g.label) {
@@ -1634,12 +1596,12 @@ var CartService = /** @class */ (function (_super) {
1634
1596
  cartId = typeof cartOrCartId === "string" ? cartOrCartId : cartOrCartId.id;
1635
1597
  return [4 /*yield*/, this.retrieve(cartId, {
1636
1598
  select: [
1637
- "gift_card_total",
1599
+ "total",
1638
1600
  "subtotal",
1639
1601
  "tax_total",
1640
- "shipping_total",
1641
1602
  "discount_total",
1642
- "total",
1603
+ "shipping_total",
1604
+ "gift_card_total",
1643
1605
  ],
1644
1606
  relations: [
1645
1607
  "items",
@@ -1647,19 +1609,21 @@ var CartService = /** @class */ (function (_super) {
1647
1609
  "discounts.rule",
1648
1610
  "discounts.rule.valid_for",
1649
1611
  "gift_cards",
1612
+ "shipping_methods",
1650
1613
  "billing_address",
1651
1614
  "shipping_address",
1652
1615
  "region",
1616
+ "region.tax_rates",
1653
1617
  "region.payment_providers",
1654
1618
  "payment_sessions",
1655
1619
  "customer",
1656
1620
  ],
1657
- })];
1621
+ }, { force_taxes: true })];
1658
1622
  case 1:
1659
1623
  cart = _g.sent();
1660
- region = cart.region;
1661
- if (typeof cart.total === "undefined") {
1662
- throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.UNEXPECTED_STATE, "cart.total should be defined");
1624
+ total = cart.total, region = cart.region;
1625
+ if (typeof total === "undefined") {
1626
+ throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.UNEXPECTED_STATE, "cart.total must be defined");
1663
1627
  }
1664
1628
  seen = [];
1665
1629
  if (!(cart.payment_sessions && cart.payment_sessions.length)) return [3 /*break*/, 9];
@@ -1667,7 +1631,7 @@ var CartService = /** @class */ (function (_super) {
1667
1631
  return __generator(this, function (_h) {
1668
1632
  switch (_h.label) {
1669
1633
  case 0:
1670
- if (!(cart.total <= 0 ||
1634
+ if (!(total <= 0 ||
1671
1635
  !region.payment_providers.find(function (_a) {
1672
1636
  var id = _a.id;
1673
1637
  return id === session.provider_id;
@@ -1718,7 +1682,7 @@ var CartService = /** @class */ (function (_super) {
1718
1682
  finally { if (e_9) throw e_9.error; }
1719
1683
  return [7 /*endfinally*/];
1720
1684
  case 9:
1721
- if (!(cart.total > 0)) return [3 /*break*/, 19];
1685
+ if (!(total > 0)) return [3 /*break*/, 19];
1722
1686
  if (!(region.payment_providers.length === 1 && !cart.payment_session)) return [3 /*break*/, 12];
1723
1687
  p = region.payment_providers[0];
1724
1688
  return [4 /*yield*/, this.paymentProviderService_
@@ -1768,10 +1732,10 @@ var CartService = /** @class */ (function (_super) {
1768
1732
  };
1769
1733
  /**
1770
1734
  * Removes a payment session from the cart.
1771
- * @param {string} cartId - the id of the cart to remove from
1772
- * @param {string} providerId - the id of the provider whoose payment session
1735
+ * @param cartId - the id of the cart to remove from
1736
+ * @param providerId - the id of the provider whoose payment session
1773
1737
  * should be removed.
1774
- * @return {Promise<Cart>} the resulting cart.
1738
+ * @return the resulting cart.
1775
1739
  */
1776
1740
  CartService.prototype.deletePaymentSession = function (cartId, providerId) {
1777
1741
  return __awaiter(this, void 0, void 0, function () {
@@ -1822,8 +1786,8 @@ var CartService = /** @class */ (function (_super) {
1822
1786
  };
1823
1787
  /**
1824
1788
  * Refreshes a payment session on a cart
1825
- * @param {string} cartId - the id of the cart to remove from
1826
- * @param {string} providerId - the id of the provider whoose payment session
1789
+ * @param cartId - the id of the cart to remove from
1790
+ * @param providerId - the id of the provider whoose payment session
1827
1791
  * should be removed.
1828
1792
  * @return {Promise<Cart>} the resulting cart.
1829
1793
  */
@@ -1875,10 +1839,10 @@ var CartService = /** @class */ (function (_super) {
1875
1839
  * Shipping Option is a possible way to ship an order. Shipping Methods may
1876
1840
  * also have additional details in the data field such as an id for a package
1877
1841
  * shop.
1878
- * @param {string} cartId - the id of the cart to add shipping method to
1879
- * @param {string} optionId - id of shipping option to add as valid method
1880
- * @param {Object} data - the fulmillment data for the method
1881
- * @return {Promise} the result of the update operation
1842
+ * @param cartId - the id of the cart to add shipping method to
1843
+ * @param optionId - id of shipping option to add as valid method
1844
+ * @param data - the fulmillment data for the method
1845
+ * @return the result of the update operation
1882
1846
  */
1883
1847
  CartService.prototype.addShippingMethod = function (cartId, optionId, data) {
1884
1848
  if (data === void 0) { data = {}; }
@@ -2018,9 +1982,9 @@ var CartService = /** @class */ (function (_super) {
2018
1982
  /**
2019
1983
  * Finds the cart's custom shipping options based on the passed option id.
2020
1984
  * throws if custom options is not empty and no shipping option corresponds to optionId
2021
- * @param {Object} cartCustomShippingOptions - the cart's custom shipping options
2022
- * @param {string} optionId - id of the normal or custom shipping option to find in the cartCustomShippingOptions
2023
- * @return {CustomShippingOption | undefined}
1985
+ * @param cartCustomShippingOptions - the cart's custom shipping options
1986
+ * @param optionId - id of the normal or custom shipping option to find in the cartCustomShippingOptions
1987
+ * @return custom shipping option
2024
1988
  */
2025
1989
  CartService.prototype.findCustomShippingOption = function (cartCustomShippingOptions, optionId) {
2026
1990
  var customOption = cartCustomShippingOptions === null || cartCustomShippingOptions === void 0 ? void 0 : cartCustomShippingOptions.find(function (cso) { return cso.shipping_option_id === optionId; });
@@ -2032,10 +1996,10 @@ var CartService = /** @class */ (function (_super) {
2032
1996
  };
2033
1997
  /**
2034
1998
  * Set's the region of a cart.
2035
- * @param {Cart} cart - the cart to set region on
2036
- * @param {string} regionId - the id of the region to set the region to
2037
- * @param {string} countryCode - the country code to set the country to
2038
- * @return {Promise} the result of the update operation
1999
+ * @param cart - the cart to set region on
2000
+ * @param regionId - the id of the region to set the region to
2001
+ * @param countryCode - the country code to set the country to
2002
+ * @return the result of the update operation
2039
2003
  */
2040
2004
  CartService.prototype.setRegion_ = function (cart, regionId, countryCode) {
2041
2005
  return __awaiter(this, void 0, void 0, function () {
@@ -2162,9 +2126,8 @@ var CartService = /** @class */ (function (_super) {
2162
2126
  };
2163
2127
  /**
2164
2128
  * Deletes a cart from the database. Completed carts cannot be deleted.
2165
- * @param {string} cartId - the id of the cart to delete
2166
- * @return {Promise<string>} the deleted cart or undefined if the cart was
2167
- * not found.
2129
+ * @param cartId - the id of the cart to delete
2130
+ * @return the deleted cart or undefined if the cart was not found.
2168
2131
  */
2169
2132
  CartService.prototype.delete = function (cartId) {
2170
2133
  return __awaiter(this, void 0, void 0, function () {
@@ -2206,10 +2169,10 @@ var CartService = /** @class */ (function (_super) {
2206
2169
  * Dedicated method to set metadata for a cart.
2207
2170
  * To ensure that plugins does not overwrite each
2208
2171
  * others metadata fields, setMetadata is provided.
2209
- * @param {string} cartId - the cart to apply metadata to.
2210
- * @param {string} key - key for metadata field
2211
- * @param {string} value - value for metadata field.
2212
- * @return {Promise} resolves to the updated result.
2172
+ * @param cartId - the cart to apply metadata to.
2173
+ * @param key - key for metadata field
2174
+ * @param value - value for metadata field.
2175
+ * @return resolves to the updated result.
2213
2176
  */
2214
2177
  CartService.prototype.setMetadata = function (cartId, key, value) {
2215
2178
  return __awaiter(this, void 0, void 0, function () {
@@ -2247,11 +2210,46 @@ var CartService = /** @class */ (function (_super) {
2247
2210
  });
2248
2211
  });
2249
2212
  };
2213
+ CartService.prototype.createTaxLines = function (id) {
2214
+ return __awaiter(this, void 0, void 0, function () {
2215
+ var _this = this;
2216
+ return __generator(this, function (_a) {
2217
+ return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
2218
+ var cart, calculationContext;
2219
+ return __generator(this, function (_a) {
2220
+ switch (_a.label) {
2221
+ case 0: return [4 /*yield*/, this.retrieve(id, {
2222
+ relations: [
2223
+ "items",
2224
+ "gift_cards",
2225
+ "discounts",
2226
+ "discounts.rule",
2227
+ "discounts.rule.valid_for",
2228
+ "shipping_methods",
2229
+ "region",
2230
+ "region.tax_rates",
2231
+ ],
2232
+ })];
2233
+ case 1:
2234
+ cart = _a.sent();
2235
+ calculationContext = this.totalsService_.getCalculationContext(cart);
2236
+ return [4 /*yield*/, this.taxProviderService_
2237
+ .withTransaction(manager)
2238
+ .createTaxLines(cart, calculationContext)];
2239
+ case 2:
2240
+ _a.sent();
2241
+ return [2 /*return*/, cart];
2242
+ }
2243
+ });
2244
+ }); })];
2245
+ });
2246
+ });
2247
+ };
2250
2248
  /**
2251
2249
  * Dedicated method to delete metadata for a cart.
2252
- * @param {string} cartId - the cart to delete metadata from.
2253
- * @param {string} key - key for metadata field
2254
- * @return {Promise} resolves to the updated result.
2250
+ * @param cartId - the cart to delete metadata from.
2251
+ * @param key - key for metadata field
2252
+ * @return resolves to the updated result.
2255
2253
  */
2256
2254
  CartService.prototype.deleteMetadata = function (cartId, key) {
2257
2255
  return __awaiter(this, void 0, void 0, function () {