@intlayer/backend 4.1.11 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/controllers/dictionary.controller.cjs +2 -2
  2. package/dist/cjs/controllers/dictionary.controller.cjs.map +1 -1
  3. package/dist/cjs/routes/ai.routes.cjs +6 -6
  4. package/dist/cjs/routes/ai.routes.cjs.map +1 -1
  5. package/dist/cjs/types/dictionary.types.cjs.map +1 -1
  6. package/dist/cjs/utils/AI/embeddings.json +16 -16
  7. package/dist/cjs/utils/auditDictionary/JSX_FORMAT.md +1 -1
  8. package/dist/cjs/utils/auditDictionary/PROMPT.md +10 -10
  9. package/dist/cjs/utils/auditDictionary/TSX_FORMAT.md +2 -2
  10. package/dist/cjs/utils/auditDictionary/TS_FORMAT.md +2 -2
  11. package/dist/cjs/utils/auditDictionaryField/PROMPT.md +5 -5
  12. package/dist/cjs/utils/auditDictionaryMetadata/PROMPT.md +4 -4
  13. package/dist/cjs/utils/auditTag/PROMPT.md +2 -2
  14. package/dist/cjs/utils/mapper/dictionary.cjs +1 -1
  15. package/dist/cjs/utils/mapper/dictionary.cjs.map +1 -1
  16. package/dist/esm/controllers/dictionary.controller.mjs +2 -2
  17. package/dist/esm/controllers/dictionary.controller.mjs.map +1 -1
  18. package/dist/esm/routes/ai.routes.mjs +6 -6
  19. package/dist/esm/routes/ai.routes.mjs.map +1 -1
  20. package/dist/esm/utils/AI/embeddings.json +16 -16
  21. package/dist/esm/utils/auditDictionary/JSX_FORMAT.md +1 -1
  22. package/dist/esm/utils/auditDictionary/PROMPT.md +10 -10
  23. package/dist/esm/utils/auditDictionary/TSX_FORMAT.md +2 -2
  24. package/dist/esm/utils/auditDictionary/TS_FORMAT.md +2 -2
  25. package/dist/esm/utils/auditDictionaryField/PROMPT.md +5 -5
  26. package/dist/esm/utils/auditDictionaryMetadata/PROMPT.md +4 -4
  27. package/dist/esm/utils/auditTag/PROMPT.md +2 -2
  28. package/dist/esm/utils/mapper/dictionary.mjs +1 -1
  29. package/dist/esm/utils/mapper/dictionary.mjs.map +1 -1
  30. package/dist/types/types/dictionary.types.d.ts +6 -7
  31. package/dist/types/types/dictionary.types.d.ts.map +1 -1
  32. package/dist/types/utils/mapper/dictionary.d.ts.map +1 -1
  33. package/package.json +8 -8
