mirror of
https://github.com/nocobase/nocobase
synced 2024-11-17 09:19:30 +00:00
6b0ed79f51
* chore: dump plugin * chore: rename plugin * chore: add duplicator into preset * chore: tmp commit * feat: restore & dump action * feat: collection dump & restore * feat: collection dump & restore * fix: dump with json type * fix: dump uischema * chore: tmp commit * chore: tmp commit * feat: restore custom collections * chore: code * fix: build * chore: tmp commit * fix: pm.generateClientFile * feat: dump with user plugins * feat: restore ignore collection * feat: ignore user with rolesUsers * chore: client plugins * refactor: restore insert sql * chore: code format * feat: restore with sequelize insert query * fix: restore json field * fix: json restore * refactor: dumper * refactor: restorer * chore: dump file name * chore: dump file name * chore: dump message * fix: restore with jsonb fields * feat: field data writer * chore: code * feat: collection group manager * feat: duplicator client * feat: duplicator panel * chore: disable duplicator ui * feat: dump with inquirer * chore: dumper * chore: collection group manager * feat: restore with inquirer * chore: comment * chore: inquirer page size * feat: warning before restore * feat: sync postgres sequence id after import collection * chore: restore checked * feat: dump with through table * feat: restore with through table * feat: restore with sequence field * chore: graph collection manager collection group * fix: dump with no column tables * fix: dump empty table * fix: force remove workdir * chore: disable throw error when sync empty table * feat: support map field restore * fix: restore from pg dumped file * fix: dump with logic field * chore: console.log * chore: collection group * chore: handle import collection error * fix: dump migrations table * feat: display custom collection title * fix: restore collection title display * fix: dump iframe html * fix: dump with postgres inhertitance * fix: dump sql * chore: export snapshot field * fix: import with sequences * fix: import sequences * fix: storage Co-authored-by: chenos <chenlinxh@gmail.com>
82 lines
1.4 KiB
TypeScript
82 lines
1.4 KiB
TypeScript
import { Application } from './application';
|
|
import { InstallOptions } from './plugin-manager';
|
|
|
|
export interface PluginInterface {
|
|
beforeLoad?: () => void;
|
|
|
|
load();
|
|
|
|
getName(): string;
|
|
}
|
|
|
|
export interface PluginOptions {
|
|
activate?: boolean;
|
|
displayName?: string;
|
|
description?: string;
|
|
version?: string;
|
|
enabled?: boolean;
|
|
install?: (this: Plugin) => void;
|
|
load?: (this: Plugin) => void;
|
|
plugin?: typeof Plugin;
|
|
|
|
[key: string]: any;
|
|
}
|
|
|
|
export type PluginType = typeof Plugin;
|
|
|
|
export abstract class Plugin<O = any> implements PluginInterface {
|
|
options: any;
|
|
app: Application;
|
|
|
|
constructor(app: Application, options?: any) {
|
|
this.setOptions(options);
|
|
|
|
this.app = app;
|
|
this.setOptions(options);
|
|
this.afterAdd();
|
|
}
|
|
|
|
get db() {
|
|
return this.app.db;
|
|
}
|
|
|
|
get enabled() {
|
|
return this.options.enabled;
|
|
}
|
|
|
|
set enabled(value) {
|
|
this.options.enabled = value;
|
|
}
|
|
|
|
setOptions(options: any) {
|
|
this.options = options || {};
|
|
}
|
|
|
|
getName() {
|
|
return (this.options as any).name;
|
|
}
|
|
|
|
afterAdd() {}
|
|
|
|
beforeLoad() {}
|
|
|
|
async load() {}
|
|
|
|
async install(options?: InstallOptions) {}
|
|
|
|
async afterEnable() {}
|
|
|
|
async afterDisable() {}
|
|
|
|
async remove() {}
|
|
|
|
async importCollections(collectionsPath: string) {
|
|
await this.db.import({
|
|
directory: collectionsPath,
|
|
from: this.getName(),
|
|
});
|
|
}
|
|
}
|
|
|
|
export default Plugin;
|