From 317a1211226b0e551e5dc9cb6c1a7ea4528feb80 Mon Sep 17 00:00:00 2001 From: Joao Date: Thu, 6 Feb 2025 09:36:47 -0400 Subject: [PATCH] fix: enforce required ISO639_1 field in language schemas and update usage in FileMappers --- app/api/files.v2/database/FilesMappers.ts | 2 +- app/shared/types/commonSchemas.ts | 2 +- app/shared/types/commonTypes.d.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/files.v2/database/FilesMappers.ts b/app/api/files.v2/database/FilesMappers.ts index bfe724719a..724c61477e 100644 --- a/app/api/files.v2/database/FilesMappers.ts +++ b/app/api/files.v2/database/FilesMappers.ts @@ -42,7 +42,7 @@ export const FileMappers = { fileDBO.entity, fileDBO.totalPages, fileDBO.filename, - LanguageUtils.fromISO639_3(fileDBO.language).ISO639_1! + LanguageUtils.fromISO639_3(fileDBO.language).ISO639_1 ).withCreationDate(new Date(fileDBO.creationDate)); }, }; diff --git a/app/shared/types/commonSchemas.ts b/app/shared/types/commonSchemas.ts index 7d948c3899..abb2f6499b 100644 --- a/app/shared/types/commonSchemas.ts +++ b/app/shared/types/commonSchemas.ts @@ -239,7 +239,7 @@ export const LanguageISO6391Schema = { export const languageSchema = { type: 'object', - required: ['key', 'label'], + required: ['key', 'label', 'ISO639_1'], additionalProperties: false, definitions: { LanguageISO6391Schema, diff --git a/app/shared/types/commonTypes.d.ts b/app/shared/types/commonTypes.d.ts index 69ed0c5bba..2963b99834 100644 --- a/app/shared/types/commonTypes.d.ts +++ b/app/shared/types/commonTypes.d.ts @@ -245,7 +245,7 @@ export interface LanguageSchema { default?: boolean; ISO639_3?: string; elastic?: string; - ISO639_1?: LanguageISO6391; + ISO639_1: LanguageISO6391; localized_label?: string; translationAvailable?: boolean; } @@ -258,7 +258,7 @@ export type LanguagesListSchema = { default?: boolean; ISO639_3?: string; elastic?: string; - ISO639_1?: LanguageISO6391; + ISO639_1: LanguageISO6391; localized_label?: string; translationAvailable?: boolean; }[];