@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,34 @@
1
+ import { DeleteResult, EntityTarget, Repository } from "typeorm";
2
+ import { DiscountCondition, DiscountConditionType } from "../models/discount-condition";
3
+ import { DiscountConditionCustomerGroup } from "../models/discount-condition-customer-group";
4
+ import { DiscountConditionProduct } from "../models/discount-condition-product";
5
+ import { DiscountConditionProductCollection } from "../models/discount-condition-product-collection";
6
+ import { DiscountConditionProductTag } from "../models/discount-condition-product-tag";
7
+ import { DiscountConditionProductType } from "../models/discount-condition-product-type";
8
+ export declare enum DiscountConditionJoinTableForeignKey {
9
+ PRODUCT_ID = "product_id",
10
+ PRODUCT_TYPE_ID = "product_type_id",
11
+ PRODUCT_COLLECTION_ID = "product_collection_id",
12
+ PRODUCT_TAG_ID = "product_tag_id",
13
+ CUSTOMER_GROUP_ID = "customer_group_id"
14
+ }
15
+ declare type DiscountConditionResourceType = EntityTarget<DiscountConditionProduct | DiscountConditionProductType | DiscountConditionProductCollection | DiscountConditionProductTag | DiscountConditionCustomerGroup>;
16
+ export declare class DiscountConditionRepository extends Repository<DiscountCondition> {
17
+ getJoinTableResourceIdentifiers(type: string): {
18
+ joinTable: string;
19
+ resourceKey: string;
20
+ joinTableForeignKey: DiscountConditionJoinTableForeignKey;
21
+ conditionTable: DiscountConditionResourceType;
22
+ joinTableKey: string;
23
+ };
24
+ removeConditionResources(id: string, type: DiscountConditionType, resourceIds: string[]): Promise<DeleteResult | void>;
25
+ addConditionResources(conditionId: string, resourceIds: string[], type: DiscountConditionType, overrideExisting?: boolean): Promise<(DiscountConditionProduct | DiscountConditionProductType | DiscountConditionProductCollection | DiscountConditionProductTag | DiscountConditionCustomerGroup)[]>;
26
+ queryConditionTable({ type, condId, resourceId }: {
27
+ type: any;
28
+ condId: any;
29
+ resourceId: any;
30
+ }): Promise<number>;
31
+ isValidForProduct(discountRuleId: string, productId: string): Promise<boolean>;
32
+ canApplyForCustomer(discountRuleId: string, customerId: string): Promise<boolean>;
33
+ }
34
+ export {};
@@ -0,0 +1,384 @@
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
24
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25
+ return new (P || (P = Promise))(function (resolve, reject) {
26
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
27
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
28
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
29
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
30
+ });
31
+ };
32
+ var __generator = (this && this.__generator) || function (thisArg, body) {
33
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
34
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
35
+ function verb(n) { return function (v) { return step([n, v]); }; }
36
+ function step(op) {
37
+ if (f) throw new TypeError("Generator is already executing.");
38
+ while (_) try {
39
+ 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;
40
+ if (y = 0, t) op = [op[0] & 2, t.value];
41
+ switch (op[0]) {
42
+ case 0: case 1: t = op; break;
43
+ case 4: _.label++; return { value: op[1], done: false };
44
+ case 5: _.label++; y = op[1]; op = [0]; continue;
45
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
46
+ default:
47
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
48
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
49
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
50
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
51
+ if (t[2]) _.ops.pop();
52
+ _.trys.pop(); continue;
53
+ }
54
+ op = body.call(thisArg, _);
55
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
56
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
57
+ }
58
+ };
59
+ var __values = (this && this.__values) || function(o) {
60
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
61
+ if (m) return m.call(o);
62
+ if (o && typeof o.length === "number") return {
63
+ next: function () {
64
+ if (o && i >= o.length) o = void 0;
65
+ return { value: o && o[i++], done: !o };
66
+ }
67
+ };
68
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
69
+ };
70
+ Object.defineProperty(exports, "__esModule", { value: true });
71
+ exports.DiscountConditionRepository = exports.DiscountConditionJoinTableForeignKey = void 0;
72
+ var typeorm_1 = require("typeorm");
73
+ var discount_condition_1 = require("../models/discount-condition");
74
+ var discount_condition_customer_group_1 = require("../models/discount-condition-customer-group");
75
+ var discount_condition_product_1 = require("../models/discount-condition-product");
76
+ var discount_condition_product_collection_1 = require("../models/discount-condition-product-collection");
77
+ var discount_condition_product_tag_1 = require("../models/discount-condition-product-tag");
78
+ var discount_condition_product_type_1 = require("../models/discount-condition-product-type");
79
+ var DiscountConditionJoinTableForeignKey;
80
+ (function (DiscountConditionJoinTableForeignKey) {
81
+ DiscountConditionJoinTableForeignKey["PRODUCT_ID"] = "product_id";
82
+ DiscountConditionJoinTableForeignKey["PRODUCT_TYPE_ID"] = "product_type_id";
83
+ DiscountConditionJoinTableForeignKey["PRODUCT_COLLECTION_ID"] = "product_collection_id";
84
+ DiscountConditionJoinTableForeignKey["PRODUCT_TAG_ID"] = "product_tag_id";
85
+ DiscountConditionJoinTableForeignKey["CUSTOMER_GROUP_ID"] = "customer_group_id";
86
+ })(DiscountConditionJoinTableForeignKey = exports.DiscountConditionJoinTableForeignKey || (exports.DiscountConditionJoinTableForeignKey = {}));
87
+ var DiscountConditionRepository = /** @class */ (function (_super) {
88
+ __extends(DiscountConditionRepository, _super);
89
+ function DiscountConditionRepository() {
90
+ return _super !== null && _super.apply(this, arguments) || this;
91
+ }
92
+ DiscountConditionRepository.prototype.getJoinTableResourceIdentifiers = function (type) {
93
+ var conditionTable = discount_condition_product_1.DiscountConditionProduct;
94
+ var joinTable = "product";
95
+ var joinTableForeignKey = DiscountConditionJoinTableForeignKey.PRODUCT_ID;
96
+ var joinTableKey = "id";
97
+ // On the joined table (e.g. `product`), what key should be match on
98
+ // (e.g `type_id` for product types and `id` for products)
99
+ var resourceKey;
100
+ switch (type) {
101
+ case discount_condition_1.DiscountConditionType.PRODUCTS: {
102
+ resourceKey = "id";
103
+ joinTableForeignKey = DiscountConditionJoinTableForeignKey.PRODUCT_ID;
104
+ joinTable = "product";
105
+ conditionTable = discount_condition_product_1.DiscountConditionProduct;
106
+ break;
107
+ }
108
+ case discount_condition_1.DiscountConditionType.PRODUCT_TYPES: {
109
+ resourceKey = "type_id";
110
+ joinTableForeignKey =
111
+ DiscountConditionJoinTableForeignKey.PRODUCT_TYPE_ID;
112
+ joinTable = "product";
113
+ conditionTable = discount_condition_product_type_1.DiscountConditionProductType;
114
+ break;
115
+ }
116
+ case discount_condition_1.DiscountConditionType.PRODUCT_COLLECTIONS: {
117
+ resourceKey = "collection_id";
118
+ joinTableForeignKey =
119
+ DiscountConditionJoinTableForeignKey.PRODUCT_COLLECTION_ID;
120
+ joinTable = "product";
121
+ conditionTable = discount_condition_product_collection_1.DiscountConditionProductCollection;
122
+ break;
123
+ }
124
+ case discount_condition_1.DiscountConditionType.PRODUCT_TAGS: {
125
+ joinTableKey = "product_id";
126
+ resourceKey = "product_tag_id";
127
+ joinTableForeignKey =
128
+ DiscountConditionJoinTableForeignKey.PRODUCT_TAG_ID;
129
+ joinTable = "product_tags";
130
+ conditionTable = discount_condition_product_tag_1.DiscountConditionProductTag;
131
+ break;
132
+ }
133
+ case discount_condition_1.DiscountConditionType.CUSTOMER_GROUPS: {
134
+ joinTableKey = "customer_id";
135
+ resourceKey = "customer_group_id";
136
+ joinTable = "customer_group_customers";
137
+ joinTableForeignKey =
138
+ DiscountConditionJoinTableForeignKey.CUSTOMER_GROUP_ID;
139
+ conditionTable = discount_condition_customer_group_1.DiscountConditionCustomerGroup;
140
+ break;
141
+ }
142
+ default:
143
+ break;
144
+ }
145
+ return {
146
+ joinTable: joinTable,
147
+ joinTableKey: joinTableKey,
148
+ resourceKey: resourceKey,
149
+ joinTableForeignKey: joinTableForeignKey,
150
+ conditionTable: conditionTable,
151
+ };
152
+ };
153
+ DiscountConditionRepository.prototype.removeConditionResources = function (id, type, resourceIds) {
154
+ return __awaiter(this, void 0, void 0, function () {
155
+ var _a, conditionTable, joinTableForeignKey;
156
+ var _b;
157
+ return __generator(this, function (_c) {
158
+ switch (_c.label) {
159
+ case 0:
160
+ _a = this.getJoinTableResourceIdentifiers(type), conditionTable = _a.conditionTable, joinTableForeignKey = _a.joinTableForeignKey;
161
+ if (!conditionTable || !joinTableForeignKey) {
162
+ return [2 /*return*/, Promise.resolve()];
163
+ }
164
+ return [4 /*yield*/, this.createQueryBuilder()
165
+ .delete()
166
+ .from(conditionTable)
167
+ .where((_b = { condition_id: id }, _b[joinTableForeignKey] = (0, typeorm_1.In)(resourceIds), _b))
168
+ .execute()];
169
+ case 1: return [2 /*return*/, _c.sent()];
170
+ }
171
+ });
172
+ });
173
+ };
174
+ DiscountConditionRepository.prototype.addConditionResources = function (conditionId, resourceIds, type, overrideExisting) {
175
+ if (overrideExisting === void 0) { overrideExisting = false; }
176
+ return __awaiter(this, void 0, void 0, function () {
177
+ var toInsert, _a, conditionTable, joinTableForeignKey, insertResult;
178
+ var _b;
179
+ return __generator(this, function (_c) {
180
+ switch (_c.label) {
181
+ case 0:
182
+ toInsert = [];
183
+ _a = this.getJoinTableResourceIdentifiers(type), conditionTable = _a.conditionTable, joinTableForeignKey = _a.joinTableForeignKey;
184
+ if (!conditionTable || !joinTableForeignKey) {
185
+ return [2 /*return*/, Promise.resolve([])];
186
+ }
187
+ toInsert = resourceIds.map(function (rId) {
188
+ var _a;
189
+ return (_a = {
190
+ condition_id: conditionId
191
+ },
192
+ _a[joinTableForeignKey] = rId,
193
+ _a);
194
+ });
195
+ return [4 /*yield*/, this.createQueryBuilder()
196
+ .insert()
197
+ .orIgnore(true)
198
+ .into(conditionTable)
199
+ .values(toInsert)
200
+ .execute()];
201
+ case 1:
202
+ insertResult = _c.sent();
203
+ if (!overrideExisting) return [3 /*break*/, 3];
204
+ return [4 /*yield*/, this.createQueryBuilder()
205
+ .delete()
206
+ .from(conditionTable)
207
+ .where((_b = {
208
+ condition_id: conditionId
209
+ },
210
+ _b[joinTableForeignKey] = (0, typeorm_1.Not)((0, typeorm_1.In)(resourceIds)),
211
+ _b))
212
+ .execute()];
213
+ case 2:
214
+ _c.sent();
215
+ _c.label = 3;
216
+ case 3: return [4 /*yield*/, this.manager
217
+ .createQueryBuilder(conditionTable, "discon")
218
+ .select()
219
+ .where(insertResult.identifiers)
220
+ .getMany()];
221
+ case 4: return [2 /*return*/, _c.sent()];
222
+ }
223
+ });
224
+ });
225
+ };
226
+ DiscountConditionRepository.prototype.queryConditionTable = function (_a) {
227
+ var type = _a.type, condId = _a.condId, resourceId = _a.resourceId;
228
+ return __awaiter(this, void 0, void 0, function () {
229
+ var _b, conditionTable, joinTable, joinTableForeignKey, resourceKey, joinTableKey;
230
+ return __generator(this, function (_c) {
231
+ switch (_c.label) {
232
+ case 0:
233
+ _b = this.getJoinTableResourceIdentifiers(type), conditionTable = _b.conditionTable, joinTable = _b.joinTable, joinTableForeignKey = _b.joinTableForeignKey, resourceKey = _b.resourceKey, joinTableKey = _b.joinTableKey;
234
+ return [4 /*yield*/, this.manager
235
+ .createQueryBuilder(conditionTable, "dc")
236
+ .innerJoin(joinTable, "resource", "dc.".concat(joinTableForeignKey, " = resource.").concat(resourceKey, " and resource.").concat(joinTableKey, " = :resourceId "), {
237
+ resourceId: resourceId,
238
+ })
239
+ .where("dc.condition_id = :conditionId", {
240
+ conditionId: condId,
241
+ })
242
+ .getCount()];
243
+ case 1: return [2 /*return*/, _c.sent()];
244
+ }
245
+ });
246
+ });
247
+ };
248
+ DiscountConditionRepository.prototype.isValidForProduct = function (discountRuleId, productId) {
249
+ return __awaiter(this, void 0, void 0, function () {
250
+ var discountConditions, discountConditions_1, discountConditions_1_1, condition, numConditions, e_1_1;
251
+ var e_1, _a;
252
+ return __generator(this, function (_b) {
253
+ switch (_b.label) {
254
+ case 0: return [4 /*yield*/, this.createQueryBuilder("discon")
255
+ .select(["discon.id", "discon.type", "discon.operator"])
256
+ .where("discon.discount_rule_id = :discountRuleId", {
257
+ discountRuleId: discountRuleId,
258
+ })
259
+ .getMany()
260
+ // in case of no discount conditions, we assume that the discount
261
+ // is valid for all
262
+ ];
263
+ case 1:
264
+ discountConditions = _b.sent();
265
+ // in case of no discount conditions, we assume that the discount
266
+ // is valid for all
267
+ if (!discountConditions.length) {
268
+ return [2 /*return*/, true];
269
+ }
270
+ _b.label = 2;
271
+ case 2:
272
+ _b.trys.push([2, 7, 8, 9]);
273
+ discountConditions_1 = __values(discountConditions), discountConditions_1_1 = discountConditions_1.next();
274
+ _b.label = 3;
275
+ case 3:
276
+ if (!!discountConditions_1_1.done) return [3 /*break*/, 6];
277
+ condition = discountConditions_1_1.value;
278
+ return [4 /*yield*/, this.queryConditionTable({
279
+ type: condition.type,
280
+ condId: condition.id,
281
+ resourceId: productId,
282
+ })];
283
+ case 4:
284
+ numConditions = _b.sent();
285
+ if (condition.operator === discount_condition_1.DiscountConditionOperator.IN &&
286
+ numConditions === 0) {
287
+ return [2 /*return*/, false];
288
+ }
289
+ if (condition.operator === discount_condition_1.DiscountConditionOperator.NOT_IN &&
290
+ numConditions > 0) {
291
+ return [2 /*return*/, false];
292
+ }
293
+ _b.label = 5;
294
+ case 5:
295
+ discountConditions_1_1 = discountConditions_1.next();
296
+ return [3 /*break*/, 3];
297
+ case 6: return [3 /*break*/, 9];
298
+ case 7:
299
+ e_1_1 = _b.sent();
300
+ e_1 = { error: e_1_1 };
301
+ return [3 /*break*/, 9];
302
+ case 8:
303
+ try {
304
+ if (discountConditions_1_1 && !discountConditions_1_1.done && (_a = discountConditions_1.return)) _a.call(discountConditions_1);
305
+ }
306
+ finally { if (e_1) throw e_1.error; }
307
+ return [7 /*endfinally*/];
308
+ case 9: return [2 /*return*/, true];
309
+ }
310
+ });
311
+ });
312
+ };
313
+ DiscountConditionRepository.prototype.canApplyForCustomer = function (discountRuleId, customerId) {
314
+ return __awaiter(this, void 0, void 0, function () {
315
+ var discountConditions, discountConditions_2, discountConditions_2_1, condition, numConditions, e_2_1;
316
+ var e_2, _a;
317
+ return __generator(this, function (_b) {
318
+ switch (_b.label) {
319
+ case 0: return [4 /*yield*/, this.createQueryBuilder("discon")
320
+ .select(["discon.id", "discon.type", "discon.operator"])
321
+ .where("discon.discount_rule_id = :discountRuleId", {
322
+ discountRuleId: discountRuleId,
323
+ })
324
+ .getMany()
325
+ // in case of no discount conditions, we assume that the discount
326
+ // is valid for all
327
+ ];
328
+ case 1:
329
+ discountConditions = _b.sent();
330
+ // in case of no discount conditions, we assume that the discount
331
+ // is valid for all
332
+ if (!discountConditions.length) {
333
+ return [2 /*return*/, true];
334
+ }
335
+ _b.label = 2;
336
+ case 2:
337
+ _b.trys.push([2, 7, 8, 9]);
338
+ discountConditions_2 = __values(discountConditions), discountConditions_2_1 = discountConditions_2.next();
339
+ _b.label = 3;
340
+ case 3:
341
+ if (!!discountConditions_2_1.done) return [3 /*break*/, 6];
342
+ condition = discountConditions_2_1.value;
343
+ return [4 /*yield*/, this.queryConditionTable({
344
+ type: "customer_groups",
345
+ condId: condition.id,
346
+ resourceId: customerId,
347
+ })];
348
+ case 4:
349
+ numConditions = _b.sent();
350
+ if (condition.operator === discount_condition_1.DiscountConditionOperator.IN &&
351
+ numConditions === 0) {
352
+ return [2 /*return*/, false];
353
+ }
354
+ if (condition.operator === discount_condition_1.DiscountConditionOperator.NOT_IN &&
355
+ numConditions > 0) {
356
+ return [2 /*return*/, false];
357
+ }
358
+ _b.label = 5;
359
+ case 5:
360
+ discountConditions_2_1 = discountConditions_2.next();
361
+ return [3 /*break*/, 3];
362
+ case 6: return [3 /*break*/, 9];
363
+ case 7:
364
+ e_2_1 = _b.sent();
365
+ e_2 = { error: e_2_1 };
366
+ return [3 /*break*/, 9];
367
+ case 8:
368
+ try {
369
+ if (discountConditions_2_1 && !discountConditions_2_1.done && (_a = discountConditions_2.return)) _a.call(discountConditions_2);
370
+ }
371
+ finally { if (e_2) throw e_2.error; }
372
+ return [7 /*endfinally*/];
373
+ case 9: return [2 /*return*/, true];
374
+ }
375
+ });
376
+ });
377
+ };
378
+ DiscountConditionRepository = __decorate([
379
+ (0, typeorm_1.EntityRepository)(discount_condition_1.DiscountCondition)
380
+ ], DiscountConditionRepository);
381
+ return DiscountConditionRepository;
382
+ }(typeorm_1.Repository));
383
+ exports.DiscountConditionRepository = DiscountConditionRepository;
384
+ //# sourceMappingURL=discount-condition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discount-condition.js","sourceRoot":"","sources":["../../src/repositories/discount-condition.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAOgB;AAChB,mEAIqC;AACrC,iGAA4F;AAC5F,mFAA+E;AAC/E,yGAAoG;AACpG,2FAAsF;AACtF,6FAAwF;AAExF,IAAY,oCAMX;AAND,WAAY,oCAAoC;IAC9C,iEAAyB,CAAA;IACzB,2EAAmC,CAAA;IACnC,uFAA+C,CAAA;IAC/C,yEAAiC,CAAA;IACjC,+EAAuC,CAAA;AACzC,CAAC,EANW,oCAAoC,GAApC,4CAAoC,KAApC,4CAAoC,QAM/C;AAWD;IAAiD,+CAA6B;IAA9E;;IA4QA,CAAC;IA3QC,qEAA+B,GAA/B,UAAgC,IAAY;QAO1C,IAAI,cAAc,GAAkC,qDAAwB,CAAA;QAE5E,IAAI,SAAS,GAAG,SAAS,CAAA;QACzB,IAAI,mBAAmB,GACrB,oCAAoC,CAAC,UAAU,CAAA;QACjD,IAAI,YAAY,GAAG,IAAI,CAAA;QAEvB,oEAAoE;QACpE,0DAA0D;QAC1D,IAAI,WAAW,CAAA;QAEf,QAAQ,IAAI,EAAE;YACZ,KAAK,0CAAqB,CAAC,QAAQ,CAAC,CAAC;gBACn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C,kBAAkB,CAAC,MAAM,EAAE;4BAC9B,sBAAO,IAAI,EAAA;yBACZ;;;;wBAMuB,uBAAA,SAAA,kBAAkB,CAAA;;;;wBAA/B,SAAS;wBACI,qBAAM,IAAI,CAAC,mBAAmB,CAAC;gCACnD,IAAI,EAAE,iBAAiB;gCACvB,MAAM,EAAE,SAAS,CAAC,EAAE;gCACpB,UAAU,EAAE,UAAU;6BACvB,CAAC,EAAA;;wBAJI,aAAa,GAAG,SAIpB;wBAEF,IACE,SAAS,CAAC,QAAQ,KAAK,8CAAyB,CAAC,EAAE;4BACnD,aAAa,KAAK,CAAC,EACnB;4BACA,sBAAO,KAAK,EAAA;yBACb;wBAED,IACE,SAAS,CAAC,QAAQ,KAAK,8CAAyB,CAAC,MAAM;4BACvD,aAAa,GAAG,CAAC,EACjB;4BACA,sBAAO,KAAK,EAAA;yBACb;;;;;;;;;;;;;;;;4BAGH,sBAAO,IAAI,EAAA;;;;KACZ;IA3QU,2BAA2B;QADvC,IAAA,0BAAgB,EAAC,sCAAiB,CAAC;OACvB,2BAA2B,CA4QvC;IAAD,kCAAC;CAAA,AA5QD,CAAiD,oBAAU,GA4Q1D;AA5QY,kEAA2B"}
@@ -0,0 +1,4 @@
1
+ import { Repository } from "typeorm";
2
+ import { LineItemAdjustment } from "../models/line-item-adjustment";
3
+ export declare class LineItemAdjustmentRepository extends Repository<LineItemAdjustment> {
4
+ }
@@ -0,0 +1,38 @@
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.LineItemAdjustmentRepository = void 0;
25
+ var typeorm_1 = require("typeorm");
26
+ var line_item_adjustment_1 = require("../models/line-item-adjustment");
27
+ var LineItemAdjustmentRepository = /** @class */ (function (_super) {
28
+ __extends(LineItemAdjustmentRepository, _super);
29
+ function LineItemAdjustmentRepository() {
30
+ return _super !== null && _super.apply(this, arguments) || this;
31
+ }
32
+ LineItemAdjustmentRepository = __decorate([
33
+ (0, typeorm_1.EntityRepository)(line_item_adjustment_1.LineItemAdjustment)
34
+ ], LineItemAdjustmentRepository);
35
+ return LineItemAdjustmentRepository;
36
+ }(typeorm_1.Repository));
37
+ exports.LineItemAdjustmentRepository = LineItemAdjustmentRepository;
38
+ //# sourceMappingURL=line-item-adjustment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-item-adjustment.js","sourceRoot":"","sources":["../../src/repositories/line-item-adjustment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAsD;AACtD,uEAAmE;AAGnE;IAAkD,gDAA8B;IAAhF;;IAAkF,CAAC;IAAtE,4BAA4B;QADxC,IAAA,0BAAgB,EAAC,yCAAkB,CAAC;OACxB,4BAA4B,CAA0C;IAAD,mCAAC;CAAA,AAAnF,CAAkD,oBAAU,GAAuB;AAAtE,oEAA4B"}
@@ -1,4 +1,6 @@
1
1
  import { Repository } from "typeorm";
2
2
  import { LineItemTaxLine } from "../models/line-item-tax-line";
3
3
  export declare class LineItemTaxLineRepository extends Repository<LineItemTaxLine> {
4
+ upsertLines(lines: LineItemTaxLine[]): Promise<LineItemTaxLine[]>;
5
+ deleteForCart(cartId: string): Promise<void>;
4
6
  }
@@ -20,6 +20,42 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
20
20
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
21
  return c > 3 && r && Object.defineProperty(target, key, r), r;
22
22
  };
