@widgetic/workflows 0.2.14 → 0.2.16

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 (114) hide show
  1. package/README.md +117 -3
  2. package/dist/api/types.d.ts +17 -0
  3. package/dist/api/workflowsApi.d.ts +12 -1
  4. package/dist/api/workflowsApi.js +37 -0
  5. package/dist/assistant/assistantEvents.d.ts +44 -2
  6. package/dist/assistant/assistantEvents.js +58 -2
  7. package/dist/assistant/assistantReferences.d.ts +66 -0
  8. package/dist/assistant/assistantReferences.js +109 -0
  9. package/dist/assistant/assistantSaveMode.d.ts +15 -3
  10. package/dist/assistant/assistantSaveMode.js +16 -2
  11. package/dist/assistant/assistantSeed.d.ts +55 -0
  12. package/dist/assistant/assistantSeed.js +90 -0
  13. package/dist/assistant/assistantStream.js +81 -3
  14. package/dist/assistant/assistantSuggest.d.ts +18 -0
  15. package/dist/assistant/assistantSuggest.js +21 -0
  16. package/dist/assistant/assistantTurns.d.ts +75 -0
  17. package/dist/assistant/assistantTurns.js +56 -0
  18. package/dist/assistant/attachmentUploads.d.ts +42 -0
  19. package/dist/assistant/attachmentUploads.js +69 -0
  20. package/dist/assistant/canvasLink.d.ts +30 -0
  21. package/dist/assistant/canvasLink.js +51 -0
  22. package/dist/assistant/compositionMention.d.ts +18 -0
  23. package/dist/assistant/compositionMention.js +47 -0
  24. package/dist/assistant/liveData.d.ts +150 -0
  25. package/dist/assistant/liveData.js +286 -0
  26. package/dist/assistant/mcpMention.d.ts +20 -0
  27. package/dist/assistant/mcpMention.js +30 -0
  28. package/dist/assistant/mentionEntries.d.ts +39 -0
  29. package/dist/assistant/mentionEntries.js +69 -0
  30. package/dist/assistant/planFlow.d.ts +26 -0
  31. package/dist/assistant/planFlow.js +57 -0
  32. package/dist/assistant/templateDestinations.d.ts +37 -0
  33. package/dist/assistant/templateDestinations.js +64 -0
  34. package/dist/assistant/types.d.ts +99 -2
  35. package/dist/assistant/workflowPlanViewModel.d.ts +13 -2
  36. package/dist/assistant/workflowPlanViewModel.js +9 -1
  37. package/dist/components/Workflows.svelte +7 -1
  38. package/dist/components/WorkflowsWorkspace.svelte +29 -1
  39. package/dist/components/WorkflowsWorkspace.svelte.d.ts +3 -0
  40. package/dist/components/assistant/AssistantPlanStepRow.svelte +56 -0
  41. package/dist/components/assistant/AssistantPlanStepRow.svelte.d.ts +9 -0
  42. package/dist/components/assistant/CompositionMentionMenu.svelte +135 -0
  43. package/dist/components/assistant/CompositionMentionMenu.svelte.d.ts +9 -0
  44. package/dist/components/assistant/DataPreviewCard.svelte +108 -0
  45. package/dist/components/assistant/DataPreviewCard.svelte.d.ts +7 -0
  46. package/dist/components/assistant/PlanBindingsBlock.svelte +200 -0
  47. package/dist/components/assistant/PlanBindingsBlock.svelte.d.ts +14 -0
  48. package/dist/components/assistant/TemplateProjectCard.svelte +81 -0
  49. package/dist/components/assistant/TemplateProjectCard.svelte.d.ts +14 -0
  50. package/dist/components/assistant/WorkflowAssistantPanel.svelte +1045 -147
  51. package/dist/components/assistant/WorkflowAssistantPanel.svelte.d.ts +5 -0
  52. package/dist/components/canvas/CanvasContextMenu.svelte +199 -0
  53. package/dist/components/canvas/CanvasContextMenu.svelte.d.ts +16 -0
  54. package/dist/components/canvas/CompositionNodeView.svelte +7 -2
  55. package/dist/components/canvas/ConditionNodeView.svelte +5 -1
  56. package/dist/components/canvas/HandlePoint.svelte +25 -3
  57. package/dist/components/canvas/WorkflowCanvas.svelte +351 -12
  58. package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +12 -1
  59. package/dist/components/canvas/altDragDuplicateController.d.ts +29 -0
  60. package/dist/components/canvas/altDragDuplicateController.js +92 -0
  61. package/dist/components/canvas/connectionSnapController.d.ts +29 -0
  62. package/dist/components/canvas/connectionSnapController.js +182 -0
  63. package/dist/components/canvas/spacePanController.d.ts +16 -0
  64. package/dist/components/canvas/spacePanController.js +103 -0
  65. package/dist/components/editor/EditorCanvasArea.svelte +98 -4
  66. package/dist/components/editor/EditorCanvasArea.svelte.d.ts +5 -0
  67. package/dist/components/editor/EditorLoadFailure.svelte +53 -0
  68. package/dist/components/editor/EditorLoadFailure.svelte.d.ts +7 -0
  69. package/dist/components/editor/EditorTopBar.svelte +53 -42
  70. package/dist/components/editor/WorkflowEditor.svelte +74 -50
  71. package/dist/components/editor/WorkflowEditor.svelte.d.ts +5 -0
  72. package/dist/components/editor/WorkflowNameControl.svelte +9 -8
  73. package/dist/components/editor/WorkflowNameControl.svelte.d.ts +3 -1
  74. package/dist/components/list/WorkflowList.svelte +43 -41
  75. package/dist/components/list/WorkflowList.svelte.d.ts +5 -0
  76. package/dist/components/panel/CompositionForm.svelte +3 -2
  77. package/dist/components/panel/CompositionPicker.svelte +25 -23
  78. package/dist/components/panel/CompositionPicker.svelte.d.ts +2 -2
  79. package/dist/components/panel/CompositionSelect.svelte +4 -4
  80. package/dist/components/panel/CompositionSelect.svelte.d.ts +2 -2
  81. package/dist/components/ui/ErrorState.svelte +43 -0
  82. package/dist/components/ui/ErrorState.svelte.d.ts +13 -0
  83. package/dist/components/ui/icons.d.ts +8 -0
  84. package/dist/components/ui/icons.js +24 -1
  85. package/dist/editor/apiErrorText.d.ts +2 -0
  86. package/dist/editor/apiErrorText.js +15 -0
  87. package/dist/editor/autoLayout.d.ts +38 -0
  88. package/dist/editor/autoLayout.js +403 -0
  89. package/dist/editor/blockClipboard.svelte.d.ts +9 -0
  90. package/dist/editor/blockClipboard.svelte.js +24 -0
  91. package/dist/editor/blockCopy.d.ts +39 -0
  92. package/dist/editor/blockCopy.js +137 -0
  93. package/dist/editor/canvasMenu.d.ts +45 -0
  94. package/dist/editor/canvasMenu.js +68 -0
  95. package/dist/editor/connectionSnap.d.ts +90 -0
  96. package/dist/editor/connectionSnap.js +98 -0
  97. package/dist/editor/editorState.svelte.d.ts +122 -13
  98. package/dist/editor/editorState.svelte.js +262 -22
  99. package/dist/editor/graphIssues.d.ts +5 -0
  100. package/dist/editor/graphIssues.js +18 -0
  101. package/dist/editor/graphModel.d.ts +6 -1
  102. package/dist/editor/graphModel.js +8 -1
  103. package/dist/editor/keyHints.d.ts +21 -0
  104. package/dist/editor/keyHints.js +30 -0
  105. package/dist/editor/listState.svelte.d.ts +4 -4
  106. package/dist/editor/listState.svelte.js +3 -1
  107. package/dist/editor/staleGuard.d.ts +111 -0
  108. package/dist/editor/staleGuard.js +279 -0
  109. package/dist/i18n/language.d.ts +3 -3
  110. package/dist/i18n/messages.d.ts +85 -1
  111. package/dist/i18n/messages.js +99 -4
  112. package/dist/index.d.ts +1 -0
  113. package/dist/types/index.d.ts +19 -2
  114. package/package.json +10 -10
