@medusajs/medusa 1.2.2-dev.47 → 1.3.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 (440) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/api/index.d.ts +1 -0
  3. package/dist/api/index.js +1 -0
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/api/middlewares/error-handler.js +1 -1
  6. package/dist/api/routes/admin/auth/create-session.js +5 -5
  7. package/dist/api/routes/admin/auth/create-session.js.map +1 -1
  8. package/dist/api/routes/admin/customer-groups/get-customer-group-customers.d.ts +20 -0
  9. package/dist/api/routes/admin/customer-groups/get-customer-group-customers.js +76 -0
  10. package/dist/api/routes/admin/customer-groups/get-customer-group-customers.js.map +1 -0
  11. package/dist/api/routes/admin/customer-groups/index.js +1 -0
  12. package/dist/api/routes/admin/customer-groups/index.js.map +1 -1
  13. package/dist/api/routes/admin/customer-groups/list-customer-groups.js +2 -2
  14. package/dist/api/routes/admin/customer-groups/list-customer-groups.js.map +1 -1
  15. package/dist/api/routes/admin/customers/index.js +1 -1
  16. package/dist/api/routes/admin/customers/index.js.map +1 -1
  17. package/dist/api/routes/admin/customers/list-customers.js +1 -0
  18. package/dist/api/routes/admin/customers/list-customers.js.map +1 -1
  19. package/dist/api/routes/admin/discounts/create-discount.d.ts +11 -2
  20. package/dist/api/routes/admin/discounts/create-discount.js +66 -12
  21. package/dist/api/routes/admin/discounts/create-discount.js.map +1 -1
  22. package/dist/api/routes/admin/discounts/create-dynamic-code.d.ts +1 -0
  23. package/dist/api/routes/admin/discounts/create-dynamic-code.js +4 -1
  24. package/dist/api/routes/admin/discounts/create-dynamic-code.js.map +1 -1
  25. package/dist/api/routes/admin/discounts/delete-dynamic-code.js +3 -1
  26. package/dist/api/routes/admin/discounts/delete-dynamic-code.js.map +1 -1
  27. package/dist/api/routes/admin/discounts/get-discount.d.ts +7 -0
  28. package/dist/api/routes/admin/discounts/get-discount.js +43 -9
  29. package/dist/api/routes/admin/discounts/get-discount.js.map +1 -1
  30. package/dist/api/routes/admin/discounts/index.d.ts +1 -3
  31. package/dist/api/routes/admin/discounts/index.js +1 -6
  32. package/dist/api/routes/admin/discounts/index.js.map +1 -1
  33. package/dist/api/routes/admin/discounts/list-discounts.d.ts +2 -6
  34. package/dist/api/routes/admin/discounts/list-discounts.js +15 -28
  35. package/dist/api/routes/admin/discounts/list-discounts.js.map +1 -1
  36. package/dist/api/routes/admin/discounts/update-discount.d.ts +12 -2
  37. package/dist/api/routes/admin/discounts/update-discount.js +70 -15
  38. package/dist/api/routes/admin/discounts/update-discount.js.map +1 -1
  39. package/dist/api/routes/admin/draft-orders/create-draft-order.d.ts +3 -3
  40. package/dist/api/routes/admin/draft-orders/create-draft-order.js.map +1 -1
  41. package/dist/api/routes/admin/draft-orders/create-line-item.d.ts +1 -1
  42. package/dist/api/routes/admin/draft-orders/create-line-item.js.map +1 -1
  43. package/dist/api/routes/admin/draft-orders/index.js +7 -1
  44. package/dist/api/routes/admin/draft-orders/index.js.map +1 -1
  45. package/dist/api/routes/admin/draft-orders/register-payment.js +0 -1
  46. package/dist/api/routes/admin/draft-orders/register-payment.js.map +1 -1
  47. package/dist/api/routes/admin/draft-orders/update-line-item.d.ts +1 -1
  48. package/dist/api/routes/admin/draft-orders/update-line-item.js.map +1 -1
  49. package/dist/api/routes/admin/index.js +21 -19
  50. package/dist/api/routes/admin/index.js.map +1 -1
  51. package/dist/api/routes/admin/notifications/index.js.map +1 -1
  52. package/dist/api/routes/admin/notifications/list-notifications.js.map +1 -1
  53. package/dist/api/routes/admin/notifications/resend-notification.js.map +1 -1
  54. package/dist/api/routes/admin/orders/add-shipping-method.d.ts +1 -1
  55. package/dist/api/routes/admin/orders/add-shipping-method.js.map +1 -1
  56. package/dist/api/routes/admin/orders/create-order.js.map +1 -1
  57. package/dist/api/routes/admin/orders/create-swap.js +7 -3
  58. package/dist/api/routes/admin/orders/create-swap.js.map +1 -1
  59. package/dist/api/routes/admin/orders/index.d.ts +1 -1
  60. package/dist/api/routes/admin/orders/index.js +1 -3
  61. package/dist/api/routes/admin/orders/index.js.map +1 -1
  62. package/dist/api/routes/admin/orders/list-orders.js.map +1 -1
  63. package/dist/api/routes/admin/orders/update-order.js.map +1 -1
  64. package/dist/api/routes/admin/price-lists/add-prices-batch.d.ts +70 -0
  65. package/dist/api/routes/admin/{orders/receive-swap.js → price-lists/add-prices-batch.js} +77 -78
  66. package/dist/api/routes/admin/price-lists/add-prices-batch.js.map +1 -0
  67. package/dist/api/routes/admin/price-lists/create-price-list.d.ts +87 -0
  68. package/dist/api/routes/admin/price-lists/create-price-list.js +193 -0
  69. package/dist/api/routes/admin/price-lists/create-price-list.js.map +1 -0
  70. package/dist/api/routes/admin/price-lists/delete-price-list.d.ts +28 -0
  71. package/dist/api/routes/admin/{discounts/remove-valid-product.js → price-lists/delete-price-list.js} +27 -25
  72. package/dist/api/routes/admin/price-lists/delete-price-list.js.map +1 -0
  73. package/dist/api/routes/admin/price-lists/delete-prices-batch.d.ts +43 -0
  74. package/dist/api/routes/{store/carts/update-payment-method.js → admin/price-lists/delete-prices-batch.js} +42 -46
  75. package/dist/api/routes/admin/price-lists/delete-prices-batch.js.map +1 -0
  76. package/dist/api/routes/admin/price-lists/get-price-list.d.ts +22 -0
  77. package/dist/api/routes/admin/{discounts/add-valid-product.js → price-lists/get-price-list.js} +20 -24
  78. package/dist/api/routes/admin/price-lists/get-price-list.js.map +1 -0
  79. package/dist/api/routes/admin/price-lists/index.d.ts +28 -0
  80. package/dist/api/routes/admin/price-lists/index.js +55 -0
  81. package/dist/api/routes/admin/price-lists/index.js.map +1 -0
  82. package/dist/api/routes/admin/price-lists/list-price-list-products.d.ts +74 -0
  83. package/dist/api/routes/admin/price-lists/list-price-list-products.js +246 -0
  84. package/dist/api/routes/admin/price-lists/list-price-list-products.js.map +1 -0
  85. package/dist/api/routes/admin/price-lists/list-price-lists.d.ts +38 -0
  86. package/dist/api/routes/admin/price-lists/list-price-lists.js +197 -0
  87. package/dist/api/routes/admin/price-lists/list-price-lists.js.map +1 -0
  88. package/dist/api/routes/admin/price-lists/update-price-list.d.ts +92 -0
  89. package/dist/api/routes/admin/price-lists/update-price-list.js +211 -0
  90. package/dist/api/routes/admin/price-lists/update-price-list.js.map +1 -0
  91. package/dist/api/routes/admin/products/create-product.d.ts +2 -7
  92. package/dist/api/routes/admin/products/create-product.js +2 -24
  93. package/dist/api/routes/admin/products/create-product.js.map +1 -1
  94. package/dist/api/routes/admin/products/create-variant.d.ts +7 -9
  95. package/dist/api/routes/admin/products/create-variant.js +7 -26
  96. package/dist/api/routes/admin/products/create-variant.js.map +1 -1
  97. package/dist/api/routes/admin/products/index.d.ts +1 -1
  98. package/dist/api/routes/admin/products/index.js +7 -1
  99. package/dist/api/routes/admin/products/index.js.map +1 -1
  100. package/dist/api/routes/admin/products/list-products.d.ts +2 -1
  101. package/dist/api/routes/admin/products/list-products.js +31 -65
  102. package/dist/api/routes/admin/products/list-products.js.map +1 -1
  103. package/dist/api/routes/admin/products/update-product.d.ts +2 -7
  104. package/dist/api/routes/admin/products/update-product.js +2 -24
  105. package/dist/api/routes/admin/products/update-product.js.map +1 -1
  106. package/dist/api/routes/admin/products/update-variant.d.ts +10 -9
  107. package/dist/api/routes/admin/products/update-variant.js +21 -33
  108. package/dist/api/routes/admin/products/update-variant.js.map +1 -1
  109. package/dist/api/routes/admin/regions/index.d.ts +1 -1
  110. package/dist/api/routes/admin/store/get-store.js.map +1 -1
  111. package/dist/api/routes/admin/swaps/index.js +3 -0
  112. package/dist/api/routes/admin/swaps/index.js.map +1 -1
  113. package/dist/api/routes/admin/tax-rates/list-tax-rates.js.map +1 -1
  114. package/dist/api/routes/admin/tax-rates/utils/get-query-config.d.ts +1 -1
  115. package/dist/api/routes/admin/tax-rates/utils/get-query-config.js +4 -2
  116. package/dist/api/routes/admin/tax-rates/utils/get-query-config.js.map +1 -1
  117. package/dist/api/routes/admin/uploads/index.d.ts +1 -1
  118. package/dist/api/routes/store/auth/create-session.js +4 -5
  119. package/dist/api/routes/store/auth/create-session.js.map +1 -1
  120. package/dist/api/routes/store/carts/create-cart.js +8 -5
  121. package/dist/api/routes/store/carts/create-cart.js.map +1 -1
  122. package/dist/api/routes/store/carts/create-line-item.d.ts +1 -1
  123. package/dist/api/routes/store/carts/create-line-item.js +9 -6
  124. package/dist/api/routes/store/carts/create-line-item.js.map +1 -1
  125. package/dist/api/routes/store/carts/index.d.ts +0 -1
  126. package/dist/api/routes/store/carts/index.js +1 -3
  127. package/dist/api/routes/store/carts/index.js.map +1 -1
  128. package/dist/api/routes/store/carts/update-cart.js +7 -7
  129. package/dist/api/routes/store/carts/update-cart.js.map +1 -1
  130. package/dist/api/routes/store/collections/list-collections.d.ts +3 -0
  131. package/dist/api/routes/store/collections/list-collections.js +33 -16
  132. package/dist/api/routes/store/collections/list-collections.js.map +1 -1
  133. package/dist/api/routes/store/customers/create-customer.js +3 -4
  134. package/dist/api/routes/store/customers/create-customer.js.map +1 -1
  135. package/dist/api/routes/store/orders/index.js +0 -2
  136. package/dist/api/routes/store/orders/index.js.map +1 -1
  137. package/dist/api/routes/store/products/get-product.js +17 -5
  138. package/dist/api/routes/store/products/get-product.js.map +1 -1
  139. package/dist/api/routes/store/products/index.d.ts +2 -2
  140. package/dist/api/routes/store/products/list-products.d.ts +5 -3
  141. package/dist/api/routes/store/products/list-products.js +60 -18
  142. package/dist/api/routes/store/products/list-products.js.map +1 -1
  143. package/dist/api/routes/store/products/search.d.ts +1 -1
  144. package/dist/api/routes/store/products/search.js.map +1 -1
  145. package/dist/api/routes/store/regions/list-regions.d.ts +3 -0
  146. package/dist/api/routes/store/regions/list-regions.js +22 -7
  147. package/dist/api/routes/store/regions/list-regions.js.map +1 -1
  148. package/dist/api/routes/store/shipping-options/list-options.js.map +1 -1
  149. package/dist/api/routes/store/swaps/create-swap.js +7 -3
  150. package/dist/api/routes/store/swaps/create-swap.js.map +1 -1
  151. package/dist/api/routes/store/variants/get-variant.js +17 -5
  152. package/dist/api/routes/store/variants/get-variant.js.map +1 -1
  153. package/dist/api/routes/store/variants/list-variants.d.ts +6 -1
  154. package/dist/api/routes/store/variants/list-variants.js +63 -10
  155. package/dist/api/routes/store/variants/list-variants.js.map +1 -1
  156. package/dist/commands/develop.js +1 -1
  157. package/dist/commands/develop.js.map +1 -1
  158. package/dist/controllers/customers/index.d.ts +1 -1
  159. package/dist/controllers/customers/list-customers.d.ts +1 -1
  160. package/dist/controllers/customers/list-customers.js +34 -37
  161. package/dist/controllers/customers/list-customers.js.map +1 -1
  162. package/dist/controllers/products/admin-list-products.d.ts +16 -0
  163. package/dist/controllers/products/admin-list-products.js +103 -0
  164. package/dist/controllers/products/admin-list-products.js.map +1 -0
  165. package/dist/helpers/test-request.js +15 -7
  166. package/dist/helpers/test-request.js.map +1 -1
  167. package/dist/index.d.ts +3 -58
  168. package/dist/index.js +3 -61
  169. package/dist/index.js.map +1 -1
  170. package/dist/interfaces/base-service.d.ts +66 -0
  171. package/dist/interfaces/base-service.js +378 -0
  172. package/dist/interfaces/base-service.js.map +1 -0
  173. package/dist/interfaces/index.d.ts +1 -0
  174. package/dist/interfaces/index.js +1 -0
  175. package/dist/interfaces/index.js.map +1 -1
  176. package/dist/interfaces/price-selection-strategy.d.ts +50 -0
  177. package/dist/interfaces/price-selection-strategy.js +34 -0
  178. package/dist/interfaces/price-selection-strategy.js.map +1 -0
  179. package/dist/interfaces/tax-service.d.ts +6 -0
  180. package/dist/interfaces/tax-service.js +31 -0
  181. package/dist/interfaces/tax-service.js.map +1 -1
  182. package/dist/loaders/api.d.ts +9 -5
  183. package/dist/loaders/api.js +2 -6
  184. package/dist/loaders/api.js.map +1 -1
  185. package/dist/loaders/config.d.ts +3 -0
  186. package/dist/loaders/config.js +47 -0
  187. package/dist/loaders/config.js.map +1 -0
  188. package/dist/loaders/database.d.ts +8 -4
  189. package/dist/loaders/database.js.map +1 -1
  190. package/dist/loaders/defaults.d.ts +4 -3
  191. package/dist/loaders/defaults.js +39 -31
  192. package/dist/loaders/defaults.js.map +1 -1
  193. package/dist/loaders/express.d.ts +7 -4
  194. package/dist/loaders/express.js +7 -5
  195. package/dist/loaders/express.js.map +1 -1
  196. package/dist/loaders/index.d.ts +13 -8
  197. package/dist/loaders/index.js +29 -54
  198. package/dist/loaders/index.js.map +1 -1
  199. package/dist/loaders/logger.d.ts +1 -0
  200. package/dist/loaders/logger.js.map +1 -1
  201. package/dist/loaders/models.d.ts +8 -3
  202. package/dist/loaders/models.js +19 -17
  203. package/dist/loaders/models.js.map +1 -1
  204. package/dist/loaders/passport.d.ts +7 -4
  205. package/dist/loaders/passport.js +23 -21
  206. package/dist/loaders/passport.js.map +1 -1
  207. package/dist/loaders/plugins.d.ts +18 -10
  208. package/dist/loaders/plugins.js +27 -24
  209. package/dist/loaders/plugins.js.map +1 -1
  210. package/dist/loaders/redis.d.ts +8 -5
  211. package/dist/loaders/redis.js +3 -3
  212. package/dist/loaders/redis.js.map +1 -1
  213. package/dist/loaders/repositories.d.ts +7 -3
  214. package/dist/loaders/repositories.js +1 -1
  215. package/dist/loaders/repositories.js.map +1 -1
  216. package/dist/loaders/search-index.d.ts +4 -3
  217. package/dist/loaders/search-index.js.map +1 -1
  218. package/dist/loaders/services.d.ts +10 -5
  219. package/dist/loaders/services.js.map +1 -1
  220. package/dist/loaders/strategies.d.ts +1 -1
  221. package/dist/loaders/subscribers.d.ts +7 -3
  222. package/dist/loaders/subscribers.js.map +1 -1
  223. package/dist/migrations/1646324713514-discount_conditions.d.ts +6 -0
  224. package/dist/migrations/1646324713514-discount_conditions.js +335 -0
  225. package/dist/migrations/1646324713514-discount_conditions.js.map +1 -0
  226. package/dist/migrations/1646915480108-update_money_amount_add_price_list.d.ts +6 -0
  227. package/dist/migrations/1646915480108-update_money_amount_add_price_list.js +143 -0
  228. package/dist/migrations/1646915480108-update_money_amount_add_price_list.js.map +1 -0
  229. package/dist/migrations/1648600574750-add_line_item_adjustments.d.ts +6 -0
  230. package/dist/migrations/1648600574750-add_line_item_adjustments.js +101 -0
  231. package/dist/migrations/1648600574750-add_line_item_adjustments.js.map +1 -0
  232. package/dist/migrations/1648641130007-tax_line_constraints.d.ts +6 -0
  233. package/dist/migrations/1648641130007-tax_line_constraints.js +77 -0
  234. package/dist/migrations/1648641130007-tax_line_constraints.js.map +1 -0
  235. package/dist/migrations/1649775522087-add_batch_job_model.d.ts +6 -0
  236. package/dist/migrations/1649775522087-add_batch_job_model.js +77 -0
  237. package/dist/migrations/1649775522087-add_batch_job_model.js.map +1 -0
  238. package/dist/models/batch-job.d.ts +58 -0
  239. package/dist/models/batch-job.js +119 -0
  240. package/dist/models/batch-job.js.map +1 -0
  241. package/dist/models/country.d.ts +1 -1
  242. package/dist/models/country.js +1 -1
  243. package/dist/models/country.js.map +1 -1
  244. package/dist/models/customer-group.d.ts +3 -1
  245. package/dist/models/customer-group.js +9 -13
  246. package/dist/models/customer-group.js.map +1 -1
  247. package/dist/models/discount-condition-customer-group.d.ts +39 -0
  248. package/dist/models/discount-condition-customer-group.js +84 -0
  249. package/dist/models/discount-condition-customer-group.js.map +1 -0
  250. package/dist/models/discount-condition-product-collection.d.ts +39 -0
  251. package/dist/models/discount-condition-product-collection.js +84 -0
  252. package/dist/models/discount-condition-product-collection.js.map +1 -0
  253. package/dist/models/discount-condition-product-tag.d.ts +39 -0
  254. package/dist/models/discount-condition-product-tag.js +84 -0
  255. package/dist/models/discount-condition-product-tag.js.map +1 -0
  256. package/dist/models/discount-condition-product-type.d.ts +39 -0
  257. package/dist/models/discount-condition-product-type.js +84 -0
  258. package/dist/models/discount-condition-product-type.js.map +1 -0
  259. package/dist/models/discount-condition-product.d.ts +39 -0
  260. package/dist/models/discount-condition-product.js +84 -0
  261. package/dist/models/discount-condition-product.js.map +1 -0
  262. package/dist/models/discount-condition.d.ts +68 -0
  263. package/dist/models/discount-condition.js +208 -0
  264. package/dist/models/discount-condition.js.map +1 -0
  265. package/dist/models/discount-rule.d.ts +5 -5
  266. package/dist/models/discount-rule.js +6 -17
  267. package/dist/models/discount-rule.js.map +1 -1
  268. package/dist/models/discount.js.map +1 -1
  269. package/dist/models/index.d.ts +66 -0
  270. package/dist/models/index.js +79 -0
  271. package/dist/models/index.js.map +1 -0
  272. package/dist/models/line-item-adjustment.d.ts +13 -0
  273. package/dist/models/line-item-adjustment.js +79 -0
  274. package/dist/models/line-item-adjustment.js.map +1 -0
  275. package/dist/models/line-item-tax-line.js +2 -1
  276. package/dist/models/line-item-tax-line.js.map +1 -1
  277. package/dist/models/line-item.d.ts +2 -0
  278. package/dist/models/line-item.js +5 -0
  279. package/dist/models/line-item.js.map +1 -1
  280. package/dist/models/money-amount.d.ts +10 -3
  281. package/dist/models/money-amount.js +25 -5
  282. package/dist/models/money-amount.js.map +1 -1
  283. package/dist/models/price-list.d.ts +57 -0
  284. package/dist/models/price-list.js +146 -0
  285. package/dist/models/price-list.js.map +1 -0
  286. package/dist/models/product-variant.js +9 -3
  287. package/dist/models/product-variant.js.map +1 -1
  288. package/dist/models/shipping-method-tax-line.js +2 -1
  289. package/dist/models/shipping-method-tax-line.js.map +1 -1
  290. package/dist/models/swap.d.ts +4 -4
  291. package/dist/models/swap.js +23 -23
  292. package/dist/models/swap.js.map +1 -1
  293. package/dist/repositories/cart.d.ts +2 -2
  294. package/dist/repositories/cart.js.map +1 -1
  295. package/dist/repositories/customer.d.ts +1 -0
  296. package/dist/repositories/customer.js +63 -0
  297. package/dist/repositories/customer.js.map +1 -1
  298. package/dist/repositories/discount-condition.d.ts +34 -0
  299. package/dist/repositories/discount-condition.js +384 -0
  300. package/dist/repositories/discount-condition.js.map +1 -0
  301. package/dist/repositories/line-item-adjustment.d.ts +4 -0
  302. package/dist/repositories/line-item-adjustment.js +38 -0
  303. package/dist/repositories/line-item-adjustment.js.map +1 -0
  304. package/dist/repositories/line-item-tax-line.d.ts +2 -0
  305. package/dist/repositories/line-item-tax-line.js +80 -0
  306. package/dist/repositories/line-item-tax-line.js.map +1 -1
  307. package/dist/repositories/line-item.js +1 -0
  308. package/dist/repositories/line-item.js.map +1 -1
  309. package/dist/repositories/money-amount.d.ts +7 -2
  310. package/dist/repositories/money-amount.js +149 -2
  311. package/dist/repositories/money-amount.js.map +1 -1
  312. package/dist/repositories/price-list.d.ts +4 -0
  313. package/dist/repositories/price-list.js +38 -0
  314. package/dist/repositories/price-list.js.map +1 -0
  315. package/dist/repositories/product.d.ts +3 -0
  316. package/dist/repositories/product.js +41 -19
  317. package/dist/repositories/product.js.map +1 -1
  318. package/dist/repositories/shipping-method-tax-line.d.ts +2 -0
  319. package/dist/repositories/shipping-method-tax-line.js +80 -0
  320. package/dist/repositories/shipping-method-tax-line.js.map +1 -1
  321. package/dist/scripts/discount-rule-migration.d.ts +4 -0
  322. package/dist/scripts/discount-rule-migration.js +177 -0
  323. package/dist/scripts/discount-rule-migration.js.map +1 -0
  324. package/dist/scripts/line-item-adjustment-migration.d.ts +4 -0
  325. package/dist/scripts/line-item-adjustment-migration.js +173 -0
  326. package/dist/scripts/line-item-adjustment-migration.js.map +1 -0
  327. package/dist/services/cart.d.ts +58 -47
  328. package/dist/services/cart.js +1306 -1391
  329. package/dist/services/cart.js.map +1 -1
  330. package/dist/services/customer.js +18 -18
  331. package/dist/services/customer.js.map +1 -1
  332. package/dist/services/discount.d.ts +50 -58
  333. package/dist/services/discount.js +365 -154
  334. package/dist/services/discount.js.map +1 -1
  335. package/dist/services/draft-order.js +1 -0
  336. package/dist/services/draft-order.js.map +1 -1
  337. package/dist/services/fulfillment-provider.js +23 -17
  338. package/dist/services/fulfillment-provider.js.map +1 -1
  339. package/dist/services/invite.d.ts +4 -2
  340. package/dist/services/invite.js +11 -9
  341. package/dist/services/invite.js.map +1 -1
  342. package/dist/services/line-item-adjustment.d.ts +87 -0
  343. package/dist/services/line-item-adjustment.js +436 -0
  344. package/dist/services/line-item-adjustment.js.map +1 -0
  345. package/dist/services/line-item.d.ts +48 -40
  346. package/dist/services/line-item.js +226 -193
  347. package/dist/services/line-item.js.map +1 -1
  348. package/dist/services/order.js +4 -4
  349. package/dist/services/order.js.map +1 -1
  350. package/dist/services/payment-provider.js +23 -17
  351. package/dist/services/payment-provider.js.map +1 -1
  352. package/dist/services/price-list.d.ts +86 -0
  353. package/dist/services/price-list.js +469 -0
  354. package/dist/services/price-list.js.map +1 -0
  355. package/dist/services/product-variant.d.ts +40 -16
  356. package/dist/services/product-variant.js +259 -109
  357. package/dist/services/product-variant.js.map +1 -1
  358. package/dist/services/product.d.ts +22 -4
  359. package/dist/services/product.js +239 -49
  360. package/dist/services/product.js.map +1 -1
  361. package/dist/services/region.js +8 -4
  362. package/dist/services/region.js.map +1 -1
  363. package/dist/services/return.js +0 -1
  364. package/dist/services/return.js.map +1 -1
  365. package/dist/services/shipping-option.d.ts +2 -2
  366. package/dist/services/shipping-option.js +7 -4
  367. package/dist/services/shipping-option.js.map +1 -1
  368. package/dist/services/swap.d.ts +4 -1
  369. package/dist/services/swap.js +29 -16
  370. package/dist/services/swap.js.map +1 -1
  371. package/dist/services/system-tax.d.ts +2 -3
  372. package/dist/services/system-tax.js +2 -2
  373. package/dist/services/system-tax.js.map +1 -1
  374. package/dist/services/tax-provider.d.ts +2 -0
  375. package/dist/services/tax-provider.js +96 -7
  376. package/dist/services/tax-provider.js.map +1 -1
  377. package/dist/services/tax-rate.d.ts +3 -3
  378. package/dist/services/tax-rate.js +1 -1
  379. package/dist/services/tax-rate.js.map +1 -1
  380. package/dist/services/totals.d.ts +9 -8
  381. package/dist/services/totals.js +41 -88
  382. package/dist/services/totals.js.map +1 -1
  383. package/dist/strategies/price-selection.d.ts +13 -0
  384. package/dist/strategies/price-selection.js +185 -0
  385. package/dist/strategies/price-selection.js.map +1 -0
  386. package/dist/subscribers/order.js +1 -7
  387. package/dist/subscribers/order.js.map +1 -1
  388. package/dist/types/batch-job.d.ts +6 -0
  389. package/dist/types/batch-job.js +11 -0
  390. package/dist/types/batch-job.js.map +1 -0
  391. package/dist/types/common.d.ts +1 -3
  392. package/dist/types/customers.d.ts +1 -0
  393. package/dist/types/customers.js +5 -0
  394. package/dist/types/customers.js.map +1 -1
  395. package/dist/types/discount.d.ts +69 -1
  396. package/dist/types/discount.js +129 -5
  397. package/dist/types/discount.js.map +1 -1
  398. package/dist/types/global.d.ts +34 -0
  399. package/dist/types/global.js +3 -0
  400. package/dist/types/global.js.map +1 -0
  401. package/dist/types/line-item-adjustment.d.ts +9 -0
  402. package/dist/types/line-item-adjustment.js +50 -0
  403. package/dist/types/line-item-adjustment.js.map +1 -0
  404. package/dist/types/price-list.d.ts +70 -0
  405. package/dist/types/price-list.js +152 -0
  406. package/dist/types/price-list.js.map +1 -0
  407. package/dist/types/price-selection.d.ts +5 -0
  408. package/dist/types/price-selection.js +35 -0
  409. package/dist/types/price-selection.js.map +1 -0
  410. package/dist/types/product-variant.d.ts +26 -3
  411. package/dist/types/product-variant.js +69 -5
  412. package/dist/types/product-variant.js.map +1 -1
  413. package/dist/types/product.d.ts +16 -0
  414. package/dist/types/product.js +86 -1
  415. package/dist/types/product.js.map +1 -1
  416. package/dist/types/validators/exactly-one.d.ts +6 -0
  417. package/dist/types/validators/exactly-one.js +37 -0
  418. package/dist/types/validators/exactly-one.js.map +1 -0
  419. package/dist/utils/date-helpers.d.ts +2 -0
  420. package/dist/utils/date-helpers.js +15 -0
  421. package/dist/utils/date-helpers.js.map +1 -0
  422. package/dist/utils/get-query-config.d.ts +11 -0
  423. package/dist/utils/get-query-config.js +88 -0
  424. package/dist/utils/get-query-config.js.map +1 -0
  425. package/package.json +7 -8
  426. package/dist/api/routes/admin/discounts/add-valid-product.d.ts +0 -23
  427. package/dist/api/routes/admin/discounts/add-valid-product.js.map +0 -1
  428. package/dist/api/routes/admin/discounts/remove-valid-product.d.ts +0 -23
  429. package/dist/api/routes/admin/discounts/remove-valid-product.js.map +0 -1
  430. package/dist/api/routes/admin/orders/receive-swap.d.ts +0 -46
  431. package/dist/api/routes/admin/orders/receive-swap.js.map +0 -1
  432. package/dist/api/routes/store/carts/update-payment-method.d.ts +0 -38
  433. package/dist/api/routes/store/carts/update-payment-method.js.map +0 -1
  434. package/dist/config/index.d.ts +0 -14
  435. package/dist/config/index.js +0 -40
  436. package/dist/config/index.js.map +0 -1
  437. package/dist/controllers/list-customers.d.ts +0 -0
  438. package/dist/controllers/list-customers.js +0 -1
  439. package/dist/controllers/list-customers.js.map +0 -1
  440. package/yarn-error.log +0 -6769
