A TypeScript code generator for creating type-safe clients for Windmill.
windmill-ts.mov
Under the hood, it uses the official windmill-client library to interact with Windmill, and exposes a similar interface.
The output is a single file that could be used from Windmill itself (by creating
a script from the output and importing it from other TypeScript files), and from
your own codebase (by setting up windmill-client
in it).
- Generates fully typed TypeScript client code for your Windmill workspace
- Type-safe access to scripts, flows and resources
- Automatic schema generation from Windmill's JSON schemas
- Integration with the Windmill CLI configuration
- A configured Windmill CLI environment
Refer to the Windmill docs for instructions on how to set up the Windmill CLI.
npm install windmill-ts
The simplest way to use windmill-ts is to run it with no arguments, which will use your active Windmill CLI workspace:
npx windmill-ts ./generated-client.ts
You can also specify a specific workspace:
npx windmill-ts -w my-workspace ./generated-client.ts
To output to stdout instead of a file, use -
as the output path:
npx windmill-ts -
The generated client provides type-safe functions for running scripts and flows, and getting resources:
import {
runScript,
runScriptAsync,
runFlow,
runFlowAsync,
getResource,
} from "./generated-client";
// Run a script synchronously
const result = await runScript("my/script/path", {
// TypeScript will enforce the correct argument types here
arg1: "value",
arg2: 42,
});
// Run a script asynchronously
const jobId = await runScriptAsync("my/script/path", {
arg1: "value",
arg2: 42,
});
// Run a flow
const flowResult = await runFlow("my/flow/path", {
input1: "value",
input2: true,
});
// Get a resource with type validation
const resource = await getResource("my/resource/path");
// TypeScript will infer the correct type based on the resource type
The generator:
- Connects to your configured Windmill workspace
- Fetches all available scripts, flows and resource types
- Generates Zod schemas for validating inputs
- Creates type-safe wrapper functions for running scripts and flows
- Handles resource type references and validations
This project is licensed under the Unlicense - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.