@pokit/sdk-gen
@pokit/sdk-gen generates a typed TypeScript client from a pok command tree.
The generated SDK mirrors the CLI command tree as nested methods such as client.db.migrate(...) and executes commands in process through createSdkRuntime().
Install
pnpm add -D @pokit/sdk-genGenerate Programmatically
import { generateSdk } from '@pokit/sdk-gen';
const result = await generateSdk({
config: './pok.config.ts',
out: './pok.sdk.gen.ts',
includePm: false,
});
console.log(result.outPath);By default, this API:
- discovers
pok.config.tsby walking up fromprocess.cwd() - writes
./pok.sdk.gen.tsrelative to the config directory - does not include package-manager commands (
pmScripts/pmCommands)
Options
config: apok.config.tsfile path or a directory containing oneout: output TS file (default./pok.sdk.gen.tsrelative to config dir)importExtension: control generated import specifiers (preserve|ts|js, defaultpreserve)includePm: include pm-generated commands (defaultfalse)cwd: working directory used for config discovery and relative paths (defaultprocess.cwd())
CLI
pok-sdk generateCLI flags map directly to the same programmatic options:
--config <path>--out <path>--import-extension <preserve|ts|js>--include-pm <true|false>
Use The Generated SDK
import { createClient } from './pok.sdk.gen';
const client = createClient();
const result = await client.hello({ name: 'world' });
console.log(result);
client.close();Notes
- The generator emits typed methods for commands that come from real command modules (file-based commands and mounted sub-app commands).
- If you enable
--include-pm true, pm-generated commands are callable but untyped.