UNPKG

windmill-utils-internal

Version:

Internal utility functions for Windmill

59 lines (58 loc) 2.56 kB
import { RawScript } from "../gen/types.gen"; /** * Union type of all supported programming languages in Windmill */ export type SupportedLanguage = RawScript["language"] | "frontend" | "bunnative" | "oracledb" | "rust" | "csharp" | "nu" | "ansible" | "java" | "duckdb"; /** * Mapping of supported languages to their file extensions */ export declare const LANGUAGE_EXTENSIONS: Record<SupportedLanguage, string>; /** * Gets the appropriate file extension for a given programming language. * Handles special cases for TypeScript variants based on the default runtime. * * @param language - The programming language to get extension for * @param defaultTs - Default TypeScript runtime ("bun" or "deno") * @returns File extension string (without the dot) */ export declare function getLanguageExtension(language: SupportedLanguage, defaultTs?: "bun" | "deno"): string; /** * Reverse mapping from file extensions to languages. * Used when deriving language from file extension. */ export declare const EXTENSION_TO_LANGUAGE: Record<string, SupportedLanguage>; /** * Gets the language from a file extension. * * @param ext - File extension (e.g., "py", "ts", "bun.ts") * @param defaultTs - Default TypeScript runtime for plain .ts files * @returns The language, or undefined if not recognized */ export declare function getLanguageFromExtension(ext: string, defaultTs?: "bun" | "deno"): SupportedLanguage | undefined; export interface PathAssigner { assignPath(summary: string | undefined, language: SupportedLanguage): [string, string]; } export interface PathAssignerOptions { defaultTs: "bun" | "deno"; /** When true, skip the .inline_script. suffix in file names */ skipInlineScriptSuffix?: boolean; } /** * Creates a new path assigner for inline scripts. * * @param defaultTs - Default TypeScript runtime ("bun" or "deno") * @param options - Optional configuration (can pass options object instead of defaultTs) * @returns Path assigner function */ export declare function newPathAssigner(defaultTs: "bun" | "deno" | PathAssignerOptions, options?: { skipInlineScriptSuffix?: boolean; }): PathAssigner; /** * Creates a new path assigner for raw app runnables. * Unlike newPathAssigner, this does NOT add ".inline_script." prefix since * everything in raw_app/backend/ is already known to be for inline scripts. * * @param defaultTs - Default TypeScript runtime ("bun" or "deno") * @returns Path assigner function */ export declare function newRawAppPathAssigner(defaultTs: "bun" | "deno"): PathAssigner;