@@ -1,7 +1,8 @@
1
1
  <!--
2
2
  A list of the compositions a person may use in a workflow, with a search above it. Used where a composition is chosen: when a
3
3
  workflow is made, and on a composition block. Each line has the composition's picture and name; one that is already in the
4
- workflow is shown but cannot be chosen again (a composition has one block), and one whose widget was never published says so.
4
+ workflow says so and can still be chosen (the same composition may sit on several blocks), and one whose widget was never
5
+ published says so too.
5
6
 
6
7
  It asks the API for twenty at a time (`composition-options`), and for the next twenty when asked. Every search replaces the
7
8
  one before it: an answer to an older search that arrives late is dropped.
@@ -23,8 +24,8 @@
23
24
  interface Props {
24
25
  /** The composition that is chosen now, if any. */
25
26
  selectedId?: string | null;
26
- /** Compositions already in the workflow: shown, but cannot be chosen. */
27
- takenIds?: readonly string[];
27
+ /** Compositions already on a block of the workflow: marked as such, and still free to choose again. */
28
+ usedIds?: readonly string[];
28
29
  /** Called with every composition the person picks, so the owner can remember its name and picture. */
29
30
  onpick: (option: CompositionOption) => void;
30
31
  /** Called with each page of compositions that was read, so the owner can remember them. */
@@ -36,7 +37,7 @@
36
37
  bordered?: boolean;
37
38
  }
