@nocobase/plugin-flow-engine 2.0.0-alpha.11 → 2.0.0-alpha.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.
@@ -8,14 +8,14 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.0.0-alpha.11",
11
+ "@nocobase/client": "2.0.0-alpha.13",
12
12
  "lodash": "4.17.21",
13
- "@nocobase/database": "2.0.0-alpha.11",
14
- "@nocobase/data-source-manager": "2.0.0-alpha.11",
15
- "@nocobase/resourcer": "2.0.0-alpha.11",
16
- "@nocobase/server": "2.0.0-alpha.11",
17
- "@nocobase/cache": "2.0.0-alpha.11",
18
- "@nocobase/utils": "2.0.0-alpha.11",
19
- "@nocobase/plugin-localization": "2.0.0-alpha.11",
20
- "@nocobase/actions": "2.0.0-alpha.11"
13
+ "@nocobase/database": "2.0.0-alpha.13",
14
+ "@nocobase/data-source-manager": "2.0.0-alpha.13",
15
+ "@nocobase/resourcer": "2.0.0-alpha.13",
16
+ "@nocobase/server": "2.0.0-alpha.13",
17
+ "@nocobase/cache": "2.0.0-alpha.13",
18
+ "@nocobase/utils": "2.0.0-alpha.13",
19
+ "@nocobase/plugin-localization": "2.0.0-alpha.13",
20
+ "@nocobase/actions": "2.0.0-alpha.13"
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":"2025-10-16T02:24:02.558Z"}
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":"2025-10-16T13:37:44.868Z"}
@@ -70,7 +70,8 @@ export declare class FlowModelRepository extends Repository {
70
70
  }): Promise<void>;
71
71
  remove(uid: string, options?: Transactionable & removeParentOptions): Promise<void>;
72
72
  insertAdjacent(position: 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd', target: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
73
- duplicate(uid: string, options?: Transactionable): Promise<any>;
73
+ duplicate(modelUid: string, options?: Transactionable): Promise<any>;
74
+ private replaceStepParamsModelUids;
74
75
  insert(schema: any, options?: Transactionable): Promise<any>;
75
76
  insertNewSchema(schema: any, options?: Transactionable & {
76
77
  returnNode?: boolean;
@@ -426,13 +426,76 @@ const _FlowModelRepository = class _FlowModelRepository extends import_database.
426
426
  await this.clearXUidPathCache(result["uid"], transaction2);
427
427
  return result;
428
428
  }
429
- async duplicate(uid2, options) {
430
- const s = await this.getJsonSchema(uid2, { ...options, includeAsyncNode: true });
431
- if (!(s == null ? void 0 : s["uid"])) {
429
+ async duplicate(modelUid, options) {
430
+ const nodes = await this.findNodesById(modelUid, { ...options, includeAsyncNode: true });
431
+ if (!(nodes == null ? void 0 : nodes.length)) {
432
432
  return null;
433
433
  }
434
- this.regenerateUid(s);
435
- return this.insert(s, options);
434
+ const uidMap = {};
435
+ for (const n of nodes) {
436
+ uidMap[n["uid"]] = (0, import_utils.uid)();
437
+ }
438
+ const sorted = [...nodes].sort((a, b) => {
439
+ if (a.depth !== b.depth) return a.depth - b.depth;
440
+ const ap = a.parent || "";
441
+ const bp = b.parent || "";
442
+ if (ap !== bp) return ap < bp ? -1 : 1;
443
+ const at = a.type || "";
444
+ const bt = b.type || "";
445
+ if (at !== bt) return at < bt ? -1 : 1;
446
+ const as = a.sort ?? 0;
447
+ const bs = b.sort ?? 0;
448
+ return as - bs;
449
+ });
450
+ for (const n of sorted) {
451
+ const oldUid = n["uid"];
452
+ const newUid = uidMap[oldUid];
453
+ const oldParentUid = n["parent"];
454
+ const newParentUid = uidMap[oldParentUid] ?? null;
455
+ const optionsObj = this.replaceStepParamsModelUids(
456
+ import_lodash.default.isPlainObject(n.options) ? n.options : JSON.parse(n.options),
457
+ uidMap
458
+ );
459
+ if (newParentUid) {
460
+ optionsObj.parent = newParentUid;
461
+ optionsObj.parentId = newParentUid;
462
+ }
463
+ const schemaNode = {
464
+ uid: newUid,
465
+ ["x-async"]: !!n.async,
466
+ ...optionsObj
467
+ };
468
+ if (newParentUid) {
469
+ schemaNode.childOptions = {
470
+ parentUid: newParentUid,
471
+ type: n.type,
472
+ position: "last"
473
+ };
474
+ }
475
+ await this.insertSingleNode(schemaNode, { transaction: options == null ? void 0 : options.transaction });
476
+ }
477
+ return this.findModelById(uidMap[modelUid], { ...options });
478
+ }
479
+ replaceStepParamsModelUids(options, uidMap) {
480
+ const opts = options && typeof options === "object" ? options : {};
481
+ const replaceUidString = (v) => typeof v === "string" && uidMap[v] ? uidMap[v] : v;
482
+ const replaceInPlace = (val) => {
483
+ if (Array.isArray(val)) {
484
+ for (let i = 0; i < val.length; i++) {
485
+ val[i] = replaceInPlace(val[i]);
486
+ }
487
+ return val;
488
+ }
489
+ if (val && typeof val === "object") {
490
+ for (const k of Object.keys(val)) {
491
+ val[k] = replaceInPlace(val[k]);
492
+ }
493
+ return val;
494
+ }
495
+ return replaceUidString(val);
496
+ };
497
+ if (opts.stepParams) opts.stepParams = replaceInPlace(opts.stepParams);
498
+ return opts;
436
499
  }
437
500
  async insert(schema, options) {
438
501
  const nodes = _FlowModelRepository.schemaToSingleNodes(schema);
@@ -136,6 +136,13 @@ class PluginUISchemaStorageServer extends import_server.Plugin {
136
136
  }
137
137
  await next();
138
138
  },
139
+ duplicate: async (ctx, next) => {
140
+ const { uid: uid2 } = ctx.action.params;
141
+ const repository = ctx.db.getRepository("flowModels");
142
+ const duplicated = await repository.duplicate(uid2);
143
+ ctx.body = duplicated;
144
+ await next();
145
+ },
139
146
  move: async (ctx, next) => {
140
147
  const { sourceId, targetId, position } = ctx.action.params;
141
148
  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-alpha.11",
7
+ "version": "2.0.0-alpha.13",
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": "172b05411f66f7024d5294caf2852533569c3796"
27
+ "gitHead": "b5b60c6ddb996b96bdc1e6d21604ef6585ae01e8"
28
28
  }