@nocobase/server 2.0.11 → 2.0.13
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.
- package/lib/helper.js +33 -1
- package/lib/plugin-manager/options/resource.js +4 -1
- package/package.json +17 -17
package/lib/helper.js
CHANGED
|
@@ -239,14 +239,46 @@ function isNumeric(str) {
|
|
|
239
239
|
return !isNaN(str) && !isNaN(parseFloat(str));
|
|
240
240
|
}
|
|
241
241
|
__name(isNumeric, "isNumeric");
|
|
242
|
+
function getFieldFromCollectionManager(ctx, resourceName, fieldPath) {
|
|
243
|
+
var _a;
|
|
244
|
+
const collectionManager = (_a = ctx.dataSource) == null ? void 0 : _a.collectionManager;
|
|
245
|
+
if (!(collectionManager == null ? void 0 : collectionManager.getCollection)) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const collection = collectionManager.getCollection(resourceName);
|
|
249
|
+
if (!(collection == null ? void 0 : collection.getField)) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const [firstName, ...others] = fieldPath.split(".");
|
|
253
|
+
let field = collection.getField(firstName);
|
|
254
|
+
if (!field || !others.length) {
|
|
255
|
+
return field;
|
|
256
|
+
}
|
|
257
|
+
let currentCollection = typeof field.targetCollection === "function" ? field.targetCollection() : field.targetCollection;
|
|
258
|
+
for (const name of others) {
|
|
259
|
+
if (!(currentCollection == null ? void 0 : currentCollection.getField)) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
field = currentCollection.getField(name);
|
|
263
|
+
if (!field) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
currentCollection = typeof field.targetCollection === "function" ? field.targetCollection() : field.targetCollection;
|
|
267
|
+
}
|
|
268
|
+
return field;
|
|
269
|
+
}
|
|
270
|
+
__name(getFieldFromCollectionManager, "getFieldFromCollectionManager");
|
|
242
271
|
function createContextVariablesScope(ctx) {
|
|
243
272
|
const state = JSON.parse(JSON.stringify(ctx.state));
|
|
244
273
|
return {
|
|
245
274
|
timezone: ctx.get("x-timezone"),
|
|
246
275
|
now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
247
276
|
getField: /* @__PURE__ */ __name((path) => {
|
|
248
|
-
const fieldPath = path.split(".").filter((p) => !p.startsWith("$") && !isNumeric(p)).join(".");
|
|
249
277
|
const { resourceName } = ctx.action;
|
|
278
|
+
const fieldPath = path.split(".").filter((p) => !p.startsWith("$") && !isNumeric(p)).join(".");
|
|
279
|
+
if (!ctx.database) {
|
|
280
|
+
return getFieldFromCollectionManager(ctx, resourceName, fieldPath);
|
|
281
|
+
}
|
|
250
282
|
return ctx.database.getFieldByPath(`${resourceName}.${fieldPath}`);
|
|
251
283
|
}, "getField"),
|
|
252
284
|
vars: {
|
|
@@ -47,6 +47,7 @@ var import_fs = __toESM(require("fs"));
|
|
|
47
47
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
48
48
|
var import_path = __toESM(require("path"));
|
|
49
49
|
var import_crypto = __toESM(require("crypto"));
|
|
50
|
+
var import_package = __toESM(require("../../../package.json"));
|
|
50
51
|
const _PackageUrls = class _PackageUrls {
|
|
51
52
|
static async get(packageName) {
|
|
52
53
|
if (!this.items[packageName]) {
|
|
@@ -73,7 +74,9 @@ const _PackageUrls = class _PackageUrls {
|
|
|
73
74
|
}
|
|
74
75
|
} catch (error) {
|
|
75
76
|
}
|
|
76
|
-
const
|
|
77
|
+
const appVersion = import_package.default.version;
|
|
78
|
+
const salt = process.env.PLUGIN_URL_HASH_SALT || "";
|
|
79
|
+
const hash = import_crypto.default.createHash("sha256").update(fsState.mtime.getTime() + appKey + version + appVersion + salt).digest("hex").slice(0, 8);
|
|
77
80
|
t = `?hash=${hash}`;
|
|
78
81
|
}
|
|
79
82
|
const cdnBaseUrl = process.env.CDN_BASE_URL.replace(/\/+$/, "");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,21 +10,21 @@
|
|
|
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.
|
|
14
|
-
"@nocobase/actions": "2.0.
|
|
15
|
-
"@nocobase/ai": "2.0.
|
|
16
|
-
"@nocobase/auth": "2.0.
|
|
17
|
-
"@nocobase/cache": "2.0.
|
|
18
|
-
"@nocobase/data-source-manager": "2.0.
|
|
19
|
-
"@nocobase/database": "2.0.
|
|
20
|
-
"@nocobase/evaluators": "2.0.
|
|
21
|
-
"@nocobase/lock-manager": "2.0.
|
|
22
|
-
"@nocobase/logger": "2.0.
|
|
23
|
-
"@nocobase/resourcer": "2.0.
|
|
24
|
-
"@nocobase/sdk": "2.0.
|
|
25
|
-
"@nocobase/snowflake-id": "2.0.
|
|
26
|
-
"@nocobase/telemetry": "2.0.
|
|
27
|
-
"@nocobase/utils": "2.0.
|
|
13
|
+
"@nocobase/acl": "2.0.13",
|
|
14
|
+
"@nocobase/actions": "2.0.13",
|
|
15
|
+
"@nocobase/ai": "2.0.13",
|
|
16
|
+
"@nocobase/auth": "2.0.13",
|
|
17
|
+
"@nocobase/cache": "2.0.13",
|
|
18
|
+
"@nocobase/data-source-manager": "2.0.13",
|
|
19
|
+
"@nocobase/database": "2.0.13",
|
|
20
|
+
"@nocobase/evaluators": "2.0.13",
|
|
21
|
+
"@nocobase/lock-manager": "2.0.13",
|
|
22
|
+
"@nocobase/logger": "2.0.13",
|
|
23
|
+
"@nocobase/resourcer": "2.0.13",
|
|
24
|
+
"@nocobase/sdk": "2.0.13",
|
|
25
|
+
"@nocobase/snowflake-id": "2.0.13",
|
|
26
|
+
"@nocobase/telemetry": "2.0.13",
|
|
27
|
+
"@nocobase/utils": "2.0.13",
|
|
28
28
|
"@types/decompress": "4.2.7",
|
|
29
29
|
"@types/ini": "^1.3.31",
|
|
30
30
|
"@types/koa-send": "^4.1.3",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@types/serve-handler": "^6.1.1",
|
|
62
62
|
"@types/ws": "^8.5.5"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "3486d15dd3f821411f514b7e0b57e44d942917c9"
|
|
65
65
|
}
|