From 31a057558c0ec6ff7233489a28edc1fda0ec5375 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Fri, 12 Dec 2025 11:11:01 +0200 Subject: [PATCH] fix(types,translations): fix types for translation and locale updates (#14278) * fix(types,translations): fix types for translation and locale updates * remove array type --- .changeset/chubby-jobs-shout.md | 6 +++ .../translation/steps/update-translations.ts | 3 +- .../steps/validate-translations.ts | 3 +- .../core/types/src/translation/mutations.ts | 38 ++++++++++++------- .../core/types/src/translation/service.ts | 6 ++- 5 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 .changeset/chubby-jobs-shout.md diff --git a/.changeset/chubby-jobs-shout.md b/.changeset/chubby-jobs-shout.md new file mode 100644 index 0000000000..b3c7b3f21b --- /dev/null +++ b/.changeset/chubby-jobs-shout.md @@ -0,0 +1,6 @@ +--- +"@medusajs/core-flows": patch +"@medusajs/types": patch +--- + +fix(types,translations): fix types for translation and locale updates diff --git a/packages/core/core-flows/src/translation/steps/update-translations.ts b/packages/core/core-flows/src/translation/steps/update-translations.ts index d14c1a07cc..347934e02a 100644 --- a/packages/core/core-flows/src/translation/steps/update-translations.ts +++ b/packages/core/core-flows/src/translation/steps/update-translations.ts @@ -1,6 +1,7 @@ import { FilterableTranslationProps, ITranslationModuleService, + UpdateTranslationDataDTO, UpdateTranslationDTO, } from "@medusajs/framework/types" import { @@ -22,7 +23,7 @@ export type UpdateTranslationsStepInput = /** * The data to update in the translations. */ - update: UpdateTranslationDTO + update: UpdateTranslationDataDTO } | { translations: UpdateTranslationDTO[] diff --git a/packages/core/core-flows/src/translation/steps/validate-translations.ts b/packages/core/core-flows/src/translation/steps/validate-translations.ts index bcfeff6d6e..9fec95af2e 100644 --- a/packages/core/core-flows/src/translation/steps/validate-translations.ts +++ b/packages/core/core-flows/src/translation/steps/validate-translations.ts @@ -4,7 +4,7 @@ import { MedusaErrorTypes, } from "@medusajs/framework/utils" import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" -import { CreateTranslationDTO, UpdateTranslationDTO } from "@medusajs/types" +import { CreateTranslationDTO, UpdateTranslationDataDTO, UpdateTranslationDTO } from "@medusajs/types" export const validateTranslationsStepId = "validate-translations" @@ -13,6 +13,7 @@ export type ValidateTranslationsStepInput = | CreateTranslationDTO | UpdateTranslationDTO[] | UpdateTranslationDTO + | UpdateTranslationDataDTO // TODO: Do we want to validate anything else here? export const validateTranslationsStep = createStep( diff --git a/packages/core/types/src/translation/mutations.ts b/packages/core/types/src/translation/mutations.ts index bc7f1ffb91..5319ab4cfb 100644 --- a/packages/core/types/src/translation/mutations.ts +++ b/packages/core/types/src/translation/mutations.ts @@ -19,14 +19,9 @@ export interface CreateLocaleDTO { } /** - * The attributes to update in the locale. + * The data to update in the locale. */ -export interface UpdateLocaleDTO { - /** - * The ID of the locale to update. - */ - id: string - +export interface UpdateLocaleDataDTO { /** * The BCP 47 language tag code of the locale. */ @@ -38,6 +33,16 @@ export interface UpdateLocaleDTO { name?: string } +/** + * The attributes to update in the locale. + */ +export interface UpdateLocaleDTO extends UpdateLocaleDataDTO { + /** + * The ID of the locale to update. + */ + id: string +} + /** * The attributes in the locale to be created or updated. */ @@ -84,14 +89,9 @@ export interface CreateTranslationDTO { } /** - * The attributes to update in the translation. + * The attributes to update in translations matching a selector. */ -export interface UpdateTranslationDTO { - /** - * The ID of the translation to update. - */ - id: string - +export interface UpdateTranslationDataDTO { /** * The ID of the entity being translated. */ @@ -113,6 +113,16 @@ export interface UpdateTranslationDTO { translations?: Record } +/** + * The attributes to update in the translation. + */ +export interface UpdateTranslationDTO extends UpdateTranslationDataDTO { + /** + * The ID of the translation to update. + */ + id: string +} + /** * The attributes in the translation to be created or updated. */ diff --git a/packages/core/types/src/translation/service.ts b/packages/core/types/src/translation/service.ts index c8e3869d32..08a6971087 100644 --- a/packages/core/types/src/translation/service.ts +++ b/packages/core/types/src/translation/service.ts @@ -12,7 +12,9 @@ import { CreateLocaleDTO, CreateTranslationDTO, UpdateLocaleDTO, + UpdateLocaleDataDTO, UpdateTranslationDTO, + UpdateTranslationDataDTO, } from "./mutations" /** @@ -110,7 +112,7 @@ export interface ITranslationModuleService extends IModuleService { | UpdateLocaleDTO[] | { selector: Record - data: UpdateLocaleDTO | UpdateLocaleDTO[] + data: UpdateLocaleDataDTO | UpdateLocaleDataDTO[] }, sharedContext?: Context ): Promise @@ -245,7 +247,7 @@ export interface ITranslationModuleService extends IModuleService { | UpdateTranslationDTO[] | { selector: Record - data: UpdateTranslationDTO | UpdateTranslationDTO[] + data: UpdateTranslationDataDTO | UpdateTranslationDataDTO[] }, sharedContext?: Context ): Promise