refactor(nestjs): export module

This commit is contained in:
Ahmed Bouhuolia
2025-04-10 23:34:42 +02:00
parent ab49113d5a
commit c953c48c39
23 changed files with 176 additions and 68 deletions

View File

@@ -7,7 +7,6 @@ import { ExportApplication } from './ExportApplication';
import { ResourceModule } from '../Resource/Resource.module';
import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module';
import { ImportModel } from '../Import/models/Import';
import { ExportableResources } from './ExportResources';
import { ExportableRegistry } from './ExportRegistery';
import { TemplateInjectableModule } from '../TemplateInjectable/TemplateInjectable.module';
import { ChromiumlyTenancyModule } from '../ChromiumlyTenancy/ChromiumlyTenancy.module';
@@ -28,7 +27,6 @@ const models = [RegisterTenancyModel(ImportModel)];
ExportPdf,
ExportAls,
ExportApplication,
ExportableResources,
ExportableRegistry
],
exports: [...models],

View File

@@ -3,7 +3,6 @@ import * as xlsx from 'xlsx';
import * as R from 'ramda';
import { get } from 'lodash';
import { sanitizeResourceName } from '../Import/_utils';
import { ExportableResources } from './ExportResources';
import { Errors, ExportFormat } from './common';
import { flatDataCollections, getDataAccessor } from './utils';
import { ExportPdf } from './ExportPdf';
@@ -19,7 +18,6 @@ export class ExportResourceService {
constructor(
private readonly exportAls: ExportAls,
private readonly exportPdf: ExportPdf,
private readonly exportableResources: ExportableResources,
private readonly resourceService: ResourceService,
private readonly moduleRef: ModuleRef,
) {}

View File

@@ -1,3 +1,5 @@
import { Global } from "@nestjs/common";
const exportableModels = new Map<string, boolean>();
const exportableService = new Map<string, any>()
@@ -15,6 +17,9 @@ export function ExportableModel() {
export function ExportableService({ name }: { name: string }) {
return function (target: any) {
exportableService.set(name, target);
// Apply the @Global() decorator to make the service globally available
Global()(target);
};
}