@nocobase/server 1.2.33-alpha → 1.2.35-alpha

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.
@@ -36,10 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  mod
37
37
  ));
38
38
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
- var __publicField = (obj, key, value) => {
40
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
41
- return value;
42
- };
39
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
43
40
  var app_supervisor_exports = {};
44
41
  __export(app_supervisor_exports, {
45
42
  AppSupervisor: () => AppSupervisor
@@ -279,8 +279,7 @@ const _Application = class _Application extends import_koa.default {
279
279
  */
280
280
  callback() {
281
281
  const fn = (0, import_koa_compose.default)(this.middleware.nodes);
282
- if (!this.listenerCount("error"))
283
- this.on("error", this.onerror);
282
+ if (!this.listenerCount("error")) this.on("error", this.onerror);
284
283
  return (req, res) => {
285
284
  const ctx = this.createContext(req, res);
286
285
  return this.handleRequest(ctx, fn);
@@ -456,25 +455,25 @@ const _Application = class _Application extends import_koa.default {
456
455
  });
457
456
  return {
458
457
  beforeLoad: {
459
- up: async () => {
458
+ up: /* @__PURE__ */ __name(async () => {
460
459
  this.log.debug("run core migrations(beforeLoad)");
461
460
  const migrator = this.db.createMigrator({ migrations: migrations.beforeLoad });
462
461
  await migrator.up();
463
- }
462
+ }, "up")
464
463
  },
465
464
  afterSync: {
466
- up: async () => {
465
+ up: /* @__PURE__ */ __name(async () => {
467
466
  this.log.debug("run core migrations(afterSync)");
468
467
  const migrator = this.db.createMigrator({ migrations: migrations.afterSync });
469
468
  await migrator.up();
470
- }
469
+ }, "up")
471
470
  },
472
471
  afterLoad: {
473
- up: async () => {
472
+ up: /* @__PURE__ */ __name(async () => {
474
473
  this.log.debug("run core migrations(afterLoad)");
475
474
  const migrator = this.db.createMigrator({ migrations: migrations.afterLoad });
476
475
  await migrator.up();
477
- }
476
+ }, "up")
478
477
  }
479
478
  };
480
479
  }
@@ -47,12 +47,12 @@ var import_lodash = __toESM(require("lodash"));
47
47
  const errors = {
48
48
  APP_NOT_FOUND: {
49
49
  status: 404,
50
- message: ({ appName }) => `application ${appName} not found`,
50
+ message: /* @__PURE__ */ __name(({ appName }) => `application ${appName} not found`, "message"),
51
51
  maintaining: true
52
52
  },
53
53
  APP_ERROR: {
54
54
  status: 503,
55
- message: ({ app }) => {
55
+ message: /* @__PURE__ */ __name(({ app }) => {
56
56
  const error = import_app_supervisor.AppSupervisor.getInstance().appErrors[app.name];
57
57
  if (!error) {
58
58
  return "";
@@ -62,56 +62,56 @@ const errors = {
62
62
  message = `${message}: ${error.cause.message}`;
63
63
  }
64
64
  return message;
65
- },
66
- code: ({ app }) => {
65
+ }, "message"),
66
+ code: /* @__PURE__ */ __name(({ app }) => {
67
67
  const error = import_app_supervisor.AppSupervisor.getInstance().appErrors[app.name];
68
68
  return error["code"] || "APP_ERROR";
69
- },
70
- command: ({ app }) => app.getMaintaining().command,
69
+ }, "code"),
70
+ command: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().command, "command"),
71
71
  maintaining: true
72
72
  },
73
73
  APP_STARTING: {
74
74
  status: 503,
75
- message: ({ app }) => app.maintainingMessage,
75
+ message: /* @__PURE__ */ __name(({ app }) => app.maintainingMessage, "message"),
76
76
  maintaining: true
77
77
  },
78
78
  APP_STOPPED: {
79
79
  status: 503,
80
- message: ({ app }) => `application ${app.name} is stopped`,
80
+ message: /* @__PURE__ */ __name(({ app }) => `application ${app.name} is stopped`, "message"),
81
81
  maintaining: true
82
82
  },
83
83
  APP_INITIALIZED: {
84
84
  status: 503,
85
- message: ({ app }) => `application ${app.name} is initialized, waiting for command`,
85
+ message: /* @__PURE__ */ __name(({ app }) => `application ${app.name} is initialized, waiting for command`, "message"),
86
86
  maintaining: true
87
87
  },
88
88
  APP_INITIALIZING: {
89
89
  status: 503,
90
- message: ({ appName }) => `application ${appName} is initializing`,
90
+ message: /* @__PURE__ */ __name(({ appName }) => `application ${appName} is initializing`, "message"),
91
91
  maintaining: true
92
92
  },
93
93
  COMMAND_ERROR: {
94
94
  status: 503,
95
95
  maintaining: true,
96
- message: ({ app }) => app.getMaintaining().error.message,
97
- command: ({ app }) => app.getMaintaining().command
96
+ message: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().error.message, "message"),
97
+ command: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().command, "command")
98
98
  },
99
99
  COMMAND_END: {
100
100
  status: 503,
101
101
  maintaining: true,
102
- message: ({ app }) => `${app.getMaintaining().command.name} running end`,
103
- command: ({ app }) => app.getMaintaining().command
102
+ message: /* @__PURE__ */ __name(({ app }) => `${app.getMaintaining().command.name} running end`, "message"),
103
+ command: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().command, "command")
104
104
  },
105
105
  APP_COMMANDING: {
106
106
  status: 503,
107
107
  maintaining: true,
108
- message: ({ app, message }) => message || app.maintainingMessage,
109
- command: ({ app, command }) => command || app.getMaintaining().command
108
+ message: /* @__PURE__ */ __name(({ app, message }) => message || app.maintainingMessage, "message"),
109
+ command: /* @__PURE__ */ __name(({ app, command }) => command || app.getMaintaining().command, "command")
110
110
  },
111
111
  APP_RUNNING: {
112
112
  status: 200,
113
113
  maintaining: false,
114
- message: ({ message, app }) => message || `application ${app.name} is running`
114
+ message: /* @__PURE__ */ __name(({ message, app }) => message || `application ${app.name} is running`, "message")
115
115
  },
116
116
  UNKNOWN_ERROR: {
117
117
  status: 500,
@@ -36,10 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  mod
37
37
  ));
