windmill-components 1.35.42 → 1.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/components/AppConnect.svelte +85 -59
  2. package/components/ArgInput.svelte +50 -33
  3. package/components/ArgInput.svelte.d.ts +1 -1
  4. package/components/Button.svelte +15 -48
  5. package/components/Button.svelte.d.ts +1 -1
  6. package/components/CronInput.svelte +1 -1
  7. package/components/DisplayResult.svelte +75 -67
  8. package/components/Dropdown.svelte +9 -7
  9. package/components/Editor.svelte +187 -178
  10. package/components/Editor.svelte.d.ts +4 -2
  11. package/components/EditorBar.svelte +135 -98
  12. package/components/EditorBar.svelte.d.ts +2 -1
  13. package/components/FlowBuilder.svelte +115 -134
  14. package/components/FlowJobResult.svelte +4 -5
  15. package/components/FlowModulesViewer.svelte +89 -7
  16. package/components/FlowModulesViewer.svelte.d.ts +1 -0
  17. package/components/FlowPreviewContent.svelte +88 -27
  18. package/components/FlowPreviewContent.svelte.d.ts +1 -1
  19. package/components/FlowStatusViewer.svelte +39 -24
  20. package/components/FlowStatusViewer.svelte.d.ts +0 -1
  21. package/components/FlowViewer.svelte +17 -11
  22. package/components/GroupModal.svelte +10 -1
  23. package/components/HighlightCode.svelte +22 -0
  24. package/components/HighlightCode.svelte.d.ts +17 -0
  25. package/components/IconedPath.svelte +9 -7
  26. package/components/InputTransformForm.svelte +97 -115
  27. package/components/InputTransformForm.svelte.d.ts +0 -1
  28. package/components/InputTransformsViewer.svelte +1 -1
  29. package/components/InviteGlobalUser.svelte +8 -8
  30. package/components/InviteUser.svelte +9 -9
  31. package/components/ItemPicker.svelte +37 -30
  32. package/components/ItemPicker.svelte.d.ts +2 -1
  33. package/components/JobStatus.svelte +2 -1
  34. package/components/LogViewer.svelte +23 -0
  35. package/components/LogViewer.svelte.d.ts +19 -0
  36. package/components/ModulePreview.svelte +107 -0
  37. package/components/ModulePreview.svelte.d.ts +24 -0
  38. package/components/Path.svelte +1 -1
  39. package/components/RadioButton.svelte +3 -2
  40. package/components/ResourceEditor.svelte +22 -34
  41. package/components/ResourceTypePicker.svelte +23 -34
  42. package/components/RunForm.svelte +34 -31
  43. package/components/RunForm.svelte.d.ts +6 -2
  44. package/components/SchemaEditor.svelte +19 -11
  45. package/components/SchemaForm.svelte +3 -3
  46. package/components/SchemaForm.svelte.d.ts +1 -1
  47. package/components/SchemaModal.svelte +18 -7
  48. package/components/ScriptBuilder.svelte +99 -83
  49. package/components/ScriptBuilder.svelte.d.ts +2 -4
  50. package/components/ScriptEditor.svelte +71 -143
  51. package/components/ScriptEditor.svelte.d.ts +0 -5
  52. package/components/ScriptPicker.svelte +24 -14
  53. package/components/ScriptPicker.svelte.d.ts +2 -1
  54. package/components/ScriptSchema.svelte +8 -11
  55. package/components/ScriptSchema.svelte.d.ts +0 -1
  56. package/components/ShareModal.svelte +6 -6
  57. package/components/SharedBadge.svelte +5 -13
  58. package/components/SimpleEditor.svelte +14 -10
  59. package/components/StringTypeNarrowing.svelte +24 -30
  60. package/components/TestJobLoader.svelte +106 -0
  61. package/components/TestJobLoader.svelte.d.ts +26 -0
  62. package/components/Tooltip.svelte +3 -2
  63. package/components/VariableEditor.svelte +15 -24
  64. package/components/common/actionRow/ActionRow.svelte +31 -0
  65. package/components/common/actionRow/ActionRow.svelte.d.ts +22 -0
  66. package/components/common/alert/Alert.svelte +53 -0
  67. package/components/common/alert/Alert.svelte.d.ts +20 -0
  68. package/components/common/alert/model.d.ts +1 -0
  69. package/components/common/alert/model.js +1 -0
  70. package/components/common/badge/Badge.svelte +76 -0
  71. package/components/common/badge/Badge.svelte.d.ts +28 -0
  72. package/components/common/badge/model.d.ts +8 -0
  73. package/components/common/badge/model.js +1 -0
  74. package/components/common/button/Button.svelte +110 -0
  75. package/components/common/button/Button.svelte.d.ts +39 -0
  76. package/components/common/button/model.d.ts +6 -0
  77. package/components/common/button/model.js +1 -0
  78. package/components/common/confirmationModal/ConfirmationModal.svelte +72 -0
  79. package/components/common/confirmationModal/ConfirmationModal.svelte.d.ts +23 -0
  80. package/components/common/confirmationModal/UnsavedConfirmationModal.svelte +41 -0
  81. package/components/common/confirmationModal/UnsavedConfirmationModal.svelte.d.ts +14 -0
  82. package/components/common/confirmationModal/dirtyStore.d.ts +1 -0
  83. package/components/common/confirmationModal/dirtyStore.js +2 -0
  84. package/components/common/drawer/Drawer.svelte +3 -0
  85. package/components/common/drawer/Drawer.svelte.d.ts +2 -0
  86. package/components/common/index.d.ts +14 -0
  87. package/components/common/index.js +14 -0
  88. package/components/common/tabs/TabContent.svelte +3 -2
  89. package/components/common/tabs/TabContent.svelte.d.ts +1 -0
  90. package/components/common/tabs/Tabs.svelte +8 -1
  91. package/components/common/tabs/Tabs.svelte.d.ts +2 -0
  92. package/components/common/toggleButton/ToggleButton.svelte +20 -0
  93. package/components/common/toggleButton/ToggleButton.svelte.d.ts +19 -0
  94. package/components/common/toggleButton/ToggleButtonGroup.svelte +33 -0
  95. package/components/common/toggleButton/ToggleButtonGroup.svelte.d.ts +24 -0
  96. package/components/flows/FlowEditor.svelte +30 -0
  97. package/components/{FlowEditor.svelte.d.ts → flows/FlowEditor.svelte.d.ts} +1 -6
  98. package/components/flows/common/FlowCard.svelte +9 -0
  99. package/components/flows/common/FlowCard.svelte.d.ts +21 -0
  100. package/components/flows/common/FlowCardHeader.svelte +39 -0
  101. package/components/flows/common/FlowCardHeader.svelte.d.ts +20 -0
  102. package/components/flows/content/CopyFirstStepSchema.svelte +13 -0
  103. package/components/flows/{CopyFirstStepSchema.svelte.d.ts → content/CopyFirstStepSchema.svelte.d.ts} +0 -0
  104. package/components/flows/{DynamicInputHelpBox.svelte → content/DynamicInputHelpBox.svelte} +0 -0
  105. package/components/flows/{DynamicInputHelpBox.svelte.d.ts → content/DynamicInputHelpBox.svelte.d.ts} +0 -0
  106. package/components/flows/content/FlowEditorPanel.svelte +25 -0
  107. package/components/flows/content/FlowEditorPanel.svelte.d.ts +16 -0
  108. package/components/flows/content/FlowFailureModule.svelte +15 -0
  109. package/components/flows/content/FlowFailureModule.svelte.d.ts +14 -0
  110. package/components/flows/content/FlowInput.svelte +26 -0
  111. package/components/flows/{FlowInput.svelte.d.ts → content/FlowInput.svelte.d.ts} +0 -0
  112. package/components/flows/content/FlowInputs.svelte +91 -0
  113. package/components/flows/{FlowInputs.svelte.d.ts → content/FlowInputs.svelte.d.ts} +1 -0
  114. package/components/flows/content/FlowLoop.svelte +168 -0
  115. package/components/flows/content/FlowLoop.svelte.d.ts +18 -0
  116. package/components/flows/content/FlowLoopWrapper.svelte +9 -0
  117. package/components/flows/content/FlowLoopWrapper.svelte.d.ts +14 -0
  118. package/components/flows/content/FlowModule.svelte +211 -0
  119. package/components/flows/content/FlowModule.svelte.d.ts +29 -0
  120. package/components/flows/content/FlowModuleEarlyStop.svelte +76 -0
  121. package/components/flows/content/FlowModuleEarlyStop.svelte.d.ts +17 -0
  122. package/components/flows/content/FlowModuleHeader.svelte +157 -0
  123. package/components/flows/{FlowModuleHeader.svelte.d.ts → content/FlowModuleHeader.svelte.d.ts} +5 -3
  124. package/components/flows/content/FlowModuleScript.svelte +21 -0
  125. package/components/flows/content/FlowModuleScript.svelte.d.ts +17 -0
  126. package/components/flows/content/FlowModuleSuspend.svelte +27 -0
  127. package/components/flows/content/FlowModuleSuspend.svelte.d.ts +17 -0
  128. package/components/flows/content/FlowModuleWrapper.svelte +45 -0
  129. package/components/flows/content/FlowModuleWrapper.svelte.d.ts +14 -0
  130. package/components/flows/content/FlowRetries.svelte +80 -0
  131. package/components/flows/content/FlowRetries.svelte.d.ts +17 -0
  132. package/components/flows/content/FlowSchedules.svelte +18 -0
  133. package/components/flows/content/FlowSchedules.svelte.d.ts +14 -0
  134. package/components/flows/content/FlowSettings.svelte +78 -0
  135. package/components/flows/{FlowSettings.svelte.d.ts → content/FlowSettings.svelte.d.ts} +2 -6
  136. package/components/flows/content/RemoveStepConfirmationModal.svelte +32 -0
  137. package/components/flows/content/RemoveStepConfirmationModal.svelte.d.ts +19 -0
  138. package/components/flows/flowState.d.ts +8 -7
  139. package/components/flows/flowState.js +25 -46
  140. package/components/flows/flowStateUtils.d.ts +16 -14
  141. package/components/flows/flowStateUtils.js +81 -73
  142. package/components/flows/flowStore.js +7 -4
  143. package/components/flows/header/FlowImportExportMenu.svelte +55 -0
  144. package/components/flows/header/FlowImportExportMenu.svelte.d.ts +14 -0
  145. package/components/flows/header/FlowPreviewButtons.svelte +57 -0
  146. package/components/flows/header/FlowPreviewButtons.svelte.d.ts +14 -0
  147. package/components/flows/map/FlowErrorHandlerItem.svelte +60 -0
  148. package/components/flows/map/FlowErrorHandlerItem.svelte.d.ts +14 -0
  149. package/components/flows/map/FlowModuleSchemaItem.svelte +80 -0
  150. package/components/flows/map/FlowModuleSchemaItem.svelte.d.ts +32 -0
  151. package/components/flows/map/FlowModuleSchemaMap.svelte +241 -0
  152. package/components/flows/map/FlowModuleSchemaMap.svelte.d.ts +20 -0
  153. package/components/flows/pickers/PickHubScript.svelte +5 -3
  154. package/components/flows/pickers/PickHubScript.svelte.d.ts +2 -1
  155. package/components/flows/pickers/PickScript.svelte +4 -12
  156. package/components/flows/pickers/PickScript.svelte.d.ts +1 -1
  157. package/components/flows/propPicker/PropPickerWrapper.svelte +44 -0
  158. package/components/flows/propPicker/PropPickerWrapper.svelte.d.ts +33 -0
  159. package/components/flows/scheduleUtils.d.ts +0 -1
  160. package/components/flows/scheduleUtils.js +0 -1
  161. package/components/flows/types.d.ts +8 -0
  162. package/components/flows/types.js +1 -0
  163. package/components/flows/utils.d.ts +3 -1
  164. package/components/flows/utils.js +26 -10
  165. package/components/icons/AirtableIcon.svelte +1 -1
  166. package/components/icons/DiscordIcon.svelte +1 -1
  167. package/components/icons/GCloudIcon.svelte +1 -1
  168. package/components/icons/GItlabIcon.svelte +1 -1
  169. package/components/icons/GSheetsIcon.svelte +1 -1
  170. package/components/icons/GcalIcon.svelte +1 -1
  171. package/components/icons/GdriveIcon.svelte +1 -1
  172. package/components/icons/GithubIcon.svelte +1 -1
  173. package/components/icons/GmailIcon.svelte +1 -1
  174. package/components/icons/HatIcon.svelte +19 -0
  175. package/components/icons/HatIcon.svelte.d.ts +16 -0
  176. package/components/icons/MastodonIcon.svelte +1 -1
  177. package/components/icons/MatrixIcon.svelte +1 -1
  178. package/components/icons/PostgresIcon.svelte +1 -1
  179. package/components/icons/S3Icon.svelte +1 -1
  180. package/components/icons/Slack.svelte +1 -1
  181. package/components/icons/TogglIcon.svelte +8 -46
  182. package/components/jobs/JobDetail.svelte +1 -1
  183. package/components/landing/FlowGettingStarted.svelte +22 -68
  184. package/components/landing/FlowLandingBox.svelte +1 -1
  185. package/components/landing/RessourceGettingStarted.svelte +7 -37
  186. package/components/landing/ScriptBox.svelte +33 -60
  187. package/components/landing/ScriptGettingStarted.svelte +23 -69
  188. package/components/propertyPicker/ObjectViewer.svelte +18 -12
  189. package/components/propertyPicker/ObjectViewer.svelte.d.ts +1 -0
  190. package/components/propertyPicker/PropPicker.svelte +108 -11
  191. package/components/propertyPicker/WarningMessage.svelte +2 -15
  192. package/components/script_editor/LogPanel.svelte +108 -119
  193. package/components/script_editor/LogPanel.svelte.d.ts +2 -0
  194. package/components/sidebar/SidebarContent.svelte +2 -2
  195. package/editorUtils.d.ts +3 -0
  196. package/editorUtils.js +1 -0
  197. package/gen/core/OpenAPI.js +1 -1
  198. package/gen/index.d.ts +1 -0
  199. package/gen/models/CompletedJob.d.ts +2 -1
  200. package/gen/models/CompletedJob.js +1 -0
  201. package/gen/models/FlowModule.d.ts +3 -0
  202. package/gen/models/FlowStatus.d.ts +3 -0
  203. package/gen/models/FlowStatusModule.d.ts +1 -1
  204. package/gen/models/Preview.d.ts +2 -1
  205. package/gen/models/Preview.js +1 -0
  206. package/gen/models/QueuedJob.d.ts +2 -1
  207. package/gen/models/QueuedJob.js +1 -0
  208. package/gen/models/RawScript.d.ts +2 -1
  209. package/gen/models/RawScript.js +1 -0
  210. package/gen/models/Retry.d.ts +11 -0
  211. package/gen/models/Retry.js +4 -0
  212. package/gen/models/Script.d.ts +9 -2
  213. package/gen/models/Script.js +8 -0
  214. package/gen/services/JobService.d.ts +40 -0
  215. package/gen/services/JobService.js +70 -0
  216. package/gen/services/ScriptService.d.ts +14 -3
  217. package/gen/services/ScriptService.js +13 -0
  218. package/infer.d.ts +1 -1
  219. package/infer.js +6 -1
  220. package/package.json +71 -38
  221. package/script_helpers.d.ts +8 -2
  222. package/script_helpers.js +88 -16
  223. package/stores.d.ts +1 -1
  224. package/utils.d.ts +8 -6
  225. package/utils.js +57 -21
  226. package/components/FlowEditor.svelte +0 -55
  227. package/components/FlowPreview.svelte +0 -107
  228. package/components/FlowPreview.svelte.d.ts +0 -23
  229. package/components/ModuleStep.svelte +0 -131
  230. package/components/ModuleStep.svelte.d.ts +0 -25
  231. package/components/flows/CopyFirstStepSchema.svelte +0 -13
  232. package/components/flows/FlowBox.svelte +0 -16
  233. package/components/flows/FlowBox.svelte.d.ts +0 -23
  234. package/components/flows/FlowBoxHeader.svelte +0 -16
  235. package/components/flows/FlowBoxHeader.svelte.d.ts +0 -21
  236. package/components/flows/FlowInput.svelte +0 -22
  237. package/components/flows/FlowInputs.svelte +0 -65
  238. package/components/flows/FlowModuleHeader.svelte +0 -109
  239. package/components/flows/FlowSettings.svelte +0 -165
  240. package/components/flows/FlowTimeline.svelte +0 -169
  241. package/components/flows/FlowTimeline.svelte.d.ts +0 -21
  242. package/components/flows/stepOpenedStore.d.ts +0 -1
  243. package/components/flows/stepOpenedStore.js +0 -6
  244. package/components/propertyPicker/OverlayPropertyPicker.svelte +0 -69
  245. package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +0 -24
