windmill-components 1.13.25 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common.js +1 -5
- package/components/AppConnect.svelte +281 -0
- package/components/AppConnect.svelte.d.ts +22 -0
- package/components/ArgInfo.svelte +11 -16
- package/components/ArgInput.svelte +73 -70
- package/components/ArgInput.svelte.d.ts +6 -1
- package/components/AutosizedTextarea.svelte +6 -8
- package/components/Badge.svelte +4 -10
- package/components/Button.svelte +22 -18
- package/components/ButtonAndDropdown.svelte +6 -12
- package/components/CenteredModal.svelte +30 -0
- package/components/CenteredModal.svelte.d.ts +19 -0
- package/components/ChevronButton.svelte +4 -9
- package/components/DisplayResult.svelte +58 -57
- package/components/Dropdown.svelte +8 -13
- package/components/Editor.svelte +108 -149
- package/components/Editor.svelte.d.ts +3 -1
- package/components/FieldHeader.svelte +7 -12
- package/components/FlowBuilder.svelte +72 -121
- package/components/FlowBuilder.svelte.d.ts +0 -2
- package/components/FlowEditor.svelte +185 -73
- package/components/FlowEditor.svelte.d.ts +4 -4
- package/components/FlowJobResult.svelte +23 -0
- package/components/FlowJobResult.svelte.d.ts +17 -0
- package/components/FlowPreview.svelte +36 -51
- package/components/FlowPreview.svelte.d.ts +7 -1
- package/components/FlowStatusViewer.svelte +66 -40
- package/components/FlowStatusViewer.svelte.d.ts +1 -1
- package/components/FlowViewer.svelte +100 -0
- package/components/FlowViewer.svelte.d.ts +24 -0
- package/components/GroupModal.svelte +13 -20
- package/components/IconedResourceType.svelte +15 -18
- package/components/InviteGlobalUser.svelte +8 -15
- package/components/InviteUser.svelte +9 -16
- package/components/ItemPicker.svelte +11 -14
- package/components/JobStatus.svelte +6 -11
- package/components/Modal.svelte +14 -17
- package/components/ModuleStep.svelte +125 -64
- package/components/ModuleStep.svelte.d.ts +4 -8
- package/components/ObjectResourceInput.svelte +15 -20
- package/components/ObjectTypeNarrowing.svelte +7 -12
- package/components/PageHeader.svelte +4 -9
- package/components/Password.svelte +6 -8
- package/components/Path.svelte +78 -38
- package/components/Path.svelte.d.ts +2 -0
- package/components/RadioButton.svelte +7 -8
- package/components/RadioButtonV2.svelte +33 -0
- package/components/RadioButtonV2.svelte.d.ts +20 -0
- package/components/Required.svelte +2 -4
- package/components/ResourceEditor.svelte +44 -48
- package/components/ResourcePicker.svelte +6 -7
- package/components/ResourcePicker.svelte.d.ts +2 -2
- package/components/ResourceTypePicker.svelte +8 -13
- package/components/RunForm.svelte +15 -20
- package/components/SchemaEditor.svelte +31 -61
- package/components/SchemaForm.svelte +126 -134
- package/components/SchemaForm.svelte.d.ts +6 -4
- package/components/SchemaModal.svelte +25 -40
- package/components/SchemaModal.svelte.d.ts +1 -1
- package/components/SchemaViewer.svelte +6 -12
- package/components/ScriptBuilder.svelte +76 -101
- package/components/ScriptEditor.svelte +55 -60
- package/components/ScriptPicker.svelte +28 -34
- package/components/ScriptPicker.svelte.d.ts +1 -0
- package/components/ScriptSchema.svelte +13 -17
- package/components/ShareModal.svelte +23 -29
- package/components/SharedBadge.svelte +11 -16
- package/components/StringTypeNarrowing.svelte +8 -11
- package/components/Switch.svelte.d.ts +2 -2
- package/components/TableCustom.svelte +5 -8
- package/components/TableSimple.svelte +9 -8
- package/components/Tabs.svelte +6 -8
- package/components/Toggle.svelte +34 -0
- package/components/Toggle.svelte.d.ts +28 -0
- package/components/Tooltip.svelte +56 -89
- package/components/Tooltip.svelte.d.ts +1 -5
- package/components/VariableEditor.svelte +30 -29
- package/components/flows/CopyFirstStepSchema.svelte +10 -0
- package/components/flows/CopyFirstStepSchema.svelte.d.ts +14 -0
- package/components/flows/DynamicInputHelpBox.svelte +72 -0
- package/components/flows/DynamicInputHelpBox.svelte.d.ts +14 -0
- package/components/flows/FlowInputs.svelte +27 -0
- package/components/flows/FlowInputs.svelte.d.ts +19 -0
- package/components/flows/FlowModuleHeader.svelte +91 -0
- package/components/flows/FlowModuleHeader.svelte.d.ts +22 -0
- package/components/flows/flowStore.d.ts +17 -0
- package/components/flows/flowStore.js +161 -0
- package/components/flows/pickers/FlowScriptPicker.svelte +11 -0
- package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +22 -0
- package/components/flows/pickers/PickHubScript.svelte +30 -0
- package/components/flows/pickers/PickHubScript.svelte.d.ts +18 -0
- package/components/flows/pickers/PickScript.svelte +38 -0
- package/components/flows/pickers/PickScript.svelte.d.ts +18 -0
- package/components/flows/utils.d.ts +21 -0
- package/components/flows/utils.js +164 -0
- package/components/icons/DbIcon.svelte +2 -5
- package/components/icons/Mail.svelte +2 -5
- package/components/icons/Mysql.svelte +2 -5
- package/components/icons/PostgresIcon.svelte +2 -5
- package/components/icons/Slack.svelte +2 -5
- package/components/propertyPicker/ObjectViewer.svelte +113 -0
- package/components/propertyPicker/ObjectViewer.svelte.d.ts +21 -0
- package/components/propertyPicker/OverlayPropertyPicker.svelte +69 -0
- package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +21 -0
- package/components/propertyPicker/PropPicker.svelte +24 -0
- package/components/propertyPicker/PropPicker.svelte.d.ts +18 -0
- package/components/propertyPicker/WarningMessage.svelte +43 -0
- package/components/propertyPicker/WarningMessage.svelte.d.ts +16 -0
- package/components/propertyPicker/utils.d.ts +2 -0
- package/components/propertyPicker/utils.js +40 -0
- package/gen/core/ApiError.d.ts +3 -1
- package/gen/core/ApiError.js +4 -6
- package/gen/core/ApiRequestOptions.js +1 -2
- package/gen/core/ApiResult.js +1 -2
- package/gen/core/CancelablePromise.js +2 -7
- package/gen/core/OpenAPI.js +2 -5
- package/gen/core/request.js +8 -13
- package/gen/index.d.ts +3 -0
- package/gen/index.js +28 -58
- package/gen/models/AuditLog.js +2 -5
- package/gen/models/CompletedJob.d.ts +3 -1
- package/gen/models/CompletedJob.js +3 -5
- package/gen/models/ContextualVariable.js +1 -2
- package/gen/models/CreateResource.d.ts +1 -0
- package/gen/models/CreateResource.js +1 -2
- package/gen/models/CreateVariable.d.ts +2 -0
- package/gen/models/CreateVariable.js +1 -2
- package/gen/models/CreateWorkspace.js +1 -2
- package/gen/models/EditResource.js +1 -2
- package/gen/models/EditResourceType.js +1 -2
- package/gen/models/EditSchedule.js +1 -2
- package/gen/models/EditVariable.js +1 -2
- package/gen/models/EditWorkspaceUser.js +1 -2
- package/gen/models/Flow.js +1 -2
- package/gen/models/FlowModule.d.ts +2 -0
- package/gen/models/FlowModule.js +1 -2
- package/gen/models/FlowModuleValue.d.ts +14 -2
- package/gen/models/FlowModuleValue.js +9 -5
- package/gen/models/FlowPreview.js +1 -2
- package/gen/models/FlowStatus.js +1 -2
- package/gen/models/FlowStatusModule.d.ts +6 -0
- package/gen/models/FlowStatusModule.js +2 -5
- package/gen/models/FlowValue.js +1 -2
- package/gen/models/GlobalUserInfo.js +2 -5
- package/gen/models/Group.js +1 -2
- package/gen/models/InputTransform.js +2 -5
- package/gen/models/Job.js +2 -5
- package/gen/models/ListableVariable.d.ts +2 -0
- package/gen/models/ListableVariable.js +1 -2
- package/gen/models/Login.js +1 -2
- package/gen/models/MainArgSignature.js +1 -2
- package/gen/models/NewSchedule.js +1 -2
- package/gen/models/NewToken.js +1 -2
- package/gen/models/NewUser.js +1 -2
- package/gen/models/Preview.js +2 -5
- package/gen/models/QueuedJob.d.ts +2 -1
- package/gen/models/QueuedJob.js +3 -5
- package/gen/models/Resource.d.ts +1 -0
- package/gen/models/Resource.js +1 -2
- package/gen/models/ResourceType.js +1 -2
- package/gen/models/Schedule.js +1 -2
- package/gen/models/Script.d.ts +1 -0
- package/gen/models/Script.js +2 -5
- package/gen/models/ScriptArgs.js +1 -2
- package/gen/models/SlackToken.d.ts +8 -0
- package/gen/models/SlackToken.js +4 -0
- package/gen/models/TokenResponse.d.ts +6 -0
- package/gen/models/TokenResponse.js +4 -0
- package/gen/models/TruncatedToken.js +1 -2
- package/gen/models/User.js +1 -2
- package/gen/models/UserWorkspaceList.js +1 -2
- package/gen/models/WorkerPing.js +1 -2
- package/gen/models/Workspace.js +1 -2
- package/gen/models/WorkspaceInvite.js +1 -2
- package/gen/services/AdminService.d.ts +6 -2
- package/gen/services/AdminService.js +6 -10
- package/gen/services/AuditService.d.ts +24 -8
- package/gen/services/AuditService.js +5 -9
- package/gen/services/FlowService.d.ts +37 -10
- package/gen/services/FlowService.js +23 -12
- package/gen/services/GranularAclService.d.ts +6 -2
- package/gen/services/GranularAclService.js +6 -10
- package/gen/services/GroupService.d.ts +18 -6
- package/gen/services/GroupService.js +11 -15
- package/gen/services/JobService.d.ts +167 -46
- package/gen/services/JobService.js +42 -22
- package/gen/services/OauthService.d.ts +104 -0
- package/gen/services/OauthService.js +133 -0
- package/gen/services/ResourceService.d.ts +39 -7
- package/gen/services/ResourceService.js +44 -18
- package/gen/services/ScheduleService.d.ts +36 -6
- package/gen/services/ScheduleService.js +39 -13
- package/gen/services/ScriptService.d.ts +66 -19
- package/gen/services/ScriptService.js +32 -20
- package/gen/services/SettingsService.js +5 -9
- package/gen/services/UserService.d.ts +49 -11
- package/gen/services/UserService.js +42 -29
- package/gen/services/VariableService.d.ts +19 -4
- package/gen/services/VariableService.js +24 -13
- package/gen/services/WorkerService.d.ts +6 -2
- package/gen/services/WorkerService.js +4 -8
- package/gen/services/WorkspaceService.d.ts +29 -24
- package/gen/services/WorkspaceService.js +23 -42
- package/infer.js +5 -9
- package/logout.js +20 -18
- package/package.json +51 -24
- package/script_helpers.d.ts +4 -0
- package/script_helpers.js +70 -0
- package/scripts.d.ts +2 -1
- package/scripts.js +11 -15
- package/stores.d.ts +6 -0
- package/stores.js +30 -22
- package/user.js +10 -15
- package/utils.d.ts +15 -1
- package/utils.js +191 -52
|
@@ -1,130 +1,83 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def main(name: str = "Nicolas Bourbaki",
|
|
16
|
-
age: int = 42,
|
|
17
|
-
obj: dict = {"even": "dicts"},
|
|
18
|
-
l: list = ["or", "lists!"],
|
|
19
|
-
file_: bytes = bytes(0),
|
|
20
|
-
dtime: datetime = datetime.now()):
|
|
21
|
-
"""A main function is required for the script to be able to accept arguments.
|
|
22
|
-
Types are recommended."""
|
|
23
|
-
print(f"Hello World and a warm welcome especially to {name}")
|
|
24
|
-
print("and its acolytes..", age, obj, l, len(file_), dtime)
|
|
25
|
-
# retrieve variables, including secrets by querying the windmill platform.
|
|
26
|
-
# secret fetching is audited by windmill.
|
|
27
|
-
secret = wmill.get_variable("g/all/pretty_secret")
|
|
28
|
-
print(f"The env variable at \`g_all/pretty_secret\`: {secret}")
|
|
29
|
-
# interact with the windmill platform to get the version
|
|
30
|
-
version = wmill.get_version()
|
|
31
|
-
# fetch reserved variables as environment variables
|
|
32
|
-
user = os.environ.get("WM_USERNAME")
|
|
33
|
-
# the return value is then parsed and can be retrieved by other scripts conveniently
|
|
34
|
-
return {"version": version, "splitted": name.split(), "user": user}
|
|
35
|
-
`
|
|
36
|
-
const DENO_INIT_CODE = `
|
|
37
|
-
// only do the following import if you require your script to interact with the windmill
|
|
38
|
-
// for instance to get a variable or resource
|
|
39
|
-
// import * as wmill from 'https://deno.land/x/windmill@v${__pkg__.version}/index.ts'
|
|
40
|
-
|
|
41
|
-
export async function main(x: string, y: string = 'default arg') {
|
|
42
|
-
// let x = await wmill.getVariable('u/user/foo');
|
|
43
|
-
// let y = await wmill.getResource('u/user/foo')
|
|
44
|
-
return { foo: x }
|
|
45
|
-
}
|
|
46
|
-
`
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<script>"use strict";
|
|
50
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
51
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.setCode = exports.initialPath = exports.script = void 0;
|
|
55
|
-
const gen_1 = require("$lib/gen");
|
|
56
|
-
const utils_1 = require("$lib/utils");
|
|
57
|
-
const svelte_1 = require("svelte");
|
|
58
|
-
const ScriptEditor_svelte_1 = __importDefault(require("./ScriptEditor.svelte"));
|
|
59
|
-
const stores_1 = require("$app/stores");
|
|
60
|
-
const navigation_1 = require("$app/navigation");
|
|
61
|
-
const Path_svelte_1 = __importDefault(require("./Path.svelte"));
|
|
62
|
-
const svelte_markdown_1 = __importDefault(require("svelte-markdown"));
|
|
63
|
-
const stores_2 = require("$lib/stores");
|
|
64
|
-
const ScriptSchema_svelte_1 = __importDefault(require("./ScriptSchema.svelte"));
|
|
65
|
-
const infer_1 = require("$lib/infer");
|
|
66
|
-
const Required_svelte_1 = __importDefault(require("./Required.svelte"));
|
|
67
|
-
const RadioButton_svelte_1 = __importDefault(require("./RadioButton.svelte"));
|
|
1
|
+
<script>import { ScriptService } from '../gen';
|
|
2
|
+
import { emptySchema, sendUserToast, setQueryWithoutLoad } from '../utils';
|
|
3
|
+
import { onDestroy } from 'svelte';
|
|
4
|
+
import ScriptEditor from './ScriptEditor.svelte';
|
|
5
|
+
import { page } from '$app/stores';
|
|
6
|
+
import { goto } from '$app/navigation';
|
|
7
|
+
import Path from './Path.svelte';
|
|
8
|
+
import SvelteMarkdown from 'svelte-markdown';
|
|
9
|
+
import { workspaceStore } from '../stores';
|
|
10
|
+
import ScriptSchema from './ScriptSchema.svelte';
|
|
11
|
+
import { inferArgs } from '../infer';
|
|
12
|
+
import Required from './Required.svelte';
|
|
13
|
+
import RadioButton from './RadioButton.svelte';
|
|
14
|
+
import { DENO_INIT_CODE, DENO_INIT_CODE_TRIGGER, initialCode } from '../script_helpers';
|
|
68
15
|
let editor;
|
|
69
16
|
let scriptSchema;
|
|
70
17
|
$: step = Number($page.url.searchParams.get('step')) || 1;
|
|
71
|
-
|
|
18
|
+
export let script;
|
|
19
|
+
export let initialPath = '';
|
|
20
|
+
let pathError = '';
|
|
72
21
|
$: {
|
|
73
|
-
$page.url
|
|
74
|
-
|
|
22
|
+
setQueryWithoutLoad($page.url, 'state', btoa(JSON.stringify(script)));
|
|
23
|
+
}
|
|
24
|
+
$: {
|
|
25
|
+
if (script.language == 'python3') {
|
|
26
|
+
script.is_trigger = false;
|
|
27
|
+
}
|
|
75
28
|
}
|
|
76
|
-
if (
|
|
77
|
-
initContent(
|
|
29
|
+
if (script.content == '') {
|
|
30
|
+
initContent(script.language, script.is_trigger);
|
|
78
31
|
}
|
|
79
|
-
function initContent(lang) {
|
|
80
|
-
|
|
32
|
+
function initContent(lang, is_trigger) {
|
|
33
|
+
script.content = initialCode(lang, is_trigger);
|
|
81
34
|
}
|
|
82
35
|
async function editScript() {
|
|
83
36
|
try {
|
|
84
|
-
const newHash = await
|
|
37
|
+
const newHash = await ScriptService.createScript({
|
|
85
38
|
workspace: $workspaceStore,
|
|
86
39
|
requestBody: {
|
|
87
|
-
path:
|
|
88
|
-
summary:
|
|
89
|
-
description:
|
|
90
|
-
content:
|
|
91
|
-
parent_hash:
|
|
92
|
-
schema:
|
|
93
|
-
is_template:
|
|
94
|
-
language:
|
|
40
|
+
path: script.path,
|
|
41
|
+
summary: script.summary,
|
|
42
|
+
description: script.description ?? '',
|
|
43
|
+
content: script.content,
|
|
44
|
+
parent_hash: script.hash != '' ? script.hash : undefined,
|
|
45
|
+
schema: script.schema,
|
|
46
|
+
is_template: script.is_template,
|
|
47
|
+
language: script.language,
|
|
48
|
+
is_trigger: script.is_trigger
|
|
95
49
|
}
|
|
96
50
|
});
|
|
97
|
-
|
|
98
|
-
|
|
51
|
+
sendUserToast(`Success! New script version created with hash ${newHash}`);
|
|
52
|
+
goto(`/scripts/get/${newHash}`);
|
|
99
53
|
}
|
|
100
54
|
catch (error) {
|
|
101
|
-
|
|
55
|
+
sendUserToast(`Impossible to save the script: ${error.body}`, true);
|
|
102
56
|
}
|
|
103
57
|
}
|
|
104
|
-
function setCode(script) {
|
|
58
|
+
export function setCode(script) {
|
|
105
59
|
editor?.getEditor().setCode(script.content);
|
|
106
60
|
if (scriptSchema) {
|
|
107
61
|
if (script.schema) {
|
|
108
62
|
scriptSchema.setSchema(script.schema);
|
|
109
63
|
}
|
|
110
64
|
else {
|
|
111
|
-
scriptSchema.setSchema(
|
|
65
|
+
scriptSchema.setSchema(emptySchema());
|
|
112
66
|
}
|
|
113
67
|
}
|
|
114
68
|
}
|
|
115
|
-
exports.setCode = setCode;
|
|
116
69
|
async function inferSchema() {
|
|
117
|
-
await
|
|
70
|
+
await inferArgs(script.language, script.content, script.schema);
|
|
118
71
|
}
|
|
119
72
|
async function changeStep(step) {
|
|
120
73
|
if (step == 3) {
|
|
121
|
-
|
|
74
|
+
script.content = editor?.getEditor().getCode() ?? script.content;
|
|
122
75
|
await inferSchema();
|
|
123
|
-
|
|
76
|
+
script.schema = script.schema;
|
|
124
77
|
}
|
|
125
|
-
|
|
78
|
+
goto(`?step=${step}`);
|
|
126
79
|
}
|
|
127
|
-
|
|
80
|
+
onDestroy(() => {
|
|
128
81
|
editor?.$destroy();
|
|
129
82
|
});
|
|
130
83
|
</script>
|
|
@@ -143,6 +96,7 @@ async function changeStep(step) {
|
|
|
143
96
|
}}>Step 1: Metadata</button
|
|
144
97
|
>
|
|
145
98
|
<button
|
|
99
|
+
disabled={pathError != ''}
|
|
146
100
|
class="{step === 2
|
|
147
101
|
? 'default-button-disabled text-gray-700'
|
|
148
102
|
: 'default-button-secondary'} min-w-max ml-2"
|
|
@@ -151,6 +105,7 @@ async function changeStep(step) {
|
|
|
151
105
|
}}>Step 2: Code</button
|
|
152
106
|
>
|
|
153
107
|
<button
|
|
108
|
+
disabled={pathError != ''}
|
|
154
109
|
class="{step === 3
|
|
155
110
|
? 'default-button-disabled text-gray-700'
|
|
156
111
|
: 'default-button-secondary'} min-w-max ml-2"
|
|
@@ -162,8 +117,7 @@ async function changeStep(step) {
|
|
|
162
117
|
<div class="flex flex-row-reverse ml-2">
|
|
163
118
|
{#if step != 3}
|
|
164
119
|
<button
|
|
165
|
-
disabled={step == 1 &&
|
|
166
|
-
(script.path == undefined || script.path == '' || script.path.split('/')[2] == '')}
|
|
120
|
+
disabled={step == 1 && pathError != ''}
|
|
167
121
|
class="default-button px-6 max-h-8"
|
|
168
122
|
on:click={() => {
|
|
169
123
|
changeStep(step + 1)
|
|
@@ -195,8 +149,14 @@ async function changeStep(step) {
|
|
|
195
149
|
<!-- metadata -->
|
|
196
150
|
{#if step === 1}
|
|
197
151
|
<div class="grid grid-cols-1 gap-6 max-w-7xl">
|
|
198
|
-
<Path
|
|
199
|
-
|
|
152
|
+
<Path
|
|
153
|
+
bind:error={pathError}
|
|
154
|
+
bind:path={script.path}
|
|
155
|
+
{initialPath}
|
|
156
|
+
namePlaceholder="example/my/script"
|
|
157
|
+
kind="script"
|
|
158
|
+
>
|
|
159
|
+
<div slot="ownerToolkit">
|
|
200
160
|
Script permissions depend on their path. Select the group <span class="font-mono"
|
|
201
161
|
>all</span
|
|
202
162
|
>
|
|
@@ -210,10 +170,10 @@ async function changeStep(step) {
|
|
|
210
170
|
label="Language"
|
|
211
171
|
small={true}
|
|
212
172
|
options={[
|
|
213
|
-
['
|
|
214
|
-
['
|
|
173
|
+
['Typescript (Deno)', 'deno'],
|
|
174
|
+
['Python 3.10', 'python3']
|
|
215
175
|
]}
|
|
216
|
-
on:change={(e) => initContent(e.detail)}
|
|
176
|
+
on:change={(e) => initContent(e.detail, script.is_trigger)}
|
|
217
177
|
bind:value={script.language}
|
|
218
178
|
/>
|
|
219
179
|
</div>
|
|
@@ -255,11 +215,26 @@ async function changeStep(step) {
|
|
|
255
215
|
/>
|
|
256
216
|
</span></label
|
|
257
217
|
>
|
|
218
|
+
|
|
258
219
|
<label class="block">
|
|
259
220
|
<span class="text-gray-700 mr-2">Save as template</span>
|
|
260
221
|
<input type="checkbox" bind:checked={script.is_template} />
|
|
261
222
|
</label>
|
|
262
223
|
|
|
224
|
+
<label class="block">
|
|
225
|
+
<span class="text-gray-700 mr-2">Save as trigger script</span>
|
|
226
|
+
<input
|
|
227
|
+
disabled={script.language == 'python3'}
|
|
228
|
+
type="checkbox"
|
|
229
|
+
bind:checked={script.is_trigger}
|
|
230
|
+
on:change={() => {
|
|
231
|
+
if (script.content == DENO_INIT_CODE || script.content == DENO_INIT_CODE_TRIGGER) {
|
|
232
|
+
initContent(script.language, script.is_trigger)
|
|
233
|
+
}
|
|
234
|
+
}}
|
|
235
|
+
/>
|
|
236
|
+
</label>
|
|
237
|
+
|
|
263
238
|
<div>
|
|
264
239
|
<h3 class="text-gray-700 ">Description rendered</h3>
|
|
265
240
|
<div
|
|
@@ -1,37 +1,34 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const languages_1 = require("svelte-highlight/languages");
|
|
21
|
-
const github_1 = __importDefault(require("svelte-highlight/styles/github"));
|
|
22
|
-
const ItemPicker_svelte_1 = __importDefault(require("./ItemPicker.svelte"));
|
|
23
|
-
const VariableEditor_svelte_1 = __importDefault(require("./VariableEditor.svelte"));
|
|
24
|
-
const ResourceEditor_svelte_1 = __importDefault(require("./ResourceEditor.svelte"));
|
|
25
|
-
const infer_1 = require("$lib/infer");
|
|
1
|
+
<script>import { JobService, Job, CompletedJob, VariableService, ResourceService, ScriptService } from '../gen';
|
|
2
|
+
import { sendUserToast, emptySchema, displayDate } from '../utils';
|
|
3
|
+
import { fade } from 'svelte/transition';
|
|
4
|
+
import Icon from 'svelte-awesome';
|
|
5
|
+
import { faCheck, faChevronDown, faChevronUp, faExclamationTriangle, faMagic, faSearch, faSpinner, faTimes } from '@fortawesome/free-solid-svg-icons';
|
|
6
|
+
import Editor from './Editor.svelte';
|
|
7
|
+
import Tooltip from './Tooltip.svelte';
|
|
8
|
+
import { onDestroy, onMount } from 'svelte';
|
|
9
|
+
import { userStore, workspaceStore } from '../stores';
|
|
10
|
+
import TableCustom from './TableCustom.svelte';
|
|
11
|
+
import { check } from 'svelte-awesome/icons';
|
|
12
|
+
import Modal from './Modal.svelte';
|
|
13
|
+
import { Highlight } from 'svelte-highlight';
|
|
14
|
+
import { json, python, typescript } from 'svelte-highlight/languages';
|
|
15
|
+
import github from 'svelte-highlight/styles/github';
|
|
16
|
+
import ItemPicker from './ItemPicker.svelte';
|
|
17
|
+
import VariableEditor from './VariableEditor.svelte';
|
|
18
|
+
import ResourceEditor from './ResourceEditor.svelte';
|
|
19
|
+
import { inferArgs } from '../infer';
|
|
26
20
|
// @ts-ignore
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
import { VSplitPane } from 'svelte-split-pane';
|
|
22
|
+
import SchemaForm from './SchemaForm.svelte';
|
|
23
|
+
import DisplayResult from './DisplayResult.svelte';
|
|
30
24
|
// Exported
|
|
31
|
-
|
|
25
|
+
export let schema = emptySchema();
|
|
26
|
+
export let code;
|
|
27
|
+
export let path;
|
|
28
|
+
export let lang;
|
|
32
29
|
// Control Editor layout
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
export let viewPreview = true;
|
|
31
|
+
export let previewTab = 'logs';
|
|
35
32
|
let websocketAlive = { pyright: false, black: false, deno: false };
|
|
36
33
|
// Internal state
|
|
37
34
|
let editor;
|
|
@@ -55,31 +52,30 @@ let resourceEditor;
|
|
|
55
52
|
let syncIteration = 0;
|
|
56
53
|
let ITERATIONS_BEFORE_SLOW_REFRESH = 100;
|
|
57
54
|
let lastSave;
|
|
58
|
-
$: lastSave = localStorage.getItem(
|
|
59
|
-
function getEditor() {
|
|
55
|
+
$: lastSave = localStorage.getItem(path ?? 'last_save');
|
|
56
|
+
export function getEditor() {
|
|
60
57
|
return editor;
|
|
61
58
|
}
|
|
62
|
-
|
|
63
|
-
async function runPreview() {
|
|
59
|
+
export async function runPreview() {
|
|
64
60
|
try {
|
|
65
61
|
if (previewIntervalId) {
|
|
66
62
|
clearInterval(previewIntervalId);
|
|
67
63
|
}
|
|
68
64
|
if (previewIsLoading && previewJob) {
|
|
69
|
-
|
|
65
|
+
JobService.cancelQueuedJob({
|
|
70
66
|
workspace: $workspaceStore,
|
|
71
67
|
id: previewJob.id,
|
|
72
68
|
requestBody: {}
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
71
|
previewIsLoading = true;
|
|
76
|
-
const previewId = await
|
|
72
|
+
const previewId = await JobService.runScriptPreview({
|
|
77
73
|
workspace: $workspaceStore,
|
|
78
74
|
requestBody: {
|
|
79
|
-
path
|
|
75
|
+
path,
|
|
80
76
|
content: editor.getCode(),
|
|
81
77
|
args: args,
|
|
82
|
-
language:
|
|
78
|
+
language: lang
|
|
83
79
|
}
|
|
84
80
|
});
|
|
85
81
|
previewJob = undefined;
|
|
@@ -95,19 +91,18 @@ async function runPreview() {
|
|
|
95
91
|
throw err;
|
|
96
92
|
}
|
|
97
93
|
}
|
|
98
|
-
exports.runPreview = runPreview;
|
|
99
94
|
async function loadPastPreviews() {
|
|
100
|
-
pastPreviews = await
|
|
95
|
+
pastPreviews = await JobService.listCompletedJobs({
|
|
101
96
|
workspace: $workspaceStore,
|
|
102
97
|
jobKinds: 'preview',
|
|
103
98
|
createdBy: $userStore?.username,
|
|
104
|
-
scriptPathExact:
|
|
99
|
+
scriptPathExact: path
|
|
105
100
|
});
|
|
106
101
|
}
|
|
107
102
|
async function loadPreviewJob(id) {
|
|
108
103
|
try {
|
|
109
104
|
if (previewJob && `running` in previewJob) {
|
|
110
|
-
let previewJobUpdates = await
|
|
105
|
+
let previewJobUpdates = await JobService.getJobUpdates({
|
|
111
106
|
workspace: $workspaceStore,
|
|
112
107
|
id,
|
|
113
108
|
running: previewJob.running,
|
|
@@ -117,11 +112,11 @@ async function loadPreviewJob(id) {
|
|
|
117
112
|
previewJob.logs = (previewJob.logs ?? '').concat(previewJobUpdates.new_logs);
|
|
118
113
|
}
|
|
119
114
|
if ((previewJobUpdates.running ?? false) || (previewJobUpdates.completed ?? false)) {
|
|
120
|
-
previewJob = await
|
|
115
|
+
previewJob = await JobService.getJob({ workspace: $workspaceStore, id });
|
|
121
116
|
}
|
|
122
117
|
}
|
|
123
118
|
else {
|
|
124
|
-
previewJob = await
|
|
119
|
+
previewJob = await JobService.getJob({ workspace: $workspaceStore, id });
|
|
125
120
|
}
|
|
126
121
|
if (previewJob?.type === 'CompletedJob') {
|
|
127
122
|
//only CompletedJob has success property
|
|
@@ -137,15 +132,15 @@ async function loadPreviewJob(id) {
|
|
|
137
132
|
async function inferSchema() {
|
|
138
133
|
let isDefault = [];
|
|
139
134
|
Object.entries(args).forEach(([k, v]) => {
|
|
140
|
-
if (
|
|
135
|
+
if (schema.properties[k].default == v) {
|
|
141
136
|
isDefault.push(k);
|
|
142
137
|
}
|
|
143
138
|
});
|
|
144
|
-
await
|
|
145
|
-
|
|
146
|
-
isDefault.forEach((key) => (args[key] =
|
|
139
|
+
await inferArgs(lang, editor.getCode(), schema);
|
|
140
|
+
schema = schema;
|
|
141
|
+
isDefault.forEach((key) => (args[key] = schema.properties[key].default));
|
|
147
142
|
for (const key of Object.keys(args)) {
|
|
148
|
-
if (
|
|
143
|
+
if (schema.properties[key] == undefined) {
|
|
149
144
|
delete args[key];
|
|
150
145
|
}
|
|
151
146
|
}
|
|
@@ -165,30 +160,30 @@ function syncer(id) {
|
|
|
165
160
|
}
|
|
166
161
|
async function loadVariables() {
|
|
167
162
|
let r = [];
|
|
168
|
-
const variables = (await
|
|
163
|
+
const variables = (await VariableService.listVariable({ workspace: $workspaceStore ?? 'NO_W' })).map((x) => {
|
|
169
164
|
return { name: x.path, ...x };
|
|
170
165
|
});
|
|
171
|
-
const rvariables = await
|
|
166
|
+
const rvariables = await VariableService.listContextualVariables({
|
|
172
167
|
workspace: $workspaceStore ?? 'NO_W'
|
|
173
168
|
});
|
|
174
169
|
r = r.concat(variables).concat(rvariables);
|
|
175
170
|
return r;
|
|
176
171
|
}
|
|
177
172
|
async function loadScripts() {
|
|
178
|
-
return await
|
|
173
|
+
return await ScriptService.listScripts({ workspace: $workspaceStore ?? 'NO_W' });
|
|
179
174
|
}
|
|
180
175
|
let syncCode;
|
|
181
|
-
|
|
176
|
+
onMount(() => {
|
|
182
177
|
syncCode = setInterval(() => {
|
|
183
178
|
const newCode = editor?.getCode();
|
|
184
|
-
if (newCode &&
|
|
185
|
-
|
|
179
|
+
if (newCode && code != newCode) {
|
|
180
|
+
code = editor.getCode();
|
|
186
181
|
}
|
|
187
182
|
}, 3000);
|
|
188
183
|
});
|
|
189
|
-
|
|
184
|
+
onDestroy(() => {
|
|
190
185
|
if (editor) {
|
|
191
|
-
|
|
186
|
+
code = editor.getCode();
|
|
192
187
|
}
|
|
193
188
|
if (previewIntervalId) {
|
|
194
189
|
clearInterval(previewIntervalId);
|
|
@@ -300,7 +295,7 @@ let syncCode;
|
|
|
300
295
|
`import * as wmill from 'https://deno.land/x/windmill@v${__pkg__.version}/index.ts'\n`
|
|
301
296
|
)
|
|
302
297
|
}
|
|
303
|
-
getEditor().insertAtCursor(`(await wmill.getResource('${path}
|
|
298
|
+
getEditor().insertAtCursor(`(await wmill.getResource('${path}'))`)
|
|
304
299
|
} else {
|
|
305
300
|
if (!getEditor().getCode().includes('import wmill')) {
|
|
306
301
|
getEditor().insertAtBeginning('import wmill\n')
|
|
@@ -523,7 +518,7 @@ let syncCode;
|
|
|
523
518
|
{:else if previewTab === 'input'}
|
|
524
519
|
<div class="break-all relative h-full font-sans">
|
|
525
520
|
<div class="p-2 w-full">
|
|
526
|
-
<button class="default-button w-full" on:click|stopPropagation={inferSchema}
|
|
521
|
+
<button class="default-button w-full mb-4" on:click|stopPropagation={inferSchema}
|
|
527
522
|
><Icon data={faMagic} scale={0.7} /><span class="pl-1"
|
|
528
523
|
>Infer schema from main parameters</span
|
|
529
524
|
>
|
|
@@ -1,54 +1,48 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const languages_1 = require("svelte-highlight/languages");
|
|
18
|
-
const github_1 = __importDefault(require("svelte-highlight/styles/github"));
|
|
19
|
-
exports.scriptPath = undefined;
|
|
20
|
-
exports.allowFlow = false;
|
|
21
|
-
exports.allowHub = false;
|
|
22
|
-
exports.itemKind = exports.allowHub ? 'hub' : 'script';
|
|
1
|
+
<script>import { ScriptService, FlowService, Script } from '../gen';
|
|
2
|
+
import Icon from 'svelte-awesome';
|
|
3
|
+
import { faSearch } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import { hubScripts, workspaceStore } from '../stores';
|
|
5
|
+
import { createEventDispatcher } from 'svelte';
|
|
6
|
+
import ItemPicker from './ItemPicker.svelte';
|
|
7
|
+
import RadioButton from './RadioButton.svelte';
|
|
8
|
+
import Modal from './Modal.svelte';
|
|
9
|
+
import { Highlight } from 'svelte-highlight';
|
|
10
|
+
import { python, typescript } from 'svelte-highlight/languages';
|
|
11
|
+
import github from 'svelte-highlight/styles/github';
|
|
12
|
+
export let scriptPath = undefined;
|
|
13
|
+
export let allowFlow = false;
|
|
14
|
+
export let allowHub = false;
|
|
15
|
+
export let itemKind = allowHub ? 'hub' : 'script';
|
|
16
|
+
export let isTrigger = undefined;
|
|
23
17
|
let items = [];
|
|
24
18
|
let itemPicker;
|
|
25
19
|
let modalViewer;
|
|
26
20
|
let code = '';
|
|
27
21
|
let lang;
|
|
28
22
|
let options = [['Script', 'script']];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const dispatch =
|
|
23
|
+
allowHub && options.unshift(['Hub', 'hub']);
|
|
24
|
+
allowFlow && options.push(['Flow', 'flow']);
|
|
25
|
+
const dispatch = createEventDispatcher();
|
|
32
26
|
async function getScript() {
|
|
33
|
-
if (
|
|
34
|
-
code = await
|
|
35
|
-
lang =
|
|
27
|
+
if (itemKind == 'hub') {
|
|
28
|
+
code = await ScriptService.getHubScriptContentByPath({ path: scriptPath });
|
|
29
|
+
lang = Script.language.DENO;
|
|
36
30
|
}
|
|
37
31
|
else {
|
|
38
|
-
const script = await
|
|
32
|
+
const script = await ScriptService.getScriptByPath({
|
|
39
33
|
workspace: $workspaceStore,
|
|
40
|
-
path:
|
|
34
|
+
path: scriptPath
|
|
41
35
|
});
|
|
42
36
|
code = script.content;
|
|
43
37
|
lang = script.language;
|
|
44
38
|
}
|
|
45
39
|
}
|
|
46
40
|
async function loadItems() {
|
|
47
|
-
if (
|
|
48
|
-
items = await
|
|
41
|
+
if (itemKind == 'flow') {
|
|
42
|
+
items = await FlowService.listFlows({ workspace: $workspaceStore });
|
|
49
43
|
}
|
|
50
|
-
else if (
|
|
51
|
-
items = await
|
|
44
|
+
else if (itemKind == 'script') {
|
|
45
|
+
items = await ScriptService.listScripts({ workspace: $workspaceStore, isTrigger });
|
|
52
46
|
}
|
|
53
47
|
else {
|
|
54
48
|
items = $hubScripts ?? [];
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const github_1 = __importDefault(require("svelte-highlight/styles/github"));
|
|
13
|
-
const svelte_markdown_1 = __importDefault(require("svelte-markdown"));
|
|
14
|
-
exports.synchronizedHeader = true;
|
|
1
|
+
<script>import PageHeader from './PageHeader.svelte';
|
|
2
|
+
import SchemaForm from './SchemaForm.svelte';
|
|
3
|
+
import Tabs from './Tabs.svelte';
|
|
4
|
+
import Highlight from 'svelte-highlight';
|
|
5
|
+
import json from 'svelte-highlight/languages/json';
|
|
6
|
+
import github from 'svelte-highlight/styles/github';
|
|
7
|
+
import SvelteMarkdown from 'svelte-markdown';
|
|
8
|
+
export let schema;
|
|
9
|
+
export let summary;
|
|
10
|
+
export let description;
|
|
11
|
+
export let synchronizedHeader = true;
|
|
15
12
|
let tab = 'ui';
|
|
16
|
-
function setSchema(newSchema) {
|
|
17
|
-
|
|
13
|
+
export function setSchema(newSchema) {
|
|
14
|
+
schema = newSchema;
|
|
18
15
|
}
|
|
19
|
-
exports.setSchema = setSchema;
|
|
20
16
|
</script>
|
|
21
17
|
|
|
22
18
|
<svelte:head>
|