import { type Context } from './contexts'; import { RacerBackend } from '../Backend'; import { type Connection } from './connection'; import { type ModelData } from './collections'; export type UUID = string; export type DefualtType = unknown; declare module './Model' { interface DebugOptions { /** Enables browser side logging of ShareDB operations */ debugMutations?: boolean; /** Disable submitting of local operations to remote backend */ disableSubmit?: boolean; remoteMutations?: boolean; } interface ModelOptions { /** see {@link DebugOptions} */ debug?: DebugOptions; /** Ensure read-only access of model data */ fetchOnly?: boolean; /** * Delay in milliseconds before actually unloading data after `unload` called * * Default to 0 on server, and 1000ms for browser. Runtime value can be inspected * on {@link RootModel.unloadDelay} */ unloadDelay?: number; bundleTimeout?: number; } type ErrorCallback = (err?: Error) => void; } type ModelInitFunction = (instance: RootModel, options: ModelOptions) => void; /** * Base class for Racer models * * @typeParam T - Type of data the Model contains */ export declare class Model { static INITS: ModelInitFunction[]; ChildModel: typeof ChildModel; debug: DebugOptions; root: RootModel; data: T; _at: string; _context: Context; /** * Optional "event context" tag applied to event listeners registered using this model, allowing * `removeContextListeners` to later remove all listeners with this model's "event context". * * Every Derby component instance uses its component id ("_1", "_b", etc.) as the event context * for its component model, so that the component can deregister all its listeners when the * component is destroyed. * * Note that this has nothing to do with `model._context`. */ _eventContext: string | null; _events: []; _maxListeners: number; _pass: any; _preventCompose: boolean; _silent: boolean; /** * Creates a new Racer UUID * * @returns a new Racer UUID. * */ id(): UUID; _child(): any; } /** * RootModel is the model that holds all data and maintains connection info */ export declare class RootModel extends Model { backend: RacerBackend; connection: Connection; constructor(options?: ModelOptions); } /** * Model for some subset of the data * * @typeParam T - type of data the ChildModel contains. */ export declare class ChildModel extends Model { constructor(model: Model); } export {};