@nocobase/plugin-flow-engine 2.0.0-beta.11 → 2.0.0-beta.12
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
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.12",
|
|
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.12",
|
|
14
|
+
"@nocobase/data-source-manager": "2.0.0-beta.12",
|
|
15
|
+
"@nocobase/resourcer": "2.0.0-beta.12",
|
|
16
|
+
"@nocobase/server": "2.0.0-beta.12",
|
|
17
|
+
"@nocobase/utils": "2.0.0-beta.12",
|
|
18
|
+
"@nocobase/cache": "2.0.0-beta.12",
|
|
19
|
+
"@nocobase/plugin-localization": "2.0.0-beta.12",
|
|
20
|
+
"@nocobase/actions": "2.0.0-beta.12"
|
|
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":"2026-01-
|
|
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-16T01:59:26.562Z"}
|
|
@@ -44,7 +44,6 @@ 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");
|
|
48
47
|
class VariableRegistry {
|
|
49
48
|
vars = /* @__PURE__ */ new Map();
|
|
50
49
|
register(def) {
|
|
@@ -130,8 +129,8 @@ function inferSelectsFromUsage(paths = [], _params) {
|
|
|
130
129
|
const generatedFields = fieldSet.size ? Array.from(fieldSet) : void 0;
|
|
131
130
|
return { generatedAppends, generatedFields };
|
|
132
131
|
}
|
|
133
|
-
async function fetchRecordWithRequestCache(koaCtx, dataSourceKey, collection, filterByTk, fields, appends, preferFullRecord, associationName, sourceId) {
|
|
134
|
-
var _a, _b, _c, _d, _e
|
|
132
|
+
async function fetchRecordWithRequestCache(koaCtx, dataSourceKey, collection, filterByTk, fields, appends, strictSelects, preferFullRecord, associationName, sourceId) {
|
|
133
|
+
var _a, _b, _c, _d, _e;
|
|
135
134
|
try {
|
|
136
135
|
const log = (_b = (_a = koaCtx.app) == null ? void 0 : _a.logger) == null ? void 0 : _b.child({
|
|
137
136
|
module: "plugin-flow-engine",
|
|
@@ -151,14 +150,7 @@ async function fetchRecordWithRequestCache(koaCtx, dataSourceKey, collection, fi
|
|
|
151
150
|
const modelInfo = (_c = repo.collection) == null ? void 0 : _c.model;
|
|
152
151
|
const pkAttr = modelInfo == null ? void 0 : modelInfo.primaryKeyAttribute;
|
|
153
152
|
const pkIsValid = pkAttr && (modelInfo == null ? void 0 : modelInfo.rawAttributes) && Object.prototype.hasOwnProperty.call(modelInfo.rawAttributes, pkAttr);
|
|
154
|
-
const
|
|
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);
|
|
153
|
+
const fieldsWithPk = Array.isArray(fields) && fields.length > 0 && pkIsValid ? Array.from(/* @__PURE__ */ new Set([...fields, pkAttr])) : fields;
|
|
162
154
|
const cacheKeyFields = preferFullRecord && pkIsValid ? void 0 : Array.isArray(fieldsWithPk) ? [...fieldsWithPk].sort() : void 0;
|
|
163
155
|
const cacheKeyAppends = preferFullRecord ? void 0 : Array.isArray(appends) ? [...appends].sort() : void 0;
|
|
164
156
|
const keyObj = {
|
|
@@ -176,43 +168,46 @@ async function fetchRecordWithRequestCache(koaCtx, dataSourceKey, collection, fi
|
|
|
176
168
|
if (cache.has(key)) {
|
|
177
169
|
return cache.get(key);
|
|
178
170
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
171
|
+
if (!strictSelects) {
|
|
172
|
+
const needFields = !preferFullRecord && Array.isArray(fieldsWithPk) ? [...new Set(fieldsWithPk)] : void 0;
|
|
173
|
+
const needAppends = !preferFullRecord && Array.isArray(appends) ? new Set(appends) : void 0;
|
|
174
|
+
for (const [cacheKey, cacheVal] of cache.entries()) {
|
|
175
|
+
const parsed = JSON.parse(cacheKey);
|
|
176
|
+
if (!parsed || parsed.ds !== keyObj.ds || parsed.c !== keyObj.c || parsed.tk !== keyObj.tk || parsed.assoc !== keyObj.assoc || parsed.sid !== keyObj.sid)
|
|
177
|
+
continue;
|
|
178
|
+
const cachedFields = new Set(parsed.f || []);
|
|
179
|
+
const cachedAppends = new Set(parsed.a || []);
|
|
180
|
+
const fieldCoveredByAppends = (fieldPath) => {
|
|
181
|
+
const p = String(fieldPath || "");
|
|
182
|
+
for (const a of cachedAppends) {
|
|
183
|
+
if (!a) continue;
|
|
184
|
+
if (p === a || p.startsWith(a + ".")) return true;
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
};
|
|
188
|
+
const fieldsOk = needFields ? needFields.every((f) => cachedFields.has(f) || fieldCoveredByAppends(f)) : parsed.f === void 0;
|
|
189
|
+
const appendsOk = !needAppends || [...needAppends].every((a) => cachedAppends.has(a));
|
|
190
|
+
const fullOk = preferFullRecord ? parsed.full === true : true;
|
|
191
|
+
if (fieldsOk && appendsOk && fullOk) {
|
|
192
|
+
return cacheVal;
|
|
192
193
|
}
|
|
193
|
-
return false;
|
|
194
|
-
};
|
|
195
|
-
const fieldsOk = needFields ? needFields.every((f) => cachedFields.has(f) || fieldCoveredByAppends(f)) : parsed.f === void 0;
|
|
196
|
-
const appendsOk = !needAppends || [...needAppends].every((a) => cachedAppends.has(a));
|
|
197
|
-
const fullOk = preferFullRecord ? parsed.full === true : true;
|
|
198
|
-
if (fieldsOk && appendsOk && fullOk) {
|
|
199
|
-
return cacheVal;
|
|
200
194
|
}
|
|
201
195
|
}
|
|
202
196
|
}
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
197
|
+
const rec = await repo.findOne(
|
|
198
|
+
preferFullRecord ? {
|
|
199
|
+
filterByTk
|
|
200
|
+
} : {
|
|
201
|
+
filterByTk,
|
|
202
|
+
fields: fieldsWithPk,
|
|
203
|
+
appends
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
const json = rec ? rec.toJSON() : void 0;
|
|
212
207
|
if (cache) cache.set(key, json);
|
|
213
208
|
return json;
|
|
214
209
|
} catch (e) {
|
|
215
|
-
const log = (
|
|
210
|
+
const log = (_e = (_d = koaCtx.app) == null ? void 0 : _d.logger) == null ? void 0 : _e.child({
|
|
216
211
|
module: "plugin-flow-engine",
|
|
217
212
|
submodule: "variables.resolve",
|
|
218
213
|
method: "fetchRecordWithRequestCache"
|
|
@@ -240,12 +235,37 @@ function attachGenericRecordVariables(flowCtx, koaCtx, usage, contextParams) {
|
|
|
240
235
|
for (const varName of Object.keys(usage)) {
|
|
241
236
|
const usedPaths = usage[varName] || [];
|
|
242
237
|
const topParams = import_lodash.default.get(contextParams, varName);
|
|
238
|
+
const deepRecordMap = /* @__PURE__ */ new Map();
|
|
239
|
+
const cp = contextParams;
|
|
240
|
+
if (cp && typeof cp === "object") {
|
|
241
|
+
const cpRec = cp;
|
|
242
|
+
for (const key of Object.keys(cpRec)) {
|
|
243
|
+
if (!key || key !== varName && !key.startsWith(`${varName}.`)) continue;
|
|
244
|
+
if (key === varName) continue;
|
|
245
|
+
const val = cpRec[key];
|
|
246
|
+
if (!isRecordParams(val)) continue;
|
|
247
|
+
const relative = key.slice(varName.length + 1);
|
|
248
|
+
if (!relative) continue;
|
|
249
|
+
deepRecordMap.set(relative, val);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
243
252
|
if (isRecordParams(topParams)) {
|
|
244
|
-
const
|
|
245
|
-
|
|
253
|
+
const usedPathsForBase = deepRecordMap.size ? (usedPaths || []).filter((p) => {
|
|
254
|
+
if (!p) return true;
|
|
255
|
+
for (const relative of deepRecordMap.keys()) {
|
|
256
|
+
if (!relative) continue;
|
|
257
|
+
if (p === relative || p.startsWith(relative + ".") || p.startsWith(relative + "[")) return false;
|
|
258
|
+
}
|
|
259
|
+
return true;
|
|
260
|
+
}) : usedPaths || [];
|
|
261
|
+
const hasDirectRefTop = usedPathsForBase.some((p) => p === "");
|
|
246
262
|
flowCtx.defineProperty(varName, {
|
|
247
263
|
get: async () => {
|
|
248
264
|
const dataSourceKey = (topParams == null ? void 0 : topParams.dataSourceKey) || "main";
|
|
265
|
+
const strictSelects = Array.isArray(topParams == null ? void 0 : topParams.fields) || Array.isArray(topParams == null ? void 0 : topParams.appends);
|
|
266
|
+
let { generatedAppends, generatedFields } = inferSelectsFromUsage(usedPathsForBase, topParams);
|
|
267
|
+
if (Array.isArray(topParams == null ? void 0 : topParams.fields)) generatedFields = topParams.fields;
|
|
268
|
+
if (Array.isArray(topParams == null ? void 0 : topParams.appends)) generatedAppends = topParams.appends;
|
|
249
269
|
const fixed = (0, import_selects.adjustSelectsForCollection)(
|
|
250
270
|
koaCtx,
|
|
251
271
|
dataSourceKey,
|
|
@@ -253,17 +273,69 @@ function attachGenericRecordVariables(flowCtx, koaCtx, usage, contextParams) {
|
|
|
253
273
|
generatedFields,
|
|
254
274
|
generatedAppends
|
|
255
275
|
);
|
|
256
|
-
|
|
276
|
+
const base = await fetchRecordWithRequestCache(
|
|
257
277
|
koaCtx,
|
|
258
278
|
dataSourceKey,
|
|
259
279
|
topParams.collection,
|
|
260
280
|
topParams.filterByTk,
|
|
261
281
|
fixed.fields,
|
|
262
282
|
fixed.appends,
|
|
283
|
+
strictSelects,
|
|
263
284
|
hasDirectRefTop,
|
|
264
285
|
topParams.associationName,
|
|
265
286
|
topParams.sourceId
|
|
266
287
|
);
|
|
288
|
+
if (!deepRecordMap.size) return base;
|
|
289
|
+
const merged = base && typeof base === "object" && !Array.isArray(base) ? { ...base } : {};
|
|
290
|
+
const setClonedPath = (obj, path, value) => {
|
|
291
|
+
const segs = String(path || "").split(".").filter(Boolean);
|
|
292
|
+
if (!segs.length) return;
|
|
293
|
+
if (segs.length === 1) {
|
|
294
|
+
obj[segs[0]] = value;
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
let cur = obj;
|
|
298
|
+
for (let i = 0; i < segs.length - 1; i++) {
|
|
299
|
+
const seg = segs[i];
|
|
300
|
+
const prev = cur[seg];
|
|
301
|
+
const next = prev && typeof prev === "object" && !Array.isArray(prev) ? { ...prev } : {};
|
|
302
|
+
cur[seg] = next;
|
|
303
|
+
cur = next;
|
|
304
|
+
}
|
|
305
|
+
cur[segs[segs.length - 1]] = value;
|
|
306
|
+
};
|
|
307
|
+
const buildNestedPromise = (recordParams, relative) => {
|
|
308
|
+
const subPaths = (usedPaths || []).map((p) => p === relative ? "" : p.startsWith(relative + ".") ? p.slice(relative.length + 1) : "").filter((x) => x !== "");
|
|
309
|
+
const hasDirectRef = (usedPaths || []).some((p) => p === relative);
|
|
310
|
+
const dataSourceKey2 = (recordParams == null ? void 0 : recordParams.dataSourceKey) || "main";
|
|
311
|
+
const strictSelects2 = Array.isArray(recordParams == null ? void 0 : recordParams.fields) || Array.isArray(recordParams == null ? void 0 : recordParams.appends);
|
|
312
|
+
let { generatedAppends: generatedAppends2, generatedFields: generatedFields2 } = inferSelectsFromUsage(subPaths, recordParams);
|
|
313
|
+
if (Array.isArray(recordParams == null ? void 0 : recordParams.fields)) generatedFields2 = recordParams.fields;
|
|
314
|
+
if (Array.isArray(recordParams == null ? void 0 : recordParams.appends)) generatedAppends2 = recordParams.appends;
|
|
315
|
+
const fixed2 = (0, import_selects.adjustSelectsForCollection)(
|
|
316
|
+
koaCtx,
|
|
317
|
+
dataSourceKey2,
|
|
318
|
+
recordParams.collection,
|
|
319
|
+
generatedFields2,
|
|
320
|
+
generatedAppends2
|
|
321
|
+
);
|
|
322
|
+
return fetchRecordWithRequestCache(
|
|
323
|
+
koaCtx,
|
|
324
|
+
dataSourceKey2,
|
|
325
|
+
recordParams.collection,
|
|
326
|
+
recordParams.filterByTk,
|
|
327
|
+
fixed2.fields,
|
|
328
|
+
fixed2.appends,
|
|
329
|
+
strictSelects2,
|
|
330
|
+
hasDirectRef,
|
|
331
|
+
recordParams.associationName,
|
|
332
|
+
recordParams.sourceId
|
|
333
|
+
);
|
|
334
|
+
};
|
|
335
|
+
for (const [relative, recordParams] of deepRecordMap.entries()) {
|
|
336
|
+
setClonedPath(merged, relative, buildNestedPromise(recordParams, relative));
|
|
337
|
+
}
|
|
338
|
+
return merged;
|
|
267
339
|
},
|
|
268
340
|
cache: true
|
|
269
341
|
});
|
|
@@ -302,27 +374,16 @@ function attachGenericRecordVariables(flowCtx, koaCtx, usage, contextParams) {
|
|
|
302
374
|
const dotted = (contextParams || {})[`${varName}.${seg}`] ?? (idx ? (contextParams || {})[`${varName}.${idx}`] : void 0);
|
|
303
375
|
return isRecordParams(nestedObj) || isRecordParams(dotted);
|
|
304
376
|
});
|
|
305
|
-
const deepRecordMap = /* @__PURE__ */ new Map();
|
|
306
|
-
const cp = contextParams;
|
|
307
|
-
if (cp && typeof cp === "object") {
|
|
308
|
-
const cpRec = cp;
|
|
309
|
-
for (const key of Object.keys(cpRec)) {
|
|
310
|
-
if (!key || key !== varName && !key.startsWith(`${varName}.`)) continue;
|
|
311
|
-
if (key === varName) continue;
|
|
312
|
-
const val = cpRec[key];
|
|
313
|
-
if (!isRecordParams(val)) continue;
|
|
314
|
-
const relative = key.slice(varName.length + 1);
|
|
315
|
-
if (!relative) continue;
|
|
316
|
-
deepRecordMap.set(relative, val);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
377
|
if (!oneLevelRecordChildren.length && deepRecordMap.size === 0) continue;
|
|
320
378
|
flowCtx.defineProperty(varName, {
|
|
321
379
|
get: () => {
|
|
322
380
|
const root = new import_contexts.ServerBaseContext();
|
|
323
381
|
const definedFirstLevel = /* @__PURE__ */ new Set();
|
|
324
382
|
const defineRecordGetter = (container, key, recordParams, subPaths = [], preferFull) => {
|
|
325
|
-
const
|
|
383
|
+
const strictSelects = Array.isArray(recordParams == null ? void 0 : recordParams.fields) || Array.isArray(recordParams == null ? void 0 : recordParams.appends);
|
|
384
|
+
let { generatedAppends, generatedFields } = inferSelectsFromUsage(subPaths, recordParams);
|
|
385
|
+
if (Array.isArray(recordParams == null ? void 0 : recordParams.fields)) generatedFields = recordParams.fields;
|
|
386
|
+
if (Array.isArray(recordParams == null ? void 0 : recordParams.appends)) generatedAppends = recordParams.appends;
|
|
326
387
|
container.defineProperty(key, {
|
|
327
388
|
get: async () => {
|
|
328
389
|
const dataSourceKey = (recordParams == null ? void 0 : recordParams.dataSourceKey) || "main";
|
|
@@ -340,6 +401,7 @@ function attachGenericRecordVariables(flowCtx, koaCtx, usage, contextParams) {
|
|
|
340
401
|
recordParams.filterByTk,
|
|
341
402
|
fixed.fields,
|
|
342
403
|
fixed.appends,
|
|
404
|
+
strictSelects,
|
|
343
405
|
preferFull || ((subPaths == null ? void 0 : subPaths.length) ?? 0) === 0,
|
|
344
406
|
recordParams.associationName,
|
|
345
407
|
recordParams.sourceId
|
|
@@ -423,6 +485,7 @@ function registerBuiltInVariables(reg) {
|
|
|
423
485
|
uid,
|
|
424
486
|
generatedFields,
|
|
425
487
|
generatedAppends,
|
|
488
|
+
false,
|
|
426
489
|
void 0,
|
|
427
490
|
void 0,
|
|
428
491
|
void 0
|
|
@@ -31,14 +31,19 @@ __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");
|
|
35
34
|
async function prefetchRecordsForResolve(koaCtx, items) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
37
36
|
try {
|
|
38
37
|
const log = (_b = (_a = koaCtx.app) == null ? void 0 : _a.logger) == null ? void 0 : _b.child({ module: "plugin-flow-engine", submodule: "variables.prefetch" });
|
|
39
38
|
const groupMap = /* @__PURE__ */ new Map();
|
|
40
|
-
const ensureGroup = (dataSourceKey, collection, filterByTk) => {
|
|
41
|
-
const groupKey = JSON.stringify({
|
|
39
|
+
const ensureGroup = (dataSourceKey, collection, filterByTk, opts) => {
|
|
40
|
+
const groupKey = JSON.stringify({
|
|
41
|
+
ds: dataSourceKey,
|
|
42
|
+
collection,
|
|
43
|
+
tk: filterByTk,
|
|
44
|
+
f: Array.isArray(opts == null ? void 0 : opts.fields) ? [...opts.fields].sort() : void 0,
|
|
45
|
+
a: Array.isArray(opts == null ? void 0 : opts.appends) ? [...opts.appends].sort() : void 0
|
|
46
|
+
});
|
|
42
47
|
let group = groupMap.get(groupKey);
|
|
43
48
|
if (!group) {
|
|
44
49
|
group = { dataSourceKey, collection, filterByTk, fields: /* @__PURE__ */ new Set(), appends: /* @__PURE__ */ new Set() };
|
|
@@ -70,8 +75,19 @@ async function prefetchRecordsForResolve(koaCtx, items) {
|
|
|
70
75
|
const collection = recordParams == null ? void 0 : recordParams.collection;
|
|
71
76
|
const filterByTk = recordParams == null ? void 0 : recordParams.filterByTk;
|
|
72
77
|
if (!collection || typeof filterByTk === "undefined") continue;
|
|
73
|
-
|
|
74
|
-
const
|
|
78
|
+
const explicitFields = recordParams == null ? void 0 : recordParams.fields;
|
|
79
|
+
const explicitAppends = recordParams == null ? void 0 : recordParams.appends;
|
|
80
|
+
const hasExplicit = Array.isArray(explicitFields) || Array.isArray(explicitAppends);
|
|
81
|
+
const group = ensureGroup(dataSourceKey, collection, filterByTk, {
|
|
82
|
+
fields: hasExplicit ? explicitFields : void 0,
|
|
83
|
+
appends: hasExplicit ? explicitAppends : void 0
|
|
84
|
+
});
|
|
85
|
+
if (hasExplicit) {
|
|
86
|
+
const fixed2 = (0, import_selects.adjustSelectsForCollection)(koaCtx, dataSourceKey, collection, explicitFields, explicitAppends);
|
|
87
|
+
(_c = fixed2.fields) == null ? void 0 : _c.forEach((f) => group.fields.add(f));
|
|
88
|
+
(_d = fixed2.appends) == null ? void 0 : _d.forEach((a) => group.appends.add(a));
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
75
91
|
let { generatedAppends, generatedFields } = (0, import_registry.inferSelectsFromUsage)(remainders);
|
|
76
92
|
const fixed = (0, import_selects.adjustSelectsForCollection)(koaCtx, dataSourceKey, collection, generatedFields, generatedAppends);
|
|
77
93
|
generatedFields = fixed.fields;
|
|
@@ -85,37 +101,23 @@ async function prefetchRecordsForResolve(koaCtx, items) {
|
|
|
85
101
|
if (stateObj && !stateObj["__varResolveBatchCache"]) {
|
|
86
102
|
stateObj["__varResolveBatchCache"] = /* @__PURE__ */ new Map();
|
|
87
103
|
}
|
|
88
|
-
const cache = (
|
|
104
|
+
const cache = (_e = koaCtx.state) == null ? void 0 : _e["__varResolveBatchCache"];
|
|
89
105
|
for (const { dataSourceKey, collection, filterByTk, fields, appends } of groupMap.values()) {
|
|
90
106
|
try {
|
|
91
107
|
const ds = koaCtx.app.dataSourceManager.get(dataSourceKey);
|
|
92
108
|
const cm = ds.collectionManager;
|
|
93
109
|
if (!(cm == null ? void 0 : cm.db)) continue;
|
|
94
110
|
const repo = cm.db.getRepository(collection);
|
|
95
|
-
const modelInfo = (
|
|
111
|
+
const modelInfo = (_f = repo.collection) == null ? void 0 : _f.model;
|
|
96
112
|
const pkAttr = modelInfo == null ? void 0 : modelInfo.primaryKeyAttribute;
|
|
97
113
|
const pkIsValid = pkAttr && (modelInfo == null ? void 0 : modelInfo.rawAttributes) && Object.prototype.hasOwnProperty.call(modelInfo.rawAttributes, pkAttr);
|
|
98
|
-
|
|
99
|
-
|
|
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));
|
|
114
|
+
if (fields.size && pkIsValid) {
|
|
115
|
+
fields.add(pkAttr);
|
|
107
116
|
}
|
|
108
117
|
const fld = fields.size ? Array.from(fields).sort() : void 0;
|
|
109
118
|
const app = appends.size ? Array.from(appends).sort() : void 0;
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
preferFullRecord: false,
|
|
113
|
-
fields: fld,
|
|
114
|
-
appends: app,
|
|
115
|
-
filterTargetKey,
|
|
116
|
-
pkAttr,
|
|
117
|
-
pkIsValid
|
|
118
|
-
});
|
|
119
|
+
const rec = await repo.findOne({ filterByTk, fields: fld, appends: app });
|
|
120
|
+
const json = rec ? rec.toJSON() : void 0;
|
|
119
121
|
if (cache) {
|
|
120
122
|
const key = JSON.stringify({ ds: dataSourceKey, c: collection, tk: filterByTk, f: fld, a: app });
|
|
121
123
|
cache.set(key, json);
|
|
@@ -130,7 +132,7 @@ async function prefetchRecordsForResolve(koaCtx, items) {
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
} catch (e) {
|
|
133
|
-
(
|
|
135
|
+
(_i = (_h = (_g = koaCtx.app) == null ? void 0 : _g.logger) == null ? void 0 : _h.child({ module: "plugin-flow-engine", submodule: "variables.prefetch" })) == null ? void 0 : _i.debug("[variables.resolve] prefetch fatal error", { error: (e == null ? void 0 : e.message) || String(e) });
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
// 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.12",
|
|
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": "184ac65ad8ca60618075936c990dc52addda79b7"
|
|
28
28
|
}
|