| {name} |
@@ -206,13 +211,17 @@
>
|
{#if i > 0}
- changePosition(i, true)}
+ class="text-lg mr-2 {isAnimated ? 'invisible' : ''}"
+ >
+ ↑
{/if}
{#if i < Object.keys(schema.properties).length - 1}
- changePosition(i, false)}
+ class="text-lg mr-2 {isAnimated ? 'invisible' : ''}">↓
{/if}
diff --git a/frontend/src/lib/components/ScriptBuilder.svelte b/frontend/src/lib/components/ScriptBuilder.svelte
index b3c8875615..4670fd7608 100644
--- a/frontend/src/lib/components/ScriptBuilder.svelte
+++ b/frontend/src/lib/components/ScriptBuilder.svelte
@@ -19,14 +19,21 @@
import { faChevronDown, faChevronUp, faPen, faSave } from '@fortawesome/free-solid-svg-icons'
import Breadcrumb from './common/breadcrumb/Breadcrumb.svelte'
import Toggle from './Toggle.svelte'
+ import LanguageIcon from './common/languageIcons/LanguageIcon.svelte'
+ import type { SupportedLanguage } from '$lib/common'
export let script: Script
export let initialPath: string = ''
export let template: 'pgsql' | 'script' = 'script'
export let initialArgs: Record = {}
+ const langs: [string, SupportedLanguage][] = [
+ ['Typescript (Deno)', Script.language.DENO],
+ ['Python 3.11', Script.language.PYTHON3],
+ ['Go', Script.language.GO],
+ ['Bash', Script.language.BASH]
+ ]
let viewScriptKind = script.kind !== Script.kind.SCRIPT
- let viewTemplate = script.kind !== Script.kind.SCRIPT && script.language == Script.language.DENO
let pathError = ''
@@ -185,18 +192,36 @@
/>
Language
-
- initContent(e.detail, script.kind, template)}
- bind:value={script.language}
- />
+
+ {#each langs as [label, lang]}
+ {@const isPicked = script.language == lang && template == 'script'}
+
+ {/each}
+
Advanced
@@ -206,7 +231,7 @@
endIcon={{ icon: viewScriptKind ? faChevronUp : faChevronDown }}
on:click={() => (viewScriptKind = !viewScriptKind)}
>
- Specialize the script as a specific module kind for flows
+ Tag this script as having a specific purpose inside flows
{#if viewScriptKind}
@@ -249,31 +274,6 @@
/>
{/if}
- {#if script.language == 'deno' && script.kind == Script.kind.SCRIPT}
-
-
- {#if viewTemplate}
-
- initContent(script.language, script.kind, e.detail)}
- bind:value={template}
- />
-
- {/if}
- {/if}
(hidden = !hidden)
-
+
import type { SupportedLanguage } from '$lib/common'
+ import PostgresIcon from '$lib/components/icons/PostgresIcon.svelte'
import type { SvelteComponent } from 'svelte'
import { BashIcon, GoIcon, PythonIcon, TypeScriptIcon } from './'
- export let lang: SupportedLanguage
+ export let lang: SupportedLanguage | 'pgsql'
export let width = 16
export let height = 16
export let scale = 1
- const langToComponent: Record = {
+ const langToComponent: Record = {
go: GoIcon,
python3: PythonIcon,
deno: TypeScriptIcon,
- bash: BashIcon
+ bash: BashIcon,
+ pgsql: PostgresIcon
}
diff --git a/frontend/src/lib/components/common/menu/Menu.svelte b/frontend/src/lib/components/common/menu/Menu.svelte
index dbd24e0d84..3d529e7796 100644
--- a/frontend/src/lib/components/common/menu/Menu.svelte
+++ b/frontend/src/lib/components/common/menu/Menu.svelte
@@ -1,8 +1,8 @@
- (show = !show)} on:click>
+
+ (show = !show)}>
{#if show}
-
+
{#if loading}
@@ -25,7 +25,7 @@
{/if}
-
+
{#if loading}
diff --git a/frontend/src/lib/components/flows/content/FlowBranchesWrapper.svelte b/frontend/src/lib/components/flows/content/FlowBranchesWrapper.svelte
index cfd98f4f37..6a4e2e0aa9 100644
--- a/frontend/src/lib/components/flows/content/FlowBranchesWrapper.svelte
+++ b/frontend/src/lib/components/flows/content/FlowBranchesWrapper.svelte
@@ -80,7 +80,7 @@
{branch.summary && branch.summary != '' ? branch.summary : 'No summary'}
-
@@ -94,7 +94,7 @@
{branch.summary && branch.summary != '' ? branch.summary : 'No summary'}
- ($selectedId = branch.id)}>
+ ($selectedId = branch.id)}>
Set branch {i} summary
diff --git a/frontend/src/lib/components/flows/content/FlowInput.svelte b/frontend/src/lib/components/flows/content/FlowInput.svelte
index 5f3d02d6c9..e4d3a01481 100644
--- a/frontend/src/lib/components/flows/content/FlowInput.svelte
+++ b/frontend/src/lib/components/flows/content/FlowInput.svelte
@@ -13,33 +13,29 @@
-
-
+
+
+ Copy input's schema from
{
capturePayload.openDrawer()
}}
- variant="border"
>
- Capture from a request to seed inputs
+ A request
- Copy from first step schema {#if $flowStore.value.modules.length === 0 || isEmptyFlowModule($flowStore.value.modules[0])}
- (no steps to copy from!){/if}
+ First step's inputs
-
-
-
+ Customize Inputs
diff --git a/frontend/src/lib/components/flows/content/FlowInputs.svelte b/frontend/src/lib/components/flows/content/FlowInputs.svelte
index 0a5fccfca0..11af933a8b 100644
--- a/frontend/src/lib/components/flows/content/FlowInputs.svelte
+++ b/frontend/src/lib/components/flows/content/FlowInputs.svelte
@@ -1,163 +1,131 @@
-
- {failureModule ? 'Error handler' : 'Common script'}
-
+
+ {#if !failureModule}
+
+
+
+
+ Common
+
+ {#if !shouldDisableTriggerScripts}
+
+ Trigger
+ Used as a first step most commonly with a state and a schedule to watch for changes
+ on an external system, compute the diff since last time, set the new state. The
+ diffs are then treated one by one with a for-loop.
+
+
+ {/if}
+
+ Approval
+ An approval step will suspend the execution of a flow until it has been approved
+ through the resume endpoints or the approval page by and solely by the recipients of
+ those secret urls. Use getResumeEndpoints from the wmill client to generate those
+ URLs.
+
+
+
+
+
+ {/if}
+ Inline new
+
{
- dispatch('new', {
- language: RawScript.language.PYTHON3,
- kind: failureModule ? 'failure' : 'script',
- subkind: 'flow'
- })
- }}
- />
-
- {
dispatch('new', {
language: RawScript.language.DENO,
- kind: failureModule ? 'failure' : 'script',
+ kind,
subkind: 'flow'
})
}}
/>
{
dispatch('new', {
- language: RawScript.language.GO,
- kind: failureModule ? 'failure' : 'script',
- subkind: 'flow'
+ language: RawScript.language.PYTHON3,
+ kind,
+ subkind: kind
})
}}
/>
- {
- dispatch('new', {
- language: RawScript.language.BASH,
- kind: failureModule ? 'failure' : 'script',
- subkind: 'flow'
- })
- }}
- />
-
- {#if !failureModule}
+ {#if kind != 'approval'}
- dispatch('new', { language: RawScript.language.DENO, kind: 'script', subkind: 'pgsql' })}
+ label="Go"
+ lang={Script.language.GO}
+ on:click={() => {
+ dispatch('new', {
+ language: RawScript.language.GO,
+ kind,
+ subkind: 'flow'
+ })
+ }}
/>
{/if}
-
-
+ {#if kind == 'script'}
+ {
+ dispatch('new', {
+ language: RawScript.language.BASH,
+ kind,
+ subkind: 'flow'
+ })
+ }}
+ />
+
+ {#if !failureModule}
+
+ dispatch('new', { language: RawScript.language.DENO, kind, subkind: 'pgsql' })}
+ />
+ {/if}
+ {/if}
- {#if !shouldDisableTriggerScripts}
-
- Trigger script
-
- Used as a first step most commonly with an internal state and a schedule to watch for
- changes on an external system, compute the diff since last time, set the new state. The
- diffs are then treated one by one with a for-loop.
-
-
-
-
-
-
- dispatch('new', { language: RawScript.language.DENO, kind: 'trigger' })}
- />
-
- {/if}
- {#if !failureModule}
-
- Approval step
-
- Inlined common scripts can be turned into approval step by changing their suspend settings.
- An approval step will suspend the execution of a flow until it has been approved through the
- resume endpoints or the approval page by and solely by the recipients of those secret urls.
- Use getResumeEndpoints from the wmill client to generate those URLs.
-
-
-
-
-
- dispatch('new', { language: RawScript.language.DENO, kind: 'approval' })}
- />
-
-
- Flow primitive
-
-
- dispatch('branchone')}
- />
- dispatch('branchall')}
- />
-
- dispatch('loop')}
- />
-
+ Use pre-made
+
+
+
+ Hub
+
+
+ Workspace
+
+
+
+ {#if pick_existing == 'hub'}
+
+ {:else}
+
{/if}
diff --git a/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte b/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte
index 4b3df95657..a47465cc55 100644
--- a/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte
+++ b/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte
@@ -165,7 +165,7 @@
{#if flowModule.value.type === 'rawscript'}
- reload(flowModule)} class="h-full">
+
- {:else}
- Select a step kind Until being defined, this step acts as an identify function, returning as result its
- input and assigning it a key 'previous_result' if the input is not a json object
{/if}
{
- const [module, state] = await createLoop(flowModule.id)
- flowModule = module
- $flowStateStore[module.id] = state
- }}
- on:branchone={async () => {
- const [module, state] = await createBranches(flowModule.id)
- flowModule = module
- $flowStateStore[module.id] = state
- }}
- on:branchall={async () => {
- const [module, state] = await createBranchAll(flowModule.id)
- flowModule = module
- $flowStateStore[module.id] = state
- }}
on:pick={async ({ detail }) => {
const { path, summary, kind } = detail
const [module, state] = await pickScript(path, summary, flowModule.id)
diff --git a/frontend/src/lib/components/flows/header/FlowPreviewButtons.svelte b/frontend/src/lib/components/flows/header/FlowPreviewButtons.svelte
index 94ae28114c..3c5c5d1e69 100644
--- a/frontend/src/lib/components/flows/header/FlowPreviewButtons.svelte
+++ b/frontend/src/lib/components/flows/header/FlowPreviewButtons.svelte
@@ -56,7 +56,7 @@
{/if}
-
+
('FlowEditorContext')
async function addBranch() {
@@ -24,11 +23,9 @@
module.value.branches.splice(module.value.branches.length, 0, {
summary: '',
skip_failure: false,
- modules: [newModule]
+ modules: []
})
module = module
-
- $flowStateStore[newModule.id] = emptyFlowModuleState()
}
})
}
@@ -52,43 +49,44 @@
>
{#each module.value.branches ?? [] as branch, branchIndex (branchIndex)}
- {
- selectedBranch = branchIndex
- select(`${module.id}-branch-${branchIndex}`)
- }}
- class={classNames(
- `border-b ${
- branchIndex > 0 ? 'border-t' : ''
- } w-full p-2 bg-white border-gray-500 text-sm cursor-pointer flex items-center relative module`,
- $selectedId === `${module.id}-branch-${branchIndex}`
- ? 'outline outline-2 outline-slate-900'
- : ''
- )}
- >
-
-
+ {
+ selectedBranch = branchIndex
+ select(`${module.id}-branch-${branchIndex}`)
+ }}
+ class={classNames(
+ `border-b ${
+ branchIndex > 0 ? 'border-t' : ''
+ } w-full p-2 bg-white border-gray-500 text-sm cursor-pointer flex items-center relative module`,
+ $selectedId === `${module.id}-branch-${branchIndex}`
+ ? 'outline outline-2 outline-slate-900'
+ : ''
+ )}
>
- {branch.summary || `Branch ${branchIndex}`}
- removeBranch(branchIndex)}
- >
+
-
-
+ {branch.summary || `Branch ${branchIndex}`}
+ removeBranch(branchIndex)}
+ >
+
+
-
{/each}
diff --git a/frontend/src/lib/components/flows/map/FlowBranchOneMap.svelte b/frontend/src/lib/components/flows/map/FlowBranchOneMap.svelte
index 009a1d09f2..4c9ec37217 100644
--- a/frontend/src/lib/components/flows/map/FlowBranchOneMap.svelte
+++ b/frontend/src/lib/components/flows/map/FlowBranchOneMap.svelte
@@ -21,15 +21,12 @@
async function addBranch() {
await idMutex.runExclusive(async () => {
if (module.value.type === 'branchone') {
- const newModule = emptyModule()
module.value.branches.splice(module.value.branches.length, 0, {
summary: '',
- expr: '',
- modules: [newModule]
+ expr: 'false',
+ modules: []
})
module = module
-
- $flowStateStore[newModule.id] = emptyFlowModuleState()
}
})
}
@@ -77,41 +74,42 @@
{#each module.value.branches ?? [] as branch, branchIndex (branchIndex)}
- {
- selectedBranch = branchIndex + 1
- select(`${module.id}-branch-${branchIndex}`)
- }}
- class={classNames(
- `border-b border-t w-full p-2 bg-white border-gray-500 text-sm cursor-pointer flex items-center relative module`,
- $selectedId === `${module.id}-branch-${branchIndex}`
- ? 'outline outline-2 outline-slate-900'
- : ''
- )}
- >
-
-
+ {
+ selectedBranch = branchIndex + 1
+ select(`${module.id}-branch-${branchIndex}`)
+ }}
+ class={classNames(
+ `border-b border-t w-full p-2 bg-white border-gray-500 text-sm cursor-pointer flex items-center relative module`,
+ $selectedId === `${module.id}-branch-${branchIndex}`
+ ? 'outline outline-2 outline-slate-900'
+ : ''
+ )}
>
- {branch.summary || `Branch ${branchIndex}`}
- removeBranch(branchIndex)}
- >
+
-
-
+ {branch.summary || `Branch ${branchIndex}`}
+ removeBranch(branchIndex)}
+ >
+
+
-
{/each}
diff --git a/frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte b/frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte
index 8a71b64ee7..03b754e8cc 100644
--- a/frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte
+++ b/frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte
@@ -41,16 +41,18 @@
}
}}
class={classNames(
- 'border rounded-md p-2 bg-white text-sm border-gray-400 cursor-pointer flex flex-col overflow-x-hidden ',
+ 'border rounded-sm p-2 bg-white text-sm border-gray-400 cursor-pointer flex flex-col overflow-x-hidden ',
$selectedId.includes('failure') ? 'outline outline-offset-1 outline-2 outline-slate-900' : ''
)}
>
- Error handler
+ Error handler
+
+
+
-
diff --git a/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte b/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte
index 529f9e0bd9..3e694bc15d 100644
--- a/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte
+++ b/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte
@@ -1,8 +1,15 @@
diff --git a/frontend/src/lib/components/flows/map/InsertModuleButton.svelte b/frontend/src/lib/components/flows/map/InsertModuleButton.svelte
index 33b93d5c37..724b45d993 100644
--- a/frontend/src/lib/components/flows/map/InsertModuleButton.svelte
+++ b/frontend/src/lib/components/flows/map/InsertModuleButton.svelte
@@ -1,12 +1,67 @@
-
-
-
+
diff --git a/frontend/src/lib/components/flows/map/MapItem.svelte b/frontend/src/lib/components/flows/map/MapItem.svelte
index 29aa5d20e6..eb71b17c30 100644
--- a/frontend/src/lib/components/flows/map/MapItem.svelte
+++ b/frontend/src/lib/components/flows/map/MapItem.svelte
@@ -12,7 +12,6 @@
faCode,
faCodeBranch,
faLongArrowDown,
- faQuestion,
faRepeat
} from '@fortawesome/free-solid-svg-icons'
import Icon from 'svelte-awesome'
@@ -20,7 +19,10 @@
export let mod: FlowModule
const { select, selectedId } = getContext ('FlowEditorContext')
- const dispatch = createEventDispatcher<{ delete: CustomEvent; insert: void }>()
+ const dispatch = createEventDispatcher<{
+ delete: CustomEvent
+ insert: 'script' | 'forloop' | 'branchone' | 'branchall'
+ }>()
$: itemProps = {
selected: $selectedId === mod.id,
@@ -35,7 +37,7 @@
{#if mod}
- dispatch('insert')} />
+ dispatch('insert', e.detail)} />
{#if mod.value.type === 'forloopflow'}
-
+
diff --git a/frontend/src/lib/components/flows/pickers/FlowScriptPicker.svelte b/frontend/src/lib/components/flows/pickers/FlowScriptPicker.svelte
index 63a078b410..a9837452e2 100644
--- a/frontend/src/lib/components/flows/pickers/FlowScriptPicker.svelte
+++ b/frontend/src/lib/components/flows/pickers/FlowScriptPicker.svelte
@@ -1,11 +1,14 @@
- {label}
+ {#if lang}
+
+ {/if}{label}
diff --git a/frontend/src/lib/components/flows/pickers/PickHubScript.svelte b/frontend/src/lib/components/flows/pickers/PickHubScript.svelte
index c846caec2a..df33ed56e1 100644
--- a/frontend/src/lib/components/flows/pickers/PickHubScript.svelte
+++ b/frontend/src/lib/components/flows/pickers/PickHubScript.svelte
@@ -1,39 +1,88 @@
- {
- dispatch('pick', { path, summary, kind })
- }}
- itemName={'Script'}
- extraField="summary"
- loadItems={async () => {
- return items
- }}
- noItemMessage="Hub not reachable. If your environment is air gapped, contact sales@windmill.dev to setup a local mirror."
-/>
+
+
+
+
- itemPicker.openDrawer()}
-/>
+
+ {#each apps as app}
+ {
+ appFilter = appFilter == app ? undefined : app
+ }}
+ capitalize
+ color={app === appFilter ? 'blue' : 'gray'}
+ >
+ {app}
+ {#if app === appFilter}✗{/if}
+
+ {/each}
+
+ {#if filteredItems}
+
+
+ {#each filteredItems as obj}
+ -
+ {
+ dispatch('pick', obj)
+ }}
+ >
+
+
+
+
+
+ {obj['summary'] ?? ''}
+ {obj['path'] ?? ''}
+
+ {obj['description'] ?? ''}
+
+
+
+ {/each}
+
+
+ {/if}
+
diff --git a/frontend/src/lib/components/flows/pickers/PickScript.svelte b/frontend/src/lib/components/flows/pickers/PickScript.svelte
index 06a8389824..1f7355ace1 100644
--- a/frontend/src/lib/components/flows/pickers/PickScript.svelte
+++ b/frontend/src/lib/components/flows/pickers/PickScript.svelte
@@ -1,6 +1,6 @@
+
+
+
+
+
+
+ {#if filteredItems}
+
+ {#each filteredItems as obj}
+ -
+ {
+ dispatch('pick', obj)
+ }}
+ >
+
+
+ {obj['summary'] ?? ''}
+ {obj['path'] ?? ''}
+
+ {obj['description'] ?? ''}
+
+
+
+ {/each}
+
+ {/if}
+
diff --git a/frontend/src/lib/components/flows/propPicker/PropPickerWrapper.svelte b/frontend/src/lib/components/flows/propPicker/PropPickerWrapper.svelte
index f0dd351447..4ecedd0b8b 100644
--- a/frontend/src/lib/components/flows/propPicker/PropPickerWrapper.svelte
+++ b/frontend/src/lib/components/flows/propPicker/PropPickerWrapper.svelte
@@ -49,10 +49,10 @@
-
+
-
+
{#if result}
{:else if pickableProperties}
diff --git a/frontend/src/lib/components/flows/utils.ts b/frontend/src/lib/components/flows/utils.ts
index 0f4d6d17c3..15709f397b 100644
--- a/frontend/src/lib/components/flows/utils.ts
+++ b/frontend/src/lib/components/flows/utils.ts
@@ -152,7 +152,7 @@ export async function runFlowPreview(args: Record, flow: Flow) {
}
export function codeToStaticTemplate(code?: string): string | undefined {
- if (!code) return undefined
+ if (!code || typeof code != 'string') return undefined
const lines = code
.split('\n')
diff --git a/frontend/src/lib/components/propertyPicker/PropPicker.svelte b/frontend/src/lib/components/propertyPicker/PropPicker.svelte
index 7ae03af88b..c42e65744b 100644
--- a/frontend/src/lib/components/propertyPicker/PropPicker.svelte
+++ b/frontend/src/lib/components/propertyPicker/PropPicker.svelte
@@ -59,135 +59,139 @@
}
-{#if !notSelectable}
-
- {#if $propPickerConfig}
-
- {`Selected: ${$propPickerConfig?.propName}`}
-
-
- {`Mode: ${$propPickerConfig?.insertionMode}`}
-
- {:else}
- ← Select a step input
+
+
+ {#if !notSelectable}
+
+ {#if $propPickerConfig}
+
+ {`Selected: ${$propPickerConfig?.propName}`}
+
+
+ {`Mode: ${$propPickerConfig?.insertionMode}`}
+
+ {:else}
+ ← Select a step input
+ {/if}
+
{/if}
-
-{/if}
-
-
-
-
- {
- dispatch('select', `flow_input.${e.detail}`)
- }}
+
- {#if error}
- Error
+
+
{
+ dispatch('select', `flow_input.${e.detail}`)
+ }}
/>
- {:else}
- {#if previousId}
- Previous Result
+ {#if error}
+ Error
k == previousId)
- )}
- on:select={(e) => {
- dispatch('select', `results.${e.detail}`)
- }}
+ json={{ previous_result: { error: 'The error to handle' } }}
+ on:select
/>
+ {:else}
+ {#if previousId}
+ Previous Result
+
+ k == previousId)
+ )}
+ on:select={(e) => {
+ dispatch('select', `results.${e.detail}`)
+ }}
+ />
+
+ {/if}
+ {#if Object.keys(pickableProperties.priorIds).length > 0}
+ All Results
+
+ {
+ dispatch('select', `results.${e.detail}`)
+ }}
+ />
+
+ {/if}
{/if}
- {#if Object.keys(pickableProperties.priorIds).length > 0}
- All Results
-
- {
- dispatch('select', `results.${e.detail}`)
- }}
- />
-
- {/if}
- {/if}
- {#if displayContext}
- Variables
-
- {#if displayVariable}
- {
- displayVariable = false
- }}>-
- dispatch('select', `variable('${e.detail}')`)}
- />
- {:else}
- {
- await loadVariables()
- displayVariable = true
- }}>{'{...}'}
- {/if}
-
- Resources
-
- {#if displayResources}
- {
- displayResources = false
- }}>-
- dispatch('select', `resource('${e.detail}')`)}
- />
- {:else}
- {
- await loadResources()
- displayResources = true
- }}>{'{...}'}
- {/if}
-
- {/if}
+ {#if displayContext}
+ Variables
+
+ {#if displayVariable}
+ {
+ displayVariable = false
+ }}>-
+ dispatch('select', `variable('${e.detail}')`)}
+ />
+ {:else}
+ {
+ await loadVariables()
+ displayVariable = true
+ }}>{'{...}'}
+ {/if}
+
+ Resources
+
+ {#if displayResources}
+ {
+ displayResources = false
+ }}>-
+ dispatch('select', `resource('${e.detail}')`)}
+ />
+ {:else}
+ {
+ await loadResources()
+ displayResources = true
+ }}>{'{...}'}
+ {/if}
+
+ {/if}
+
diff --git a/frontend/src/lib/script_helpers.ts b/frontend/src/lib/script_helpers.ts
index aaa8dca4d6..5f3d9702f0 100644
--- a/frontend/src/lib/script_helpers.ts
+++ b/frontend/src/lib/script_helpers.ts
@@ -161,20 +161,60 @@ export const DENO_INIT_CODE_TRIGGER = `import * as wmill from "https://deno.land
export async function main() {
- // A common trigger script would follow this pattern:
- // 1. Get the last saved state
- // const state = await wmill.getState()
- // 2. Get the actual state from the external service
- // const newState = await (await fetch('https://hacker-news.firebaseio.com/v0/topstories.json')).json()
- // 3. Compare the two states and update the internal state
- // await wmill.setState(newState)
- // 4. Return the new rows
- // return range from (state to newState)
+ // A common trigger script would follow this pattern:
+ // 1. Get the last saved state
+ // const state = await wmill.getState()
+ // 2. Get the actual state from the external service
+ // const newState = await (await fetch('https://hacker-news.firebaseio.com/v0/topstories.json')).json()
+ // 3. Compare the two states and update the internal state
+ // await wmill.setState(newState)
+ // 4. Return the new rows
+ // return range from (state to newState)
- return [1,2,3]
+ return [1,2,3]
- // In subsequent scripts, you may refer to each row/value returned by the trigger script using
- // 'flow_input._value'
+ // In subsequent scripts, you may refer to each row/value returned by the trigger script using
+ // 'flow_input.iter.value'
+}
+`
+
+export const PYTHON_INIT_CODE_TRIGGER = `import wmill
+
+def main():
+ # A common trigger script would follow this pattern:
+ # 1. Get the last saved state
+ # const state = wnmill.get_state()
+ # 2. Get the actual state from the external service
+ # const newState = ...
+ # 3. Compare the two states and update the internal state
+ # wmill.setState(newState)
+ # 4. Return the new rows
+ # return range from (state to newState)
+ return [1, 2, 3]
+`
+
+
+export const GO_INIT_CODE_TRIGGER = `package inner
+
+import (
+ wmill "github.com/windmill-labs/windmill-go-client"
+)
+
+func main() (interface{}, error) {
+
+ // A common trigger script would follow this pattern:
+ // 1. Get the last saved state
+ state, _ := wmill.GetState()
+ // 2. Get the actual state from the external service
+ // newState := ...
+ // 3. Compare the two states and update the internal state
+ wmill.SetState(4)
+ // 4. Return the new rows
+
+ return state, nil
+
+ // In subsequent scripts, you may refer to each row/value returned by the trigger script using
+ // 'flow_input.iter.value'
}
`
@@ -184,7 +224,7 @@ export async function main(approver?: string) {
return wmill.getResumeEndpoints(approver)
}`
-const ALL_INITIAL_CODE = [PYTHON_INIT_CODE, DENO_INIT_CODE, POSTGRES_INIT_CODE, DENO_INIT_CODE_TRIGGER, DENO_INIT_CODE_CLEAR, PYTHON_INIT_CODE_CLEAR, DENO_INIT_CODE_APPROVAL, DENO_FAILURE_MODULE_CODE]
+const ALL_INITIAL_CODE = [PYTHON_INIT_CODE, PYTHON_INIT_CODE_TRIGGER, DENO_INIT_CODE, POSTGRES_INIT_CODE, DENO_INIT_CODE_TRIGGER, DENO_INIT_CODE_CLEAR, PYTHON_INIT_CODE_CLEAR, DENO_INIT_CODE_APPROVAL, DENO_FAILURE_MODULE_CODE]
export function isInitialCode(content: string): boolean {
for (const code of ALL_INITIAL_CODE) {
@@ -221,6 +261,8 @@ export function initialCode(language: 'deno' | 'python3' | 'go' | 'bash', kind:
return PYTHON_INIT_CODE_CLEAR
} else if (kind === 'failure') {
return PYTHON_FAILURE_MODULE_CODE
+ } else if (kind === 'trigger') {
+ return PYTHON_INIT_CODE_TRIGGER
} else {
return PYTHON_INIT_CODE
}
@@ -229,6 +271,8 @@ export function initialCode(language: 'deno' | 'python3' | 'go' | 'bash', kind:
} else {
if (kind === 'failure') {
return GO_FAILURE_MODULE_CODE
+ } else if (kind === 'trigger') {
+ return GO_INIT_CODE_TRIGGER
} else {
return GO_INIT_CODE
}
diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts
index d1012ce462..0338f6dbf9 100644
--- a/frontend/src/lib/utils.ts
+++ b/frontend/src/lib/utils.ts
@@ -59,9 +59,8 @@ export function displayDate(dateString: string | undefined): string {
if (date.toString() === 'Invalid Date') {
return ''
} else {
- return `${date.getFullYear()}/${
- date.getMonth() + 1
- }/${date.getDate()} at ${date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`
+ return `${date.getFullYear()}/${date.getMonth() + 1
+ }/${date.getDate()} at ${date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`
}
}
@@ -441,7 +440,7 @@ export async function getScriptByPath(path: string): Promise<{
return {
content,
- language,
+ language: language as SupportedLanguage,
schema
}
} else {
diff --git a/frontend/src/routes/flows/add.svelte b/frontend/src/routes/flows/add.svelte
index b03ea453c4..087487878e 100644
--- a/frontend/src/routes/flows/add.svelte
+++ b/frontend/src/routes/flows/add.svelte
@@ -44,7 +44,8 @@
path: templatePath
})
Object.assign(flow, template)
- flow.path = templatePath
+ const oldPath = flow.path.split('/')
+ flow.path = `u/${$userStore?.username}/${oldPath[oldPath.length - 1]}`
flow = flow
$page.url.searchParams.delete('template')
selectedId = 'settings-graph'
diff --git a/frontend/src/routes/flows/run/[...path].svelte b/frontend/src/routes/flows/run/[...path].svelte
index 38df9cbf23..b1f2ab9b0d 100644
--- a/frontend/src/routes/flows/run/[...path].svelte
+++ b/frontend/src/routes/flows/run/[...path].svelte
@@ -20,7 +20,7 @@
import { userStore, workspaceStore } from '$lib/stores'
import CenteredPage from '$lib/components/CenteredPage.svelte'
import RunForm from '$lib/components/RunForm.svelte'
- import { Button } from '$lib/components/common'
+ import { Button, Skeleton } from '$lib/components/common'
import { faPlay, faScroll } from '@fortawesome/free-solid-svg-icons'
import SharedBadge from '$lib/components/SharedBadge.svelte'
import SvelteMarkdown from 'svelte-markdown'
@@ -131,13 +131,15 @@
+
+ {:else}
+
{/if}
-
diff --git a/frontend/src/routes/scripts/run/[...hash].svelte b/frontend/src/routes/scripts/run/[...hash].svelte
index b8dd1494f8..a14c5f257a 100644
--- a/frontend/src/routes/scripts/run/[...hash].svelte
+++ b/frontend/src/routes/scripts/run/[...hash].svelte
@@ -23,7 +23,7 @@
import { inferArgs } from '$lib/infer'
import CenteredPage from '$lib/components/CenteredPage.svelte'
import RunForm from '$lib/components/RunForm.svelte'
- import { Alert, Badge, Button } from '$lib/components/common'
+ import { Alert, Badge, Button, Skeleton } from '$lib/components/common'
import SharedBadge from '$lib/components/SharedBadge.svelte'
import SvelteMarkdown from 'svelte-markdown'
import { faPlay, faScroll } from '@fortawesome/free-solid-svg-icons'
@@ -167,30 +167,32 @@
- {/if}
- {#if script?.lock_error_logs}
-
- Not deployed properly
-
- This version of this script is unable to be run because because the deployment had the
- following errors:
-
- {script.lock_error_logs}
-
- {:else if script && script?.lock == undefined}
-
- Deployment in progress
- Refresh this page in a few seconds.
-
+ {#if script?.lock_error_logs}
+
+ Not deployed properly
+
+ This version of this script is unable to be run because because the deployment had the
+ following errors:
+
+ {script.lock_error_logs}
+
+ {:else if script && script?.lock == undefined}
+
+ Deployment in progress
+ Refresh this page in a few seconds.
+
+ {:else}
+
+ {/if}
{:else}
-
+
{/if}
|