@oomol-lab/open-flow 0.1.0-beta.67 → 0.1.0-beta.69

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 (72) hide show
  1. package/dist/browser/ContentIcon-CsECY5id.js +11868 -0
  2. package/dist/browser/FlowCanvas-C5X22xQ7.js +22721 -0
  3. package/dist/browser/{createResourceDialog-BQVD8Rqb.js → createResourceDialog-Di5BBrQv.js} +3 -2
  4. package/dist/browser/dialog-Bjo-r9B0.js +8862 -0
  5. package/dist/browser/event-sources.d.ts +4 -2
  6. package/dist/browser/exportSvg-Cj6Spxx-.js +659 -0
  7. package/dist/browser/flow-authoring-node.d.ts +3 -1
  8. package/dist/browser/flow-authoring.js +68 -7
  9. package/dist/browser/flow-change-schema.d.ts +3 -1
  10. package/dist/browser/flow-change.d.ts +17 -2
  11. package/dist/browser/flow-change.js +82 -9
  12. package/dist/browser/{flowChanges-VB9Y4iy7.js → flowChanges-Dp-rcEJ6.js} +4312 -16566
  13. package/dist/browser/{flowRunInputEditorStore-DJqmR6Qh.js → flowRunInputEditorStore-ys1-w9GW.js} +2 -1
  14. package/dist/browser/{flowWorkspace-C1hlTnZq.js → flowWorkspace-CB1QACku.js} +1304 -23538
  15. package/dist/browser/languages-gYzoQqCi.js +68 -0
  16. package/dist/browser/licenses.md +24 -0
  17. package/dist/browser/preview.css +53 -41
  18. package/dist/browser/preview.js +3974 -4094
  19. package/dist/browser/{dialog-CS2Vt2if.js → tooltip-CJjYs_2I.js} +710 -9472
  20. package/dist/browser/{typeScriptSession-D0bjYDeg.js → typeScriptSession-B0hC-C8y.js} +1 -1
  21. package/dist/browser/ui.css +12 -0
  22. package/dist/browser/{value-BADHeZ9I.js → value-BbFQZZ_V.js} +1 -68
  23. package/dist/browser/workbench.css +2840 -2824
  24. package/dist/browser/workbench.js +437 -337
  25. package/dist/browser/{workbenchSelect-CpXhjUou.js → workbenchSelect-C3hxUcYm.js} +2 -1
  26. package/dist/command/index.js +55 -51
  27. package/dist/common/authoring.d.ts +20 -0
  28. package/dist/common/authoringSchema.d.ts +243 -0
  29. package/dist/common/connector-proxy.d.ts +4 -0
  30. package/dist/common/control-api-conformance.js +173 -36
  31. package/dist/common/control-api.d.ts +22 -8
  32. package/dist/common/control-api.js +156 -18
  33. package/dist/common/control-requests.d.ts +32 -19
  34. package/dist/common/control-requests.js +2854 -152
  35. package/dist/common/decision.js +27 -3
  36. package/dist/common/engine-contract.d.ts +2 -2
  37. package/dist/common/event-source-definition.d.ts +34 -16
  38. package/dist/common/event-source.d.ts +63 -5
  39. package/dist/common/event-source.js +5744 -261
  40. package/dist/common/event-sources.d.ts +99 -6
  41. package/dist/common/flow-encoding.js +49 -10
  42. package/dist/common/flow-errorHandling.d.ts +36 -0
  43. package/dist/common/flow-graph.d.ts +4 -2
  44. package/dist/common/flow-retry.d.ts +19 -0
  45. package/dist/common/flow-semantics.js +94 -10
  46. package/dist/common/{fr-Du5gv3kM.js → fr-CNTSedYU.js} +259 -18
  47. package/dist/common/integration-trigger.d.ts +1 -1
  48. package/dist/common/integration-trigger.js +27 -3
  49. package/dist/common/{ja-D2wyPdTF.js → ja-CxQBHr2J.js} +259 -18
  50. package/dist/common/{ko-Cuu2AOaC.js → ko-D1Exiv1h.js} +259 -18
  51. package/dist/common/mcp.d.ts +30 -0
  52. package/dist/common/mcp.js +158 -20
  53. package/dist/common/openapi.js +27 -3
  54. package/dist/common/poll-trigger.js +27 -3
  55. package/dist/common/provider-triggers.d.ts +0 -2
  56. package/dist/common/provider-triggers.js +358 -155
  57. package/dist/common/{ru-BjI_JSsx.js → ru-BzLZv0B7.js} +259 -18
  58. package/dist/common/run-events.d.ts +2 -0
  59. package/dist/common/run-events.js +4 -2
  60. package/dist/common/runtime-contract.d.ts +1 -0
  61. package/dist/common/runtime-contract.js +4 -4
  62. package/dist/common/scheduler.d.ts +13 -2
  63. package/dist/common/scheduler.js +288 -98
  64. package/dist/common/webhook-trigger.js +27 -3
  65. package/dist/common/workflow.js +27 -3
  66. package/dist/common/{zh-CN-CnnXkzLh.js → zh-CN-Dg_xSGde.js} +259 -18
  67. package/dist/common/{zh-TW-CJnR2dgF.js → zh-TW-oxuLwsV0.js} +259 -18
  68. package/dist/index.d.ts +1 -0
  69. package/package.json +1 -1
  70. package/dist/common/event-source-feishu.d.ts +0 -3
  71. package/dist/common/feishu-events.d.ts +0 -19
  72. package/dist/common/feishu-subscriptions.d.ts +0 -6
@@ -1,8 +1,10 @@
1
- import { $t as EmptyDescription, An as EventSourcesPage, Ar as controlErrorCode, At as setTriggerConnection, B as scopedValue, Ct as setNodePositions, Dr as record, Dt as setConnectorConnection, Er as jsonValue, Et as setCodeActions, Ft as IdTooltip, G as connectorActionPorts, Ht as PopoverTitle, I as feishuResourceKind, It as followWorkbenchLink, Jn as randomId, Jt as InputGroup, K as designerGraph, Kn as errorNotice, L as supportsFeishuChatFilter, Lt as Popover, Mt as updateTriggerConfig, N as addNodeIntent, Nn as createI18n, Nr as IconThemeContext, Nt as updateTriggerSchedule, Or as string, Ot as setInputSources, P as deriveAddNodeOptions, Pt as WorkflowExportMenuItem, Qt as EmptyContent, R as combineSources, Rt as PopoverContent, St as setNodeContentHidden, Tr as invalidResponse, Tt as resetInputValues, U as resourceData, Ut as PopoverTrigger, V as CacheResource, W as resourceValue, X as providerIcon, Xt as InputGroupInput, Yn as allConnectorConnectionsQuery, Yt as InputGroupAddon, Zn as decodeTriggerCatalog, Zt as Empty, _ as updateTaskPorts, _t as flowPresentation, a as nameCreatedNodes, an as DropdownMenuContent, ar as connectorActionMetadata, at as revisionView, bt as setComment, c as updateCondition, cr as workflowFileName, ct as deriveInspectorDiagnostics, d as updateNodeName, dn as DropdownMenuSeparator, en as EmptyHeader, er as normalizeTriggerOutputs, f as updateNodeSettings, fr as providerIconAppearance, g as updateTaskAdditionalInputs, gt as commentIds, h as updateTask, hn as DropdownMenuTrigger, ht as canvasPresentationChange, i as deleteSelection, ir as connection, jt as updateStartInputDefs, kn as Badge, kr as ApiError, kt as setServiceConnections, l as updateNodeDescription, lr as workflowNameFromFile, lt as diagnosticItems, m as updateResolution, mt as connectionCatalog, nn as EmptyTitle, nr as triggerOutputDefinitions, nt as RunStore, o as setInputValue, or as encodeWorkflowFile, ot as flowResourceReferences, p as updateOutputPorts, pt as actionWithConnections, qn as WorkbenchClient, r as applyFlowChanges, rn as DropdownMenu, rr as isJsonObject, s as setInputVariable, sn as DropdownMenuItem, sr as parseWorkflowFile, st as Latest, t as addNode, tn as EmptyMedia, tr as sampleErrorOutputs, u as updateNodeIcon, v as updateValue, vt as removeComments, wr as inputValue, wt as repairNodeNames, xr as workflowCandidate, xt as setFlowViewport, y as updateWebhook, yt as restoreCanvasPresentation } from "./flowChanges-VB9Y4iy7.js";
1
+ import { C as DropdownMenuContent, N as DropdownMenuTrigger, T as DropdownMenuItem, d as PopoverContent, g as PopoverTrigger, h as PopoverTitle, it as providerIconAppearance, k as DropdownMenuSeparator, st as IconThemeContext, u as Popover, x as DropdownMenu } from "./ContentIcon-CsECY5id.js";
2
2
  import { a as derive, i as compute, l as val } from "./dist-bO8nvHFH.js";
3
3
  import { c as useLang, l as useTranslate, o as I18nProvider, u as useVal } from "./dist-BFmpkX4P.js";
