@nocobase/server 2.2.0-alpha.3 → 2.2.0-alpha.5

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.
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "2.2.0-alpha.3",
3
+ "version": "2.2.0-alpha.5",
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.3",
14
- "@nocobase/actions": "2.2.0-alpha.3",
15
- "@nocobase/ai": "2.2.0-alpha.3",
16
- "@nocobase/auth": "2.2.0-alpha.3",
17
- "@nocobase/cache": "2.2.0-alpha.3",
18
- "@nocobase/data-source-manager": "2.2.0-alpha.3",
19
- "@nocobase/database": "2.2.0-alpha.3",
20
- "@nocobase/evaluators": "2.2.0-alpha.3",
21
- "@nocobase/lock-manager": "2.2.0-alpha.3",
22
- "@nocobase/logger": "2.2.0-alpha.3",
23
- "@nocobase/resourcer": "2.2.0-alpha.3",
24
- "@nocobase/sdk": "2.2.0-alpha.3",
25
- "@nocobase/snowflake-id": "2.2.0-alpha.3",
26
- "@nocobase/telemetry": "2.2.0-alpha.3",
27
- "@nocobase/utils": "2.2.0-alpha.3",
13
+ "@nocobase/acl": "2.2.0-alpha.5",
14
+ "@nocobase/actions": "2.2.0-alpha.5",
15
+ "@nocobase/ai": "2.2.0-alpha.5",
16
+ "@nocobase/auth": "2.2.0-alpha.5",
17
+ "@nocobase/cache": "2.2.0-alpha.5",
18
+ "@nocobase/data-source-manager": "2.2.0-alpha.5",
19
+ "@nocobase/database": "2.2.0-alpha.5",
20
+ "@nocobase/evaluators": "2.2.0-alpha.5",
21
+ "@nocobase/lock-manager": "2.2.0-alpha.5",
22
+ "@nocobase/logger": "2.2.0-alpha.5",
23
+ "@nocobase/resourcer": "2.2.0-alpha.5",
24
+ "@nocobase/sdk": "2.2.0-alpha.5",
25
+ "@nocobase/snowflake-id": "2.2.0-alpha.5",
26
+ "@nocobase/telemetry": "2.2.0-alpha.5",
27
+ "@nocobase/utils": "2.2.0-alpha.5",
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": "e3ec19361fd7981af9fe2a7f24ad335025cbefcd"
64
+ "gitHead": "814ff497dd1233ca7218c9f7f2a016c2ead6516d"
65
65
  }