@huzapi/types-cms
TypeScript icon, indicating that this package has built-in type declarations

1.0.28 • Public • Published

Huz Api / @Types for CMS

Definition types for entity, enumeration and endpoints etc

  • TypeScript
  • Eslint
  • Prettier

Install

npm i @huzapi/types-cms

Sample Files

Sample TypeScript

import {brand, profile} from "@huzapi/types-cms";

export class SampleClass  {
    getBrand(id: brand.Id): brand.Doc {
    } 
    checkEnum(role: profile.role.Id): void {
    } 
}

const sample = new SampleClass();
const givenBrandId = 'bla bla';
/*
IDE checks "givenBrandId" is string, because brand.Id is string
*/
const brandDoc = sample.getBrand(givenBrandId);
/*
IDE auto-completes brandDoc properties as
        id: string;
        createdAt: Date;
        createdBy: string;
        updatedAt: Date;
        updatedBy: string;
        _revision: number;
        name: {[lang: string]: string}; also checks lang is valid lang by enum
        code: string;
        description: {[lang: string]: string}; also checks lang is valid lang by enum
        activated: boolean;
        weight: number;
        publishedAt: Date;
        metatag: {
            title: {[lang: string]: string}; also checks lang is valid lang by enum
            keywords: {[lang: string]: string}; also checks lang is valid lang by enum
            description: {[lang: string]: string}; also checks lang is valid lang by enum
        };
        logo: {id: string};
        subject: {id: string};
        topSlider: {id: string};
        forAllProjects: boolean;
        projects: Array<{id: string}>;
*/

const givenRole = 'bla bla';
/*
IDE checks "givenRole" is string and it is in Enum[owner,kid,adult]
*/
sample.checkEnum(givenRole);

Sample JavaScript

const {brand, profile} = require("@huzapi/types-cms");

/**
 * @param {brand.Id} id
 * @returns {brand.Doc}
*/
const getBrand = (id) => {} 

/**
 * @param {profile.role.Id} role
 * @returns {void}
*/
const checkEnum = (role) => {} 

const givenBrandId = 'bla bla';
/*
IDE checks "givenBrandId" is string, because brand.Id is string
*/
const brandDoc = getBrand(givenBrandId);
/*
IDE auto-completes brandDoc properties likes type-script sample
*/

const givenRole = 'bla bla';
/*
IDE checks "givenRole" is string and it is in Enum[owner,kid,adult]
*/
checkEnum(givenRole);

Readme

Keywords

none

Package Sidebar

Install

npm i @huzapi/types-cms

Weekly Downloads

3

Version

1.0.28

License

ISC

Unpacked Size

205 kB

Total Files

350

Last publish

Collaborators

  • npm