1.0.28 • Published 4 years ago

@huzapi/types-cms v1.0.28

Weekly downloads
69
License
ISC
Repository
gitlab
Last release
4 years ago

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);
1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.19

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago