Edits history of script submission #23596 for ' Run Code (windmill)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    import * as wmill from "windmill-client"
    
    // windmill-client errors only carry the status text: throw the response body, which says why
    wmill.OpenAPI.interceptors.response.use(async (response) => {
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
      return response
    })
    
    /**
     * Run Code
     * Run code that is not deployed, in any Windmill language, and return its result. It runs as the flow's user, with the given args.
     */
    export async function main(
      language:
        | "bun"
        | "python3"
        | "deno"
        | "go"
        | "bash"
        | "powershell"
        | "postgresql"
        | "mysql"
        | "bigquery"
        | "snowflake"
        | "mssql"
        | "oracledb"
        | "graphql"
        | "nativets"
        | "bunnative"
        | "php"
        | "rust"
        | "ansible"
        | "csharp"
        | "nu"
        | "java"
        | "ruby"
        | "rlang"
        | "duckdb",
      content: string,
      args: { [key: string]: any } | undefined
    ) {
      return await wmill.JobService.runScriptPreviewAndWaitResult({
        workspace: wmill.getWorkspace(),
        requestBody: { language, content, args: args ?? {} },
      })
    }
    

    Submitted by hugo989 5 hours ago