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.
- package/components/ArgInput.svelte +21 -21
- package/components/ArgInput.svelte.d.ts +3 -3
- package/components/DisplayResult.svelte +73 -67
- package/components/Editor.svelte +184 -246
- package/components/Editor.svelte.d.ts +4 -4
- package/components/EditorBar.svelte +58 -45
- package/components/EditorBar.svelte.d.ts +2 -1
- package/components/FlowBuilder.svelte +113 -121
- package/components/FlowJobResult.svelte +4 -5
- package/components/FlowModulesViewer.svelte +89 -7
- package/components/FlowModulesViewer.svelte.d.ts +1 -0
- package/components/FlowPreviewContent.svelte +56 -15
- package/components/FlowPreviewContent.svelte.d.ts +1 -1
- package/components/FlowStatusViewer.svelte +42 -24
- package/components/FlowStatusViewer.svelte.d.ts +0 -1
- package/components/FlowViewer.svelte +7 -3
- package/components/HighlightCode.svelte +21 -0
- package/components/HighlightCode.svelte.d.ts +17 -0
- package/components/IconedPath.svelte +9 -7
- package/components/IconedResourceType.svelte +1 -1
- package/components/InputTransformForm.svelte +88 -107
- package/components/InputTransformForm.svelte.d.ts +0 -1
- package/components/ItemPicker.svelte +2 -2
- package/components/LogViewer.svelte +23 -0
- package/components/LogViewer.svelte.d.ts +19 -0
- package/components/ModulePreview.svelte +108 -0
- package/components/ModulePreview.svelte.d.ts +24 -0
- package/components/RunForm.svelte +29 -18
- package/components/RunForm.svelte.d.ts +6 -2
- package/components/SchemaEditor.svelte +5 -3
- package/components/SchemaForm.svelte +0 -2
- package/components/SchemaForm.svelte.d.ts +0 -1
- package/components/ScriptBuilder.svelte +77 -66
- package/components/ScriptBuilder.svelte.d.ts +2 -4
- package/components/ScriptEditor.svelte +69 -142
- package/components/ScriptEditor.svelte.d.ts +0 -5
- package/components/ScriptPicker.svelte +3 -3
- package/components/ScriptPicker.svelte.d.ts +2 -1
- package/components/SharedBadge.svelte +5 -13
- package/components/SimpleEditor.svelte +147 -0
- package/components/SimpleEditor.svelte.d.ts +35 -0
- package/components/TestJobLoader.svelte +98 -0
- package/components/TestJobLoader.svelte.d.ts +26 -0
- package/components/Tooltip.svelte +2 -1
- package/components/common/actionRow/ActionRow.svelte +26 -0
- package/components/common/actionRow/ActionRow.svelte.d.ts +21 -0
- package/components/common/alert/Alert.svelte +53 -0
- package/components/common/alert/Alert.svelte.d.ts +20 -0
- package/components/common/alert/model.d.ts +1 -0
- package/components/common/alert/model.js +1 -0
- package/components/common/badge/Badge.svelte +82 -0
- package/components/common/badge/Badge.svelte.d.ts +28 -0
- package/components/common/badge/model.d.ts +8 -0
- package/components/common/badge/model.js +1 -0
- package/components/common/button/Button.svelte +107 -0
- package/components/common/button/Button.svelte.d.ts +37 -0
- package/components/common/button/model.d.ts +6 -0
- package/components/common/button/model.js +1 -0
- package/components/common/confirmationModal/ConfirmationModal.svelte +55 -0
- package/components/common/confirmationModal/ConfirmationModal.svelte.d.ts +23 -0
- package/components/common/drawer/Drawer.svelte +3 -0
- package/components/common/drawer/Drawer.svelte.d.ts +2 -0
- package/components/common/index.d.ts +14 -0
- package/components/common/index.js +14 -0
- package/components/common/tabs/TabContent.svelte +3 -2
- package/components/common/tabs/TabContent.svelte.d.ts +1 -0
- package/components/common/tabs/Tabs.svelte +8 -1
- package/components/common/tabs/Tabs.svelte.d.ts +2 -0
- package/components/common/toggleButton/ToggleButton.svelte +20 -0
- package/components/common/toggleButton/ToggleButton.svelte.d.ts +19 -0
- package/components/common/toggleButton/ToggleButtonGroup.svelte +33 -0
- package/components/common/toggleButton/ToggleButtonGroup.svelte.d.ts +24 -0
- package/components/flows/FlowEditor.svelte +30 -0
- package/components/{FlowEditor.svelte.d.ts → flows/FlowEditor.svelte.d.ts} +1 -8
- package/components/flows/common/FlowCard.svelte +9 -0
- package/components/flows/common/FlowCard.svelte.d.ts +21 -0
- package/components/flows/common/FlowCardHeader.svelte +39 -0
- package/components/flows/common/FlowCardHeader.svelte.d.ts +20 -0
- package/components/flows/content/CopyFirstStepSchema.svelte +13 -0
- package/components/flows/{CopyFirstStepSchema.svelte.d.ts → content/CopyFirstStepSchema.svelte.d.ts} +0 -0
- package/components/flows/{DynamicInputHelpBox.svelte → content/DynamicInputHelpBox.svelte} +0 -0
- package/components/flows/{DynamicInputHelpBox.svelte.d.ts → content/DynamicInputHelpBox.svelte.d.ts} +0 -0
- package/components/flows/content/FlowEditorPanel.svelte +26 -0
- package/components/flows/content/FlowEditorPanel.svelte.d.ts +14 -0
- package/components/flows/content/FlowFailureModule.svelte +17 -0
- package/components/flows/content/FlowFailureModule.svelte.d.ts +14 -0
- package/components/flows/content/FlowInput.svelte +22 -0
- package/components/flows/{FlowInput.svelte.d.ts → content/FlowInput.svelte.d.ts} +0 -0
- package/components/flows/{FlowInputs.svelte → content/FlowInputs.svelte} +24 -13
- package/components/flows/{FlowInputs.svelte.d.ts → content/FlowInputs.svelte.d.ts} +0 -0
- package/components/flows/content/FlowLoop.svelte +38 -0
- package/components/flows/content/FlowLoop.svelte.d.ts +14 -0
- package/components/flows/content/FlowModule.svelte +190 -0
- package/components/flows/content/FlowModule.svelte.d.ts +29 -0
- package/components/flows/content/FlowModuleAdvancedSettings.svelte +64 -0
- package/components/flows/content/FlowModuleAdvancedSettings.svelte.d.ts +17 -0
- package/components/flows/content/FlowModuleHeader.svelte +68 -0
- package/components/flows/{FlowModuleHeader.svelte.d.ts → content/FlowModuleHeader.svelte.d.ts} +2 -3
- package/components/flows/content/FlowModuleScript.svelte +21 -0
- package/components/flows/content/FlowModuleScript.svelte.d.ts +17 -0
- package/components/flows/content/FlowModuleWrapper.svelte +47 -0
- package/components/flows/content/FlowModuleWrapper.svelte.d.ts +14 -0
- package/components/flows/content/FlowRetries.svelte +80 -0
- package/components/flows/content/FlowRetries.svelte.d.ts +14 -0
- package/components/flows/content/FlowSchedules.svelte +18 -0
- package/components/flows/content/FlowSchedules.svelte.d.ts +14 -0
- package/components/flows/content/FlowSettings.svelte +51 -0
- package/components/flows/{FlowSettings.svelte.d.ts → content/FlowSettings.svelte.d.ts} +1 -6
- package/components/flows/content/RemoveStepConfirmationModal.svelte +32 -0
- package/components/flows/content/RemoveStepConfirmationModal.svelte.d.ts +19 -0
- package/components/flows/flowState.d.ts +8 -7
- package/components/flows/flowState.js +25 -46
- package/components/flows/flowStateUtils.d.ts +15 -13
- package/components/flows/flowStateUtils.js +80 -72
- package/components/flows/flowStore.js +7 -4
- package/components/flows/header/FlowEditorHeader.svelte +23 -0
- package/components/flows/header/FlowEditorHeader.svelte.d.ts +14 -0
- package/components/flows/header/FlowImportExportMenu.svelte +56 -0
- package/components/flows/header/FlowImportExportMenu.svelte.d.ts +14 -0
- package/components/flows/header/FlowPreviewButtons.svelte +49 -0
- package/components/flows/header/FlowPreviewButtons.svelte.d.ts +14 -0
- package/components/flows/header/FlowStatus.svelte +36 -0
- package/components/flows/header/FlowStatus.svelte.d.ts +14 -0
- package/components/flows/map/FlowErrorHandlerItem.svelte +54 -0
- package/components/flows/map/FlowErrorHandlerItem.svelte.d.ts +14 -0
- package/components/flows/map/FlowModuleSchemaItem.svelte +58 -0
- package/components/flows/map/FlowModuleSchemaItem.svelte.d.ts +27 -0
- package/components/flows/map/FlowModuleSchemaMap.svelte +161 -0
- package/components/flows/map/FlowModuleSchemaMap.svelte.d.ts +20 -0
- package/components/flows/pickers/PickHubScript.svelte +4 -3
- package/components/flows/pickers/PickHubScript.svelte.d.ts +2 -1
- package/components/flows/pickers/PickScript.svelte +4 -12
- package/components/flows/pickers/PickScript.svelte.d.ts +1 -1
- package/components/flows/propPicker/PropPickerWrapper.svelte +42 -0
- package/components/flows/propPicker/PropPickerWrapper.svelte.d.ts +31 -0
- package/components/flows/scheduleUtils.d.ts +0 -1
- package/components/flows/scheduleUtils.js +0 -1
- package/components/flows/types.d.ts +9 -0
- package/components/flows/types.js +1 -0
- package/components/flows/utils.d.ts +1 -1
- package/components/flows/utils.js +8 -11
- package/components/icons/HatIcon.svelte +19 -0
- package/components/icons/HatIcon.svelte.d.ts +16 -0
- package/components/landing/FlowGettingStarted.svelte +22 -68
- package/components/landing/FlowLandingBox.svelte +1 -1
- package/components/landing/RessourceGettingStarted.svelte +7 -37
- package/components/landing/ScriptBox.svelte +33 -60
- package/components/landing/ScriptGettingStarted.svelte +23 -69
- package/components/propertyPicker/ObjectViewer.svelte +16 -7
- package/components/propertyPicker/PropPicker.svelte +38 -12
- package/components/propertyPicker/WarningMessage.svelte +2 -15
- package/components/script_editor/LogPanel.svelte +108 -119
- package/components/script_editor/LogPanel.svelte.d.ts +2 -0
- package/components/sidebar/SidebarContent.svelte +2 -2
- package/editorUtils.d.ts +25 -0
- package/editorUtils.js +43 -0
- package/gen/models/CompletedJob.d.ts +2 -1
- package/gen/models/CompletedJob.js +1 -0
- package/gen/models/FlowModule.d.ts +1 -0
- package/gen/models/FlowStatus.d.ts +3 -0
- package/gen/models/FlowStatusModule.d.ts +1 -1
- package/gen/models/FlowValue.d.ts +11 -0
- package/gen/models/Preview.d.ts +2 -1
- package/gen/models/Preview.js +1 -0
- package/gen/models/QueuedJob.d.ts +2 -1
- package/gen/models/QueuedJob.js +1 -0
- package/gen/models/RawScript.d.ts +2 -1
- package/gen/models/RawScript.js +1 -0
- package/gen/models/Script.d.ts +9 -2
- package/gen/models/Script.js +8 -0
- package/gen/services/JobService.d.ts +40 -0
- package/gen/services/JobService.js +70 -0
- package/gen/services/ScriptService.d.ts +14 -3
- package/gen/services/ScriptService.js +13 -0
- package/infer.d.ts +1 -1
- package/infer.js +6 -1
- package/package.json +67 -35
- package/script_helpers.d.ts +5 -2
- package/script_helpers.js +41 -13
- package/stores.d.ts +1 -1
- package/utils.d.ts +6 -4
- package/utils.js +27 -4
- package/components/FlowEditor.svelte +0 -55
- package/components/FlowPreview.svelte +0 -107
- package/components/FlowPreview.svelte.d.ts +0 -23
- package/components/ModuleStep.svelte +0 -131
- package/components/ModuleStep.svelte.d.ts +0 -25
- package/components/flows/CopyFirstStepSchema.svelte +0 -13
- package/components/flows/FlowBox.svelte +0 -16
- package/components/flows/FlowBox.svelte.d.ts +0 -23
- package/components/flows/FlowBoxHeader.svelte +0 -16
- package/components/flows/FlowBoxHeader.svelte.d.ts +0 -21
- package/components/flows/FlowInput.svelte +0 -22
- package/components/flows/FlowModuleHeader.svelte +0 -109
- package/components/flows/FlowSettings.svelte +0 -165
- package/components/flows/FlowTimeline.svelte +0 -169
- package/components/flows/FlowTimeline.svelte.d.ts +0 -21
- package/components/flows/stepOpenedStore.d.ts +0 -1
- package/components/flows/stepOpenedStore.js +0 -6
- package/components/propertyPicker/OverlayPropertyPicker.svelte +0 -69
- package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +0 -24
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script>import { CompletedJob, Job, JobService } from '../gen';
|
|
2
2
|
import { userStore, workspaceStore } from '../stores';
|
|
3
|
-
import {
|
|
3
|
+
import { emptySchema, scriptLangToEditorLang } from '../utils';
|
|
4
4
|
import { faCheck, faExclamationTriangle, faPlay, faRotateRight } from '@fortawesome/free-solid-svg-icons';
|
|
5
|
-
import { onDestroy, onMount } from 'svelte';
|
|
6
5
|
import Icon from 'svelte-awesome';
|
|
7
6
|
import Editor from './Editor.svelte';
|
|
8
7
|
import { inferArgs } from '../infer';
|
|
@@ -11,6 +10,9 @@ import LogPanel from './script_editor/LogPanel.svelte';
|
|
|
11
10
|
import { HSplitPane, VSplitPane } from 'svelte-split-pane';
|
|
12
11
|
import { faGithub } from '@fortawesome/free-brands-svg-icons';
|
|
13
12
|
import EditorBar from './EditorBar.svelte';
|
|
13
|
+
import Button from './common/button/Button.svelte';
|
|
14
|
+
import TestJobLoader from './TestJobLoader.svelte';
|
|
15
|
+
import { onMount } from 'svelte';
|
|
14
16
|
// Exported
|
|
15
17
|
export let schema = emptySchema();
|
|
16
18
|
export let code;
|
|
@@ -19,58 +21,26 @@ export let lang;
|
|
|
19
21
|
let websocketAlive = { pyright: false, black: false, deno: false };
|
|
20
22
|
// Internal state
|
|
21
23
|
let editor;
|
|
22
|
-
|
|
24
|
+
let testJobLoader;
|
|
25
|
+
// Test args input
|
|
23
26
|
let args = {};
|
|
24
27
|
let isValid = true;
|
|
25
|
-
//
|
|
26
|
-
let
|
|
27
|
-
let
|
|
28
|
-
let previewJob;
|
|
28
|
+
// Test
|
|
29
|
+
let testIsLoading = false;
|
|
30
|
+
let testJob;
|
|
29
31
|
let pastPreviews = [];
|
|
30
32
|
let lastSave;
|
|
31
|
-
let syncIteration = 0;
|
|
32
|
-
let ITERATIONS_BEFORE_SLOW_REFRESH = 100;
|
|
33
33
|
$: lastSave = localStorage.getItem(path ?? 'last_save');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export async function runPreview() {
|
|
39
|
-
try {
|
|
40
|
-
if (previewIntervalId) {
|
|
41
|
-
clearInterval(previewIntervalId);
|
|
42
|
-
}
|
|
43
|
-
if (previewIsLoading && previewJob) {
|
|
44
|
-
JobService.cancelQueuedJob({
|
|
45
|
-
workspace: $workspaceStore,
|
|
46
|
-
id: previewJob.id,
|
|
47
|
-
requestBody: {}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
previewIsLoading = true;
|
|
51
|
-
const previewId = await JobService.runScriptPreview({
|
|
52
|
-
workspace: $workspaceStore,
|
|
53
|
-
requestBody: {
|
|
54
|
-
path,
|
|
55
|
-
content: editor.getCode(),
|
|
56
|
-
args: args,
|
|
57
|
-
language: lang
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
previewJob = undefined;
|
|
61
|
-
loadPreviewJob(previewId);
|
|
62
|
-
syncIteration = 0;
|
|
63
|
-
previewIntervalId = setInterval(() => {
|
|
64
|
-
syncer(previewId);
|
|
65
|
-
}, 500);
|
|
66
|
-
//TODO fetch preview, every x time, until it's completed
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
previewIsLoading = false;
|
|
70
|
-
throw err;
|
|
34
|
+
function onKeyDown(event) {
|
|
35
|
+
if ((event.ctrlKey || event.metaKey) && event.key == 'Enter') {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
runTest();
|
|
71
38
|
}
|
|
72
39
|
}
|
|
73
|
-
|
|
40
|
+
function runTest() {
|
|
41
|
+
testJobLoader.runPreview(path, code, lang, args);
|
|
42
|
+
}
|
|
43
|
+
async function loadPastTests() {
|
|
74
44
|
pastPreviews = await JobService.listCompletedJobs({
|
|
75
45
|
workspace: $workspaceStore,
|
|
76
46
|
jobKinds: 'preview',
|
|
@@ -78,37 +48,6 @@ async function loadPastPreviews() {
|
|
|
78
48
|
scriptPathExact: path
|
|
79
49
|
});
|
|
80
50
|
}
|
|
81
|
-
async function loadPreviewJob(id) {
|
|
82
|
-
try {
|
|
83
|
-
if (previewJob && `running` in previewJob) {
|
|
84
|
-
let previewJobUpdates = await JobService.getJobUpdates({
|
|
85
|
-
workspace: $workspaceStore,
|
|
86
|
-
id,
|
|
87
|
-
running: previewJob.running,
|
|
88
|
-
logOffset: previewJob.logs?.length ?? 0
|
|
89
|
-
});
|
|
90
|
-
if (previewJobUpdates.new_logs) {
|
|
91
|
-
previewJob.logs = (previewJob.logs ?? '').concat(previewJobUpdates.new_logs);
|
|
92
|
-
}
|
|
93
|
-
if ((previewJobUpdates.running ?? false) || (previewJobUpdates.completed ?? false)) {
|
|
94
|
-
previewJob = await JobService.getJob({ workspace: $workspaceStore, id });
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
previewJob = await JobService.getJob({ workspace: $workspaceStore, id });
|
|
99
|
-
}
|
|
100
|
-
if (previewJob?.type === 'CompletedJob') {
|
|
101
|
-
//only CompletedJob has success property
|
|
102
|
-
clearInterval(previewIntervalId);
|
|
103
|
-
previewIsLoading = false;
|
|
104
|
-
loadPastPreviews();
|
|
105
|
-
}
|
|
106
|
-
div?.scroll({ top: div?.scrollHeight, behavior: 'smooth' });
|
|
107
|
-
}
|
|
108
|
-
catch (err) {
|
|
109
|
-
console.error(err);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
51
|
async function inferSchema() {
|
|
113
52
|
let isDefault = [];
|
|
114
53
|
Object.entries(args).forEach(([k, v]) => {
|
|
@@ -116,7 +55,7 @@ async function inferSchema() {
|
|
|
116
55
|
isDefault.push(k);
|
|
117
56
|
}
|
|
118
57
|
});
|
|
119
|
-
await inferArgs(lang,
|
|
58
|
+
await inferArgs(lang, code, schema);
|
|
120
59
|
schema = schema;
|
|
121
60
|
isDefault
|
|
122
61
|
.filter((key) => schema.properties[key] != undefined)
|
|
@@ -127,72 +66,38 @@ async function inferSchema() {
|
|
|
127
66
|
}
|
|
128
67
|
}
|
|
129
68
|
}
|
|
130
|
-
function syncer(id) {
|
|
131
|
-
if (syncIteration > ITERATIONS_BEFORE_SLOW_REFRESH) {
|
|
132
|
-
loadPreviewJob(id);
|
|
133
|
-
if (previewIntervalId) {
|
|
134
|
-
clearInterval(previewIntervalId);
|
|
135
|
-
previewIntervalId = setInterval(() => loadPreviewJob(id), 5000);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
syncIteration++;
|
|
140
|
-
loadPreviewJob(id);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
let syncCode;
|
|
144
69
|
onMount(() => {
|
|
145
70
|
inferSchema();
|
|
146
|
-
syncCode = setInterval(() => {
|
|
147
|
-
const newCode = editor?.getCode();
|
|
148
|
-
if (newCode && code != newCode) {
|
|
149
|
-
code = editor.getCode();
|
|
150
|
-
}
|
|
151
|
-
}, 3000);
|
|
152
|
-
});
|
|
153
|
-
onDestroy(() => {
|
|
154
|
-
if (editor) {
|
|
155
|
-
code = editor.getCode();
|
|
156
|
-
}
|
|
157
|
-
if (previewIntervalId) {
|
|
158
|
-
clearInterval(previewIntervalId);
|
|
159
|
-
}
|
|
160
|
-
if (syncCode) {
|
|
161
|
-
clearInterval(syncCode);
|
|
162
|
-
}
|
|
163
71
|
});
|
|
164
72
|
</script>
|
|
165
73
|
|
|
74
|
+
<TestJobLoader
|
|
75
|
+
on:done={loadPastTests}
|
|
76
|
+
bind:this={testJobLoader}
|
|
77
|
+
bind:isLoading={testIsLoading}
|
|
78
|
+
bind:job={testJob}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<svelte:window on:keydown={onKeyDown} />
|
|
82
|
+
|
|
166
83
|
<div class="border-b shadow-sm p-1 pr-4">
|
|
167
84
|
<div class="flex justify-between">
|
|
168
85
|
<EditorBar {editor} {lang} {websocketAlive} />
|
|
169
86
|
|
|
170
87
|
<div class="flex divide-x">
|
|
171
88
|
<div>
|
|
172
|
-
<
|
|
89
|
+
<Button
|
|
173
90
|
target="_blank"
|
|
174
91
|
href="https://github.com/windmill-labs/windmill-gh-action-deploy"
|
|
175
|
-
|
|
92
|
+
color="light"
|
|
93
|
+
size="xs"
|
|
94
|
+
btnClasses="mr-1"
|
|
95
|
+
startIcon={{
|
|
96
|
+
icon: faGithub
|
|
97
|
+
}}
|
|
176
98
|
>
|
|
177
|
-
<Icon data={faGithub} class="h-4 w-4 mr-2" />
|
|
178
99
|
Sync from Github
|
|
179
|
-
</
|
|
180
|
-
</div>
|
|
181
|
-
|
|
182
|
-
<div>
|
|
183
|
-
<button
|
|
184
|
-
type="button"
|
|
185
|
-
on:click|stopPropagation={() => runPreview()}
|
|
186
|
-
disabled={previewIsLoading}
|
|
187
|
-
class="text-white ml-1 w-28 bg-blue-500 hover:bg-blue-700 rounded-md flex justify-center items-center focus:outline-none font-medium text-xs p-2"
|
|
188
|
-
>
|
|
189
|
-
<Icon
|
|
190
|
-
data={previewIsLoading ? faRotateRight : faPlay}
|
|
191
|
-
class={classNames('h-4 w-4 mr-2', previewIsLoading ? 'animate-spin' : 'animate-none')}
|
|
192
|
-
/>
|
|
193
|
-
|
|
194
|
-
{previewIsLoading ? 'Running' : 'Run preview'}
|
|
195
|
-
</button>
|
|
100
|
+
</Button>
|
|
196
101
|
</div>
|
|
197
102
|
</div>
|
|
198
103
|
</div>
|
|
@@ -204,29 +109,23 @@ onDestroy(() => {
|
|
|
204
109
|
<div
|
|
205
110
|
class="p-2 h-full"
|
|
206
111
|
on:mouseleave={() => {
|
|
207
|
-
code = getEditor().getCode()
|
|
208
112
|
inferSchema()
|
|
209
113
|
}}
|
|
210
114
|
>
|
|
211
115
|
<Editor
|
|
212
|
-
|
|
116
|
+
bind:code
|
|
213
117
|
bind:websocketAlive
|
|
214
118
|
bind:this={editor}
|
|
215
119
|
cmdEnterAction={() => {
|
|
216
|
-
|
|
120
|
+
runTest()
|
|
217
121
|
}}
|
|
218
122
|
formatAction={async () => {
|
|
219
|
-
code = getEditor().getCode()
|
|
220
123
|
await inferSchema()
|
|
221
124
|
localStorage.setItem(path ?? 'last_save', code)
|
|
222
125
|
lastSave = code
|
|
223
126
|
}}
|
|
224
|
-
on:blur={() => {
|
|
225
|
-
code = getEditor().getCode()
|
|
226
|
-
inferSchema()
|
|
227
|
-
}}
|
|
228
127
|
class="flex flex-1 h-full"
|
|
229
|
-
|
|
128
|
+
lang={scriptLangToEditorLang(lang)}
|
|
230
129
|
automaticLayout={true}
|
|
231
130
|
/>
|
|
232
131
|
</div>
|
|
@@ -264,13 +163,41 @@ onDestroy(() => {
|
|
|
264
163
|
</div>
|
|
265
164
|
</top>
|
|
266
165
|
<down slot="down">
|
|
267
|
-
<div class="
|
|
166
|
+
<div class="h-full overflow-hidden">
|
|
167
|
+
<div class="px-2 py-1">
|
|
168
|
+
{#if testIsLoading}
|
|
169
|
+
<Button
|
|
170
|
+
on:click={testJobLoader?.cancelJob}
|
|
171
|
+
btnClasses="w-full"
|
|
172
|
+
color="red"
|
|
173
|
+
size="xs"
|
|
174
|
+
startIcon={{
|
|
175
|
+
icon: faRotateRight,
|
|
176
|
+
classes: 'animate-spin'
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
'Cancel'
|
|
180
|
+
</Button>
|
|
181
|
+
{:else}
|
|
182
|
+
<Button
|
|
183
|
+
on:click={runTest}
|
|
184
|
+
btnClasses="w-full"
|
|
185
|
+
size="xs"
|
|
186
|
+
startIcon={{
|
|
187
|
+
icon: faPlay,
|
|
188
|
+
classes: 'animate-none'
|
|
189
|
+
}}
|
|
190
|
+
>
|
|
191
|
+
{testIsLoading ? 'Running' : 'Test (Ctrl+Enter)'}
|
|
192
|
+
</Button>
|
|
193
|
+
{/if}
|
|
194
|
+
</div>
|
|
268
195
|
<LogPanel
|
|
269
196
|
{path}
|
|
270
197
|
{lang}
|
|
271
|
-
{
|
|
198
|
+
previewJob={testJob}
|
|
272
199
|
{pastPreviews}
|
|
273
|
-
{
|
|
200
|
+
previewIsLoading={testIsLoading}
|
|
274
201
|
bind:lastSave
|
|
275
202
|
/>
|
|
276
203
|
</div>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { Schema } from '../common';
|
|
3
|
-
import Editor from './Editor.svelte';
|
|
4
3
|
import type { Preview } from '../gen/models/Preview';
|
|
5
4
|
declare const __propDef: {
|
|
6
5
|
props: {
|
|
@@ -8,8 +7,6 @@ declare const __propDef: {
|
|
|
8
7
|
code: string;
|
|
9
8
|
path: string | undefined;
|
|
10
9
|
lang: Preview.language;
|
|
11
|
-
getEditor?: (() => Editor) | undefined;
|
|
12
|
-
runPreview?: (() => Promise<void>) | undefined;
|
|
13
10
|
};
|
|
14
11
|
events: {
|
|
15
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -20,7 +17,5 @@ export declare type ScriptEditorProps = typeof __propDef.props;
|
|
|
20
17
|
export declare type ScriptEditorEvents = typeof __propDef.events;
|
|
21
18
|
export declare type ScriptEditorSlots = typeof __propDef.slots;
|
|
22
19
|
export default class ScriptEditor extends SvelteComponentTyped<ScriptEditorProps, ScriptEditorEvents, ScriptEditorSlots> {
|
|
23
|
-
get getEditor(): () => Editor;
|
|
24
|
-
get runPreview(): () => Promise<void>;
|
|
25
20
|
}
|
|
26
21
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import { ScriptService, FlowService } from '../gen';
|
|
1
|
+
<script>import { ScriptService, FlowService, Script } from '../gen';
|
|
2
2
|
import Icon from 'svelte-awesome';
|
|
3
3
|
import { faSearch } from '@fortawesome/free-solid-svg-icons';
|
|
4
4
|
import { hubScripts, workspaceStore } from '../stores';
|
|
@@ -14,7 +14,7 @@ export let scriptPath = undefined;
|
|
|
14
14
|
export let allowFlow = false;
|
|
15
15
|
export let allowHub = false;
|
|
16
16
|
export let itemKind = allowHub ? 'hub' : 'script';
|
|
17
|
-
export let
|
|
17
|
+
export let kind = Script.kind.SCRIPT;
|
|
18
18
|
let items = [];
|
|
19
19
|
let itemPicker;
|
|
20
20
|
let modalViewer;
|
|
@@ -29,7 +29,7 @@ async function loadItems() {
|
|
|
29
29
|
items = await FlowService.listFlows({ workspace: $workspaceStore });
|
|
30
30
|
}
|
|
31
31
|
else if (itemKind == 'script') {
|
|
32
|
-
items = await ScriptService.listScripts({ workspace: $workspaceStore,
|
|
32
|
+
items = await ScriptService.listScripts({ workspace: $workspaceStore, kind });
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
35
|
items = $hubScripts ?? [];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { Script } from '../gen';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
scriptPath?: string | undefined;
|
|
5
6
|
allowFlow?: boolean | undefined;
|
|
6
7
|
allowHub?: boolean | undefined;
|
|
7
8
|
itemKind?: "flow" | "script" | "hub" | undefined;
|
|
8
|
-
|
|
9
|
+
kind?: Script.kind | undefined;
|
|
9
10
|
};
|
|
10
11
|
events: {
|
|
11
12
|
select: CustomEvent<any>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script>import { userStore } from '../stores';
|
|
2
2
|
import { faPeopleGroup } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
-
import
|
|
4
|
-
import Badge from './Badge.svelte';
|
|
3
|
+
import Badge from './common/badge/Badge.svelte';
|
|
5
4
|
export let extraPerms = {};
|
|
6
5
|
export let canWrite;
|
|
7
6
|
let kind = undefined;
|
|
@@ -47,15 +46,8 @@ $: {
|
|
|
47
46
|
}
|
|
48
47
|
</script>
|
|
49
48
|
|
|
50
|
-
{#if kind
|
|
51
|
-
<
|
|
52
|
-
{
|
|
53
|
-
|
|
54
|
-
<Icon data={faPeopleGroup} scale={0.7} />
|
|
55
|
-
read</Badge
|
|
56
|
-
>
|
|
57
|
-
{:else if kind == 'write'}
|
|
58
|
-
<Badge tooltip={reason}><Icon data={faPeopleGroup} scale={0.7} /></Badge>
|
|
59
|
-
{/if}
|
|
60
|
-
</span>
|
|
49
|
+
{#if kind === 'read' || kind === 'write'}
|
|
50
|
+
<Badge icon={{ data: faPeopleGroup }} capitalize color="blue">
|
|
51
|
+
{kind}
|
|
52
|
+
</Badge>
|
|
61
53
|
{/if}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<script context="module">import * as monaco from 'monaco-editor';
|
|
2
|
+
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
|
3
|
+
target: monaco.languages.typescript.ScriptTarget.Latest,
|
|
4
|
+
allowNonTsExtensions: true,
|
|
5
|
+
noLib: true
|
|
6
|
+
});
|
|
7
|
+
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
8
|
+
validate: true,
|
|
9
|
+
allowComments: false,
|
|
10
|
+
schemas: [],
|
|
11
|
+
enableSchemaRequest: true
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script>import { browser, dev } from '$app/env';
|
|
16
|
+
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
|
17
|
+
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
|
18
|
+
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
|
19
|
+
import { buildWorkerDefinition } from 'monaco-editor-workers';
|
|
20
|
+
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
|
21
|
+
import { createHash, editorConfig, langToExt, updateOptions } from '../editorUtils';
|
|
22
|
+
let divEl = null;
|
|
23
|
+
let editor;
|
|
24
|
+
export let lang;
|
|
25
|
+
export let code = '';
|
|
26
|
+
export let hash = createHash();
|
|
27
|
+
export let cmdEnterAction = undefined;
|
|
28
|
+
export let formatAction = undefined;
|
|
29
|
+
export let automaticLayout = true;
|
|
30
|
+
export let extraLib = '';
|
|
31
|
+
export let extraLibPath = '';
|
|
32
|
+
export let shouldBindKey = true;
|
|
33
|
+
const dispatch = createEventDispatcher();
|
|
34
|
+
const uri = `file:///${hash}.${langToExt(lang)}`;
|
|
35
|
+
if (browser) {
|
|
36
|
+
if (dev) {
|
|
37
|
+
buildWorkerDefinition('../../../node_modules/monaco-editor-workers/dist/workers', import.meta.url, false);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
self.MonacoEnvironment = {
|
|
42
|
+
getWorker: function (_moduleId, label) {
|
|
43
|
+
if (label === 'json') {
|
|
44
|
+
return new jsonWorker();
|
|
45
|
+
}
|
|
46
|
+
else if (label === 'typescript' || label === 'javascript') {
|
|
47
|
+
return new tsWorker();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return new editorWorker();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function getCode() {
|
|
57
|
+
return editor?.getValue() ?? '';
|
|
58
|
+
}
|
|
59
|
+
export function insertAtCursor(code) {
|
|
60
|
+
if (editor) {
|
|
61
|
+
editor.trigger('keyboard', 'type', { text: code });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function setCode(ncode) {
|
|
65
|
+
code = ncode;
|
|
66
|
+
if (editor) {
|
|
67
|
+
editor.setValue(ncode);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function format() {
|
|
71
|
+
if (editor) {
|
|
72
|
+
code = getCode();
|
|
73
|
+
editor.getAction('editor.action.formatDocument').run();
|
|
74
|
+
if (formatAction) {
|
|
75
|
+
formatAction();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function loadMonaco() {
|
|
80
|
+
const model = monaco.editor.createModel(code, lang, monaco.Uri.parse(uri));
|
|
81
|
+
model.updateOptions(updateOptions);
|
|
82
|
+
editor = monaco.editor.create(divEl, editorConfig(model, code, lang, automaticLayout));
|
|
83
|
+
if (shouldBindKey) {
|
|
84
|
+
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
|
|
85
|
+
format();
|
|
86
|
+
});
|
|
87
|
+
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, function () {
|
|
88
|
+
if (cmdEnterAction) {
|
|
89
|
+
cmdEnterAction();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
let timeoutModel = undefined;
|
|
94
|
+
editor.onDidChangeModelContent((event) => {
|
|
95
|
+
timeoutModel && clearTimeout(timeoutModel);
|
|
96
|
+
timeoutModel = setTimeout(() => {
|
|
97
|
+
code = getCode();
|
|
98
|
+
}, 500);
|
|
99
|
+
dispatch('change');
|
|
100
|
+
});
|
|
101
|
+
editor.onDidFocusEditorText(() => {
|
|
102
|
+
dispatch('focus');
|
|
103
|
+
});
|
|
104
|
+
editor.onDidBlurEditorText(() => {
|
|
105
|
+
dispatch('blur');
|
|
106
|
+
});
|
|
107
|
+
if (lang == 'javascript' && extraLib != '' && extraLibPath != '') {
|
|
108
|
+
monaco.languages.typescript.javascriptDefaults.setExtraLibs([
|
|
109
|
+
{
|
|
110
|
+
content: extraLib,
|
|
111
|
+
filePath: extraLibPath
|
|
112
|
+
}
|
|
113
|
+
]);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
onMount(() => {
|
|
117
|
+
if (browser) {
|
|
118
|
+
loadMonaco();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
onDestroy(() => {
|
|
122
|
+
try {
|
|
123
|
+
editor && editor.dispose();
|
|
124
|
+
}
|
|
125
|
+
catch (err) { }
|
|
126
|
+
});
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<div bind:this={divEl} class={$$props.class} />
|
|
130
|
+
|
|
131
|
+
<style>
|
|
132
|
+
.editor {
|
|
133
|
+
padding-left: 0px;
|
|
134
|
+
padding-right: 0px;
|
|
135
|
+
/* stylelint-disable-next-line unit-allowed-list */
|
|
136
|
+
height: 80vh;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.small-editor {
|
|
140
|
+
/* stylelint-disable-next-line unit-allowed-list */
|
|
141
|
+
height: 26vh;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.few-lines-editor {
|
|
145
|
+
/* stylelint-disable-next-line unit-allowed-list */
|
|
146
|
+
height: 80px;
|
|
147
|
+
}</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
lang: string;
|
|
6
|
+
code?: string | undefined;
|
|
7
|
+
hash?: string | undefined;
|
|
8
|
+
cmdEnterAction?: (() => void) | undefined;
|
|
9
|
+
formatAction?: (() => void) | undefined;
|
|
10
|
+
automaticLayout?: boolean | undefined;
|
|
11
|
+
extraLib?: string | undefined;
|
|
12
|
+
extraLibPath?: string | undefined;
|
|
13
|
+
shouldBindKey?: boolean | undefined;
|
|
14
|
+
getCode?: (() => string) | undefined;
|
|
15
|
+
insertAtCursor?: ((code: string) => void) | undefined;
|
|
16
|
+
setCode?: ((ncode: string) => void) | undefined;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
change: CustomEvent<any>;
|
|
20
|
+
focus: CustomEvent<any>;
|
|
21
|
+
blur: CustomEvent<any>;
|
|
22
|
+
} & {
|
|
23
|
+
[evt: string]: CustomEvent<any>;
|
|
24
|
+
};
|
|
25
|
+
slots: {};
|
|
26
|
+
};
|
|
27
|
+
export declare type SimpleEditorProps = typeof __propDef.props;
|
|
28
|
+
export declare type SimpleEditorEvents = typeof __propDef.events;
|
|
29
|
+
export declare type SimpleEditorSlots = typeof __propDef.slots;
|
|
30
|
+
export default class SimpleEditor extends SvelteComponentTyped<SimpleEditorProps, SimpleEditorEvents, SimpleEditorSlots> {
|
|
31
|
+
get getCode(): () => string;
|
|
32
|
+
get insertAtCursor(): (code: string) => void;
|
|
33
|
+
get setCode(): (ncode: string) => void;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script>import { Job, JobService } from '../gen';
|
|
2
|
+
import { workspaceStore } from '../stores';
|
|
3
|
+
import { onDestroy } from 'svelte';
|
|
4
|
+
import { createEventDispatcher } from 'svelte';
|
|
5
|
+
const dispatch = createEventDispatcher();
|
|
6
|
+
export let isLoading = false;
|
|
7
|
+
export let job = undefined;
|
|
8
|
+
let intervalId;
|
|
9
|
+
let syncIteration = 0;
|
|
10
|
+
let ITERATIONS_BEFORE_SLOW_REFRESH = 100;
|
|
11
|
+
export async function runPreview(path, code, lang, args) {
|
|
12
|
+
try {
|
|
13
|
+
if (intervalId) {
|
|
14
|
+
clearInterval(intervalId);
|
|
15
|
+
}
|
|
16
|
+
if (isLoading && job) {
|
|
17
|
+
JobService.cancelQueuedJob({
|
|
18
|
+
workspace: $workspaceStore,
|
|
19
|
+
id: job.id,
|
|
20
|
+
requestBody: {}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
isLoading = true;
|
|
24
|
+
const testId = await JobService.runScriptPreview({
|
|
25
|
+
workspace: $workspaceStore,
|
|
26
|
+
requestBody: {
|
|
27
|
+
path,
|
|
28
|
+
content: code,
|
|
29
|
+
args,
|
|
30
|
+
language: lang
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
await watchJob(testId);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
isLoading = false;
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function cancelJob() {
|
|
41
|
+
await JobService.cancelQueuedJob({
|
|
42
|
+
workspace: $workspaceStore ?? '',
|
|
43
|
+
id: job?.id ?? '',
|
|
44
|
+
requestBody: {}
|
|
45
|
+
});
|
|
46
|
+
console.log('cancelled');
|
|
47
|
+
}
|
|
48
|
+
export async function watchJob(testId) {
|
|
49
|
+
console.log('watch jobs');
|
|
50
|
+
job = undefined;
|
|
51
|
+
await loadTestJob(testId);
|
|
52
|
+
syncIteration = 0;
|
|
53
|
+
intervalId = setInterval(() => {
|
|
54
|
+
syncer(testId);
|
|
55
|
+
}, 500);
|
|
56
|
+
}
|
|
57
|
+
async function loadTestJob(id) {
|
|
58
|
+
try {
|
|
59
|
+
if (job && `running` in job) {
|
|
60
|
+
let previewJobUpdates = await JobService.getJobUpdates({
|
|
61
|
+
workspace: $workspaceStore,
|
|
62
|
+
id,
|
|
63
|
+
running: job.running,
|
|
64
|
+
logOffset: job.logs?.length ?? 0
|
|
65
|
+
});
|
|
66
|
+
if (previewJobUpdates.new_logs) {
|
|
67
|
+
job.logs = (job.logs ?? '').concat(previewJobUpdates.new_logs);
|
|
68
|
+
}
|
|
69
|
+
if ((previewJobUpdates.running ?? false) || (previewJobUpdates.completed ?? false)) {
|
|
70
|
+
job = await JobService.getJob({ workspace: $workspaceStore, id });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
job = await JobService.getJob({ workspace: $workspaceStore, id });
|
|
75
|
+
}
|
|
76
|
+
if (job?.type === 'CompletedJob' && isLoading) {
|
|
77
|
+
//only CompletedJob has success property
|
|
78
|
+
dispatch('done', job);
|
|
79
|
+
clearInterval(intervalId);
|
|
80
|
+
isLoading = false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
console.error(err);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function syncer(id) {
|
|
88
|
+
if (syncIteration == ITERATIONS_BEFORE_SLOW_REFRESH) {
|
|
89
|
+
intervalId && clearInterval(intervalId);
|
|
90
|
+
intervalId = setInterval(() => syncer(id), 2000);
|
|
91
|
+
}
|
|
92
|
+
syncIteration++;
|
|
93
|
+
loadTestJob(id);
|
|
94
|
+
}
|
|
95
|
+
onDestroy(() => {
|
|
96
|
+
intervalId && clearInterval(intervalId);
|
|
97
|
+
});
|
|
98
|
+
</script>
|