From e8279a9ee12242b17382238d00917810a67ab8ea Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 21 Dec 2023 15:25:40 +0100 Subject: [PATCH] fix: pin deno windmill-client version to relase --- .../apps/editor/component/default-codes.ts | 144 +++++++++--------- .../EmptyInlineScript.svelte | 4 +- .../flows/content/FlowInputs.svelte | 28 ++-- .../flows/content/s3Scripts/deno.ts | 2 +- frontend/src/lib/script_helpers.ts | 6 +- 5 files changed, 92 insertions(+), 92 deletions(-) diff --git a/frontend/src/lib/components/apps/editor/component/default-codes.ts b/frontend/src/lib/components/apps/editor/component/default-codes.ts index e61826cec3..b645c72920 100644 --- a/frontend/src/lib/components/apps/editor/component/default-codes.ts +++ b/frontend/src/lib/components/apps/editor/component/default-codes.ts @@ -1,17 +1,17 @@ import type { AppComponent } from '.' export function defaultCode(component: string, language: string): string | undefined { - return DEFAULT_CODES[component]?.[language] + return DEFAULT_CODES[component]?.[language] } export const DEFAULT_CODES: Partial< - Record< - AppComponent['type'], - Partial> - > + Record< + AppComponent['type'], + Partial> + > > = { - tablecomponent: { - deno: `export async function main() { + tablecomponent: { + deno: `export async function main() { return [ { "id": 1, @@ -25,7 +25,7 @@ export const DEFAULT_CODES: Partial< } ] }`, - python3: `def main(): + python3: `def main(): return [ { "id": 1, @@ -38,7 +38,7 @@ export const DEFAULT_CODES: Partial< "age": 84 } ]`, - pgsql: `import { pgSql } from "npm:windmill-client@1"; + pgsql: `import { pgSql } from "npm:windmill-client@${__pkg__.version}"; type Postgresql = object @@ -46,9 +46,9 @@ export async function main(db: Postgresql) { const query = await pgSql(db)\`SELECT * FROM demo;\`; return query.rows; }` - }, - aggridcomponent: { - deno: `export async function main() { + }, + aggridcomponent: { + deno: `export async function main() { return [ { "id": 1, @@ -62,7 +62,7 @@ export async function main(db: Postgresql) { } ] }`, - python3: `def main(): + python3: `def main(): return [ { "id": 1, @@ -75,7 +75,7 @@ export async function main(db: Postgresql) { "age": 84 } ]`, - pgsql: `import { pgSql } from "npm:windmill-client@1"; + pgsql: `import { pgSql } from "npm:windmill-client@${__pkg__.version}"; type Postgresql = object @@ -83,29 +83,29 @@ export async function main(db: Postgresql) { const query = await pgSql(db)\`SELECT * FROM demo;\`; return query.rows; }` - }, - steppercomponent: { - deno: `export async function main(stepIndex: number) { + }, + steppercomponent: { + deno: `export async function main(stepIndex: number) { // if (stepIndex == 0) { // if (page0Invalid) throw Error("first step invalid") // } else if ... }`, - python3: `def main(stepIndex: int): + python3: `def main(stepIndex: int): # if stepIndex == 0: # if page0Invalid: # raise Exception("first step invalid") # elif ... ` - }, - textcomponent: { - deno: `export async function main() { + }, + textcomponent: { + deno: `export async function main() { return "foo" }`, - python3: `def main(): + python3: `def main(): return "foo"` - }, - barchartcomponent: { - deno: `export async function main() { + }, + barchartcomponent: { + deno: `export async function main() { return { "data": [ 25, @@ -119,7 +119,7 @@ export async function main(db: Postgresql) { ] } }`, - python3: `def main(): + python3: `def main(): return { "data": [ 25, @@ -132,7 +132,7 @@ export async function main(db: Postgresql) { "<3" ] }`, - pgsql: `import { pgSql } from "npm:windmill-client@1"; + pgsql: `import { pgSql } from "npm:windmill-client@${__pkg__.version}"; type Postgresql = object @@ -143,20 +143,20 @@ export async function main(db: Postgresql) { labels: query.rows.map((row) => row['1']?.slice(0, 6)) }; }` - }, - displaycomponent: { - deno: `export async function main(x = 42) { + }, + displaycomponent: { + deno: `export async function main(x = 42) { return { foo: x } }`, - python3: `def main(): + python3: `def main(): return { "foo": 42 }` - }, - htmlcomponent: { - deno: `export async function main() { + }, + htmlcomponent: { + deno: `export async function main() { return \` @@ -164,16 +164,16 @@ export async function main(db: Postgresql) { Hello world \` }`, - python3: `def main(): + python3: `def main(): return '''

Hello world

'''` - }, - vegalitecomponent: { - deno: `export async function main() { + }, + vegalitecomponent: { + deno: `export async function main() { return { data: { values: [ @@ -190,7 +190,7 @@ export async function main(db: Postgresql) { } } }`, - python3: `def main(): + python3: `def main(): return { "data": { "values": [ @@ -206,7 +206,7 @@ export async function main(db: Postgresql) { "y": { "field": "b", "type": "quantitative" }, }, }`, - pgsql: `import { pgSql } from "npm:windmill-client@1"; + pgsql: `import { pgSql } from "npm:windmill-client@${__pkg__.version}"; type Postgresql = object @@ -226,9 +226,9 @@ export async function main(Postgresqlstgresql) { } }; }` - }, - plotlycomponent: { - deno: `export async function main() { + }, + plotlycomponent: { + deno: `export async function main() { return { type: 'bar', x: [1, 2, 3, 4], @@ -241,7 +241,7 @@ export async function main(Postgresqlstgresql) { } }; }`, - python3: `def main(): + python3: `def main(): return { "type": "bar", "x": [1, 2, 3, 4], @@ -253,7 +253,7 @@ export async function main(Postgresqlstgresql) { } } }`, - pgsql: `import { pgSql } from "npm:windmill-client@1"; + pgsql: `import { pgSql } from "npm:windmill-client@${__pkg__.version}"; type Postgresql = object @@ -271,9 +271,9 @@ export async function main(Postgresqlstgresql) { } }; }` - }, - piechartcomponent: { - deno: `export async function main() { + }, + piechartcomponent: { + deno: `export async function main() { return { "data": [ 25, @@ -287,7 +287,7 @@ export async function main(Postgresqlstgresql) { ] } }`, - python3: `def main(): + python3: `def main(): return { "data": [ 25, @@ -300,7 +300,7 @@ export async function main(Postgresqlstgresql) { "<3" ] }`, - pgsql: `import { pgSql } from "npm:windmill-client@1"; + pgsql: `import { pgSql } from "npm:windmill-client@${__pkg__.version}"; type Postgresql = object @@ -311,9 +311,9 @@ export async function main(db: Postgresql) { labels: query.rows.map((row) => row['1']?.slice(0, 6)) }; }` - }, - scatterchartcomponent: { - deno: `export async function main() { + }, + scatterchartcomponent: { + deno: `export async function main() { return [ { label: "foo", @@ -335,7 +335,7 @@ export async function main(db: Postgresql) { } ]; }`, - python3: `def main(): + python3: `def main(): return [ { "label": "foo", @@ -356,7 +356,7 @@ export async function main(db: Postgresql) { "backgroundColor": "orange" } ]`, - pgsql: `import { pgSql } from "npm:windmill-client@1"; + pgsql: `import { pgSql } from "npm:windmill-client@${__pkg__.version}"; type Postgresql = object @@ -386,9 +386,9 @@ export async function main(db: Postgresql) { return []; } }` - }, - timeseriescomponent: { - deno: `export async function main() { + }, + timeseriescomponent: { + deno: `export async function main() { return [ { label: "foo", @@ -428,7 +428,7 @@ export async function main(db: Postgresql) { } ] }`, - python3: `def main(): + python3: `def main(): return [ { "label": "foo", @@ -467,16 +467,16 @@ export async function main(db: Postgresql) { "backgroundColor": "orange" } ]` - }, - iconcomponent: { - deno: `export async function main() { + }, + iconcomponent: { + deno: `export async function main() { return "Smile"; }`, - python3: `def main(): + python3: `def main(): return "Smile"` - }, - schemaformcomponent: { - deno: `export async function main() { + }, + schemaformcomponent: { + deno: `export async function main() { return { properties: { first_name: { @@ -488,7 +488,7 @@ return { required: [] } }`, - python3: `def main(): + python3: `def main(): return { "properties": { "first_name": { @@ -500,9 +500,9 @@ return { "required": [] } ` - }, - listcomponent: { - deno: `export async function main() { + }, + listcomponent: { + deno: `export async function main() { return [{ "foo": 1, }, { @@ -511,7 +511,7 @@ return { "foo": 3, }]; }`, - python3: `def main(): + python3: `def main(): return [{"foo": 1}, {"foo": 2}, {"foo": 3}]` - } + } } as const diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte index d9ccd04b66..0bf56bb89a 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte @@ -95,6 +95,7 @@ const langs = [ ['deno', 'TypeScript (Deno)'], ['python3', 'Python'], + ['bun', 'TypeScript (Bun)'], ['go', 'Go'], ['bash', 'Bash'], ['powershell', 'PowerShell'], @@ -104,8 +105,7 @@ ['bigquery', 'BigQuery'], ['snowflake', 'Snowflake'], ['mssql', 'MS SQL Server'], - ['graphql', 'GraphQL'], - ['bun', 'TypeScript (Bun)'] + ['graphql', 'GraphQL'] ] as [Script.language, string][] diff --git a/frontend/src/lib/components/flows/content/FlowInputs.svelte b/frontend/src/lib/components/flows/content/FlowInputs.svelte index e4c24ed421..1f7b436a96 100644 --- a/frontend/src/lib/components/flows/content/FlowInputs.svelte +++ b/frontend/src/lib/components/flows/content/FlowInputs.svelte @@ -120,6 +120,20 @@ }} /> + { + dispatch('new', { + language: RawScript.language.BUN, + kind, + subkind: 'flow', + summary + }) + }} + /> + {#if kind != 'approval'} --> {/if} {/if} - - { - dispatch('new', { - language: RawScript.language.BUN, - kind, - subkind: 'flow', - summary - }) - }} - /> diff --git a/frontend/src/lib/components/flows/content/s3Scripts/deno.ts b/frontend/src/lib/components/flows/content/s3Scripts/deno.ts index 67e84f3a2a..f4e9324572 100644 --- a/frontend/src/lib/components/flows/content/s3Scripts/deno.ts +++ b/frontend/src/lib/components/flows/content/s3Scripts/deno.ts @@ -1,5 +1,5 @@ const deno = { - s3_client: `import * as wmill from "npm:windmill-client@1"; + s3_client: `import * as wmill from "npm:windmill-client@${__pkg__.version}"; import { S3Client } from "https://deno.land/x/s3_lite_client@0.2.0/mod.ts"; type s3object = object; diff --git a/frontend/src/lib/script_helpers.ts b/frontend/src/lib/script_helpers.ts index 4797a60181..376f11ec13 100644 --- a/frontend/src/lib/script_helpers.ts +++ b/frontend/src/lib/script_helpers.ts @@ -37,7 +37,7 @@ export async function main() { export const DENO_INIT_CODE = `// Ctrl/CMD+. to cache dependencies on imports hover. // Deno uses "npm:" prefix to import from npm (https://deno.land/manual@v1.36.3/node/npm_specifiers) -// import * as wmill from "npm:windmill-client@1" +// import * as wmill from "npm:windmill-client@${__pkg__.version}" // fill the type, or use the +Resource type to get a type-safe reference to a resource // type Postgresql = object @@ -114,7 +114,7 @@ func main(message string, name string) (interface{}, error) { } ` -export const DENO_INIT_CODE_CLEAR = `// import * as wmill from "npm:windmill-client@1" +export const DENO_INIT_CODE_CLEAR = `// import * as wmill from "npm:windmill-client@${__pkg__.version}" export async function main(x: string) { return x @@ -214,7 +214,7 @@ dflt="\${2:-default value}" echo "Hello $msg" ` -export const DENO_INIT_CODE_TRIGGER = `import * as wmill from "npm:windmill-client@1" +export const DENO_INIT_CODE_TRIGGER = `import * as wmill from "npm:windmill-client@${__pkg__.version}" export async function main() {