Typings generator for your Cockpit CMS content model.
npm install cockpit-type

> Typings generator for your Cockpit CMS content model.
cockpit-type uses plopjs therefore all prompts and CLI usage are extended from it.
yarn add -D cockpit-type or npm install --save-dev cockpit-type
cockpit-type or cockpit-type without options, and the interactive CLI will prompt the 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'
Types are generated using type keyword:
``typescript
export type CPImageBaseType = {
path: string
}
export type CPGalleryBaseType = CPImageBaseType & {
meta: {
title: string
asset: string
}
}
`
- Types are generated using case class.
- Requires JSON library circe as a dependency.
`scala
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)
``