@@ -256,7 +256,7 @@ const pushDictionaries = async (req, res, _next) => {
256
256
  const updatedDictionariesResult = [];
257
257
  const errorResult = [];
258
258
  for (const dictionaryDataEl of newDictionaries) {
259
- const publishedVersion = dictionaryDataEl.publishedVersion ? dictionaryDataEl.publishedVersion === "-1" ? null : dictionaryDataEl.publishedVersion : null;
259
+ const publishedVersion = dictionaryDataEl.version ? dictionaryDataEl.version === "-1" ? null : dictionaryDataEl.version : null;
260
260
  const dictionary = {
261
261
  title: dictionaryDataEl.title,
262
262
  description: dictionaryDataEl.description,
@@ -307,7 +307,7 @@ const pushDictionaries = async (req, res, _next) => {
307
307
  }
308
308
  };
309
309
  }
310
- const publishedVersion = dictionaryDataEl.publishedVersion ? dictionaryDataEl.publishedVersion === "-1" ? null : dictionaryDataEl.publishedVersion : null;
310
+ const publishedVersion = dictionaryDataEl.version ? dictionaryDataEl.version === "-1" ? null : dictionaryDataEl.version : null;
311
311
  const dictionary = {
312
312
  ...existingDictionaryDB,
313
313
  ...dictionaryDataEl,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/controllers/dictionary.controller.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Dictionary as LocalDictionary } from '@intlayer/core';\nimport { logger } from '@logger';\nimport type { ResponseWithInformation } from '@middlewares/sessionAuth.middleware';\nimport * as dictionaryService from '@services/dictionary.service';\nimport { AppError, ErrorHandler } from '@utils/errors';\nimport {\n type DictionaryFiltersParams,\n getDictionaryFiltersAndPagination,\n} from '@utils/filtersAndPagination/getDictionaryFiltersAndPagination';\nimport type { FiltersAndPagination } from '@utils/filtersAndPagination/getFiltersAndPaginationFromBody';\nimport { mapDictionaryToAPI } from '@utils/mapper/dictionary';\nimport {\n formatPaginatedResponse,\n type ResponseData,\n type PaginatedResponse,\n formatResponse,\n} from '@utils/responseData';\nimport type { NextFunction, Request } from 'express';\nimport { t } from 'express-intlayer';\nimport * as eventListener from '@/controllers/event-listener';\nimport type {\n Dictionary,\n DictionaryAPI,\n DictionaryCreationData,\n DictionaryData,\n VersionedContent,\n} from '@/types/dictionary.types';\n\nexport type GetDictionariesParams =\n FiltersAndPagination<DictionaryFiltersParams>;\nexport type GetDictionariesResult = PaginatedResponse<DictionaryAPI>;\n\n/**\n * Retrieves a list of dictionaries based on filters and pagination.\n */\nexport const getDictionaries = async (\n req: Request<GetDictionariesParams>,\n res: ResponseWithInformation<GetDictionariesResult>,\n _next: NextFunction\n): Promise<void> => {\n const { user, project, dictionaryRights } = res.locals;\n const { filters, pageSize, skip, page, getNumberOfPages } =\n getDictionaryFiltersAndPagination(req);\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n if (!dictionaryRights?.read) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_READ');\n return;\n }\n\n try {\n const dictionaries = await dictionaryService.findDictionaries(\n filters,\n skip,\n pageSize\n );\n const totalItems = await dictionaryService.countDictionaries(filters);\n\n const dictionariesAPI = dictionaries.map((el) =>\n mapDictionaryToAPI(el, project._id, el.publishedVersion ?? undefined)\n );\n\n const responseData = formatPaginatedResponse<DictionaryAPI>({\n data: dictionariesAPI,\n page,\n pageSize,\n totalPages: getNumberOfPages(totalItems),\n totalItems,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type GetDictionariesKeysResult = ResponseData<string[]>;\n\n/**\n * Retrieves a list of dictionaries keys based on filters and pagination.\n */\nexport const getDictionariesKeys = async (\n _req: Request,\n res: ResponseWithInformation<GetDictionariesKeysResult>,\n _next: NextFunction\n) => {\n const { project, dictionaryRights } = res.locals;\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n if (!dictionaryRights?.read) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_READ');\n return;\n }\n\n try {\n const dictionariesKeys = await dictionaryService.getDictionariesKeys(\n project._id\n );\n\n const responseData = formatResponse<string[]>({\n data: dictionariesKeys,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type GetDictionaryParams = { dictionaryKey: string };\nexport type GetDictionaryQuery = { version?: string };\nexport type GetDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Retrieves a list of dictionaries based on filters and pagination.\n */\nexport const getDictionaryByKey = async (\n req: Request<GetDictionaryParams, any, any, GetDictionaryQuery>,\n res: ResponseWithInformation<GetDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user, dictionaryRights } = res.locals;\n const { dictionaryKey } = req.params;\n const version = req.query.version;\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n if (!dictionaryRights?.read) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_READ');\n return;\n }\n\n try {\n const dictionary = await dictionaryService.getDictionaryByKey(\n dictionaryKey,\n project._id\n );\n\n if (!dictionary.projectIds.map(String).includes(String(project._id))) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'DICTIONARY_PROJECT_MISMATCH'\n );\n return;\n }\n\n const apiResult = mapDictionaryToAPI(dictionary, project._id, version);\n\n const responseData = formatResponse<DictionaryAPI>({\n data: apiResult,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type AddDictionaryBody = DictionaryCreationData;\nexport type AddDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Adds a new dictionary to the database.\n */\nexport const addDictionary = async (\n req: Request<any, any, AddDictionaryBody>,\n res: ResponseWithInformation<AddDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user, dictionaryRights } = res.locals;\n const dictionaryData = req.body;\n\n if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n if (!dictionaryData.projectIds.includes(String(project._id))) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_PROJECT_MISMATCH');\n return;\n }\n\n if (!dictionaryRights?.admin) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_ADMIN');\n return;\n }\n\n const dictionary: DictionaryData = {\n key: dictionaryData.key,\n title: dictionaryData.title,\n description: dictionaryData.description,\n content: {\n v1: {\n content: dictionaryData.content,\n },\n },\n creatorId: user._id,\n filePath: {\n [String(project._id)]: dictionaryData.filePath ?? '',\n },\n projectIds: dictionaryData.projectIds ?? [String(project._id)],\n };\n\n try {\n const newDictionary = await dictionaryService.createDictionary(dictionary);\n\n const apiResult = mapDictionaryToAPI(newDictionary, project._id);\n\n const responseData = formatResponse<DictionaryAPI>({\n message: t({\n en: 'Dictionary created successfully',\n fr: 'Dictionnaire créé avec succès',\n es: 'Diccionario creado con éxito',\n }),\n description: t({\n en: 'Your dictionary has been created successfully',\n fr: 'Votre dictionnaire a été créé avec succès',\n es: 'Su diccionario ha sido creado con éxito',\n }),\n data: apiResult,\n });\n\n res.json(responseData);\n\n eventListener.sendDictionaryUpdate([\n {\n dictionary: mapDictionaryToAPI(newDictionary, project._id),\n status: 'ADDED',\n },\n ]);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type PushDictionariesBody = {\n dictionaries: LocalDictionary[];\n};\ntype PushDictionariesResultData = {\n newDictionaries: string[];\n updatedDictionaries: string[];\n error: { dictionaryId: string; message: string }[];\n};\nexport type PushDictionariesResult = ResponseData<PushDictionariesResultData>;\n\n/**\n * Check each dictionaries, add the new ones and update the existing ones.\n * @param req - Express request object.\n * @param res - Express response object.\n * @returns Response containing the created dictionary.\n */\nexport const pushDictionaries = async (\n req: Request<any, any, PushDictionariesBody>,\n res: ResponseWithInformation<PushDictionariesResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user, dictionaryRights } = res.locals;\n const dictionaryData = req.body.dictionaries;\n const dictionariesKeys = dictionaryData.map((dictionary) => dictionary.key);\n\n if (\n typeof dictionaryData === 'object' &&\n Array.isArray(dictionaryData) &&\n dictionaryData.length === 0\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARIES_NOT_PROVIDED');\n return;\n } else if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n if (!dictionaryRights?.write) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_WRITE');\n return;\n }\n\n if (!dictionaryRights?.admin) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_ADMIN');\n return;\n }\n\n try {\n const { existingDictionariesKey, newDictionariesKey } =\n await dictionaryService.getExistingDictionaryKey(\n dictionariesKeys,\n project._id\n );\n\n const existingDictionaries = dictionaryData.filter((dictionary) =>\n existingDictionariesKey.includes(dictionary.key)\n );\n const newDictionaries = dictionaryData.filter((dictionary) =>\n newDictionariesKey.includes(dictionary.key)\n );\n\n const newDictionariesResult: DictionaryAPI[] = [];\n const updatedDictionariesResult: DictionaryAPI[] = [];\n const errorResult: PushDictionariesResultData['error'] = [];\n\n for (const dictionaryDataEl of newDictionaries) {\n const publishedVersion = dictionaryDataEl.publishedVersion\n ? dictionaryDataEl.publishedVersion === '-1'\n ? null\n : dictionaryDataEl.publishedVersion\n : null;\n\n const dictionary: DictionaryData = {\n title: dictionaryDataEl.title,\n description: dictionaryDataEl.description,\n projectIds: [String(project._id)],\n creatorId: user._id,\n content: {\n v1: {\n content: dictionaryDataEl.content,\n },\n },\n filePath: {\n [String(project._id)]: dictionaryDataEl.filePath ?? '',\n },\n key: dictionaryDataEl.key,\n publishedVersion,\n };\n\n try {\n const newDictionary =\n await dictionaryService.createDictionary(dictionary);\n newDictionariesResult.push(\n mapDictionaryToAPI(newDictionary, project._id)\n );\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n }\n\n if (existingDictionariesKey.length >= 0) {\n const existingDictionariesDB =\n await dictionaryService.getDictionariesByKeys(\n existingDictionariesKey,\n project._id\n );\n\n for (const dictionaryDataEl of existingDictionaries) {\n const existingDictionaryDB = existingDictionariesDB.find(\n (dictionaryDB) => dictionaryDB.key === dictionaryDataEl.key\n )!;\n\n const existingContentArray = Object.values(\n existingDictionaryDB.content\n );\n\n const lastContent =\n existingContentArray[existingContentArray.length - 1].content;\n\n const isSameContent =\n JSON.stringify(lastContent) ===\n JSON.stringify(dictionaryDataEl.content);\n\n let newContent: VersionedContent = existingDictionaryDB.content;\n\n if (!isSameContent) {\n const newContentVersion =\n dictionaryService.incrementVersion(existingDictionaryDB);\n\n newContent = {\n ...newContent,\n [newContentVersion]: {\n content: dictionaryDataEl.content,\n },\n };\n }\n\n const publishedVersion = dictionaryDataEl.publishedVersion\n ? dictionaryDataEl.publishedVersion === '-1'\n ? null\n : dictionaryDataEl.publishedVersion\n : null;\n\n const dictionary: DictionaryData = {\n ...existingDictionaryDB,\n ...dictionaryDataEl,\n content: newContent,\n projectIds: [String(project._id)],\n creatorId: user._id,\n filePath: {\n [String(project._id)]: dictionaryDataEl.filePath ?? '',\n },\n publishedVersion,\n key: dictionaryDataEl.key,\n };\n\n try {\n const updatedDictionary =\n await dictionaryService.updateDictionaryByKey(\n dictionaryDataEl.key,\n dictionary,\n project._id\n );\n updatedDictionariesResult.push(\n mapDictionaryToAPI(updatedDictionary, project._id)\n );\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n }\n }\n\n const result: PushDictionariesResultData = {\n newDictionaries: newDictionariesResult.map(\n (dictionary) => dictionary.key\n ),\n updatedDictionaries: updatedDictionariesResult.map(\n (dictionary) => dictionary.key\n ),\n error: errorResult,\n };\n\n const responseData = formatResponse<PushDictionariesResultData>({\n message: t({\n en: 'Dictionaries updated successfully',\n fr: 'Dictionnaires mis à jour avec succès',\n es: 'Diccionarios actualizados con éxito',\n }),\n description: t({\n en: 'Your dictionaries have been updated successfully',\n fr: 'Vos dictionnaires ont été mis à jour avec succès',\n es: 'Sus diccionarios han sido actualizados con éxito',\n }),\n data: result,\n });\n\n eventListener.sendDictionaryUpdate([\n ...newDictionariesResult.map(\n (dictionary) =>\n ({\n dictionary,\n status: 'ADDED',\n }) as eventListener.SendDictionaryUpdateArg\n ),\n ...updatedDictionariesResult.map(\n (dictionary) =>\n ({\n dictionary,\n status: 'UPDATED',\n }) as eventListener.SendDictionaryUpdateArg\n ),\n ]);\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type UpdateDictionaryParam = { dictionaryId: string };\nexport type UpdateDictionaryBody = Partial<Dictionary>;\nexport type UpdateDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Updates an existing dictionary in the database.\n */\nexport const updateDictionary = async (\n req: Request<UpdateDictionaryParam, any, UpdateDictionaryBody>,\n res: ResponseWithInformation<UpdateDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { dictionaryId } = req.params;\n const { project, dictionaryRights } = res.locals;\n const dictionaryData = req.body;\n\n if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!dictionaryData.projectIds?.includes(String(project._id))) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_PROJECT_MISMATCH');\n return;\n }\n\n if (typeof dictionaryId === 'undefined') {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_ID_NOT_FOUND');\n return;\n }\n\n if (!dictionaryRights?.write) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_WRITE');\n return;\n }\n\n try {\n const updatedDictionary = await dictionaryService.updateDictionaryById(\n dictionaryId,\n dictionaryData\n );\n\n const apiResult = mapDictionaryToAPI(updatedDictionary, project._id);\n\n const responseData = formatResponse<DictionaryAPI>({\n message: t({\n en: 'Dictionary updated successfully',\n fr: 'Dictionnaire mis à jour avec succès',\n es: 'Diccionario actualizado con éxito',\n }),\n description: t({\n en: 'Your dictionary has been updated successfully',\n fr: 'Votre dictionnaire a été mis à jour avec succès',\n es: 'Su diccionario ha sido actualizado con éxito',\n }),\n data: apiResult,\n });\n\n eventListener.sendDictionaryUpdate([\n {\n dictionary: apiResult,\n status: 'UPDATED',\n },\n ]);\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type DeleteDictionaryParam = { dictionaryId: string };\nexport type DeleteDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Deletes a dictionary from the database by its ID.\n */\nexport const deleteDictionary = async (\n req: Request<DeleteDictionaryParam>,\n res: ResponseWithInformation<DeleteDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, dictionaryRights } = res.locals;\n const { dictionaryId } = req.params as Partial<DeleteDictionaryParam>;\n\n if (!dictionaryId) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_ID_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!dictionaryRights?.admin) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_ADMIN');\n return;\n }\n\n try {\n const dictionaryToDelete =\n await dictionaryService.getDictionaryById(dictionaryId);\n\n if (!dictionaryToDelete.projectIds.includes(project._id)) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'DICTIONARY_PROJECT_MISMATCH'\n );\n return;\n }\n\n const deletedDictionary =\n await dictionaryService.deleteDictionaryById(dictionaryId);\n\n if (!deletedDictionary) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_NOT_FOUND', {\n dictionaryId,\n });\n return;\n }\n\n logger.info(`Dictionary deleted: ${String(deletedDictionary._id)}`);\n\n const apiResult = mapDictionaryToAPI(deletedDictionary, project._id);\n\n const responseData = formatResponse<DictionaryAPI>({\n message: t({\n en: 'Dictionary deleted successfully',\n fr: 'Dictionnaire supprimé avec succès',\n es: 'Diccionario eliminado con éxito',\n }),\n description: t({\n en: 'Your dictionary has been deleted successfully',\n fr: 'Votre dictionnaire a été supprimé avec succès',\n es: 'Su diccionario ha sido eliminado con éxito',\n }),\n data: apiResult,\n });\n\n res.json(responseData);\n\n eventListener.sendDictionaryUpdate([\n {\n dictionary: apiResult,\n status: 'DELETED',\n },\n ]);\n\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA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I;AAAA,QACJ,IAAI;AAAA,MACN,CAAC;AAAA,MACD,iBAAa,2BAAE;AAAA,QACb,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MACN,CAAC;AAAA,MACD,MAAM;AAAA,IACR,CAAC;AAED,QAAI,KAAK,YAAY;AAErB,kBAAc,qBAAqB;AAAA,MACjC;AAAA,QACE,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAED;AAAA,EACF,SAAS,OAAO;AACd,+BAAa,uBAAuB,KAAK,KAAiB;AAC1D;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/controllers/dictionary.controller.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Dictionary as LocalDictionary } from '@intlayer/core';\nimport { logger } from '@logger';\nimport type { ResponseWithInformation } from '@middlewares/sessionAuth.middleware';\nimport * as dictionaryService from '@services/dictionary.service';\nimport { AppError, ErrorHandler } from '@utils/errors';\nimport {\n type DictionaryFiltersParams,\n getDictionaryFiltersAndPagination,\n} from '@utils/filtersAndPagination/getDictionaryFiltersAndPagination';\nimport type { FiltersAndPagination } from '@utils/filtersAndPagination/getFiltersAndPaginationFromBody';\nimport { mapDictionaryToAPI } from '@utils/mapper/dictionary';\nimport {\n formatPaginatedResponse,\n type ResponseData,\n type PaginatedResponse,\n formatResponse,\n} from '@utils/responseData';\nimport type { NextFunction, Request } from 'express';\nimport { t } from 'express-intlayer';\nimport * as eventListener from '@/controllers/event-listener';\nimport type {\n Dictionary,\n DictionaryAPI,\n DictionaryCreationData,\n DictionaryData,\n VersionedContent,\n} from '@/types/dictionary.types';\n\nexport type GetDictionariesParams =\n FiltersAndPagination<DictionaryFiltersParams>;\nexport type GetDictionariesResult = PaginatedResponse<DictionaryAPI>;\n\n/**\n * Retrieves a list of dictionaries based on filters and pagination.\n */\nexport const getDictionaries = async (\n req: Request<GetDictionariesParams>,\n res: ResponseWithInformation<GetDictionariesResult>,\n _next: NextFunction\n): Promise<void> => {\n const { user, project, dictionaryRights } = res.locals;\n const { filters, pageSize, skip, page, getNumberOfPages } =\n getDictionaryFiltersAndPagination(req);\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n if (!dictionaryRights?.read) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_READ');\n return;\n }\n\n try {\n const dictionaries = await dictionaryService.findDictionaries(\n filters,\n skip,\n pageSize\n );\n const totalItems = await dictionaryService.countDictionaries(filters);\n\n const dictionariesAPI = dictionaries.map((el) =>\n mapDictionaryToAPI(el, project._id, el.publishedVersion ?? undefined)\n );\n\n const responseData = formatPaginatedResponse<DictionaryAPI>({\n data: dictionariesAPI,\n page,\n pageSize,\n totalPages: getNumberOfPages(totalItems),\n totalItems,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type GetDictionariesKeysResult = ResponseData<string[]>;\n\n/**\n * Retrieves a list of dictionaries keys based on filters and pagination.\n */\nexport const getDictionariesKeys = async (\n _req: Request,\n res: ResponseWithInformation<GetDictionariesKeysResult>,\n _next: NextFunction\n) => {\n const { project, dictionaryRights } = res.locals;\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n if (!dictionaryRights?.read) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_READ');\n return;\n }\n\n try {\n const dictionariesKeys = await dictionaryService.getDictionariesKeys(\n project._id\n );\n\n const responseData = formatResponse<string[]>({\n data: dictionariesKeys,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type GetDictionaryParams = { dictionaryKey: string };\nexport type GetDictionaryQuery = { version?: string };\nexport type GetDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Retrieves a list of dictionaries based on filters and pagination.\n */\nexport const getDictionaryByKey = async (\n req: Request<GetDictionaryParams, any, any, GetDictionaryQuery>,\n res: ResponseWithInformation<GetDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user, dictionaryRights } = res.locals;\n const { dictionaryKey } = req.params;\n const version = req.query.version;\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n if (!dictionaryRights?.read) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_READ');\n return;\n }\n\n try {\n const dictionary = await dictionaryService.getDictionaryByKey(\n dictionaryKey,\n project._id\n );\n\n if (!dictionary.projectIds.map(String).includes(String(project._id))) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'DICTIONARY_PROJECT_MISMATCH'\n );\n return;\n }\n\n const apiResult = mapDictionaryToAPI(dictionary, project._id, version);\n\n const responseData = formatResponse<DictionaryAPI>({\n data: apiResult,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type AddDictionaryBody = DictionaryCreationData;\nexport type AddDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Adds a new dictionary to the database.\n */\nexport const addDictionary = async (\n req: Request<any, any, AddDictionaryBody>,\n res: ResponseWithInformation<AddDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user, dictionaryRights } = res.locals;\n const dictionaryData = req.body;\n\n if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n if (!dictionaryData.projectIds.includes(String(project._id))) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_PROJECT_MISMATCH');\n return;\n }\n\n if (!dictionaryRights?.admin) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_ADMIN');\n return;\n }\n\n const dictionary: DictionaryData = {\n key: dictionaryData.key,\n title: dictionaryData.title,\n description: dictionaryData.description,\n content: {\n v1: {\n content: dictionaryData.content,\n },\n },\n creatorId: user._id,\n filePath: {\n [String(project._id)]: dictionaryData.filePath ?? '',\n },\n projectIds: dictionaryData.projectIds ?? [String(project._id)],\n };\n\n try {\n const newDictionary = await dictionaryService.createDictionary(dictionary);\n\n const apiResult = mapDictionaryToAPI(newDictionary, project._id);\n\n const responseData = formatResponse<DictionaryAPI>({\n message: t({\n en: 'Dictionary created successfully',\n fr: 'Dictionnaire créé avec succès',\n es: 'Diccionario creado con éxito',\n }),\n description: t({\n en: 'Your dictionary has been created successfully',\n fr: 'Votre dictionnaire a été créé avec succès',\n es: 'Su diccionario ha sido creado con éxito',\n }),\n data: apiResult,\n });\n\n res.json(responseData);\n\n eventListener.sendDictionaryUpdate([\n {\n dictionary: mapDictionaryToAPI(newDictionary, project._id),\n status: 'ADDED',\n },\n ]);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type PushDictionariesBody = {\n dictionaries: LocalDictionary[];\n};\ntype PushDictionariesResultData = {\n newDictionaries: string[];\n updatedDictionaries: string[];\n error: { dictionaryId: string; message: string }[];\n};\nexport type PushDictionariesResult = ResponseData<PushDictionariesResultData>;\n\n/**\n * Check each dictionaries, add the new ones and update the existing ones.\n * @param req - Express request object.\n * @param res - Express response object.\n * @returns Response containing the created dictionary.\n */\nexport const pushDictionaries = async (\n req: Request<any, any, PushDictionariesBody>,\n res: ResponseWithInformation<PushDictionariesResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user, dictionaryRights } = res.locals;\n const dictionaryData = req.body.dictionaries;\n const dictionariesKeys = dictionaryData.map((dictionary) => dictionary.key);\n\n if (\n typeof dictionaryData === 'object' &&\n Array.isArray(dictionaryData) &&\n dictionaryData.length === 0\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARIES_NOT_PROVIDED');\n return;\n } else if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n if (!dictionaryRights?.write) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_WRITE');\n return;\n }\n\n if (!dictionaryRights?.admin) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_ADMIN');\n return;\n }\n\n try {\n const { existingDictionariesKey, newDictionariesKey } =\n await dictionaryService.getExistingDictionaryKey(\n dictionariesKeys,\n project._id\n );\n\n const existingDictionaries = dictionaryData.filter((dictionary) =>\n existingDictionariesKey.includes(dictionary.key)\n );\n const newDictionaries = dictionaryData.filter((dictionary) =>\n newDictionariesKey.includes(dictionary.key)\n );\n\n const newDictionariesResult: DictionaryAPI[] = [];\n const updatedDictionariesResult: DictionaryAPI[] = [];\n const errorResult: PushDictionariesResultData['error'] = [];\n\n for (const dictionaryDataEl of newDictionaries) {\n const publishedVersion = dictionaryDataEl.version\n ? dictionaryDataEl.version === '-1'\n ? null\n : dictionaryDataEl.version\n : null;\n\n const dictionary: DictionaryData = {\n title: dictionaryDataEl.title,\n description: dictionaryDataEl.description,\n projectIds: [String(project._id)],\n creatorId: user._id,\n content: {\n v1: {\n content: dictionaryDataEl.content,\n },\n },\n filePath: {\n [String(project._id)]: dictionaryDataEl.filePath ?? '',\n },\n key: dictionaryDataEl.key,\n publishedVersion,\n };\n\n try {\n const newDictionary =\n await dictionaryService.createDictionary(dictionary);\n newDictionariesResult.push(\n mapDictionaryToAPI(newDictionary, project._id)\n );\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n }\n\n if (existingDictionariesKey.length >= 0) {\n const existingDictionariesDB =\n await dictionaryService.getDictionariesByKeys(\n existingDictionariesKey,\n project._id\n );\n\n for (const dictionaryDataEl of existingDictionaries) {\n const existingDictionaryDB = existingDictionariesDB.find(\n (dictionaryDB) => dictionaryDB.key === dictionaryDataEl.key\n )!;\n\n const existingContentArray = Object.values(\n existingDictionaryDB.content\n );\n\n const lastContent =\n existingContentArray[existingContentArray.length - 1].content;\n\n const isSameContent =\n JSON.stringify(lastContent) ===\n JSON.stringify(dictionaryDataEl.content);\n\n let newContent: VersionedContent = existingDictionaryDB.content;\n\n if (!isSameContent) {\n const newContentVersion =\n dictionaryService.incrementVersion(existingDictionaryDB);\n\n newContent = {\n ...newContent,\n [newContentVersion]: {\n content: dictionaryDataEl.content,\n },\n };\n }\n\n const publishedVersion = dictionaryDataEl.version\n ? dictionaryDataEl.version === '-1'\n ? null\n : dictionaryDataEl.version\n : null;\n\n const dictionary: DictionaryData = {\n ...existingDictionaryDB,\n ...dictionaryDataEl,\n content: newContent,\n projectIds: [String(project._id)],\n creatorId: user._id,\n filePath: {\n [String(project._id)]: dictionaryDataEl.filePath ?? '',\n },\n publishedVersion,\n key: dictionaryDataEl.key,\n };\n\n try {\n const updatedDictionary =\n await dictionaryService.updateDictionaryByKey(\n dictionaryDataEl.key,\n dictionary,\n project._id\n );\n updatedDictionariesResult.push(\n mapDictionaryToAPI(updatedDictionary, project._id)\n );\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n }\n }\n\n const result: PushDictionariesResultData = {\n newDictionaries: newDictionariesResult.map(\n (dictionary) => dictionary.key\n ),\n updatedDictionaries: updatedDictionariesResult.map(\n (dictionary) => dictionary.key\n ),\n error: errorResult,\n };\n\n const responseData = formatResponse<PushDictionariesResultData>({\n message: t({\n en: 'Dictionaries updated successfully',\n fr: 'Dictionnaires mis à jour avec succès',\n es: 'Diccionarios actualizados con éxito',\n }),\n description: t({\n en: 'Your dictionaries have been updated successfully',\n fr: 'Vos dictionnaires ont été mis à jour avec succès',\n es: 'Sus diccionarios han sido actualizados con éxito',\n }),\n data: result,\n });\n\n eventListener.sendDictionaryUpdate([\n ...newDictionariesResult.map(\n (dictionary) =>\n ({\n dictionary,\n status: 'ADDED',\n }) as eventListener.SendDictionaryUpdateArg\n ),\n ...updatedDictionariesResult.map(\n (dictionary) =>\n ({\n dictionary,\n status: 'UPDATED',\n }) as eventListener.SendDictionaryUpdateArg\n ),\n ]);\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type UpdateDictionaryParam = { dictionaryId: string };\nexport type UpdateDictionaryBody = Partial<Dictionary>;\nexport type UpdateDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Updates an existing dictionary in the database.\n */\nexport const updateDictionary = async (\n req: Request<UpdateDictionaryParam, any, UpdateDictionaryBody>,\n res: ResponseWithInformation<UpdateDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { dictionaryId } = req.params;\n const { project, dictionaryRights } = res.locals;\n const dictionaryData = req.body;\n\n if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!dictionaryData.projectIds?.includes(String(project._id))) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_PROJECT_MISMATCH');\n return;\n }\n\n if (typeof dictionaryId === 'undefined') {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_ID_NOT_FOUND');\n return;\n }\n\n if (!dictionaryRights?.write) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_WRITE');\n return;\n }\n\n try {\n const updatedDictionary = await dictionaryService.updateDictionaryById(\n dictionaryId,\n dictionaryData\n );\n\n const apiResult = mapDictionaryToAPI(updatedDictionary, project._id);\n\n const responseData = formatResponse<DictionaryAPI>({\n message: t({\n en: 'Dictionary updated successfully',\n fr: 'Dictionnaire mis à jour avec succès',\n es: 'Diccionario actualizado con éxito',\n }),\n description: t({\n en: 'Your dictionary has been updated successfully',\n fr: 'Votre dictionnaire a été mis à jour avec succès',\n es: 'Su diccionario ha sido actualizado con éxito',\n }),\n data: apiResult,\n });\n\n eventListener.sendDictionaryUpdate([\n {\n dictionary: apiResult,\n status: 'UPDATED',\n },\n ]);\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type DeleteDictionaryParam = { dictionaryId: string };\nexport type DeleteDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Deletes a dictionary from the database by its ID.\n */\nexport const deleteDictionary = async (\n req: Request<DeleteDictionaryParam>,\n res: ResponseWithInformation<DeleteDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, dictionaryRights } = res.locals;\n const { dictionaryId } = req.params as Partial<DeleteDictionaryParam>;\n\n if (!dictionaryId) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_ID_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!dictionaryRights?.admin) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_RIGHTS_NOT_ADMIN');\n return;\n }\n\n try {\n const dictionaryToDelete =\n await dictionaryService.getDictionaryById(dictionaryId);\n\n if (!dictionaryToDelete.projectIds.includes(project._id)) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'DICTIONARY_PROJECT_MISMATCH'\n );\n return;\n }\n\n const deletedDictionary =\n await dictionaryService.deleteDictionaryById(dictionaryId);\n\n if (!deletedDictionary) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_NOT_FOUND', {\n dictionaryId,\n });\n return;\n }\n\n logger.info(`Dictionary deleted: ${String(deletedDictionary._id)}`);\n\n const apiResult = mapDictionaryToAPI(deletedDictionary, project._id);\n\n const responseData = formatResponse<DictionaryAPI>({\n message: t({\n en: 'Dictionary deleted successfully',\n fr: 'Dictionnaire supprimé avec succès',\n es: 'Diccionario eliminado con éxito',\n }),\n description: t({\n en: 'Your dictionary has been deleted successfully',\n fr: 'Votre dictionnaire a été supprimé avec succès',\n es: 'Su diccionario ha sido eliminado con éxito',\n }),\n data: apiResult,\n });\n\n res.json(responseData);\n\n eventListener.sendDictionaryUpdate([\n {\n dictionary: apiResult,\n status: 'DELETED',\n },\n ]);\n\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAuB;AAEvB,wBAAmC;AACnC,oBAAuC;AACvC,+CAGO;AAEP,wBAAmC;AACnC,0BAKO;AAEP,8BAAkB;AAClB,oBAA+B;AAgBxB,MAAM,kBAAkB,OAC7B,KACA,KACA,UACkB;AAClB,QAAM,EAAE,MAAM,SAAS,iBAAiB,IAAI,IAAI;AAChD,QAAM,EAAE,SAAS,UAAU,MAAM,MAAM,iBAAiB,QACtD,4EAAkC,GAAG;AAEvC,MAAI,CAAC,SAAS;AACZ,+BAAa,2BAA2B,KAAK,qBAAqB;AAClE;AAAA,EACF;AACA,MAAI,CAAC,MAAM;AACT,+BAAa,2BAA2B,KAAK,kBAAkB;AAC/D;AAAA,EACF;AACA,MAAI,CAAC,kBAAkB,MAAM;AAC3B,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,EACF;AAEA,MAAI,CAAC,SAAS;AACZ,+BAAa,2BAA2B,KAAK,qBAAqB;AAClE;AAAA,EACF;AAEA,MAAI,CAAC,kBAAkB,OAAO;AAC5B,+BAAa,2BAA2B,KAAK,6BAA6B;AAC1E;AAAA,EACF;AAEA,MAAI;AACF,UAAM,qBACJ,MAAM,kBAAkB,kBAAkB,YAAY;AAExD,QAAI,CAAC,mBAAmB,WAAW,SAAS,QAAQ,GAAG,GAAG;AACxD,iCAAa;AAAA,QACX;AAAA,QACA;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,oBACJ,MAAM,kBAAkB,qBAAqB,YAAY;AAE3D,QAAI,CAAC,mBAAmB;AACtB,iCAAa,2BAA2B,KAAK,wBAAwB;AAAA,QACnE;AAAA,MACF,CAAC;AACD;AAAA,IACF;AAEA,yBAAO,KAAK,uBAAuB,OAAO,kBAAkB,GAAG,CAAC,EAAE;AAElE,UAAM,gBAAY,sCAAmB,mBAAmB,QAAQ,GAAG;AAEnE,UAAM,mBAAe,oCAA8B;AAAA,MACjD,aAAS,2BAAE;AAAA,QACT,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MACN,CAAC;AAAA,MACD,iBAAa,2BAAE;AAAA,QACb,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MACN,CAAC;AAAA,MACD,MAAM;AAAA,IACR,CAAC;AAED,QAAI,KAAK,YAAY;AAErB,kBAAc,qBAAqB;AAAA,MACjC;AAAA,QACE,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAED;AAAA,EACF,SAAS,OAAO;AACd,+BAAa,uBAAuB,KAAK,KAAiB;AAC1D;AAAA,EACF;AACF;","names":[]}
