@medusajs/core-flows 0.0.3 → 0.0.4-next-20240108145510

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 (30) hide show
  1. package/dist/definition/cart/create-cart.d.ts +1 -3
  2. package/dist/definition/cart/create-cart.js +37 -4
  3. package/dist/definition/cart/create-cart.js.map +1 -1
  4. package/dist/definition/inventory/create-inventory-item.d.ts +4 -6
  5. package/dist/definition/price-list/create-price-lists.d.ts +3 -5
  6. package/dist/definition/price-list/remove-price-list-prices.d.ts +1 -3
  7. package/dist/definition/price-list/remove-price-lists.d.ts +3 -5
  8. package/dist/definition/price-list/remove-product-prices.d.ts +1 -3
  9. package/dist/definition/price-list/remove-variant-prices.d.ts +1 -3
  10. package/dist/definition/price-list/update-price-lists.d.ts +3 -5
  11. package/dist/definition/product/create-product-variants.d.ts +1 -3
  12. package/dist/definition/product/create-products.d.ts +1 -3
  13. package/dist/definition/product/update-product-variants.d.ts +1 -3
  14. package/dist/definition/product/update-products.d.ts +1 -3
  15. package/dist/handlers/cart/attach-cart-to-sales-channel.d.ts +18 -0
  16. package/dist/handlers/cart/attach-cart-to-sales-channel.js +29 -0
  17. package/dist/handlers/cart/attach-cart-to-sales-channel.js.map +1 -0
  18. package/dist/handlers/cart/create-cart.js +1 -2
  19. package/dist/handlers/cart/create-cart.js.map +1 -1
  20. package/dist/handlers/cart/detach-cart-from-sales-channel.d.ts +18 -0
  21. package/dist/handlers/cart/detach-cart-from-sales-channel.js +29 -0
  22. package/dist/handlers/cart/detach-cart-from-sales-channel.js.map +1 -0
  23. package/dist/handlers/cart/index.d.ts +2 -0
  24. package/dist/handlers/cart/index.js +2 -0
  25. package/dist/handlers/cart/index.js.map +1 -1
  26. package/dist/handlers/product/attach-sales-channel-to-products.js +23 -3
  27. package/dist/handlers/product/attach-sales-channel-to-products.js.map +1 -1
  28. package/dist/handlers/product/detach-sales-channel-from-products.js +20 -3
  29. package/dist/handlers/product/detach-sales-channel-from-products.js.map +1 -1
  30. package/package.json +6 -6
@@ -3,7 +3,5 @@ type CreateCartWorkflowOutput = Record<any, any>;
3
3
  export declare const createCart: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
4
4
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
5
5
  __definition: import("@medusajs/types").ModuleDefinition;
6
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
7
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? CartWorkflow.CreateCartWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? CreateCartWorkflowOutput : TResultOverride>>;
8
- };
6
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<CartWorkflow.CreateCartWorkflowInputDTO, CreateCartWorkflowOutput, TDataOverride, TResultOverride>;
9
7
  export {};
