@medusajs/core-flows 0.0.7 → 0.0.9-next-20240425093236

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 (401) hide show
  1. package/dist/api-key/steps/index.d.ts +3 -1
  2. package/dist/api-key/steps/index.js +3 -1
  3. package/dist/api-key/steps/link-sales-channels-to-publishable-key.d.ts +3 -0
  4. package/dist/api-key/steps/link-sales-channels-to-publishable-key.js +53 -0
  5. package/dist/api-key/steps/validate-sales-channel-exists.d.ts +6 -0
  6. package/dist/api-key/steps/validate-sales-channel-exists.js +17 -0
  7. package/dist/api-key/workflows/delete-api-keys.js +7 -1
  8. package/dist/api-key/workflows/index.d.ts +1 -0
  9. package/dist/api-key/workflows/index.js +1 -0
  10. package/dist/api-key/workflows/link-sales-channels-to-publishable-key.d.ts +3 -0
  11. package/dist/api-key/workflows/link-sales-channels-to-publishable-key.js +12 -0
  12. package/dist/common/index.d.ts +2 -0
  13. package/dist/common/index.js +18 -0
  14. package/dist/common/steps/remove-remote-links.d.ts +5 -0
  15. package/dist/common/steps/remove-remote-links.js +32 -0
  16. package/dist/customer/steps/delete-addresses.js +1 -1
  17. package/dist/customer-group/steps/index.d.ts +1 -2
  18. package/dist/customer-group/steps/index.js +1 -2
  19. package/dist/customer-group/steps/link-customers-customer-group.d.ts +3 -0
  20. package/dist/customer-group/steps/link-customers-customer-group.js +42 -0
  21. package/dist/customer-group/workflows/index.d.ts +1 -2
  22. package/dist/customer-group/workflows/index.js +1 -2
  23. package/dist/customer-group/workflows/link-customers-customer-group.d.ts +3 -0
  24. package/dist/customer-group/workflows/link-customers-customer-group.js +9 -0
  25. package/dist/defaults/index.d.ts +2 -0
  26. package/dist/defaults/index.js +18 -0
  27. package/dist/defaults/steps/create-default-store.d.ts +7 -0
  28. package/dist/defaults/steps/create-default-store.js +34 -0
  29. package/dist/defaults/steps/index.d.ts +1 -0
  30. package/dist/defaults/steps/index.js +17 -0
  31. package/dist/defaults/workflows/create-defaults.d.ts +2 -0
  32. package/dist/defaults/workflows/create-defaults.js +21 -0
  33. package/dist/defaults/workflows/index.d.ts +1 -0
  34. package/dist/defaults/workflows/index.js +17 -0
  35. package/dist/definition/cart/steps/add-shipping-method-to-cart.js +3 -3
  36. package/dist/definition/cart/steps/add-to-cart.js +3 -3
  37. package/dist/definition/cart/steps/confirm-inventory.js +4 -4
  38. package/dist/definition/cart/steps/create-payment-collection.d.ts +2 -1
  39. package/dist/definition/cart/steps/get-item-tax-lines.js +3 -3
  40. package/dist/definition/cart/steps/update-tax-lines.js +11 -3
  41. package/dist/definition/cart/utils/prepare-confirm-inventory-input.d.ts +2 -1
  42. package/dist/definition/cart/utils/prepare-confirm-inventory-input.js +10 -9
  43. package/dist/definition/cart/utils/prepare-line-item-data.d.ts +3 -3
  44. package/dist/definition/cart/utils/prepare-line-item-data.js +4 -1
  45. package/dist/definition/payment-collection/steps/create-payment-session.d.ts +2 -2
  46. package/dist/definitions.d.ts +12 -12
  47. package/dist/definitions.js +12 -12
  48. package/dist/file/index.d.ts +2 -0
  49. package/dist/file/index.js +18 -0
  50. package/dist/file/steps/delete-files.d.ts +2 -0
  51. package/dist/file/steps/delete-files.js +11 -0
  52. package/dist/file/steps/index.d.ts +2 -0
  53. package/dist/file/steps/index.js +18 -0
  54. package/dist/file/steps/upload-files.d.ts +10 -0
  55. package/dist/file/steps/upload-files.js +17 -0
  56. package/dist/file/workflows/delete-files.d.ts +6 -0
  57. package/dist/file/workflows/delete-files.js +9 -0
  58. package/dist/file/workflows/index.d.ts +2 -0
  59. package/dist/file/workflows/index.js +18 -0
  60. package/dist/file/workflows/upload-files.d.ts +11 -0
  61. package/dist/file/workflows/upload-files.js +9 -0
  62. package/dist/fulfillment/steps/add-shipping-options-prices.d.ts +18 -0
  63. package/dist/fulfillment/steps/add-shipping-options-prices.js +66 -0
  64. package/dist/fulfillment/steps/cancel-fulfillment.d.ts +2 -0
  65. package/dist/fulfillment/steps/cancel-fulfillment.js +11 -0
  66. package/dist/fulfillment/steps/create-fulfillment-set.d.ts +3 -0
  67. package/dist/fulfillment/steps/create-fulfillment-set.js +17 -0
  68. package/dist/fulfillment/steps/create-fulfillment.d.ts +3 -0
  69. package/dist/fulfillment/steps/create-fulfillment.js +17 -0
  70. package/dist/fulfillment/steps/create-service-zones.d.ts +5 -0
  71. package/dist/fulfillment/steps/create-service-zones.js +17 -0
  72. package/dist/fulfillment/steps/create-shipping-option-rules.d.ts +3 -0
  73. package/dist/fulfillment/steps/{add-rules-to-fulfillment-shipping-option.js → create-shipping-option-rules.js} +3 -3
  74. package/dist/fulfillment/steps/create-shipping-profiles.d.ts +5 -0
  75. package/dist/fulfillment/steps/create-shipping-profiles.js +17 -0
  76. package/dist/fulfillment/steps/delete-fulfillment-sets.d.ts +2 -0
  77. package/dist/fulfillment/steps/delete-fulfillment-sets.js +17 -0
  78. package/dist/fulfillment/steps/delete-service-zones.d.ts +2 -0
  79. package/dist/fulfillment/steps/delete-service-zones.js +17 -0
  80. package/dist/fulfillment/steps/delete-shipping-option-rules.d.ts +3 -0
  81. package/dist/fulfillment/steps/{remove-rules-from-fulfillment-shipping-option.js → delete-shipping-option-rules.js} +3 -3
  82. package/dist/fulfillment/steps/delete-shipping-options.d.ts +3 -0
  83. package/dist/fulfillment/steps/delete-shipping-options.js +23 -0
  84. package/dist/fulfillment/steps/index.d.ts +15 -2
  85. package/dist/fulfillment/steps/index.js +15 -2
  86. package/dist/fulfillment/steps/set-shipping-options-price-sets.d.ts +7 -0
  87. package/dist/fulfillment/steps/set-shipping-options-price-sets.js +102 -0
  88. package/dist/fulfillment/steps/set-shipping-options-prices.d.ts +8 -0
  89. package/dist/fulfillment/steps/set-shipping-options-prices.js +111 -0
  90. package/dist/fulfillment/steps/update-fulfillment-workflow.d.ts +3 -0
  91. package/dist/fulfillment/steps/update-fulfillment-workflow.js +21 -0
  92. package/dist/fulfillment/steps/update-fulfillment.d.ts +3 -0
  93. package/dist/fulfillment/steps/update-fulfillment.js +27 -0
  94. package/dist/fulfillment/steps/update-service-zones.d.ts +3 -0
  95. package/dist/fulfillment/steps/update-service-zones.js +25 -0
  96. package/dist/fulfillment/steps/upsert-shipping-options.d.ts +5 -0
  97. package/dist/fulfillment/steps/upsert-shipping-options.js +49 -0
  98. package/dist/fulfillment/steps/validate-shipment.d.ts +2 -0
  99. package/dist/fulfillment/steps/validate-shipment.js +23 -0
  100. package/dist/fulfillment/workflows/batch-shipping-option-rules.d.ts +3 -0
  101. package/dist/fulfillment/workflows/batch-shipping-option-rules.js +21 -0
  102. package/dist/fulfillment/workflows/cancel-fulfillment.d.ts +4 -0
  103. package/dist/fulfillment/workflows/cancel-fulfillment.js +9 -0
  104. package/dist/fulfillment/workflows/create-fulfillment.d.ts +3 -0
  105. package/dist/fulfillment/workflows/create-fulfillment.js +9 -0
  106. package/dist/fulfillment/workflows/create-service-zones.d.ts +3 -0
  107. package/dist/fulfillment/workflows/create-service-zones.js +10 -0
  108. package/dist/fulfillment/workflows/create-shipment.d.ts +3 -0
  109. package/dist/fulfillment/workflows/create-shipment.js +15 -0
  110. package/dist/fulfillment/workflows/create-shipping-options.d.ts +3 -0
  111. package/dist/fulfillment/workflows/create-shipping-options.js +62 -0
  112. package/dist/fulfillment/workflows/create-shipping-profiles.d.ts +3 -0
  113. package/dist/fulfillment/workflows/create-shipping-profiles.js +10 -0
  114. package/dist/fulfillment/workflows/delete-fulfillment-sets.d.ts +4 -0
  115. package/dist/fulfillment/workflows/delete-fulfillment-sets.js +14 -0
  116. package/dist/fulfillment/workflows/delete-service-zones.d.ts +4 -0
  117. package/dist/fulfillment/workflows/delete-service-zones.js +9 -0
  118. package/dist/fulfillment/workflows/delete-shipping-options.d.ts +3 -0
  119. package/dist/fulfillment/workflows/delete-shipping-options.js +11 -0
  120. package/dist/fulfillment/workflows/index.d.ts +13 -2
  121. package/dist/fulfillment/workflows/index.js +13 -2
  122. package/dist/fulfillment/workflows/update-fulfillment.d.ts +3 -0
  123. package/dist/fulfillment/workflows/update-fulfillment.js +9 -0
  124. package/dist/fulfillment/workflows/update-service-zones.d.ts +3 -0
  125. package/dist/fulfillment/workflows/update-service-zones.js +10 -0
  126. package/dist/fulfillment/workflows/update-shipping-options.d.ts +3 -0
  127. package/dist/fulfillment/workflows/update-shipping-options.js +51 -0
  128. package/dist/handlers/product/create-product-variants-prepare-data.d.ts +4 -4
  129. package/dist/handlers/product/create-product-variants.d.ts +4 -4
  130. package/dist/handlers/product/create-products-prepare-data.d.ts +4 -4
  131. package/dist/handlers/product/update-product-variants-prepare-data.d.ts +4 -4
  132. package/dist/handlers/product/update-product-variants.js +1 -1
  133. package/dist/handlers/product/update-products-prepare-data.d.ts +4 -4
  134. package/dist/handlers/product/upsert-variant-prices.d.ts +4 -4
  135. package/dist/index.d.ts +9 -1
  136. package/dist/index.js +9 -1
  137. package/dist/inventory/steps/create-inventory-items.js +3 -3
  138. package/dist/inventory/steps/create-inventory-levels.d.ts +2 -2
  139. package/dist/inventory/steps/delete-levels-by-item-and-location.d.ts +6 -0
  140. package/dist/inventory/steps/delete-levels-by-item-and-location.js +31 -0
  141. package/dist/inventory/steps/index.d.ts +3 -1
  142. package/dist/inventory/steps/index.js +3 -1
  143. package/dist/inventory/steps/update-inventory-items.d.ts +3 -0
  144. package/dist/inventory/steps/update-inventory-items.js +25 -0
  145. package/dist/inventory/steps/update-inventory-levels.d.ts +3 -0
  146. package/dist/inventory/steps/update-inventory-levels.js +30 -0
  147. package/dist/inventory/steps/validate-inventory-locations.d.ts +2 -2
  148. package/dist/inventory/workflows/bulk-create-delete-levels.d.ts +11 -0
  149. package/dist/inventory/workflows/bulk-create-delete-levels.js +12 -0
  150. package/dist/inventory/workflows/create-inventory-levels.d.ts +2 -2
  151. package/dist/inventory/workflows/delete-inventory-items.js +5 -1
  152. package/dist/inventory/workflows/index.d.ts +3 -0
  153. package/dist/inventory/workflows/index.js +3 -0
  154. package/dist/inventory/workflows/update-inventory-items.d.ts +7 -0
  155. package/dist/inventory/workflows/update-inventory-items.js +9 -0
  156. package/dist/inventory/workflows/update-inventory-levels.d.ts +7 -0
  157. package/dist/inventory/workflows/update-inventory-levels.js +9 -0
  158. package/dist/invite/workflows/accept-invite.d.ts +1 -2
  159. package/dist/invite/workflows/accept-invite.js +3 -4
  160. package/dist/order/index.d.ts +2 -0
  161. package/dist/order/index.js +18 -0
  162. package/dist/order/steps/create-orders.d.ts +5 -0
  163. package/dist/order/steps/create-orders.js +17 -0
  164. package/dist/order/steps/get-item-tax-lines.d.ts +13 -0
  165. package/dist/order/steps/get-item-tax-lines.js +73 -0
  166. package/dist/order/steps/index.d.ts +4 -0
  167. package/dist/order/steps/index.js +20 -0
  168. package/dist/order/steps/set-tax-lines-for-items.d.ts +9 -0
  169. package/dist/order/steps/set-tax-lines-for-items.js +80 -0
  170. package/dist/order/steps/update-tax-lines.d.ts +10 -0
  171. package/dist/order/steps/update-tax-lines.js +19 -0
  172. package/dist/order/utils/prepare-custom-line-item-data.d.ts +22 -0
  173. package/dist/order/utils/prepare-custom-line-item-data.js +17 -0
  174. package/dist/order/workflows/create-orders.d.ts +3 -0
  175. package/dist/order/workflows/create-orders.js +143 -0
  176. package/dist/order/workflows/index.d.ts +2 -0
  177. package/dist/order/workflows/index.js +18 -0
  178. package/dist/order/workflows/update-tax-lines.d.ts +10 -0
  179. package/dist/order/workflows/update-tax-lines.js +70 -0
  180. package/dist/payment/steps/capture-payment.d.ts +2 -1
  181. package/dist/payment/steps/refund-payment.d.ts +2 -1
  182. package/dist/payment/workflows/capture-payment.d.ts +2 -2
  183. package/dist/payment/workflows/refund-payment.d.ts +2 -1
  184. package/dist/price-list/steps/create-price-list-prices-workflow.d.ts +3 -0
  185. package/dist/price-list/steps/create-price-list-prices-workflow.js +15 -0
  186. package/dist/price-list/steps/create-price-list-prices.d.ts +1 -1
  187. package/dist/price-list/steps/create-price-list-prices.js +1 -1
  188. package/dist/price-list/steps/delete-price-lists.js +2 -4
  189. package/dist/price-list/steps/get-existing-price-lists-price-ids.js +1 -1
  190. package/dist/price-list/steps/index.d.ts +3 -1
  191. package/dist/price-list/steps/index.js +3 -1
  192. package/dist/price-list/steps/remove-price-list-prices-workflow.d.ts +2 -0
  193. package/dist/price-list/steps/remove-price-list-prices-workflow.js +15 -0
  194. package/dist/price-list/steps/remove-price-list-prices.d.ts +1 -1
  195. package/dist/price-list/steps/remove-price-list-prices.js +7 -7
  196. package/dist/price-list/steps/update-price-list-prices-workflow.d.ts +3 -0
  197. package/dist/price-list/steps/update-price-list-prices-workflow.js +15 -0
  198. package/dist/price-list/steps/update-price-list-prices.d.ts +2 -2
  199. package/dist/price-list/steps/update-price-list-prices.js +8 -8
  200. package/dist/price-list/steps/validate-variant-price-links.d.ts +5 -2
  201. package/dist/price-list/workflows/batch-price-list-prices.d.ts +5 -0
  202. package/dist/price-list/workflows/batch-price-list-prices.js +18 -0
  203. package/dist/price-list/workflows/create-price-list-prices.d.ts +2 -1
  204. package/dist/price-list/workflows/create-price-list-prices.js +5 -3
  205. package/dist/price-list/workflows/index.d.ts +2 -1
  206. package/dist/price-list/workflows/index.js +2 -1
  207. package/dist/price-list/workflows/remove-price-list-prices.d.ts +1 -1
  208. package/dist/price-list/workflows/remove-price-list-prices.js +2 -2
  209. package/dist/price-list/workflows/update-price-list-prices.d.ts +6 -0
  210. package/dist/price-list/workflows/update-price-list-prices.js +15 -0
  211. package/dist/price-list/workflows/update-price-lists.js +2 -19
  212. package/dist/pricing/steps/create-pricing-rule-types.js +9 -1
  213. package/dist/pricing/steps/update-price-sets.d.ts +9 -2
  214. package/dist/pricing/steps/update-price-sets.js +22 -9
  215. package/dist/pricing/steps/update-pricing-rule-types.js +1 -1
  216. package/dist/product/steps/batch-link-products-collection.d.ts +3 -0
  217. package/dist/product/steps/batch-link-products-collection.js +38 -0
  218. package/dist/product/steps/batch-link-products-in-category.d.ts +3 -0
  219. package/dist/product/steps/batch-link-products-in-category.js +63 -0
  220. package/dist/product/steps/batch-product-variants.d.ts +11 -0
  221. package/dist/product/steps/batch-product-variants.js +59 -0
  222. package/dist/product/steps/batch-products.d.ts +11 -0
  223. package/dist/product/steps/batch-products.js +59 -0
  224. package/dist/product/steps/create-product-types.d.ts +3 -0
  225. package/dist/product/steps/create-product-types.js +17 -0
  226. package/dist/product/steps/delete-product-types.d.ts +2 -0
  227. package/dist/product/steps/delete-product-types.js +17 -0
  228. package/dist/product/steps/get-variant-pricing-link.d.ts +6 -0
  229. package/dist/product/steps/get-variant-pricing-link.js +20 -0
  230. package/dist/product/steps/index.d.ts +6 -1
  231. package/dist/product/steps/index.js +6 -1
  232. package/dist/product/steps/update-product-options.d.ts +1 -1
  233. package/dist/product/steps/update-product-options.js +7 -9
  234. package/dist/product/steps/update-product-types.d.ts +8 -0
  235. package/dist/product/steps/update-product-types.js +25 -0
  236. package/dist/product/steps/update-product-variants.d.ts +3 -1
  237. package/dist/product/steps/update-product-variants.js +12 -9
  238. package/dist/product/steps/update-products.d.ts +2 -0
  239. package/dist/product/steps/update-products.js +10 -0
  240. package/dist/product/workflows/batch-link-products-collection.d.ts +3 -0
  241. package/dist/product/workflows/batch-link-products-collection.js +9 -0
  242. package/dist/product/workflows/batch-product-variants.d.ts +3 -0
  243. package/dist/product/workflows/batch-product-variants.js +9 -0
  244. package/dist/product/workflows/batch-products-in-category.d.ts +3 -0
  245. package/dist/product/workflows/batch-products-in-category.js +11 -0
  246. package/dist/product/workflows/batch-products.d.ts +4 -0
  247. package/dist/product/workflows/batch-products.js +9 -0
  248. package/dist/product/workflows/create-product-types.d.ts +7 -0
  249. package/dist/product/workflows/create-product-types.js +9 -0
  250. package/dist/product/workflows/create-product-variants.js +8 -13
  251. package/dist/product/workflows/create-products.d.ts +3 -6
  252. package/dist/product/workflows/create-products.js +28 -23
  253. package/dist/product/workflows/delete-product-types.d.ts +6 -0
  254. package/dist/product/workflows/delete-product-types.js +9 -0
  255. package/dist/product/workflows/delete-product-variants.js +5 -2
  256. package/dist/product/workflows/delete-products.js +12 -6
  257. package/dist/product/workflows/index.d.ts +15 -8
  258. package/dist/product/workflows/index.js +15 -8
  259. package/dist/product/workflows/update-product-types.d.ts +8 -0
  260. package/dist/product/workflows/update-product-types.js +9 -0
  261. package/dist/product/workflows/update-product-variants.d.ts +8 -2
  262. package/dist/product/workflows/update-product-variants.js +71 -1
  263. package/dist/product/workflows/update-products.d.ts +2 -0
  264. package/dist/product/workflows/update-products.js +4 -2
  265. package/dist/product-category/index.d.ts +2 -0
  266. package/dist/product-category/index.js +18 -0
  267. package/dist/product-category/steps/create-product-category.d.ts +7 -0
  268. package/dist/product-category/steps/create-product-category.js +17 -0
  269. package/dist/product-category/steps/index.d.ts +1 -0
  270. package/dist/product-category/steps/index.js +17 -0
  271. package/dist/product-category/steps/update-product-category.d.ts +8 -0
  272. package/dist/product-category/steps/update-product-category.js +36 -0
  273. package/dist/product-category/workflows/create-product-category.d.ts +3 -0
  274. package/dist/product-category/workflows/create-product-category.js +10 -0
  275. package/dist/product-category/workflows/index.d.ts +2 -0
  276. package/dist/product-category/workflows/index.js +18 -0
  277. package/dist/product-category/workflows/update-product-category.d.ts +3 -0
  278. package/dist/product-category/workflows/update-product-category.js +10 -0
  279. package/dist/promotion/steps/create-promotion-rules-workflow.d.ts +3 -0
  280. package/dist/promotion/steps/create-promotion-rules-workflow.js +21 -0
  281. package/dist/promotion/steps/delete-promotion-rules-workflow.d.ts +7 -0
  282. package/dist/promotion/steps/delete-promotion-rules-workflow.js +25 -0
  283. package/dist/promotion/steps/update-promotion-rules-workflow.d.ts +3 -0
  284. package/dist/promotion/steps/update-promotion-rules-workflow.js +21 -0
  285. package/dist/promotion/workflows/batch-promotion-rules.d.ts +7 -0
  286. package/dist/promotion/workflows/batch-promotion-rules.js +23 -0
  287. package/dist/promotion/workflows/create-promotion-rules.d.ts +3 -0
  288. package/dist/promotion/workflows/create-promotion-rules.js +9 -0
  289. package/dist/promotion/workflows/delete-promotion-rules.d.ts +3 -0
  290. package/dist/promotion/workflows/delete-promotion-rules.js +9 -0
  291. package/dist/promotion/workflows/index.d.ts +3 -2
  292. package/dist/promotion/workflows/index.js +3 -2
  293. package/dist/promotion/workflows/update-promotion-rules.d.ts +2 -2
  294. package/dist/promotion/workflows/update-promotion-rules.js +1 -1
  295. package/dist/region/steps/set-regions-payment-providers.d.ts +8 -0
  296. package/dist/region/steps/set-regions-payment-providers.js +117 -0
  297. package/dist/region/steps/update-regions.js +4 -1
  298. package/dist/region/workflows/create-regions.d.ts +2 -6
  299. package/dist/region/workflows/create-regions.js +29 -1
  300. package/dist/region/workflows/update-regions.d.ts +2 -7
  301. package/dist/region/workflows/update-regions.js +23 -1
  302. package/dist/reservation/index.d.ts +2 -0
  303. package/dist/reservation/index.js +18 -0
  304. package/dist/reservation/steps/create-reservations.d.ts +3 -0
  305. package/dist/reservation/steps/create-reservations.js +17 -0
  306. package/dist/reservation/steps/delete-reservations.d.ts +2 -0
  307. package/dist/reservation/steps/delete-reservations.js +17 -0
  308. package/dist/reservation/steps/index.d.ts +3 -0
  309. package/dist/reservation/steps/index.js +19 -0
  310. package/dist/reservation/steps/update-reservations.d.ts +3 -0
  311. package/dist/reservation/steps/update-reservations.js +25 -0
  312. package/dist/reservation/workflows/create-reservations.d.ts +3 -0
  313. package/dist/reservation/workflows/create-reservations.js +9 -0
  314. package/dist/reservation/workflows/delete-reservations.d.ts +6 -0
  315. package/dist/reservation/workflows/delete-reservations.js +9 -0
  316. package/dist/reservation/workflows/index.d.ts +3 -0
  317. package/dist/reservation/workflows/index.js +19 -0
  318. package/dist/reservation/workflows/update-reservations.d.ts +3 -0
  319. package/dist/reservation/workflows/update-reservations.js +9 -0
  320. package/dist/sales-channel/steps/associate-locations-with-channels.d.ts +9 -0
  321. package/dist/sales-channel/steps/associate-locations-with-channels.js +31 -0
  322. package/dist/sales-channel/steps/associate-products-with-channels.d.ts +1 -1
  323. package/dist/sales-channel/steps/associate-products-with-channels.js +13 -14
  324. package/dist/sales-channel/steps/create-default-sales-channel.d.ts +7 -0
  325. package/dist/sales-channel/steps/create-default-sales-channel.js +22 -0
  326. package/dist/sales-channel/steps/detach-locations-from-channels.d.ts +9 -0
  327. package/dist/sales-channel/steps/detach-locations-from-channels.js +31 -0
  328. package/dist/sales-channel/steps/detach-products-from-sales-channels.d.ts +9 -0
  329. package/dist/sales-channel/steps/detach-products-from-sales-channels.js +31 -0
  330. package/dist/sales-channel/steps/index.d.ts +4 -0
  331. package/dist/sales-channel/steps/index.js +4 -0
  332. package/dist/sales-channel/workflows/delete-sales-channels.js +6 -1
  333. package/dist/sales-channel/workflows/index.d.ts +1 -1
  334. package/dist/sales-channel/workflows/index.js +1 -1
  335. package/dist/sales-channel/workflows/link-products-to-sales-channel.d.ts +3 -0
  336. package/dist/sales-channel/workflows/link-products-to-sales-channel.js +24 -0
  337. package/dist/shipping-profile/index.d.ts +2 -0
  338. package/dist/shipping-profile/index.js +18 -0
  339. package/dist/shipping-profile/steps/delete-shipping-profile.d.ts +2 -0
  340. package/dist/shipping-profile/steps/delete-shipping-profile.js +17 -0
  341. package/dist/shipping-profile/steps/index.d.ts +1 -0
  342. package/dist/shipping-profile/steps/index.js +17 -0
  343. package/dist/shipping-profile/workflows/delete-shipping-profile.d.ts +4 -0
  344. package/dist/shipping-profile/workflows/delete-shipping-profile.js +14 -0
  345. package/dist/shipping-profile/workflows/index.d.ts +1 -0
  346. package/dist/shipping-profile/workflows/index.js +17 -0
  347. package/dist/stock-location/index.d.ts +2 -0
  348. package/dist/stock-location/index.js +18 -0
  349. package/dist/stock-location/steps/associate-locations-with-fulfillment-sets.d.ts +9 -0
  350. package/dist/stock-location/steps/associate-locations-with-fulfillment-sets.js +35 -0
  351. package/dist/stock-location/steps/create-stock-locations.d.ts +3 -0
  352. package/dist/stock-location/steps/create-stock-locations.js +17 -0
  353. package/dist/stock-location/steps/delete-stock-locations.d.ts +2 -0
  354. package/dist/stock-location/steps/delete-stock-locations.js +17 -0
  355. package/dist/stock-location/steps/index.d.ts +3 -0
  356. package/dist/stock-location/steps/index.js +19 -0
  357. package/dist/stock-location/steps/update-stock-locations.d.ts +9 -0
  358. package/dist/stock-location/steps/update-stock-locations.js +30 -0
  359. package/dist/stock-location/workflows/create-location-fulfillment-set.d.ts +3 -0
  360. package/dist/stock-location/workflows/create-location-fulfillment-set.js +24 -0
  361. package/dist/stock-location/workflows/create-stock-locations.d.ts +7 -0
  362. package/dist/stock-location/workflows/create-stock-locations.js +10 -0
  363. package/dist/stock-location/workflows/delete-stock-locations.d.ts +6 -0
  364. package/dist/stock-location/workflows/delete-stock-locations.js +14 -0
  365. package/dist/stock-location/workflows/index.d.ts +5 -0
  366. package/dist/stock-location/workflows/index.js +21 -0
  367. package/dist/stock-location/workflows/link-sales-channels-to-stock-location.d.ts +3 -0
  368. package/dist/stock-location/workflows/link-sales-channels-to-stock-location.js +23 -0
  369. package/dist/stock-location/workflows/update-stock-locations.d.ts +10 -0
  370. package/dist/stock-location/workflows/update-stock-locations.js +9 -0
  371. package/dist/user/workflows/create-user-account.d.ts +8 -0
  372. package/dist/user/workflows/create-user-account.js +17 -0
  373. package/dist/user/workflows/index.d.ts +2 -1
  374. package/dist/user/workflows/index.js +2 -1
  375. package/package.json +6 -6
  376. package/dist/customer-group/steps/create-customer-group-customers.d.ts +0 -5
  377. package/dist/customer-group/steps/create-customer-group-customers.js +0 -17
  378. package/dist/customer-group/workflows/create-customer-group-customers.d.ts +0 -9
  379. package/dist/customer-group/workflows/create-customer-group-customers.js +0 -9
  380. package/dist/customer-group/workflows/delete-customer-group-customers.d.ts +0 -7
  381. package/dist/customer-group/workflows/delete-customer-group-customers.js +0 -9
  382. package/dist/fulfillment/steps/add-rules-to-fulfillment-shipping-option.d.ts +0 -3
  383. package/dist/fulfillment/steps/remove-rules-from-fulfillment-shipping-option.d.ts +0 -3
  384. package/dist/fulfillment/workflows/add-rules-to-fulfillment-shipping-option.d.ts +0 -3
  385. package/dist/fulfillment/workflows/add-rules-to-fulfillment-shipping-option.js +0 -9
  386. package/dist/fulfillment/workflows/remove-rules-from-fulfillment-shipping-option.d.ts +0 -3
  387. package/dist/fulfillment/workflows/remove-rules-from-fulfillment-shipping-option.js +0 -9
  388. package/dist/inventory/steps/deatach-inventory-items.d.ts +0 -2
  389. package/dist/inventory/steps/deatach-inventory-items.js +0 -35
  390. package/dist/price-list/steps/upsert-price-list-prices.d.ts +0 -3
  391. package/dist/price-list/steps/upsert-price-list-prices.js +0 -84
  392. package/dist/price-list/workflows/upsert-price-list-prices.d.ts +0 -5
  393. package/dist/price-list/workflows/upsert-price-list-prices.js +0 -13
  394. package/dist/product/steps/remove-variant-pricing-link.d.ts +0 -6
  395. package/dist/product/steps/remove-variant-pricing-link.js +0 -29
  396. package/dist/promotion/workflows/add-rules-to-promotions.d.ts +0 -3
  397. package/dist/promotion/workflows/add-rules-to-promotions.js +0 -9
  398. package/dist/promotion/workflows/remove-rules-from-promotions.d.ts +0 -3
  399. package/dist/promotion/workflows/remove-rules-from-promotions.js +0 -9
  400. package/dist/sales-channel/workflows/add-products-to-sales-channels.d.ts +0 -10
  401. package/dist/sales-channel/workflows/add-products-to-sales-channels.js +0 -9
