@nocobase/server 1.6.0-alpha.4 → 1.6.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.
@@ -15,8 +15,8 @@ import Database, { CollectionOptions, IDatabaseOptions } from '@nocobase/databas
15
15
  import { Logger, LoggerOptions, RequestLoggerOptions, SystemLogger, SystemLoggerOptions } from '@nocobase/logger';
16
16
  import { ResourceOptions, Resourcer } from '@nocobase/resourcer';
17
17
  import { Telemetry, TelemetryOptions } from '@nocobase/telemetry';
18
- import { AsyncEmitter, ToposortOptions } from '@nocobase/utils';
19
18
  import { LockManager, LockManagerOptions } from '@nocobase/lock-manager';
19
+ import { AsyncEmitter, ToposortOptions } from '@nocobase/utils';
20
20
  import { Command, CommandOptions, ParseOptions } from 'commander';
21
21
  import { IncomingMessage, ServerResponse } from 'http';
22
22
  import { i18n, InitOptions } from 'i18next';
@@ -49,8 +49,8 @@ var import_data_source_manager = require("@nocobase/data-source-manager");
49
49
  var import_database = __toESM(require("@nocobase/database"));
50
50
  var import_logger = require("@nocobase/logger");
51
51
  var import_telemetry = require("@nocobase/telemetry");
52
- var import_utils = require("@nocobase/utils");
53
52
  var import_lock_manager = require("@nocobase/lock-manager");
53
+ var import_utils = require("@nocobase/utils");
54
54
  var import_crypto = require("crypto");
55
55
  var import_glob = __toESM(require("glob"));
56
56
  var import_koa = __toESM(require("koa"));
@@ -76,6 +76,7 @@ var import_plugin_manager = require("./plugin-manager");
76
76
  var import_pub_sub_manager = require("./pub-sub-manager");
77
77
  var import_sync_message_manager = require("./sync-message-manager");
78
78
  var import_package = __toESM(require("../package.json"));
79
+ var import_available_action = require("./acl/available-action");
79
80
  var import_audit_manager = require("./audit-manager");
