GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cli-plugins/packages/contentstack-cli-tsgen at main · contentstack/cli-plugins

Expand file tree

/

contentstack-cli-tsgen

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

contentstack-cli-tsgen

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
bin
bin
 
 
skills
skills
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
AGENTS.md
AGENTS.md
 
 
MIGRATION.md
MIGRATION.md
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
eslint.config.js
eslint.config.js
 
 
jest.config.js
jest.config.js
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 

README.md

Outline

npm

Description

This is a plugin for Contentstack's CLI. This plugin generates TypeScript typings from Content Types. Interfaces and fields are optionally annotated with JSDoc comments.

Source lives in the contentstack/cli-plugins monorepo at packages/contentstack-cli-tsgen.

How to install this plugin

Requires Contentstack CLI 2.x:

$ csdx plugins:install contentstack-cli-tsgen

Migration

  • Monorepo / v2 CLI: See TSGEN-MIGRATION.md and package MIGRATION.md for 5.0.0.
  • Older plugin versions: Refer to MIGRATION.md for v3→v4 and earlier schema changes.

How to use this plugin

$ csdx tsgen

generate TypeScript typings from a Stack

USAGE
  $ csdx tsgen

FLAGS
  -a, --alias=<value>         (required) delivery token alias
      --output=<value>          (required) full path to output
      --[no-]doc              include documentation comments
      --prefix=<value>        interface prefix, e.g. "I"
      --branch=<value>        branch
      --include-system-fields include system fields in generated types
      --include-editable-tags include editable tags in generated types
      --include-referenced-entry
                              Includes the ReferencedEntry interface in generated types. Use this option to add a
                              generic interface for handling referenced entries when the exact content type is unknown
                              or when you need a flexible reference type
      --api-type=<option>     [default: rest] [Optional] Please enter an API type to generate the type definitions.
                              <options: rest|graphql>
      --namespace=<value>     [Optional]Please enter a namespace for the GraphQL API type to organize the generated
                              types.

EXAMPLES
  $ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts"
  $ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --prefix "I"
  $ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --no-doc
  $ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --include-referenced-entry
  $ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --api-type graphql
  $ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --api-type graphql --namespace "GraphQL" 

See code: src/commands/tsgen.ts

Supported Fields

  • Number
  • Text
  • IsoDate
  • Boolean
  • Single Select w/ String and Number Types
  • Multiple Select w/ String and Number Types
  • Modular Block
  • Global Field
  • Group
  • Link
  • File
  • References

Supported Field Options

  • Mandatory
  • Multiple
  • Multiple Max Limit
  • Description (used in JSDoc comment)

Example Output

/** This is a description. */
interface BuiltinExample {
  /** Title */
  title: string;
  /** URL */
  url: string;
  /** Group1 */
  group1?: {
    /** Group2 */
    group2?: {
      /** Group3 */
      group3?: {
        /** Number */
        number?: number;
      };
    };
  };
  /** SEO */
  seo?: Seo;
  /** Single line textbox */
  single_line?: string;
  /** Multi line textbox */
  multi_line?: string;
  /** Rich text editor */
  rich_text_editor?: string;
  /** Multiple Single Line Textbox */
  multiple_single_line_textbox?: string[];
  /** Markdown */
  markdown?: string;
  /** Multiple Choice */
  multiple_choice?: ("Choice 1" | "Choice 2" | "Choice 3")[];
  /** Single Choice */
  single_choice: "Choice 1" | "Choice 2" | "Choice 3";
  /** Modular Blocks */
  modular_blocks?:ModularBlocks[];
  /** Number */
  number?: number;
  /** Link */
  link?: Link;
  /** File */
  file?: File;
  /** Boolean */
  boolean?: boolean;
  /** Date */
  date?: string;
}

interface ModularBlocks {
  block_1: {
    /** Number */
    number?: number;
    /** Single line textbox */
    single_line?: string;
  };
  block_2: {
    /** Boolean */
    boolean?: boolean;
    /** Date */
    date?: string;
  };
  seo_gf: {
    /** Keywords */
    keywords?: string;
    /** Description */
    description?: string;
  };
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.