@widgetic/workflows 0.2.0 → 0.2.2

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 (36) hide show
  1. package/README.md +28 -5
  2. package/dist/api/types.d.ts +55 -1
  3. package/dist/api/workflowsApi.d.ts +47 -1
  4. package/dist/api/workflowsApi.js +179 -1
  5. package/dist/components/Workflows.svelte +2 -0
  6. package/dist/components/WorkflowsWorkspace.svelte +3 -0
  7. package/dist/components/WorkflowsWorkspace.svelte.d.ts +1 -0
  8. package/dist/components/editor/ConflictBanner.svelte +78 -0
  9. package/dist/components/editor/ConflictBanner.svelte.d.ts +3 -0
  10. package/dist/components/editor/EditorBanners.svelte +9 -11
  11. package/dist/components/editor/PresenceBanner.svelte +126 -0
  12. package/dist/components/editor/PresenceBanner.svelte.d.ts +3 -0
  13. package/dist/components/editor/SettingsTab.svelte +19 -11
  14. package/dist/components/editor/WorkflowEditor.svelte +14 -1
  15. package/dist/components/editor/WorkflowEditor.svelte.d.ts +2 -0
  16. package/dist/components/list/CreateWorkflowDialog.svelte +140 -14
  17. package/dist/components/list/WorkflowRow.svelte +8 -6
  18. package/dist/components/panel/VersionHistory.svelte +1 -1
  19. package/dist/editor/apiErrorText.js +10 -0
  20. package/dist/editor/deleteWords.d.ts +39 -0
  21. package/dist/editor/deleteWords.js +28 -0
  22. package/dist/editor/editLeaseController.d.ts +162 -0
  23. package/dist/editor/editLeaseController.js +459 -0
  24. package/dist/editor/editorState.svelte.d.ts +62 -5
  25. package/dist/editor/editorState.svelte.js +155 -6
  26. package/dist/editor/keepCopy.d.ts +41 -0
  27. package/dist/editor/keepCopy.js +52 -0
  28. package/dist/editor/listState.svelte.d.ts +39 -3
  29. package/dist/editor/listState.svelte.js +80 -1
  30. package/dist/editor/presetChoice.d.ts +26 -0
  31. package/dist/editor/presetChoice.js +32 -0
  32. package/dist/i18n/language.d.ts +3 -3
  33. package/dist/i18n/messages.d.ts +55 -2
  34. package/dist/i18n/messages.js +60 -3
  35. package/dist/types/index.d.ts +10 -0
  36. package/package.json +1 -1