@@ -1,14 +1,13 @@
1
- import { CompletedJob, Job, ScriptService } from '../../gen';
2
- import { initialCode } from '../../script_helpers';
1
+ import { CompletedJob, Job, Script, ScriptService } from '../../gen';
2
+ import { DENO_FAILURE_MODULE_CODE, initialCode } from '../../script_helpers';
3
3
  import { userStore, workspaceStore } from '../../stores';
4
- import { buildExtraLib, emptyModule, emptySchema, getScriptByPath, objectToTsType, schemaToObject, schemaToTsType } from '../../utils';
4
+ import { buildExtraLib, emptySchema, getScriptByPath, objectToTsType, schemaToObject, schemaToTsType } from '../../utils';
5
5
  import { get } from 'svelte/store';
6
6
  import { flowStateStore } from './flowState';
7
7
  import { flowStore } from './flowStore';
8
- import { jobsToResults, loadSchemaFromModule } from './utils';
9
- export function emptyFlowModuleSchema() {
8
+ import { loadSchemaFromModule } from './utils';
9
+ export function emptyFlowModuleState() {
10
10
  return {
11
- flowModule: emptyModule(),
12
11
  schema: emptySchema()
13
12
  };
14
13
  }
@@ -16,10 +15,10 @@ export async function loadFlowModuleSchema(flowModule) {
16
15
  try {
17
16
  const { input_transforms, schema } = await loadSchemaFromModule(flowModule);
18
17
  flowModule.input_transforms = input_transforms;
19
- return { flowModule, schema };
18
+ return { schema, previewResult: NEVER_TESTED_THIS_FAR };
20
19
  }
21
20
  catch (e) {
22
- return { flowModule, schema: emptySchema() };
21
+ return { schema: emptySchema(), previewResult: NEVER_TESTED_THIS_FAR };
23
22
  }
24
23
  }
25
24
  export async function pickScript(path) {
@@ -27,40 +26,42 @@ export async function pickScript(path) {
27
26
  value: { type: 'script', path },
28
27
  input_transforms: {}
29
28
  };
30
- return await loadFlowModuleSchema(flowModule);
29
+ return [flowModule, await loadFlowModuleSchema(flowModule)];
31
30
  }
32
- export async function createInlineScriptModule({ language, type }) {
33
- const code = initialCode(language, type);
31
+ export async function createInlineScriptModule({ language, kind, subkind }) {
32
+ const code = initialCode(language, kind, subkind);
34
33
  const flowModule = {
35
34
  value: { type: 'rawscript', content: code, language },
36
35
  input_transforms: {}
37
36
  };
38
- return await loadFlowModuleSchema(flowModule);
37
+ return [flowModule, await loadFlowModuleSchema(flowModule)];
39
38
  }
40
39
  export async function createLoop() {
41
40
  const loopFlowModule = {
42
41
  value: {
43
42
  type: 'forloopflow',
44
43
  modules: [],
45
- iterator: { type: 'javascript', expr: 'result' },
44
+ iterator: { type: 'javascript', expr: 'previous_result' },
46
45
  skip_failures: true
47
46
  },
48
47
  input_transforms: {}
49
48
  };
50
- const { flowModule, schema } = await loadFlowModuleSchema(loopFlowModule);
51
- return {
52
- flowModule,
53
- schema,
54
- childFlowModules: [emptyFlowModuleSchema()],
55
- previewResult: undefined
56
- };
49
+ const { schema } = await loadFlowModuleSchema(loopFlowModule);
50
+ return [
51
+ loopFlowModule,
52
+ {
53
+ schema,
54
+ childFlowModules: [emptyFlowModuleState()],
55
+ previewResult: NEVER_TESTED_THIS_FAR
56
+ }
57
+ ];
57
58
  }
58
59
  export async function fork(flowModule) {
59
60
  if (flowModule.value.type !== 'script') {
60
61
  throw new Error('Can only fork a script module');
61
62
  }
62
63
  const fm = await createInlineScriptModuleFromPath(flowModule.value.path ?? '');
63
- return await loadFlowModuleSchema(fm);
64
+ return [fm, await loadFlowModuleSchema(fm)];
64
65
  }
65
66
  export async function createInlineScriptModuleFromPath(path) {
66
67
  const { content, language } = await getScriptByPath(path);
@@ -88,7 +89,7 @@ export async function createScriptFromInlineScript({ flowModule, suffix, schema
88
89
  }
89
90
  const path = `${flow.path}/${suffix}`;
90
91
  const forkedDescription = wasForked ? `as a fork of ${originalScriptPath}` : '';
91
- const description = `This script was edited in place of flow ${flow.path} ${forkedDescription} by ${user?.username}}.`;
92
+ const description = `This script was edited in place of flow ${flow.path} ${forkedDescription} by ${user?.username}.`;
92
93
  const availablePath = await findNextAvailablePath(path);
93
94
  await ScriptService.createScript({
94
95
  workspace: get(workspaceStore),
@@ -126,34 +127,41 @@ async function findNextAvailablePath(path) {
126
127
  export function isEmptyFlowModule(flowModule) {
127
128
  return flowModule.value.type === 'script' && flowModule.value.path === '';
128
129
  }
130
+ export const NEVER_TESTED_THIS_FAR = 'never tested this far';
129
131
  export function getStepPropPicker(indexes, flowInputSchema, flowState, args) {
130
- const isInsideLoop = indexes.length > 1;
131
- const [parentIndex] = indexes;
132
+ const [parentIndex, childIndex] = indexes;
133
+ const isInsideLoop = childIndex !== undefined;
132
134
  const flowInput = schemaToObject(flowInputSchema, args);
133
- const results = getPreviousResults(flowState, parentIndex);
134
- const lastResult = results.length > 0 ? results[results.length - 1] : undefined;
135
+ const results = getPreviousResults(flowState.modules, parentIndex);
136
+ const lastResult = parentIndex == 0
137
+ ? flowInput
138
+ : results.length > 0
139
+ ? results[results.length - 1]
140
+ : NEVER_TESTED_THIS_FAR;
135
141
  if (isInsideLoop) {
136
- const forLoopFlowInput = {
142
+ let forLoopFlowInput = {
137
143
  ...flowInput,
138
144
  iter: {
139
145
  value: "Iteration's value",
140
146
  index: "Iteration's index"
141
147
  }
142
148
  };
143
- if (Array.isArray(lastResult) && lastResult.length > 0) {
144
- const last = lastResult[lastResult.length - 1];
145
- forLoopFlowInput.iter = {
146
- value: last,
147
- index: `Iteration's index (0 to ${lastResult.length - 1})`
148
- };
149
+ if (flowState.modules[parentIndex]?.previewArgs) {
150
+ forLoopFlowInput = flowState.modules[parentIndex]?.previewArgs;
149
151
  }
150
- const extraLib = buildExtraLib(objectToTsType(forLoopFlowInput), undefined);
152
+ const innerResults = getPreviousResults(flowState.modules[parentIndex]?.childFlowModules, childIndex);
153
+ const innerLastResult = childIndex == 0
154
+ ? forLoopFlowInput
155
+ : innerResults.length > 0
156
+ ? innerResults[innerResults.length - 1]
157
+ : NEVER_TESTED_THIS_FAR;
158
+ const extraLib = buildExtraLib(objectToTsType(forLoopFlowInput), objectToTsType(innerLastResult));
151
159
  return {
152
160
  extraLib,
153
161
  pickableProperties: {
154
162
  flow_input: forLoopFlowInput,
155
- step: [],
156
- previous_result: {}
163
+ previous_result: innerLastResult,
164
+ step: innerResults
157
165
  }
158
166
  };
159
167
  }
@@ -163,8 +171,8 @@ export function getStepPropPicker(indexes, flowInputSchema, flowState, args) {
163
171
  extraLib,
164
172
  pickableProperties: {
165
173
  flow_input: flowInput,
166
- step: results,
167
- previous_result: lastResult
174
+ previous_result: lastResult,
175
+ step: results
168
176
  }
169
177
  };
170
178
  }
@@ -179,42 +187,42 @@ function getPreviousResults(flowModuleSchemas, target) {
179
187
  function extractPreviewResults(flowModuleSchemas) {
180
188
  return flowModuleSchemas.map((fms) => fms.previewResult);
181
189
  }
182
- export function mapJobResultsToFlowState(jobs, config, configIndex) {
183
- if (!Array.isArray(jobs.innerJobs) || jobs.innerJobs.length === 0) {
184
- return;
185
- }
186
- if (config === 'justthis') {
187
- const job = jobs.job;
188
- flowStateStore.update((flowState) => {
189
- flowState[configIndex] = job.result;
190
- return flowState;
191
- });
190
+ function getResult(job) {
191
+ if (job && 'result' in job) {
192
+ return job.result;
192
193
  }
193
- else {
194
- const results = jobs.innerJobs.map(({ job, loopJobs }) => {
195
- if (Array.isArray(loopJobs) && loopJobs.length > 0) {
196
- return loopJobs.map(({ job }) => {
197
- if (job && 'result' in job) {
198
- return job.result;
199
- }
194
+ }
195
+ export function mapJobResultsToFlowState(jobs, upto) {
196
+ const results = jobs.innerJobs.map(({ job, loopJobs }) => {
197
+ if (loopJobs && loopJobs.length > 0) {
198
+ return [
199
+ job?.args,
200
+ loopJobs.map(({ job }) => {
201
+ return getResult(job);
202
+ })
203
+ ];
204
+ }
205
+ else {
206
+ return [job?.args, getResult(job)];
207
+ }
208
+ });
209
+ const old = get(flowStateStore);
210
+ const modules = old.modules.map((flowModuleState, index) => {
211
+ if (results[index] && index <= upto) {
212
+ if (results[index][1] != NEVER_TESTED_THIS_FAR ||
213
+ flowModuleState.previewResult == undefined) {
214
+ flowModuleState.previewArgs = results[index][0];
215
+ flowModuleState.previewResult = results[index][1];
216
+ flowModuleState.childFlowModules?.map((innerMod, j) => {
217
+ const lastLoopJob = jobs.innerJobs[index].loopJobs?.length ?? 0;
218
+ innerMod.previewResult = getResult(jobs.innerJobs[index].loopJobs?.[lastLoopJob - 1]?.innerJobs?.[j]?.job);
200
219
  });
201
220
  }
202
- else {
203
- if (job && 'result' in job) {
204
- return job.result;
205
- }
206
- }
207
- });
208
- flowStateStore.update((flowState) => {
209
- if (!Array.isArray(flowState)) {
210
- return flowState;
211
- }
212
- return flowState.map((flowModuleSchema, index) => {
213
- if (index <= configIndex) {
214
- flowModuleSchema.previewResult = results[index];
215
- }
216
- return flowModuleSchema;
217
- });
218
- });
219
- }
221
+ }
222
+ return flowModuleState;
223
+ });
224
+ flowStateStore.set({
225
+ modules,
226
+ failureModule: old.failureModule
227
+ });
220
228
  }
@@ -1,6 +1,6 @@
1
1
  import { get, writable } from 'svelte/store';
2
2
  import { flowStateStore, initFlowState } from './flowState';
3
- export const flowStore = writable(undefined);
3
+ export const flowStore = writable({ summary: "", value: { modules: [] }, path: "", edited_at: "", edited_by: "", archived: false, extra_perms: {} });
4
4
  export function initFlow(flow) {
5
5
  for (const mod of flow.value.modules) {
6
6
  migrateFlowModule(mod);
@@ -23,7 +23,10 @@ export function initFlow(flow) {
23
23
  delete modVal.input_transform;
24
24
  }
25
25
  if (modVal.stop_after_if_expr) {
26
- modVal.stop_after_if = { expr: modVal.stop_after_if_expr, skip_if_stopped: modVal.skip_if_stopped };
26
+ modVal.stop_after_if = {
27
+ expr: modVal.stop_after_if_expr,
28
+ skip_if_stopped: modVal.skip_if_stopped
29
+ };
27
30
  delete modVal.stop_after_if_expr;
28
31
  delete modVal.skip_if_stopped;
29
32
  }
@@ -32,8 +35,8 @@ export function initFlow(flow) {
32
35
  export async function copyFirstStepSchema() {
33
36
  const flowState = get(flowStateStore);
34
37
  flowStore.update((flow) => {
35
- if (flowState[0].schema) {
36
- flow.schema = flowState[0].schema;
38
+ if (flowState.modules[0].schema) {
39
+ flow.schema = flowState.modules[0].schema;
37
40
  }
38
41
  return flow;
39
42
  });
@@ -0,0 +1,55 @@
1
+ <script>import Drawer from '../../common/drawer/Drawer.svelte';
2
+ import DrawerContent from '../../common/drawer/DrawerContent.svelte';
3
+ import Menu from '../../common/menu/Menu.svelte';
4
+ import MenuItem from '../../common/menu/MenuItem.svelte';
5
+ import FlowViewer from '../../FlowViewer.svelte';
6
+ import SimpleEditor from '../../SimpleEditor.svelte';
7
+ import { sendUserToast } from '../../../utils';
8
+ import { faFileExport, faFileImport, faGlobe } from '@fortawesome/free-solid-svg-icons';
9
+ import Icon from 'svelte-awesome';
10
+ import { Button } from '../../common';
11
+ import { flowStore, initFlow } from '../flowStore';
12
+ import { cleanInputs } from '../utils';
13
+ let jsonSetterDrawer;
14
+ let jsonViewerDrawer;
15
+ let pendingJson;
16
+ function importJson() {
17
+ Object.assign($flowStore, JSON.parse(pendingJson));
18
+ initFlow($flowStore);
19
+ sendUserToast('OpenFlow imported from JSON');
20
+ jsonSetterDrawer.toggleDrawer();
21
+ }
22
+ </script>
23
+
24
+ <Menu placement="bottom-end">
25
+ <button
26
+ slot="trigger"
27
+ class="flex items-center text-sm border focus:outline-none focus:ring-4 font-medium rounded-md text-gray-800 bg-white hover:bg-gray-100 focus:ring-gray-300 px-4 py-2"
28
+ >
29
+ Import/Export
30
+ </button>
31
+ <div class="divide-y divide-gray-200">
32
+ <MenuItem on:click={() => jsonSetterDrawer.toggleDrawer()}>
33
+ <Icon data={faFileImport} scale={0.6} class="inline mr-2" />
34
+ Import from a JSON OpenFlow
35
+ </MenuItem>
36
+ <MenuItem on:click={() => jsonViewerDrawer.toggleDrawer()}>
37
+ <Icon data={faFileExport} scale={0.6} class="inline mr-2" />
38
+ Export to a JSON OpenFlow
39
+ </MenuItem>
40
+ </div>
41
+ </Menu>
42
+
43
+ <Drawer bind:this={jsonSetterDrawer} size="800px">
44
+ <DrawerContent title="Import JSON" on:close={() => jsonSetterDrawer.toggleDrawer()}>
45
+ <Button size="sm" on:click={importJson}>Import</Button>
46
+ <SimpleEditor bind:code={pendingJson} lang="json" class="h-full" />
47
+ </DrawerContent>
48
+ </Drawer>
49
+ <Drawer bind:this={jsonViewerDrawer} size="800px">
50
+ <DrawerContent title="See JSON" on:close={() => jsonViewerDrawer.toggleDrawer()}>
51
+ {#if $flowStore}
52
+ <FlowViewer flow={cleanInputs($flowStore)} tab="json" />
53
+ {/if}
54
+ </DrawerContent>
55
+ </Drawer>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {};
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export declare type FlowImportExportMenuProps = typeof __propDef.props;
10
+ export declare type FlowImportExportMenuEvents = typeof __propDef.events;
11
+ export declare type FlowImportExportMenuSlots = typeof __propDef.slots;
12
+ export default class FlowImportExportMenu extends SvelteComponentTyped<FlowImportExportMenuProps, FlowImportExportMenuEvents, FlowImportExportMenuSlots> {
13
+ }
14
+ export {};
@@ -0,0 +1,57 @@
1
+ <script>import Button from '../../common/button/Button.svelte';
2
+ import Drawer from '../../common/drawer/Drawer.svelte';
3
+ import FlowPreviewContent from '../../FlowPreviewContent.svelte';
4
+ import { faPlay } from '@fortawesome/free-solid-svg-icons';
5
+ import { getContext } from 'svelte';
6
+ import Icon from 'svelte-awesome';
7
+ const { selectedId } = getContext('FlowEditorContext');
8
+ let previewOpen = false;
9
+ let previewMode = 'whole';
10
+ $: upToDisabled = [
11
+ 'settings',
12
+ 'settings-schedule',
13
+ 'settings-retries',
14
+ 'inputs',
15
+ 'schedules'
16
+ ].includes($selectedId);
17
+ </script>
18
+
19
+ <span
20
+ class="flex flex-row-reverse justify-between flex-wrap gap-2 w-full py-2 px-4 bg-white border-b border-t"
21
+ >
22
+ <Button
23
+ btnClasses="grow"
24
+ on:click={() => {
25
+ previewMode = 'whole'
26
+ previewOpen = !previewOpen
27
+ }}
28
+ size="sm"
29
+ >
30
+ Test flow
31
+ <Icon data={faPlay} class="ml-2" scale={0.8} />
32
+ </Button>
33
+ {#if !upToDisabled}
34
+ <Button
35
+ btnClasses="grow"
36
+ size="sm"
37
+ disabled={upToDisabled}
38
+ color="light"
39
+ variant="border"
40
+ on:click={() => {
41
+ previewMode = 'upTo'
42
+
43
+ previewOpen = !previewOpen
44
+ }}
45
+ >
46
+ Test up to step {$selectedId
47
+ .split('-')
48
+ .map((x) => (Number.isNaN(Number(x)) ? x : Number(x) + 1))
49
+ .join(' ')}
50
+ <Icon data={faPlay} class="ml-2" scale={0.8} />
51
+ </Button>
52
+ {/if}
53
+ </span>
54
+
55
+ <Drawer bind:open={previewOpen} size="800px">
56
+ <FlowPreviewContent bind:previewMode on:close={() => (previewOpen = !previewOpen)} />
57
+ </Drawer>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {};
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export declare type FlowPreviewButtonsProps = typeof __propDef.props;
10
+ export declare type FlowPreviewButtonsEvents = typeof __propDef.events;
11
+ export declare type FlowPreviewButtonsSlots = typeof __propDef.slots;
12
+ export default class FlowPreviewButtons extends SvelteComponentTyped<FlowPreviewButtonsProps, FlowPreviewButtonsEvents, FlowPreviewButtonsSlots> {
13
+ }
14
+ export {};
@@ -0,0 +1,60 @@
1
+ <script>import { getContext } from 'svelte';
2
+ import Icon from 'svelte-awesome';
3
+ import { faBug } from '@fortawesome/free-solid-svg-icons';
4
+ import { NEVER_TESTED_THIS_FAR } from '../flowStateUtils';
5
+ import { classNames, emptyModule, emptySchema } from '../../../utils';
6
+ import { flowStateStore } from '../flowState';
7
+ import Toggle from '../../Toggle.svelte';
8
+ import { flowStore } from '../flowStore';
9
+ const { select, selectedId } = getContext('FlowEditorContext');
10
+ function onToggle() {
11
+ if ($flowStore.value.failure_module) {
12
+ $flowStore.value.failure_module = undefined;
13
+ // By default, we return to settings when disabling the failure module
14
+ select('settings');
15
+ }
16
+ else {
17
+ const failureModule = {
18
+ schema: emptySchema(),
19
+ previewResult: NEVER_TESTED_THIS_FAR,
20
+ childFlowModules: []
21
+ };
22
+ $flowStateStore.failureModule = failureModule;
23
+ $flowStore.value.failure_module = emptyModule();
24
+ select('failure');
25
+ }
26
+ }
27
+ </script>
28
+
29
+ <div
30
+ on:click={() => {
31
+ if ($flowStore.value.failure_module) {
32
+ select('failure')
33
+ } else {
34
+ onToggle()
35
+ }
36
+ }}
37
+ class={classNames(
38
+ 'border rounded-md p-2 bg-white text-sm cursor-pointer mt-4 flex flex-col overflow-x-hidden',
39
+ $selectedId.includes('failure') ? 'outline outline-offset-1 outline-2 outline-slate-900' : ''
40
+ )}
41
+ >
42
+ <div class=" flex justify-between items-center flex-wrap">
43
+ <div>
44
+ <Icon data={faBug} class="mr-2" />
45
+ <span class="font-bold">Error handler</span>
46
+ </div>
47
+ <Toggle checked={Boolean($flowStore.value.failure_module)} on:change={onToggle} />
48
+ </div>
49
+
50
+ <div class="w-full truncate block">
51
+ {#if Boolean($flowStore.value.failure_module)}
52
+ <span
53
+ >{$flowStore.value.failure_module?.summary ||
54
+ ($flowStore.value.failure_module?.value.type === 'rawscript'
55
+ ? `Inline ${$flowStore.value.failure_module?.value.language}`
56
+ : 'Select a script')}</span
57
+ >
58
+ {/if}
59
+ </div>
60
+ </div>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {};
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export declare type FlowErrorHandlerItemProps = typeof __propDef.props;
10
+ export declare type FlowErrorHandlerItemEvents = typeof __propDef.events;
11
+ export declare type FlowErrorHandlerItemSlots = typeof __propDef.slots;
12
+ export default class FlowErrorHandlerItem extends SvelteComponentTyped<FlowErrorHandlerItemProps, FlowErrorHandlerItemEvents, FlowErrorHandlerItemSlots> {
13
+ }
14
+ export {};
@@ -0,0 +1,80 @@
1
+ <script>import Button from '../../common/button/Button.svelte';
2
+ import { classNames } from '../../../utils';
3
+ import { faBed, faRepeat, faStop, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
4
+ import { createEventDispatcher } from 'svelte';
5
+ import Icon from 'svelte-awesome';
6
+ export let color = 'blue';
7
+ export let isFirst = false;
8
+ export let isLast = false;
9
+ export let hasLine = true;
10
+ export let selected = false;
11
+ export let deletable = false;
12
+ export let retry = false;
13
+ export let earlyStop = false;
14
+ export let suspend = false;
15
+ const margin = isLast ? '' : isFirst ? 'mb-0.5' : 'my-0.5';
16
+ const dispatch = createEventDispatcher();
17
+ </script>
18
+
19
+ <div class="flex" on:click>
20
+ <div
21
+ class={classNames(
22
+ 'flex mr-2 w-8 ',
23
+ hasLine ? 'line' : '',
24
+ isFirst ? 'justify-center items-start' : 'justify-center items-center'
25
+ )}
26
+ >
27
+ <div
28
+ class={classNames(
29
+ 'flex justify-center items-center w-6 h-6 border rounded-full text-xs font-bold',
30
+ color === 'blue' ? 'bg-blue-100 text-blue-400' : 'bg-orange-100 text-orange-400',
31
+ margin
32
+ )}
33
+ >
34
+ <slot name="icon" />
35
+ </div>
36
+ </div>
37
+ <div class="relative w-full">
38
+ <div class="absolute text-sm right-14 -bottom-3 flex flex-row gap-1"
39
+ >{#if retry}
40
+ <div class="bg-white rounded border text-gray-600 px-1"
41
+ ><Icon scale={0.8} data={faRepeat} /></div
42
+ >
43
+ {/if}{#if earlyStop}
44
+ <div class="bg-white rounded border text-gray-600 px-1"
45
+ ><Icon scale={0.8} data={faStop} /></div
46
+ >
47
+ {/if}
48
+ {#if suspend}
49
+ <div class="bg-white rounded border text-gray-600 px-1"
50
+ ><Icon scale={0.8} data={faBed} /></div
51
+ >
52
+ {/if}</div
53
+ >
54
+ <div
55
+ class={classNames(
56
+ 'border w-full rounded-sm p-2 bg-white text-sm cursor-pointer flex justify-between items-center space-x-2 overflow-hidden',
57
+ margin,
58
+ selected ? 'outline outline-offset-1 outline-2 outline-gray-600' : ''
59
+ )}
60
+ >
61
+ <slot name="content" class="w-full" />
62
+ {#if deletable}
63
+ <Button
64
+ on:click={(event) => dispatch('delete', { event })}
65
+ startIcon={{ icon: faTrashAlt }}
66
+ iconOnly={true}
67
+ color="light"
68
+ variant="border"
69
+ size="xs"
70
+ />
71
+ {/if}
72
+ </div>
73
+ </div>
74
+ </div>
75
+
76
+ <style>
77
+ .line {
78
+ background: repeating-linear-gradient(to bottom, transparent 0 4px, #bbb 4px 8px) 50%/1px 100%
79
+ no-repeat;
80
+ }</style>
@@ -0,0 +1,32 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ color?: "blue" | "orange" | undefined;
5
+ isFirst?: boolean | undefined;
6
+ isLast?: boolean | undefined;
7
+ hasLine?: boolean | undefined;
8
+ selected?: boolean | undefined;
9
+ deletable?: boolean | undefined;
10
+ retry?: boolean | undefined;
11
+ earlyStop?: boolean | undefined;
12
+ suspend?: boolean | undefined;
13
+ };
14
+ events: {
15
+ click: MouseEvent;
16
+ delete: CustomEvent<any>;
17
+ } & {
18
+ [evt: string]: CustomEvent<any>;
19
+ };
20
+ slots: {
21
+ icon: {};
22
+ content: {
23
+ class: string;
24
+ };
25
+ };
26
+ };
27
+ export declare type FlowModuleSchemaItemProps = typeof __propDef.props;
28
+ export declare type FlowModuleSchemaItemEvents = typeof __propDef.events;
29
+ export declare type FlowModuleSchemaItemSlots = typeof __propDef.slots;
30
+ export default class FlowModuleSchemaItem extends SvelteComponentTyped<FlowModuleSchemaItemProps, FlowModuleSchemaItemEvents, FlowModuleSchemaItemSlots> {
31
+ }
32
+ export {};