@@ -9,6 +9,7 @@ var CreateCartActions;
9
9
  (function (CreateCartActions) {
10
10
  CreateCartActions["setContext"] = "setContext";
11
11
  CreateCartActions["attachLineItems"] = "attachLineItems";
12
+ CreateCartActions["attachToSalesChannel"] = "attachToSalesChannel";
12
13
  CreateCartActions["findRegion"] = "findRegion";
13
14
  CreateCartActions["findSalesChannel"] = "findSalesChannel";
14
15
  CreateCartActions["createCart"] = "createCart";
@@ -47,10 +48,13 @@ const workflowSteps = {
47
48
  noCompensation: true,
48
49
  next: {
49
50
  action: CreateCartActions.createCart,
50
- next: {
51
- action: CreateCartActions.attachLineItems,
52
- noCompensation: true,
53
- },
51
+ next: [
52
+ {
53
+ action: CreateCartActions.attachLineItems,
54
+ noCompensation: true,
55
+ },
56
+ { action: CreateCartActions.attachToSalesChannel },
57
+ ],
54
58
  },
55
59
  },
56
60
  },
@@ -100,6 +104,10 @@ const handlers = new Map([
100
104
  {
101
105
  invoke: (0, workflows_sdk_1.pipe)({
102
106
  invoke: [
107
+ {
108
+ from: CreateCartActions.findSalesChannel,
109
+ alias: handlers_1.CartHandlers.createCart.aliases.SalesChannel,
110
+ },
103
111
  {
104
112
  from: CreateCartActions.findRegion,
105
113
  alias: handlers_1.CartHandlers.createCart.aliases.Region,
@@ -142,6 +150,31 @@ const handlers = new Map([
142
150
  }, handlers_1.CartHandlers.attachLineItemsToCart),
143
151
  },
144
152
  ],
153
+ [
154
+ CreateCartActions.attachToSalesChannel,
155
+ {
156
+ invoke: (0, workflows_sdk_1.pipe)({
157
+ invoke: [
158
+ {
159
+ from: CreateCartActions.createCart,
160
+ alias: handlers_1.CartHandlers.attachCartToSalesChannel.aliases.Cart,
161
+ },
162
+ {
163
+ from: CreateCartActions.findSalesChannel,
164
+ alias: handlers_1.CartHandlers.attachCartToSalesChannel.aliases.SalesChannel,
165
+ },
166
+ ],
167
+ }, handlers_1.CartHandlers.attachCartToSalesChannel),
168
+ compensate: (0, workflows_sdk_1.pipe)({
169
+ invoke: [
170
+ {
171
+ from: CreateCartActions.findSalesChannel,
172
+ alias: handlers_1.CartHandlers.detachCartFromSalesChannel.aliases.SalesChannel,
173
+ },
174
+ ],
175
+ }, handlers_1.CartHandlers.detachCartFromSalesChannel),
176
+ },
177
+ ],
145
178
  ]);
146
179
  orchestration_1.WorkflowManager.register(definitions_1.Workflows.CreateCart, workflowSteps, handlers);
147
180
  exports.createCart = (0, workflows_sdk_1.exportWorkflow)(definitions_1.Workflows.CreateCart, CreateCartActions.createCart);
@@ -1 +1 @@
1
- {"version":3,"file":"create-cart.js","sourceRoot":"","sources":["../../../src/definition/cart/create-cart.ts"],"names":[],"mappings":";;;AAAA,2DAGgC;AAGhC,mDAA6C;AAC7C,6CAOuB;AACvB,2DAA8D;AAE9D,IAAK,iBAUJ;AAVD,WAAK,iBAAiB;IACpB,8CAAyB,CAAA;IACzB,wDAAmC,CAAA;IACnC,8CAAyB,CAAA;IACzB,0DA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C5C,KAAK,EAAE,uBAAY,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ;qBAChD;oBACD;wBACE,IAAI,EAAE,iBAAiB,CAAC,qBAAqB;wBAC7C,KAAK,EAAE,uBAAY,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS;qBACjD;iBACF;aACF,EACD,uBAAY,CAAC,UAAU,CACxB;YACD,UAAU,EAAE,IAAA,oBAAI,EACd;gBACE,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,iBAAiB,CAAC,UAAU;wBAClC,KAAK,EAAE,uBAAY,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI;qBAC5C;iBACF;aACF,EACD,uBAAY,CAAC,UAAU,CACxB;SACF;KACF;IACD;QACE,iBAAiB,CAAC,eAAe;QACjC;YACE,MAAM,EAAE,IAAA,oBAAI,EACV;gBACE,MAAM,EAAE;oBACN,gBAAgB,CACd,uBAAY,CAAC,qBAAqB,CAAC,OAAO,CAAC,SAAS,CACrD,CAAC,MAAM;oBACR;wBACE,IAAI,EAAE,iBAAiB,CAAC,UAAU;wBAClC,KAAK,EAAE,uBAAY,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAAI;qBACvD;iBACF;aACF,EACD,uBAAY,CAAC,qBAAqB,CACnC;SACF;KACF;CACF,CAAC,CAAA;AAEF,+BAAe,CAAC,QAAQ,CAAC,uBAAS,CAAC,UAAU,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAA;AAI1D,QAAA,UAAU,GAAG,IAAA,8BAAc,EAGtC,uBAAS,CAAC,UAAU,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAA"}
1
+ {"version":3,"file":"create-cart.js","sourceRoot":"","sources":["../../../src/definition/cart/create-cart.ts"],"names":[],"mappings":";;;AAAA,2DAGgC;AAGhC,mDAA6C;AAC7C,6CAOuB;AACvB,2DAA8D;AAE9D,IAAK,iBAWJ;AAXD,WAAK,iBAAiB;IACpB,8CAAyB,CAAA;IACzB,wDAAmC,CAAA;IACnC,kE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ACE,IAAI,EAAE,iBAAiB,CAAC,gBAAgB;wBACxC,KAAK,EAAE,uBAAY,CAAC,wBAAwB,CAAC,OAAO,CAAC,YAAY;qBAClE;iBACF;aACF,EACD,uBAAY,CAAC,wBAAwB,CACtC;YACD,UAAU,EAAE,IAAA,oBAAI,EACd;gBACE,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,iBAAiB,CAAC,gBAAgB;wBACxC,KAAK,EACH,uBAAY,CAAC,0BAA0B,CAAC,OAAO,CAAC,YAAY;qBAC/D;iBACF;aACF,EACD,uBAAY,CAAC,0BAA0B,CACxC;SACF;KACF;CACF,CAAC,CAAA;AAEF,+BAAe,CAAC,QAAQ,CAAC,uBAAS,CAAC,UAAU,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAA;AAI1D,QAAA,UAAU,GAAG,IAAA,8BAAc,EAGtC,uBAAS,CAAC,UAAU,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAA"}
@@ -6,9 +6,7 @@ export declare enum CreateInventoryItemActions {
6
6
  export declare const createInventoryItems: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
7
7
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
8
8
  __definition: import("@medusajs/types").ModuleDefinition;
9
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
10
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.InventoryWorkflow.CreateInventoryItemsWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? {
11
- tag: string;
12
- inventoryItem: InventoryTypes.InventoryItemDTO;
13
- }[] : TResultOverride>>;
14
- };
9
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.InventoryWorkflow.CreateInventoryItemsWorkflowInputDTO, {
10
+ tag: string;
11
+ inventoryItem: InventoryTypes.InventoryItemDTO;
12
+ }[], TDataOverride, TResultOverride>;
@@ -6,8 +6,6 @@ export declare enum CreatePriceListActions {
6
6
  export declare const createPriceLists: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
7
7
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
8
8
  __definition: import("@medusajs/types").ModuleDefinition;
9
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
10
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.PriceListWorkflow.CreatePriceListWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? {
11
- priceList: PricingTypes.CreatePriceListDTO;
12
- }[] : TResultOverride>>;
13
- };
9
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.PriceListWorkflow.CreatePriceListWorkflowInputDTO, {
10
+ priceList: PricingTypes.CreatePriceListDTO;
11
+ }[], TDataOverride, TResultOverride>;
@@ -6,6 +6,4 @@ export declare enum RemovePriceListPricesActions {
6
6
  export declare const removePriceListPrices: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
7
7
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
8
8
  __definition: import("@medusajs/types").ModuleDefinition;
9
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
10
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.PriceListWorkflow.RemovePriceListPricesWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? string[] : TResultOverride>>;
11
- };
9
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.PriceListWorkflow.RemovePriceListPricesWorkflowInputDTO, string[], TDataOverride, TResultOverride>;
@@ -5,8 +5,6 @@ export declare enum RemovePriceListActions {
5
5
  export declare const removePriceLists: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
6
6
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
7
7
  __definition: import("@medusajs/types").ModuleDefinition;
8
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
9
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.PriceListWorkflow.RemovePriceListWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? {
10
- price_list_ids: string[];
11
- } : TResultOverride>>;
12
- };
8
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.PriceListWorkflow.RemovePriceListWorkflowInputDTO, {
9
+ price_list_ids: string[];
10
+ }, TDataOverride, TResultOverride>;
@@ -6,6 +6,4 @@ export declare enum RemoveProductPricesActions {
6
6
  export declare const removePriceListProductPrices: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
7
7
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
8
8
  __definition: import("@medusajs/types").ModuleDefinition;
9
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
10
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.PriceListWorkflow.RemovePriceListProductsWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? string[] : TResultOverride>>;
11
- };
9
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.PriceListWorkflow.RemovePriceListProductsWorkflowInputDTO, string[], TDataOverride, TResultOverride>;
@@ -6,6 +6,4 @@ export declare enum RemoveVariantPricesActions {
6
6
  export declare const removePriceListVariantPrices: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
7
7
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
8
8
  __definition: import("@medusajs/types").ModuleDefinition;
9
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
10
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.PriceListWorkflow.RemovePriceListVariantsWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? string[] : TResultOverride>>;
11
- };
9
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.PriceListWorkflow.RemovePriceListVariantsWorkflowInputDTO, string[], TDataOverride, TResultOverride>;
@@ -6,8 +6,6 @@ export declare enum UpdatePriceListActions {
6
6
  export declare const updatePriceLists: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
7
7
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
8
8
  __definition: import("@medusajs/types").ModuleDefinition;
9
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
10
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.PriceListWorkflow.UpdatePriceListWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? {
11
- priceList: WorkflowTypes.PriceListWorkflow.UpdatePriceListWorkflowDTO;
12
- }[] : TResultOverride>>;
13
- };
9
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.PriceListWorkflow.UpdatePriceListWorkflowInputDTO, {
10
+ priceList: WorkflowTypes.PriceListWorkflow.UpdatePriceListWorkflowDTO;
11
+ }[], TDataOverride, TResultOverride>;
@@ -10,6 +10,4 @@ export declare const workflowSteps: TransactionStepsDefinition;
10
10
  export declare const createProductVariants: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
11
11
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
12
12
  __definition: import("@medusajs/types").ModuleDefinition;
13
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
14
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.ProductWorkflow.CreateProductVariantsWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? ProductTypes.ProductVariantDTO[] : TResultOverride>>;
15
- };
13
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.ProductWorkflow.CreateProductVariantsWorkflowInputDTO, ProductTypes.ProductVariantDTO[], TDataOverride, TResultOverride>;
@@ -13,6 +13,4 @@ export declare const workflowSteps: TransactionStepsDefinition;
13
13
  export declare const createProducts: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
14
14
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
15
15
  __definition: import("@medusajs/types").ModuleDefinition;
16
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
17
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.ProductWorkflow.CreateProductsWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? ProductTypes.ProductDTO[] : TResultOverride>>;
18
- };
16
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.ProductWorkflow.CreateProductsWorkflowInputDTO, ProductTypes.ProductDTO[], TDataOverride, TResultOverride>;
@@ -10,6 +10,4 @@ export declare const workflowSteps: TransactionStepsDefinition;
10
10
  export declare const updateProductVariants: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
11
11
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
12
12
  __definition: import("@medusajs/types").ModuleDefinition;
13
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
14
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.ProductWorkflow.UpdateProductVariantsWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? ProductTypes.ProductVariantDTO[] : TResultOverride>>;
15
- };
13
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.ProductWorkflow.UpdateProductVariantsWorkflowInputDTO, ProductTypes.ProductVariantDTO[], TDataOverride, TResultOverride>;
@@ -14,6 +14,4 @@ export declare const updateProductsWorkflowSteps: TransactionStepsDefinition;
14
14
  export declare const updateProducts: <TDataOverride = undefined, TResultOverride = undefined>(container?: import("@medusajs/types").MedusaContainer | {
15
15
  __joinerConfig: import("@medusajs/types").ModuleJoinerConfig;
16
16
  __definition: import("@medusajs/types").ModuleDefinition;
17
- }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run"> & {
18
- run: (args?: import("@medusajs/workflows-sdk").FlowRunOptions<TDataOverride extends undefined ? WorkflowTypes.ProductWorkflow.UpdateProductsWorkflowInputDTO : TDataOverride> | undefined) => Promise<import("@medusajs/workflows-sdk").WorkflowResult<TResultOverride extends undefined ? ProductTypes.ProductDTO[] : TResultOverride>>;
19
- };
17
+ }[] | undefined) => Omit<import("@medusajs/orchestration").LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure"> & import("@medusajs/workflows-sdk").ExportedWorkflow<WorkflowTypes.ProductWorkflow.UpdateProductsWorkflowInputDTO, ProductTypes.ProductDTO[], TDataOverride, TResultOverride>;
@@ -0,0 +1,18 @@
1
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
2
+ type HandlerInputData = {
3
+ cart: {
4
+ id: string;
5
+ };
6
+ sales_channel: {
7
+ sales_channel_id: string;
8
+ };
9
+ };
10
+ declare enum Aliases {
11
+ Cart = "cart",
12
+ SalesChannel = "sales_channel"
13
+ }
14
+ export declare function attachCartToSalesChannel({ container, data, }: WorkflowArguments<HandlerInputData>): Promise<void>;
15
+ export declare namespace attachCartToSalesChannel {
16
+ var aliases: typeof Aliases;
17
+ }
18
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.attachCartToSalesChannel = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ var Aliases;
6
+ (function (Aliases) {
7
+ Aliases["Cart"] = "cart";
8
+ Aliases["SalesChannel"] = "sales_channel";
9
+ })(Aliases || (Aliases = {}));
10
+ async function attachCartToSalesChannel({ container, data, }) {
11
+ const featureFlagRouter = container.resolve("featureFlagRouter");
12
+ const remoteLink = container.resolve("remoteLink");
13
+ if (!featureFlagRouter.isFeatureEnabled(utils_1.MedusaV2Flag.key)) {
14
+ return;
15
+ }
16
+ const cart = data[Aliases.Cart];
17
+ const salesChannel = data[Aliases.SalesChannel];
18
+ await remoteLink.create({
19
+ cartService: {
20
+ cart_id: cart.id,
21
+ },
22
+ salesChannelService: {
23
+ sales_channel_id: salesChannel.sales_channel_id,
24
+ },
25
+ });
26
+ }
27
+ exports.attachCartToSalesChannel = attachCartToSalesChannel;
28
+ attachCartToSalesChannel.aliases = Aliases;
29
+ //# sourceMappingURL=attach-cart-to-sales-channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-cart-to-sales-channel.js","sourceRoot":"","sources":["../../../src/handlers/cart/attach-cart-to-sales-channel.ts"],"names":[],"mappings":";;;AAAA,2CAA8C;AAY9C,IAAK,OAGJ;AAHD,WAAK,OAAO;IACV,wBAAa,CAAA;IACb,yCAA8B,CAAA;AAChC,CAAC,EAHI,OAAO,KAAP,OAAO,QAGX;AAEM,KAAK,UAAU,wBAAwB,CAAC,EAC7C,SAAS,EACT,IAAI,GACgC;IACpC,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAChE,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IAElD,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,oBAAY,CAAC,GAAG,CAAC,EAAE;QACzD,OAAM;KACP;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IAE/C,MAAM,UAAU,CAAC,MAAM,CAAC;QACtB,WAAW,EAAE;YACX,OAAO,EAAE,IAAI,CAAC,EAAE;SACjB;QACD,mBAAmB,EAAE;YACnB,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;SAChD;KACF,CAAC,CAAA;AACJ,CAAC;AAtBD,4DAsBC;AAED,wBAAwB,CAAC,OAAO,GAAG,OAAO,CAAA"}
@@ -13,14 +13,13 @@ async function createCart({ container, context, data, }) {
13
13
  const { manager } = context;
14
14
  const cartService = container.resolve("cartService");
15
15
  const cartServiceTx = cartService.withTransaction(manager);
16
- const cart = await cartServiceTx.create({
16
+ return await cartServiceTx.create({
17
17
  ...data[Aliases.SalesChannel],
18
18
  ...data[Aliases.Addresses],
19
19
  ...data[Aliases.Customer],
20
20
  ...data[Aliases.Region],
21
21
  ...data[Aliases.Context],
22
22
  });
23
- return cart;
24
23
  }
25
24
  exports.createCart = createCart;
26
25
  createCart.aliases = Aliases;
@@ -1 +1 @@
1
- {"version":3,"file":"create-cart.js","sourceRoot":"","sources":["../../../src/handlers/cart/create-cart.ts"],"names":[],"mappings":";;;AAGA,IAAK,OAMJ;AAND,WAAK,OAAO;IACV,wCAA6B,CAAA;IAC7B,kCAAuB,CAAA;IACvB,gCAAqB,CAAA;IACrB,4BAAiB,CAAA;IACjB,8BAAmB,CAAA;AACrB,CAAC,EANI,OAAO,KAAP,OAAO,QAMX;AA8BM,KAAK,UAAU,UAAU,CAAC,EAC/B,SAAS,EACT,OAAO,EACP,IAAI,GACgC;IACpC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAE3B,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IACpD,MAAM,aAAa,GAAG,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAE1D,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC;QACtC,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAC7B,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QAC1B,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACvB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;KACzB,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;AACb,CAAC;AAnBD,gCAmBC;AAED,UAAU,CAAC,OAAO,GAAG,OAAO,CAAA"}
1
+ {"version":3,"file":"create-cart.js","sourceRoot":"","sources":["../../../src/handlers/cart/create-cart.ts"],"names":[],"mappings":";;;AAGA,IAAK,OAMJ;AAND,WAAK,OAAO;IACV,wCAA6B,CAAA;IAC7B,kCAAuB,CAAA;IACvB,gCAAqB,CAAA;IACrB,4BAAiB,CAAA;IACjB,8BAAmB,CAAA;AACrB,CAAC,EANI,OAAO,KAAP,OAAO,QAMX;AA8BM,KAAK,UAAU,UAAU,CAAC,EAC/B,SAAS,EACT,OAAO,EACP,IAAI,GACgC;IACpC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAE3B,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IACpD,MAAM,aAAa,GAAG,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAE1D,OAAO,MAAM,aAAa,CAAC,MAAM,CAAC;QAChC,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAC7B,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QAC1B,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACvB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;KACzB,CAAC,CAAA;AACJ,CAAC;AAjBD,gCAiBC;AAED,UAAU,CAAC,OAAO,GAAG,OAAO,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { WorkflowArguments } from "@medusajs/workflows-sdk";
2
+ type HandlerInputData = {
3
+ cart: {
4
+ id: string;
5
+ };
6
+ sales_channel: {
7
+ sales_channel_id: string;
8
+ };
9
+ };
10
+ declare enum Aliases {
11
+ Cart = "cart",
12
+ SalesChannel = "sales_channel"
13
+ }
14
+ export declare function detachCartFromSalesChannel({ container, data, }: WorkflowArguments<HandlerInputData>): Promise<void>;
15
+ export declare namespace detachCartFromSalesChannel {
16
+ var aliases: typeof Aliases;
17
+ }
18
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detachCartFromSalesChannel = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ var Aliases;
6
+ (function (Aliases) {
7
+ Aliases["Cart"] = "cart";
8
+ Aliases["SalesChannel"] = "sales_channel";
9
+ })(Aliases || (Aliases = {}));
10
+ async function detachCartFromSalesChannel({ container, data, }) {
11
+ const featureFlagRouter = container.resolve("featureFlagRouter");
12
+ const remoteLink = container.resolve("remoteLink");
13
+ if (!featureFlagRouter.isFeatureEnabled(utils_1.MedusaV2Flag.key)) {
14
+ return;
15
+ }
16
+ const cart = data[Aliases.Cart];
17
+ const salesChannel = data[Aliases.SalesChannel];
18
+ await remoteLink.dismiss({
19
+ cartService: {
20
+ cart_id: cart.id,
21
+ },
22
+ salesChannelService: {
23
+ sales_channel_id: salesChannel.sales_channel_id,
24
+ },
25
+ });
26
+ }
27
+ exports.detachCartFromSalesChannel = detachCartFromSalesChannel;
28
+ detachCartFromSalesChannel.aliases = Aliases;
29
+ //# sourceMappingURL=detach-cart-from-sales-channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detach-cart-from-sales-channel.js","sourceRoot":"","sources":["../../../src/handlers/cart/detach-cart-from-sales-channel.ts"],"names":[],"mappings":";;;AAAA,2CAA8C;AAY9C,IAAK,OAGJ;AAHD,WAAK,OAAO;IACV,wBAAa,CAAA;IACb,yCAA8B,CAAA;AAChC,CAAC,EAHI,OAAO,KAAP,OAAO,QAGX;AAEM,KAAK,UAAU,0BAA0B,CAAC,EAC/C,SAAS,EACT,IAAI,GACgC;IACpC,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAChE,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IAElD,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,oBAAY,CAAC,GAAG,CAAC,EAAE;QACzD,OAAM;KACP;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IAE/C,MAAM,UAAU,CAAC,OAAO,CAAC;QACvB,WAAW,EAAE;YACX,OAAO,EAAE,IAAI,CAAC,EAAE;SACjB;QACD,mBAAmB,EAAE;YACnB,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;SAChD;KACF,CAAC,CAAA;AACJ,CAAC;AAtBD,gEAsBC;AAED,0BAA0B,CAAC,OAAO,GAAG,OAAO,CAAA"}
@@ -2,3 +2,5 @@ export * from "./attach-line-items-to-cart";
2
2
  export * from "./create-cart";
3
3
  export * from "./remove-cart";
4
4
  export * from "./retrieve-cart";
5
+ export * from "./attach-cart-to-sales-channel";
6
+ export * from "./detach-cart-from-sales-channel";
@@ -18,4 +18,6 @@ __exportStar(require("./attach-line-items-to-cart"), exports);
18
18
  __exportStar(require("./create-cart"), exports);
19
19
  __exportStar(require("./remove-cart"), exports);
20
20
  __exportStar(require("./retrieve-cart"), exports);
21
+ __exportStar(require("./attach-cart-to-sales-channel"), exports);
22
+ __exportStar(require("./detach-cart-from-sales-channel"), exports);
21
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handlers/cart/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA2C;AAC3C,gDAA6B;AAC7B,gDAA6B;AAC7B,kDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handlers/cart/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA2C;AAC3C,gDAA6B;AAC7B,gDAA6B;AAC7B,kDAA+B;AAC/B,iEAA8C;AAC9C,mEAAgD"}
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.attachSalesChannelToProducts = void 0;
4
4
  const utils_1 = require("@medusajs/utils");
5
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
6
  async function attachSalesChannelToProducts({ container, context, data, }) {
6
7
  const { manager } = context;
8
+ const featureFlagRouter = container.resolve("featureFlagRouter");
7
9
  const productsHandleSalesChannelsMap = data.productsHandleSalesChannelsMap;
8
10
  const products = data.products;
9
11
  const salesChannelService = container.resolve("salesChannelService");
@@ -19,9 +21,27 @@ async function attachSalesChannelToProducts({ container, context, data, }) {
19
21
  });
20
22
  }
21
23
  });