@@ -0,0 +1,469 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
54
+ var t = {};
55
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
56
+ t[p] = s[p];
57
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
58
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
59
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
60
+ t[p[i]] = s[p[i]];
61
+ }
62
+ return t;
63
+ };
64
+ var __values = (this && this.__values) || function(o) {
65
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
66
+ if (m) return m.call(o);
67
+ if (o && typeof o.length === "number") return {
68
+ next: function () {
69
+ if (o && i >= o.length) o = void 0;
70
+ return { value: o && o[i++], done: !o };
71
+ }
72
+ };
73
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
74
+ };
75
+ var __read = (this && this.__read) || function (o, n) {
76
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
77
+ if (!m) return o;
78
+ var i = m.call(o), r, ar = [], e;
79
+ try {
80
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
81
+ }
82
+ catch (error) { e = { error: error }; }
83
+ finally {
84
+ try {
85
+ if (r && !r.done && (m = i["return"])) m.call(i);
86
+ }
87
+ finally { if (e) throw e.error; }
88
+ }
89
+ return ar;
90
+ };
91
+ Object.defineProperty(exports, "__esModule", { value: true });
92
+ var medusa_core_utils_1 = require("medusa-core-utils");
93
+ var medusa_interfaces_1 = require("medusa-interfaces");
94
+ var exception_formatter_1 = require("../utils/exception-formatter");
95
+ /**
96
+ * Provides layer to manipulate product tags.
97
+ * @extends BaseService
98
+ */
99
+ var PriceListService = /** @class */ (function (_super) {
100
+ __extends(PriceListService, _super);
101
+ function PriceListService(_a) {
102
+ var manager = _a.manager, customerGroupService = _a.customerGroupService, priceListRepository = _a.priceListRepository, moneyAmountRepository = _a.moneyAmountRepository;
103
+ var _this = _super.call(this) || this;
104
+ _this.manager_ = manager;
105
+ _this.customerGroupService_ = customerGroupService;
106
+ _this.priceListRepo_ = priceListRepository;
107
+ _this.moneyAmountRepo_ = moneyAmountRepository;
108
+ return _this;
109
+ }
110
+ PriceListService.prototype.withTransaction = function (transactionManager) {
111
+ if (!transactionManager) {
112
+ return this;
113
+ }
114
+ var cloned = new PriceListService({
115
+ manager: transactionManager,
116
+ customerGroupService: this.customerGroupService_,
117
+ priceListRepository: this.priceListRepo_,
118
+ moneyAmountRepository: this.moneyAmountRepo_,
119
+ });
120
+ cloned.transactionManager_ = transactionManager;
121
+ return cloned;
122
+ };
123
+ /**
124
+ * Retrieves a product tag by id.
125
+ * @param {string} priceListId - the id of the product tag to retrieve
126
+ * @param {Object} config - the config to retrieve the tag by
127
+ * @return {Promise<PriceList>} the collection.
128
+ */
129
+ PriceListService.prototype.retrieve = function (priceListId, config) {
130
+ if (config === void 0) { config = {}; }
131
+ return __awaiter(this, void 0, void 0, function () {
132
+ var priceListRepo, query, priceList;
133
+ return __generator(this, function (_a) {
134
+ switch (_a.label) {
135
+ case 0:
136
+ priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
137
+ query = this.buildQuery_({ id: priceListId }, config);
138
+ return [4 /*yield*/, priceListRepo.findOne(query)];
139
+ case 1:
140
+ priceList = _a.sent();
141
+ if (!priceList) {
142
+ throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Price list with id: ".concat(priceListId, " was not found"));
143
+ }
144
+ return [2 /*return*/, priceList];
145
+ }
146
+ });
147
+ });
148
+ };
149
+ /**
150
+ * Creates a Price List
151
+ * @param {CreatePriceListInput} priceListObject - the Price List to create
152
+ * @return {Promise<PriceList>} created Price List
153
+ */
154
+ PriceListService.prototype.create = function (priceListObject) {
155
+ return __awaiter(this, void 0, void 0, function () {
156
+ var _this = this;
157
+ return __generator(this, function (_a) {
158
+ switch (_a.label) {
159
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
160
+ var priceListRepo, moneyAmountRepo, prices, customer_groups, rest, entity, priceList, result, error_1;
161
+ return __generator(this, function (_a) {
162
+ switch (_a.label) {
163
+ case 0:
164
+ priceListRepo = manager.getCustomRepository(this.priceListRepo_);
165
+ moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
166
+ prices = priceListObject.prices, customer_groups = priceListObject.customer_groups, rest = __rest(priceListObject, ["prices", "customer_groups"]);
167
+ _a.label = 1;
168
+ case 1:
169
+ _a.trys.push([1, 8, , 9]);
170
+ entity = priceListRepo.create(rest);
171
+ return [4 /*yield*/, priceListRepo.save(entity)];
172
+ case 2:
173
+ priceList = _a.sent();
174
+ if (!prices) return [3 /*break*/, 4];
175
+ return [4 /*yield*/, moneyAmountRepo.addPriceListPrices(priceList.id, prices)];
176
+ case 3:
177
+ _a.sent();
178
+ _a.label = 4;
179
+ case 4:
180
+ if (!customer_groups) return [3 /*break*/, 6];
181
+ return [4 /*yield*/, this.upsertCustomerGroups_(priceList.id, customer_groups)];
182
+ case 5:
183
+ _a.sent();
184
+ _a.label = 6;
185
+ case 6: return [4 /*yield*/, this.retrieve(priceList.id, {
186
+ relations: ["prices", "customer_groups"],
187
+ })];
188
+ case 7:
189
+ result = _a.sent();
190
+ return [2 /*return*/, result];
191
+ case 8:
192
+ error_1 = _a.sent();
193
+ throw (0, exception_formatter_1.formatException)(error_1);
194
+ case 9: return [2 /*return*/];
195
+ }
196
+ });
197
+ }); })];
198
+ case 1: return [2 /*return*/, _a.sent()];
199
+ }
200
+ });
201
+ });
202
+ };
203
+ /**
204
+ * Updates a Price List
205
+ * @param {string} id - the id of the Product List to update
206
+ * @param {UpdatePriceListInput} update - the update to apply
207
+ * @returns {Promise<PriceList>} updated Price List
208
+ */
209
+ PriceListService.prototype.update = function (id, update) {
210
+ return __awaiter(this, void 0, void 0, function () {
211
+ var _this = this;
212
+ return __generator(this, function (_a) {
213
+ switch (_a.label) {
214
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
215
+ var priceListRepo, moneyAmountRepo, priceList, prices, customer_groups, rest, _a, _b, _c, key, value, result;
216
+ var e_1, _d;
217
+ return __generator(this, function (_e) {
218
+ switch (_e.label) {
219
+ case 0:
220
+ priceListRepo = manager.getCustomRepository(this.priceListRepo_);
221
+ moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
222
+ return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
223
+ case 1:
224
+ priceList = _e.sent();
225
+ prices = update.prices, customer_groups = update.customer_groups, rest = __rest(update, ["prices", "customer_groups"]);
226
+ try {
227
+ for (_a = __values(Object.entries(rest)), _b = _a.next(); !_b.done; _b = _a.next()) {
228
+ _c = __read(_b.value, 2), key = _c[0], value = _c[1];
229
+ priceList[key] = value;
230
+ }
231
+ }
232
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
233
+ finally {
234
+ try {
235
+ if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
236
+ }
237
+ finally { if (e_1) throw e_1.error; }
238
+ }
239
+ return [4 /*yield*/, priceListRepo.save(priceList)];
240
+ case 2:
241
+ _e.sent();
242
+ if (!prices) return [3 /*break*/, 4];
243
+ return [4 /*yield*/, moneyAmountRepo.updatePriceListPrices(id, prices)];
244
+ case 3:
245
+ _e.sent();
246
+ _e.label = 4;
247
+ case 4:
248
+ if (!customer_groups) return [3 /*break*/, 6];
249
+ return [4 /*yield*/, this.upsertCustomerGroups_(id, customer_groups)];
250
+ case 5:
251
+ _e.sent();
252
+ _e.label = 6;
253
+ case 6: return [4 /*yield*/, this.retrieve(id, {
254
+ relations: ["prices", "customer_groups"],
255
+ })];
256
+ case 7:
257
+ result = _e.sent();
258
+ return [2 /*return*/, result];
259
+ }
260
+ });
261
+ }); })];
262
+ case 1: return [2 /*return*/, _a.sent()];
263
+ }
264
+ });
265
+ });
266
+ };
267
+ /**
268
+ * Adds prices to a price list in bulk, optionally replacing all existing prices
269
+ * @param id - id of the price list
270
+ * @param prices - prices to add
271
+ * @param replace - whether to replace existing prices
272
+ * @returns {Promise<PriceList>} updated Price List
273
+ */
274
+ PriceListService.prototype.addPrices = function (id, prices, replace) {
275
+ if (replace === void 0) { replace = false; }
276
+ return __awaiter(this, void 0, void 0, function () {
277
+ var _this = this;
278
+ return __generator(this, function (_a) {
279
+ switch (_a.label) {
280
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
281
+ var moneyAmountRepo, priceList, result;
282
+ return __generator(this, function (_a) {
283
+ switch (_a.label) {
284
+ case 0:
285
+ moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
286
+ return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
287
+ case 1:
288
+ priceList = _a.sent();
289
+ return [4 /*yield*/, moneyAmountRepo.addPriceListPrices(priceList.id, prices, replace)];
290
+ case 2:
291
+ _a.sent();
292
+ return [4 /*yield*/, this.retrieve(priceList.id, {
293
+ relations: ["prices"],
294
+ })];
295
+ case 3:
296
+ result = _a.sent();
297
+ return [2 /*return*/, result];
298
+ }
299
+ });
300
+ }); })];
301
+ case 1: return [2 /*return*/, _a.sent()];
302
+ }
303
+ });
304
+ });
305
+ };
306
+ /**
307
+ * Removes prices from a price list and deletes the removed prices in bulk
308
+ * @param id - id of the price list
309
+ * @param priceIds - ids of the prices to delete
310
+ * @returns {Promise<void>} updated Price List
311
+ */
312
+ PriceListService.prototype.deletePrices = function (id, priceIds) {
313
+ return __awaiter(this, void 0, void 0, function () {
314
+ var _this = this;
315
+ return __generator(this, function (_a) {
316
+ switch (_a.label) {
317
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
318
+ var moneyAmountRepo, priceList;
319
+ return __generator(this, function (_a) {
320
+ switch (_a.label) {
321
+ case 0:
322
+ moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
323
+ return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
324
+ case 1:
325
+ priceList = _a.sent();
326
+ return [4 /*yield*/, moneyAmountRepo.deletePriceListPrices(priceList.id, priceIds)];
327
+ case 2:
328
+ _a.sent();
329
+ return [2 /*return*/, Promise.resolve()];
330
+ }
331
+ });
332
+ }); })];
333
+ case 1: return [2 /*return*/, _a.sent()];
334
+ }
335
+ });
336
+ });
337
+ };
338
+ /**
339
+ * Deletes a Price List
340
+ * Will never fail due to delete being idempotent.
341
+ * @param id - id of the price list
342
+ * @returns {Promise<void>} empty promise
343
+ */
344
+ PriceListService.prototype.delete = function (id) {
345
+ return __awaiter(this, void 0, void 0, function () {
346
+ var _this = this;
347
+ return __generator(this, function (_a) {
348
+ switch (_a.label) {
349
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
350
+ var priceListRepo, priceList;
351
+ return __generator(this, function (_a) {
352
+ switch (_a.label) {
353
+ case 0:
354
+ priceListRepo = manager.getCustomRepository(this.priceListRepo_);
355
+ return [4 /*yield*/, priceListRepo.findOne({ where: { id: id } })];
356
+ case 1:
357
+ priceList = _a.sent();
358
+ if (!priceList) {
359
+ return [2 /*return*/, Promise.resolve()];
360
+ }
361
+ return [4 /*yield*/, priceListRepo.delete(priceList)];
362
+ case 2:
363
+ _a.sent();
364
+ return [2 /*return*/, Promise.resolve()];
365
+ }
366
+ });
367
+ }); })];
368
+ case 1: return [2 /*return*/, _a.sent()];
369
+ }
370
+ });
371
+ });
372
+ };
373
+ /**
374
+ * Lists Price Lists
375
+ * @param {Object} selector - the query object for find
376
+ * @param {Object} config - the config to be used for find
377
+ * @return {Promise<PriceList[]>} the result of the find operation
378
+ */
379
+ PriceListService.prototype.list = function (selector, config) {
380
+ if (selector === void 0) { selector = {}; }
381
+ if (config === void 0) { config = { skip: 0, take: 20 }; }
382
+ return __awaiter(this, void 0, void 0, function () {
383
+ var priceListRepo, query;
384
+ return __generator(this, function (_a) {
385
+ switch (_a.label) {
386
+ case 0:
387
+ priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
388
+ query = this.buildQuery_(selector, config);
389
+ return [4 /*yield*/, priceListRepo.find(query)];
390
+ case 1: return [2 /*return*/, _a.sent()];
391
+ }
392
+ });
393
+ });
394
+ };
395
+ /**
396
+ * Lists Price Lists and adds count
397
+ * @param {Object} selector - the query object for find
398
+ * @param {Object} config - the config to be used for find
399
+ * @return {Promise} the result of the find operation
400
+ */
401
+ PriceListService.prototype.listAndCount = function (selector, config) {
402
+ if (selector === void 0) { selector = {}; }
403
+ if (config === void 0) { config = { skip: 0, take: 20 }; }
404
+ return __awaiter(this, void 0, void 0, function () {
405
+ var priceListRepo, query;
406
+ return __generator(this, function (_a) {
407
+ switch (_a.label) {
408
+ case 0:
409
+ priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
410
+ query = this.buildQuery_(selector, config);
411
+ return [4 /*yield*/, priceListRepo.findAndCount(query)];
412
+ case 1: return [2 /*return*/, _a.sent()];
413
+ }
414
+ });
415
+ });
416
+ };
417
+ PriceListService.prototype.upsertCustomerGroups_ = function (priceListId, customerGroups) {
418
+ return __awaiter(this, void 0, void 0, function () {
419
+ var priceListRepo, priceList, groups, customerGroups_1, customerGroups_1_1, cg, customerGroup, e_2_1;
420
+ var e_2, _a;
421
+ return __generator(this, function (_b) {
422
+ switch (_b.label) {
423
+ case 0:
424
+ priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
425
+ return [4 /*yield*/, this.retrieve(priceListId, { select: ["id"] })];
426
+ case 1:
427
+ priceList = _b.sent();
428
+ groups = [];
429
+ _b.label = 2;
430
+ case 2:
431
+ _b.trys.push([2, 7, 8, 9]);
432
+ customerGroups_1 = __values(customerGroups), customerGroups_1_1 = customerGroups_1.next();
433
+ _b.label = 3;
434
+ case 3:
435
+ if (!!customerGroups_1_1.done) return [3 /*break*/, 6];
436
+ cg = customerGroups_1_1.value;
437
+ return [4 /*yield*/, this.customerGroupService_.retrieve(cg.id)];
438
+ case 4:
439
+ customerGroup = _b.sent();
440
+ groups.push(customerGroup);
441
+ _b.label = 5;
442
+ case 5:
443
+ customerGroups_1_1 = customerGroups_1.next();
444
+ return [3 /*break*/, 3];
445
+ case 6: return [3 /*break*/, 9];
446
+ case 7:
447
+ e_2_1 = _b.sent();
448
+ e_2 = { error: e_2_1 };
449
+ return [3 /*break*/, 9];
450
+ case 8:
451
+ try {
452
+ if (customerGroups_1_1 && !customerGroups_1_1.done && (_a = customerGroups_1.return)) _a.call(customerGroups_1);
453
+ }
454
+ finally { if (e_2) throw e_2.error; }
455
+ return [7 /*endfinally*/];
456
+ case 9:
457
+ priceList.customer_groups = groups;
458
+ return [4 /*yield*/, priceListRepo.save(priceList)];
459
+ case 10:
460
+ _b.sent();
461
+ return [2 /*return*/];
462
+ }
463
+ });
464
+ });
465
+ };
466
+ return PriceListService;
467
+ }(medusa_interfaces_1.BaseService));
468
+ exports.default = PriceListService;
469
+ //# sourceMappingURL=price-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-list.js","sourceRoot":"","sources":["../../src/services/price-list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAC/C,uDAA+C;AAc/C,oEAA8D;AAS9D;;;GAGG;AACH;IAA+B,oCAAW;IAMxC,0BAAY,EAKgB;YAJ1B,OAAO,aAAA,EACP,oBAAoB,0BAAA,EACpB,mBAAmB,yBAAA,EACnB,qBAAqB,2BAAA;QAJvB,YAME,iBAAO,SAKR;QAJC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,KAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAA;QACjD,KAAI,CAAC,cAAc,GAAG,mBAAmB,CAAA;QACzC,KAAI,CAAC,gBAAgB,GAAG,qBAAqB,CAAA;;IAC/C,CAAC;IAED,0CAAe,GAAf,UAAgB,kBAAiC;QAC/C,IAAI,CAAC,kBAAkB,EAAE;YACvB,OAAO,IAAI,CAAA;SACZ;QAED,IAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC;YAClC,OAAO,EAAE,kBAAkB;YAC3B,oBAAoB,EAAE,IAAI,CAAC,qBAAqB;YAChD,mBAAmB,EAAE,IAAI,CAAC,cAAc;YACxC,qBAAqB,EAAE,IAAI,CAAC,gBAAgB;SAC7C,CAAC,CAAA;QAEF,MAAM,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAE/C,OAAO,MAAM,CAAA;IACf,CAAC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CAAC,CAAA;;;;;;;;;;;;;;;;;wBAG5B,SAAS,CAAC,eAAe,GAAG,MAAM,CAAA;wBAElC,qBAAM,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,EAAA;;wBAAnC,SAAmC,CAAA;;;;;KACpC;IACH,uBAAC;AAAD,CAAC,AA1PD,CAA+B,+BAAW,GA0PzC;AAED,kBAAe,gBAAgB,CAAA"}
@@ -1,12 +1,13 @@
1
1
  import { BaseService } from "medusa-interfaces";
