import { Constructor } from '@noeldemartin/utils'; import { Nullable } from '@noeldemartin/utils'; import { Pretty } from '@noeldemartin/utils'; export declare type ArrayFieldDefinition = FieldDefinitionBase & { type: typeof FieldType.Array; items: Omit, 'required'>; }; export declare type Attributes = Record; export declare type AttributeValue = any; export declare type BasicFieldDefinition = FieldDefinitionBase & { type: Exclude; }; export declare class BelongsToManyRelation = ModelConstructor> extends MultiModelRelation { isEmpty(): boolean | null; load(): Promise; setForeignAttributes(related: Related): void; clearForeignAttributes(related: Related): void; } export declare class BelongsToOneRelation = ModelConstructor> extends SingleModelRelation { isEmpty(): boolean | null; load(): Promise; setForeignAttributes(related: Related): void; clearForeignAttributes(related: Related): void; } export declare type BootedArrayFieldDefinition = BootedFieldDefinitionBase & { type: typeof FieldType.Array; items: Omit, 'required'>; }; export declare type BootedBasicFieldDefinition = BootedFieldDefinitionBase & { type: Exclude; }; export declare type BootedFieldDefinition = BootedBasicFieldDefinition | BootedArrayFieldDefinition | BootedObjectFieldDefinition; export declare type BootedFieldDefinitionBase = T & { required: boolean; alias?: string; cast?: (value: unknown) => unknown; set?: (this: Model, value: unknown) => void; get?: (this: Model) => unknown; serialize?: (value: any) => unknown; deserialize?: (value: any) => unknown; }; export declare type BootedFieldsDefinition = Record>; export declare type BootedObjectFieldDefinition = BootedFieldDefinitionBase & { type: typeof FieldType.Object; fields: BootedFieldsDefinition; }; export declare function bootModels(models: Record): void; export declare function bootModelsFromViteGlob(glob: Record>, ignoreSuffixes?: string[]): void; export declare function bootModelsFromWebpackContext(context: __WebpackModuleApi.RequireContext, ignoreSuffixes?: string[]): void; export declare function closeEngineConnections(): Promise; export declare interface ClosesConnections { closeConnections(): Promise; } export declare function defineModelSchema(definition: Schema): Constructor> & ModelConstructor; export declare function defineModelSchema(baseModel: ModelConstructor, definition: Schema): Constructor> & ModelConstructor; export declare class DocumentAlreadyExists extends SoukaiError { readonly id: string; constructor(id: string); } export declare class DocumentNotFound extends SoukaiError { readonly id: string; readonly collection?: string; constructor(id: string, collection?: string); } export declare function emitModelEvent(modelClass: ModelConstructor, ...args: ModelEmitArgs): Promise; export declare function emitModelEvent(model: Model, ...args: ModelEmitArgs): Promise; export declare interface Engine { create(collection: string, document: EngineDocument, id?: string): Promise; readOne(collection: string, id: string): Promise; readMany(collection: string, filters?: EngineFilters): Promise; update(collection: string, id: string, updates: EngineUpdates): Promise; delete(collection: string, id: string): Promise; } export declare type EngineAttributeFilter = EngineAttributeValue | { $eq: EngineAttributeValue; } | { $or: EngineAttributeFilter[]; } | { $in: EngineAttributeLeafValue[]; } | { $contains: EngineAttributeFilter | EngineAttributeFilter[]; }; export declare type EngineAttributeLeafValue = string | number | boolean | null | Date; export declare type EngineAttributeUpdate = EngineAttributeValue | EngineAttributeUpdateMap | EngineAttributeUpdateOperation | { $apply: EngineAttributeUpdateOperation[]; }; export declare interface EngineAttributeUpdateMap extends Record { } export declare type EngineAttributeUpdateOperation = { $update: EngineAttributeUpdate; } | { $updateItems: EngineUpdateItemsOperatorData | EngineUpdateItemsOperatorData[]; } | { $unset: string | string[] | true; } | { $push: EngineAttributeValue; }; export declare type EngineAttributeValue = EngineAttributeLeafValue | EngineAttributeValueMap | EngineAttributeValueArray | EngineAttributeValueArrayMap; export declare interface EngineAttributeValueArray extends Array { } export declare interface EngineAttributeValueArrayMap extends Array> { } export declare interface EngineAttributeValueMap extends Record { } export declare function engineClosesConnections(engine: Engine): engine is Engine & ClosesConnections; export declare type EngineDocument = Record; export declare type EngineDocumentsCollection = Record; export declare type EngineFilters = EngineRootFilter & Record; export declare class EngineHelper { private rootFilters; private rootUpdates; private attributeFilters; private attributeUpdates; constructor(); filterDocuments(documents: EngineDocumentsCollection, filters?: EngineFilters): EngineDocumentsCollection; updateAttributes(attributes: Record, updates: EngineUpdates): void; obtainDocumentId(id?: string): string; private filterDocument; private filterValue; private documentsIn; private documentOverwrite; private attributeEq; private attributeContains; private attributeOr; private attributeIn; private attributeUpdate; private attributeUpdateItems; private attributePush; private attributeUnset; private attributeApply; private attributeOverwrite; private isOperation; private runOperation; private requireArrayProperty; } export declare interface EngineRootFilter { $in?: (string | number | Record)[]; } export declare interface EngineUpdateItemsOperatorData { $where?: EngineFilters; $update?: EngineAttributeUpdate; $override?: EngineAttributeValueMap; $unset?: true; } export declare type EngineUpdates = Record | { $unset: string | string[]; } | { $overwrite: EngineAttributeValue; }; export declare function ensureInverseRelationsBooted(): void; export declare function extractFinalEngine(engine: Engine): Engine; export declare type FieldDefinition = BasicFieldDefinition | ArrayFieldDefinition | ObjectFieldDefinition | FieldTypeValue | Record; export declare type FieldDefinitionBase = T & { required?: boolean; alias?: string; cast?: (value: unknown) => unknown; set?: (this: Model, value: unknown) => void; get?: (this: Model) => unknown; serialize?: (value: any) => unknown; deserialize?: (value: any) => unknown; }; export declare const FieldRequired: { Required: true; Optional: false; }; export declare type FieldsDefinition = Record>; export declare const FieldType: { Number: "number"; String: "string"; Boolean: "boolean"; Array: "array"; Object: "object"; Date: "date"; Key: "key"; Any: "any"; }; export declare type FieldTypeValue = (typeof FieldType)[keyof typeof FieldType]; export declare type GetArrayFields = { [K in keyof F]: F[K] extends { type: typeof FieldType.Array; } ? K : never; }[keyof F]; export declare function getBootedModels(): Map; export declare type GetDefinedFields = { [K in keyof F]: F[K] extends string | { type: string; } ? K : F[K] extends Record ? K : never; }[keyof F]; export declare function getEngine(): Engine | undefined; export declare type GetFieldsDefinition = D extends { fields: infer F; } ? F extends undefined ? {} : F : {}; export declare type GetFieldType = T extends FieldTypeValue ? T : T extends BasicFieldDefinition ? T['type'] : T extends ArrayFieldDefinition ? T['items'][] : T extends ObjectFieldDefinition ? T['fields'] : T; export declare function getFinalEngine(): Engine | undefined; export declare function getModelsFromViteGlob(glob: Record>, ignoreSuffixes?: string[]): Record; export declare function getModelsFromWebpackContext(context: __WebpackModuleApi.RequireContext, ignoreSuffixes?: string[]): Record; export declare type GetRequiredFields = { [K in keyof F]: F[K] extends { required: true; } ? K : never; }[keyof F]; export declare type GetTimestampsDefinition = D extends { timestamps: infer T; } ? T extends undefined ? true : T : true; export declare class HasManyRelation = ModelConstructor> extends MultiModelRelation { load(): Promise; setForeignAttributes(related: Related): void; clearForeignAttributes(related: Related): void; } export declare class HasOneRelation = ModelConstructor> extends SingleModelRelation { load(): Promise; setForeignAttributes(related: Related): void; clearForeignAttributes(related: Related): void; } export declare class IndexedDBEngine implements Engine, ClosesConnections { private database; private helper; private lock; private _metadata?; private _metadataConnection?; private _documentsConnection?; constructor(database?: null | string); getCollections(): Promise; dropCollections(collections: string[]): Promise; purgeDatabase(): Promise; closeConnections(): Promise; create(collection: string, document: EngineDocument, id?: string): Promise; readOne(collection: string, id: string): Promise; readMany(collection: string, filters?: EngineFilters): Promise; update(collection: string, id: string, updates: EngineUpdates): Promise; delete(collection: string, id: string): Promise; private __getCollections; private collectionExists; private documentExists; private getDocument; private createDocument; private updateDocument; private deleteDocument; private withMetadataTransaction; private withDocumentsTransaction; private getDocumentsConnection; private getMetadata; private initializeMetadata; private retryingOnTransactionInactive; private createCollection; private throwDatabaseBlockedError; } /** * Engine that stores data in memory. Data can be accessed with the [[database]] property to * get an [[InMemoryEngineDatabase]]. */ export declare class InMemoryEngine implements Engine { private helper; private _database; constructor(); get database(): InMemoryEngineDatabase; create(collectionName: string, document: EngineDocument, id?: string): Promise; readOne(collectionName: string, id: string): Promise; readMany(collection: string, filters?: EngineFilters): Promise; update(collectionName: string, id: string, updates: EngineUpdates): Promise; delete(collectionName: string, id: string): Promise; private hasCollection; private collection; } export declare interface InMemoryEngineCollection { [id: string]: EngineDocument; } export declare interface InMemoryEngineDatabase { [collection: string]: InMemoryEngineCollection; } export declare class InvalidModelAttributes extends SoukaiError { readonly modelName: string; readonly attributes: Attributes; constructor(modelName: string, attributes: Attributes, options?: SoukaiErrorOptions); } export declare class InvalidModelDefinition extends SoukaiError { readonly modelName: string; constructor(modelName: string, message: string); } /** * @deprecated Use ProxyEngine class instead. */ export declare interface IProxyEngine { getProxySubject(): Engine; } export declare function isArrayFieldDefinition(fieldDefinition: BootedFieldDefinition): fieldDefinition is BootedArrayFieldDefinition; export declare function isArrayFieldDefinition(fieldDefinition: Omit): fieldDefinition is Omit; export declare function isObjectFieldDefinition(fieldDefinition: BootedFieldDefinition): fieldDefinition is BootedObjectFieldDefinition; export declare function isObjectFieldDefinition(fieldDefinition: Omit): fieldDefinition is Omit; export declare function isProxyEngine(engine: Engine): engine is Engine & IProxyEngine; export declare type Key = string | number | Record; export declare class LocalStorageEngine implements Engine { private prefix; private helper; constructor(prefix?: string); clear(): void; create(collection: string, document: EngineDocument, id?: string): Promise; readOne(collection: string, id: string): Promise; readMany(collection: string, filters?: EngineFilters): Promise; update(collection: string, id: string, updates: EngineUpdates): Promise; delete(collection: string, id: string): Promise; private readItem; private writeItem; private serializeAttributes; private serializeAttributeValue; private deserializeAttributes; private deserializeAttributeValue; } export declare class LogEngine extends ProxyEngine { constructor(subject: SubjectEngine); } export declare type MagicAttributeProperties = { -readonly [K in keyof T]: T[K] extends { deserialize: (value: any) => infer TValue; } ? TValue : MagicAttributeValue, TKey>; }; export declare type MagicAttributes = Pretty & NestedMagicAttributes, TKey> & MagicTimestampAttributes>>; export declare type MagicAttributeValue = T extends FieldsDefinition ? NestedMagicAttributes : T extends FieldTypeValue ? ResolveFieldType : T extends Array ? R extends FieldTypeValue ? ResolveFieldType[] : never : never; export declare type MagicTimestampAttributes = T extends false ? {} : T extends (typeof TimestampField.CreatedAt)[] ? { createdAt: Date; } : T extends (typeof TimestampField.UpdatedAt)[] ? { updatedAt: Date; } : { createdAt: Date; updatedAt: Date; }; export declare class Model { static collection: string; static primaryKey: string; static timestamps: TimestampsDefinition; static fields: FieldsDefinition; static modelName: string; static classFields: string[]; static relations: string[]; static hooks: ModelHooks; static __attributeGetters: Map unknown>; static __attributeSetters: Map void>; private static instances; private static pureInstances; private static bootedModels; private static engines; private static ignoringTimestamps; private static fieldAliases; static boot(this: ModelConstructor, name?: string): void; static ensureBooted(this: ModelConstructor): void; static updateSchema(schema: SchemaDefinition | ModelConstructor): Promise; static create(this: ModelConstructor, attributes?: Attributes): Promise; static createFromEngineDocument(this: ModelConstructor, id: Key, document: EngineDocument): Promise; static createManyFromEngineDocuments(this: ModelConstructor, documents: Record): Promise; static findOrFail(this: ModelConstructor, id: Key): Promise; static find(this: ModelConstructor, id: Key): Promise; static all(this: ModelConstructor, filters?: EngineFilters): Promise; static first(this: ModelConstructor, filters?: EngineFilters): Promise; static newInstance(this: ModelConstructor, ...params: ConstructorParameters>): T; static on(this: ModelConstructor, event: TEvent, listener: ModelListener): () => void; static instance(this: ModelConstructor): T; static hasAutomaticTimestamp(timestamp: TimestampFieldValue): boolean; static hasAutomaticTimestamps(): boolean; static getEngine(): Engine | undefined; static getFinalEngine(): Engine | undefined; static requireEngine(): T; static requireFinalEngine(): T; static setEngine(engine?: Engine): void; static withEngine(this: T, engine: Engine): T; static withEngine(engine: Engine, operation: () => T): T; static withEngine(engine: Engine, operation: () => Promise): Promise; static withCollection(collection: string | undefined, operation: () => Result | Promise): Promise; static withoutTimestamps(operation: () => Promise): Promise; static exclusive(operation: () => Promise | T): Promise; protected static pureInstance(this: ModelConstructor): T; protected static bootModelName(name?: string): string; protected static bootCollection(): string; protected static bootTimestamps(timestamps: TimestampFieldValue[] | boolean | undefined, fieldDefinitions: BootedFieldsDefinition): TimestampFieldValue[]; protected static bootFields(fields: FieldsDefinition | undefined, primaryKey: string, timestamps: TimestampFieldValue[], fieldDefinitions: BootedFieldsDefinition): { fields: BootedFieldsDefinition; fieldAliases: Record; }; protected static bootClassDefinitions(): { classFields: string[]; relations: string[]; attributeGetters: Map unknown>; attributeSetters: Map void>; }; protected static bootHooks(hooks?: ModelHooks): ModelHooks; protected static performSchemaUpdate(schema: SchemaDefinition | ModelConstructor): Promise; id: string; protected _exists: boolean; protected _wasRecentlyCreated: boolean; protected _proxy: this; protected _attributes: Attributes; protected _originalAttributes: Attributes; protected _dirtyAttributes: Attributes; protected _malformedDocumentAttributes: Record; protected _relations: { [relation: string]: Relation; }; private _engine?; private _recentlyDeletedPrimaryKey?; constructor(attributes?: Attributes, _?: boolean); static(property: 'fields'): BootedFieldsDefinition; static(property: 'timestamps'): TimestampFieldValue[]; static(): T; static(property: K): T[K]; newInstance(this: T, ...params: ConstructorParameters>): T; fresh(): Promise; update(attributes?: Attributes): Promise; hasRelation(relation: string): boolean; getRelation(relation: string): T | null; requireRelation(relation: string): T; getEngine(): Engine | undefined; getFinalEngine(): Engine | undefined; requireEngine(): T; requireFinalEngine(): T; getDefaultCollection(): string; loadRelation(relation: string): Promise; loadRelationIfUnloaded(relation: string): Promise; unloadRelation(relation: string): void; getRelationModel(relation: string): T | null; getRelationModels(relation: string): T[] | null; setRelationModel(relation: string, model: Model | null): void; setRelationModels(relation: string, models: Model[] | null): void; isRelationLoaded(relation: string): boolean; hasAttribute(field: string): boolean; setAttribute(field: string, value: unknown): void; setAttributeValue(field: string, value: unknown): void; hasAttributeSetter(field: string): boolean; callAttributeSetter(field: string, value: unknown): void; getOriginalAttribute(field: string): T; getDeletedPrimaryKey(): Key | null; setOriginalAttribute(field: string, value: unknown): void; setAttributes(attributes: Attributes): void; getMalformedDocumentAttributes(): Record; setMalformedDocumentAttributes(malformedAttributes: Record): void; setEngine(engine?: Engine): void; withEngine(engine: Engine): this; withEngine(engine: Engine, operation: (model: this) => T): T; withEngine(engine: Engine, operation: (model: this) => Promise): Promise; withoutTimestamps(operation: () => Promise): Promise; getAttribute(field: string, includeUndefined?: boolean): T; getAttributeValue(field: string, includeUndefined?: boolean): T; getAttributes(includeUndefined?: boolean): Attributes; hasAttributeGetter(field: string): boolean; callAttributeGetter(field: string): unknown; unsetAttribute(field: string): void; hasIncompleteAttributes(): boolean; is(another: this): boolean; isDirty(field?: string): boolean; cleanDirty(): void; reset(): void; getPrimaryKey(): Key | null; getSerializedPrimaryKey(): string | null; delete(): Promise; save(): Promise; fixMalformedAttributes(): void; /** * Set the `updatedAt` attribute to the current time. */ touch(): void; setExists(exists: boolean): void; exists(): boolean; wasRecentlyCreated(): boolean; wasRecentlyDeleted(): boolean; clone(options?: ModelCloneOptions): this; clone(options?: ModelCloneOptions): T; protected initialize(attributes: Attributes, exists: boolean): void; protected initializeProxy(): void; protected initializeAttributes(attributes: Attributes, exists: boolean): void; protected initializeRelations(): void; protected createFromEngineDocument(id: Key, document: EngineDocument): Promise; protected createManyFromEngineDocuments(documents: Record): Promise; protected beforeSave(): Promise; protected performSave(): Promise; protected afterSave(): Promise; protected performDelete(): Promise; protected performMalformedAttributeFixes(): void; protected emit(...args: ModelEmitArgs): Promise; protected syncDirty(): Promise; protected getCascadeModels(): Promise; protected deleteModelsFromEngine(models: Model[]): Promise; /** * @deprecated use `reset` instead. */ protected resetEngineData(): void; /** * Creates a relation when this model is referenced by one instance of another model. * * @param relatedClass - Related model class. * @param foreignKeyField - Name of the foreign key field in the related model. * @param localKeyField - Name of the local key field in the local model. Defaults to * the primary key name defined in the local model class. */ protected hasOne(relatedClass: T, foreignKeyField?: string, localKeyField?: string): HasOneRelation; /** * Creates a relation when this model references one instance of another model. * * @param relatedClass - Related model class. * @param foreignKeyField - Name of the foreign key field in the local model. * @param localKeyField - Name of the local key field in the related model. Defaults to * the primary key name defined in the related model class. */ protected belongsToOne(relatedClass: T, foreignKeyField?: string, localKeyField?: string): BelongsToOneRelation; /** * Creates a relation when this model is referenced by multiple instances of another model. * * @param relatedClass - Related model class. * @param foreignKeyField - Name of the foreign key field in the related model. * @param localKeyField - Name of the local key field in the local model. Defaults to * the primary key name defined in the local model class. */ protected hasMany(relatedClass: T, foreignKeyField?: string, localKeyField?: string): HasManyRelation; /** * Creates a relation when this model references multiple instances of another model. * * @param relatedClass - Related model class. * @param foreignKeyField - Name of the foreign key field in the local model. * @param localKeyField - Name of the local key field in the related model. Defaults to * the primary key name defined in the related model class. */ protected belongsToMany(relatedClass: T, foreignKeyField?: string, localKeyField?: string): BelongsToManyRelation; protected loadEmptyRelations(): Promise; protected attributeValueChanged(originalValue: unknown, newValue: unknown): boolean; protected markAttributeDirty(field: string, originalValue: unknown, newValue: unknown): boolean; protected castAttributes(attributes: Attributes, definitions: BootedFieldsDefinition, malformedAttributes?: Record, fieldPrefix?: string): Attributes; protected castAttribute(value: unknown, { field, definition, malformedAttributes }?: ModelCastAttributeOptions): unknown; protected toEngineDocument(): EngineDocument; protected getDirtyEngineDocumentUpdates(): EngineUpdates; protected populateCascadeModels(cascadeModels: Set): Promise; protected parseEngineDocumentAttributes(id: Key, document: EngineDocument): Promise; protected serializeKey(key: Key): string; protected parseKey(key: string): Key; } export declare type ModelCastAttributeOptions = { field?: string; definition?: BootedFieldDefinition; malformedAttributes?: Record; }; export declare interface ModelClassEvents { 'schema-updated': SchemaDefinition; } export declare type ModelCloneOptions = Partial<{ clean: boolean; clones: WeakMap; constructors: WeakMap | [typeof Model, typeof Model][]; }>; export declare type ModelConstructor = Constructor & typeof Model; export declare type ModelEmitArgs = T extends keyof ModelEvents ? ModelEvents[T] extends void ? [event: T] : [event: T, payload: ModelEvents[T]] : T extends keyof ModelClassEvents ? ModelClassEvents[T] extends void ? [event: T] : [event: T, payload: ModelClassEvents[T]] : never; /** * @deprecated Use ModelEvents keys instead. */ export declare const ModelEvent: { Created: "created"; Deleted: "deleted"; Updated: "updated"; }; export declare interface ModelEvents { created: void; deleted: void; updated: void; modified: string; 'relation-loaded': Relation; } /** * @deprecated Use ModelEvents keys instead. */ export declare type ModelEventValue = (typeof ModelEvent)[keyof typeof ModelEvent]; export declare interface ModelHooks { beforeSave?: (this: Model) => Promise | void; afterSave?: (this: Model) => Promise | void; afterInitialize?: (this: Model) => void; } export declare class ModelKey { static from(value: unknown): ModelKey; private value; constructor(rawValue: unknown); equals(other: ModelKey): boolean; toString(): string; } export declare type ModelListener = (...args: ModelListenerArgs) => unknown; export declare type ModelListenerArgs = TEvent extends keyof ModelEvents ? ModelEvents[TEvent] extends void ? [model: TModel] : [model: TModel, payload: ModelEvents[TEvent]] : TEvent extends keyof ModelClassEvents ? ModelClassEvents[TEvent] extends void ? [] : [payload: ModelClassEvents[TEvent]] : never; export declare interface ModelsRegistry { } export declare abstract class MultiModelRelation = ModelConstructor> extends Relation { constructor(parent: Parent, relatedClass: RelatedClass, foreignKeyName?: string, localKeyName?: string); get related(): Related[] | undefined; set related(related: Related[] | undefined); attach(model?: Related): Related; attach(attributes: Attributes): Related; create(attributes?: Attributes): Promise; addRelated(related: Related): void; removeRelated(related: Related): void; abstract load(): Promise; isRelated(model: Related): boolean; protected onRelatedUpdated(oldValue: Nullable, newValue: Nullable): void; protected assertLoaded(method: string): this is { related: Related[]; }; } export declare type NestedMagicAttributes = MagicAttributeProperties>, TKey> & Partial>, TKey>>; export declare type ObjectFieldDefinition = FieldDefinitionBase & { type: typeof FieldType.Object; fields: FieldsDefinition; }; export declare class ProxyEngine implements Engine, IProxyEngine { readonly subject: SubjectEngine; private overrides; constructor(subject: SubjectEngine, overrides?: Partial); getProxySubject(): Engine; create(collection: string, document: EngineDocument, id?: string): Promise; readOne(collection: string, id: string): Promise; readMany(collection: string, filters?: EngineFilters): Promise; update(collection: string, id: string, updates: EngineUpdates): Promise; delete(collection: string, id: string): Promise; } export declare function registerModelListener(modelClass: ModelConstructor, event: TEvent, listener: ModelListener): () => void; export declare abstract class Relation = ModelConstructor> { static inverseHasRelationClasses: Constructor[]; static inverseBelongsToRelationClasses: Constructor[]; name: string; parent: Parent; relatedClass: RelatedClass; foreignKeyName: string; localKeyName: string; enabled: boolean; deleteStrategy: RelationDeleteStrategy; protected _related?: Related[] | Related | null; constructor(parent: Parent, relatedClass: RelatedClass, foreignKeyName: string, localKeyName?: string); get loaded(): boolean; get related(): Nullable; set related(related: Nullable); static(): RelationConstructor; enable(): void; disable(): void; abstract load(): Promise; abstract setForeignAttributes(related: Related): void; abstract clearForeignAttributes(related: Related): void; abstract addRelated(related: Related): void; abstract removeRelated(related: Related): void; abstract isRelated(model: Related): boolean; /** * @deprecated This method has been renamed to `load`. */ resolve(): Promise; isEmpty(): boolean | null; getModels(): Promise; getLoadedModels(): Related[]; unload(): void; onDelete(strategy: RelationDeleteStrategy): this; clone(options?: RelationCloneOptions): this; initializeInverseRelations(model: Related): void; clearInverseRelations(model: Related): void; isInverseOf(other: Relation): boolean; protected onRelatedUpdated(oldValue: Nullable, newValue: Nullable): void; } export declare type RelationCloneOptions = Partial<{ clones: WeakMap; constructors: WeakMap; }>; export declare type RelationConstructor = Constructor & typeof Relation; export declare type RelationDeleteStrategy = null | 'cascade'; export declare function requireBootedModel(name: T): ModelsRegistry[T]; export declare function requireBootedModel = ModelConstructor>(name: string): T; export declare function requireEngine(): T; export declare function requireFinalEngine(): T; export declare function resetModelListeners(): void; export declare type ResolveFieldType = T extends typeof FieldType.Number ? number : T extends typeof FieldType.String ? string : T extends typeof FieldType.Boolean ? boolean : T extends typeof FieldType.Date ? Date : T extends typeof FieldType.Key ? TKey : T extends typeof FieldType.Any ? any : never; export declare type SchemaDefinition = Partial<{ primaryKey: string; timestamps: TimestampsDefinition; fields: FieldsDefinition; hooks?: ModelHooks; }>; export declare function setEngine(engine: Engine | null): void; export declare abstract class SingleModelRelation = ModelConstructor> extends Relation { constructor(parent: Parent, relatedClass: RelatedClass, foreignKeyName?: string, localKeyName?: string); get related(): Related | undefined | null; set related(related: Related | undefined | null); attach(model?: Related): Related; attach(attributes: Attributes): Related; addRelated(related: Related): void; removeRelated(related: Related): void; isRelated(related: Related): boolean; abstract load(): Promise; protected onRelatedUpdated(oldValue: Nullable, newValue: Nullable): void; } export declare class SoukaiError extends Error { constructor(message?: string, options?: SoukaiErrorOptions); } export declare interface SoukaiErrorOptions { cause?: unknown; } export declare const TimestampField: { CreatedAt: "createdAt"; UpdatedAt: "updatedAt"; }; export declare type TimestampFieldValue = (typeof TimestampField)[keyof typeof TimestampField]; export declare type TimestampsDefinition = TimestampFieldValue[] | boolean; export declare function withEngine(engine: Engine, operation: () => T): T; export declare function withEngine(engine: Engine, operation: () => Promise): Promise; export { }