@@ -28,18 +28,18 @@ const aiRouter = (0, import_express.Router)();
28
28
  const baseURL = `${process.env.BACKEND_URL}/api/ai`;
29
29
  const aiRoutes = {
30
30
  auditContentDeclaration: {
31
- urlModel: "/audit/content-declaration",
32
- url: `${baseURL}/audit/content-declaration`,
31
+ urlModel: "/audit/dictionary",
32
+ url: `${baseURL}/audit/dictionary`,
33
33
  method: "POST"
34
34
  },
35
35
  auditContentDeclarationField: {
36
- urlModel: "/audit/content-declaration/field",
37
- url: `${baseURL}/audit/content-declaration/field`,
36
+ urlModel: "/audit/dictionary/field",
37
+ url: `${baseURL}/audit/dictionary/field`,
38
38
  method: "POST"
39
39
  },
40
40
  auditContentDeclarationMetadata: {
41
- urlModel: "/audit/content-declaration/metadata",
42
- url: `${baseURL}/audit/content-declaration/metadata`,
41
+ urlModel: "/audit/dictionary/metadata",
42
+ url: `${baseURL}/audit/dictionary/metadata`,
43
43
  method: "POST"
44
44
  },
45
45
  auditTag: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/routes/ai.routes.ts"],"sourcesContent":["import {\n askDocQuestion,\n auditContentDeclaration,\n auditContentDeclarationField,\n auditContentDeclarationMetadata,\n auditTag,\n} from '@controllers/ai.controller';\nimport { Router } from 'express';\nimport { Routes } from '@/types/Routes';\n\nexport const aiRouter: Router = Router();\n\nconst baseURL = `${process.env.BACKEND_URL}/api/ai`;\n\nexport const aiRoutes = {\n auditContentDeclaration: {\n urlModel: '/audit/content-declaration',\n url: `${baseURL}/audit/content-declaration`,\n method: 'POST',\n },\n auditContentDeclarationField: {\n urlModel: '/audit/content-declaration/field',\n url: `${baseURL}/audit/content-declaration/field`,\n method: 'POST',\n },\n auditContentDeclarationMetadata: {\n urlModel: '/audit/content-declaration/metadata',\n url: `${baseURL}/audit/content-declaration/metadata`,\n method: 'POST',\n },\n auditTag: {\n urlModel: '/audit/tag',\n url: `${baseURL}/audit/tag`,\n method: 'POST',\n },\n ask: {\n urlModel: '/ask',\n url: `${baseURL}/ask`,\n method: 'POST',\n },\n} satisfies Routes;\n\naiRouter.post(\n aiRoutes.auditContentDeclaration.urlModel,\n auditContentDeclaration\n);\naiRouter.post(\n aiRoutes.auditContentDeclarationField.urlModel,\n auditContentDeclarationField\n);\naiRouter.post(\n aiRoutes.auditContentDeclarationMetadata.urlModel,\n auditContentDeclarationMetadata\n);\naiRouter.post(aiRoutes.ask.urlModel, askDocQuestion);\n\naiRouter.post(aiRoutes.auditTag.urlModel, auditTag);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAMO;AACP,qBAAuB;AAGhB,MAAM,eAAmB,uBAAO;AAEvC,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW;AAEnC,MAAM,WAAW;AAAA,EACtB,yBAAyB;AAAA,IACvB,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,8BAA8B;AAAA,IAC5B,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,iCAAiC;AAAA,IAC/B,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,UAAU;AAAA,IACR,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACH,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AACF;AAEA,SAAS;AAAA,EACP,SAAS,wBAAwB;AAAA,EACjC;AACF;AACA,SAAS;AAAA,EACP,SAAS,6BAA6B;AAAA,EACtC;AACF;AACA,SAAS;AAAA,EACP,SAAS,gCAAgC;AAAA,EACzC;AACF;AACA,SAAS,KAAK,SAAS,IAAI,UAAU,wBAAc;AAEnD,SAAS,KAAK,SAAS,SAAS,UAAU,kBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../../src/routes/ai.routes.ts"],"sourcesContent":["import {\n askDocQuestion,\n auditContentDeclaration,\n auditContentDeclarationField,\n auditContentDeclarationMetadata,\n auditTag,\n} from '@controllers/ai.controller';\nimport { Router } from 'express';\nimport { Routes } from '@/types/Routes';\n\nexport const aiRouter: Router = Router();\n\nconst baseURL = `${process.env.BACKEND_URL}/api/ai`;\n\nexport const aiRoutes = {\n auditContentDeclaration: {\n urlModel: '/audit/dictionary',\n url: `${baseURL}/audit/dictionary`,\n method: 'POST',\n },\n auditContentDeclarationField: {\n urlModel: '/audit/dictionary/field',\n url: `${baseURL}/audit/dictionary/field`,\n method: 'POST',\n },\n auditContentDeclarationMetadata: {\n urlModel: '/audit/dictionary/metadata',\n url: `${baseURL}/audit/dictionary/metadata`,\n method: 'POST',\n },\n auditTag: {\n urlModel: '/audit/tag',\n url: `${baseURL}/audit/tag`,\n method: 'POST',\n },\n ask: {\n urlModel: '/ask',\n url: `${baseURL}/ask`,\n method: 'POST',\n },\n} satisfies Routes;\n\naiRouter.post(\n aiRoutes.auditContentDeclaration.urlModel,\n auditContentDeclaration\n);\naiRouter.post(\n aiRoutes.auditContentDeclarationField.urlModel,\n auditContentDeclarationField\n);\naiRouter.post(\n aiRoutes.auditContentDeclarationMetadata.urlModel,\n auditContentDeclarationMetadata\n);\naiRouter.post(aiRoutes.ask.urlModel, askDocQuestion);\n\naiRouter.post(aiRoutes.auditTag.urlModel, auditTag);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAMO;AACP,qBAAuB;AAGhB,MAAM,eAAmB,uBAAO;AAEvC,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW;AAEnC,MAAM,WAAW;AAAA,EACtB,yBAAyB;AAAA,IACvB,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,8BAA8B;AAAA,IAC5B,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,iCAAiC;AAAA,IAC/B,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,UAAU;AAAA,IACR,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACH,UAAU;AAAA,IACV,KAAK,GAAG,OAAO;AAAA,IACf,QAAQ;AAAA,EACV;AACF;AAEA,SAAS;AAAA,EACP,SAAS,wBAAwB;AAAA,EACjC;AACF;AACA,SAAS;AAAA,EACP,SAAS,6BAA6B;AAAA,EACtC;AACF;AACA,SAAS;AAAA,EACP,SAAS,gCAAgC;AAAA,EACzC;AACF;AACA,SAAS,KAAK,SAAS,IAAI,UAAU,wBAAc;AAEnD,SAAS,KAAK,SAAS,SAAS,UAAU,kBAAQ;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/dictionary.types.ts"],"sourcesContent":["import type { DictionaryValue } from '@intlayer/core';\nimport type { Model, ObjectId, Document } from 'mongoose';\nimport type { Project } from './project.types';\nimport type { User } from './user.types';\n\nexport type DictionaryCreationData = {\n projectIds: (Project['_id'] | string)[];\n key: string;\n content?: DictionaryValue;\n title?: string;\n description?: string;\n tags?: string[];\n filePath?: string;\n};\n\nexport type VersionedContentEl = {\n name?: string;\n description?: string;\n content: DictionaryValue;\n};\n\nexport type ContentVersion = string;\nexport type VersionedContent = Record<string, VersionedContentEl>;\n\nexport type DictionaryData = {\n key: string;\n content: VersionedContent;\n projectIds: (Project['_id'] | string)[];\n creatorId: User['_id'];\n title?: string;\n description?: string;\n tags?: string[];\n filePath?: Record<string, string>;\n publishedVersion?: string | null;\n};\n\nexport type Dictionary = DictionaryData & {\n _id: ObjectId;\n createdAt: number;\n updatedAt: number;\n availableVersions?: string[];\n};\n\nexport type DictionaryAPI = Omit<Dictionary, 'filePath' | 'content'> & {\n content: DictionaryValue;\n filePath?: string;\n availableVersions?: string[];\n};\n\nexport type DictionaryDocument = Document<unknown, {}, Dictionary> & Dictionary;\nexport type DictionaryModelType = Model<Dictionary>;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/types/dictionary.types.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/core';\nimport type { Model, ObjectId, Document } from 'mongoose';\nimport type { Project } from './project.types';\nimport type { User } from './user.types';\nimport type { Dictionary as DictionaryCore } from '@intlayer/core';\n\nexport type DictionaryCreationData = {\n projectIds: (Project['_id'] | string)[];\n key: string;\n content?: ContentNode;\n title?: string;\n description?: string;\n tags?: string[];\n filePath?: string;\n};\n\nexport type VersionedContentEl = {\n name?: string;\n description?: string;\n content: ContentNode;\n};\n\nexport type ContentVersion = string;\nexport type VersionedContent = Record<string, VersionedContentEl>;\n\nexport type DictionaryData = {\n key: string;\n content: VersionedContent;\n projectIds: (Project['_id'] | string)[];\n creatorId: User['_id'];\n title?: string;\n description?: string;\n tags?: string[];\n filePath?: Record<string, string>;\n publishedVersion?: string | null;\n};\n\nexport type Dictionary = DictionaryData & {\n _id: ObjectId;\n createdAt: number;\n updatedAt: number;\n availableVersions?: string[];\n};\n\nexport type DictionaryAPI = DictionaryCore & {\n projectIds: (Project['_id'] | string)[];\n};\n\nexport type DictionaryDocument = Document<unknown, {}, Dictionary> & Dictionary;\nexport type DictionaryModelType = Model<Dictionary>;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -76820,7 +76820,7 @@
76820
76820
  -0.010884557, 0.006415053, 0.007872337, 0.0014629175, -0.021603854,
76821
76821
  0.01547425
76822
76822
  ],