2
2
  import { EntityManager, SelectQueryBuilder } from "typeorm";
3
+ import { PriceSelectionContext } from "../interfaces/price-selection-strategy";
3
4
  import { MoneyAmount } from "../models/money-amount";
4
5
  import { Product } from "../models/product";
5
6
  import { ProductOptionValue } from "../models/product-option-value";
6
7
  import { ProductVariant } from "../models/product-variant";
7
8
  import { FindWithRelationsOptions, ProductVariantRepository } from "../repositories/product-variant";
8
9
  import { FindConfig } from "../types/common";
9
- import { CreateProductVariantInput, FilterableProductVariantProps, ProductVariantPrice, UpdateProductVariantInput } from "../types/product-variant";
10
+ import { CreateProductVariantInput, FilterableProductVariantProps, GetRegionPriceContext, ProductVariantPrice, UpdateProductVariantInput } from "../types/product-variant";
10
11
  /**
11
12
  * Provides layer to manipulate product variants.
12
13
  * @extends BaseService
@@ -22,9 +23,11 @@ declare class ProductVariantService extends BaseService {
22
23
  private productRepository_;
23
24
  private eventBus_;
24
25
  private regionService_;
26
+ private priceSelectionStrategy_;
25
27
  private moneyAmountRepository_;
26
28
  private productOptionValueRepository_;
27
- constructor({ manager, productVariantRepository, productRepository, eventBusService, regionService, moneyAmountRepository, productOptionValueRepository, }: {
29
+ private cartRepository_;
30
+ constructor({ manager, productVariantRepository, productRepository, eventBusService, regionService, moneyAmountRepository, productOptionValueRepository, cartRepository, priceSelectionStrategy, }: {
28
31
  manager: any;
29
32
  productVariantRepository: any;
30
33
  productRepository: any;
@@ -32,6 +35,8 @@ declare class ProductVariantService extends BaseService {
32
35
  regionService: any;
33
36
  moneyAmountRepository: any;
34
37
  productOptionValueRepository: any;
38
+ cartRepository: any;
39
+ priceSelectionStrategy: any;
35
40
  });
36
41
  withTransaction(transactionManager: EntityManager): ProductVariantService;
37
42
  /**
@@ -40,14 +45,14 @@ declare class ProductVariantService extends BaseService {
40
45
  * @param {FindConfig<ProductVariant>} config - query config object for variant retrieval.
41
46
  * @return {Promise<Product>} the product document.
42
47
  */
