@nocobase/server 2.2.0-beta.1 → 2.2.0-beta.11
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/app-supervisor/index.d.ts +9 -0
- package/lib/app-supervisor/index.js +53 -0
- package/lib/app-supervisor/main-only-adapter.d.ts +9 -0
- package/lib/app-supervisor/main-only-adapter.js +42 -0
- package/lib/app-supervisor/types.d.ts +7 -0
- package/lib/plugin-manager/deps.js +1 -1
- package/lib/plugin-manager/findPackageNames.js +1 -0
- package/lib/plugin-manager/options/resource.js +22 -4
- package/lib/plugin-manager/plugin-manager.js +1 -0
- package/lib/plugin.js +1 -1
- package/package.json +18 -18
|
@@ -49,6 +49,7 @@ export declare class AppSupervisor extends EventEmitter implements AsyncEmitter
|
|
|
49
49
|
private commandAdapterName;
|
|
50
50
|
private appDbCreator;
|
|
51
51
|
private appConditions;
|
|
52
|
+
private appSsoIssuer?;
|
|
52
53
|
appOptionsFactory: AppOptionsFactory;
|
|
53
54
|
private environmentHeartbeatInterval;
|
|
54
55
|
private environmentHeartbeatTimer;
|
|
@@ -81,6 +82,8 @@ export declare class AppSupervisor extends EventEmitter implements AsyncEmitter
|
|
|
81
82
|
registerAppDbCreator(condition: Predicate<AppDbCreatorOptions>, creator: AppDbCreator, priority?: number): void;
|
|
82
83
|
createDatabase(options: AppDbCreatorOptions): Promise<void>;
|
|
83
84
|
setAppOptionsFactory(factory: AppOptionsFactory): void;
|
|
85
|
+
setAppSsoIssuer(issuer?: string): void;
|
|
86
|
+
getAppSsoIssuer(): string;
|
|
84
87
|
bootstrapApp(appName: string): Promise<void>;
|
|
85
88
|
initApp({ appName, options }: {
|
|
86
89
|
appName: string;
|
|
@@ -108,6 +111,12 @@ export declare class AppSupervisor extends EventEmitter implements AsyncEmitter
|
|
|
108
111
|
getAppLastSeenAt(appName: string): Promise<number>;
|
|
109
112
|
addAppModel(appModel: AppModel): Promise<void>;
|
|
110
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[]>>;
|
|
111
120
|
registerAppCondition(name: string, condition: AppCondition): void;
|
|
112
121
|
unregisterAppCondition(name: string): void;
|
|
113
122
|
getAppCondition(name: string): AppCondition;
|
|
@@ -70,6 +70,7 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
70
70
|
commandAdapterName;
|
|
71
71
|
appDbCreator = new import_condition_registry.ConditionalRegistry();
|
|
72
72
|
appConditions = /* @__PURE__ */ new Map();
|
|
73
|
+
appSsoIssuer;
|
|
73
74
|
appOptionsFactory = import_app_options_factory.appOptionsFactory;
|
|
74
75
|
environmentHeartbeatInterval = 2 * 60 * 1e3;
|
|
75
76
|
environmentHeartbeatTimer = null;
|
|
@@ -228,6 +229,13 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
228
229
|
setAppOptionsFactory(factory) {
|
|
229
230
|
this.appOptionsFactory = factory ?? import_app_options_factory.appOptionsFactory;
|
|
230
231
|
}
|
|
232
|
+
setAppSsoIssuer(issuer) {
|
|
233
|
+
const normalized = String(issuer || "").trim().replace(/\/+$/, "");
|
|
234
|
+
this.appSsoIssuer = normalized || void 0;
|
|
235
|
+
}
|
|
236
|
+
getAppSsoIssuer() {
|
|
237
|
+
return this.appSsoIssuer;
|
|
238
|
+
}
|
|
231
239
|
async bootstrapApp(appName) {
|
|
232
240
|
return this.processAdapter.bootstrapApp(appName);
|
|
233
241
|
}
|
|
@@ -421,6 +429,51 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
421
429
|
async getAppModel(appName) {
|
|
422
430
|
return this.discoveryAdapter.getAppModel(appName);
|
|
423
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
|
+
}
|
|
424
477
|
registerAppCondition(name, condition) {
|
|
425
478
|
this.appConditions.set(name, condition);
|
|
426
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>;
|
|
@@ -302,12 +302,19 @@ var resource_default = {
|
|
|
302
302
|
if (!keys.length) {
|
|
303
303
|
ctx.throw(400, "plugin name invalid");
|
|
304
304
|
}
|
|
305
|
+
for (const key of keys) {
|
|
306
|
+
try {
|
|
307
|
+
(0, import_utils2.assertSafePluginPackageName)(key);
|
|
308
|
+
} catch (error) {
|
|
309
|
+
ctx.throw(400, "plugin name invalid");
|
|
310
|
+
}
|
|
311
|
+
}
|
|
305
312
|
const awaitResponse = coerceAwaitResponse(awaitResponseRaw);
|
|
306
313
|
const argv = ["pm", "enable", ...keys];
|
|
307
314
|
if (awaitResponse) {
|
|
308
315
|
await app.runAsCLI(argv, { from: "user", throwError: true });
|
|
309
316
|
} else {
|
|
310
|
-
|
|
317
|
+
app.runAsCLI(argv, { from: "user" }).catch((err) => {
|
|
311
318
|
app.log.error(err);
|
|
312
319
|
});
|
|
313
320
|
}
|
|
@@ -326,7 +333,7 @@ var resource_default = {
|
|
|
326
333
|
if (awaitResponse) {
|
|
327
334
|
await app.runAsCLI(argv, { from: "user", throwError: true });
|
|
328
335
|
} else {
|
|
329
|
-
|
|
336
|
+
app.runAsCLI(argv, { from: "user" }).catch((err) => {
|
|
330
337
|
app.log.error(err);
|
|
331
338
|
});
|
|
332
339
|
}
|
|
@@ -344,7 +351,7 @@ var resource_default = {
|
|
|
344
351
|
await next();
|
|
345
352
|
},
|
|
346
353
|
async list(ctx, next) {
|
|
347
|
-
const { mode } = ctx.action.params;
|
|
354
|
+
const { mode, v2 } = ctx.action.params;
|
|
348
355
|
if (mode === "summary") {
|
|
349
356
|
ctx.body = await (0, import_utils2.pmListSummary)(ctx.app);
|
|
350
357
|
return next();
|
|
@@ -352,7 +359,18 @@ var resource_default = {
|
|
|
352
359
|
const locale = ctx.getCurrentLocale();
|
|
353
360
|
const pm = ctx.app.pm;
|
|
354
361
|
const plugin = pm.get("nocobase");
|
|
355
|
-
|
|
362
|
+
const plugins = await plugin.getAllPlugins(locale);
|
|
363
|
+
ctx.body = plugins.filter((item) => {
|
|
364
|
+
var _a;
|
|
365
|
+
if (process.env.NOCOBASE_SHOW_DEPRECATED_PLUGINS === "true") {
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
if (!v2) {
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
const nocobaseConfig = ((_a = item == null ? void 0 : item.packageJson) == null ? void 0 : _a.nocobase) || {};
|
|
372
|
+
return nocobaseConfig.internal !== true && nocobaseConfig.deprecated !== true;
|
|
373
|
+
});
|
|
356
374
|
await next();
|
|
357
375
|
},
|
|
358
376
|
async listEnabled(ctx, next) {
|
package/lib/plugin.js
CHANGED
|
@@ -276,7 +276,7 @@ const _Plugin = class _Plugin {
|
|
|
276
276
|
"fr-FR": "fr/"
|
|
277
277
|
};
|
|
278
278
|
if (packageName.startsWith("@nocobase/plugin-")) {
|
|
279
|
-
packageJson.homepage = `https://
|
|
279
|
+
packageJson.homepage = `https://docs.nocobase.com/${langMap[locale] || ""}plugins/${packageName}`;
|
|
280
280
|
}
|
|
281
281
|
const results = {
|
|
282
282
|
...this.options,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.2.0-beta.
|
|
3
|
+
"version": "2.2.0-beta.11",
|
|
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-beta.
|
|
14
|
-
"@nocobase/actions": "2.2.0-beta.
|
|
15
|
-
"@nocobase/ai": "2.2.0-beta.
|
|
16
|
-
"@nocobase/auth": "2.2.0-beta.
|
|
17
|
-
"@nocobase/cache": "2.2.0-beta.
|
|
18
|
-
"@nocobase/data-source-manager": "2.2.0-beta.
|
|
19
|
-
"@nocobase/database": "2.2.0-beta.
|
|
20
|
-
"@nocobase/evaluators": "2.2.0-beta.
|
|
21
|
-
"@nocobase/lock-manager": "2.2.0-beta.
|
|
22
|
-
"@nocobase/logger": "2.2.0-beta.
|
|
23
|
-
"@nocobase/resourcer": "2.2.0-beta.
|
|
24
|
-
"@nocobase/sdk": "2.2.0-beta.
|
|
25
|
-
"@nocobase/snowflake-id": "2.2.0-beta.
|
|
26
|
-
"@nocobase/telemetry": "2.2.0-beta.
|
|
27
|
-
"@nocobase/utils": "2.2.0-beta.
|
|
13
|
+
"@nocobase/acl": "2.2.0-beta.11",
|
|
14
|
+
"@nocobase/actions": "2.2.0-beta.11",
|
|
15
|
+
"@nocobase/ai": "2.2.0-beta.11",
|
|
16
|
+
"@nocobase/auth": "2.2.0-beta.11",
|
|
17
|
+
"@nocobase/cache": "2.2.0-beta.11",
|
|
18
|
+
"@nocobase/data-source-manager": "2.2.0-beta.11",
|
|
19
|
+
"@nocobase/database": "2.2.0-beta.11",
|
|
20
|
+
"@nocobase/evaluators": "2.2.0-beta.11",
|
|
21
|
+
"@nocobase/lock-manager": "2.2.0-beta.11",
|
|
22
|
+
"@nocobase/logger": "2.2.0-beta.11",
|
|
23
|
+
"@nocobase/resourcer": "2.2.0-beta.11",
|
|
24
|
+
"@nocobase/sdk": "2.2.0-beta.11",
|
|
25
|
+
"@nocobase/snowflake-id": "2.2.0-beta.11",
|
|
26
|
+
"@nocobase/telemetry": "2.2.0-beta.11",
|
|
27
|
+
"@nocobase/utils": "2.2.0-beta.11",
|
|
28
28
|
"@types/decompress": "4.2.7",
|
|
29
29
|
"@types/ini": "^1.3.31",
|
|
30
30
|
"@types/koa-send": "^4.1.3",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"koa-send": "^5.0.1",
|
|
48
48
|
"koa-static": "^5.0.0",
|
|
49
49
|
"lodash": "^4.17.21",
|
|
50
|
-
"multer": "^1.
|
|
50
|
+
"multer": "^2.1.1",
|
|
51
51
|
"nanoid": "^3.3.11",
|
|
52
52
|
"p-queue": "^6.6.2",
|
|
53
53
|
"redis": "^5.10.0",
|
|
@@ -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": "8dab25af2bb83a81da68158d0dcf836f96103d61"
|
|
65
65
|
}
|