windmill-components 1.35.1 → 1.35.43

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 (201) hide show
  1. package/components/ArgInput.svelte +21 -21
  2. package/components/ArgInput.svelte.d.ts +3 -3
  3. package/components/DisplayResult.svelte +73 -67
  4. package/components/Editor.svelte +184 -246
  5. package/components/Editor.svelte.d.ts +4 -4
  6. package/components/EditorBar.svelte +58 -45
  7. package/components/EditorBar.svelte.d.ts +2 -1
  8. package/components/FlowBuilder.svelte +113 -121
  9. package/components/FlowJobResult.svelte +4 -5
  10. package/components/FlowModulesViewer.svelte +89 -7
  11. package/components/FlowModulesViewer.svelte.d.ts +1 -0
  12. package/components/FlowPreviewContent.svelte +56 -15
  13. package/components/FlowPreviewContent.svelte.d.ts +1 -1
  14. package/components/FlowStatusViewer.svelte +42 -24
  15. package/components/FlowStatusViewer.svelte.d.ts +0 -1
  16. package/components/FlowViewer.svelte +7 -3
  17. package/components/HighlightCode.svelte +21 -0
  18. package/components/HighlightCode.svelte.d.ts +17 -0
  19. package/components/IconedPath.svelte +9 -7
  20. package/components/IconedResourceType.svelte +1 -1
  21. package/components/InputTransformForm.svelte +88 -107
  22. package/components/InputTransformForm.svelte.d.ts +0 -1
  23. package/components/ItemPicker.svelte +2 -2
  24. package/components/LogViewer.svelte +23 -0
  25. package/components/LogViewer.svelte.d.ts +19 -0
  26. package/components/ModulePreview.svelte +108 -0
  27. package/components/ModulePreview.svelte.d.ts +24 -0
  28. package/components/RunForm.svelte +29 -18
  29. package/components/RunForm.svelte.d.ts +6 -2
  30. package/components/SchemaEditor.svelte +5 -3
  31. package/components/SchemaForm.svelte +0 -2
  32. package/components/SchemaForm.svelte.d.ts +0 -1
  33. package/components/ScriptBuilder.svelte +77 -66
  34. package/components/ScriptBuilder.svelte.d.ts +2 -4
  35. package/components/ScriptEditor.svelte +69 -142
  36. package/components/ScriptEditor.svelte.d.ts +0 -5
  37. package/components/ScriptPicker.svelte +3 -3
  38. package/components/ScriptPicker.svelte.d.ts +2 -1
  39. package/components/SharedBadge.svelte +5 -13
  40. package/components/SimpleEditor.svelte +147 -0
  41. package/components/SimpleEditor.svelte.d.ts +35 -0
  42. package/components/TestJobLoader.svelte +98 -0
  43. package/components/TestJobLoader.svelte.d.ts +26 -0
  44. package/components/Tooltip.svelte +2 -1
  45. package/components/common/actionRow/ActionRow.svelte +26 -0
  46. package/components/common/actionRow/ActionRow.svelte.d.ts +21 -0
  47. package/components/common/alert/Alert.svelte +53 -0
  48. package/components/common/alert/Alert.svelte.d.ts +20 -0
  49. package/components/common/alert/model.d.ts +1 -0
  50. package/components/common/alert/model.js +1 -0
  51. package/components/common/badge/Badge.svelte +82 -0
  52. package/components/common/badge/Badge.svelte.d.ts +28 -0
  53. package/components/common/badge/model.d.ts +8 -0
  54. package/components/common/badge/model.js +1 -0
  55. package/components/common/button/Button.svelte +107 -0
  56. package/components/common/button/Button.svelte.d.ts +37 -0
  57. package/components/common/button/model.d.ts +6 -0
  58. package/components/common/button/model.js +1 -0
  59. package/components/common/confirmationModal/ConfirmationModal.svelte +55 -0
  60. package/components/common/confirmationModal/ConfirmationModal.svelte.d.ts +23 -0
  61. package/components/common/drawer/Drawer.svelte +3 -0
  62. package/components/common/drawer/Drawer.svelte.d.ts +2 -0
  63. package/components/common/index.d.ts +14 -0
  64. package/components/common/index.js +14 -0
  65. package/components/common/tabs/TabContent.svelte +3 -2
  66. package/components/common/tabs/TabContent.svelte.d.ts +1 -0
  67. package/components/common/tabs/Tabs.svelte +8 -1
  68. package/components/common/tabs/Tabs.svelte.d.ts +2 -0
  69. package/components/common/toggleButton/ToggleButton.svelte +20 -0
  70. package/components/common/toggleButton/ToggleButton.svelte.d.ts +19 -0
  71. package/components/common/toggleButton/ToggleButtonGroup.svelte +33 -0
  72. package/components/common/toggleButton/ToggleButtonGroup.svelte.d.ts +24 -0
  73. package/components/flows/FlowEditor.svelte +30 -0
  74. package/components/{FlowEditor.svelte.d.ts → flows/FlowEditor.svelte.d.ts} +1 -8
  75. package/components/flows/common/FlowCard.svelte +9 -0
  76. package/components/flows/common/FlowCard.svelte.d.ts +21 -0
  77. package/components/flows/common/FlowCardHeader.svelte +39 -0
  78. package/components/flows/common/FlowCardHeader.svelte.d.ts +20 -0
  79. package/components/flows/content/CopyFirstStepSchema.svelte +13 -0
  80. package/components/flows/{CopyFirstStepSchema.svelte.d.ts → content/CopyFirstStepSchema.svelte.d.ts} +0 -0
  81. package/components/flows/{DynamicInputHelpBox.svelte → content/DynamicInputHelpBox.svelte} +0 -0
  82. package/components/flows/{DynamicInputHelpBox.svelte.d.ts → content/DynamicInputHelpBox.svelte.d.ts} +0 -0
  83. package/components/flows/content/FlowEditorPanel.svelte +26 -0
  84. package/components/flows/content/FlowEditorPanel.svelte.d.ts +14 -0
  85. package/components/flows/content/FlowFailureModule.svelte +17 -0
  86. package/components/flows/content/FlowFailureModule.svelte.d.ts +14 -0
  87. package/components/flows/content/FlowInput.svelte +22 -0
  88. package/components/flows/{FlowInput.svelte.d.ts → content/FlowInput.svelte.d.ts} +0 -0
  89. package/components/flows/{FlowInputs.svelte → content/FlowInputs.svelte} +24 -13
  90. package/components/flows/{FlowInputs.svelte.d.ts → content/FlowInputs.svelte.d.ts} +0 -0
  91. package/components/flows/content/FlowLoop.svelte +38 -0
  92. package/components/flows/content/FlowLoop.svelte.d.ts +14 -0
  93. package/components/flows/content/FlowModule.svelte +190 -0
  94. package/components/flows/content/FlowModule.svelte.d.ts +29 -0
  95. package/components/flows/content/FlowModuleAdvancedSettings.svelte +64 -0
  96. package/components/flows/content/FlowModuleAdvancedSettings.svelte.d.ts +17 -0
  97. package/components/flows/content/FlowModuleHeader.svelte +68 -0
  98. package/components/flows/{FlowModuleHeader.svelte.d.ts → content/FlowModuleHeader.svelte.d.ts} +2 -3
  99. package/components/flows/content/FlowModuleScript.svelte +21 -0
  100. package/components/flows/content/FlowModuleScript.svelte.d.ts +17 -0
  101. package/components/flows/content/FlowModuleWrapper.svelte +47 -0
  102. package/components/flows/content/FlowModuleWrapper.svelte.d.ts +14 -0
  103. package/components/flows/content/FlowRetries.svelte +80 -0
  104. package/components/flows/content/FlowRetries.svelte.d.ts +14 -0
  105. package/components/flows/content/FlowSchedules.svelte +18 -0
  106. package/components/flows/content/FlowSchedules.svelte.d.ts +14 -0
  107. package/components/flows/content/FlowSettings.svelte +51 -0
  108. package/components/flows/{FlowSettings.svelte.d.ts → content/FlowSettings.svelte.d.ts} +1 -6
  109. package/components/flows/content/RemoveStepConfirmationModal.svelte +32 -0
  110. package/components/flows/content/RemoveStepConfirmationModal.svelte.d.ts +19 -0
  111. package/components/flows/flowState.d.ts +8 -7
  112. package/components/flows/flowState.js +25 -46
  113. package/components/flows/flowStateUtils.d.ts +15 -13
  114. package/components/flows/flowStateUtils.js +80 -72
  115. package/components/flows/flowStore.js +7 -4
  116. package/components/flows/header/FlowEditorHeader.svelte +23 -0
  117. package/components/flows/header/FlowEditorHeader.svelte.d.ts +14 -0
  118. package/components/flows/header/FlowImportExportMenu.svelte +56 -0
  119. package/components/flows/header/FlowImportExportMenu.svelte.d.ts +14 -0
  120. package/components/flows/header/FlowPreviewButtons.svelte +49 -0
  121. package/components/flows/header/FlowPreviewButtons.svelte.d.ts +14 -0
  122. package/components/flows/header/FlowStatus.svelte +36 -0
  123. package/components/flows/header/FlowStatus.svelte.d.ts +14 -0
  124. package/components/flows/map/FlowErrorHandlerItem.svelte +54 -0
  125. package/components/flows/map/FlowErrorHandlerItem.svelte.d.ts +14 -0
  126. package/components/flows/map/FlowModuleSchemaItem.svelte +58 -0
  127. package/components/flows/map/FlowModuleSchemaItem.svelte.d.ts +27 -0
  128. package/components/flows/map/FlowModuleSchemaMap.svelte +161 -0
  129. package/components/flows/map/FlowModuleSchemaMap.svelte.d.ts +20 -0
  130. package/components/flows/pickers/PickHubScript.svelte +4 -3
  131. package/components/flows/pickers/PickHubScript.svelte.d.ts +2 -1
  132. package/components/flows/pickers/PickScript.svelte +4 -12
  133. package/components/flows/pickers/PickScript.svelte.d.ts +1 -1
  134. package/components/flows/propPicker/PropPickerWrapper.svelte +42 -0
  135. package/components/flows/propPicker/PropPickerWrapper.svelte.d.ts +31 -0
  136. package/components/flows/scheduleUtils.d.ts +0 -1
  137. package/components/flows/scheduleUtils.js +0 -1
  138. package/components/flows/types.d.ts +9 -0
  139. package/components/flows/types.js +1 -0
  140. package/components/flows/utils.d.ts +1 -1
  141. package/components/flows/utils.js +8 -11
  142. package/components/icons/HatIcon.svelte +19 -0
  143. package/components/icons/HatIcon.svelte.d.ts +16 -0
  144. package/components/landing/FlowGettingStarted.svelte +22 -68
  145. package/components/landing/FlowLandingBox.svelte +1 -1
  146. package/components/landing/RessourceGettingStarted.svelte +7 -37
  147. package/components/landing/ScriptBox.svelte +33 -60
  148. package/components/landing/ScriptGettingStarted.svelte +23 -69
  149. package/components/propertyPicker/ObjectViewer.svelte +16 -7
  150. package/components/propertyPicker/PropPicker.svelte +38 -12
  151. package/components/propertyPicker/WarningMessage.svelte +2 -15
  152. package/components/script_editor/LogPanel.svelte +108 -119
  153. package/components/script_editor/LogPanel.svelte.d.ts +2 -0
  154. package/components/sidebar/SidebarContent.svelte +2 -2
  155. package/editorUtils.d.ts +25 -0
  156. package/editorUtils.js +43 -0
  157. package/gen/models/CompletedJob.d.ts +2 -1
  158. package/gen/models/CompletedJob.js +1 -0
  159. package/gen/models/FlowModule.d.ts +1 -0
  160. package/gen/models/FlowStatus.d.ts +3 -0
  161. package/gen/models/FlowStatusModule.d.ts +1 -1
  162. package/gen/models/FlowValue.d.ts +11 -0
  163. package/gen/models/Preview.d.ts +2 -1
  164. package/gen/models/Preview.js +1 -0
  165. package/gen/models/QueuedJob.d.ts +2 -1
  166. package/gen/models/QueuedJob.js +1 -0
  167. package/gen/models/RawScript.d.ts +2 -1
  168. package/gen/models/RawScript.js +1 -0
  169. package/gen/models/Script.d.ts +9 -2
  170. package/gen/models/Script.js +8 -0
  171. package/gen/services/JobService.d.ts +40 -0
  172. package/gen/services/JobService.js +70 -0
  173. package/gen/services/ScriptService.d.ts +14 -3
  174. package/gen/services/ScriptService.js +13 -0
  175. package/infer.d.ts +1 -1
  176. package/infer.js +6 -1
  177. package/package.json +67 -35
  178. package/script_helpers.d.ts +5 -2
  179. package/script_helpers.js +41 -13
  180. package/stores.d.ts +1 -1
  181. package/utils.d.ts +6 -4
  182. package/utils.js +27 -4
  183. package/components/FlowEditor.svelte +0 -55
  184. package/components/FlowPreview.svelte +0 -107
  185. package/components/FlowPreview.svelte.d.ts +0 -23
  186. package/components/ModuleStep.svelte +0 -131
  187. package/components/ModuleStep.svelte.d.ts +0 -25
  188. package/components/flows/CopyFirstStepSchema.svelte +0 -13
  189. package/components/flows/FlowBox.svelte +0 -16
  190. package/components/flows/FlowBox.svelte.d.ts +0 -23
  191. package/components/flows/FlowBoxHeader.svelte +0 -16
  192. package/components/flows/FlowBoxHeader.svelte.d.ts +0 -21
  193. package/components/flows/FlowInput.svelte +0 -22
  194. package/components/flows/FlowModuleHeader.svelte +0 -109
  195. package/components/flows/FlowSettings.svelte +0 -165
  196. package/components/flows/FlowTimeline.svelte +0 -169
  197. package/components/flows/FlowTimeline.svelte.d.ts +0 -21
  198. package/components/flows/stepOpenedStore.d.ts +0 -1
  199. package/components/flows/stepOpenedStore.js +0 -6
  200. package/components/propertyPicker/OverlayPropertyPicker.svelte +0 -69
  201. package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +0 -24
