Skip to content

Commit a78f68f

Browse files
authored
fix(utils,core-flows): add events constant for translations and use it in workflows (medusajs#14277)
1 parent d739873 commit a78f68f

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

.changeset/fruity-eyes-glow.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@medusajs/core-flows": patch
3+
"@medusajs/utils": patch
4+
---
5+
6+
fix(utils,core-flows): add events constant for translations and use it in workflows

packages/core/core-flows/src/translation/workflows/create-translations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { emitEventStep } from "../../common/steps/emit-event"
99
import { createTranslationsStep } from "../steps"
1010
import { validateTranslationsStep } from "../steps"
11+
import { TranslationWorkflowEvents } from "@medusajs/framework/utils"
1112

1213
export type CreateTranslationsWorkflowInput = {
1314
translations: CreateTranslationDTO[]
@@ -57,7 +58,7 @@ export const createTranslationsWorkflow = createWorkflow(
5758
)
5859

5960
emitEventStep({
60-
eventName: "translation.created",
61+
eventName: TranslationWorkflowEvents.CREATED,
6162
data: translationIdEvents,
6263
})
6364

packages/core/core-flows/src/translation/workflows/delete-translations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from "@medusajs/framework/workflows-sdk"
66
import { emitEventStep } from "../../common/steps/emit-event"
77
import { deleteTranslationsStep } from "../steps"
8+
import { TranslationWorkflowEvents } from "@medusajs/framework/utils"
89

910
export type DeleteTranslationsWorkflowInput = { ids: string[] }
1011

@@ -41,7 +42,7 @@ export const deleteTranslationsWorkflow = createWorkflow(
4142
})
4243

4344
emitEventStep({
44-
eventName: "translation.deleted",
45+
eventName: TranslationWorkflowEvents.DELETED,
4546
data: translationIdEvents,
4647
})
4748
}

packages/core/core-flows/src/translation/workflows/update-translations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { emitEventStep } from "../../common/steps/emit-event"
99
import { updateTranslationsStep, UpdateTranslationsStepInput } from "../steps"
1010
import { validateTranslationsStep } from "../steps"
11+
import { TranslationWorkflowEvents } from "@medusajs/framework/utils"
1112

1213
export type UpdateTranslationsWorkflowInput = UpdateTranslationsStepInput
1314

@@ -58,7 +59,7 @@ export const updateTranslationsWorkflow = createWorkflow(
5859
)
5960

6061
emitEventStep({
61-
eventName: "translation.updated",
62+
eventName: TranslationWorkflowEvents.UPDATED,
6263
data: translationIdEvents,
6364
})
6465

packages/core/utils/src/core-flows/events.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,3 +889,49 @@ export const PaymentEvents = {
889889
*/
890890
REFUNDED: "payment.refunded",
891891
}
892+
893+
/**
894+
* @category Translation
895+
* @customNamespace Translation
896+
*/
897+
export const TranslationWorkflowEvents = {
898+
/**
899+
* Emitted when translations are created.
900+
*
901+
* @since 2.13.0
902+
* @featureFlag translation
903+
* @eventPayload
904+
* ```ts
905+
* {
906+
* id, // The ID of the translation
907+
* }
908+
* ```
909+
*/
910+
CREATED: "translation.created",
911+
/**
912+
* Emitted when translations are updated.
913+
*
914+
* @since 2.13.0
915+
* @featureFlag translation
916+
* @eventPayload
917+
* ```ts
918+
* {
919+
* id, // The ID of the translation
920+
* }
921+
* ```
922+
*/
923+
UPDATED: "translation.updated",
924+
/**
925+
* Emitted when translations are deleted.
926+
*
927+
* @since 2.13.0
928+
* @featureFlag translation
929+
* @eventPayload
930+
* ```ts
931+
* {
932+
* id, // The ID of the translation
933+
* }
934+
* ```
935+
*/
936+
DELETED: "translation.deleted",
937+
}

0 commit comments

Comments
 (0)