2.3.2 • Published 2 months ago

contentstack-cli-tsgen v2.3.2

Weekly downloads
2
License
MIT
Repository
github
Last release
2 months ago

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;
}
2.3.2

2 months ago

2.3.1

3 months ago

2.3.0

3 months ago

2.2.2

4 months ago

2.2.1

5 months ago

2.2.0

6 months ago

2.1.6

8 months ago

2.1.5

9 months ago

2.1.8

7 months ago

2.1.7

7 months ago

2.1.4

10 months ago

2.1.3

10 months ago

2.1.2

11 months ago

2.1.1

12 months ago

1.0.14

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago