@nocobase/plugin-flow-engine 2.0.0-beta.20 → 2.0.0-beta.21

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.20",
11
+ "@nocobase/client": "2.0.0-beta.21",
12
12
  "lodash": "4.17.21",
13
- "@nocobase/database": "2.0.0-beta.20",
14
- "@nocobase/data-source-manager": "2.0.0-beta.20",
15
- "@nocobase/resourcer": "2.0.0-beta.20",
16
- "@nocobase/server": "2.0.0-beta.20",
17
- "@nocobase/utils": "2.0.0-beta.20",
18
- "@nocobase/cache": "2.0.0-beta.20",
19
- "@nocobase/plugin-localization": "2.0.0-beta.20",
20
- "@nocobase/actions": "2.0.0-beta.20"
13
+ "@nocobase/database": "2.0.0-beta.21",
14
+ "@nocobase/data-source-manager": "2.0.0-beta.21",
15
+ "@nocobase/resourcer": "2.0.0-beta.21",
16
+ "@nocobase/server": "2.0.0-beta.21",
17
+ "@nocobase/utils": "2.0.0-beta.21",
18
+ "@nocobase/cache": "2.0.0-beta.21",
19
+ "@nocobase/plugin-localization": "2.0.0-beta.21",
20
+ "@nocobase/actions": "2.0.0-beta.21"
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-02-05T04:38:23.535Z"}
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-02-07T03:52:51.226Z"}
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import { Cache } from '@nocobase/cache';
10
10
  import { Repository, Transaction, Transactionable } from '@nocobase/database';
11
- import { ChildOptions, SchemaNode } from './dao/ui_schema_node_dao';
11
+ import { ChildOptions, SchemaNode, TargetPosition } from './dao/ui_schema_node_dao';
12
12
  export interface GetJsonSchemaOptions {
13
13
  includeAsyncNode?: boolean;
14
14
  readFromCache?: boolean;
@@ -18,6 +18,13 @@ export interface GetPropertiesOptions {
18
18
  readFromCache?: boolean;
19
19
  transaction?: Transaction;
20
20
  }
21
+ export type FlowModelAttachPosition = 'first' | 'last' | TargetPosition;
22
+ export interface FlowModelAttachOptions {
23
+ parentId: string;
24
+ subKey: string;
25
+ subType: 'array' | 'object';
26
+ position?: FlowModelAttachPosition;
27
+ }
21
28
  type BreakRemoveOnType = {
22
29
  [key: string]: any;
23
30
  };
@@ -114,6 +121,7 @@ export declare class FlowModelRepository extends Repository {
114
121
  findModelByParentId(parentUid: string, options?: GetJsonSchemaOptions & {
115
122
  subKey?: string;
116
123
  }): Promise<any>;
124
+ attach(uid: string, attachOptions: FlowModelAttachOptions, options?: Transactionable): Promise<any>;
117
125
  move(options: any): Promise<any>;
118
126
  }
119
127
  export default FlowModelRepository;
@@ -1248,6 +1248,141 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
1248
1248
  }
1249
1249
  return null;
1250
1250
  }
