fix(types,translations): fix types for translation and locale updates (#14278)

* fix(types,translations): fix types for translation and locale updates

* remove array type
This commit is contained in:
Shahed Nasser authored and GitHub committed 2025-12-12 10:11:01 +01:00
1 parent a4ca4ef170
commit 31a057558c
5 files changed
+38 -18

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
---
"@medusajs/core-flows": patch
"@medusajs/types": patch
---
fix(types,translations): fix types for translation and locale updates
@@ -1,6 +1,7 @@
import { import {
FilterableTranslationProps, FilterableTranslationProps,
ITranslationModuleService, ITranslationModuleService,
UpdateTranslationDataDTO,
UpdateTranslationDTO, UpdateTranslationDTO,
} from "@medusajs/framework/types" } from "@medusajs/framework/types"
import { import {
@@ -22,7 +23,7 @@ export type UpdateTranslationsStepInput =
/** /**
* The data to update in the translations. * The data to update in the translations.
*/ */
update: UpdateTranslationDTO update: UpdateTranslationDataDTO
} }
| { | {
translations: UpdateTranslationDTO[] translations: UpdateTranslationDTO[]
@@ -4,7 +4,7 @@ import {
MedusaErrorTypes, MedusaErrorTypes,
} from "@medusajs/framework/utils" } from "@medusajs/framework/utils"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" 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" export const validateTranslationsStepId = "validate-translations"
@@ -13,6 +13,7 @@ export type ValidateTranslationsStepInput =
| CreateTranslationDTO | CreateTranslationDTO
| UpdateTranslationDTO[] | UpdateTranslationDTO[]
| UpdateTranslationDTO | UpdateTranslationDTO
| UpdateTranslationDataDTO
// TODO: Do we want to validate anything else here? // TODO: Do we want to validate anything else here?
export const validateTranslationsStep = createStep( export const validateTranslationsStep = createStep(
@@ -19,14 +19,9 @@ export interface CreateLocaleDTO {
} }
/** /**
* The attributes to update in the locale. * The data to update in the locale.
*/ */
export interface UpdateLocaleDTO { export interface UpdateLocaleDataDTO {
/**
* The ID of the locale to update.
*/
id: string
/** /**
* The BCP 47 language tag code of the locale. * The BCP 47 language tag code of the locale.
*/ */
@@ -38,6 +33,16 @@ export interface UpdateLocaleDTO {
name?: string 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. * 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 { export interface UpdateTranslationDataDTO {
/**
* The ID of the translation to update.
*/
id: string
/** /**
* The ID of the entity being translated. * The ID of the entity being translated.
*/ */
@@ -113,6 +113,16 @@ export interface UpdateTranslationDTO {
translations?: Record<string, unknown> translations?: Record<string, unknown>
} }
/**
* 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. * The attributes in the translation to be created or updated.
*/ */
@@ -12,7 +12,9 @@ import {
CreateLocaleDTO, CreateLocaleDTO,
CreateTranslationDTO, CreateTranslationDTO,
UpdateLocaleDTO, UpdateLocaleDTO,
UpdateLocaleDataDTO,
UpdateTranslationDTO, UpdateTranslationDTO,
UpdateTranslationDataDTO,
} from "./mutations" } from "./mutations"
/** /**
@@ -110,7 +112,7 @@ export interface ITranslationModuleService extends IModuleService {
| UpdateLocaleDTO[] | UpdateLocaleDTO[]
| { | {
selector: Record<string, any> selector: Record<string, any>
data: UpdateLocaleDTO | UpdateLocaleDTO[] data: UpdateLocaleDataDTO | UpdateLocaleDataDTO[]
}, },
sharedContext?: Context sharedContext?: Context
): Promise<LocaleDTO[]> ): Promise<LocaleDTO[]>
@@ -245,7 +247,7 @@ export interface ITranslationModuleService extends IModuleService {
| UpdateTranslationDTO[] | UpdateTranslationDTO[]
| { | {
selector: Record<string, any> selector: Record<string, any>
data: UpdateTranslationDTO | UpdateTranslationDTO[] data: UpdateTranslationDataDTO | UpdateTranslationDataDTO[]
}, },
sharedContext?: Context sharedContext?: Context
): Promise<TranslationDTO[]> ): Promise<TranslationDTO[]>