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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script>import { faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import Icon from 'svelte-awesome';
|
|
3
|
+
import { slide } from 'svelte/transition';
|
|
4
|
+
$: opened = false;
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="text-xs flex flex-row-reverse">
|
|
8
|
+
<span
|
|
9
|
+
class="underline mr-4"
|
|
10
|
+
on:click={() => {
|
|
11
|
+
opened = !opened
|
|
12
|
+
}}
|
|
13
|
+
>
|
|
14
|
+
Help
|
|
15
|
+
<Icon class="ml-2" data={opened ? faChevronUp : faChevronDown} scale={0.7} />
|
|
16
|
+
</span>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
{#if opened}
|
|
20
|
+
<div
|
|
21
|
+
transition:slide
|
|
22
|
+
class="bg-gray-100 border-l-4 border-gray-600 text-gray-700 p-4 m-4"
|
|
23
|
+
role="alert"
|
|
24
|
+
id="dynamic-input-help-box"
|
|
25
|
+
>
|
|
26
|
+
<p class="font-bold">Dynamic arg help</p>
|
|
27
|
+
<p>
|
|
28
|
+
When a field is "dynamic", its value is computed dynamically as the evaluation of its
|
|
29
|
+
corresponding typescript snippet.
|
|
30
|
+
</p>
|
|
31
|
+
That snippet can be single line:
|
|
32
|
+
<pre><code>last_result.myarg</code></pre>
|
|
33
|
+
or multiline:
|
|
34
|
+
<pre><code
|
|
35
|
+
>let x = 5;
|
|
36
|
+
x + 2</code
|
|
37
|
+
></pre>
|
|
38
|
+
<p>
|
|
39
|
+
If it is multiline, the last statement before the final expression<b
|
|
40
|
+
>MUST END WITH ; and a newline</b
|
|
41
|
+
>
|
|
42
|
+
</p>
|
|
43
|
+
The snippet can also be a string template:
|
|
44
|
+
<pre><code
|
|
45
|
+
>`Hello ${params.name}, all your base ${previous_result.base_name}
|
|
46
|
+
belong to us`</code
|
|
47
|
+
></pre>
|
|
48
|
+
However, the last line must always be the final expression.
|
|
49
|
+
<p>
|
|
50
|
+
The snippet can use any typescript primitives, and the following flow specific objects and
|
|
51
|
+
functions:
|
|
52
|
+
</p>
|
|
53
|
+
<ul class="ml-4">
|
|
54
|
+
<li>
|
|
55
|
+
<b>previous_result</b>: the object containing the result of the previous step
|
|
56
|
+
</li>
|
|
57
|
+
<li><b>flow_input</b>: the object containing the flow input arguments</li>
|
|
58
|
+
<li><b>params</b>: the object containing the current step static values</li>
|
|
59
|
+
<li>
|
|
60
|
+
<b>step(n)</b>: the function returning the result of step number n. One can also use a
|
|
61
|
+
negative n. step(0) == flow_input , step(-1) == previous_result
|
|
62
|
+
</li>
|
|
63
|
+
<li>
|
|
64
|
+
<b>variable(path)</b>: the function returning the variable (including secrets) at given path
|
|
65
|
+
as a string
|
|
66
|
+
</li>
|
|
67
|
+
<li>
|
|
68
|
+
<b>resource(path)</b>: the function returning the resource at a given path as an object
|
|
69
|
+
</li>
|
|
70
|
+
</ul>
|
|
71
|
+
</div>
|
|
72
|
+
{/if}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {};
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export declare type DynamicInputHelpBoxProps = typeof __propDef.props;
|
|
10
|
+
export declare type DynamicInputHelpBoxEvents = typeof __propDef.events;
|
|
11
|
+
export declare type DynamicInputHelpBoxSlots = typeof __propDef.slots;
|
|
12
|
+
export default class DynamicInputHelpBox extends SvelteComponentTyped<DynamicInputHelpBoxProps, DynamicInputHelpBoxEvents, DynamicInputHelpBoxSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script>import { FlowModuleValue } from '../../gen/models/FlowModuleValue';
|
|
2
|
+
import { faCode } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
import { createEventDispatcher } from 'svelte';
|
|
4
|
+
import FlowScriptPicker from './pickers/FlowScriptPicker.svelte';
|
|
5
|
+
import PickHubScript from './pickers/PickHubScript.svelte';
|
|
6
|
+
import PickScript from './pickers/PickScript.svelte';
|
|
7
|
+
export let isTrigger;
|
|
8
|
+
const dispatch = createEventDispatcher();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class="columns-2">
|
|
12
|
+
<PickScript {isTrigger} on:pick />
|
|
13
|
+
<PickHubScript {isTrigger} on:pick />
|
|
14
|
+
<FlowScriptPicker
|
|
15
|
+
label="New Typescript {isTrigger ? 'trigger ' : ''}script (Deno)"
|
|
16
|
+
icon={faCode}
|
|
17
|
+
iconColor="text-blue-800"
|
|
18
|
+
on:click={() => dispatch('new', { language: FlowModuleValue.language.DENO })}
|
|
19
|
+
/>
|
|
20
|
+
<FlowScriptPicker
|
|
21
|
+
disabled={isTrigger}
|
|
22
|
+
label="New Python {isTrigger ? 'trigger ' : ''}script (3.10)"
|
|
23
|
+
icon={faCode}
|
|
24
|
+
iconColor="text-yellow-500"
|
|
25
|
+
on:click={() => dispatch('new', { language: FlowModuleValue.language.PYTHON3 })}
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
isTrigger: boolean;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
pick: CustomEvent<any>;
|
|
8
|
+
new: CustomEvent<any>;
|
|
9
|
+
} & {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export declare type FlowInputsProps = typeof __propDef.props;
|
|
15
|
+
export declare type FlowInputsEvents = typeof __propDef.events;
|
|
16
|
+
export declare type FlowInputsSlots = typeof __propDef.slots;
|
|
17
|
+
export default class FlowInputs extends SvelteComponentTyped<FlowInputsProps, FlowInputsEvents, FlowInputsSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script>import { FlowModuleValue, Script } from '../../gen';
|
|
2
|
+
import { faCode, faCodeBranch, faSave, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
import Icon from 'svelte-awesome';
|
|
4
|
+
import { Highlight } from 'svelte-highlight';
|
|
5
|
+
import { python, typescript } from 'svelte-highlight/languages';
|
|
6
|
+
import github from 'svelte-highlight/styles/github';
|
|
7
|
+
import Modal from '../Modal.svelte';
|
|
8
|
+
import { createScriptFromInlineScript, fork, removeModule } from './flowStore';
|
|
9
|
+
import { getScriptByPath, scrollIntoView } from './utils';
|
|
10
|
+
export let open;
|
|
11
|
+
export let i;
|
|
12
|
+
export let shouldPick = false;
|
|
13
|
+
export let mod;
|
|
14
|
+
let modalViewer;
|
|
15
|
+
let modalViewerContent = '';
|
|
16
|
+
let modalViewerLanguage = Script.language.DENO;
|
|
17
|
+
async function viewCode() {
|
|
18
|
+
const { content, language } = await getScriptByPath(mod.value.path);
|
|
19
|
+
modalViewerContent = content;
|
|
20
|
+
modalViewerLanguage = language;
|
|
21
|
+
modalViewer.openModal();
|
|
22
|
+
}
|
|
23
|
+
function scrollTo({ target }) {
|
|
24
|
+
const el = document.querySelector(target.getAttribute('href'));
|
|
25
|
+
scrollIntoView(el);
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<svelte:head>
|
|
30
|
+
{@html github}
|
|
31
|
+
</svelte:head>
|
|
32
|
+
|
|
33
|
+
<div class="flex flex-row w-full space-x-2">
|
|
34
|
+
<slot />
|
|
35
|
+
<a href="#module-{i}" class="grow" on:click={() => (open = i)} on:click|preventDefault={scrollTo}
|
|
36
|
+
><div class="w-full" /></a
|
|
37
|
+
>
|
|
38
|
+
|
|
39
|
+
<div class="flex flex-row space-x-2">
|
|
40
|
+
{#if mod.value.type === FlowModuleValue.type.SCRIPT && !shouldPick}
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
on:click={() => {
|
|
44
|
+
open = i
|
|
45
|
+
fork(i)
|
|
46
|
+
}}
|
|
47
|
+
class="default-secondary-button-v2 text-xs"
|
|
48
|
+
>
|
|
49
|
+
<Icon data={faCodeBranch} class={`w-4 mr-2 h-4`} />
|
|
50
|
+
Fork
|
|
51
|
+
</button>
|
|
52
|
+
<button type="button" on:click={viewCode} class="default-secondary-button-v2 text-xs">
|
|
53
|
+
<Icon data={faCode} class="w-4 mr-2 h-4" />
|
|
54
|
+
View code
|
|
55
|
+
</button>
|
|
56
|
+
{/if}
|
|
57
|
+
|
|
58
|
+
{#if mod.value.type === FlowModuleValue.type.RAWSCRIPT && !shouldPick}
|
|
59
|
+
<button
|
|
60
|
+
type="button"
|
|
61
|
+
on:click={() => createScriptFromInlineScript(i)}
|
|
62
|
+
class="default-secondary-button-v2 text-sm"
|
|
63
|
+
>
|
|
64
|
+
<Icon data={faSave} class="w-4 mr-4" />
|
|
65
|
+
Save to workspace
|
|
66
|
+
</button>
|
|
67
|
+
{/if}
|
|
68
|
+
<button
|
|
69
|
+
type="button"
|
|
70
|
+
on:click={() => {
|
|
71
|
+
open = -1
|
|
72
|
+
removeModule(i)
|
|
73
|
+
}}
|
|
74
|
+
class="default-secondary-button-v2 text-xs"
|
|
75
|
+
>
|
|
76
|
+
<Icon data={faTrashAlt} class="w-4 mr-2 h-4" />
|
|
77
|
+
Remove step
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<Modal bind:this={modalViewer}>
|
|
83
|
+
<div slot="title">Script {mod?.value.path}</div>
|
|
84
|
+
<div slot="content">
|
|
85
|
+
{#if modalViewerLanguage === 'python3'}
|
|
86
|
+
<Highlight language={python} code={modalViewerContent} />
|
|
87
|
+
{:else if modalViewerLanguage === 'deno'}
|
|
88
|
+
<Highlight language={typescript} code={modalViewerContent} />
|
|
89
|
+
{/if}
|
|
90
|
+
</div>
|
|
91
|
+
</Modal>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type FlowModule } from '../../gen';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
open: number;
|
|
6
|
+
i: number;
|
|
7
|
+
shouldPick?: boolean | undefined;
|
|
8
|
+
mod: FlowModule;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
default: {};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare type FlowModuleHeaderProps = typeof __propDef.props;
|
|
18
|
+
export declare type FlowModuleHeaderEvents = typeof __propDef.events;
|
|
19
|
+
export declare type FlowModuleHeaderSlots = typeof __propDef.slots;
|
|
20
|
+
export default class FlowModuleHeader extends SvelteComponentTyped<FlowModuleHeaderProps, FlowModuleHeaderEvents, FlowModuleHeaderSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Schema } from '../../common';
|
|
2
|
+
import { FlowModuleValue, type Flow } from '../../gen';
|
|
3
|
+
export declare type FlowMode = 'push' | 'pull';
|
|
4
|
+
export declare const flowStore: import("svelte/store").Writable<Flow>;
|
|
5
|
+
export declare const schemasStore: import("svelte/store").Writable<Schema[]>;
|
|
6
|
+
export declare function initFlow(flow: Flow): void;
|
|
7
|
+
export declare const isCopyFirstStepSchemaDisabled: import("svelte/store").Readable<boolean>;
|
|
8
|
+
export declare function addModule(i?: number): void;
|
|
9
|
+
export declare function pickScript(path: string, step: number): Promise<void>;
|
|
10
|
+
export declare function createInlineScriptModule(language: FlowModuleValue.language, step: number, mode: FlowMode): Promise<void>;
|
|
11
|
+
export declare function loadSchema(step: number): Promise<void>;
|
|
12
|
+
export declare function fork(step: number): Promise<void>;
|
|
13
|
+
export declare function createScriptFromInlineScript(step: number): Promise<void>;
|
|
14
|
+
export declare function removeModule(step: number): void;
|
|
15
|
+
export declare function copyFirstStepSchema(): Promise<void>;
|
|
16
|
+
export declare function findNextAvailablePath(path: string): Promise<string>;
|
|
17
|
+
export declare function shouldPickOrCreateScript(flow: Flow, step: number): boolean;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { FlowModuleValue, ScriptService } from '../../gen';
|
|
2
|
+
import { initialCode } from '../../script_helpers';
|
|
3
|
+
import { userStore, workspaceStore } from '../../stores';
|
|
4
|
+
import { derived, get, writable } from 'svelte/store';
|
|
5
|
+
import { createInlineScriptModuleFromPath, getFirstStepSchema, loadSchemaFromModule, scrollIntoView } from './utils';
|
|
6
|
+
export const flowStore = writable(undefined);
|
|
7
|
+
export const schemasStore = writable([]);
|
|
8
|
+
export function initFlow(flow) {
|
|
9
|
+
schemasStore.set([]);
|
|
10
|
+
flowStore.set(flow);
|
|
11
|
+
// For each module in flow, we should load the corresponding schema
|
|
12
|
+
flow.value.modules.forEach((_, index) => {
|
|
13
|
+
loadSchema(index);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export const isCopyFirstStepSchemaDisabled = derived(flowStore, (flow) => {
|
|
17
|
+
if (flow) {
|
|
18
|
+
const modules = flow.value.modules;
|
|
19
|
+
const [firstModule] = modules;
|
|
20
|
+
return (modules.length === 0 || (firstModule.value.path === '' && firstModule.value.type === 'script'));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export function addModule(i) {
|
|
27
|
+
const newModule = {
|
|
28
|
+
value: { type: FlowModuleValue.type.SCRIPT, path: '' },
|
|
29
|
+
input_transform: {}
|
|
30
|
+
};
|
|
31
|
+
flowStore.update((flow) => {
|
|
32
|
+
const insertAt = i ?? flow.value.modules.length;
|
|
33
|
+
flow.value.modules.splice(insertAt, 0, newModule);
|
|
34
|
+
flow.value.modules = flow.value.modules;
|
|
35
|
+
setTimeout(() => scrollIntoView(document.querySelector(`#module-${insertAt}`)), 100);
|
|
36
|
+
return flow;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export async function pickScript(path, step) {
|
|
40
|
+
flowStore.update((flow) => {
|
|
41
|
+
if (flow.value.modules[step]) {
|
|
42
|
+
flow.value.modules[step].value.path = path;
|
|
43
|
+
}
|
|
44
|
+
return flow;
|
|
45
|
+
});
|
|
46
|
+
await loadSchema(step);
|
|
47
|
+
}
|
|
48
|
+
export async function createInlineScriptModule(language, step, mode) {
|
|
49
|
+
const code = initialCode(language, (mode === 'pull' && step == 0));
|
|
50
|
+
flowStore.update((flow) => {
|
|
51
|
+
flow.value.modules[step].value = {
|
|
52
|
+
type: FlowModuleValue.type.RAWSCRIPT,
|
|
53
|
+
content: code,
|
|
54
|
+
language,
|
|
55
|
+
};
|
|
56
|
+
return flow;
|
|
57
|
+
});
|
|
58
|
+
await loadSchema(step);
|
|
59
|
+
}
|
|
60
|
+
export async function loadSchema(step) {
|
|
61
|
+
const flow = get(flowStore);
|
|
62
|
+
const module = flow.value.modules[step];
|
|
63
|
+
const { input_transform, schema } = await loadSchemaFromModule(module);
|
|
64
|
+
flowStore.update((flow) => {
|
|
65
|
+
flow.value.modules[step].input_transform = input_transform;
|
|
66
|
+
return flow;
|
|
67
|
+
});
|
|
68
|
+
schemasStore.update((schemas) => {
|
|
69
|
+
schemas[step] = schema;
|
|
70
|
+
return schemas;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export async function fork(step) {
|
|
74
|
+
const flow = get(flowStore);
|
|
75
|
+
const flowModuleValue = flow.value.modules[step].value;
|
|
76
|
+
if (flowModuleValue.path) {
|
|
77
|
+
const moduleValue = await createInlineScriptModuleFromPath(flowModuleValue.path);
|
|
78
|
+
flowStore.update((flow) => {
|
|
79
|
+
flow.value.modules[step].value = moduleValue;
|
|
80
|
+
return flow;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export async function createScriptFromInlineScript(step) {
|
|
85
|
+
const flow = get(flowStore);
|
|
86
|
+
const schemas = get(schemasStore);
|
|
87
|
+
const user = get(userStore);
|
|
88
|
+
const flowModuleValue = flow.value.modules[step].value;
|
|
89
|
+
const originalScriptPath = flowModuleValue.path;
|
|
90
|
+
const wasForked = Boolean(originalScriptPath);
|
|
91
|
+
let suffix = `step-${step}`;
|
|
92
|
+
if (wasForked && originalScriptPath) {
|
|
93
|
+
const [first, second, ...others] = originalScriptPath.split('/');
|
|
94
|
+
suffix = others.join('/');
|
|
95
|
+
}
|
|
96
|
+
const path = `${flow.path}/${suffix}`;
|
|
97
|
+
const forkedDescription = wasForked ? `as a fork of ${originalScriptPath}` : '';
|
|
98
|
+
const description = `This script was edited in place of flow ${flow.path} ${forkedDescription} by ${user?.username} at step ${step}.`;
|
|
99
|
+
const availablePath = await findNextAvailablePath(path);
|
|
100
|
+
await ScriptService.createScript({
|
|
101
|
+
workspace: get(workspaceStore),
|
|
102
|
+
requestBody: {
|
|
103
|
+
path: availablePath,
|
|
104
|
+
summary: '',
|
|
105
|
+
description,
|
|
106
|
+
content: flowModuleValue.content,
|
|
107
|
+
parent_hash: undefined,
|
|
108
|
+
schema: schemas[step],
|
|
109
|
+
is_template: false,
|
|
110
|
+
language: flowModuleValue.language
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
flowStore.update((flow) => {
|
|
114
|
+
flow.value.modules[step].value = {
|
|
115
|
+
type: FlowModuleValue.type.SCRIPT,
|
|
116
|
+
path: availablePath
|
|
117
|
+
};
|
|
118
|
+
return flow;
|
|
119
|
+
});
|
|
120
|
+
await loadSchema(step);
|
|
121
|
+
}
|
|
122
|
+
export function removeModule(step) {
|
|
123
|
+
flowStore.update((flow) => {
|
|
124
|
+
flow.value.modules.splice(step, 1);
|
|
125
|
+
return flow;
|
|
126
|
+
});
|
|
127
|
+
schemasStore.update((schemas) => {
|
|
128
|
+
schemas.splice(step, 1);
|
|
129
|
+
return schemas;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
export async function copyFirstStepSchema() {
|
|
133
|
+
const flow = get(flowStore);
|
|
134
|
+
const flowSchema = await getFirstStepSchema(flow);
|
|
135
|
+
flowStore.update((flow) => {
|
|
136
|
+
flow.schema = flowSchema;
|
|
137
|
+
return flow;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
export async function findNextAvailablePath(path) {
|
|
141
|
+
try {
|
|
142
|
+
await ScriptService.getScriptByPath({
|
|
143
|
+
workspace: get(workspaceStore),
|
|
144
|
+
path
|
|
145
|
+
});
|
|
146
|
+
const [_, version] = path.split(/.*_([0-9]*)/);
|
|
147
|
+
if (version.length > 0) {
|
|
148
|
+
path = path.slice(0, -(version.length + 1));
|
|
149
|
+
}
|
|
150
|
+
path = `${path}_${Number(version) + 1}`;
|
|
151
|
+
return findNextAvailablePath(path);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
// Catching an error means the path is available
|
|
155
|
+
return path;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
export function shouldPickOrCreateScript(flow, step) {
|
|
159
|
+
const module = flow.value.modules[step];
|
|
160
|
+
return module.value.path === '' && module.value.language === undefined;
|
|
161
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script>import Icon from 'svelte-awesome';
|
|
2
|
+
export let disabled = false;
|
|
3
|
+
export let icon;
|
|
4
|
+
export let label;
|
|
5
|
+
export let iconColor;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<button {disabled} type="button" on:click class="default-secondary-button-v2 mb-2 w-full">
|
|
9
|
+
<Icon data={icon} class={`w-4 h-4 mr-2 -ml-2 ${iconColor}`} />
|
|
10
|
+
{label}
|
|
11
|
+
</button>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { IconDefinition } from '@fortawesome/free-brands-svg-icons';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
disabled?: boolean | undefined;
|
|
6
|
+
icon: IconDefinition;
|
|
7
|
+
label: string;
|
|
8
|
+
iconColor: string;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
click: MouseEvent;
|
|
12
|
+
} & {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {};
|
|
16
|
+
};
|
|
17
|
+
export declare type FlowScriptPickerProps = typeof __propDef.props;
|
|
18
|
+
export declare type FlowScriptPickerEvents = typeof __propDef.events;
|
|
19
|
+
export declare type FlowScriptPickerSlots = typeof __propDef.slots;
|
|
20
|
+
export default class FlowScriptPicker extends SvelteComponentTyped<FlowScriptPickerProps, FlowScriptPickerEvents, FlowScriptPickerSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script>import { faUserGroup } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import FlowScriptPicker from './FlowScriptPicker.svelte';
|
|
3
|
+
import ItemPicker from '../../ItemPicker.svelte';
|
|
4
|
+
import { hubScripts } from '../../../stores';
|
|
5
|
+
import { createEventDispatcher } from 'svelte';
|
|
6
|
+
export let isTrigger;
|
|
7
|
+
let items;
|
|
8
|
+
$: items = $hubScripts?.filter((x) => x.is_trigger == isTrigger) ?? [];
|
|
9
|
+
let itemPicker;
|
|
10
|
+
const dispatch = createEventDispatcher();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<ItemPicker
|
|
14
|
+
bind:this={itemPicker}
|
|
15
|
+
pickCallback={(path) => {
|
|
16
|
+
dispatch('pick', { path })
|
|
17
|
+
}}
|
|
18
|
+
itemName={'Script'}
|
|
19
|
+
extraField="summary"
|
|
20
|
+
loadItems={async () => {
|
|
21
|
+
return items
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
|
|
25
|
+
<FlowScriptPicker
|
|
26
|
+
label={`Pick a ${isTrigger ? 'trigger ' : ''} script from the Hub`}
|
|
27
|
+
icon={faUserGroup}
|
|
28
|
+
iconColor="text-blue-500"
|
|
29
|
+
on:click={() => itemPicker.openModal()}
|
|
30
|
+
/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
isTrigger: boolean;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
pick: CustomEvent<any>;
|
|
8
|
+
} & {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {};
|
|
12
|
+
};
|
|
13
|
+
export declare type PickHubScriptProps = typeof __propDef.props;
|
|
14
|
+
export declare type PickHubScriptEvents = typeof __propDef.events;
|
|
15
|
+
export declare type PickHubScriptSlots = typeof __propDef.slots;
|
|
16
|
+
export default class PickHubScript extends SvelteComponentTyped<PickHubScriptProps, PickHubScriptEvents, PickHubScriptSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script>import ItemPicker from '../../ItemPicker.svelte';
|
|
2
|
+
import { faUserGroup } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
import { ScriptService } from '../../../gen';
|
|
4
|
+
import { workspaceStore } from '../../../stores';
|
|
5
|
+
import { createEventDispatcher } from 'svelte';
|
|
6
|
+
import FlowScriptPicker from './FlowScriptPicker.svelte';
|
|
7
|
+
export let isTrigger;
|
|
8
|
+
let items = [];
|
|
9
|
+
let itemPicker;
|
|
10
|
+
const dispatch = createEventDispatcher();
|
|
11
|
+
async function loadItems() {
|
|
12
|
+
items = await ScriptService.listScripts({ workspace: $workspaceStore, isTrigger });
|
|
13
|
+
}
|
|
14
|
+
$: {
|
|
15
|
+
if ($workspaceStore) {
|
|
16
|
+
loadItems();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<ItemPicker
|
|
22
|
+
bind:this={itemPicker}
|
|
23
|
+
pickCallback={(path) => {
|
|
24
|
+
dispatch('pick', { path })
|
|
25
|
+
}}
|
|
26
|
+
itemName={'Script'}
|
|
27
|
+
extraField="summary"
|
|
28
|
+
loadItems={async () => {
|
|
29
|
+
return items
|
|
30
|
+
}}
|
|
31
|
+
/>
|
|
32
|
+
|
|
33
|
+
<FlowScriptPicker
|
|
34
|
+
label={`Pick a ${isTrigger ? 'trigger ' : ''}script from your workspace`}
|
|
35
|
+
icon={faUserGroup}
|
|
36
|
+
iconColor="text-blue-500"
|
|
37
|
+
on:click={() => itemPicker.openModal()}
|
|
38
|
+
/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
isTrigger: boolean;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
pick: CustomEvent<any>;
|
|
8
|
+
} & {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {};
|
|
12
|
+
};
|
|
13
|
+
export declare type PickScriptProps = typeof __propDef.props;
|
|
14
|
+
export declare type PickScriptEvents = typeof __propDef.events;
|
|
15
|
+
export declare type PickScriptSlots = typeof __propDef.slots;
|
|
16
|
+
export default class PickScript extends SvelteComponentTyped<PickScriptProps, PickScriptEvents, PickScriptSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Schema } from '../../common';
|
|
2
|
+
import { FlowModuleValue, InputTransform, type Flow, type FlowModule } from '../../gen';
|
|
3
|
+
import type { FlowMode } from './flowStore';
|
|
4
|
+
export declare function flowToMode(flow: Flow, mode: FlowMode): Flow;
|
|
5
|
+
export declare function flattenForloopFlows(flow: Flow): Flow;
|
|
6
|
+
export declare function getTypeAsString(arg: any): string;
|
|
7
|
+
export declare function formatValue(arg: any): any;
|
|
8
|
+
export declare function getFirstStepSchema(flow: Flow): Promise<Schema>;
|
|
9
|
+
export declare function getScriptByPath(path: string): Promise<{
|
|
10
|
+
content: string;
|
|
11
|
+
language: FlowModuleValue.language;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function createInlineScriptModuleFromPath(path: string): Promise<FlowModuleValue>;
|
|
14
|
+
export declare function scrollIntoView(el: any): void;
|
|
15
|
+
export declare function loadSchemaFromModule(module: FlowModule): Promise<{
|
|
16
|
+
input_transform: Record<string, InputTransform>;
|
|
17
|
+
schema: Schema;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function isCodeInjection(expr: string | undefined): boolean;
|
|
20
|
+
export declare function getCodeInjectionExpr(code: string, isRaw: boolean): string;
|
|
21
|
+
export declare function getDefaultExpr(i: number, key?: string): string;
|