@@ -1,12 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- pathError?: string | undefined;
5
- initialPath?: string | undefined;
6
- previewArgs?: Record<string, any> | undefined;
7
- scheduleArgs?: Record<string, any> | undefined;
8
- scheduleEnabled?: boolean | undefined;
9
- scheduleCron?: string | undefined;
4
+ defaultTab?: string | undefined;
10
5
  };
11
6
  events: {
12
7
  [evt: string]: CustomEvent<any>;
@@ -0,0 +1,32 @@
1
+ <script>import Alert from '../../common/alert/Alert.svelte';
2
+ import Badge from '../../common/badge/Badge.svelte';
3
+ import ConfirmationModal from '../../common/confirmationModal/ConfirmationModal.svelte';
4
+ import { createEventDispatcher } from 'svelte';
5
+ export let open;
6
+ const dispatch = createEventDispatcher();
7
+ </script>
8
+
9
+ <ConfirmationModal
10
+ {open}
11
+ title="Remove step"
12
+ confirmationText="Remove"
13
+ on:canceled={() => {
14
+ open = false
15
+ dispatch('canceled')
16
+ }}
17
+ on:confirmed={() => {
18
+ open = false
19
+ dispatch('confirmed')
20
+ }}
21
+ >
22
+ <div class="flex flex-col w-full space-y-4">
23
+ <span>Are you sure you want to remove this step?</span>
24
+ <Alert type="info" title="Bypass confirmation">
25
+ <div>
26
+ You can press
27
+ <Badge color="dark-gray">SHIFT</Badge>
28
+ while removing a step to bypass confirmation.
29
+ </div>
30
+ </Alert>
31
+ </div>
32
+ </ConfirmationModal>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ open: boolean;
5
+ };
6
+ events: {
7
+ canceled: CustomEvent<any>;
8
+ confirmed: CustomEvent<any>;
9
+ } & {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {};
13
+ };
14
+ export declare type RemoveStepConfirmationModalProps = typeof __propDef.props;
15
+ export declare type RemoveStepConfirmationModalEvents = typeof __propDef.events;
16
+ export declare type RemoveStepConfirmationModalSlots = typeof __propDef.slots;
17
+ export default class RemoveStepConfirmationModal extends SvelteComponentTyped<RemoveStepConfirmationModalProps, RemoveStepConfirmationModalEvents, RemoveStepConfirmationModalSlots> {
18
+ }
19
+ export {};
@@ -1,14 +1,15 @@
1
1
  import type { Schema } from '../../common';
