@nocobase/plugin-flow-engine 2.0.0-beta.1 → 2.0.0-beta.11
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/dist/externalVersion.js +9 -9
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/server/variables/records.d.ts +38 -0
- package/dist/server/variables/records.js +120 -0
- package/dist/server/variables/registry.js +20 -13
- package/dist/server/variables/utils.js +22 -6
- package/package.json +2 -2
package/dist/externalVersion.js
CHANGED
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.0.0-beta.
|
|
11
|
+
"@nocobase/client": "2.0.0-beta.11",
|
|
12
12
|
"lodash": "4.17.21",
|
|
13
|
-
"@nocobase/database": "2.0.0-beta.
|
|
14
|
-
"@nocobase/data-source-manager": "2.0.0-beta.
|
|
15
|
-
"@nocobase/resourcer": "2.0.0-beta.
|
|
16
|
-
"@nocobase/server": "2.0.0-beta.
|
|
17
|
-
"@nocobase/utils": "2.0.0-beta.
|
|
18
|
-
"@nocobase/cache": "2.0.0-beta.
|
|
19
|
-
"@nocobase/plugin-localization": "2.0.0-beta.
|
|
20
|
-
"@nocobase/actions": "2.0.0-beta.
|
|
13
|
+
"@nocobase/database": "2.0.0-beta.11",
|
|
14
|
+
"@nocobase/data-source-manager": "2.0.0-beta.11",
|
|
15
|
+
"@nocobase/resourcer": "2.0.0-beta.11",
|
|
16
|
+
"@nocobase/server": "2.0.0-beta.11",
|
|
17
|
+
"@nocobase/utils": "2.0.0-beta.11",
|
|
18
|
+
"@nocobase/cache": "2.0.0-beta.11",
|
|
19
|
+
"@nocobase/plugin-localization": "2.0.0-beta.11",
|
|
20
|
+
"@nocobase/actions": "2.0.0-beta.11"
|
|
21
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"ses","version":"1.14.0","description":"Hardened JavaScript for Fearless Cooperation","keywords":["lockdown","harden","Compartment","assert","security","confinement","isolation","object capabilities","ocaps","secure execution","third-party code","prototype pollution","supply-chain attack","plugin"],"author":"Agoric","license":"Apache-2.0","homepage":"https://github.com/Agoric/SES-shim/tree/master/packages/ses#readme","repository":{"type":"git","url":"git+https://github.com/endojs/endo.git","directory":"packages/ses"},"bugs":{"url":"https://github.com/endojs/endo/issues"},"type":"module","main":"./dist/ses.cjs","module":"./index.js","unpkg":"./dist/ses.umd.js","types":"./types.d.ts","exports":{".":{"import":{"types":"./types.d.ts","xs":"./src-xs/index.js","default":"./index.js"},"require":{"types":"./dist/types.d.cts","default":"./dist/ses.cjs"}},"./lockdown":{"import":{"types":"./types.d.ts","default":"./index.js"},"require":{"types":"./dist/types.d.cts","default":"./dist/ses.cjs"}},"./hermes":{"require":{"types":"./dist/types.d.cts","default":"./dist/ses-hermes.cjs"}},"./tools.js":"./tools.js","./assert-shim.js":"./assert-shim.js","./lockdown-shim.js":{"xs":"./src-xs/lockdown-shim.js","default":"./lockdown-shim.js"},"./compartment-shim.js":{"xs":"./src-xs/compartment-shim.js","default":"./compartment-shim.js"},"./console-shim.js":"./console-shim.js","./package.json":"./package.json"},"scripts":{"build:vanilla":"node scripts/bundle.js","build:hermes":"node scripts/bundle.js hermes","build":"yarn build:vanilla && yarn build:hermes","clean":"rm -rf dist","cover":"c8 ava","demo":"python3 -m http.server","lint":"yarn lint:types && yarn lint:eslint","lint-fix":"eslint --fix .","lint:eslint":"eslint .","lint:types":"tsc","prepare":"npm run clean && npm run build","qt":"ava","test":"tsd && ava","test:hermes":"./scripts/hermes-test.sh","test:xs":"xst dist/ses.umd.js test/_lockdown-safe.js && node scripts/generate-test-xs.js && xst tmp/test-xs.js && rm -rf tmp","postpack":"git clean -fX \"*.d.ts*\" \"*.d.cts*\" \"*.d.mts*\" \"*.tsbuildinfo\""},"dependencies":{"@endo/cache-map":"^1.1.0","@endo/env-options":"^1.1.11","@endo/immutable-arraybuffer":"^1.1.2"},"devDependencies":{"@babel/generator":"^7.26.3","@babel/parser":"~7.26.2","@babel/traverse":"~7.25.9","@babel/types":"~7.26.0","@endo/compartment-mapper":"^1.6.3","@endo/module-source":"^1.3.3","@endo/test262-runner":"^0.1.48","@types/babel__traverse":"^7.20.5","ava":"^6.1.3","babel-eslint":"^10.1.0","c8":"^7.14.0","core-js":"^3.31.0","eslint":"^8.57.1","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^9.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-import":"^2.31.0","hermes-engine-cli":"^0.12.0","prettier":"^3.5.3","terser":"^5.16.6","tsd":"^0.31.2","typescript":"~5.8.3"},"files":["./*.d.ts","./*.js","./*.map","LICENSE*","SECURITY*","dist","lib","src","tools"],"publishConfig":{"access":"public"},"eslintConfig":{"extends":["plugin:@endo/ses"]},"ava":{"files":["test/**/*.test.*"],"timeout":"2m"},"typeCoverage":{"atLeast":81.17},"gitHead":"9815aea9541f241389d2135c6097a7442bdffa17","_lastModified":"
|
|
1
|
+
{"name":"ses","version":"1.14.0","description":"Hardened JavaScript for Fearless Cooperation","keywords":["lockdown","harden","Compartment","assert","security","confinement","isolation","object capabilities","ocaps","secure execution","third-party code","prototype pollution","supply-chain attack","plugin"],"author":"Agoric","license":"Apache-2.0","homepage":"https://github.com/Agoric/SES-shim/tree/master/packages/ses#readme","repository":{"type":"git","url":"git+https://github.com/endojs/endo.git","directory":"packages/ses"},"bugs":{"url":"https://github.com/endojs/endo/issues"},"type":"module","main":"./dist/ses.cjs","module":"./index.js","unpkg":"./dist/ses.umd.js","types":"./types.d.ts","exports":{".":{"import":{"types":"./types.d.ts","xs":"./src-xs/index.js","default":"./index.js"},"require":{"types":"./dist/types.d.cts","default":"./dist/ses.cjs"}},"./lockdown":{"import":{"types":"./types.d.ts","default":"./index.js"},"require":{"types":"./dist/types.d.cts","default":"./dist/ses.cjs"}},"./hermes":{"require":{"types":"./dist/types.d.cts","default":"./dist/ses-hermes.cjs"}},"./tools.js":"./tools.js","./assert-shim.js":"./assert-shim.js","./lockdown-shim.js":{"xs":"./src-xs/lockdown-shim.js","default":"./lockdown-shim.js"},"./compartment-shim.js":{"xs":"./src-xs/compartment-shim.js","default":"./compartment-shim.js"},"./console-shim.js":"./console-shim.js","./package.json":"./package.json"},"scripts":{"build:vanilla":"node scripts/bundle.js","build:hermes":"node scripts/bundle.js hermes","build":"yarn build:vanilla && yarn build:hermes","clean":"rm -rf dist","cover":"c8 ava","demo":"python3 -m http.server","lint":"yarn lint:types && yarn lint:eslint","lint-fix":"eslint --fix .","lint:eslint":"eslint .","lint:types":"tsc","prepare":"npm run clean && npm run build","qt":"ava","test":"tsd && ava","test:hermes":"./scripts/hermes-test.sh","test:xs":"xst dist/ses.umd.js test/_lockdown-safe.js && node scripts/generate-test-xs.js && xst tmp/test-xs.js && rm -rf tmp","postpack":"git clean -fX \"*.d.ts*\" \"*.d.cts*\" \"*.d.mts*\" \"*.tsbuildinfo\""},"dependencies":{"@endo/cache-map":"^1.1.0","@endo/env-options":"^1.1.11","@endo/immutable-arraybuffer":"^1.1.2"},"devDependencies":{"@babel/generator":"^7.26.3","@babel/parser":"~7.26.2","@babel/traverse":"~7.25.9","@babel/types":"~7.26.0","@endo/compartment-mapper":"^1.6.3","@endo/module-source":"^1.3.3","@endo/test262-runner":"^0.1.48","@types/babel__traverse":"^7.20.5","ava":"^6.1.3","babel-eslint":"^10.1.0","c8":"^7.14.0","core-js":"^3.31.0","eslint":"^8.57.1","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^9.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-import":"^2.31.0","hermes-engine-cli":"^0.12.0","prettier":"^3.5.3","terser":"^5.16.6","tsd":"^0.31.2","typescript":"~5.8.3"},"files":["./*.d.ts","./*.js","./*.map","LICENSE*","SECURITY*","dist","lib","src","tools"],"publishConfig":{"access":"public"},"eslintConfig":{"extends":["plugin:@endo/ses"]},"ava":{"files":["test/**/*.test.*"],"timeout":"2m"},"typeCoverage":{"atLeast":81.17},"gitHead":"9815aea9541f241389d2135c6097a7442bdffa17","_lastModified":"2026-01-15T06:43:18.131Z"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
type FilterTargetKey = string | string[] | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* 为了:
|
|
12
|
+
* - 关联加载/缓存:fields 模式下确保包含主键
|
|
13
|
+
* - filterByTk 为数组时:尽量包含 filterTargetKey,以便按输入顺序对齐结果
|
|
14
|
+
*
|
|
15
|
+
* 该函数只返回“建议追加”的 key 字段(不会决定是否追加,由调用方根据是否启用 fields 决定)。
|
|
16
|
+
*/
|
|
17
|
+
export declare function getExtraKeyFieldsForSelect(filterByTk: unknown, options: {
|
|
18
|
+
filterTargetKey?: FilterTargetKey;
|
|
19
|
+
pkAttr?: string;
|
|
20
|
+
pkIsValid?: boolean;
|
|
21
|
+
rawAttributes?: Record<string, unknown>;
|
|
22
|
+
}): string[];
|
|
23
|
+
export declare function mergeFieldsWithExtras(fields?: string[], extras?: string[]): string[] | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* 根据 filterByTk 类型(单值/数组)查询并返回 JSON 数据:
|
|
26
|
+
* - 单值:返回 object | undefined
|
|
27
|
+
* - 数组:返回 array(空数组时返回 [],不会退化为无条件查询)
|
|
28
|
+
*/
|
|
29
|
+
export declare function fetchRecordOrRecordsJson(repo: any, params: {
|
|
30
|
+
filterByTk: unknown;
|
|
31
|
+
preferFullRecord?: boolean;
|
|
32
|
+
fields?: string[];
|
|
33
|
+
appends?: string[];
|
|
34
|
+
filterTargetKey?: FilterTargetKey;
|
|
35
|
+
pkAttr?: string;
|
|
36
|
+
pkIsValid?: boolean;
|
|
37
|
+
}): Promise<unknown>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
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 __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var records_exports = {};
|
|
28
|
+
__export(records_exports, {
|
|
29
|
+
fetchRecordOrRecordsJson: () => fetchRecordOrRecordsJson,
|
|
30
|
+
getExtraKeyFieldsForSelect: () => getExtraKeyFieldsForSelect,
|
|
31
|
+
mergeFieldsWithExtras: () => mergeFieldsWithExtras
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(records_exports);
|
|
34
|
+
function uniqStrings(list) {
|
|
35
|
+
return Array.from(new Set(list));
|
|
36
|
+
}
|
|
37
|
+
function isPrimitiveTkArray(arr) {
|
|
38
|
+
return arr.every((v) => typeof v === "string" || typeof v === "number");
|
|
39
|
+
}
|
|
40
|
+
function getOrderKey(options) {
|
|
41
|
+
if (typeof options.filterTargetKey === "string") return options.filterTargetKey;
|
|
42
|
+
if (options.pkIsValid && options.pkAttr) return options.pkAttr;
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
function getExtraKeyFieldsForSelect(filterByTk, options) {
|
|
46
|
+
const extra = [];
|
|
47
|
+
if (options.pkIsValid && options.pkAttr) {
|
|
48
|
+
extra.push(options.pkAttr);
|
|
49
|
+
}
|
|
50
|
+
if (Array.isArray(filterByTk) && filterByTk.length > 0) {
|
|
51
|
+
const tkKeys = typeof options.filterTargetKey === "string" ? [options.filterTargetKey] : Array.isArray(options.filterTargetKey) ? options.filterTargetKey : [];
|
|
52
|
+
if (options.rawAttributes) {
|
|
53
|
+
for (const k of tkKeys) {
|
|
54
|
+
if (k && Object.prototype.hasOwnProperty.call(options.rawAttributes, k)) {
|
|
55
|
+
extra.push(k);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return uniqStrings(extra);
|
|
61
|
+
}
|
|
62
|
+
function mergeFieldsWithExtras(fields, extras = []) {
|
|
63
|
+
if (!Array.isArray(fields) || fields.length === 0 || extras.length === 0) return fields;
|
|
64
|
+
return uniqStrings([...fields, ...extras]);
|
|
65
|
+
}
|
|
66
|
+
function toJsonArray(rows) {
|
|
67
|
+
if (!Array.isArray(rows)) return [];
|
|
68
|
+
return rows.map((r) => (r == null ? void 0 : r.toJSON) ? r.toJSON() : r);
|
|
69
|
+
}
|
|
70
|
+
function reorderRecordsByFilterByTk(records, filterByTk, options) {
|
|
71
|
+
if (!Array.isArray(filterByTk) || filterByTk.length === 0) return records;
|
|
72
|
+
if (!isPrimitiveTkArray(filterByTk)) return records;
|
|
73
|
+
const orderKey = getOrderKey(options);
|
|
74
|
+
if (!orderKey) return records;
|
|
75
|
+
const map = /* @__PURE__ */ new Map();
|
|
76
|
+
for (const rec of records || []) {
|
|
77
|
+
const k = rec == null ? void 0 : rec[orderKey];
|
|
78
|
+
if (typeof k !== "undefined" && k !== null) {
|
|
79
|
+
map.set(String(k), rec);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const ordered = [];
|
|
83
|
+
const used = /* @__PURE__ */ new Set();
|
|
84
|
+
for (const tk of filterByTk) {
|
|
85
|
+
const k = String(tk);
|
|
86
|
+
const rec = map.get(k);
|
|
87
|
+
if (typeof rec !== "undefined") {
|
|
88
|
+
ordered.push(rec);
|
|
89
|
+
used.add(k);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
for (const rec of records || []) {
|
|
93
|
+
const k = rec == null ? void 0 : rec[orderKey];
|
|
94
|
+
const ks = typeof k === "undefined" || k === null ? void 0 : String(k);
|
|
95
|
+
if (!ks || used.has(ks)) continue;
|
|
96
|
+
ordered.push(rec);
|
|
97
|
+
}
|
|
98
|
+
return ordered;
|
|
99
|
+
}
|
|
100
|
+
async function fetchRecordOrRecordsJson(repo, params) {
|
|
101
|
+
const { filterByTk, preferFullRecord, fields, appends } = params;
|
|
102
|
+
if (Array.isArray(filterByTk)) {
|
|
103
|
+
if (filterByTk.length === 0) return [];
|
|
104
|
+
const rows = await repo.find(
|
|
105
|
+
preferFullRecord ? { filterByTk } : { filterByTk, fields, appends }
|
|
106
|
+
);
|
|
107
|
+
const jsonArr = toJsonArray(rows);
|
|
108
|
+
return reorderRecordsByFilterByTk(jsonArr, filterByTk, params);
|
|
109
|
+
}
|
|
110
|
+
const rec = await repo.findOne(
|
|
111
|
+
preferFullRecord ? { filterByTk } : { filterByTk, fields, appends }
|
|
112
|
+
);
|
|
113
|
+
return rec ? rec.toJSON() : void 0;
|
|
114
|
+
}
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 && (module.exports = {
|
|
117
|
+
fetchRecordOrRecordsJson,
|
|
118
|
+
getExtraKeyFieldsForSelect,
|
|
119
|
+
mergeFieldsWithExtras
|
|
120
|
+
});
|
|
@@ -44,6 +44,7 @@ var import_lodash = __toESM(require("lodash"));
|
|
|
44
44
|
var import_contexts = require("../template/contexts");
|
|
45
45
|
var import_utils = require("@nocobase/utils");
|
|
46
46
|
var import_selects = require("./selects");
|
|
47
|
+
var import_records = require("./records");
|
|
47
48
|
class VariableRegistry {
|
|
48
49
|
vars = /* @__PURE__ */ new Map();
|
|
49
50
|
register(def) {
|
|
@@ -130,7 +131,7 @@ function inferSelectsFromUsage(paths = [], _params) {
|
|
|
130
131
|
return { generatedAppends, generatedFields };
|
|
131
132
|
}
|
|
132
133
|
async function fetchRecordWithRequestCache(koaCtx, dataSourceKey, collection, filterByTk, fields, appends, preferFullRecord, associationName, sourceId) {
|
|
133
|
-
var _a, _b, _c, _d, _e;
|
|
134
|
+
var _a, _b, _c, _d, _e, _f;
|
|
134
135
|
try {
|
|
135
136
|
const log = (_b = (_a = koaCtx.app) == null ? void 0 : _a.logger) == null ? void 0 : _b.child({
|
|
136
137
|
module: "plugin-flow-engine",
|
|
@@ -150,7 +151,14 @@ async function fetchRecordWithRequestCache(koaCtx, dataSourceKey, collection, fi
|
|
|
150
151
|
const modelInfo = (_c = repo.collection) == null ? void 0 : _c.model;
|
|
151
152
|
const pkAttr = modelInfo == null ? void 0 : modelInfo.primaryKeyAttribute;
|
|
152
153
|
const pkIsValid = pkAttr && (modelInfo == null ? void 0 : modelInfo.rawAttributes) && Object.prototype.hasOwnProperty.call(modelInfo.rawAttributes, pkAttr);
|
|
153
|
-
const
|
|
154
|
+
const filterTargetKey = (_d = repo.collection) == null ? void 0 : _d.filterTargetKey;
|
|
155
|
+
const extraKeyFields = (0, import_records.getExtraKeyFieldsForSelect)(filterByTk, {
|
|
156
|
+
filterTargetKey,
|
|
157
|
+
pkAttr,
|
|
158
|
+
pkIsValid,
|
|
159
|
+
rawAttributes: modelInfo == null ? void 0 : modelInfo.rawAttributes
|
|
160
|
+
});
|
|
161
|
+
const fieldsWithPk = (0, import_records.mergeFieldsWithExtras)(fields, extraKeyFields);
|
|
154
162
|
const cacheKeyFields = preferFullRecord && pkIsValid ? void 0 : Array.isArray(fieldsWithPk) ? [...fieldsWithPk].sort() : void 0;
|
|
155
163
|
const cacheKeyAppends = preferFullRecord ? void 0 : Array.isArray(appends) ? [...appends].sort() : void 0;
|
|
156
164
|
const keyObj = {
|
|
@@ -192,20 +200,19 @@ async function fetchRecordWithRequestCache(koaCtx, dataSourceKey, collection, fi
|
|
|
192
200
|
}
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
);
|
|
204
|
-
const json = rec ? rec.toJSON() : void 0;
|
|
203
|
+
const json = await (0, import_records.fetchRecordOrRecordsJson)(repo, {
|
|
204
|
+
filterByTk,
|
|
205
|
+
preferFullRecord,
|
|
206
|
+
fields: fieldsWithPk,
|
|
207
|
+
appends,
|
|
208
|
+
filterTargetKey,
|
|
209
|
+
pkAttr,
|
|
210
|
+
pkIsValid
|
|
211
|
+
});
|
|
205
212
|
if (cache) cache.set(key, json);
|
|
206
213
|
return json;
|
|
207
214
|
} catch (e) {
|
|
208
|
-
const log = (
|
|
215
|
+
const log = (_f = (_e = koaCtx.app) == null ? void 0 : _e.logger) == null ? void 0 : _f.child({
|
|
209
216
|
module: "plugin-flow-engine",
|
|
210
217
|
submodule: "variables.resolve",
|
|
211
218
|
method: "fetchRecordWithRequestCache"
|
|
@@ -31,8 +31,9 @@ __export(utils_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(utils_exports);
|
|
32
32
|
var import_registry = require("./registry");
|
|
33
33
|
var import_selects = require("./selects");
|
|
34
|
+
var import_records = require("./records");
|
|
34
35
|
async function prefetchRecordsForResolve(koaCtx, items) {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
36
37
|
try {
|
|
37
38
|
const log = (_b = (_a = koaCtx.app) == null ? void 0 : _a.logger) == null ? void 0 : _b.child({ module: "plugin-flow-engine", submodule: "variables.prefetch" });
|
|
38
39
|
const groupMap = /* @__PURE__ */ new Map();
|
|
@@ -69,6 +70,7 @@ async function prefetchRecordsForResolve(koaCtx, items) {
|
|
|
69
70
|
const collection = recordParams == null ? void 0 : recordParams.collection;
|
|
70
71
|
const filterByTk = recordParams == null ? void 0 : recordParams.filterByTk;
|
|
71
72
|
if (!collection || typeof filterByTk === "undefined") continue;
|
|
73
|
+
if (Array.isArray(filterByTk) && filterByTk.length === 0) continue;
|
|
72
74
|
const group = ensureGroup(dataSourceKey, collection, filterByTk);
|
|
73
75
|
let { generatedAppends, generatedFields } = (0, import_registry.inferSelectsFromUsage)(remainders);
|
|
74
76
|
const fixed = (0, import_selects.adjustSelectsForCollection)(koaCtx, dataSourceKey, collection, generatedFields, generatedAppends);
|
|
@@ -93,13 +95,27 @@ async function prefetchRecordsForResolve(koaCtx, items) {
|
|
|
93
95
|
const modelInfo = (_d = repo.collection) == null ? void 0 : _d.model;
|
|
94
96
|
const pkAttr = modelInfo == null ? void 0 : modelInfo.primaryKeyAttribute;
|
|
95
97
|
const pkIsValid = pkAttr && (modelInfo == null ? void 0 : modelInfo.rawAttributes) && Object.prototype.hasOwnProperty.call(modelInfo.rawAttributes, pkAttr);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
const filterTargetKey = (_e = repo == null ? void 0 : repo.collection) == null ? void 0 : _e.filterTargetKey;
|
|
99
|
+
const extraKeyFields = (0, import_records.getExtraKeyFieldsForSelect)(filterByTk, {
|
|
100
|
+
filterTargetKey,
|
|
101
|
+
pkAttr,
|
|
102
|
+
pkIsValid,
|
|
103
|
+
rawAttributes: modelInfo == null ? void 0 : modelInfo.rawAttributes
|
|
104
|
+
});
|
|
105
|
+
if (fields.size && extraKeyFields.length) {
|
|
106
|
+
extraKeyFields.forEach((f) => fields.add(f));
|
|
98
107
|
}
|
|
99
108
|
const fld = fields.size ? Array.from(fields).sort() : void 0;
|
|
100
109
|
const app = appends.size ? Array.from(appends).sort() : void 0;
|
|
101
|
-
const
|
|
102
|
-
|
|
110
|
+
const json = await (0, import_records.fetchRecordOrRecordsJson)(repo, {
|
|
111
|
+
filterByTk,
|
|
112
|
+
preferFullRecord: false,
|
|
113
|
+
fields: fld,
|
|
114
|
+
appends: app,
|
|
115
|
+
filterTargetKey,
|
|
116
|
+
pkAttr,
|
|
117
|
+
pkIsValid
|
|
118
|
+
});
|
|
103
119
|
if (cache) {
|
|
104
120
|
const key = JSON.stringify({ ds: dataSourceKey, c: collection, tk: filterByTk, f: fld, a: app });
|
|
105
121
|
cache.set(key, json);
|
|
@@ -114,7 +130,7 @@ async function prefetchRecordsForResolve(koaCtx, items) {
|
|
|
114
130
|
}
|
|
115
131
|
}
|
|
116
132
|
} catch (e) {
|
|
117
|
-
(
|
|
133
|
+
(_h = (_g = (_f = koaCtx.app) == null ? void 0 : _f.logger) == null ? void 0 : _g.child({ module: "plugin-flow-engine", submodule: "variables.prefetch" })) == null ? void 0 : _h.debug("[variables.resolve] prefetch fatal error", { error: (e == null ? void 0 : e.message) || String(e) });
|
|
118
134
|
}
|
|
119
135
|
}
|
|
120
136
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "前端流引擎",
|
|
5
5
|
"description": "",
|
|
6
6
|
"description.zh-CN": "",
|
|
7
|
-
"version": "2.0.0-beta.
|
|
7
|
+
"version": "2.0.0-beta.11",
|
|
8
8
|
"main": "./dist/server/index.js",
|
|
9
9
|
"license": "AGPL-3.0",
|
|
10
10
|
"devDependencies": {
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@nocobase/test": "2.x",
|
|
25
25
|
"@nocobase/utils": "2.x"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "a7b36d7c7c42621fb048cd7d82b1e4180b84ab08"
|
|
28
28
|
}
|