feat: export resource data to csv, xlsx

This commit is contained in:
Ahmed Bouhuolia
2024-04-29 23:45:11 +02:00
parent 4a713980bf
commit 8a96c41258
9 changed files with 345 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import Container, { Service } from 'typedi';
import { AccountsExportable } from '../Accounts/AccountsExportable';
import { ExportableRegistry } from './ExportRegistery';
import { ItemsImportable } from '../Items/ItemsImportable';
import { ItemsExportable } from '../Items/ItemsExportable';
@Service()
export class ExportableResources {
private static registry: ExportableRegistry;
constructor() {
this.boot();
}
/**
* Importable instances.
*/
private importables = [
{ resource: 'Account', exportable: AccountsExportable },
{ resource: 'Item', exportable: ItemsExportable },
];
/**
*
*/
public get registry() {
return ExportableResources.registry;
}
/**
* Boots all the registered importables.
*/
public boot() {
if (!ExportableResources.registry) {
const instance = ExportableRegistry.getInstance();
this.importables.forEach((importable) => {
const importableInstance = Container.get(importable.exportable);
instance.registerExportable(importable.resource, importableInstance);
});
ExportableResources.registry = instance;
}
}
}