windmill-components 1.13.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/LICENSE +661 -0
- package/common.d.ts +29 -0
- package/components/ArgInfo.svelte +48 -0
- package/components/ArgInput.svelte +277 -0
- package/components/AutosizedTextarea.svelte +34 -0
- package/components/Badge.svelte +12 -0
- package/components/Button.svelte +82 -0
- package/components/ButtonAndDropdown.svelte +25 -0
- package/components/CenteredPage.svelte +5 -0
- package/components/ChevronButton.svelte +21 -0
- package/components/DisplayResult.svelte +101 -0
- package/components/Dropdown.svelte +108 -0
- package/components/Editor.svelte +370 -0
- package/components/FieldHeader.svelte +21 -0
- package/components/FlowBuilder.svelte +202 -0
- package/components/FlowEditor.svelte +95 -0
- package/components/FlowPreview.svelte +141 -0
- package/components/FlowStatusViewer.svelte +137 -0
- package/components/GroupModal.svelte +90 -0
- package/components/IconedResourceType.svelte +32 -0
- package/components/InviteGlobalUser.svelte +56 -0
- package/components/InviteUser.svelte +48 -0
- package/components/ItemPicker.svelte +58 -0
- package/components/JobStatus.svelte +38 -0
- package/components/Modal.svelte +94 -0
- package/components/ModuleStep.svelte +64 -0
- package/components/Multiselect.svelte +327 -0
- package/components/ObjectResourceInput.svelte +62 -0
- package/components/ObjectTypeNarrowing.svelte +25 -0
- package/components/PageHeader.svelte +29 -0
- package/components/Password.svelte +45 -0
- package/components/Path.svelte +129 -0
- package/components/RadioButton.svelte +117 -0
- package/components/Required.svelte +11 -0
- package/components/ResourceEditor.svelte +260 -0
- package/components/ResourcePicker.svelte +21 -0
- package/components/ResourceTypePicker.svelte +71 -0
- package/components/RunForm.svelte +127 -0
- package/components/SchemaEditor.svelte +221 -0
- package/components/SchemaForm.svelte +166 -0
- package/components/SchemaModal.svelte +160 -0
- package/components/SchemaViewer.svelte +76 -0
- package/components/ScriptBuilder.svelte +293 -0
- package/components/ScriptEditor.svelte +669 -0
- package/components/ScriptPicker.svelte +110 -0
- package/components/ScriptSchema.svelte +71 -0
- package/components/ShareModal.svelte +135 -0
- package/components/SharedBadge.svelte +54 -0
- package/components/StringTypeNarrowing.svelte +101 -0
- package/components/Switch.svelte +61 -0
- package/components/TableCustom.svelte +39 -0
- package/components/TableSimple.svelte +66 -0
- package/components/Tabs.svelte +21 -0
- package/components/Tooltip.svelte +93 -0
- package/components/VariableEditor.svelte +159 -0
- package/components/icons/DbIcon.svelte +12 -0
- package/components/icons/Mail.svelte +62 -0
- package/components/icons/Mysql.svelte +77 -0
- package/components/icons/PostgresIcon.svelte +57 -0
- package/components/icons/Slack.svelte +26 -0
- package/gen/core/ApiError.d.ts +8 -0
- package/gen/core/ApiRequestOptions.d.ts +13 -0
- package/gen/core/ApiResult.d.ts +7 -0
- package/gen/core/CancelablePromise.d.ts +26 -0
- package/gen/core/OpenAPI.d.ts +16 -0
- package/gen/core/request.d.ts +13 -0
- package/gen/index.d.ts +59 -0
- package/gen/models/AuditLog.d.ts +32 -0
- package/gen/models/CompletedJob.d.ts +48 -0
- package/gen/models/ContextualVariable.d.ts +5 -0
- package/gen/models/CreateResource.d.ts +6 -0
- package/gen/models/CreateVariable.d.ts +6 -0
- package/gen/models/CreateWorkspace.d.ts +6 -0
- package/gen/models/EditResource.d.ts +5 -0
- package/gen/models/EditResourceType.d.ts +4 -0
- package/gen/models/EditSchedule.d.ts +7 -0
- package/gen/models/EditVariable.d.ts +6 -0
- package/gen/models/EditWorkspaceUser.d.ts +3 -0
- package/gen/models/Flow.d.ts +13 -0
- package/gen/models/FlowModule.d.ts +6 -0
- package/gen/models/FlowModuleValue.d.ts +10 -0
- package/gen/models/FlowPreview.d.ts +7 -0
- package/gen/models/FlowStatus.d.ts +6 -0
- package/gen/models/FlowStatusModule.d.ts +15 -0
- package/gen/models/FlowValue.d.ts +5 -0
- package/gen/models/GlobalUserInfo.d.ts +14 -0
- package/gen/models/Group.d.ts +6 -0
- package/gen/models/InputTransform.d.ts +12 -0
- package/gen/models/Job.d.ts +11 -0
- package/gen/models/ListableVariable.d.ts +8 -0
- package/gen/models/Login.d.ts +4 -0
- package/gen/models/MainArgSignature.d.ts +14 -0
- package/gen/models/NewSchedule.d.ts +9 -0
- package/gen/models/NewToken.d.ts +4 -0
- package/gen/models/NewUser.d.ts +5 -0
- package/gen/models/Preview.d.ts +13 -0
- package/gen/models/QueuedJob.d.ts +47 -0
- package/gen/models/Resource.d.ts +8 -0
- package/gen/models/ResourceType.d.ts +6 -0
- package/gen/models/Schedule.d.ts +13 -0
- package/gen/models/Script.d.ts +29 -0
- package/gen/models/ScriptArgs.d.ts +1 -0
- package/gen/models/TruncatedToken.d.ts +7 -0
- package/gen/models/User.d.ts +10 -0
- package/gen/models/UserWorkspaceList.d.ts +8 -0
- package/gen/models/WorkerPing.d.ts +8 -0
- package/gen/models/Workspace.d.ts +6 -0
- package/gen/models/WorkspaceInvite.d.ts +5 -0
- package/gen/services/AdminService.d.ts +35 -0
- package/gen/services/AuditService.d.ts +37 -0
- package/gen/services/FlowService.d.ts +82 -0
- package/gen/services/GranularAclService.d.ts +42 -0
- package/gen/services/GroupService.d.ts +94 -0
- package/gen/services/JobService.d.ts +217 -0
- package/gen/services/ResourceService.d.ts +116 -0
- package/gen/services/ScheduleService.d.ts +73 -0
- package/gen/services/ScriptService.d.ts +165 -0
- package/gen/services/SettingsService.d.ts +15 -0
- package/gen/services/UserService.d.ts +211 -0
- package/gen/services/VariableService.d.ts +66 -0
- package/gen/services/WorkerService.d.ts +15 -0
- package/gen/services/WorkspaceService.d.ts +137 -0
- package/infer.d.ts +2 -0
- package/lib/components/ArgInfo.svelte.d.ts +16 -0
- package/lib/components/ArgInput.svelte.d.ts +37 -0
- package/lib/components/AutosizedTextarea.svelte.d.ts +19 -0
- package/lib/components/Badge.svelte.d.ts +20 -0
- package/lib/components/Button.svelte.d.ts +23 -0
- package/lib/components/ButtonAndDropdown.svelte.d.ts +23 -0
- package/lib/components/CenteredPage.svelte.d.ts +23 -0
- package/lib/components/ChevronButton.svelte.d.ts +19 -0
- package/lib/components/DisplayResult.svelte.d.ts +16 -0
- package/lib/components/Dropdown.svelte.d.ts +22 -0
- package/lib/components/Editor.svelte.d.ts +38 -0
- package/lib/components/FieldHeader.svelte.d.ts +23 -0
- package/lib/components/FlowBuilder.svelte.d.ts +18 -0
- package/lib/components/FlowEditor.svelte.d.ts +19 -0
- package/lib/components/FlowPreview.svelte.d.ts +21 -0
- package/lib/components/FlowStatusViewer.svelte.d.ts +18 -0
- package/lib/components/GroupModal.svelte.d.ts +17 -0
- package/lib/components/IconedResourceType.svelte.d.ts +19 -0
- package/lib/components/InviteGlobalUser.svelte.d.ts +19 -0
- package/lib/components/InviteUser.svelte.d.ts +19 -0
- package/lib/components/ItemPicker.svelte.d.ts +24 -0
- package/lib/components/JobStatus.svelte.d.ts +17 -0
- package/lib/components/Modal.svelte.d.ts +28 -0
- package/lib/components/ModuleStep.svelte.d.ts +26 -0
- package/lib/components/Multiselect.svelte.d.ts +33 -0
- package/lib/components/ObjectResourceInput.svelte.d.ts +17 -0
- package/lib/components/ObjectTypeNarrowing.svelte.d.ts +16 -0
- package/lib/components/PageHeader.svelte.d.ts +20 -0
- package/lib/components/Password.svelte.d.ts +18 -0
- package/lib/components/Path.svelte.d.ts +26 -0
- package/lib/components/RadioButton.svelte.d.ts +21 -0
- package/lib/components/Required.svelte.d.ts +17 -0
- package/lib/components/ResourceEditor.svelte.d.ts +22 -0
- package/lib/components/ResourcePicker.svelte.d.ts +17 -0
- package/lib/components/ResourceTypePicker.svelte.d.ts +19 -0
- package/lib/components/RunForm.svelte.d.ts +22 -0
- package/lib/components/SchemaEditor.svelte.d.ts +22 -0
- package/lib/components/SchemaForm.svelte.d.ts +23 -0
- package/lib/components/SchemaModal.svelte.d.ts +44 -0
- package/lib/components/SchemaViewer.svelte.d.ts +17 -0
- package/lib/components/ScriptBuilder.svelte.d.ts +20 -0
- package/lib/components/ScriptEditor.svelte.d.ts +28 -0
- package/lib/components/ScriptPicker.svelte.d.ts +21 -0
- package/lib/components/ScriptSchema.svelte.d.ts +22 -0
- package/lib/components/ShareModal.svelte.d.ts +21 -0
- package/lib/components/SharedBadge.svelte.d.ts +17 -0
- package/lib/components/StringTypeNarrowing.svelte.d.ts +18 -0
- package/lib/components/Switch.svelte.d.ts +31 -0
- package/lib/components/TableCustom.svelte.d.ts +25 -0
- package/lib/components/TableSimple.svelte.d.ts +24 -0
- package/lib/components/Tabs.svelte.d.ts +20 -0
- package/lib/components/Tooltip.svelte.d.ts +20 -0
- package/lib/components/VariableEditor.svelte.d.ts +21 -0
- package/lib/components/icons/DbIcon.svelte.d.ts +17 -0
- package/lib/components/icons/Mail.svelte.d.ts +17 -0
- package/lib/components/icons/Mysql.svelte.d.ts +17 -0
- package/lib/components/icons/PostgresIcon.svelte.d.ts +17 -0
- package/lib/components/icons/Slack.svelte.d.ts +17 -0
- package/package.json +110 -0
- package/stores.d.ts +19 -0
- package/utils.d.ts +60 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<script>import { clickOutside } from '../../utils';
|
|
2
|
+
import { createEventDispatcher } from 'svelte';
|
|
3
|
+
import Icon from 'svelte-awesome';
|
|
4
|
+
import { faEllipsisH } from '@fortawesome/free-solid-svg-icons';
|
|
5
|
+
let open = false;
|
|
6
|
+
export let dropdownItems;
|
|
7
|
+
export let name = undefined;
|
|
8
|
+
// The dropdown is positioned versus its first relatively positioned partent
|
|
9
|
+
// By default, the dropdown is positioned relative to its button
|
|
10
|
+
// This can cause the dropdown to be hidden if it is in an overflow-hidden div.
|
|
11
|
+
// In that case, set relative to false and control the dropdown positioning from the div
|
|
12
|
+
export let relative = true;
|
|
13
|
+
const dispatch = createEventDispatcher();
|
|
14
|
+
function openMenu() {
|
|
15
|
+
open = true;
|
|
16
|
+
}
|
|
17
|
+
function handleClickOutsideMenu(event) {
|
|
18
|
+
open = false;
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div
|
|
23
|
+
class="ml-3 {relative ? 'relative' : ''} {$$props.class}"
|
|
24
|
+
use:clickOutside
|
|
25
|
+
on:click_outside={handleClickOutsideMenu}
|
|
26
|
+
>
|
|
27
|
+
<button
|
|
28
|
+
class="text-blue-500 text-right "
|
|
29
|
+
id="dropdown"
|
|
30
|
+
aria-expanded="false"
|
|
31
|
+
aria-haspopup="true"
|
|
32
|
+
on:click={openMenu}
|
|
33
|
+
>
|
|
34
|
+
{#if !name}
|
|
35
|
+
<Icon data={faEllipsisH} scale={1.2} />
|
|
36
|
+
{:else}
|
|
37
|
+
{name}
|
|
38
|
+
{/if}
|
|
39
|
+
</button>
|
|
40
|
+
<div
|
|
41
|
+
class="flex flex-col z-50 origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white ring-1 ring-black ring-opacity-5 focus:outline-none {open
|
|
42
|
+
? 'visible'
|
|
43
|
+
: 'hidden'}"
|
|
44
|
+
role="menu"
|
|
45
|
+
tabindex="-1"
|
|
46
|
+
>
|
|
47
|
+
{#if dropdownItems}
|
|
48
|
+
{#each dropdownItems as item, i}
|
|
49
|
+
{#if item.action}
|
|
50
|
+
<button
|
|
51
|
+
on:click={() => {
|
|
52
|
+
if (!item.disabled) {
|
|
53
|
+
open = false
|
|
54
|
+
item.action && item.action()
|
|
55
|
+
dispatch('click', { item: item?.eventName })
|
|
56
|
+
}
|
|
57
|
+
}}
|
|
58
|
+
class="block hover:drop-shadow-sm hover:bg-gray-50 hover:bg-opacity-30 px-4 py-2 text-sm text-gray-700 text-left{item.separatorTop
|
|
59
|
+
? 'border-t'
|
|
60
|
+
: ''} {item.separatorBottom ? 'border-b' : ''} {item.type == 'delete'
|
|
61
|
+
? 'text-red-500'
|
|
62
|
+
: ''}"
|
|
63
|
+
role="menuitem"
|
|
64
|
+
tabindex="-1"
|
|
65
|
+
id="user-menu-item-{name}-{i}}"
|
|
66
|
+
disabled={item.disabled}
|
|
67
|
+
class:disabled={item.disabled}
|
|
68
|
+
>
|
|
69
|
+
{#if item.icon}
|
|
70
|
+
<Icon
|
|
71
|
+
data={item.icon}
|
|
72
|
+
scale={0.6}
|
|
73
|
+
class="inline mr-2 {item.type == 'delete' ? 'text-red-500' : 'text-gray-700'}"
|
|
74
|
+
/>
|
|
75
|
+
{/if}{item.displayName}
|
|
76
|
+
</button>
|
|
77
|
+
{:else if item.href}
|
|
78
|
+
<a
|
|
79
|
+
href={item.href}
|
|
80
|
+
on:click={() => {
|
|
81
|
+
if (!item.disabled) {
|
|
82
|
+
open = false
|
|
83
|
+
}
|
|
84
|
+
}}
|
|
85
|
+
class="block px-4 py-2 text-sm text-gray-700 hover:drop-shadow-sm hover:bg-gray-50 hover:bg-opacity-30"
|
|
86
|
+
role="menuitem"
|
|
87
|
+
tabindex="-1"
|
|
88
|
+
id="user-menu-item-{name}-{i}}"
|
|
89
|
+
class:disabled={item.disabled}
|
|
90
|
+
>{#if item.icon}
|
|
91
|
+
<Icon
|
|
92
|
+
data={item.icon}
|
|
93
|
+
scale={0.6}
|
|
94
|
+
class="inline mr-2 {item.type == 'delete' ? 'text-red-500' : 'text-gray-700'}"
|
|
95
|
+
/>
|
|
96
|
+
{/if}{item.displayName}</a
|
|
97
|
+
>
|
|
98
|
+
{:else}
|
|
99
|
+
<span
|
|
100
|
+
class="block px-4 py-2 text-sm text-gray-700"
|
|
101
|
+
role="menuitem"
|
|
102
|
+
tabindex="-1"
|
|
103
|
+
id="user-menu-item-{name}-{i}}">{item.displayName}</span
|
|
104
|
+
>{/if}
|
|
105
|
+
{/each}
|
|
106
|
+
{/if}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
<script>import { page } from '$app/stores';
|
|
2
|
+
import { browser } from '$app/env';
|
|
3
|
+
import { RequestType, toSocket, WebSocketMessageReader, WebSocketMessageWriter } from '@codingame/monaco-jsonrpc';
|
|
4
|
+
import { onDestroy, onMount } from 'svelte';
|
|
5
|
+
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
|
6
|
+
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
|
7
|
+
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
|
8
|
+
import * as vscode from 'vscode';
|
|
9
|
+
let divEl = null;
|
|
10
|
+
let editor;
|
|
11
|
+
export let deno = false;
|
|
12
|
+
export let lang = deno ? 'typescript' : 'python';
|
|
13
|
+
export let code;
|
|
14
|
+
export let hash = (Math.random() + 1).toString(36).substring(2);
|
|
15
|
+
export let cmdEnterAction = undefined;
|
|
16
|
+
export let formatAction = undefined;
|
|
17
|
+
export let automaticLayout = true;
|
|
18
|
+
export let websocketAlive = { pyright: false, black: false, deno: false };
|
|
19
|
+
let websockets = [];
|
|
20
|
+
let uri = '';
|
|
21
|
+
let disposeMethod;
|
|
22
|
+
if (browser) {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
self.MonacoEnvironment = {
|
|
25
|
+
getWorker: function (_moduleId, label) {
|
|
26
|
+
if (label === 'json') {
|
|
27
|
+
return new jsonWorker();
|
|
28
|
+
}
|
|
29
|
+
else if (label === 'typescript' || label === 'javascript') {
|
|
30
|
+
return new tsWorker();
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return new editorWorker();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function getCode() {
|
|
39
|
+
return editor?.getValue();
|
|
40
|
+
}
|
|
41
|
+
export function insertAtCursor(code) {
|
|
42
|
+
if (editor) {
|
|
43
|
+
editor.trigger('keyboard', 'type', { text: code });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function insertAtBeginning(code) {
|
|
47
|
+
if (editor) {
|
|
48
|
+
const range = { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 };
|
|
49
|
+
const op = { range: range, text: code, forceMoveMarkers: true };
|
|
50
|
+
editor.executeEdits('external', [op]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function setCode(ncode) {
|
|
54
|
+
if (editor) {
|
|
55
|
+
return editor.setValue(ncode);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
code = ncode;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function format() {
|
|
62
|
+
if (editor) {
|
|
63
|
+
editor.getAction('editor.action.formatDocument').run();
|
|
64
|
+
if (formatAction) {
|
|
65
|
+
formatAction();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export async function reloadWebsocket() {
|
|
70
|
+
closeWebsockets();
|
|
71
|
+
if (lang == 'python' || deno) {
|
|
72
|
+
// install Monaco language client services
|
|
73
|
+
const { MonacoLanguageClient } = await import('monaco-languageclient');
|
|
74
|
+
const { CloseAction, ErrorAction } = await import('vscode-languageclient');
|
|
75
|
+
function createLanguageClient(transports, name, initializationOptions) {
|
|
76
|
+
const client = new MonacoLanguageClient({
|
|
77
|
+
name: name,
|
|
78
|
+
clientOptions: {
|
|
79
|
+
documentSelector: deno ? ['typescript'] : ['python'],
|
|
80
|
+
errorHandler: {
|
|
81
|
+
error: () => ({ action: ErrorAction.Shutdown }),
|
|
82
|
+
closed: () => ({
|
|
83
|
+
action: CloseAction.Restart
|
|
84
|
+
})
|
|
85
|
+
},
|
|
86
|
+
markdown: {
|
|
87
|
+
isTrusted: true
|
|
88
|
+
},
|
|
89
|
+
// workspaceFolder: { uri: Uri.parse(`/tmp/${name}`), name: 'tmp', index: 0 },
|
|
90
|
+
initializationOptions,
|
|
91
|
+
middleware: {
|
|
92
|
+
workspace: {
|
|
93
|
+
configuration: (params, token, configuration) => {
|
|
94
|
+
return [
|
|
95
|
+
{
|
|
96
|
+
enable: true
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
connectionProvider: {
|
|
104
|
+
get: () => {
|
|
105
|
+
return Promise.resolve(transports);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return client;
|
|
110
|
+
}
|
|
111
|
+
async function connectToLanguageServer(url, name, options) {
|
|
112
|
+
try {
|
|
113
|
+
const webSocket = new WebSocket(url);
|
|
114
|
+
webSocket.onopen = () => {
|
|
115
|
+
websockets.push(webSocket);
|
|
116
|
+
const socket = toSocket(webSocket);
|
|
117
|
+
const reader = new WebSocketMessageReader(socket);
|
|
118
|
+
const writer = new WebSocketMessageWriter(socket);
|
|
119
|
+
const languageClient = createLanguageClient({ reader, writer }, name, options);
|
|
120
|
+
languageClient.start();
|
|
121
|
+
socket.onClose((_code, _reason) => {
|
|
122
|
+
websocketAlive[name] = false;
|
|
123
|
+
});
|
|
124
|
+
vscode.commands.registerCommand('deno.cache', (uris = []) => {
|
|
125
|
+
languageClient.sendRequest(new RequestType('deno/cache'), {
|
|
126
|
+
referrer: { uri },
|
|
127
|
+
uris: uris.map((uri) => ({ uri }))
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
websocketAlive[name] = true;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
console.error(`connection to ${name} language server failed`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (deno) {
|
|
138
|
+
await connectToLanguageServer(`wss://${$page.url.host}/ws/deno`, 'deno', {
|
|
139
|
+
certificateStores: null,
|
|
140
|
+
enablePaths: [],
|
|
141
|
+
config: null,
|
|
142
|
+
importMap: null,
|
|
143
|
+
internalDebug: false,
|
|
144
|
+
lint: false,
|
|
145
|
+
path: null,
|
|
146
|
+
tlsCertificate: null,
|
|
147
|
+
unsafelyIgnoreCertificateErrors: null,
|
|
148
|
+
unstable: false,
|
|
149
|
+
enable: true,
|
|
150
|
+
cache: null,
|
|
151
|
+
codeLens: {
|
|
152
|
+
implementations: true,
|
|
153
|
+
references: true
|
|
154
|
+
},
|
|
155
|
+
suggest: {
|
|
156
|
+
autoImports: true,
|
|
157
|
+
completeFunctionCalls: false,
|
|
158
|
+
names: true,
|
|
159
|
+
paths: true,
|
|
160
|
+
imports: {
|
|
161
|
+
autoDiscover: true,
|
|
162
|
+
hosts: {
|
|
163
|
+
'https://deno.land': true
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
await connectToLanguageServer(`wss://${$page.url.host}/ws/pyright`, 'pyright', {
|
|
171
|
+
executionEnvironments: [
|
|
172
|
+
{
|
|
173
|
+
root: '/tmp/pyright',
|
|
174
|
+
pythonVersion: '3.7',
|
|
175
|
+
pythonPlatform: 'platform',
|
|
176
|
+
extraPaths: []
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
});
|
|
180
|
+
connectToLanguageServer(`wss://${$page.url.host}/ws/black`, 'black', {
|
|
181
|
+
formatters: {
|
|
182
|
+
black: {
|
|
183
|
+
command: 'black',
|
|
184
|
+
args: ['--quiet', '-']
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
formatFiletypes: {
|
|
188
|
+
python: 'black'
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function closeWebsockets() {
|
|
195
|
+
for (const x of websockets) {
|
|
196
|
+
try {
|
|
197
|
+
x.close();
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
console.log('error disposing websocket', err);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
websockets = [];
|
|
204
|
+
}
|
|
205
|
+
async function loadMonaco() {
|
|
206
|
+
const monaco = await import('monaco-editor');
|
|
207
|
+
if (lang == 'python') {
|
|
208
|
+
monaco.languages.register({
|
|
209
|
+
id: 'python',
|
|
210
|
+
extensions: ['.py'],
|
|
211
|
+
aliases: ['python'],
|
|
212
|
+
mimetypes: ['application/text']
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
let path = 'unknown';
|
|
216
|
+
if (lang == 'python') {
|
|
217
|
+
path = `${hash}.py`;
|
|
218
|
+
}
|
|
219
|
+
else if (lang == 'json') {
|
|
220
|
+
path = `${hash}.json`;
|
|
221
|
+
}
|
|
222
|
+
else if (lang == 'javascript') {
|
|
223
|
+
path = `${hash}.js`;
|
|
224
|
+
}
|
|
225
|
+
else if (lang == 'typescript') {
|
|
226
|
+
path = `${hash}.ts`;
|
|
227
|
+
}
|
|
228
|
+
uri = `file:///${path}`;
|
|
229
|
+
const model = monaco.editor.createModel(code, lang, monaco.Uri.parse(uri));
|
|
230
|
+
model.updateOptions({ tabSize: 4, insertSpaces: true });
|
|
231
|
+
editor = monaco.editor.create(divEl, {
|
|
232
|
+
model: model,
|
|
233
|
+
value: code,
|
|
234
|
+
language: lang,
|
|
235
|
+
automaticLayout,
|
|
236
|
+
readOnly: false,
|
|
237
|
+
autoDetectHighContrast: true,
|
|
238
|
+
//lineNumbers: 'off',
|
|
239
|
+
//lineDecorationsWidth: 0,
|
|
240
|
+
lineNumbersMinChars: 4,
|
|
241
|
+
lineNumbers: (ln) => '<span class="pr-4 text-gray-400">' + ln + '</span>',
|
|
242
|
+
folding: false,
|
|
243
|
+
scrollBeyondLastLine: false,
|
|
244
|
+
minimap: {
|
|
245
|
+
enabled: false
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
|
|
249
|
+
format();
|
|
250
|
+
});
|
|
251
|
+
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, function () {
|
|
252
|
+
if (cmdEnterAction) {
|
|
253
|
+
cmdEnterAction();
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
editor.onDidChangeModelContent((event) => {
|
|
257
|
+
code = getCode();
|
|
258
|
+
});
|
|
259
|
+
if (lang == 'json') {
|
|
260
|
+
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
261
|
+
validate: true,
|
|
262
|
+
allowComments: false,
|
|
263
|
+
schemas: [],
|
|
264
|
+
enableSchemaRequest: true
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
if (lang == 'typescript') {
|
|
268
|
+
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
269
|
+
target: monaco.languages.typescript.ScriptTarget.Latest,
|
|
270
|
+
allowNonTsExtensions: true,
|
|
271
|
+
noLib: true
|
|
272
|
+
});
|
|
273
|
+
if (deno) {
|
|
274
|
+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
275
|
+
noSemanticValidation: true,
|
|
276
|
+
noSuggestionDiagnostics: true,
|
|
277
|
+
noSyntaxValidation: true
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
monaco.languages.typescript.typescriptDefaults.addExtraLib(`
|
|
282
|
+
/**
|
|
283
|
+
* get variable (including secret) at path
|
|
284
|
+
* @param {string} path - path of the variable (e.g: g/all/pretty_secret)
|
|
285
|
+
*/
|
|
286
|
+
export function variable(path: string): string;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* get resource at path
|
|
290
|
+
* @param {string} path - path of the resource (e.g: g/all/my_resource)
|
|
291
|
+
*/
|
|
292
|
+
export function resource(path: string): any;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* get result of step n.
|
|
296
|
+
* If n is negative, for instance -1, it is the step just before this one.
|
|
297
|
+
* Step 0 is flow input.
|
|
298
|
+
* @param {number} n - step number.
|
|
299
|
+
*/
|
|
300
|
+
export function step(n: number): any;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* flow input as an object
|
|
304
|
+
*/
|
|
305
|
+
export const flow_input: any;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* previous result as an object
|
|
309
|
+
*/
|
|
310
|
+
export const previous_result: any;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* static params of this same step
|
|
314
|
+
*/
|
|
315
|
+
export const params: any;
|
|
316
|
+
`, 'file:///node_modules/@types/windmill/index.d.ts');
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (lang == 'python' || deno) {
|
|
320
|
+
const { MonacoServices } = await import('monaco-languageclient');
|
|
321
|
+
MonacoServices.install(monaco);
|
|
322
|
+
}
|
|
323
|
+
reloadWebsocket();
|
|
324
|
+
return () => {
|
|
325
|
+
if (editor) {
|
|
326
|
+
try {
|
|
327
|
+
closeWebsockets();
|
|
328
|
+
editor.dispose();
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
console.log('error disposing editor', err);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
onMount(() => {
|
|
337
|
+
if (browser) {
|
|
338
|
+
loadMonaco().then((x) => (disposeMethod = x));
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
onDestroy(() => {
|
|
342
|
+
if (disposeMethod) {
|
|
343
|
+
disposeMethod();
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
</script>
|
|
347
|
+
|
|
348
|
+
<!-- <button class="default-button px-6 max-h-8" type="button" on:click={format}>
|
|
349
|
+
Format (CtrlCmd + S)
|
|
350
|
+
</button> -->
|
|
351
|
+
|
|
352
|
+
<div bind:this={divEl} class={$$props.class} />
|
|
353
|
+
|
|
354
|
+
<style>
|
|
355
|
+
.editor {
|
|
356
|
+
padding-left: 0px;
|
|
357
|
+
padding-right: 0px;
|
|
358
|
+
/* stylelint-disable-next-line unit-allowed-list */
|
|
359
|
+
height: 80vh;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.small-editor {
|
|
363
|
+
/* stylelint-disable-next-line unit-allowed-list */
|
|
364
|
+
height: 26vh;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.few-lines-editor {
|
|
368
|
+
/* stylelint-disable-next-line unit-allowed-list */
|
|
369
|
+
height: 80px;
|
|
370
|
+
}</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>import Required from './Required.svelte';
|
|
2
|
+
export let label;
|
|
3
|
+
export let format = '';
|
|
4
|
+
export let contentEncoding = '';
|
|
5
|
+
export let type = undefined;
|
|
6
|
+
export let required = false;
|
|
7
|
+
export let itemsType = undefined;
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<h3>
|
|
11
|
+
<span class="font-semibold">
|
|
12
|
+
{label}<Required {required} />
|
|
13
|
+
</span>
|
|
14
|
+
<span class="text-sm italic text-indigo-800"
|
|
15
|
+
>({type ?? 'any'}{contentEncoding && contentEncoding != ''
|
|
16
|
+
? `, encoding: ${contentEncoding}`
|
|
17
|
+
: ''}{format && format != '' ? `, format: ${format}` : ''}{itemsType?.type
|
|
18
|
+
? ` of ${itemsType?.type}s`
|
|
19
|
+
: ''})</span
|
|
20
|
+
>
|
|
21
|
+
</h3>
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
<script>import { FlowService } from '../../gen';
|
|
2
|
+
import { sendUserToast } from '../../utils';
|
|
3
|
+
import { page } from '$app/stores';
|
|
4
|
+
import { goto } from '$app/navigation';
|
|
5
|
+
import Path from './Path.svelte';
|
|
6
|
+
import SvelteMarkdown from 'svelte-markdown';
|
|
7
|
+
import { workspaceStore } from '../../stores';
|
|
8
|
+
import ScriptSchema from './ScriptSchema.svelte';
|
|
9
|
+
import Required from './Required.svelte';
|
|
10
|
+
import FlowEditor from './FlowEditor.svelte';
|
|
11
|
+
export let flow;
|
|
12
|
+
export let initialPath = '';
|
|
13
|
+
$: step = Number($page.url.searchParams.get('step')) || 1;
|
|
14
|
+
async function saveFlow() {
|
|
15
|
+
try {
|
|
16
|
+
if (initialPath == '') {
|
|
17
|
+
await FlowService.createFlow({
|
|
18
|
+
workspace: $workspaceStore,
|
|
19
|
+
requestBody: {
|
|
20
|
+
path: flow.path,
|
|
21
|
+
summary: flow.summary,
|
|
22
|
+
description: flow.description ?? '',
|
|
23
|
+
value: flow.value,
|
|
24
|
+
schema: flow.schema
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
await FlowService.updateFlow({
|
|
30
|
+
workspace: $workspaceStore,
|
|
31
|
+
path: initialPath,
|
|
32
|
+
requestBody: {
|
|
33
|
+
path: flow.path,
|
|
34
|
+
summary: flow.summary,
|
|
35
|
+
description: flow.description ?? '',
|
|
36
|
+
value: flow.value,
|
|
37
|
+
schema: flow.schema
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
sendUserToast(`Success! flow saved at ${flow.path}`);
|
|
42
|
+
goto(`/flows/get/${flow.path}`);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (error.status === 400) {
|
|
46
|
+
sendUserToast(error.body, true);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
sendUserToast(`Ooops.Something bad happened: ${error}`, true);
|
|
50
|
+
console.error(error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function inferSchema() {
|
|
55
|
+
//await inferArgs(flow.content, flow.schema);
|
|
56
|
+
}
|
|
57
|
+
async function changeStep(step) {
|
|
58
|
+
goto(`?step=${step}`);
|
|
59
|
+
}
|
|
60
|
+
$: {
|
|
61
|
+
$page.url.searchParams.set('state', btoa(JSON.stringify(flow)));
|
|
62
|
+
history.replaceState({}, '', $page.url);
|
|
63
|
+
}
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<div class="flex flex-col h-screen max-w-screen-lg xl:-ml-20 xl:pl-4 w-full -mt-4 pt-4 md:mx-10 ">
|
|
67
|
+
<!-- Nav between steps-->
|
|
68
|
+
<div class="flex flex-col w-full">
|
|
69
|
+
<div class="justify-between flex flex-row drop-shadow-sm w-full">
|
|
70
|
+
<div class="wizard-nav flex flex-row w-full">
|
|
71
|
+
<button
|
|
72
|
+
class="{step === 1
|
|
73
|
+
? 'default-button-disabled text-gray-700'
|
|
74
|
+
: 'default-button-secondary'} min-w-max ml-2"
|
|
75
|
+
on:click={() => {
|
|
76
|
+
changeStep(1)
|
|
77
|
+
}}>Step 1: Metadata</button
|
|
78
|
+
>
|
|
79
|
+
<button
|
|
80
|
+
class="{step === 2
|
|
81
|
+
? 'default-button-disabled text-gray-700'
|
|
82
|
+
: 'default-button-secondary'} min-w-max ml-2"
|
|
83
|
+
on:click={() => {
|
|
84
|
+
changeStep(2)
|
|
85
|
+
}}>Step 2: Flow</button
|
|
86
|
+
>
|
|
87
|
+
<button
|
|
88
|
+
class="{step === 3
|
|
89
|
+
? 'default-button-disabled text-gray-700'
|
|
90
|
+
: 'default-button-secondary'} min-w-max ml-2"
|
|
91
|
+
on:click={() => {
|
|
92
|
+
changeStep(3)
|
|
93
|
+
}}>Step 3: UI customisation</button
|
|
94
|
+
>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="flex flex-row-reverse ml-2">
|
|
97
|
+
{#if step != 3}
|
|
98
|
+
<button
|
|
99
|
+
disabled={step == 1 &&
|
|
100
|
+
(flow.path == undefined || flow.path == '' || flow.path.split('/')[2] == '')}
|
|
101
|
+
class="default-button px-6 max-h-8"
|
|
102
|
+
on:click={() => {
|
|
103
|
+
changeStep(step + 1)
|
|
104
|
+
}}>Next</button
|
|
105
|
+
>
|
|
106
|
+
{#if step == 2}
|
|
107
|
+
<button class="default-button-secondary px-6 max-h-8 mr-2" on:click={saveFlow}
|
|
108
|
+
>Save</button
|
|
109
|
+
>
|
|
110
|
+
{/if}
|
|
111
|
+
{:else}
|
|
112
|
+
<button class="default-button px-6 self-end" on:click={saveFlow}>Save</button>
|
|
113
|
+
{/if}
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="flex flex-row-reverse">
|
|
117
|
+
<span class="my-1 text-sm text-gray-500 italic">
|
|
118
|
+
{#if initialPath && initialPath != flow.path} {initialPath} → {/if}
|
|
119
|
+
{flow.path}
|
|
120
|
+
</span>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<!-- metadata -->
|
|
125
|
+
{#if step === 1}
|
|
126
|
+
<div class="grid grid-cols-1 gap-6 max-w-7xl">
|
|
127
|
+
<Path bind:path={flow.path} {initialPath} namePlaceholder="example/my/flow">
|
|
128
|
+
<div slot="ownerToolkit" class="text-gray-700 text-2xs">
|
|
129
|
+
Flow permissions depend on their path. Select the group <span class="font-mono">all</span>
|
|
130
|
+
to share your flow, and <span class="font-mono">user</span> to keep it private.
|
|
131
|
+
<a href="https://docs.windmill.dev/docs/reference/namespaces">docs</a>
|
|
132
|
+
</div>
|
|
133
|
+
</Path>
|
|
134
|
+
<h3 class="text-gray-700 pb-1 border-b">Metadata</h3>
|
|
135
|
+
|
|
136
|
+
<label class="block ">
|
|
137
|
+
<span class="text-gray-700">Summary <Required required={false} /></span>
|
|
138
|
+
<textarea
|
|
139
|
+
bind:value={flow.summary}
|
|
140
|
+
class="
|
|
141
|
+
mt-1
|
|
142
|
+
block
|
|
143
|
+
w-full
|
|
144
|
+
rounded-md
|
|
145
|
+
border-gray-300
|
|
146
|
+
shadow-sm
|
|
147
|
+
focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
|
|
148
|
+
"
|
|
149
|
+
placeholder="A very short summary of the flow displayed when the flow is listed"
|
|
150
|
+
rows="1"
|
|
151
|
+
/>
|
|
152
|
+
</label>
|
|
153
|
+
<label class="block ">
|
|
154
|
+
<span class="text-gray-700"
|
|
155
|
+
>Description<Required required={false} detail="accept markdown formatting" />
|
|
156
|
+
<textarea
|
|
157
|
+
bind:value={flow.description}
|
|
158
|
+
class="
|
|
159
|
+
mt-1
|
|
160
|
+
block
|
|
161
|
+
w-full
|
|
162
|
+
rounded-md
|
|
163
|
+
border-gray-300
|
|
164
|
+
shadow-sm
|
|
165
|
+
focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
|
|
166
|
+
"
|
|
167
|
+
placeholder="A description to help users understand what this flow does and how to use it."
|
|
168
|
+
rows="3"
|
|
169
|
+
/>
|
|
170
|
+
</span></label
|
|
171
|
+
>
|
|
172
|
+
|
|
173
|
+
<div>
|
|
174
|
+
<h3 class="text-gray-700 ">Description rendered</h3>
|
|
175
|
+
<div
|
|
176
|
+
class="prose mt-5 text-xs shadow-inner shadow-blue p-4 overflow-auto"
|
|
177
|
+
style="max-height: 200px;"
|
|
178
|
+
>
|
|
179
|
+
<SvelteMarkdown source={flow.description ?? ''} />
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
{:else if step === 2}
|
|
184
|
+
<FlowEditor bind:flow />
|
|
185
|
+
{:else if step === 3}
|
|
186
|
+
<ScriptSchema
|
|
187
|
+
synchronizedHeader={false}
|
|
188
|
+
bind:summary={flow.summary}
|
|
189
|
+
bind:description={flow.description}
|
|
190
|
+
bind:schema={flow.schema}
|
|
191
|
+
/>
|
|
192
|
+
{/if}
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<style>
|
|
196
|
+
/* .wizard-nav {
|
|
197
|
+
@apply w-1/2 sm:w-1/4;
|
|
198
|
+
} */
|
|
199
|
+
|
|
200
|
+
.wizard-nav button {
|
|
201
|
+
max-height: 30px;
|
|
202
|
+
}</style>
|