windmill-components 1.85.0 → 1.86.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/components/CenteredModal.svelte +9 -7
- package/components/CronInput.svelte +301 -64
- package/components/CronInput.svelte.d.ts +3 -3
- package/components/DisplayResult.svelte +2 -2
- package/components/Editor.svelte +97 -42
- package/components/Editor.svelte.d.ts +10 -4
- package/components/EditorBar.svelte +14 -9
- package/components/EditorBar.svelte.d.ts +1 -1
- package/components/FlowBuilder.svelte +73 -53
- package/components/FlowGraphViewer.svelte +2 -0
- package/components/FlowGraphViewer.svelte.d.ts +1 -0
- package/components/FlowPreviewContent.svelte +3 -2
- package/components/FlowViewer.svelte +1 -1
- package/components/InputTransformForm.svelte +75 -72
- package/components/LightweightArgInput.svelte +3 -0
- package/components/LightweightArgInput.svelte.d.ts +1 -0
- package/components/LightweightSchemaForm.svelte +1 -0
- package/components/LightweightSchemaForm.svelte.d.ts +2 -0
- package/components/ModulePreview.svelte +2 -2
- package/components/Path.svelte +15 -3
- package/components/Popover.svelte +7 -19
- package/components/ScheduleEditor.svelte +18 -8
- package/components/ScriptBuilder.svelte +201 -206
- package/components/ScriptBuilder.svelte.d.ts +2 -0
- package/components/ScriptEditor.svelte +38 -37
- package/components/ScriptEditor.svelte.d.ts +5 -1
- package/components/ScriptSchema.svelte +1 -20
- package/components/ScriptSchema.svelte.d.ts +0 -1
- package/components/SimpleEditor.svelte +8 -2
- package/components/SimpleEditor.svelte.d.ts +6 -0
- package/components/Star.svelte +2 -1
- package/components/TemplateEditor.svelte +16 -3
- package/components/TemplateEditor.svelte.d.ts +3 -0
- package/components/Toast.svelte +50 -0
- package/components/Toast.svelte.d.ts +18 -0
- package/components/apps/components/buttons/AppButton.svelte +2 -1
- package/components/apps/components/display/AppHtml.svelte +9 -6
- package/components/apps/components/display/AppIcon.svelte +3 -0
- package/components/apps/components/display/AppImage.svelte +3 -0
- package/components/apps/components/display/AppMap.svelte +3 -0
- package/components/apps/components/display/AppPdf.svelte +3 -0
- package/components/apps/components/display/AppText.svelte +143 -51
- package/components/apps/components/display/AppText.svelte.d.ts +4 -0
- package/components/apps/components/helpers/AlignWrapper.svelte +1 -20
- package/components/apps/components/helpers/HiddenComponent.svelte +12 -6
- package/components/apps/components/helpers/HiddenComponent.svelte.d.ts +2 -1
- package/components/apps/components/helpers/InitializeComponent.svelte +12 -0
- package/components/apps/components/helpers/InitializeComponent.svelte.d.ts +16 -0
- package/components/apps/components/helpers/InputValue.svelte +6 -0
- package/components/apps/components/helpers/NonRunnableComponent.svelte +3 -0
- package/components/apps/components/helpers/RunnableComponent.svelte +24 -6
- package/components/apps/components/helpers/RunnableComponent.svelte.d.ts +2 -1
- package/components/apps/components/helpers/RunnableWrapper.svelte +8 -2
- package/components/apps/components/helpers/RunnableWrapper.svelte.d.ts +1 -0
- package/components/apps/components/inputs/AppCheckbox.svelte +3 -0
- package/components/apps/components/inputs/AppDateInput.svelte +3 -0
- package/components/apps/components/inputs/AppFileInput.svelte +4 -0
- package/components/apps/components/inputs/AppMultiSelect.svelte +3 -0
- package/components/apps/components/inputs/AppNumberInput.svelte +3 -0
- package/components/apps/components/inputs/AppRangeInput.svelte +3 -0
- package/components/apps/components/inputs/AppSelect.svelte +3 -9
- package/components/apps/components/inputs/AppSliderInputs.svelte +2 -0
- package/components/apps/components/inputs/AppTextInput.svelte +3 -0
- package/components/apps/components/inputs/currency/AppCurrencyInput.svelte +3 -0
- package/components/apps/components/layout/AppContainer.svelte +3 -0
- package/components/apps/components/layout/AppDivider.svelte +3 -0
- package/components/apps/components/layout/AppDrawer.svelte +3 -0
- package/components/apps/components/layout/AppSplitpanes.svelte +3 -0
- package/components/apps/components/layout/AppTabs.svelte +3 -0
- package/components/apps/editor/AppEditor.svelte +29 -18
- package/components/apps/editor/AppEditorHeader.svelte +23 -15
- package/components/apps/editor/AppPreview.svelte +5 -3
- package/components/apps/editor/ComponentHeader.svelte +20 -1
- package/components/apps/editor/ComponentHeader.svelte.d.ts +3 -0
- package/components/apps/editor/GridEditor.svelte +2 -2
- package/components/apps/editor/RecomputeAllComponents.svelte +7 -4
- package/components/apps/editor/SettingsPanel.svelte +1 -0
- package/components/apps/editor/appUtils.js +12 -2
- package/components/apps/editor/component/Component.svelte +24 -2
- package/components/apps/editor/component/components.d.ts +39 -39
- package/components/apps/editor/componentsPanel/ComponentList.svelte +12 -26
- package/components/apps/editor/componentsPanel/CssSettings.svelte +1 -1
- package/components/apps/editor/componentsPanel/ListItem.svelte +2 -2
- package/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte +4 -3
- package/components/apps/editor/settingsPanel/ComponentInputTypeEditor.svelte +50 -37
- package/components/apps/editor/settingsPanel/ComponentPanel.svelte +3 -3
- package/components/apps/editor/settingsPanel/SelectedRunnable.svelte +14 -6
- package/components/apps/editor/settingsPanel/inputEditor/ConnectedInputEditor.svelte +2 -2
- package/components/apps/editor/settingsPanel/inputEditor/IconSelectInput.svelte +8 -3
- package/components/apps/editor/settingsPanel/inputEditor/IconSelectInput.svelte.d.ts +0 -2
- package/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte +2 -2
- package/components/apps/editor/settingsPanel/triggerLists/BackgroundScriptTriggerList.svelte +15 -7
- package/components/apps/editor/settingsPanel/triggerLists/BackgroundScriptTriggerList.svelte.d.ts +2 -1
- package/components/apps/editor/settingsPanel/triggerLists/ComponentTriggerList.svelte +2 -2
- package/components/apps/editor/settingsPanel/triggerLists/ComponentTriggerList.svelte.d.ts +1 -1
- package/components/apps/editor/settingsPanel/triggerLists/TriggerBadgesList.svelte +6 -5
- package/components/apps/editor/settingsPanel/triggerLists/TriggerBadgesList.svelte.d.ts +1 -1
- package/components/apps/inputType.d.ts +1 -0
- package/components/apps/rx.d.ts +0 -2
- package/components/apps/rx.js +1 -3
- package/components/apps/types.d.ts +8 -0
- package/components/apps/utils.d.ts +3 -1
- package/components/apps/utils.js +24 -1
- package/components/build_workers.d.ts +14 -0
- package/components/build_workers.js +45 -0
- package/components/common/button/Button.svelte +46 -24
- package/components/common/button/Button.svelte.d.ts +7 -1
- package/components/common/button/ButtonDropdown.svelte +25 -0
- package/components/common/button/ButtonDropdown.svelte.d.ts +27 -0
- package/components/common/button/model.d.ts +2 -3
- package/components/common/button/model.js +7 -3
- package/components/common/drawer/Drawer.svelte +0 -1
- package/components/common/drawer/DrawerContent.svelte +1 -1
- package/components/common/fileInput/FileInput.svelte +5 -1
- package/components/common/fileInput/FileInput.svelte.d.ts +1 -0
- package/components/common/index.d.ts +0 -2
- package/components/common/index.js +0 -2
- package/components/common/menu/Menu.svelte.d.ts +1 -1
- package/components/common/popup/Popup.svelte +9 -5
- package/components/common/table/ScriptRow.svelte +2 -2
- package/components/common/tabs/Tab.svelte +10 -5
- package/components/common/tabs/Tabs.svelte +20 -1
- package/components/common/tabs/Tabs.svelte.d.ts +3 -0
- package/components/flows/CreateActionsApp.svelte +12 -7
- package/components/flows/CreateActionsFlow.svelte +11 -10
- package/components/flows/FlowEditor.svelte +2 -2
- package/components/flows/content/CapturePayload.svelte +2 -4
- package/components/flows/content/FlowModuleComponent.svelte +1 -0
- package/components/flows/content/FlowSchedules.svelte +3 -1
- package/components/flows/header/FlowImportExportMenu.svelte +10 -12
- package/components/flows/header/FlowPreviewButtons.svelte +21 -23
- package/components/flows/scheduleUtils.d.ts +1 -0
- package/components/flows/scheduleUtils.js +2 -1
- package/components/graph/FlowGraph.svelte +21 -7
- package/components/graph/FlowGraph.svelte.d.ts +2 -0
- package/components/graph/svelvet/container/views/GraphView.svelte +17 -29
- package/components/graph/svelvet/container/views/GraphView.svelte.d.ts +2 -0
- package/components/graph/svelvet/container/views/Svelvet.svelte +4 -3
- package/components/graph/svelvet/container/views/Svelvet.svelte.d.ts +3 -0
- package/components/home/ItemsList.svelte +1 -1
- package/components/icons/WindmillIcon.svelte +4 -0
- package/components/icons/WindmillIcon.svelte.d.ts +1 -0
- package/components/propertyPicker/PropPicker.svelte +2 -2
- package/components/scripts/CreateActionsScript.svelte +4 -22
- package/editorUtils.js +3 -1
- package/gen/core/OpenAPI.js +1 -1
- package/gen/index.d.ts +6 -0
- package/gen/index.js +2 -0
- package/gen/models/CreateInput.d.ts +5 -0
- package/gen/models/CreateInput.js +4 -0
- package/gen/models/EditSchedule.d.ts +1 -0
- package/gen/models/Input.d.ts +6 -0
- package/gen/models/Input.js +4 -0
- package/gen/models/NewSchedule.d.ts +1 -1
- package/gen/models/NewTokenImpersonate.d.ts +5 -0
- package/gen/models/NewTokenImpersonate.js +4 -0
- package/gen/models/RunnableType.d.ts +5 -0
- package/gen/models/RunnableType.js +9 -0
- package/gen/models/Schedule.d.ts +1 -1
- package/gen/models/UpdateInput.d.ts +4 -0
- package/gen/models/UpdateInput.js +4 -0
- package/gen/services/FlowService.d.ts +18 -0
- package/gen/services/FlowService.js +19 -0
- package/gen/services/InputService.d.ts +78 -0
- package/gen/services/InputService.js +95 -0
- package/gen/services/JobService.d.ts +35 -15
- package/gen/services/JobService.js +25 -7
- package/gen/services/ScheduleService.d.ts +2 -2
- package/gen/services/ScheduleService.js +1 -1
- package/gen/services/ScriptService.d.ts +10 -0
- package/gen/services/ScriptService.js +16 -0
- package/gen/services/UserService.d.ts +12 -0
- package/gen/services/UserService.js +13 -0
- package/package.json +24 -13
- package/script_helpers.d.ts +1 -1
- package/script_helpers.js +7 -5
- package/utils.d.ts +2 -2
- package/utils.js +21 -11
- package/components/common/button/ButtonPopup.svelte +0 -78
- package/components/common/button/ButtonPopup.svelte.d.ts +0 -39
- package/components/common/button/ButtonPopupItem.svelte +0 -48
- package/components/common/button/ButtonPopupItem.svelte.d.ts +0 -28
|
@@ -8,20 +8,27 @@ import { emptySchema, encodeState, sendUserToast, setQueryWithoutLoad } from '..
|
|
|
8
8
|
import Path from './Path.svelte';
|
|
9
9
|
import ScriptEditor from './ScriptEditor.svelte';
|
|
10
10
|
import ScriptSchema from './ScriptSchema.svelte';
|
|
11
|
-
import CenteredPage from './CenteredPage.svelte';
|
|
12
11
|
import { dirtyStore } from './common/confirmationModal/dirtyStore';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import Breadcrumb from './common/breadcrumb/Breadcrumb.svelte';
|
|
12
|
+
import { Badge, Button, Drawer } from './common';
|
|
13
|
+
import { faSave } from '@fortawesome/free-solid-svg-icons';
|
|
16
14
|
import LanguageIcon from './common/languageIcons/LanguageIcon.svelte';
|
|
17
15
|
import Tooltip from './Tooltip.svelte';
|
|
18
|
-
import
|
|
16
|
+
import DrawerContent from './common/drawer/DrawerContent.svelte';
|
|
17
|
+
import { Pen } from 'lucide-svelte';
|
|
18
|
+
import autosize from 'svelte-autosize';
|
|
19
19
|
export let script;
|
|
20
20
|
export let initialPath = '';
|
|
21
21
|
export let template = 'script';
|
|
22
22
|
export let initialArgs = {};
|
|
23
23
|
export let lockedLanguage = false;
|
|
24
24
|
export let topHash = undefined;
|
|
25
|
+
let metadataOpen = initialPath == '' && $page.url.searchParams.get('state') == undefined;
|
|
26
|
+
let advancedOpen = false;
|
|
27
|
+
let editor = undefined;
|
|
28
|
+
let scriptEditor = undefined;
|
|
29
|
+
export function setCode(code) {
|
|
30
|
+
editor?.setCode(code);
|
|
31
|
+
}
|
|
25
32
|
const langs = [
|
|
26
33
|
['Typescript', Script.language.DENO],
|
|
27
34
|
['Python', Script.language.PYTHON3],
|
|
@@ -50,16 +57,14 @@ const scriptKindOptions = [
|
|
|
50
57
|
}
|
|
51
58
|
];
|
|
52
59
|
let pathError = '';
|
|
53
|
-
let summaryC = undefined;
|
|
54
|
-
let pathC = undefined;
|
|
55
60
|
let loadingSave = false;
|
|
56
61
|
$: setQueryWithoutLoad($page.url, [{ key: 'state', value: encodeState(script) }]);
|
|
57
|
-
$: step = Number($page.url.searchParams.get('step')) || 1;
|
|
58
62
|
if (script.content == '') {
|
|
59
63
|
initContent(script.language, script.kind, template);
|
|
60
64
|
}
|
|
61
65
|
function initContent(language, kind, template) {
|
|
62
66
|
script.content = initialCode(language, kind, template);
|
|
67
|
+
scriptEditor?.inferSchema(script.content, language);
|
|
63
68
|
}
|
|
64
69
|
async function editScript(leave) {
|
|
65
70
|
loadingSave = true;
|
|
@@ -88,11 +93,11 @@ async function editScript(leave) {
|
|
|
88
93
|
}
|
|
89
94
|
});
|
|
90
95
|
if (leave) {
|
|
91
|
-
history.replaceState(history.state, '', `/scripts/edit/${newHash}
|
|
96
|
+
history.replaceState(history.state, '', `/scripts/edit/${newHash}`);
|
|
92
97
|
goto(`/scripts/get/${newHash}?workspace_id=${$workspaceStore}`);
|
|
93
98
|
}
|
|
94
99
|
else {
|
|
95
|
-
await goto(`/scripts/edit/${newHash}
|
|
100
|
+
await goto(`/scripts/edit/${newHash}`);
|
|
96
101
|
script.hash = newHash;
|
|
97
102
|
topHash = undefined;
|
|
98
103
|
}
|
|
@@ -102,240 +107,230 @@ async function editScript(leave) {
|
|
|
102
107
|
}
|
|
103
108
|
loadingSave = false;
|
|
104
109
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
await inferArgs(script.language, script.content, script.schema);
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
console.info('The main signature was not parsable. This script is considered to be without main function');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
goto(`?step=${step}`);
|
|
116
|
-
}
|
|
117
|
-
$: kind = script.kind;
|
|
118
|
-
function onKeyDown(event) {
|
|
119
|
-
if (event.key == 'Enter' && step == 1) {
|
|
120
|
-
changeStep(2);
|
|
110
|
+
const dropdownItems = [
|
|
111
|
+
{
|
|
112
|
+
label: 'Save and leave',
|
|
113
|
+
onClick: () => editScript(true)
|
|
121
114
|
}
|
|
115
|
+
];
|
|
116
|
+
if (initialPath != '') {
|
|
117
|
+
dropdownItems.push({
|
|
118
|
+
label: 'Fork',
|
|
119
|
+
onClick: () => {
|
|
120
|
+
window.open(`/scripts/add?template=${initialPath}`);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
122
123
|
}
|
|
123
124
|
</script>
|
|
124
125
|
|
|
125
126
|
{#if !$userStore?.operator}
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
127
|
+
<Drawer placement="right" bind:open={metadataOpen} size="800px">
|
|
128
|
+
<DrawerContent title="Metadata" on:close={() => (metadataOpen = false)}>
|
|
129
|
+
<h2 class="border-b pb-1 mb-4">Path</h2>
|
|
130
|
+
<Path
|
|
131
|
+
bind:error={pathError}
|
|
132
|
+
bind:path={script.path}
|
|
133
|
+
{initialPath}
|
|
134
|
+
namePlaceholder="script"
|
|
135
|
+
kind="script"
|
|
136
|
+
/>
|
|
137
|
+
<h2 class="border-b pb-1 mt-10 mb-4">Summary</h2>
|
|
138
|
+
|
|
139
|
+
<input
|
|
140
|
+
type="text"
|
|
141
|
+
bind:value={script.summary}
|
|
142
|
+
placeholder="Short summary to be displayed when listed"
|
|
143
|
+
/>
|
|
144
|
+
<h2 class="border-b pb-1 mt-10 mb-4">Language</h2>
|
|
142
145
|
|
|
143
|
-
|
|
146
|
+
{#if lockedLanguage}
|
|
147
|
+
<div class="text-sm text-gray-600 italic mb-2">
|
|
148
|
+
As a forked script, the language '{script.language}' cannot be modified.
|
|
149
|
+
</div>
|
|
150
|
+
{/if}
|
|
151
|
+
<div class="flex flex-row gap-2 flex-wrap">
|
|
152
|
+
{#each langs as [label, lang]}
|
|
153
|
+
{@const isPicked = script.language == lang && template == 'script'}
|
|
144
154
|
<Button
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
size="sm"
|
|
156
|
+
variant="border"
|
|
157
|
+
color={isPicked ? 'blue' : 'dark'}
|
|
158
|
+
btnClasses={isPicked ? '!border-2 !bg-blue-50/75' : 'm-[1px]'}
|
|
159
|
+
on:click={() => {
|
|
160
|
+
template = 'script'
|
|
161
|
+
initContent(lang, script.kind, template)
|
|
162
|
+
script.language = lang
|
|
153
163
|
}}
|
|
164
|
+
disabled={lockedLanguage}
|
|
154
165
|
>
|
|
155
|
-
{
|
|
166
|
+
<LanguageIcon {lang} />
|
|
167
|
+
<span class="ml-2 py-2">{label}</span>
|
|
156
168
|
</Button>
|
|
169
|
+
{/each}
|
|
170
|
+
<Button
|
|
171
|
+
size="sm"
|
|
172
|
+
variant="border"
|
|
173
|
+
color={template == 'pgsql' ? 'blue' : 'dark'}
|
|
174
|
+
btnClasses={template == 'pgsql' ? '!border-2 !bg-blue-50/75' : 'm-[1px]'}
|
|
175
|
+
disabled={lockedLanguage}
|
|
176
|
+
on:click={() => {
|
|
177
|
+
template = 'pgsql'
|
|
178
|
+
initContent(Script.language.DENO, script.kind, template)
|
|
179
|
+
script.language = Script.language.DENO
|
|
180
|
+
}}
|
|
181
|
+
>
|
|
182
|
+
<LanguageIcon lang="pgsql" /><span class="ml-2 py-2">PostgreSQL</span>
|
|
183
|
+
</Button>
|
|
184
|
+
<!-- <Button
|
|
185
|
+
size="sm"
|
|
186
|
+
variant="border"
|
|
187
|
+
color={template == 'mysql' ? 'blue' : 'dark'}
|
|
188
|
+
btnClasses={template == 'mysql' ? '!border-2 !bg-blue-50/75' : 'm-[1px]'}
|
|
189
|
+
on:click={() => {
|
|
190
|
+
script.language = Script.language.DENO
|
|
191
|
+
template = 'mysql'
|
|
192
|
+
initContent(script.language, script.kind, template)
|
|
193
|
+
}}
|
|
194
|
+
>
|
|
195
|
+
<LanguageIcon lang="mysql" /><span class="ml-2 py-2">MySQL</span>
|
|
196
|
+
</Button> -->
|
|
197
|
+
</div>
|
|
157
198
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
199
|
+
<h2 class="border-b pb-1 mt-10 mb-4">Description</h2>
|
|
200
|
+
<textarea
|
|
201
|
+
use:autosize
|
|
202
|
+
bind:value={script.description}
|
|
203
|
+
placeholder="Edit description"
|
|
204
|
+
class="text-sm"
|
|
205
|
+
/>
|
|
206
|
+
</DrawerContent>
|
|
207
|
+
</Drawer>
|
|
208
|
+
|
|
209
|
+
<div class="flex flex-col h-screen">
|
|
210
|
+
<div class="flex flex-col w-full px-2 py-1 border-b shadow-sm">
|
|
211
|
+
<div class="justify-between flex gap-8 w-full items-center px-2">
|
|
212
|
+
<div class="min-w-64 w-full max-w-md">
|
|
213
|
+
<input
|
|
214
|
+
type="text"
|
|
215
|
+
placeholder="Script summary"
|
|
216
|
+
class="text-sm w-full font-semibold"
|
|
217
|
+
bind:value={script.summary}
|
|
218
|
+
/>
|
|
219
|
+
</div>
|
|
220
|
+
<div class="gap-4 flex">
|
|
221
|
+
<div class="flex justify-start w-full">
|
|
222
|
+
<div>
|
|
223
|
+
<button
|
|
224
|
+
on:click={async () => {
|
|
225
|
+
metadataOpen = true
|
|
226
|
+
}}
|
|
227
|
+
>
|
|
228
|
+
<Badge
|
|
229
|
+
color="gray"
|
|
230
|
+
class="center-center !bg-gray-300 !text-gray-600 !h-[28px] !w-[70px] rounded-r-none"
|
|
231
|
+
>
|
|
232
|
+
<Pen size={12} class="mr-2" /> Path
|
|
233
|
+
</Badge>
|
|
234
|
+
</button>
|
|
235
|
+
</div>
|
|
236
|
+
<input
|
|
237
|
+
type="text"
|
|
238
|
+
readonly
|
|
239
|
+
value={script.path}
|
|
240
|
+
size={script.path?.length || 50}
|
|
241
|
+
class="font-mono !text-xs !min-w-[96px] !max-w-[300px] !w-full !h-[28px] !my-0 !py-0 !border-l-0 !rounded-l-none"
|
|
242
|
+
on:focus={({ currentTarget }) => {
|
|
243
|
+
currentTarget.select()
|
|
244
|
+
}}
|
|
245
|
+
/>
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
<div class="center-center">
|
|
249
|
+
<button
|
|
163
250
|
on:click={async () => {
|
|
164
|
-
|
|
165
|
-
setTimeout(() => summaryC?.focus(), 100)
|
|
251
|
+
metadataOpen = true
|
|
166
252
|
}}
|
|
167
253
|
>
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
</div>
|
|
171
|
-
</Button>
|
|
254
|
+
<LanguageIcon lang={script.language} />
|
|
255
|
+
</button>
|
|
172
256
|
</div>
|
|
173
|
-
<div class="flex flex-row gap-x-
|
|
257
|
+
<div class="flex flex-row gap-x-4">
|
|
174
258
|
<Button
|
|
259
|
+
color="dark"
|
|
175
260
|
variant="border"
|
|
176
|
-
size="
|
|
177
|
-
|
|
178
|
-
|
|
261
|
+
size="xs"
|
|
262
|
+
on:click={() => {
|
|
263
|
+
advancedOpen = true
|
|
264
|
+
}}
|
|
179
265
|
>
|
|
180
|
-
|
|
266
|
+
Customise
|
|
181
267
|
</Button>
|
|
182
268
|
<Button
|
|
183
|
-
|
|
184
|
-
variant={step == 1 ? 'contained' : 'border'}
|
|
185
|
-
btnClasses={step == 3 ? 'invisible' : 'inline-flex gap-2'}
|
|
186
|
-
disabled={step === 1 && pathError !== ''}
|
|
187
|
-
on:click={() => changeStep(step + 1)}
|
|
188
|
-
>
|
|
189
|
-
Next {#if step == 1}<Kbd>Enter</Kbd>{/if}
|
|
190
|
-
</Button>
|
|
191
|
-
<ButtonPopup
|
|
269
|
+
color="dark"
|
|
192
270
|
loading={loadingSave}
|
|
193
271
|
size="sm"
|
|
194
|
-
variant={step == 1 ? 'border' : 'contained'}
|
|
195
|
-
disabled={step === 1 && pathError !== ''}
|
|
196
272
|
startIcon={{ icon: faSave }}
|
|
197
273
|
on:click={() => editScript(false)}
|
|
274
|
+
{dropdownItems}
|
|
198
275
|
>
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
{#if initialPath != ''}
|
|
202
|
-
<ButtonPopupItem
|
|
203
|
-
on:click={() => {
|
|
204
|
-
window.open(`/scripts/add?template=${initialPath}`)
|
|
205
|
-
}}>Fork</ButtonPopupItem
|
|
206
|
-
>
|
|
207
|
-
{/if}
|
|
208
|
-
</ButtonPopup>
|
|
276
|
+
Save
|
|
277
|
+
</Button>
|
|
209
278
|
</div>
|
|
210
279
|
</div>
|
|
211
280
|
</div>
|
|
212
281
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
kind="script"
|
|
225
|
-
/>
|
|
226
|
-
</SettingSection>
|
|
227
|
-
<SettingSection title="Summary" element="h2">
|
|
228
|
-
<input
|
|
229
|
-
type="text"
|
|
230
|
-
bind:this={summaryC}
|
|
231
|
-
bind:value={script.summary}
|
|
232
|
-
placeholder="Short summary to be displayed when listed"
|
|
233
|
-
/>
|
|
234
|
-
</SettingSection>
|
|
235
|
-
<SettingSection title="Language" element="h2">
|
|
236
|
-
{#if lockedLanguage}
|
|
237
|
-
<div class="text-sm text-gray-600 italic mb-2">
|
|
238
|
-
As a forked script, the language '{script.language}' cannot be modified.
|
|
239
|
-
</div>
|
|
240
|
-
{/if}
|
|
241
|
-
<div class="flex flex-row gap-2 flex-wrap">
|
|
242
|
-
{#each langs as [label, lang]}
|
|
243
|
-
{@const isPicked = script.language == lang && template == 'script'}
|
|
244
|
-
<Button
|
|
245
|
-
size="sm"
|
|
246
|
-
variant="border"
|
|
247
|
-
color={isPicked ? 'blue' : 'dark'}
|
|
248
|
-
btnClasses={isPicked ? '!border-2 !bg-blue-50/75' : 'm-[1px]'}
|
|
249
|
-
on:click={() => {
|
|
250
|
-
script.language = lang
|
|
251
|
-
template = 'script'
|
|
252
|
-
initContent(lang, script.kind, template)
|
|
253
|
-
}}
|
|
254
|
-
disabled={lockedLanguage}
|
|
255
|
-
>
|
|
256
|
-
<LanguageIcon {lang} />
|
|
257
|
-
<span class="ml-2 py-2">{label}</span>
|
|
258
|
-
</Button>
|
|
259
|
-
{/each}
|
|
282
|
+
<Drawer bind:open={advancedOpen} size="800px">
|
|
283
|
+
<DrawerContent title="Customise" on:close={() => (advancedOpen = false)}>
|
|
284
|
+
<h2 class="border-b pb-1 mb-4"
|
|
285
|
+
>Script Kind <Tooltip
|
|
286
|
+
>Tag this script's purpose within flows such that it is available as the corresponding
|
|
287
|
+
action.</Tooltip
|
|
288
|
+
></h2
|
|
289
|
+
>
|
|
290
|
+
<div class="flex flex-wrap gap-2">
|
|
291
|
+
{#each scriptKindOptions as { value, title, desc }}
|
|
292
|
+
{@const isPicked = script.kind === value}
|
|
260
293
|
<Button
|
|
261
294
|
size="sm"
|
|
262
295
|
variant="border"
|
|
263
|
-
color={
|
|
264
|
-
btnClasses={
|
|
265
|
-
disabled={lockedLanguage}
|
|
296
|
+
color={isPicked ? 'blue' : 'dark'}
|
|
297
|
+
btnClasses="font-medium {isPicked ? '!bg-blue-50/75' : ''}"
|
|
266
298
|
on:click={() => {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
initContent(script.language,
|
|
299
|
+
template = 'script'
|
|
300
|
+
script.kind = value
|
|
301
|
+
initContent(script.language, value, template)
|
|
302
|
+
setCode(script.content)
|
|
270
303
|
}}
|
|
271
304
|
>
|
|
272
|
-
|
|
305
|
+
{title}
|
|
306
|
+
{#if desc}
|
|
307
|
+
<Tooltip class="mb-0.5 ml-1">
|
|
308
|
+
{desc}
|
|
309
|
+
</Tooltip>
|
|
310
|
+
{/if}
|
|
273
311
|
</Button>
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
template = 'mysql'
|
|
282
|
-
initContent(script.language, script.kind, template)
|
|
283
|
-
}}
|
|
284
|
-
>
|
|
285
|
-
<LanguageIcon lang="mysql" /><span class="ml-2 py-2">MySQL</span>
|
|
286
|
-
</Button> -->
|
|
287
|
-
</div>
|
|
288
|
-
</SettingSection>
|
|
289
|
-
<SettingSection
|
|
290
|
-
title="Script kind"
|
|
291
|
-
element="h3"
|
|
292
|
-
tooltip="Tag this script as having a specific purpose inside flows. If it won't be used in flows,
|
|
293
|
-
you don't have to worry about this."
|
|
294
|
-
accordion
|
|
312
|
+
{/each}
|
|
313
|
+
</div>
|
|
314
|
+
<h2 class="border-b pb-1 mt-10 mb-4"
|
|
315
|
+
>Arguments <Tooltip
|
|
316
|
+
>The arguments are synced with the main signature but you may refine the parts that
|
|
317
|
+
cannot be inferred from the type directly.</Tooltip
|
|
318
|
+
></h2
|
|
295
319
|
>
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
disabled={lockedLanguage}
|
|
310
|
-
>
|
|
311
|
-
{title}
|
|
312
|
-
{#if desc}
|
|
313
|
-
<Tooltip class="mb-0.5 ml-1">
|
|
314
|
-
{desc}
|
|
315
|
-
</Tooltip>
|
|
316
|
-
{/if}
|
|
317
|
-
</Button>
|
|
318
|
-
{/each}
|
|
319
|
-
</div>
|
|
320
|
-
</SettingSection>
|
|
321
|
-
</CenteredPage>
|
|
322
|
-
{:else if step === 2}
|
|
323
|
-
<ScriptEditor
|
|
324
|
-
bind:schema={script.schema}
|
|
325
|
-
path={script.path}
|
|
326
|
-
bind:code={script.content}
|
|
327
|
-
lang={script.language}
|
|
328
|
-
{initialArgs}
|
|
329
|
-
{kind}
|
|
330
|
-
/>
|
|
331
|
-
{:else if step === 3}
|
|
332
|
-
<CenteredPage>
|
|
333
|
-
<ScriptSchema bind:description={script.description} bind:schema={script.schema} />
|
|
334
|
-
</CenteredPage>
|
|
335
|
-
{/if}
|
|
320
|
+
<ScriptSchema bind:schema={script.schema} />
|
|
321
|
+
</DrawerContent>
|
|
322
|
+
</Drawer>
|
|
323
|
+
<ScriptEditor
|
|
324
|
+
bind:editor
|
|
325
|
+
bind:this={scriptEditor}
|
|
326
|
+
bind:schema={script.schema}
|
|
327
|
+
path={script.path}
|
|
328
|
+
bind:code={script.content}
|
|
329
|
+
lang={script.language}
|
|
330
|
+
{initialArgs}
|
|
331
|
+
kind={script.kind}
|
|
332
|
+
/>
|
|
336
333
|
</div>
|
|
337
334
|
{:else}
|
|
338
335
|
Script Builder not available to operators
|
|
339
336
|
{/if}
|
|
340
|
-
|
|
341
|
-
<svelte:window on:keydown={onKeyDown} />
|
|
@@ -8,6 +8,7 @@ declare const __propDef: {
|
|
|
8
8
|
initialArgs?: Record<string, any> | undefined;
|
|
9
9
|
lockedLanguage?: boolean | undefined;
|
|
10
10
|
topHash?: string | undefined;
|
|
11
|
+
setCode?: ((code: string) => void) | undefined;
|
|
11
12
|
};
|
|
12
13
|
events: {
|
|
13
14
|
[evt: string]: CustomEvent<any>;
|
|
@@ -18,5 +19,6 @@ export type ScriptBuilderProps = typeof __propDef.props;
|
|
|
18
19
|
export type ScriptBuilderEvents = typeof __propDef.events;
|
|
19
20
|
export type ScriptBuilderSlots = typeof __propDef.slots;
|
|
20
21
|
export default class ScriptBuilder extends SvelteComponentTyped<ScriptBuilderProps, ScriptBuilderEvents, ScriptBuilderSlots> {
|
|
22
|
+
get setCode(): (code: string) => void;
|
|
21
23
|
}
|
|
22
24
|
export {};
|
|
@@ -23,10 +23,9 @@ export let kind = undefined;
|
|
|
23
23
|
export let initialArgs = {};
|
|
24
24
|
export let fixedOverflowWidgets = true;
|
|
25
25
|
export let noSyncFromGithub = false;
|
|
26
|
+
export let editor = undefined;
|
|
26
27
|
let websocketAlive = { pyright: false, black: false, deno: false, go: false };
|
|
27
28
|
let width = 1200;
|
|
28
|
-
// Internal state
|
|
29
|
-
let editor;
|
|
30
29
|
let testJobLoader;
|
|
31
30
|
// Test args input
|
|
32
31
|
let args = initialArgs;
|
|
@@ -55,7 +54,7 @@ async function loadPastTests() {
|
|
|
55
54
|
scriptPathExact: path
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
|
-
async function inferSchema(code) {
|
|
57
|
+
export async function inferSchema(code, nlang) {
|
|
59
58
|
schema = schema ?? emptySchema();
|
|
60
59
|
let isDefault = [];
|
|
61
60
|
Object.entries(args).forEach(([k, v]) => {
|
|
@@ -64,7 +63,7 @@ async function inferSchema(code) {
|
|
|
64
63
|
}
|
|
65
64
|
});
|
|
66
65
|
try {
|
|
67
|
-
await inferArgs(lang, code, schema);
|
|
66
|
+
await inferArgs(nlang ?? lang, code, schema);
|
|
68
67
|
validCode = true;
|
|
69
68
|
}
|
|
70
69
|
catch (e) {
|
|
@@ -84,6 +83,9 @@ onMount(() => {
|
|
|
84
83
|
inferSchema(code);
|
|
85
84
|
loadPastTests();
|
|
86
85
|
});
|
|
86
|
+
function asKind(str) {
|
|
87
|
+
return str;
|
|
88
|
+
}
|
|
87
89
|
</script>
|
|
88
90
|
|
|
89
91
|
<TestJobLoader
|
|
@@ -103,7 +105,7 @@ onMount(() => {
|
|
|
103
105
|
{editor}
|
|
104
106
|
{lang}
|
|
105
107
|
{websocketAlive}
|
|
106
|
-
{kind}
|
|
108
|
+
kind={asKind(kind)}
|
|
107
109
|
/>
|
|
108
110
|
{#if !noSyncFromGithub}
|
|
109
111
|
<div class="py-1">
|
|
@@ -126,37 +128,35 @@ onMount(() => {
|
|
|
126
128
|
<SplitPanesWrapper>
|
|
127
129
|
<Splitpanes class="!overflow-visible">
|
|
128
130
|
<Pane size={60} minSize={10} class="!overflow-visible">
|
|
129
|
-
<div
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
{fixedOverflowWidgets}
|
|
159
|
-
/>
|
|
131
|
+
<div class="pl-2 h-full !overflow-visible">
|
|
132
|
+
{#key lang}
|
|
133
|
+
<Editor
|
|
134
|
+
{path}
|
|
135
|
+
bind:code
|
|
136
|
+
bind:websocketAlive
|
|
137
|
+
bind:this={editor}
|
|
138
|
+
on:change={(e) => {
|
|
139
|
+
inferSchema(e.detail)
|
|
140
|
+
}}
|
|
141
|
+
cmdEnterAction={async () => {
|
|
142
|
+
await inferSchema(code)
|
|
143
|
+
runTest()
|
|
144
|
+
}}
|
|
145
|
+
formatAction={async () => {
|
|
146
|
+
await inferSchema(code)
|
|
147
|
+
try {
|
|
148
|
+
localStorage.setItem(path ?? 'last_save', code)
|
|
149
|
+
} catch (e) {
|
|
150
|
+
console.error('Could not save last_save to local storage', e)
|
|
151
|
+
}
|
|
152
|
+
lastSave = code
|
|
153
|
+
}}
|
|
154
|
+
class="flex flex-1 h-full !overflow-visible"
|
|
155
|
+
lang={scriptLangToEditorLang(lang)}
|
|
156
|
+
automaticLayout={true}
|
|
157
|
+
{fixedOverflowWidgets}
|
|
158
|
+
/>
|
|
159
|
+
{/key}
|
|
160
160
|
</div>
|
|
161
161
|
</Pane>
|
|
162
162
|
<Pane size={40} minSize={10}>
|
|
@@ -166,9 +166,10 @@ onMount(() => {
|
|
|
166
166
|
<Button on:click={testJobLoader?.cancelJob} btnClasses="w-full" color="red" size="xs">
|
|
167
167
|
<WindmillIcon
|
|
168
168
|
white={true}
|
|
169
|
-
class="
|
|
169
|
+
class="mr-2 text-white"
|
|
170
170
|
height="20px"
|
|
171
171
|
width="20px"
|
|
172
|
+
spin="fast"
|
|
172
173
|
/>
|
|
173
174
|
Cancel
|
|
174
175
|
</Button>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { Schema } from '../common';
|
|
3
|
+
import Editor from './Editor.svelte';
|
|
3
4
|
import type { Preview } from '../gen/models/Preview';
|
|
4
5
|
declare const __propDef: {
|
|
5
6
|
props: {
|
|
@@ -7,10 +8,12 @@ declare const __propDef: {
|
|
|
7
8
|
code: string;
|
|
8
9
|
path: string | undefined;
|
|
9
10
|
lang: Preview.language;
|
|
10
|
-
kind?:
|
|
11
|
+
kind?: string | undefined;
|
|
11
12
|
initialArgs?: Record<string, any> | undefined;
|
|
12
13
|
fixedOverflowWidgets?: boolean | undefined;
|
|
13
14
|
noSyncFromGithub?: boolean | undefined;
|
|
15
|
+
editor?: Editor | undefined;
|
|
16
|
+
inferSchema?: ((code: string, nlang?: 'go' | 'bash' | 'python3' | 'deno') => Promise<void>) | undefined;
|
|
14
17
|
};
|
|
15
18
|
events: {
|
|
16
19
|
[evt: string]: CustomEvent<any>;
|
|
@@ -21,5 +24,6 @@ export type ScriptEditorProps = typeof __propDef.props;
|
|
|
21
24
|
export type ScriptEditorEvents = typeof __propDef.events;
|
|
22
25
|
export type ScriptEditorSlots = typeof __propDef.slots;
|
|
23
26
|
export default class ScriptEditor extends SvelteComponentTyped<ScriptEditorProps, ScriptEditorEvents, ScriptEditorSlots> {
|
|
27
|
+
get inferSchema(): (code: string, nlang?: "deno" | "python3" | "go" | "bash" | undefined) => Promise<void>;
|
|
24
28
|
}
|
|
25
29
|
export {};
|