feat: restructure i18n into a dir

This commit is contained in:
Mohamed Marrouchi 2024-09-22 08:55:15 +01:00
parent 7d5962d84f
commit 38950a0287
28 changed files with 69 additions and 64 deletions

View File

@ -32,7 +32,7 @@ import { ChannelModule } from './channel/channel.module';
import { ChatModule } from './chat/chat.module'; import { ChatModule } from './chat/chat.module';
import { CmsModule } from './cms/cms.module'; import { CmsModule } from './cms/cms.module';
import { config } from './config'; import { config } from './config';
import { ExtendedI18nModule } from './extended-18n.module'; import { I18nModule } from './i18n/i18n.module';
import { LoggerModule } from './logger/logger.module'; import { LoggerModule } from './logger/logger.module';
import { DtoUpdateMiddleware } from './middlewares/dto.update.middleware'; import { DtoUpdateMiddleware } from './middlewares/dto.update.middleware';
import { NlpModule } from './nlp/nlp.module'; import { NlpModule } from './nlp/nlp.module';
@ -120,7 +120,7 @@ const i18nOptions: I18nOptions = {
ignoreErrors: false, ignoreErrors: false,
}), }),
CsrfModule, CsrfModule,
ExtendedI18nModule.forRoot(i18nOptions), I18nModule.forRoot(i18nOptions),
CacheModule.register({ CacheModule.register({
isGlobal: true, isGlobal: true,
ttl: config.cache.ttl, ttl: config.cache.ttl,

View File

@ -9,11 +9,11 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { ExtendedI18nService } from './extended-i18n.service'; import { I18nService } from './i18n/services/i18n.service';
@Injectable() @Injectable()
export class AppService { export class AppService {
constructor(private readonly i18n: ExtendedI18nService) {} constructor(private readonly i18n: I18nService) {}
getHello(): string { getHello(): string {
return this.i18n.t('welcome', { lang: 'en' }); return this.i18n.t('welcome', { lang: 'en' });

View File

@ -19,7 +19,7 @@ import { AttachmentService } from '@/attachment/services/attachment.service';
import { ContentRepository } from '@/cms/repositories/content.repository'; import { ContentRepository } from '@/cms/repositories/content.repository';
import { ContentModel } from '@/cms/schemas/content.schema'; import { ContentModel } from '@/cms/schemas/content.schema';
import { ContentService } from '@/cms/services/content.service'; 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 { LoggerService } from '@/logger/logger.service';
import { PluginService } from '@/plugins/plugins.service'; import { PluginService } from '@/plugins/plugins.service';
import { SettingService } from '@/setting/services/setting.service'; import { SettingService } from '@/setting/services/setting.service';
@ -108,7 +108,7 @@ describe('BlockController', () => {
PluginService, PluginService,
LoggerService, LoggerService,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -18,7 +18,7 @@ import { AttachmentService } from '@/attachment/services/attachment.service';
import { ContentRepository } from '@/cms/repositories/content.repository'; import { ContentRepository } from '@/cms/repositories/content.repository';
import { ContentModel } from '@/cms/schemas/content.schema'; import { ContentModel } from '@/cms/schemas/content.schema';
import { ContentService } from '@/cms/services/content.service'; 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 { LoggerService } from '@/logger/logger.service';
import { PluginService } from '@/plugins/plugins.service'; import { PluginService } from '@/plugins/plugins.service';
import { SettingService } from '@/setting/services/setting.service'; import { SettingService } from '@/setting/services/setting.service';
@ -77,7 +77,7 @@ describe('CategoryController', () => {
}, },
LoggerService, LoggerService,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -19,7 +19,7 @@ import { ChannelService } from '@/channel/channel.service';
import { MenuRepository } from '@/cms/repositories/menu.repository'; import { MenuRepository } from '@/cms/repositories/menu.repository';
import { MenuModel } from '@/cms/schemas/menu.schema'; import { MenuModel } from '@/cms/schemas/menu.schema';
import { MenuService } from '@/cms/services/menu.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 { LoggerService } from '@/logger/logger.service';
import { NlpService } from '@/nlp/services/nlp.service'; import { NlpService } from '@/nlp/services/nlp.service';
import { SettingService } from '@/setting/services/setting.service'; import { SettingService } from '@/setting/services/setting.service';
@ -92,7 +92,7 @@ describe('MessageController', () => {
MenuService, MenuService,
MenuRepository, MenuRepository,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -23,7 +23,7 @@ import { ContentModel } from '@/cms/schemas/content.schema';
import { MenuModel } from '@/cms/schemas/menu.schema'; import { MenuModel } from '@/cms/schemas/menu.schema';
import { ContentService } from '@/cms/services/content.service'; import { ContentService } from '@/cms/services/content.service';
import { MenuService } from '@/cms/services/menu.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 { LoggerService } from '@/logger/logger.service';
import { NlpService } from '@/nlp/services/nlp.service'; import { NlpService } from '@/nlp/services/nlp.service';
import { PluginService } from '@/plugins/plugins.service'; import { PluginService } from '@/plugins/plugins.service';
@ -114,7 +114,7 @@ describe('TranslationController', () => {
EventEmitter2, EventEmitter2,
LoggerService, LoggerService,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
initDynamicTranslations: jest.fn(), initDynamicTranslations: jest.fn(),

View File

@ -24,11 +24,11 @@ import { ContentTypeModel } from '@/cms/schemas/content-type.schema';
import { Content, ContentModel } from '@/cms/schemas/content.schema'; import { Content, ContentModel } from '@/cms/schemas/content.schema';
import { ContentTypeService } from '@/cms/services/content-type.service'; import { ContentTypeService } from '@/cms/services/content-type.service';
import { ContentService } from '@/cms/services/content.service'; import { ContentService } from '@/cms/services/content.service';
import { ExtendedI18nService } from '@/extended-i18n.service';
import OfflineHandler from '@/extensions/channels/offline/index.channel'; import OfflineHandler from '@/extensions/channels/offline/index.channel';
import { OFFLINE_CHANNEL_NAME } from '@/extensions/channels/offline/settings'; import { OFFLINE_CHANNEL_NAME } from '@/extensions/channels/offline/settings';
import { Offline } from '@/extensions/channels/offline/types'; import { Offline } from '@/extensions/channels/offline/types';
import OfflineEventWrapper from '@/extensions/channels/offline/wrapper'; import OfflineEventWrapper from '@/extensions/channels/offline/wrapper';
import { I18nService } from '@/i18n/services/i18n.service';
import { LoggerService } from '@/logger/logger.service'; import { LoggerService } from '@/logger/logger.service';
import { PluginService } from '@/plugins/plugins.service'; import { PluginService } from '@/plugins/plugins.service';
import { Settings } from '@/setting/schemas/types'; import { Settings } from '@/setting/schemas/types';
@ -111,7 +111,7 @@ describe('BlockService', () => {
}, },
LoggerService, LoggerService,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => { t: jest.fn().mockImplementation((t) => {
return t === 'Welcome' ? 'Bienvenue' : t; return t === 'Welcome' ? 'Bienvenue' : t;

View File

@ -13,7 +13,7 @@ import { Attachment } from '@/attachment/schemas/attachment.schema';
import { AttachmentService } from '@/attachment/services/attachment.service'; import { AttachmentService } from '@/attachment/services/attachment.service';
import EventWrapper from '@/channel/lib/EventWrapper'; import EventWrapper from '@/channel/lib/EventWrapper';
import { ContentService } from '@/cms/services/content.service'; 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 { LoggerService } from '@/logger/logger.service';
import { Nlp } from '@/nlp/lib/types'; import { Nlp } from '@/nlp/lib/types';
import { PluginService } from '@/plugins/plugins.service'; import { PluginService } from '@/plugins/plugins.service';
@ -43,7 +43,7 @@ export class BlockService extends BaseService<Block, BlockPopulate, BlockFull> {
private readonly settingService: SettingService, private readonly settingService: SettingService,
private readonly pluginService: PluginService, private readonly pluginService: PluginService,
private readonly logger: LoggerService, private readonly logger: LoggerService,
protected readonly i18n: ExtendedI18nService, protected readonly i18n: I18nService,
) { ) {
super(repository); super(repository);
} }

View File

@ -25,10 +25,10 @@ import { MenuModel } from '@/cms/schemas/menu.schema';
import { ContentTypeService } from '@/cms/services/content-type.service'; import { ContentTypeService } from '@/cms/services/content-type.service';
import { ContentService } from '@/cms/services/content.service'; import { ContentService } from '@/cms/services/content.service';
import { MenuService } from '@/cms/services/menu.service'; import { MenuService } from '@/cms/services/menu.service';
import { ExtendedI18nService } from '@/extended-i18n.service';
import { offlineEventText } from '@/extensions/channels/offline/__test__/events.mock'; import { offlineEventText } from '@/extensions/channels/offline/__test__/events.mock';
import OfflineHandler from '@/extensions/channels/offline/index.channel'; import OfflineHandler from '@/extensions/channels/offline/index.channel';
import OfflineEventWrapper from '@/extensions/channels/offline/wrapper'; import OfflineEventWrapper from '@/extensions/channels/offline/wrapper';
import { I18nService } from '@/i18n/services/i18n.service';
import { LoggerService } from '@/logger/logger.service'; import { LoggerService } from '@/logger/logger.service';
import { NlpEntityRepository } from '@/nlp/repositories/nlp-entity.repository'; import { NlpEntityRepository } from '@/nlp/repositories/nlp-entity.repository';
import { NlpSampleEntityRepository } from '@/nlp/repositories/nlp-sample-entity.repository'; import { NlpSampleEntityRepository } from '@/nlp/repositories/nlp-sample-entity.repository';
@ -149,7 +149,7 @@ describe('BlockService', () => {
}, },
LoggerService, LoggerService,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -10,7 +10,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter'; 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 { SettingService } from '@/setting/services/setting.service';
import { BaseService } from '@/utils/generics/base-service'; import { BaseService } from '@/utils/generics/base-service';
@ -25,7 +25,7 @@ export class TranslationService extends BaseService<Translation> {
readonly repository: TranslationRepository, readonly repository: TranslationRepository,
private readonly blockService: BlockService, private readonly blockService: BlockService,
private readonly settingService: SettingService, private readonly settingService: SettingService,
private readonly i18n: ExtendedI18nService, private readonly i18n: I18nService,
) { ) {
super(repository); super(repository);
this.resetI18nTranslations(); this.resetI18nTranslations();

View File

@ -15,7 +15,7 @@ import { ChannelService } from '@/channel/channel.service';
import { MessageService } from '@/chat/services/message.service'; import { MessageService } from '@/chat/services/message.service';
import { SubscriberService } from '@/chat/services/subscriber.service'; import { SubscriberService } from '@/chat/services/subscriber.service';
import { MenuService } from '@/cms/services/menu.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 { LoggerService } from '@/logger/logger.service';
import { NlpService } from '@/nlp/services/nlp.service'; import { NlpService } from '@/nlp/services/nlp.service';
import { SettingCreateDto } from '@/setting/dto/setting.dto'; import { SettingCreateDto } from '@/setting/dto/setting.dto';
@ -38,7 +38,7 @@ export default class LiveChatTesterHandler extends OfflineHandler {
nlpService: NlpService, nlpService: NlpService,
logger: LoggerService, logger: LoggerService,
eventEmitter: EventEmitter2, eventEmitter: EventEmitter2,
i18n: ExtendedI18nService, i18n: I18nService,
subscriberService: SubscriberService, subscriberService: SubscriberService,
attachmentService: AttachmentService, attachmentService: AttachmentService,
messageService: MessageService, messageService: MessageService,

View File

@ -35,7 +35,7 @@ import { SubscriberService } from '@/chat/services/subscriber.service';
import { MenuRepository } from '@/cms/repositories/menu.repository'; import { MenuRepository } from '@/cms/repositories/menu.repository';
import { MenuModel } from '@/cms/schemas/menu.schema'; import { MenuModel } from '@/cms/schemas/menu.schema';
import { MenuService } from '@/cms/services/menu.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 { LoggerService } from '@/logger/logger.service';
import { NlpService } from '@/nlp/services/nlp.service'; import { NlpService } from '@/nlp/services/nlp.service';
import { SettingService } from '@/setting/services/setting.service'; import { SettingService } from '@/setting/services/setting.service';
@ -113,7 +113,7 @@ describe('Offline Handler', () => {
EventEmitter2, EventEmitter2,
LoggerService, LoggerService,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -25,7 +25,7 @@ import { SubscriberService } from '@/chat/services/subscriber.service';
import { MenuRepository } from '@/cms/repositories/menu.repository'; import { MenuRepository } from '@/cms/repositories/menu.repository';
import { MenuModel } from '@/cms/schemas/menu.schema'; import { MenuModel } from '@/cms/schemas/menu.schema';
import { MenuService } from '@/cms/services/menu.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 { LoggerService } from '@/logger/logger.service';
import { NlpService } from '@/nlp/services/nlp.service'; import { NlpService } from '@/nlp/services/nlp.service';
import { SettingService } from '@/setting/services/setting.service'; import { SettingService } from '@/setting/services/setting.service';
@ -90,7 +90,7 @@ describe(`Offline event wrapper`, () => {
EventEmitter2, EventEmitter2,
LoggerService, LoggerService,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -50,7 +50,7 @@ import { SubscriberService } from '@/chat/services/subscriber.service';
import { Content } from '@/cms/schemas/content.schema'; import { Content } from '@/cms/schemas/content.schema';
import { MenuService } from '@/cms/services/menu.service'; import { MenuService } from '@/cms/services/menu.service';
import { config } from '@/config'; import { config } from '@/config';
import { ExtendedI18nService } from '@/extended-i18n.service'; import { I18nService } from '@/i18n/services/i18n.service';
import { LoggerService } from '@/logger/logger.service'; import { LoggerService } from '@/logger/logger.service';
import { NlpService } from '@/nlp/services/nlp.service'; import { NlpService } from '@/nlp/services/nlp.service';
import { SettingCreateDto } from '@/setting/dto/setting.dto'; import { SettingCreateDto } from '@/setting/dto/setting.dto';
@ -73,7 +73,7 @@ export default class OfflineHandler extends ChannelHandler {
nlpService: NlpService, nlpService: NlpService,
logger: LoggerService, logger: LoggerService,
protected readonly eventEmitter: EventEmitter2, protected readonly eventEmitter: EventEmitter2,
protected readonly i18n: ExtendedI18nService, protected readonly i18n: I18nService,
protected readonly subscriberService: SubscriberService, protected readonly subscriberService: SubscriberService,
protected readonly attachmentService: AttachmentService, protected readonly attachmentService: AttachmentService,
protected readonly messageService: MessageService, protected readonly messageService: MessageService,

View File

@ -12,19 +12,19 @@ import { HttpAdapterHost } from '@nestjs/core';
import { import {
I18N_OPTIONS, I18N_OPTIONS,
I18N_TRANSLATIONS, I18N_TRANSLATIONS,
I18nModule, I18nModule as NativeI18nModule,
I18nOptions, I18nOptions,
I18nTranslation, I18nTranslation,
} from 'nestjs-i18n'; } from 'nestjs-i18n';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ExtendedI18nService } from './extended-i18n.service'; import { I18nService } from './services/i18n.service';
@Global() @Global()
@Module({}) @Module({})
export class ExtendedI18nModule extends I18nModule { export class I18nModule extends NativeI18nModule {
constructor( constructor(
i18n: ExtendedI18nService, i18n: I18nService,
@Inject(I18N_TRANSLATIONS) @Inject(I18N_TRANSLATIONS)
translations: Observable<I18nTranslation>, translations: Observable<I18nTranslation>,
@Inject(I18N_OPTIONS) i18nOptions: I18nOptions, @Inject(I18N_OPTIONS) i18nOptions: I18nOptions,
@ -36,9 +36,9 @@ export class ExtendedI18nModule extends I18nModule {
static forRoot(options: I18nOptions): DynamicModule { static forRoot(options: I18nOptions): DynamicModule {
const { providers, exports } = super.forRoot(options); const { providers, exports } = super.forRoot(options);
return { return {
module: ExtendedI18nModule, module: I18nModule,
providers: providers.concat(ExtendedI18nService), providers: providers.concat(I18nService),
exports: exports.concat(ExtendedI18nService), exports: exports.concat(I18nService),
}; };
} }
} }

View File

@ -9,16 +9,21 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter'; 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 { IfAnyOrNever } from 'nestjs-i18n/dist/types';
import { Translation } from './chat/schemas/translation.schema'; import { Translation } from '@/chat/schemas/translation.schema';
import { config } from './config'; import { config } from '@/config';
@Injectable() @Injectable()
export class ExtendedI18nService< export class I18nService<
K = Record<string, unknown>, K = Record<string, unknown>,
> extends I18nService<K> { > extends NativeI18nService<K> {
private dynamicTranslations: Record<string, Record<string, string>> = private dynamicTranslations: Record<string, Record<string, string>> =
config.chatbot.lang.available.reduce( config.chatbot.lang.available.reduce(
(acc, curr) => ({ ...acc, [curr]: {} }), (acc, curr) => ({ ...acc, [curr]: {} }),

View File

@ -18,7 +18,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { AttachmentRepository } from '@/attachment/repositories/attachment.repository'; import { AttachmentRepository } from '@/attachment/repositories/attachment.repository';
import { AttachmentModel } from '@/attachment/schemas/attachment.schema'; import { AttachmentModel } from '@/attachment/schemas/attachment.schema';
import { AttachmentService } from '@/attachment/services/attachment.service'; 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 { LoggerService } from '@/logger/logger.service';
import { SettingRepository } from '@/setting/repositories/setting.repository'; import { SettingRepository } from '@/setting/repositories/setting.repository';
import { SettingModel } from '@/setting/schemas/setting.schema'; import { SettingModel } from '@/setting/schemas/setting.schema';
@ -94,7 +94,7 @@ describe('NlpSampleController', () => {
SettingService, SettingService,
SettingSeeder, SettingSeeder,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -12,7 +12,7 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
import { Test } from '@nestjs/testing'; 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 { LoggerService } from '@/logger/logger.service';
import { import {
installSettingFixtures, installSettingFixtures,
@ -47,7 +47,7 @@ describe('SettingController', () => {
LoggerService, LoggerService,
EventEmitter2, EventEmitter2,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -13,7 +13,7 @@ import { InjectModel } from '@nestjs/mongoose';
import { Document, Model, Query, Types } from 'mongoose'; import { Document, Model, Query, Types } from 'mongoose';
import { config } from '@/config'; 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 { BaseRepository } from '@/utils/generics/base-repository';
import { Setting } from '../schemas/setting.schema'; import { Setting } from '../schemas/setting.schema';
@ -23,7 +23,7 @@ export class SettingRepository extends BaseRepository<Setting> {
constructor( constructor(
@InjectModel(Setting.name) readonly model: Model<Setting>, @InjectModel(Setting.name) readonly model: Model<Setting>,
private readonly eventEmitter: EventEmitter2, private readonly eventEmitter: EventEmitter2,
private readonly i18n: ExtendedI18nService, private readonly i18n: I18nService,
) { ) {
super(model, Setting); super(model, Setting);
} }

View File

@ -12,7 +12,7 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
import { Test } from '@nestjs/testing'; 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 { LoggerService } from '@/logger/logger.service';
import { import {
installSettingFixtures, installSettingFixtures,
@ -51,7 +51,7 @@ describe('SettingService', () => {
SettingSeeder, SettingSeeder,
EventEmitter2, EventEmitter2,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -23,7 +23,7 @@ import { SentMessageInfo } from 'nodemailer';
import { AttachmentRepository } from '@/attachment/repositories/attachment.repository'; import { AttachmentRepository } from '@/attachment/repositories/attachment.repository';
import { AttachmentModel } from '@/attachment/schemas/attachment.schema'; import { AttachmentModel } from '@/attachment/schemas/attachment.schema';
import { AttachmentService } from '@/attachment/services/attachment.service'; 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 { LoggerService } from '@/logger/logger.service';
import { installUserFixtures } from '@/utils/test/fixtures/user'; import { installUserFixtures } from '@/utils/test/fixtures/user';
import { import {
@ -106,7 +106,7 @@ describe('AuthController', () => {
EventEmitter2, EventEmitter2,
ValidateAccountService, ValidateAccountService,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -20,7 +20,7 @@ import { SentMessageInfo } from 'nodemailer';
import { AttachmentRepository } from '@/attachment/repositories/attachment.repository'; import { AttachmentRepository } from '@/attachment/repositories/attachment.repository';
import { AttachmentModel } from '@/attachment/schemas/attachment.schema'; import { AttachmentModel } from '@/attachment/schemas/attachment.schema';
import { AttachmentService } from '@/attachment/services/attachment.service'; 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 { LoggerService } from '@/logger/logger.service';
import { IGNORED_TEST_FIELDS } from '@/utils/test/constants'; import { IGNORED_TEST_FIELDS } from '@/utils/test/constants';
import { installPermissionFixtures } from '@/utils/test/fixtures/permission'; import { installPermissionFixtures } from '@/utils/test/fixtures/permission';
@ -110,7 +110,7 @@ describe('UserController', () => {
AttachmentRepository, AttachmentRepository,
ValidateAccountService, ValidateAccountService,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -16,7 +16,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { ISendMailOptions, MailerService } from '@nestjs-modules/mailer'; import { ISendMailOptions, MailerService } from '@nestjs-modules/mailer';
import { SentMessageInfo } from 'nodemailer'; import { SentMessageInfo } from 'nodemailer';
import { ExtendedI18nService } from '@/extended-i18n.service'; import { I18nService } from '@/i18n/services/i18n.service';
import { LoggerService } from '@/logger/logger.service'; import { LoggerService } from '@/logger/logger.service';
import { IGNORED_TEST_FIELDS } from '@/utils/test/constants'; import { IGNORED_TEST_FIELDS } from '@/utils/test/constants';
import { import {
@ -69,7 +69,7 @@ describe('InvitationService', () => {
JwtService, JwtService,
Logger, Logger,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -17,7 +17,7 @@ import { JwtService, JwtSignOptions } from '@nestjs/jwt';
import { MailerService } from '@nestjs-modules/mailer'; import { MailerService } from '@nestjs-modules/mailer';
import { config } from '@/config'; import { config } from '@/config';
import { ExtendedI18nService } from '@/extended-i18n.service'; import { I18nService } from '@/i18n/services/i18n.service';
import { LoggerService } from '@/logger/logger.service'; import { LoggerService } from '@/logger/logger.service';
import { BaseService } from '@/utils/generics/base-service'; import { BaseService } from '@/utils/generics/base-service';
@ -41,7 +41,7 @@ export class InvitationService extends BaseService<
@Inject(JwtService) private readonly jwtService: JwtService, @Inject(JwtService) private readonly jwtService: JwtService,
@Optional() private readonly mailerService: MailerService | undefined, @Optional() private readonly mailerService: MailerService | undefined,
private logger: LoggerService, private logger: LoggerService,
protected readonly i18n: ExtendedI18nService, protected readonly i18n: I18nService,
) { ) {
super(repository); super(repository);
} }

View File

@ -21,7 +21,7 @@ import { SentMessageInfo } from 'nodemailer';
import { AttachmentRepository } from '@/attachment/repositories/attachment.repository'; import { AttachmentRepository } from '@/attachment/repositories/attachment.repository';
import { AttachmentModel } from '@/attachment/schemas/attachment.schema'; import { AttachmentModel } from '@/attachment/schemas/attachment.schema';
import { AttachmentService } from '@/attachment/services/attachment.service'; 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 { LoggerService } from '@/logger/logger.service';
import { installUserFixtures, users } from '@/utils/test/fixtures/user'; import { installUserFixtures, users } from '@/utils/test/fixtures/user';
import { import {
@ -75,7 +75,7 @@ describe('PasswordResetService', () => {
}, },
}, },
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -21,7 +21,7 @@ import { MailerService } from '@nestjs-modules/mailer';
import { compareSync } from 'bcryptjs'; import { compareSync } from 'bcryptjs';
import { config } from '@/config'; import { config } from '@/config';
import { ExtendedI18nService } from '@/extended-i18n.service'; import { I18nService } from '@/i18n/services/i18n.service';
import { LoggerService } from '@/logger/logger.service'; import { LoggerService } from '@/logger/logger.service';
import { UserService } from './user.service'; import { UserService } from './user.service';
@ -34,7 +34,7 @@ export class PasswordResetService {
@Optional() private readonly mailerService: MailerService | undefined, @Optional() private readonly mailerService: MailerService | undefined,
private logger: LoggerService, private logger: LoggerService,
private readonly userService: UserService, private readonly userService: UserService,
public readonly i18n: ExtendedI18nService, public readonly i18n: I18nService,
) {} ) {}
public readonly jwtSignOptions: JwtSignOptions = { public readonly jwtSignOptions: JwtSignOptions = {

View File

@ -17,7 +17,7 @@ import { SentMessageInfo } from 'nodemailer';
import { AttachmentRepository } from '@/attachment/repositories/attachment.repository'; import { AttachmentRepository } from '@/attachment/repositories/attachment.repository';
import { AttachmentModel } from '@/attachment/schemas/attachment.schema'; import { AttachmentModel } from '@/attachment/schemas/attachment.schema';
import { AttachmentService } from '@/attachment/services/attachment.service'; 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 { LoggerService } from '@/logger/logger.service';
import { installUserFixtures, users } from '@/utils/test/fixtures/user'; import { installUserFixtures, users } from '@/utils/test/fixtures/user';
import { import {
@ -69,7 +69,7 @@ describe('ValidateAccountService', () => {
EventEmitter2, EventEmitter2,
ValidateAccountService, ValidateAccountService,
{ {
provide: ExtendedI18nService, provide: I18nService,
useValue: { useValue: {
t: jest.fn().mockImplementation((t) => t), t: jest.fn().mockImplementation((t) => t),
}, },

View File

@ -18,7 +18,7 @@ import { JwtService, JwtSignOptions } from '@nestjs/jwt';
import { MailerService } from '@nestjs-modules/mailer'; import { MailerService } from '@nestjs-modules/mailer';
import { config } from '@/config'; import { config } from '@/config';
import { ExtendedI18nService } from '@/extended-i18n.service'; import { I18nService } from '@/i18n/services/i18n.service';
import { UserService } from './user.service'; import { UserService } from './user.service';
import { UserCreateDto } from '../dto/user.dto'; import { UserCreateDto } from '../dto/user.dto';
@ -35,7 +35,7 @@ export class ValidateAccountService {
@Inject(JwtService) private readonly jwtService: JwtService, @Inject(JwtService) private readonly jwtService: JwtService,
private readonly userService: UserService, private readonly userService: UserService,
@Optional() private readonly mailerService: MailerService | undefined, @Optional() private readonly mailerService: MailerService | undefined,
private readonly i18n: ExtendedI18nService, private readonly i18n: I18nService,
) {} ) {}
/** /**