43
- retrieve(variantId: string, config?: FindConfig<ProductVariant>): Promise<ProductVariant>;
48
+ retrieve(variantId: string, config?: FindConfig<ProductVariant> & PriceSelectionContext): Promise<ProductVariant>;
44
49
  /**
45
50
  * Gets a product variant by id.
46
51
  * @param {string} sku - The unique stock keeping unit used to identify the product variant.
47
52
  * @param {FindConfig<ProductVariant>} config - query config object for variant retrieval.
48
53
  * @return {Promise<Product>} the product document.
49
54
  */
50
- retrieveBySKU(sku: string, config?: FindConfig<ProductVariant>): Promise<ProductVariant>;
55
+ retrieveBySKU(sku: string, config?: FindConfig<ProductVariant> & PriceSelectionContext): Promise<ProductVariant>;
51
56
  /**
52
57
  * Creates an unpublished product variant. Will validate against parent product
53
58
  * to ensure that the variant can in fact be created.
@@ -62,33 +67,41 @@ declare class ProductVariantService extends BaseService {
62
67
  * The function will throw, if price updates are attempted.
63
68
  * @param {string | ProductVariant} variantOrVariantId - variant or id of a variant.
64
69
  * @param {object} update - an object with the update values.
70
+ * @param {object} config - an object with the config values for returning the variant.
65
71
  * @return {Promise} resolves to the update result.
66
72
  */
