windmill-components 1.28.6 → 1.35.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.
- package/common.d.ts +3 -0
- package/components/AppConnect.svelte +29 -13
- package/components/ArgInput.svelte +28 -14
- package/components/ArgInput.svelte.d.ts +4 -0
- package/components/CenteredPage.svelte +2 -2
- package/components/DisplayResult.svelte +3 -3
- package/components/Editor.svelte +97 -97
- package/components/Editor.svelte.d.ts +3 -0
- package/components/EditorBar.svelte +57 -38
- package/components/FlowBuilder.svelte +40 -32
- package/components/FlowEditor.svelte +19 -57
- package/components/FlowEditor.svelte.d.ts +1 -0
- package/components/FlowJobResult.svelte +16 -16
- package/components/FlowModulesViewer.svelte +97 -0
- package/components/FlowModulesViewer.svelte.d.ts +17 -0
- package/components/FlowPreview.svelte +47 -68
- package/components/FlowPreview.svelte.d.ts +2 -6
- package/components/FlowPreviewContent.svelte +59 -44
- package/components/FlowPreviewContent.svelte.d.ts +0 -1
- package/components/FlowStatusViewer.svelte +104 -204
- package/components/FlowStatusViewer.svelte.d.ts +7 -4
- package/components/FlowViewer.svelte +60 -155
- package/components/FlowViewer.svelte.d.ts +0 -1
- package/components/IconedPath.svelte +12 -0
- package/components/IconedPath.svelte.d.ts +16 -0
- package/components/IconedResourceType.svelte +21 -2
- package/components/IconedResourceType.svelte.d.ts +1 -0
- package/components/InputTransformForm.svelte +9 -8
- package/components/InputTransformForm.svelte.d.ts +1 -1
- package/components/InviteGlobalUser.svelte +1 -1
- package/components/ItemPicker.svelte +6 -1
- package/components/JobStatus.svelte +1 -1
- package/components/ModuleStep.svelte +74 -96
- package/components/ModuleStep.svelte.d.ts +7 -4
- package/components/Multiselect.svelte +1 -1
- package/components/Path.svelte +62 -40
- package/components/Path.svelte.d.ts +2 -0
- package/components/ProgressBar.svelte +31 -0
- package/components/ProgressBar.svelte.d.ts +17 -0
- package/components/ProgressBarPart.svelte +20 -0
- package/components/ProgressBarPart.svelte.d.ts +20 -0
- package/components/ResourceEditor.svelte +2 -1
- package/components/ResourcePicker.svelte +9 -0
- package/components/SchemaForm.svelte +9 -4
- package/components/SchemaForm.svelte.d.ts +1 -1
- package/components/SchemaModal.svelte +20 -3
- package/components/SchemaViewer.svelte +58 -68
- package/components/ScriptBuilder.svelte +145 -122
- package/components/ScriptBuilder.svelte.d.ts +1 -0
- package/components/ScriptEditor.svelte +118 -339
- package/components/ScriptEditor.svelte.d.ts +0 -2
- package/components/ScriptSchema.svelte +45 -44
- package/components/SharedBadge.svelte +8 -3
- package/components/VariableEditor.svelte +1 -1
- package/components/common/drawer/Drawer.svelte +108 -0
- package/components/common/drawer/Drawer.svelte.d.ts +23 -0
- package/components/common/drawer/DrawerContent.svelte +19 -0
- package/components/common/drawer/DrawerContent.svelte.d.ts +20 -0
- package/components/common/menu/Menu.svelte +57 -0
- package/components/common/menu/Menu.svelte.d.ts +23 -0
- package/components/common/menu/MenuItem.svelte +9 -0
- package/components/common/menu/MenuItem.svelte.d.ts +27 -0
- package/components/common/tabs/Tab.svelte +17 -0
- package/components/common/tabs/Tab.svelte.d.ts +18 -0
- package/components/common/tabs/TabContent.svelte +12 -0
- package/components/common/tabs/TabContent.svelte.d.ts +19 -0
- package/components/common/tabs/Tabs.svelte +20 -0
- package/components/common/tabs/Tabs.svelte.d.ts +24 -0
- package/components/flows/CopyFirstStepSchema.svelte +4 -3
- package/components/flows/DynamicInputHelpBox.svelte +6 -4
- package/components/flows/DynamicInputHelpBox.svelte.d.ts +1 -1
- package/components/flows/FlowBox.svelte +15 -2
- package/components/flows/FlowBox.svelte.d.ts +14 -14
- package/components/flows/FlowBoxHeader.svelte +10 -3
- package/components/flows/FlowBoxHeader.svelte.d.ts +3 -0
- package/components/flows/FlowInput.svelte +14 -12
- package/components/flows/FlowInputs.svelte +56 -22
- package/components/flows/FlowInputs.svelte.d.ts +3 -1
- package/components/flows/FlowModuleHeader.svelte +69 -54
- package/components/flows/FlowModuleHeader.svelte.d.ts +6 -6
- package/components/flows/FlowSettings.svelte +82 -92
- package/components/flows/FlowSettings.svelte.d.ts +1 -1
- package/components/flows/FlowTimeline.svelte +169 -0
- package/components/flows/FlowTimeline.svelte.d.ts +21 -0
- package/components/flows/flowState.d.ts +14 -0
- package/components/flows/flowState.js +52 -0
- package/components/flows/flowStateUtils.d.ts +37 -0
- package/components/flows/flowStateUtils.js +220 -0
- package/components/flows/flowStore.d.ts +1 -16
- package/components/flows/flowStore.js +26 -203
- package/components/flows/pickers/FlowScriptPicker.svelte +5 -9
- package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +0 -1
- package/components/flows/pickers/PickHubScript.svelte +1 -1
- package/components/flows/pickers/PickHubScript.svelte.d.ts +1 -1
- package/components/flows/pickers/PickScript.svelte +1 -1
- package/components/flows/pickers/PickScript.svelte.d.ts +1 -1
- package/components/flows/scheduleUtils.d.ts +7 -0
- package/components/flows/scheduleUtils.js +21 -0
- package/components/flows/stepOpenedStore.d.ts +1 -0
- package/components/flows/stepOpenedStore.js +6 -0
- package/components/flows/utils.d.ts +6 -13
- package/components/flows/utils.js +47 -119
- package/components/icons/DiscordIcon.svelte +16 -0
- package/components/icons/DiscordIcon.svelte.d.ts +17 -0
- package/components/icons/HttpIcon.svelte +21 -0
- package/components/icons/HttpIcon.svelte.d.ts +17 -0
- package/components/icons/MastodonIcon.svelte +16 -0
- package/components/icons/MastodonIcon.svelte.d.ts +17 -0
- package/components/icons/MatrixIcon.svelte +16 -0
- package/components/icons/MatrixIcon.svelte.d.ts +17 -0
- package/components/icons/S3Icon.svelte +16 -0
- package/components/icons/S3Icon.svelte.d.ts +17 -0
- package/components/icons/WindmillIcon.svelte +68 -0
- package/components/icons/WindmillIcon.svelte.d.ts +17 -0
- package/components/jobs/JobDetail.svelte +176 -0
- package/components/jobs/JobDetail.svelte.d.ts +17 -0
- package/components/landing/FlowGettingStarted.svelte +95 -0
- package/components/landing/FlowGettingStarted.svelte.d.ts +19 -0
- package/components/landing/FlowLandingBox.svelte +69 -0
- package/components/landing/FlowLandingBox.svelte.d.ts +17 -0
- package/components/landing/RessourceGettingStarted.svelte +51 -0
- package/components/landing/RessourceGettingStarted.svelte.d.ts +19 -0
- package/components/landing/ScriptBox.svelte +81 -0
- package/components/landing/ScriptBox.svelte.d.ts +17 -0
- package/components/landing/ScriptGettingStarted.svelte +93 -0
- package/components/landing/ScriptGettingStarted.svelte.d.ts +19 -0
- package/components/preview/FlowPreviewStatus.svelte +28 -0
- package/components/preview/FlowPreviewStatus.svelte.d.ts +17 -0
- package/components/propertyPicker/ObjectViewer.svelte +13 -13
- package/components/propertyPicker/utils.js +3 -2
- package/components/script_editor/LogPanel.svelte +172 -0
- package/components/script_editor/LogPanel.svelte.d.ts +22 -0
- package/components/sidebar/MenuLink.svelte +49 -0
- package/components/sidebar/MenuLink.svelte.d.ts +21 -0
- package/components/sidebar/SidebarContent.svelte +55 -0
- package/components/sidebar/SidebarContent.svelte.d.ts +16 -0
- package/components/sidebar/UserMenu.svelte +62 -0
- package/components/sidebar/UserMenu.svelte.d.ts +16 -0
- package/components/sidebar/WorkspaceMenu.svelte +66 -0
- package/components/sidebar/WorkspaceMenu.svelte.d.ts +16 -0
- package/gen/core/OpenAPI.js +1 -1
- package/gen/core/request.js +1 -0
- package/gen/models/FlowModule.d.ts +5 -3
- package/gen/models/ForloopFlow.d.ts +2 -2
- package/gen/models/MainArgSignature.d.ts +14 -3
- package/gen/services/JobService.d.ts +10 -2
- package/gen/services/JobService.js +4 -2
- package/gen/services/ScriptService.d.ts +18 -0
- package/gen/services/ScriptService.js +30 -0
- package/infer.js +47 -24
- package/logout.js +1 -1
- package/package.json +57 -23
- package/script_helpers.d.ts +4 -1
- package/script_helpers.js +68 -17
- package/stores.d.ts +0 -2
- package/stores.js +0 -4
- package/utils.d.ts +5 -2
- package/utils.js +37 -6
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
<script>import { faInfoCircle, faPen, faPlus, faSliders, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import { Button, Toggle, Tooltip } from 'flowbite-svelte';
|
|
3
|
+
import Icon from 'svelte-awesome';
|
|
4
|
+
import ModuleStep from '../ModuleStep.svelte';
|
|
5
|
+
import FlowInput from './FlowInput.svelte';
|
|
6
|
+
import { emptyFlowModuleSchema } from './flowStateUtils';
|
|
7
|
+
import { stepOpened } from './stepOpenedStore';
|
|
8
|
+
export let args = {};
|
|
9
|
+
export let flowModuleSchemas;
|
|
10
|
+
export let parentIndex = undefined;
|
|
11
|
+
const root = parentIndex === undefined;
|
|
12
|
+
function insertAtIndex(index) {
|
|
13
|
+
flowModuleSchemas.splice(index, 0, emptyFlowModuleSchema());
|
|
14
|
+
flowModuleSchemas = flowModuleSchemas;
|
|
15
|
+
const indexes = getIndexes(parentIndex, index);
|
|
16
|
+
stepOpened.update(() => String(indexes.join('-')));
|
|
17
|
+
}
|
|
18
|
+
function removeAtIndex(index) {
|
|
19
|
+
flowModuleSchemas.splice(index, 1);
|
|
20
|
+
flowModuleSchemas = flowModuleSchemas;
|
|
21
|
+
}
|
|
22
|
+
function getIndexes(parentIndex, childIndex) {
|
|
23
|
+
const indexes = [];
|
|
24
|
+
if (parentIndex !== undefined) {
|
|
25
|
+
indexes.push(parentIndex);
|
|
26
|
+
}
|
|
27
|
+
indexes.push(childIndex);
|
|
28
|
+
return indexes;
|
|
29
|
+
}
|
|
30
|
+
const color = root ? 'blue' : 'orange';
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<div class="w-full">
|
|
34
|
+
<ol class="relative ml-4 border-l border-gray-200 dark:border-gray-700 space-y-12 border-dashed">
|
|
35
|
+
{#if root}
|
|
36
|
+
<li class="ml-8">
|
|
37
|
+
<span class="relative">
|
|
38
|
+
<span
|
|
39
|
+
class={`flex absolute -left-12 justify-center items-center w-8 h-8 bg-${color}-200 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-${color}-900`}
|
|
40
|
+
>
|
|
41
|
+
<Icon
|
|
42
|
+
class={`text-${color}-600 dark:text-${color}-400 text-font-bold text-center`}
|
|
43
|
+
data={faSliders}
|
|
44
|
+
/>
|
|
45
|
+
</span>
|
|
46
|
+
</span>
|
|
47
|
+
<slot name="settings" />
|
|
48
|
+
</li>
|
|
49
|
+
<li class="ml-8 ">
|
|
50
|
+
<span class="relative">
|
|
51
|
+
<span
|
|
52
|
+
class={`flex absolute top-4 -left-12 justify-center items-center w-8 h-8 bg-${color}-200 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-${color}-900`}
|
|
53
|
+
>
|
|
54
|
+
<Icon
|
|
55
|
+
class={`text-${color}-600 dark:text-${color}-400 font-bold text-center`}
|
|
56
|
+
data={faPen}
|
|
57
|
+
/>
|
|
58
|
+
</span>
|
|
59
|
+
</span>
|
|
60
|
+
<FlowInput />
|
|
61
|
+
</li>
|
|
62
|
+
{/if}
|
|
63
|
+
{#each flowModuleSchemas as flowModuleSchema, index (index)}
|
|
64
|
+
{#if flowModuleSchema.flowModule.value.type === 'forloopflow'}
|
|
65
|
+
<li id="module-{index}" class="ml-4 relative">
|
|
66
|
+
<button
|
|
67
|
+
on:click={() => insertAtIndex(index)}
|
|
68
|
+
class="flex absolute -top-10 -left-8 justify-center items-center bg-white border-2 border-gray-200 w-8 h-8 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-${color}-900"
|
|
69
|
+
>
|
|
70
|
+
<Icon class="text-gray-400" data={faPlus} />
|
|
71
|
+
</button>
|
|
72
|
+
<div
|
|
73
|
+
class="py-2 px-6 ml-4 mb-16 flex justify-between text-sm font-bold border border-gray-300 rounded-md shadow-md"
|
|
74
|
+
role="alert"
|
|
75
|
+
>
|
|
76
|
+
<span class="flex items-center z-50">
|
|
77
|
+
For loop
|
|
78
|
+
<Tooltip
|
|
79
|
+
content="Inside a loop, the flow input has an 'iter' property. It contains the value and the index of the iteration"
|
|
80
|
+
placement="bottom"
|
|
81
|
+
arrow
|
|
82
|
+
>
|
|
83
|
+
<Icon data={faInfoCircle} class="ml-2" /></Tooltip
|
|
84
|
+
>
|
|
85
|
+
</span>
|
|
86
|
+
<span class="flex items-center space-x-2">
|
|
87
|
+
<Toggle size="small" bind:checked={flowModuleSchema.flowModule.value.skip_failures}>
|
|
88
|
+
Skip failures
|
|
89
|
+
</Toggle>
|
|
90
|
+
<Button size="xs" color="alternative" on:click={() => removeAtIndex(index)}>
|
|
91
|
+
<Icon data={faTrashAlt} class="mr-2" />
|
|
92
|
+
Remove loop
|
|
93
|
+
</Button>
|
|
94
|
+
</span>
|
|
95
|
+
</div>
|
|
96
|
+
<span
|
|
97
|
+
class="flex absolute top-3 -left-8 justify-center items-center w-8 h-8 bg-orange-200 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-orange-900"
|
|
98
|
+
>
|
|
99
|
+
<span class={`text-orange-600 dark:text-orange-400 font-bold text-center`}>
|
|
100
|
+
{index + 1}
|
|
101
|
+
</span>
|
|
102
|
+
</span>
|
|
103
|
+
|
|
104
|
+
<svelte:self
|
|
105
|
+
bind:args
|
|
106
|
+
bind:flowModuleSchemas={flowModuleSchema.childFlowModules}
|
|
107
|
+
parentIndex={index}
|
|
108
|
+
/>
|
|
109
|
+
|
|
110
|
+
<div
|
|
111
|
+
class="flex px-6 py-4 ml-4 mt-4 text-sm font-bold border border-gray-300 rounded-md shadow-md z-50"
|
|
112
|
+
role="alert"
|
|
113
|
+
>
|
|
114
|
+
End of For Loop
|
|
115
|
+
<Tooltip
|
|
116
|
+
content="The results of each iteration are collecting in an array and is the result of the step. "
|
|
117
|
+
placement="bottom"
|
|
118
|
+
arrow
|
|
119
|
+
>
|
|
120
|
+
<Icon data={faInfoCircle} class="ml-2" /></Tooltip
|
|
121
|
+
>
|
|
122
|
+
</div>
|
|
123
|
+
</li>
|
|
124
|
+
{:else}
|
|
125
|
+
<li id="module-{String(getIndexes(parentIndex, index).join('-'))}" class="ml-8">
|
|
126
|
+
<span class="relative">
|
|
127
|
+
<button
|
|
128
|
+
on:click={() => insertAtIndex(index)}
|
|
129
|
+
class="flex absolute -top-10 -left-12 justify-center items-center bg-white border-2 border-gray-200 w-8 h-8 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-${color}-900"
|
|
130
|
+
>
|
|
131
|
+
<Icon class="text-gray-400" data={faPlus} />
|
|
132
|
+
</button>
|
|
133
|
+
<span
|
|
134
|
+
class={`flex absolute top-4 -left-12 justify-center items-center w-8 h-8 bg-${color}-200 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-${color}-900`}
|
|
135
|
+
>
|
|
136
|
+
<span class={`text-${color}-600 dark:text-${color}-400 font-bold text-center`}>
|
|
137
|
+
{index + 1}
|
|
138
|
+
</span>
|
|
139
|
+
</span>
|
|
140
|
+
<ModuleStep
|
|
141
|
+
indexes={getIndexes(parentIndex, index)}
|
|
142
|
+
bind:mod={flowModuleSchema.flowModule}
|
|
143
|
+
bind:args
|
|
144
|
+
bind:schema={flowModuleSchema.schema}
|
|
145
|
+
bind:childFlowModules={flowModuleSchema.childFlowModules}
|
|
146
|
+
on:delete={() => removeAtIndex(index)}
|
|
147
|
+
/>
|
|
148
|
+
</span>
|
|
149
|
+
</li>
|
|
150
|
+
{/if}
|
|
151
|
+
{#if flowModuleSchemas.length - 1 === index}
|
|
152
|
+
<button
|
|
153
|
+
on:click={() => insertAtIndex(flowModuleSchemas.length)}
|
|
154
|
+
class="-ml-4 -mt-4 flex justify-center items-center bg-white border-2 border-gray-200 w-8 h-8 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-${color}-900"
|
|
155
|
+
>
|
|
156
|
+
<Icon class="text-gray-400" data={faPlus} />
|
|
157
|
+
</button>
|
|
158
|
+
{/if}
|
|
159
|
+
{/each}
|
|
160
|
+
{#if flowModuleSchemas.length === 0}
|
|
161
|
+
<button
|
|
162
|
+
on:click={() => insertAtIndex(0)}
|
|
163
|
+
class="-ml-4 flex justify-center items-center bg-white border-2 border-gray-200 w-8 h-8 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-${color}-900"
|
|
164
|
+
>
|
|
165
|
+
<Icon class="text-gray-400" data={faPlus} />
|
|
166
|
+
</button>
|
|
167
|
+
{/if}
|
|
168
|
+
</ol>
|
|
169
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { FlowState } from './flowState';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
args?: Record<string, any> | undefined;
|
|
6
|
+
flowModuleSchemas: FlowState;
|
|
7
|
+
parentIndex?: number | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {
|
|
13
|
+
settings: {};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare type FlowTimelineProps = typeof __propDef.props;
|
|
17
|
+
export declare type FlowTimelineEvents = typeof __propDef.events;
|
|
18
|
+
export declare type FlowTimelineSlots = typeof __propDef.slots;
|
|
19
|
+
export default class FlowTimeline extends SvelteComponentTyped<FlowTimelineProps, FlowTimelineEvents, FlowTimelineSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Schema } from '../../common';
|
|
2
|
+
import type { Flow, FlowModule } from '../../gen';
|
|
3
|
+
export declare type FlowModuleSchema = {
|
|
4
|
+
flowModule: FlowModule;
|
|
5
|
+
schema: Schema;
|
|
6
|
+
childFlowModules?: FlowModuleSchema[];
|
|
7
|
+
previewResult?: any;
|
|
8
|
+
};
|
|
9
|
+
export declare type FlowState = FlowModuleSchema[];
|
|
10
|
+
export declare const flowStateStore: import("svelte/store").Writable<FlowState>;
|
|
11
|
+
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;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { derived, writable } from 'svelte/store';
|
|
2
|
+
import { emptyFlowModuleSchema, isEmptyFlowModule, loadFlowModuleSchema } from './flowStateUtils';
|
|
3
|
+
export const flowStateStore = writable(undefined);
|
|
4
|
+
export async function initFlowState(flow) {
|
|
5
|
+
const flowState = await flowModulesToFlowState(flow.value.modules);
|
|
6
|
+
flowStateStore.set(flowState);
|
|
7
|
+
}
|
|
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);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
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
|
+
}));
|
|
37
|
+
}
|
|
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;
|
|
52
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 }: {
|
|
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>;
|
|
13
|
+
export declare function createInlineScriptModuleFromPath(path: string): Promise<FlowModule>;
|
|
14
|
+
export declare function createScriptFromInlineScript({ flowModule, suffix, schema }: {
|
|
15
|
+
flowModule: FlowModule;
|
|
16
|
+
suffix: string;
|
|
17
|
+
schema: Schema;
|
|
18
|
+
}): Promise<FlowModuleSchema>;
|
|
19
|
+
export declare function isEmptyFlowModule(flowModule: FlowModule): boolean;
|
|
20
|
+
declare type Result = any;
|
|
21
|
+
declare type PickableProperties = {
|
|
22
|
+
flow_input?: Object;
|
|
23
|
+
previous_result: Result | undefined;
|
|
24
|
+
step: Result[];
|
|
25
|
+
};
|
|
26
|
+
declare type StepPropPicker = {
|
|
27
|
+
pickableProperties: PickableProperties;
|
|
28
|
+
extraLib: string;
|
|
29
|
+
};
|
|
30
|
+
export declare function getStepPropPicker(indexes: number[], flowInputSchema: Schema, flowState: FlowState, args: Record<string, any>): StepPropPicker;
|
|
31
|
+
export declare type JobResult = {
|
|
32
|
+
job?: Job;
|
|
33
|
+
innerJobs?: JobResult[];
|
|
34
|
+
loopJobs?: JobResult[];
|
|
35
|
+
};
|
|
36
|
+
export declare function mapJobResultsToFlowState(jobs: JobResult, config: 'upto' | 'justthis', configIndex: number): void;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { CompletedJob, Job, ScriptService } from '../../gen';
|
|
2
|
+
import { initialCode } from '../../script_helpers';
|
|
3
|
+
import { userStore, workspaceStore } from '../../stores';
|
|
4
|
+
import { buildExtraLib, emptyModule, emptySchema, getScriptByPath, objectToTsType, schemaToObject, schemaToTsType } from '../../utils';
|
|
5
|
+
import { get } from 'svelte/store';
|
|
6
|
+
import { flowStateStore } from './flowState';
|
|
7
|
+
import { flowStore } from './flowStore';
|
|
8
|
+
import { jobsToResults, loadSchemaFromModule } from './utils';
|
|
9
|
+
export function emptyFlowModuleSchema() {
|
|
10
|
+
return {
|
|
11
|
+
flowModule: emptyModule(),
|
|
12
|
+
schema: emptySchema()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export async function loadFlowModuleSchema(flowModule) {
|
|
16
|
+
try {
|
|
17
|
+
const { input_transforms, schema } = await loadSchemaFromModule(flowModule);
|
|
18
|
+
flowModule.input_transforms = input_transforms;
|
|
19
|
+
return { flowModule, schema };
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
return { flowModule, schema: emptySchema() };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function pickScript(path) {
|
|
26
|
+
const flowModule = {
|
|
27
|
+
value: { type: 'script', path },
|
|
28
|
+
input_transforms: {}
|
|
29
|
+
};
|
|
30
|
+
return await loadFlowModuleSchema(flowModule);
|
|
31
|
+
}
|
|
32
|
+
export async function createInlineScriptModule({ language, type }) {
|
|
33
|
+
const code = initialCode(language, type);
|
|
34
|
+
const flowModule = {
|
|
35
|
+
value: { type: 'rawscript', content: code, language },
|
|
36
|
+
input_transforms: {}
|
|
37
|
+
};
|
|
38
|
+
return await loadFlowModuleSchema(flowModule);
|
|
39
|
+
}
|
|
40
|
+
export async function createLoop() {
|
|
41
|
+
const loopFlowModule = {
|
|
42
|
+
value: {
|
|
43
|
+
type: 'forloopflow',
|
|
44
|
+
modules: [],
|
|
45
|
+
iterator: { type: 'javascript', expr: 'result' },
|
|
46
|
+
skip_failures: true
|
|
47
|
+
},
|
|
48
|
+
input_transforms: {}
|
|
49
|
+
};
|
|
50
|
+
const { flowModule, schema } = await loadFlowModuleSchema(loopFlowModule);
|
|
51
|
+
return {
|
|
52
|
+
flowModule,
|
|
53
|
+
schema,
|
|
54
|
+
childFlowModules: [emptyFlowModuleSchema()],
|
|
55
|
+
previewResult: undefined
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export async function fork(flowModule) {
|
|
59
|
+
if (flowModule.value.type !== 'script') {
|
|
60
|
+
throw new Error('Can only fork a script module');
|
|
61
|
+
}
|
|
62
|
+
const fm = await createInlineScriptModuleFromPath(flowModule.value.path ?? '');
|
|
63
|
+
return await loadFlowModuleSchema(fm);
|
|
64
|
+
}
|
|
65
|
+
export async function createInlineScriptModuleFromPath(path) {
|
|
66
|
+
const { content, language } = await getScriptByPath(path);
|
|
67
|
+
return {
|
|
68
|
+
value: {
|
|
69
|
+
type: 'rawscript',
|
|
70
|
+
language: language,
|
|
71
|
+
content: content,
|
|
72
|
+
path
|
|
73
|
+
},
|
|
74
|
+
input_transforms: {}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export async function createScriptFromInlineScript({ flowModule, suffix, schema }) {
|
|
78
|
+
const flow = get(flowStore);
|
|
79
|
+
const user = get(userStore);
|
|
80
|
+
if (flowModule.value.type != 'rawscript') {
|
|
81
|
+
throw new Error("Can't create script from non-inline script");
|
|
82
|
+
}
|
|
83
|
+
const originalScriptPath = flowModule.value.path;
|
|
84
|
+
const wasForked = Boolean(originalScriptPath);
|
|
85
|
+
if (wasForked && originalScriptPath) {
|
|
86
|
+
const [first, second, ...others] = originalScriptPath.split('/');
|
|
87
|
+
suffix = others.join('/');
|
|
88
|
+
}
|
|
89
|
+
const path = `${flow.path}/${suffix}`;
|
|
90
|
+
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 availablePath = await findNextAvailablePath(path);
|
|
93
|
+
await ScriptService.createScript({
|
|
94
|
+
workspace: get(workspaceStore),
|
|
95
|
+
requestBody: {
|
|
96
|
+
path: availablePath,
|
|
97
|
+
summary: '',
|
|
98
|
+
description,
|
|
99
|
+
content: flowModule.value.content,
|
|
100
|
+
parent_hash: undefined,
|
|
101
|
+
schema,
|
|
102
|
+
is_template: false,
|
|
103
|
+
language: flowModule.value.language
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return pickScript(availablePath);
|
|
107
|
+
}
|
|
108
|
+
async function findNextAvailablePath(path) {
|
|
109
|
+
try {
|
|
110
|
+
await ScriptService.getScriptByPath({
|
|
111
|
+
workspace: get(workspaceStore),
|
|
112
|
+
path
|
|
113
|
+
});
|
|
114
|
+
const [_, version] = path.split(/.*_([0-9]*)/);
|
|
115
|
+
if (version.length > 0) {
|
|
116
|
+
path = path.slice(0, -(version.length + 1));
|
|
117
|
+
}
|
|
118
|
+
path = `${path}_${Number(version) + 1}`;
|
|
119
|
+
return findNextAvailablePath(path);
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
// Catching an error means the path is available
|
|
123
|
+
return path;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function isEmptyFlowModule(flowModule) {
|
|
127
|
+
return flowModule.value.type === 'script' && flowModule.value.path === '';
|
|
128
|
+
}
|
|
129
|
+
export function getStepPropPicker(indexes, flowInputSchema, flowState, args) {
|
|
130
|
+
const isInsideLoop = indexes.length > 1;
|
|
131
|
+
const [parentIndex] = indexes;
|
|
132
|
+
const flowInput = schemaToObject(flowInputSchema, args);
|
|
133
|
+
const results = getPreviousResults(flowState, parentIndex);
|
|
134
|
+
const lastResult = results.length > 0 ? results[results.length - 1] : undefined;
|
|
135
|
+
if (isInsideLoop) {
|
|
136
|
+
const forLoopFlowInput = {
|
|
137
|
+
...flowInput,
|
|
138
|
+
iter: {
|
|
139
|
+
value: "Iteration's value",
|
|
140
|
+
index: "Iteration's index"
|
|
141
|
+
}
|
|
142
|
+
};
|
|
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
|
+
}
|
|
150
|
+
const extraLib = buildExtraLib(objectToTsType(forLoopFlowInput), undefined);
|
|
151
|
+
return {
|
|
152
|
+
extraLib,
|
|
153
|
+
pickableProperties: {
|
|
154
|
+
flow_input: forLoopFlowInput,
|
|
155
|
+
step: [],
|
|
156
|
+
previous_result: {}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const extraLib = buildExtraLib(schemaToTsType(flowInputSchema), objectToTsType(lastResult));
|
|
162
|
+
return {
|
|
163
|
+
extraLib,
|
|
164
|
+
pickableProperties: {
|
|
165
|
+
flow_input: flowInput,
|
|
166
|
+
step: results,
|
|
167
|
+
previous_result: lastResult
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function getPreviousResults(flowModuleSchemas, target) {
|
|
173
|
+
if (!Array.isArray(flowModuleSchemas) || target < 1) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
const results = extractPreviewResults(flowModuleSchemas);
|
|
177
|
+
return results.splice(0, target);
|
|
178
|
+
}
|
|
179
|
+
function extractPreviewResults(flowModuleSchemas) {
|
|
180
|
+
return flowModuleSchemas.map((fms) => fms.previewResult);
|
|
181
|
+
}
|
|
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
|
+
});
|
|
192
|
+
}
|
|
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
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
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
|
+
}
|
|
220
|
+
}
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { RawScript, type Flow } from '../../gen';
|
|
1
|
+
import type { Flow } from '../../gen';
|
|
3
2
|
export declare type FlowMode = 'push' | 'pull';
|
|
4
|
-
export declare const mode: import("svelte/store").Writable<FlowMode>;
|
|
5
3
|
export declare const flowStore: import("svelte/store").Writable<Flow>;
|
|
6
|
-
export declare const schemasStore: import("svelte/store").Writable<Schema[]>;
|
|
7
4
|
export declare function initFlow(flow: Flow): void;
|
|
8
|
-
export declare function codeToStaticTemplate(code?: string): string | undefined;
|
|
9
|
-
export declare function flattenForloopFlows(flow: Flow): Flow;
|
|
10
|
-
export declare const isCopyFirstStepSchemaDisabled: import("svelte/store").Readable<boolean>;
|
|
11
|
-
export declare function addModule(i?: number): void;
|
|
12
|
-
export declare function pickScript(path: string, step: number): Promise<void>;
|
|
13
|
-
export declare function createInlineScriptModule(language: RawScript.language, step: number, mode: FlowMode): Promise<void>;
|
|
14
|
-
export declare function loadSchema(step: number): Promise<void>;
|
|
15
|
-
export declare function fork(step: number): Promise<void>;
|
|
16
|
-
export declare function createScriptFromInlineScript(step: number): Promise<void>;
|
|
17
|
-
export declare function removeModule(step: number): void;
|
|
18
5
|
export declare function copyFirstStepSchema(): Promise<void>;
|
|
19
|
-
export declare function findNextAvailablePath(path: string): Promise<string>;
|
|
20
|
-
export declare function shouldPickOrCreateScript(flow: Flow, step: number): boolean;
|