@nocobase/server 1.3.49-beta → 1.3.51

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.
@@ -165,6 +165,8 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
165
165
  private _sqlLogger;
166
166
  protected _logger: SystemLogger;
167
167
  constructor(options: ApplicationOptions);
168
+ private static staticCommands;
169
+ static addCommand(callback: (app: Application) => void): void;
168
170
  /**
169
171
  * @experimental
170
172
  */
@@ -243,6 +245,7 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
243
245
  * @deprecated
244
246
  */
245
247
  getVersion(): string;
248
+ getPackageVersion(): string;
246
249
  /**
247
250
  * This method is deprecated and should not be used.
248
251
  * Use {@link #this.pm.addPreset()} instead.
@@ -13,6 +13,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
14
  var __getProtoOf = Object.getPrototypeOf;
15
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
17
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
18
  var __export = (target, all) => {
18
19
  for (var name in all)
@@ -35,6 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
35
36
  mod
36
37
  ));
37
38
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
38
40
  var application_exports = {};
39
41
  __export(application_exports, {
40
42
  Application: () => Application,
@@ -122,6 +124,9 @@ const _Application = class _Application extends import_koa.default {
122
124
  requestLogger;
123
125
  _sqlLogger;
124
126
  _logger;
127
+ static addCommand(callback) {
128
+ this.staticCommands.push(callback);
129
+ }
125
130
  /**
126
131
  * @experimental
127
132
  */