67
73
  update(variantOrVariantId: string | Partial<ProductVariant>, update: UpdateProductVariantInput): Promise<ProductVariant>;
68
- updateVariantPrices(variantId: string, prices: ProductVariantPrice[]): Promise<void>;
69
74
  /**
70
- * Sets the default price for the given currency.
71
- * @param {string} variantId - the id of the variant to set prices for
72
- * @param {ProductVariantPrice} price - the price for the variant
73
- * @return {Promise} the result of the update operation
75
+ * Updates a variant's prices.
76
+ * Deletes any prices that are not in the update object, and is not associated with a price list.
77
+ * @param variantId - the id of variant variant
78
+ * @param prices - the update prices
79
+ * @returns {Promise<void>} empty promise
74
80
  */
75
- setCurrencyPrice(variantId: string, price: ProductVariantPrice): Promise<MoneyAmount>;
81
+ updateVariantPrices(variantId: string, prices: ProductVariantPrice[]): Promise<void>;
76
82
  /**
77
83
  * Gets the price specific to a region. If no region specific money amount
78
84
  * exists the function will try to use a currency price. If no default
79
85
  * currency price exists the function will throw an error.
80
86
  * @param {string} variantId - the id of the variant to get price from
81
- * @param {string} regionId - the id of the region to get price for
87
+ * @param {GetRegionPriceContext} context - context for getting region price
82
88
  * @return {number} the price specific to the region
83
89
  */
