@allgemein/schema-api
Version:
Library for schema api
66 lines (65 loc) • 3.4 kB
TypeScript
/**
* Handler for metadata
*/
import { CLASS_TYPE, METADATA_TYPE } from './../Constants';
import { IEntityOptions } from './../options/IEntityOptions';
import { IPropertyOptions } from './../options/IPropertyOptions';
import { ISchemaOptions } from './../options/ISchemaOptions';
import { IObjectOptions } from './../options/IObjectOptions';
import { EventEmitter } from 'events';
import { IAbstractOptions } from '../options/IAbstractOptions';
import { IAttributeOptions } from '../options/IAttributeOptions';
/**
* Registry for metadata of classes and there properties
*/
export declare class MetadataRegistry extends EventEmitter {
private static INC;
private static $self;
private readonly metadata;
private readonly cached;
private schemas;
private targets;
constructor();
static $(): MetadataRegistry;
static reset(): void;
/**
* Add typed element to the local registry
*
* @param context
* @param options
*/
add(context: METADATA_TYPE | string, options: IEntityOptions | IPropertyOptions | ISchemaOptions | IObjectOptions | IAttributeOptions, trigger?: boolean): IEntityOptions | IPropertyOptions | ISchemaOptions | IObjectOptions | IAttributeOptions;
/**
* Add cached content mostly for ClassRef instances throw AbstractRef
*
* @param context
* @param options
*/
addCached(context: METADATA_TYPE | string, options: IEntityOptions | IPropertyOptions | ISchemaOptions | IObjectOptions | IAttributeOptions): IEntityOptions | IPropertyOptions | ISchemaOptions | IObjectOptions | IAttributeOptions;
notify(eventName: string, context: string, options: any): void;
remove(context: METADATA_TYPE | string, c: (x: any) => boolean, trigger?: boolean): void;
getByContext<T extends IAbstractOptions>(context: METADATA_TYPE): T[];
getTargets(): any[];
/**
* Return the metadata/options for some entry (entity/property/classref/...). A copy of the original will be delivered.
*
* @param context
* @param target
* @param attributes
* @param propertyName
*/
getByContextAndTarget<T extends IAbstractOptions>(context: METADATA_TYPE | string, target: CLASS_TYPE | string, attributes?: 'merge' | 'assign' | 'defaults', propertyName?: string): T[];
mergeAttributes(context: METADATA_TYPE | string, target: CLASS_TYPE | string, data: IPropertyOptions | IEntityOptions | IObjectOptions | ISchemaOptions, mode?: 'merge' | 'assign' | 'defaults'): void;
getAttributesForTarget<T extends IAttributeOptions>(context: METADATA_TYPE | string, target: CLASS_TYPE | string): T[];
getAttributesForTargetProperty<T extends IAttributeOptions>(context: METADATA_TYPE, target: CLASS_TYPE, propertyName: string): T[];
getAttributesForTargetProperties<T extends IAttributeOptions>(context: METADATA_TYPE, target: CLASS_TYPE | string): T[];
getByTarget(target: CLASS_TYPE): IAbstractOptions[];
private createSearchFunction;
find(context: METADATA_TYPE | string, find: CLASS_TYPE): IAbstractOptions;
findCached(context: METADATA_TYPE | string, find: CLASS_TYPE): IAbstractOptions;
filter(context: METADATA_TYPE | string, find: CLASS_TYPE): IAbstractOptions[];
getMetadata(): IAbstractOptions[];
getCached(): IAbstractOptions[];
getSchemas(): any[];
getMetadatasForSchema(schema: string): IAbstractOptions[];
}