@@ -1,4 +1,6 @@
1
+ export * from "./link-sales-channels-to-publishable-key";
1
2
  export * from "./create-api-keys";
2
3
  export * from "./delete-api-keys";
3
- export * from "./update-api-keys";
4
4
  export * from "./revoke-api-keys";
5
+ export * from "./update-api-keys";
6
+ export * from "./validate-sales-channel-exists";
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./link-sales-channels-to-publishable-key"), exports);
17
18
  __exportStar(require("./create-api-keys"), exports);
18
19
  __exportStar(require("./delete-api-keys"), exports);
19
- __exportStar(require("./update-api-keys"), exports);
20
20
  __exportStar(require("./revoke-api-keys"), exports);
21
+ __exportStar(require("./update-api-keys"), exports);
22
+ __exportStar(require("./validate-sales-channel-exists"), exports);
@@ -0,0 +1,3 @@
1
+ import { LinkWorkflowInput } from "@medusajs/types/src";
2
+ export declare const linkSalesChannelsToApiKeyStepId = "link-sales-channels-to-api-key";
3
+ export declare const linkSalesChannelsToApiKeyStep: import("@medusajs/workflows-sdk").StepFunction<LinkWorkflowInput, undefined>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.linkSalesChannelsToApiKeyStep = exports.linkSalesChannelsToApiKeyStepId = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ const utils_1 = require("@medusajs/utils");
6
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
7
+ exports.linkSalesChannelsToApiKeyStepId = "link-sales-channels-to-api-key";
8
+ exports.linkSalesChannelsToApiKeyStep = (0, workflows_sdk_1.createStep)(exports.linkSalesChannelsToApiKeyStepId, async (input, { container }) => {
9
+ const remoteLink = container.resolve(utils_1.ContainerRegistrationKeys.REMOTE_LINK);
10
+ if (!input || (!input.add?.length && !input.remove?.length)) {
11
+ return;
12
+ }
13
+ const linksToCreate = (input.add ?? []).map((salesChannelId) => {
14
+ return {
15
+ [modules_sdk_1.Modules.API_KEY]: {
16
+ publishable_key_id: input.id,
17
+ },
18
+ [modules_sdk_1.Modules.SALES_CHANNEL]: {
19
+ sales_channel_id: salesChannelId,
20
+ },
21
+ };
22
+ });
23
+ const linksToDismiss = (input.remove ?? []).map((salesChannelId) => {
24
+ return {
25
+ [modules_sdk_1.Modules.API_KEY]: {
26
+ publishable_key_id: input.id,
27
+ },
28
+ [modules_sdk_1.Modules.SALES_CHANNEL]: {
29
+ sales_channel_id: salesChannelId,
30
+ },
31
+ };
32
+ });
33
+ const promises = [];
34
+ if (linksToCreate.length) {
35
+ promises.push(remoteLink.create(linksToCreate));
36
+ }
37
+ if (linksToDismiss.length) {
38
+ promises.push(remoteLink.dismiss(linksToDismiss));
39
+ }
40
+ await (0, utils_1.promiseAll)(promises);
41
+ return new workflows_sdk_1.StepResponse(void 0, { linksToCreate, linksToDismiss });
42
+ }, async (prevData, { container }) => {
43
+ if (!prevData) {
44
+ return;
45
+ }
46
+ const remoteLink = container.resolve(utils_1.ContainerRegistrationKeys.REMOTE_LINK);
47
+ if (prevData.linksToCreate.length) {
48
+ await remoteLink.dismiss(prevData.linksToCreate);
49
+ }
50
+ if (prevData.linksToDismiss.length) {
51
+ await remoteLink.create(prevData.linksToDismiss);
52
+ }
53
+ });
@@ -0,0 +1,6 @@
1
+ interface StepInput {
2
+ sales_channel_ids: string[];
3
+ }
4
+ export declare const validateSalesChannelsExistStepId = "validate-sales-channels-exist";
5
+ export declare const validateSalesChannelsExistStep: import("@medusajs/workflows-sdk").StepFunction<StepInput, string[]>;
6
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateSalesChannelsExistStep = exports.validateSalesChannelsExistStepId = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ const utils_1 = require("@medusajs/utils");
6
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
7
+ exports.validateSalesChannelsExistStepId = "validate-sales-channels-exist";
8
+ exports.validateSalesChannelsExistStep = (0, workflows_sdk_1.createStep)(exports.validateSalesChannelsExistStepId, async (data, { container }) => {
9
+ const salesChannelModuleService = container.resolve(modules_sdk_1.ModuleRegistrationName.SALES_CHANNEL);
10
+ const salesChannels = await salesChannelModuleService.list({ id: data.sales_channel_ids }, { select: ["id"] });
11
+ const salesChannelIds = salesChannels.map((v) => v.id);
12
+ const notFound = (0, utils_1.arrayDifference)(data.sales_channel_ids, salesChannelIds);
13
+ if (notFound.length) {
14
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Sales channels with IDs ${notFound.join(", ")} do not exist`);
15
+ }
16
+ return new workflows_sdk_1.StepResponse(salesChannelIds);
17
+ });
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteApiKeysWorkflow = exports.deleteApiKeysWorkflowId = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
4
5
  const workflows_sdk_1 = require("@medusajs/workflows-sdk");
6
+ const remove_remote_links_1 = require("../../common/steps/remove-remote-links");
5
7
  const steps_1 = require("../steps");
6
8
  exports.deleteApiKeysWorkflowId = "delete-api-keys";
7
9
  exports.deleteApiKeysWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.deleteApiKeysWorkflowId, (input) => {
8
- return (0, steps_1.deleteApiKeysStep)(input.ids);
10
+ (0, steps_1.deleteApiKeysStep)(input.ids);
11
+ // Please note, the ids here should be publishable key IDs
12
+ (0, remove_remote_links_1.removeRemoteLinkStep)({
13
+ [modules_sdk_1.Modules.API_KEY]: { publishable_key_id: input.ids },
14
+ });
9
15
  });
@@ -2,3 +2,4 @@ export * from "./create-api-keys";
2
2
  export * from "./delete-api-keys";
3
3
  export * from "./update-api-keys";
4
4
  export * from "./revoke-api-keys";
5
+ export * from "./link-sales-channels-to-publishable-key";
@@ -18,3 +18,4 @@ __exportStar(require("./create-api-keys"), exports);
18
18
  __exportStar(require("./delete-api-keys"), exports);
19
19
  __exportStar(require("./update-api-keys"), exports);
20
20
  __exportStar(require("./revoke-api-keys"), exports);
21
+ __exportStar(require("./link-sales-channels-to-publishable-key"), exports);
@@ -0,0 +1,3 @@
1
+ import { LinkWorkflowInput } from "@medusajs/types/src";
2
+ export declare const linkSalesChannelsToApiKeyWorkflowId = "link-sales-channels-to-api-key";
3
+ export declare const linkSalesChannelsToApiKeyWorkflow: import("@medusajs/workflows-sdk").ReturnWorkflow<LinkWorkflowInput, void, Record<string, Function>>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.linkSalesChannelsToApiKeyWorkflow = exports.linkSalesChannelsToApiKeyWorkflowId = void 0;
4
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
+ const steps_1 = require("../steps");
6
+ exports.linkSalesChannelsToApiKeyWorkflowId = "link-sales-channels-to-api-key";
7
+ exports.linkSalesChannelsToApiKeyWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.linkSalesChannelsToApiKeyWorkflowId, (input) => {
8
+ (0, steps_1.validateSalesChannelsExistStep)({
9
+ sales_channel_ids: input.add ?? [],
10
+ });
11
+ (0, steps_1.linkSalesChannelsToApiKeyStep)(input);
12
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./steps/remove-remote-links";
2
+ export * from "./steps/use-remote-query";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./steps/remove-remote-links"), exports);
18
+ __exportStar(require("./steps/use-remote-query"), exports);
@@ -0,0 +1,5 @@
1
+ import { DeleteEntityInput } from "@medusajs/modules-sdk";
2
+ type RemoveRemoteLinksStepInput = DeleteEntityInput | DeleteEntityInput[];
3
+ export declare const removeRemoteLinkStepId = "remove-remote-links";
4
+ export declare const removeRemoteLinkStep: import("@medusajs/workflows-sdk").StepFunction<RemoveRemoteLinksStepInput, DeleteEntityInput>;
5
+ export {};
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeRemoteLinkStep = exports.removeRemoteLinkStepId = void 0;
4
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
+ const utils_1 = require("@medusajs/utils");
6
+ exports.removeRemoteLinkStepId = "remove-remote-links";
7
+ exports.removeRemoteLinkStep = (0, workflows_sdk_1.createStep)(exports.removeRemoteLinkStepId, async (data, { container }) => {
8
+ var _a;
9
+ const entries = Array.isArray(data) ? data : [data];
10
+ const grouped = {};
11
+ for (const entry of entries) {
12
+ for (const moduleName of Object.keys(entry)) {
13
+ grouped[moduleName] ?? (grouped[moduleName] = {});
14
+ for (const linkableKey of Object.keys(entry[moduleName])) {
15
+ (_a = grouped[moduleName])[linkableKey] ?? (_a[linkableKey] = []);
16
+ const keys = Array.isArray(entry[moduleName][linkableKey])
17
+ ? entry[moduleName][linkableKey]
18
+ : [entry[moduleName][linkableKey]];
19
+ grouped[moduleName][linkableKey] = grouped[moduleName][linkableKey].concat(keys);
20
+ }
21
+ }
22
+ }
23
+ const link = container.resolve(utils_1.ContainerRegistrationKeys.REMOTE_LINK);
24
+ await link.delete(grouped);
25
+ return new workflows_sdk_1.StepResponse(grouped, grouped);
26
+ }, async (removedLinks, { container }) => {
27
+ if (!removedLinks) {
28
+ return;
29
+ }
30
+ const link = container.resolve(utils_1.ContainerRegistrationKeys.REMOTE_LINK);
31
+ await link.restore(removedLinks);
32
+ });
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteCustomerAddressesStep = exports.deleteCustomerAddressesStepId = void 0;
4
- const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
4
  const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
6
6
  exports.deleteCustomerAddressesStepId = "delete-customer-addresses";
7
7
  exports.deleteCustomerAddressesStep = (0, workflows_sdk_1.createStep)(exports.deleteCustomerAddressesStepId, async (ids, { container }) => {
8
8
  const service = container.resolve(modules_sdk_1.ModuleRegistrationName.CUSTOMER);
@@ -1,5 +1,4 @@
1
1
  export * from "./update-customer-groups";
2
2
  export * from "./delete-customer-groups";
3
3
  export * from "./create-customer-groups";
4
- export * from "./create-customer-group-customers";
5
- export * from "./delete-customer-group-customers";
4
+ export * from "./link-customers-customer-group";
@@ -17,5 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./update-customer-groups"), exports);
18
18
  __exportStar(require("./delete-customer-groups"), exports);
19
19
  __exportStar(require("./create-customer-groups"), exports);
20
- __exportStar(require("./create-customer-group-customers"), exports);
21
- __exportStar(require("./delete-customer-group-customers"), exports);
20
+ __exportStar(require("./link-customers-customer-group"), exports);
@@ -0,0 +1,3 @@
1
+ import { LinkWorkflowInput } from "@medusajs/types/src";
2
+ export declare const linkCustomersToCustomerGroupStepId = "link-customers-to-customer-group";
3
+ export declare const linkCustomersToCustomerGroupStep: import("@medusajs/workflows-sdk").StepFunction<LinkWorkflowInput, undefined>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.linkCustomersToCustomerGroupStep = exports.linkCustomersToCustomerGroupStepId = void 0;
4
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
6
+ const utils_1 = require("@medusajs/utils");
7
+ exports.linkCustomersToCustomerGroupStepId = "link-customers-to-customer-group";
8
+ exports.linkCustomersToCustomerGroupStep = (0, workflows_sdk_1.createStep)(exports.linkCustomersToCustomerGroupStepId, async (data, { container }) => {
9
+ const service = container.resolve(modules_sdk_1.ModuleRegistrationName.CUSTOMER);
10
+ const toAdd = (data.add ?? []).map((customerId) => {
11
+ return {
12
+ customer_id: customerId,
13
+ customer_group_id: data.id,
14
+ };
15
+ });
16
+ const toRemove = (data.remove ?? []).map((customerId) => {
17
+ return {
18
+ customer_id: customerId,
19
+ customer_group_id: data.id,
20
+ };
21
+ });
22
+ const promises = [];
23
+ if (toAdd.length) {
24
+ promises.push(service.addCustomerToGroup(toAdd));
25
+ }
26
+ if (toRemove.length) {
27
+ promises.push(service.removeCustomerFromGroup(toRemove));
28
+ }
29
+ await (0, utils_1.promiseAll)(promises);
30
+ return new workflows_sdk_1.StepResponse(void 0, { toAdd, toRemove });
31
+ }, async (prevData, { container }) => {
32
+ if (!prevData) {
33
+ return;
34
+ }
35
+ const service = container.resolve(modules_sdk_1.ModuleRegistrationName.CUSTOMER);
36
+ if (prevData.toAdd.length) {
37
+ await service.removeCustomerFromGroup(prevData.toAdd);
38
+ }
39
+ if (prevData.toRemove.length) {
40
+ await service.addCustomerToGroup(prevData.toRemove);
41
+ }
42
+ });
@@ -1,5 +1,4 @@
1
1
  export * from "./update-customer-groups";
2
2
  export * from "./delete-customer-groups";
3
3
  export * from "./create-customer-groups";
4
- export * from "./create-customer-group-customers";
5
- export * from "./delete-customer-group-customers";
4
+ export * from "./link-customers-customer-group";
@@ -17,5 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./update-customer-groups"), exports);
18
18
  __exportStar(require("./delete-customer-groups"), exports);
19
19
  __exportStar(require("./create-customer-groups"), exports);
20
- __exportStar(require("./create-customer-group-customers"), exports);
21
- __exportStar(require("./delete-customer-group-customers"), exports);
20
+ __exportStar(require("./link-customers-customer-group"), exports);
@@ -0,0 +1,3 @@
1
+ import { LinkWorkflowInput } from "@medusajs/types/src";
2
+ export declare const linkCustomersToCustomerGroupWorkflowId = "link-customers-to-customer-group";
3
+ export declare const linkCustomersToCustomerGroupWorkflow: import("@medusajs/workflows-sdk").ReturnWorkflow<LinkWorkflowInput, void, Record<string, Function>>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.linkCustomersToCustomerGroupWorkflow = exports.linkCustomersToCustomerGroupWorkflowId = void 0;
4
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
+ const steps_1 = require("../steps");
6
+ exports.linkCustomersToCustomerGroupWorkflowId = "link-customers-to-customer-group";
7
+ exports.linkCustomersToCustomerGroupWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.linkCustomersToCustomerGroupWorkflowId, (input) => {
8
+ return (0, steps_1.linkCustomersToCustomerGroupStep)(input);
9
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./steps";
2
+ export * from "./workflows";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./steps"), exports);
18
+ __exportStar(require("./workflows"), exports);
@@ -0,0 +1,7 @@
1
+ import { CreateStoreDTO } from "@medusajs/types";
2
+ type CreateDefaultStoreStepInput = {
3
+ store: CreateStoreDTO;
4
+ };
5
+ export declare const createDefaultStoreStepId = "create-default-store";
6
+ export declare const createDefaultStoreStep: import("@medusajs/workflows-sdk").StepFunction<CreateDefaultStoreStepInput, any>;
7
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDefaultStoreStep = exports.createDefaultStoreStepId = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
6
+ const store_1 = require("../../store");
7
+ exports.createDefaultStoreStepId = "create-default-store";
8
+ exports.createDefaultStoreStep = (0, workflows_sdk_1.createStep)(exports.createDefaultStoreStepId, async (data, { container }) => {
9
+ const storeService = container.resolve(modules_sdk_1.ModuleRegistrationName.STORE);
10
+ let shouldDelete = false;
11
+ let [store] = await storeService.list({}, { take: 1 });
12
+ if (!store) {
13
+ store = await (0, store_1.createStoresWorkflow)(container).run({
14
+ input: {
15
+ stores: [
16
+ {
17
+ // TODO: Revisit for a more sophisticated approach
18
+ ...data.store,
19
+ supported_currency_codes: ["usd"],
20
+ default_currency_code: "usd",
21
+ },
22
+ ],
23
+ },
24
+ });
25
+ shouldDelete = true;
26
+ }
27
+ return new workflows_sdk_1.StepResponse(store, { storeId: store.id, shouldDelete });
28
+ }, async (data, { container }) => {
29
+ if (!data || !data.shouldDelete) {
30
+ return;
31
+ }
32
+ const service = container.resolve(modules_sdk_1.ModuleRegistrationName.STORE);
33
+ await service.delete(data.storeId);
34
+ });
@@ -0,0 +1 @@
1
+ export * from "./create-default-store";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./create-default-store"), exports);
@@ -0,0 +1,2 @@
1
+ export declare const createDefaultsWorkflowID = "create-defaults";
2
+ export declare const createDefaultsWorkflow: import("@medusajs/workflows-sdk").ReturnWorkflow<unknown, any, Record<string, Function>>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDefaultsWorkflow = exports.createDefaultsWorkflowID = void 0;
4
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
+ const sales_channel_1 = require("../../sales-channel");
6
+ const create_default_store_1 = require("../steps/create-default-store");
7
+ exports.createDefaultsWorkflowID = "create-defaults";
8
+ exports.createDefaultsWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.createDefaultsWorkflowID, (input) => {
9
+ const salesChannel = (0, sales_channel_1.createDefaultSalesChannelStep)({
10
+ data: {
11
+ name: "Default Sales Channel",
12
+ description: "Created by Medusa",
13
+ },
14
+ });
15
+ const store = (0, create_default_store_1.createDefaultStoreStep)({
16
+ store: {
17
+ default_sales_channel_id: salesChannel.id,
18
+ },
19
+ });
20
+ return store;
21
+ });
@@ -0,0 +1 @@
1
+ export * from "./create-defaults";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./create-defaults"), exports);
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addShippingMethodToCartStep = exports.addShippingMethodToCartStepId = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
4
5
  const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
- const dist_1 = require("../../../../../modules-sdk/dist");
6
6
  exports.addShippingMethodToCartStepId = "add-shipping-method-to-cart-step";
7
7
  exports.addShippingMethodToCartStep = (0, workflows_sdk_1.createStep)(exports.addShippingMethodToCartStepId, async (data, { container }) => {
8
- const cartService = container.resolve(dist_1.ModuleRegistrationName.CART);
8
+ const cartService = container.resolve(modules_sdk_1.ModuleRegistrationName.CART);
9
9
  const methods = await cartService.addShippingMethods(data.shipping_methods);
10
10
  return new workflows_sdk_1.StepResponse(methods, methods);
11
11
  }, async (methods, { container }) => {
12
- const cartService = container.resolve(dist_1.ModuleRegistrationName.CART);
12
+ const cartService = container.resolve(modules_sdk_1.ModuleRegistrationName.CART);
13
13
  if (!methods?.length) {
14
14
  return;
15
15
  }
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addToCartStep = exports.addToCartStepId = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
4
5
  const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
- const dist_1 = require("../../../../../modules-sdk/dist");
6
6
  exports.addToCartStepId = "add-to-cart-step";
7
7
  exports.addToCartStep = (0, workflows_sdk_1.createStep)(exports.addToCartStepId, async (data, { container }) => {
8
- const cartService = container.resolve(dist_1.ModuleRegistrationName.CART);
8
+ const cartService = container.resolve(modules_sdk_1.ModuleRegistrationName.CART);
9
9
  const items = await cartService.addLineItems(data.items);
10
10
  return new workflows_sdk_1.StepResponse(items, items);
11
11
  }, async (createdLineItems, { container }) => {
12
- const cartService = container.resolve(dist_1.ModuleRegistrationName.CART);
12
+ const cartService = container.resolve(modules_sdk_1.ModuleRegistrationName.CART);
13
13
  if (!createdLineItems?.length) {
14
14
  return;
15
15
  }
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.confirmInventoryStep = exports.confirmInventoryStepId = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
4
5
  const utils_1 = require("@medusajs/utils");
5
6
  const workflows_sdk_1 = require("@medusajs/workflows-sdk");
6
7
  const medusa_core_utils_1 = require("medusa-core-utils");
7
- const dist_1 = require("../../../../../modules-sdk/dist");
8
8
  exports.confirmInventoryStepId = "confirm-inventory-step";
9
9
  exports.confirmInventoryStep = (0, workflows_sdk_1.createStep)(exports.confirmInventoryStepId, async (data, { container }) => {
10
- const inventoryService = container.resolve(dist_1.ModuleRegistrationName.INVENTORY);
10
+ const inventoryService = container.resolve(modules_sdk_1.ModuleRegistrationName.INVENTORY);
11
11
  // TODO: Should be bulk
12
- const promises = data.items.map((item) => {
12
+ const promises = data.items.map(async (item) => {
13
13
  const itemQuantity = item.required_quantity * item.quantity;
14
- return inventoryService.confirmInventory(item.inventory_item_id, item.location_ids, itemQuantity);
14
+ return await inventoryService.confirmInventory(item.inventory_item_id, item.location_ids, itemQuantity);
15
15
  });
16
16
  const inventoryCoverage = await (0, utils_1.promiseAll)(promises);
17
17
  if (inventoryCoverage.some((hasCoverage) => !hasCoverage)) {
@@ -1,7 +1,8 @@
1
+ import { BigNumberInput } from "@medusajs/types";
1
2
  type StepInput = {
2
3
  region_id: string;
3
4
  currency_code: string;
4
- amount: number;
5
+ amount: BigNumberInput;
5
6
  metadata?: Record<string, unknown>;
6
7
  };
7
8
  export declare const createPaymentCollectionsStepId = "create-payment-collections";
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getItemTaxLinesStep = exports.getItemTaxLinesStepId = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
4
5
  const utils_1 = require("@medusajs/utils");
5
6
  const workflows_sdk_1 = require("@medusajs/workflows-sdk");
6
- const dist_1 = require("../../../../../modules-sdk/dist");
7
7
  function normalizeTaxModuleContext(cart, forceTaxCalculation) {
8
8
  const address = cart.shipping_address;
9
9
  const shouldCalculateTax = forceTaxCalculation || cart.region?.automatic_taxes;
@@ -16,7 +16,7 @@ function normalizeTaxModuleContext(cart, forceTaxCalculation) {
16
16
  if (!address?.country_code) {
17
17
  return null;
18
18
  }
19
- let customer = cart.customer
19
+ const customer = cart.customer
20
20
  ? {
21
21
  id: cart.customer.id,
22
22
  email: cart.customer.email,
@@ -61,7 +61,7 @@ function normalizeLineItemsForShipping(cart, shippingMethods) {
61
61
  exports.getItemTaxLinesStepId = "get-item-tax-lines";
62
62
  exports.getItemTaxLinesStep = (0, workflows_sdk_1.createStep)(exports.getItemTaxLinesStepId, async (data, { container }) => {
63
63
  const { cart, items, shipping_methods: shippingMethods, force_tax_calculation: forceTaxCalculation = false, } = data;
64
- const taxService = container.resolve(dist_1.ModuleRegistrationName.TAX);
64
+ const taxService = container.resolve(modules_sdk_1.ModuleRegistrationName.TAX);
65
65
  const taxContext = normalizeTaxModuleContext(cart, forceTaxCalculation);
66
66
  if (!taxContext) {
67
67
  return new workflows_sdk_1.StepResponse({
@@ -5,7 +5,15 @@ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
5
  const workflows_1 = require("../workflows");
6
6
  exports.updateTaxLinesStepId = "update-tax-lines-step";
7
7
  exports.updateTaxLinesStep = (0, workflows_sdk_1.createStep)(exports.updateTaxLinesStepId, async (input, { container }) => {
8
- // TODO: manually trigger rollback on workflow when step fails
9
- await (0, workflows_1.updateTaxLinesWorkflow)(container).run({ input });
10
- return new workflows_sdk_1.StepResponse(null);
8
+ const { transaction } = await (0, workflows_1.updateTaxLinesWorkflow)(container).run({
9
+ input,
10
+ });
11
+ return new workflows_sdk_1.StepResponse(null, { transaction });
12
+ }, async (flow, { container }) => {
13
+ if (!flow) {
14
+ return;
15
+ }
16
+ await (0, workflows_1.updateTaxLinesWorkflow)(container).cancel({
17
+ transaction: flow.transaction,
18
+ });
11
19
  });
@@ -1,3 +1,4 @@
1
+ import { BigNumberInput } from "@medusajs/types";
1
2
  interface ConfirmInventoryPreparationInput {
2
3
  product_variant_inventory_items: {
3
4
  variant_id: string;
@@ -6,7 +7,7 @@ interface ConfirmInventoryPreparationInput {
6
7
  }[];
7
8
  items: {
8
9
  variant_id?: string;
9
- quantity: number;
10
+ quantity: BigNumberInput;
10
11
  }[];
11
12
  variants: {
12
13
  id: string;