@huz-com/types
v1.0.318
Published
Global Huz Types
Downloads
1,450
Maintainers
Readme
Huz.Com > Types > Global
Global Huz Types
Standards
- Language:
TS
- Eslint:
Yes
- Static Code Analysis:
Yes
IntelliJ Code Inspections - DDD - Document Driven:
Yes
- Standards Complied: Huz Standards
Commands
npm run clear
// clears "dist" foldernpm run lint
// runs eslint for static code analysisnpm run build
// builds JS files at "dist" foldernpm publish
ornpm run publix
// publishes "dist" folder to npm
Install
npm i @huz-com/types
Namespace Convention
- Dynamic entities finish with
Entity
ie: brandEntity, gameEntity, ... - Enumerations finish with
Enum
ie: languageEnum, genderEnum, ... - Client entities finish with
Action
ie: playAction, favoriteAction, ... - Classical entities finish with
Model
ie: timezoneModel, notificationSendModel, ... - Transactional entities finish with
Log
ie: actionLog, errorLog, ... - Transient entities finish with
Component
ie: i18nComponent, optionComponent, ...
Sample
import {brandEntity, profileRoleEnum} from "@huz-com/types";
export class SampleClass {
getBrand(id: brandEntity.Id): brandEntity.Doc {
}
checkEnum(role: profileRoleEnum.Id): void {
}
}
const sample = new SampleClass();
const givenBrandId = 'bla bla';
/*
IDE checks "givenBrandId" is string, because brandEntity.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 {brandEntity, profileRoleEnum} = require("@huz-com/types");
/**
* @param {brandEntity.Id} id
* @returns {brandEntity.Doc}
*/
const getBrand = (id) => {}
/**
* @param {profileRoleEnum.Id} role
* @returns {void}
*/
const checkEnum = (role) => {}
const givenBrandId = 'bla bla';
/*
IDE checks "givenBrandId" is string, because brandEntity.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);