23
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
24
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25
+ return new (P || (P = Promise))(function (resolve, reject) {
26
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
27
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
28
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
29
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
30
+ });
31
+ };
32
+ var __generator = (this && this.__generator) || function (thisArg, body) {
33
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
34
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
35
+ function verb(n) { return function (v) { return step([n, v]); }; }
36
+ function step(op) {
37
+ if (f) throw new TypeError("Generator is already executing.");
38
+ while (_) try {
39
+ 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;
40
+ if (y = 0, t) op = [op[0] & 2, t.value];
41
+ switch (op[0]) {
42
+ case 0: case 1: t = op; break;
43
+ case 4: _.label++; return { value: op[1], done: false };
44
+ case 5: _.label++; y = op[1]; op = [0]; continue;
45
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
46
+ default:
47
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
48
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
49
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
50
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
51
+ if (t[2]) _.ops.pop();
52
+ _.trys.pop(); continue;
53
+ }
54
+ op = body.call(thisArg, _);
55
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
56
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
57
+ }
58
+ };
23
59
  Object.defineProperty(exports, "__esModule", { value: true });
24
60
  exports.LineItemTaxLineRepository = void 0;
25
61
  var typeorm_1 = require("typeorm");
@@ -29,6 +65,50 @@ var LineItemTaxLineRepository = /** @class */ (function (_super) {
29
65
  function LineItemTaxLineRepository() {
30
66
  return _super !== null && _super.apply(this, arguments) || this;
31
67
  }
68
+ LineItemTaxLineRepository.prototype.upsertLines = function (lines) {
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var insertResult;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0: return [4 /*yield*/, this.createQueryBuilder()
74
+ .insert()
75
+ .values(lines)
76
+ .orUpdate({
77
+ conflict_target: ["item_id", "code"],
78
+ overwrite: ["rate", "name", "updated_at"],
79
+ })
80
+ .execute()];
81
+ case 1:
82
+ insertResult = _a.sent();
83
+ return [2 /*return*/, insertResult.identifiers];
84
+ }
85
+ });
86
+ });
87
+ };
88
+ LineItemTaxLineRepository.prototype.deleteForCart = function (cartId) {
89
+ return __awaiter(this, void 0, void 0, function () {
90
+ var qb, toDelete;
91
+ return __generator(this, function (_a) {
92
+ switch (_a.label) {
93
+ case 0:
94
+ qb = this.createQueryBuilder("line")
95
+ .select(["line.id"])
96
+ .innerJoin("line_item", "i", "i.id = line.item_id")
97
+ .innerJoin("cart", "c", "i.cart_id = :cartId AND c.completed_at is NULL", { cartId: cartId });
98
+ return [4 /*yield*/, qb.getMany()];
99
+ case 1:
100
+ toDelete = _a.sent();
101
+ return [4 /*yield*/, this.createQueryBuilder()
102
+ .delete()
103
+ .whereInIds(toDelete.map(function (d) { return d.id; }))
104
+ .execute()];
105
+ case 2:
106
+ _a.sent();
107
+ return [2 /*return*/];
108
+ }
109
+ });
110
+ });
111
+ };
32
112
  LineItemTaxLineRepository = __decorate([
33
113
  (0, typeorm_1.EntityRepository)(line_item_tax_line_1.LineItemTaxLine)
34
114
  ], LineItemTaxLineRepository);
