import { Database } from '../db/Database'; import { Entity, KeyType, ModelDictionary, PrimaryKeyType, Value } from '../glossary'; export declare enum RelationKind { OneOf = "ONE_OF", ManyOf = "MANY_OF" } export interface RelationAttributes { nullable: boolean; unique: boolean; } export interface RelationSource { modelName: string; primaryKey: PrimaryKeyType; propertyPath: string[]; } export interface RelationDefinition> { to: ModelName; kind: Kind; attributes?: Attributes; } export declare type LazyRelation = (modelName: ModelName, propertyPath: string, dictionary: Dictionary, db: Database) => Relation; export declare type OneOf = Relation; export declare type ManyOf = Relation; export declare type RelationsList = Array<{ propertyPath: string[]; relation: Relation; }>; export declare class Relation, ReferenceType = Kind extends RelationKind.OneOf ? Value : Value[]> { kind: Kind; attributes: RelationAttributes; source: RelationSource; target: { modelName: string; primaryKey: PrimaryKeyType; }; private dictionary; private db; constructor(definition: RelationDefinition); /** * Applies the relation to the given entity. * Creates a connection between the relation's target and source. * Does not define the proxy property getter. */ apply(entity: Entity, propertyPath: string[], dictionary: Dictionary, db: Database): void; /** * Updates the relation references (values) to resolve the relation with. */ resolveWith(entity: Entity, refs: ReferenceType | null): void; private setValueResolver; }