@allgemein/schema-api
Version:
Library for schema api
124 lines (122 loc) • 3.7 kB
TypeScript
import { METADATA_TYPE } from './Constants';
import { IClassRef } from '../api/IClassRef';
import { IEntityRef } from '../api/IEntityRef';
import { IPropertyRef } from '../api/IPropertyRef';
import { IBuildOptions } from '../api/IBuildOptions';
import { AbstractRef } from './AbstractRef';
/**
* Reflective reference to a class function
*
* There can exist multiple ClassRef depending of context for a single class function.
* The context is defined by the lookup registry.
* It can be also a placeholder, for a dummy or later loaded class.
*
* This is a default implementation for IClassRef
*
class can be in different namespaces
*/
export declare class ClassRef extends AbstractRef implements IClassRef {
static __inc: number;
private readonly idx;
/**
* Original reference to the class function or the given class name as string
*/
originalValue: string | Function;
private _cacheEntity;
private _isPlaceholder;
private _isAnonymous;
extends: IClassRef[];
constructor(klass: string | Function, namespace?: string);
isPlaceholder(): boolean;
isAnonymous(): boolean;
getClassRefFor(object: string | Function | IClassRef, type: METADATA_TYPE): IClassRef;
static getClassName(k: any): any;
updateClass(cls: Function): void;
get className(): string;
get storingName(): string;
set storingName(v: string);
/**
* Check if name is passed by options
*/
hasName(): boolean;
/**
* Return the namespace for/of this class
*/
getNamespace(): string;
/**
* TODO implement
*
* @param namespace
*/
switchNamespace(namespace: string): void;
isOf(instance: any): boolean;
get machineName(): string;
getClass(create?: boolean): Function;
static find(klass: string | Function, namespace?: string): ClassRef;
/**
* get all class refs for some class name
*
* @param klass
*/
static getAllByClassName(klass: any): IClassRef[];
/**
* filter function for classrefs
*
* @param klass
*/
static filter(fn: (c: IClassRef) => boolean): IClassRef[];
static checkIfFunctionCallback(klass: string | Function): string | Function;
/**
* check if class reference already exists for given string or Function, if not create a new one
*
* @param klass
* @param namespace
* @param resolve
*/
static get(klass: string | Function, namespace?: string, options?: boolean | {
resolve?: boolean;
checkNamespace?: boolean;
}): ClassRef;
/**
* Create a class ref.
*
* @param klass
* @param namespace
*/
static createRef(klass: Function | string, namespace?: string): ClassRef;
/**
* return global class reference
*
* @param klass
* @param resolve
*/
static getGlobal(klass: string | Function, resolve?: boolean): ClassRef;
getRegistry(): import("..").ILookupRegistry;
getEntityRef(): IEntityRef;
hasEntityRef(): boolean;
create<T>(addinfo?: boolean): T;
new<T>(addinfo?: boolean): T;
getPropertyRefs(): IPropertyRef[];
getPropertyRef(name: string): IPropertyRef;
id(): string;
build<T>(data: any, options?: IBuildOptions): T;
/**
* Return base inherited class for the underlying class
* ```
* class X exnteds Y { }
* ```
* Y would be returned.
*
*/
getExtend(): IClassRef;
/**
* Return all inherited classes for underlying class. Mostly added manually.
*
*/
getExtends(): IClassRef[];
/**
* Append extend class ref.
* @param ref
*/
addExtend(ref: IClassRef): IClassRef;
}