@nocobase/plugin-flow-engine 2.0.0-beta.12 → 2.0.0-beta.14

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.
@@ -8,14 +8,14 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.0.0-beta.12",
11
+ "@nocobase/client": "2.0.0-beta.14",
12
12
  "lodash": "4.17.21",
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"
13
+ "@nocobase/database": "2.0.0-beta.14",
14
+ "@nocobase/data-source-manager": "2.0.0-beta.14",
15
+ "@nocobase/resourcer": "2.0.0-beta.14",
16
+ "@nocobase/server": "2.0.0-beta.14",
17
+ "@nocobase/utils": "2.0.0-beta.14",
18
+ "@nocobase/cache": "2.0.0-beta.14",
19
+ "@nocobase/plugin-localization": "2.0.0-beta.14",
20
+ "@nocobase/actions": "2.0.0-beta.14"
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-16T01:59:26.562Z"}
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-23T00:06:36.516Z"}
@@ -78,14 +78,18 @@ async function replacePlaceholders(input, ctx) {
78
78
  async function evaluate(expr, ctx) {
79
79
  try {
80
80
  const raw = expr.trim();
81
- const dotOnly = raw.match(/^ctx\.([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)$/);
81
+ const dotOnly = raw.match(
82
+ /^ctx\.([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\.([a-zA-Z_$][a-zA-Z0-9_$-]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$-]*)*))?$/
83
+ );
82
84
  if (dotOnly) {
83
- const path = dotOnly[1];
84
- const segs = path.split(".");
85
- const first = segs.shift();
85
+ const first = dotOnly[1];
86
+ const rest = dotOnly[2];
86
87
  const base = await ctx[first];
87
- if (!segs.length) return base;
88
- return await asyncGetValuesByPath(base, segs.join("."));
88
+ if (!rest) return base;
89
+ const resolved = await asyncGetValuesByPath(base, rest);
90
+ if (typeof resolved !== "undefined" || !rest.includes("-")) {
91
+ return resolved;
92
+ }
89
93
  }
90
94
  const transformed = preprocessExpression(raw);
91
95
  const compartment = new Compartment({
@@ -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) {
@@ -150,8 +151,17 @@ 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 fieldsWithPk = Array.isArray(fields) && fields.length > 0 && pkIsValid ? Array.from(/* @__PURE__ */ new Set([...fields, pkAttr])) : fields;
154
- const cacheKeyFields = preferFullRecord && pkIsValid ? void 0 : Array.isArray(fieldsWithPk) ? [...fieldsWithPk].sort() : void 0;
154
+ const collectionInfo = repo == null ? void 0 : repo.collection;
155
+ const filterTargetKey = collectionInfo == null ? void 0 : collectionInfo.filterTargetKey;
156
+ const extraKeys = (0, import_records.getExtraKeyFieldsForSelect)(filterByTk, {
157
+ filterTargetKey,
158
+ pkAttr,
159
+ pkIsValid,
160
+ rawAttributes: (modelInfo == null ? void 0 : modelInfo.rawAttributes) || void 0
161
+ });
162
+ const effectiveExtras = strictSelects && Array.isArray(extraKeys) && extraKeys.length ? extraKeys.filter((k) => k === pkAttr) : extraKeys;
163
+ const fieldsWithExtras = (0, import_records.mergeFieldsWithExtras)(fields, effectiveExtras);
164
+ const cacheKeyFields = preferFullRecord && pkIsValid ? void 0 : Array.isArray(fieldsWithExtras) ? [...fieldsWithExtras].sort() : void 0;
155
165
  const cacheKeyAppends = preferFullRecord ? void 0 : Array.isArray(appends) ? [...appends].sort() : void 0;
156
166
  const keyObj = {
157
167
  ds: dataSourceKey || "main",
@@ -169,11 +179,11 @@ async function fetchRecordWithRequestCache(koaCtx, dataSourceKey, collection, fi
169
179
  return cache.get(key);
170
180
  }
171
181
  if (!strictSelects) {
172
- const needFields = !preferFullRecord && Array.isArray(fieldsWithPk) ? [...new Set(fieldsWithPk)] : void 0;
182
+ const needFields = !preferFullRecord && Array.isArray(fieldsWithExtras) ? [...new Set(fieldsWithExtras)] : void 0;
173
183
  const needAppends = !preferFullRecord && Array.isArray(appends) ? new Set(appends) : void 0;
174
184
  for (const [cacheKey, cacheVal] of cache.entries()) {
175
185
  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)
186
+ if (!parsed || parsed.ds !== keyObj.ds || parsed.c !== keyObj.c || !import_lodash.default.isEqual(parsed.tk, keyObj.tk) || parsed.assoc !== keyObj.assoc || !import_lodash.default.isEqual(parsed.sid, keyObj.sid))
177
187
  continue;
178
188
  const cachedFields = new Set(parsed.f || []);
179
189
  const cachedAppends = new Set(parsed.a || []);
@@ -194,16 +204,15 @@ async function fetchRecordWithRequestCache(koaCtx, dataSourceKey, collection, fi
194
204
  }
195
205
  }
196
206
  }
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;
207
+ const json = await (0, import_records.fetchRecordOrRecordsJson)(repo, {
208
+ filterByTk,
209
+ preferFullRecord,
210
+ fields: fieldsWithExtras,
211
+ appends,
212
+ filterTargetKey,
213
+ pkAttr,
214
+ pkIsValid
215
+ });
207
216
  if (cache) cache.set(key, json);
208
217
  return json;
209
218
  } catch (e) {
@@ -31,12 +31,13 @@ __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
36
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
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();
39
- const ensureGroup = (dataSourceKey, collection, filterByTk, opts) => {
40
+ const ensureGroup = (dataSourceKey, collection, filterByTk, strictSelects, opts) => {
40
41
  const groupKey = JSON.stringify({
41
42
  ds: dataSourceKey,
42
43
  collection,
@@ -46,7 +47,14 @@ async function prefetchRecordsForResolve(koaCtx, items) {
46
47
  });
47
48
  let group = groupMap.get(groupKey);
48
49
  if (!group) {
49
- group = { dataSourceKey, collection, filterByTk, fields: /* @__PURE__ */ new Set(), appends: /* @__PURE__ */ new Set() };
50
+ group = {
51
+ dataSourceKey,
52
+ collection,
53
+ filterByTk,
54
+ strictSelects,
55
+ fields: /* @__PURE__ */ new Set(),
56
+ appends: /* @__PURE__ */ new Set()
57
+ };
50
58
  groupMap.set(groupKey, group);
51
59
  }
52
60
  return group;
@@ -78,7 +86,7 @@ async function prefetchRecordsForResolve(koaCtx, items) {
78
86
  const explicitFields = recordParams == null ? void 0 : recordParams.fields;
79
87
  const explicitAppends = recordParams == null ? void 0 : recordParams.appends;
80
88
  const hasExplicit = Array.isArray(explicitFields) || Array.isArray(explicitAppends);
81
- const group = ensureGroup(dataSourceKey, collection, filterByTk, {
89
+ const group = ensureGroup(dataSourceKey, collection, filterByTk, hasExplicit, {
82
90
  fields: hasExplicit ? explicitFields : void 0,
83
91
  appends: hasExplicit ? explicitAppends : void 0
84
92
  });
@@ -102,22 +110,36 @@ async function prefetchRecordsForResolve(koaCtx, items) {
102
110
  stateObj["__varResolveBatchCache"] = /* @__PURE__ */ new Map();
103
111
  }
104
112
  const cache = (_e = koaCtx.state) == null ? void 0 : _e["__varResolveBatchCache"];
105
- for (const { dataSourceKey, collection, filterByTk, fields, appends } of groupMap.values()) {
113
+ for (const { dataSourceKey, collection, filterByTk, strictSelects, fields, appends } of groupMap.values()) {
106
114
  try {
107
115
  const ds = koaCtx.app.dataSourceManager.get(dataSourceKey);
108
116
  const cm = ds.collectionManager;
109
117
  if (!(cm == null ? void 0 : cm.db)) continue;
110
118
  const repo = cm.db.getRepository(collection);
119
+ const collectionInfo = repo == null ? void 0 : repo.collection;
120
+ const filterTargetKey = collectionInfo == null ? void 0 : collectionInfo.filterTargetKey;
111
121
  const modelInfo = (_f = repo.collection) == null ? void 0 : _f.model;
112
122
  const pkAttr = modelInfo == null ? void 0 : modelInfo.primaryKeyAttribute;
113
- const pkIsValid = pkAttr && (modelInfo == null ? void 0 : modelInfo.rawAttributes) && Object.prototype.hasOwnProperty.call(modelInfo.rawAttributes, pkAttr);
114
- if (fields.size && pkIsValid) {
115
- fields.add(pkAttr);
116
- }
117
- const fld = fields.size ? Array.from(fields).sort() : void 0;
123
+ const rawAttributes = (modelInfo == null ? void 0 : modelInfo.rawAttributes) || void 0;
124
+ const pkIsValid = !!(pkAttr && rawAttributes && Object.prototype.hasOwnProperty.call(rawAttributes, pkAttr));
125
+ const fldBase = fields.size ? Array.from(fields).sort() : void 0;
126
+ const extraKeys = (0, import_records.getExtraKeyFieldsForSelect)(filterByTk, {
127
+ filterTargetKey,
128
+ pkAttr,
129
+ pkIsValid,
130
+ rawAttributes
131
+ });
132
+ const effectiveExtras = strictSelects && Array.isArray(extraKeys) && extraKeys.length ? extraKeys.filter((k) => k === pkAttr) : extraKeys;
133
+ const fld = (0, import_records.mergeFieldsWithExtras)(fldBase, effectiveExtras);
118
134
  const app = appends.size ? Array.from(appends).sort() : void 0;
119
- const rec = await repo.findOne({ filterByTk, fields: fld, appends: app });
120
- const json = rec ? rec.toJSON() : void 0;
135
+ const json = await (0, import_records.fetchRecordOrRecordsJson)(repo, {
136
+ filterByTk,
137
+ fields: fld,
138
+ appends: app,
139
+ filterTargetKey,
140
+ pkAttr,
141
+ pkIsValid
142
+ });
121
143
  if (cache) {
122
144
  const key = JSON.stringify({ ds: dataSourceKey, c: collection, tk: filterByTk, f: fld, a: app });
123
145
  cache.set(key, json);
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.12",
7
+ "version": "2.0.0-beta.14",
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": "184ac65ad8ca60618075936c990dc52addda79b7"
27
+ "gitHead": "e51bd3f094b93bd8bbb8fa3c6ff0f07fcca2e16d"
28
28
  }