UNPKG

@pebula/metap

Version:
73 lines (72 loc) 3.13 kB
import { Constructor } from '@pebula/utils'; import { PropMetadataArgs, ModelMetadataArgs, ExcludeMetadataArgs, RelationMetadataArgs, RelationMetadata, PropMetadata, ExcludeMetadata, TargetStore, TargetMetadata, ModelMetadata, TypeMetadata } from '@pebula/metap/internal'; export declare class TestTargetStore extends TargetStore { static getTargetMeta(target: any): TestTargetMetadata | undefined; static getModel<T extends ModelMetadata = ModelMetadata>(target: Constructor<any>): T; static clearAll(): void; static clear(target: any): void; } export declare class TestTargetMetadata extends TargetMetadata { static getFactory<T, Z>(type: Z & Constructor<T>): (target: any, key: any) => T | undefined; static removeFactory<T, Z>(type: Z & Constructor<T>): (target: any, key: any) => boolean; static getRelation: (target: any, key: any) => RelationMetadata; static getProp: (target: any, key: any) => PropMetadata; static getExclude: (target: any, key: any) => ExcludeMetadata; static removeRelation: (target: any, key: any) => boolean; static removeProp: (target: any, key: any) => boolean; static removeExclude: (target: any, key: any) => boolean; static addRelation(target: Constructor<any>, key: string, meta?: RelationMetadataArgs): void; static addProp(target: Constructor<any>, key: string, meta?: PropMetadataArgs): void; static setExcludeClass(target: Constructor<any>): void; static addExclude(target: Constructor<any>, key: string, meta?: ExcludeMetadataArgs): void; } export declare class TargetMetaModifier<T, Z> { target: Z & Constructor<T>; constructor(target: Z & Constructor<T>); build(): void; clear(): this; /** * Registers a new model * * > Clears the model from the registry before trying to register. * @param metaArgs * @param type * @returns */ setModel<T extends ModelMetadataArgs>(metaArgs?: T): this; /** * Set/Update/Remove the identity field. * If key is empty will remove identity. * @param key * @returns */ setIdentity(key?: keyof T): this; /** * Set exclusion/inclusion at the class level * @param exclude * @returns */ setExclude(exclude: boolean): this; getProp<P extends keyof T>(key: P): PropMetadata; getType<P extends keyof T>(key: P): TypeMetadata; getRelation<P extends keyof T>(key: P): RelationMetadata; getExclude<P extends keyof T>(key: P): ExcludeMetadata; relation(key: keyof T, meta?: RelationMetadataArgs | false): this; /** * Add or remove prop, to remove set meta to false * @param key * @param meta * @param type * @returns */ prop(key: keyof T, meta?: PropMetadataArgs | false | Function, type?: Function): this; props(...args: Array<keyof T>): this; /** * Add or remove exclude, to remove set meta to false * @param key * @param meta * @returns */ exclude(key: keyof T, meta?: ExcludeMetadataArgs | false): this; static create<T, Z>(target: Z & Constructor<T>): TargetMetaModifier<T, Z>; }