76823
- "content_declaration__translation/chunk_1": [
76823
+ "dictionary__translation/chunk_1": [
76824
76824
  -0.035585314, 0.022626579, -0.012719769, -0.0019629274, -0.03520297,
76825
76825
  -0.043286815, -0.024046713, 0.028703118, -0.02146589, -0.005376714,
76826
76826
  0.0014756093, 0.054757137, -0.038234413, -0.00072201586, -0.012330597,
@@ -77434,7 +77434,7 @@
77434
77434
  -0.014802179, -0.0017615139, -0.0020277894, 0.0034308557, 0.008138468,
77435
77435
  -0.005953644, 0.0033864763, -0.008971431, -0.020195963, 0.0109446
77436
77436
  ],
77437
- "content_declaration__translation/chunk_2": [
77437
+ "dictionary__translation/chunk_2": [
77438
77438
  -0.033458933, 0.019589443, -0.025920263, 0.011523201, -0.024948426,
77439
77439
  -0.02479571, -0.017090434, 0.02290757, -0.02628123, -0.011773102,
77440
77440
  0.029099554, 0.027489083, -0.019811576, -0.015396663, -0.018103922,
@@ -78048,7 +78048,7 @@
78048
78048
  -0.0013059049, 0.0049876026, 0.020353029, 0.006441886, -0.010183455,
78049
78049
  -0.02024196, -0.0007952571
78050
78050
  ],
78051
- "content_declaration__translation/chunk_3": [
78051
+ "dictionary__translation/chunk_3": [
78052
78052
  -0.01701237, -0.004796956, -0.020439886, -0.0077079968, -0.036654066,
78053
78053
  -0.014907343, -0.013991774, 0.029486021, -0.026606282, -0.024869049,
78054
78054
  0.04920597, -0.005364296, -0.018624397, 0.00041963585, -0.0006680916,
@@ -78662,7 +78662,7 @@
78662
78662
  -0.0024082598, 0.0024395613, -0.009194818, 0.014156108, 0.0049456386,
78663
78663
  0.013154459, -0.0057125255, -0.022677943, 0.010900751
78664
78664
  ],
78665
- "content_declaration__translation/chunk_4": [
78665
+ "dictionary__translation/chunk_4": [
78666
78666
  -0.02320181, 0.009202499, -0.029504083, -0.011999409, -0.028957983,
78667
78667
  -0.0295336, -0.003009077, 0.039968513, -0.04354029, -0.032824952,
78668
78668
  0.055170715, 0.006294893, -0.028515201, 0.007615861, 0.014397815,
@@ -79276,7 +79276,7 @@
79276
79276
  0.010678441, 0.0006120547, -0.0013292703, -0.0068926495, 0.009224638,
79277
79277
  0.005224835, 0.0043724785, -0.009888812, 0.009121322
79278
79278
  ],
79279
- "content_declaration__enumeration/chunk_1": [
79279
+ "dictionary__enumeration/chunk_1": [
79280
79280
  -0.03541259, 0.008890661, -0.021472635, -0.031511206, -0.016040703,
79281
79281
  -0.016130736, -0.022192892, 0.031631246, -0.006204706, -0.024398675,
79282
79282
  -0.0011366542, 0.034752358, -0.010563756, -0.005739541, -0.00826794,
@@ -79891,7 +79891,7 @@
79891
79891
  0.014390117, -0.014817769, -0.005113068, -0.017646275, -0.015192903,
79892
79892
  0.0030066941, -0.02348335, -0.005244365, 0.012837064
79893
79893
  ],
79894
- "content_declaration__enumeration/chunk_2": [
79894
+ "dictionary__enumeration/chunk_2": [
79895
79895
  -0.04526628, -0.016461847, -0.019912299, -0.034504518, -0.00026885406,
79896
79896
  -0.0077445162, -0.0045030676, 0.04189183, 0.0152838295, -0.012319786,
79897
79897
  0.008580529, 0.016963456, -0.019684296, 0.002929844, -0.022192333,
@@ -80506,7 +80506,7 @@
80506
80506
  0.028242026, -0.0020235304, -0.025992392, -0.004921074, -0.022937145,
80507
80507
  0.00047595715, -0.025019577, -0.010921365, 0.019745097
80508
80508
  ],
80509
- "content_declaration__enumeration/chunk_3": [
80509
+ "dictionary__enumeration/chunk_3": [
80510
80510
  -0.049809452, 0.0024406952, -0.021918086, -0.020649567, 0.015366746,
80511
80511
  0.00043705708, -0.01930076, 0.068082556, -0.022480087, 0.010734242,
80512
80512
  0.038697865, 0.0013718875, 0.008967949, -0.0077395733, 0.000297811,
@@ -81122,7 +81122,7 @@
81122
81122
  -0.0029866402, -0.016017063, 0.0103568975, -0.003913944, -0.008454119,
81123
81123
  0.0069326987
81124
81124
  ],
81125
- "content_declaration__function_fetching/chunk_1": [
81125
+ "dictionary__function_fetching/chunk_1": [
81126
81126
  -0.03926087, -0.005307591, -0.022329448, 0.0021981637, -0.028687427,
81127
81127
  -0.048804797, -0.025209319, 0.031775985, -0.040373866, -0.00069736043,
81128
81128
  0.041292086, 0.0218286, -0.023275493, -0.015915819, -0.016235804,
@@ -81736,7 +81736,7 @@
81736
81736
  0.025000634, -0.010176941, 0.010622139, -0.025348444, -0.003679837,
81737
81737
  0.010009992, -0.00069301284, -0.011192548, 0.003191163
81738
81738
  ],
81739
- "content_declaration__function_fetching/chunk_2": [
81739
+ "dictionary__function_fetching/chunk_2": [
81740
81740
  -0.029421065, -0.018218735, -0.02240466, -0.00041838476, -0.024504267,
81741
81741
  -0.04565979, -0.03941413, 0.018736992, -0.021939557, 0.014272007,
81742
81742
  0.04510167, 0.033088733, -0.033035576, -0.028225087, -0.0034949144,
@@ -82350,7 +82350,7 @@
82350
82350
  -0.024211915, 0.017753633, -0.012152468, 0.0036842774, -0.006963251,
82351
82351
  -0.009474806, 0.009501383, -0.013122539, -0.020132301, 0.0020148912
82352
82352
  ],
82353
- "content_declaration__function_fetching/chunk_3": [
82353
+ "dictionary__function_fetching/chunk_3": [
82354
82354
  -0.018097907, -0.0018465432, -0.016956083, 0.0064156223, -0.009598456,
82355
82355
  -0.03862219, -0.041162748, 0.024435028, -0.01480089, 0.0022889997,
82356
82356
  0.028302956, 0.033483982, -0.023821298, -0.03545363, 0.00013525705,
@@ -82964,7 +82964,7 @@
82964
82964
  -0.016442262, 0.0019625097, -0.01163233, -0.011803603, 0.021980107,
82965
82965
  -0.023807026, 0.0031096856, -0.019739278, -0.012188968, 0.007268422
82966
82966
  ],
82967
- "content_declaration__function_fetching/chunk_4": [
82967
+ "dictionary__function_fetching/chunk_4": [
82968
82968
  -0.023653839, -0.0040136916, -0.018928599, 0.015350126, -0.01552974,
82969
82969
  -0.049297255, -0.04277587, 0.03271746, -0.022092575, 0.009934059,
82970
82970
  0.015598822, 0.03901778, -0.024261765, -0.032496396, -0.00575457,
@@ -83579,7 +83579,7 @@
83579
83579
  -0.0064937524, -0.008752749, 0.014534952, -0.022520887, 0.002901464,
83580
83580
  -0.014838915, -0.008469511, 0.005778749
83581
83581
  ],
83582
- "content_declaration__get_started/chunk_1": [
83582
+ "dictionary__get_started/chunk_1": [
83583
83583
  -0.006331044, 0.02141218, -0.01124898, -0.017947271, -0.031854812,
83584
83584
  -0.029523581, 0.01068214, 0.048189383, -0.009931675, -0.0037403456,
83585
83585
  0.031774975, 0.020230599, 0.014594134, 0.00035602142, -0.013189009,
@@ -84193,7 +84193,7 @@
84193
84193
  -0.00048101562, 0.0064827334, -0.013676013, 0.0005149462, -0.0022334293,
84194
84194
  0.0060316566, -0.008223171, -0.0032194117, -0.0009844853
84195
84195
  ],
84196
- "content_declaration__get_started/chunk_2": [
84196
+ "dictionary__get_started/chunk_2": [
84197
84197
  -0.008704719, 0.021959633, -0.023113666, -0.0049788356, -0.019849397,
84198
84198
  -0.026064698, 0.015752574, 0.04589761, -0.041149583, -0.03223054,
84199
84199
  -0.0006094746, 0.011952503, -0.021530991, 0.030647865, 0.014062737,
@@ -84807,7 +84807,7 @@
84807
84807
  0.0061658425, 0.009413626, -0.00010503519, -0.009207549, -0.006726374,
84808
84808
  0.021629907, 0.0038103755, -0.015299203, -0.012587221, 0.0059762513
84809
84809
  ],
84810
- "content_declaration__get_started/chunk_3": [
84810
+ "dictionary__get_started/chunk_3": [
84811
84811
  -0.0080253035, 0.015812272, -0.019247578, -0.0046804, -0.008637577,
84812
84812
  -0.038725276, 0.011374316, 0.046088994, -0.05368283, -0.042867366,
84813
84813
  0.009804595, 0.013650823, -0.030473964, 0.020891266, -0.000042889966,
@@ -85422,7 +85422,7 @@
85422
85422
  0.0048858607, 0.0036633683, -0.0058063255, -0.008514301, -0.0097552845,
85423
85423
  0.0132399015, 0.0015758852, -0.016313598, -0.005370748, 0.0093772365
85424
85424
  ],
85425
- "content_declaration__content_extention_customization/chunk_1": [
85425
+ "dictionary__content_extention_customization/chunk_1": [
85426
85426
  -0.012471239, 0.012775585, -0.021677684, 0.013488029, 0.0043230862,
85427
85427
  -0.008909016, -0.0015640926, 0.041722972, 0.009745966, -0.0040637013,
85428
85428
  0.040145908, -0.007968313, 0.00415708, -0.026450371, -0.020570973,
@@ -86037,7 +86037,7 @@
86037
86037
  0.012609578, -0.0048487736, -0.0024226576, -0.014497902, 0.009282531,
86038
86038
  -0.0064984635, 0.017735029, -0.0029621788
86039
86039
  ],
86040
- "content_declaration__content_extention_customization/chunk_2": [
86040
+ "dictionary__content_extention_customization/chunk_2": [
86041
86041
  -0.01493925, 0.008009436, -0.023238834, 0.008400798, 0.0069770482,
86042
86042
  0.0051012076, -0.010033725, 0.044723287, -0.0073751584, 0.007112001,
86043
86043
  0.026707117, -0.0077192876, -0.006346145, -0.027638288, -0.014480412,
@@ -1,6 +1,6 @@
1
1
  ```tsx
2
2
  import React from "react";
3
- import { t, enu, type DeclarationContent } from "intlayer";
3
+ import { t, enu, type Dictionary } from "intlayer";
4
4
 
5
5
  export default {
6
6
  key: "my-key",
@@ -11,7 +11,7 @@ You are an expert in internationalization, copy writing and content management.
11
11
  - Default locale: {{defaultLocale}}
12
12
  - Required Locales: {{otherLocales}} (add the missing locales in `t({ ... })` function)
13
13
 
14
- 3. **Content Declaration Format:**
14
+ 3. **Dictionary Format:**
15
15
 
16
16
  - Example format:
17
17
 
@@ -42,7 +42,7 @@ You are an expert in internationalization, copy writing and content management.
42
42
  - **Input File:**
43
43
 
44
44
  ```typescript
45
- import { t, type DeclarationContent } from "intlayer";
45
+ import { t, type Dictionary } from "intlayer";
46
46
 
47
47
  export default {
48
48
  key: "creative-work-structured-data",
@@ -53,13 +53,13 @@ You are an expert in internationalization, copy writing and content management.
53
53
  es: "Desarrolladores, Gestores de Contenido",
54
54
  }),
55
55
  },
56
- } satisfies DeclarationContent;
56
+ } satisfies Dictionary;
57
57
  ```
58
58
 
59
59
  - **Expected Output (No Changes Needed):**
60
60
 
61
61
  ```typescript
62
- import { t, type DeclarationContent } from "intlayer";
62
+ import { t, type Dictionary } from "intlayer";
63
63
 
64
64
  export default {
65
65
  key: "creative-work-structured-data",
@@ -70,13 +70,13 @@ You are an expert in internationalization, copy writing and content management.
70
70
  es: "Desarrolladores, Gestores de Contenido",
71
71
  }),
72
72
  },
73
- } satisfies DeclarationContent;
73
+ } satisfies Dictionary;
74
74
  ```
75
75
 
76
76
  - **Incorrect Output (Unwanted Structural Change):**
77
77
 
78
78
  ```typescript
79
- import { t, type DeclarationContent } from "intlayer";
79
+ import { t, type Dictionary } from "intlayer";
80
80
 
81
81
  export default {
82
82
  key: "creative-work-structured-data",
@@ -93,7 +93,7 @@ You are an expert in internationalization, copy writing and content management.
93
93
  es: "Este proyecto involucra datos estructurados para trabajo creativo.",
94
94
  }),
95
95
  },
96
- } satisfies DeclarationContent;
96
+ } satisfies Dictionary;
97
97
  ```
98
98
 
99
99
  - **Clarification:** In this scenario, since the input file is already valid and complete, the expected output should be identical to the input without any additional fields or comments.
@@ -119,7 +119,7 @@ You are an expert in internationalization, copy writing and content management.
119
119
  - **Expected Output (No Changes Needed):**
120
120
 
121
121
  ```typescript
122
- import { t, type DeclarationContent } from "intlayer";
122
+ import { t, type Dictionary } from "intlayer";
123
123
 
124
124
  const content = {
125
125
  key: "creative-work-structured-data",
@@ -130,13 +130,13 @@ You are an expert in internationalization, copy writing and content management.
130
130
  es: "Desarrolladores, Gestores de Contenido",
131
131
  }),
132
132
  },
133
- } satisfies DeclarationContent;
133
+ } satisfies Dictionary;
134
134
  ```
135
135
 
136
136
  - **Clarification:** In this scenario:
137
137
  - A missing translation for the `audienceType` key was added.
138
138
  - The import of the `t` function was imported from `react-intlayer` instead of `intlayer`.
139
- - A type `DeclarationContent` was added to the file to strengthen the content declaration.
139
+ - A type `Dictionary` was added to the file to strengthen the content declaration.
140
140
 
141
141
  **Tags Instructions:**
142
142
 
@@ -1,6 +1,6 @@
1
1
  ```tsx
2
2
  import React, { type ReactNode } from "react";
3
- import { t, enu, type DeclarationContent } from "intlayer";
3
+ import { t, enu, type Dictionary } from "intlayer";
4
4
 
5
5
  export default {
6
6
  key: "my-key",
@@ -24,5 +24,5 @@ export default {
24
24
  ">19": "Many cars",
25
25
  }),
26
26
  },