38
39
 
39
- let { selectedId = null, takenIds = [], onpick, onread, bordered = true }: Props = $props();
40
+ let { selectedId = null, usedIds = [], onpick, onread, bordered = true }: Props = $props();
40
41
 
41
42
  const PAGE_SIZE = 20;
42
43
  const SEARCH_DELAY_MILLISECONDS = 300;
@@ -54,7 +55,7 @@
54
55
  let controller: AbortController | null = null;
55
56
  let searchTimer: ReturnType<typeof setTimeout> | null = null;
56
57
 
57
- const taken = $derived(new Set(takenIds));
58
+ const used = $derived(new Set(usedIds));
58
59
  const hasMore = $derived(items.length < total);
59
60
 
60
61
  /** Reads the first page for what is in the search box now (or the next page, when `append`). */
@@ -62,9 +63,9 @@
62
63
  controller?.abort();
63
64
  const current = new AbortController();
64
65
  controller = current;
66
+ // No loading state is set here. The first read starts as 'loading' (the initial value) and "Try again" sets it itself, so a
67
+ // search (even one that follows "no compositions") keeps what is on the screen until its answer arrives.
65
68
  if (append) isLoadingMore = true;
66
- else loadState = items.length === 0 ? 'loading' : loadState;
67
- failureKey = null;
68
69
  try {
69
70
  const trimmed = search.trim();
70
71
  const page = await api.listCompositionOptions(
@@ -80,6 +81,7 @@
80
81
  items = append ? [...items, ...page.items.filter((item) => !known.has(item.id))] : page.items;
81
82
  total = page.total;
82
83
  loadState = 'ready';
84
+ failureKey = null;
83
85
  onread?.(page.items);
84
86
  } catch (error) {
85
87
  if (isCancelled(error)) return;
@@ -91,6 +93,12 @@
91
93
  }
92
94
  }
93
95
 
