test-infer-args
v1.0.5
Published
Windmill argument inference utilities
Readme
windmill-infer-args
A TypeScript library for inferring arguments from code snippets in various languages for Windmill workflows.
Installation
npm install windmill-infer-argsUsage
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()Supported Languages
This package supports inferring arguments from code in the following languages:
- Python (
python3) - TypeScript/JavaScript (
deno,nativets,bun,bunnative) - SQL variants (
postgresql,mysql,bigquery,snowflake,mssql,oracledb) - GraphQL (
graphql) - Go (
go) - Bash (
bash) - PowerShell (
powershell) - PHP (
php) - Rust (
rust) - Ansible (
ansible) - C# (
csharp) - Nu Shell (
nu) - Java (
java)
API
inferArgs
Infers arguments from code and populates a schema object with the inferred types.
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
nullif the language is not supported
License
ISC