38
38
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
- var __publicField = (obj, key, value) => {
40
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
41
- return value;
42
- };
39
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
43
40
  var gateway_exports = {};
44
41
  __export(gateway_exports, {
45
42
  Gateway: () => Gateway
package/lib/helper.js CHANGED
@@ -162,7 +162,7 @@ const enablePerfHooks = /* @__PURE__ */ __name((app) => {
162
162
  app.resourcer.define({
163
163
  name: "perf",
164
164
  actions: {
165
- view: async (ctx, next) => {
165
+ view: /* @__PURE__ */ __name(async (ctx, next) => {
166
166
  const result = {};
167
167
  const histograms = ctx.app.perfHistograms;
168
168
  const sortedHistograms = [...histograms.entries()].sort(([i, a], [j, b]) => b.mean - a.mean);
@@ -171,12 +171,12 @@ const enablePerfHooks = /* @__PURE__ */ __name((app) => {
171
171
  });
172
172
  ctx.body = result;
173
173
  await next();
174
- },
175
- reset: async (ctx, next) => {
174
+ }, "view"),
175
+ reset: /* @__PURE__ */ __name(async (ctx, next) => {
176
176
  const histograms = ctx.app.perfHistograms;
177
177
  histograms.forEach((histogram) => histogram.reset());
178
178
  await next();
179
- }
179
+ }, "reset")
180
180
  }
181
181
  });
182
182
  app.acl.allow("perf", "*", "public");
@@ -93,7 +93,7 @@ const _Locale = class _Locale {
93
93
  }
94
94
  async wrapCache(key, fn) {
95
95
  return await this.cache.wrapWithCondition(key, fn, {
96
- isCacheable: (val) => !import_utils.lodash.isEmpty(val)
96
+ isCacheable: /* @__PURE__ */ __name((val) => !import_utils.lodash.isEmpty(val), "isCacheable")
97
97
  });
98
98
  }
99
99
  async loadResourcesByLang(lang) {
@@ -39,9 +39,9 @@ const _MainDataSource = class _MainDataSource extends import_data_source_manager
39
39
  this.collectionManager = this.createCollectionManager({
40
40
  collectionManager: {
41
41
  database,
42
- collectionsFilter: (collection) => {
42
+ collectionsFilter: /* @__PURE__ */ __name((collection) => {
43
43
  return collection.options.loadedFromCollectionManager;
44
- }
44
+ }, "collectionsFilter")
45
45
  }
46
46
  });
47
47
  if (options.useACL !== false) {
@@ -54,10 +54,8 @@ function getUser(ctx) {
54
54
  }
55
55
  __name(getUser, "getUser");
56
56
  function isNumeric(str) {
57
- if (typeof str === "number")
58
- return true;
59
- if (typeof str != "string")
60
- return false;
57
+ if (typeof str === "number") return true;
58
+ if (typeof str != "string") return false;
61
59
  return !isNaN(str) && !isNaN(parseFloat(str));
62
60
  }
63
61
  __name(isNumeric, "isNumeric");
@@ -69,11 +67,11 @@ const parseVariables = /* @__PURE__ */ __name(async (ctx, next) => {
69
67
  ctx.action.params.filter = await (0, import_utils.parseFilter)(filter, {
70
68
  timezone: ctx.get("x-timezone"),
71
69
  now: (/* @__PURE__ */ new Date()).toISOString(),
72
- getField: (path) => {
70
+ getField: /* @__PURE__ */ __name((path) => {
73
71
  const fieldPath = path.split(".").filter((p) => !p.startsWith("$") && !isNumeric(p)).join(".");
74
72
  const { resourceName } = ctx.action;
75
73
  return ctx.db.getFieldByPath(`${resourceName}.${fieldPath}`);
76
- },
74
+ }, "getField"),
77
75
  vars: {
78
76
  // @deprecated
79
77
  $system: {
@@ -36,10 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  mod
37
37
  ));
38
38
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
- var __publicField = (obj, key, value) => {
40
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
41
- return value;
42
- };
39
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
43
40
  var plugin_manager_exports = {};
44
41
  __export(plugin_manager_exports, {
45
42
  AddPresetError: () => AddPresetError,
@@ -948,25 +945,25 @@ const _PluginManager = class _PluginManager {
948
945
  }
949
946
  return {
950
947
  beforeLoad: {
951
- up: async () => {
948
+ up: /* @__PURE__ */ __name(async () => {
952
949
  this.app.log.debug("run preset migrations(beforeLoad)");
953
950
  const migrator = this.app.db.createMigrator({ migrations: migrations.beforeLoad });
954
951
  await migrator.up();
955
- }
952
+ }, "up")
956
953
  },
957
954
  afterSync: {
958
- up: async () => {
955
+ up: /* @__PURE__ */ __name(async () => {
959
956
  this.app.log.debug("run preset migrations(afterSync)");
960
957
  const migrator = this.app.db.createMigrator({ migrations: migrations.afterSync });
961
958
  await migrator.up();
962
- }
959
+ }, "up")
963
960
  },
964
961
  afterLoad: {
965
- up: async () => {
962
+ up: /* @__PURE__ */ __name(async () => {
966
963
  this.app.log.debug("run preset migrations(afterLoad)");
967
964
  const migrator = this.app.db.createMigrator({ migrations: migrations.afterLoad });
968
965
  await migrator.up();
969
- }
966
+ }, "up")
970
967
  }
971
968
  };
972
969
  }
@@ -993,25 +990,25 @@ const _PluginManager = class _PluginManager {
993
990
  }
994
991
  return {
995
992
  beforeLoad: {
996
- up: async () => {
993
+ up: /* @__PURE__ */ __name(async () => {
997
994
  this.app.log.debug("run others migrations(beforeLoad)");
998
995
  const migrator = this.app.db.createMigrator({ migrations: migrations.beforeLoad });
999
996
  await migrator.up();
1000
- }
997
+ }, "up")
1001
998
  },
1002
999
  afterSync: {
1003
- up: async () => {
1000
+ up: /* @__PURE__ */ __name(async () => {
1004
1001
  this.app.log.debug("run others migrations(afterSync)");
1005
1002
  const migrator = this.app.db.createMigrator({ migrations: migrations.afterSync });
1006
1003
  await migrator.up();
1007
- }
1004
+ }, "up")
1008
1005
  },
1009
1006
  afterLoad: {
1010
- up: async () => {
1007
+ up: /* @__PURE__ */ __name(async () => {
1011
1008
  this.app.log.debug("run others migrations(afterLoad)");
1012
1009
  const migrator = this.app.db.createMigrator({ migrations: migrations.afterLoad });
1013
1010
  await migrator.up();
1014
- }
1011
+ }, "up")
1015
1012
  }
1016
1013
  };
1017
1014
  }
@@ -355,8 +355,7 @@ async function updatePluginByCompressedFileUrl(options) {
355
355
  }
356
356
  __name(updatePluginByCompressedFileUrl, "updatePluginByCompressedFileUrl");
357
357
  async function getNewVersion(plugin) {
358
- if (!(plugin.packageName && plugin.registry))
359
- return false;
358
+ if (!(plugin.packageName && plugin.registry)) return false;
360
359
  const { version } = await getPluginInfoByNpm({
361
360
  packageName: plugin.packageName,
362
361
  registry: plugin.registry,
@@ -411,8 +410,7 @@ const isValidPackageName = /* @__PURE__ */ __name((str) => {
411
410
  return pattern.test(str);
412
411
  }, "isValidPackageName");
413
412
  function getPackageNameFromString(str) {
414
- if (str.startsWith("."))
415
- return null;
413
+ if (str.startsWith(".")) return null;
416
414
  const arr = str.split("/");
417
415
  let packageName;
418
416
  if (arr[0].startsWith("@")) {
@@ -494,8 +492,7 @@ async function getCompatible(packageName) {
494
492
  __name(getCompatible, "getCompatible");
495
493
  async function checkCompatible(packageName) {
496
494
  const compatible = await getCompatible(packageName);
497
- if (!compatible)
498
- return false;
495
+ if (!compatible) return false;
499
496
  return compatible.every((item) => item.result);
500
497
  }
501
498
  __name(checkCompatible, "checkCompatible");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "1.2.33-alpha",
3
+ "version": "1.2.35-alpha",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -10,18 +10,18 @@
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.2.33-alpha",
14
- "@nocobase/actions": "1.2.33-alpha",
15
- "@nocobase/auth": "1.2.33-alpha",
16
- "@nocobase/cache": "1.2.33-alpha",
17
- "@nocobase/data-source-manager": "1.2.33-alpha",
18
- "@nocobase/database": "1.2.33-alpha",
19
- "@nocobase/evaluators": "1.2.33-alpha",
20
- "@nocobase/logger": "1.2.33-alpha",
21
- "@nocobase/resourcer": "1.2.33-alpha",
22
- "@nocobase/sdk": "1.2.33-alpha",
23
- "@nocobase/telemetry": "1.2.33-alpha",
24
- "@nocobase/utils": "1.2.33-alpha",
13
+ "@nocobase/acl": "1.2.35-alpha",
14
+ "@nocobase/actions": "1.2.35-alpha",
15
+ "@nocobase/auth": "1.2.35-alpha",
16
+ "@nocobase/cache": "1.2.35-alpha",
17
+ "@nocobase/data-source-manager": "1.2.35-alpha",
18
+ "@nocobase/database": "1.2.35-alpha",
19
+ "@nocobase/evaluators": "1.2.35-alpha",
20
+ "@nocobase/logger": "1.2.35-alpha",
21
+ "@nocobase/resourcer": "1.2.35-alpha",
22
+ "@nocobase/sdk": "1.2.35-alpha",
23
+ "@nocobase/telemetry": "1.2.35-alpha",
24
+ "@nocobase/utils": "1.2.35-alpha",
25
25
  "@types/decompress": "4.2.4",
26
26
  "@types/ini": "^1.3.31",
27
27
  "@types/koa-send": "^4.1.3",
@@ -54,5 +54,5 @@
54
54
  "@types/serve-handler": "^6.1.1",
55
55
  "@types/ws": "^8.5.5"
56
56
  },
57
- "gitHead": "b161f5e177c51d92fec745e81853c301689a9d6f"
57
+ "gitHead": "37a4edc27153f9346b3b08c25a407fb57c78b68e"
58
58
  }