2
2
  import type { Flow, FlowModule } from '../../gen';
3
- export declare type FlowModuleSchema = {
4
- flowModule: FlowModule;
3
+ export declare type FlowModuleState = {
5
4
  schema: Schema;
6
- childFlowModules?: FlowModuleSchema[];
5
+ childFlowModules?: FlowModuleState[];
6
+ previewArgs?: any;
7
7
  previewResult?: any;
8
8
  };
9
- export declare type FlowState = FlowModuleSchema[];
9
+ export declare type FlowState = {
10
+ modules: FlowModuleState[];
11
+ failureModule: FlowModuleState;
12
+ };
10
13
  export declare const flowStateStore: import("svelte/store").Writable<FlowState>;
11
14
  export declare function initFlowState(flow: Flow): Promise<void>;
12
- export declare const isCopyFirstStepSchemaDisabled: import("svelte/store").Readable<boolean>;
13
- export declare function flowModulesToFlowState(flowModules: FlowModule[]): Promise<FlowState>;
14
- export declare function flowStateToFlow(flowState: FlowState, flow: Flow): Flow;
15
+ export declare function mapFlowModules(flowModules: FlowModule[]): Promise<FlowModuleState[]>;
@@ -1,52 +1,31 @@
1
- import { derived, writable } from 'svelte/store';
2
- import { emptyFlowModuleSchema, isEmptyFlowModule, loadFlowModuleSchema } from './flowStateUtils';
3
- export const flowStateStore = writable(undefined);
1
+ import { writable } from 'svelte/store';
2
+ import { emptyFlowModuleState, isEmptyFlowModule, loadFlowModuleSchema } from './flowStateUtils';
3
+ export const flowStateStore = writable({ modules: [], failureModule: emptyFlowModuleState() });
4
4
  export async function initFlowState(flow) {
5
- const flowState = await flowModulesToFlowState(flow.value.modules);
6
- flowStateStore.set(flowState);
5
+ const modules = await mapFlowModules(flow.value.modules);
6
+ const failureModule = flow.value.failure_module
7
+ ? await mapFlowModule(flow.value.failure_module)
8
+ : emptyFlowModuleState();
9
+ flowStateStore.set({
10
+ modules,
11
+ failureModule
12
+ });
7
13
  }
8
- export const isCopyFirstStepSchemaDisabled = derived(flowStateStore, (flowState) => {
9
- if (flowState) {
10
- const firstModule = flowState[0];
11
- if (!firstModule) {
12
- return true;
13
- }
14
- const fm = firstModule.flowModule;
15
- return flowState.length === 0 || isEmptyFlowModule(fm);
14
+ async function mapFlowModule(flowModule) {
15
+ const value = flowModule.value;
16
+ if (value.type === 'forloopflow') {
17
+ const childFlowModules = await Promise.all(value.modules.map(async (module) => loadFlowModuleSchema(module)));
18
+ const loopFlowModule = await loadFlowModuleSchema(flowModule);
19
+ return {
20
+ ...loopFlowModule,
21
+ childFlowModules
22
+ };
16
23
  }
17
- else {
18
- return true;
24
+ if (isEmptyFlowModule(flowModule)) {
25
+ return emptyFlowModuleState();
19
26
  }
20
- });
21
- export async function flowModulesToFlowState(flowModules) {
22
- return Promise.all(flowModules.map(async (flowModule) => {
23
- const value = flowModule.value;
24
- if (value.type === 'forloopflow') {
25
- const childFlowModules = await Promise.all(value.modules.map(async (module) => loadFlowModuleSchema(module)));
26
- const loopFlowModule = await loadFlowModuleSchema(flowModule);
27
- return {
28
- ...loopFlowModule,
29
- childFlowModules
30
- };
31
- }
32
- if (isEmptyFlowModule(flowModule)) {
33
- return emptyFlowModuleSchema();
34
- }
35
- return loadFlowModuleSchema(flowModule);
36
- }));
27
+ return loadFlowModuleSchema(flowModule);
37
28
  }
38
- export function flowStateToFlow(flowState, flow) {
39
- if (!flowState || !flow) {
40
- return flow;
41
- }
42
- const modules = flowState.map(({ flowModule, childFlowModules }) => {
43
- const fmv = flowModule.value;
44
- if (fmv.type === 'forloopflow' && childFlowModules && Array.isArray(childFlowModules)) {
45
- fmv.modules = childFlowModules.map((cfm) => cfm.flowModule);
46
- flowModule.value = fmv;
47
- }
48
- return flowModule;
49
- });
50
- flow.value.modules = modules;
51
- return flow;
29
+ export async function mapFlowModules(flowModules) {
30
+ return Promise.all(flowModules.map(async (flowModule) => mapFlowModule(flowModule)));
52
31
  }
@@ -1,21 +1,22 @@
1
1
  import type { Schema } from '../../common';
2
- import { Job, type FlowModule, type RawScript } from '../../gen';
3
- import { type FlowModuleSchema, type FlowState } from './flowState';
4
- export declare function emptyFlowModuleSchema(): FlowModuleSchema;
5
- export declare function loadFlowModuleSchema(flowModule: FlowModule): Promise<FlowModuleSchema>;
6
- export declare function pickScript(path: string): Promise<FlowModuleSchema>;
7
- export declare function createInlineScriptModule({ language, type }: {
2
+ import { Job, Script, type FlowModule, type RawScript } from '../../gen';
3
+ import { type FlowModuleState, type FlowState } from './flowState';
4
+ export declare function emptyFlowModuleState(): FlowModuleState;
5
+ export declare function loadFlowModuleSchema(flowModule: FlowModule): Promise<FlowModuleState>;
6
+ export declare function pickScript(path: string): Promise<[FlowModule, FlowModuleState]>;
7
+ export declare function createInlineScriptModule({ language, kind, subkind }: {
8
8
  language: RawScript.language;
9
- type: 'trigger' | 'flow' | 'pgsql';
10
- }): Promise<FlowModuleSchema>;
11
- export declare function createLoop(): Promise<FlowModuleSchema>;
12
- export declare function fork(flowModule: FlowModule): Promise<FlowModuleSchema>;
9
+ kind: Script.kind;
10
+ subkind: 'pgsql' | 'flow';
11
+ }): Promise<[FlowModule, FlowModuleState]>;
12
+ export declare function createLoop(): Promise<[FlowModule, FlowModuleState]>;
13
+ export declare function fork(flowModule: FlowModule): Promise<[FlowModule, FlowModuleState]>;
13
14
  export declare function createInlineScriptModuleFromPath(path: string): Promise<FlowModule>;
14
15
  export declare function createScriptFromInlineScript({ flowModule, suffix, schema }: {
15
16
  flowModule: FlowModule;
16
17
  suffix: string;
17
18
  schema: Schema;
18
- }): Promise<FlowModuleSchema>;
19
+ }): Promise<[FlowModule, FlowModuleState]>;
19
20
  export declare function isEmptyFlowModule(flowModule: FlowModule): boolean;
20
21
  declare type Result = any;
21
22
  declare type PickableProperties = {
@@ -27,11 +28,12 @@ declare type StepPropPicker = {
27
28
  pickableProperties: PickableProperties;
28
29
  extraLib: string;
29
30
  };
31
+ export declare const NEVER_TESTED_THIS_FAR = "never tested this far";
30
32
  export declare function getStepPropPicker(indexes: number[], flowInputSchema: Schema, flowState: FlowState, args: Record<string, any>): StepPropPicker;
31
33
  export declare type JobResult = {
32
34
  job?: Job;
33
- innerJobs?: JobResult[];
35
+ innerJobs: JobResult[];
34
36
  loopJobs?: JobResult[];
35
37
  };
36
- export declare function mapJobResultsToFlowState(jobs: JobResult, config: 'upto' | 'justthis', configIndex: number): void;
38
+ export declare function mapJobResultsToFlowState(jobs: JobResult, upto: number): void;
37
39
  export {};
@@ -1,14 +1,13 @@
1
- import { CompletedJob, Job, ScriptService } from '../../gen';
1
+ import { CompletedJob, Job, Script, ScriptService } from '../../gen';
2
2
  import { 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,23 @@
1
+ <script>import { flowStore } from '../flowStore';
2
+ import { faPen } from '@fortawesome/free-solid-svg-icons';
3
+ import Icon from 'svelte-awesome';
4
+ import FlowPreviewButtons from './FlowPreviewButtons.svelte';
5
+ import FlowStatus from './FlowStatus.svelte';
6
+ import { getContext } from 'svelte';
7
+ const { select } = getContext('FlowEditorContext');
8
+ </script>
9
+
10
+ <div class="flex justify-between items-center border-y p-2 px-4">
11
+ <div id="flow_title" class="flex justify-between items-center">
12
+ <button on:click={() => select('settings')}>
13
+ <span class="font-mono text-sm"> {$flowStore.path}</span>
14
+ <Icon
15
+ data={faPen}
16
+ scale={0.8}
17
+ class="text-gray-500 ml-2 flex justify-center items-center mb-0.5"
18
+ />
19
+ </button>
20
+ </div>
21
+ <FlowStatus />
22
+ <FlowPreviewButtons />
23
+ </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 FlowEditorHeaderProps = typeof __propDef.props;
10
+ export declare type FlowEditorHeaderEvents = typeof __propDef.events;
11
+ export declare type FlowEditorHeaderSlots = typeof __propDef.slots;
12
+ export default class FlowEditorHeader extends SvelteComponentTyped<FlowEditorHeaderProps, FlowEditorHeaderEvents, FlowEditorHeaderSlots> {
13
+ }
14
+ export {};
@@ -0,0 +1,56 @@
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 { flowStore, initFlow } from '../flowStore';
11
+ import { cleanInputs } from '../utils';
12
+ let jsonSetterDrawer;
13
+ let jsonViewerDrawer;
14
+ let pendingJson;
15
+ function importJson() {
16
+ Object.assign($flowStore, JSON.parse(pendingJson));
17
+ initFlow($flowStore);
18
+ sendUserToast('OpenFlow imported from JSON');
19
+ jsonSetterDrawer.toggleDrawer();
20
+ }
21
+ </script>
22
+
23
+ <Menu placement="bottom-end">
24
+ <button
25
+ slot="trigger"
26
+ class="flex items-center h-8 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"
27
+ >
28
+ Import/Export flow
29
+ </button>
30
+ <div class="divide-y divide-gray-200">
31
+ <MenuItem on:click={() => jsonSetterDrawer.toggleDrawer()}>
32
+ <Icon data={faFileImport} scale={0.6} class="inline mr-2" />
33
+ Import from a JSON OpenFlow
34
+ </MenuItem>
35
+ <MenuItem on:click={() => jsonViewerDrawer.toggleDrawer()}>
36
+ <Icon data={faFileExport} scale={0.6} class="inline mr-2" />
37
+ Export to a JSON OpenFlow
38
+ </MenuItem>
39
+ </div>
40
+ </Menu>
41
+
42
+ <Drawer bind:this={jsonSetterDrawer} size="800px">
43
+ <DrawerContent title="Import JSON" on:close={() => jsonSetterDrawer.toggleDrawer()}>
44
+ <button class="default-button px-4 py-2 font-semibold" on:click={() => importJson()}>
45
+ Import
46
+ </button>
47
+ <SimpleEditor bind:code={pendingJson} lang="json" class="h-full" />
48
+ </DrawerContent>
49
+ </Drawer>
50
+ <Drawer bind:this={jsonViewerDrawer} size="800px">
51
+ <DrawerContent title="See JSON" on:close={() => jsonViewerDrawer.toggleDrawer()}>
52
+ {#if $flowStore}
53
+ <FlowViewer flow={cleanInputs($flowStore)} tab="json" />
54
+ {/if}
55
+ </DrawerContent>
56
+ </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,49 @@
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 class="space-x-2 flex h-8">
20
+ <Button
21
+ size="sm"
22
+ disabled={upToDisabled}
23
+ color="light"
24
+ variant="border"
25
+ on:click={() => {
26
+ previewMode = 'upTo'
27
+
28
+ previewOpen = !previewOpen
29
+ }}
30
+ >
31
+ Test up to this step
32
+ <Icon data={faPlay} class="ml-2" scale={0.8} />
33
+ </Button>
34
+
35
+ <Button
36
+ on:click={() => {
37
+ previewMode = 'whole'
38
+ previewOpen = !previewOpen
39
+ }}
40
+ size="sm"
41
+ >
42
+ Test flow
43
+ <Icon data={faPlay} class="ml-2" scale={0.8} />
44
+ </Button>
45
+ </span>
46
+
47
+ <Drawer bind:open={previewOpen} size="800px">
48
+ <FlowPreviewContent bind:previewMode on:close={() => (previewOpen = !previewOpen)} />
49
+ </Drawer>