@actor-types/input-mapper-cli
v1.0.2
Published
CLI tool to generate input types from local schema
Readme
@actor-types/input-mapper-cli
A CLI tool to generate TypeScript types from Apify actor schema files.
Installation
# Install globally
npm install -g @actor-types/input-mapper-cli
# Or use npx
npx @actor-types/input-mapper-cliUsage
Generate Types from Schema
# Using default paths
generate-input generate
# Custom schema path
generate-input generate --schema ./path/to/schema.json
# Custom output path
generate-input generate --output ./path/to/output.ts
# Custom schema and output paths
generate-input generate -s ./path/to/schema.json -o ./path/to/output.tsBy default, the CLI will:
- Look for a schema file at
.actor/INPUT_SCHEMA.jsonin the current directory - Generate a TypeScript interface named
Input - Save the generated type definition to
src/typedefs/input.ts
Command Options
| Option | Alias | Description | Default |
| ---------- | ----- | -------------------------------------- | ---------------------------- |
| --schema | -s | Path to the input schema file | ./.actor/INPUT_SCHEMA.json |
| --output | -o | Path to output the generated type file | ./src/typedefs/input.ts |
Generated Code Example
For a schema like:
{
"title": "Input",
"type": "object",
"schemaVersion": 1,
"properties": {
"url": {
"title": "URL",
"type": "string",
"description": "The URL to scrape"
},
"maxPages": {
"title": "Max Pages",
"type": "integer",
"description": "Maximum number of pages to scrape"
}
},
"required": ["url"]
}The generated TypeScript will be:
export interface Input {
/**
* The URL to scrape
*/
url: string;
/**
* Maximum number of pages to scrape
*/
maxPages?: number;
}Development
# Clone the repository
git clone <repo-url>
# Install dependencies
cd actor-types-generator
npm install
# Build the CLI
npm run build
# Run locally
npm run devLicense
MIT