27
- } satisfies DeclarationContent;
27
+ } satisfies Dictionary;
28
28
  ```
@@ -1,5 +1,5 @@
1
1
  ```typescript
2
- import { t, enu, type DeclarationContent } from "intlayer";
2
+ import { t, enu, type Dictionary } from "intlayer";
3
3
 
4
4
  export default {
5
5
  key: "my-key",
@@ -18,5 +18,5 @@ export default {
18
18
  ">19": "Many cars",
19
19
  }),
20
20
  },
21
- } satisfies DeclarationContent;
21
+ } satisfies Dictionary;
22
22
  ```
@@ -4,7 +4,7 @@ You are an expert in internationalization, copy writing and content management.
4
4
 
5
5
  1. **Terminology:**
6
6
 
7
- - **Content Declaration:** A content declaration is a is a file (.ts, .js or .json) that contains the multilingual declaration related to a specific content. A content declaration file is usually related to a specific component, or page or section of a website.
7
+ - **Dictionary:** A content declaration is a is a file (.ts, .js or .json) that contains the multilingual declaration related to a specific content. A content declaration file is usually related to a specific component, or page or section of a website.
8
8
  - **Tag:** A tag is attached to a content declaration and is used to group content declaration and harmonize them.
9
9
  - **KeyPath** The KeyPath correspond to to the path to retrieve the targeted element from the `content` key of the content declaration file.
10
10
 
@@ -33,7 +33,7 @@ You are an expert in internationalization, copy writing and content management.
33
33
  - **Input File:**
34
34
 
35
35
  ```typescript
