Windmill argument inference utilities
npm install test-infer-argsA TypeScript library for inferring arguments from code snippets in various languages for Windmill workflows.
``bash`
npm install windmill-infer-args
`typescript
import { inferArgs } from 'windmill-infer-args'
// Example schema
const schema = {
properties: {},
required: []
}
async function main() {
// Infer arguments from Python code
const pythonCode =
def main(name: str, age: int = 30):
print(f"Hello, {name}! You are {age} years old.")
const result = await inferArgs('python3', pythonCode, schema)
console.log(schema)
// Output will contain properties for 'name' and 'age' with proper types
// 'name' will be in the required array since it has no default value
}
main()
`
This package supports inferring arguments from code in the following languages:
- Python (python3)deno
- TypeScript/JavaScript (, nativets, bun, bunnative)postgresql
- SQL variants (, mysql, bigquery, snowflake, mssql, oracledb)graphql
- GraphQL ()go
- Go ()bash
- Bash ()powershell
- PowerShell ()php
- PHP ()rust
- Rust ()ansible
- Ansible ()csharp
- C# ()nu
- Nu Shell ()java
- Java ()
Infers arguments from code and populates a schema object with the inferred types.
`typescript`
async function inferArgs(
language: SupportedLanguage | 'bunnative' | undefined,
code: string,
schema: Schema,
mainOverride?: string
): Promise<{
no_main_func: boolean | null
has_preprocessor: boolean | null
} | null>
Parameters:
- language: The programming language of the codecode
- : The source code to infer arguments fromschema
- : A JSON schema object to populate with inferred typesmainOverride
- : (Optional) Override for the main function name
Returns:
- An object with information about the parsed code or null` if the language is not supported
ISC