@nocobase/server 2.0.0-alpha.33 → 2.0.0-alpha.34

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.
@@ -13,6 +13,8 @@ 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;
17
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
16
18
  var __export = (target, all) => {
17
19
  for (var name in all)
18
20
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -34,6 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
36
  mod
35
37
  ));
36
38
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
37
40
  var resource_exports = {};
38
41
  __export(resource_exports, {
39
42
  default: () => resource_default
@@ -43,6 +46,33 @@ var import_utils = require("@nocobase/utils");
43
46
  var import_fs = __toESM(require("fs"));
44
47
  var import_fs_extra = __toESM(require("fs-extra"));
45
48
  var import_path = __toESM(require("path"));
49
+ const _PackageUrls = class _PackageUrls {
50
+ static async get(packageName, version) {
51
+ if (!this.items[packageName]) {
52
+ this.items[packageName] = await this.fetch(packageName, version);
53
+ }
54
+ return this.items[packageName];
55
+ }
56
+ static async fetch(packageName, version) {
57
+ const PLUGIN_CLIENT_ENTRY_FILE = "dist/client/index.js";
58
+ const pkgPath = import_path.default.resolve(process.env.NODE_MODULES_PATH, packageName);
59
+ const r = await import_fs_extra.default.exists(pkgPath);
60
+ if (r) {
61
+ let t = "";
62
+ const dist = import_path.default.resolve(pkgPath, PLUGIN_CLIENT_ENTRY_FILE);
63
+ const distExists = await import_fs_extra.default.exists(dist);
64
+ if (distExists) {
65
+ const fsState = await import_fs_extra.default.stat(distExists ? dist : pkgPath);
66
+ t = `&t=${fsState.mtime.getTime()}`;
67
+ }
68
+ const url = `${process.env.APP_SERVER_BASE_URL}${process.env.PLUGIN_STATICS_PATH}${packageName}/${PLUGIN_CLIENT_ENTRY_FILE}?version=${version}${t}`;
69
+ return url;
70
+ }
71
+ }
72
+ };
73
+ __name(_PackageUrls, "PackageUrls");
74
+ __publicField(_PackageUrls, "items", {});
75
+ let PackageUrls = _PackageUrls;
46
76
  var resource_default = {
47
77
  name: "pm",
48
78
  actions: {
@@ -152,33 +182,26 @@ var resource_default = {
152
182
  await next();
153
183
  },
154
184
  async listEnabled(ctx, next) {
155
- const pm = ctx.db.getRepository("applicationPlugins");
156
- const PLUGIN_CLIENT_ENTRY_FILE = "dist/client/index.js";
157
- const items = await pm.find({
158
- filter: {
159
- enabled: true
160
- }
161
- });
162
- const arr = [];
163
- for (const item of items) {
164
- const pkgPath = import_path.default.resolve(process.env.NODE_MODULES_PATH, item.packageName);
165
- const r = await import_fs_extra.default.exists(pkgPath);
166
- if (r) {
167
- let t = "";
168
- const dist = import_path.default.resolve(pkgPath, PLUGIN_CLIENT_ENTRY_FILE);
169
- const distExists = await import_fs_extra.default.exists(dist);
170
- if (distExists) {
171
- const fsState = await import_fs_extra.default.stat(distExists ? dist : pkgPath);
172
- t = `&t=${fsState.mtime.getTime()}`;
185
+ const toArr = /* @__PURE__ */ __name(async () => {
186
+ const pm = ctx.db.getRepository("applicationPlugins");
187
+ const items = await pm.find({
188
+ filter: {
189
+ enabled: true
190
+ }
191
+ });
192
+ const arr = [];
193
+ for (const item of items) {
194
+ const url = await PackageUrls.get(item.packageName, item.version);
195
+ if (url) {
196
+ arr.push({
197
+ ...item.toJSON(),
198
+ url
199
+ });
173
200
  }
174
- const url = `${process.env.APP_SERVER_BASE_URL}${process.env.PLUGIN_STATICS_PATH}${item.packageName}/${PLUGIN_CLIENT_ENTRY_FILE}?version=${item.version}${t}`;
175
- arr.push({
176
- ...item.toJSON(),
177
- url
178
- });
179
201
  }
180
- }
181
- ctx.body = arr;
202
+ return arr;
203
+ }, "toArr");
204
+ ctx.body = await toArr();
182
205
  await next();
183
206
  },
184
207
  async get(ctx, next) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "2.0.0-alpha.33",
3
+ "version": "2.0.0-alpha.34",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -10,20 +10,20 @@
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.0.0-alpha.33",
14
- "@nocobase/actions": "2.0.0-alpha.33",
15
- "@nocobase/auth": "2.0.0-alpha.33",
16
- "@nocobase/cache": "2.0.0-alpha.33",
17
- "@nocobase/data-source-manager": "2.0.0-alpha.33",
18
- "@nocobase/database": "2.0.0-alpha.33",
19
- "@nocobase/evaluators": "2.0.0-alpha.33",
20
- "@nocobase/lock-manager": "2.0.0-alpha.33",
21
- "@nocobase/logger": "2.0.0-alpha.33",
22
- "@nocobase/resourcer": "2.0.0-alpha.33",
23
- "@nocobase/sdk": "2.0.0-alpha.33",
24
- "@nocobase/snowflake-id": "2.0.0-alpha.33",
25
- "@nocobase/telemetry": "2.0.0-alpha.33",
26
- "@nocobase/utils": "2.0.0-alpha.33",
13
+ "@nocobase/acl": "2.0.0-alpha.34",
14
+ "@nocobase/actions": "2.0.0-alpha.34",
15
+ "@nocobase/auth": "2.0.0-alpha.34",
16
+ "@nocobase/cache": "2.0.0-alpha.34",
17
+ "@nocobase/data-source-manager": "2.0.0-alpha.34",
18
+ "@nocobase/database": "2.0.0-alpha.34",
19
+ "@nocobase/evaluators": "2.0.0-alpha.34",
20
+ "@nocobase/lock-manager": "2.0.0-alpha.34",
21
+ "@nocobase/logger": "2.0.0-alpha.34",
22
+ "@nocobase/resourcer": "2.0.0-alpha.34",
23
+ "@nocobase/sdk": "2.0.0-alpha.34",
24
+ "@nocobase/snowflake-id": "2.0.0-alpha.34",
25
+ "@nocobase/telemetry": "2.0.0-alpha.34",
26
+ "@nocobase/utils": "2.0.0-alpha.34",
27
27
  "@types/decompress": "4.2.7",
28
28
  "@types/ini": "^1.3.31",
29
29
  "@types/koa-send": "^4.1.3",
@@ -60,5 +60,5 @@
60
60
  "@types/serve-handler": "^6.1.1",
61
61
  "@types/ws": "^8.5.5"
62
62
  },
63
- "gitHead": "d5970aa7f8bf84e92082e182b780344e86bde998"
63
+ "gitHead": "d7bda14bac775be7ef207cb25986511740b2ed70"
64
64
  }