2023-02-14 07:30:58 +00:00
|
|
|
import { Model, Transactionable } from '@nocobase/database';
|
2022-03-28 14:01:10 +00:00
|
|
|
import { Application } from '@nocobase/server';
|
2023-03-19 15:40:42 +00:00
|
|
|
import { AppOptionsFactory } from '../server';
|
2022-03-28 14:01:10 +00:00
|
|
|
|
2022-05-22 00:48:19 +00:00
|
|
|
export interface registerAppOptions extends Transactionable {
|
2022-03-28 14:01:10 +00:00
|
|
|
skipInstall?: boolean;
|
2023-02-14 07:30:58 +00:00
|
|
|
appOptionsFactory: AppOptionsFactory;
|
2022-03-28 14:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class ApplicationModel extends Model {
|
2023-08-24 09:47:45 +00:00
|
|
|
registerToSupervisor(mainApp: Application, options: registerAppOptions) {
|
2022-03-28 14:01:10 +00:00
|
|
|
const appName = this.get('name') as string;
|
2022-04-24 12:22:50 +00:00
|
|
|
const appOptions = (this.get('options') as any) || {};
|
2022-03-28 14:01:10 +00:00
|
|
|
|
2023-03-19 15:40:42 +00:00
|
|
|
const subAppOptions = {
|
2023-02-14 07:30:58 +00:00
|
|
|
...options.appOptionsFactory(appName, mainApp),
|
|
|
|
...appOptions,
|
2023-02-16 01:46:23 +00:00
|
|
|
name: appName,
|
2023-03-19 15:40:42 +00:00
|
|
|
};
|
2022-09-18 06:10:01 +00:00
|
|
|
|
2023-08-24 09:47:45 +00:00
|
|
|
return new Application(subAppOptions);
|
2022-03-28 14:01:10 +00:00
|
|
|
}
|
|
|
|
}
|