36
- import { t, type DeclarationContent } from "intlayer";
36
+ import { t, type Dictionary } from "intlayer";
37
37
 
38
38
  export default {
39
39
  key: "creative-work-structured-data",
@@ -44,7 +44,7 @@ You are an expert in internationalization, copy writing and content management.
44
44
  es: "",
45
45
  }),
46
46
  },
47
- } satisfies DeclarationContent;
47
+ } satisfies Dictionary;
48
48
  ```
49
49
 
50
50
  - **Input keyPath:**
@@ -60,7 +60,7 @@ You are an expert in internationalization, copy writing and content management.
60
60
  - **Input File:**
61
61
 
62
62
  ```typescript
63
- import { t, enu, type DeclarationContent } from "intlayer";
63
+ import { t, enu, type Dictionary } from "intlayer";
64
64
 
65
65
  const content = {
66
66
  key: "creative-work-structured-data",
@@ -87,7 +87,7 @@ You are an expert in internationalization, copy writing and content management.
87
87
  }),
88
88
  },
89
89
  },
90
- } satisfies DeclarationContent;
90
+ } satisfies Dictionary;
91
91
  ```
92
92
 
93
93
  - **Input target:**
@@ -2,7 +2,7 @@ Your role is to review content declaration fields. Correct this fields if they a
2
2
 
3
3
  1. **Terminology:**
4
4
 
5
- - **Content Declaration:** A content declaration is a is a file (.ts, .js or .json) that contains the multilingual declaration related to a specific content. A content declaration file is usually related to a specific component, or page or section of a website.
5
+ - **Dictionary:** A content declaration is a is a file (.ts, .js or .json) that contains the multilingual declaration related to a specific content. A content declaration file is usually related to a specific component, or page or section of a website.
6
6
  - **Tag:** A tag is attached to a content declaration and is used to group content declaration and harmonize them.
7
7
 
8
8
  2. **Audit Requirements:**
@@ -25,7 +25,7 @@ After completion, provide only the final title, description and tags fields in a
25
25
  - Entry:
26
26
 
27
27
  ```ts
