Edits history of script submission #23560 for ' Create Script (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
    })
    
    /**
     * Create Script
     * Deploy a new script at a path that holds none. Its lockfile is generated in the background: a run started before it lands fails.
     */
    export async function main(
      path: string,
      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,
      summary: string | undefined,
      description: string | undefined
    ) {
      return await wmill.ScriptService.createScript({
        workspace: wmill.getWorkspace(),
        requestBody: {
          path,
          language,
          content,
          summary: summary || "",
          description: description || undefined,
        },
      })
    }
    

    Submitted by hugo989 5 hours ago