@nocobase/plugin-flow-engine 2.1.0-alpha.45 → 2.1.0-alpha.46

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.
Files changed (93) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +9 -9
  3. package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
  4. package/dist/node_modules/acorn/package.json +1 -1
  5. package/dist/node_modules/acorn-jsx/package.json +1 -1
  6. package/dist/node_modules/acorn-walk/package.json +1 -1
  7. package/dist/node_modules/ses/package.json +1 -1
  8. package/dist/node_modules/zod/package.json +1 -1
  9. package/dist/server/flow-surfaces/apply/compiler.js +10 -11
  10. package/dist/server/flow-surfaces/authoring-validation.d.ts +1 -0
  11. package/dist/server/flow-surfaces/authoring-validation.js +773 -26
  12. package/dist/server/flow-surfaces/blueprint/normalize-document.js +5 -1
  13. package/dist/server/flow-surfaces/catalog.js +9 -5
  14. package/dist/server/flow-surfaces/chart-config.js +220 -16
  15. package/dist/server/flow-surfaces/contract-guard.js +40 -6
  16. package/dist/server/flow-surfaces/default-block-actions.js +2 -0
  17. package/dist/server/flow-surfaces/errors.d.ts +15 -0
  18. package/dist/server/flow-surfaces/errors.js +49 -3
  19. package/dist/server/flow-surfaces/event-flow-normalizer.d.ts +19 -0
  20. package/dist/server/flow-surfaces/event-flow-normalizer.js +128 -0
  21. package/dist/server/flow-surfaces/filter-group.d.ts +9 -1
  22. package/dist/server/flow-surfaces/filter-group.js +402 -3
  23. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +2 -1
  24. package/dist/server/flow-surfaces/route-sync.js +19 -2
  25. package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.d.ts +66 -0
  26. package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.js +661 -0
  27. package/dist/server/flow-surfaces/runjs-authoring/ast/execution.d.ts +20 -0
  28. package/dist/server/flow-surfaces/runjs-authoring/ast/execution.js +275 -0
  29. package/dist/server/flow-surfaces/runjs-authoring/ast/parser.d.ts +16 -0
  30. package/dist/server/flow-surfaces/runjs-authoring/ast/parser.js +130 -0
  31. package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.d.ts +20 -0
  32. package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.js +401 -0
  33. package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.d.ts +21 -0
  34. package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.js +199 -0
  35. package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +70 -0
  36. package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +895 -0
  37. package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.d.ts +23 -0
  38. package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.js +618 -0
  39. package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.d.ts +196 -0
  40. package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.js +1777 -0
  41. package/dist/server/flow-surfaces/runjs-authoring/ast/walk.d.ts +10 -0
  42. package/dist/server/flow-surfaces/runjs-authoring/ast/walk.js +55 -0
  43. package/dist/server/flow-surfaces/runjs-authoring/collectors.d.ts +12 -0
  44. package/dist/server/flow-surfaces/runjs-authoring/collectors.js +589 -0
  45. package/dist/server/flow-surfaces/runjs-authoring/index.d.ts +2 -25
  46. package/dist/server/flow-surfaces/runjs-authoring/index.js +5 -11138
  47. package/dist/server/flow-surfaces/runjs-authoring/inspect.d.ts +13 -0
  48. package/dist/server/flow-surfaces/runjs-authoring/inspect.js +149 -0
  49. package/dist/server/flow-surfaces/runjs-authoring/internal-types.d.ts +333 -0
  50. package/dist/server/flow-surfaces/runjs-authoring/internal-types.js +36 -0
  51. package/dist/server/flow-surfaces/runjs-authoring/rules.js +2 -0
  52. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +67 -0
  53. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +757 -0
  54. package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.d.ts +22 -0
  55. package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.js +91 -0
  56. package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.d.ts +16 -0
  57. package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.js +115 -0
  58. package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.d.ts +19 -0
  59. package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.js +140 -0
  60. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +91 -0
  61. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.js +24 -0
  62. package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.d.ts +138 -0
  63. package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.js +1779 -0
  64. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.d.ts +10 -0
  65. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +1583 -0
  66. package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +195 -0
  67. package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +463 -0
  68. package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.d.ts +48 -0
  69. package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.js +379 -0
  70. package/dist/server/flow-surfaces/runjs-authoring/scan/react.d.ts +26 -0
  71. package/dist/server/flow-surfaces/runjs-authoring/scan/react.js +1441 -0
  72. package/dist/server/flow-surfaces/runjs-authoring/scan/resource.d.ts +23 -0
  73. package/dist/server/flow-surfaces/runjs-authoring/scan/resource.js +1427 -0
  74. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +91 -0
  75. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +889 -0
  76. package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
  77. package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.d.ts +10 -0
  78. package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.js +40 -0
  79. package/dist/server/flow-surfaces/runjs-authoring/validators/index.d.ts +12 -0
  80. package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +887 -0
  81. package/dist/server/flow-surfaces/service-helpers.d.ts +29 -0
  82. package/dist/server/flow-surfaces/service-helpers.js +105 -0
  83. package/dist/server/flow-surfaces/service-utils.d.ts +15 -3
  84. package/dist/server/flow-surfaces/service-utils.js +6 -5
  85. package/dist/server/flow-surfaces/service.d.ts +7 -1
  86. package/dist/server/flow-surfaces/service.js +488 -94
  87. package/dist/server/flow-surfaces/types.d.ts +3 -0
  88. package/dist/server/repository.d.ts +12 -1
  89. package/dist/server/repository.js +195 -23
  90. package/dist/swagger/flow-surfaces.d.ts +175 -0
  91. package/dist/swagger/flow-surfaces.js +130 -51
  92. package/dist/swagger/index.d.ts +175 -0
  93. package/package.json +2 -2
