chore(core-flows): Add invite resent event (#8986)

This commit is contained in:
Oli Juhl
2024-09-04 19:53:29 +02:00
committed by GitHub
parent 4b1827ed48
commit f063a69632
2 changed files with 18 additions and 1 deletions

View File

@@ -3,8 +3,11 @@ import {
WorkflowData,
WorkflowResponse,
createWorkflow,
transform,
} from "@medusajs/workflows-sdk"
import { InviteWorkflowEvents } from "@medusajs/utils"
import { emitEventStep } from "../../common"
import { refreshInviteTokensStep } from "../steps/refresh-invite-tokens"
export const refreshInviteTokensWorkflowId = "refresh-invite-tokens-workflow"
@@ -16,6 +19,19 @@ export const refreshInviteTokensWorkflow = createWorkflow(
(
input: WorkflowData<InviteWorkflow.ResendInvitesWorkflowInputDTO>
): WorkflowResponse<InviteDTO[]> => {
return new WorkflowResponse(refreshInviteTokensStep(input.invite_ids))
const invites = refreshInviteTokensStep(input.invite_ids)
const invitesIdEvents = transform({ invites }, ({ invites }) => {
return invites.map((v) => {
return { id: v.id }
})
})
emitEventStep({
eventName: InviteWorkflowEvents.RESENT,
data: invitesIdEvents,
})
return new WorkflowResponse(invites)
}
)

View File

@@ -44,6 +44,7 @@ export const InviteWorkflowEvents = {
ACCEPTED: "invite.accepted",
CREATED: "invite.created",
DELETED: "invite.deleted",
RESENT: "invite.resent",
}
export const RegionWorkflowEvents = {