80
81
  const _Application = class _Application extends import_koa.default {
81
82
  constructor(options) {
@@ -863,6 +864,13 @@ const _Application = class _Application extends import_koa.default {
863
864
  name: "auth",
864
865
  actions: import_auth.actions
865
866
  });
867
+ this._dataSourceManager.afterAddDataSource((dataSource) => {
868
+ if (dataSource.collectionManager instanceof import_data_source_manager.SequelizeCollectionManager) {
869
+ for (const [actionName, actionParams] of Object.entries(import_available_action.availableActions)) {
870
+ dataSource.acl.setAvailableAction(actionName, actionParams);
871
+ }
872
+ }
873
+ });
866
874
  this._dataSourceManager.use(this._authManager.middleware(), { tag: "auth" });
867
875
  this._dataSourceManager.use(import_validate_filter_params.default, { tag: "validate-filter-params", before: ["auth"] });
868
876
  this._dataSourceManager.use(import_middlewares.parseVariables, {
@@ -260,6 +260,8 @@ const _AuditManager = class _AuditManager {
260
260
  const auditLog = this.formatAuditData(ctx);
261
261
  auditLog.uuid = reqId;
262
262
  auditLog.status = ctx.status;
263
+ const defaultMetaData = await this.getDefaultMetaData(ctx);
264
+ auditLog.metadata = { ...metadata, ...defaultMetaData };
263
265
  if (typeof action !== "string") {
264
266
  if (action.getUserInfo) {
265
267
  const userInfo = await action.getUserInfo(ctx);
@@ -274,10 +276,15 @@ const _AuditManager = class _AuditManager {
274
276
  }
275
277
  if (action.getMetaData) {
276
278
  const extra = await action.getMetaData(ctx);
277
- auditLog.metadata = { ...metadata, ...extra };
278
- } else {
279
- const defaultMetaData = await this.getDefaultMetaData(ctx);
280
- auditLog.metadata = { ...metadata, ...defaultMetaData };
279
+ if (extra) {
280
+ if (extra.request) {
281
+ auditLog.metadata.request = { ...auditLog.metadata.request, ...extra.request };
282
+ }
283
+ if (extra.response) {
284
+ auditLog.metadata.response = { ...auditLog.metadata.response, ...extra.response };
285
+ }
286
+ auditLog.metadata = { ...extra, ...auditLog.metadata };
287
+ }
281
288
  }
282
289
  if (action.getSourceAndTarget) {
283
290
  const sourceAndTarget = await action.getSourceAndTarget(ctx);
@@ -288,9 +295,6 @@ const _AuditManager = class _AuditManager {
288
295
  auditLog.targetRecordUK = sourceAndTarget.targetRecordUK;
289
296
  }
290
297
  }
291
- } else {
292
- const defaultMetaData = await this.getDefaultMetaData(ctx);
293
- auditLog.metadata = { ...metadata, ...defaultMetaData };
294
298
  }
295
299
  this.logger.log(auditLog);
296
300
  } catch (err) {
@@ -32,12 +32,12 @@ __export(data_template_exports, {
32
32
  module.exports = __toCommonJS(data_template_exports);
33
33
  async function dataTemplate(ctx, next) {
34
34
  const { resourceName, actionName } = ctx.action;
35
- const { isTemplate, fields } = ctx.action.params;
35
+ const { isTemplate, fields, appends } = ctx.action.params;
36
36
  await next();
37
- if (isTemplate && actionName === "get" && fields.length > 0) {
37
+ if (isTemplate && actionName === "get") {
38
38
  ctx.body = traverseJSON(JSON.parse(JSON.stringify(ctx.body)), {
39
- collection: ctx.db.getCollection(resourceName),
40
- include: fields
39
+ collection: ctx.getCurrentRepository().collection,
40
+ include: [...fields || [], ...appends || []]
41
41
  });
42
42
  }
43
43
  }
@@ -101,7 +101,7 @@ const traverseJSON = /* @__PURE__ */ __name((data, options) => {
101
101
  result[key] = data[key];
102
102
  continue;
103
103
  }
104
- if (field.options.primaryKey && excludePk) {
104
+ if (field.options.primaryKey && excludePk && !collection.isMultiFilterTargetKey()) {
105
105
  continue;
106
106
  }
107
107
  if (field.options.isForeignKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "1.6.0-alpha.4",
3
+ "version": "1.6.0-alpha.6",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -10,19 +10,19 @@
10
10
  "@koa/cors": "^3.1.0",
11
11
  "@koa/multer": "^3.0.2",
12
12
  "@koa/router": "^9.4.0",
13
- "@nocobase/acl": "1.6.0-alpha.4",
14
- "@nocobase/actions": "1.6.0-alpha.4",
15
- "@nocobase/auth": "1.6.0-alpha.4",
16
- "@nocobase/cache": "1.6.0-alpha.4",
17
- "@nocobase/data-source-manager": "1.6.0-alpha.4",
18
- "@nocobase/database": "1.6.0-alpha.4",
19
- "@nocobase/evaluators": "1.6.0-alpha.4",
20
- "@nocobase/lock-manager": "1.6.0-alpha.4",
21
- "@nocobase/logger": "1.6.0-alpha.4",
22
- "@nocobase/resourcer": "1.6.0-alpha.4",
23
- "@nocobase/sdk": "1.6.0-alpha.4",
24
- "@nocobase/telemetry": "1.6.0-alpha.4",
25
- "@nocobase/utils": "1.6.0-alpha.4",
13
+ "@nocobase/acl": "1.6.0-alpha.6",
14
+ "@nocobase/actions": "1.6.0-alpha.6",
15
+ "@nocobase/auth": "1.6.0-alpha.6",
16
+ "@nocobase/cache": "1.6.0-alpha.6",
17
+ "@nocobase/data-source-manager": "1.6.0-alpha.6",
18
+ "@nocobase/database": "1.6.0-alpha.6",
19
+ "@nocobase/evaluators": "1.6.0-alpha.6",
20
+ "@nocobase/lock-manager": "1.6.0-alpha.6",
21
+ "@nocobase/logger": "1.6.0-alpha.6",
22
+ "@nocobase/resourcer": "1.6.0-alpha.6",
23
+ "@nocobase/sdk": "1.6.0-alpha.6",
24
+ "@nocobase/telemetry": "1.6.0-alpha.6",
25
+ "@nocobase/utils": "1.6.0-alpha.6",
26
26
  "@types/decompress": "4.2.7",
27
27
  "@types/ini": "^1.3.31",
28
28
  "@types/koa-send": "^4.1.3",
@@ -56,5 +56,5 @@
56
56
  "@types/serve-handler": "^6.1.1",
57
57
  "@types/ws": "^8.5.5"
58
58
  },
59
- "gitHead": "595d5236feda9258791dac76270494721813b7e1"
59
+ "gitHead": "485580ad30e5164ead7e15f3b4d219f2bce2caf4"
60
60
  }