fix(core-flows): add missing remove remote link (#12326)

* fix(core-flows): add missing remove remote link

* temp disable test
This commit is contained in:
Carlos R. L. Rodrigues
2025-04-30 17:43:37 +02:00
committed by GitHub
parent 4a9ac0d4be
commit 90c61d1898
13 changed files with 202 additions and 108 deletions
@@ -1,4 +1,6 @@
import { Modules } from "@medusajs/framework/utils"
import { createWorkflow, WorkflowData } from "@medusajs/framework/workflows-sdk"
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
import { deletePriceListsStep } from "../steps"
/**
@@ -15,10 +17,10 @@ export const deletePriceListsWorkflowId = "delete-price-lists"
/**
* This workflow deletes one or more price lists. It's used by the
* [Delete Price List Admin API Route](https://docs.medusajs.com/api/admin#price-lists_deletepricelistsid).
*
*
* You can use this workflow within your customizations or your own custom workflows, allowing you to
* delete price lists in your custom flows.
*
*
* @example
* const { result } = await deletePriceListsWorkflow(container)
* .run({
@@ -26,14 +28,22 @@ export const deletePriceListsWorkflowId = "delete-price-lists"
* ids: ["plist_123"]
* }
* })
*
*
* @summary
*
*
* Delete one or more price lists.
*/
export const deletePriceListsWorkflow = createWorkflow(
deletePriceListsWorkflowId,
(input: WorkflowData<DeletePriceListsWorkflowInput>): WorkflowData<void> => {
return deletePriceListsStep(input.ids)
const deletedPriceLists = deletePriceListsStep(input.ids)
removeRemoteLinkStep({
[Modules.PRICING]: {
price_list_id: input.ids,
},
})
return deletedPriceLists
}
)
@@ -1,4 +1,6 @@
import { Modules } from "@medusajs/framework/utils"
import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk"
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
import { deletePricePreferencesStep } from "../steps"
/**
@@ -10,23 +12,31 @@ export const deletePricePreferencesWorkflowId = "delete-price-preferences"
/**
* This workflow deletes one or more price preferences. It's used by the
* [Delete Price Preferences Admin API Route](https://docs.medusajs.com/api/admin#price-preferences_deletepricepreferencesid).
*
*
* You can use this workflow within your customizations or your own custom workflows, allowing you to
* delete price preferences in your custom flows.
*
*
* @example
* const { result } = await deletePricePreferencesWorkflow(container)
* .run({
* input: ["pp_123"]
* })
*
*
* @summary
*
*
* Delete one or more price preferences.
*/
export const deletePricePreferencesWorkflow = createWorkflow(
deletePricePreferencesWorkflowId,
(input: WorkflowData<DeletePricePreferencesWorkflowInput>) => {
return deletePricePreferencesStep(input)
const deletedPricePreferences = deletePricePreferencesStep(input)
removeRemoteLinkStep({
[Modules.PRICING]: {
price_preference_id: input,
},
})
return deletedPricePreferences
}
)
@@ -1,12 +1,16 @@
import { ProductCategoryWorkflowEvents } from "@medusajs/framework/utils"
import {
Modules,
ProductCategoryWorkflowEvents,
} from "@medusajs/framework/utils"
import {
WorkflowData,
WorkflowResponse,
createHook,
createWorkflow,
parallelize,
transform,
createHook
} from "@medusajs/framework/workflows-sdk"
import { emitEventStep } from "../../common"
import { emitEventStep, removeRemoteLinkStep } from "../../common"
import { deleteProductCategoriesStep } from "../steps"
/**
@@ -18,18 +22,18 @@ export const deleteProductCategoriesWorkflowId = "delete-product-categories"
/**
* This workflow deletes one or more product categories. It's used by the
* [Delete Product Category Admin API Route](https://docs.medusajs.com/api/admin#product-categories_deleteproductcategoriesid).
*
*
* You can use this workflow within your customizations or your own custom workflows, allowing you to
* delete product categories within your custom flows.
*
*
* @example
* const { result } = await deleteProductCategoriesWorkflow(container)
* .run({
* input: ["pcat_123"]
* })
*
*
* @summary
*
*
* Delete product categories.
*/
export const deleteProductCategoriesWorkflow = createWorkflow(
@@ -43,17 +47,24 @@ export const deleteProductCategoriesWorkflow = createWorkflow(
})
})
emitEventStep({
eventName: ProductCategoryWorkflowEvents.DELETED,
data: productCategoryIdEvents,
})
parallelize(
removeRemoteLinkStep({
[Modules.PRODUCT]: {
product_category_id: input,
},
}),
emitEventStep({
eventName: ProductCategoryWorkflowEvents.DELETED,
data: productCategoryIdEvents,
})
)
const categoriesDeleted = createHook("categoriesDeleted", {
ids: input,
})
return new WorkflowResponse(deleted, {
hooks: [categoriesDeleted]
hooks: [categoriesDeleted],
})
}
)
@@ -1,18 +1,22 @@
import { ProductCollectionWorkflowEvents } from "@medusajs/framework/utils"
import {
Modules,
ProductCollectionWorkflowEvents,
} from "@medusajs/framework/utils"
import {
WorkflowData,
WorkflowResponse,
createHook,
createWorkflow,
parallelize,
transform,
} from "@medusajs/framework/workflows-sdk"
import { emitEventStep } from "../../common"
import { emitEventStep, removeRemoteLinkStep } from "../../common"
import { deleteCollectionsStep } from "../steps"
/**
* The data to delete one or more product collections.
*/
export type DeleteCollectionsWorkflowInput = {
export type DeleteCollectionsWorkflowInput = {
/**
* The IDs of the collections to delete.
*/
@@ -21,14 +25,14 @@ export type DeleteCollectionsWorkflowInput = {
export const deleteCollectionsWorkflowId = "delete-collections"
/**
* This workflow deletes one or more product collections. It's used by the
* This workflow deletes one or more product collections. It's used by the
* [Delete Product Collection Admin API Route](https://docs.medusajs.com/api/admin#collections_deletecollectionsid).
*
* This workflow has a hook that allows you to perform custom actions after the product collections are deleted. For example,
*
* This workflow has a hook that allows you to perform custom actions after the product collections are deleted. For example,
* you can delete custom records linked to the product colleciton.
*
*
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-collection deletion.
*
*
* @example
* const { result } = await deleteCollectionsWorkflow(container)
* .run({
@@ -36,11 +40,11 @@ export const deleteCollectionsWorkflowId = "delete-collections"
* ids: ["pcol_123"],
* }
* })
*
*
* @summary
*
*
* Delete one or more product collection.
*
*
* @property hooks.collectionsDeleted - This hook is executed after the collections are deleted. You can consume this hook to perform custom actions on the deleted collections.
*/
export const deleteCollectionsWorkflow = createWorkflow(
@@ -54,10 +58,15 @@ export const deleteCollectionsWorkflow = createWorkflow(
})
})
emitEventStep({
eventName: ProductCollectionWorkflowEvents.DELETED,
data: collectionIdEvents,
})
parallelize(
removeRemoteLinkStep({
[Modules.PRODUCT]: { product_collection_id: input.ids },
}),
emitEventStep({
eventName: ProductCollectionWorkflowEvents.DELETED,
data: collectionIdEvents,
})
)
const collectionsDeleted = createHook("collectionsDeleted", {
ids: input.ids,
@@ -1,18 +1,20 @@
import { ProductOptionWorkflowEvents } from "@medusajs/framework/utils"
import { Modules, ProductOptionWorkflowEvents } from "@medusajs/framework/utils"
import {
WorkflowData,
WorkflowResponse,
createHook,
createWorkflow,
parallelize,
transform,
} from "@medusajs/framework/workflows-sdk"
import { emitEventStep } from "../../common/steps/emit-event"
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
import { deleteProductOptionsStep } from "../steps"
/**
* The data to delete one or more product options.
*/
export type DeleteProductOptionsWorkflowInput = {
export type DeleteProductOptionsWorkflowInput = {
/**
* The IDs of the options to delete.
*/
@@ -21,14 +23,14 @@ export type DeleteProductOptionsWorkflowInput = {
export const deleteProductOptionsWorkflowId = "delete-product-options"
/**
* This workflow deletes one or more product options. It's used by the
* This workflow deletes one or more product options. It's used by the
* [Delete Product Option Admin API Route](https://docs.medusajs.com/api/admin#products_deleteproductsidoptionsoption_id).
*
* This workflow has a hook that allows you to perform custom actions after the product options are deleted. For example,
*
* This workflow has a hook that allows you to perform custom actions after the product options are deleted. For example,
* you can delete custom records linked to the product colleciton.
*
*
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-option deletion.
*
*
* @example
* const { result } = await deleteProductOptionsWorkflow(container)
* .run({
@@ -36,11 +38,11 @@ export const deleteProductOptionsWorkflowId = "delete-product-options"
* ids: ["poption_123"],
* }
* })
*
*
* @summary
*
*
* Delete one or more product option.
*
*
* @property hooks.productOptionsDeleted - This hook is executed after the options are deleted. You can consume this hook to perform custom actions on the deleted options.
*/
export const deleteProductOptionsWorkflow = createWorkflow(
@@ -57,10 +59,15 @@ export const deleteProductOptionsWorkflow = createWorkflow(
})
})
emitEventStep({
eventName: ProductOptionWorkflowEvents.DELETED,
data: optionIdEvents,
})
parallelize(
removeRemoteLinkStep({
[Modules.PRODUCT]: { product_option_id: input.ids },
}),
emitEventStep({
eventName: ProductOptionWorkflowEvents.DELETED,
data: optionIdEvents,
})
)
return new WorkflowResponse(deletedProductOptions, {
hooks: [productOptionsDeleted],
@@ -1,18 +1,20 @@
import { ProductTypeWorkflowEvents } from "@medusajs/framework/utils"
import { Modules, ProductTypeWorkflowEvents } from "@medusajs/framework/utils"
import {
WorkflowData,
WorkflowResponse,
createHook,
createWorkflow,
parallelize,
transform,
} from "@medusajs/framework/workflows-sdk"
import { emitEventStep } from "../../common/steps/emit-event"
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
import { deleteProductTypesStep } from "../steps"
/**
* The data to delete one or more product types.
*/
export type DeleteProductTypesWorkflowInput = {
export type DeleteProductTypesWorkflowInput = {
/**
* The IDs of the types to delete.
*/
@@ -21,14 +23,14 @@ export type DeleteProductTypesWorkflowInput = {
export const deleteProductTypesWorkflowId = "delete-product-types"
/**
* This workflow deletes one or more product types. It's used by the
* This workflow deletes one or more product types. It's used by the
* [Delete Product Types Admin API Route](https://docs.medusajs.com/api/admin#product-types_deleteproducttypesid).
*
* This workflow has a hook that allows you to perform custom actions after the product types are deleted. For example,
*
* This workflow has a hook that allows you to perform custom actions after the product types are deleted. For example,
* you can delete custom records linked to the product types.
*
*
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-type deletion.
*
*
* @example
* const { result } = await deleteProductTypesWorkflow(container)
* .run({
@@ -36,11 +38,11 @@ export const deleteProductTypesWorkflowId = "delete-product-types"
* ids: ["ptyp_123"],
* }
* })
*
*
* @summary
*
*
* Delete one or more product types.
*
*
* @property hooks.productTypesDeleted - This hook is executed after the types are deleted. You can consume this hook to perform custom actions on the deleted types.
*/
export const deleteProductTypesWorkflow = createWorkflow(
@@ -57,10 +59,15 @@ export const deleteProductTypesWorkflow = createWorkflow(
})
})
emitEventStep({
eventName: ProductTypeWorkflowEvents.DELETED,
data: typeIdEvents,
})
parallelize(
removeRemoteLinkStep({
[Modules.PRODUCT]: { product_type_id: input.ids },
}),
emitEventStep({
eventName: ProductTypeWorkflowEvents.DELETED,
data: typeIdEvents,
})
)
return new WorkflowResponse(deletedProductTypes, {
hooks: [productTypesDeleted],
@@ -12,14 +12,14 @@ import {
removeRemoteLinkStep,
useQueryGraphStep,
} from "../../common"
import { deleteInventoryItemWorkflow } from "../../inventory"
import { deleteProductsStep } from "../steps/delete-products"
import { getProductsStep } from "../steps/get-products"
import { deleteInventoryItemWorkflow } from "../../inventory"
/**
* The data to delete one or more products.
*/
export type DeleteProductsWorkflowInput = {
export type DeleteProductsWorkflowInput = {
/**
* The IDs of the products to delete.
*/
@@ -28,14 +28,14 @@ export type DeleteProductsWorkflowInput = {
export const deleteProductsWorkflowId = "delete-products"
/**
* This workflow deletes one or more products. It's used by the
* This workflow deletes one or more products. It's used by the
* [Delete Products Admin API Route](https://docs.medusajs.com/api/admin#products_deleteproductsid).
*
* This workflow has a hook that allows you to perform custom actions after the products are deleted. For example,
*
* This workflow has a hook that allows you to perform custom actions after the products are deleted. For example,
* you can delete custom records linked to the products.
*
*
* You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product deletion.
*
*
* @example
* const { result } = await deleteProductsWorkflow(container)
* .run({
@@ -43,11 +43,11 @@ export const deleteProductsWorkflowId = "delete-products"
* ids: ["product_123"],
* }
* })
*
*
* @summary
*
*
* Delete one or more products.
*
*
* @property hooks.productsDeleted - This hook is executed after the products are deleted. You can consume this hook to perform custom actions on the deleted products.
*/
export const deleteProductsWorkflow = createWorkflow(
@@ -1,22 +1,23 @@
import { RegionWorkflowEvents } from "@medusajs/framework/utils"
import { Modules, RegionWorkflowEvents } from "@medusajs/framework/utils"
import {
WorkflowData,
createWorkflow,
transform,
} from "@medusajs/framework/workflows-sdk"
import { emitEventStep } from "../../common/steps/emit-event"
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
import { deleteRegionsStep } from "../steps"
export type DeleteRegionsWorkflowInput = { ids: string[] }
export const deleteRegionsWorkflowId = "delete-regions"
/**
* This workflow deletes one or more regions. It's used by the
* This workflow deletes one or more regions. It's used by the
* [Delete Region Admin API Route](https://docs.medusajs.com/api/admin#regions_deleteregionsid).
*
*
* You can use this workflow within your own customizations or custom workflows, allowing you
* to delete regions in your custom flows.
*
*
* @example
* const { result } = await deleteRegionsWorkflow(container)
* .run({
@@ -24,9 +25,9 @@ export const deleteRegionsWorkflowId = "delete-regions"
* ids: ["reg_123"]
* }
* })
*
*
* @summary
*
*
* Delete one or more regions.
*/
export const deleteRegionsWorkflow = createWorkflow(
@@ -40,6 +41,12 @@ export const deleteRegionsWorkflow = createWorkflow(
})
})
removeRemoteLinkStep({
[Modules.REGION]: {
region_id: input.ids,
},
})
emitEventStep({
eventName: RegionWorkflowEvents.DELETED,
data: regionIdEvents,
@@ -1,10 +1,12 @@
import { Modules } from "@medusajs/framework/utils"
import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk"
import { removeRemoteLinkStep } from "../../common"
import { deleteReturnReasonStep } from "../steps"
/**
* The IDs of return reasons to delete.
*/
export type DeleteReturnReasonsWorkflowInput = {
export type DeleteReturnReasonsWorkflowInput = {
/**
* The IDs of return reasons to delete.
*/
@@ -15,10 +17,10 @@ export const deleteReturnReasonsWorkflowId = "delete-return-reasons"
/**
* This workflow deletes one or more return reasons. It's used by the
* [Delete Return Reasons Admin API Route](https://docs.medusajs.com/api/admin#return-reasons_deletereturnreasonsid).
*
*
* You can use this workflow within your customizations or your own custom workflows, allowing you to
* delete return reasons within your custom flows.
*
*
* @example
* const { result } = await deleteReturnReasonsWorkflow(container)
* .run({
@@ -26,9 +28,9 @@ export const deleteReturnReasonsWorkflowId = "delete-return-reasons"
* ids: ["rr_123"]
* }
* })
*
*
* @summary
*
*
* Delete return reasons.
*/
export const deleteReturnReasonsWorkflow = createWorkflow(
@@ -36,6 +38,14 @@ export const deleteReturnReasonsWorkflow = createWorkflow(
(
input: WorkflowData<DeleteReturnReasonsWorkflowInput>
): WorkflowData<void> => {
return deleteReturnReasonStep(input.ids)
const deletedReturnReasons = deleteReturnReasonStep(input.ids)
removeRemoteLinkStep({
[Modules.ORDER]: {
return_reason_id: input.ids,
},
})
return deletedReturnReasons
}
)
@@ -1,10 +1,12 @@
import { Modules } from "@medusajs/framework/utils"
import { WorkflowData, createWorkflow } from "@medusajs/framework/workflows-sdk"
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
import { deleteStoresStep } from "../steps"
/**
* The data to delete stores.
*/
export type DeleteStoresWorkflowInput = {
export type DeleteStoresWorkflowInput = {
/**
* The IDs of the stores to delete.
*/
@@ -14,18 +16,18 @@ export type DeleteStoresWorkflowInput = {
export const deleteStoresWorkflowId = "delete-stores"
/**
* This workflow deletes one or more stores.
*
*
* :::note
*
*
* By default, Medusa uses a single store. This is useful
* if you're building a multi-tenant application or a marketplace where each tenant has its own store.
* If you delete the only store in your application, the Medusa application will re-create it on application start-up.
*
*
* :::
*
*
* You can use this workflow within your customizations or your own custom workflows, allowing you to
* delete stores within your custom flows.
*
*
* @example
* const { result } = await deleteStoresWorkflow(container)
* .run({
@@ -33,14 +35,22 @@ export const deleteStoresWorkflowId = "delete-stores"
* ids: ["store_123"]
* }
* })
*
*
* @summary
*
*
* Delete one or more stores.
*/
export const deleteStoresWorkflow = createWorkflow(
deleteStoresWorkflowId,
(input: WorkflowData<DeleteStoresWorkflowInput>): WorkflowData<void> => {
return deleteStoresStep(input.ids)
const deletedStores = deleteStoresStep(input.ids)
removeRemoteLinkStep({
[Modules.STORE]: {
store_id: input.ids,
},
})
return deletedStores
}
)
@@ -1,24 +1,25 @@
import { UserWorkflow } from "@medusajs/framework/types"
import { UserWorkflowEvents } from "@medusajs/framework/utils"
import { Modules, UserWorkflowEvents } from "@medusajs/framework/utils"
import {
WorkflowData,
createWorkflow,
parallelize,
transform,
} from "@medusajs/framework/workflows-sdk"
import { emitEventStep } from "../../common"
import { emitEventStep, removeRemoteLinkStep } from "../../common"
import { deleteUsersStep } from "../steps"
export const deleteUsersWorkflowId = "delete-user"
/**
* This workflow deletes one or more users. It's used by other workflows
* This workflow deletes one or more users. It's used by other workflows
* like {@link removeUserAccountWorkflow}. If you use this workflow directly,
* you must also remove the association to the auth identity using the
* {@link setAuthAppMetadataStep}. Learn more about auth identities in
* [this documentation](https://docs.medusajs.com/resources/commerce-modules/auth/auth-identity-and-actor-types).
*
*
* You can use this workflow within your customizations or your own custom workflows, allowing you to
* delete users within your custom flows.
*
*
* @example
* const { result } = await deleteUsersWorkflow(container)
* .run({
@@ -26,9 +27,9 @@ export const deleteUsersWorkflowId = "delete-user"
* ids: ["user_123"]
* }
* })
*
*
* @summary
*
*
* Delete one or more users.
*/
export const deleteUsersWorkflow = createWorkflow(
@@ -44,9 +45,16 @@ export const deleteUsersWorkflow = createWorkflow(
})
})
emitEventStep({
eventName: UserWorkflowEvents.DELETED,
data: userIdEvents,
})
parallelize(
removeRemoteLinkStep({
[Modules.USER]: {
user_id: input.ids,
},
}),
emitEventStep({
eventName: UserWorkflowEvents.DELETED,
data: userIdEvents,
})
)
}
)