@nocobase/server 1.3.52 → 1.3.54

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.
@@ -31,6 +31,7 @@ export declare class PluginManagerRepository extends Repository {
31
31
  * @deprecated
32
32
  */
33
33
  disable(name: string | string[]): Promise<string[]>;
34
- getItems(): Promise<any>;
34
+ sort(names: string[]): Promise<string[]>;
35
+ getItems(): Promise<any[]>;
35
36
  init(): Promise<void>;
36
37
  }
@@ -40,6 +40,7 @@ __export(plugin_manager_repository_exports, {
40
40
  PluginManagerRepository: () => PluginManagerRepository
41
41
  });
42
42
  module.exports = __toCommonJS(plugin_manager_repository_exports);
43
+ var import_topo = __toESM(require("@hapi/topo"));
43
44
  var import_database = require("@nocobase/database");
44
45
  var import_lodash = __toESM(require("lodash"));
45
46
  var import_plugin_manager = require("./plugin-manager");
@@ -130,14 +131,41 @@ const _PluginManagerRepository = class _PluginManagerRepository extends import_d
130
131
  });
131
132
  return pluginNames;
132
133
  }
134
+ async sort(names) {
135
+ const pluginNames = import_lodash.default.castArray(names);
136
+ if (pluginNames.length === 1) {
137
+ return pluginNames;
138
+ }
139
+ const sorter = new import_topo.default.Sorter();
140
+ for (const pluginName of pluginNames) {
141
+ const packageJson = await import_plugin_manager.PluginManager.getPackageJson(pluginName);
142
+ const peerDependencies = Object.keys((packageJson == null ? void 0 : packageJson.peerDependencies) || {});
143
+ sorter.add(pluginName, { after: peerDependencies, group: (packageJson == null ? void 0 : packageJson.packageName) || pluginName });
144
+ }
145
+ return sorter.nodes;
146
+ }
133
147
  async getItems() {
134
148
  const exists = await this.collection.existsInDb();
135
149
  if (!exists) {
136
150
  return [];
137
151
  }
138
- return await this.find({
152
+ const items = await this.find({
139
153
  sort: "id"
140
154
  });
155
+ const sortedItems = [];
156
+ const map = {};
157
+ for (const item of items) {
158
+ if (item.packageName) {
159
+ map[item.packageName] = item;
160
+ } else {
161
+ sortedItems.push(item);
162
+ }
163
+ }
164
+ const names = await this.sort(Object.keys(map));
165
+ for (const name of names) {
166
+ sortedItems.push(map[name]);
167
+ }
168
+ return sortedItems;
141
169
  }
142
170
  async init() {
143
171
  const items = await this.getItems();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "1.3.52",
3
+ "version": "1.3.54",
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.52",
14
- "@nocobase/actions": "1.3.52",
15
- "@nocobase/auth": "1.3.52",
16
- "@nocobase/cache": "1.3.52",
17
- "@nocobase/data-source-manager": "1.3.52",
18
- "@nocobase/database": "1.3.52",
19
- "@nocobase/evaluators": "1.3.52",
20
- "@nocobase/logger": "1.3.52",
21
- "@nocobase/resourcer": "1.3.52",
22
- "@nocobase/sdk": "1.3.52",
23
- "@nocobase/telemetry": "1.3.52",
24
- "@nocobase/utils": "1.3.52",
13
+ "@nocobase/acl": "1.3.54",
14
+ "@nocobase/actions": "1.3.54",
15
+ "@nocobase/auth": "1.3.54",
16
+ "@nocobase/cache": "1.3.54",
17
+ "@nocobase/data-source-manager": "1.3.54",
18
+ "@nocobase/database": "1.3.54",
19
+ "@nocobase/evaluators": "1.3.54",
20
+ "@nocobase/logger": "1.3.54",
21
+ "@nocobase/resourcer": "1.3.54",
22
+ "@nocobase/sdk": "1.3.54",
23
+ "@nocobase/telemetry": "1.3.54",
24
+ "@nocobase/utils": "1.3.54",
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": "90afbd90f915cf5df0ee6766ddbdf7803b3ab7ea"
57
+ "gitHead": "33b487952c467cbce819533b056de538728c3226"
58
58
  }