change openflow encoding for more proper oneOf + fix all from svelte:check

This commit is contained in:
Ruben Fiszel
2022-07-31 01:20:52 +02:00
parent c4ea52b4c3
commit 2a0d70dcbc
45 changed files with 219 additions and 205 deletions
+1
View File
@@ -32,6 +32,7 @@ RUN mkdir /backend
COPY /backend/openapi.yaml /backend/openapi.yaml
COPY /openflow.openapi.yaml /openflow.openapi.yaml
RUN npm run generate-backend-client
RUN npm run check
RUN npm run build
FROM rust:slim-buster as builder
+1 -4
View File
@@ -3423,7 +3423,7 @@ components:
type: array
items:
type: string
job_duration_ms:
usage:
$ref: "#/components/schemas/Usage"
required:
- email
@@ -4050,6 +4050,3 @@ components:
required:
- access_token
- expires_in
- refresh_token
- scope
+8
View File
@@ -7,3 +7,11 @@ declare namespace App {
title: string?
}
}
declare var __pkg__: { version: string }
declare module 'svelte-highlight/languages/json'
declare module 'svelte-highlight/languages/python'
declare module 'svelte-highlight/languages/typescript'
declare module 'svelte-highlight/styles/github'
declare module 'svelte-split-pane'
@@ -3,7 +3,6 @@
import Modal from './Modal.svelte'
import Tooltip from './Tooltip.svelte'
import json from 'svelte-highlight/languages/json'
import github from 'svelte-highlight/styles/github'
import { Highlight } from 'svelte-highlight'
import { ResourceService, type Resource } from '$lib/gen'
import { workspaceStore } from '$lib/stores'
@@ -23,10 +22,6 @@
let asJson: string = JSON.stringify(value, null, 4)
</script>
<svelte:head>
{@html github}
</svelte:head>
<Modal bind:this={resourceViewer}>
<div slot="title">{resource.path}</div>
<div slot="content">
@@ -1,6 +1,5 @@
<script lang="ts">
import { Highlight } from 'svelte-highlight'
import github from 'svelte-highlight/styles/github'
import { json } from 'svelte-highlight/languages'
import TableCustom from './TableCustom.svelte'
import { truncate } from '$lib/utils'
@@ -55,9 +54,6 @@
}
</script>
<svelte:head>
{@html github}
</svelte:head>
{#if result}
{#if Object.keys(result).length > 0}<div>
The result keys are: <b>{Object.keys(result).join(', ')}</b>
@@ -11,7 +11,6 @@
import ResourceEditor from './ResourceEditor.svelte'
import { Highlight } from 'svelte-highlight'
import { python, typescript } from 'svelte-highlight/languages'
import github from 'svelte-highlight/styles/github'
import Modal from './Modal.svelte'
import type Editor from './Editor.svelte'
@@ -55,10 +54,6 @@
}
</script>
<svelte:head>
{@html github}
</svelte:head>
<ItemPicker
bind:this={scriptPicker}
pickCallback={async (path, _) => {
@@ -1,8 +1,8 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { FlowService, ScheduleService, ScriptService, type Flow } from '$lib/gen'
import { clearPreviewResults, hubScripts, workspaceStore } from '$lib/stores'
import { FlowService, ScheduleService, type Flow } from '$lib/gen'
import { clearPreviewResults, workspaceStore } from '$lib/stores'
import { formatCron, loadHubScripts, sendUserToast, setQueryWithoutLoad } from '$lib/utils'
import { onMount } from 'svelte'
import { OFFSET } from './CronInput.svelte'
@@ -5,7 +5,7 @@
import Icon from 'svelte-awesome'
import { check } from 'svelte-awesome/icons'
import { CompletedJob, FlowModuleValue, FlowStatusModule, JobService, QueuedJob } from '$lib/gen'
import { CompletedJob, FlowStatusModule, JobService, QueuedJob } from '$lib/gen'
import { workspaceStore } from '$lib/stores'
import JobStatus from './JobStatus.svelte'
import FlowJobResult from './FlowJobResult.svelte'
@@ -142,7 +142,7 @@
<div class="min-w-0 flex-1 pt-1.5 flex justify-between space-x-4 w-full">
<div class="w-full">
<p class="text-sm text-gray-500">
{#if mod.value.type == FlowModuleValue.type.SCRIPT}
{#if mod.value.type == 'script'}
Script at path <a
target="_blank"
href={scriptPathToHref(mod.value.path ?? '')}
+16 -15
View File
@@ -6,8 +6,7 @@
import python from 'svelte-highlight/languages/python'
import typescript from 'svelte-highlight/languages/typescript'
import { FlowModuleValue, type FlowValue } from '$lib/gen'
import github from 'svelte-highlight/styles/github'
import type { FlowValue } from '$lib/gen'
import { slide } from 'svelte/transition'
import Tabs from './Tabs.svelte'
import SchemaViewer from './SchemaViewer.svelte'
@@ -31,11 +30,11 @@
export let tab: 'ui' | 'json' | 'schema' = 'ui'
let open: { [id: number]: boolean } = {}
</script>
<svelte:head>
{@html github}
</svelte:head>
function toAny(x: unknown): any {
return x as any
}
</script>
{#if !embedded}
<Tabs
@@ -59,12 +58,14 @@
<FieldHeader
label={inp}
required={flow.schema.required?.includes(inp)}
type={v?.type}
contentEncoding={v?.contentEncoding}
format={v?.format}
itemsType={v?.itemsType}
type={toAny(v)?.type}
contentEncoding={toAny(v)?.contentEncoding}
format={toAny(v)?.format}
itemsType={toAny(v)?.itemsType}
/><span class="ml-4 mt-2 text-xs"
>{v.default != undefined ? 'default: ' + JSON.stringify(v.default) : ''}</span
>{toAny(v)?.default != undefined
? 'default: ' + JSON.stringify(toAny(v)?.default)
: ''}</span
>
</li>
{/each}
@@ -98,13 +99,13 @@
<div class="min-w-0 flex-1 pt-1.5 flex justify-between space-x-4 w-full">
<div class="w-full">
<p class="text-sm text-gray-500">
{#if mod?.value?.type == FlowModuleValue.type.SCRIPT}
{#if mod?.value?.type == 'script'}
Script at path <a
target="_blank"
href={scriptPathToHref(mod?.value?.path ?? '')}
class="font-medium text-gray-900">{mod?.value?.path}</a
>
{:else if mod?.value?.type == FlowModuleValue.type.RAWSCRIPT}
{:else if mod?.value?.type == 'rawscript'}
<button
on:click={() => (open[i] = !open[i])}
class="mb-2 underline text-black"
@@ -120,9 +121,9 @@
/>
</div>
{/if}
{:else if mod?.value?.type == FlowModuleValue.type.FLOW}
{:else if mod?.value?.type == 'flow'}
Flow at path {mod?.value?.path}
{:else if mod?.value?.type == FlowModuleValue.type.FORLOOPFLOW}
{:else if mod?.value?.type == 'forloopflow'}
For loop over step {i}'s result':
<svelte:self flow={mod?.value} embedded={true} />
{/if}
@@ -23,8 +23,8 @@
let company: string | undefined
function handleKeyUp(event: KeyboardEvent) {
const key = event.key || event.keyCode
if (key === 13 || key === 'Enter') {
const key = event.key
if (key === 'Enter') {
event.preventDefault()
addUser()
}
@@ -21,8 +21,8 @@
let is_admin = false
function handleKeyUp(event: KeyboardEvent) {
const key = event.key || event.keyCode
if (key === 13 || key === 'Enter') {
const key = event.key
if (key === 'Enter') {
event.preventDefault()
inviteUser()
}
+2 -2
View File
@@ -20,8 +20,8 @@
}
function handleKeyUp(event: KeyboardEvent): void {
const key = event.key || event.keyCode
if (key === 27 || key === 'Escape' || key === 'Esc') {
const key = event.key
if (key === 'Escape' || key === 'Esc') {
if (open) {
event.preventDefault()
closeModal()
@@ -1,8 +1,8 @@
<script lang="ts">
import { FlowModuleValue, type FlowModule } from '$lib/gen'
import { type FlowModule, RawScript } from '$lib/gen'
import { previewResults } from '$lib/stores'
import { buildExtraLib, objectToTsType, schemaToTsType } from '$lib/utils'
import { faChevronDown, faChevronUp, faRobot } from '@fortawesome/free-solid-svg-icons'
import { faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons'
import Icon from 'svelte-awesome'
import Editor from './Editor.svelte'
import EditorBar from './EditorBar.svelte'
@@ -34,7 +34,7 @@
let bigEditor = false
$: schema = $schemasStore[i]
$: shouldPick = mod.value.path === '' && mod.value.language === undefined
$: shouldPick = 'path' in mod.value && mod.value.path === '' && !('language' in mod.value)
$: pickableProperties = getPickableProperties($flowStore?.schema, args, $previewResults, mode, i)
$: extraLib = buildExtraLib(
schemaToTsType($flowStore?.schema),
@@ -73,13 +73,13 @@
>
</h3>{/if}
<p>
{#if mod.value.path}
{#if 'path' in mod.value && mod.value.path}
{mod.value.path}
{/if}
{#if mod.value.language}
{#if 'language' in mod.value && mod.value.language}
Inline {mod.value.language}
{/if}
{#if !mod.value.path && !mod.value.language}
{#if !('path' in mod.value) && !('language' in mod.value)}
Select a script
{/if}
</p>
@@ -96,7 +96,7 @@
on:new={(e) => createInlineScriptModule(e.detail.language, i, mode)}
/>
{/if}
{#if mod.value.type === FlowModuleValue.type.RAWSCRIPT}
{#if mod.value.type === 'rawscript'}
<div class="p-1 overflow-hidden">
<EditorBar {editor} {websocketAlive} lang={mod.value.language ?? 'deno'} />
</div>
@@ -106,7 +106,7 @@
bind:this={editor}
class="{bigEditor ? 'h-2/3' : 'h-80'} border p-2 rounded"
bind:code={mod.value.content}
deno={mod.value.language === FlowModuleValue.language.DENO}
deno={mod.value.language === RawScript.language.DENO}
automaticLayout={true}
on:blur={() => loadSchema(i)}
formatAction={() => loadSchema(i)}
@@ -49,7 +49,6 @@
import ArgInput from './ArgInput.svelte'
import StringTypeNarrowing from './StringTypeNarrowing.svelte'
import Required from './Required.svelte'
import ResourceTypePicker from './ResourceTypePicker.svelte'
import ObjectTypeNarrowing from './ObjectTypeNarrowing.svelte'
export let property: ModalSchemaProperty = DEFAULT_PROPERTY
@@ -4,7 +4,6 @@
import Highlight from 'svelte-highlight'
import json from 'svelte-highlight/languages/json'
import github from 'svelte-highlight/styles/github'
import TableCustom from './TableCustom.svelte'
export let schema: Schema | undefined = emptySchema()
@@ -12,10 +11,6 @@
let viewJsonSchema = false
</script>
<svelte:head>
{@html github}
</svelte:head>
<div class="w-full">
<div class="flex flex-col sm:flex-row text-base">
<button
@@ -208,10 +208,11 @@
rows="1"
/>
</label>
<label class="block ">
<label class="block" for="inp">
<span class="text-gray-700"
>Description<Required required={false} detail="accept markdown formatting" />
<textarea
id="inp"
bind:value={script.description}
class="
mt-1
@@ -1,5 +1,5 @@
<script lang="ts">
import { JobService, Job, CompletedJob, VariableService, ScriptService } from '$lib/gen'
import { JobService, Job, CompletedJob } from '$lib/gen'
import { emptySchema, displayDate } from '$lib/utils'
import type { Schema } from '$lib/common'
import { fade } from 'svelte/transition'
@@ -9,7 +9,6 @@
faChevronDown,
faChevronUp,
faExclamationTriangle,
faMagic,
faSpinner,
faTimes
} from '@fortawesome/free-solid-svg-icons'
@@ -30,7 +29,9 @@
import type { Preview } from '$lib/gen/models/Preview'
import EditorBar from './EditorBar.svelte'
import { Highlight } from 'svelte-highlight'
import { json, python, typescript } from 'svelte-highlight/languages'
import typescript from 'svelte-highlight/languages/typescript'
import python from 'svelte-highlight/languages/python'
import json from 'svelte-highlight/languages/json'
// Exported
export let schema: Schema = emptySchema()
@@ -432,7 +433,7 @@
<th class="text-xs">logs</th>
</tr>
<tbody slot="body">
{#each pastPreviews as { id, created_at, success, result, logs }}
{#each pastPreviews as { id, created_at, success, result }}
<tr class="">
<td class="text-xs"
><a class="pr-3" href="/run/{id}" target="_blank">{id.substring(30)}</a></td
@@ -1,5 +1,5 @@
<script lang="ts">
import { ScriptService, FlowService, Script } from '$lib/gen'
import { ScriptService, FlowService } from '$lib/gen'
import Icon from 'svelte-awesome'
import { faSearch } from '@fortawesome/free-solid-svg-icons'
@@ -8,9 +8,9 @@
import ItemPicker from './ItemPicker.svelte'
import Modal from './Modal.svelte'
import { Highlight } from 'svelte-highlight'
import { python, typescript } from 'svelte-highlight/languages'
import typescript from 'svelte-highlight/languages/typescript'
import python from 'svelte-highlight/languages/python'
import github from 'svelte-highlight/styles/github'
import { getScriptByPath } from '$lib/utils'
import RadioButtonV3 from './RadioButtonV3.svelte'
@@ -48,10 +48,6 @@
}
</script>
<svelte:head>
{@html github}
</svelte:head>
<ItemPicker
bind:this={itemPicker}
pickCallback={(path, _) => {
@@ -7,7 +7,6 @@
import Highlight from 'svelte-highlight'
import json from 'svelte-highlight/languages/json'
import github from 'svelte-highlight/styles/github'
import SvelteMarkdown from 'svelte-markdown'
export let schema: Schema
@@ -21,10 +20,6 @@
}
</script>
<svelte:head>
{@html github}
</svelte:head>
<div class="w-full">
<PageHeader title="UI customisation" />
<Tabs
@@ -101,7 +101,7 @@
<option>group</option>
</select>
</label>
<label class="block grow mx-2">
<label class="block grow mx-2" for="inp">
<span class="text-sm text-gray-700">Owner</span>
<div class="block mt-1">
<div class="static z-50">
@@ -1,5 +1,5 @@
<script lang="ts">
import { FlowModuleValue } from '$lib/gen/models/FlowModuleValue'
import { RawScript } from '$lib/gen'
import { faCode } from '@fortawesome/free-solid-svg-icons'
import { createEventDispatcher } from 'svelte'
@@ -19,13 +19,13 @@
label="New Typescript {isTrigger ? 'trigger ' : ''}script (Deno)"
icon={faCode}
iconColor="text-blue-800"
on:click={() => dispatch('new', { language: FlowModuleValue.language.DENO })}
on:click={() => dispatch('new', { language: RawScript.language.DENO })}
/>
<FlowScriptPicker
disabled={isTrigger}
label="New Python {isTrigger ? 'trigger ' : ''}script (3.10)"
icon={faCode}
iconColor="text-yellow-500"
on:click={() => dispatch('new', { language: FlowModuleValue.language.PYTHON3 })}
on:click={() => dispatch('new', { language: RawScript.language.PYTHON3 })}
/>
</div>
@@ -1,11 +1,11 @@
<script lang="ts">
import { FlowModuleValue, Script, type FlowModule } from '$lib/gen'
import type { FlowModule } from '$lib/gen'
import { getScriptByPath } from '$lib/utils'
import { faCode, faCodeBranch, faSave, faTrashAlt } from '@fortawesome/free-solid-svg-icons'
import Icon from 'svelte-awesome'
import { Highlight } from 'svelte-highlight'
import { python, typescript } from 'svelte-highlight/languages'
import github from 'svelte-highlight/styles/github'
import typescript from 'svelte-highlight/languages/typescript'
import python from 'svelte-highlight/languages/python'
import Modal from '../Modal.svelte'
import { createScriptFromInlineScript, fork, removeModule } from './flowStore'
import { scrollIntoView } from './utils'
@@ -20,10 +20,14 @@
let modalViewerLanguage: 'deno' | 'python3' = 'deno'
async function viewCode() {
const { content, language } = await getScriptByPath(mod.value.path!)
modalViewerContent = content
modalViewerLanguage = language
modalViewer.openModal()
if (mod.value.type == 'script') {
const { content, language } = await getScriptByPath(mod.value.path!)
modalViewerContent = content
modalViewerLanguage = language
modalViewer.openModal()
} else {
throw Error('Not a script')
}
}
function scrollTo({ target }) {
@@ -32,10 +36,6 @@
}
</script>
<svelte:head>
{@html github}
</svelte:head>
<div class="flex flex-row w-full space-x-2">
<slot />
<a href="#module-{i}" class="grow" on:click={() => (open = i)} on:click|preventDefault={scrollTo}
@@ -43,7 +43,7 @@
>
<div class="flex flex-row space-x-2">
{#if mod.value.type === FlowModuleValue.type.SCRIPT && !shouldPick}
{#if mod.value.type === 'script' && !shouldPick}
<button
type="button"
on:click={() => {
@@ -61,7 +61,7 @@
</button>
{/if}
{#if mod.value.type === FlowModuleValue.type.RAWSCRIPT && !shouldPick}
{#if mod.value.type === 'rawscript' && !shouldPick}
<button
type="button"
on:click={() => createScriptFromInlineScript(i)}
@@ -86,7 +86,7 @@
</div>
<Modal bind:this={modalViewer}>
<div slot="title">Script {mod?.value.path}</div>
<div slot="title">Script {'path' in mod?.value ? mod?.value.path : ''}</div>
<div slot="content">
{#if modalViewerLanguage === 'python3'}
<Highlight language={python} code={modalViewerContent} />
+24 -15
View File
@@ -1,5 +1,5 @@
import type { Schema } from '$lib/common'
import { FlowModuleValue, InputTransform, ScriptService, type Flow, type FlowModule } from '$lib/gen'
import { InputTransform, RawScript, ScriptService, type Flow, type FlowModule } from '$lib/gen'
import { initialCode } from '$lib/script_helpers'
import { userStore, workspaceStore } from '$lib/stores'
import { derived, get, writable } from 'svelte/store'
@@ -12,9 +12,9 @@ export const flowStore = writable<Flow>(undefined)
export const schemasStore = writable<Schema[]>([])
export function initFlow(flow: Flow) {
const newMode = flow.value.modules[1]?.value.type === FlowModuleValue.type.FORLOOPFLOW ? 'pull' : 'push'
const newMode = flow.value.modules[1]?.value.type === 'forloopflow' ? 'pull' : 'push'
mode.set(newMode)
flow = flattenForloopFlows(flow, newMode)
flow = flattenForloopFlows(flow)
flow.value.modules.forEach((mod) => {
Object.values(mod.input_transform).forEach((inp) => {
if (inp.type == InputTransform.type.JAVASCRIPT) {
@@ -46,10 +46,11 @@ export function codeToStaticTemplate(code?: string): string | undefined {
}
return undefined
}
export function flattenForloopFlows(flow: Flow, mode: FlowMode): Flow {
export function flattenForloopFlows(flow: Flow): Flow {
let newFlow: Flow = JSON.parse(JSON.stringify(flow))
if (mode == 'pull') {
const oldModules = newFlow.value.modules[1].value.value?.modules ?? []
const mod = flow.value.modules[1]?.value
if (mod.type === 'forloopflow') {
const oldModules = mod.value?.modules ?? []
newFlow.value.modules = newFlow.value.modules.slice(0, 1)
newFlow.value.modules.push(...oldModules)
}
@@ -61,7 +62,7 @@ export const isCopyFirstStepSchemaDisabled = derived(flowStore, (flow: Flow | un
const modules = flow.value.modules
const [firstModule] = modules
return (
modules.length === 0 || (firstModule.value.path === '' && firstModule.value.type === 'script')
modules.length === 0 || (firstModule.value.type === 'script' && firstModule.value.path === '')
)
} else {
return true
@@ -70,7 +71,7 @@ export const isCopyFirstStepSchemaDisabled = derived(flowStore, (flow: Flow | un
export function addModule(i?: number) {
const newModule: FlowModule = {
value: { type: FlowModuleValue.type.SCRIPT, path: '' },
value: { type: 'script', path: '' },
input_transform: {}
}
@@ -89,7 +90,7 @@ export function addModule(i?: number) {
export async function pickScript(path: string, step: number) {
flowStore.update((flow: Flow) => {
if (flow.value.modules[step]) {
flow.value.modules[step].value.path = path
flow.value.modules[step].value = { type: 'script', path }
}
return flow
@@ -98,11 +99,11 @@ export async function pickScript(path: string, step: number) {
await loadSchema(step)
}
export async function createInlineScriptModule(language: FlowModuleValue.language, step: number, mode: FlowMode) {
export async function createInlineScriptModule(language: RawScript.language, step: number, mode: FlowMode) {
const code = initialCode(language, (mode === 'pull' && step == 0))
flowStore.update((flow: Flow) => {
flow.value.modules[step].value = {
type: FlowModuleValue.type.RAWSCRIPT,
type: 'rawscript',
content: code,
language,
}
@@ -132,6 +133,9 @@ export async function fork(step: number) {
const flow = get(flowStore)
const flowModuleValue = flow.value.modules[step].value
if (flowModuleValue.type !== 'script') {
throw new Error('Can only fork a script module')
}
if (flowModuleValue.path) {
const moduleValue = await createInlineScriptModuleFromPath(flowModuleValue.path)
flowStore.update((flow: Flow) => {
@@ -146,8 +150,13 @@ export async function createScriptFromInlineScript(step: number) {
const schemas = get(schemasStore)
const user = get(userStore)
const flowModuleValue = flow.value.modules[step].value
if (flowModuleValue.type != 'rawscript') {
throw new Error("Can't create script from non-inline script")
}
const originalScriptPath = flowModuleValue.path
const wasForked = Boolean(originalScriptPath)
@@ -170,17 +179,17 @@ export async function createScriptFromInlineScript(step: number) {
path: availablePath,
summary: '',
description,
content: flowModuleValue.content!,
content: flowModuleValue.content,
parent_hash: undefined,
schema: schemas[step],
is_template: false,
language: flowModuleValue.language!
language: flowModuleValue.language
}
})
flowStore.update((flow: Flow) => {
flow.value.modules[step].value = {
type: FlowModuleValue.type.SCRIPT,
type: 'script',
path: availablePath
}
@@ -236,5 +245,5 @@ export async function findNextAvailablePath(path: string): Promise<string> {
export function shouldPickOrCreateScript(flow: Flow, step: number): boolean {
const module = flow.value.modules[step]
return module.value.path === '' && module.value.language === undefined
return module.value.type === 'script' && module.value.path === ''
}
+11 -11
View File
@@ -1,5 +1,5 @@
import type { Schema } from '$lib/common'
import { FlowModuleValue, InputTransform, type Flow, type FlowModule } from '$lib/gen'
import { type FlowModuleValue, InputTransform, type Flow, type FlowModule, RawScript } from '$lib/gen'
import { inferArgs } from '$lib/infer'
import { loadSchema } from '$lib/scripts'
import { emptySchema, getScriptByPath, schemaToObject } from '$lib/utils'
@@ -32,7 +32,7 @@ export function flowToMode(flow: Flow | any, mode: FlowMode): Flow {
newFlow.value.modules.push({
input_transform: oldModules[0].input_transform,
value: {
type: FlowModuleValue.type.FORLOOPFLOW,
type: 'forloopflow',
iterator: { type: InputTransform.type.JAVASCRIPT, expr: 'result.res1' },
value: {
modules: oldModules
@@ -60,14 +60,14 @@ export function getTypeAsString(arg: any): string {
export async function getFirstStepSchema(flow: Flow): Promise<Schema> {
const [firstModule] = flow.value.modules
if (firstModule.value.type === FlowModuleValue.type.RAWSCRIPT) {
if (firstModule.value.type === 'rawscript') {
const { language, content } = firstModule.value
if (language && content) {
const schema = emptySchema()
await inferArgs(language, content, schema)
return schema
}
} else if (firstModule.value.path) {
} else if (firstModule.value.type == 'script') {
return await loadSchema(firstModule.value.path)
}
return emptySchema()
@@ -77,8 +77,8 @@ export async function createInlineScriptModuleFromPath(path: string): Promise<Fl
const { content, language } = await getScriptByPath(path)
return {
type: FlowModuleValue.type.RAWSCRIPT,
language: language as FlowModuleValue.language,
type: 'rawscript',
language: language as RawScript.language,
content: content,
path
}
@@ -97,15 +97,15 @@ export async function loadSchemaFromModule(module: FlowModule): Promise<{
input_transform: Record<string, InputTransform>
schema: Schema
}> {
const isRaw = module?.value.type === FlowModuleValue.type.RAWSCRIPT
const mod = module.value
if (isRaw || Boolean(module.value.path)) {
if (mod.type == 'rawscript' || mod.type === 'script') {
let schema: Schema
if (isRaw) {
if (mod.type === 'rawscript') {
schema = emptySchema()
await inferArgs(module.value.language!, module.value.content!, schema)
await inferArgs(mod.language!, mod.content!, schema)
} else {
schema = await loadSchema(module.value.path!)
schema = await loadSchema(mod.path!)
}
const keys = Object.keys(schema?.properties ?? {})
-1
View File
@@ -1,6 +1,5 @@
import type { Schema, SchemaProperty } from './common.js'
import { ScriptService, type MainArgSignature } from '$lib/gen'
import { sendUserToast } from './utils.js'
export async function inferArgs(
language: 'python3' | 'deno',
+5 -5
View File
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { goto } from '$app/navigation'
import { FlowService, Script, ScriptService, type Flow, type User } from '$lib/gen'
import { FlowService, ScriptService, type Flow, type User } from '$lib/gen'
import { toast } from '@zerodevx/svelte-toast'
import { get } from 'svelte/store'
import type { Schema } from './common'
@@ -48,9 +48,9 @@ export function displayDate(dateString: string | undefined): string {
}
}
export function msToSec(ms: integer | undefined): string {
if (ms === undefined) return '?';
return (ms / 1000).toLocaleString(undefined, {maximumFractionDigits: 3});
export function msToSec(ms: number | undefined): string {
if (ms === undefined) return '?'
return (ms / 1000).toLocaleString(undefined, { maximumFractionDigits: 3 })
}
export function getToday() {
@@ -302,7 +302,7 @@ export function step(n: number): any;
/**
* flow input as an object
*/
export const flow_input: ${previousResultType};
export const flow_input: ${flowInput};
/**
* previous result as an object
@@ -8,6 +8,7 @@
import { sendUserToast } from '$lib/utils'
import { SvelteToast } from '@zerodevx/svelte-toast'
import { onMount } from 'svelte'
import github from 'svelte-highlight/styles/github'
// Default toast options
const toastOptions = {
@@ -93,6 +94,10 @@
})
</script>
<svelte:head>
{@html github}
</svelte:head>
<slot />
<SvelteToast options={toastOptions} />
+1 -2
View File
@@ -21,10 +21,9 @@
import { onMount } from 'svelte'
import Icon from 'svelte-awesome'
import '../app.css'
import { page } from '$app/stores'
import { OpenAPI } from '$lib/gen'
import { superadmin, userStore, usersWorkspaceStore, workspaceStore } from '$lib/stores'
import { clickOutside, sendUserToast, sleep } from '$lib/utils'
import { clickOutside } from '$lib/utils'
import { logout } from '$lib/logout'
import { goto } from '$app/navigation'
+1 -1
View File
@@ -10,7 +10,7 @@
import { AuditService, AuditLog, UserService } from '$lib/gen'
import type { ActionKind } from '$lib/common'
import { page } from '$app/stores'
import { displayDate, sendUserToast } from '$lib/utils'
import { displayDate } from '$lib/utils'
import { goto } from '$app/navigation'
import PageHeader from '$lib/components/PageHeader.svelte'
import { userStore, workspaceStore } from '$lib/stores'
+1 -1
View File
@@ -215,7 +215,7 @@
<th />
</tr>
<tbody slot="body">
{#each filteredHubFlows ?? [] as { summary, apps, id, flow_id }}
{#each filteredHubFlows ?? [] as { summary, apps, flow_id }}
<tr>
<td class="font-black">{apps.join(', ')}</td>
<td><button on:click={() => viewFlow(flow_id)}>{summary}</button></td>
@@ -7,7 +7,7 @@
</script>
<script lang="ts">
import { FlowModuleValue, FlowService, type Flow } from '$lib/gen'
import { FlowService, type Flow } from '$lib/gen'
import { page } from '$app/stores'
import FlowBuilder from '$lib/components/FlowBuilder.svelte'
+2 -2
View File
@@ -36,8 +36,8 @@
}
function handleKeyUp(event: KeyboardEvent) {
const key = event.key || event.keyCode
if (key === 13 || key === 'Enter') {
const key = event.key
if (key === 'Enter') {
event.preventDefault()
addGroup()
}
@@ -19,7 +19,10 @@
sendUserToast(`Error trying to add slack connection: ${error}`, true)
} else if (code && state) {
const res = await OauthService.connectSlackCallback({ requestBody: { code, state } })
$oauthStore = res.bot.bot_access_token
if (!res.bot.bot_access_token) {
throw Error('access token missing')
}
$oauthStore = { access_token: res.bot.bot_access_token }
await OauthService.setWorkspaceSlack({ workspace: $workspaceStore!, requestBody: res })
sendUserToast('Slack workspace connected to your Windmill workspace')
} else {
+2 -7
View File
@@ -17,7 +17,6 @@
import Modal from '$lib/components/Modal.svelte'
import Highlight from 'svelte-highlight'
import json from 'svelte-highlight/languages/json'
import github from 'svelte-highlight/styles/github'
import IconedResourceType from '$lib/components/IconedResourceType.svelte'
import ShareModal from '$lib/components/ShareModal.svelte'
import SharedBadge from '$lib/components/SharedBadge.svelte'
@@ -132,10 +131,6 @@
})
</script>
<svelte:head>
{@html github}
</svelte:head>
<CenteredPage>
<PageHeader title="Resources">
<div class="flex flex-row space-x-4">
@@ -314,7 +309,7 @@
<div slot="title">{resourceViewerTitle}</div>
<div slot="content">
{#if typeModalMode === 'create'}
<label
<label for="inp"
><h3 class="font-semibold text-gray-700">Name<Required required={true} /></h3>
<div>
<span
@@ -322,7 +317,7 @@
>c_</span
>
<div class="inline-block">
<input type="text" bind:value={newResourceTypeName} />
<input id="inp" type="text" bind:value={newResourceTypeName} />
</div>
</div>
</label>
+4 -18
View File
@@ -10,16 +10,9 @@
import { page } from '$app/stores'
import { JobService, Job } from '$lib/gen'
import { onDestroy } from 'svelte'
import {
canWrite,
displayDaysAgo,
forLater,
sendUserToast,
truncate,
truncateHash
} from '$lib/utils'
import { canWrite, displayDaysAgo, forLater, sendUserToast, truncateHash } from '$lib/utils'
import Icon from 'svelte-awesome'
import { check, minus } from 'svelte-awesome/icons'
import { check } from 'svelte-awesome/icons'
import {
faBolt,
faCircle,
@@ -41,8 +34,8 @@
import DisplayResult from '$lib/components/DisplayResult.svelte'
import Highlight from 'svelte-highlight'
import { python, typescript } from 'svelte-highlight/languages'
import github from 'svelte-highlight/styles/github'
import typescript from 'svelte-highlight/languages/typescript'
import python from 'svelte-highlight/languages/python'
import { userStore, workspaceStore } from '$lib/stores'
import CenteredPage from '$lib/components/CenteredPage.svelte'
import FlowStatusViewer from '$lib/components/FlowStatusViewer.svelte'
@@ -452,10 +445,3 @@
</div>
</div>
</CenteredPage>
<svelte:head>
{@html github}
</svelte:head>
<style>
</style>
+4 -9
View File
@@ -32,7 +32,6 @@
} from '@fortawesome/free-solid-svg-icons'
import { page } from '$app/stores'
import { sendUserToast } from '$lib/utils'
import { goto } from '$app/navigation'
import PageHeader from '$lib/components/PageHeader.svelte'
import { workspaceStore } from '$lib/stores'
import CenteredPage from '$lib/components/CenteredPage.svelte'
@@ -73,7 +72,7 @@
}
}
$: $workspaceStore && loadJobs(createdBefore, success, isSkipped, jobKinds)
$: ($workspaceStore && loadJobs(createdBefore)) || (success && isSkipped && jobKinds)
const SMALL_ICON_SCALE = 0.7
@@ -103,12 +102,7 @@
})
}
async function loadJobs(
createdBefore: string | undefined,
success: boolean | undefined,
isSkipped: boolean | undefined,
jobKinds: string | undefined
): Promise<void> {
async function loadJobs(createdBefore: string | undefined): Promise<void> {
try {
const newJobs = await fetchJobs(createdBefore, undefined)
showOlderJobs = newJobs.length === jobsPerPage
@@ -146,7 +140,8 @@
$: {
if ($workspaceStore) {
loadJobs(createdBefore, success, isSkipped, jobKinds)
loadJobs(createdBefore)
success && isSkipped && jobKinds
if (intervalId) {
clearInterval(intervalId)
}
+1 -6
View File
@@ -41,8 +41,7 @@
import Tooltip from '$lib/components/Tooltip.svelte'
import TableCustom from '$lib/components/TableCustom.svelte'
import { Highlight } from 'svelte-highlight'
import { typescript } from 'svelte-highlight/languages'
import github from 'svelte-highlight/styles/github'
import { typescript } from 'svelte-highlight/languages/typescript'
type Tab = 'all' | 'personal' | 'groups' | 'shared' | 'examples' | 'hub'
type Section = [string, ScriptW[]]
@@ -170,10 +169,6 @@
}
</script>
<svelte:head>
{@html github}
</svelte:head>
<Modal bind:this={codeViewer}>
<div slot="title">{codeViewerPath}</div>
<div slot="content">
@@ -30,9 +30,9 @@
faGlobe
} from '@fortawesome/free-solid-svg-icons'
import Highlight from 'svelte-highlight'
import { typescript, python } from 'svelte-highlight/languages'
import typescript from 'svelte-highlight/languages/typescript'
import python from 'svelte-highlight/languages/python'
import github from 'svelte-highlight/styles/github'
import Tooltip from '$lib/components/Tooltip.svelte'
import ShareModal from '$lib/components/ShareModal.svelte'
import { userStore, workspaceStore } from '$lib/stores'
@@ -101,7 +101,7 @@
const script_by_path = await ScriptService.getScriptByPath({
workspace: $workspaceStore!,
path: script.path
}).catch((e) => console.error('this script has no non-archived version'))
}).catch((_) => console.error('this script has no non-archived version'))
topHash = script_by_path?.hash
} else {
topHash = undefined
@@ -118,10 +118,6 @@
})
</script>
<svelte:head>
{@html github}
</svelte:head>
<CenteredPage>
<div class="flex flex-row justify-between">
<h1>
@@ -36,8 +36,8 @@
}
function handleKey(event: KeyboardEvent) {
const key = event.key || event.keyCode
if (key === 13 || key === 'Enter') {
const key = event.key
if (key === 'Enter') {
event.preventDefault()
acceptInvite()
}
@@ -57,8 +57,8 @@
}
function handleKeyUp(event: KeyboardEvent) {
const key = event.key || event.keyCode
if (key === 13 || key === 'Enter') {
const key = event.key
if (key === 'Enter') {
event.preventDefault()
createWorkspace()
}
+2 -2
View File
@@ -75,9 +75,9 @@
})
function handleKeyUp(event: KeyboardEvent) {
const key = event.key || event.keyCode
const key = event.key
if (key === 13 || key === 'Enter') {
if (key === 'Enter') {
event.preventDefault()
login()
}
@@ -1,7 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { sendUserToast, sleep } from '$lib/utils'
import { sendUserToast } from '$lib/utils'
import { onMount } from 'svelte'
import { UserService } from '$lib/gen'
import CenteredModal from '$lib/components/CenteredModal.svelte'
@@ -117,7 +117,7 @@
<th>email</th>
<th>username</th>
<th>role</th>
<th colspan=3>jobs &amp; flows (<abbr title="past two weeks">2w</abbr>)</th>
<th colspan="3">jobs &amp; flows (<abbr title="past two weeks">2w</abbr>)</th>
</tr>
<tbody slot="body">
{#if filteredUsers && users}
@@ -126,9 +126,9 @@
<td>{email}</td>
<td>{username}</td>
<td>{is_admin ? 'admin' : 'user'}</td>
<td>{usage.jobs}</td>
<td>{usage.flows}</td>
<td>{msToSec(usage.duration_ms)}s</td>
<td>{usage?.jobs}</td>
<td>{usage?.flows}</td>
<td>{msToSec(usage?.duration_ms)}s</td>
<td
><button
class="ml-2 text-red-500"
+64 -12
View File
@@ -77,6 +77,67 @@ components:
type: string
FlowModuleValue:
oneOf:
- $ref: "#/components/schemas/RawScript"
- $ref: "#/components/schemas/PathScript"
- $ref: "#/components/schemas/ForloopFlow"
- $ref: "#/components/schemas/PathFlow"
discriminator:
propertyName: type
mapping:
rawscript: "#/components/schemas/RawScript"
script: "#/components/schemas/PathScript"
forloopflow: "#/components/schemas/ForloopFlow"
flow: "#/components/schemas/PathFlow"
required:
- type
RawScript:
type: object
properties:
content:
type: string
language:
type: string
enum:
- deno
- python3
path:
type: string
type:
type: string
required:
- type
- content
- language
PathScript:
type: object
properties:
path:
type: string
type:
type: string
enum:
- script
required:
- type
- path
PathFlow:
type: object
properties:
path:
type: string
type:
type: string
enum:
- flow
required:
- type
ForloopFlow:
type: object
properties:
value:
@@ -85,23 +146,14 @@ components:
$ref: "#/components/schemas/InputTransform"
skip_failures:
type: boolean
path:
type: string
content:
type: string
language:
type: string
enum:
- deno
- python3
type:
type: string
enum:
- script
- flow
- rawscript
- forloopflow
required:
- value
- iterator
- skip_failures
- type
FlowStatus:
+3 -3
View File
@@ -2,12 +2,12 @@
set -e
#TODO: remove once openapi-python-client supports recursive values
sed -z 's/ FlowModuleValue:\n type: object\n properties:\n value:\n $ref: "#\/components\/schemas\/FlowValue"/ FlowModuleValue:\n type: object\n properties:/' ../openflow.openapi.yaml > ../openflow.openapi.yaml
#sed -z 's/ FlowModuleValue:\n type: object\n properties:\n value:\n $ref: "#\/components\/schemas\/FlowValue"/ FlowModuleValue:\n type: object\n properties:/' ../openflow.openapi.yaml > ../openflow.openapi.yaml
cp ../backend/openapi.yaml openapi.yaml
swagger-cli bundle -r openapi.yaml.tmp -o openapi-deref.yaml
swagger-cli bundle -r openapi.yaml -o openapi-deref.yaml
rm openapi.yaml && rm ../openflow.openapi.yaml
rm openapi.yaml #&& rm ../openflow.openapi.yaml
rm -rf windmill-api/ || true
openapi-python-client generate --config $PWD/python-gen.yaml --path openapi-deref.yaml