22
- await (0, utils_1.promiseAll)(Array.from(salesChannelIdProductIdsMap.entries()).map(async ([salesChannelId, productIds]) => {
23
- return await salesChannelServiceTx.addProducts(salesChannelId, productIds);
24
- }));
24
+ if (featureFlagRouter.isFeatureEnabled(utils_1.MedusaV2Flag.key)) {
25
+ const remoteLink = container.resolve("remoteLink");
26
+ const links = [];
27
+ for (const [salesChannelId, productIds,] of salesChannelIdProductIdsMap.entries()) {
28
+ productIds.forEach((id) => links.push({
29
+ [modules_sdk_1.Modules.PRODUCT]: {
30
+ product_id: id,
31
+ },
32
+ salesChannelService: {
33
+ sales_channel_id: salesChannelId,
34
+ },
35
+ }));
36
+ await remoteLink.create(links);
37
+ }
38
+ return;
39
+ }
40
+ else {
41
+ await (0, utils_1.promiseAll)(Array.from(salesChannelIdProductIdsMap.entries()).map(async ([salesChannelId, productIds]) => {
42
+ return await salesChannelServiceTx.addProducts(salesChannelId, productIds);
43
+ }));
44
+ }
25
45
  }
26
46
  exports.attachSalesChannelToProducts = attachSalesChannelToProducts;
