typ3s
Version:
Allow define type on json
98 lines (97 loc) • 2.87 kB
TypeScript
import { Primitive } from '../domain/primitive';
export interface PropertyType {
name: string;
type?: Type;
}
export interface ObjType {
properties: PropertyType[];
}
export interface ListType {
items: Type;
}
export interface FuncType {
params: ParamType[];
ret: Type;
}
export interface ParamType {
name: string;
type?: Type;
}
export interface TypeOptions {
info?: boolean;
describe?: boolean;
enums?: boolean;
}
export declare class Type {
primitive: Primitive;
obj?: ObjType | undefined;
list?: ListType | undefined;
func?: FuncType | undefined;
nullable?: boolean;
undefinable?: boolean;
async?: boolean;
unique?: boolean;
repeated?: number;
repeatRate?: number;
indefinite?: number;
nullables?: number;
count?: number;
distinctCount?: number;
onParentDistinctRepeated?: number;
onParentDistinctRepeatedRate?: number;
onParentDistinctUnique?: boolean;
mean?: any;
sum?: any;
max?: any;
min?: any;
maxLen?: number;
minLen?: number;
std?: number;
percent10?: any;
percent25?: any;
percent50?: any;
percent75?: any;
percent90?: any;
enums?: {
value: any;
count: number;
}[];
constructor(primitive: Primitive, obj?: ObjType | undefined, list?: ListType | undefined, func?: FuncType | undefined);
static get any(): Type;
static get string(): Type;
static get integer(): Type;
static get decimal(): Type;
static get number(): Type;
static get boolean(): Type;
static get date(): Type;
static get dateTime(): Type;
static get time(): Type;
static get void(): Type;
static Obj(properties?: PropertyType[]): Type;
static List(items: Type): Type;
static Function(params: ParamType[], ret: Type): Type;
static isPrimitive(type: Type | string): boolean;
static to(primitive: Primitive | string): Type;
static get(value: any): Type;
static isList(type: Type | string): boolean;
static isObj(type: Type | string): boolean;
static isFunc(type: Type | string): boolean;
static stringify(type?: Type): string;
static parse(stringified: string): Type;
static serialize(type?: Type, indentation?: number): string | undefined;
static deserialize(type?: string): Type | undefined;
static validate(value: any, type: Type | string): [boolean, string];
static type(value: any, options?: TypeOptions): Type;
private static modifier;
private static _validate;
private static _type;
private static info;
private static propertyInfo;
private static onObjectProperties;
private static completeInfoProperties;
private static describe;
private static percentiles;
private static enums;
private static iterations;
static key(value: any, type: Type): string;
}