1251
+ async attach(uid2, attachOptions, options) {
1252
+ const { transaction: transaction2 } = options || {};
1253
+ const modelUid = String(uid2 || "").trim();
1254
+ const parentId = String((attachOptions == null ? void 0 : attachOptions.parentId) || "").trim();
1255
+ const subKey = String((attachOptions == null ? void 0 : attachOptions.subKey) || "").trim();
1256
+ const subType = attachOptions == null ? void 0 : attachOptions.subType;
1257
+ if (!modelUid || !parentId || !subKey || subType !== "array" && subType !== "object") {
1258
+ throw new Error("flowModels:attach missing required params");
1259
+ }
1260
+ if (modelUid === parentId) {
1261
+ throw new Error("flowModels:attach cannot attach model to itself");
1262
+ }
1263
+ const treeTable = this.flowModelTreePathTableName;
1264
+ const modelInstance = await this.model.findByPk(modelUid, { transaction: transaction2 });
1265
+ if (!modelInstance) {
1266
+ throw new Error(`flowModels:attach uid '${modelUid}' not found`);
1267
+ }
1268
+ const parentInstance = await this.model.findByPk(parentId, { transaction: transaction2 });
1269
+ if (!parentInstance) {
1270
+ throw new Error(`flowModels:attach parentId '${parentId}' not found`);
1271
+ }
1272
+ const cycle = await this.database.sequelize.query(
1273
+ `SELECT 1 as v
1274
+ FROM ${treeTable}
1275
+ WHERE ancestor = :ancestor AND descendant = :descendant AND depth > 0
1276
+ LIMIT 1`,
1277
+ {
1278
+ type: "SELECT",
1279
+ replacements: {
1280
+ ancestor: modelUid,
1281
+ descendant: parentId
1282
+ },
1283
+ transaction: transaction2
1284
+ }
1285
+ );
1286
+ if (cycle == null ? void 0 : cycle.length) {
1287
+ throw new Error("flowModels:attach cycle detected");
1288
+ }
1289
+ if (subType === "object") {
1290
+ const conflict = await this.database.sequelize.query(
1291
+ `SELECT TreeTable.descendant as uid
1292
+ FROM ${treeTable} as TreeTable
1293
+ LEFT JOIN ${treeTable} as NodeInfo
1294
+ ON NodeInfo.descendant = TreeTable.descendant
1295
+ AND NodeInfo.depth = 0
1296
+ WHERE TreeTable.depth = 1
1297
+ AND TreeTable.ancestor = :ancestor
1298
+ AND NodeInfo.type = :type
1299
+ AND TreeTable.descendant != :uid
1300
+ LIMIT 1`,
1301
+ {
1302
+ type: "SELECT",
1303
+ replacements: {
1304
+ ancestor: parentId,
1305
+ type: subKey,
1306
+ uid: modelUid
1307
+ },
1308
+ transaction: transaction2
1309
+ }
1310
+ );
1311
+ if (conflict == null ? void 0 : conflict.length) {
1312
+ throw new Error(`flowModels:attach subKey '${subKey}' already exists on parent '${parentId}'`);
1313
+ }
1314
+ }
1315
+ const normalizePosition = (input) => {
1316
+ if (!input) return "last";
1317
+ if (input === "first" || input === "last") return input;
1318
+ if (typeof input === "object") {
1319
+ const p = input;
1320
+ const type = p == null ? void 0 : p.type;
1321
+ const target = String((p == null ? void 0 : p.target) || "").trim();
1322
+ if ((type === "before" || type === "after") && target) {
1323
+ return { type, target };
1324
+ }
1325
+ }
1326
+ throw new Error("flowModels:attach invalid position");
1327
+ };
1328
+ const position = subType === "object" ? "last" : normalizePosition(attachOptions == null ? void 0 : attachOptions.position);
1329
+ if (typeof position === "object") {
1330
+ const target = String(position.target || "").trim();
1331
+ if (target === modelUid) {
1332
+ throw new Error("flowModels:attach position target cannot be itself");
1333
+ }
1334
+ const ok = await this.database.sequelize.query(
1335
+ `SELECT 1 as v
1336
+ FROM ${treeTable} as TreeTable
1337
+ LEFT JOIN ${treeTable} as NodeInfo
1338
+ ON NodeInfo.descendant = TreeTable.descendant
1339
+ AND NodeInfo.depth = 0
1340
+ WHERE TreeTable.depth = 1
1341
+ AND TreeTable.ancestor = :ancestor
1342
+ AND TreeTable.descendant = :descendant
1343
+ AND NodeInfo.type = :type
1344
+ LIMIT 1`,
1345
+ {
1346
+ type: "SELECT",
1347
+ replacements: {
1348
+ ancestor: parentId,
1349
+ descendant: target,
1350
+ type: subKey
1351
+ },
1352
+ transaction: transaction2
1353
+ }
1354
+ );
1355
+ if (!(ok == null ? void 0 : ok.length)) {
1356
+ throw new Error("flowModels:attach position target is not a sibling under the same parent/subKey");
1357
+ }
1358
+ }
1359
+ await this.clearXUidPathCache(modelUid, transaction2);
1360
+ await modelInstance.update(
1361
+ {
1362
+ options: {
1363
+ ...modelInstance.get("options"),
1364
+ parentId,
1365
+ parent: parentId,
1366
+ subKey,
1367
+ subType
1368
+ }
1369
+ },
1370
+ { transaction: transaction2, hooks: false }
1371
+ );
1372
+ await this.insertSingleNode(
1373
+ {
1374
+ uid: modelUid,
1375
+ name: modelUid,
1376
+ childOptions: {
1377
+ parentUid: parentId,
1378
+ type: subKey,
1379
+ position
1380
+ }
1381
+ },
1382
+ { transaction: transaction2, removeParentsIfNoChildren: false }
1383
+ );
1384
+ return await this.findModelById(modelUid, { transaction: transaction2, includeAsyncNode: true });
1385
+ }
1251
1386
  async move(options) {
1252
1387
  const { sourceId, targetId, position } = options;
1253
1388
  return await this.insertAdjacent(position === "after" ? "afterEnd" : "beforeBegin", targetId, {
@@ -1312,6 +1447,9 @@ __decorateClass([
1312
1447
  __decorateClass([
1313
1448
  transaction()
1314
1449
  ], _FlowModelRepository.prototype, "upsertModel", 1);
1450
+ __decorateClass([
1451
+ transaction()
1452
+ ], _FlowModelRepository.prototype, "attach", 1);
1315
1453
  let FlowModelRepository = _FlowModelRepository;
1316
1454
  var repository_default = FlowModelRepository;
1317
1455
  // Annotate the CommonJS export names for ESM import in node:
@@ -143,6 +143,18 @@ class PluginUISchemaStorageServer extends import_server.Plugin {
143
143
  ctx.body = duplicated;
144
144
  await next();
145
145
  },
146
+ attach: async (ctx, next) => {
147
+ const { uid: uid2, parentId, subKey, subType, position } = ctx.action.params;
148
+ const repository = ctx.db.getRepository("flowModels");
149
+ const attached = await repository.attach(String(uid2 || "").trim(), {
150
+ parentId: String(parentId || "").trim(),
151
+ subKey: String(subKey || "").trim(),
152
+ subType,
153
+ position
154
+ });
155
+ ctx.body = attached;
156
+ await next();
157
+ },
146
158
  move: async (ctx, next) => {
147
159
  const { sourceId, targetId, position } = ctx.action.params;
148
160
  const repository = ctx.db.getRepository("flowModels");
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.20",
7
+ "version": "2.0.0-beta.21",
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": "f4ab788fc6c17915157617026dfbba6f0d78eaac"
27
+ "gitHead": "3ea30685d9592934ec578c0b5e8def60a7fcc3c2"
28
28
  }