84
- getRegionPrice(variantId: string, regionId: string): Promise<number>;
90
+ getRegionPrice(variantId: string, context: GetRegionPriceContext): Promise<number>;
85
91
  /**
86
- * Sets the price of a specific region
92
+ * Sets the default price of a specific region
87
93
  * @param {string} variantId - the id of the variant to update
88
94
  * @param {string} price - the price for the variant.
89
95
  * @return {Promise} the result of the update operation
90
96
  */
91
97
  setRegionPrice(variantId: string, price: ProductVariantPrice): Promise<MoneyAmount>;
98
+ /**
99
+ * Sets the default price for the given currency.
100
+ * @param {string} variantId - the id of the variant to set prices for
101
+ * @param {ProductVariantPrice} price - the price for the variant
102
+ * @return {Promise} the result of the update operation
103
+ */
104
+ setCurrencyPrice(variantId: string, price: ProductVariantPrice): Promise<MoneyAmount>;
92
105
  /**
93
106
  * Updates variant's option value.
94
107
  * Option value must be of type string or number.
@@ -123,13 +136,13 @@ declare class ProductVariantService extends BaseService {
123
136
  * @param {FindConfig<ProductVariant>} config - query config object for variant retrieval
124
137
  * @return {Promise} the result of the find operation
125
138
  */
