@nocobase/server 2.0.0-alpha.7 → 2.0.0-alpha.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/acl/available-action.js +1 -1
- package/lib/aes-encryptor.d.ts +1 -0
- package/lib/aes-encryptor.js +12 -5
- package/lib/app-command.d.ts +1 -0
- package/lib/app-command.js +3 -0
- package/lib/app-supervisor/app-options-factory.d.ts +80 -0
- package/lib/app-supervisor/app-options-factory.js +91 -0
- package/lib/app-supervisor/condition-registry.d.ts +18 -0
- package/lib/app-supervisor/condition-registry.js +60 -0
- package/lib/app-supervisor/db-creator.d.ts +16 -0
- package/lib/app-supervisor/db-creator.js +163 -0
- package/lib/app-supervisor/db-drivers.d.ts +11 -0
- package/lib/app-supervisor/db-drivers.js +52 -0
- package/lib/app-supervisor/index.d.ts +161 -0
- package/lib/app-supervisor/index.js +690 -0
- package/lib/app-supervisor/main-only-adapter.d.ts +37 -0
- package/lib/app-supervisor/main-only-adapter.js +156 -0
- package/lib/app-supervisor/types.d.ts +161 -0
- package/lib/app-supervisor/types.js +24 -0
- package/lib/application.d.ts +10 -7
- package/lib/application.js +30 -18
- package/lib/commands/index.js +2 -0
- package/lib/commands/pm.js +11 -0
- package/lib/commands/repair.d.ts +11 -0
- package/lib/commands/repair.js +43 -0
- package/lib/commands/start.js +1 -1
- package/lib/event-queue.d.ts +8 -1
- package/lib/event-queue.js +25 -22
- package/lib/gateway/errors.js +50 -12
- package/lib/gateway/index.d.ts +8 -0
- package/lib/gateway/index.js +80 -16
- package/lib/gateway/ipc-socket-server.js +1 -1
- package/lib/gateway/ws-server.js +6 -2
- package/lib/helper.d.ts +359 -0
- package/lib/helper.js +78 -3
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -3
- package/lib/locale/locale.js +1 -1
- package/lib/locale/resource.js +6 -9
- package/lib/main-data-source.d.ts +11 -0
- package/lib/main-data-source.js +128 -0
- package/lib/middlewares/data-template.js +1 -6
- package/lib/middlewares/parse-variables.js +2 -49
- package/lib/plugin-manager/deps.js +2 -2
- package/lib/plugin-manager/options/resource.js +52 -25
- package/lib/plugin-manager/plugin-manager.d.ts +1 -0
- package/lib/plugin-manager/plugin-manager.js +36 -1
- package/lib/pub-sub-manager/pub-sub-manager.d.ts +1 -1
- package/lib/pub-sub-manager/pub-sub-manager.js +14 -20
- package/lib/redis-connection-manager.d.ts +15 -5
- package/lib/redis-connection-manager.js +117 -24
- package/lib/snowflake-id-field.d.ts +2 -1
- package/lib/snowflake-id-field.js +2 -2
- package/package.json +18 -17
- package/lib/app-supervisor.d.ts +0 -69
- package/lib/app-supervisor.js +0 -299
- package/lib/background-job-manager.d.ts +0 -40
- package/lib/background-job-manager.js +0 -111
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
/// <reference types="node" />
|
|
10
|
+
/// <reference types="node" />
|
|
11
|
+
/// <reference types="node" />
|
|
12
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
13
|
+
import { AsyncEmitter } from '@nocobase/utils';
|
|
14
|
+
import { EventEmitter } from 'events';
|
|
15
|
+
import Application, { ApplicationOptions } from '../application';
|
|
16
|
+
import type { AppDiscoveryAdapter, AppProcessAdapter, AppStatus, EnvironmentInfo, GetAppOptions, ProcessCommand, AppDbCreator, AppOptionsFactory, AppDbCreatorOptions, AppCommandAdapter, AppModel, BootstrapLock } from './types';
|
|
17
|
+
import { Predicate } from './condition-registry';
|
|
18
|
+
import { PubSubManagerPublishOptions } from '../pub-sub-manager';
|
|
19
|
+
import { Transaction, Transactionable } from '@nocobase/database';
|
|
20
|
+
import { SystemLogger } from '@nocobase/logger';
|
|
21
|
+
import AesEncryptor from '../aes-encryptor';
|
|
22
|
+
export type AppDiscoveryAdapterFactory = (context: {
|
|
23
|
+
supervisor: AppSupervisor;
|
|
24
|
+
}) => AppDiscoveryAdapter;
|
|
25
|
+
export type AppProcessAdapterFactory = (context: {
|
|
26
|
+
supervisor: AppSupervisor;
|
|
27
|
+
}) => AppProcessAdapter;
|
|
28
|
+
export type AppCommandAdapterFactory = (context: {
|
|
29
|
+
supervisor: AppSupervisor;
|
|
30
|
+
}) => AppCommandAdapter;
|
|
31
|
+
export declare class AppSupervisor extends EventEmitter implements AsyncEmitter {
|
|
32
|
+
private static instance;
|
|
33
|
+
private static discoveryAdapterFactories;
|
|
34
|
+
private static processAdapterFactories;
|
|
35
|
+
private static commandAdapterFactories;
|
|
36
|
+
private static defaultDiscoveryAdapterName;
|
|
37
|
+
private static defaultProcessAdapterName;
|
|
38
|
+
private static defaultCommandAdapterName;
|
|
39
|
+
runningMode: 'single' | 'multiple';
|
|
40
|
+
singleAppName: string | null;
|
|
41
|
+
logger: SystemLogger;
|
|
42
|
+
aesEncryptor?: AesEncryptor;
|
|
43
|
+
emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
|
|
44
|
+
private discoveryAdapter;
|
|
45
|
+
private processAdapter;
|
|
46
|
+
private commandAdapter;
|
|
47
|
+
private discoveryAdapterName;
|
|
48
|
+
private processAdapterName;
|
|
49
|
+
private commandAdapterName;
|
|
50
|
+
private appDbCreator;
|
|
51
|
+
appOptionsFactory: AppOptionsFactory;
|
|
52
|
+
private environmentHeartbeatInterval;
|
|
53
|
+
private environmentHeartbeatTimer;
|
|
54
|
+
private constructor();
|
|
55
|
+
private resolveDiscoveryAdapterName;
|
|
56
|
+
private resolveProcessAdapterName;
|
|
57
|
+
private resolveCommandAdapterName;
|
|
58
|
+
private createDiscoveryAdapter;
|
|
59
|
+
private isProcessCapableAdapter;
|
|
60
|
+
private createProcessAdapter;
|
|
61
|
+
private createCommandAdapter;
|
|
62
|
+
static registerDiscoveryAdapter(name: string, factory: AppDiscoveryAdapterFactory): void;
|
|
63
|
+
static registerProcessAdapter(name: string, factory: AppProcessAdapterFactory): void;
|
|
64
|
+
static registerCommandAdapter(name: string, factory: AppCommandAdapterFactory): void;
|
|
65
|
+
static setDefaultDiscoveryAdapter(name: string): void;
|
|
66
|
+
static setDefaultProcessAdapter(name: string): void;
|
|
67
|
+
static setDefaultCommandAdapter(name: string): void;
|
|
68
|
+
static getInstance(): AppSupervisor;
|
|
69
|
+
get apps(): Record<string, Application>;
|
|
70
|
+
get appStatus(): Record<string, AppStatus>;
|
|
71
|
+
get appErrors(): Record<string, Error>;
|
|
72
|
+
get lastSeenAt(): Map<string, number>;
|
|
73
|
+
get lastMaintainingMessage(): Record<string, string>;
|
|
74
|
+
get statusBeforeCommanding(): Record<string, AppStatus>;
|
|
75
|
+
get environmentName(): string;
|
|
76
|
+
get environmentUrl(): string;
|
|
77
|
+
get environmentProxyUrl(): string;
|
|
78
|
+
getProcessAdapter(): AppProcessAdapter;
|
|
79
|
+
getDiscoveryAdapter(): AppDiscoveryAdapter;
|
|
80
|
+
registerAppDbCreator(condition: Predicate<AppDbCreatorOptions>, creator: AppDbCreator, priority?: number): void;
|
|
81
|
+
createDatabase(options: AppDbCreatorOptions): Promise<void>;
|
|
82
|
+
setAppOptionsFactory(factory: AppOptionsFactory): void;
|
|
83
|
+
bootstrapApp(appName: string): Promise<void>;
|
|
84
|
+
initApp({ appName, options }: {
|
|
85
|
+
appName: string;
|
|
86
|
+
options?: {
|
|
87
|
+
upgrading?: boolean;
|
|
88
|
+
};
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
setAppError(appName: string, error: Error): void;
|
|
91
|
+
hasAppError(appName: string): boolean;
|
|
92
|
+
clearAppError(appName: string): void;
|
|
93
|
+
reset(): Promise<void>;
|
|
94
|
+
destroy(): Promise<void>;
|
|
95
|
+
getAppStatus(appName: string, defaultStatus?: AppStatus): Promise<AppStatus>;
|
|
96
|
+
setAppStatus(appName: string, status: AppStatus, options?: {}): Promise<void>;
|
|
97
|
+
clearAppStatus(appName: string): Promise<void>;
|
|
98
|
+
getAppsStatuses(appNames?: string[]): Promise<import("./types").AppStatusesResult>;
|
|
99
|
+
getBootstrapLock(appName: string): Promise<BootstrapLock | null>;
|
|
100
|
+
registerApp({ appModel, mainApp, hook }: {
|
|
101
|
+
appModel: AppModel;
|
|
102
|
+
mainApp?: Application;
|
|
103
|
+
hook?: boolean;
|
|
104
|
+
}): Application<import("../application").DefaultState, import("../application").DefaultContext>;
|
|
105
|
+
bootMainApp(options: ApplicationOptions): Application<import("../application").DefaultState, import("../application").DefaultContext>;
|
|
106
|
+
setAppLastSeenAt(appName: string): Promise<void>;
|
|
107
|
+
getAppLastSeenAt(appName: string): Promise<number>;
|
|
108
|
+
addAppModel(appModel: AppModel): Promise<void>;
|
|
109
|
+
getAppModel(appName: string): Promise<AppModel>;
|
|
110
|
+
removeAppModel(appName: string): Promise<void>;
|
|
111
|
+
getAppNameByCName(cname: string): Promise<string>;
|
|
112
|
+
addAutoStartApps(environmentName: string, appNames: string[]): Promise<void>;
|
|
113
|
+
getAutoStartApps(): Promise<string[]>;
|
|
114
|
+
removeAutoStartApps(environmentName: string, appNames: string[]): Promise<void>;
|
|
115
|
+
addApp(app: Application): Application<import("../application").DefaultState, import("../application").DefaultContext>;
|
|
116
|
+
getApp(appName: string, options?: GetAppOptions): Promise<Application<import("../application").DefaultState, import("../application").DefaultContext>>;
|
|
117
|
+
hasApp(appName: string): boolean;
|
|
118
|
+
createApp(options: {
|
|
119
|
+
appModel: AppModel;
|
|
120
|
+
mainApp?: Application;
|
|
121
|
+
transaction?: Transaction;
|
|
122
|
+
}, context?: {
|
|
123
|
+
requestId: string;
|
|
124
|
+
}): Promise<void>;
|
|
125
|
+
startApp(appName: string, context?: {
|
|
126
|
+
requestId: string;
|
|
127
|
+
}): Promise<void>;
|
|
128
|
+
stopApp(appName: string, context?: {
|
|
129
|
+
requestId: string;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
removeApp(appName: string, context?: {
|
|
132
|
+
requestId: string;
|
|
133
|
+
}): Promise<void>;
|
|
134
|
+
upgradeApp(appName: string, context?: {
|
|
135
|
+
requestId: string;
|
|
136
|
+
}): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated
|
|
139
|
+
* use {#getApps} instead
|
|
140
|
+
*/
|
|
141
|
+
subApps(): Application<import("../application").DefaultState, import("../application").DefaultContext>[];
|
|
142
|
+
getApps(): Application<import("../application").DefaultState, import("../application").DefaultContext>[];
|
|
143
|
+
proxyWeb(appName: string, req: IncomingMessage, res: ServerResponse): Promise<boolean>;
|
|
144
|
+
proxyWs(req: IncomingMessage, socket: any, head: Buffer): Promise<boolean>;
|
|
145
|
+
registerEnvironment(mainApp: Application): Promise<void>;
|
|
146
|
+
unregisterEnvironment(): Promise<void>;
|
|
147
|
+
private normalizeEnvInfo;
|
|
148
|
+
listEnvironments(): Promise<EnvironmentInfo[]>;
|
|
149
|
+
getEnvironment(environmentName: string): Promise<EnvironmentInfo>;
|
|
150
|
+
heartbeatEnvironment(): Promise<void>;
|
|
151
|
+
dispatchCommand(command: ProcessCommand): Promise<void>;
|
|
152
|
+
registerCommandHandler(mainApp: Application): void;
|
|
153
|
+
sendSyncMessage(mainApp: Application, message: {
|
|
154
|
+
type: string;
|
|
155
|
+
appName: string;
|
|
156
|
+
}, options?: PubSubManagerPublishOptions & Transactionable): Promise<void>;
|
|
157
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
158
|
+
private bindAppEvents;
|
|
159
|
+
}
|
|
160
|
+
export type { AppDiscoveryAdapter, AppProcessAdapter, AppCommandAdapter, AppStatus, ProcessCommand, EnvironmentInfo, GetAppOptions, AppDbCreator, AppOptionsFactory, AppModel, AppModelOptions, BootstrapLock, } from './types';
|
|
161
|
+
export { MainOnlyAdapter } from './main-only-adapter';
|