28
- import { t, type DeclarationContent } from "intlayer";
28
+ import { t, type Dictionary } from "intlayer";
29
29
  import { Metadata } from "next";
30
30
 
31
31
  const metadataContent = {
@@ -50,7 +50,7 @@ const metadataContent = {
50
50
  es: ["Precios", "Suscripción"],
51
51
  }),
52
52
  },
53
- } satisfies DeclarationContent<Metadata>;
53
+ } satisfies Dictionary<Metadata>;
54
54
 
55
55
  export default metadataContent;
56
56
  ```
@@ -71,6 +71,6 @@ Here the list of existing tags as a context to help you to pick related ones.
71
71
 
72
72
  {{tags}}
73
73
 
74
- **Content Declaration to complete:**
74
+ **Dictionary to complete:**
75
75
 
76
76
  {{contentDeclaration}}
@@ -7,7 +7,7 @@ Your role is to review a tag. A tag is attached to a content declaration and is
7
7
  "key": "page-metadata",
8
8
  "name": "Page metadata",
9
9
  "description": "Contain all metadata related to the page, such as title, description, keywords, etc for SEO purpose. It will help search engines understand the content of the page.",
10
- "instructions": "## Metadata Tag//## Content Declaration structure//A content declaration containing this tag should a least includes the following fields://- title/- description/- keywords//### Example of structure//```json/{/ \"key\": \"...\",/ \"content\": {/ \"title\": \"...\",/ \"description\": \"...\",/ \"keywords\": [\"...\", \"...\", \"...\"]/ }/}/```//## Fields instructions//### 1. **Title Tag**//#### **Purpose**//The title tag defines the title of your webpage. It's displayed on search engine results pages (SERPs) as the clickable headline and is essential for both SEO and user experience.//#### **Best Practices**//- **Length:** Aim for **50-60 characters**. Search engines typically display the first 50-60 characters of a title tag. Titles longer than this may be truncated./- **Keywords:** Include primary keywords relevant to the page content, preferably toward the beginning./- **Clarity and Relevance:** Ensure the title accurately reflects the content of the page./- **Branding:** If appropriate, include your brand name at the end of the title (e.g., \"How to Bake a Cake | YourBrand\")./- **Uniqueness:** Each page on your website should have a unique title to avoid confusion and duplication issues.//### 2. **Meta Description**//#### **Purpose**//The meta description provides a brief summary of the webpage's content. While not a direct ranking factor, a compelling meta description can improve click-through rates (CTR) from SERPs.//#### **Best Practices**//- **Length:** Keep it between **150-160 characters**. Descriptions longer than this may be cut off in search results./- **Engaging and Inviting:** Write a clear, concise, and enticing summary that encourages users to click./- **Include Keywords:** Incorporate relevant keywords naturally, as they may be bolded in SERPs when they match the search query./- **Call to Action (CTA):** Use action-oriented language (e.g., \"Learn more,\" \"Discover,\" \"Get started\")./- **Unique Descriptions:** Ensure each page has a unique meta description to differentiate it from others.//### 3. **Meta Keywords**//#### **Purpose**//Historically used to list important keywords for a webpage. However, most modern search engines no longer use meta keywords for ranking.//#### **Best Practices**//- **Page Related Keywords:** The provided keywords should be relevant to the content of the page./- **Uniqueness:** Each page on your website should have a unique set of keywords to avoid confusion and duplication issues./- **Keyword number:** The number of keywords should be between 3-10."
10
+ "instructions": "## Metadata Tag//## Dictionary structure//A content declaration containing this tag should a least includes the following fields://- title/- description/- keywords//### Example of structure//```json/{/ \"key\": \"...\",/ \"content\": {/ \"title\": \"...\",/ \"description\": \"...\",/ \"keywords\": [\"...\", \"...\", \"...\"]/ }/}/```//## Fields instructions//### 1. **Title Tag**//#### **Purpose**//The title tag defines the title of your webpage. It's displayed on search engine results pages (SERPs) as the clickable headline and is essential for both SEO and user experience.//#### **Best Practices**//- **Length:** Aim for **50-60 characters**. Search engines typically display the first 50-60 characters of a title tag. Titles longer than this may be truncated./- **Keywords:** Include primary keywords relevant to the page content, preferably toward the beginning./- **Clarity and Relevance:** Ensure the title accurately reflects the content of the page./- **Branding:** If appropriate, include your brand name at the end of the title (e.g., \"How to Bake a Cake | YourBrand\")./- **Uniqueness:** Each page on your website should have a unique title to avoid confusion and duplication issues.//### 2. **Meta Description**//#### **Purpose**//The meta description provides a brief summary of the webpage's content. While not a direct ranking factor, a compelling meta description can improve click-through rates (CTR) from SERPs.//#### **Best Practices**//- **Length:** Keep it between **150-160 characters**. Descriptions longer than this may be cut off in search results./- **Engaging and Inviting:** Write a clear, concise, and enticing summary that encourages users to click./- **Include Keywords:** Incorporate relevant keywords naturally, as they may be bolded in SERPs when they match the search query./- **Call to Action (CTA):** Use action-oriented language (e.g., \"Learn more,\" \"Discover,\" \"Get started\")./- **Unique Descriptions:** Ensure each page has a unique meta description to differentiate it from others.//### 3. **Meta Keywords**//#### **Purpose**//Historically used to list important keywords for a webpage. However, most modern search engines no longer use meta keywords for ranking.//#### **Best Practices**//- **Page Related Keywords:** The provided keywords should be relevant to the content of the page./- **Uniqueness:** Each page on your website should have a unique set of keywords to avoid confusion and duplication issues./- **Keyword number:** The number of keywords should be between 3-10."
11
11
  }
