windmill-components 1.22.42 → 1.28.3
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/AppConnect.svelte +93 -47
- package/components/AppConnect.svelte.d.ts +2 -2
- package/components/ArgInfo.svelte +0 -5
- package/components/ArgInput.svelte +91 -64
- package/components/ArgInput.svelte.d.ts +8 -3
- package/components/Button.svelte +4 -4
- package/components/CenteredPage.svelte +1 -1
- package/components/CollapseLink.svelte +12 -0
- package/components/CollapseLink.svelte.d.ts +19 -0
- package/components/CronInput.svelte +84 -0
- package/components/CronInput.svelte.d.ts +18 -0
- package/components/DisplayResult.svelte +28 -15
- package/components/Editor.svelte +136 -66
- package/components/Editor.svelte.d.ts +2 -0
- package/components/EditorBar.svelte +56 -45
- package/components/FlowBuilder.svelte +155 -70
- package/components/FlowEditor.svelte +79 -200
- package/components/FlowEditor.svelte.d.ts +3 -2
- package/components/FlowJobResult.svelte +1 -1
- package/components/FlowPreview.svelte +18 -24
- package/components/FlowPreviewContent.svelte +68 -0
- package/components/FlowPreviewContent.svelte.d.ts +21 -0
- package/components/FlowStatusViewer.svelte +85 -37
- package/components/FlowStatusViewer.svelte.d.ts +3 -2
- package/components/FlowViewer.svelte +85 -45
- package/components/FlowViewer.svelte.d.ts +2 -1
- package/components/IconedResourceType.svelte +30 -5
- package/components/InputTransformForm.svelte +209 -0
- package/components/InputTransformForm.svelte.d.ts +26 -0
- package/components/InputTransformsViewer.svelte +19 -0
- package/components/InputTransformsViewer.svelte.d.ts +17 -0
- package/components/InviteGlobalUser.svelte +2 -2
- package/components/InviteUser.svelte +2 -2
- package/components/JobStatus.svelte +32 -25
- package/components/Modal.svelte +44 -42
- package/components/ModuleStep.svelte +94 -79
- package/components/ObjectResourceInput.svelte +58 -38
- package/components/ObjectTypeNarrowing.svelte +4 -19
- package/components/Path.svelte +1 -0
- package/components/Path.svelte.d.ts +1 -1
- package/components/RadioButton.svelte +11 -96
- package/components/RadioButton.svelte.d.ts +4 -2
- package/components/ResourceEditor.svelte +4 -5
- package/components/ResourceEditor.svelte.d.ts +2 -2
- package/components/ResourcePicker.svelte +25 -2
- package/components/ResourcePicker.svelte.d.ts +3 -0
- package/components/ResourceTypePicker.svelte +17 -29
- package/components/ResourceTypePicker.svelte.d.ts +1 -0
- package/components/RunForm.svelte +14 -15
- package/components/RunForm.svelte.d.ts +1 -1
- package/components/SchemaEditor.svelte +87 -71
- package/components/SchemaEditor.svelte.d.ts +2 -0
- package/components/SchemaEditorProperty.svelte +11 -0
- package/components/SchemaEditorProperty.svelte.d.ts +17 -0
- package/components/SchemaForm.svelte +21 -127
- package/components/SchemaForm.svelte.d.ts +3 -4
- package/components/SchemaModal.svelte +20 -33
- package/components/SchemaModal.svelte.d.ts +1 -1
- package/components/SchemaViewer.svelte +4 -6
- package/components/ScriptBuilder.svelte +40 -43
- package/components/ScriptEditor.svelte +71 -66
- package/components/ScriptPicker.svelte +10 -12
- package/components/ScriptPicker.svelte.d.ts +1 -1
- package/components/ScriptSchema.svelte +0 -5
- package/components/ShareModal.svelte +1 -1
- package/components/SharedBadge.svelte +12 -10
- package/components/StringTypeNarrowing.svelte +8 -4
- package/components/StringTypeNarrowing.svelte.d.ts +1 -0
- package/components/TableCustom.svelte +7 -9
- package/components/TableSimple.svelte +1 -1
- package/components/Toggle.svelte +8 -10
- package/components/Toggle.svelte.d.ts +5 -11
- package/components/Tooltip.svelte +3 -2
- package/components/VariableEditor.svelte +21 -6
- package/components/flows/CopyFirstStepSchema.svelte +7 -5
- package/components/flows/DynamicInputHelpBox.svelte +1 -1
- package/components/flows/FlowBox.svelte +3 -0
- package/components/flows/FlowBox.svelte.d.ts +23 -0
- package/components/flows/FlowBoxHeader.svelte +9 -0
- package/components/flows/FlowBoxHeader.svelte.d.ts +18 -0
- package/components/flows/FlowInput.svelte +20 -0
- package/components/flows/FlowInput.svelte.d.ts +14 -0
- package/components/flows/FlowInputs.svelte +7 -3
- package/components/flows/FlowModuleHeader.svelte +42 -40
- package/components/flows/FlowModuleHeader.svelte.d.ts +1 -1
- package/components/flows/FlowSettings.svelte +174 -0
- package/components/flows/FlowSettings.svelte.d.ts +21 -0
- package/components/flows/flowStore.d.ts +5 -2
- package/components/flows/flowStore.js +65 -9
- package/components/flows/pickers/FlowScriptPicker.svelte +6 -1
- package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +1 -0
- package/components/flows/utils.d.ts +11 -7
- package/components/flows/utils.js +114 -45
- package/components/icons/AirtableIcon.svelte +17 -0
- package/components/icons/AirtableIcon.svelte.d.ts +17 -0
- package/components/icons/GCloudIcon.svelte +16 -0
- package/components/icons/GCloudIcon.svelte.d.ts +17 -0
- package/components/icons/GItlabIcon.svelte +16 -0
- package/components/icons/GItlabIcon.svelte.d.ts +17 -0
- package/components/icons/GSheetsIcon.svelte +16 -0
- package/components/icons/GSheetsIcon.svelte.d.ts +17 -0
- package/components/icons/GcalIcon.svelte +16 -0
- package/components/icons/GcalIcon.svelte.d.ts +17 -0
- package/components/icons/GdriveIcon.svelte +16 -0
- package/components/icons/GdriveIcon.svelte.d.ts +17 -0
- package/components/icons/GmailIcon.svelte +16 -0
- package/components/icons/GmailIcon.svelte.d.ts +17 -0
- package/components/icons/PostgresIcon.svelte +8 -49
- package/components/icons/Slack.svelte +9 -18
- package/components/icons/TogglIcon.svelte +59 -0
- package/components/icons/TogglIcon.svelte.d.ts +17 -0
- package/components/propertyPicker/ObjectViewer.svelte +35 -37
- package/components/propertyPicker/ObjectViewer.svelte.d.ts +2 -0
- package/components/propertyPicker/OverlayPropertyPicker.svelte +53 -53
- package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +5 -2
- package/components/propertyPicker/PropPicker.svelte +13 -15
- package/components/propertyPicker/PropPicker.svelte.d.ts +1 -1
- package/components/propertyPicker/WarningMessage.svelte +14 -41
- package/components/propertyPicker/WarningMessage.svelte.d.ts +11 -8
- package/components/propertyPicker/utils.d.ts +1 -0
- package/components/propertyPicker/utils.js +25 -0
- package/gen/core/OpenAPI.js +1 -1
- package/gen/index.d.ts +11 -2
- package/gen/index.js +1 -2
- package/gen/models/CompletedJob.d.ts +1 -1
- package/gen/models/Flow.d.ts +3 -13
- package/gen/models/FlowMetadata.d.ts +9 -0
- package/gen/models/FlowMetadata.js +4 -0
- package/gen/models/FlowModuleValue.d.ts +5 -22
- package/gen/models/FlowModuleValue.js +1 -15
- package/gen/models/ForloopFlow.d.ts +8 -0
- package/gen/models/ForloopFlow.js +4 -0
- package/gen/models/InputTransform.d.ts +3 -12
- package/gen/models/InputTransform.js +1 -8
- package/gen/models/JavascriptTransform.d.ts +4 -0
- package/gen/models/JavascriptTransform.js +4 -0
- package/gen/models/MainArgSignature.d.ts +1 -1
- package/gen/models/NewSchedule.d.ts +1 -0
- package/gen/models/OpenFlowWPath.d.ts +4 -0
- package/gen/models/OpenFlowWPath.js +4 -0
- package/gen/models/PathFlow.d.ts +4 -0
- package/gen/models/PathFlow.js +4 -0
- package/gen/models/PathScript.d.ts +4 -0
- package/gen/models/PathScript.js +4 -0
- package/gen/models/RawScript.d.ts +12 -0
- package/gen/models/RawScript.js +11 -0
- package/gen/models/Schedule.d.ts +1 -1
- package/gen/models/StaticTransform.d.ts +4 -0
- package/gen/models/StaticTransform.js +4 -0
- package/gen/models/TokenResponse.d.ts +3 -3
- package/gen/models/Usage.d.ts +5 -0
- package/gen/models/Usage.js +4 -0
- package/gen/models/User.d.ts +2 -0
- package/gen/schemas/$AuditLog.d.ts +32 -0
- package/gen/schemas/$AuditLog.js +35 -0
- package/gen/schemas/$CompletedJob.d.ts +98 -0
- package/gen/schemas/$CompletedJob.js +103 -0
- package/gen/schemas/$ContextualVariable.d.ts +16 -0
- package/gen/schemas/$ContextualVariable.js +19 -0
- package/gen/schemas/$CreateResource.d.ts +22 -0
- package/gen/schemas/$CreateResource.js +25 -0
- package/gen/schemas/$CreateVariable.d.ts +26 -0
- package/gen/schemas/$CreateVariable.js +29 -0
- package/gen/schemas/$CreateWorkspace.d.ts +20 -0
- package/gen/schemas/$CreateWorkspace.js +23 -0
- package/gen/schemas/$EditResource.d.ts +13 -0
- package/gen/schemas/$EditResource.js +16 -0
- package/gen/schemas/$EditResourceType.d.ts +10 -0
- package/gen/schemas/$EditResourceType.js +13 -0
- package/gen/schemas/$EditSchedule.d.ts +20 -0
- package/gen/schemas/$EditSchedule.js +23 -0
- package/gen/schemas/$EditVariable.d.ts +16 -0
- package/gen/schemas/$EditVariable.js +19 -0
- package/gen/schemas/$EditWorkspaceUser.d.ts +7 -0
- package/gen/schemas/$EditWorkspaceUser.js +10 -0
- package/gen/schemas/$Flow.d.ts +23 -0
- package/gen/schemas/$Flow.js +26 -0
- package/gen/schemas/$FlowMetadata.d.ts +31 -0
- package/gen/schemas/$FlowMetadata.js +34 -0
- package/gen/schemas/$FlowPreview.d.ts +80 -0
- package/gen/schemas/$FlowPreview.js +83 -0
- package/gen/schemas/$GlobalUserInfo.d.ts +26 -0
- package/gen/schemas/$GlobalUserInfo.js +29 -0
- package/gen/schemas/$Group.d.ts +23 -0
- package/gen/schemas/$Group.js +26 -0
- package/gen/schemas/$Job.d.ts +17 -0
- package/gen/schemas/$Job.js +20 -0
- package/gen/schemas/$ListableVariable.d.ts +35 -0
- package/gen/schemas/$ListableVariable.js +38 -0
- package/gen/schemas/$Login.d.ts +12 -0
- package/gen/schemas/$Login.js +15 -0
- package/gen/schemas/$MainArgSignature.d.ts +50 -0
- package/gen/schemas/$MainArgSignature.js +53 -0
- package/gen/schemas/$NewSchedule.d.ts +30 -0
- package/gen/schemas/$NewSchedule.js +33 -0
- package/gen/schemas/$NewToken.d.ts +11 -0
- package/gen/schemas/$NewToken.js +14 -0
- package/gen/schemas/$NewUser.d.ts +16 -0
- package/gen/schemas/$NewUser.js +19 -0
- package/gen/schemas/$Preview.d.ts +19 -0
- package/gen/schemas/$Preview.js +22 -0
- package/gen/schemas/$QueuedJob.d.ts +139 -0
- package/gen/schemas/$QueuedJob.js +144 -0
- package/gen/schemas/$Resource.d.ts +31 -0
- package/gen/schemas/$Resource.js +34 -0
- package/gen/schemas/$ResourceType.d.ts +17 -0
- package/gen/schemas/$ResourceType.js +20 -0
- package/gen/schemas/$Schedule.d.ts +47 -0
- package/gen/schemas/$Schedule.js +50 -0
- package/gen/schemas/$Script.d.ts +77 -0
- package/gen/schemas/$Script.js +80 -0
- package/gen/schemas/$ScriptArgs.d.ts +6 -0
- package/gen/schemas/$ScriptArgs.js +9 -0
- package/gen/schemas/$SlackToken.d.ts +24 -0
- package/gen/schemas/$SlackToken.js +27 -0
- package/gen/schemas/$TokenResponse.d.ts +23 -0
- package/gen/schemas/$TokenResponse.js +26 -0
- package/gen/schemas/$TruncatedToken.d.ts +25 -0
- package/gen/schemas/$TruncatedToken.js +28 -0
- package/gen/schemas/$Usage.d.ts +13 -0
- package/gen/schemas/$Usage.js +16 -0
- package/gen/schemas/$User.d.ts +42 -0
- package/gen/schemas/$User.js +45 -0
- package/gen/schemas/$UserWorkspaceList.d.ts +28 -0
- package/gen/schemas/$UserWorkspaceList.js +31 -0
- package/gen/schemas/$WorkerPing.d.ts +31 -0
- package/gen/schemas/$WorkerPing.js +34 -0
- package/gen/schemas/$Workspace.d.ts +19 -0
- package/gen/schemas/$Workspace.js +22 -0
- package/gen/schemas/$WorkspaceInvite.d.ts +16 -0
- package/gen/schemas/$WorkspaceInvite.js +19 -0
- package/gen/services/FlowService.d.ts +24 -23
- package/gen/services/FlowService.js +14 -0
- package/gen/services/JobService.d.ts +1 -1
- package/gen/services/ScriptService.d.ts +13 -19
- package/gen/services/ScriptService.js +0 -14
- package/gen/services/WorkspaceService.d.ts +1 -1
- package/gen/services/WorkspaceService.js +1 -1
- package/infer.js +8 -1
- package/package.json +85 -16
- package/script_helpers.d.ts +1 -1
- package/script_helpers.js +11 -13
- package/sql.d.ts +89 -0
- package/sql.js +817 -0
- package/stores.d.ts +0 -1
- package/stores.js +0 -6
- package/utils.d.ts +12 -5
- package/utils.js +55 -9
- package/components/RadioButtonV2.svelte +0 -33
- package/components/RadioButtonV2.svelte.d.ts +0 -20
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
export const OFFSET = new Date().getTimezoneOffset()
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script>import { ScheduleService } from '../gen';
|
|
6
|
+
import { displayDate, formatCron, sendUserToast } from '../utils';
|
|
7
|
+
import CollapseLink from './CollapseLink.svelte';
|
|
8
|
+
export let validCRON = true;
|
|
9
|
+
let preview = [];
|
|
10
|
+
let cronError = '';
|
|
11
|
+
export let schedule = '0 0 12 * *';
|
|
12
|
+
let limit = 3;
|
|
13
|
+
$: handleScheduleInput(schedule);
|
|
14
|
+
async function handleScheduleInput(input) {
|
|
15
|
+
try {
|
|
16
|
+
preview = await ScheduleService.previewSchedule({
|
|
17
|
+
requestBody: { schedule: formatCron(input), offset: OFFSET }
|
|
18
|
+
});
|
|
19
|
+
cronError = '';
|
|
20
|
+
validCRON = true;
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
if (err.status == 400 && err.body.includes('cron')) {
|
|
24
|
+
cronError = `Invalid cron expression`;
|
|
25
|
+
validCRON = false;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
sendUserToast(`Cannot preview: ${err}`, true);
|
|
29
|
+
validCRON = false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<div class="text-purple-500 text-2xs grow">{cronError}</div>
|
|
36
|
+
<div class="flex flex-row items-end max-w-5xl">
|
|
37
|
+
<label class="text-xs min-w-max mr-2 self-center" for="cron-schedule">CRON expression</label>
|
|
38
|
+
<input
|
|
39
|
+
class="inline-block"
|
|
40
|
+
type="text"
|
|
41
|
+
id="cron-schedule"
|
|
42
|
+
name="cron-schedule"
|
|
43
|
+
bind:value={schedule}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="flex flex-row text-xs text-blue-500 gap-3 pl-28">
|
|
47
|
+
<button
|
|
48
|
+
on:click={() => {
|
|
49
|
+
schedule = '0 */15 * * *'
|
|
50
|
+
cronError = ''
|
|
51
|
+
}}>every 15 min</button
|
|
52
|
+
>
|
|
53
|
+
<button
|
|
54
|
+
on:click={() => {
|
|
55
|
+
schedule = '0 0 * * * *'
|
|
56
|
+
cronError = ''
|
|
57
|
+
}}>every hour</button
|
|
58
|
+
>
|
|
59
|
+
<button
|
|
60
|
+
on:click={() => {
|
|
61
|
+
schedule = '0 0 8 * * *'
|
|
62
|
+
cronError = ''
|
|
63
|
+
}}>once a day at 8AM</button
|
|
64
|
+
>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<CollapseLink text="preview next runs" open={true}>
|
|
68
|
+
{#if preview && preview.length > 0}
|
|
69
|
+
<div class="text-sm text-gray-700 border p-2 rounded-md">
|
|
70
|
+
<div class="flex flex-row justify-between">The next runs will be scheduled at:</div>
|
|
71
|
+
<ul class="list-disc mx-12">
|
|
72
|
+
{#each preview.slice(0, limit) as p}
|
|
73
|
+
<li class="mx-2 text-gray-700 text-sm">{displayDate(p)}</li>
|
|
74
|
+
{/each}
|
|
75
|
+
<li class="text-sm mx-2">...</li>
|
|
76
|
+
{#if limit != 10}
|
|
77
|
+
<button class="underline text-gray-400" on:click={() => (limit = 10)}>Load more</button>
|
|
78
|
+
{:else}
|
|
79
|
+
<button class="underline text-gray-400" on:click={() => (limit = 3)}>Load less</button>
|
|
80
|
+
{/if}
|
|
81
|
+
</ul>
|
|
82
|
+
</div>
|
|
83
|
+
{/if}
|
|
84
|
+
</CollapseLink>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
export declare const OFFSET: number;
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
validCRON?: boolean | undefined;
|
|
6
|
+
schedule?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {};
|
|
12
|
+
};
|
|
13
|
+
export declare type CronInputProps = typeof __propDef.props;
|
|
14
|
+
export declare type CronInputEvents = typeof __propDef.events;
|
|
15
|
+
export declare type CronInputSlots = typeof __propDef.slots;
|
|
16
|
+
export default class CronInput extends SvelteComponentTyped<CronInputProps, CronInputEvents, CronInputSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
<script>import { Highlight } from 'svelte-highlight';
|
|
2
|
-
import github from 'svelte-highlight/styles/github';
|
|
3
2
|
import { json } from 'svelte-highlight/languages';
|
|
4
3
|
import TableCustom from './TableCustom.svelte';
|
|
4
|
+
import { truncate } from '../utils';
|
|
5
5
|
export let result;
|
|
6
6
|
let resultKind = inferResultKind(result);
|
|
7
|
-
function isArray(obj) {
|
|
8
|
-
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
9
|
-
}
|
|
10
7
|
function isRectangularArray(obj) {
|
|
11
|
-
if (!isArray(obj) || obj.length == 0) {
|
|
8
|
+
if (!Array.isArray(obj) || obj.length == 0) {
|
|
12
9
|
return false;
|
|
13
10
|
}
|
|
14
11
|
if (!Object.values(obj)
|
|
15
|
-
.map(isArray)
|
|
12
|
+
.map(Array.isArray)
|
|
16
13
|
.reduce((a, b) => a && b)) {
|
|
17
14
|
return false;
|
|
18
15
|
}
|
|
@@ -28,15 +25,18 @@ function inferResultKind(result) {
|
|
|
28
25
|
if (result) {
|
|
29
26
|
try {
|
|
30
27
|
let keys = Object.keys(result);
|
|
31
|
-
if (
|
|
28
|
+
if (isRectangularArray(result)) {
|
|
32
29
|
return 'table-row';
|
|
33
30
|
}
|
|
34
|
-
else if (keys.map((k) => isArray(result[k])).reduce((a, b) => a && b)) {
|
|
31
|
+
else if (keys.map((k) => Array.isArray(result[k])).reduce((a, b) => a && b)) {
|
|
35
32
|
return 'table-col';
|
|
36
33
|
}
|
|
37
34
|
else if (keys.length == 1 && keys[0] == 'png') {
|
|
38
35
|
return 'png';
|
|
39
36
|
}
|
|
37
|
+
else if (keys.length == 1 && keys[0] == 'jpeg') {
|
|
38
|
+
return 'jpeg';
|
|
39
|
+
}
|
|
40
40
|
else if (keys.length == 1 && keys[0] == 'file') {
|
|
41
41
|
return 'file';
|
|
42
42
|
}
|
|
@@ -47,24 +47,21 @@ function inferResultKind(result) {
|
|
|
47
47
|
}
|
|
48
48
|
</script>
|
|
49
49
|
|
|
50
|
-
<svelte:head>
|
|
51
|
-
{@html github}
|
|
52
|
-
</svelte:head>
|
|
53
50
|
{#if result}
|
|
54
|
-
{#if Object.keys(result).length > 0}<div>
|
|
51
|
+
{#if typeof result == 'object' && Object.keys(result).length > 0}<div>
|
|
55
52
|
The result keys are: <b>{Object.keys(result).join(', ')}</b>
|
|
56
53
|
</div>
|
|
57
54
|
{/if}
|
|
58
55
|
{#if resultKind == 'table-col'}
|
|
59
56
|
<div class="grid grid-flow-col-dense border border-gray-200 rounded-md ">
|
|
60
57
|
{#each Object.keys(result) as col}
|
|
61
|
-
<div class="flex flex-col
|
|
58
|
+
<div class="flex flex-col max-h-40 min-w-full overflow-auto">
|
|
62
59
|
<div class="px-12 text-left uppercase border-b bg-gray-50 overflow-hidden rounded-t-md ">
|
|
63
60
|
{col}
|
|
64
61
|
</div>
|
|
65
62
|
{#if Array.isArray(result[col])}
|
|
66
63
|
{#each result[col] as item}
|
|
67
|
-
<div class="px-12 text-left">
|
|
64
|
+
<div class="px-12 text-left whitespace-nowrap">
|
|
68
65
|
{typeof item === 'string' ? item : JSON.stringify(item)}
|
|
69
66
|
</div>
|
|
70
67
|
{/each}
|
|
@@ -80,7 +77,7 @@ function inferResultKind(result) {
|
|
|
80
77
|
{#each asListOfList(Object.values(result)[0]) as row}
|
|
81
78
|
<tr>
|
|
82
79
|
{#each row as v}
|
|
83
|
-
<td>{v ?? ''}</td>
|
|
80
|
+
<td>{truncate(v, 200) ?? ''}</td>
|
|
84
81
|
{/each}
|
|
85
82
|
</tr>
|
|
86
83
|
{/each}
|
|
@@ -95,6 +92,22 @@ function inferResultKind(result) {
|
|
|
95
92
|
src="data:image/png;base64,{result.png}"
|
|
96
93
|
/>
|
|
97
94
|
</div>
|
|
95
|
+
{:else if resultKind == 'jpeg'}
|
|
96
|
+
<div class="h-full">
|
|
97
|
+
Result is an image: <img
|
|
98
|
+
alt="jpeg rendered"
|
|
99
|
+
class="w-auto h-full"
|
|
100
|
+
src="data:image/jpeg;base64,{result.jpeg}"
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
{:else if resultKind == 'gif'}
|
|
104
|
+
<div class="h-full">
|
|
105
|
+
Result is an image: <img
|
|
106
|
+
alt="gif rendered"
|
|
107
|
+
class="w-auto h-full"
|
|
108
|
+
src="data:image/gif;base64,{result.gif}"
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
98
111
|
{:else if resultKind == 'file'}
|
|
99
112
|
<div>
|
|
100
113
|
Result is a file: <a
|
package/components/Editor.svelte
CHANGED
|
@@ -1,11 +1,48 @@
|
|
|
1
|
+
<script context="module">import * as monaco from 'monaco-editor';
|
|
2
|
+
import { language as sql } from 'monaco-editor/esm/vs/basic-languages/sql/sql';
|
|
3
|
+
monaco.languages.register({
|
|
4
|
+
id: 'python',
|
|
5
|
+
extensions: ['.py'],
|
|
6
|
+
aliases: ['python'],
|
|
7
|
+
mimetypes: ['application/text']
|
|
8
|
+
});
|
|
9
|
+
monaco.languages.register({
|
|
10
|
+
id: 'sql',
|
|
11
|
+
extensions: ['.sql'],
|
|
12
|
+
aliases: ['SQL'],
|
|
13
|
+
mimetypes: ['application/text']
|
|
14
|
+
});
|
|
15
|
+
monaco.languages.registerInlineCompletionsProvider('sql', {
|
|
16
|
+
provideInlineCompletions: (a, b, c, d) => {
|
|
17
|
+
const w = a.getWordUntilPosition(b).word.toLowerCase();
|
|
18
|
+
return {
|
|
19
|
+
items: w.length > 0
|
|
20
|
+
? ['SELECT', 'FROM', 'WHILE', 'AND', 'OR', 'DELETE', 'UPDATE', 'SET', 'WHEN', 'LIMIT']
|
|
21
|
+
.concat(sql.keywords)
|
|
22
|
+
.filter((x) => x.toLowerCase().startsWith(w))
|
|
23
|
+
.map((x) => ({
|
|
24
|
+
text: x + ' '
|
|
25
|
+
}))
|
|
26
|
+
: []
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
freeInlineCompletions: () => { }
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
32
|
+
|
|
1
33
|
<script>import { browser, dev } from '$app/env';
|
|
2
34
|
import { page } from '$app/stores';
|
|
3
|
-
import {
|
|
35
|
+
import { sendUserToast } from '../utils';
|
|
4
36
|
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
|
5
37
|
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
|
6
38
|
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
|
7
39
|
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
|
8
40
|
import { buildWorkerDefinition } from 'monaco-editor-workers';
|
|
41
|
+
import { StandaloneServices } from 'vscode/services';
|
|
42
|
+
import getMessageServiceOverride from 'vscode/service-override/messages';
|
|
43
|
+
StandaloneServices.initialize({
|
|
44
|
+
...getMessageServiceOverride(document.body)
|
|
45
|
+
});
|
|
9
46
|
let divEl = null;
|
|
10
47
|
let editor;
|
|
11
48
|
export let deno = false;
|
|
@@ -16,13 +53,15 @@ export let cmdEnterAction = undefined;
|
|
|
16
53
|
export let formatAction = undefined;
|
|
17
54
|
export let automaticLayout = true;
|
|
18
55
|
export let websocketAlive = { pyright: false, black: false, deno: false };
|
|
19
|
-
export let extraLib =
|
|
20
|
-
export let extraLibPath = '
|
|
56
|
+
export let extraLib = '';
|
|
57
|
+
export let extraLibPath = '';
|
|
21
58
|
let websockets = [];
|
|
22
59
|
let websocketInterval;
|
|
23
|
-
let
|
|
60
|
+
let lastWsAttempt = new Date();
|
|
61
|
+
let nbWsAttempt = 0;
|
|
24
62
|
let disposeMethod;
|
|
25
63
|
const dispatch = createEventDispatcher();
|
|
64
|
+
const uri = `file:///${hash}.${langToExt(lang)}`;
|
|
26
65
|
if (browser) {
|
|
27
66
|
if (dev) {
|
|
28
67
|
buildWorkerDefinition('../../../node_modules/monaco-editor-workers/dist/workers', import.meta.url, false);
|
|
@@ -52,6 +91,22 @@ export function insertAtCursor(code) {
|
|
|
52
91
|
editor.trigger('keyboard', 'type', { text: code });
|
|
53
92
|
}
|
|
54
93
|
}
|
|
94
|
+
function langToExt(lang) {
|
|
95
|
+
switch (lang) {
|
|
96
|
+
case 'typescript':
|
|
97
|
+
return 'ts';
|
|
98
|
+
case 'python':
|
|
99
|
+
return 'py';
|
|
100
|
+
case 'javascript':
|
|
101
|
+
return 'js';
|
|
102
|
+
case 'json':
|
|
103
|
+
return 'json';
|
|
104
|
+
case 'sql':
|
|
105
|
+
return 'sql';
|
|
106
|
+
default:
|
|
107
|
+
return 'unknown';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
55
110
|
export function insertAtBeginning(code) {
|
|
56
111
|
if (editor) {
|
|
57
112
|
const range = { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 };
|
|
@@ -76,14 +131,15 @@ function format() {
|
|
|
76
131
|
}
|
|
77
132
|
}
|
|
78
133
|
export async function reloadWebsocket() {
|
|
79
|
-
closeWebsockets();
|
|
134
|
+
await closeWebsockets();
|
|
80
135
|
if (lang == 'python' || deno) {
|
|
81
|
-
// install Monaco language client services
|
|
82
136
|
const { MonacoLanguageClient } = await import('monaco-languageclient');
|
|
83
137
|
const { CloseAction, ErrorAction } = await import('vscode-languageclient');
|
|
84
|
-
const vscode = await import('vscode');
|
|
85
138
|
const { toSocket, WebSocketMessageReader, WebSocketMessageWriter } = await import('vscode-ws-jsonrpc');
|
|
139
|
+
const vscode = await import('vscode');
|
|
86
140
|
const { RequestType } = await import('vscode-jsonrpc');
|
|
141
|
+
const { MonacoServices } = await import('monaco-languageclient');
|
|
142
|
+
MonacoServices.install();
|
|
87
143
|
function createLanguageClient(transports, name, initializationOptions) {
|
|
88
144
|
const client = new MonacoLanguageClient({
|
|
89
145
|
name: name,
|
|
@@ -92,7 +148,7 @@ export async function reloadWebsocket() {
|
|
|
92
148
|
errorHandler: {
|
|
93
149
|
error: () => ({ action: ErrorAction.Continue }),
|
|
94
150
|
closed: () => ({
|
|
95
|
-
action: CloseAction.
|
|
151
|
+
action: CloseAction.Restart
|
|
96
152
|
})
|
|
97
153
|
},
|
|
98
154
|
markdown: {
|
|
@@ -124,23 +180,14 @@ export async function reloadWebsocket() {
|
|
|
124
180
|
try {
|
|
125
181
|
const webSocket = new WebSocket(url);
|
|
126
182
|
webSocket.onopen = () => {
|
|
127
|
-
websockets.push(webSocket);
|
|
128
183
|
const socket = toSocket(webSocket);
|
|
129
184
|
const reader = new WebSocketMessageReader(socket);
|
|
130
185
|
const writer = new WebSocketMessageWriter(socket);
|
|
131
186
|
const languageClient = createLanguageClient({ reader, writer }, name, options);
|
|
187
|
+
websockets.push([languageClient, webSocket]);
|
|
132
188
|
languageClient.start();
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
languageClient.stop();
|
|
136
|
-
}
|
|
137
|
-
catch (err) {
|
|
138
|
-
console.error(err);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
socket.onClose((_code, _reason) => {
|
|
142
|
-
websocketAlive[name] = false;
|
|
143
|
-
});
|
|
189
|
+
lastWsAttempt = new Date();
|
|
190
|
+
nbWsAttempt = 0;
|
|
144
191
|
if (name == 'deno') {
|
|
145
192
|
vscode.commands.getCommands().then((v) => {
|
|
146
193
|
if (!v.includes('deno.cache')) {
|
|
@@ -153,6 +200,18 @@ export async function reloadWebsocket() {
|
|
|
153
200
|
}
|
|
154
201
|
});
|
|
155
202
|
}
|
|
203
|
+
reader.onClose(() => {
|
|
204
|
+
try {
|
|
205
|
+
console.log('CLOSE');
|
|
206
|
+
languageClient.stop();
|
|
207
|
+
}
|
|
208
|
+
catch (err) {
|
|
209
|
+
console.error(err);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
socket.onClose((_code, _reason) => {
|
|
213
|
+
websocketAlive[name] = false;
|
|
214
|
+
});
|
|
156
215
|
websocketAlive[name] = true;
|
|
157
216
|
};
|
|
158
217
|
}
|
|
@@ -171,7 +230,7 @@ export async function reloadWebsocket() {
|
|
|
171
230
|
path: null,
|
|
172
231
|
tlsCertificate: null,
|
|
173
232
|
unsafelyIgnoreCertificateErrors: null,
|
|
174
|
-
unstable:
|
|
233
|
+
unstable: true,
|
|
175
234
|
enable: true,
|
|
176
235
|
cache: null,
|
|
177
236
|
codeLens: {
|
|
@@ -218,18 +277,30 @@ export async function reloadWebsocket() {
|
|
|
218
277
|
websocketInterval && clearInterval(websocketInterval);
|
|
219
278
|
websocketInterval = setInterval(() => {
|
|
220
279
|
if (document.visibilityState == 'visible') {
|
|
221
|
-
if (!
|
|
222
|
-
|
|
223
|
-
|
|
280
|
+
if (!lastWsAttempt ||
|
|
281
|
+
(lastWsAttempt.getTime() - new Date().getTime() > 60000 && nbWsAttempt < 2)) {
|
|
282
|
+
if (!websocketAlive.black && !websocketAlive.deno && !websocketAlive.pyright) {
|
|
283
|
+
console.log('reconnecting to language servers');
|
|
284
|
+
lastWsAttempt = new Date();
|
|
285
|
+
nbWsAttempt++;
|
|
286
|
+
reloadWebsocket();
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
if (nbWsAttempt >= 2) {
|
|
290
|
+
sendUserToast('Giving up on establishing smart assistant connection', true);
|
|
291
|
+
clearInterval(websocketInterval);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
224
294
|
}
|
|
225
295
|
}
|
|
226
296
|
}, 5000);
|
|
227
297
|
}
|
|
228
298
|
}
|
|
229
|
-
function closeWebsockets() {
|
|
299
|
+
async function closeWebsockets() {
|
|
230
300
|
for (const x of websockets) {
|
|
231
301
|
try {
|
|
232
|
-
x.
|
|
302
|
+
await x[0].stop();
|
|
303
|
+
x[1].close();
|
|
233
304
|
}
|
|
234
305
|
catch (err) {
|
|
235
306
|
console.log('error disposing websocket', err);
|
|
@@ -239,37 +310,15 @@ function closeWebsockets() {
|
|
|
239
310
|
websocketInterval && clearInterval(websocketInterval);
|
|
240
311
|
}
|
|
241
312
|
async function loadMonaco() {
|
|
242
|
-
const monaco = await import('monaco-editor');
|
|
243
|
-
if (lang == 'python') {
|
|
244
|
-
monaco.languages.register({
|
|
245
|
-
id: 'python',
|
|
246
|
-
extensions: ['.py'],
|
|
247
|
-
aliases: ['python'],
|
|
248
|
-
mimetypes: ['application/text']
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
let path = 'unknown';
|
|
252
|
-
if (lang == 'python') {
|
|
253
|
-
path = `${hash}.py`;
|
|
254
|
-
}
|
|
255
|
-
else if (lang == 'json') {
|
|
256
|
-
path = `${hash}.json`;
|
|
257
|
-
}
|
|
258
|
-
else if (lang == 'javascript') {
|
|
259
|
-
path = `${hash}.js`;
|
|
260
|
-
}
|
|
261
|
-
else if (lang == 'typescript') {
|
|
262
|
-
path = `${hash}.ts`;
|
|
263
|
-
}
|
|
264
|
-
uri = `file:///${path}`;
|
|
265
313
|
const model = monaco.editor.createModel(code, lang, monaco.Uri.parse(uri));
|
|
266
|
-
model.updateOptions({ tabSize:
|
|
314
|
+
model.updateOptions({ tabSize: 2, insertSpaces: true });
|
|
267
315
|
editor = monaco.editor.create(divEl, {
|
|
268
316
|
model: model,
|
|
269
317
|
value: code,
|
|
270
318
|
language: lang,
|
|
271
319
|
automaticLayout,
|
|
272
320
|
readOnly: false,
|
|
321
|
+
fixedOverflowWidgets: true,
|
|
273
322
|
autoDetectHighContrast: true,
|
|
274
323
|
//lineNumbers: 'off',
|
|
275
324
|
//lineDecorationsWidth: 0,
|
|
@@ -299,7 +348,16 @@ async function loadMonaco() {
|
|
|
299
348
|
code = getCode();
|
|
300
349
|
dispatch('change');
|
|
301
350
|
});
|
|
302
|
-
|
|
351
|
+
editor.onDidFocusEditorText(() => {
|
|
352
|
+
dispatch('focus');
|
|
353
|
+
});
|
|
354
|
+
editor.onDidBlurEditorText(() => {
|
|
355
|
+
dispatch('blur');
|
|
356
|
+
});
|
|
357
|
+
if (lang == 'sql') {
|
|
358
|
+
monaco.languages.register;
|
|
359
|
+
}
|
|
360
|
+
else if (lang == 'json') {
|
|
303
361
|
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
304
362
|
validate: true,
|
|
305
363
|
allowComments: false,
|
|
@@ -307,28 +365,36 @@ async function loadMonaco() {
|
|
|
307
365
|
enableSchemaRequest: true
|
|
308
366
|
});
|
|
309
367
|
}
|
|
310
|
-
if (lang == 'typescript') {
|
|
311
|
-
monaco.languages.typescript.
|
|
368
|
+
else if (lang == 'javascript' || lang == 'typescript') {
|
|
369
|
+
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
|
312
370
|
target: monaco.languages.typescript.ScriptTarget.Latest,
|
|
313
371
|
allowNonTsExtensions: true,
|
|
314
372
|
noLib: true
|
|
315
373
|
});
|
|
316
|
-
if (
|
|
317
|
-
monaco.languages.typescript.typescriptDefaults.
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
374
|
+
if (lang == 'typescript') {
|
|
375
|
+
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
376
|
+
target: monaco.languages.typescript.ScriptTarget.Latest,
|
|
377
|
+
allowNonTsExtensions: true,
|
|
378
|
+
noLib: true
|
|
321
379
|
});
|
|
380
|
+
if (deno) {
|
|
381
|
+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
382
|
+
noSemanticValidation: true,
|
|
383
|
+
noSuggestionDiagnostics: true,
|
|
384
|
+
noSyntaxValidation: true
|
|
385
|
+
});
|
|
386
|
+
}
|
|
322
387
|
}
|
|
323
|
-
|
|
324
|
-
|
|
388
|
+
if (lang == 'javascript') {
|
|
389
|
+
if (extraLib != '' && extraLibPath != '') {
|
|
390
|
+
monaco.languages.typescript.javascriptDefaults.addExtraLib(extraLib, extraLibPath);
|
|
391
|
+
}
|
|
325
392
|
}
|
|
326
393
|
}
|
|
327
394
|
if (lang == 'python' || deno) {
|
|
328
|
-
|
|
329
|
-
|
|
395
|
+
// install Monaco language client services
|
|
396
|
+
reloadWebsocket();
|
|
330
397
|
}
|
|
331
|
-
reloadWebsocket();
|
|
332
398
|
return () => {
|
|
333
399
|
if (editor) {
|
|
334
400
|
try {
|
|
@@ -347,9 +413,8 @@ onMount(() => {
|
|
|
347
413
|
}
|
|
348
414
|
});
|
|
349
415
|
onDestroy(() => {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
416
|
+
disposeMethod && disposeMethod();
|
|
417
|
+
websocketInterval && clearInterval(websocketInterval);
|
|
353
418
|
});
|
|
354
419
|
</script>
|
|
355
420
|
|
|
@@ -375,4 +440,9 @@ onDestroy(() => {
|
|
|
375
440
|
.few-lines-editor {
|
|
376
441
|
/* stylelint-disable-next-line unit-allowed-list */
|
|
377
442
|
height: 80px;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.two-lines-editor {
|
|
446
|
+
/* stylelint-disable-next-line unit-allowed-list */
|
|
447
|
+
height: 40px;
|
|
378
448
|
}</style>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<script>import { ResourceService, ScriptService, VariableService } from '../gen';
|
|
2
2
|
import { getScriptByPath, loadHubScripts, sendUserToast } from '../utils';
|
|
3
|
-
import Icon from 'svelte-awesome';
|
|
4
3
|
import { faSearch } from '@fortawesome/free-solid-svg-icons';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import ResourceEditor from './ResourceEditor.svelte';
|
|
4
|
+
import Icon from 'svelte-awesome';
|
|
5
|
+
import { hubScripts, workspaceStore } from '../stores';
|
|
6
|
+
import { Button } from 'flowbite-svelte';
|
|
9
7
|
import { Highlight } from 'svelte-highlight';
|
|
10
8
|
import { python, typescript } from 'svelte-highlight/languages';
|
|
11
|
-
import
|
|
9
|
+
import ItemPicker from './ItemPicker.svelte';
|
|
12
10
|
import Modal from './Modal.svelte';
|
|
11
|
+
import ResourceEditor from './ResourceEditor.svelte';
|
|
12
|
+
import VariableEditor from './VariableEditor.svelte';
|
|
13
13
|
export let lang;
|
|
14
14
|
export let editor;
|
|
15
15
|
export let websocketAlive;
|
|
@@ -42,10 +42,6 @@ async function loadScripts() {
|
|
|
42
42
|
}
|
|
43
43
|
</script>
|
|
44
44
|
|
|
45
|
-
<svelte:head>
|
|
46
|
-
{@html github}
|
|
47
|
-
</svelte:head>
|
|
48
|
-
|
|
49
45
|
<ItemPicker
|
|
50
46
|
bind:this={scriptPicker}
|
|
51
47
|
pickCallback={async (path, _) => {
|
|
@@ -164,41 +160,56 @@ async function loadScripts() {
|
|
|
164
160
|
|
|
165
161
|
<VariableEditor bind:this={variableEditor} on:create={variablePicker.openModal} />
|
|
166
162
|
|
|
167
|
-
<div class="flex flex-row
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
163
|
+
<div class="flex flex-row w-full">
|
|
164
|
+
<div class="flex flex-row w-full space-x-2 whitespace-nowrap">
|
|
165
|
+
<Button
|
|
166
|
+
size="xs"
|
|
167
|
+
color="alternative"
|
|
168
|
+
on:click={() => {
|
|
169
|
+
variablePicker.openModal()
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
<Icon data={faSearch} scale={0.7} class="mr-2" />
|
|
173
|
+
Variable picker
|
|
174
|
+
</Button>
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
scriptPicker.openModal()
|
|
187
|
-
}}
|
|
188
|
-
>Script explorer <Icon data={faSearch} scale={0.7} />
|
|
189
|
-
</button>
|
|
176
|
+
<Button
|
|
177
|
+
size="xs"
|
|
178
|
+
color="alternative"
|
|
179
|
+
on:click={() => {
|
|
180
|
+
resourcePicker.openModal()
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
<Icon data={faSearch} scale={0.7} class="mr-2" />
|
|
184
|
+
Resource picker
|
|
185
|
+
</Button>
|
|
190
186
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
187
|
+
<Button
|
|
188
|
+
size="xs"
|
|
189
|
+
color="alternative"
|
|
190
|
+
on:click={() => {
|
|
191
|
+
scriptPicker.openModal()
|
|
192
|
+
}}
|
|
193
|
+
>
|
|
194
|
+
<Icon data={faSearch} scale={0.7} class="mr-2" />
|
|
195
|
+
Script explorer
|
|
196
|
+
</Button>
|
|
197
|
+
</div>
|
|
198
|
+
<div class="flex flex-row-reverse w-full">
|
|
199
|
+
<Button
|
|
200
|
+
size="xs"
|
|
201
|
+
color="alternative"
|
|
202
|
+
on:click={() => {
|
|
203
|
+
editor.reloadWebsocket()
|
|
204
|
+
}}
|
|
205
|
+
>
|
|
206
|
+
Reload assistants (status:
|
|
207
|
+
{#if lang == 'deno'}
|
|
208
|
+
<span class={websocketAlive.deno ? 'text-green-600' : 'text-red-600'}>Deno</span>
|
|
209
|
+
{:else if lang == 'python3'}
|
|
210
|
+
<span class={websocketAlive.pyright ? 'text-green-600' : 'text-red-600'}>Pyright</span>
|
|
211
|
+
<span class={websocketAlive.black ? 'text-green-600' : 'text-red-600'}>Black</span>
|
|
212
|
+
{/if})
|
|
213
|
+
</Button>
|
|
214
|
+
</div>
|
|
204
215
|
</div>
|