Skip to content

apify-projects/input_to_schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Syntax

You should create a type named Input in your main.ts

The Typescript type definition should get picked up automatically, and then you can annotate the rest with JSDoc, like so

interface Input {
  /**
  * @name Name
  * @description Name of the Account
  * @prefill "John"
  */
  name: string

  /**
  * @name Role
  * @description Role of the account
  */
  role: 'admin' | 'normal'
}

const {
  // It can do defaults like so!
  role = 'admin'
} = (await Actor.getInput<Input>())!

Result:

{
    "type": "object",
    "properties": {
        "name": {
            "title": "Name",
            "description": "Name of the Account",
            "editor": "textfield",
            "prefill": "John",
            "type": "string"
        },
        "role": {
            "type": "string",
            "editor": "select",
            "title": "Role",
            "description": "Role of the account",
            "default": "admin",
            "enum": [
                "admin",
                "normal"
            ]
        }
    },
    "required": []
}

Usage

tsx ./index.ts print <folder_with_main.ts>

Or you can get help with

tsx ./index.ts help print

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published