UNPKG

@medusajs/core-flows

Version:

Set of workflow definitions for Medusa

47 lines 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deleteUsersWorkflow = exports.deleteUsersWorkflowId = void 0; const utils_1 = require("@medusajs/framework/utils"); const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk"); const common_1 = require("../../common"); const steps_1 = require("../steps"); exports.deleteUsersWorkflowId = "delete-user"; /** * 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({ * input: { * ids: ["user_123"] * } * }) * * @summary * * Delete one or more users. */ exports.deleteUsersWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.deleteUsersWorkflowId, (input) => { (0, steps_1.deleteUsersStep)(input.ids); const userIdEvents = (0, workflows_sdk_1.transform)({ input }, ({ input }) => { return input.ids?.map((id) => { return { id }; }); }); (0, workflows_sdk_1.parallelize)((0, common_1.removeRemoteLinkStep)({ [utils_1.Modules.USER]: { user_id: input.ids, }, }), (0, common_1.emitEventStep)({ eventName: utils_1.UserWorkflowEvents.DELETED, data: userIdEvents, })); }); //# sourceMappingURL=delete-users.js.map