27
47
  attachSalesChannelToProducts.aliases = {
@@ -1 +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,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CAAA"}
1
+ {"version":3,"file":"attach-sales-channel-to-products.js","sourceRoot":"","sources":["../../../src/handlers/product/attach-sales-channel-to-products.ts"],"names":[],"mappings":";;;AACA,2CAA0D;AAC1D,uDAA+C;AAYxC,KAAK,UAAU,4BAA4B,CAAC,EACjD,SAAS,EACT,OAAO,EACP,IAAI,GAC4B;IAChC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAC3B,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAEhE,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,IAAI,iBAAiB,CAAC,gBAAgB,CAAC,oBAAY,CAAC,GAAG,CAAC,EAAE;QACxD,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;QAClD,MAAM,KAAK,GAAU,EAAE,CAAA;QAEvB,KAAK,MAAM,CACT,cAAc,EACd,UAAU,EACX,IAAI,2BAA2B,CAAC,OAAO,EAAE,EAAE;YAC1C,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CACxB,KAAK,CAAC,IAAI,CAAC;gBACT,CAAC,qBAAO,CAAC,OAAO,CAAC,EAAE;oBACjB,UAAU,EAAE,EAAE;iBACf;gBACD,mBAAmB,EAAE;oBACnB,gBAAgB,EAAE,cAAc;iBACjC;aACF,CAAC,CACH,CAAA;YAED,MAAM,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;SAC/B;QAED,OAAM;KACP;SAAM;QACL,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;YACrC,OAAO,MAAM,qBAAqB,CAAC,WAAW,CAC5C,cAAc,EACd,UAAU,CACX,CAAA;QACH,CAAC,CACF,CACF,CAAA;KACF;AACH,CAAC;AA7DD,oEA6DC;AAED,4BAA4B,CAAC,OAAO,GAAG;IACrC,QAAQ,EAAE,UAAU;CACrB,CAAA"}
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.detachSalesChannelFromProducts = void 0;
4
4
  const utils_1 = require("@medusajs/utils");
5
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
6
  async function detachSalesChannelFromProducts({ container, context, data, }) {
6
7
  const { manager } = context;
8
+ const featureFlagRouter = container.resolve("featureFlagRouter");
7
9
  const productsHandleSalesChannelsMap = data.productsHandleSalesChannelsMap;
8
10
  const products = data.products;
9
11
  const salesChannelService = container.resolve("salesChannelService");
@@ -19,9 +21,24 @@ async function detachSalesChannelFromProducts({ container, context, data, }) {
19
21
  });
20
22
  }
