mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 16:02:14 +00:00
a3faea16e7
* feat: add nu (nushell) support * add worker tests * deactivate tables and non-any types below top-level full support will come in V1 for V0 it's better to keep things minimal and simple * add syntax highlighting used python's grammar, since nushell isn't supported by monaco nor svelte-highlights for V1 nu will get it`s own grammar * add logo * partially implement plugin support * change logo + ability to deploy + nsjail draft * static variables + get_resource + get_variable * lsp/dev.nu + initial nu lsp (not working yet) * make it work with nsjail * nullguard * Much more flexible signature parsing and better error-messages * add init script * rename nulsp to nu * install nu to dockerfile * fix merge * implement Default for MainArgSignature * stage NU_CACHE_DIR * improve dockerfiles * dev.nu for parser-wasm + flake.nix * update code for windows * add nushell to flake * upload Cargo.lock * make build.sh work on nixos * build wasm cli parsers * add docs to README_DEV.md * add helper script docker/dev.nu * improve docker/dev.nu * fix windows * commit frontend/package(lock).json * update cargo.lock * correctly update cargo.lock * remove lsp * update flake.nix to include svelte server and nushell * Revert base.sql to main * remove PLUGIN_USE_RE * make CARGO_PATH private * add nu to cli * Change flags to build wasm-nu-parser * remove flake.nix from parser-wasm * update wasm-build target * remove unused import * add cli support for nu * update github workflows * wasm-build 0.17 -> 0.19 * update build script * update cargo.lock * Fix typographical error * update Cargo.lock * update ENV_SETTINGS * use published nu parser * update package.lock * rewrite parser in tree-sitter * implement parser from scratch * polishing * change init script to match new parser * fix imports * fix cli build * fix cli build * merge * update wasm * use MiniPulledJob * update cli * change cli wasm schema * change cli * update deno.json * make wasm modules load lazily * regenerate parsers * remove leftover * update cargo.lock * clean up dnt.ts * add docs to cli/test.nu * add schema validation option * add Nu to try_validate_schema * reference frontend to new parser version
199 lines
4.9 KiB
TypeScript
199 lines
4.9 KiB
TypeScript
import { get } from 'svelte/store'
|
|
import { base } from '$lib/base'
|
|
import type { Schema, SupportedLanguage } from './common'
|
|
import { FlowService, type Script, ScriptService, ScheduleService } from './gen'
|
|
import { workspaceStore } from './stores'
|
|
|
|
export function scriptLangToEditorLang(
|
|
lang: Script['language'] | 'bunnative' | 'frontend' | undefined
|
|
) {
|
|
if (lang == 'deno') {
|
|
return 'typescript'
|
|
} else if (lang == 'bun' || lang == 'bunnative' || lang == 'frontend') {
|
|
return 'typescript'
|
|
} else if (lang == 'nativets') {
|
|
return 'typescript'
|
|
// } else if (lang == 'graphql') {
|
|
// return 'typescript'
|
|
} else if (lang == 'postgresql') {
|
|
return 'sql'
|
|
} else if (lang == 'mysql') {
|
|
return 'sql'
|
|
} else if (lang == 'bigquery') {
|
|
return 'sql'
|
|
} else if (lang == 'oracledb') {
|
|
return 'sql'
|
|
} else if (lang == 'snowflake') {
|
|
return 'sql'
|
|
} else if (lang == 'mssql') {
|
|
return 'sql'
|
|
} else if (lang == 'python3') {
|
|
return 'python'
|
|
} else if (lang == 'bash') {
|
|
return 'shell'
|
|
} else if (lang == 'powershell') {
|
|
return 'powershell'
|
|
} else if (lang == 'php') {
|
|
return 'php'
|
|
} else if (lang == 'rust') {
|
|
return 'rust'
|
|
} else if (lang == 'graphql') {
|
|
return 'graphql'
|
|
} else if (lang == 'ansible') {
|
|
return 'yaml'
|
|
} else if (lang == 'csharp') {
|
|
return 'csharp'
|
|
} else if (lang == 'nu') {
|
|
return 'nu'
|
|
} else if (lang == undefined) {
|
|
return 'typescript'
|
|
} else {
|
|
return lang
|
|
}
|
|
}
|
|
|
|
export type ScriptSchedule = {
|
|
summary: string | undefined
|
|
args: Record<string, any>
|
|
cron: string
|
|
timezone: string
|
|
enabled: boolean
|
|
}
|
|
|
|
// Load the schedule of a flow given its path and the workspace
|
|
export async function loadScriptSchedule(
|
|
path: string,
|
|
workspace: string
|
|
): Promise<ScriptSchedule | undefined> {
|
|
const existsSchedule = await ScheduleService.existsSchedule({
|
|
workspace,
|
|
path
|
|
})
|
|
|
|
if (!existsSchedule) {
|
|
return undefined
|
|
}
|
|
|
|
const schedule = await ScheduleService.getSchedule({
|
|
workspace,
|
|
path
|
|
})
|
|
|
|
return {
|
|
summary: schedule.summary,
|
|
enabled: schedule.enabled,
|
|
cron: schedule.schedule,
|
|
timezone: schedule.timezone,
|
|
args: schedule.args ?? {}
|
|
}
|
|
}
|
|
|
|
export async function loadSchemaFlow(path: string): Promise<Schema> {
|
|
const flow = await FlowService.getFlowByPath({
|
|
workspace: get(workspaceStore)!,
|
|
path: path ?? ''
|
|
})
|
|
return flow.schema as any
|
|
}
|
|
|
|
export function scriptPathToHref(path: string, hubBaseUrl: string): string {
|
|
if (path.startsWith('hub/')) {
|
|
return hubBaseUrl + '/from_version/' + path.substring(4)
|
|
} else {
|
|
return `${base}/scripts/get/${path}?workspace=${get(workspaceStore)}`
|
|
}
|
|
}
|
|
|
|
const scriptLanguagesArray: [SupportedLanguage | 'docker' | 'bunnative', string][] = [
|
|
['bun', 'TypeScript (Bun)'],
|
|
['python3', 'Python'],
|
|
['deno', 'TypeScript (Deno)'],
|
|
['bash', 'Bash'],
|
|
['go', 'Go'],
|
|
['nativets', 'REST'],
|
|
['bunnative', 'REST'],
|
|
['postgresql', 'PostgreSQL'],
|
|
['mysql', 'MySQL'],
|
|
['bigquery', 'BigQuery'],
|
|
['oracledb', 'Oracle Database'],
|
|
['snowflake', 'Snowflake'],
|
|
['mssql', 'MS SQL Server'],
|
|
['graphql', 'GraphQL'],
|
|
['powershell', 'PowerShell'],
|
|
['php', 'PHP'],
|
|
['rust', 'Rust'],
|
|
['ansible', 'Ansible Playbook'],
|
|
['csharp', 'C#'],
|
|
['docker', 'Docker'],
|
|
['nu', 'Nu']
|
|
]
|
|
export function processLangs(selected: string | undefined, langs: string[]): string[] {
|
|
if (selected === 'nativets') {
|
|
return langs
|
|
} else {
|
|
let ls = langs.filter((lang) => lang !== 'nativets')
|
|
|
|
//those languages are newer and may not be in the saved list
|
|
let nl = ['bunnative', 'rust', 'ansible', 'csharp', 'nu']
|
|
nl.forEach((lang) => {
|
|
if (!ls.includes(lang)) {
|
|
ls.push(lang)
|
|
}
|
|
})
|
|
return ls
|
|
}
|
|
}
|
|
|
|
export const defaultScriptLanguages = Object.fromEntries(scriptLanguagesArray)
|
|
|
|
export async function getScriptByPath(path: string): Promise<{
|
|
content: string
|
|
language: SupportedLanguage
|
|
schema: any
|
|
description: string
|
|
tag: string | undefined
|
|
concurrent_limit: number | undefined
|
|
concurrency_time_window_s: number | undefined
|
|
lock?: string
|
|
created_at?: string
|
|
}> {
|
|
if (path.startsWith('hub/')) {
|
|
const { content, language, schema, lockfile } = await ScriptService.getHubScriptByPath({ path })
|
|
|
|
return {
|
|
content,
|
|
language: language as SupportedLanguage,
|
|
schema,
|
|
description: '',
|
|
tag: undefined,
|
|
concurrent_limit: undefined,
|
|
concurrency_time_window_s: undefined,
|
|
lock: lockfile
|
|
}
|
|
} else {
|
|
const script = await ScriptService.getScriptByPath({
|
|
workspace: get(workspaceStore)!,
|
|
path: path ?? ''
|
|
})
|
|
return {
|
|
content: script.content,
|
|
language: script.language,
|
|
schema: script.schema,
|
|
description: script.description,
|
|
tag: script.tag,
|
|
concurrent_limit: script.concurrent_limit,
|
|
concurrency_time_window_s: script.concurrency_time_window_s,
|
|
lock: script.lock,
|
|
created_at: script.created_at
|
|
}
|
|
}
|
|
}
|
|
|
|
export async function getLatestHashForScript(path: string): Promise<string> {
|
|
const script = await ScriptService.getScriptByPath({
|
|
workspace: get(workspaceStore)!,
|
|
path: path ?? ''
|
|
})
|
|
return script.hash
|
|
}
|