4
- import { B as upgradeManualTrigger, E as FieldLabel, Ei as cn, G as mapConditionSources, K as nodeInputMappings, M as applyFlowChanges$1, P as isTriggerNode, S as Field, T as FieldGroup, Tt as dequal$1, V as upgradeRevisionContent, a as DialogFooter, d as TooltipContent, fr as Input, i as DialogDescription, j as FlowChangeError, l as Icon, o as DialogHeader, p as TooltipTrigger, r as DialogContent, s as DialogTitle, t as Dialog, u as Tooltip, w as FieldError, wi as Button, x as Spinner, z as resourceNameIssue } from "./dialog-CS2Vt2if.js";
5
- import { c as importedWorkflowName, d as uiLanguageNames, f as uiLanguages, l as isUiLanguage, u as resolveUiLanguage } from "./value-BADHeZ9I.js";
4
+ import { gr as cn, i as TooltipTrigger, mr as Button, n as TooltipContent, t as Tooltip } from "./tooltip-CJjYs_2I.js";
5
+ import { A as upgradeRevisionContent, C as isTriggerNode, Et as Input, L as mapConditionSources, O as resourceNameIssue, R as nodeInputMappings, a as DialogFooter, b as FlowChangeError, d as Field, h as FieldLabel, i as DialogDescription, k as upgradeManualTrigger, l as Icon, m as FieldGroup, o as DialogHeader, ot as dequal$1, p as FieldError, r as DialogContent, s as DialogTitle, t as Dialog, u as Spinner, x as applyFlowChanges } from "./dialog-Bjo-r9B0.js";
6
+ import { $ as providerIcon, An as record, At as WorkflowExportMenuItem, Bt as EmptyMedia, Ct as resetInputValues, Dt as setServiceConnections, Et as setInputSources, Ft as InputGroupInput, Ht as Badge, It as Empty, J as connectorActionPorts, K as resourceData, Kt as createI18n, Lt as EmptyContent, Mn as ApiError, Mt as followWorkbenchLink, Nn as controlErrorCode, Nt as InputGroup, On as invalidResponse, Ot as updateStartInputDefs, Pt as InputGroupAddon, Qt as allConnectorConnectionsQuery, R as addNodeIntent, Rt as EmptyDescription, S as updateWebhook, St as repairNodeNames, Tt as setConnectorConnection, U as scopedValue, Ut as EventSourcesPage, V as combineSources, Vt as EmptyTitle, W as CacheResource, Xt as WorkbenchClient, Y as designerGraph, Yt as errorNotice, Zt as randomId, _ as updateTask, _t as restoreCanvasPresentation, a as nameCreatedNodes, an as sampleErrorOutputs, at as Latest, b as updateTriggerConfig, bt as setNodeContentHidden, c as setTriggerConnection, cn as connection, d as updateNodeDescription, dn as parseWorkflowFile, dt as actionWithConnections, en as decodeTriggerCatalog, et as RunStore, f as updateNodeIcon, fn as workflowFileName, ft as connectionCatalog, g as updateResolution, gt as removeComments, h as updateOutputPorts, ht as flowPresentation, i as deleteSelection, in as normalizeTriggerOutputs, it as flowResourceReferences, jn as string, jt as IdTooltip, kn as jsonValue, kt as updateTriggerSchedule, l as setTriggerEventSource, ln as connectorActionMetadata, m as updateNodeSettings, mt as commentIds, o as setInputValue, on as triggerOutputDefinitions, ot as deriveInspectorDiagnostics, p as updateNodeName, pn as workflowNameFromFile, pt as canvasPresentationChange, q as resourceValue, r as applyFlowChanges$1, rt as revisionView, s as setInputVariable, st as diagnosticItems, t as addNode, u as updateCondition, un as encodeWorkflowFile, v as updateTaskAdditionalInputs, vt as setComment, wn as workflowCandidate, wt as setCodeActions, x as updateValue, xt as setNodePositions, y as updateTaskPorts, yt as setFlowViewport, z as deriveAddNodeOptions, zt as EmptyHeader } from "./flowChanges-Dp-rcEJ6.js";
7
+ import { a as uiLanguages, i as uiLanguageNames, n as isUiLanguage, r as resolveUiLanguage, t as importedWorkflowName } from "./languages-gYzoQqCi.js";
6
8
  import { Suspense, forwardRef, lazy, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
7
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
10
  import * as Cause from "effect/Cause";
@@ -514,7 +516,7 @@ function FlowDeletionDialog({ flow, workspace, container, busy, finalFocus, onCl
514
516
  }
515
517
  //#endregion
516
518
  //#region src/workbench/browser/runtime/shell/resourceBrowser.tsx
517
- var CreateResourceDialog = lazy(() => import("./createResourceDialog-BQVD8Rqb.js"));
519
+ var CreateResourceDialog = lazy(() => import("./createResourceDialog-Di5BBrQv.js"));
518
520
  var flowIdTooltipAlignOffset = 44;
519
521
  var renamePopoverAlignOffset = -12;
520
522
  function compactFlowId(flowId) {
@@ -1873,7 +1875,7 @@ function inputSignature(spec) {
1873
1875
  }
1874
1876
  async function inputEditor(spec, language, values) {
1875
1877
  if (spec == null) return void 0;
1876
- const { FlowRunInputEditorStore } = await import("./flowRunInputEditorStore-DJqmR6Qh.js").then((n) => n.t);
1878
+ const { FlowRunInputEditorStore } = await import("./flowRunInputEditorStore-ys1-w9GW.js").then((n) => n.t);
1877
1879
  const editor = new FlowRunInputEditorStore(spec.definitions, language, { allowOmittedNullable: spec.allowOmittedNullable });
1878
1880
  const initial = values ?? spec.samples;
1879
1881
  if (initial != null) editor.replaceValues(Object.fromEntries(spec.definitions.flatMap(({ handle }) => Object.hasOwn(initial, handle) ? [[handle, initial[handle]]] : [])));
@@ -4011,7 +4013,7 @@ var ConnectorStore = class {
4011
4013
  }
4012
4014
  }
4013
4015
  async setConnection(nodeId, connectionId) {
4014
- return await this.#workspace.setConnectorConnection(nodeId, connectionId);
4016
+ return await this.#workspace.nodes.setConnectorConnection(nodeId, connectionId);
4015
4017
  }
4016
4018
  async refreshAfterAuthorization() {
4017
4019
  if (this.#disposed || this.#authorization == null) return;
@@ -4055,7 +4057,7 @@ var ConnectorStore = class {
4055
4057
  const connection = created.length == 1 ? created[0] : catalog.preferred;
4056
4058
  const selected = this.#workspace.$.revision.value?.node(target.nodeId);
4057
4059
  const task = selected?.kind == "task" ? selected.definition : void 0;
4058
- if (connection != null && this.#workspace.$.selectedNodeIds.value.includes(target.nodeId) && task != null && "executor" in task && task.executor.kind == "connector" && task.executor.connectionId == null) await this.#workspace.setConnectorConnection(target.nodeId, connection.connectionId);
4060
+ if (connection != null && this.#workspace.$.selectedNodeIds.value.includes(target.nodeId) && task != null && "executor" in task && task.executor.kind == "connector" && task.executor.connectionId == null) await this.#workspace.nodes.setConnectorConnection(target.nodeId, connection.connectionId);
4059
4061
  }
4060
4062
  #remember(source, ids) {
4061
4063
  if (ids.some((id) => !source.value.includes(id))) source.set([.../* @__PURE__ */ new Set([...source.value, ...ids])]);
@@ -4328,7 +4330,7 @@ var TriggerStore = class {
4328
4330
  }
4329
4331
  }
4330
4332
  async setConnection(triggerId, connectionId) {
4331
- return await this.#workspace.setTriggerConnection(triggerId, connectionId);
4333
+ return await this.#workspace.nodes.setTriggerConnection(triggerId, connectionId);
4332
4334
  }
4333
4335
  async refreshAfterAuthorization() {
4334
4336
  if (this.#disposed) return;
@@ -4363,7 +4365,7 @@ function inverseFlowChanges(content, operations) {
4363
4365
  before: upgradeManualTrigger(requested.before),
4364
4366
  node: upgradeManualTrigger(requested.node)
4365
4367
  } : requested;
4366
- const after = applyFlowChanges$1(current, [operation]);
4368
+ const after = applyFlowChanges(current, [operation]);
4367
4369
  const restore = [];
4368
4370
  switch (operation.kind) {
4369
4371
  case "graph.node.replace":
@@ -4513,6 +4515,14 @@ function inverseFlowChanges(content, operations) {
4513
4515
  });
4514
4516
  break;
4515
4517
  case "graph.node.field.set":
4518
+ if (operation.field == "retry") {
4519
+ restore.push({
4520
+ ...operation,
4521
+ before: operation.value,
4522
+ value: operation.before
4523
+ });
4524
+ break;
4525
+ }
4516
4526
  restore.push({
4517
4527
  ...operation,
4518
4528
  before: operation.value,
@@ -4746,6 +4756,77 @@ function pasteNodes(revision, clipboard, identity) {
4746
4756
  };
4747
4757
  }
4748
4758
  //#endregion
4759
+ //#region src/workbench/browser/runtime/editor/canvasClipboard.ts
4760
+ var CanvasClipboard = class {
4761
+ #value;
4762
+ constructor(identity, t) {
4763
+ this.identity = identity;
4764
+ this.t = t;
4765
+ }
4766
+ copy(revision, graph, nodeIds) {
4767
+ const selected = new Set(nodeIds);
4768
+ this.#value = {
4769
+ hiddenNodeIds: graph.nodes.flatMap((node) => node.contentHidden && selected.has(node.id) ? [node.id] : []),
4770
+ comments: graph.nodes.flatMap((node) => node.kind == "comment" && selected.has(node.id) ? [{
4771
+ content: node.content,
4772
+ position: node.position,
4773
+ sourceId: node.id,
4774
+ title: node.title
4775
+ }] : []),
4776
+ nodes: copyNodes(revision, nodeIds)
4777
+ };
4778
+ }
4779
+ paste(revision, graph, sourcePositions, offset = {
4780
+ x: 40,
4781
+ y: 40
4782
+ }) {
4783
+ if (this.#value == null) return;
4784
+ const hiddenNodeIds = new Set(this.#value.hiddenNodeIds);
4785
+ const pasted = pasteNodes(revision, this.#value.nodes, this.identity);
4786
+ const comments = this.#value.comments.map((comment) => ({
4787
+ ...comment,
4788
+ nodeId: this.identity()
4789
+ }));
4790
+ if (pasted.nodeIds.length == 0 && comments.length == 0) return;
4791
+ const designerNodes = new Map(graph.nodes.map((node) => [node.id, node]));
4792
+ const added = /* @__PURE__ */ new Set([...pasted.nodeIds, ...comments.map((comment) => comment.nodeId)]);
4793
+ const occupied = new Set([...designerNodes].filter(([nodeId]) => !added.has(nodeId)).map(([, node]) => `${node.position.x}\0${node.position.y}`));
4794
+ const sources = [...pasted.sourceIds.map((sourceId) => sourcePositions?.[sourceId] ?? designerNodes.get(sourceId)?.position ?? {
4795
+ x: 80,
4796
+ y: 80
4797
+ }), ...comments.map((comment) => comment.position)];
4798
+ let step = 1;
4799
+ if (offset.x != 0 || offset.y != 0) while (sources.some((source) => occupied.has(`${source.x + offset.x * step}\0${source.y + offset.y * step}`))) step += 1;
4800
+ const positions = Object.fromEntries(pasted.sourceIds.map((sourceId, index) => {
4801
+ const source = sourcePositions?.[sourceId] ?? designerNodes.get(sourceId)?.position;
4802
+ return [pasted.nodeIds[index], {
4803
+ x: (source?.x ?? 80) + offset.x * step,
4804
+ y: (source?.y ?? 80) + offset.y * step
4805
+ }];
4806
+ }));
4807
+ return {
4808
+ changes: pasted.changes,
4809
+ nodeIds: [...pasted.nodeIds, ...comments.map((comment) => comment.nodeId)],
4810
+ update: (value) => {
4811
+ let next = setNodePositions(value, positions);
4812
+ for (const [index, sourceId] of pasted.sourceIds.entries()) if (hiddenNodeIds.has(sourceId)) next = setNodeContentHidden(next, pasted.nodeIds[index], true);
4813
+ for (const comment of comments) {
4814
+ if (hiddenNodeIds.has(comment.sourceId)) next = setNodeContentHidden(next, comment.nodeId, true);
4815
+ next = setComment(next, comment.nodeId, {
4816
+ content: comment.content,
4817
+ position: {
4818
+ x: comment.position.x + offset.x * step,
4819
+ y: comment.position.y + offset.y * step
4820
+ },
4821
+ title: this.t("addNode.commentCopy", { title: comment.title })
4822
+ });
4823
+ }
4824
+ return next;
4825
+ }
4826
+ };
4827
+ }
4828
+ };
4829
+ //#endregion
4749
4830
  //#region src/workbench/browser/runtime/stores/canvasHistory.ts
4750
4831
  var CanvasHistory = class {
4751
4832
  constructor() {
@@ -4779,6 +4860,17 @@ var CanvasHistory = class {
4779
4860
  this.#redo.length = 0;
4780
4861
  this.publish();
4781
4862
  }
4863
+ completeNodeCreation(nodeId, changes) {
4864
+ const index = this.#undo.findIndex((entry) => entry.forward.some((operation) => operation.kind == "graph.node.create" && operation.nodeId == nodeId));
4865
+ if (index < 0 || this.applying || this.failed) return false;
4866
+ const entry = this.#undo[index];
4867
+ this.#undo[index] = {
4868
+ ...entry,
4869
+ forward: [...entry.forward, ...changes]
4870
+ };
4871
+ this.publish();
4872
+ return true;
4873
+ }
4782
4874
  rebaseModuleCreation(moduleId, module) {
4783
4875
  for (const [index, entry] of this.#undo.entries()) {
4784
4876
  if (!entry.forward.some((operation) => operation.kind == "module.create" && operation.moduleId == moduleId)) continue;
@@ -4843,6 +4935,11 @@ function mergeChanges(before, after) {
4843
4935
  const last = after[0];
4844
4936
  if (first?.kind == "graph.node.field.set" && last?.kind == "graph.node.field.set") {
4845
4937
  if (first.nodeId != last.nodeId || first.field != last.field) return;
4938
+ if (first.field == "retry" && last.field == "retry") return [{
4939
+ ...last,
4940
+ before: first.before
4941
+ }];
4942
+ if (first.field == "retry" || last.field == "retry") return;
4846
4943
  return [{
4847
4944
  before: first.before,
4848
4945
  field: last.field,
@@ -4896,7 +4993,7 @@ var DraftChanges = class {
4896
4993
  let projected = draft;
4897
4994
  const pending = [];
4898
4995
  for (const change of this.#pending) try {
4899
- projected = applyFlowChanges(projected, change.changes);
4996
+ projected = applyFlowChanges$1(projected, change.changes);
4900
4997
  pending.push(change);
4901
4998
  } catch (error) {
4902
4999
  if (!(error instanceof FlowChangeError)) throw error;
@@ -4906,7 +5003,7 @@ var DraftChanges = class {
4906
5003
  return projected;
4907
5004
  }
4908
5005
  project(draft) {
4909
- return this.#pending.reduce((current, pending) => applyFlowChanges(current, pending.changes), draft);
5006
+ return this.#pending.reduce((current, pending) => applyFlowChanges$1(current, pending.changes), draft);
4910
5007
  }
4911
5008
  async settled() {
4912
5009
  await this.#queue;
@@ -4994,7 +5091,7 @@ var DraftChanges = class {
4994
5091
  #applyCommitted(pending, base, change) {
4995
5092
  const committed = {
4996
5093
  ...change.revision,
4997
- content: applyFlowChanges(base, pending.changes).content
5094
+ content: applyFlowChanges$1(base, pending.changes).content
4998
5095
  };
4999
5096
  this.#pending = this.#pending.filter((candidate) => candidate !== pending);
5000
5097
  this.#committed = committed;
@@ -5176,6 +5273,61 @@ var FlowCatalog = class {
5176
5273
  this.#pending.delete(flow.flowId);
5177
5274
  }
5178
5275
  }
5276
+ create(name, create) {
5277
+ return this.#create(async () => create == null ? this.#client.createFlow(name) : this.#client.getFlow(await create(name)));
5278
+ }
5279
+ import(file, name, key, importer) {
5280
+ return this.#create(async () => importer == null ? this.#client.importFlow(file, {
5281
+ name,
5282
+ idempotencyKey: key
5283
+ }) : this.#client.getFlow(await importer(file, name, key)));
5284
+ }
5285
+ async #create(create) {
5286
+ try {
5287
+ const created = await create();
5288
+ if (this.#disposed) return;
5289
+ this.#insert(created);
5290
+ return created;
5291
+ } catch (error) {
5292
+ if (!this.#disposed) this.#setNotice(errorNotice(error, this.#i18n.t));
5293
+ }
5294
+ }
5295
+ async delete(flowId) {
5296
+ const flow = this.flow(flowId);
5297
+ if (flow == null || flow.status == "retiring") return false;
5298
+ try {
5299
+ await this.#client.deleteFlow(flowId);
5300
+ if (this.#disposed) return false;
5301
+ this.#remove(flowId);
5302
+ this.#setNotice({
5303
+ kind: "success",
5304
+ message: this.#i18n.t("notice.flowDeleteAccepted", { name: flow.name })
5305
+ });
5306
+ return true;
5307
+ } catch (error) {
5308
+ if (!this.#disposed) this.#setNotice(errorNotice(error, this.#i18n.t));
5309
+ return false;
5310
+ }
5311
+ }
5312
+ async rename(flowId, name) {
5313
+ const flow = this.flow(flowId);
5314
+ const nextName = name.trim();
5315
+ if (flow == null || nextName.length == 0) return false;
5316
+ if (flow.name == nextName) return true;
5317
+ try {
5318
+ const changed = await this.#client.renameFlow(flowId, nextName);
5319
+ if (this.#disposed) return false;
5320
+ this.include(changed);
5321
+ this.#setNotice({
5322
+ kind: "success",
5323
+ message: this.#i18n.t("notice.flowRenamed", { name: nextName })
5324
+ });
5325
+ return true;
5326
+ } catch (error) {
5327
+ if (!this.#disposed) this.#setNotice(errorNotice(error, this.#i18n.t));
5328
+ return false;
5329
+ }
5330
+ }
5179
5331
  include(flow) {
5180
5332
  const index = this.#state.value.flows.findIndex((candidate) => candidate.flowId == flow.flowId);
5181
5333
  if (index < 0) {
@@ -5188,14 +5340,14 @@ var FlowCatalog = class {
5188
5340
  ...referenceCount == null ? {} : { referenceCount }
5189
5341
  }) });
5190
5342
  }
5191
- insert(flow) {
5343
+ #insert(flow) {
5192
5344
  if (this.#state.value.flows.some((candidate) => candidate.flowId == flow.flowId)) return;
5193
5345
  this.#set({
5194
5346
  flows: [...this.#state.value.flows, flow],
5195
5347
  total: this.#state.value.total == null ? void 0 : this.#state.value.total + 1
5196
5348
  });
5197
5349
  }
5198
- remove(flowId) {
5350
+ #remove(flowId) {
5199
5351
  this.#set({
5200
5352
  flows: this.#state.value.flows.filter((flow) => flow.flowId != flowId),
5201
5353
  total: this.#state.value.total == null ? void 0 : this.#state.value.total - 1
@@ -5354,6 +5506,183 @@ var ModuleEditorSession = class {
5354
5506
  }
5355
5507
  };
5356
5508
  //#endregion
5509
+ //#region src/workbench/browser/runtime/stores/nodeEdits.ts
5510
+ var NodeEdits = class {
5511
+ constructor(revision, save, identity) {
5512
+ this.revision = revision;
5513
+ this.save = save;
5514
+ this.identity = identity;
5515
+ }
5516
+ async saveErrorSources(nodeId, value) {
5517
+ const node = this.revision.value?.graph()?.nodes[nodeId];
5518
+ if (node?.kind != "error" || dequal$1(node.sourceFlowIds ?? [], value)) return false;
5519
+ return await this.save([{
5520
+ kind: "graph.trigger.sources.set",
5521
+ nodeId,
5522
+ before: node.sourceFlowIds,
5523
+ value: value.length == 0 ? void 0 : value
5524
+ }]);
5525
+ }
5526
+ async saveNodeSettings(nodeId, settings) {
5527
+ const revision = this.revision.value;
5528
+ if (revision == null) return false;
5529
+ const changes = updateNodeSettings(revision, nodeId, settings);
5530
+ return changes != null && await this.save(changes);
5531
+ }
5532
+ async saveNodeDescription(nodeId, description) {
5533
+ const revision = this.revision.value;
5534
+ if (revision == null) return false;
5535
+ const changes = updateNodeDescription(revision, nodeId, description);
5536
+ return changes != null && await this.save(changes);
5537
+ }
5538
+ async saveNodeIcon(nodeId, icon) {
5539
+ const revision = this.revision.value;
5540
+ if (revision == null) return false;
5541
+ const changes = updateNodeIcon(revision, nodeId, icon);
5542
+ return changes != null && await this.save(changes);
5543
+ }
5544
+ async saveNodeTitle(nodeId, title) {
5545
+ const revision = this.revision.value;
5546
+ if (revision == null) return false;
5547
+ const changes = updateNodeName(revision, nodeId, title);
5548
+ return changes != null && await this.save(changes);
5549
+ }
5550
+ async setInputValue(nodeId, handle, value, deletion) {
5551
+ const revision = this.revision.value;
5552
+ if (revision == null) return false;
5553
+ const changes = setInputValue(revision, nodeId, handle, value);
5554
+ return changes != null && await this.save(changes, deletion);
5555
+ }
5556
+ async resetInputs(nodeId, handles) {
5557
+ const revision = this.revision.value;
5558
+ if (revision == null) return false;
5559
+ return await this.save(resetInputValues(revision.revision.content, nodeId, handles));
5560
+ }
5561
+ async saveOutputsDefs(nodeId, definitions, deletion, values) {
5562
+ const revision = this.revision.value;
5563
+ if (revision == null || revision.graph().nodes[nodeId]?.kind != "outputs") return false;
5564
+ return await this.save(updateOutputPorts(revision, nodeId, definitions, values), deletion);
5565
+ }
5566
+ async saveStartInputDefs(nodeId, inputDefs, deletion) {
5567
+ const revision = this.revision.value;
5568
+ if (revision == null || revision.graph().nodes[nodeId]?.kind != "start") return false;
5569
+ const changes = updateStartInputDefs(revision.revision.content, nodeId, inputDefs);
5570
+ return await this.save(changes, deletion);
5571
+ }
5572
+ async resetTriggerConfig(triggerId, names) {
5573
+ const revision = this.revision.value;
5574
+ if (revision == null) return false;
5575
+ const trigger = revision.graph()?.nodes[triggerId];
5576
+ if (trigger?.kind !== "poll" && trigger?.kind !== "integration") return false;
5577
+ const changes = (names == null ? Object.entries(trigger.config) : names.flatMap((name) => Object.hasOwn(trigger.config, name) ? [[name, trigger.config[name]]] : [])).map(([name, before]) => ({
5578
+ kind: "graph.trigger.config.set",
5579
+ nodeId: triggerId,
5580
+ name,
5581
+ before,
5582
+ value: void 0
5583
+ }));
5584
+ return await this.save(changes);
5585
+ }
5586
+ async setInputSource(nodeId, handle, source) {
5587
+ const revision = this.revision.value;
5588
+ if (revision == null) return false;
5589
+ return await this.save(setInputSources(revision.revision.content, nodeId, handle, [{
5590
+ kind: "node",
5591
+ ...source
5592
+ }]));
5593
+ }
5594
+ async setInputVariable(nodeId, handle, name) {
5595
+ const revision = this.revision.value;
5596
+ if (revision == null) return false;
5597
+ const changes = name == null ? setInputValue(revision, nodeId, handle, void 0) : setInputVariable(revision, nodeId, handle, name, this.identity());
5598
+ return changes != null && await this.save(changes);
5599
+ }
5600
+ async saveCondition(nodeId, settings, deletion) {
5601
+ const revision = this.revision.value;
5602
+ if (revision == null) return false;
5603
+ const changes = updateCondition(revision, nodeId, settings);
5604
+ return changes != null && await this.save(changes, deletion);
5605
+ }
5606
+ async saveValue(nodeId, values, deletion) {
5607
+ const revision = this.revision.value;
5608
+ if (revision == null) return false;
5609
+ const changes = updateValue(revision, nodeId, values);
5610
+ return changes != null && await this.save(changes, deletion);
5611
+ }
5612
+ async saveResolution(nodeId, settings, deletion, values) {
5613
+ const revision = this.revision.value;
5614
+ if (revision == null) return false;
5615
+ const changes = updateResolution(revision, nodeId, settings, values);
5616
+ return changes != null && await this.save(changes, deletion);
5617
+ }
5618
+ async saveTaskSettings(nodeId, settings, deletion) {
5619
+ const revision = this.revision.value;
5620
+ if (revision == null) return false;
5621
+ const changes = updateTask(revision, nodeId, settings);
5622
+ return changes != null && await this.save(changes, deletion);
5623
+ }
5624
+ async saveTaskPorts(nodeId, ports, deletion, values) {
5625
+ const revision = this.revision.value;
5626
+ if (revision == null) return false;
5627
+ const changes = updateTaskPorts(revision, nodeId, ports, values);
5628
+ return changes != null && await this.save(changes, deletion);
5629
+ }
5630
+ async saveTaskAdditionalInputs(nodeId, inputs, deletion, values) {
5631
+ const revision = this.revision.value;
5632
+ if (revision == null) return false;
5633
+ const changes = updateTaskAdditionalInputs(revision, nodeId, inputs, values);
5634
+ return changes != null && await this.save(changes, deletion);
5635
+ }
5636
+ async setConnectorConnection(nodeId, connectionId) {
5637
+ const revision = this.revision.value;
5638
+ if (revision == null) return false;
5639
+ const changes = setConnectorConnection(revision.revision.content, nodeId, connectionId);
5640
+ return changes != null && await this.save(changes);
5641
+ }
5642
+ async setServiceConnections(providerId, connectionId, previousConnectionId) {
5643
+ const revision = this.revision.value;
5644
+ if (revision == null) return false;
5645
+ const changes = setServiceConnections(revision.revision.content, providerId, connectionId, previousConnectionId);
5646
+ return changes.length == 0 || await this.save(changes);
5647
+ }
5648
+ async setCodeActions(nodeId, capabilities) {
5649
+ const revision = this.revision.value;
5650
+ if (revision == null) return false;
5651
+ const changes = setCodeActions(revision.revision.content, nodeId, capabilities);
5652
+ return changes == null || await this.save(changes);
5653
+ }
5654
+ async setTriggerEventSource(triggerId, source) {
5655
+ const revision = this.revision.value;
5656
+ if (revision == null) return false;
5657
+ const changes = setTriggerEventSource(revision, triggerId, source);
5658
+ return changes != null && await this.save(changes);
5659
+ }
5660
+ async saveTriggerConfig(triggerId, name, value) {
5661
+ const revision = this.revision.value;
5662
+ if (revision == null) return false;
5663
+ const changes = updateTriggerConfig(revision, triggerId, name, value);
5664
+ return changes != null && await this.save(changes);
5665
+ }
5666
+ async saveTriggerSchedule(triggerId, schedule) {
5667
+ const revision = this.revision.value;
5668
+ if (revision == null) return false;
5669
+ const changes = updateTriggerSchedule(revision.revision.content, triggerId, schedule);
5670
+ return changes != null && await this.save(changes);
5671
+ }
5672
+ async saveWebhook(triggerId, settings, deletion) {
5673
+ const revision = this.revision.value;
5674
+ if (revision == null) return false;
5675
+ const changes = updateWebhook(revision, triggerId, settings);
5676
+ return changes != null && await this.save(changes, deletion);
5677
+ }
5678
+ async setTriggerConnection(triggerId, connectionId) {
5679
+ const revision = this.revision.value;
5680
+ if (revision == null) return false;
5681
+ const changes = setTriggerConnection(revision, triggerId, connectionId);
5682
+ return changes != null && await this.save(changes);
5683
+ }
5684
+ };
5685
+ //#endregion
5357
5686
  //#region src/workbench/browser/runtime/stores/presentationChanges.ts
5358
5687
  var PresentationChanges = class {
5359
5688
  #client;
@@ -5572,10 +5901,6 @@ var WorkspaceModel = class {
5572
5901
  };
5573
5902
  //#endregion
5574
5903
  //#region src/workbench/browser/runtime/stores/workspaceStore.ts
5575
- var PASTE_OFFSET = {
5576
- x: 40,
5577
- y: 40
5578
- };
5579
5904
  var deletionMessageKeys = {
5580
5905
  field: "history.deleted.field",
5581
5906
  group: "history.deleted.group",
@@ -5641,6 +5966,7 @@ var WorkspaceStore = class {
5641
5966
  this.#client = client;
5642
5967
  this.#setNotice = setNotice;
5643
5968
  this.#identity = identity;
5969
+ this.#clipboard = new CanvasClipboard(identity, i18n.t);
5644
5970
  this.#i18n = i18n;
5645
5971
  this.#runChanged = runChanged;
5646
5972
  this.#flows = new FlowCatalog(client, setNotice, i18n);
@@ -5664,6 +5990,7 @@ var WorkspaceStore = class {
5664
5990
  });
5665
5991
  this.#presentationChanges = new PresentationChanges(client, setNotice, (presentation) => this.#set({ presentation }), i18n);
5666
5992
  this.$ = this.#model.$;
5993
+ this.nodes = new NodeEdits(this.$.revision, async (changes, deletion) => await this.#canvasChange("edit", 1, changes, void 0, void 0, deletion) && this.#model.value.draft != null, identity);
5667
5994
  }
5668
5995
  dispose() {
5669
5996
  this.catalogs.dispose();
@@ -5679,9 +6006,13 @@ var WorkspaceStore = class {
5679
6006
  this.#flows.dispose();
5680
6007
  }
5681
6008
  async start(flowId) {
5682
- const current = this.#draftSession.capture();
5683
- let initialLoad;
5684
6009
  this.#started = false;
6010
+ await this.selectFlow(flowId);
6011
+ this.#started = !this.#disposed;
6012
+ }
6013
+ async #loadFlowCatalog() {
6014
+ if (this.#flows.loaded && this.#stopCatalogWatch != null) return;
6015
+ let initialLoad;
5685
6016
  if (this.#stopCatalogWatch == null) {
5686
6017
  const subscription = this.#client.watchFlowCatalog((event) => {
5687
6018
  if (this.#disposed) return;
@@ -5699,8 +6030,6 @@ var WorkspaceStore = class {
5699
6030
  if (this.#disposed) return;
5700
6031
  initialLoad = this.reloadFlows();
5701
6032
  await initialLoad;
5702
- if (!this.#disposed && current()) await this.selectFlow(flowId);
5703
- this.#started = !this.#disposed;
5704
6033
  }
5705
6034
  async reloadFlows() {
5706
6035
  await this.#flows.reload();
@@ -5745,17 +6074,21 @@ var WorkspaceStore = class {
5745
6074
  workspaceLoading: flowId != null,
5746
6075
  workspaceRepairing: false
5747
6076
  });
5748
- if (flowId == null) return true;
6077
+ if (flowId == null) {
6078
+ await this.#loadFlowCatalog();
6079
+ return true;
6080
+ }
5749
6081
  try {
5750
6082
  let invalidated = false;
5751
6083
  let pendingRevision;
5752
- const subscription = this.#client.watchFlow(flowId, (revisionId) => {
6084
+ const changed = (revisionId) => {
5753
6085
  if (!current()) return;
5754
6086
  if (this.#draftChanges.committed == null) {
5755
6087
  invalidated = true;
5756
6088
  pendingRevision = revisionId;
5757
6089
  } else if (revisionId != this.#draftChanges.committed.revisionId) this.#refreshDraft(revisionId);
5758
- }, (event) => {
6090
+ };
6091
+ const subscription = this.#client.watchFlow(flowId, changed, (event) => {
5759
6092
  if (current()) this.#runChanged(event);
5760
6093
  }, (accessRevision) => {
5761
6094
  if (current()) {
@@ -5766,8 +6099,18 @@ var WorkspaceStore = class {
5766
6099
  if (current() && !this.#model.value.workspaceLoading) for (const execute of this.#canvasCommandListeners) execute(command);
5767
6100
  });
5768
6101
  this.#stopFlowWatch = subscription.stop;
5769
- await subscription.ready;
6102
+ let reading = false;
6103
+ subscription.ready.then(() => {
6104
+ if (reading) changed();
6105
+ }, (error) => {
6106
+ if (!current()) return;
6107
+ subscription.stop();
6108
+ this.#stopFlowWatch = void 0;
6109
+ this.#setNotice(errorNotice(error, this.#i18n.t));
6110
+ });
6111
+ await Promise.resolve();
5770
6112
  if (!current()) return false;
6113
+ reading = true;
5771
6114
  let editor = await this.#client.getEditor(flowId);
5772
6115
  for (let attempt = 0; current() && Object.values(revisionView(editor.draft).graph().nodes).some((node) => node.kind == "manual"); attempt += 1) {
5773
6116
  if (attempt >= 3) throw new ApiError(409, controlErrorCode.flowRevisionConflict, "The Draft changed while upgrading its Start node.");
@@ -5814,22 +6157,28 @@ var WorkspaceStore = class {
5814
6157
  }
5815
6158
  async repairWorkspace() {
5816
6159
  const flowId = this.#model.value.flowId;
5817
- const flow = flowId == null ? void 0 : this.#flows.flow(flowId);
5818
- if (flowId == null || flow == null || this.#model.value.workspaceRepairing) return;
5819
- const repair = this.#pendingRepair ??= {
5820
- changeId: this.#identity(),
5821
- expectedRevisionId: flow.draftRevisionId
5822
- };
6160
+ if (flowId == null || this.#model.value.workspaceRepairing) return;
6161
+ const current = this.#draftSession.capture();
5823
6162
  this.#set({
5824
6163
  workspaceRepairing: true,
5825
6164
  workspaceLoadProblem: this.#model.value.workspaceLoadProblem
5826
6165
  });
5827
6166
  try {
6167
+ let repair = this.#pendingRepair;
6168
+ if (repair == null) {
6169
+ const flow = this.#flows.flow(flowId) ?? await this.#client.getFlow(flowId);
6170
+ if (!current()) return;
6171
+ repair = this.#pendingRepair = {
6172
+ changeId: this.#identity(),
6173
+ expectedRevisionId: flow.draftRevisionId
6174
+ };
6175
+ }
5828
6176
  await this.#client.repairDraft(flowId, repair.expectedRevisionId, repair.changeId);
6177
+ if (!current()) return;
5829
6178
  this.#pendingRepair = void 0;
5830
6179
  await this.selectFlow(flowId);
5831
6180
  } catch (error) {
5832
- if (this.#disposed) return;
6181
+ if (this.#disposed || !current()) return;
5833
6182
  if (error instanceof ApiError && error.code == controlErrorCode.flowRevisionConflict) {
5834
6183
  this.#pendingRepair = void 0;
5835
6184
  await this.selectFlow(flowId);
@@ -5890,24 +6239,16 @@ var WorkspaceStore = class {
5890
6239
  }
5891
6240
  }
5892
6241
  createFlow(name, create) {
5893
- return this.#createFlow(async () => create == null ? this.#client.createFlow(name) : this.#client.getFlow(await create(name)));
6242
+ return this.#createFlow(() => this.#flows.create(name, create));
5894
6243
  }
5895
6244
  importFlow(file, name, key, importer) {
5896
- return this.#createFlow(async () => importer == null ? this.#client.importFlow(file, {
5897
- name,
5898
- idempotencyKey: key
5899
- }) : this.#client.getFlow(await importer(file, name, key)));
6245
+ return this.#createFlow(() => this.#flows.import(file, name, key, importer));
5900
6246
  }
5901
6247
  async #createFlow(create) {
5902
6248
  if (!await this.saveModuleEditor()) return;
5903
6249
  this.#set({ busy: "flow" });
5904
6250
  try {
5905
- const created = await create();
5906
- if (this.#disposed) return;
5907
- this.#flows.insert(created);
5908
- return created;
5909
- } catch (error) {
5910
- if (!this.#disposed) this.#setNotice(errorNotice(error, this.#i18n.t));
6251
+ return await create();
5911
6252
  } finally {
5912
6253
  this.#set({ busy: void 0 });
5913
6254
  }
@@ -5924,45 +6265,20 @@ var WorkspaceStore = class {
5924
6265
  }
5925
6266
  async deleteFlow(flowId) {
5926
6267
  if (!await this.saveModuleEditor()) return false;
5927
- const flow = this.#flows.flow(flowId);
5928
- if (flow == null || flow.status == "retiring") return false;
5929
6268
  this.#set({ busy: "flow" });
5930
6269
  try {
5931
- await this.#client.deleteFlow(flowId);
5932
- if (this.#disposed) return false;
5933
- this.#flows.remove(flowId);
5934
- this.#setNotice({
5935
- kind: "success",
5936
- message: this.#i18n.t("notice.flowDeleteAccepted", { name: flow.name })
5937
- });
5938
- return true;
5939
- } catch (error) {
5940
- if (!this.#disposed) this.#setNotice(errorNotice(error, this.#i18n.t));
5941
- return false;
6270
+ return await this.#flows.delete(flowId);
5942
6271
  } finally {
5943
6272
  this.#set({ busy: void 0 });
5944
6273
  }
5945
6274
  }
5946
6275
  async renameFlow(flowId, name) {
5947
- const flow = this.#flows.flow(flowId);
5948
- const nextName = name.trim();
5949
- if (flow == null || nextName.length == 0) return false;
5950
- if (flow.name == nextName) return true;
5951
6276
  this.#set({ busy: "flow" });
5952
- let changed;
5953
6277
  try {
5954
- changed = await this.#client.renameFlow(flowId, nextName);
5955
- if (changed != null) this.#flows.include(changed);
5956
- } catch (error) {
5957
- if (!this.#disposed) this.#setNotice(errorNotice(error, this.#i18n.t));
6278
+ return await this.#flows.rename(flowId, name);
6279
+ } finally {
6280
+ this.#set({ busy: void 0 });
5958
6281
  }
5959
- this.#set({ busy: void 0 });
5960
- if (changed == null) return false;
5961
- this.#setNotice({
5962
- kind: "success",
5963
- message: this.#i18n.t("notice.flowRenamed", { name: nextName })
5964
- });
5965
- return true;
5966
6282
  }
5967
6283
  async addNode(option, position, connection) {
5968
6284
  if (!await this.saveModuleEditor()) return;
@@ -5971,25 +6287,12 @@ var WorkspaceStore = class {
5971
6287
  const nodeId = this.#identity();
5972
6288
  if (option.kind == "comment") return await this.#addComment(nodeId, position);
5973
6289
  const revision = revisionView(draft);
5974
- let intent = addNodeIntent(option, revision, this.#i18n.t);
6290
+ const intent = addNodeIntent(option, revision, this.#i18n.t);
5975
6291
  if (intent == null) return;
5976
- if (intent.kind == "provider-trigger" && intent.connectionId == null) {
5977
- try {
5978
- const connections = await resourceValue(this.catalogs.connections.get(intent.definition.provider, draft.flowId));
5979
- const allowed = this.filterTriggerConnections == null ? connections : await this.filterTriggerConnections(draft.flowId, intent.definition, connections);
5980
- intent = {
5981
- ...intent,
5982
- connectionId: connectionCatalog(allowed).preferred?.connectionId
5983
- };
5984
- } catch (error) {
5985
- if (!this.#disposed && this.#model.value.draft == draft) this.#setNotice(errorNotice(error, this.#i18n.t));
5986
- }
5987
- if (this.#disposed || this.#model.value.draft != draft) return;
5988
- }
5989
6292
  const edge = connection?.(nodeId);
5990
6293
  const nodeChanges = addNode(revision, nodeId, intent);
5991
6294
  if (nodeChanges == null) return;
5992
- const changes = edge == null ? nodeChanges : [...nodeChanges, ...connect(applyFlowChanges(draft, nodeChanges).content, {
6295
+ const changes = edge == null ? nodeChanges : [...nodeChanges, ...connect(applyFlowChanges$1(draft, nodeChanges).content, {
5993
6296
  source: edge.source,
5994
6297
  target: edge.target,
5995
6298
  ...edge.sourceHandle.startsWith("$branch:") ? { sourceHandle: edge.sourceHandle.slice(8) } : {}
@@ -6000,8 +6303,28 @@ var WorkspaceStore = class {
6000
6303
  nodeId,
6001
6304
  requestId: ++this.#nodeFocusId
6002
6305
  } });
6306
+ if (intent.kind == "provider-trigger" && intent.connectionId == null) this.#configureAddedTrigger(draft.flowId, nodeId, intent.definition);
6003
6307
  return nodeId;
6004
6308
  }
6309
+ async #configureAddedTrigger(flowId, nodeId, definition) {
6310
+ const current = this.#draftSession.capture();
6311
+ const original = this.$.revision.value?.graph().nodes[nodeId];
6312
+ const unchanged = () => current() && !this.#disposed && this.$.revision.value?.graph().nodes[nodeId] === original;
6313
+ try {
6314
+ const connections = await resourceValue(this.catalogs.connections.get(definition.provider, flowId));
6315
+ if (!unchanged()) return;
6316
+ const allowed = this.filterTriggerConnections == null ? connections : await this.filterTriggerConnections(flowId, definition, connections);
6317
+ if (!unchanged()) return;
6318
+ const connection = connectionCatalog(allowed).preferred;
6319
+ if (connection == null) return;
6320
+ const revision = this.$.revision.value;
6321
+ if (revision == null) return;
6322
+ const changes = setTriggerConnection(revision, nodeId, connection.connectionId);
6323
+ if (changes != null && this.#history.completeNodeCreation(nodeId, changes)) await this.#changeDraft(changes, false, "canvas");
6324
+ } catch (error) {
6325
+ if (unchanged()) this.#setNotice(errorNotice(error, this.#i18n.t));
6326
+ }
6327
+ }
6005
6328
  async connect(edge) {
6006
6329
  const revision = this.$.revision.value;
6007
6330
  if (revision == null) return;
@@ -6039,168 +6362,19 @@ var WorkspaceStore = class {
6039
6362
  copySelectedNodes() {
6040
6363
  const revision = this.$.revision.value;
6041
6364
  if (revision == null || this.#model.value.selectedNodeIds.length == 0) return;
6042
- const selected = new Set(this.#model.value.selectedNodeIds);
6043
- this.#clipboard = {
6044
- hiddenNodeIds: this.#designer().nodes.flatMap((node) => node.contentHidden && selected.has(node.id) ? [node.id] : []),
6045
- comments: this.#designer().nodes.flatMap((node) => node.kind == "comment" && selected.has(node.id) ? [{
6046
- content: node.content,
6047
- position: node.position,
6048
- sourceId: node.id,
6049
- title: node.title
6050
- }] : []),
6051
- nodes: copyNodes(revision, this.#model.value.selectedNodeIds)
6052
- };
6365
+ this.#clipboard.copy(revision, this.#designer(), this.#model.value.selectedNodeIds);
6053
6366
  }
6054
- async pasteNodes(sourcePositions, offset = PASTE_OFFSET) {
6367
+ async pasteNodes(sourcePositions, offset) {
6055
6368
  if (!await this.saveModuleEditor()) return;
6056
6369
  const revision = this.$.revision.value;
6057
- if (revision == null || this.#clipboard == null) return;
6058
- const hiddenNodeIds = new Set(this.#clipboard.hiddenNodeIds);
6059
- const pasted = pasteNodes(revision, this.#clipboard.nodes, this.#identity);
6060
- const comments = this.#clipboard.comments.map((comment) => ({
6061
- ...comment,
6062
- nodeId: this.#identity()
6063
- }));
6064
- if (pasted.nodeIds.length == 0 && comments.length == 0) return;
6065
- const designerNodes = new Map(this.#designer().nodes.map((node) => [node.id, node]));
6066
- const added = /* @__PURE__ */ new Set([...pasted.nodeIds, ...comments.map((comment) => comment.nodeId)]);
6067
- const occupied = new Set([...designerNodes].filter(([nodeId]) => !added.has(nodeId)).map(([, node]) => `${node.position.x}\0${node.position.y}`));
6068
- const sources = [...pasted.sourceIds.map((sourceId) => sourcePositions?.[sourceId] ?? designerNodes.get(sourceId)?.position ?? {
6069
- x: 80,
6070
- y: 80
6071
- }), ...comments.map((comment) => comment.position)];
6072
- let step = 1;
6073
- if (offset.x != 0 || offset.y != 0) while (sources.some((source) => occupied.has(`${source.x + offset.x * step}\0${source.y + offset.y * step}`))) step += 1;
6074
- const positions = Object.fromEntries(pasted.sourceIds.map((sourceId, index) => {
6075
- const source = sourcePositions?.[sourceId] ?? designerNodes.get(sourceId)?.position;
6076
- return [pasted.nodeIds[index], {
6077
- x: (source?.x ?? 80) + offset.x * step,
6078
- y: (source?.y ?? 80) + offset.y * step
6079
- }];
6080
- }));
6081
- await this.#canvasChange("paste", added.size, pasted.changes, (value) => {
6082
- let next = setNodePositions(value, positions);
6083
- for (const [index, sourceId] of pasted.sourceIds.entries()) if (hiddenNodeIds.has(sourceId)) next = setNodeContentHidden(next, pasted.nodeIds[index], true);
6084
- for (const comment of comments) {
6085
- if (hiddenNodeIds.has(comment.sourceId)) next = setNodeContentHidden(next, comment.nodeId, true);
6086
- next = setComment(next, comment.nodeId, {
6087
- content: comment.content,
6088
- position: {
6089
- x: comment.position.x + offset.x * step,
6090
- y: comment.position.y + offset.y * step
6091
- },
6092
- title: this.#i18n.t("addNode.commentCopy", { title: comment.title })
6093
- });
6094
- }
6095
- return next;
6096
- }, [...pasted.nodeIds, ...comments.map((comment) => comment.nodeId)]);
6370
+ if (revision == null) return;
6371
+ const pasted = this.#clipboard.paste(revision, this.#designer(), sourcePositions, offset);
6372
+ if (pasted != null) await this.#canvasChange("paste", pasted.nodeIds.length, pasted.changes, pasted.update, pasted.nodeIds);
6097
6373
  }
6098
6374
  async duplicateSelectedNodes(positions, offset) {
6099
6375
  this.copySelectedNodes();
6100
6376
  await this.pasteNodes(positions, offset);
6101
6377
  }
6102
- async saveErrorSources(nodeId, value) {
6103
- const node = this.$.revision.value?.graph()?.nodes[nodeId];
6104
- if (node?.kind != "error" || dequal$1(node.sourceFlowIds ?? [], value)) return false;
6105
- return await this.#editDraft([{
6106
- kind: "graph.trigger.sources.set",
6107
- nodeId,
6108
- before: node.sourceFlowIds,
6109
- value: value.length == 0 ? void 0 : value
6110
- }]) != null;
6111
- }
6112
- async saveNodeSettings(nodeId, settings) {
6113
- const revision = this.$.revision.value;
6114
- if (revision == null) return false;
6115
- const changes = updateNodeSettings(revision, nodeId, settings);
6116
- return changes != null && await this.#editDraft(changes) != null;
6117
- }
6118
- async saveNodeDescription(nodeId, description) {
6119
- const revision = this.$.revision.value;
6120
- if (revision == null) return false;
6121
- const changes = updateNodeDescription(revision, nodeId, description);
6122
- return changes != null && await this.#editDraft(changes) != null;
6123
- }
6124
- async saveNodeIcon(nodeId, icon) {
6125
- const revision = this.$.revision.value;
6126
- if (revision == null) return false;
6127
- const changes = updateNodeIcon(revision, nodeId, icon);
6128
- return changes != null && await this.#editDraft(changes) != null;
6129
- }
6130
- async saveNodeTitle(nodeId, title) {
6131
- const revision = this.$.revision.value;
6132
- if (revision == null) return false;
6133
- const changes = updateNodeName(revision, nodeId, title);
6134
- return changes != null && await this.#editDraft(changes) != null;
6135
- }
6136
- async setInputValue(nodeId, handle, value, deletion) {
6137
- const revision = this.$.revision.value;
6138
- if (revision == null) return false;
6139
- const changes = setInputValue(revision, nodeId, handle, value);
6140
- return changes != null && await this.#editDraft(changes, deletion) != null;
6141
- }
6142
- async resetInputs(nodeId, handles) {
6143
- const revision = this.$.revision.value;
6144
- if (revision == null) return false;
6145
- return await this.#editDraft(resetInputValues(revision.revision.content, nodeId, handles)) != null;
6146
- }
6147
- async saveOutputsDefs(nodeId, definitions, deletion, values) {
6148
- const revision = this.$.revision.value;
6149
- if (revision == null || revision.graph().nodes[nodeId]?.kind != "outputs") return false;
6150
- return await this.#editDraft(updateOutputPorts(revision, nodeId, definitions, values), deletion) != null;
6151
- }
6152
- async saveStartInputDefs(nodeId, inputDefs, deletion) {
6153
- const revision = this.$.revision.value;
6154
- if (revision == null || revision.graph().nodes[nodeId]?.kind != "start") return false;
6155
- const changes = updateStartInputDefs(revision.revision.content, nodeId, inputDefs);
6156
- return await this.#editDraft(changes, deletion) != null;
6157
- }
6158
- async resetTriggerConfig(triggerId, names) {
6159
- const revision = this.$.revision.value;
6160
- if (revision == null) return false;
6161
- const trigger = revision.graph()?.nodes[triggerId];
6162
- if (trigger?.kind !== "poll" && trigger?.kind !== "integration") return false;
6163
- const changes = (names == null ? Object.entries(trigger.config) : names.flatMap((name) => Object.hasOwn(trigger.config, name) ? [[name, trigger.config[name]]] : [])).map(([name, before]) => ({
6164
- kind: "graph.trigger.config.set",
6165
- nodeId: triggerId,
6166
- name,
6167
- before,
6168
- value: void 0
6169
- }));
6170
- return await this.#editDraft(changes) != null;
6171
- }
6172
- async setInputSource(nodeId, handle, source) {
6173
- const revision = this.$.revision.value;
6174
- if (revision == null) return false;
6175
- return await this.#editDraft(setInputSources(revision.revision.content, nodeId, handle, [{
6176
- kind: "node",
6177
- ...source
6178
- }])) != null;
6179
- }
6180
- async setInputVariable(nodeId, handle, name) {
6181
- const revision = this.$.revision.value;
6182
- if (revision == null) return false;
6183
- const changes = name == null ? setInputValue(revision, nodeId, handle, void 0) : setInputVariable(revision, nodeId, handle, name, this.#identity());
6184
- return changes != null && await this.#editDraft(changes) != null;
6185
- }
6186
- async saveCondition(nodeId, settings, deletion) {
6187
- const revision = this.$.revision.value;
6188
- if (revision == null) return false;
6189
- const changes = updateCondition(revision, nodeId, settings);
6190
- return changes != null && await this.#editDraft(changes, deletion) != null;
6191
- }
6192
- async saveValue(nodeId, values, deletion) {
6193
- const revision = this.$.revision.value;
6194
- if (revision == null) return false;
6195
- const changes = updateValue(revision, nodeId, values);
6196
- return changes != null && await this.#editDraft(changes, deletion) != null;
6197
- }
6198
- async saveResolution(nodeId, settings, deletion, values) {
6199
- const revision = this.$.revision.value;
6200
- if (revision == null) return false;
6201
- const changes = updateResolution(revision, nodeId, settings, values);
6202
- return changes != null && await this.#editDraft(changes, deletion) != null;
6203
- }
6204
6378
  async saveNodeContentHidden(nodeId, hidden) {
6205
6379
  const node = this.#designer().nodes.find((candidate) => candidate.id == nodeId);
6206
6380
  if (node == null || node.kind == "condition") return;
@@ -6237,42 +6411,6 @@ var WorkspaceStore = class {
6237
6411
  loadOpenApiDocument(url, signal) {
6238
6412
  return this.#client.loadOpenApiDocument(url, signal);
6239
6413
  }
6240
- async saveTaskSettings(nodeId, settings, deletion) {
6241
- const revision = this.$.revision.value;
6242
- if (revision == null) return false;
6243
- const changes = updateTask(revision, nodeId, settings);
6244
- return changes != null && await this.#editDraft(changes, deletion) != null;
6245
- }
6246
- async saveTaskPorts(nodeId, ports, deletion, values) {
6247
- const revision = this.$.revision.value;
6248
- if (revision == null) return false;
6249
- const changes = updateTaskPorts(revision, nodeId, ports, values);
6250
- return changes != null && await this.#editDraft(changes, deletion) != null;
6251
- }
6252
- async saveTaskAdditionalInputs(nodeId, inputs, deletion, values) {
6253
- const revision = this.$.revision.value;
6254
- if (revision == null) return false;
6255
- const changes = updateTaskAdditionalInputs(revision, nodeId, inputs, values);
6256
- return changes != null && await this.#editDraft(changes, deletion) != null;
6257
- }
6258
- async setConnectorConnection(nodeId, connectionId) {
6259
- const revision = this.$.revision.value;
6260
- if (revision == null) return false;
6261
- const changes = setConnectorConnection(revision.revision.content, nodeId, connectionId);
6262
- return changes != null && await this.#editDraft(changes) != null;
6263
- }
6264
- async setServiceConnections(providerId, connectionId, previousConnectionId) {
6265
- const revision = this.$.revision.value;
6266
- if (revision == null) return false;
6267
- const changes = setServiceConnections(revision.revision.content, providerId, connectionId, previousConnectionId);
6268
- return changes.length == 0 || await this.#editDraft(changes) != null;
6269
- }
6270
- async setCodeActions(nodeId, capabilities) {
6271
- const revision = this.$.revision.value;
6272
- if (revision == null) return false;
6273
- const changes = setCodeActions(revision.revision.content, nodeId, capabilities);
6274
- return changes == null || await this.#editDraft(changes) != null;
6275
- }
6276
6414
  get eventSourceClient() {
6277
6415
  return this.#client;
6278
6416
  }
@@ -6281,22 +6419,6 @@ var WorkspaceStore = class {
6281
6419
  if (flowId == null) throw new Error("No Flow selected");
6282
6420
  return await this.#client.listEventSources(flowId, signal);
6283
6421
  }
6284
- async setTriggerEventSource(triggerId, source) {
6285
- const revision = this.$.revision.value;
6286
- if (revision == null) return false;
6287
- const trigger = revision.graph()?.nodes[triggerId];
6288
- if (trigger?.kind != "integration" || trigger.definition.key != "feishu_app_bot.on_event" || source.provider != trigger.definition.provider) return false;
6289
- const connectionChanges = setTriggerConnection(revision.revision.content, triggerId, source.connectionId);
6290
- if (connectionChanges == null) return false;
6291
- const changed = inputValue(trigger.config.sourceId, void 0) != source.sourceId;
6292
- return await this.#editDraft([
6293
- ...connectionChanges,
6294
- ...updateTriggerConfig(revision.revision.content, triggerId, "sourceId", source.sourceId) ?? [],
6295
- ...changed ? updateTriggerConfig(revision.revision.content, triggerId, "eventTypes", void 0) ?? [] : [],
6296
- ...changed ? updateTriggerConfig(revision.revision.content, triggerId, "resource", void 0) ?? [] : [],
6297
- ...changed ? updateTriggerConfig(revision.revision.content, triggerId, "chatIds", void 0) ?? [] : []
6298
- ]) != null;
6299
- }
6300
6422
  async loadTriggerConfigOptions(triggerId, field, signal) {
6301
6423
  const flowId = this.#model.value.flowId;
6302
6424
  const current = this.#draftSession.capture();
@@ -6305,42 +6427,6 @@ var WorkspaceStore = class {
6305
6427
  if (this.#disposed || !current() || flowId == null) throw new DOMException("Draft changed", "AbortError");
6306
6428
  return await this.#client.listTriggerConfigOptions(flowId, triggerId, field, signal);
6307
6429
  }
6308
- async saveTriggerConfig(triggerId, name, value) {
6309
- const revision = this.$.revision.value;
6310
- if (revision == null) return false;
6311
- let changes = updateTriggerConfig(revision.revision.content, triggerId, name, value);
6312
- if (changes == null) return false;
6313
- const trigger = revision.graph()?.nodes[triggerId];
6314
- if (changes.length > 0 && trigger?.kind == "integration" && trigger.definition.key == "feishu_app_bot.on_event" && name == "eventTypes") {
6315
- const events = Array.isArray(value) ? value.filter((item) => typeof item == "string") : [];
6316
- if (!supportsFeishuChatFilter(events)) changes = [...changes, ...updateTriggerConfig(revision.revision.content, triggerId, "chatIds", void 0) ?? []];
6317
- const resource = inputValue(trigger.config.resource, void 0);
6318
- if (isJsonObject(resource) && resource.kind != feishuResourceKind(events)) changes = [...changes, ...updateTriggerConfig(revision.revision.content, triggerId, "resource", void 0) ?? []];
6319
- }
6320
- if (changes.length > 0 && trigger?.kind == "poll" && trigger.definition.key == "linear.on_issue_changed" && name == "teamId") return await this.#editDraft([...changes, ...updateTriggerConfig(revision.revision.content, triggerId, "stateIds", void 0) ?? []]) != null;
6321
- return await this.#editDraft(changes) != null;
6322
- }
6323
- async saveTriggerSchedule(triggerId, schedule) {
6324
- const revision = this.$.revision.value;
6325
- if (revision == null) return false;
6326
- const changes = updateTriggerSchedule(revision.revision.content, triggerId, schedule);
6327
- return changes != null && await this.#editDraft(changes) != null;
6328
- }
6329
- async saveWebhook(triggerId, settings, deletion) {
6330
- const revision = this.$.revision.value;
6331
- if (revision == null) return false;
6332
- const changes = updateWebhook(revision, triggerId, settings);
6333
- return changes != null && await this.#editDraft(changes, deletion) != null;
6334
- }
6335
- async setTriggerConnection(triggerId, connectionId) {
6336
- const revision = this.$.revision.value;
6337
- if (revision == null) return false;
6338
- const changes = setTriggerConnection(revision.revision.content, triggerId, connectionId);
6339
- if (changes == null) return false;
6340
- const trigger = revision.graph()?.nodes[triggerId];
6341
- if (changes.length > 0 && trigger?.kind == "poll" && trigger.definition.key == "linear.on_issue_changed") return await this.#editDraft([...changes, ...["teamId", "stateIds"].flatMap((field) => updateTriggerConfig(revision.revision.content, triggerId, field, void 0) ?? [])]) != null;
6342
- return await this.#editDraft(changes) != null;
6343
- }
6344
6430
  updateModuleSource(source) {
6345
6431
  const editor = this.#model.value.moduleEditor;
6346
6432
  if (this.#history.applying || this.#history.failed || editor == null || editor.source == source) return;
@@ -6411,9 +6497,6 @@ var WorkspaceStore = class {
6411
6497
  }), [nodeId]) || this.#disposed) return;
6412
6498
  return nodeId;
6413
6499
  }
6414
- async #editDraft(changes, deletion) {
6415
- return await this.#canvasChange("edit", 1, changes, void 0, void 0, deletion) ? this.#model.value.draft : void 0;
6416
- }
6417
6500
  #notifyDeletion(deletion, entry) {
6418
6501
  this.#setNotice({
6419
6502
  kind: "success",
@@ -6432,7 +6515,7 @@ var WorkspaceStore = class {
6432
6515
  const flowId = this.#model.value.flowId;
6433
6516
  const draft = this.#model.value.draft;
6434
6517
  if (flowId == null || draft == null) return;
6435
- if (changes.length == 0 || dequal$1(applyFlowChanges(draft, changes).content, draft.content)) return draft;
6518
+ if (changes.length == 0 || dequal$1(applyFlowChanges$1(draft, changes).content, draft.content)) return draft;
6436
6519
  const cleared = historyMode == "clear" && this.#history.clear();
6437
6520
  const current = this.#draftSession.capture();
6438
6521
  this.#history.pending++;
@@ -6526,7 +6609,7 @@ var WorkspaceStore = class {
6526
6609
  if (draft == null || presentation == null) return false;
6527
6610
  const next = update?.(presentation.value) ?? presentation.value;
6528
6611
  const presentationChange = canvasPresentationChange(presentation.value, next);
6529
- if (dequal$1(applyFlowChanges(draft, changes).content, draft.content) && presentationChange.nodeIds.length == 0) return true;
6612
+ if (dequal$1(applyFlowChanges$1(draft, changes).content, draft.content) && presentationChange.nodeIds.length == 0) return true;
6530
6613
  const generation = this.#history.generation;
6531
6614
  const inverse = inverseFlowChanges(draft.content, changes);
6532
6615
  this.#history.pending++;
@@ -6943,6 +7026,23 @@ var WorkbenchStore = class {
6943
7026
  dismissNotice() {
6944
7027
  if (!this.#disposed) this.#notice.set(void 0);
6945
7028
  }
7029
+ async exportSvg(language, options) {
7030
+ const model = this.$.designer.value;
7031
+ const title = this.workspace.$.flow.value?.name ?? this.workspace.$.flowId.value ?? "Workflow";
7032
+ try {
7033
+ const { downloadFlowSvg } = await import("./exportSvg-Cj6Spxx-.js");
7034
+ await downloadFlowSvg(model, title, language, options);
7035
+ if (!this.#disposed) this.#notice.set({
7036
+ kind: "success",
7037
+ message: this.#i18n.t("resource.exportSvgComplete")
7038
+ });
7039
+ } catch {
7040
+ if (!this.#disposed) this.#notice.set({
7041
+ kind: "error",
7042
+ message: this.#i18n.t("resource.exportSvgFailed")
7043
+ });
7044
+ }
7045
+ }
6946
7046
  invalidateVariableNames() {
6947
7047
  this.#variableNamesStale = true;
6948
7048
  }
@@ -7075,7 +7175,7 @@ var WorkbenchStore = class {
7075
7175
  const executor = "executor" in node.node.task ? node.node.task.executor : void 0;
7076
7176
  if (executor?.kind != "connector" || executor.action != action.actionId || executor.connectionId != null) return;
7077
7177
  const connection = prepared.action.defaultConnection;
7078
- if (connection != null) await this.workspace.setConnectorConnection(node.id, connection.connectionId);
7178
+ if (connection != null) await this.workspace.nodes.setConnectorConnection(node.id, connection.connectionId);
7079
7179
  if (!this.#disposed && flowId == this.workspace.$.flowId.value) await this.connectors.refresh();
7080
7180
  } catch (error) {
7081
7181
  if (!this.#disposed && flowId == this.workspace.$.flowId.value) this.#notice.set(errorNotice(error, this.#i18n.t));
@@ -7184,7 +7284,7 @@ var WorkbenchStore = class {
7184
7284
  };
7185
7285
  //#endregion
7186
7286
  //#region src/workbench/browser/runtime/openFlowWorkbench.tsx
7187
- var FlowWorkspace = lazy(() => import("./flowWorkspace-C1hlTnZq.js"));
7287
+ var FlowWorkspace = lazy(() => import("./flowWorkspace-CB1QACku.js"));
7188
7288
  function OpenFlowSessionGate({ action, description, error, onSubmit, onTokenChange, pending = false, title, token, tokenLabel }) {
7189
7289
  const hasToken = token != null && tokenLabel != null && onTokenChange != null;
7190
7290
  const tokenValue = token ?? "";