96
+ /** "Try again" after a failed read: the person asked for it, so the loading line shows until the answer arrives. */
97
+ function retry(): void {
98
+ loadState = 'loading';
99
+ void read(false);
100
+ }
101
+
94
102
  function handleSearchChange(): void {
95
103
  if (searchTimer !== null) clearTimeout(searchTimer);
96
104
  searchTimer = setTimeout(() => {
@@ -128,7 +136,7 @@
128
136
  {:else if loadState === 'failed'}
129
137
  <div class="flex flex-col items-start gap-2 py-2">
130
138
  <p class="text-body text-destructive" role="alert">{failureKey ? $t(failureKey) : ''}</p>
131
- <Button size={dsButtonSize("small")} onclick={() => void read(false)}>
139
+ <Button size={dsButtonSize("small")} onclick={retry}>
132
140
  {$t('workflows.error.retry')}
133
141
  </Button>
134
142
  </div>
@@ -145,15 +153,14 @@
145
153
  >
146
154
  {#each items as option (option.id)}
147
155
  {@const isSelected = option.id === selectedId}
148
- {@const isTaken = taken.has(option.id) && !isSelected}
156
+ {@const isUsed = used.has(option.id) && !isSelected}
149
157
  <li role="none">
150
158
  <button
151
159
  type="button"
152
- disabled={isTaken}
153
160
  role="option"
154
161
  aria-selected={isSelected}
155
162
  aria-current={isSelected ? 'true' : undefined}
156
- class="focus-visible:ring-ring flex w-full items-center gap-3 rounded-lg px-2 py-2 text-start text-body text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background {isSelected
163
+ class="focus-visible:ring-ring flex w-full items-center gap-3 rounded-lg px-2 py-2 text-start text-body text-foreground hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background {isSelected
157
164
  ? 'bg-brand-subtle text-brand-foreground'
158
165
  : ''}"
159
166
  onclick={() => onpick(option)}
@@ -175,18 +182,13 @@
175
182
  {/if}
176
183
  <span class="flex min-w-0 flex-1 flex-col gap-0.5 text-start">
177
184
  <span class="text-body-medium truncate" dir="auto">{option.name}</span>
178
- {#if isTaken}
179
- <span class="text-caption text-muted-foreground"
180
- >{$t('workflows.composition.alreadyUsed')}</span
181
- >
182
- {:else}
183
- <!-- Whether the widget is published, as the design's rows say it. -->
184
- <span class="text-caption text-muted-foreground">
185
- {option.published
186
- ? $t('workflows.block.publishedMeta')
187
- : $t('workflows.block.notPublished')}
188
- </span>
189
- {/if}
185
+ <!-- Whether the widget is published, as the design's rows say it, and that it is already in the workflow. -->
186
+ <span class="text-caption text-muted-foreground">
187
+ {option.published
188
+ ? $t('workflows.block.publishedMeta')
189
+ : $t('workflows.block.notPublished')}{#if isUsed}
190
+ · {$t('workflows.composition.alreadyUsed')}{/if}
191
+ </span>
190
192
  </span>
191
193
  {#if isSelected}<Icon name="check" class="text-brand-foreground size-4 shrink-0" />{/if}
192
194
  </button>
@@ -2,8 +2,8 @@ import type { CompositionOption } from '../../api/types.js';
2
2
  interface Props {
3
3
  /** The composition that is chosen now, if any. */
4
4
  selectedId?: string | null;
5
- /** Compositions already in the workflow: shown, but cannot be chosen. */
6
- takenIds?: readonly string[];
5
+ /** Compositions already on a block of the workflow: marked as such, and still free to choose again. */
6
+ usedIds?: readonly string[];
7
7
  /** Called with every composition the person picks, so the owner can remember its name and picture. */
8
8
  onpick: (option: CompositionOption) => void;
9
9
  /** Called with each page of compositions that was read, so the owner can remember them. */
@@ -25,8 +25,8 @@
25
25
  help?: string | null;
26
26
  /** The composition that is chosen now, so the list marks it. */
27
27
  selectedId: string | null;
28
- /** Compositions that are already in the workflow: the list shows them but they cannot be chosen again. */
29
- takenIds?: readonly string[];
28
+ /** Compositions that are already on a block of the workflow: the list says so, and they can still be chosen again. */
29
+ usedIds?: readonly string[];
30
30
  /** The person picked a line (the line that is already chosen too: the owner decides what that means). */
31
31
  onpick: (option: CompositionOption) => void;
32
32
  /** Each page of compositions the list read, so the owner can remember their names and pictures. */
@@ -40,7 +40,7 @@
40
40
  placeholder,
41
41
  help = null,
42
42
  selectedId,
43
- takenIds = [],
43
+ usedIds = [],
44
44
  onpick,
45
45
  onread,
46
46
  disabled = false
@@ -103,7 +103,7 @@
103
103
  {/if}
104
104
  {#if isOpen}
105
105
  <div id="{fieldId}-list" class="flex min-h-0 flex-col">
106
- <CompositionPicker {selectedId} {takenIds} onpick={pick} {onread} />
106
+ <CompositionPicker {selectedId} {usedIds} onpick={pick} {onread} />
107
107
  </div>
108
108
  {/if}
109
109
  </div>
@@ -10,8 +10,8 @@ interface Props {
10
10
  help?: string | null;
11
11
  /** The composition that is chosen now, so the list marks it. */
12
12
  selectedId: string | null;
13
- /** Compositions that are already in the workflow: the list shows them but they cannot be chosen again. */
14
- takenIds?: readonly string[];
13
+ /** Compositions that are already on a block of the workflow: the list says so, and they can still be chosen again. */
14
+ usedIds?: readonly string[];
15
15
  /** The person picked a line (the line that is already chosen too: the owner decides what that means). */
16
16
  onpick: (option: CompositionOption) => void;
17
17
  /** Each page of compositions the list read, so the owner can remember their names and pictures. */
@@ -0,0 +1,43 @@
1
+ <!--
2
+ Figma "Error State" (component set 139:2): what a page or a list shows when it could not be read. The placeholder stands in
3
+ the middle of the space it has: a tile with the red alert, a title, one line that says what happened, and under them the
4
+ way on. The design has ONE primary action (a second one is the quiet outline button, and only when it is a real way out);
5
+ the actions come from the screen, because what helps differs (a failure that passes is tried again, a workflow that is
6
+ gone is left for the list).
7
+
8
+ The whole block is an alert, so a screen reader hears it as soon as it appears.
9
+ -->
10
+ <script lang="ts">
11
+ import type { Snippet } from 'svelte';
12
+ import Icon from './Icon.svelte';
13
+
14
+ interface Props {
15
+ /** What failed, in a few words. */
16
+ title: string;
17
+ /** The line under it: what happened, or what to try. */
18
+ description: string;
19
+ /** The buttons under the text (the first is the primary one). Nothing is drawn under the text when there are none. */
20
+ actions?: Snippet;
21
+ class?: string;
22
+ }
23
+
24
+ let { title, description, actions, class: className = '' }: Props = $props();
25
+ </script>
26
+
27
+ <div class="flex flex-1 flex-col items-center justify-center px-4 py-12 {className}">
28
+ <div class="flex w-120 max-w-full flex-col items-center gap-3 px-12 text-center" role="alert">
29
+ <div class="flex size-12 items-center justify-center rounded-xl bg-destructive/10">
30
+ <Icon name="warning" class="size-4 text-destructive" />
31
+ </div>
32
+ <div class="flex w-full flex-col gap-1">
33
+ <h2 class="text-heading-section text-foreground">{title}</h2>
34
+ <!-- Balanced, so a reason that needs two lines does not leave one word alone on the second ("... may have been / deleted."). -->
35
+ <p class="text-body text-muted-foreground text-balance">{description}</p>
36
+ </div>
37
+ {#if actions}
38
+ <div class="flex flex-wrap items-center justify-center gap-2 pt-3">
39
+ {@render actions()}
40
+ </div>
41
+ {/if}
42
+ </div>
43
+ </div>
@@ -0,0 +1,13 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ /** What failed, in a few words. */
4
+ title: string;
5
+ /** The line under it: what happened, or what to try. */
6
+ description: string;
7
+ /** The buttons under the text (the first is the primary one). Nothing is drawn under the text when there are none. */
8
+ actions?: Snippet;
9
+ class?: string;
10
+ }
11
+ declare const ErrorState: import("svelte").Component<Props, {}, "">;
12
+ type ErrorState = ReturnType<typeof ErrorState>;
13
+ export default ErrorState;
@@ -46,5 +46,13 @@ export declare const ICON_PATHS: {
46
46
  readonly condition: readonly ["M12 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0", "M7 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0", "M17 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0", "M7 8v2a2 2 0 0 0 2 2h6a2 2 0 0 0 2 -2v-2", "M12 12l0 4"];
47
47
  /** Small pencil shown on hover beside an editable title. */
48
48
  readonly pencil: readonly ["M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4", "M13.5 6.5l4 4"];
49
+ /** Arrow to the right, Tabler arrow-right: between the widgets of the flow in a plan. */
50
+ readonly arrowRight: readonly ["M5 12l14 0", "M13 18l6 -6", "M13 6l6 6"];
51
+ /** Chat / assistant, Tabler message-circle (the `Icon/message-circle` of the design's icon page). */
52
+ readonly chat: readonly ["M3 20l1.3 -3.9a9 8 0 1 1 3.4 2.9l-4.7 1"];
53
+ /** A document, Tabler file (the `Icon/file` of the design's icon page): the leading icon of an attached file's chip. */
54
+ readonly file: readonly ["M14 3v4a1 1 0 0 0 1 1h4", "M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"];
55
+ readonly plugConnected: readonly ["M7 12l5 5l-1.5 1.5a3.536 3.536 0 1 1 -5 -5l1.5 -1.5", "M17 12l-5 -5l1.5 -1.5a3.536 3.536 0 1 1 5 5l-1.5 1.5", "M3 21l2.5 -2.5", "M18.5 5.5l2.5 -2.5", "M10 11l-2 2", "M13 14l-2 2"];
56
+ readonly table: readonly ["M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14", "M3 10h18", "M10 3v18"];
49
57
  };
50
58
  export type IconName = keyof typeof ICON_PATHS;
@@ -112,6 +112,29 @@ export const ICON_PATHS = {
112
112
  'M12 12l0 4'
113
113
  ],
114
114
  /** Small pencil shown on hover beside an editable title. */
115
- pencil: ['M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4', 'M13.5 6.5l4 4']
115
+ pencil: ['M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4', 'M13.5 6.5l4 4'],
116
+ /** Arrow to the right, Tabler arrow-right: between the widgets of the flow in a plan. */
117
+ arrowRight: ['M5 12l14 0', 'M13 18l6 -6', 'M13 6l6 6'],
118
+ /** Chat / assistant, Tabler message-circle (the `Icon/message-circle` of the design's icon page). */
119
+ chat: ['M3 20l1.3 -3.9a9 8 0 1 1 3.4 2.9l-4.7 1'],
120
+ /** A document, Tabler file (the `Icon/file` of the design's icon page): the leading icon of an attached file's chip. */
121
+ file: [
122
+ 'M14 3v4a1 1 0 0 0 1 1h4',
123
+ 'M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z'
124
+ ],
125
+ // An Open MCP of the person (a server they connected), and a table of values (what a call would show).
126
+ plugConnected: [
127
+ 'M7 12l5 5l-1.5 1.5a3.536 3.536 0 1 1 -5 -5l1.5 -1.5',
128
+ 'M17 12l-5 -5l1.5 -1.5a3.536 3.536 0 1 1 5 5l-1.5 1.5',
129
+ 'M3 21l2.5 -2.5',
130
+ 'M18.5 5.5l2.5 -2.5',
131
+ 'M10 11l-2 2',
132
+ 'M13 14l-2 2'
133
+ ],
134
+ table: [
135
+ 'M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14',
136
+ 'M3 10h18',
137
+ 'M10 3v18'
138
+ ]
116
139
  // [extra icons]
117
140
  };
@@ -8,3 +8,5 @@ import type { WorkflowsMessageKey } from '../i18n/messages.js';
8
8
  * nothing went wrong, so nothing is said.
9
9
  */
10
10
  export declare function pickApiErrorMessage(error: unknown): WorkflowsMessageKey | null;
11
+ /** Whether trying the same request again can work, for a failure that `pickApiErrorMessage` put into words. */
12
+ export declare function isRetryableFailure(messageKey: WorkflowsMessageKey): boolean;
@@ -60,3 +60,18 @@ export function pickApiErrorMessage(error) {
60
60
  return 'workflows.error.server';
61
61
  return 'workflows.error.generic';
62
62
  }
63
+ /**
64
+ * The failures that asking again cannot change: the workflow is not there (it was deleted, or the address is not right),
65
+ * the plan has no workflows, the session has ended. A screen that could not read something offers "Try again" for every
66
+ * other failure (offline, too slow, a server that had a problem, too many requests, one that is not known), which may be
67
+ * passing, and a way out instead for these.
68
+ */
69
+ const FAILURES_THAT_STAY = new Set([
70
+ 'workflows.error.notFound',
71
+ 'workflows.error.planRestricted',
72
+ 'workflows.error.sessionEnded'
73
+ ]);
74
+ /** Whether trying the same request again can work, for a failure that `pickApiErrorMessage` put into words. */
75
+ export function isRetryableFailure(messageKey) {
76
+ return !FAILURES_THAT_STAY.has(messageKey);
77
+ }
@@ -0,0 +1,38 @@
1
+ import type { NodePosition, WorkflowGraph, WorkflowNode } from '@widgetic/workflows-engine';
2
+ /** What the layout needs to know about one block. Sizes are in canvas units; offsets are from the top of the block. */
3
+ export interface BlockMeasure {
4
+ width: number;
5
+ height: number;
6
+ /** The centre of the connection point lines come in at (default: the middle of the block). */
7
+ inputOffset?: number;
8
+ /** The centre of each place a line leaves from, by port: `out`, a rule's id or `default` (default: the middle). */
9
+ outputOffsets?: Readonly<Record<string, number>>;
10
+ }
11
+ export interface OrganiseOptions {
12
+ /** What the canvas measured of a block. A block it has no answer for gets an estimate. */
13
+ measureBlock?: (node: WorkflowNode) => BlockMeasure | undefined;
14
+ /** The room between two columns (default `COLUMN_GAP`). */
15
+ columnGap?: number;
16
+ /** The room between two blocks of a column (default `ROW_GAP`). */
17
+ rowGap?: number;
18
+ /** The room between two groups of blocks that are not connected (default `GROUP_GAP`). */
19
+ groupGap?: number;
20
+ /** Where the top left corner of the result goes (default: where the top left corner of the blocks is now). */
21
+ origin?: NodePosition;
22
+ }
23
+ /** The room between two columns: enough for the line between them to be seen and for its arrow. */
24
+ export declare const COLUMN_GAP = 120;
25
+ export declare const ROW_GAP = 48;
26
+ export declare const GROUP_GAP = 96;
27
+ /**
28
+ * How wide a row of blocks that are not connected may be at least, in canvas units: four compositions side by side. A row is
29
+ * as wide as the widest group of connected blocks when that one is wider, so the grid lines up with the flow above it.
30
+ */
31
+ export declare const SHELF_MIN_WIDTH = 1500;
32
+ /** The ports of a block in the order they are drawn, top to bottom. */
33
+ export declare function listPorts(node: WorkflowNode): string[];
34
+ /**
35
+ * Where each block of the graph goes, as the new graph. A graph with no blocks, or in which no block needs to move, comes
36
+ * back as it is.
37
+ */
38
+ export declare function organiseGraph(graph: WorkflowGraph, options?: OrganiseOptions): WorkflowGraph;