@nocobase/server 2.2.52 → 2.2.53
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.
|
@@ -43,6 +43,7 @@ export declare class AppSupervisor extends EventEmitter implements AsyncEmitter
|
|
|
43
43
|
emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
|
|
44
44
|
private discoveryAdapter;
|
|
45
45
|
private processAdapter;
|
|
46
|
+
private readonly syncedStopAppName;
|
|
46
47
|
private commandAdapter;
|
|
47
48
|
private discoveryAdapterName;
|
|
48
49
|
private processAdapterName;
|
|
@@ -43,6 +43,7 @@ __export(app_supervisor_exports, {
|
|
|
43
43
|
MainOnlyAdapter: () => import_main_only_adapter2.MainOnlyAdapter
|
|
44
44
|
});
|
|
45
45
|
module.exports = __toCommonJS(app_supervisor_exports);
|
|
46
|
+
var import_node_async_hooks = require("node:async_hooks");
|
|
46
47
|
var import_lodash = __toESM(require("lodash"));
|
|
47
48
|
var import_utils = require("@nocobase/utils");
|
|
48
49
|
var import_events = require("events");
|
|
@@ -64,6 +65,7 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
64
65
|
aesEncryptor;
|
|
65
66
|
discoveryAdapter;
|
|
66
67
|
processAdapter;
|
|
68
|
+
syncedStopAppName = new import_node_async_hooks.AsyncLocalStorage();
|
|
67
69
|
commandAdapter;
|
|
68
70
|
discoveryAdapterName;
|
|
69
71
|
processAdapterName;
|
|
@@ -352,6 +354,9 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
352
354
|
});
|
|
353
355
|
});
|
|
354
356
|
app.on("afterStop", async () => {
|
|
357
|
+
if (this.syncedStopAppName.getStore() === appName) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
355
360
|
await this.sendSyncMessage(mainApp, {
|
|
356
361
|
type: "app:stopped",
|
|
357
362
|
appName
|
|
@@ -396,7 +401,9 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
396
401
|
}
|
|
397
402
|
if (type === "app:stopped") {
|
|
398
403
|
const { appName } = message;
|
|
399
|
-
|
|
404
|
+
if (this.hasApp(appName)) {
|
|
405
|
+
await this.syncedStopAppName.run(appName, () => this.stopApp(appName));
|
|
406
|
+
}
|
|
400
407
|
}
|
|
401
408
|
if (type === "app:removed") {
|
|
402
409
|
const { appName } = message;
|
|
@@ -43,10 +43,13 @@ type Action = string | {
|
|
|
43
43
|
getUserInfo?: (ctx: Context) => Promise<UserInfo>;
|
|
44
44
|
getSourceAndTarget?: (ctx: Context) => Promise<SourceAndTarget>;
|
|
45
45
|
};
|
|
46
|
+
type MetadataSanitizer = (metadata: NonNullable<AuditLog['metadata']>) => NonNullable<AuditLog['metadata']>;
|
|
46
47
|
export declare class AuditManager {
|
|
48
|
+
private readonly metadataSanitizers;
|
|
47
49
|
logger: AuditLogger;
|
|
48
50
|
resources: Map<string, Map<string, Action>>;
|
|
49
51
|
constructor();
|
|
52
|
+
registerMetadataSanitizer(dataSource: string, resource: string, actions: string[], sanitize: MetadataSanitizer): void;
|
|
50
53
|
setLogger(logger: AuditLogger): void;
|
|
51
54
|
/**
|
|
52
55
|
* 注册需要参与审计的资源和操作,支持几种写法
|
|
@@ -47,11 +47,17 @@ function isStream(obj) {
|
|
|
47
47
|
}
|
|
48
48
|
__name(isStream, "isStream");
|
|
49
49
|
const _AuditManager = class _AuditManager {
|
|
50
|
+
metadataSanitizers = /* @__PURE__ */ new Map();
|
|
50
51
|
logger;
|
|
51
52
|
resources;
|
|
52
53
|
constructor() {
|
|
53
54
|
this.resources = /* @__PURE__ */ new Map();
|
|
54
55
|
}
|
|
56
|
+
registerMetadataSanitizer(dataSource, resource, actions, sanitize) {
|
|
57
|
+
for (const action of actions) {
|
|
58
|
+
this.metadataSanitizers.set(`${dataSource}:${resource}:${action}`, sanitize);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
55
61
|
setLogger(logger) {
|
|
56
62
|
this.logger = logger;
|
|
57
63
|
}
|
|
@@ -253,7 +259,7 @@ const _AuditManager = class _AuditManager {
|
|
|
253
259
|
return auditLog;
|
|
254
260
|
}
|
|
255
261
|
async output(ctx, reqId, metadata) {
|
|
256
|
-
var _a;
|
|
262
|
+
var _a, _b;
|
|
257
263
|
try {
|
|
258
264
|
if (!ctx.action) {
|
|
259
265
|
return;
|
|
@@ -302,9 +308,13 @@ const _AuditManager = class _AuditManager {
|
|
|
302
308
|
}
|
|
303
309
|
}
|
|
304
310
|
}
|
|
311
|
+
const sanitize = this.metadataSanitizers.get(`${((_a = ctx.dataSource) == null ? void 0 : _a.name) || "main"}:${resourceName}:${actionName}`);
|
|
312
|
+
if (sanitize) {
|
|
313
|
+
auditLog.metadata = sanitize(auditLog.metadata);
|
|
314
|
+
}
|
|
305
315
|
this.logger.log(auditLog);
|
|
306
316
|
} catch (err) {
|
|
307
|
-
(
|
|
317
|
+
(_b = ctx.log) == null ? void 0 : _b.error(err);
|
|
308
318
|
}
|
|
309
319
|
}
|
|
310
320
|
// 中间件
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.53",
|
|
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.
|
|
14
|
-
"@nocobase/actions": "2.2.
|
|
15
|
-
"@nocobase/ai": "2.2.
|
|
16
|
-
"@nocobase/auth": "2.2.
|
|
17
|
-
"@nocobase/cache": "2.2.
|
|
18
|
-
"@nocobase/data-source-manager": "2.2.
|
|
19
|
-
"@nocobase/database": "2.2.
|
|
20
|
-
"@nocobase/evaluators": "2.2.
|
|
21
|
-
"@nocobase/lock-manager": "2.2.
|
|
22
|
-
"@nocobase/logger": "2.2.
|
|
23
|
-
"@nocobase/resourcer": "2.2.
|
|
24
|
-
"@nocobase/sdk": "2.2.
|
|
25
|
-
"@nocobase/snowflake-id": "2.2.
|
|
26
|
-
"@nocobase/telemetry": "2.2.
|
|
27
|
-
"@nocobase/utils": "2.2.
|
|
13
|
+
"@nocobase/acl": "2.2.53",
|
|
14
|
+
"@nocobase/actions": "2.2.53",
|
|
15
|
+
"@nocobase/ai": "2.2.53",
|
|
16
|
+
"@nocobase/auth": "2.2.53",
|
|
17
|
+
"@nocobase/cache": "2.2.53",
|
|
18
|
+
"@nocobase/data-source-manager": "2.2.53",
|
|
19
|
+
"@nocobase/database": "2.2.53",
|
|
20
|
+
"@nocobase/evaluators": "2.2.53",
|
|
21
|
+
"@nocobase/lock-manager": "2.2.53",
|
|
22
|
+
"@nocobase/logger": "2.2.53",
|
|
23
|
+
"@nocobase/resourcer": "2.2.53",
|
|
24
|
+
"@nocobase/sdk": "2.2.53",
|
|
25
|
+
"@nocobase/snowflake-id": "2.2.53",
|
|
26
|
+
"@nocobase/telemetry": "2.2.53",
|
|
27
|
+
"@nocobase/utils": "2.2.53",
|
|
28
28
|
"@types/ini": "^1.3.31",
|
|
29
29
|
"@types/koa-send": "^4.1.3",
|
|
30
30
|
"@types/multer": "^1.4.12",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"@types/serve-handler": "^6.1.1",
|
|
61
61
|
"@types/ws": "^8.5.5"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "ce368f267e6e2d422a35ab108f7d79fc04065857"
|
|
64
64
|
}
|