@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
117 lines (116 loc) • 4.19 kB
TypeScript
import { DecoratorTypes, Store, Type } from "@tsed/core";
import type { JsonClassStore } from "./JsonClassStore.js";
import type { JsonMethodStore } from "./JsonMethodStore.js";
import type { JsonParameterStore } from "./JsonParameterStore.js";
import type { JsonPropertyStore } from "./JsonPropertyStore.js";
import type { JsonSchema } from "./JsonSchema.js";
/**
* @ignore
*/
export declare const JsonEntitiesContainer: Map<DecoratorTypes, Type<JsonEntityStore>>;
export interface JsonEntityStoreOptions {
decoratorType: DecoratorTypes;
target: Type<any>;
propertyKey?: string | symbol;
index?: number;
descriptor?: any;
type?: Type<any>;
collectionType?: Type<any>;
beforeMiddlewares?: Function[];
middlewares?: Function[];
afterMiddlewares?: Function[];
[key: string]: any;
}
export declare abstract class JsonEntityStore implements JsonEntityStoreOptions {
/**
* Original property key decorated by the decorator
*/
readonly propertyKey: string | symbol;
/**
* Alias of the property
*/
readonly propertyName: string;
/**
* Parameter index
*/
readonly index: number;
/**
* Method's descriptor
*/
readonly descriptor: PropertyDescriptor;
/**
* Decorator type used to declare the JsonSchemaStore.
*/
readonly decoratorType: DecoratorTypes;
token: Type<any>;
readonly store: Store;
readonly isStore = true;
readonly parent: JsonEntityStore;
readonly target: Type<any>;
[key: string]: any;
constructor(options: JsonEntityStoreOptions);
/**
* Type of the collection (Array, Map, Set, etc...)
*/
private _collectionType;
get collectionType(): Type<any> | undefined;
set collectionType(value: Type<any>);
/**
*
*/
protected _type: Type<any>;
get type(): Type<any> | any;
/**
* Get original type without transformation
* @param value
*/
set type(value: Type<any> | any);
/**
* Ref to JsonSchema
*/
protected _schema: JsonSchema;
/**
* Return the JsonSchema
*/
get schema(): JsonSchema;
/**
* Return the class name of the entity.
* @returns {string}
*/
get targetName(): string;
get isCollection(): boolean;
get isArray(): boolean;
get discriminatorAncestor(): JsonEntityStore | undefined;
get isPrimitive(): boolean;
get isDate(): boolean;
get isObject(): boolean;
get isClass(): boolean;
/**
* Return the itemSchema computed type. if the type is a function used for recursive model, the function will be called to
* get the right type.
*/
get computedType(): Type<any>;
get itemSchema(): JsonSchema;
get parentSchema(): JsonSchema;
get isDiscriminatorChild(): boolean;
get path(): string;
set path(path: string);
static from<T extends JsonClassStore = JsonClassStore>(target: Type<any>): T;
static from<T extends JsonPropertyStore = JsonPropertyStore>(target: Type<any> | any, propertyKey: string | symbol): T;
static from<T extends JsonParameterStore = JsonParameterStore>(target: Type<any> | any, propertyKey: string | symbol, index: number): T;
static from<T extends JsonMethodStore = JsonMethodStore>(target: Type<any> | any, propertyKey: string | symbol, descriptor: PropertyDescriptor): T;
static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T;
static fromMethod<T extends JsonMethodStore = JsonMethodStore>(target: any, propertyKey: string | symbol): T;
static get(target: Type<any>, propertyKey: string | symbol, descriptor?: any): JsonEntityStore;
isGetterOnly(): boolean | undefined;
get<T = any>(key: string, defaultValue?: any): T;
set(key: string, value?: any): Store;
toString(): string;
getBestType(): any;
is(input: DecoratorTypes.CLASS): this is JsonClassStore;
is(input: DecoratorTypes.PROP): this is JsonPropertyStore;
is(input: DecoratorTypes.METHOD): this is JsonMethodStore;
is(input: DecoratorTypes.PARAM): this is JsonParameterStore;
protected abstract build(): void;
protected buildType(type: any): void;
}