@@ -1 +1 @@
1
- {"version":3,"file":"line-item-tax-line.js","sourceRoot":"","sources":["../../src/repositories/line-item-tax-line.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAsD;AACtD,mEAA8D;AAG9D;IAA+C,6CAA2B;IAA1E;;IAA4E,CAAC;IAAhE,yBAAyB;QADrC,IAAA,0BAAgB,EAAC,oCAAe,CAAC;OACrB,yBAAyB,CAAuC;IAAD,gCAAC;CAAA,AAA7E,CAA+C,oBAAU,GAAoB;AAAhE,8DAAyB"}
1
+ {"version":3,"file":"line-item-tax-line.js","sourceRoot":"","sources":["../../src/repositories/line-item-tax-line.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAsD;AACtD,mEAA8D;AAG9D;IAA+C,6CAA2B;IAA1E;;IAgCA,CAAC;IA/BO,+CAAW,GAAjB,UAAkB,KAAwB;;;;;4BACnB,qBAAM,IAAI,CAAC,kBAAkB,EAAE;6BACjD,MAAM,EAAE;6BACR,MAAM,CAAC,KAAK,CAAC;6BACb,QAAQ,CAAC;4BACR,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;4BACpC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC;yBAC1C,CAAC;6BACD,OAAO,EAAE,EAAA;;wBAPN,YAAY,GAAG,SAOT;wBAEZ,sBAAO,YAAY,CAAC,WAAgC,EAAA;;;;KACrD;IAEK,iDAAa,GAAnB,UAAoB,MAAc;;;;;;wBAC1B,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC;6BACvC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC;6BACnB,SAAS,CAAC,WAAW,EAAE,GAAG,EAAE,qBAAqB,CAAC;6BAClD,SAAS,CACR,MAAM,EACN,GAAG,EACH,gDAAgD,EAChD,EAAE,MAAM,QAAA,EAAE,CACX,CAAA;wBAEc,qBAAM,EAAE,CAAC,OAAO,EAAE,EAAA;;wBAA7B,QAAQ,GAAG,SAAkB;wBAEnC,qBAAM,IAAI,CAAC,kBAAkB,EAAE;iCAC5B,MAAM,EAAE;iCACR,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAE,EAAJ,CAAI,CAAC,CAAC;iCACrC,OAAO,EAAE,EAAA;;wBAHZ,SAGY,CAAA;;;;;KACb;IA/BU,yBAAyB;QADrC,IAAA,0BAAgB,EAAC,oCAAe,CAAC;OACrB,yBAAyB,CAgCrC;IAAD,gCAAC;CAAA,AAhCD,CAA+C,oBAAU,GAgCxD;AAhCY,8DAAyB"}
@@ -82,6 +82,7 @@ var LineItemRepository = /** @class */ (function (_super) {
82
82
  case 0:
83
83
  qb = this.createQueryBuilder("li")
84
84
  .leftJoinAndSelect("li.tax_lines", "tax_lines")
85
+ .leftJoinAndSelect("li.adjustments", "adjustments")
85
86
  .leftJoinAndMapOne("li.return_item", return_item_1.ReturnItem, "ri", "ri.item_id = li.id")
86
87
  .where("ri.return_id = :returnId", { returnId: returnId });
87
88
  return [4 /*yield*/, qb.getMany()];
@@ -1 +1 @@
1
- {"version":3,"file":"line-item.js","sourceRoot":"","sources":["../../src/repositories/line-item.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAsD;AACtD,iDAA8C;AAC9C,qDAAkD;AAGlD;IAAwC,sCAAoB;IAA5D;;IAwBA,CAAC;IAvBC;;;;;;;OAOG;IACG,yCAAY,GAAlB,UACE,QAAgB;;;;;;wBAEV,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;6BACrC,iBAAiB,CAAC,cAAc,EAAE,WAAW,CAAC;6BAC9C,iBAAiB,CAChB,gBAAgB,EAChB,wBAAU,EACV,IAAI,EACJ,oBAAoB,CACrB;6BACA,KAAK,CAAC,0BAA0B,EAAE,EAAE,QAAQ,UAAA,EAAE,CAAC,CAAA;wBAE1C,qBAAM,EAAE,CAAC,OAAO,EAAE,EAAA;4BAA1B,sBAAO,CAAC,SAAkB,CAA+C,EAAA;;;;KAC1E;IAvBU,kBAAkB;QAD9B,IAAA,0BAAgB,EAAC,oBAAQ,CAAC;OACd,kBAAkB,CAwB9B;IAAD,yBAAC;CAAA,AAxBD,CAAwC,oBAAU,GAwBjD;AAxBY,gDAAkB"}
1
+ {"version":3,"file":"line-item.js","sourceRoot":"","sources":["../../src/repositories/line-item.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAsD;AACtD,iDAA8C;AAC9C,qDAAkD;AAGlD;IAAwC,sCAAoB;IAA5D;;IAyBA,CAAC;IAxBC;;;;;;;OAOG;IACG,yCAAY,GAAlB,UACE,QAAgB;;;;;;wBAEV,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;6BACrC,iBAAiB,CAAC,cAAc,EAAE,WAAW,CAAC;6BAC9C,iBAAiB,CAAC,gBAAgB,EAAE,aAAa,CAAC;6BAClD,iBAAiB,CAChB,gBAAgB,EAChB,wBAAU,EACV,IAAI,EACJ,oBAAoB,CACrB;6BACA,KAAK,CAAC,0BAA0B,EAAE,EAAE,QAAQ,UAAA,EAAE,CAAC,CAAA;wBAE1C,qBAAM,EAAE,CAAC,OAAO,EAAE,EAAA;4BAA1B,sBAAO,CAAC,SAAkB,CAA+C,EAAA;;;;KAC1E;IAxBU,kBAAkB;QAD9B,IAAA,0BAAgB,EAAC,oBAAQ,CAAC;OACd,kBAAkB,CAyB9B;IAAD,yBAAC;CAAA,AAzBD,CAAwC,oBAAU,GAyBjD;AAzBY,gDAAkB"}
@@ -1,10 +1,15 @@
1
1
  import { Repository } from "typeorm";
2
2
  import { MoneyAmount } from "../models/money-amount";
3
- declare type Price = Partial<Pick<MoneyAmount, "currency_code" | "region_id" | "sale_amount" | "currency_code">> & {
3
+ import { PriceListPriceCreateInput, PriceListPriceUpdateInput } from "../types/price-list";
4
+ declare type Price = Partial<Omit<MoneyAmount, "created_at" | "updated_at" | "deleted_at">> & {
4
5
  amount: number;
5
6
  };
6
7
  export declare class MoneyAmountRepository extends Repository<MoneyAmount> {
7
8
  findVariantPricesNotIn(variantId: string, prices: Price[]): Promise<MoneyAmount[]>;
8
- upsertCurrencyPrice(variantId: string, price: Price): Promise<MoneyAmount>;
9
+ upsertVariantCurrencyPrice(variantId: string, price: Price): Promise<MoneyAmount>;
10
+ addPriceListPrices(priceListId: string, prices: PriceListPriceCreateInput[], overrideExisting?: boolean): Promise<MoneyAmount[]>;
11
+ deletePriceListPrices(priceListId: string, moneyAmountIds: string[]): Promise<void>;
12
+ findManyForVariantInRegion(variant_id: string, region_id?: string, currency_code?: string, customer_id?: string, include_discount_prices?: boolean): Promise<[MoneyAmount[], number]>;
13
+ updatePriceListPrices(priceListId: string, updates: PriceListPriceUpdateInput[]): Promise<MoneyAmount[]>;
9
14
  }
10
15
  export {};