cockpit-type
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

cockpit-type

GitHub release Publish

Typings generator for your Cockpit CMS content model.

Usage

cockpit-type uses plopjs therefore all prompts and CLI usage are extended from it.

Add it to your project

yarn add -D cockpit-type or npm install --save-dev cockpit-type

Use it as script (see CLI Options)

cockpit-type <options> or cockpit-type without options, and the interactive CLI will prompt the options.

CLI options

Option Type Description
language string Programming language
path string Destination file
prefix string Prefix for the types
filter string Filter option ex: 'group=My Groups' allowed filters: 'collection', 'singleton' or 'group'

example: cockpit-type typescript path/to/file.ts MyPrefix 'group=My Group'

TypeScript

Types are generated using type keyword:

export type CPImageBaseType = {
    path: string
}

export type CPGalleryBaseType = CPImageBaseType & {
    meta: {
        title: string
        asset: string
    }
}

Scala

  • Types are generated using case class.
  • Requires JSON library circe as a dependency.
import io.circe.Json
import io.circe.generic.JsonCodec

@JsonCodec
case class CPImageBaseType(path: String)

@JsonCodec
case class CPMetaBaseType(title: String, asset: String)

@JsonCodec
case class CPGalleryBaseType(meta: CPMetaBaseType, path: String)

Package Sidebar

Install

npm i cockpit-type

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

38.6 kB

Total Files

40

Last publish

Collaborators

  • marcodaniels