Giter VIP home page Giter VIP logo

contentstack-cli-tsgen's Introduction

Node.js CI 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.

How to install this plugin

$ csdx plugins:install contentstack-cli-tsgen

How to use this plugin

$ csdx tsgen

generate TypeScript typings from a Stack

USAGE
  $ csdx tsgen

OPTIONS
  -a, --token-alias=token-alias  (required) delivery token alias
  -d, --[no-]doc                 include documentation comments
  -o, --output=output            (required) full path to output
  -p, --prefix=prefix            interface prefix, e.g. "I"

EXAMPLES
  $ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts"
  $ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" -p "I"
  $ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --no-doc

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?: (
    | {
        block_1: {
          /** Number */ 
          number?: number;
          /** Single line textbox */
          single_line?: string;
        };
        block_2: undefined;
        seo_gf: undefined;
      }
    | {
        block_2: {
          /** Boolean */ 
          boolean?: boolean;
          /** Date */
          date?: string;
        };
        block_1: undefined;
        seo_gf: undefined;
      }
    | {
        seo_gf: {
          /** Keywords */ 
          keywords?: string;
          /** Description */
          description?: string;
        };
        block_1: undefined;
        block_2: undefined;
      }
  )[];
  /** Number */
  number?: number;
  /** Link */
  link?: Link;
  /** File */
  file?: File;
  /** Boolean */
  boolean?: boolean;
  /** Date */
  date?: string;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.