@@ -272,6 +277,9 @@ const _Application = class _Application extends import_koa.default {
272
277
  getVersion() {
273
278
  return import_package.default.version;
274
279
  }
280
+ getPackageVersion() {
281
+ return import_package.default.version;
282
+ }
275
283
  /**
276
284
  * This method is deprecated and should not be used.
277
285
  * Use {@link #this.pm.addPreset()} instead.
@@ -844,6 +852,9 @@ const _Application = class _Application extends import_koa.default {
844
852
  }
845
853
  (0, import_commands.registerCli)(this);
846
854
  this._version = new import_application_version.ApplicationVersion(this);
855
+ for (const callback of _Application.staticCommands) {
856
+ callback(this);
857
+ }
847
858
  }
848
859
  createMainDataSource(options) {
849
860
  const mainDataSourceInstance = new import_main_data_source.MainDataSource({
@@ -887,6 +898,7 @@ const _Application = class _Application extends import_koa.default {
887
898
  }
888
899
  };
889
900
  __name(_Application, "Application");
901
+ __publicField(_Application, "staticCommands", []);
890
902
  let Application = _Application;
891
903
  (0, import_utils.applyMixins)(Application, [import_utils.AsyncEmitter]);
892
904
  var application_default = Application;
package/lib/index.d.ts CHANGED
@@ -6,13 +6,15 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ export * from './app-supervisor';
9
10
  export * from './application';
10
11
  export { Application as default } from './application';
12
+ export * from './gateway';
11
13
  export * as middlewares from './middlewares';
12
14
  export * from './migration';
13
15
  export * from './plugin';
14
16
  export * from './plugin-manager';
15
- export * from './gateway';
16
- export * from './app-supervisor';
17
17
  export * from './sync-manager';
18
18
  export declare const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
19
+ export { appendToBuiltInPlugins, findAllPlugins, findBuiltInPlugins, findLocalPlugins, packageNameTrim, } from './plugin-manager/findPackageNames';
20
+ export { runPluginStaticImports } from './run-plugin-static-imports';
package/lib/index.js CHANGED
@@ -38,29 +38,43 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
38
38
  var src_exports = {};
39
39
  __export(src_exports, {
40
40
  OFFICIAL_PLUGIN_PREFIX: () => OFFICIAL_PLUGIN_PREFIX,
41
+ appendToBuiltInPlugins: () => import_findPackageNames.appendToBuiltInPlugins,
41
42
  default: () => import_application.Application,
42
- middlewares: () => middlewares
43
+ findAllPlugins: () => import_findPackageNames.findAllPlugins,
44
+ findBuiltInPlugins: () => import_findPackageNames.findBuiltInPlugins,
45
+ findLocalPlugins: () => import_findPackageNames.findLocalPlugins,
46
+ middlewares: () => middlewares,
47
+ packageNameTrim: () => import_findPackageNames.packageNameTrim,
48
+ runPluginStaticImports: () => import_run_plugin_static_imports.runPluginStaticImports
43
49
  });
44
50
  module.exports = __toCommonJS(src_exports);
51
+ __reExport(src_exports, require("./app-supervisor"), module.exports);
45
52
  __reExport(src_exports, require("./application"), module.exports);
46
53
  var import_application = require("./application");
54
+ __reExport(src_exports, require("./gateway"), module.exports);
47
55
  var middlewares = __toESM(require("./middlewares"));
48
56
  __reExport(src_exports, require("./migration"), module.exports);
49
57
  __reExport(src_exports, require("./plugin"), module.exports);
50
58
  __reExport(src_exports, require("./plugin-manager"), module.exports);
51
- __reExport(src_exports, require("./gateway"), module.exports);
52
- __reExport(src_exports, require("./app-supervisor"), module.exports);
53
59
  __reExport(src_exports, require("./sync-manager"), module.exports);
60
+ var import_findPackageNames = require("./plugin-manager/findPackageNames");
61
+ var import_run_plugin_static_imports = require("./run-plugin-static-imports");
54
62
  const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
55
63
  // Annotate the CommonJS export names for ESM import in node:
56
64
  0 && (module.exports = {
57
65
  OFFICIAL_PLUGIN_PREFIX,
66
+ appendToBuiltInPlugins,
67
+ findAllPlugins,
68
+ findBuiltInPlugins,
69
+ findLocalPlugins,
58
70
  middlewares,
71
+ packageNameTrim,
72
+ runPluginStaticImports,
73
+ ...require("./app-supervisor"),
59
74
  ...require("./application"),
75
+ ...require("./gateway"),
60
76
  ...require("./migration"),
61
77
  ...require("./plugin"),
62
78
  ...require("./plugin-manager"),
63
- ...require("./gateway"),
64
- ...require("./app-supervisor"),
65
79
  ...require("./sync-manager")
66
80
  });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ declare function trim(packageNames: string[]): Promise<any[]>;
10
+ export declare function findPackageNames(): Promise<any[]>;
11
+ export declare function findBuiltInPlugins(): Promise<any[]>;
12
+ export declare function findLocalPlugins(): Promise<any[]>;
13
+ export declare function findAllPlugins(): Promise<any[]>;
14
+ export declare const packageNameTrim: typeof trim;
15
+ export declare function appendToBuiltInPlugins(nameOrPkg: string): Promise<void>;
16
+ export {};
@@ -0,0 +1,183 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
+ var __export = (target, all) => {
18
+ for (var name in all)
19
+ __defProp(target, name, { get: all[name], enumerable: true });
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (let key of __getOwnPropNames(from))
24
+ if (!__hasOwnProp.call(to, key) && key !== except)
25
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var findPackageNames_exports = {};
39
+ __export(findPackageNames_exports, {
40
+ appendToBuiltInPlugins: () => appendToBuiltInPlugins,
41
+ findAllPlugins: () => findAllPlugins,
42
+ findBuiltInPlugins: () => findBuiltInPlugins,
43
+ findLocalPlugins: () => findLocalPlugins,
44
+ findPackageNames: () => findPackageNames,
45
+ packageNameTrim: () => packageNameTrim
46
+ });
47
+ module.exports = __toCommonJS(findPackageNames_exports);
48
+ var import_fast_glob = __toESM(require("fast-glob"));
49
+ var import_fs_extra = __toESM(require("fs-extra"));
50
+ var import_lodash = __toESM(require("lodash"));
51
+ var import_path = __toESM(require("path"));
52
+ var import__ = require("./");
53
+ function splitNames(name) {
54
+ return (name || "").split(",").filter(Boolean);
55
+ }
56
+ __name(splitNames, "splitNames");
57
+ async function trim(packageNames) {
58
+ const nameOrPkgs = import_lodash.default.uniq(packageNames).filter(Boolean);
59
+ const names = [];
60
+ for (const nameOrPkg of nameOrPkgs) {
61
+ const { name, packageName } = await import__.PluginManager.parseName(nameOrPkg);
62
+ try {
63
+ await import__.PluginManager.getPackageJson(packageName);
64
+ names.push(name);
65
+ } catch (error) {
66
+ }
67
+ }
68
+ return names;
69
+ }
70
+ __name(trim, "trim");
71
+ const excludes = [
72
+ "@nocobase/plugin-audit-logs",
73
+ "@nocobase/plugin-backup-restore",
74
+ "@nocobase/plugin-charts",
75
+ "@nocobase/plugin-disable-pm-add",
76
+ "@nocobase/plugin-mobile-client",
77
+ "@nocobase/plugin-mock-collections",
78
+ "@nocobase/plugin-multi-app-share-collection",
79
+ "@nocobase/plugin-notifications",
80
+ "@nocobase/plugin-snapshot-field",
81
+ "@nocobase/plugin-workflow-test"
82
+ ];
83
+ async function findPackageNames() {
84
+ const patterns = [
85
+ "./packages/plugins/*/package.json",
86
+ "./packages/plugins/*/*/package.json",
87
+ "./packages/pro-plugins/*/*/package.json",
88
+ "./storage/plugins/*/package.json",
89
+ "./storage/plugins/*/*/package.json"
90
+ ];
91
+ try {
92
+ const packageJsonPaths = await (0, import_fast_glob.default)(patterns, {
93
+ cwd: process.cwd(),
94
+ absolute: true,
95
+ ignore: ["**/external-db-data-source/**"]
96
+ });
97
+ const packageNames = await Promise.all(
98
+ packageJsonPaths.map(async (packageJsonPath) => {
99
+ const packageJson = await import_fs_extra.default.readJson(packageJsonPath);
100
+ return packageJson.name;
101
+ })
102
+ );
103
+ const nocobasePlugins = await findNocobasePlugins();
104
+ const { APPEND_PRESET_BUILT_IN_PLUGINS = "", APPEND_PRESET_LOCAL_PLUGINS = "" } = process.env;
105
+ return trim(
106
+ packageNames.filter((pkg) => pkg && !excludes.includes(pkg)).concat(nocobasePlugins).concat(splitNames(APPEND_PRESET_BUILT_IN_PLUGINS)).concat(splitNames(APPEND_PRESET_LOCAL_PLUGINS))
107
+ );
108
+ } catch (error) {
109
+ return [];
110
+ }
111
+ }
112
+ __name(findPackageNames, "findPackageNames");
113
+ async function getPackageJson() {
114
+ const packageJson = await import_fs_extra.default.readJson(
115
+ import_path.default.resolve(process.env.NODE_MODULES_PATH, "@nocobase/preset-nocobase/package.json")
116
+ );
117
+ return packageJson;
118
+ }
119
+ __name(getPackageJson, "getPackageJson");
120
+ async function findNocobasePlugins() {
121
+ try {
122
+ const packageJson = await getPackageJson();
123
+ const pluginNames = Object.keys(packageJson.dependencies).filter((name) => name.startsWith("@nocobase/plugin-"));
124
+ return trim(pluginNames.filter((pkg) => pkg && !excludes.includes(pkg)));
125
+ } catch (error) {
126
+ return [];
127
+ }
128
+ }
129
+ __name(findNocobasePlugins, "findNocobasePlugins");
130
+ async function findBuiltInPlugins() {
131
+ const { APPEND_PRESET_BUILT_IN_PLUGINS = "" } = process.env;
132
+ try {
133
+ const packageJson = await getPackageJson();
134
+ return trim(packageJson.builtIn.concat(splitNames(APPEND_PRESET_BUILT_IN_PLUGINS)));
135
+ } catch (error) {
136
+ return [];
137
+ }
138
+ }
139
+ __name(findBuiltInPlugins, "findBuiltInPlugins");
140
+ async function findLocalPlugins() {
141
+ const { APPEND_PRESET_LOCAL_PLUGINS = "" } = process.env;
142
+ const plugins1 = await findNocobasePlugins();
143
+ const plugins2 = await findPackageNames();
144
+ const builtInPlugins = await findBuiltInPlugins();
145
+ const packageJson = await getPackageJson();
146
+ const items = await trim(
147
+ import_lodash.default.difference(
148
+ plugins1.concat(plugins2).concat(splitNames(APPEND_PRESET_LOCAL_PLUGINS)),
149
+ builtInPlugins.concat(await trim(packageJson.deprecated))
150
+ )
151
+ );
152
+ return items;
153
+ }
154
+ __name(findLocalPlugins, "findLocalPlugins");
155
+ async function findAllPlugins() {
156
+ const builtInPlugins = await findBuiltInPlugins();
157
+ const localPlugins = await findLocalPlugins();
158
+ return import_lodash.default.uniq(builtInPlugins.concat(localPlugins));
159
+ }
160
+ __name(findAllPlugins, "findAllPlugins");
161
+ const packageNameTrim = trim;
162
+ async function appendToBuiltInPlugins(nameOrPkg) {
163
+ const APPEND_PRESET_BUILT_IN_PLUGINS = process.env.APPEND_PRESET_BUILT_IN_PLUGINS || "";
164
+ const keys = APPEND_PRESET_BUILT_IN_PLUGINS.split(",");
165
+ const { name, packageName } = await import__.PluginManager.parseName(nameOrPkg);
166
+ if (keys.includes(packageName)) {
167
+ return;
168
+ }
169
+ if (keys.includes(name)) {
170
+ return;
171
+ }
172
+ process.env.APPEND_PRESET_BUILT_IN_PLUGINS += "," + nameOrPkg;
173
+ }
174
+ __name(appendToBuiltInPlugins, "appendToBuiltInPlugins");
175
+ // Annotate the CommonJS export names for ESM import in node:
176
+ 0 && (module.exports = {
177
+ appendToBuiltInPlugins,
178
+ findAllPlugins,
179
+ findBuiltInPlugins,
180
+ findLocalPlugins,
181
+ findPackageNames,
182
+ packageNameTrim
183
+ });
@@ -0,0 +1 @@
1
+ export declare function runPluginStaticImports(): Promise<void>;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var run_plugin_static_imports_exports = {};
29
+ __export(run_plugin_static_imports_exports, {
30
+ runPluginStaticImports: () => runPluginStaticImports
31
+ });
32
+ module.exports = __toCommonJS(run_plugin_static_imports_exports);
33
+ var import_server = require("@nocobase/server");
34
+ async function runPluginStaticImports() {
35
+ const packages = await (0, import_server.findAllPlugins)();
36
+ for (const name of packages) {
37
+ const { packageName } = await import_server.PluginManager.parseName(name);
38
+ try {
39
+ const plugin = require(packageName);
40
+ if (plugin && plugin.staticImport) {
41
+ await plugin.staticImport();
42
+ }
43
+ } catch (error) {
44
+ continue;
45
+ }
46
+ }
47
+ }
48
+ __name(runPluginStaticImports, "runPluginStaticImports");
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ runPluginStaticImports
52
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "1.3.49-beta",
3
+ "version": "1.3.51",
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.3.49-beta",
14
- "@nocobase/actions": "1.3.49-beta",
15
- "@nocobase/auth": "1.3.49-beta",
16
- "@nocobase/cache": "1.3.49-beta",
17
- "@nocobase/data-source-manager": "1.3.49-beta",
18
- "@nocobase/database": "1.3.49-beta",
19
- "@nocobase/evaluators": "1.3.49-beta",
20
- "@nocobase/logger": "1.3.49-beta",
21
- "@nocobase/resourcer": "1.3.49-beta",
22
- "@nocobase/sdk": "1.3.49-beta",
23
- "@nocobase/telemetry": "1.3.49-beta",
24
- "@nocobase/utils": "1.3.49-beta",
13
+ "@nocobase/acl": "1.3.51",
14
+ "@nocobase/actions": "1.3.51",
15
+ "@nocobase/auth": "1.3.51",
16
+ "@nocobase/cache": "1.3.51",
17
+ "@nocobase/data-source-manager": "1.3.51",
18
+ "@nocobase/database": "1.3.51",
19
+ "@nocobase/evaluators": "1.3.51",
20
+ "@nocobase/logger": "1.3.51",
21
+ "@nocobase/resourcer": "1.3.51",
22
+ "@nocobase/sdk": "1.3.51",
23
+ "@nocobase/telemetry": "1.3.51",
24
+ "@nocobase/utils": "1.3.51",
25
25
  "@types/decompress": "4.2.7",
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": "46dde74e2c220ae19bc275bb40be9ddf52485fa9"
57
+ "gitHead": "01f2b933a0681d99c5928d91d41f3f0c0ecae988"
58
58
  }