1.0.2 • Published 6 months ago

@tealina/doc-types v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

API document type designed for transformation tools

Pre-knowledge

There's a package call tealina, it offer some CLI commands make create API service more easier, one of the command is tealina gdoc, it generate a doc.json file.

Install

Should be add as dependencies, not devDependencies, because the DocKind is exported as const object

pnpm add @tealina/doc-types

yarn add @tealina/doc-types

bun add @tealina/doc-types

npm i @tealina/doc-types

Demo

//doc.json
{
  "apis": {
    "get": { // http method
      "health": { // endpoind
        "response": {// DocNode
          "kind": 4, // DocKind
          "id": 268 
        },
      }
    }
  },
  "entityRefs": {
    "268": {
      "name": "{ status: string; }",
      "props": [
        {
          "kind": 0,// DocKind
          "type": "string",
          "name": "status"
        }
      ]
    }
  }
}

Every DocNode has a kind property, it's easy to code with switch case.

import { DocNode, DocKind, EntityRef } from '@tealina/doc-types'

function tranform2span(docNode:DocNode){
  switch(docNode.kind){
    case DocKind.Primitive:
      return <span>{docNode.type}</span>
    ...
  }
}

Convention

The name of your package should have a clear name with tealina-doc prefix.

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago

0.0.1

7 months ago