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
|
@@ -1,217 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { userStore, workspaceStore } from '../../stores';
|
|
4
|
-
import { emptySchema } from '../../utils';
|
|
5
|
-
import { derived, get, writable } from 'svelte/store';
|
|
6
|
-
import { createInlineScriptModuleFromPath, getFirstStepSchema, loadSchemaFromModule, scrollIntoView } from './utils';
|
|
7
|
-
export const mode = writable('push');
|
|
1
|
+
import { get, writable } from 'svelte/store';
|
|
2
|
+
import { flowStateStore, initFlowState } from './flowState';
|
|
8
3
|
export const flowStore = writable(undefined);
|
|
9
|
-
export const schemasStore = writable([]);
|
|
10
4
|
export function initFlow(flow) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
for (const mod of flow.value.modules) {
|
|
6
|
+
migrateFlowModule(mod);
|
|
7
|
+
let val = mod.value;
|
|
8
|
+
if (val.type == 'forloopflow') {
|
|
9
|
+
let flowVal = val;
|
|
10
|
+
if (flowVal.value && flowVal.value.modules) {
|
|
11
|
+
flowVal.modules = flowVal.value.modules;
|
|
12
|
+
flowVal.modules.forEach(migrateFlowModule);
|
|
13
|
+
flowVal.value = undefined;
|
|
20
14
|
}
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
schemasStore.set([]);
|
|
24
|
-
flowStore.set(flow);
|
|
25
|
-
// For each module in flow, we should load the corresponding schema
|
|
26
|
-
flow.value.modules.forEach((_, index) => {
|
|
27
|
-
loadSchema(index);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
export function codeToStaticTemplate(code) {
|
|
31
|
-
if (!code)
|
|
32
|
-
return undefined;
|
|
33
|
-
const lines = code
|
|
34
|
-
.split('\n')
|
|
35
|
-
.slice(1)
|
|
36
|
-
.filter((x) => x != '');
|
|
37
|
-
if (lines.length == 1) {
|
|
38
|
-
const line = lines[0].trim();
|
|
39
|
-
if (line[0] == '`' && line.charAt(line.length - 1) == '`') {
|
|
40
|
-
return line.slice(1, line.length - 1);
|
|
41
15
|
}
|
|
42
16
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
newFlow.value.modules = newFlow.value.modules.slice(0, 1);
|
|
51
|
-
newFlow.value.modules.push(...oldModules);
|
|
52
|
-
}
|
|
53
|
-
return newFlow;
|
|
54
|
-
}
|
|
55
|
-
export const isCopyFirstStepSchemaDisabled = derived(flowStore, (flow) => {
|
|
56
|
-
if (flow) {
|
|
57
|
-
const modules = flow.value.modules;
|
|
58
|
-
const [firstModule] = modules;
|
|
59
|
-
return (modules.length === 0 || (firstModule.value.type === 'script' && firstModule.value.path === ''));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
export function addModule(i) {
|
|
66
|
-
const newModule = {
|
|
67
|
-
value: { type: 'script', path: '' },
|
|
68
|
-
input_transform: {}
|
|
69
|
-
};
|
|
70
|
-
flowStore.update((flow) => {
|
|
71
|
-
const insertAt = i ?? flow.value.modules.length;
|
|
72
|
-
flow.value.modules.splice(insertAt, 0, newModule);
|
|
73
|
-
flow.value.modules = flow.value.modules;
|
|
74
|
-
setTimeout(() => scrollIntoView(document.querySelector(`#module-${insertAt}`)), 100);
|
|
75
|
-
return flow;
|
|
76
|
-
});
|
|
77
|
-
schemasStore.update((schemas) => {
|
|
78
|
-
if (typeof i !== 'undefined') {
|
|
79
|
-
const previousSchema = schemas[i];
|
|
80
|
-
const hadSchema = Boolean(previousSchema);
|
|
81
|
-
if (hadSchema) {
|
|
82
|
-
schemas[i] = emptySchema();
|
|
83
|
-
schemas[i + 1] = previousSchema;
|
|
84
|
-
}
|
|
17
|
+
flowStore.set(flow);
|
|
18
|
+
initFlowState(flow);
|
|
19
|
+
function migrateFlowModule(mod) {
|
|
20
|
+
let modVal = mod;
|
|
21
|
+
if (modVal.input_transform) {
|
|
22
|
+
modVal.input_transforms = modVal.input_transform;
|
|
23
|
+
delete modVal.input_transform;
|
|
85
24
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
flowStore.update((flow) => {
|
|
91
|
-
if (flow.value.modules[step]) {
|
|
92
|
-
flow.value.modules[step].value = { type: 'script', path };
|
|
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 };
|
|
27
|
+
delete modVal.stop_after_if_expr;
|
|
28
|
+
delete modVal.skip_if_stopped;
|
|
93
29
|
}
|
|
94
|
-
return flow;
|
|
95
|
-
});
|
|
96
|
-
await loadSchema(step);
|
|
97
|
-
}
|
|
98
|
-
export async function createInlineScriptModule(language, step, mode) {
|
|
99
|
-
const code = initialCode(language, mode === 'pull' && step == 0);
|
|
100
|
-
flowStore.update((flow) => {
|
|
101
|
-
flow.value.modules[step].value = {
|
|
102
|
-
type: 'rawscript',
|
|
103
|
-
content: code,
|
|
104
|
-
language
|
|
105
|
-
};
|
|
106
|
-
return flow;
|
|
107
|
-
});
|
|
108
|
-
await loadSchema(step);
|
|
109
|
-
}
|
|
110
|
-
export async function loadSchema(step) {
|
|
111
|
-
const flow = get(flowStore);
|
|
112
|
-
const module = flow.value.modules[step];
|
|
113
|
-
const { input_transform, schema } = await loadSchemaFromModule(module);
|
|
114
|
-
flowStore.update((flow) => {
|
|
115
|
-
flow.value.modules[step].input_transform = input_transform;
|
|
116
|
-
return flow;
|
|
117
|
-
});
|
|
118
|
-
schemasStore.update((schemas) => {
|
|
119
|
-
schemas[step] = schema;
|
|
120
|
-
return schemas;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
export async function fork(step) {
|
|
124
|
-
const flow = get(flowStore);
|
|
125
|
-
const flowModuleValue = flow.value.modules[step].value;
|
|
126
|
-
if (flowModuleValue.type !== 'script') {
|
|
127
|
-
throw new Error('Can only fork a script module');
|
|
128
|
-
}
|
|
129
|
-
if (flowModuleValue.path) {
|
|
130
|
-
const moduleValue = await createInlineScriptModuleFromPath(flowModuleValue.path);
|
|
131
|
-
flowStore.update((flow) => {
|
|
132
|
-
flow.value.modules[step].value = moduleValue;
|
|
133
|
-
return flow;
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
export async function createScriptFromInlineScript(step) {
|
|
138
|
-
const flow = get(flowStore);
|
|
139
|
-
const schemas = get(schemasStore);
|
|
140
|
-
const user = get(userStore);
|
|
141
|
-
const flowModuleValue = flow.value.modules[step].value;
|
|
142
|
-
if (flowModuleValue.type != 'rawscript') {
|
|
143
|
-
throw new Error("Can't create script from non-inline script");
|
|
144
|
-
}
|
|
145
|
-
const originalScriptPath = flowModuleValue.path;
|
|
146
|
-
const wasForked = Boolean(originalScriptPath);
|
|
147
|
-
let suffix = `step-${step}`;
|
|
148
|
-
if (wasForked && originalScriptPath) {
|
|
149
|
-
const [first, second, ...others] = originalScriptPath.split('/');
|
|
150
|
-
suffix = others.join('/');
|
|
151
30
|
}
|
|
152
|
-
const path = `${flow.path}/${suffix}`;
|
|
153
|
-
const forkedDescription = wasForked ? `as a fork of ${originalScriptPath}` : '';
|
|
154
|
-
const description = `This script was edited in place of flow ${flow.path} ${forkedDescription} by ${user?.username} at step ${step}.`;
|
|
155
|
-
const availablePath = await findNextAvailablePath(path);
|
|
156
|
-
await ScriptService.createScript({
|
|
157
|
-
workspace: get(workspaceStore),
|
|
158
|
-
requestBody: {
|
|
159
|
-
path: availablePath,
|
|
160
|
-
summary: '',
|
|
161
|
-
description,
|
|
162
|
-
content: flowModuleValue.content,
|
|
163
|
-
parent_hash: undefined,
|
|
164
|
-
schema: schemas[step],
|
|
165
|
-
is_template: false,
|
|
166
|
-
language: flowModuleValue.language
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
flowStore.update((flow) => {
|
|
170
|
-
flow.value.modules[step].value = {
|
|
171
|
-
type: 'script',
|
|
172
|
-
path: availablePath
|
|
173
|
-
};
|
|
174
|
-
return flow;
|
|
175
|
-
});
|
|
176
|
-
await loadSchema(step);
|
|
177
|
-
}
|
|
178
|
-
export function removeModule(step) {
|
|
179
|
-
flowStore.update((flow) => {
|
|
180
|
-
flow.value.modules.splice(step, 1);
|
|
181
|
-
return flow;
|
|
182
|
-
});
|
|
183
|
-
schemasStore.update((schemas) => {
|
|
184
|
-
schemas.splice(step, 1);
|
|
185
|
-
return schemas;
|
|
186
|
-
});
|
|
187
31
|
}
|
|
188
32
|
export async function copyFirstStepSchema() {
|
|
189
|
-
const
|
|
190
|
-
const flowSchema = await getFirstStepSchema(flow);
|
|
33
|
+
const flowState = get(flowStateStore);
|
|
191
34
|
flowStore.update((flow) => {
|
|
192
|
-
|
|
35
|
+
if (flowState[0].schema) {
|
|
36
|
+
flow.schema = flowState[0].schema;
|
|
37
|
+
}
|
|
193
38
|
return flow;
|
|
194
39
|
});
|
|
195
40
|
}
|
|
196
|
-
export async function findNextAvailablePath(path) {
|
|
197
|
-
try {
|
|
198
|
-
await ScriptService.getScriptByPath({
|
|
199
|
-
workspace: get(workspaceStore),
|
|
200
|
-
path
|
|
201
|
-
});
|
|
202
|
-
const [_, version] = path.split(/.*_([0-9]*)/);
|
|
203
|
-
if (version.length > 0) {
|
|
204
|
-
path = path.slice(0, -(version.length + 1));
|
|
205
|
-
}
|
|
206
|
-
path = `${path}_${Number(version) + 1}`;
|
|
207
|
-
return findNextAvailablePath(path);
|
|
208
|
-
}
|
|
209
|
-
catch (e) {
|
|
210
|
-
// Catching an error means the path is available
|
|
211
|
-
return path;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
export function shouldPickOrCreateScript(flow, step) {
|
|
215
|
-
const module = flow.value.modules[step];
|
|
216
|
-
return module.value.type === 'script' && module.value.path === '';
|
|
217
|
-
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { Button } from 'flowbite-svelte';
|
|
2
2
|
import Icon from 'svelte-awesome';
|
|
3
3
|
export let disabled = false;
|
|
4
4
|
export let icon;
|
|
5
5
|
export let label;
|
|
6
6
|
export let iconColor;
|
|
7
|
-
export let tooltip = undefined;
|
|
8
7
|
</script>
|
|
9
8
|
|
|
10
|
-
<
|
|
11
|
-
<Icon data={icon} class={`
|
|
12
|
-
{label}
|
|
13
|
-
|
|
14
|
-
<Tooltip placement="bottom" content={tooltip}>(?)</Tooltip>
|
|
15
|
-
{/if}
|
|
16
|
-
</button>
|
|
9
|
+
<Button {disabled} on:click size="md" class="text-left" color="alternative">
|
|
10
|
+
<Icon data={icon} class={`mr-2 ${iconColor} w-4`} scale={1.5} />
|
|
11
|
+
<span class="text-sm text-left"> {label} </span>
|
|
12
|
+
</Button>
|
|
@@ -3,7 +3,7 @@ import FlowScriptPicker from './FlowScriptPicker.svelte';
|
|
|
3
3
|
import ItemPicker from '../../ItemPicker.svelte';
|
|
4
4
|
import { hubScripts } from '../../../stores';
|
|
5
5
|
import { createEventDispatcher } from 'svelte';
|
|
6
|
-
export let isTrigger;
|
|
6
|
+
export let isTrigger = false;
|
|
7
7
|
let items;
|
|
8
8
|
$: items = $hubScripts?.filter((x) => x.is_trigger == isTrigger) ?? [];
|
|
9
9
|
let itemPicker;
|
|
@@ -4,7 +4,7 @@ import { ScriptService } from '../../../gen';
|
|
|
4
4
|
import { workspaceStore } from '../../../stores';
|
|
5
5
|
import { createEventDispatcher } from 'svelte';
|
|
6
6
|
import FlowScriptPicker from './FlowScriptPicker.svelte';
|
|
7
|
-
export let isTrigger;
|
|
7
|
+
export let isTrigger = false;
|
|
8
8
|
let items = [];
|
|
9
9
|
let itemPicker;
|
|
10
10
|
const dispatch = createEventDispatcher();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ScheduleService } from '../../gen';
|
|
2
|
+
// Load the schedule of a flow given its path and the workspace
|
|
3
|
+
export async function loadFlowSchedule(path, workspace = '') {
|
|
4
|
+
const existsSchedule = await ScheduleService.existsSchedule({
|
|
5
|
+
workspace,
|
|
6
|
+
path
|
|
7
|
+
});
|
|
8
|
+
if (!existsSchedule) {
|
|
9
|
+
throw new Error(`Flow at path: ${path} doesn't exit`);
|
|
10
|
+
}
|
|
11
|
+
const schedule = await ScheduleService.getSchedule({
|
|
12
|
+
workspace,
|
|
13
|
+
path
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
enabled: schedule.enabled,
|
|
17
|
+
cron: schedule.schedule,
|
|
18
|
+
args: schedule.args ?? {},
|
|
19
|
+
previewArgs: JSON.parse(JSON.stringify(schedule.args))
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const stepOpened: import("svelte/store").Writable<string | undefined>;
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import type { Schema } from '../../common';
|
|
2
|
-
import { type Flow, type FlowModule, type
|
|
3
|
-
|
|
4
|
-
export declare function flowToMode(flow: Flow | any, mode: FlowMode): Flow;
|
|
2
|
+
import { type Flow, type FlowModule, type InputTransform, type Job } from '../../gen';
|
|
3
|
+
export declare function cleanInputs(flow: Flow | any): Flow;
|
|
5
4
|
export declare function getTypeAsString(arg: any): string;
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function createInlineScriptModuleFromPath(path: string): Promise<FlowModuleValue>;
|
|
8
|
-
export declare function scrollIntoView(el: any): void;
|
|
5
|
+
export declare function scrollIntoView(element: any): void;
|
|
9
6
|
export declare function loadSchemaFromModule(module: FlowModule): Promise<{
|
|
10
|
-
|
|
7
|
+
input_transforms: Record<string, InputTransform>;
|
|
11
8
|
schema: Schema;
|
|
12
9
|
}>;
|
|
13
10
|
export declare function isCodeInjection(expr: string | undefined): boolean;
|
|
14
|
-
export declare function getDefaultExpr(
|
|
15
|
-
export declare function getPickableProperties(schema: Schema, args: Record<string, any>, previewResults: Record<number, Object>, mode: FlowMode, i: number): {
|
|
16
|
-
flow_input: any;
|
|
17
|
-
previous_result: any;
|
|
18
|
-
step: any[];
|
|
19
|
-
};
|
|
11
|
+
export declare function getDefaultExpr(importPath?: string | undefined, key?: string, previousExpr?: string): string;
|
|
20
12
|
export declare function jobsToResults(jobs: Job[]): any;
|
|
21
13
|
export declare function runFlowPreview(args: Record<string, any>, flow: Flow): Promise<string>;
|
|
14
|
+
export declare function codeToStaticTemplate(code?: string): string | undefined;
|
|
@@ -2,19 +2,20 @@ import { JobService } from '../../gen';
|
|
|
2
2
|
import { inferArgs } from '../../infer';
|
|
3
3
|
import { loadSchema } from '../../scripts';
|
|
4
4
|
import { workspaceStore } from '../../stores';
|
|
5
|
-
import { emptySchema
|
|
5
|
+
import { emptySchema } from '../../utils';
|
|
6
6
|
import { get } from 'svelte/store';
|
|
7
|
-
|
|
8
|
-
export function flowToMode(flow, mode) {
|
|
7
|
+
export function cleanInputs(flow) {
|
|
9
8
|
const newFlow = JSON.parse(JSON.stringify(flow));
|
|
10
9
|
newFlow.value.modules.forEach((mod) => {
|
|
11
|
-
Object.values(mod.
|
|
10
|
+
Object.values(mod.input_transforms).forEach((inp) => {
|
|
12
11
|
// for now we use the value for dynamic expression when done in the static editor so we have to resort to this
|
|
13
12
|
if (inp.type == 'javascript') {
|
|
14
13
|
//@ts-ignore
|
|
15
14
|
inp.value = undefined;
|
|
16
|
-
inp.expr = inp.expr
|
|
17
|
-
.
|
|
15
|
+
inp.expr = inp.expr
|
|
16
|
+
.split('\n')
|
|
17
|
+
.filter((x) => x != '' &&
|
|
18
|
+
!x.startsWith(`import { previous_result, flow_input, step, variable, resource, params } from 'windmill@`))
|
|
18
19
|
.join('\n');
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
@@ -23,29 +24,6 @@ export function flowToMode(flow, mode) {
|
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
26
|
});
|
|
26
|
-
if (mode == 'pull') {
|
|
27
|
-
const triggerModule = newFlow.value.modules[0];
|
|
28
|
-
const oldModules = newFlow.value.modules.slice(1);
|
|
29
|
-
if (triggerModule) {
|
|
30
|
-
triggerModule.stop_after_if_expr = 'result.length == 0';
|
|
31
|
-
triggerModule.skip_if_stopped = true;
|
|
32
|
-
}
|
|
33
|
-
newFlow.value.modules = newFlow.value.modules.slice(0, 1);
|
|
34
|
-
if (oldModules.length > 0) {
|
|
35
|
-
newFlow.value.modules.push({
|
|
36
|
-
//TODO: once we allow arbitrary for loop, we will also allow arbitrary input transform here
|
|
37
|
-
input_transform: {},
|
|
38
|
-
value: {
|
|
39
|
-
type: 'forloopflow',
|
|
40
|
-
iterator: { type: 'javascript', expr: 'result' },
|
|
41
|
-
value: {
|
|
42
|
-
modules: oldModules
|
|
43
|
-
},
|
|
44
|
-
skip_failures: true
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
27
|
return newFlow;
|
|
50
28
|
}
|
|
51
29
|
export function getTypeAsString(arg) {
|
|
@@ -57,37 +35,15 @@ export function getTypeAsString(arg) {
|
|
|
57
35
|
}
|
|
58
36
|
return typeof arg;
|
|
59
37
|
}
|
|
60
|
-
export
|
|
61
|
-
|
|
62
|
-
if (firstModule.value.type === 'rawscript') {
|
|
63
|
-
const { language, content } = firstModule.value;
|
|
64
|
-
if (language && content) {
|
|
65
|
-
const schema = emptySchema();
|
|
66
|
-
await inferArgs(language, content, schema);
|
|
67
|
-
return schema;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else if (firstModule.value.type == 'script') {
|
|
71
|
-
return await loadSchema(firstModule.value.path);
|
|
72
|
-
}
|
|
73
|
-
return emptySchema();
|
|
74
|
-
}
|
|
75
|
-
export async function createInlineScriptModuleFromPath(path) {
|
|
76
|
-
const { content, language } = await getScriptByPath(path);
|
|
77
|
-
return {
|
|
78
|
-
type: 'rawscript',
|
|
79
|
-
language: language,
|
|
80
|
-
content: content,
|
|
81
|
-
path
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
export function scrollIntoView(el) {
|
|
85
|
-
if (!el)
|
|
38
|
+
export function scrollIntoView(element) {
|
|
39
|
+
if (!element)
|
|
86
40
|
return;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
41
|
+
var headerOffset = 45;
|
|
42
|
+
var elementPosition = element.getBoundingClientRect().top;
|
|
43
|
+
var offsetPosition = elementPosition + window.pageYOffset - headerOffset;
|
|
44
|
+
window.scrollTo({
|
|
45
|
+
top: offsetPosition,
|
|
46
|
+
behavior: 'smooth'
|
|
91
47
|
});
|
|
92
48
|
}
|
|
93
49
|
export async function loadSchemaFromModule(module) {
|
|
@@ -96,16 +52,22 @@ export async function loadSchemaFromModule(module) {
|
|
|
96
52
|
let schema;
|
|
97
53
|
if (mod.type === 'rawscript') {
|
|
98
54
|
schema = emptySchema();
|
|
99
|
-
await inferArgs(mod.language, mod.content, schema);
|
|
55
|
+
await inferArgs(mod.language, mod.content ?? '', schema);
|
|
100
56
|
}
|
|
101
|
-
else {
|
|
57
|
+
else if (mod.path && mod.path != '') {
|
|
102
58
|
schema = await loadSchema(mod.path);
|
|
103
59
|
}
|
|
60
|
+
else {
|
|
61
|
+
return {
|
|
62
|
+
input_transforms: {},
|
|
63
|
+
schema: emptySchema()
|
|
64
|
+
};
|
|
65
|
+
}
|
|
104
66
|
const keys = Object.keys(schema?.properties ?? {});
|
|
105
|
-
let
|
|
106
|
-
if (JSON.stringify(keys.sort()) !== JSON.stringify(Object.keys(module.
|
|
107
|
-
|
|
108
|
-
let nv = module.
|
|
67
|
+
let input_transforms = module.input_transforms;
|
|
68
|
+
if (JSON.stringify(keys.sort()) !== JSON.stringify(Object.keys(module.input_transforms).sort())) {
|
|
69
|
+
input_transforms = keys.reduce((accu, key) => {
|
|
70
|
+
let nv = module.input_transforms[key] ?? {
|
|
109
71
|
type: 'static',
|
|
110
72
|
value: undefined
|
|
111
73
|
};
|
|
@@ -114,62 +76,28 @@ export async function loadSchemaFromModule(module) {
|
|
|
114
76
|
}, {});
|
|
115
77
|
}
|
|
116
78
|
return {
|
|
117
|
-
|
|
79
|
+
input_transforms: input_transforms,
|
|
118
80
|
schema: schema ?? emptySchema()
|
|
119
81
|
};
|
|
120
82
|
}
|
|
121
83
|
return {
|
|
122
|
-
|
|
84
|
+
input_transforms: {},
|
|
123
85
|
schema: emptySchema()
|
|
124
86
|
};
|
|
125
87
|
}
|
|
126
|
-
const
|
|
88
|
+
const dynamicTemplateRegex = new RegExp(/\$\{(.*)\}/);
|
|
127
89
|
export function isCodeInjection(expr) {
|
|
128
90
|
if (!expr) {
|
|
129
91
|
return false;
|
|
130
92
|
}
|
|
131
|
-
|
|
132
|
-
const [returnStatement] = lines.reverse();
|
|
133
|
-
return returnStatementRegex.test(returnStatement);
|
|
93
|
+
return dynamicTemplateRegex.test(expr);
|
|
134
94
|
}
|
|
135
|
-
export function getDefaultExpr(
|
|
95
|
+
export function getDefaultExpr(importPath = undefined, key = 'myfield', previousExpr) {
|
|
136
96
|
const expr = previousExpr ?? `previous_result.${key}`;
|
|
137
|
-
return `import { previous_result, flow_input, step, variable, resource, params } from 'windmill
|
|
97
|
+
return `import { previous_result, flow_input, step, variable, resource, params } from 'windmill${importPath ? `@${importPath}` : ''}'
|
|
138
98
|
|
|
139
99
|
${expr}`;
|
|
140
100
|
}
|
|
141
|
-
export function getPickableProperties(schema, args, previewResults, mode, i) {
|
|
142
|
-
const flowInputAsObject = schemaToObject(schema, args);
|
|
143
|
-
const flowInput = mode === 'pull' && i >= 1
|
|
144
|
-
? computeFlowInputPull(previewResults[0], flowInputAsObject)
|
|
145
|
-
: flowInputAsObject;
|
|
146
|
-
let previous_result;
|
|
147
|
-
if (i === 0 || (i == 1 && mode == 'pull')) {
|
|
148
|
-
previous_result = flowInput;
|
|
149
|
-
}
|
|
150
|
-
else if (mode == 'pull') {
|
|
151
|
-
previous_result = previewResults[1] ? previewResults[1][i - 2] : undefined;
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
previous_result = previewResults[i - 1];
|
|
155
|
-
}
|
|
156
|
-
let step;
|
|
157
|
-
if (i >= 1 && mode == 'push') {
|
|
158
|
-
step = Object.values(previewResults).slice(0, i);
|
|
159
|
-
}
|
|
160
|
-
else if (i >= 2 && mode == 'pull') {
|
|
161
|
-
step = Object.values(previewResults[1] ?? {}).slice(0, i - 1);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
step = [];
|
|
165
|
-
}
|
|
166
|
-
const pickableProperties = {
|
|
167
|
-
flow_input: flowInput,
|
|
168
|
-
previous_result,
|
|
169
|
-
step
|
|
170
|
-
};
|
|
171
|
-
return pickableProperties;
|
|
172
|
-
}
|
|
173
101
|
export function jobsToResults(jobs) {
|
|
174
102
|
return jobs.map((job) => {
|
|
175
103
|
if ('result' in job) {
|
|
@@ -181,7 +109,7 @@ export function jobsToResults(jobs) {
|
|
|
181
109
|
});
|
|
182
110
|
}
|
|
183
111
|
export async function runFlowPreview(args, flow) {
|
|
184
|
-
const newFlow =
|
|
112
|
+
const newFlow = flow;
|
|
185
113
|
return await JobService.runFlowPreview({
|
|
186
114
|
workspace: get(workspaceStore) ?? '',
|
|
187
115
|
requestBody: {
|
|
@@ -191,18 +119,18 @@ export async function runFlowPreview(args, flow) {
|
|
|
191
119
|
}
|
|
192
120
|
});
|
|
193
121
|
}
|
|
194
|
-
function
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
122
|
+
export function codeToStaticTemplate(code) {
|
|
123
|
+
if (!code)
|
|
124
|
+
return undefined;
|
|
125
|
+
const lines = code
|
|
126
|
+
.split('\n')
|
|
127
|
+
.slice(1)
|
|
128
|
+
.filter((x) => x != '');
|
|
129
|
+
if (lines.length == 1) {
|
|
130
|
+
const line = lines[0].trim();
|
|
131
|
+
if (line[0] == '`' && line.charAt(line.length - 1) == '`') {
|
|
132
|
+
return line.slice(1, line.length - 1);
|
|
205
133
|
}
|
|
206
|
-
}
|
|
207
|
-
return
|
|
134
|
+
}
|
|
135
|
+
return undefined;
|
|
208
136
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script>export let height = '24px';
|
|
2
|
+
export let width = '24px';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
x="0px"
|
|
8
|
+
y="0px"
|
|
9
|
+
{width}
|
|
10
|
+
{height}
|
|
11
|
+
viewBox="0 0 50 50"
|
|
12
|
+
style=" fill:#000000;"
|
|
13
|
+
><path
|
|
14
|
+
d="M 18.90625 7 C 18.90625 7 12.539063 7.4375 8.375 10.78125 C 8.355469 10.789063 8.332031 10.800781 8.3125 10.8125 C 7.589844 11.480469 7.046875 12.515625 6.375 14 C 5.703125 15.484375 4.992188 17.394531 4.34375 19.53125 C 3.050781 23.808594 2 29.058594 2 34 C 1.996094 34.175781 2.039063 34.347656 2.125 34.5 C 3.585938 37.066406 6.273438 38.617188 8.78125 39.59375 C 11.289063 40.570313 13.605469 40.960938 14.78125 41 C 15.113281 41.011719 15.429688 40.859375 15.625 40.59375 L 18.0625 37.21875 C 20.027344 37.683594 22.332031 38 25 38 C 27.667969 38 29.972656 37.683594 31.9375 37.21875 L 34.375 40.59375 C 34.570313 40.859375 34.886719 41.011719 35.21875 41 C 36.394531 40.960938 38.710938 40.570313 41.21875 39.59375 C 43.726563 38.617188 46.414063 37.066406 47.875 34.5 C 47.960938 34.347656 48.003906 34.175781 48 34 C 48 29.058594 46.949219 23.808594 45.65625 19.53125 C 45.007813 17.394531 44.296875 15.484375 43.625 14 C 42.953125 12.515625 42.410156 11.480469 41.6875 10.8125 C 41.667969 10.800781 41.644531 10.789063 41.625 10.78125 C 37.460938 7.4375 31.09375 7 31.09375 7 C 31.019531 6.992188 30.949219 6.992188 30.875 7 C 30.527344 7.046875 30.234375 7.273438 30.09375 7.59375 C 30.09375 7.59375 29.753906 8.339844 29.53125 9.40625 C 27.582031 9.09375 25.941406 9 25 9 C 24.058594 9 22.417969 9.09375 20.46875 9.40625 C 20.246094 8.339844 19.90625 7.59375 19.90625 7.59375 C 19.734375 7.203125 19.332031 6.964844 18.90625 7 Z M 18.28125 9.15625 C 18.355469 9.359375 18.40625 9.550781 18.46875 9.78125 C 16.214844 10.304688 13.746094 11.160156 11.4375 12.59375 C 11.074219 12.746094 10.835938 13.097656 10.824219 13.492188 C 10.816406 13.882813 11.039063 14.246094 11.390625 14.417969 C 11.746094 14.585938 12.167969 14.535156 12.46875 14.28125 C 17.101563 11.410156 22.996094 11 25 11 C 27.003906 11 32.898438 11.410156 37.53125 14.28125 C 37.832031 14.535156 38.253906 14.585938 38.609375 14.417969 C 38.960938 14.246094 39.183594 13.882813 39.175781 13.492188 C 39.164063 13.097656 38.925781 12.746094 38.5625 12.59375 C 36.253906 11.160156 33.785156 10.304688 31.53125 9.78125 C 31.59375 9.550781 31.644531 9.359375 31.71875 9.15625 C 32.859375 9.296875 37.292969 9.894531 40.3125 12.28125 C 40.507813 12.460938 41.1875 13.460938 41.8125 14.84375 C 42.4375 16.226563 43.09375 18.027344 43.71875 20.09375 C 44.9375 24.125 45.921875 29.097656 45.96875 33.65625 C 44.832031 35.496094 42.699219 36.863281 40.5 37.71875 C 38.5 38.496094 36.632813 38.84375 35.65625 38.9375 L 33.96875 36.65625 C 34.828125 36.378906 35.601563 36.078125 36.28125 35.78125 C 38.804688 34.671875 40.15625 33.5 40.15625 33.5 C 40.570313 33.128906 40.605469 32.492188 40.234375 32.078125 C 39.863281 31.664063 39.226563 31.628906 38.8125 32 C 38.8125 32 37.765625 32.957031 35.46875 33.96875 C 34.625 34.339844 33.601563 34.707031 32.4375 35.03125 C 32.167969 35 31.898438 35.078125 31.6875 35.25 C 29.824219 35.703125 27.609375 36 25 36 C 22.371094 36 20.152344 35.675781 18.28125 35.21875 C 18.070313 35.078125 17.8125 35.019531 17.5625 35.0625 C 16.394531 34.738281 15.378906 34.339844 14.53125 33.96875 C 12.234375 32.957031 11.1875 32 11.1875 32 C 10.960938 31.789063 10.648438 31.699219 10.34375 31.75 C 9.957031 31.808594 9.636719 32.085938 9.53125 32.464844 C 9.421875 32.839844 9.546875 33.246094 9.84375 33.5 C 9.84375 33.5 11.195313 34.671875 13.71875 35.78125 C 14.398438 36.078125 15.171875 36.378906 16.03125 36.65625 L 14.34375 38.9375 C 13.367188 38.84375 11.5 38.496094 9.5 37.71875 C 7.300781 36.863281 5.167969 35.496094 4.03125 33.65625 C 4.078125 29.097656 5.0625 24.125 6.28125 20.09375 C 6.90625 18.027344 7.5625 16.226563 8.1875 14.84375 C 8.8125 13.460938 9.492188 12.460938 9.6875 12.28125 C 12.707031 9.894531 17.140625 9.296875 18.28125 9.15625 Z M 18.5 21 C 15.949219 21 14 23.316406 14 26 C 14 28.683594 15.949219 31 18.5 31 C 21.050781 31 23 28.683594 23 26 C 23 23.316406 21.050781 21 18.5 21 Z M 31.5 21 C 28.949219 21 27 23.316406 27 26 C 27 28.683594 28.949219 31 31.5 31 C 34.050781 31 36 28.683594 36 26 C 36 23.316406 34.050781 21 31.5 21 Z M 18.5 23 C 19.816406 23 21 24.265625 21 26 C 21 27.734375 19.816406 29 18.5 29 C 17.183594 29 16 27.734375 16 26 C 16 24.265625 17.183594 23 18.5 23 Z M 31.5 23 C 32.816406 23 34 24.265625 34 26 C 34 27.734375 32.816406 29 31.5 29 C 30.183594 29 29 27.734375 29 26 C 29 24.265625 30.183594 23 31.5 23 Z"
|
|
15
|
+
/></svg
|
|
16
|
+
>
|