12
12
  ````
13
13
 
@@ -25,7 +25,7 @@ Your role is to review a tag. A tag is attached to a content declaration and is
25
25
 
26
26
  {{tag}}
27
27
 
28
- **Content Declaration that attach the tag into:**
28
+ **Dictionary that attach the tag into:**
29
29
 
30
30
  {{contentDeclarations}}
31
31
 
@@ -30,7 +30,7 @@ const mapDictionaryToAPI = (dictionary, projectId, version) => {
30
30
  const lastVersion = versionList[versionList.length - 1];
31
31
  returnedVersion = lastVersion;
32
32
  }
33
- const content = dictionaryObject.content[returnedVersion]?.content;
33
+ const content = dictionaryObject.content[returnedVersion].content;
34
34
  return {
35
35
  ...dictionaryObject,
36
36
  content,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/mapper/dictionary.ts"],"sourcesContent":["import { ensureMongoDocumentToObject } from '@utils/ensureMongoDocumentToObject';\nimport { Dictionary, DictionaryAPI } from '@/types/dictionary.types';\nimport { Project } from '@/types/project.types';\n\n/**\n * Maps a dictionary to an API response.\n * If the version is not provided, the latest version is used.\n *\n * @param dictionary - The dictionary to map.\n * @param projectId - The ID of the project the dictionary belongs to.\n * @returns The dictionary mapped to an API response.\n */\nexport const mapDictionaryToAPI = (\n dictionary: Dictionary,\n projectId: string | Project['_id'],\n version?: string\n): DictionaryAPI => {\n const dictionaryObject = ensureMongoDocumentToObject<Dictionary>(dictionary);\n\n let returnedVersion = version;\n\n if (!returnedVersion) {\n const versionList = dictionaryObject.availableVersions ?? [];\n const lastVersion = versionList[versionList.length - 1];\n returnedVersion = lastVersion;\n }\n\n const content = dictionaryObject.content[returnedVersion]?.content;\n\n return {\n ...dictionaryObject,\n content,\n filePath: dictionaryObject.filePath?.[String(projectId)],\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAA4C;AAYrC,MAAM,qBAAqB,CAChC,YACA,WACA,YACkB;AAClB,QAAM,uBAAmB,gEAAwC,UAAU;AAE3E,MAAI,kBAAkB;AAEtB,MAAI,CAAC,iBAAiB;AACpB,UAAM,cAAc,iBAAiB,qBAAqB,CAAC;AAC3D,UAAM,cAAc,YAAY,YAAY,SAAS,CAAC;AACtD,sBAAkB;AAAA,EACpB;AAEA,QAAM,UAAU,iBAAiB,QAAQ,eAAe,GAAG;AAE3D,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA,UAAU,iBAAiB,WAAW,OAAO,SAAS,CAAC;AAAA,EACzD;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/mapper/dictionary.ts"],"sourcesContent":["import { ensureMongoDocumentToObject } from '@utils/ensureMongoDocumentToObject';\nimport { Dictionary, DictionaryAPI } from '@/types/dictionary.types';\nimport { Project } from '@/types/project.types';\n\n/**\n * Maps a dictionary to an API response.\n * If the version is not provided, the latest version is used.\n *\n * @param dictionary - The dictionary to map.\n * @param projectId - The ID of the project the dictionary belongs to.\n * @returns The dictionary mapped to an API response.\n */\nexport const mapDictionaryToAPI = (\n dictionary: Dictionary,\n projectId: string | Project['_id'],\n version?: string\n): DictionaryAPI => {\n const dictionaryObject = ensureMongoDocumentToObject<Dictionary>(dictionary);\n\n let returnedVersion = version;\n\n if (!returnedVersion) {\n const versionList = dictionaryObject.availableVersions ?? [];\n const lastVersion = versionList[versionList.length - 1];\n returnedVersion = lastVersion;\n }\n\n const content =\n dictionaryObject.content[\n returnedVersion as keyof typeof dictionaryObject.content\n ].content;\n\n return {\n ...dictionaryObject,\n content,\n filePath: dictionaryObject.filePath?.[String(projectId)],\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAA4C;AAYrC,MAAM,qBAAqB,CAChC,YACA,WACA,YACkB;AAClB,QAAM,uBAAmB,gEAAwC,UAAU;AAE3E,MAAI,kBAAkB;AAEtB,MAAI,CAAC,iBAAiB;AACpB,UAAM,cAAc,iBAAiB,qBAAqB,CAAC;AAC3D,UAAM,cAAc,YAAY,YAAY,SAAS,CAAC;AACtD,sBAAkB;AAAA,EACpB;AAEA,QAAM,UACJ,iBAAiB,QACf,eACF,EAAE;AAEJ,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA,UAAU,iBAAiB,WAAW,OAAO,SAAS,CAAC;AAAA,EACzD;AACF;","names":[]}
@@ -222,7 +222,7 @@ const pushDictionaries = async (req, res, _next) => {
222
222
  const updatedDictionariesResult = [];
223
223
  const errorResult = [];
224
224
  for (const dictionaryDataEl of newDictionaries) {
225
- const publishedVersion = dictionaryDataEl.publishedVersion ? dictionaryDataEl.publishedVersion === "-1" ? null : dictionaryDataEl.publishedVersion : null;
225
+ const publishedVersion = dictionaryDataEl.version ? dictionaryDataEl.version === "-1" ? null : dictionaryDataEl.version : null;
226
226
  const dictionary = {
227
227
  title: dictionaryDataEl.title,
228
228
  description: dictionaryDataEl.description,
@@ -273,7 +273,7 @@ const pushDictionaries = async (req, res, _next) => {
273
273
  }
274
274
  };
275
275
  }
276
- const publishedVersion = dictionaryDataEl.publishedVersion ? dictionaryDataEl.publishedVersion === "-1" ? null : dictionaryDataEl.publishedVersion : null;
276
+ const publishedVersion = dictionaryDataEl.version ? dictionaryDataEl.version === "-1" ? null : dictionaryDataEl.version : null;
277
277
  const dictionary = {
278
278
  ...existingDictionaryDB,
279
279
  ...dictionaryDataEl,