From 38950a0287ad0e54973a6638f8b06dc6b21569ca Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Sun, 22 Sep 2024 08:55:15 +0100 Subject: [PATCH] feat: restructure i18n into a dir --- api/src/app.module.ts | 4 ++-- api/src/app.service.ts | 4 ++-- api/src/chat/controllers/block.controller.spec.ts | 4 ++-- .../chat/controllers/category.contoller.spec.ts | 4 ++-- .../chat/controllers/message.controller.spec.ts | 4 ++-- .../controllers/translation.controller.spec.ts | 4 ++-- api/src/chat/services/block.service.spec.ts | 4 ++-- api/src/chat/services/block.service.ts | 4 ++-- api/src/chat/services/bot.service.spec.ts | 4 ++-- api/src/chat/services/translation.service.ts | 4 ++-- .../channels/live-chat-tester/index.channel.ts | 4 ++-- .../channels/offline/__test__/index.spec.ts | 4 ++-- .../channels/offline/__test__/wrapper.spec.ts | 4 ++-- .../extensions/channels/offline/index.channel.ts | 4 ++-- .../i18n.module.ts} | 14 +++++++------- .../services/i18n.service.ts} | 15 ++++++++++----- .../nlp/controllers/nlp-sample.controller.spec.ts | 4 ++-- .../controllers/setting.controller.spec.ts | 4 ++-- .../setting/repositories/setting.repository.ts | 4 ++-- api/src/setting/services/setting.service.spec.ts | 4 ++-- api/src/user/controllers/auth.controller.spec.ts | 4 ++-- api/src/user/controllers/user.controller.spec.ts | 4 ++-- api/src/user/services/invitation.service.spec.ts | 4 ++-- api/src/user/services/invitation.service.ts | 4 ++-- .../user/services/passwordReset.service.spec.ts | 4 ++-- api/src/user/services/passwordReset.service.ts | 4 ++-- .../services/validate-account.service.spec.ts | 4 ++-- api/src/user/services/validate-account.service.ts | 4 ++-- 28 files changed, 69 insertions(+), 64 deletions(-) rename api/src/{extended-18n.module.ts => i18n/i18n.module.ts} (83%) rename api/src/{extended-i18n.service.ts => i18n/services/i18n.service.ts} (90%) diff --git a/api/src/app.module.ts b/api/src/app.module.ts index 53f6ef0..aa5c861 100644 --- a/api/src/app.module.ts +++ b/api/src/app.module.ts @@ -32,7 +32,7 @@ import { ChannelModule } from './channel/channel.module'; import { ChatModule } from './chat/chat.module'; import { CmsModule } from './cms/cms.module'; import { config } from './config'; -import { ExtendedI18nModule } from './extended-18n.module'; +import { I18nModule } from './i18n/i18n.module'; import { LoggerModule } from './logger/logger.module'; import { DtoUpdateMiddleware } from './middlewares/dto.update.middleware'; import { NlpModule } from './nlp/nlp.module'; @@ -120,7 +120,7 @@ const i18nOptions: I18nOptions = { ignoreErrors: false, }), CsrfModule, - ExtendedI18nModule.forRoot(i18nOptions), + I18nModule.forRoot(i18nOptions), CacheModule.register({ isGlobal: true, ttl: config.cache.ttl, diff --git a/api/src/app.service.ts b/api/src/app.service.ts index a78e0d3..a81eaa2 100644 --- a/api/src/app.service.ts +++ b/api/src/app.service.ts @@ -9,11 +9,11 @@ import { Injectable } from '@nestjs/common'; -import { ExtendedI18nService } from './extended-i18n.service'; +import { I18nService } from './i18n/services/i18n.service'; @Injectable() export class AppService { - constructor(private readonly i18n: ExtendedI18nService) {} + constructor(private readonly i18n: I18nService) {} getHello(): string { return this.i18n.t('welcome', { lang: 'en' }); diff --git a/api/src/chat/controllers/block.controller.spec.ts b/api/src/chat/controllers/block.controller.spec.ts index 2659039..08ad35f 100644 --- a/api/src/chat/controllers/block.controller.spec.ts +++ b/api/src/chat/controllers/block.controller.spec.ts @@ -19,7 +19,7 @@ import { AttachmentService } from '@/attachment/services/attachment.service'; import { ContentRepository } from '@/cms/repositories/content.repository'; import { ContentModel } from '@/cms/schemas/content.schema'; import { ContentService } from '@/cms/services/content.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { PluginService } from '@/plugins/plugins.service'; import { SettingService } from '@/setting/services/setting.service'; @@ -108,7 +108,7 @@ describe('BlockController', () => { PluginService, LoggerService, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/chat/controllers/category.contoller.spec.ts b/api/src/chat/controllers/category.contoller.spec.ts index f346bd3..c307a79 100644 --- a/api/src/chat/controllers/category.contoller.spec.ts +++ b/api/src/chat/controllers/category.contoller.spec.ts @@ -18,7 +18,7 @@ import { AttachmentService } from '@/attachment/services/attachment.service'; import { ContentRepository } from '@/cms/repositories/content.repository'; import { ContentModel } from '@/cms/schemas/content.schema'; import { ContentService } from '@/cms/services/content.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { PluginService } from '@/plugins/plugins.service'; import { SettingService } from '@/setting/services/setting.service'; @@ -77,7 +77,7 @@ describe('CategoryController', () => { }, LoggerService, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/chat/controllers/message.controller.spec.ts b/api/src/chat/controllers/message.controller.spec.ts index 5f80153..9e5c877 100644 --- a/api/src/chat/controllers/message.controller.spec.ts +++ b/api/src/chat/controllers/message.controller.spec.ts @@ -19,7 +19,7 @@ import { ChannelService } from '@/channel/channel.service'; import { MenuRepository } from '@/cms/repositories/menu.repository'; import { MenuModel } from '@/cms/schemas/menu.schema'; import { MenuService } from '@/cms/services/menu.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { NlpService } from '@/nlp/services/nlp.service'; import { SettingService } from '@/setting/services/setting.service'; @@ -92,7 +92,7 @@ describe('MessageController', () => { MenuService, MenuRepository, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/chat/controllers/translation.controller.spec.ts b/api/src/chat/controllers/translation.controller.spec.ts index b751389..27aef36 100644 --- a/api/src/chat/controllers/translation.controller.spec.ts +++ b/api/src/chat/controllers/translation.controller.spec.ts @@ -23,7 +23,7 @@ import { ContentModel } from '@/cms/schemas/content.schema'; import { MenuModel } from '@/cms/schemas/menu.schema'; import { ContentService } from '@/cms/services/content.service'; import { MenuService } from '@/cms/services/menu.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { NlpService } from '@/nlp/services/nlp.service'; import { PluginService } from '@/plugins/plugins.service'; @@ -114,7 +114,7 @@ describe('TranslationController', () => { EventEmitter2, LoggerService, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), initDynamicTranslations: jest.fn(), diff --git a/api/src/chat/services/block.service.spec.ts b/api/src/chat/services/block.service.spec.ts index 43af4af..7ef8786 100644 --- a/api/src/chat/services/block.service.spec.ts +++ b/api/src/chat/services/block.service.spec.ts @@ -24,11 +24,11 @@ import { ContentTypeModel } from '@/cms/schemas/content-type.schema'; import { Content, ContentModel } from '@/cms/schemas/content.schema'; import { ContentTypeService } from '@/cms/services/content-type.service'; import { ContentService } from '@/cms/services/content.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; import OfflineHandler from '@/extensions/channels/offline/index.channel'; import { OFFLINE_CHANNEL_NAME } from '@/extensions/channels/offline/settings'; import { Offline } from '@/extensions/channels/offline/types'; import OfflineEventWrapper from '@/extensions/channels/offline/wrapper'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { PluginService } from '@/plugins/plugins.service'; import { Settings } from '@/setting/schemas/types'; @@ -111,7 +111,7 @@ describe('BlockService', () => { }, LoggerService, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => { return t === 'Welcome' ? 'Bienvenue' : t; diff --git a/api/src/chat/services/block.service.ts b/api/src/chat/services/block.service.ts index 91e0f07..8104f4f 100644 --- a/api/src/chat/services/block.service.ts +++ b/api/src/chat/services/block.service.ts @@ -13,7 +13,7 @@ import { Attachment } from '@/attachment/schemas/attachment.schema'; import { AttachmentService } from '@/attachment/services/attachment.service'; import EventWrapper from '@/channel/lib/EventWrapper'; import { ContentService } from '@/cms/services/content.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { Nlp } from '@/nlp/lib/types'; import { PluginService } from '@/plugins/plugins.service'; @@ -43,7 +43,7 @@ export class BlockService extends BaseService { private readonly settingService: SettingService, private readonly pluginService: PluginService, private readonly logger: LoggerService, - protected readonly i18n: ExtendedI18nService, + protected readonly i18n: I18nService, ) { super(repository); } diff --git a/api/src/chat/services/bot.service.spec.ts b/api/src/chat/services/bot.service.spec.ts index 3625a1a..7e87e4d 100644 --- a/api/src/chat/services/bot.service.spec.ts +++ b/api/src/chat/services/bot.service.spec.ts @@ -25,10 +25,10 @@ import { MenuModel } from '@/cms/schemas/menu.schema'; import { ContentTypeService } from '@/cms/services/content-type.service'; import { ContentService } from '@/cms/services/content.service'; import { MenuService } from '@/cms/services/menu.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; import { offlineEventText } from '@/extensions/channels/offline/__test__/events.mock'; import OfflineHandler from '@/extensions/channels/offline/index.channel'; import OfflineEventWrapper from '@/extensions/channels/offline/wrapper'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { NlpEntityRepository } from '@/nlp/repositories/nlp-entity.repository'; import { NlpSampleEntityRepository } from '@/nlp/repositories/nlp-sample-entity.repository'; @@ -149,7 +149,7 @@ describe('BlockService', () => { }, LoggerService, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/chat/services/translation.service.ts b/api/src/chat/services/translation.service.ts index 113262a..9895dc4 100644 --- a/api/src/chat/services/translation.service.ts +++ b/api/src/chat/services/translation.service.ts @@ -10,7 +10,7 @@ import { Injectable } from '@nestjs/common'; import { OnEvent } from '@nestjs/event-emitter'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { SettingService } from '@/setting/services/setting.service'; import { BaseService } from '@/utils/generics/base-service'; @@ -25,7 +25,7 @@ export class TranslationService extends BaseService { readonly repository: TranslationRepository, private readonly blockService: BlockService, private readonly settingService: SettingService, - private readonly i18n: ExtendedI18nService, + private readonly i18n: I18nService, ) { super(repository); this.resetI18nTranslations(); diff --git a/api/src/extensions/channels/live-chat-tester/index.channel.ts b/api/src/extensions/channels/live-chat-tester/index.channel.ts index 3f5888e..1c44879 100644 --- a/api/src/extensions/channels/live-chat-tester/index.channel.ts +++ b/api/src/extensions/channels/live-chat-tester/index.channel.ts @@ -15,7 +15,7 @@ import { ChannelService } from '@/channel/channel.service'; import { MessageService } from '@/chat/services/message.service'; import { SubscriberService } from '@/chat/services/subscriber.service'; import { MenuService } from '@/cms/services/menu.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { NlpService } from '@/nlp/services/nlp.service'; import { SettingCreateDto } from '@/setting/dto/setting.dto'; @@ -38,7 +38,7 @@ export default class LiveChatTesterHandler extends OfflineHandler { nlpService: NlpService, logger: LoggerService, eventEmitter: EventEmitter2, - i18n: ExtendedI18nService, + i18n: I18nService, subscriberService: SubscriberService, attachmentService: AttachmentService, messageService: MessageService, diff --git a/api/src/extensions/channels/offline/__test__/index.spec.ts b/api/src/extensions/channels/offline/__test__/index.spec.ts index 9bd05f4..d5a3bec 100644 --- a/api/src/extensions/channels/offline/__test__/index.spec.ts +++ b/api/src/extensions/channels/offline/__test__/index.spec.ts @@ -35,7 +35,7 @@ import { SubscriberService } from '@/chat/services/subscriber.service'; import { MenuRepository } from '@/cms/repositories/menu.repository'; import { MenuModel } from '@/cms/schemas/menu.schema'; import { MenuService } from '@/cms/services/menu.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { NlpService } from '@/nlp/services/nlp.service'; import { SettingService } from '@/setting/services/setting.service'; @@ -113,7 +113,7 @@ describe('Offline Handler', () => { EventEmitter2, LoggerService, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/extensions/channels/offline/__test__/wrapper.spec.ts b/api/src/extensions/channels/offline/__test__/wrapper.spec.ts index 3a96764..ade376e 100644 --- a/api/src/extensions/channels/offline/__test__/wrapper.spec.ts +++ b/api/src/extensions/channels/offline/__test__/wrapper.spec.ts @@ -25,7 +25,7 @@ import { SubscriberService } from '@/chat/services/subscriber.service'; import { MenuRepository } from '@/cms/repositories/menu.repository'; import { MenuModel } from '@/cms/schemas/menu.schema'; import { MenuService } from '@/cms/services/menu.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { NlpService } from '@/nlp/services/nlp.service'; import { SettingService } from '@/setting/services/setting.service'; @@ -90,7 +90,7 @@ describe(`Offline event wrapper`, () => { EventEmitter2, LoggerService, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/extensions/channels/offline/index.channel.ts b/api/src/extensions/channels/offline/index.channel.ts index b6073bd..001a8d6 100644 --- a/api/src/extensions/channels/offline/index.channel.ts +++ b/api/src/extensions/channels/offline/index.channel.ts @@ -50,7 +50,7 @@ import { SubscriberService } from '@/chat/services/subscriber.service'; import { Content } from '@/cms/schemas/content.schema'; import { MenuService } from '@/cms/services/menu.service'; import { config } from '@/config'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { NlpService } from '@/nlp/services/nlp.service'; import { SettingCreateDto } from '@/setting/dto/setting.dto'; @@ -73,7 +73,7 @@ export default class OfflineHandler extends ChannelHandler { nlpService: NlpService, logger: LoggerService, protected readonly eventEmitter: EventEmitter2, - protected readonly i18n: ExtendedI18nService, + protected readonly i18n: I18nService, protected readonly subscriberService: SubscriberService, protected readonly attachmentService: AttachmentService, protected readonly messageService: MessageService, diff --git a/api/src/extended-18n.module.ts b/api/src/i18n/i18n.module.ts similarity index 83% rename from api/src/extended-18n.module.ts rename to api/src/i18n/i18n.module.ts index 3bba634..9c78167 100644 --- a/api/src/extended-18n.module.ts +++ b/api/src/i18n/i18n.module.ts @@ -12,19 +12,19 @@ import { HttpAdapterHost } from '@nestjs/core'; import { I18N_OPTIONS, I18N_TRANSLATIONS, - I18nModule, + I18nModule as NativeI18nModule, I18nOptions, I18nTranslation, } from 'nestjs-i18n'; import { Observable } from 'rxjs'; -import { ExtendedI18nService } from './extended-i18n.service'; +import { I18nService } from './services/i18n.service'; @Global() @Module({}) -export class ExtendedI18nModule extends I18nModule { +export class I18nModule extends NativeI18nModule { constructor( - i18n: ExtendedI18nService, + i18n: I18nService, @Inject(I18N_TRANSLATIONS) translations: Observable, @Inject(I18N_OPTIONS) i18nOptions: I18nOptions, @@ -36,9 +36,9 @@ export class ExtendedI18nModule extends I18nModule { static forRoot(options: I18nOptions): DynamicModule { const { providers, exports } = super.forRoot(options); return { - module: ExtendedI18nModule, - providers: providers.concat(ExtendedI18nService), - exports: exports.concat(ExtendedI18nService), + module: I18nModule, + providers: providers.concat(I18nService), + exports: exports.concat(I18nService), }; } } diff --git a/api/src/extended-i18n.service.ts b/api/src/i18n/services/i18n.service.ts similarity index 90% rename from api/src/extended-i18n.service.ts rename to api/src/i18n/services/i18n.service.ts index 5bb4e3d..b9fc7f2 100644 --- a/api/src/extended-i18n.service.ts +++ b/api/src/i18n/services/i18n.service.ts @@ -9,16 +9,21 @@ import { Injectable } from '@nestjs/common'; import { OnEvent } from '@nestjs/event-emitter'; -import { I18nService, Path, PathValue, TranslateOptions } from 'nestjs-i18n'; +import { + I18nService as NativeI18nService, + Path, + PathValue, + TranslateOptions, +} from 'nestjs-i18n'; import { IfAnyOrNever } from 'nestjs-i18n/dist/types'; -import { Translation } from './chat/schemas/translation.schema'; -import { config } from './config'; +import { Translation } from '@/chat/schemas/translation.schema'; +import { config } from '@/config'; @Injectable() -export class ExtendedI18nService< +export class I18nService< K = Record, -> extends I18nService { +> extends NativeI18nService { private dynamicTranslations: Record> = config.chatbot.lang.available.reduce( (acc, curr) => ({ ...acc, [curr]: {} }), diff --git a/api/src/nlp/controllers/nlp-sample.controller.spec.ts b/api/src/nlp/controllers/nlp-sample.controller.spec.ts index f71d112..5d5831c 100644 --- a/api/src/nlp/controllers/nlp-sample.controller.spec.ts +++ b/api/src/nlp/controllers/nlp-sample.controller.spec.ts @@ -18,7 +18,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { AttachmentRepository } from '@/attachment/repositories/attachment.repository'; import { AttachmentModel } from '@/attachment/schemas/attachment.schema'; import { AttachmentService } from '@/attachment/services/attachment.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { SettingRepository } from '@/setting/repositories/setting.repository'; import { SettingModel } from '@/setting/schemas/setting.schema'; @@ -94,7 +94,7 @@ describe('NlpSampleController', () => { SettingService, SettingSeeder, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/setting/controllers/setting.controller.spec.ts b/api/src/setting/controllers/setting.controller.spec.ts index 6e6d0e4..57dc52b 100644 --- a/api/src/setting/controllers/setting.controller.spec.ts +++ b/api/src/setting/controllers/setting.controller.spec.ts @@ -12,7 +12,7 @@ import { EventEmitter2 } from '@nestjs/event-emitter'; import { MongooseModule } from '@nestjs/mongoose'; import { Test } from '@nestjs/testing'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { installSettingFixtures, @@ -47,7 +47,7 @@ describe('SettingController', () => { LoggerService, EventEmitter2, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/setting/repositories/setting.repository.ts b/api/src/setting/repositories/setting.repository.ts index d215a30..6c1d362 100644 --- a/api/src/setting/repositories/setting.repository.ts +++ b/api/src/setting/repositories/setting.repository.ts @@ -13,7 +13,7 @@ import { InjectModel } from '@nestjs/mongoose'; import { Document, Model, Query, Types } from 'mongoose'; import { config } from '@/config'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { BaseRepository } from '@/utils/generics/base-repository'; import { Setting } from '../schemas/setting.schema'; @@ -23,7 +23,7 @@ export class SettingRepository extends BaseRepository { constructor( @InjectModel(Setting.name) readonly model: Model, private readonly eventEmitter: EventEmitter2, - private readonly i18n: ExtendedI18nService, + private readonly i18n: I18nService, ) { super(model, Setting); } diff --git a/api/src/setting/services/setting.service.spec.ts b/api/src/setting/services/setting.service.spec.ts index 69e4e98..0fa7c6b 100644 --- a/api/src/setting/services/setting.service.spec.ts +++ b/api/src/setting/services/setting.service.spec.ts @@ -12,7 +12,7 @@ import { EventEmitter2 } from '@nestjs/event-emitter'; import { MongooseModule } from '@nestjs/mongoose'; import { Test } from '@nestjs/testing'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { installSettingFixtures, @@ -51,7 +51,7 @@ describe('SettingService', () => { SettingSeeder, EventEmitter2, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/user/controllers/auth.controller.spec.ts b/api/src/user/controllers/auth.controller.spec.ts index b30a6ad..e888bb2 100644 --- a/api/src/user/controllers/auth.controller.spec.ts +++ b/api/src/user/controllers/auth.controller.spec.ts @@ -23,7 +23,7 @@ import { SentMessageInfo } from 'nodemailer'; import { AttachmentRepository } from '@/attachment/repositories/attachment.repository'; import { AttachmentModel } from '@/attachment/schemas/attachment.schema'; import { AttachmentService } from '@/attachment/services/attachment.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { installUserFixtures } from '@/utils/test/fixtures/user'; import { @@ -106,7 +106,7 @@ describe('AuthController', () => { EventEmitter2, ValidateAccountService, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/user/controllers/user.controller.spec.ts b/api/src/user/controllers/user.controller.spec.ts index 399a68d..7aee982 100644 --- a/api/src/user/controllers/user.controller.spec.ts +++ b/api/src/user/controllers/user.controller.spec.ts @@ -20,7 +20,7 @@ import { SentMessageInfo } from 'nodemailer'; import { AttachmentRepository } from '@/attachment/repositories/attachment.repository'; import { AttachmentModel } from '@/attachment/schemas/attachment.schema'; import { AttachmentService } from '@/attachment/services/attachment.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { IGNORED_TEST_FIELDS } from '@/utils/test/constants'; import { installPermissionFixtures } from '@/utils/test/fixtures/permission'; @@ -110,7 +110,7 @@ describe('UserController', () => { AttachmentRepository, ValidateAccountService, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/user/services/invitation.service.spec.ts b/api/src/user/services/invitation.service.spec.ts index 82216ae..90fb79f 100644 --- a/api/src/user/services/invitation.service.spec.ts +++ b/api/src/user/services/invitation.service.spec.ts @@ -16,7 +16,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { ISendMailOptions, MailerService } from '@nestjs-modules/mailer'; import { SentMessageInfo } from 'nodemailer'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { IGNORED_TEST_FIELDS } from '@/utils/test/constants'; import { @@ -69,7 +69,7 @@ describe('InvitationService', () => { JwtService, Logger, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/user/services/invitation.service.ts b/api/src/user/services/invitation.service.ts index f6a921c..925eb5e 100644 --- a/api/src/user/services/invitation.service.ts +++ b/api/src/user/services/invitation.service.ts @@ -17,7 +17,7 @@ import { JwtService, JwtSignOptions } from '@nestjs/jwt'; import { MailerService } from '@nestjs-modules/mailer'; import { config } from '@/config'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { BaseService } from '@/utils/generics/base-service'; @@ -41,7 +41,7 @@ export class InvitationService extends BaseService< @Inject(JwtService) private readonly jwtService: JwtService, @Optional() private readonly mailerService: MailerService | undefined, private logger: LoggerService, - protected readonly i18n: ExtendedI18nService, + protected readonly i18n: I18nService, ) { super(repository); } diff --git a/api/src/user/services/passwordReset.service.spec.ts b/api/src/user/services/passwordReset.service.spec.ts index c05b43b..cbbfc95 100644 --- a/api/src/user/services/passwordReset.service.spec.ts +++ b/api/src/user/services/passwordReset.service.spec.ts @@ -21,7 +21,7 @@ import { SentMessageInfo } from 'nodemailer'; import { AttachmentRepository } from '@/attachment/repositories/attachment.repository'; import { AttachmentModel } from '@/attachment/schemas/attachment.schema'; import { AttachmentService } from '@/attachment/services/attachment.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { installUserFixtures, users } from '@/utils/test/fixtures/user'; import { @@ -75,7 +75,7 @@ describe('PasswordResetService', () => { }, }, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/user/services/passwordReset.service.ts b/api/src/user/services/passwordReset.service.ts index 60143f8..9115914 100644 --- a/api/src/user/services/passwordReset.service.ts +++ b/api/src/user/services/passwordReset.service.ts @@ -21,7 +21,7 @@ import { MailerService } from '@nestjs-modules/mailer'; import { compareSync } from 'bcryptjs'; import { config } from '@/config'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { UserService } from './user.service'; @@ -34,7 +34,7 @@ export class PasswordResetService { @Optional() private readonly mailerService: MailerService | undefined, private logger: LoggerService, private readonly userService: UserService, - public readonly i18n: ExtendedI18nService, + public readonly i18n: I18nService, ) {} public readonly jwtSignOptions: JwtSignOptions = { diff --git a/api/src/user/services/validate-account.service.spec.ts b/api/src/user/services/validate-account.service.spec.ts index 701d5fe..adb18a4 100644 --- a/api/src/user/services/validate-account.service.spec.ts +++ b/api/src/user/services/validate-account.service.spec.ts @@ -17,7 +17,7 @@ import { SentMessageInfo } from 'nodemailer'; import { AttachmentRepository } from '@/attachment/repositories/attachment.repository'; import { AttachmentModel } from '@/attachment/schemas/attachment.schema'; import { AttachmentService } from '@/attachment/services/attachment.service'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { LoggerService } from '@/logger/logger.service'; import { installUserFixtures, users } from '@/utils/test/fixtures/user'; import { @@ -69,7 +69,7 @@ describe('ValidateAccountService', () => { EventEmitter2, ValidateAccountService, { - provide: ExtendedI18nService, + provide: I18nService, useValue: { t: jest.fn().mockImplementation((t) => t), }, diff --git a/api/src/user/services/validate-account.service.ts b/api/src/user/services/validate-account.service.ts index 4c2d06c..9526066 100644 --- a/api/src/user/services/validate-account.service.ts +++ b/api/src/user/services/validate-account.service.ts @@ -18,7 +18,7 @@ import { JwtService, JwtSignOptions } from '@nestjs/jwt'; import { MailerService } from '@nestjs-modules/mailer'; import { config } from '@/config'; -import { ExtendedI18nService } from '@/extended-i18n.service'; +import { I18nService } from '@/i18n/services/i18n.service'; import { UserService } from './user.service'; import { UserCreateDto } from '../dto/user.dto'; @@ -35,7 +35,7 @@ export class ValidateAccountService { @Inject(JwtService) private readonly jwtService: JwtService, private readonly userService: UserService, @Optional() private readonly mailerService: MailerService | undefined, - private readonly i18n: ExtendedI18nService, + private readonly i18n: I18nService, ) {} /**