import { ContainableTypes, } from './ContainableTypes'; import { ContainingTypes, } from './ContainingTypes'; import { ContainmentTypes, } from './ContainmentTypes'; import { IFindBaseArgs, FindContainmentArgs, } from '../querying/FindModelArgs'; import { IModel, } from '../models/IModel'; import { IRelation, } from './IRelation'; import { ISerializedContainmentRelation, } from './ISerializedContainmentRelation'; import { IWorld, } from '../world/IWorld'; import { ModelType, } from '../models/ModelType'; export interface IContainmentRelation< Type extends ContainmentTypes, Being extends ContainmentTypes, > extends IRelation { readonly parent: Type extends ModelType.Location ? IWorld : IModel; readonly find: ( args: string | IFindBaseArgs & FindContainmentArgs, ) => IModel | null; readonly findAll: ( args: '*' | IFindBaseArgs & FindContainmentArgs, ) => readonly IModel[]; readonly findAllGenerator: ( args: '*' | IFindBaseArgs & FindContainmentArgs, ) => IterableIterator>; readonly parents: ( args: string | IFindBaseArgs & FindContainmentArgs, ) => readonly ( IModel | IWorld )[]; readonly serialize: ( self: IContainmentRelation, spaces?: number, ) => string; readonly serializeToObject: ( self: IContainmentRelation, ) => ISerializedContainmentRelation; /* The following properties are not usable for models which are themselves * contained but which may not contain other models. */ readonly children: Type extends ContainingTypes ? readonly IModel[] : null; readonly addChild: Type extends ContainingTypes ? (model: IModel) => void : null; readonly descendants: Type extends ContainingTypes ? () => readonly IModel[] : null; readonly removeChild: Type extends ContainingTypes ? (model: IModel) => void : null; }