@mas-soft/mas-core-server
Version:
main application
72 lines (71 loc) • 2.31 kB
TypeScript
import { AnyObject, DataObject, Options } from './common-types';
import { RelationMetadata } from './relations';
import { TypeResolver } from './type-resolver';
import { Type } from './types';
export declare type PropertyType = string | Function | Object | Type<any> | TypeResolver<Model>;
export interface PropertyDefinition {
type: PropertyType;
id?: boolean | number;
json?: PropertyForm;
store?: PropertyForm;
itemType?: PropertyType;
[attribute: string]: any;
}
export interface PropertyForm {
in?: boolean;
out?: boolean;
name?: string;
}
export declare type RelationDefinitionMap = {
[relationName: string]: RelationMetadata;
};
export interface ModelDefinitionSyntax {
name: string;
properties?: {
[name: string]: PropertyDefinition | PropertyType;
};
settings?: {
[name: string]: any;
};
relations?: RelationDefinitionMap;
[attribute: string]: any;
}
export declare class ModelDefinition {
readonly name: string;
properties: {
[name: string]: PropertyDefinition;
};
settings: {
[name: string]: any;
};
relations: RelationDefinitionMap;
[attribute: string]: any;
constructor(nameOrDef: string | ModelDefinitionSyntax);
addProperty(name: string, definitionOrType: PropertyDefinition | PropertyType): this;
addSetting(name: string, value: any): this;
addRelation(definition: RelationMetadata): this;
idProperties(): string[];
}
export declare abstract class Model {
static readonly modelName: string;
static definition: ModelDefinition;
toJSON(): Object;
toObject(options?: Options): Object;
constructor(data?: DataObject<Model>);
}
export interface Persistable {
}
export declare abstract class ValueObject extends Model implements Persistable {
}
export declare abstract class Entity extends Model implements Persistable {
static getIdOf(entityOrData: AnyObject): any;
getId(): any;
getIdObject(): Object;
static buildWhereForId(id: any): any;
}
export declare class Event {
source: any;
type: string;
}
export declare type EntityData = DataObject<Entity>;
export declare type EntityResolver<T extends Entity> = TypeResolver<T, typeof Entity>;