126
- listAndCount(selector: FilterableProductVariantProps, config?: FindConfig<ProductVariant>): Promise<[ProductVariant[], number]>;
139
+ listAndCount(selector: FilterableProductVariantProps, config?: FindConfig<ProductVariant> & PriceSelectionContext): Promise<[ProductVariant[], number]>;
127
140
  /**
128
141
  * @param {FilterableProductVariantProps} selector - the query object for find
129
142
  * @param {FindConfig<ProductVariant>} config - query config object for variant retrieval
130
143
  * @return {Promise} the result of the find operation
131
144
  */
132
- list(selector: FilterableProductVariantProps, config?: FindConfig<ProductVariant>): Promise<ProductVariant[]>;
145
+ list(selector: FilterableProductVariantProps, config?: FindConfig<ProductVariant> & PriceSelectionContext): Promise<ProductVariant[]>;
133
146
  /**
134
147
  * Deletes variant.
135
148
  * Will never fail due to delete being idempotent.
@@ -144,7 +157,7 @@ declare class ProductVariantService extends BaseService {
144
157
  * @param {Object} metadata - the metadata to set
145
158
  * @return {Object} updated metadata object
146
159
  */
147
- setMetadata_(variant: ProductVariant, metadata: object): Record<string, any>;
160
+ setMetadata_(variant: ProductVariant, metadata: object): Record<string, unknown>;
148
161
  /**
149
162
  * Creates a query object to be used for list queries.
150
163
  * @param {object} selector - the selector to create the query from
@@ -167,5 +180,16 @@ declare class ProductVariantService extends BaseService {
167
180
  * count of products that matches the query as the second element.
168
181
  */
169
182
  getFreeTextQueryBuilder_(variantRepo: ProductVariantRepository, query: FindWithRelationsOptions, q?: string): SelectQueryBuilder<ProductVariant>;
183
+ /**
184
+ * Set additional prices on a list of variants.
185
+ * @param {ProductVariant | ProductVariant[] } variant variant on which to set additional prices
186
+ * @param {string} currency_code currency code to fetch prices for
187
+ * @param {string} region_id region to fetch prices for
188
+ * @param {string} cart_id string of cart to use as a basis for getting currency and region
189
+ * @param {string} customer_id id of potentially logged in customer, used to get prices valid for their customer groups
190
+ * @param {boolean} include_discount_prices should result include discount pricing
191
+ * @return {Promise<ProductVariant | ProductVariant[]>} A list of variants with variants decorated with "additional_prices"
192
+ */
193
+ setAdditionalPrices(variant: any, currency_code: any, region_id: any, cart_id: any, customer_id: any, include_discount_prices?: boolean): Promise<ProductVariant | ProductVariant[]>;
170
194
  }
171
195
  export default ProductVariantService;