21
23
  });
22
- await (0, utils_1.promiseAll)(Array.from(salesChannelIdProductIdsMap.entries()).map(async ([salesChannelId, productIds]) => {
23
- return await salesChannelServiceTx.removeProducts(salesChannelId, productIds);
24
- }));
24
+ if (featureFlagRouter.isFeatureEnabled(utils_1.MedusaV2Flag.key)) {
25
+ const remoteLink = container.resolve("remoteLink");
26
+ for (const [salesChannelId, productIds,] of salesChannelIdProductIdsMap.entries()) {
27
+ await (0, utils_1.promiseAll)(productIds.map((id) => remoteLink.dismiss({
28
+ [modules_sdk_1.Modules.PRODUCT]: {
29
+ product_id: id,
30
+ },
31
+ salesChannelService: {
32
+ sales_channel_id: salesChannelId,
33
+ },
34
+ })));
35
+ }
36
+ }
37
+ else {
38
+ await (0, utils_1.promiseAll)(Array.from(salesChannelIdProductIdsMap.entries()).map(async ([salesChannelId, productIds]) => {
39
+ return await salesChannelServiceTx.removeProducts(salesChannelId, productIds);
40
+ }));
41
+ }
25
42
  }
26
43
  exports.detachSalesChannelFromProducts = detachSalesChannelFromProducts;
