@nocobase/server 2.2.0-alpha.4 → 2.2.0-alpha.6
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.
|
@@ -111,6 +111,12 @@ export declare class AppSupervisor extends EventEmitter implements AsyncEmitter
|
|
|
111
111
|
getAppLastSeenAt(appName: string): Promise<number>;
|
|
112
112
|
addAppModel(appModel: AppModel): Promise<void>;
|
|
113
113
|
getAppModel(appName: string): Promise<AppModel>;
|
|
114
|
+
listAppModels(): Promise<AppModel[]>;
|
|
115
|
+
setAppManifestItem(appName: string, namespace: string, itemKey: string, item: unknown): Promise<void>;
|
|
116
|
+
removeAppManifestItem(appName: string, namespace: string, itemKey: string): Promise<void>;
|
|
117
|
+
removeAppManifest(appName: string, namespace: string): Promise<void>;
|
|
118
|
+
getAppManifestItems<T = unknown>(appName: string, namespace: string): Promise<T[]>;
|
|
119
|
+
getAppManifests<T = unknown>(namespace: string, appNames: string[]): Promise<Record<string, T[]>>;
|
|
114
120
|
registerAppCondition(name: string, condition: AppCondition): void;
|
|
115
121
|
unregisterAppCondition(name: string): void;
|
|
116
122
|
getAppCondition(name: string): AppCondition;
|
|
@@ -429,6 +429,51 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
429
429
|
async getAppModel(appName) {
|
|
430
430
|
return this.discoveryAdapter.getAppModel(appName);
|
|
431
431
|
}
|
|
432
|
+
async listAppModels() {
|
|
433
|
+
if (typeof this.discoveryAdapter.listAppModels !== "function") {
|
|
434
|
+
return [];
|
|
435
|
+
}
|
|
436
|
+
return this.discoveryAdapter.listAppModels();
|
|
437
|
+
}
|
|
438
|
+
async setAppManifestItem(appName, namespace, itemKey, item) {
|
|
439
|
+
if (typeof this.discoveryAdapter.setAppManifestItem !== "function") {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
return this.discoveryAdapter.setAppManifestItem(appName, namespace, itemKey, item);
|
|
443
|
+
}
|
|
444
|
+
async removeAppManifestItem(appName, namespace, itemKey) {
|
|
445
|
+
if (typeof this.discoveryAdapter.removeAppManifestItem !== "function") {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
return this.discoveryAdapter.removeAppManifestItem(appName, namespace, itemKey);
|
|
449
|
+
}
|
|
450
|
+
async removeAppManifest(appName, namespace) {
|
|
451
|
+
if (typeof this.discoveryAdapter.removeAppManifest !== "function") {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
return this.discoveryAdapter.removeAppManifest(appName, namespace);
|
|
455
|
+
}
|
|
456
|
+
async getAppManifestItems(appName, namespace) {
|
|
457
|
+
if (typeof this.discoveryAdapter.getAppManifestItems !== "function") {
|
|
458
|
+
return [];
|
|
459
|
+
}
|
|
460
|
+
return this.discoveryAdapter.getAppManifestItems(appName, namespace);
|
|
461
|
+
}
|
|
462
|
+
async getAppManifests(namespace, appNames) {
|
|
463
|
+
if (typeof this.discoveryAdapter.getAppManifests === "function") {
|
|
464
|
+
return this.discoveryAdapter.getAppManifests(namespace, appNames);
|
|
465
|
+
}
|
|
466
|
+
const result = {};
|
|
467
|
+
await Promise.all(
|
|
468
|
+
appNames.map(async (appName) => {
|
|
469
|
+
const manifest = await this.getAppManifestItems(appName, namespace);
|
|
470
|
+
if (manifest.length > 0) {
|
|
471
|
+
result[appName] = manifest;
|
|
472
|
+
}
|
|
473
|
+
})
|
|
474
|
+
);
|
|
475
|
+
return result;
|
|
476
|
+
}
|
|
432
477
|
registerAppCondition(name, condition) {
|
|
433
478
|
this.appConditions.set(name, condition);
|
|
434
479
|
}
|
|
@@ -16,11 +16,18 @@ export declare class MainOnlyAdapter implements AppDiscoveryAdapter, AppProcessA
|
|
|
16
16
|
apps: Record<string, Application>;
|
|
17
17
|
status: AppStatus;
|
|
18
18
|
appErrors: Record<string, Error>;
|
|
19
|
+
private readonly appManifests;
|
|
19
20
|
constructor(supervisor: AppSupervisor);
|
|
20
21
|
getApp(appName: string, options?: GetAppOptions): Promise<Application<import("../application").DefaultState, import("../application").DefaultContext>>;
|
|
21
22
|
bootstrapApp(appName: string): Promise<void>;
|
|
22
23
|
addApp(app: Application): Application<import("../application").DefaultState, import("../application").DefaultContext>;
|
|
23
24
|
getApps(): Application<import("../application").DefaultState, import("../application").DefaultContext>[];
|
|
25
|
+
listAppModels(): Promise<any[]>;
|
|
26
|
+
setAppManifestItem(appName: string, namespace: string, itemKey: string, item: unknown): Promise<void>;
|
|
27
|
+
removeAppManifestItem(appName: string, namespace: string, itemKey: string): Promise<void>;
|
|
28
|
+
removeAppManifest(appName: string, namespace: string): Promise<void>;
|
|
29
|
+
getAppManifestItems<T = unknown>(appName: string, namespace: string): Promise<T[]>;
|
|
30
|
+
getAppManifests<T = unknown>(namespace: string, appNames: string[]): Promise<Record<string, T[]>>;
|
|
24
31
|
hasApp(appName: string): boolean;
|
|
25
32
|
startApp(appName: string): Promise<void>;
|
|
26
33
|
stopApp(appName: string): Promise<void>;
|
|
@@ -37,4 +44,6 @@ export declare class MainOnlyAdapter implements AppDiscoveryAdapter, AppProcessA
|
|
|
37
44
|
clearAppError(appName: string): void;
|
|
38
45
|
setAppLastSeenAt(): void;
|
|
39
46
|
getAppLastSeenAt(appName: string): any;
|
|
47
|
+
private getAppManifestKey;
|
|
48
|
+
private getOrCreateAppManifest;
|
|
40
49
|
}
|
|
@@ -39,6 +39,7 @@ const _MainOnlyAdapter = class _MainOnlyAdapter {
|
|
|
39
39
|
apps = {};
|
|
40
40
|
status;
|
|
41
41
|
appErrors = {};
|
|
42
|
+
appManifests = /* @__PURE__ */ new Map();
|
|
42
43
|
async getApp(appName, options = {}) {
|
|
43
44
|
if (appName !== "main") {
|
|
44
45
|
this.supervisor.logger.warn(`only main app is supported`, { method: "getApp", appName });
|
|
@@ -78,6 +79,34 @@ const _MainOnlyAdapter = class _MainOnlyAdapter {
|
|
|
78
79
|
getApps() {
|
|
79
80
|
return Object.values(this.apps);
|
|
80
81
|
}
|
|
82
|
+
async listAppModels() {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
async setAppManifestItem(appName, namespace, itemKey, item) {
|
|
86
|
+
const manifest = this.getOrCreateAppManifest(appName, namespace);
|
|
87
|
+
manifest.set(itemKey, item);
|
|
88
|
+
}
|
|
89
|
+
async removeAppManifestItem(appName, namespace, itemKey) {
|
|
90
|
+
var _a;
|
|
91
|
+
(_a = this.appManifests.get(this.getAppManifestKey(appName, namespace))) == null ? void 0 : _a.delete(itemKey);
|
|
92
|
+
}
|
|
93
|
+
async removeAppManifest(appName, namespace) {
|
|
94
|
+
this.appManifests.delete(this.getAppManifestKey(appName, namespace));
|
|
95
|
+
}
|
|
96
|
+
async getAppManifestItems(appName, namespace) {
|
|
97
|
+
var _a;
|
|
98
|
+
return Array.from(((_a = this.appManifests.get(this.getAppManifestKey(appName, namespace))) == null ? void 0 : _a.values()) || []);
|
|
99
|
+
}
|
|
100
|
+
async getAppManifests(namespace, appNames) {
|
|
101
|
+
const result = {};
|
|
102
|
+
for (const appName of appNames) {
|
|
103
|
+
const data = await this.getAppManifestItems(appName, namespace);
|
|
104
|
+
if (data.length > 0) {
|
|
105
|
+
result[appName] = data;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
81
110
|
hasApp(appName) {
|
|
82
111
|
if (appName !== "main") {
|
|
83
112
|
return false;
|
|
@@ -159,6 +188,19 @@ const _MainOnlyAdapter = class _MainOnlyAdapter {
|
|
|
159
188
|
getAppLastSeenAt(appName) {
|
|
160
189
|
return null;
|
|
161
190
|
}
|
|
191
|
+
getAppManifestKey(appName, namespace) {
|
|
192
|
+
return `${namespace}:${appName}`;
|
|
193
|
+
}
|
|
194
|
+
getOrCreateAppManifest(appName, namespace) {
|
|
195
|
+
const key = this.getAppManifestKey(appName, namespace);
|
|
196
|
+
const manifest = this.appManifests.get(key);
|
|
197
|
+
if (manifest) {
|
|
198
|
+
return manifest;
|
|
199
|
+
}
|
|
200
|
+
const nextManifest = /* @__PURE__ */ new Map();
|
|
201
|
+
this.appManifests.set(key, nextManifest);
|
|
202
|
+
return nextManifest;
|
|
203
|
+
}
|
|
162
204
|
};
|
|
163
205
|
__name(_MainOnlyAdapter, "MainOnlyAdapter");
|
|
164
206
|
let MainOnlyAdapter = _MainOnlyAdapter;
|
|
@@ -66,6 +66,7 @@ export type AppModel = {
|
|
|
66
66
|
environments?: string[];
|
|
67
67
|
options: AppModelOptions;
|
|
68
68
|
};
|
|
69
|
+
export type AppManifestValue = unknown;
|
|
69
70
|
export type AppCondition = {
|
|
70
71
|
filter?: Record<string, any>;
|
|
71
72
|
match?: (appModel: AppModel) => boolean;
|
|
@@ -115,11 +116,17 @@ export interface AppDiscoveryAdapter {
|
|
|
115
116
|
loadAppModels?(mainApp: Application): Promise<void>;
|
|
116
117
|
getAppsStatuses?(appNames?: string[]): Promise<AppStatusesResult> | AppStatusesResult;
|
|
117
118
|
getAppsByCondition?(conditionName: string, condition: AppCondition, options?: GetAppsByConditionOptions): Promise<string[]>;
|
|
119
|
+
listAppModels?(): Promise<AppModel[]>;
|
|
118
120
|
addAppsToCondition?(conditionName: string, environmentName: string, appNames: string[]): Promise<void>;
|
|
119
121
|
removeAppsFromCondition?(conditionName: string, environmentName: string, appNames: string[]): Promise<void>;
|
|
120
122
|
addAppModel?(appModel: AppModel): Promise<void>;
|
|
121
123
|
getAppModel?(appName: string): Promise<AppModel>;
|
|
122
124
|
removeAppModel?(appName: string): Promise<void>;
|
|
125
|
+
setAppManifestItem?(appName: string, namespace: string, itemKey: string, item: AppManifestValue): Promise<void>;
|
|
126
|
+
removeAppManifestItem?(appName: string, namespace: string, itemKey: string): Promise<void>;
|
|
127
|
+
removeAppManifest?(appName: string, namespace: string): Promise<void>;
|
|
128
|
+
getAppManifestItems?<T = AppManifestValue>(appName: string, namespace: string): Promise<T[]>;
|
|
129
|
+
getAppManifests?<T = AppManifestValue>(namespace: string, appNames: string[]): Promise<Record<string, T[]>>;
|
|
123
130
|
getAppNameByCName?(cname: string): Promise<string | null>;
|
|
124
131
|
registerEnvironment?(environment: EnvironmentInfo): Promise<boolean>;
|
|
125
132
|
unregisterEnvironment?(): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.6",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"@koa/cors": "^5.0.0",
|
|
11
11
|
"@koa/multer": "^3.1.0",
|
|
12
12
|
"@koa/router": "^13.1.0",
|
|
13
|
-
"@nocobase/acl": "2.2.0-alpha.
|
|
14
|
-
"@nocobase/actions": "2.2.0-alpha.
|
|
15
|
-
"@nocobase/ai": "2.2.0-alpha.
|
|
16
|
-
"@nocobase/auth": "2.2.0-alpha.
|
|
17
|
-
"@nocobase/cache": "2.2.0-alpha.
|
|
18
|
-
"@nocobase/data-source-manager": "2.2.0-alpha.
|
|
19
|
-
"@nocobase/database": "2.2.0-alpha.
|
|
20
|
-
"@nocobase/evaluators": "2.2.0-alpha.
|
|
21
|
-
"@nocobase/lock-manager": "2.2.0-alpha.
|
|
22
|
-
"@nocobase/logger": "2.2.0-alpha.
|
|
23
|
-
"@nocobase/resourcer": "2.2.0-alpha.
|
|
24
|
-
"@nocobase/sdk": "2.2.0-alpha.
|
|
25
|
-
"@nocobase/snowflake-id": "2.2.0-alpha.
|
|
26
|
-
"@nocobase/telemetry": "2.2.0-alpha.
|
|
27
|
-
"@nocobase/utils": "2.2.0-alpha.
|
|
13
|
+
"@nocobase/acl": "2.2.0-alpha.6",
|
|
14
|
+
"@nocobase/actions": "2.2.0-alpha.6",
|
|
15
|
+
"@nocobase/ai": "2.2.0-alpha.6",
|
|
16
|
+
"@nocobase/auth": "2.2.0-alpha.6",
|
|
17
|
+
"@nocobase/cache": "2.2.0-alpha.6",
|
|
18
|
+
"@nocobase/data-source-manager": "2.2.0-alpha.6",
|
|
19
|
+
"@nocobase/database": "2.2.0-alpha.6",
|
|
20
|
+
"@nocobase/evaluators": "2.2.0-alpha.6",
|
|
21
|
+
"@nocobase/lock-manager": "2.2.0-alpha.6",
|
|
22
|
+
"@nocobase/logger": "2.2.0-alpha.6",
|
|
23
|
+
"@nocobase/resourcer": "2.2.0-alpha.6",
|
|
24
|
+
"@nocobase/sdk": "2.2.0-alpha.6",
|
|
25
|
+
"@nocobase/snowflake-id": "2.2.0-alpha.6",
|
|
26
|
+
"@nocobase/telemetry": "2.2.0-alpha.6",
|
|
27
|
+
"@nocobase/utils": "2.2.0-alpha.6",
|
|
28
28
|
"@types/decompress": "4.2.7",
|
|
29
29
|
"@types/ini": "^1.3.31",
|
|
30
30
|
"@types/koa-send": "^4.1.3",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@types/serve-handler": "^6.1.1",
|
|
62
62
|
"@types/ws": "^8.5.5"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "f55b252811f6af01d08cd3814171867b70c8ef7a"
|
|
65
65
|
}
|