@medusajs/core-flows 0.0.2-next-20231124140416

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 (241) hide show
  1. package/dist/definition/cart/create-cart.d.ts +9 -0
  2. package/dist/definition/cart/create-cart.js +148 -0
  3. package/dist/definition/cart/create-cart.js.map +1 -0
  4. package/dist/definition/cart/index.d.ts +1 -0
  5. package/dist/definition/cart/index.js +18 -0
  6. package/dist/definition/cart/index.js.map +1 -0
  7. package/dist/definition/index.d.ts +4 -0
  8. package/dist/definition/index.js +21 -0
  9. package/dist/definition/index.js.map +1 -0
  10. package/dist/definition/inventory/create-inventory-item.d.ts +14 -0
  11. package/dist/definition/inventory/create-inventory-item.js +41 -0
  12. package/dist/definition/inventory/create-inventory-item.js.map +1 -0
  13. package/dist/definition/inventory/index.d.ts +1 -0
  14. package/dist/definition/inventory/index.js +18 -0
  15. package/dist/definition/inventory/index.js.map +1 -0
  16. package/dist/definition/price-list/create-price-lists.d.ts +13 -0
  17. package/dist/definition/price-list/create-price-lists.js +55 -0
  18. package/dist/definition/price-list/create-price-lists.js.map +1 -0
  19. package/dist/definition/price-list/index.d.ts +6 -0
  20. package/dist/definition/price-list/index.js +23 -0
  21. package/dist/definition/price-list/index.js.map +1 -0
  22. package/dist/definition/price-list/remove-price-list-prices.d.ts +11 -0
  23. package/dist/definition/price-list/remove-price-list-prices.js +50 -0
  24. package/dist/definition/price-list/remove-price-list-prices.js.map +1 -0
  25. package/dist/definition/price-list/remove-price-lists.d.ts +12 -0
  26. package/dist/definition/price-list/remove-price-lists.js +40 -0
  27. package/dist/definition/price-list/remove-price-lists.js.map +1 -0
  28. package/dist/definition/price-list/remove-product-prices.d.ts +11 -0
  29. package/dist/definition/price-list/remove-product-prices.js +51 -0
  30. package/dist/definition/price-list/remove-product-prices.js.map +1 -0
  31. package/dist/definition/price-list/remove-variant-prices.d.ts +11 -0
  32. package/dist/definition/price-list/remove-variant-prices.js +51 -0
  33. package/dist/definition/price-list/remove-variant-prices.js.map +1 -0
  34. package/dist/definition/price-list/update-price-lists.d.ts +13 -0
  35. package/dist/definition/price-list/update-price-lists.js +51 -0
  36. package/dist/definition/price-list/update-price-lists.js.map +1 -0
  37. package/dist/definition/product/create-product-variants.d.ts +15 -0
  38. package/dist/definition/product/create-product-variants.js +91 -0
  39. package/dist/definition/product/create-product-variants.js.map +1 -0
  40. package/dist/definition/product/create-products.d.ts +18 -0
  41. package/dist/definition/product/create-products.js +211 -0
  42. package/dist/definition/product/create-products.js.map +1 -0
  43. package/dist/definition/product/index.d.ts +4 -0
  44. package/dist/definition/product/index.js +34 -0
  45. package/dist/definition/product/index.js.map +1 -0
  46. package/dist/definition/product/prepare-create-inventory-items.d.ts +23 -0
  47. package/dist/definition/product/prepare-create-inventory-items.js +28 -0
  48. package/dist/definition/product/prepare-create-inventory-items.js.map +1 -0
  49. package/dist/definition/product/update-product-variants.d.ts +15 -0
  50. package/dist/definition/product/update-product-variants.js +81 -0
  51. package/dist/definition/product/update-product-variants.js.map +1 -0
  52. package/dist/definition/product/update-products.d.ts +19 -0
  53. package/dist/definition/product/update-products.js +328 -0
  54. package/dist/definition/product/update-products.js.map +1 -0
  55. package/dist/definitions.d.ts +27 -0
  56. package/dist/definitions.js +37 -0
  57. package/dist/definitions.js.map +1 -0
  58. package/dist/handlers/address/find-or-create-addresses.d.ts +24 -0
  59. package/dist/handlers/address/find-or-create-addresses.js +66 -0
  60. package/dist/handlers/address/find-or-create-addresses.js.map +1 -0
  61. package/dist/handlers/address/index.d.ts +1 -0
  62. package/dist/handlers/address/index.js +18 -0
  63. package/dist/handlers/address/index.js.map +1 -0
  64. package/dist/handlers/cart/attach-line-items-to-cart.d.ts +21 -0
  65. package/dist/handlers/cart/attach-line-items-to-cart.js +35 -0
  66. package/dist/handlers/cart/attach-line-items-to-cart.js.map +1 -0
  67. package/dist/handlers/cart/create-cart.d.ts +36 -0
  68. package/dist/handlers/cart/create-cart.js +27 -0
  69. package/dist/handlers/cart/create-cart.js.map +1 -0
  70. package/dist/handlers/cart/index.d.ts +4 -0
  71. package/dist/handlers/cart/index.js +21 -0
  72. package/dist/handlers/cart/index.js.map +1 -0
  73. package/dist/handlers/cart/remove-cart.d.ts +14 -0
  74. package/dist/handlers/cart/remove-cart.js +17 -0
  75. package/dist/handlers/cart/remove-cart.js.map +1 -0
  76. package/dist/handlers/cart/retrieve-cart.d.ts +22 -0
  77. package/dist/handlers/cart/retrieve-cart.js +18 -0
  78. package/dist/handlers/cart/retrieve-cart.js.map +1 -0
  79. package/dist/handlers/common/index.d.ts +1 -0
  80. package/dist/handlers/common/index.js +18 -0
  81. package/dist/handlers/common/index.js.map +1 -0
  82. package/dist/handlers/common/set-context.d.ts +17 -0
  83. package/dist/handlers/common/set-context.js +16 -0
  84. package/dist/handlers/common/set-context.js.map +1 -0
  85. package/dist/handlers/customer/find-or-create-customer.d.ts +19 -0
  86. package/dist/handlers/customer/find-or-create-customer.js +38 -0
  87. package/dist/handlers/customer/find-or-create-customer.js.map +1 -0
  88. package/dist/handlers/customer/index.d.ts +1 -0
  89. package/dist/handlers/customer/index.js +18 -0
  90. package/dist/handlers/customer/index.js.map +1 -0
  91. package/dist/handlers/index.d.ts +10 -0
  92. package/dist/handlers/index.js +37 -0
  93. package/dist/handlers/index.js.map +1 -0
  94. package/dist/handlers/inventory/attach-inventory-items.d.ts +16 -0
  95. package/dist/handlers/inventory/attach-inventory-items.js +23 -0
  96. package/dist/handlers/inventory/attach-inventory-items.js.map +1 -0
  97. package/dist/handlers/inventory/create-inventory-items.d.ts +17 -0
  98. package/dist/handlers/inventory/create-inventory-items.js +31 -0
  99. package/dist/handlers/inventory/create-inventory-items.js.map +1 -0
  100. package/dist/handlers/inventory/detach-inventory-items.d.ts +16 -0
  101. package/dist/handlers/inventory/detach-inventory-items.js +22 -0
  102. package/dist/handlers/inventory/detach-inventory-items.js.map +1 -0
  103. package/dist/handlers/inventory/index.d.ts +5 -0
  104. package/dist/handlers/inventory/index.js +22 -0
  105. package/dist/handlers/inventory/index.js.map +1 -0
  106. package/dist/handlers/inventory/remove-inventory-items.d.ts +14 -0
  107. package/dist/handlers/inventory/remove-inventory-items.js +18 -0
  108. package/dist/handlers/inventory/remove-inventory-items.js.map +1 -0
  109. package/dist/handlers/inventory/restore-inventory-items.d.ts +12 -0
  110. package/dist/handlers/inventory/restore-inventory-items.js +18 -0
  111. package/dist/handlers/inventory/restore-inventory-items.js.map +1 -0
  112. package/dist/handlers/middlewares/create-products-prepare-create-prices-compensation.d.ts +26 -0
  113. package/dist/handlers/middlewares/create-products-prepare-create-prices-compensation.js +31 -0
  114. package/dist/handlers/middlewares/create-products-prepare-create-prices-compensation.js.map +1 -0
  115. package/dist/handlers/middlewares/extract-variants.d.ts +18 -0
  116. package/dist/handlers/middlewares/extract-variants.js +23 -0
  117. package/dist/handlers/middlewares/extract-variants.js.map +1 -0
  118. package/dist/handlers/middlewares/index.d.ts +6 -0
  119. package/dist/handlers/middlewares/index.js +23 -0
  120. package/dist/handlers/middlewares/index.js.map +1 -0
  121. package/dist/handlers/middlewares/map-data.d.ts +11 -0
  122. package/dist/handlers/middlewares/map-data.js +19 -0
  123. package/dist/handlers/middlewares/map-data.js.map +1 -0
  124. package/dist/handlers/middlewares/update-products-extract-created-variants.d.ts +19 -0
  125. package/dist/handlers/middlewares/update-products-extract-created-variants.js +27 -0
  126. package/dist/handlers/middlewares/update-products-extract-created-variants.js.map +1 -0
  127. package/dist/handlers/middlewares/update-products-extract-deleted-variants.d.ts +19 -0
  128. package/dist/handlers/middlewares/update-products-extract-deleted-variants.js +29 -0
  129. package/dist/handlers/middlewares/update-products-extract-deleted-variants.js.map +1 -0
  130. package/dist/handlers/middlewares/use-variants-inventory-items.d.ts +24 -0
  131. package/dist/handlers/middlewares/use-variants-inventory-items.js +31 -0
  132. package/dist/handlers/middlewares/use-variants-inventory-items.js.map +1 -0
  133. package/dist/handlers/price-list/create-price-list.d.ts +18 -0
  134. package/dist/handlers/price-list/create-price-list.js +18 -0
  135. package/dist/handlers/price-list/create-price-list.js.map +1 -0
  136. package/dist/handlers/price-list/index.d.ts +10 -0
  137. package/dist/handlers/price-list/index.js +27 -0
  138. package/dist/handlers/price-list/index.js.map +1 -0
  139. package/dist/handlers/price-list/prepare-create-price-list.d.ts +17 -0
  140. package/dist/handlers/price-list/prepare-create-price-list.js +57 -0
  141. package/dist/handlers/price-list/prepare-create-price-list.js.map +1 -0
  142. package/dist/handlers/price-list/prepare-remove-price-list-prices.d.ts +15 -0
  143. package/dist/handlers/price-list/prepare-remove-price-list-prices.js +23 -0
  144. package/dist/handlers/price-list/prepare-remove-price-list-prices.js.map +1 -0
  145. package/dist/handlers/price-list/prepare-remove-product-prices.d.ts +10 -0
  146. package/dist/handlers/price-list/prepare-remove-product-prices.js +35 -0
  147. package/dist/handlers/price-list/prepare-remove-product-prices.js.map +1 -0
  148. package/dist/handlers/price-list/prepare-remove-variant-prices.d.ts +10 -0
  149. package/dist/handlers/price-list/prepare-remove-variant-prices.js +33 -0
  150. package/dist/handlers/price-list/prepare-remove-variant-prices.js.map +1 -0
  151. package/dist/handlers/price-list/prepare-update-price-lists.d.ts +15 -0
  152. package/dist/handlers/price-list/prepare-update-price-lists.js +58 -0
  153. package/dist/handlers/price-list/prepare-update-price-lists.js.map +1 -0
  154. package/dist/handlers/price-list/remove-price-list.d.ts +14 -0
  155. package/dist/handlers/price-list/remove-price-list.js +14 -0
  156. package/dist/handlers/price-list/remove-price-list.js.map +1 -0
  157. package/dist/handlers/price-list/remove-price-set-price-list-prices.d.ts +5 -0
  158. package/dist/handlers/price-list/remove-price-set-price-list-prices.js +25 -0
  159. package/dist/handlers/price-list/remove-price-set-price-list-prices.js.map +1 -0
  160. package/dist/handlers/price-list/remove-prices.d.ts +13 -0
  161. package/dist/handlers/price-list/remove-prices.js +17 -0
  162. package/dist/handlers/price-list/remove-prices.js.map +1 -0
  163. package/dist/handlers/price-list/update-price-lists.d.ts +15 -0
  164. package/dist/handlers/price-list/update-price-lists.js +38 -0
  165. package/dist/handlers/price-list/update-price-lists.js.map +1 -0
  166. package/dist/handlers/product/attach-sales-channel-to-products.d.ts +18 -0
  167. package/dist/handlers/product/attach-sales-channel-to-products.js +30 -0
  168. package/dist/handlers/product/attach-sales-channel-to-products.js.map +1 -0
  169. package/dist/handlers/product/attach-shipping-profile-to-products.d.ts +18 -0
  170. package/dist/handlers/product/attach-shipping-profile-to-products.js +28 -0
  171. package/dist/handlers/product/attach-shipping-profile-to-products.js.map +1 -0
  172. package/dist/handlers/product/create-product-variants-prepare-data.d.ts +21 -0
  173. package/dist/handlers/product/create-product-variants-prepare-data.js +35 -0
  174. package/dist/handlers/product/create-product-variants-prepare-data.js.map +1 -0
  175. package/dist/handlers/product/create-product-variants.d.ts +23 -0
  176. package/dist/handlers/product/create-product-variants.js +22 -0
  177. package/dist/handlers/product/create-product-variants.js.map +1 -0
  178. package/dist/handlers/product/create-products-prepare-data.d.ts +28 -0
  179. package/dist/handlers/product/create-products-prepare-data.js +77 -0
  180. package/dist/handlers/product/create-products-prepare-data.js.map +1 -0
  181. package/dist/handlers/product/create-products.d.ts +12 -0
  182. package/dist/handlers/product/create-products.js +14 -0
  183. package/dist/handlers/product/create-products.js.map +1 -0
  184. package/dist/handlers/product/detach-sales-channel-from-products.d.ts +18 -0
  185. package/dist/handlers/product/detach-sales-channel-from-products.js +30 -0
  186. package/dist/handlers/product/detach-sales-channel-from-products.js.map +1 -0
  187. package/dist/handlers/product/detach-shipping-profile-from-products.d.ts +18 -0
  188. package/dist/handlers/product/detach-shipping-profile-from-products.js +28 -0
  189. package/dist/handlers/product/detach-shipping-profile-from-products.js.map +1 -0
  190. package/dist/handlers/product/index.d.ts +19 -0
  191. package/dist/handlers/product/index.js +36 -0
  192. package/dist/handlers/product/index.js.map +1 -0
  193. package/dist/handlers/product/list-products.d.ts +13 -0
  194. package/dist/handlers/product/list-products.js +31 -0
  195. package/dist/handlers/product/list-products.js.map +1 -0
  196. package/dist/handlers/product/remove-product-variants.d.ts +13 -0
  197. package/dist/handlers/product/remove-product-variants.js +16 -0
  198. package/dist/handlers/product/remove-product-variants.js.map +1 -0
  199. package/dist/handlers/product/remove-products.d.ts +13 -0
  200. package/dist/handlers/product/remove-products.js +16 -0
  201. package/dist/handlers/product/remove-products.js.map +1 -0
  202. package/dist/handlers/product/revert-update-products.d.ts +14 -0
  203. package/dist/handlers/product/revert-update-products.js +20 -0
  204. package/dist/handlers/product/revert-update-products.js.map +1 -0
  205. package/dist/handlers/product/revert-variant-prices.d.ts +14 -0
  206. package/dist/handlers/product/revert-variant-prices.js +28 -0
  207. package/dist/handlers/product/revert-variant-prices.js.map +1 -0
  208. package/dist/handlers/product/update-product-variants-prepare-data.d.ts +21 -0
  209. package/dist/handlers/product/update-product-variants-prepare-data.js +48 -0
  210. package/dist/handlers/product/update-product-variants-prepare-data.js.map +1 -0
  211. package/dist/handlers/product/update-product-variants.d.ts +12 -0
  212. package/dist/handlers/product/update-product-variants.js +23 -0
  213. package/dist/handlers/product/update-product-variants.js.map +1 -0
  214. package/dist/handlers/product/update-products-prepare-data.d.ts +25 -0
  215. package/dist/handlers/product/update-products-prepare-data.js +65 -0
  216. package/dist/handlers/product/update-products-prepare-data.js.map +1 -0
  217. package/dist/handlers/product/update-products-variants-prices.d.ts +18 -0
  218. package/dist/handlers/product/update-products-variants-prices.js +90 -0
  219. package/dist/handlers/product/update-products-variants-prices.js.map +1 -0
  220. package/dist/handlers/product/update-products.d.ts +12 -0
  221. package/dist/handlers/product/update-products.js +29 -0
  222. package/dist/handlers/product/update-products.js.map +1 -0
  223. package/dist/handlers/product/upsert-variant-prices.d.ts +25 -0
  224. package/dist/handlers/product/upsert-variant-prices.js +122 -0
  225. package/dist/handlers/product/upsert-variant-prices.js.map +1 -0
  226. package/dist/handlers/region/find-region.d.ts +17 -0
  227. package/dist/handlers/region/find-region.js +29 -0
  228. package/dist/handlers/region/find-region.js.map +1 -0
  229. package/dist/handlers/region/index.d.ts +1 -0
  230. package/dist/handlers/region/index.js +18 -0
  231. package/dist/handlers/region/index.js.map +1 -0
  232. package/dist/handlers/sales-channel/find-sales-channel.d.ts +20 -0
  233. package/dist/handlers/sales-channel/find-sales-channel.js +41 -0
  234. package/dist/handlers/sales-channel/find-sales-channel.js.map +1 -0
  235. package/dist/handlers/sales-channel/index.d.ts +1 -0
  236. package/dist/handlers/sales-channel/index.js +18 -0
  237. package/dist/handlers/sales-channel/index.js.map +1 -0
  238. package/dist/index.d.ts +3 -0
  239. package/dist/index.js +33 -0
  240. package/dist/index.js.map +1 -0
  241. package/package.json +42 -0
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareRemovePriceListPrices = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ async function prepareRemovePriceListPrices({ container, data, }) {
6
+ const pricingService = container.resolve(modules_sdk_1.ModuleRegistrationName.PRICING);
7
+ const { price_list_id: priceListId, money_amount_ids: moneyAmountIdsToDelete, } = data;
8
+ const moneyAmounts = await pricingService.listMoneyAmounts({ id: moneyAmountIdsToDelete }, {
9
+ relations: [
10
+ "price_set_money_amount",
11
+ "price_set_money_amount.price_list",
12
+ ],
13
+ });
14
+ const moneyAmountIds = moneyAmounts
15
+ .filter((moneyAmount) => moneyAmount?.price_set_money_amount?.price_list?.id === priceListId)
16
+ .map((ma) => ma.id);
17
+ return { moneyAmountIds, priceListId };
18
+ }
19
+ exports.prepareRemovePriceListPrices = prepareRemovePriceListPrices;
20
+ prepareRemovePriceListPrices.aliases = {
21
+ payload: "payload",
22
+ };
23
+ //# sourceMappingURL=prepare-remove-price-list-prices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-remove-price-list-prices.js","sourceRoot":"","sources":["../../../src/handlers/price-list/prepare-remove-price-list-prices.ts"],"names":[],"mappings":";;;AAAA,uDAA8D;AASvD,KAAK,UAAU,4BAA4B,CAAC,EACjD,SAAS,EACT,IAAI,GAIJ;IACA,MAAM,cAAc,GAA0B,SAAS,CAAC,OAAO,CAC7D,oCAAsB,CAAC,OAAO,CAC/B,CAAA;IAED,MAAM,EACJ,aAAa,EAAE,WAAW,EAC1B,gBAAgB,EAAE,sBAAsB,GACzC,GAAG,IAAI,CAAA;IAER,MAAM,YAAY,GAAG,MAAM,cAAc,CAAC,gBAAgB,CACxD,EAAE,EAAE,EAAE,sBAAsB,EAAE,EAC9B;QACE,SAAS,EAAE;YACT,wBAAwB;YACxB,mCAAmC;SACpC;KACF,CACF,CAAA;IAED,MAAM,cAAc,GAAG,YAAY;SAChC,MAAM,CACL,CAAC,WAAW,EAAE,EAAE,CACd,WAAW,EAAE,sBAAsB,EAAE,UAAU,EAAE,EAAE,KAAK,WAAW,CACtE;SACA,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IAErB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,CAAA;AACxC,CAAC;AAlCD,oEAkCC;AAED,4BAA4B,CAAC,OAAO,GAAG;IACrC,OAAO,EAAE,SAAS;CACnB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
2
+ type Result = {
3
+ priceSetIds: string[];
4
+ priceListId: string;
5
+ };
6
+ export declare function prepareRemoveProductPrices({ container, data, }: WorkflowArguments<{
7
+ product_ids: string[];
8
+ price_list_id: string;
9
+ }>): Promise<Result | void>;
10
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareRemoveProductPrices = void 0;
4
+ const prepare_create_price_list_1 = require("./prepare-create-price-list");
5
+ async function prepareRemoveProductPrices({ container, data, }) {
6
+ const remoteQuery = container.resolve("remoteQuery");
7
+ const { price_list_id, product_ids } = data;
8
+ const variables = {
9
+ id: product_ids,
10
+ };
11
+ const query = {
12
+ product: {
13
+ __args: variables,
14
+ ...defaultAdminProductRemoteQueryObject,
15
+ },
16
+ };
17
+ const productsWithVariantPriceSets = await remoteQuery(query);
18
+ const priceSetIds = productsWithVariantPriceSets
19
+ .map(({ variants }) => variants.map(({ price }) => price.price_set_id))
20
+ .flat();
21
+ return { priceSetIds, priceListId: price_list_id };
22
+ }
23
+ exports.prepareRemoveProductPrices = prepareRemoveProductPrices;
24
+ prepare_create_price_list_1.prepareCreatePriceLists.aliases = {
25
+ payload: "payload",
26
+ };
27
+ const defaultAdminProductRemoteQueryObject = {
28
+ fields: ["id"],
29
+ variants: {
30
+ price: {
31
+ fields: ["variant_id", "price_set_id"],
32
+ },
33
+ },
34
+ };
35
+ //# sourceMappingURL=prepare-remove-product-prices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-remove-product-prices.js","sourceRoot":"","sources":["../../../src/handlers/price-list/prepare-remove-product-prices.ts"],"names":[],"mappings":";;;AACA,2EAAqE;AAO9D,KAAK,UAAU,0BAA0B,CAAC,EAC/C,SAAS,EACT,IAAI,GAIJ;IACA,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IAEpD,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAE3C,MAAM,SAAS,GAAG;QAChB,EAAE,EAAE,WAAW;KAChB,CAAA;IAED,MAAM,KAAK,GAAG;QACZ,OAAO,EAAE;YACP,MAAM,EAAE,SAAS;YACjB,GAAG,oCAAoC;SACxC;KACF,CAAA;IAED,MAAM,4BAA4B,GAAkB,MAAM,WAAW,CAAC,KAAK,CAAC,CAAA;IAE5E,MAAM,WAAW,GAAG,4BAA4B;SAC7C,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;SACtE,IAAI,EAAE,CAAA;IAET,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA;AACpD,CAAC;AA7BD,gEA6BC;AAED,mDAAuB,CAAC,OAAO,GAAG;IAChC,OAAO,EAAE,SAAS;CACnB,CAAA;AAaD,MAAM,oCAAoC,GAAG;IAC3C,MAAM,EAAE,CAAC,IAAI,CAAC;IACd,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,YAAY,EAAE,cAAc,CAAC;SACvC;KACF;CACF,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
2
+ type Result = {
3
+ priceSetIds: string[];
4
+ priceListId: string;
5
+ };
6
+ export declare function prepareRemoveVariantPrices({ container, data, }: WorkflowArguments<{
7
+ variant_ids: string[];
8
+ price_list_id: string;
9
+ }>): Promise<Result | void>;
10
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareRemoveVariantPrices = void 0;
4
+ const prepare_create_price_list_1 = require("./prepare-create-price-list");
5
+ async function prepareRemoveVariantPrices({ container, data, }) {
6
+ const remoteQuery = container.resolve("remoteQuery");
7
+ const { price_list_id, variant_ids } = data;
8
+ const variables = {
9
+ variant_id: variant_ids,
10
+ };
11
+ const query = {
12
+ product_variant_price_set: {
13
+ __args: variables,
14
+ fields: ["variant_id", "price_set_id"],
15
+ },
16
+ };
17
+ const productsWithVariantPriceSets = await remoteQuery(query);
18
+ const priceSetIds = productsWithVariantPriceSets.map((variantPriceSet) => variantPriceSet.price_set_id);
19
+ return { priceSetIds, priceListId: price_list_id };
20
+ }
21
+ exports.prepareRemoveVariantPrices = prepareRemoveVariantPrices;
22
+ prepare_create_price_list_1.prepareCreatePriceLists.aliases = {
23
+ payload: "payload",
24
+ };
25
+ const defaultAdminProductRemoteQueryObject = {
26
+ fields: ["id"],
27
+ variants: {
28
+ price: {
29
+ fields: ["variant_id", "price_set_id"],
30
+ },
31
+ },
32
+ };
33
+ //# sourceMappingURL=prepare-remove-variant-prices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-remove-variant-prices.js","sourceRoot":"","sources":["../../../src/handlers/price-list/prepare-remove-variant-prices.ts"],"names":[],"mappings":";;;AACA,2EAAqE;AAO9D,KAAK,UAAU,0BAA0B,CAAC,EAC/C,SAAS,EACT,IAAI,GAIJ;IACA,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IAEpD,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAE3C,MAAM,SAAS,GAAG;QAChB,UAAU,EAAE,WAAW;KACxB,CAAA;IAED,MAAM,KAAK,GAAG;QACZ,yBAAyB,EAAE;YACzB,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,CAAC,YAAY,EAAE,cAAc,CAAC;SACvC;KACF,CAAA;IAED,MAAM,4BAA4B,GAAkB,MAAM,WAAW,CAAC,KAAK,CAAC,CAAA;IAE5E,MAAM,WAAW,GAAG,4BAA4B,CAAC,GAAG,CAClD,CAAC,eAAe,EAAE,EAAE,CAAC,eAAe,CAAC,YAAY,CAClD,CAAA;IAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA;AACpD,CAAC;AA7BD,gEA6BC;AAED,mDAAuB,CAAC,OAAO,GAAG;IAChC,OAAO,EAAE,SAAS;CACnB,CAAA;AAOD,MAAM,oCAAoC,GAAG;IAC3C,MAAM,EAAE,CAAC,IAAI,CAAC;IACd,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,YAAY,EAAE,cAAc,CAAC;SACvC;KACF;CACF,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { PriceListPriceDTO, UpdatePriceListDTO, WorkflowTypes } from "@medusajs/types";
2
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
3
+ type Result = {
4
+ priceLists: UpdatePriceListDTO[];
5
+ priceListPricesMap: Map<string, PriceListPriceDTO[]>;
6
+ };
7
+ export declare function prepareUpdatePriceLists({ container, data, }: WorkflowArguments<{
8
+ price_lists: WorkflowTypes.PriceListWorkflow.UpdatePriceListWorkflowDTO[];
9
+ }>): Promise<Result>;
10
+ export declare namespace prepareUpdatePriceLists {
11
+ var aliases: {
12
+ payload: string;
13
+ };
14
+ }
15
+ export {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareUpdatePriceLists = void 0;
4
+ async function prepareUpdatePriceLists({ container, data, }) {
5
+ const { price_lists: priceListsData } = data;
6
+ const remoteQuery = container.resolve("remoteQuery");
7
+ const variantPriceSetMap = new Map();
8
+ const priceListPricesMap = new Map();
9
+ const variantIds = priceListsData
10
+ .map((priceListData) => priceListData.prices?.map((p) => p.variant_id))
11
+ .flat();
12
+ const variables = {
13
+ variant_id: variantIds,
14
+ };
15
+ const query = {
16
+ product_variant_price_set: {
17
+ __args: variables,
18
+ fields: ["variant_id", "price_set_id"],
19
+ },
20
+ };
21
+ const variantPriceSets = await remoteQuery(query);
22
+ for (const { variant_id, price_set_id } of variantPriceSets) {
23
+ variantPriceSetMap.set(variant_id, price_set_id);
24
+ }
25
+ const priceLists = priceListsData.map((priceListData) => {
26
+ const priceListPrices = [];
27
+ priceListData.prices?.forEach((price) => {
28
+ const { variant_id, ...priceData } = price;
29
+ if (!variant_id) {
30
+ return;
31
+ }
32
+ priceListPrices.push({
33
+ id: priceData.id,
34
+ price_set_id: variantPriceSetMap.get(variant_id),
35
+ currency_code: priceData.currency_code,
36
+ amount: priceData.amount,
37
+ min_quantity: priceData.min_quantity,
38
+ max_quantity: priceData.max_quantity,
39
+ });
40
+ return;
41
+ });
42
+ priceListPricesMap.set(priceListData.id, priceListPrices);
43
+ delete priceListData?.prices;
44
+ const priceListDataClone = {
45
+ ...priceListData,
46
+ };
47
+ if (priceListData.name) {
48
+ priceListDataClone.title = priceListData.name;
49
+ }
50
+ return priceListDataClone;
51
+ });
52
+ return { priceLists, priceListPricesMap };
53
+ }
54
+ exports.prepareUpdatePriceLists = prepareUpdatePriceLists;
55
+ prepareUpdatePriceLists.aliases = {
56
+ payload: "prepare",
57
+ };
58
+ //# sourceMappingURL=prepare-update-price-lists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-update-price-lists.js","sourceRoot":"","sources":["../../../src/handlers/price-list/prepare-update-price-lists.ts"],"names":[],"mappings":";;;AAYO,KAAK,UAAU,uBAAuB,CAAC,EAC5C,SAAS,EACT,IAAI,GAGJ;IACA,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;IAC5C,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IAEpD,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAA;IACpD,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAA+B,CAAA;IAEjE,MAAM,UAAU,GAAG,cAAc;SAC9B,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;SACtE,IAAI,EAAE,CAAA;IAET,MAAM,SAAS,GAAG;QAChB,UAAU,EAAE,UAAU;KACvB,CAAA;IAED,MAAM,KAAK,GAAG;QACZ,yBAAyB,EAAE;YACzB,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,CAAC,YAAY,EAAE,cAAc,CAAC;SACvC;KACF,CAAA;IAED,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,CAAA;IAEjD,KAAK,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,gBAAgB,EAAE;QAC3D,kBAAkB,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;KACjD;IAED,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE;QACtD,MAAM,eAAe,GAAwB,EAAE,CAAA;QAE/C,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACtC,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAA;YAC1C,IAAI,CAAC,UAAU,EAAE;gBACf,OAAM;aACP;YAED,eAAe,CAAC,IAAI,CAAC;gBACnB,EAAE,EAAE,SAAS,CAAC,EAAE;gBAChB,YAAY,EAAE,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAW;gBAC1D,aAAa,EAAE,SAAS,CAAC,aAAuB;gBAChD,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,YAAY,EAAE,SAAS,CAAC,YAAY;gBACpC,YAAY,EAAE,SAAS,CAAC,YAAY;aACrC,CAAC,CAAA;YAEF,OAAM;QACR,CAAC,CAAC,CAAA;QAEF,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,EAAE,eAAe,CAAC,CAAA;QAEzD,OAAO,aAAa,EAAE,MAAM,CAAA;QAE5B,MAAM,kBAAkB,GAAuB;YAC7C,GAAG,aAAa;SACjB,CAAA;QAED,IAAI,aAAa,CAAC,IAAI,EAAE;YACtB,kBAAkB,CAAC,KAAK,GAAG,aAAa,CAAC,IAAI,CAAA;SAC9C;QAED,OAAO,kBAAkB,CAAA;IAC3B,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAA;AAC3C,CAAC;AAtED,0DAsEC;AAED,uBAAuB,CAAC,OAAO,GAAG;IAChC,OAAO,EAAE,SAAS;CACnB,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { PriceListDTO } from "@medusajs/types";
2
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
3
+ export declare function removePriceLists({ container, data, }: WorkflowArguments<{
4
+ price_lists: {
5
+ price_list: PriceListDTO;
6
+ }[];
7
+ }>): Promise<{
8
+ price_list: PriceListDTO;
9
+ }[]>;
10
+ export declare namespace removePriceLists {
11
+ var aliases: {
12
+ priceLists: string;
13
+ };
14
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removePriceLists = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ async function removePriceLists({ container, data, }) {
6
+ const pricingService = container.resolve(modules_sdk_1.ModuleRegistrationName.PRICING);
7
+ await pricingService.deletePriceLists(data.price_lists.map(({ price_list }) => price_list.id));
8
+ return data.price_lists;
9
+ }
10
+ exports.removePriceLists = removePriceLists;
11
+ removePriceLists.aliases = {
12
+ priceLists: "priceLists",
13
+ };
14
+ //# sourceMappingURL=remove-price-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-price-list.js","sourceRoot":"","sources":["../../../src/handlers/price-list/remove-price-list.ts"],"names":[],"mappings":";;;AAEA,uDAA8D;AAGvD,KAAK,UAAU,gBAAgB,CAAC,EACrC,SAAS,EACT,IAAI,GAKJ;IAKA,MAAM,cAAc,GAA0B,SAAS,CAAC,OAAO,CAC7D,oCAAsB,CAAC,OAAO,CAC/B,CAAA;IAED,MAAM,cAAe,CAAC,gBAAgB,CACpC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CACxD,CAAA;IAED,OAAO,IAAI,CAAC,WAAW,CAAA;AACzB,CAAC;AArBD,4CAqBC;AAED,gBAAgB,CAAC,OAAO,GAAG;IACzB,UAAU,EAAE,YAAY;CACzB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
2
+ export declare function removePriceListPriceSetPrices({ container, data, }: WorkflowArguments<{
3
+ priceSetIds: string[];
4
+ priceListId: string;
5
+ }>): Promise<string[]>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removePriceListPriceSetPrices = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ const prepare_create_price_list_1 = require("./prepare-create-price-list");
6
+ async function removePriceListPriceSetPrices({ container, data, }) {
7
+ const { priceSetIds, priceListId } = data;
8
+ const pricingService = container.resolve(modules_sdk_1.ModuleRegistrationName.PRICING);
9
+ const priceSetMoneyAmounts = await pricingService.listPriceSetMoneyAmounts({
10
+ price_set_id: priceSetIds,
11
+ price_list_id: [priceListId],
12
+ }, {
13
+ relations: ["money_amount"],
14
+ });
15
+ const moneyAmountIDs = priceSetMoneyAmounts
16
+ .map((priceSetMoneyAmount) => priceSetMoneyAmount.money_amount?.id)
17
+ .filter((moneyAmountId) => !!moneyAmountId);
18
+ await pricingService.deleteMoneyAmounts(moneyAmountIDs);
19
+ return moneyAmountIDs;
20
+ }
21
+ exports.removePriceListPriceSetPrices = removePriceListPriceSetPrices;
22
+ prepare_create_price_list_1.prepareCreatePriceLists.aliases = {
23
+ payload: "payload",
24
+ };
25
+ //# sourceMappingURL=remove-price-set-price-list-prices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-price-set-price-list-prices.js","sourceRoot":"","sources":["../../../src/handlers/price-list/remove-price-set-price-list-prices.ts"],"names":[],"mappings":";;;AAAA,uDAA8D;AAG9D,2EAAqE;AAE9D,KAAK,UAAU,6BAA6B,CAAC,EAClD,SAAS,EACT,IAAI,GAIJ;IACA,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IACzC,MAAM,cAAc,GAA0B,SAAS,CAAC,OAAO,CAC7D,oCAAsB,CAAC,OAAO,CAC/B,CAAA;IAED,MAAM,oBAAoB,GAAG,MAAM,cAAc,CAAC,wBAAwB,CACxE;QACE,YAAY,EAAE,WAAW;QACzB,aAAa,EAAE,CAAC,WAAW,CAAC;KAC7B,EACD;QACE,SAAS,EAAE,CAAC,cAAc,CAAC;KAC5B,CACF,CAAA;IAED,MAAM,cAAc,GAAG,oBAAoB;SACxC,GAAG,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAAC,mBAAmB,CAAC,YAAY,EAAE,EAAE,CAAC;SAClE,MAAM,CAAC,CAAC,aAAa,EAA2B,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAA;IAEtE,MAAM,cAAc,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAA;IAEvD,OAAO,cAAc,CAAA;AACvB,CAAC;AA7BD,sEA6BC;AAED,mDAAuB,CAAC,OAAO,GAAG;IAChC,OAAO,EAAE,SAAS;CACnB,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
2
+ type Result = {
3
+ deletedPriceIds: string[];
4
+ };
5
+ export declare function removePrices({ container, data, }: WorkflowArguments<{
6
+ moneyAmountIds: string[];
7
+ }>): Promise<Result>;
8
+ export declare namespace removePrices {
9
+ var aliases: {
10
+ payload: string;
11
+ };
12
+ }
13
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removePrices = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ async function removePrices({ container, data, }) {
6
+ const { moneyAmountIds } = data;
7
+ const pricingService = container.resolve(modules_sdk_1.ModuleRegistrationName.PRICING);
8
+ await pricingService.deleteMoneyAmounts(moneyAmountIds);
9
+ return {
10
+ deletedPriceIds: moneyAmountIds,
11
+ };
12
+ }
13
+ exports.removePrices = removePrices;
14
+ removePrices.aliases = {
15
+ payload: "payload",
16
+ };
17
+ //# sourceMappingURL=remove-prices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-prices.js","sourceRoot":"","sources":["../../../src/handlers/price-list/remove-prices.ts"],"names":[],"mappings":";;;AAAA,uDAA8D;AAQvD,KAAK,UAAU,YAAY,CAAC,EACjC,SAAS,EACT,IAAI,GAGJ;IACA,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;IAC/B,MAAM,cAAc,GAA0B,SAAS,CAAC,OAAO,CAC7D,oCAAsB,CAAC,OAAO,CAC/B,CAAA;IAED,MAAM,cAAc,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAA;IAEvD,OAAO;QACL,eAAe,EAAE,cAAc;KAChC,CAAA;AACH,CAAC;AAhBD,oCAgBC;AAED,YAAY,CAAC,OAAO,GAAG;IACrB,OAAO,EAAE,SAAS;CACnB,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { PriceListDTO, PriceListPriceDTO, UpdatePriceListDTO } from "@medusajs/types";
2
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
3
+ type Result = {
4
+ priceLists: PriceListDTO[];
5
+ };
6
+ export declare function updatePriceLists({ container, data, }: WorkflowArguments<{
7
+ priceLists: UpdatePriceListDTO[];
8
+ priceListPricesMap: Map<string, PriceListPriceDTO[]>;
9
+ }>): Promise<Result>;
10
+ export declare namespace updatePriceLists {
11
+ var aliases: {
12
+ payload: string;
13
+ };
14
+ }
15
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updatePriceLists = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ async function updatePriceLists({ container, data, }) {
6
+ const { priceLists: priceListsData, priceListPricesMap } = data;
7
+ const pricingService = container.resolve(modules_sdk_1.ModuleRegistrationName.PRICING);
8
+ const priceLists = await pricingService.updatePriceLists(priceListsData);
9
+ const addPriceListPricesData = [];
10
+ const moneyAmountsToUpdate = [];
11
+ for (const [priceListId, prices] of priceListPricesMap.entries()) {
12
+ const moneyAmountsToCreate = [];
13
+ for (const price of prices) {
14
+ if (price.id) {
15
+ moneyAmountsToUpdate.push(price);
16
+ }
17
+ else {
18
+ moneyAmountsToCreate.push(price);
19
+ }
20
+ }
21
+ addPriceListPricesData.push({
22
+ priceListId,
23
+ prices: moneyAmountsToCreate,
24
+ });
25
+ }
26
+ if (addPriceListPricesData.length) {
27
+ await pricingService.addPriceListPrices(addPriceListPricesData);
28
+ }
29
+ if (moneyAmountsToUpdate.length) {
30
+ await pricingService.updateMoneyAmounts(moneyAmountsToUpdate);
31
+ }
32
+ return { priceLists };
33
+ }
34
+ exports.updatePriceLists = updatePriceLists;
35
+ updatePriceLists.aliases = {
36
+ payload: "updatePriceLists",
37
+ };
38
+ //# sourceMappingURL=update-price-lists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-price-lists.js","sourceRoot":"","sources":["../../../src/handlers/price-list/update-price-lists.ts"],"names":[],"mappings":";;;AASA,uDAA8D;AAOvD,KAAK,UAAU,gBAAgB,CAAC,EACrC,SAAS,EACT,IAAI,GAIJ;IACA,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAA;IAC/D,MAAM,cAAc,GAA0B,SAAS,CAAC,OAAO,CAC7D,oCAAsB,CAAC,OAAO,CAC/B,CAAA;IAED,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAA;IACxE,MAAM,sBAAsB,GAA4B,EAAE,CAAA;IAC1D,MAAM,oBAAoB,GAA2B,EAAE,CAAA;IAEvD,KAAK,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,kBAAkB,CAAC,OAAO,EAAE,EAAE;QAChE,MAAM,oBAAoB,GAAwB,EAAE,CAAA;QAEpD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI,KAAK,CAAC,EAAE,EAAE;gBACZ,oBAAoB,CAAC,IAAI,CAAC,KAA6B,CAAC,CAAA;aACzD;iBAAM;gBACL,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;aACjC;SACF;QAED,sBAAsB,CAAC,IAAI,CAAC;YAC1B,WAAW;YACX,MAAM,EAAE,oBAAoB;SAC7B,CAAC,CAAA;KACH;IAED,IAAI,sBAAsB,CAAC,MAAM,EAAE;QACjC,MAAM,cAAc,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,CAAA;KAChE;IAED,IAAI,oBAAoB,CAAC,MAAM,EAAE;QAC/B,MAAM,cAAc,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAA;KAC9D;IAED,OAAO,EAAE,UAAU,EAAE,CAAA;AACvB,CAAC;AA1CD,4CA0CC;AAED,gBAAgB,CAAC,OAAO,GAAG;IACzB,OAAO,EAAE,kBAAkB;CAC5B,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
2
+ type ProductHandle = string;
3
+ type SalesChannelId = string;
4
+ type PartialProduct = {
5
+ handle: string;
6
+ id: string;
7
+ };
8
+ type HandlerInput = {
9
+ productsHandleSalesChannelsMap: Map<ProductHandle, SalesChannelId[]>;
10
+ products: PartialProduct[];
11
+ };
12
+ export declare function attachSalesChannelToProducts({ container, context, data, }: WorkflowArguments<HandlerInput>): Promise<void>;
13
+ export declare namespace attachSalesChannelToProducts {
14
+ var aliases: {
15
+ products: string;
16
+ };
17
+ }
18
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.attachSalesChannelToProducts = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ async function attachSalesChannelToProducts({ container, context, data, }) {
6
+ const { manager } = context;
7
+ const productsHandleSalesChannelsMap = data.productsHandleSalesChannelsMap;
8
+ const products = data.products;
9
+ const salesChannelService = container.resolve("salesChannelService");
10
+ const salesChannelServiceTx = salesChannelService.withTransaction(manager);
11
+ const salesChannelIdProductIdsMap = new Map();
12
+ products.forEach((product) => {
13
+ const salesChannelIds = productsHandleSalesChannelsMap.get(product.handle);
14
+ if (salesChannelIds) {
15
+ salesChannelIds.forEach((salesChannelId) => {
16
+ const productIds = salesChannelIdProductIdsMap.get(salesChannelId) || [];
17
+ productIds.push(product.id);
18
+ salesChannelIdProductIdsMap.set(salesChannelId, productIds);
19
+ });
20
+ }
21
+ });
22
+ await (0, utils_1.promiseAll)(Array.from(salesChannelIdProductIdsMap.entries()).map(async ([salesChannelId, productIds]) => {
23
+ return await salesChannelServiceTx.addProducts(salesChannelId, productIds);
24
+ }));
25
+ }
26
+ exports.attachSalesChannelToProducts = attachSalesChannelToProducts;
27
+ attachSalesChannelToProducts.aliases = {
28
+ products: "products",
29
+ };
30
+ //# sourceMappingURL=attach-sales-channel-to-products.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-sales-channel-to-products.js","sourceRoot":"","sources":["../../../src/handlers/product/attach-sales-channel-to-products.ts"],"names":[],"mappings":";;;AACA,2CAA4C;AAYrC,KAAK,UAAU,4BAA4B,CAAC,EACjD,SAAS,EACT,OAAO,EACP,IAAI,GAC4B;IAChC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAC3B,MAAM,8BAA8B,GAAG,IAAI,CAAC,8BAA8B,CAAA;IAC1E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAE9B,MAAM,mBAAmB,GAAG,SAAS,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACpE,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAE1E,MAAM,2BAA2B,GAAG,IAAI,GAAG,EAAmC,CAAA;IAC9E,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,eAAe,GAAG,8BAA8B,CAAC,GAAG,CAAC,OAAO,CAAC,MAAO,CAAC,CAAA;QAC3E,IAAI,eAAe,EAAE;YACnB,eAAe,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;gBACzC,MAAM,UAAU,GAAG,2BAA2B,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAA;gBACxE,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;gBAC3B,2BAA2B,CAAC,GAAG,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA;YAC7D,CAAC,CAAC,CAAA;SACH;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,IAAA,kBAAU,EACd,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CACnD,KAAK,EAAE,CAAC,cAAc,EAAE,UAAU,CAAC,EAAE,EAAE;QACrC,OAAO,MAAM,qBAAqB,CAAC,WAAW,CAC5C,cAAc,EACd,UAAU,CACX,CAAA;IACH,CAAC,CACF,CACF,CAAA;AACH,CAAC;AAlCD,oEAkCC;AAED,4BAA4B,CAAC,OAAO,GAAG;IACrC,QAAQ,EAAE,UAAU;CACrB,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
2
+ type ProductHandle = string;
3
+ type ShippingProfileId = string;
4
+ type PartialProduct = {
5
+ handle: string;
6
+ id: string;
7
+ };
8
+ type handlerInput = {
9
+ productsHandleShippingProfileIdMap: Map<ProductHandle, ShippingProfileId>;
10
+ products: PartialProduct[];
11
+ };
12
+ export declare function attachShippingProfileToProducts({ container, context, data, }: WorkflowArguments<handlerInput>): Promise<void>;
13
+ export declare namespace attachShippingProfileToProducts {
14
+ var aliases: {
15
+ products: string;
16
+ };
17
+ }
18
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.attachShippingProfileToProducts = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ async function attachShippingProfileToProducts({ container, context, data, }) {
6
+ const { manager } = context;
7
+ const productsHandleShippingProfileIdMap = data.productsHandleShippingProfileIdMap;
8
+ const products = data.products;
9
+ const shippingProfileService = container.resolve("shippingProfileService");
10
+ const shippingProfileServiceTx = shippingProfileService.withTransaction(manager);
11
+ const profileIdProductIdsMap = new Map();
12
+ products.forEach((product) => {
13
+ const profileId = productsHandleShippingProfileIdMap.get(product.handle);
14
+ if (profileId) {
15
+ const productIds = profileIdProductIdsMap.get(profileId) || [];
16
+ productIds.push(product.id);
17
+ profileIdProductIdsMap.set(profileId, productIds);
18
+ }
19
+ });
20
+ await (0, utils_1.promiseAll)(Array.from(profileIdProductIdsMap.entries()).map(async ([profileId, productIds]) => {
21
+ return await shippingProfileServiceTx.addProducts(profileId, productIds);
22
+ }));
23
+ }
24
+ exports.attachShippingProfileToProducts = attachShippingProfileToProducts;
25
+ attachShippingProfileToProducts.aliases = {
26
+ products: "products",
27
+ };
28
+ //# sourceMappingURL=attach-shipping-profile-to-products.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-shipping-profile-to-products.js","sourceRoot":"","sources":["../../../src/handlers/product/attach-shipping-profile-to-products.ts"],"names":[],"mappings":";;;AACA,2CAA4C;AAUrC,KAAK,UAAU,+BAA+B,CAAC,EACpD,SAAS,EACT,OAAO,EACP,IAAI,GAC4B;IAChC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAE3B,MAAM,kCAAkC,GACtC,IAAI,CAAC,kCAAkC,CAAA;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAE9B,MAAM,sBAAsB,GAAG,SAAS,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAA;IAC1E,MAAM,wBAAwB,GAC5B,sBAAsB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAEjD,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAsC,CAAA;IAC5E,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,SAAS,GAAG,kCAAkC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAO,CAAC,CAAA;QACzE,IAAI,SAAS,EAAE;YACb,MAAM,UAAU,GAAG,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;YAC9D,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAC3B,sBAAsB,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;SAClD;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,IAAA,kBAAU,EACd,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAC9C,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE;QAChC,OAAO,MAAM,wBAAwB,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IAC1E,CAAC,CACF,CACF,CAAA;AACH,CAAC;AAhCD,0EAgCC;AAED,+BAA+B,CAAC,OAAO,GAAG;IACxC,QAAQ,EAAE,UAAU;CACrB,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { ProductWorkflow, WorkflowTypes } from "@medusajs/types";
2
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
3
+ type VariantPrice = {
4
+ region_id?: string;
5
+ currency_code?: string;
6
+ amount: number;
7
+ min_quantity?: number;
8
+ max_quantity?: number;
9
+ };
10
+ export type CreateProductVariantsPreparedData = {
11
+ productVariants: ProductWorkflow.CreateProductVariantsInputDTO[];
12
+ variantIndexPricesMap: Map<number, VariantPrice[]>;
13
+ productVariantsMap: Map<string, ProductWorkflow.CreateProductVariantsInputDTO[]>;
14
+ };
15
+ export declare function createProductVariantsPrepareData({ container, data, }: WorkflowArguments<WorkflowTypes.ProductWorkflow.CreateProductVariantsWorkflowInputDTO>): Promise<CreateProductVariantsPreparedData>;
16
+ export declare namespace createProductVariantsPrepareData {
17
+ var aliases: {
18
+ payload: string;
19
+ };
20
+ }
21
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProductVariantsPrepareData = void 0;
4
+ async function createProductVariantsPrepareData({ container, data, }) {
5
+ const featureFlagRouter = container.resolve("featureFlagRouter");
6
+ const productVariants = data.productVariants || [];
7
+ const variantIndexPricesMap = new Map();
8
+ const productVariantsMap = new Map();
9
+ for (const [index, productVariantData] of productVariants.entries()) {
10
+ if (!productVariantData.product_id) {
11
+ continue;
12
+ }
13
+ variantIndexPricesMap.set(index, productVariantData.prices || []);
14
+ delete productVariantData.prices;
15
+ const productVariants = productVariantsMap.get(productVariantData.product_id);
16
+ if (productVariants) {
17
+ productVariants.push(productVariantData);
18
+ }
19
+ else {
20
+ productVariantsMap.set(productVariantData.product_id, [
21
+ productVariantData,
22
+ ]);
23
+ }
24
+ }
25
+ return {
26
+ productVariants,
27
+ variantIndexPricesMap,
28
+ productVariantsMap,
29
+ };
30
+ }
31
+ exports.createProductVariantsPrepareData = createProductVariantsPrepareData;
32
+ createProductVariantsPrepareData.aliases = {
33
+ payload: "payload",
34
+ };
35
+ //# sourceMappingURL=create-product-variants-prepare-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-product-variants-prepare-data.js","sourceRoot":"","sources":["../../../src/handlers/product/create-product-variants-prepare-data.ts"],"names":[],"mappings":";;;AAqBO,KAAK,UAAU,gCAAgC,CAAC,EACrD,SAAS,EACT,IAAI,GACmF;IACvF,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAChE,MAAM,eAAe,GACnB,IAAI,CAAC,eAAe,IAAI,EAAE,CAAA;IAE5B,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAA0B,CAAA;IAC/D,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAG/B,CAAA;IAEH,KAAK,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,IAAI,eAAe,CAAC,OAAO,EAAE,EAAE;QACnE,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAAE;YAClC,SAAQ;SACT;QAED,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,kBAAkB,CAAC,MAAM,IAAI,EAAE,CAAC,CAAA;QAEjE,OAAO,kBAAkB,CAAC,MAAM,CAAA;QAEhC,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAC5C,kBAAkB,CAAC,UAAU,CAC9B,CAAA;QAED,IAAI,eAAe,EAAE;YACnB,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;SACzC;aAAM;YACL,kBAAkB,CAAC,GAAG,CAAC,kBAAkB,CAAC,UAAU,EAAE;gBACpD,kBAAkB;aACnB,CAAC,CAAA;SACH;KACF;IAED,OAAO;QACL,eAAe;QACf,qBAAqB;QACrB,kBAAkB;KACnB,CAAA;AACH,CAAC;AAzCD,4EAyCC;AAED,gCAAgC,CAAC,OAAO,GAAG;IACzC,OAAO,EAAE,SAAS;CACnB,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { ProductTypes } from "@medusajs/types";
2
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
3
+ type VariantPrice = {
4
+ region_id?: string;
5
+ currency_code?: string;
6
+ amount: number;
7
+ min_quantity?: number;
8
+ max_quantity?: number;
9
+ };
10
+ type HandlerInput = {
11
+ productVariantsMap: Map<string, ProductTypes.CreateProductVariantDTO[]>;
12
+ variantIndexPricesMap: Map<number, VariantPrice[]>;
13
+ };
14
+ export declare function createProductVariants({ container, data, }: WorkflowArguments<HandlerInput>): Promise<{
15
+ productVariants: ProductTypes.ProductVariantDTO[];
16
+ variantPricesMap: Map<string, VariantPrice[]>;
17
+ }>;
18
+ export declare namespace createProductVariants {
19
+ var aliases: {
20
+ payload: string;
21
+ };
22
+ }
23
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProductVariants = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ async function createProductVariants({ container, data, }) {
6
+ const { productVariantsMap, variantIndexPricesMap } = data;
7
+ const variantPricesMap = new Map();
8
+ const productModuleService = container.resolve(modules_sdk_1.ModulesDefinition[modules_sdk_1.Modules.PRODUCT].registrationName);
9
+ const productVariants = await productModuleService.createVariants([...productVariantsMap.values()].flat());
10
+ productVariants.forEach((variant, index) => {
11
+ variantPricesMap.set(variant.id, variantIndexPricesMap.get(index) || []);
12
+ });
13
+ return {
14
+ productVariants,
15
+ variantPricesMap,
16
+ };
17
+ }
18
+ exports.createProductVariants = createProductVariants;
19
+ createProductVariants.aliases = {
20
+ payload: "payload",
21
+ };
22
+ //# sourceMappingURL=create-product-variants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-product-variants.js","sourceRoot":"","sources":["../../../src/handlers/product/create-product-variants.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAiB3D,KAAK,UAAU,qBAAqB,CAAC,EAC1C,SAAS,EACT,IAAI,GAC4B;IAIhC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,GAAG,IAAI,CAAA;IAC1D,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA0B,CAAA;IAC1D,MAAM,oBAAoB,GACxB,SAAS,CAAC,OAAO,CAAC,+BAAiB,CAAC,qBAAO,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAExE,MAAM,eAAe,GAAG,MAAM,oBAAoB,CAAC,cAAc,CAC/D,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CACxC,CAAA;IAED,eAAe,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;QACzC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;IAC1E,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,eAAe;QACf,gBAAgB;KACjB,CAAA;AACH,CAAC;AAxBD,sDAwBC;AAED,qBAAqB,CAAC,OAAO,GAAG;IAC9B,OAAO,EAAE,SAAS;CACnB,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { ProductTypes, WorkflowTypes } from "@medusajs/types";
2
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
3
+ type ShippingProfileId = string;
4
+ type SalesChannelId = string;
5
+ type ProductHandle = string;
6
+ type VariantIndexAndPrices = {
7
+ index: number;
8
+ prices: {
9
+ region_id?: string;
10
+ currency_code?: string;
11
+ amount: number;
12
+ min_quantity?: number;
13
+ max_quantity?: number;
14
+ }[];
15
+ };
16
+ export type CreateProductsPreparedData = {
17
+ products: ProductTypes.CreateProductDTO[];
18
+ productsHandleShippingProfileIdMap: Map<ProductHandle, ShippingProfileId>;
19
+ productsHandleSalesChannelsMap: Map<ProductHandle, SalesChannelId[]>;
20
+ productsHandleVariantsIndexPricesMap: Map<ProductHandle, VariantIndexAndPrices[]>;
21
+ };
22
+ export declare function createProductsPrepareData({ container, context, data, }: WorkflowArguments<WorkflowTypes.ProductWorkflow.CreateProductsWorkflowInputDTO>): Promise<CreateProductsPreparedData>;
23
+ export declare namespace createProductsPrepareData {
24
+ var aliases: {
25
+ payload: string;
26
+ };
27
+ }
28
+ export {};