mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat: export resource data to csv, xlsx
This commit is contained in:
44
packages/server/src/services/Export/ExportResources.ts
Normal file
44
packages/server/src/services/Export/ExportResources.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user