1.0.2 • Published 6 months ago

@actor-types/input-mapper-cli v1.0.2

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

@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-cli

Usage

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.ts

By default, the CLI will: 1. Look for a schema file at .actor/INPUT_SCHEMA.json in the current directory 2. Generate a TypeScript interface named Input 3. Save the generated type definition to src/typedefs/input.ts

Command Options

OptionAliasDescriptionDefault
--schema-sPath to the input schema file./.actor/INPUT_SCHEMA.json
--output-oPath 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 dev

License

MIT

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago