handle loading erronous code in flows

This commit is contained in:
Ruben Fiszel
2022-08-18 13:26:52 +02:00
parent 157dc5b501
commit d73d2578f2
2 changed files with 16 additions and 5 deletions
@@ -1,6 +1,6 @@
<script lang="ts">
import type { FlowModule } from '$lib/gen'
import { getScriptByPath } from '$lib/utils'
import { getScriptByPath, valueToTsType } from '$lib/utils'
import {
faArrowDown,
faClose,
@@ -15,6 +15,7 @@
import { Highlight } from 'svelte-highlight'
import python from 'svelte-highlight/languages/python'
import typescript from 'svelte-highlight/languages/typescript'
import IconedResourceType from '../IconedResourceType.svelte'
import Modal from '../Modal.svelte'
import { isEmptyFlowModule } from './flowStateUtils'
import { stepOpened } from './stepOpenedStore'
@@ -46,7 +47,12 @@
<div on:click={() => stepOpened.update(() => String(indexes.join('-')))}>
<h3 class="text-sm font-bold text-gray-900">
{#if 'path' in mod.value && mod.value.path}
{mod.value.path}
{#if mod.value.path.startsWith('hub/')}
<IconedResourceType name={mod.value.path.split('/')[2]} silent={true} />&nbsp;{mod.value
.path}
{:else}
{mod.value.path}
{/if}
{:else if 'language' in mod.value && mod.value.language}
Inline {mod.value.language}
{:else}
@@ -17,10 +17,15 @@ export function emptyFlowModuleSchema(): FlowModuleSchema {
}
export async function loadFlowModuleSchema(flowModule: FlowModule): Promise<FlowModuleSchema> {
const { input_transform, schema } = await loadSchemaFromModule(flowModule)
flowModule.input_transform = input_transform
try {
const { input_transform, schema } = await loadSchemaFromModule(flowModule)
return { flowModule, schema, previewResults: [] }
flowModule.input_transform = input_transform
return { flowModule, schema, previewResults: [] }
} catch (e) {
return { flowModule, schema: emptySchema(), previewResults: [] }
}
}
export async function pickScript(path: string): Promise<FlowModuleSchema> {