27
44
  detachSalesChannelFromProducts.aliases = {
@@ -1 +1 @@
1
- {"version":3,"file":"detach-sales-channel-from-products.js","sourceRoot":"","sources":["../../../src/handlers/product/detach-sales-channel-from-products.ts"],"names":[],"mappings":";;;AACA,2CAA4C;AAUrC,KAAK,UAAU,8BAA8B,CAAC,EACnD,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,cAAc,CAC/C,cAAc,EACd,UAAU,CACX,CAAA;IACH,CAAC,CACF,CACF,CAAA;AACH,CAAC;AAlCD,wEAkCC;AAED,8BAA8B,CAAC,OAAO,GAAG;IACvC,QAAQ,EAAE,UAAU;CACrB,CAAA"}
1
+ {"version":3,"file":"detach-sales-channel-from-products.js","sourceRoot":"","sources":["../../../src/handlers/product/detach-sales-channel-from-products.ts"],"names":[],"mappings":";;;AACA,2CAA0D;AAC1D,uDAA+C;AAUxC,KAAK,UAAU,8BAA8B,CAAC,EACnD,SAAS,EACT,OAAO,EACP,IAAI,GAC4B;IAChC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAC3B,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAEhE,MAAM,8BAA8B,GAAG,IAAI,CAAC,8BAA8B,CAAA;IAC1E,MAAM,QAAQ,GAAG,IAAI,CAAC,QA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AAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CACnD,KAAK,EAAE,CAAC,cAAc,EAAE,UAAU,CAAC,EAAE,EAAE;YACrC,OAAO,MAAM,qBAAqB,CAAC,cAAc,CAC/C,cAAc,EACd,UAAU,CACX,CAAA;QACH,CAAC,CACF,CACF,CAAA;KACF;AACH,CAAC;AA1DD,wEA0DC;AAED,8BAA8B,CAAC,OAAO,GAAG;IACvC,QAAQ,EAAE,UAAU;CACrB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/core-flows",
3
- "version": "0.0.3",
3
+ "version": "0.0.4-next-20240108145510",
4
4
  "description": "Set of workflow definitions for Medusa",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "author": "Medusa",
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
- "@medusajs/types": "^1.11.9",
24
+ "@medusajs/types": "1.11.10-next-20240108145510",
25
25
  "cross-env": "^5.2.1",
26
26
  "jest": "^29.6.3",
27
27
  "rimraf": "^5.0.1",
@@ -29,10 +29,10 @@
29
29
  "typescript": "^5.1.6"
30
30
  },
31
31
  "dependencies": {
32
- "@medusajs/modules-sdk": "^1.12.5",
33
- "@medusajs/orchestration": "^0.5.1",
34
- "@medusajs/utils": "^1.11.2",
35
- "@medusajs/workflows-sdk": "^0.1.0",
32
+ "@medusajs/modules-sdk": "1.12.6-next-20240108145510",
33
+ "@medusajs/orchestration": "0.5.2-next-20240108145510",
34
+ "@medusajs/utils": "1.11.3-next-20240108145510",
35
+ "@medusajs/workflows-sdk": "0.1.1-next-20240108145510",
36
36
  "awilix": "^8.0.1",
37
37
  "ulid": "^2.3.0"
38
38
  },