@ixo/editor 7.0.0 → 7.2.0

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.
@@ -155,6 +155,7 @@ __export(core_exports, {
155
155
  actionManifestIssues: () => actionManifestIssues,
156
156
  actionTypeToCan: () => actionTypeToCan,
157
157
  addFlowNode: () => addFlowNode,
158
+ addUnlistedSteps: () => addUnlistedSteps,
158
159
  adoptLegacyFlowDocument: () => adoptLegacyFlowDocument,
159
160
  adoptLegacyRuntime: () => adoptLegacyRuntime,
160
161
  appendAgentLedgerEvent: () => appendAgentLedgerEvent,
@@ -277,6 +278,7 @@ __export(core_exports, {
277
278
  executeQueuedAgentCommands: () => executeQueuedAgentCommands,
278
279
  executeQueuedFlowAgentCoreCommands: () => executeQueuedFlowAgentCoreCommands,
279
280
  findFailedListenersForSourceRun: () => findFailedListenersForSourceRun,
281
+ findUnlistedActionBlocks: () => findUnlistedActionBlocks,
280
282
  findXeroWorkItems: () => findXeroWorkItems,
281
283
  findXeroWorkItemsForEditor: () => findXeroWorkItemsForEditor,
282
284
  fingerprintFlowCommand: () => fingerprintFlowCommand,
@@ -28325,12 +28327,119 @@ function createYMapFromNode(node) {
28325
28327
  return yNode;
28326
28328
  }
28327
28329
 
28330
+ // src/core/lib/flowCompiler/stepListMigration.ts
28331
+ var Y7 = __toESM(require("yjs"), 1);
28332
+ function actionBlocksInOrder(yDoc) {
28333
+ const propsByBlockId = legacyPropsByBlockId(yDoc);
28334
+ const blocks = [];
28335
+ const walk = (parent) => {
28336
+ for (let index = 0; index < parent.length; index += 1) {
28337
+ const child = parent.get(index);
28338
+ if (!(child instanceof Y7.XmlElement)) continue;
28339
+ if (child.nodeName === "blockContainer") {
28340
+ const content = child.get(0);
28341
+ const attrs = child.getAttribute("attrs");
28342
+ const directId = child.getAttribute("id");
28343
+ const blockId = typeof directId === "string" && directId ? directId : typeof attrs?.id === "string" ? attrs.id : "";
28344
+ if (blockId && content instanceof Y7.XmlElement && content.nodeName === COMPILED_BLOCK_TYPE) {
28345
+ blocks.push({ blockId, props: propsByBlockId.get(blockId) ?? {} });
28346
+ }
28347
+ }
28348
+ walk(child);
28349
+ }
28350
+ };
28351
+ walk(yDoc.getXmlFragment("document"));
28352
+ return blocks;
28353
+ }
28354
+ function listedBlockIds(yDoc) {
28355
+ const listed = /* @__PURE__ */ new Set();
28356
+ yDoc.getMap("qi.flow.nodes").forEach((value, nodeId) => {
28357
+ listed.add(nodeId);
28358
+ const blockId = value instanceof Y7.Map ? value.get("blockId") : void 0;
28359
+ if (typeof blockId === "string" && blockId) listed.add(blockId);
28360
+ });
28361
+ yDoc.getMap("qi.flow.blockIndex").forEach((blockId) => listed.add(blockId));
28362
+ return listed;
28363
+ }
28364
+ function governedByStepList(yDoc) {
28365
+ return yDoc.getMap("qi.flow.meta").get("draftSchemaVersion") === 1 && yDoc.getMap("qi.flow.nodes").size > 0;
28366
+ }
28367
+ function findUnlistedActionBlocks(yDoc) {
28368
+ if (!governedByStepList(yDoc)) return [];
28369
+ const listed = listedBlockIds(yDoc);
28370
+ return actionBlocksInOrder(yDoc).filter((block) => !listed.has(block.blockId)).map((block) => {
28371
+ const actionType = block.props.actionType ?? "";
28372
+ return { blockId: block.blockId, actionType, known: Boolean(actionType && getAction(actionType)) };
28373
+ });
28374
+ }
28375
+ function flowSegment(yDoc) {
28376
+ const docId = yDoc.getMap("root").get("doc_id");
28377
+ if (typeof docId === "string" && docId) return `ixo:flow:${docId}`;
28378
+ const flowId = yDoc.getMap("qi.flow.meta").get("flowId");
28379
+ return typeof flowId === "string" && flowId ? `ixo:flow:${flowId}` : "ixo:flow";
28380
+ }
28381
+ function addUnlistedSteps(yDoc) {
28382
+ const unlisted = findUnlistedActionBlocks(yDoc).filter((block) => block.known);
28383
+ if (unlisted.length === 0) return [];
28384
+ const blocks = actionBlocksInOrder(yDoc);
28385
+ const propsByBlockId = new Map(blocks.map((block) => [block.blockId, block.props]));
28386
+ const flowPrefix = flowSegment(yDoc);
28387
+ const added = [];
28388
+ yDoc.transact(() => {
28389
+ const nodes = yDoc.getMap("qi.flow.nodes");
28390
+ const blockIndex = yDoc.getMap("qi.flow.blockIndex");
28391
+ for (const { blockId, actionType } of unlisted) {
28392
+ const action = getAction(actionType);
28393
+ if (!action) continue;
28394
+ const props = propsByBlockId.get(blockId) ?? {};
28395
+ const resource = `${flowPrefix}:${blockId}`;
28396
+ const node = {
28397
+ id: blockId,
28398
+ blockId,
28399
+ can: action.can ?? "",
28400
+ with: resource,
28401
+ registryType: action.type,
28402
+ title: props.title || action.can || action.type,
28403
+ description: props.description ?? "",
28404
+ props: { ...props, with: resource }
28405
+ };
28406
+ nodes.set(blockId, createYMapFromNode(node));
28407
+ blockIndex.set(blockId, blockId);
28408
+ added.push(blockId);
28409
+ }
28410
+ const order = yDoc.getArray("qi.flow.order");
28411
+ if (order.length > 0) {
28412
+ const nodeIdByBlock = /* @__PURE__ */ new Map();
28413
+ nodes.forEach((value, nodeId) => {
28414
+ const blockId = value instanceof Y7.Map ? value.get("blockId") : void 0;
28415
+ nodeIdByBlock.set(typeof blockId === "string" && blockId ? blockId : nodeId, nodeId);
28416
+ });
28417
+ for (const blockId of added) {
28418
+ const position = blocks.findIndex((block) => block.blockId === blockId);
28419
+ let insertAt = 0;
28420
+ for (let previous = position - 1; previous >= 0; previous -= 1) {
28421
+ const previousNode = nodeIdByBlock.get(blocks[previous].blockId);
28422
+ const index = previousNode ? order.toArray().indexOf(previousNode) : -1;
28423
+ if (index >= 0) {
28424
+ insertAt = index + 1;
28425
+ break;
28426
+ }
28427
+ }
28428
+ order.insert(insertAt, [blockId]);
28429
+ }
28430
+ }
28431
+ yDoc.getMap("qi.flow.meta").delete("definitionDigest");
28432
+ ensureFlowExecutionMetadata(yDoc);
28433
+ }, "step-list-migration");
28434
+ return added;
28435
+ }
28436
+
28328
28437
  // src/core/lib/flowCompiler/setup.ts
28329
- var Y8 = __toESM(require("yjs"), 1);
28438
+ var Y9 = __toESM(require("yjs"), 1);
28330
28439
  var import_matrix_crdt2 = require("@ixo/matrix-crdt");
28331
28440
 
28332
28441
  // src/core/lib/flowCompiler/documentFragment.ts
28333
- var Y7 = __toESM(require("yjs"), 1);
28442
+ var Y8 = __toESM(require("yjs"), 1);
28334
28443
  function writeCompiledBlocksToFragment(fragment, blocks) {
28335
28444
  const documentBlockGroup = getOrCreateDocumentBlockGroup(fragment);
28336
28445
  for (const block of blocks) {
@@ -28452,12 +28561,12 @@ function readBlocksFromFragment(fragment) {
28452
28561
  return blocks;
28453
28562
  }
28454
28563
  function createBlockContainer(block) {
28455
- const blockContainer = new Y7.XmlElement("blockContainer");
28564
+ const blockContainer = new Y8.XmlElement("blockContainer");
28456
28565
  const { backgroundColor: rawBackgroundColor, textColor: rawTextColor, ...contentProps } = block.props;
28457
28566
  blockContainer.setAttribute("id", block.id);
28458
28567
  blockContainer.setAttribute("textColor", rawTextColor || "default");
28459
28568
  blockContainer.setAttribute("backgroundColor", rawBackgroundColor || "default");
28460
- const blockContent = new Y7.XmlElement(block.type);
28569
+ const blockContent = new Y8.XmlElement(block.type);
28461
28570
  for (const [key, value] of Object.entries(contentProps)) {
28462
28571
  if (value !== "") {
28463
28572
  blockContent.setAttribute(key, value);
@@ -28472,7 +28581,7 @@ function appendBlockToGroup(blockGroup, block) {
28472
28581
  }
28473
28582
  function getOrCreateDocumentBlockGroup(fragment) {
28474
28583
  if (fragment.length === 0) {
28475
- const blockGroup = new Y7.XmlElement("blockGroup");
28584
+ const blockGroup = new Y8.XmlElement("blockGroup");
28476
28585
  fragment.insert(0, [blockGroup]);
28477
28586
  return blockGroup;
28478
28587
  }
@@ -28857,7 +28966,7 @@ function applyFlowPlanToYDoc(yDoc, options) {
28857
28966
  return mergeResult.merged;
28858
28967
  }
28859
28968
  async function connectToRoom(roomId, matrixClient, options) {
28860
- const yDoc = new Y8.Doc();
28969
+ const yDoc = new Y9.Doc();
28861
28970
  const client = matrixClient;
28862
28971
  client.canSupportVoip = false;
28863
28972
  client.clientOpts = { lazyLoadMembers: true };
@@ -29265,7 +29374,7 @@ function fragmentHasContentBlocks(fragment) {
29265
29374
  }
29266
29375
 
29267
29376
  // src/core/lib/flowCompiler/draftRepository.ts
29268
- var Y9 = __toESM(require("yjs"), 1);
29377
+ var Y10 = __toESM(require("yjs"), 1);
29269
29378
  var FlowDraftCommandError = class extends Error {
29270
29379
  constructor(code, message, details) {
29271
29380
  super(message);
@@ -29382,14 +29491,14 @@ function createYjsFlowDefinitionDraftRepository(yDoc) {
29382
29491
  },
29383
29492
  applyBatch: (commands) => {
29384
29493
  if (commands.length === 0) return [];
29385
- const beforeVector = Y9.encodeStateVector(yDoc);
29386
- const stagedDoc = new Y9.Doc();
29494
+ const beforeVector = Y10.encodeStateVector(yDoc);
29495
+ const stagedDoc = new Y10.Doc();
29387
29496
  try {
29388
- Y9.applyUpdate(stagedDoc, Y9.encodeStateAsUpdate(yDoc));
29497
+ Y10.applyUpdate(stagedDoc, Y10.encodeStateAsUpdate(yDoc));
29389
29498
  const stagedRepository = createYjsFlowDefinitionDraftRepository(stagedDoc);
29390
29499
  const results = commands.map((command) => stagedRepository.apply(command));
29391
- const update = Y9.encodeStateAsUpdate(stagedDoc, beforeVector);
29392
- yDoc.transact(() => Y9.applyUpdate(yDoc, update), "flow-draft-command-batch");
29500
+ const update = Y10.encodeStateAsUpdate(stagedDoc, beforeVector);
29501
+ yDoc.transact(() => Y10.applyUpdate(yDoc, update), "flow-draft-command-batch");
29393
29502
  return results;
29394
29503
  } finally {
29395
29504
  stagedDoc.destroy();
@@ -29402,7 +29511,7 @@ function createYjsFlowDefinitionDraftRepository(yDoc) {
29402
29511
  }
29403
29512
 
29404
29513
  // src/core/lib/flowCompiler/participants.ts
29405
- var Y10 = __toESM(require("yjs"), 1);
29514
+ var Y11 = __toESM(require("yjs"), 1);
29406
29515
  var FLOW_PARTICIPANTS_MAP_KEY = "qi.flow.participants";
29407
29516
  function readFlowParticipants(yDoc) {
29408
29517
  const participants = [];
@@ -29462,7 +29571,7 @@ function getParticipantsMap(yDoc) {
29462
29571
  function ensureEntry2(map, userId) {
29463
29572
  const existing = map.get(userId);
29464
29573
  if (isYMapLike(existing)) return existing;
29465
- const created = new Y10.Map();
29574
+ const created = new Y11.Map();
29466
29575
  map.set(userId, created);
29467
29576
  return created;
29468
29577
  }
@@ -31096,6 +31205,7 @@ function createOracleInitFlowTemplate() {
31096
31205
  actionManifestIssues,
31097
31206
  actionTypeToCan,
31098
31207
  addFlowNode,
31208
+ addUnlistedSteps,
31099
31209
  adoptLegacyFlowDocument,
31100
31210
  adoptLegacyRuntime,
31101
31211
  appendAgentLedgerEvent,
@@ -31218,6 +31328,7 @@ function createOracleInitFlowTemplate() {
31218
31328
  executeQueuedAgentCommands,
31219
31329
  executeQueuedFlowAgentCoreCommands,
31220
31330
  findFailedListenersForSourceRun,
31331
+ findUnlistedActionBlocks,
31221
31332
  findXeroWorkItems,
31222
31333
  findXeroWorkItemsForEditor,
31223
31334
  fingerprintFlowCommand,