@allgemein/schema-api
Version:
Library for schema api
100 lines (99 loc) • 3.32 kB
TypeScript
import { METADATA_TYPE } from './../Constants';
import { ILookupRegistry } from '../../api/ILookupRegistry';
import { IEntityRef } from '../../api/IEntityRef';
import { IClassRef } from '../../api/IClassRef';
import { IPropertyRef } from '../../api/IPropertyRef';
import { LookupRegistry } from '../LookupRegistry';
import { Semaphore } from '@allgemein/base';
import { ISchemaRef } from '../../api/ISchemaRef';
import { IRegistryOptions } from './IRegistryOptions';
/**
* Registry for metadata of classes and there properties
*/
export declare abstract class AbstractRegistry implements ILookupRegistry {
protected readonly namespace: string;
private _lock;
readonly options: IRegistryOptions;
constructor(namespace: string, options?: IRegistryOptions);
get lock(): Semaphore;
ready(timeout?: number): Promise<boolean>;
getOptions(): IRegistryOptions;
/**
* Return all registered schema references
*
* @param ref
* @return ISchemaRef[]
*/
getSchemaRefs<T extends ISchemaRef>(filter?: (x: ISchemaRef) => boolean): (T | ISchemaRef)[];
/**
* Return schema references for an given entity or class reference
*
* @param ref
* @return ISchemaRef[]
*/
getSchemaRefsFor<T extends ISchemaRef>(ref: string): T | ISchemaRef;
/**
* TODO
*
* @param filter
*/
getEntityRefs<T extends IEntityRef>(filter?: (x: IEntityRef) => boolean): (T | IEntityRef)[];
/**
* Can get get entity ref for function.
*
* @param fn
*/
getEntityRefFor<T extends IEntityRef>(fn: string | object | Function, skipNsCheck?: boolean): (T | IEntityRef);
/**
* Returns the used instance of lookup registry handler
*/
getLookupRegistry(namespace?: string): LookupRegistry;
/**
* Method for returning class ref
*
* @param object
* @param type
*/
getClassRefFor(object: string | Function | IClassRef, type: METADATA_TYPE): IClassRef;
/**
* Returns property by name for a given class or entity ref
*
* @param filter
*/
getPropertyRef<T extends IPropertyRef>(ref: IClassRef | IEntityRef, name: string): (T | IPropertyRef);
/**
* Returns all properties for given class or entity ref
*
* @param ref
*/
getPropertyRefs<T extends IPropertyRef>(ref: IClassRef | IEntityRef): (T | IPropertyRef)[];
getPropertyRefsFor<T extends IPropertyRef>(fn: string | object | Function): (T | IPropertyRef)[];
list<X>(type: METADATA_TYPE, filter?: (x: any) => boolean): X[];
listEntities(filter?: (x: IEntityRef) => boolean): IEntityRef[];
listProperties(filter?: (x: IPropertyRef) => boolean): IPropertyRef[];
create<T>(context: string, options: any): T;
/**
* TODO
*/
add<T>(context: string, entry: T, ns?: string): T;
/**
* TODO
*/
filter<T>(context: string, search: (x: any) => boolean, ns?: string): T[];
/**
* TODO
*/
find<T>(context: string, search: any, ns?: string): T;
/**
* TODO
*/
remove<T>(context: string, search: any, ns?: string): T[];
/**
* reset current registry
*/
reset(): void;
/**
* Remove namespace from LookupRegistry and also remove semaphore lock if exists
*/
clear(): void;
}