@@ -4,14 +4,16 @@ import type { CompositionOption, WorkflowDetail, WorkflowStateAction, WorkflowVe
4
4
  import type { WorkflowsMessageKey } from '../i18n/messages.js';
5
5
  import type { WorkflowsError } from '../types/index.js';
6
6
  import { type SaveState } from './autosave.js';
7
+ import { type EditLeaseControllerOptions, type PresenceState } from './editLeaseController.js';
7
8
  import { type BlockRequest } from './graphModel.js';
9
+ import { type KeptCopy } from './keepCopy.js';
8
10
  import { type TestRunState } from './testRun.js';
9
11
  /** The tabs of an open workflow. */
10
12
  export type EditorTab = 'editor' | 'runs' | 'settings';
11
13
  /** What the side panel shows next to the canvas. */
12
14
  export type PanelMode = 'selection' | 'history' | 'test';
13
15
  /** Something the person is waiting for. */
14
- export type BusyKind = 'publishing' | 'discarding' | 'restoring' | 'changingState' | 'duplicating' | 'deleting';
16
+ export type BusyKind = 'publishing' | 'discarding' | 'restoring' | 'changingState' | 'duplicating' | 'deleting' | 'keepingCopy';
15
17
  /** A line the editor says about what just happened: a message of the catalog, so the screen says it in the page's language. */
16
18
  export interface EditorNotice {
17
19
  tone: 'info' | 'problem';
@@ -49,6 +51,13 @@ export interface WorkflowEditorOptions {
49
51
  noticeMilliseconds?: number;
50
52
  /** For tests: the delay before a change is saved. */
51
53
  saveDelayMilliseconds?: number;
54
+ /**
55
+ * Tell who else is editing this workflow and keep this tab's claim on it (a team's workspace). Off unless the page asks:
56
+ * where it is off, nothing is asked of the API and nothing is ever blocked. See `startPresence`.
57
+ */
58
+ presence?: boolean;
59
+ /** For tests: the clock, the timers, the page and the tab id of the presence. */
60
+ presenceOptions?: Omit<EditLeaseControllerOptions, 'port' | 'logger'>;
52
61
  }
53
62
  /**
54
63
  * Everything the open workflow is: what the server says about it, the draft the person is changing, the compositions that
@@ -67,7 +76,7 @@ export declare class WorkflowEditorState {
67
76
  readonly workflowId: string;
68
77
  workflow: WorkflowDetail | null;
69
78
  loadState: "loading" | "ready" | "failed";
70
- loadFailure: "workflows.region.label" | "workflows.header.title" | "workflows.header.subtitle" | "workflows.common.cancel" | "workflows.common.close" | "workflows.common.dismiss" | "workflows.common.loading" | "workflows.empty.title" | "workflows.empty.hint" | "workflows.error.title" | "workflows.error.hint" | "workflows.error.retry" | "workflows.error.generic" | "workflows.error.network" | "workflows.error.timeout" | "workflows.error.server" | "workflows.error.sessionEnded" | "workflows.error.planRestricted" | "workflows.error.notFound" | "workflows.error.revisionChanged" | "workflows.error.archived" | "workflows.error.nothingToPublish" | "workflows.error.nothingToDiscard" | "workflows.error.everPublished" | "workflows.error.wrongState" | "workflows.error.tooManyWorkflows" | "workflows.error.publishBlocked" | "workflows.error.invalidGraph" | "workflows.error.tooManyRequests" | "workflows.list.label" | "workflows.list.newWorkflow" | "workflows.list.searchLabel" | "workflows.list.searchPlaceholder" | "workflows.list.filterLabel" | "workflows.list.filterActive" | "workflows.list.filterAll" | "workflows.list.sortLabel" | "workflows.list.sortCreated" | "workflows.list.sortPublished" | "workflows.list.sortRuns" | "workflows.list.sortName" | "workflows.list.sortAscending" | "workflows.list.sortDescending" | "workflows.list.columnName" | "workflows.list.columnStatus" | "workflows.list.columnRuns" | "workflows.list.columnPublished" | "workflows.list.columnCreated" | "workflows.list.compositionsCount" | "workflows.list.runsCount" | "workflows.list.publishedOn" | "workflows.list.neverPublished" | "workflows.list.never" | "workflows.list.open" | "workflows.list.rowMenu" | "workflows.list.showMore" | "workflows.list.noMatches" | "workflows.list.duplicated" | "workflows.list.deleted" | "workflows.create.title" | "workflows.create.nameLabel" | "workflows.create.namePlaceholder" | "workflows.create.compositionLabel" | "workflows.create.compositionHelp" | "workflows.create.create" | "workflows.create.creating" | "workflows.status.draft" | "workflows.status.live" | "workflows.status.paused" | "workflows.status.archived" | "workflows.status.unpublishedChanges" | "workflows.top.back" | "workflows.top.nameLabel" | "workflows.top.testRun" | "workflows.top.history" | "workflows.top.embedCode" | "workflows.top.publish" | "workflows.top.publishChanges" | "workflows.top.publishing" | "workflows.save.saved" | "workflows.save.saving" | "workflows.save.pending" | "workflows.save.failed" | "workflows.save.conflict" | "workflows.tabs.label" | "workflows.tabs.editor" | "workflows.tabs.runs" | "workflows.tabs.settings" | "workflows.banner.unpublishedChanges" | "workflows.banner.publishChanges" | "workflows.banner.discard" | "workflows.banner.discardTitle" | "workflows.banner.discardMessage" | "workflows.banner.neverPublished" | "workflows.banner.paused" | "workflows.banner.archived" | "workflows.banner.conflict" | "workflows.banner.reload" | "workflows.banner.touchOnly" | "workflows.editor.published" | "workflows.editor.discarded" | "workflows.editor.restored" | "workflows.editor.reloaded" | "workflows.editor.paused" | "workflows.editor.resumed" | "workflows.editor.archived" | "workflows.editor.unarchived" | "workflows.editor.saveFirst" | "workflows.editor.fixProblems" | "workflows.editor.blockLimit" | "workflows.publish.firstTitle" | "workflows.publish.firstMessage" | "workflows.publish.changesTitle" | "workflows.publish.changesMessage" | "workflows.leave.title" | "workflows.leave.message" | "workflows.leave.confirm" | "workflows.canvas.label" | "workflows.canvas.pointIn" | "workflows.canvas.pointOut" | "workflows.toolbar.label" | "workflows.toolbar.addBlock" | "workflows.toolbar.undo" | "workflows.toolbar.redo" | "workflows.toolbar.zoomIn" | "workflows.toolbar.zoomOut" | "workflows.toolbar.fit" | "workflows.addBlock.composition" | "workflows.addBlock.helpComposition" | "workflows.addBlock.condition" | "workflows.addBlock.helpCondition" | "workflows.addBlock.triggerHeading" | "workflows.addBlock.helpInput" | "workflows.addBlock.helpAction" | "workflows.addBlock.helpPageEvent" | "workflows.addBlock.helpScheduled" | "workflows.block.startsHere" | "workflows.block.trigger" | "workflows.block.condition" | "workflows.block.unknown" | "workflows.block.compositionNotChosen" | "workflows.block.compositionLoading" | "workflows.block.compositionUnavailable" | "workflows.block.notPublished" | "workflows.block.numbered" | "workflows.block.problems" | "workflows.panel.label" | "workflows.panel.overviewHeading" | "workflows.panel.overviewHelp" | "workflows.panel.problemsHeading" | "workflows.panel.problemsLabel" | "workflows.panel.noProblems" | "workflows.panel.manyBlocksSelected" | "workflows.panel.connectionSelected" | "workflows.panel.removeBlock" | "workflows.panel.removeBlocks" | "workflows.panel.removeConnection" | "workflows.composition.heading" | "workflows.composition.help" | "workflows.composition.searchLabel" | "workflows.composition.searchPlaceholder" | "workflows.composition.none" | "workflows.composition.alreadyUsed" | "workflows.composition.isStart" | "workflows.composition.makeStart" | "workflows.composition.capabilitiesHeading" | "workflows.composition.capabilityInput" | "workflows.composition.capabilityAction" | "workflows.composition.capabilityWebsites" | "workflows.composition.inputTables" | "workflows.composition.actionCount" | "workflows.trigger.heading" | "workflows.trigger.help" | "workflows.trigger.kindLabel" | "workflows.trigger.kindInput" | "workflows.trigger.kindAction" | "workflows.trigger.kindPageEvent" | "workflows.trigger.kindScheduled" | "workflows.trigger.unavailable" | "workflows.trigger.tableLabel" | "workflows.trigger.tableHelp" | "workflows.trigger.actionLabel" | "workflows.trigger.actionHelp" | "workflows.trigger.chooseOne" | "workflows.trigger.notFound" | "workflows.trigger.readableValues" | "workflows.trigger.noReadableValues" | "workflows.trigger.nextLabel" | "workflows.trigger.nextHelp" | "workflows.trigger.nextNone" | "workflows.trigger.summaryInput" | "workflows.trigger.summaryAction" | "workflows.trigger.summaryPageEvent" | "workflows.trigger.summaryAt" | "workflows.trigger.summaryUnfinished" | "workflows.reason.widgetKeepsNoData" | "workflows.reason.widgetReportsNoActions" | "workflows.reason.widgetNotPublished" | "workflows.schedule.modeLabel" | "workflows.schedule.modeAfter" | "workflows.schedule.modeAt" | "workflows.schedule.afterHelp" | "workflows.schedule.amountLabel" | "workflows.schedule.unitLabel" | "workflows.schedule.unitSeconds" | "workflows.schedule.unitMinutes" | "workflows.schedule.unitHours" | "workflows.schedule.unitDays" | "workflows.schedule.unitWeeks" | "workflows.schedule.waitSeconds" | "workflows.schedule.waitMinutes" | "workflows.schedule.waitHours" | "workflows.schedule.waitDays" | "workflows.schedule.waitWeeks" | "workflows.schedule.momentLabel" | "workflows.schedule.momentHelp" | "workflows.schedule.invalidMoment" | "workflows.event.nameLabel" | "workflows.event.namePlaceholder" | "workflows.event.nameHelp" | "workflows.event.nameInvalid" | "workflows.event.howToSend" | "workflows.event.valuesHeading" | "workflows.event.valuesHelp" | "workflows.event.addValue" | "workflows.event.valueName" | "workflows.event.valueNamePlaceholder" | "workflows.event.valueNameInvalid" | "workflows.event.valueType" | "workflows.event.removeValue" | "workflows.fieldType.text" | "workflows.fieldType.number" | "workflows.fieldType.boolean" | "workflows.value.yes" | "workflows.value.no" | "workflows.condition.heading" | "workflows.condition.help" | "workflows.condition.noTrigger" | "workflows.condition.noValues" | "workflows.condition.addRule" | "workflows.condition.ruleLimit" | "workflows.condition.defaultName" | "workflows.condition.defaultLabel" | "workflows.condition.defaultStay" | "workflows.condition.defaultHelp" | "workflows.condition.defaultHint" | "workflows.condition.defaultStays" | "workflows.rule.defaultName" | "workflows.rule.nameLabel" | "workflows.rule.moveUp" | "workflows.rule.moveDown" | "workflows.rule.remove" | "workflows.rule.matchLabel" | "workflows.rule.matchAll" | "workflows.rule.matchAny" | "workflows.rule.noTests" | "workflows.rule.addTest" | "workflows.rule.testLimit" | "workflows.rule.thenGoTo" | "workflows.rule.testWithValue" | "workflows.rule.testWithoutValue" | "workflows.rule.testAndMore" | "workflows.test.field" | "workflows.test.operator" | "workflows.test.value" | "workflows.test.valuePlaceholder" | "workflows.test.remove" | "workflows.operator.is" | "workflows.operator.isNot" | "workflows.operator.contains" | "workflows.operator.doesNotContain" | "workflows.operator.startsWith" | "workflows.operator.endsWith" | "workflows.operator.greaterThan" | "workflows.operator.atLeast" | "workflows.operator.lessThan" | "workflows.operator.atMost" | "workflows.operator.isEmpty" | "workflows.operator.isNotEmpty" | "workflows.test.heading" | "workflows.test.help" | "workflows.test.close" | "workflows.test.start" | "workflows.test.restart" | "workflows.test.ended" | "workflows.test.noStart" | "workflows.test.noTriggers" | "workflows.test.visitorIsOn" | "workflows.test.fire" | "workflows.test.resultMoved" | "workflows.test.resultStayed" | "workflows.test.resultIgnored" | "workflows.history.heading" | "workflows.history.help" | "workflows.history.close" | "workflows.history.none" | "workflows.history.failed" | "workflows.history.version" | "workflows.history.live" | "workflows.history.by" | "workflows.history.view" | "workflows.history.viewing" | "workflows.history.backToDraft" | "workflows.history.restore" | "workflows.history.restoreTitle" | "workflows.history.restoreMessage" | "workflows.runs.help" | "workflows.runs.rangeLabel" | "workflows.runs.lastDays" | "workflows.runs.versionLabel" | "workflows.runs.allVersions" | "workflows.runs.versionLive" | "workflows.runs.started" | "workflows.runs.entered" | "workflows.runs.fired" | "workflows.runs.failed" | "workflows.runs.none" | "workflows.runs.neverPublished" | "workflows.settings.zoneHeading" | "workflows.settings.zoneLabel" | "workflows.settings.zoneHelp" | "workflows.settings.embedHeading" | "workflows.settings.embedHelp" | "workflows.settings.stateHeading" | "workflows.settings.pause" | "workflows.settings.pauseHelp" | "workflows.settings.resume" | "workflows.settings.resumeHelp" | "workflows.settings.archive" | "workflows.settings.archiveHelp" | "workflows.settings.archiveTitle" | "workflows.settings.archiveMessage" | "workflows.settings.unarchive" | "workflows.settings.unarchiveHelp" | "workflows.settings.duplicate" | "workflows.settings.duplicateHelp" | "workflows.settings.delete" | "workflows.settings.deleteHelp" | "workflows.settings.deleteBlocked" | "workflows.settings.deleteTitle" | "workflows.settings.deleteMessage" | "workflows.issue.unknown" | "workflows.issue.malformed" | "workflows.issue.schemaVersion" | "workflows.issue.graphTooLarge" | "workflows.issue.unknownNodeType" | "workflows.issue.unknownTriggerKind" | "workflows.issue.badId" | "workflows.issue.duplicateId" | "workflows.issue.tooManyBlocks" | "workflows.issue.tooManyEdges" | "workflows.issue.noComposition" | "workflows.issue.noStart" | "workflows.issue.manyStarts" | "workflows.issue.compositionMissingId" | "workflows.issue.duplicateComposition" | "workflows.issue.compositionNotAvailable" | "workflows.issue.compositionWebsiteMismatch" | "workflows.issue.unreachableBlock" | "workflows.issue.edgeUnknownNode" | "workflows.issue.edgeBadPort" | "workflows.issue.edgeInvalidConnection" | "workflows.issue.portManyTargets" | "workflows.issue.cycle" | "workflows.issue.triggerNoSource" | "workflows.issue.triggerManySources" | "workflows.issue.triggerNoTarget" | "workflows.issue.triggerConfigIncomplete" | "workflows.issue.triggerNeedsTable" | "workflows.issue.triggerNeedsAction" | "workflows.issue.triggerNeedsName" | "workflows.issue.scheduleInvalid" | "workflows.issue.eventValueInvalid" | "workflows.issue.eventTooManyValues" | "workflows.issue.triggerCapabilityMissing" | "workflows.issue.triggerInputMissing" | "workflows.issue.triggerActionMissing" | "workflows.issue.conditionNoSource" | "workflows.issue.conditionManySources" | "workflows.issue.conditionNoCases" | "workflows.issue.conditionTooManyCases" | "workflows.issue.caseBadId" | "workflows.issue.caseDuplicateId" | "workflows.issue.caseNoTests" | "workflows.issue.caseTooManyTests" | "workflows.issue.caseNoTarget" | "workflows.issue.testBadField" | "workflows.issue.testBadOperator" | "workflows.issue.testMissingValue" | "workflows.issue.fieldUnknown" | null;
79
+ loadFailure: "workflows.region.label" | "workflows.header.title" | "workflows.header.subtitle" | "workflows.common.cancel" | "workflows.common.close" | "workflows.common.dismiss" | "workflows.common.loading" | "workflows.empty.title" | "workflows.empty.hint" | "workflows.error.title" | "workflows.error.hint" | "workflows.error.retry" | "workflows.error.generic" | "workflows.error.network" | "workflows.error.timeout" | "workflows.error.server" | "workflows.error.sessionEnded" | "workflows.error.planRestricted" | "workflows.error.notFound" | "workflows.error.revisionChanged" | "workflows.error.archived" | "workflows.error.nothingToPublish" | "workflows.error.nothingToDiscard" | "workflows.error.everPublished" | "workflows.error.wrongState" | "workflows.error.tooManyWorkflows" | "workflows.error.presetGone" | "workflows.error.presetCopyFailed" | "workflows.error.stillWorking" | "workflows.error.publishBlocked" | "workflows.error.invalidGraph" | "workflows.error.tooManyRequests" | "workflows.list.label" | "workflows.list.newWorkflow" | "workflows.list.searchLabel" | "workflows.list.searchPlaceholder" | "workflows.list.filterLabel" | "workflows.list.filterActive" | "workflows.list.filterAll" | "workflows.list.sortLabel" | "workflows.list.sortCreated" | "workflows.list.sortPublished" | "workflows.list.sortRuns" | "workflows.list.sortName" | "workflows.list.sortAscending" | "workflows.list.sortDescending" | "workflows.list.columnName" | "workflows.list.columnStatus" | "workflows.list.columnRuns" | "workflows.list.columnPublished" | "workflows.list.columnCreated" | "workflows.list.compositionsCount" | "workflows.list.runsCount" | "workflows.list.publishedOn" | "workflows.list.neverPublished" | "workflows.list.never" | "workflows.list.open" | "workflows.list.rowMenu" | "workflows.list.showMore" | "workflows.list.noMatches" | "workflows.list.duplicated" | "workflows.list.deleted" | "workflows.create.title" | "workflows.create.nameLabel" | "workflows.create.namePlaceholder" | "workflows.create.compositionLabel" | "workflows.create.compositionHelp" | "workflows.create.create" | "workflows.create.creating" | "workflows.create.startLabel" | "workflows.create.blankTitle" | "workflows.create.blankHint" | "workflows.create.presetSummary" | "workflows.create.presetMorePictures" | "workflows.create.presetsLoading" | "workflows.create.presetsFailed" | "workflows.create.presetHelp" | "workflows.create.presetNameHelp" | "workflows.create.settingUp" | "workflows.status.draft" | "workflows.status.live" | "workflows.status.paused" | "workflows.status.archived" | "workflows.status.unpublishedChanges" | "workflows.top.back" | "workflows.top.nameLabel" | "workflows.top.testRun" | "workflows.top.history" | "workflows.top.embedCode" | "workflows.top.publish" | "workflows.top.publishChanges" | "workflows.top.publishing" | "workflows.save.saved" | "workflows.save.saving" | "workflows.save.pending" | "workflows.save.failed" | "workflows.save.conflict" | "workflows.tabs.label" | "workflows.tabs.editor" | "workflows.tabs.runs" | "workflows.tabs.settings" | "workflows.banner.unpublishedChanges" | "workflows.banner.publishChanges" | "workflows.banner.discard" | "workflows.banner.discardTitle" | "workflows.banner.discardMessage" | "workflows.banner.neverPublished" | "workflows.banner.paused" | "workflows.banner.archived" | "workflows.banner.conflict" | "workflows.banner.reload" | "workflows.banner.touchOnly" | "workflows.conflict.keepCopy" | "workflows.conflict.keepingCopy" | "workflows.conflict.copyName" | "workflows.conflict.copyKept" | "workflows.conflict.openCopy" | "workflows.conflict.loadTitle" | "workflows.conflict.loadMessage" | "workflows.presence.blockedTitleNamed" | "workflows.presence.blockedTitleYou" | "workflows.presence.blockedTitle" | "workflows.presence.blockedBody" | "workflows.presence.lostTitleNamed" | "workflows.presence.lostTitleYou" | "workflows.presence.lostTitle" | "workflows.presence.lostBody" | "workflows.presence.takeOver" | "workflows.presence.takeOverHint" | "workflows.presence.lookOnly" | "workflows.presence.lookOnlyHint" | "workflows.presence.working" | "workflows.presence.actionFailed" | "workflows.presence.readOnlyNamed" | "workflows.presence.readOnlyYou" | "workflows.presence.readOnly" | "workflows.presence.readOnlyFree" | "workflows.presence.startEditing" | "workflows.editor.published" | "workflows.editor.discarded" | "workflows.editor.restored" | "workflows.editor.reloaded" | "workflows.editor.paused" | "workflows.editor.resumed" | "workflows.editor.archived" | "workflows.editor.unarchived" | "workflows.editor.saveFirst" | "workflows.editor.fixProblems" | "workflows.editor.blockLimit" | "workflows.publish.firstTitle" | "workflows.publish.firstMessage" | "workflows.publish.changesTitle" | "workflows.publish.changesMessage" | "workflows.leave.title" | "workflows.leave.message" | "workflows.leave.confirm" | "workflows.canvas.label" | "workflows.canvas.pointIn" | "workflows.canvas.pointOut" | "workflows.toolbar.label" | "workflows.toolbar.addBlock" | "workflows.toolbar.undo" | "workflows.toolbar.redo" | "workflows.toolbar.zoomIn" | "workflows.toolbar.zoomOut" | "workflows.toolbar.fit" | "workflows.addBlock.composition" | "workflows.addBlock.helpComposition" | "workflows.addBlock.condition" | "workflows.addBlock.helpCondition" | "workflows.addBlock.triggerHeading" | "workflows.addBlock.helpInput" | "workflows.addBlock.helpAction" | "workflows.addBlock.helpPageEvent" | "workflows.addBlock.helpScheduled" | "workflows.block.startsHere" | "workflows.block.trigger" | "workflows.block.condition" | "workflows.block.unknown" | "workflows.block.compositionNotChosen" | "workflows.block.compositionLoading" | "workflows.block.compositionUnavailable" | "workflows.block.notPublished" | "workflows.block.numbered" | "workflows.block.problems" | "workflows.panel.label" | "workflows.panel.overviewHeading" | "workflows.panel.overviewHelp" | "workflows.panel.problemsHeading" | "workflows.panel.problemsLabel" | "workflows.panel.noProblems" | "workflows.panel.manyBlocksSelected" | "workflows.panel.connectionSelected" | "workflows.panel.removeBlock" | "workflows.panel.removeBlocks" | "workflows.panel.removeConnection" | "workflows.composition.heading" | "workflows.composition.help" | "workflows.composition.searchLabel" | "workflows.composition.searchPlaceholder" | "workflows.composition.none" | "workflows.composition.alreadyUsed" | "workflows.composition.isStart" | "workflows.composition.makeStart" | "workflows.composition.capabilitiesHeading" | "workflows.composition.capabilityInput" | "workflows.composition.capabilityAction" | "workflows.composition.capabilityWebsites" | "workflows.composition.inputTables" | "workflows.composition.actionCount" | "workflows.trigger.heading" | "workflows.trigger.help" | "workflows.trigger.kindLabel" | "workflows.trigger.kindInput" | "workflows.trigger.kindAction" | "workflows.trigger.kindPageEvent" | "workflows.trigger.kindScheduled" | "workflows.trigger.unavailable" | "workflows.trigger.tableLabel" | "workflows.trigger.tableHelp" | "workflows.trigger.actionLabel" | "workflows.trigger.actionHelp" | "workflows.trigger.chooseOne" | "workflows.trigger.notFound" | "workflows.trigger.readableValues" | "workflows.trigger.noReadableValues" | "workflows.trigger.nextLabel" | "workflows.trigger.nextHelp" | "workflows.trigger.nextNone" | "workflows.trigger.summaryInput" | "workflows.trigger.summaryAction" | "workflows.trigger.summaryPageEvent" | "workflows.trigger.summaryAt" | "workflows.trigger.summaryUnfinished" | "workflows.reason.widgetKeepsNoData" | "workflows.reason.widgetReportsNoActions" | "workflows.reason.widgetNotPublished" | "workflows.schedule.modeLabel" | "workflows.schedule.modeAfter" | "workflows.schedule.modeAt" | "workflows.schedule.afterHelp" | "workflows.schedule.amountLabel" | "workflows.schedule.unitLabel" | "workflows.schedule.unitSeconds" | "workflows.schedule.unitMinutes" | "workflows.schedule.unitHours" | "workflows.schedule.unitDays" | "workflows.schedule.unitWeeks" | "workflows.schedule.waitSeconds" | "workflows.schedule.waitMinutes" | "workflows.schedule.waitHours" | "workflows.schedule.waitDays" | "workflows.schedule.waitWeeks" | "workflows.schedule.momentLabel" | "workflows.schedule.momentHelp" | "workflows.schedule.invalidMoment" | "workflows.event.nameLabel" | "workflows.event.namePlaceholder" | "workflows.event.nameHelp" | "workflows.event.nameInvalid" | "workflows.event.howToSend" | "workflows.event.valuesHeading" | "workflows.event.valuesHelp" | "workflows.event.addValue" | "workflows.event.valueName" | "workflows.event.valueNamePlaceholder" | "workflows.event.valueNameInvalid" | "workflows.event.valueType" | "workflows.event.removeValue" | "workflows.fieldType.text" | "workflows.fieldType.number" | "workflows.fieldType.boolean" | "workflows.value.yes" | "workflows.value.no" | "workflows.condition.heading" | "workflows.condition.help" | "workflows.condition.noTrigger" | "workflows.condition.noValues" | "workflows.condition.addRule" | "workflows.condition.ruleLimit" | "workflows.condition.defaultName" | "workflows.condition.defaultLabel" | "workflows.condition.defaultStay" | "workflows.condition.defaultHelp" | "workflows.condition.defaultHint" | "workflows.condition.defaultStays" | "workflows.rule.defaultName" | "workflows.rule.nameLabel" | "workflows.rule.moveUp" | "workflows.rule.moveDown" | "workflows.rule.remove" | "workflows.rule.matchLabel" | "workflows.rule.matchAll" | "workflows.rule.matchAny" | "workflows.rule.noTests" | "workflows.rule.addTest" | "workflows.rule.testLimit" | "workflows.rule.thenGoTo" | "workflows.rule.testWithValue" | "workflows.rule.testWithoutValue" | "workflows.rule.testAndMore" | "workflows.test.field" | "workflows.test.operator" | "workflows.test.value" | "workflows.test.valuePlaceholder" | "workflows.test.remove" | "workflows.operator.is" | "workflows.operator.isNot" | "workflows.operator.contains" | "workflows.operator.doesNotContain" | "workflows.operator.startsWith" | "workflows.operator.endsWith" | "workflows.operator.greaterThan" | "workflows.operator.atLeast" | "workflows.operator.lessThan" | "workflows.operator.atMost" | "workflows.operator.isEmpty" | "workflows.operator.isNotEmpty" | "workflows.test.heading" | "workflows.test.help" | "workflows.test.close" | "workflows.test.start" | "workflows.test.restart" | "workflows.test.ended" | "workflows.test.noStart" | "workflows.test.noTriggers" | "workflows.test.visitorIsOn" | "workflows.test.fire" | "workflows.test.resultMoved" | "workflows.test.resultStayed" | "workflows.test.resultIgnored" | "workflows.history.heading" | "workflows.history.help" | "workflows.history.close" | "workflows.history.none" | "workflows.history.failed" | "workflows.history.version" | "workflows.history.live" | "workflows.history.by" | "workflows.history.view" | "workflows.history.viewing" | "workflows.history.backToDraft" | "workflows.history.restore" | "workflows.history.restoreTitle" | "workflows.history.restoreMessage" | "workflows.runs.help" | "workflows.runs.rangeLabel" | "workflows.runs.lastDays" | "workflows.runs.versionLabel" | "workflows.runs.allVersions" | "workflows.runs.versionLive" | "workflows.runs.started" | "workflows.runs.entered" | "workflows.runs.fired" | "workflows.runs.failed" | "workflows.runs.none" | "workflows.runs.neverPublished" | "workflows.settings.zoneHeading" | "workflows.settings.zoneLabel" | "workflows.settings.zoneHelp" | "workflows.settings.embedHeading" | "workflows.settings.embedHelp" | "workflows.settings.stateHeading" | "workflows.settings.pause" | "workflows.settings.pauseHelp" | "workflows.settings.resume" | "workflows.settings.resumeHelp" | "workflows.settings.archive" | "workflows.settings.archiveHelp" | "workflows.settings.archiveTitle" | "workflows.settings.archiveMessage" | "workflows.settings.unarchive" | "workflows.settings.unarchiveHelp" | "workflows.settings.duplicate" | "workflows.settings.duplicateHelp" | "workflows.settings.delete" | "workflows.settings.deleteHelp" | "workflows.settings.deleteTitle" | "workflows.settings.deleteMessageDraft" | "workflows.settings.deleteMessageLive" | "workflows.settings.deleteMessagePaused" | "workflows.settings.deleteMessageArchived" | "workflows.issue.unknown" | "workflows.issue.malformed" | "workflows.issue.schemaVersion" | "workflows.issue.graphTooLarge" | "workflows.issue.unknownNodeType" | "workflows.issue.unknownTriggerKind" | "workflows.issue.badId" | "workflows.issue.duplicateId" | "workflows.issue.tooManyBlocks" | "workflows.issue.tooManyEdges" | "workflows.issue.noComposition" | "workflows.issue.noStart" | "workflows.issue.manyStarts" | "workflows.issue.compositionMissingId" | "workflows.issue.duplicateComposition" | "workflows.issue.compositionNotAvailable" | "workflows.issue.compositionWebsiteMismatch" | "workflows.issue.unreachableBlock" | "workflows.issue.edgeUnknownNode" | "workflows.issue.edgeBadPort" | "workflows.issue.edgeInvalidConnection" | "workflows.issue.portManyTargets" | "workflows.issue.cycle" | "workflows.issue.triggerNoSource" | "workflows.issue.triggerManySources" | "workflows.issue.triggerNoTarget" | "workflows.issue.triggerConfigIncomplete" | "workflows.issue.triggerNeedsTable" | "workflows.issue.triggerNeedsAction" | "workflows.issue.triggerNeedsName" | "workflows.issue.scheduleInvalid" | "workflows.issue.eventValueInvalid" | "workflows.issue.eventTooManyValues" | "workflows.issue.triggerCapabilityMissing" | "workflows.issue.triggerInputMissing" | "workflows.issue.triggerActionMissing" | "workflows.issue.conditionNoSource" | "workflows.issue.conditionManySources" | "workflows.issue.conditionNoCases" | "workflows.issue.conditionTooManyCases" | "workflows.issue.caseBadId" | "workflows.issue.caseDuplicateId" | "workflows.issue.caseNoTests" | "workflows.issue.caseTooManyTests" | "workflows.issue.caseNoTarget" | "workflows.issue.testBadField" | "workflows.issue.testBadOperator" | "workflows.issue.testMissingValue" | "workflows.issue.fieldUnknown" | null;
71
80
  /** The compositions the workflow uses, as the API describes them. `null`: not there for this person. */
72
81
  options: Readonly<Record<string, CompositionOption | null | undefined>>;
73
82
  optionsReady: boolean;
@@ -77,7 +86,7 @@ export declare class WorkflowEditorState {
77
86
  /** Bumped when the whole draft is replaced from outside (a reload, a restore), so the canvas starts again from it. */
78
87
  draftEpoch: number;
79
88
  saveState: SaveState;
80
- saveFailure: "workflows.region.label" | "workflows.header.title" | "workflows.header.subtitle" | "workflows.common.cancel" | "workflows.common.close" | "workflows.common.dismiss" | "workflows.common.loading" | "workflows.empty.title" | "workflows.empty.hint" | "workflows.error.title" | "workflows.error.hint" | "workflows.error.retry" | "workflows.error.generic" | "workflows.error.network" | "workflows.error.timeout" | "workflows.error.server" | "workflows.error.sessionEnded" | "workflows.error.planRestricted" | "workflows.error.notFound" | "workflows.error.revisionChanged" | "workflows.error.archived" | "workflows.error.nothingToPublish" | "workflows.error.nothingToDiscard" | "workflows.error.everPublished" | "workflows.error.wrongState" | "workflows.error.tooManyWorkflows" | "workflows.error.publishBlocked" | "workflows.error.invalidGraph" | "workflows.error.tooManyRequests" | "workflows.list.label" | "workflows.list.newWorkflow" | "workflows.list.searchLabel" | "workflows.list.searchPlaceholder" | "workflows.list.filterLabel" | "workflows.list.filterActive" | "workflows.list.filterAll" | "workflows.list.sortLabel" | "workflows.list.sortCreated" | "workflows.list.sortPublished" | "workflows.list.sortRuns" | "workflows.list.sortName" | "workflows.list.sortAscending" | "workflows.list.sortDescending" | "workflows.list.columnName" | "workflows.list.columnStatus" | "workflows.list.columnRuns" | "workflows.list.columnPublished" | "workflows.list.columnCreated" | "workflows.list.compositionsCount" | "workflows.list.runsCount" | "workflows.list.publishedOn" | "workflows.list.neverPublished" | "workflows.list.never" | "workflows.list.open" | "workflows.list.rowMenu" | "workflows.list.showMore" | "workflows.list.noMatches" | "workflows.list.duplicated" | "workflows.list.deleted" | "workflows.create.title" | "workflows.create.nameLabel" | "workflows.create.namePlaceholder" | "workflows.create.compositionLabel" | "workflows.create.compositionHelp" | "workflows.create.create" | "workflows.create.creating" | "workflows.status.draft" | "workflows.status.live" | "workflows.status.paused" | "workflows.status.archived" | "workflows.status.unpublishedChanges" | "workflows.top.back" | "workflows.top.nameLabel" | "workflows.top.testRun" | "workflows.top.history" | "workflows.top.embedCode" | "workflows.top.publish" | "workflows.top.publishChanges" | "workflows.top.publishing" | "workflows.save.saved" | "workflows.save.saving" | "workflows.save.pending" | "workflows.save.failed" | "workflows.save.conflict" | "workflows.tabs.label" | "workflows.tabs.editor" | "workflows.tabs.runs" | "workflows.tabs.settings" | "workflows.banner.unpublishedChanges" | "workflows.banner.publishChanges" | "workflows.banner.discard" | "workflows.banner.discardTitle" | "workflows.banner.discardMessage" | "workflows.banner.neverPublished" | "workflows.banner.paused" | "workflows.banner.archived" | "workflows.banner.conflict" | "workflows.banner.reload" | "workflows.banner.touchOnly" | "workflows.editor.published" | "workflows.editor.discarded" | "workflows.editor.restored" | "workflows.editor.reloaded" | "workflows.editor.paused" | "workflows.editor.resumed" | "workflows.editor.archived" | "workflows.editor.unarchived" | "workflows.editor.saveFirst" | "workflows.editor.fixProblems" | "workflows.editor.blockLimit" | "workflows.publish.firstTitle" | "workflows.publish.firstMessage" | "workflows.publish.changesTitle" | "workflows.publish.changesMessage" | "workflows.leave.title" | "workflows.leave.message" | "workflows.leave.confirm" | "workflows.canvas.label" | "workflows.canvas.pointIn" | "workflows.canvas.pointOut" | "workflows.toolbar.label" | "workflows.toolbar.addBlock" | "workflows.toolbar.undo" | "workflows.toolbar.redo" | "workflows.toolbar.zoomIn" | "workflows.toolbar.zoomOut" | "workflows.toolbar.fit" | "workflows.addBlock.composition" | "workflows.addBlock.helpComposition" | "workflows.addBlock.condition" | "workflows.addBlock.helpCondition" | "workflows.addBlock.triggerHeading" | "workflows.addBlock.helpInput" | "workflows.addBlock.helpAction" | "workflows.addBlock.helpPageEvent" | "workflows.addBlock.helpScheduled" | "workflows.block.startsHere" | "workflows.block.trigger" | "workflows.block.condition" | "workflows.block.unknown" | "workflows.block.compositionNotChosen" | "workflows.block.compositionLoading" | "workflows.block.compositionUnavailable" | "workflows.block.notPublished" | "workflows.block.numbered" | "workflows.block.problems" | "workflows.panel.label" | "workflows.panel.overviewHeading" | "workflows.panel.overviewHelp" | "workflows.panel.problemsHeading" | "workflows.panel.problemsLabel" | "workflows.panel.noProblems" | "workflows.panel.manyBlocksSelected" | "workflows.panel.connectionSelected" | "workflows.panel.removeBlock" | "workflows.panel.removeBlocks" | "workflows.panel.removeConnection" | "workflows.composition.heading" | "workflows.composition.help" | "workflows.composition.searchLabel" | "workflows.composition.searchPlaceholder" | "workflows.composition.none" | "workflows.composition.alreadyUsed" | "workflows.composition.isStart" | "workflows.composition.makeStart" | "workflows.composition.capabilitiesHeading" | "workflows.composition.capabilityInput" | "workflows.composition.capabilityAction" | "workflows.composition.capabilityWebsites" | "workflows.composition.inputTables" | "workflows.composition.actionCount" | "workflows.trigger.heading" | "workflows.trigger.help" | "workflows.trigger.kindLabel" | "workflows.trigger.kindInput" | "workflows.trigger.kindAction" | "workflows.trigger.kindPageEvent" | "workflows.trigger.kindScheduled" | "workflows.trigger.unavailable" | "workflows.trigger.tableLabel" | "workflows.trigger.tableHelp" | "workflows.trigger.actionLabel" | "workflows.trigger.actionHelp" | "workflows.trigger.chooseOne" | "workflows.trigger.notFound" | "workflows.trigger.readableValues" | "workflows.trigger.noReadableValues" | "workflows.trigger.nextLabel" | "workflows.trigger.nextHelp" | "workflows.trigger.nextNone" | "workflows.trigger.summaryInput" | "workflows.trigger.summaryAction" | "workflows.trigger.summaryPageEvent" | "workflows.trigger.summaryAt" | "workflows.trigger.summaryUnfinished" | "workflows.reason.widgetKeepsNoData" | "workflows.reason.widgetReportsNoActions" | "workflows.reason.widgetNotPublished" | "workflows.schedule.modeLabel" | "workflows.schedule.modeAfter" | "workflows.schedule.modeAt" | "workflows.schedule.afterHelp" | "workflows.schedule.amountLabel" | "workflows.schedule.unitLabel" | "workflows.schedule.unitSeconds" | "workflows.schedule.unitMinutes" | "workflows.schedule.unitHours" | "workflows.schedule.unitDays" | "workflows.schedule.unitWeeks" | "workflows.schedule.waitSeconds" | "workflows.schedule.waitMinutes" | "workflows.schedule.waitHours" | "workflows.schedule.waitDays" | "workflows.schedule.waitWeeks" | "workflows.schedule.momentLabel" | "workflows.schedule.momentHelp" | "workflows.schedule.invalidMoment" | "workflows.event.nameLabel" | "workflows.event.namePlaceholder" | "workflows.event.nameHelp" | "workflows.event.nameInvalid" | "workflows.event.howToSend" | "workflows.event.valuesHeading" | "workflows.event.valuesHelp" | "workflows.event.addValue" | "workflows.event.valueName" | "workflows.event.valueNamePlaceholder" | "workflows.event.valueNameInvalid" | "workflows.event.valueType" | "workflows.event.removeValue" | "workflows.fieldType.text" | "workflows.fieldType.number" | "workflows.fieldType.boolean" | "workflows.value.yes" | "workflows.value.no" | "workflows.condition.heading" | "workflows.condition.help" | "workflows.condition.noTrigger" | "workflows.condition.noValues" | "workflows.condition.addRule" | "workflows.condition.ruleLimit" | "workflows.condition.defaultName" | "workflows.condition.defaultLabel" | "workflows.condition.defaultStay" | "workflows.condition.defaultHelp" | "workflows.condition.defaultHint" | "workflows.condition.defaultStays" | "workflows.rule.defaultName" | "workflows.rule.nameLabel" | "workflows.rule.moveUp" | "workflows.rule.moveDown" | "workflows.rule.remove" | "workflows.rule.matchLabel" | "workflows.rule.matchAll" | "workflows.rule.matchAny" | "workflows.rule.noTests" | "workflows.rule.addTest" | "workflows.rule.testLimit" | "workflows.rule.thenGoTo" | "workflows.rule.testWithValue" | "workflows.rule.testWithoutValue" | "workflows.rule.testAndMore" | "workflows.test.field" | "workflows.test.operator" | "workflows.test.value" | "workflows.test.valuePlaceholder" | "workflows.test.remove" | "workflows.operator.is" | "workflows.operator.isNot" | "workflows.operator.contains" | "workflows.operator.doesNotContain" | "workflows.operator.startsWith" | "workflows.operator.endsWith" | "workflows.operator.greaterThan" | "workflows.operator.atLeast" | "workflows.operator.lessThan" | "workflows.operator.atMost" | "workflows.operator.isEmpty" | "workflows.operator.isNotEmpty" | "workflows.test.heading" | "workflows.test.help" | "workflows.test.close" | "workflows.test.start" | "workflows.test.restart" | "workflows.test.ended" | "workflows.test.noStart" | "workflows.test.noTriggers" | "workflows.test.visitorIsOn" | "workflows.test.fire" | "workflows.test.resultMoved" | "workflows.test.resultStayed" | "workflows.test.resultIgnored" | "workflows.history.heading" | "workflows.history.help" | "workflows.history.close" | "workflows.history.none" | "workflows.history.failed" | "workflows.history.version" | "workflows.history.live" | "workflows.history.by" | "workflows.history.view" | "workflows.history.viewing" | "workflows.history.backToDraft" | "workflows.history.restore" | "workflows.history.restoreTitle" | "workflows.history.restoreMessage" | "workflows.runs.help" | "workflows.runs.rangeLabel" | "workflows.runs.lastDays" | "workflows.runs.versionLabel" | "workflows.runs.allVersions" | "workflows.runs.versionLive" | "workflows.runs.started" | "workflows.runs.entered" | "workflows.runs.fired" | "workflows.runs.failed" | "workflows.runs.none" | "workflows.runs.neverPublished" | "workflows.settings.zoneHeading" | "workflows.settings.zoneLabel" | "workflows.settings.zoneHelp" | "workflows.settings.embedHeading" | "workflows.settings.embedHelp" | "workflows.settings.stateHeading" | "workflows.settings.pause" | "workflows.settings.pauseHelp" | "workflows.settings.resume" | "workflows.settings.resumeHelp" | "workflows.settings.archive" | "workflows.settings.archiveHelp" | "workflows.settings.archiveTitle" | "workflows.settings.archiveMessage" | "workflows.settings.unarchive" | "workflows.settings.unarchiveHelp" | "workflows.settings.duplicate" | "workflows.settings.duplicateHelp" | "workflows.settings.delete" | "workflows.settings.deleteHelp" | "workflows.settings.deleteBlocked" | "workflows.settings.deleteTitle" | "workflows.settings.deleteMessage" | "workflows.issue.unknown" | "workflows.issue.malformed" | "workflows.issue.schemaVersion" | "workflows.issue.graphTooLarge" | "workflows.issue.unknownNodeType" | "workflows.issue.unknownTriggerKind" | "workflows.issue.badId" | "workflows.issue.duplicateId" | "workflows.issue.tooManyBlocks" | "workflows.issue.tooManyEdges" | "workflows.issue.noComposition" | "workflows.issue.noStart" | "workflows.issue.manyStarts" | "workflows.issue.compositionMissingId" | "workflows.issue.duplicateComposition" | "workflows.issue.compositionNotAvailable" | "workflows.issue.compositionWebsiteMismatch" | "workflows.issue.unreachableBlock" | "workflows.issue.edgeUnknownNode" | "workflows.issue.edgeBadPort" | "workflows.issue.edgeInvalidConnection" | "workflows.issue.portManyTargets" | "workflows.issue.cycle" | "workflows.issue.triggerNoSource" | "workflows.issue.triggerManySources" | "workflows.issue.triggerNoTarget" | "workflows.issue.triggerConfigIncomplete" | "workflows.issue.triggerNeedsTable" | "workflows.issue.triggerNeedsAction" | "workflows.issue.triggerNeedsName" | "workflows.issue.scheduleInvalid" | "workflows.issue.eventValueInvalid" | "workflows.issue.eventTooManyValues" | "workflows.issue.triggerCapabilityMissing" | "workflows.issue.triggerInputMissing" | "workflows.issue.triggerActionMissing" | "workflows.issue.conditionNoSource" | "workflows.issue.conditionManySources" | "workflows.issue.conditionNoCases" | "workflows.issue.conditionTooManyCases" | "workflows.issue.caseBadId" | "workflows.issue.caseDuplicateId" | "workflows.issue.caseNoTests" | "workflows.issue.caseTooManyTests" | "workflows.issue.caseNoTarget" | "workflows.issue.testBadField" | "workflows.issue.testBadOperator" | "workflows.issue.testMissingValue" | "workflows.issue.fieldUnknown" | null;
89
+ saveFailure: "workflows.region.label" | "workflows.header.title" | "workflows.header.subtitle" | "workflows.common.cancel" | "workflows.common.close" | "workflows.common.dismiss" | "workflows.common.loading" | "workflows.empty.title" | "workflows.empty.hint" | "workflows.error.title" | "workflows.error.hint" | "workflows.error.retry" | "workflows.error.generic" | "workflows.error.network" | "workflows.error.timeout" | "workflows.error.server" | "workflows.error.sessionEnded" | "workflows.error.planRestricted" | "workflows.error.notFound" | "workflows.error.revisionChanged" | "workflows.error.archived" | "workflows.error.nothingToPublish" | "workflows.error.nothingToDiscard" | "workflows.error.everPublished" | "workflows.error.wrongState" | "workflows.error.tooManyWorkflows" | "workflows.error.presetGone" | "workflows.error.presetCopyFailed" | "workflows.error.stillWorking" | "workflows.error.publishBlocked" | "workflows.error.invalidGraph" | "workflows.error.tooManyRequests" | "workflows.list.label" | "workflows.list.newWorkflow" | "workflows.list.searchLabel" | "workflows.list.searchPlaceholder" | "workflows.list.filterLabel" | "workflows.list.filterActive" | "workflows.list.filterAll" | "workflows.list.sortLabel" | "workflows.list.sortCreated" | "workflows.list.sortPublished" | "workflows.list.sortRuns" | "workflows.list.sortName" | "workflows.list.sortAscending" | "workflows.list.sortDescending" | "workflows.list.columnName" | "workflows.list.columnStatus" | "workflows.list.columnRuns" | "workflows.list.columnPublished" | "workflows.list.columnCreated" | "workflows.list.compositionsCount" | "workflows.list.runsCount" | "workflows.list.publishedOn" | "workflows.list.neverPublished" | "workflows.list.never" | "workflows.list.open" | "workflows.list.rowMenu" | "workflows.list.showMore" | "workflows.list.noMatches" | "workflows.list.duplicated" | "workflows.list.deleted" | "workflows.create.title" | "workflows.create.nameLabel" | "workflows.create.namePlaceholder" | "workflows.create.compositionLabel" | "workflows.create.compositionHelp" | "workflows.create.create" | "workflows.create.creating" | "workflows.create.startLabel" | "workflows.create.blankTitle" | "workflows.create.blankHint" | "workflows.create.presetSummary" | "workflows.create.presetMorePictures" | "workflows.create.presetsLoading" | "workflows.create.presetsFailed" | "workflows.create.presetHelp" | "workflows.create.presetNameHelp" | "workflows.create.settingUp" | "workflows.status.draft" | "workflows.status.live" | "workflows.status.paused" | "workflows.status.archived" | "workflows.status.unpublishedChanges" | "workflows.top.back" | "workflows.top.nameLabel" | "workflows.top.testRun" | "workflows.top.history" | "workflows.top.embedCode" | "workflows.top.publish" | "workflows.top.publishChanges" | "workflows.top.publishing" | "workflows.save.saved" | "workflows.save.saving" | "workflows.save.pending" | "workflows.save.failed" | "workflows.save.conflict" | "workflows.tabs.label" | "workflows.tabs.editor" | "workflows.tabs.runs" | "workflows.tabs.settings" | "workflows.banner.unpublishedChanges" | "workflows.banner.publishChanges" | "workflows.banner.discard" | "workflows.banner.discardTitle" | "workflows.banner.discardMessage" | "workflows.banner.neverPublished" | "workflows.banner.paused" | "workflows.banner.archived" | "workflows.banner.conflict" | "workflows.banner.reload" | "workflows.banner.touchOnly" | "workflows.conflict.keepCopy" | "workflows.conflict.keepingCopy" | "workflows.conflict.copyName" | "workflows.conflict.copyKept" | "workflows.conflict.openCopy" | "workflows.conflict.loadTitle" | "workflows.conflict.loadMessage" | "workflows.presence.blockedTitleNamed" | "workflows.presence.blockedTitleYou" | "workflows.presence.blockedTitle" | "workflows.presence.blockedBody" | "workflows.presence.lostTitleNamed" | "workflows.presence.lostTitleYou" | "workflows.presence.lostTitle" | "workflows.presence.lostBody" | "workflows.presence.takeOver" | "workflows.presence.takeOverHint" | "workflows.presence.lookOnly" | "workflows.presence.lookOnlyHint" | "workflows.presence.working" | "workflows.presence.actionFailed" | "workflows.presence.readOnlyNamed" | "workflows.presence.readOnlyYou" | "workflows.presence.readOnly" | "workflows.presence.readOnlyFree" | "workflows.presence.startEditing" | "workflows.editor.published" | "workflows.editor.discarded" | "workflows.editor.restored" | "workflows.editor.reloaded" | "workflows.editor.paused" | "workflows.editor.resumed" | "workflows.editor.archived" | "workflows.editor.unarchived" | "workflows.editor.saveFirst" | "workflows.editor.fixProblems" | "workflows.editor.blockLimit" | "workflows.publish.firstTitle" | "workflows.publish.firstMessage" | "workflows.publish.changesTitle" | "workflows.publish.changesMessage" | "workflows.leave.title" | "workflows.leave.message" | "workflows.leave.confirm" | "workflows.canvas.label" | "workflows.canvas.pointIn" | "workflows.canvas.pointOut" | "workflows.toolbar.label" | "workflows.toolbar.addBlock" | "workflows.toolbar.undo" | "workflows.toolbar.redo" | "workflows.toolbar.zoomIn" | "workflows.toolbar.zoomOut" | "workflows.toolbar.fit" | "workflows.addBlock.composition" | "workflows.addBlock.helpComposition" | "workflows.addBlock.condition" | "workflows.addBlock.helpCondition" | "workflows.addBlock.triggerHeading" | "workflows.addBlock.helpInput" | "workflows.addBlock.helpAction" | "workflows.addBlock.helpPageEvent" | "workflows.addBlock.helpScheduled" | "workflows.block.startsHere" | "workflows.block.trigger" | "workflows.block.condition" | "workflows.block.unknown" | "workflows.block.compositionNotChosen" | "workflows.block.compositionLoading" | "workflows.block.compositionUnavailable" | "workflows.block.notPublished" | "workflows.block.numbered" | "workflows.block.problems" | "workflows.panel.label" | "workflows.panel.overviewHeading" | "workflows.panel.overviewHelp" | "workflows.panel.problemsHeading" | "workflows.panel.problemsLabel" | "workflows.panel.noProblems" | "workflows.panel.manyBlocksSelected" | "workflows.panel.connectionSelected" | "workflows.panel.removeBlock" | "workflows.panel.removeBlocks" | "workflows.panel.removeConnection" | "workflows.composition.heading" | "workflows.composition.help" | "workflows.composition.searchLabel" | "workflows.composition.searchPlaceholder" | "workflows.composition.none" | "workflows.composition.alreadyUsed" | "workflows.composition.isStart" | "workflows.composition.makeStart" | "workflows.composition.capabilitiesHeading" | "workflows.composition.capabilityInput" | "workflows.composition.capabilityAction" | "workflows.composition.capabilityWebsites" | "workflows.composition.inputTables" | "workflows.composition.actionCount" | "workflows.trigger.heading" | "workflows.trigger.help" | "workflows.trigger.kindLabel" | "workflows.trigger.kindInput" | "workflows.trigger.kindAction" | "workflows.trigger.kindPageEvent" | "workflows.trigger.kindScheduled" | "workflows.trigger.unavailable" | "workflows.trigger.tableLabel" | "workflows.trigger.tableHelp" | "workflows.trigger.actionLabel" | "workflows.trigger.actionHelp" | "workflows.trigger.chooseOne" | "workflows.trigger.notFound" | "workflows.trigger.readableValues" | "workflows.trigger.noReadableValues" | "workflows.trigger.nextLabel" | "workflows.trigger.nextHelp" | "workflows.trigger.nextNone" | "workflows.trigger.summaryInput" | "workflows.trigger.summaryAction" | "workflows.trigger.summaryPageEvent" | "workflows.trigger.summaryAt" | "workflows.trigger.summaryUnfinished" | "workflows.reason.widgetKeepsNoData" | "workflows.reason.widgetReportsNoActions" | "workflows.reason.widgetNotPublished" | "workflows.schedule.modeLabel" | "workflows.schedule.modeAfter" | "workflows.schedule.modeAt" | "workflows.schedule.afterHelp" | "workflows.schedule.amountLabel" | "workflows.schedule.unitLabel" | "workflows.schedule.unitSeconds" | "workflows.schedule.unitMinutes" | "workflows.schedule.unitHours" | "workflows.schedule.unitDays" | "workflows.schedule.unitWeeks" | "workflows.schedule.waitSeconds" | "workflows.schedule.waitMinutes" | "workflows.schedule.waitHours" | "workflows.schedule.waitDays" | "workflows.schedule.waitWeeks" | "workflows.schedule.momentLabel" | "workflows.schedule.momentHelp" | "workflows.schedule.invalidMoment" | "workflows.event.nameLabel" | "workflows.event.namePlaceholder" | "workflows.event.nameHelp" | "workflows.event.nameInvalid" | "workflows.event.howToSend" | "workflows.event.valuesHeading" | "workflows.event.valuesHelp" | "workflows.event.addValue" | "workflows.event.valueName" | "workflows.event.valueNamePlaceholder" | "workflows.event.valueNameInvalid" | "workflows.event.valueType" | "workflows.event.removeValue" | "workflows.fieldType.text" | "workflows.fieldType.number" | "workflows.fieldType.boolean" | "workflows.value.yes" | "workflows.value.no" | "workflows.condition.heading" | "workflows.condition.help" | "workflows.condition.noTrigger" | "workflows.condition.noValues" | "workflows.condition.addRule" | "workflows.condition.ruleLimit" | "workflows.condition.defaultName" | "workflows.condition.defaultLabel" | "workflows.condition.defaultStay" | "workflows.condition.defaultHelp" | "workflows.condition.defaultHint" | "workflows.condition.defaultStays" | "workflows.rule.defaultName" | "workflows.rule.nameLabel" | "workflows.rule.moveUp" | "workflows.rule.moveDown" | "workflows.rule.remove" | "workflows.rule.matchLabel" | "workflows.rule.matchAll" | "workflows.rule.matchAny" | "workflows.rule.noTests" | "workflows.rule.addTest" | "workflows.rule.testLimit" | "workflows.rule.thenGoTo" | "workflows.rule.testWithValue" | "workflows.rule.testWithoutValue" | "workflows.rule.testAndMore" | "workflows.test.field" | "workflows.test.operator" | "workflows.test.value" | "workflows.test.valuePlaceholder" | "workflows.test.remove" | "workflows.operator.is" | "workflows.operator.isNot" | "workflows.operator.contains" | "workflows.operator.doesNotContain" | "workflows.operator.startsWith" | "workflows.operator.endsWith" | "workflows.operator.greaterThan" | "workflows.operator.atLeast" | "workflows.operator.lessThan" | "workflows.operator.atMost" | "workflows.operator.isEmpty" | "workflows.operator.isNotEmpty" | "workflows.test.heading" | "workflows.test.help" | "workflows.test.close" | "workflows.test.start" | "workflows.test.restart" | "workflows.test.ended" | "workflows.test.noStart" | "workflows.test.noTriggers" | "workflows.test.visitorIsOn" | "workflows.test.fire" | "workflows.test.resultMoved" | "workflows.test.resultStayed" | "workflows.test.resultIgnored" | "workflows.history.heading" | "workflows.history.help" | "workflows.history.close" | "workflows.history.none" | "workflows.history.failed" | "workflows.history.version" | "workflows.history.live" | "workflows.history.by" | "workflows.history.view" | "workflows.history.viewing" | "workflows.history.backToDraft" | "workflows.history.restore" | "workflows.history.restoreTitle" | "workflows.history.restoreMessage" | "workflows.runs.help" | "workflows.runs.rangeLabel" | "workflows.runs.lastDays" | "workflows.runs.versionLabel" | "workflows.runs.allVersions" | "workflows.runs.versionLive" | "workflows.runs.started" | "workflows.runs.entered" | "workflows.runs.fired" | "workflows.runs.failed" | "workflows.runs.none" | "workflows.runs.neverPublished" | "workflows.settings.zoneHeading" | "workflows.settings.zoneLabel" | "workflows.settings.zoneHelp" | "workflows.settings.embedHeading" | "workflows.settings.embedHelp" | "workflows.settings.stateHeading" | "workflows.settings.pause" | "workflows.settings.pauseHelp" | "workflows.settings.resume" | "workflows.settings.resumeHelp" | "workflows.settings.archive" | "workflows.settings.archiveHelp" | "workflows.settings.archiveTitle" | "workflows.settings.archiveMessage" | "workflows.settings.unarchive" | "workflows.settings.unarchiveHelp" | "workflows.settings.duplicate" | "workflows.settings.duplicateHelp" | "workflows.settings.delete" | "workflows.settings.deleteHelp" | "workflows.settings.deleteTitle" | "workflows.settings.deleteMessageDraft" | "workflows.settings.deleteMessageLive" | "workflows.settings.deleteMessagePaused" | "workflows.settings.deleteMessageArchived" | "workflows.issue.unknown" | "workflows.issue.malformed" | "workflows.issue.schemaVersion" | "workflows.issue.graphTooLarge" | "workflows.issue.unknownNodeType" | "workflows.issue.unknownTriggerKind" | "workflows.issue.badId" | "workflows.issue.duplicateId" | "workflows.issue.tooManyBlocks" | "workflows.issue.tooManyEdges" | "workflows.issue.noComposition" | "workflows.issue.noStart" | "workflows.issue.manyStarts" | "workflows.issue.compositionMissingId" | "workflows.issue.duplicateComposition" | "workflows.issue.compositionNotAvailable" | "workflows.issue.compositionWebsiteMismatch" | "workflows.issue.unreachableBlock" | "workflows.issue.edgeUnknownNode" | "workflows.issue.edgeBadPort" | "workflows.issue.edgeInvalidConnection" | "workflows.issue.portManyTargets" | "workflows.issue.cycle" | "workflows.issue.triggerNoSource" | "workflows.issue.triggerManySources" | "workflows.issue.triggerNoTarget" | "workflows.issue.triggerConfigIncomplete" | "workflows.issue.triggerNeedsTable" | "workflows.issue.triggerNeedsAction" | "workflows.issue.triggerNeedsName" | "workflows.issue.scheduleInvalid" | "workflows.issue.eventValueInvalid" | "workflows.issue.eventTooManyValues" | "workflows.issue.triggerCapabilityMissing" | "workflows.issue.triggerInputMissing" | "workflows.issue.triggerActionMissing" | "workflows.issue.conditionNoSource" | "workflows.issue.conditionManySources" | "workflows.issue.conditionNoCases" | "workflows.issue.conditionTooManyCases" | "workflows.issue.caseBadId" | "workflows.issue.caseDuplicateId" | "workflows.issue.caseNoTests" | "workflows.issue.caseTooManyTests" | "workflows.issue.caseNoTarget" | "workflows.issue.testBadField" | "workflows.issue.testBadOperator" | "workflows.issue.testMissingValue" | "workflows.issue.fieldUnknown" | null;
81
90
  tab: EditorTab;
82
91
  panel: PanelMode;
83
92
  selectedNodeIds: readonly string[];
@@ -95,6 +104,10 @@ export declare class WorkflowEditorState {
95
104
  /** A published version being looked at, read-only. */
96
105
  viewing: WorkflowVersionDetail | null;
97
106
  testRun: TestRunState | null;
107
+ /** Where the claim on editing stands (see `EditLeaseController`). Nothing is blocked while it is `off` or `editing`. */
108
+ presence: PresenceState;
109
+ /** The workflow that holds the changes the person made while somebody else saved the draft first, once it was made. */
110
+ keptCopy: KeptCopy | null;
98
111
  /** The canvas, while one is on the screen (a pointer that changes when the canvas comes and goes). */
99
112
  canvas: CanvasHandle | null;
100
113
  private revision;
@@ -109,6 +122,11 @@ export declare class WorkflowEditorState {
109
122
  private noticeTimer;
110
123
  private loadController;
111
124
  private disposed;
125
+ private readonly presenceWanted;
126
+ private readonly presenceOptions;
127
+ private leaseController;
128
+ /** The latest look at the server's draft, after editing came back (see `catchUpAfterPause`): a newer look and leaving the screen cancel it. */
129
+ private catchUpController;
112
130
  constructor(options: WorkflowEditorOptions);
113
131
  /** What the engine finds missing in the draft, with what it knows about the compositions once that has arrived. */
114
132
  issues: ValidationIssue[];
@@ -117,8 +135,16 @@ export declare class WorkflowEditorState {
117
135
  /** Errors stop a publish; warnings are advice. */
118
136
  hasPublishBlockers: boolean;
119
137
  status: import("../api/types.js").WorkflowStatus;
120
- /** Archived workflows are only looked at; so is a version, and so is a canvas on a touch screen. */
138
+ /**
139
+ * Archived workflows are only looked at; so is a version, and so is a workflow somebody else is editing (the person
140
+ * chose to look only, or has not yet chosen to take over). The canvas on a touch screen only shows, see `canEditCanvas`.
141
+ */
121
142
  isReadOnly: boolean;
143
+ /**
144
+ * The workflow as a whole can be changed now (paused, archived, put back to a version, deleted): nothing else is
145
+ * running, and nobody else is editing it. Those are the changes that take what somebody is working on from under them.
146
+ */
147
+ canChangeWorkflow: boolean;
122
148
  canEditCanvas: boolean;
123
149
  hasChangesToPublish: boolean;
124
150
  /** Publish can be tried: there is something to publish and nothing else in the way. The problems found are told on the try. */
@@ -139,10 +165,32 @@ export declare class WorkflowEditorState {
139
165
  flushSaves(): Promise<SaveState>;
140
166
  /** Leaves the workflow: what is waiting is sent first, then everything that was running is stopped. */
141
167
  finish(): Promise<SaveState>;
142
- /** Takes what the server holds as the draft, replacing what is on the screen. */
168
+ /**
169
+ * Takes what the server holds as the draft, replacing what is on the screen. A published version that was being looked
170
+ * at is let go of: the canvas shows the draft now, and a banner that says otherwise would be wrong.
171
+ */
143
172
  private adoptServerDraft;
144
173
  /** Throws away what is unsaved on this screen and reads the draft again (after somebody else changed it). */
145
174
  reloadDraft(): Promise<void>;
175
+ /**
176
+ * Begins asking to edit, and keeps this tab's claim while the screen is open. When a teammate holds it, editing is paused
177
+ * here (`presence.editsBlocked`) until the person takes over or the teammate leaves. Nothing happens unless the page
178
+ * asked for presence: a personal workspace has no teammate, and there nothing is asked of the API and nothing is blocked.
179
+ */
180
+ startPresence(): void;
181
+ /** The person chose to take over from the teammate who is editing: their editing pauses, and what they saved stays. */
182
+ takeOverEditing(): void;
183
+ /** The person chose to only look, for now. */
184
+ lookOnly(): void;
185
+ /** The person chose to begin editing, after looking (the teammate is gone). */
186
+ startEditing(): void;
187
+ private followPresence;
188
+ /**
189
+ * Editing came back after a pause, and what the screen shows may be older than what the other editor saved meanwhile.
190
+ * When everything on the screen is saved, the screen takes the server's draft if that is newer, so that the first thing
191
+ * the person does is not refused as a conflict. What is not saved is never replaced: the conflict banner decides that.
192
+ */
193
+ private catchUpAfterPause;
146
194
  /** Reads what the API says about these compositions; the ones it does not know come back as `null`. */
147
195
  private readCompositionOptions;
148
196
  /** Remembers compositions the person picked from the list, so the blocks that show them have their names at once. */
@@ -184,6 +232,15 @@ export declare class WorkflowEditorState {
184
232
  private followSaveState;
185
233
  /** Tries a failed save again (the person pressed "Try again"). */
186
234
  retrySave(): void;
235
+ /**
236
+ * Somebody else saved the draft first, so what this person changed was not saved (`saveState` is `conflict`). Keeps what
237
+ * is on this screen as a new workflow, so that loading the latest version does not cost the person their work. The words
238
+ * of the copy's name are the screen's (`wording` puts them around the workflow's name, in the person's language).
239
+ * Nothing is done to the workflow being edited. Resolves to whether the copy was made; `keptCopy` says which.
240
+ */
241
+ keepCopyOfChanges(wording: (name: string) => string): Promise<boolean>;
242
+ /** The person chose to open the copy they kept: the page follows, as it does for a duplicate. Nothing without a copy. */
243
+ openKeptCopy(): void;
187
244
  /** Runs one thing the person waits for. Nothing else that changes the workflow runs meanwhile. */
188
245
  private runBusy;
189
246
  /** Makes the draft the next version visitors get. */
@@ -5,10 +5,20 @@ import { workflowsError, workflowsWarn } from '../utils/logger.js';
5
5
  import { pickApiErrorMessage } from './apiErrorText.js';
6
6
  import { createDraftSaver } from './autosave.js';
7
7
  import { toValidationContext } from './capabilityModel.js';
8
+ import { EditLeaseController, NO_PRESENCE } from './editLeaseController.js';
8
9
  import { dropStrandedConnections, ensureOneStart, isSameGraph, listCompositionIds, makeEmptyGraph, planAddBlock, removeBlocks, removeConnections, setStartBlock } from './graphModel.js';
9
10
  import { groupIssues } from './flowAdapter.js';
11
+ import { keepCopyOfDraft, nameForCopy } from './keepCopy.js';
10
12
  import { fireTestTrigger, startTestRun } from './testRun.js';
11
13
  const DEFAULT_NOTICE_MILLISECONDS = 5000;
14
+ /**
15
+ * Where the presence writes its own notes (a request refused as malformed, a listener that failed): the console of the
16
+ * package, which starts every line with `[Workflows]` and says a line once.
17
+ */
18
+ const PRESENCE_LOGGER = {
19
+ warn: (message, detail) => workflowsWarn(String(message), detail),
20
+ error: (message, detail) => workflowsError(String(message), detail)
21
+ };
12
22
  /**
13
23
  * Everything the open workflow is: what the server says about it, the draft the person is changing, the compositions that
14
24
  * can be used, what the draft is missing, where saving stands, and the small things the person is in the middle of
@@ -60,6 +70,12 @@ export class WorkflowEditorState {
60
70
  viewing = $state.raw(null);
61
71
  // ---- the test visitor ------------------------------------------------------------------------------------------
62
72
  testRun = $state.raw(null);
73
+ // ---- who else is editing ---------------------------------------------------------------------------------------
74
+ /** Where the claim on editing stands (see `EditLeaseController`). Nothing is blocked while it is `off` or `editing`. */
75
+ presence = $state.raw(NO_PRESENCE);
76
+ // ---- a copy of what the person did ------------------------------------------------------------------------------
77
+ /** The workflow that holds the changes the person made while somebody else saved the draft first, once it was made. */
78
+ keptCopy = $state.raw(null);
63
79
  /** The canvas, while one is on the screen (a pointer that changes when the canvas comes and goes). */
64
80
  canvas = $state.raw(null);
65
81
  revision = 0;
@@ -74,6 +90,11 @@ export class WorkflowEditorState {
74
90
  noticeTimer = null;
75
91
  loadController = null;
76
92
  disposed = false;
93
+ presenceWanted;
94
+ presenceOptions;
95
+ leaseController = null;
96
+ /** The latest look at the server's draft, after editing came back (see `catchUpAfterPause`): a newer look and leaving the screen cancel it. */
97
+ catchUpController = null;
77
98
  constructor(options) {
78
99
  this.workflowId = options.workflowId;
79
100
  this.api = options.api;
@@ -82,6 +103,8 @@ export class WorkflowEditorState {
82
103
  this.openWorkflow = options.openWorkflow;
83
104
  this.random = options.random ?? Math.random;
84
105
  this.noticeMilliseconds = options.noticeMilliseconds ?? DEFAULT_NOTICE_MILLISECONDS;
106
+ this.presenceWanted = options.presence === true;
107
+ this.presenceOptions = options.presenceOptions;
85
108
  this.saver = createDraftSaver({
86
109
  readSnapshot: () => this.readSaveSnapshot(),
87
110
  send: (snapshot) => this.api.saveDraft(this.workflowId, this.toSaveInput(snapshot)),
@@ -101,8 +124,16 @@ export class WorkflowEditorState {
101
124
  /** Errors stop a publish; warnings are advice. */
102
125
  hasPublishBlockers = $derived(hasErrors(this.issues));
103
126
  status = $derived(this.workflow?.status ?? 'draft');
104
- /** Archived workflows are only looked at; so is a version, and so is a canvas on a touch screen. */
105
- isReadOnly = $derived(this.status === 'archived' || this.viewing !== null);
127
+ /**
128
+ * Archived workflows are only looked at; so is a version, and so is a workflow somebody else is editing (the person
129
+ * chose to look only, or has not yet chosen to take over). The canvas on a touch screen only shows, see `canEditCanvas`.
130
+ */
131
+ isReadOnly = $derived(this.status === 'archived' || this.viewing !== null || this.presence.editsBlocked);
132
+ /**
133
+ * The workflow as a whole can be changed now (paused, archived, put back to a version, deleted): nothing else is
134
+ * running, and nobody else is editing it. Those are the changes that take what somebody is working on from under them.
135
+ */
136
+ canChangeWorkflow = $derived(this.busy === null && !this.presence.editsBlocked);
106
137
  canEditCanvas = $derived(!this.isReadOnly && !this.canvasTouchOnly && this.tab === 'editor');
107
138
  hasChangesToPublish = $derived.by(() => {
108
139
  const workflow = this.workflow;
@@ -168,7 +199,11 @@ export class WorkflowEditorState {
168
199
  dispose() {
169
200
  this.disposed = true;
170
201
  this.loadController?.abort();
202
+ this.catchUpController?.abort();
171
203
  this.saver.dispose();
204
+ // The claim on editing is given up with the screen, so a teammate does not have to wait for it to run out.
205
+ this.leaseController?.dispose();
206
+ this.leaseController = null;
172
207
  if (this.noticeTimer !== null)
173
208
  clearTimeout(this.noticeTimer);
174
209
  this.noticeTimer = null;
@@ -184,8 +219,12 @@ export class WorkflowEditorState {
184
219
  this.dispose();
185
220
  return state;
186
221
  }
187
- /** Takes what the server holds as the draft, replacing what is on the screen. */
222
+ /**
223
+ * Takes what the server holds as the draft, replacing what is on the screen. A published version that was being looked
224
+ * at is let go of: the canvas shows the draft now, and a banner that says otherwise would be wrong.
225
+ */
188
226
  adoptServerDraft(detail) {
227
+ this.viewing = null;
189
228
  this.workflow = detail;
190
229
  this.revision = detail.revision;
191
230
  const graph = ensureOneStart(detail.graph);
@@ -210,6 +249,87 @@ export class WorkflowEditorState {
210
249
  this.showNotice('info', 'workflows.editor.reloaded');
211
250
  }
212
251
  // =================================================================================================================
252
+ // Who else is editing
253
+ // =================================================================================================================
254
+ /**
255
+ * Begins asking to edit, and keeps this tab's claim while the screen is open. When a teammate holds it, editing is paused
256
+ * here (`presence.editsBlocked`) until the person takes over or the teammate leaves. Nothing happens unless the page
257
+ * asked for presence: a personal workspace has no teammate, and there nothing is asked of the API and nothing is blocked.
258
+ */
259
+ startPresence() {
260
+ if (!this.presenceWanted || this.disposed || this.leaseController !== null)
261
+ return;
262
+ const workflowId = this.workflowId;
263
+ const controller = new EditLeaseController({
264
+ port: {
265
+ acquire: (sessionId, options) => this.api.acquireEditLease(workflowId, sessionId, options),
266
+ takeOver: (sessionId, options) => this.api.takeOverEditLease(workflowId, sessionId, options),
267
+ peek: (options) => this.api.peekEditLease(workflowId, options),
268
+ release: (sessionId, options) => this.api.releaseEditLease(workflowId, sessionId, options)
269
+ },
270
+ logger: PRESENCE_LOGGER,
271
+ ...this.presenceOptions
272
+ });
273
+ this.leaseController = controller;
274
+ controller.subscribe((state) => this.followPresence(state));
275
+ controller.start();
276
+ }
277
+ /** The person chose to take over from the teammate who is editing: their editing pauses, and what they saved stays. */
278
+ takeOverEditing() {
279
+ this.leaseController?.takeOver();
280
+ }
281
+ /** The person chose to only look, for now. */
282
+ lookOnly() {
283
+ this.leaseController?.openReadOnly();
284
+ }
285
+ /** The person chose to begin editing, after looking (the teammate is gone). */
286
+ startEditing() {
287
+ this.leaseController?.startEditing();
288
+ }
289
+ followPresence(next) {
290
+ const wasPaused = this.presence.editsBlocked;
291
+ this.presence = next;
292
+ // Editing is back (the person took over, or the teammate left): see what the teammate saved while it was paused.
293
+ if (wasPaused && !next.editsBlocked)
294
+ void this.catchUpAfterPause();
295
+ }
296
+ /**
297
+ * Editing came back after a pause, and what the screen shows may be older than what the other editor saved meanwhile.
298
+ * When everything on the screen is saved, the screen takes the server's draft if that is newer, so that the first thing
299
+ * the person does is not refused as a conflict. What is not saved is never replaced: the conflict banner decides that.
300
+ */
301
+ async catchUpAfterPause() {
302
+ // Not before the draft was read the first time: that read is the latest one. (Nothing gets here after the screen is
303
+ // gone: leaving it silences the claim's listeners.)
304
+ if (this.loadState !== 'ready')
305
+ return;
306
+ this.catchUpController?.abort();
307
+ const controller = new AbortController();
308
+ this.catchUpController = controller;
309
+ try {
310
+ const detail = await this.api.getWorkflow(this.workflowId, { signal: controller.signal });
311
+ // Leaving the screen, and a newer look, both abort this one: its answer is then of no use.
312
+ if (controller.signal.aborted)
313
+ return;
314
+ // A draft that is not newer is what the screen already has (or older than what it saved itself since).
315
+ if (detail.revision <= this.revision)
316
+ return;
317
+ await this.ensureOptionsFor(detail.graph);
318
+ if (controller.signal.aborted)
319
+ return;
320
+ // Something was typed while the look was on its way: it is not saved yet, and not for this to throw away.
321
+ if (this.saveState !== 'saved')
322
+ return;
323
+ this.adoptServerDraft(detail);
324
+ }
325
+ catch (error) {
326
+ // A look that was cancelled is no failure (`noteFailure` knows that), and nothing is said once the screen is gone.
327
+ if (this.disposed)
328
+ return;
329
+ this.noteFailure('Reading the latest draft failed', error);
330
+ }
331
+ }
332
+ // =================================================================================================================
213
333
  // The compositions
214
334
  // =================================================================================================================
215
335
  /** Reads what the API says about these compositions; the ones it does not know come back as `null`. */
@@ -434,11 +554,40 @@ export class WorkflowEditorState {
434
554
  else {
435
555
  this.saveFailure = null;
436
556
  }
557
+ // A copy was kept for one conflict: once it is over, a banner must not go on telling about it.
558
+ if (state !== 'conflict')
559
+ this.keptCopy = null;
437
560
  }
438
561
  /** Tries a failed save again (the person pressed "Try again"). */
439
562
  retrySave() {
440
563
  void this.saver.flush();
441
564
  }
565
+ /**
566
+ * Somebody else saved the draft first, so what this person changed was not saved (`saveState` is `conflict`). Keeps what
567
+ * is on this screen as a new workflow, so that loading the latest version does not cost the person their work. The words
568
+ * of the copy's name are the screen's (`wording` puts them around the workflow's name, in the person's language).
569
+ * Nothing is done to the workflow being edited. Resolves to whether the copy was made; `keptCopy` says which.
570
+ */
571
+ async keepCopyOfChanges(wording) {
572
+ // While something else runs, `runBusy` below refuses (a second copy is not started).
573
+ if (this.disposed || this.saveState !== 'conflict')
574
+ return false;
575
+ const copy = await this.runBusy('keepingCopy', () => keepCopyOfDraft(this.api, {
576
+ name: nameForCopy(this.name, wording),
577
+ timezone: this.timezone,
578
+ graph: this.graph
579
+ }), 'Keeping a copy of the changes failed');
580
+ if (!copy)
581
+ return false;
582
+ this.keptCopy = copy;
583
+ return true;
584
+ }
585
+ /** The person chose to open the copy they kept: the page follows, as it does for a duplicate. Nothing without a copy. */
586
+ openKeptCopy() {
587
+ const copy = this.keptCopy;
588
+ if (copy)
589
+ this.openWorkflow(copy.id);
590
+ }
442
591
  // =================================================================================================================
443
592
  // Publishing, discarding, restoring
444
593
  // =================================================================================================================
@@ -562,7 +711,7 @@ export class WorkflowEditorState {
562
711
  /** Copies the version into the draft (the draft it replaces stays recoverable only through undo, so the screen asks first). */
563
712
  async restoreViewedVersion() {
564
713
  const viewing = this.viewing;
565
- if (!viewing || this.busy !== null)
714
+ if (!viewing || !this.canChangeWorkflow)
566
715
  return false;
567
716
  const detail = await this.runBusy('restoring', () => this.api.restoreVersion(this.workflowId, viewing.id, this.revision), 'Restoring a version failed');
568
717
  if (!detail)
@@ -588,7 +737,7 @@ export class WorkflowEditorState {
588
737
  }
589
738
  // ---- states of the workflow -------------------------------------------------------------------------------
590
739
  async changeState(action) {
591
- if (this.busy !== null)
740
+ if (!this.canChangeWorkflow)
592
741
  return false;
593
742
  await this.saver.flush();
594
743
  const item = await this.runBusy('changingState', () => this.api.changeState(this.workflowId, action), 'Changing the state failed');
@@ -609,7 +758,7 @@ export class WorkflowEditorState {
609
758
  this.openWorkflow(copy.id);
610
759
  }
611
760
  async deleteWorkflow() {
612
- if (this.busy !== null)
761
+ if (!this.canChangeWorkflow)
613
762
  return;
614
763
  this.saver.dispose();
615
764
  const done = await this.runBusy('deleting', async () => {
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Keeping what a person did when somebody else saved the draft first.
3
+ *
4
+ * Two people open the same workflow. One saves; the other's next save is refused (the draft is no longer the one that
5
+ * person started from). Nothing the other person typed is lost until they load the latest version, because that replaces
6
+ * the screen with the draft the server holds. So before that, the person may keep a copy: a new workflow that holds what
7
+ * is on their screen. No part of the API is new for it, a copy is a workflow made and then saved like any other:
8
+ *
9
+ * 1. the new workflow is made, with the name and the time zone the person has (`createWorkflow`);
10
+ * 2. the blocks and lines the person has are saved into it (`saveDraft`, with the revision the new workflow answered).
11
+ *
12
+ * If the second step fails the first is taken back (the workflow made is deleted: it was never published, so it can be), so
13
+ * that a failed attempt does not leave an empty workflow named after the person's work. Nothing is ever done to the workflow
14
+ * the person is editing: the other person's draft is not touched.
15
+ */
16
+ import type { WorkflowGraph } from '@widgetic/workflows-engine';
17
+ import type { WorkflowsApi } from '../api/workflowsApi.js';
18
+ /** The workflow that holds the person's changes. */
19
+ export interface KeptCopy {
20
+ id: string;
21
+ name: string;
22
+ }
23
+ /** What is on the person's screen and is to be kept. */
24
+ export interface KeepCopyInput {
25
+ /** The name of the copy, already worded in the person's language and cut to fit (see {@link nameForCopy}). */
26
+ name: string;
27
+ timezone: string;
28
+ graph: WorkflowGraph;
29
+ }
30
+ /**
31
+ * The name of a copy: the person's own words around the name of the workflow (`wording` puts them there, in the person's
32
+ * language: "{name} (my changes)"), cut so that the whole is at most what the API accepts. It is the workflow's name that
33
+ * gives way, with an ellipsis, never the words around it; a letter is never cut in two (an emoji is one letter here).
34
+ */
35
+ export declare function nameForCopy(name: string, wording: (name: string) => string, max?: number): string;
36
+ /**
37
+ * Makes a new workflow that holds the draft on the person's screen, and answers it. If the draft cannot be saved into it,
38
+ * the new workflow is deleted again and the failure is thrown. `signal` cancels the requests of the copy (the screen was
39
+ * left); the clean-up after a failure is made anyway.
40
+ */
41
+ export declare function keepCopyOfDraft(api: WorkflowsApi, input: KeepCopyInput, signal?: AbortSignal): Promise<KeptCopy>;
@@ -0,0 +1,52 @@
1
+ import { MAX_WORKFLOW_NAME_LENGTH } from '../api/types.js';
2
+ import { workflowsWarn } from '../utils/logger.js';
3
+ const ELLIPSIS = '…';
4
+ /** Whether a text is short enough for the API, which counts what a script counts (UTF-16 units, not letters). */
5
+ function fitsIn(text, max) {
6
+ return text.length <= max;
7
+ }
8
+ /**
9
+ * The name of a copy: the person's own words around the name of the workflow (`wording` puts them there, in the person's
10
+ * language: "{name} (my changes)"), cut so that the whole is at most what the API accepts. It is the workflow's name that
11
+ * gives way, with an ellipsis, never the words around it; a letter is never cut in two (an emoji is one letter here).
12
+ */
13
+ export function nameForCopy(name, wording, max = MAX_WORKFLOW_NAME_LENGTH) {
14
+ const whole = Array.from(name.trim());
15
+ const uncut = wording(whole.join('')).trim();
16
+ if (fitsIn(uncut, max))
17
+ return uncut;
18
+ // One letter fewer at a time, down to none: "…" alone, between the words, is the shortest the name can be.
19
+ for (let kept = whole.length - 1; kept >= 0; kept -= 1) {
20
+ const shown = `${whole.slice(0, kept).join('').trimEnd()}${ELLIPSIS}`;
21
+ const candidate = wording(shown).trim();
22
+ if (fitsIn(candidate, max))
23
+ return candidate;
24
+ }
25
+ // The words around the name are too long on their own (no catalog does that): cut them, a letter at a time.
26
+ const letters = Array.from(wording('').trim());
27
+ while (letters.length > 0 && !fitsIn(letters.join(''), max))
28
+ letters.pop();
29
+ return letters.join('');
30
+ }
31
+ /**
32
+ * Makes a new workflow that holds the draft on the person's screen, and answers it. If the draft cannot be saved into it,
33
+ * the new workflow is deleted again and the failure is thrown. `signal` cancels the requests of the copy (the screen was
34
+ * left); the clean-up after a failure is made anyway.
35
+ */
36
+ export async function keepCopyOfDraft(api, input, signal) {
37
+ const made = await api.createWorkflow({ name: input.name, timezone: input.timezone }, { signal });
38
+ try {
39
+ await api.saveDraft(made.id, { revision: made.revision, graph: input.graph }, { signal });
40
+ }
41
+ catch (failure) {
42
+ try {
43
+ await api.deleteWorkflow(made.id);
44
+ }
45
+ catch (cleanupFailure) {
46
+ // The copy stays, empty. The person is told the copy failed; the console tells the page's developer why it is there.
47
+ workflowsWarn(`An empty workflow (${made.id}) was left behind: the draft could not be saved into it and it could not be deleted.`, cleanupFailure);
48
+ }
49
+ throw failure;
50
+ }
51
+ return { id: made.id, name: made.name };
52
+ }