import { AnyDataModel } from '../dataModel/BaseDataModel'; import { ModelClass } from '../modelShared/BaseModelShared'; import { ModelInfo } from '../modelShared/modelInfo'; import { AnyModel } from './BaseModel'; /** * Checks if an object is a model instance. * * @param model * @returns */ export declare function isModel(model: unknown): model is AnyModel; /** * Gets the model type name from a model snapshot. * * @param snapshot - The snapshot to get the model type from. * @returns The model type name if the snapshot is a model snapshot, `undefined` otherwise. */ export declare function getSnapshotModelType(snapshot: unknown): string | undefined; /** * Gets the model ID from a model snapshot. * * This function extracts the model's unique identifier from a snapshot * by looking up the model class using `$modelType` and then reading * the value of the ID property (as declared with `idProp`). * * @param snapshot - A model snapshot (must have `$modelType`). * @returns The model ID if the snapshot has an ID property, or `undefined` if not. */ export declare function getSnapshotModelId(snapshot: unknown): string | undefined; /** * Ensures the given model classes are referenced at runtime and already present in the model registry. * * This helper is mostly useful when your app primarily uses snapshots and your bundler/compiler * may elide otherwise-unused model imports. * * @param modelClasses Model and/or data model classes to keep as runtime references. */ export declare function registerModels(...modelClasses: Array | ModelClass>): void; /** * Model type and ID information. */ export interface ModelTypeAndId { /** * The model type name (from `$modelType`). */ modelType: string; /** * The model ID value, or `undefined` if the model has no ID property. */ modelId: string | undefined; /** * The name of the property that holds the model ID (as declared with `idProp`), * or `undefined` if the model has no ID property. */ modelIdPropertyName: string | undefined; /** * The model info (contains the model class and name). */ modelInfo: ModelInfo; } /** * Gets the model type and ID from a model snapshot. * * The result includes: * - `modelType`: The model type name (from `$modelType`) * - `modelId`: The model ID value (or `undefined` if no ID property) * - `modelIdPropertyName`: The name of the property that holds the model ID (or `undefined` if no ID property) * - `modelInfo`: The model info (contains the model class and name) * * @param snapshot - A model snapshot (must have `$modelType`). * @returns The model type and ID info, or `undefined` if not a valid model snapshot. */ export declare function getSnapshotModelTypeAndId(snapshot: unknown): ModelTypeAndId | undefined; /** * Gets the model type and ID from a Model or DataModel instance. * * The result includes: * - `modelType`: The model type name (from `$modelType`) * - `modelId`: The model ID value (or `undefined` if no ID property) * - `modelIdPropertyName`: The name of the property that holds the model ID (or `undefined` if no ID property) * - `modelInfo`: The model info (contains the model class and name) * * @param model - A Model or DataModel instance. * @returns The model type and ID info, or `undefined` if not a valid model. */ export declare function getModelTypeAndId(model: AnyModel | AnyDataModel): ModelTypeAndId | undefined; /** * Gets the model type and ID from a Model instance, DataModel instance, or model snapshot. * * The result includes: * - `modelType`: The model type name (from `$modelType`) * - `modelId`: The model ID value (or `undefined` if no ID property) * - `modelIdPropertyName`: The name of the property that holds the model ID (or `undefined` if no ID property) * - `modelInfo`: The model info (contains the model class and name) * * @param value - A Model instance, DataModel instance, or model snapshot. * @returns The model type and ID info, or `undefined` if not a valid model or snapshot. */ export declare function getModelOrSnapshotTypeAndId(value: unknown): ModelTypeAndId | undefined;