import { Observability } from "../mobx_internal"; import { Model } from "../model"; import { BaseField } from "./base"; /** * Reference Types: * - `local` - When serializing the referencer, the referencee is serialized and embedded * - `reference` - When serializing the referencer, the referencee is serialized as a reference * - `virtual` - The field is not serialized at all. Ideal for inverses * * `local` Cycles must be avoided - If instance `A` has a `local` reference to `B`, `B` must not of a `local` reference to `A` * A tree structure where model instances are `local` referenced exactly once is ideal. */ export type ReferenceType = 'reference' | 'local' | 'virtual'; export interface BaseRelationOptions { type?: ReferenceType; resolve_reference?: (ref: any, self: T) => R; model?: typeof Model | (() => typeof Model); inverseOf?: keyof R; autoLink?: 'always' | 'never' | 'model' | ((inst: any) => boolean); observable?: Observability; } export interface BaseRelationMeta { inverseInstance: any; observerDisposer?: () => void; attached?: boolean; } export declare abstract class BaseRelationField, S extends Model> extends BaseField { constructor(ctx: ClassMemberDecoratorContext, options?: O); get referenceType(): ReferenceType; get inversePropKey(): string; get referenceResolver(): (ref: any, self: S) => any; get refModelType(): typeof Model; abstract offerObjectFromInverse(inst: S, object: any, inverseField: BaseRelationField): any; abstract removeObjectFromInverse(inst: S, object: any, inverseField: BaseRelationField): any; resolveReference(inst: S, ref: any, { raise }?: { raise?: boolean; }): any; protected shouldAutoAttach(inst: S): boolean; protected shouldAutoDetach(inst: S): boolean; protected detachFromInverse(inst: S, inverseInst: any): void; protected attachToInverse(inst: S, inverseInst: any): void; abstract attach(inst: S): any; abstract detach(inst: S): any; possiblyAttach(inst: S): void; }