@@ -229,6 +229,9 @@ export type FlowSurfaceComposeValues = {
229
229
  target: FlowSurfaceWriteTarget;
230
230
  mode?: FlowSurfaceComposeMode;
231
231
  blocks?: Array<Record<string, any>>;
232
+ assets?: {
233
+ charts?: Record<string, any>;
234
+ };
232
235
  layout?: Record<string, any>;
233
236
  defaults?: FlowSurfaceApplyBlueprintDefaults;
234
237
  };
@@ -25,6 +25,12 @@ export interface FlowModelAttachOptions {
25
25
  subType: 'array' | 'object';
26
26
  position?: FlowModelAttachPosition;
27
27
  }
28
+ type FlowModelMovePosition = 'before' | 'after';
29
+ interface FlowModelMoveOptions {
30
+ sourceId: string;
31
+ targetId: string;
32
+ position?: FlowModelMovePosition;
33
+ }
28
34
  type BreakRemoveOnType = {
29
35
  [key: string]: any;
30
36
  };
@@ -59,6 +65,8 @@ export declare class FlowModelRepository extends Repository {
59
65
  getParentProperty(uid: string, options?: GetPropertiesOptions): Promise<any>;
60
66
  getJsonSchema(uid: string, options?: GetJsonSchemaOptions): Promise<any>;
61
67
  static optionsToJson(options: any): any;
68
+ private static getSortNumber;
69
+ private static compareBySortAndUid;
62
70
  nodesToSchema(nodes: any, rootUid: any): {
63
71
  uid: any;
64
72
  "x-async": boolean;
@@ -90,6 +98,9 @@ export declare class FlowModelRepository extends Repository {
90
98
  protected childrenCount(uid: any, transaction: any): Promise<number>;
91
99
  protected isLeafNode(uid: any, transaction: any): Promise<boolean>;
92
100
  protected findParentUid(uid: any, transaction?: any): Promise<string>;
101
+ private findSiblingInfo;
102
+ private findSiblingSortRows;
103
+ private writeSiblingSorts;
93
104
  protected findNodeSchemaWithParent(uid: any, transaction: any): Promise<{
94
105
  parentUid: string;
95
106
  schema: any;
@@ -122,6 +133,6 @@ export declare class FlowModelRepository extends Repository {
122
133
  subKey?: string;
123
134
  }): Promise<any>;
124
135
  attach(uid: string, attachOptions: FlowModelAttachOptions, options?: Transactionable): Promise<any>;
125
- move(options: any): Promise<any>;
136
+ move(options: FlowModelMoveOptions, transactionOptions?: Transactionable): Promise<any>;
126
137
  }
127
138
  export default FlowModelRepository;
@@ -207,6 +207,32 @@ const _FlowModelRepository = class _FlowModelRepository extends import_database.
207
207
  static optionsToJson(options) {
208
208
  return import_lodash.default.isPlainObject(options) ? options : JSON.parse(options);
209
209
  }
210
+ static getSortNumber(value) {
211
+ if (typeof value === "number" && Number.isFinite(value)) {
212
+ return value;
213
+ }
214
+ if (typeof value === "string" && value.trim()) {
215
+ const parsed = Number(value);
216
+ if (Number.isFinite(parsed)) {
217
+ return parsed;
218
+ }
219
+ }
220
+ return null;
221
+ }
222
+ static compareBySortAndUid(a, b) {
223
+ const aSort = _FlowModelRepository.getSortNumber(a.sort);
224
+ const bSort = _FlowModelRepository.getSortNumber(b.sort);
225
+ if (aSort !== null && bSort !== null && aSort !== bSort) {
226
+ return aSort - bSort;
227
+ }
228
+ if (aSort !== null && bSort === null) {
229
+ return -1;
230
+ }
231
+ if (aSort === null && bSort !== null) {
232
+ return 1;
233
+ }
234
+ return String(a.uid || "").localeCompare(String(b.uid || ""));
235
+ }
210
236
  nodesToSchema(nodes, rootUid) {
211
237
  const nodeAttributeSanitize = (node) => {
212
238
  const schema = {
@@ -215,8 +241,9 @@ const _FlowModelRepository = class _FlowModelRepository extends import_database.
215
241
  ["uid"]: node["uid"],
216
242
  ["x-async"]: !!node.async
217
243
  };
218
- if (import_lodash.default.isNumber(node.sort)) {
219
- schema["x-index"] = node.sort;
244
+ const sort = _FlowModelRepository.getSortNumber(node.sort);
245
+ if (sort !== null) {
246
+ schema["x-index"] = sort;
220
247
  }
221
248
  return schema;
222
249
  };
@@ -228,7 +255,12 @@ const _FlowModelRepository = class _FlowModelRepository extends import_database.
228
255
  if (children.length > 0) {
229
256
  const childrenGroupByType = import_lodash.default.groupBy(children, "type");
230
257
  for (const childType of Object.keys(childrenGroupByType)) {
231
- const properties = childrenGroupByType[childType].map((child) => buildTree(child)).sort((a, b) => a["x-index"] - b["x-index"]);
258
+ const properties = childrenGroupByType[childType].map((child) => buildTree(child)).sort(
259
+ (a, b) => _FlowModelRepository.compareBySortAndUid(
260
+ { sort: a["x-index"], uid: a.uid },
261
+ { sort: b["x-index"], uid: b.uid }
262
+ )
263
+ );
232
264
  rootNode[childType] = childType == "items" ? properties.length == 1 ? properties[0] : properties : properties.reduce((carry, item) => {
233
265
  carry[item.name] = item;
234
266
  delete item["name"];
@@ -289,7 +321,10 @@ const _FlowModelRepository = class _FlowModelRepository extends import_database.
289
321
  await this.clearXUidPathCache(rootUid, transaction2);
290
322
  if (!newSchema["properties"]) {
291
323
  const s = await this.model.findByPk(rootUid, { transaction: transaction2 });
292
- s.set("options", { ...s.toJSON(), ...newSchema });
324
+ s.set("options", {
325
+ ...import_lodash.default.omit(_FlowModelRepository.optionsToJson(s.get("options") || {}), ["uid"]),
326
+ ...import_lodash.default.omit(newSchema, ["uid", "name", "options"])
327
+ });
293
328
  await s.save({ transaction: transaction2, hooks: false });
294
329
  await this.emitAfterSaveEvent(s, options);
295
330
  if (newSchema["x-server-hooks"]) {
@@ -478,17 +513,25 @@ const _FlowModelRepository = class _FlowModelRepository extends import_database.
478
513
  const oldParentUid = n["parent"];
479
514
  const newParentUid = uidMap[oldParentUid] ?? null;
480
515
  const optionsObj = this.replaceStepParamsModelUids(
481
- import_lodash.default.isPlainObject(n.options) ? n.options : JSON.parse(n.options),
516
+ import_lodash.default.cloneDeep(_FlowModelRepository.optionsToJson(n.options)),
482
517
  uidMap
483
518
  );
519
+ delete optionsObj.uid;
520
+ delete optionsObj.name;
521
+ delete optionsObj.childOptions;
522
+ delete optionsObj["x-async"];
484
523
  if (newParentUid) {
485
524
  optionsObj.parent = newParentUid;
486
525
  optionsObj.parentId = newParentUid;
526
+ } else {
527
+ delete optionsObj.parent;
528
+ delete optionsObj.parentId;
487
529
  }
488
530
  const schemaNode = {
531
+ ...optionsObj,
489
532
  uid: newUid,
490
- ["x-async"]: !!n.async,
491
- ...optionsObj
533
+ name: newUid,
534
+ ["x-async"]: !!n.async
492
535
  };
493
536
  if (newParentUid) {
494
537
  schemaNode.childOptions = {
@@ -847,7 +890,7 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
847
890
  await nodeModel.update(
848
891
  {
849
892
  options: {
850
- ...nodeModel.get("options"),
893
+ ...import_lodash.default.omit(_FlowModelRepository.optionsToJson(nodeModel.get("options") || {}), ["uid"]),
851
894
  ...import_lodash.default.omit(schema, ["x-async", "name", "uid", "properties"])
852
895
  }
853
896
  },
@@ -889,6 +932,70 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
889
932
  });
890
933
  return parent ? parent.get("ancestor") : null;
891
934
  }
935
+ async findSiblingInfo(uid2, transaction2) {
936
+ const rows = await this.database.sequelize.query(
937
+ this.sqlAdapter(`SELECT ParentPath.ancestor as parent, NodeInfo.type as type
938
+ FROM ${this.flowModelTreePathTableName} as ParentPath
939
+ LEFT JOIN ${this.flowModelTreePathTableName} as NodeInfo
940
+ ON NodeInfo.ancestor = ParentPath.descendant
941
+ AND NodeInfo.descendant = ParentPath.descendant
942
+ AND NodeInfo.depth = 0
943
+ WHERE ParentPath.descendant = :uid AND ParentPath.depth = 1`),
944
+ {
945
+ type: "SELECT",
946
+ replacements: { uid: uid2 },
947
+ transaction: transaction2
948
+ }
949
+ );
950
+ const row = rows[0];
951
+ if (!(row == null ? void 0 : row.parent) || !(row == null ? void 0 : row.type)) {
952
+ return null;
953
+ }
954
+ return {
955
+ parentUid: row.parent,
956
+ type: row.type
957
+ };
958
+ }
959
+ async findSiblingSortRows(parentUid, type, transaction2) {
960
+ const treeTable = this.flowModelTreePathTableName;
961
+ const rows = await this.database.sequelize.query(
962
+ this.sqlAdapter(`SELECT ChildPath.descendant as uid, ChildPath.sort as sort
963
+ FROM ${treeTable} as ChildPath
964
+ LEFT JOIN ${treeTable} as NodeInfo
965
+ ON NodeInfo.ancestor = ChildPath.descendant
966
+ AND NodeInfo.descendant = ChildPath.descendant
967
+ AND NodeInfo.depth = 0
968
+ WHERE ChildPath.ancestor = :parentUid
969
+ AND ChildPath.depth = 1
970
+ AND NodeInfo.type = :type`),
971
+ {
972
+ type: "SELECT",
973
+ replacements: { parentUid, type },
974
+ transaction: transaction2
975
+ }
976
+ );
977
+ return rows.sort((a, b) => _FlowModelRepository.compareBySortAndUid(a, b));
978
+ }
979
+ async writeSiblingSorts(parentUid, orderedUids, transaction2) {
980
+ const treeTable = this.flowModelTreePathTableName;
981
+ for (const [index, uid2] of orderedUids.entries()) {
982
+ await this.database.sequelize.query(
983
+ this.sqlAdapter(
984
+ `UPDATE ${treeTable} SET sort = :sort WHERE ancestor = :parentUid AND descendant = :uid AND depth = 1`
985
+ ),
986
+ {
987
+ type: "UPDATE",
988
+ replacements: {
989
+ parentUid,
990
+ uid: uid2,
991
+ sort: index + 1
992
+ },
993
+ transaction: transaction2
994
+ }
995
+ );
996
+ }
997
+ await this.clearXUidPathCache(parentUid, transaction2);
998
+ }
892
999
  async findNodeSchemaWithParent(uid2, transaction2) {
893
1000
  const schema = await this.database.getRepository("flowModels").findOne({
894
1001
  filter: {
@@ -1155,22 +1262,30 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
1155
1262
  for (const child of children) {
1156
1263
  const { subKey, subType } = this.optionsToJson(child.options);
1157
1264
  if (!subKey) continue;
1158
- const model = _FlowModelRepository.nodesToModel(nodes, child["uid"]) || {
1159
- uid: child["uid"],
1265
+ const model2 = _FlowModelRepository.nodesToModel(nodes, child["uid"]) || {
1160
1266
  ...this.optionsToJson(child.options),
1267
+ uid: child["uid"],
1161
1268
  sortIndex: child.sort
1162
1269
  };
1163
- model.sortIndex = child.sort;
1270
+ model2.sortIndex = child.sort;
1164
1271
  if (subType === "array") {
1165
1272
  if (!subModels[subKey]) subModels[subKey] = [];
1166
- subModels[subKey].push(model);
1273
+ subModels[subKey].push(model2);
1167
1274
  } else {
1168
- subModels[subKey] = model;
1275
+ subModels[subKey] = model2;
1169
1276
  }
1170
1277
  }
1171
1278
  for (const key in subModels) {
1172
1279
  if (Array.isArray(subModels[key])) {
1173
- subModels[key].sort((a, b) => (a.sortIndex ?? 0) - (b.sortIndex ?? 0));
1280
+ subModels[key] = subModels[key].sort(
1281
+ (a, b) => _FlowModelRepository.compareBySortAndUid(
1282
+ { sort: a.sortIndex, uid: a.uid },
1283
+ { sort: b.sortIndex, uid: b.uid }
1284
+ )
1285
+ ).map((item, index) => {
1286
+ item.sortIndex = index + 1;
1287
+ return item;
1288
+ });
1174
1289
  }
1175
1290
  }
1176
1291
  const filteredSubModels = {};
@@ -1181,11 +1296,19 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
1181
1296
  continue;
1182
1297
  filteredSubModels[key] = value;
1183
1298
  }
1184
- return {
1185
- uid: rootNode["uid"],
1299
+ const model = {
1186
1300
  ...this.optionsToJson(rootNode.options),
1301
+ uid: rootNode["uid"],
1187
1302
  ...Object.keys(filteredSubModels).length > 0 ? { subModels: filteredSubModels } : {}
1188
1303
  };
1304
+ if (rootNode.parent) {
1305
+ model.parent = rootNode.parent;
1306
+ model.parentId = rootNode.parent;
1307
+ } else {
1308
+ delete model.parent;
1309
+ delete model.parentId;
1310
+ }
1311
+ return model;
1189
1312
  }
1190
1313
  async insertModel(model, options) {
1191
1314
  const nodes = _FlowModelRepository.modelToSingleNodes(model);
@@ -1194,6 +1317,7 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
1194
1317
  return await this.findModelById(rootUid, options);
1195
1318
  }
1196
1319
  async updateSingleNode(node, options) {
1320
+ var _a;
1197
1321
  const instance = await this.model.findByPk(node["uid"], {
1198
1322
  transaction: options == null ? void 0 : options.transaction
1199
1323
  });
@@ -1201,8 +1325,12 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
1201
1325
  await instance.update(
1202
1326
  {
1203
1327
  options: {
1204
- ...instance.get("options"),
1205
- ...import_lodash.default.omit(node, ["x-async", "name", "uid", "childOptions"])
1328
+ ...import_lodash.default.omit(instance.get("options"), ["uid"]),
1329
+ ...import_lodash.default.omit(node, ["x-async", "name", "uid", "childOptions"]),
1330
+ ...((_a = node.childOptions) == null ? void 0 : _a.parentUid) ? {
1331
+ parent: node.childOptions.parentUid,
1332
+ parentId: node.childOptions.parentUid
1333
+ } : {}
1206
1334
  }
1207
1335
  },
1208
1336
  {
@@ -1376,7 +1504,7 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
1376
1504
  await modelInstance.update(
1377
1505
  {
1378
1506
  options: {
1379
- ...modelInstance.get("options"),
1507
+ ...import_lodash.default.omit(modelInstance.get("options"), ["uid"]),
1380
1508
  parentId,
1381
1509
  parent: parentId,
1382
1510
  subKey,
@@ -1399,11 +1527,52 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
1399
1527
  );
1400
1528
  return await this.findModelById(modelUid, { transaction: transaction2, includeAsyncNode: true });
1401
1529
  }
1402
- async move(options) {
1530
+ async move(options, transactionOptions) {
1403
1531
  const { sourceId, targetId, position } = options;
1404
- return await this.insertAdjacent(position === "after" ? "afterEnd" : "beforeBegin", targetId, {
1405
- ["uid"]: sourceId
1406
- });
1532
+ const sourceUid = String(sourceId || "").trim();
1533
+ const targetUid = String(targetId || "").trim();
1534
+ if (!sourceUid || !targetUid) {
1535
+ throw new Error("flowModels:move missing required params");
1536
+ }
1537
+ if (position !== "before" && position !== "after") {
1538
+ throw new Error("flowModels:move invalid position");
1539
+ }
1540
+ const transaction2 = transactionOptions == null ? void 0 : transactionOptions.transaction;
1541
+ if (sourceUid === targetUid) {
1542
+ const sourceInfo2 = await this.findSiblingInfo(sourceUid, transaction2);
1543
+ if (sourceInfo2) {
1544
+ const siblingRows2 = await this.findSiblingSortRows(sourceInfo2.parentUid, sourceInfo2.type, transaction2);
1545
+ await this.writeSiblingSorts(
1546
+ sourceInfo2.parentUid,
1547
+ siblingRows2.map((row) => row.uid),
1548
+ transaction2
1549
+ );
1550
+ }
1551
+ return null;
1552
+ }
1553
+ const sourceInfo = await this.findSiblingInfo(sourceUid, transaction2);
1554
+ const targetInfo = await this.findSiblingInfo(targetUid, transaction2);
1555
+ if (!sourceInfo || !targetInfo) {
1556
+ throw new Error("flowModels:move source or target is not attached to a parent");
1557
+ }
1558
+ if (sourceInfo.parentUid !== targetInfo.parentUid || sourceInfo.type !== targetInfo.type) {
1559
+ throw new Error("flowModels:move source and target must be sibling nodes under the same parent/subKey");
1560
+ }
1561
+ const siblingRows = await this.findSiblingSortRows(sourceInfo.parentUid, sourceInfo.type, transaction2);
1562
+ const sourceRow = siblingRows.find((row) => row.uid === sourceUid);
1563
+ const targetIndex = siblingRows.findIndex((row) => row.uid === targetUid);
1564
+ if (!sourceRow || targetIndex === -1) {
1565
+ throw new Error("flowModels:move source and target must be sibling nodes under the same parent/subKey");
1566
+ }
1567
+ const rowsWithoutSource = siblingRows.filter((row) => row.uid !== sourceUid);
1568
+ const insertIndex = rowsWithoutSource.findIndex((row) => row.uid === targetUid);
1569
+ rowsWithoutSource.splice(position === "after" ? insertIndex + 1 : insertIndex, 0, sourceRow);
1570
+ await this.writeSiblingSorts(
1571
+ sourceInfo.parentUid,
1572
+ rowsWithoutSource.map((row) => row.uid),
1573
+ transaction2
1574
+ );
1575
+ return await this.findModelById(sourceUid, { transaction: transaction2 });
1407
1576
  }
1408
1577
  };
1409
1578
  __decorateClass([
@@ -1466,6 +1635,9 @@ __decorateClass([
1466
1635
  __decorateClass([
1467
1636
  transaction()
1468
1637
  ], _FlowModelRepository.prototype, "attach", 1);
1638
+ __decorateClass([
1639
+ transaction()
1640
+ ], _FlowModelRepository.prototype, "move", 1);
1469
1641
  let FlowModelRepository = _FlowModelRepository;
1470
1642
  var repository_default = FlowModelRepository;
1471
1643
  // Annotate the CommonJS export names for ESM import in node:
@@ -4001,6 +4001,118 @@ declare const _default: {
4001
4001
  type: string;
4002
4002
  enum: string[];
4003
4003
  };
4004
+ errorCount: {
4005
+ type: string;
4006
+ description: string;
4007
+ };
4008
+ details: {
4009
+ type: string;
4010
+ description: string;
4011
+ properties: {
4012
+ errorCount: {
4013
+ type: string;
4014
+ description: string;
4015
+ example: number;
4016
+ };
4017
+ mustFixAllErrorsBeforeRetry: {
4018
+ type: string;
4019
+ example: boolean;
4020
+ };
4021
+ retryPolicy: {
4022
+ type: string;
4023
+ example: string;
4024
+ };
4025
+ sameWriteRetryRequired: {
4026
+ type: string;
4027
+ example: boolean;
4028
+ };
4029
+ agentInstruction: {
4030
+ type: string;
4031
+ description: string;
4032
+ };
4033
+ requiredBlockPolicy: {
4034
+ type: string;
4035
+ properties: {
4036
+ requiredBlockTypes: {
4037
+ type: string;
4038
+ items: {
4039
+ type: string;
4040
+ };
4041
+ };
4042
+ fixStrategy: {
4043
+ type: string;
4044
+ example: string;
4045
+ };
4046
+ doNotReplaceOrDrop: {
4047
+ type: string;
4048
+ example: boolean;
4049
+ };
4050
+ };
4051
+ additionalProperties: boolean;
4052
+ };
4053
+ };
4054
+ additionalProperties: boolean;
4055
+ };
4056
+ errors: {
4057
+ type: string;
4058
+ description: string;
4059
+ items: {
4060
+ type: string;
4061
+ properties: {
4062
+ index: {
4063
+ type: string;
4064
+ description: string;
4065
+ example: number;
4066
+ };
4067
+ code: {
4068
+ type: string;
4069
+ description: string;
4070
+ example: string;
4071
+ };
4072
+ message: {
4073
+ type: string;
4074
+ description: string;
4075
+ };
4076
+ status: {
4077
+ type: string;
4078
+ description: string;
4079
+ example: number;
4080
+ };
4081
+ type: {
4082
+ type: string;
4083
+ description: string;
4084
+ example: string;
4085
+ enum: string[];
4086
+ };
4087
+ path: {
4088
+ type: string;
4089
+ description: string;
4090
+ example: string;
4091
+ };
4092
+ ruleId: {
4093
+ type: string;
4094
+ description: string;
4095
+ example: string;
4096
+ };
4097
+ details: {
4098
+ type: string;
4099
+ description: string;
4100
+ additionalProperties: boolean;
4101
+ example: {
4102
+ action: string;
4103
+ fieldPath: string;
4104
+ titleField: string;
4105
+ targetCollection: string;
4106
+ invalidReason: string;
4107
+ availableFields: string[];
4108
+ suggestion: string;
4109
+ };
4110
+ };
4111
+ };
4112
+ required: string[];
4113
+ additionalProperties: boolean;
4114
+ };
4115
+ };
4004
4116
  };
4005
4117
  required: string[];
4006
4118
  additionalProperties: boolean;
@@ -5250,11 +5362,74 @@ declare const _default: {
5250
5362
  }[];
5251
5363
  };
5252
5364
  properties: {
5365
+ message: {
5366
+ type: string;
5367
+ description: string;
5368
+ example: string;
5369
+ };
5370
+ errorCount: {
5371
+ type: string;
5372
+ description: string;
5373
+ example: number;
5374
+ };
5375
+ details: {
5376
+ type: string;
5377
+ description: string;
5378
+ properties: {
5379
+ errorCount: {
5380
+ type: string;
5381
+ description: string;
5382
+ example: number;
5383
+ };
5384
+ mustFixAllErrorsBeforeRetry: {
5385
+ type: string;
5386
+ example: boolean;
5387
+ };
5388
+ retryPolicy: {
5389
+ type: string;
5390
+ example: string;
5391
+ };
5392
+ sameWriteRetryRequired: {
5393
+ type: string;
5394
+ example: boolean;
5395
+ };
5396
+ agentInstruction: {
5397
+ type: string;
5398
+ description: string;
5399
+ };
5400
+ requiredBlockPolicy: {
5401
+ type: string;
5402
+ properties: {
5403
+ requiredBlockTypes: {
5404
+ type: string;
5405
+ items: {
5406
+ type: string;
5407
+ };
5408
+ };
5409
+ fixStrategy: {
5410
+ type: string;
5411
+ example: string;
5412
+ };
5413
+ doNotReplaceOrDrop: {
5414
+ type: string;
5415
+ example: boolean;
5416
+ };
5417
+ };
5418
+ additionalProperties: boolean;
5419
+ };
5420
+ };
5421
+ additionalProperties: boolean;
5422
+ };
5253
5423
  errors: {
5254
5424
  type: string;
5255
5425
  items: {
5256
5426
  type: string;
5257
5427
  properties: {
5428
+ index: {
5429
+ type: string;
5430
+ description: string;
5431
+ example: number;
5432
+ };
5258
5433
  code: {
5259
5434
  type: string;
5260
5435
  description: string;