export type ValidationErrorObjectType = { type: string; message: string; }; export type LifecycleCallbackType = ((model: T) => void | Promise) | string; export type ModelConstructor = { new (changes?: Record): T; }; export type RestrictInstanceRelationship = import("./instance-relationships/base.js").default & { query: () => ModelClassQuery; }; export type TenantDatabaseProviderType = import("../../configuration-types.js").TenantDatabaseProviderType; export type RecordMetadataValue = boolean | null | string | undefined | Promise | string[] | import("../drivers/base-column.js").default[] | import("../drivers/base-table.js").default | Record | Record | Record; /** * Defines this typedef. * @typedef {{type: string, message: string}} ValidationErrorObjectType */ /** * LifecycleCallbackType type. * @template [T=VelociousDatabaseRecord] * @typedef {((model: T) => void | Promise) | string} LifecycleCallbackType */ /** * Model class constructor type used for static `this` typing. * @template T * @typedef {{new (changes?: Record): T}} ModelConstructor */ /** * RestrictInstanceRelationship type. * @typedef {import("./instance-relationships/base.js").default & {query: () => ModelClassQuery}} RestrictInstanceRelationship */ /** @typedef {import("../../configuration-types.js").TenantDatabaseProviderType} TenantDatabaseProviderType */ /** * Schema metadata cached for one record class and physical database generation. * @typedef {boolean | null | string | undefined | Promise | string[] | import("../drivers/base-column.js").default[] | import("../drivers/base-table.js").default | Record | Record | Record} RecordMetadataValue */ import { AdvisoryLockBusyError, AdvisoryLockHoldTimeoutError, AdvisoryLockTimeoutError } from "../advisory-lock-runner.js"; import Configuration from "../../configuration.js"; import RecordAttachmentHandle from "./attachments/handle.js"; import ModelClassQuery from "../query/model-class-query.js"; import TenantModelScope from "../../tenants/tenant-model-scope.js"; export type TranslationBase = VelociousDatabaseRecord & { locale: () => string; }; export type AttachmentDriverConstructor = import("../../configuration-types.js").AttachmentDriverConstructor; export type AttachmentSyncConfiguration = import("../../configuration-types.js").AttachmentSyncConfiguration; export type RecordAttachmentConfiguration = import("../../configuration-types.js").RecordAttachmentConfiguration; declare class ValidationError extends Error { _model: VelociousDatabaseRecord> | undefined; _validationErrors: Record | undefined; /** * Narrows the runtime value to the documented type. * @type {Record> | undefined} - Velocious metadata for frontend-model error reporting. */ velocious: Record> | undefined; /** * Runs get model. * @returns {VelociousDatabaseRecord} - The model. */ getModel(): VelociousDatabaseRecord; /** * Runs set model. * @param {VelociousDatabaseRecord} model - Model instance. * @returns {void} - No return value. */ setModel(model: VelociousDatabaseRecord): void; /** * Runs get validation errors. * @returns {Record} - The validation errors. */ getValidationErrors(): Record; /** * Runs set validation errors. * @param {Record} validationErrors - Validation errors to assign. */ setValidationErrors(validationErrors: Record): void; } declare class TenantDatabaseScopeError extends Error { modelName: string; /** * Runs constructor. * @param {string} message - Error message. * @param {{modelName: string}} args - Context for the failed tenant-scoped model. */ constructor(message: string, { modelName }: { modelName: string; }); } export type RelationshipScopeCallback = (query: import("../query/model-class-query.js").default) => (import("../query/model-class-query.js").default | void); export type RelationshipDataArgumentType = { /** * - Disable auto-batch-preload for this relationship by passing false. Default true. */ autoload?: boolean; /** * - Model class name for the related record. */ className?: string; /** * - Dependent action when parent is destroyed (e.g. "destroy"). */ dependent?: string; /** * - Model class for the related record. */ klass?: typeof VelociousDatabaseRecord; /** * - Optional scope callback for the relationship. */ scope?: RelationshipScopeCallback; /** * - Relationship type (e.g. "hasMany", "belongsTo"). */ type?: string; }; /** * Base database record. * @template {Record>} [WriteAttributes=Record>] */ declare class VelociousDatabaseRecord> = Record>> { static _configuration: Configuration | undefined; static _initialized: boolean | undefined; static _databaseType: string | undefined; static _table: import("../drivers/base-table.js").default | undefined; static _columns: import("../drivers/base-column.js").default[] | undefined; static _databaseIdentifier: string | undefined; static _tenantDatabaseIdentifierResolver: string | ((args: { modelClass: typeof VelociousDatabaseRecord; tenant: Record | null | undefined; }) => string | undefined) | undefined; static _primaryKey: string | string[] | null | undefined; static _tableName: string | undefined; static _translationClass: { new (changes?: Record): { /** * Attributes. * @type {Record>} */ _attributes: Record>; /** * Unmapped result aliases explicitly selected by the query that hydrated this record. * @type {Set} */ _selectedAttributeAliases: Set; /** * Changes. * @type {Record>} */ _changes: Record>; /** * Whether primary-key reads are pinned to the stored attributes. * @type {boolean} */ _readsPersistedPrimaryKey: boolean; /** * Changes captured before a create audit is written. * @type {import("./auditing.js").AuditChanges | undefined} */ _pendingCreateAuditChanges: import("./auditing.js").AuditChanges | undefined; /** * Changes captured before an update audit is written. * @type {import("./auditing.js").AuditChanges | undefined} */ _pendingUpdateAuditChanges: import("./auditing.js").AuditChanges | undefined; /** * Attribute names explicitly assigned in the current update call. * @type {Set | undefined} */ _assignedAttributeNames: Set | undefined; /** * Columns as hash. * @type {Record} */ _columnsAsHash: Record; /** * Connection. * @type {import("../drivers/base.js").default | undefined} */ __connection: import("../drivers/base.js").default | undefined; /** * Explicit operation owning this record's database work. * @type {import("../operation.js").default | undefined} */ _databaseOperation: import("../operation.js").default | undefined; /** * Instance relationships. * @type {Record} */ _instanceRelationships: Record; /** * Attachments. * @type {Record} */ _attachments: Record; /** * Load cohort. * @type {Array | undefined} - Shared reference to sibling records loaded in the same batch. Used by auto-preload. */ _loadCohort: Array | undefined; /** * Table name. * @type {string | undefined} */ __tableName: string | undefined; /** * Validation errors. * @type {Record} */ _validationErrors: Record; /** * Runs get relationship by name. * @param {string} relationshipName - Relationship name. * @returns {import("./instance-relationships/base.js").default} - The relationship by name. */ getRelationshipByName(relationshipName: string): import("./instance-relationships/base.js").default; /** * Preloads relationship(s) onto this already-loaded record. Accepts either a * query built via `Model.preload(...).select(...)` or a raw preload spec * (string / array / nested object). A relationship that is already preloaded * with all the required columns present is left untouched unless `force` is * set. Preloading onto the relationship cache lets later accessors reuse the * loaded data instead of issuing identical queries. * @param {import("../query/model-class-query.js").default | import("../query/index.js").NestedPreloadRecord | string | Array} queryOrSpec - Preload source. * @param {{force?: boolean}} [options] - Options. * @returns {Promise} - Resolves when preloading completes. */ preload(queryOrSpec: import("../query/model-class-query.js").default | import("../query/index.js").NestedPreloadRecord | string | Array, options?: { force?: boolean; }): Promise; /** * Runs load relationship. * @param {string} relationshipName - Relationship name. * @returns {Promise>} - Loaded relationship value. */ loadRelationship(relationshipName: string): Promise>; /** * Runs relationship or load. * @param {string} relationshipName - Relationship name. * @param {{preloadTranslations?: boolean}} [options] - Load options. * @returns {Promise>} - Loaded relationship value. */ relationshipOrLoad(relationshipName: string, options?: { preloadTranslations?: boolean; }): Promise>; /** * Preloads translations on a loaded relationship target when explicitly requested. * @param {ReturnType} loaded - Loaded relationship value. * @returns {Promise>} - Relationship value after translation preload. */ _preloadLoadedRelationshipTranslations(loaded: ReturnType): Promise>; /** * Runs get attachment by name. * @param {string} attachmentName - Attachment name. * @returns {RecordAttachmentHandle} - Attachment handle. */ getAttachmentByName(attachmentName: string): RecordAttachmentHandle; /** * Runs get configuration. * @returns {import("../../configuration.js").default} - The configuration. */ _getConfiguration(): import("../../configuration.js").default; /** * Runs has attribute. * @param {ReturnType} value - Value to use. * @returns {boolean} - Whether attribute. */ _hasAttribute(value: ReturnType): boolean; /** * Runs get attribute. * @param {string} name - Name. * @returns {ReturnType} - The attribute. */ getAttribute(name: string): ReturnType; /** * Runs get model class. * @abstract * @returns {typeof VelociousDatabaseRecord} - The model class. */ getModelClass(): typeof VelociousDatabaseRecord; /** * Runs set attribute. * @param {string} name - Name. * @param {ReturnType} newValue - New value. * @returns {void} - No return value. */ setAttribute(name: string, newValue: ReturnType): void; /** * Runs set column attribute. * @param {string} name - Name. * @param {ReturnType} newValue - New value. */ _setColumnAttribute(name: string, newValue: ReturnType): void; /** * Clears loaded belongs-to caches when callers assign the foreign key directly. * @param {string} columnName - Changed database column name. * @param {ReturnType} normalizedValue - New normalized column value. * @returns {void} - No return value. */ _clearBelongsToRelationshipForChangedForeignKey(columnName: string, normalizedValue: ReturnType): void; /** * Runs belongs to relationships for foreign key. * @param {string} columnName - Changed database column name. * @returns {Array>} - Loaded relationship instances that use the changed foreign key. */ _belongsToRelationshipsForForeignKey(columnName: string): Array>; /** * Runs belongs to relationship uses foreign key. * @param {object} args - Relationship match arguments. * @param {string} args.columnName - Changed database column name. * @param {ReturnType} args.relationship - Relationship instance. * @returns {boolean} - Whether the relationship is a belongs-to using the changed foreign key. */ _belongsToRelationshipUsesForeignKey({ columnName, relationship }: { columnName: string; relationship: ReturnType; }): boolean; /** * Runs belongs to relationship matches foreign key value. * @param {object} args - Relationship cache arguments. * @param {ReturnType} args.normalizedValue - New normalized column value. * @param {ReturnType} args.relationship - Relationship instance. * @returns {boolean} - Whether the loaded related record still matches the changed foreign key. */ _belongsToRelationshipMatchesForeignKeyValue({ normalizedValue, relationship }: { normalizedValue: ReturnType; relationship: ReturnType; }): boolean; /** * Returns the foreign key value for a belongs-to relationship assignment. * @param {object} args - Relationship assignment arguments. * @param {VelociousDatabaseRecord | null | undefined} args.model - Assigned model. * @param {import("./instance-relationships/base.js").default} args.relationship - Belongs-to relationship instance. * @returns {string | number | null | undefined} - Foreign key value for the assignment. */ _belongsToForeignKeyValue({ model, relationship }: { model: VelociousDatabaseRecord | null | undefined; relationship: import("./instance-relationships/base.js").default; }): string | number | null | undefined; /** * Runs clear loaded belongs to relationship. * @param {ReturnType} relationship - Relationship instance. * @returns {void} - No return value. */ _clearLoadedBelongsToRelationship(relationship: ReturnType): void; /** * Runs normalize date value. * @param {ReturnType} value - Value to use. * @returns {ReturnType} - The date value. */ _normalizeDateValue(value: ReturnType): ReturnType; /** * Runs normalize sqlite boolean value. * @param {object} args - Options object. * @param {string | undefined} args.columnType - Column type. * @param {ReturnType} args.value - Value to normalize. * @returns {ReturnType} - Normalized value. */ _normalizeSqliteBooleanValue({ columnType, value }: { columnType: string | undefined; value: ReturnType; }): ReturnType; /** * Normalizes a boolean value before storing. A declared `"boolean"` attribute cast stores * booleans as 1/0 only for integer-backed columns (e.g. an MSSQL `bit`). Columns whose * underlying type is already a native boolean (e.g. Postgres `boolean`) keep `true`/`false` * so the driver can emit the proper boolean literal; otherwise the sqlite-only normalizer applies. * @param {object} args - Options object. * @param {string} args.attributeName - Attribute name being written. * @param {string | undefined} args.columnType - Column type. * @param {ReturnType} args.value - Value to normalize. * @returns {ReturnType} - Normalized value. */ _normalizeBooleanValueForWrite({ attributeName, columnType, value }: { attributeName: string; columnType: string | undefined; value: ReturnType; }): ReturnType; /** * Runs save. * @returns {Promise} - Resolves when complete. */ save(): Promise; _autoSaveBelongsToRelationships(): Promise<{ savedCount: number; }>; _autoSaveHasManyAndHasOneRelationshipsToSave(): import("./instance-relationships/base.js").default[]; /** * Resolves a relationship foreign-key column to this model's public attribute name. * @param {import("./instance-relationships/base.js").default} instanceRelationship - Relationship instance. * @returns {string} Attribute name accepted by setAttribute/assign. */ _relationshipForeignKeyAttribute(instanceRelationship: import("./instance-relationships/base.js").default): string; /** * Runs auto save has many and has one relationships. * @param {object} args - Options object. * @param {boolean} args.isNewRecord - Whether is new record. */ _autoSaveHasManyAndHasOneRelationships({ isNewRecord }: { isNewRecord: boolean; }): Promise; /** * Runs auto save attachments. * @returns {Promise} - Resolves when pending attachments have been saved. */ _autoSaveAttachments(): Promise; /** * Runs translations loaded. * @abstract * @returns {TranslationBase[]} - The translations loaded. */ translationsLoaded(): TranslationBase[]; /** * Runs get translated attribute. * @param {string} name - Name. * @param {string} locale - Locale. * @returns {string | undefined} - The translated attribute, if found. */ _getTranslatedAttribute(name: string, locale: string): string | undefined; /** * Runs get translated attribute with fallback. * @param {string} name - Name. * @param {string} locale - Locale. * @returns {string | undefined} - The translated attribute with fallback, if found. */ _getTranslatedAttributeWithFallback(name: string, locale: string): string | undefined; /** * Runs set translated attribute. * @param {string} name - Name. * @param {string} locale - Locale. * @param {ReturnType} newValue - New value. * @returns {void} - No return value. */ _setTranslatedAttribute(name: string, locale: string, newValue: ReturnType): void; _isNewRecord: boolean; /** * Binds future query, lifecycle, relationship, and persistence work to an operation. * @param {import("../operation.js").default} operation - Owning operation. * @returns {this} - Bound record. */ bindDatabaseOperation(operation: import("../operation.js").default): /*elided*/ any; /** * Captures and validates the physical database identity that owns this record. * @param {string} databaseIdentity - Opaque operation/connection identity. * @returns {this} This record. */ captureDatabaseIdentity(databaseIdentity: string): /*elided*/ any; _databaseIdentity: string | undefined; /** * Returns the captured physical database identity. * @returns {string | undefined} Captured physical database identity. */ databaseIdentity(): string | undefined; /** * Releases this record from a completed eager-helper operation while * preserving the legacy ambient follow-up behavior of `usingTenant` finders. * @param {import("../operation.js").default} operation - Releasing operation. * @returns {this} - Record. */ releaseDatabaseOperation(operation: import("../operation.js").default): /*elided*/ any; /** * Returns the explicit operation owning this record, if any. * @returns {import("../operation.js").default | undefined} - Owning operation. */ databaseOperation(): import("../operation.js").default | undefined; /** * Binds a related record to the same operation as this record. * @template {VelociousDatabaseRecord} Model * @param {Model} record - Related record. * @returns {Model} - Related record. */ bindRelatedRecord(record: Model): Model; /** * Builds a model query preserving this record's operation ownership. * @template {typeof VelociousDatabaseRecord} MC * @param {MC} ModelClass - Target model class. * @returns {ModelClassQuery} - Target query. */ queryForModel(ModelClass: MC): ModelClassQuery; /** * Initializes a relationship/preload target without dropping this record's * explicit operation connection. * @param {typeof VelociousDatabaseRecord} ModelClass - Target model class. * @param {import("../../configuration.js").default} configuration - Owning configuration. * @returns {Promise} - Resolves when initialized. */ ensureModelClassInitialized(ModelClass: typeof VelociousDatabaseRecord, configuration: import("../../configuration.js").default): Promise; /** * Runs load existing record. * @param {Record>} attributes - Column-keyed database values. * @param {Set} [selectedAttributeAliases] - Explicit result aliases selected by the loading query. * @returns {void} - No return value. */ loadExistingRecord(attributes: Record>, selectedAttributeAliases?: Set): void; /** * Assigns the given attributes to the record. * @param {Record>} attributesToAssign - Attributes to assign. * @returns {void} - No return value. */ assign(attributesToAssign: Record>): void; /** * Returns a the current attributes of the record (original attributes from database plus changes) * @returns {Record>} - The attributes. */ attributes(): Record>; /** * Returns column-name keyed data (original attributes from database plus changes) * @returns {Record>} - The raw attributes. */ rawAttributes(): Record>; /** * Runs connection. * @returns {import("../drivers/base.js").default} - The connection. */ _connection(): import("../drivers/base.js").default; /** * Resolves the identity of an already selected concrete connection. * @param {import("../drivers/base.js").default} connection - Concrete connection. * @returns {string} Physical database identity. */ _databaseIdentityForConnection(connection: import("../drivers/base.js").default): string; /** * Returns the connection that owns this record's database work. * @returns {import("../drivers/base.js").default} - Connection. */ connection(): import("../drivers/base.js").default; /** * Counts dependent records for a `dependent: "restrict"` relationship. * @param {RestrictInstanceRelationship} instanceRelationship - Relationship instance to count. * @returns {Promise} - Dependent row count. */ _dependentRestrictCount(instanceRelationship: RestrictInstanceRelationship): Promise; /** * Counts tenant-scoped dependent records across all provider-listed tenants. * @param {RestrictInstanceRelationship} instanceRelationship - Relationship instance to count. * @param {typeof VelociousDatabaseRecord} TargetModelClass - Related model class. * @returns {Promise} - Dependent row count. */ _dependentRestrictTenantCount(instanceRelationship: RestrictInstanceRelationship, TargetModelClass: typeof VelociousDatabaseRecord): Promise; /** * Counts tenant-scoped dependent records for one configured tenant provider. * @param {RestrictInstanceRelationship} instanceRelationship - Relationship instance to count. * @param {typeof VelociousDatabaseRecord} TargetModelClass - Related model class. * @param {string} identifier - Tenant database identifier. * @param {TenantDatabaseProviderType} provider - Tenant database provider. * @returns {Promise} - Dependent row count. */ _dependentRestrictProviderCount(instanceRelationship: RestrictInstanceRelationship, TargetModelClass: typeof VelociousDatabaseRecord, identifier: string, provider: TenantDatabaseProviderType): Promise; /** * Lists restrict-check tenants for one configured tenant provider. * @param {RestrictInstanceRelationship} instanceRelationship - Relationship instance to count. * @param {typeof VelociousDatabaseRecord} TargetModelClass - Related model class. * @param {string} identifier - Tenant database identifier. * @param {TenantDatabaseProviderType} provider - Tenant database provider. * @returns {Promise>>} - Listed tenant objects. */ _dependentRestrictProviderTenants(instanceRelationship: RestrictInstanceRelationship, TargetModelClass: typeof VelociousDatabaseRecord, identifier: string, provider: TenantDatabaseProviderType): Promise>>; /** * Runs a callback while primary-key reads resolve to the persisted identity. * @param {() => Promise} callback - Callback that requires the stored identity. * @returns {Promise} - Resolves when the callback completes. */ _withPersistedPrimaryKey(callback: () => Promise): Promise; /** * Destroys the record in the database and all of its dependent records. * @returns {Promise} - Resolves when complete. */ destroy(): Promise; /** * Runs the destroy lifecycle after the persisted identity has been restored. * @returns {Promise} - Resolves when complete. */ _destroyPersistedRecord(): Promise; /** * Emits a committed record-change event after the surrounding transaction * commits, so live queries re-run uniformly for local writes, pull applies, and * realtime applies (which all end as local saves/destroys). Registered through * the connection's afterCommit hook so a rolled-back save emits nothing, and * skipped entirely when nothing observes this model class so server-side saves * stay free of live-query overhead. * @param {import("../record-changes.js").RecordChangeOperation} operation - The committed operation. * @returns {Promise} */ _emitRecordChangeAfterCommit(operation: import("../record-changes.js").RecordChangeOperation): Promise; /** * Stores an audit row for this record. * @param {import("./auditing.js").CreateAuditArgs} args - Audit row options. * @returns {Promise} Created audit row id. */ createAudit(args: import("./auditing.js").CreateAuditArgs): Promise; /** * Captures create changes before persistence clears the change set. * @returns {void} */ captureCreateAuditChanges(): void; /** * Writes the create audit row. * @returns {Promise} */ createCreateAudit(): Promise; /** * Captures update changes before persistence clears the change set. * @returns {void} */ captureUpdateAuditChanges(): void; /** * Writes the update audit row. * @returns {Promise} */ createUpdateAudit(): Promise; /** * Writes the destroy audit row. * @returns {Promise} */ createDestroyAudit(): Promise; /** * Runs run lifecycle callbacks. * @param {"afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation"} callbackName - Callback type. * @returns {Promise} */ _runLifecycleCallbacks(callbackName: "afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation"): Promise; /** * Runs has changes. * @returns {boolean} - Whether changes. */ _hasChanges(): boolean; /** * Returns true if the model has been changed since it was loaded from the database. * @returns {boolean} - Whether changed. */ isChanged(): boolean; /** * Returns the changes that have been made to this record since it was loaded from the database. * @returns {Record>>} - The changes. */ changes(): Record>>; /** * Runs table name. * @returns {string} - The table name. */ _tableName(): string; /** * Reads an attribute value from the record. Read dynamically by name, so the value can be any * column type and may be overridden by a user-defined getter on the model. * @template V * @param {string} attributeName The name of the attribute to read. This is the attribute name, not the column name. * @returns {V} The attribute value, typed by the caller's accessor contract. */ readAttribute(attributeName: string): V; /** * Read an association count attached by `.withCount(...)`. Counts are * stored on a separate map from the record's `_attributes` so a * virtual count like `tasksCount` cannot silently shadow a real * column of the same name. Returns the attached number, or 0 when * `.withCount(...)` wasn't requested for this attribute. * @param {string} attributeName - Attribute name, e.g. `"tasksCount"` or a custom `"activeMembersCount"` from `.withCount({activeMembersCount: {...}})`. * @returns {number} - Attached association count, or zero when absent. */ readCount(attributeName: string): number; /** * Attach an association count to this record. Internal helper used by * the `withCount` runner; outside code should not call this directly. * @param {string} attributeName - Attribute name. * @param {number} value - Count value. * @returns {void} */ _setAssociationCount(attributeName: string, value: number): void; /** * All attached association counts as a plain object. Used by the * frontend-model serializer to ship counts alongside the record * attributes on the wire. * @returns {Record} - Association counts keyed by attribute name. */ associationCounts(): Record; /** * Read a value attached by `.queryData(...)`. Stored on a dedicated * map rather than on `_attributes`, so a virtual queryData key like * `transportSecondsSum` cannot silently shadow a real column of the * same name. Returns `null` when the key wasn't produced by any * registered fn for this record (e.g. no child rows matched the * aggregate). * @param {string} name - queryData attribute name (matches a SELECT alias from the registered fn). * @returns {ReturnType} - Attached query-data value. */ queryData(name: string): ReturnType; /** * Attach a queryData value to this record. Internal helper used by * the `queryData` runner and by frontend-model hydration; outside * code should not call this directly. * @param {string} name - queryData attribute name. * @param {ReturnType} value - Value to attach. * @returns {void} */ _setQueryData(name: string, value: ReturnType): void; /** * All attached queryData values as a plain object. Used by the * frontend-model serializer to ship queryData alongside the record * attributes on the wire. * @returns {Record>} - Query-data values keyed by name. */ queryDataValues(): Record>; /** * Read a per-record ability result attached by `.abilities(...)`. The * backend evaluates each requested action against the current ability * for this record instance and ships the result alongside the * record's attributes. Returns `false` when the action wasn't * requested for this record — so UI code can safely branch on * `record.can("update")` without first checking whether the ability * was loaded. * @param {string} action - Ability action name, e.g. `"update"`. * @returns {boolean} - Whether the requested ability is allowed. */ can(action: string): boolean; /** * Attach a per-record ability result to this record. Internal helper * used by the `abilities` runner and by frontend-model hydration; * outside code should not call this directly. * @param {string} action - Ability action name. * @param {boolean} value - Whether the current ability permits the action on this record. * @returns {void} */ _setComputedAbility(action: string, value: boolean): void; /** * All attached per-record ability results as a plain object. Used * by the frontend-model serializer to ship results alongside the * record attributes on the wire. * @returns {Record} - Ability results keyed by action. */ computedAbilities(): Record; /** * Reads a column value from the record. * @param {string} attributeName The name of the column to read. This is the column name, not the attribute name. * @returns {ReturnType} - The column. */ readColumn(attributeName: string): ReturnType; /** * Resolves any declared per-attribute cast for a database column name. * @param {string} columnName - Database column name. * @returns {string | undefined} - Declared cast type, or undefined when none is declared. */ _declaredAttributeCastForColumn(columnName: string): string | undefined; /** * Converts a stored value to a real boolean for a declared `"boolean"` cast. * Leaves null/undefined untouched; treats 1/true/"1" as true and 0/false/"0" as false. * @param {ReturnType} value - Stored database value. * @returns {ReturnType} - Converted boolean, or the original value when not recognized. */ _castDeclaredBooleanForRead(value: ReturnType): ReturnType; /** * Whether a column value is currently loaded on this record (either as a * persisted attribute or a pending change). Used to decide whether a preload * can be skipped because the required columns are already present. * @param {string} columnName - The column name to check. * @returns {boolean} - Whether the column is loaded. */ hasLoadedColumn(columnName: string): boolean; /** * Runs normalize boolean value for read. A declared `"boolean"` attribute cast converts the * stored value (e.g. an MSSQL `bit` 0/1) to a real boolean; otherwise the existing * introspected-type normalization applies (no behaviour change for non-declared columns). * @param {object} args - Options object. * @param {string} args.columnName - Database column name being read. * @param {string | undefined} args.columnType - Column type. * @param {ReturnType} args.value - Value to normalize. * @returns {ReturnType} - Normalized value. */ _normalizeBooleanValueForRead({ columnName, columnType, value }: { columnName: string; columnType: string | undefined; value: ReturnType; }): ReturnType; /** * Runs normalize date value for read. * @param {ReturnType} value - Value from database. * @returns {ReturnType} - Normalized value. */ _normalizeDateValueForRead(value: ReturnType): ReturnType; _belongsToChanges(): Record; /** * Runs create new record. * @returns {Promise} - Resolves when complete. */ _createNewRecord(): Promise; /** * Marks only relationships with in-memory loaded values as preloaded after create. * @returns {void} - No return value. */ _markLoadedRelationshipsPreloadedAfterCreate(): void; /** * Applies the database insert response to this record. * @param {{connection: import("../drivers/base.js").default, data: Record, insertResult: Array> | null | undefined, primaryKey: string | string[]}} options - Pinned insert connection, inserted data, connection result, and primary key column name. * @returns {Promise} - Resolves when complete. */ _applyInsertResult({ connection, data, insertResult, primaryKey }: { connection: import("../drivers/base.js").default; data: Record; insertResult: Array> | null | undefined; primaryKey: string | string[]; }): Promise; /** * Sets timestamp defaults for a new record insert. * @param {Record>} data - Column-keyed data. * @returns {void} - No return value. */ _setDefaultTimestampValues(data: Record>): void; /** * Runs normalize date values for write. * @param {Record>} data - Column-keyed data. * @returns {void} - No return value. */ _normalizeDateValuesForWrite(data: Record>): void; /** * Runs update record with changes. * @returns {Promise} - Resolves when complete. */ _updateRecordWithChanges(): Promise; /** * Runs id. * @returns {import("../../utils/model-primary-key.js").ModelPrimaryKeyValue} - The id. */ id(): import("../../utils/model-primary-key.js").ModelPrimaryKeyValue; /** * Returns the identity represented by the last persisted database attributes. * @returns {import("../../utils/model-primary-key.js").ModelPrimaryKeyValue} - Persisted identity. */ _persistedPrimaryKeyValue(): import("../../utils/model-primary-key.js").ModelPrimaryKeyValue; /** * Runs is persisted. * @returns {boolean} - Whether persisted. */ isPersisted(): boolean; /** * Runs is new record. * @returns {boolean} - Whether new record. */ isNewRecord(): boolean; /** * Runs set is new record. * @param {boolean} newIsNewRecord - New is new record. * @returns {void} - No return value. */ setIsNewRecord(newIsNewRecord: boolean): void; /** * Runs reload with id. * @template {typeof VelociousDatabaseRecord} MC * @param {import("../../utils/model-primary-key.js").ModelPrimaryKeyValue} id - Record identifier. * @returns {Promise} - Resolves when complete. */ _reloadWithId(id: import("../../utils/model-primary-key.js").ModelPrimaryKeyValue): Promise; /** * Runs reload. * @returns {Promise} - Resolves when complete. */ reload(): Promise; _runValidations(): Promise; /** * Runs full error messages. * @returns {string[]} - The full error messages. */ fullErrorMessages(): string[]; /** * Assigns the attributes to the record and saves it. * @param {WriteAttributes} attributesToAssign - The attributes to assign to the record. */ update(attributesToAssign: Record): Promise; }; /** @type {Record | undefined} */ _attributeNameToColumnName: Record | undefined; /** @type {Record | undefined} */ _columnNameToAttributeName: Record | undefined; /** @type {Record | undefined} */ _translations: Record | undefined; /** @type {Record | undefined} */ _validators: Record | undefined; /** @type {Record | undefined} */ _lifecycleCallbacks: Record | undefined; /** @type {Record | undefined} */ _validatorTypes: Record | undefined; /** @type {Record | undefined} */ _attachmentsMap: Record | undefined; /** @type {Record | undefined} */ _relationships: Record | undefined; /** @type {Record | undefined} */ _queryDataRegistrations: Record | undefined; /** @type {Record>) => boolean}> | undefined} */ _acceptedNestedAttributes: Record>) => boolean; }> | undefined; /** @type {Record | undefined} */ _attributeCasts: Record | undefined; /** @type {Record | undefined} */ _columnsAsHash: Record | undefined; /** @type {Array | undefined} */ _columnNames: Array | undefined; /** @type {Record | undefined} */ _columnTypeByName: Record | undefined; /** * Narrows the runtime value to the documented type. * @type {string | undefined} */ modelName: string | undefined; /** * Opt-in client sync declaration consumed by `SyncClient.fromConfiguration(...)`. * Declare `static sync = true` (all defaults) or a declaration object like * `static sync = {track: ["create", "update"], syncType: "upsert"}` to have the * sync client auto-discover this model and derive its resource config from * column metadata. * @type {import("../../sync/sync-client-types.js").ModelSyncDeclaration | undefined} */ sync: import("../../sync/sync-client-types.js").ModelSyncDeclaration | undefined; /** * Narrows the runtime value to the documented type. * @type {Promise | null | undefined} */ _initializeRecordPromise: Promise | null | undefined; /** @type {typeof VelociousDatabaseRecord | undefined} Canonical model class exposed only by an operation-bound metadata proxy. */ _recordMetadataModelClass: typeof VelociousDatabaseRecord | undefined; /** @type {((modelClass: typeof VelociousDatabaseRecord) => typeof VelociousDatabaseRecord) | undefined} Binds related generated model classes to the same operation metadata generation. */ _recordMetadataBinder: ((modelClass: typeof VelociousDatabaseRecord) => typeof VelociousDatabaseRecord) | undefined; /** @type {import("../operation.js").default | undefined} Operation exposed only by a constructing metadata proxy. */ _recordMetadataOperation: import("../operation.js").default | undefined; /** * Narrows the runtime value to the documented type. * @type {boolean | undefined} */ _eagerLoadRecordMetadata: boolean | undefined; /** * Narrows the runtime value to the documented type. * @type {Record | undefined} */ _auditCallbacks: Record | undefined; /** * Narrows the runtime value to the documented type. * @type {boolean | undefined} */ _auditLifecycleCallbacksRegistered: boolean | undefined; /** * Returns the model name, preferring an explicit `static modelName` declaration * over the JavaScript class `.name` property. This allows minified builds to * preserve correct model names without relying on `keep_classnames`. * @returns {string} - The model name. */ getModelName(): string; getAttributeNameToColumnNameMap(): Record; /** * Resolves the database column name for a record attribute name. * @param {string} attributeName - Attribute name to resolve. * @returns {string} - Mapped column name, or the underscored attribute name when no mapping exists. */ getColumnNameForAttributeName(attributeName: string): string; /** * Resolves an incoming attribute or column name to the canonical attribute name this model exposes. * Accepts the canonical (deburred) attribute name, a raw umlaut/acronym column name, a pre-deburr * camelization, and camelCase casing variants (e.g. "vAFunktionID" vs "vAFunktionid"). Returns null * when nothing matches, so callers keep their own not-found handling. * @param {string} name - Attribute name or column name to resolve. * @returns {string | null} - Canonical attribute name, or null. */ resolveAttributeName(name: string): string | null; /** * Finds the member name on a target's prototype chain matching `memberName`, falling back to a * case-insensitive match. Resolves setters when a read-only attribute alias differs only in camelCase * casing from the generated accessor (e.g. a "vAFunktionID" alias whose setter is "setVAFunktionid"). * @param {object} target - Instance or prototype to search. * @param {string} memberName - Member name to find. * @returns {string | null} - Matching member name, or null when absent. */ findMemberNameInsensitive(target: object, memberName: string): string | null; /** * Runs define scope. * @param {(...args: Array>) => ReturnType} callback - Scope callback. * @returns {((...args: Array>) => import("../query/model-class-query.js").default) & {scope: (...args: Array>) => import("../../utils/model-scope.js").ModelScopeDescriptor}} - Scope helper. */ defineScope(callback: (...args: Array>) => ReturnType): ((...args: Array>) => import("../query/model-class-query.js").default) & { scope: (...args: Array>) => import("../../utils/model-scope.js").ModelScopeDescriptor; }; /** * Returns the application model class behind an operation-bound metadata view. * @returns {typeof VelociousDatabaseRecord} - Canonical model class. */ canonicalRecordMetadataModelClass(): typeof VelociousDatabaseRecord; /** * Binds a relationship target to this model class's metadata generation. * @param {typeof VelociousDatabaseRecord} modelClass - Relationship target. * @returns {typeof VelociousDatabaseRecord} - Generation-bound target, or the unchanged target for legacy queries. */ bindRecordMetadataModelClass(modelClass: typeof VelociousDatabaseRecord): typeof VelociousDatabaseRecord; getColumnNameToAttributeNameMap(): Record; getTranslationsMap(): Record; getValidatorsMap(): Record; /** * Runs get lifecycle callbacks map. * @returns {Record} - Lifecycle callbacks keyed by name. */ getLifecycleCallbacksMap(): Record; getValidatorTypesMap(): Record; /** * Runs get attachments map. * @returns {Record} - Attachment definitions keyed by name. */ getAttachmentsMap(): Record; validatorTypes(): Record; /** * Runs register validator type. * @param {string} name - Name. * @param {typeof import("./validators/base.js").default} validatorClass - Validator class. */ registerValidatorType(name: string, validatorClass: typeof import("./validators/base.js").default): void; /** * Runs register lifecycle callback. * @param {"afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation"} callbackName - Callback type. * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ registerLifecycleCallback(callbackName: "afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation", callback: LifecycleCallbackType): void; /** * Runs unregister lifecycle callback. * @param {"afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation"} callbackName - Callback type. * @param {LifecycleCallbackType} callback - Previously registered callback. * @returns {void} */ unregisterLifecycleCallback(callbackName: "afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation", callback: LifecycleCallbackType): void; /** * Runs before validation. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ beforeValidation(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs before save. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ beforeSave(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs before create. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ beforeCreate(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs before update. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ beforeUpdate(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs before destroy. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ beforeDestroy(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs after save. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ afterSave(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs after create. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ afterCreate(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs after update. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ afterUpdate(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs after destroy. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ afterDestroy(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Enables automatic create/update/destroy auditing for this model. * @returns {void} */ audited(): void; /** * Declares an aasm-style state machine on this model: named states, events * (guarded transitions), and enter/exit + before/after transition hooks. See * `state-machine.js`. Generates `event()` / `eventAndSave()` / `canEvent()` * transition methods per declared event. * @param {import("./state-machine.js").StateMachineDefinition} definition - State machine definition. * @returns {void} */ stateMachine(definition: import("./state-machine.js").StateMachineDefinition): void; /** * Returns this model's state machine definition, or null when it declares none. * `Model.stateMachine(...)` overrides this on classes that declare a machine. * @returns {import("./state-machine.js").StateMachineDefinition | null} - The state machine definition, or null when none is declared. */ getStateMachineDefinition(): import("./state-machine.js").StateMachineDefinition | null; /** * Returns this model's state column, or null when it declares no state machine. * @returns {string | null} - The state column name, or null when no state machine is declared. */ getStateMachineColumn(): string | null; /** * Returns this model's declared state names (empty when it has no state machine). * @returns {string[]} - The declared state names, or an empty array when no state machine is declared. */ getStateMachineStateNames(): string[]; /** * Maintains a counter column on a `belongsTo` parent as the sum of a per-record * magnitude, kept current by atomic increments diffed on every create/update/ * destroy (and moved between parents when the foreign key changes). See * `counter-cache-magnitude.js`. * @param {import("./counter-cache-magnitude.js").MagnitudeCounterCacheDefinition} definition - Counter cache definition. * @returns {void} */ magnitudeCounterCache(definition: import("./counter-cache-magnitude.js").MagnitudeCounterCacheDefinition): void; /** * Registers a callback invoked after this model writes an audit row for the action. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {string} action - Audit action name. * @param {import("./auditing.js").AuditCallback} callback - Callback to run after audit creation. * @returns {() => void} Unsubscribe function. */ onAudit(this: MC, action: string, callback: import("./auditing.js").AuditCallback): () => void; /** * Returns records that do not have an audit row for the given action. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {string} action - Audit action name. * @returns {ModelClassQuery} Query scoped to records without that audit action. */ withoutAudit(this: MC, action: string): ModelClassQuery; /** * Runs get validator type. * @param {string} validatorName - Validator name. * @returns {typeof import("./validators/base.js").default} - The validator type. */ getValidatorType(validatorName: string): typeof import("./validators/base.js").default; /** * Runs relationship exists. * @param {string} relationshipName - Relationship name. * @returns {boolean} - Whether relationship exists. */ _relationshipExists(relationshipName: string): boolean; /** * RelationshipScopeCallback type. * @typedef {(query: import("../query/model-class-query.js").default) => (import("../query/model-class-query.js").default | void)} RelationshipScopeCallback */ /** * RelationshipDataArgumentType type. * @typedef {object} RelationshipDataArgumentType * @property {boolean} [autoload] - Disable auto-batch-preload for this relationship by passing false. Default true. * @property {string} [className] - Model class name for the related record. * @property {string} [dependent] - Dependent action when parent is destroyed (e.g. "destroy"). * @property {typeof VelociousDatabaseRecord} [klass] - Model class for the related record. * @property {RelationshipScopeCallback} [scope] - Optional scope callback for the relationship. * @property {string} [type] - Relationship type (e.g. "hasMany", "belongsTo"). */ /** * Runs define relationship. * @param {string} relationshipName - Relationship name. * @param {RelationshipDataArgumentType} data - Data payload. */ _defineRelationship(relationshipName: string, data: RelationshipDataArgumentType): void; /** * Runs normalize relationship args. * @param {RelationshipScopeCallback | object | undefined} scopeOrOptions - Scope callback or options. * @param {object | undefined} options - Options. * @returns {{scope: (RelationshipScopeCallback | undefined), relationshipOptions: object}} - Normalized arguments. */ _normalizeRelationshipArgs(scopeOrOptions: RelationshipScopeCallback | object | undefined, options: object | undefined): { scope: (RelationshipScopeCallback | undefined); relationshipOptions: object; }; /** * Registers afterCreate, afterSave, and afterDestroy callbacks to sync * a counter cache column on the parent model. The column name follows * the convention `Count`. * @param {string} relationshipName - The belongsTo relationship name. */ _registerCounterCacheCallbacks(relationshipName: string): void; /** * Runs get relationship by name. * @param {string} relationshipName - Relationship name. * @returns {import("./relationships/base.js").default} - The relationship by name. */ getRelationshipByName(relationshipName: string): import("./relationships/base.js").default; /** * Runs get relationships. * @returns {Array} - The relationships. */ getRelationships(): Array; /** * Runs get relationships map. * @returns {Record} - Relationship definitions keyed by name. */ getRelationshipsMap(): Record; /** * Runs get relationship names. * @returns {Array} - The relationship names. */ getRelationshipNames(): Array; /** * Register a consumer-defined queryData entry. The callback receives * a grouped query already joined down the relationship chain from the * root of `.queryData(...)` to this model, already filtered by the * root parent IDs, and with `parent_id` pre-selected — so the fn * only needs to add its own SELECT (and optionally joins/where). Any * aliases the fn selects are attached to each **root** record via * `record.queryData(aliasName)`. Multi-column selects are fine — one * alias maps to one queryData key. * * **Quote AS aliases on PostgreSQL.** PostgreSQL folds unquoted * identifiers (including SELECT aliases) to lowercase, so a * `... AS manualTasksCount` lands in the result row as * `manualtaskscount` while the lookup `record.queryData("manualTasksCount")` * never finds it. Use `driver.quoteColumn("manualTasksCount")` for the * alias to preserve the case on every supported driver: * query.select(`COUNT(...) AS ${driver.quoteColumn("manualTasksCount")}`) * @param {string} name - Identifier used in the `.queryData(...)` spec. * @param {import("../query/query-data.js").QueryDataFn} fn - Callback that mutates the query. * @returns {void} */ queryData(name: string, fn: import("../query/query-data.js").QueryDataFn): void; /** * Runs get query data map. * @returns {Record} - queryData registrations keyed by name. */ getQueryDataMap(): Record; /** * Runs get query data by name. * @param {string} name - queryData name. * @returns {import("../query/query-data.js").QueryDataFn | null} - Registered fn or null when not found. */ getQueryDataByName(name: string): import("../query/query-data.js").QueryDataFn | null; /** * Runs get attachments. * @returns {Record} - Attachment definitions. */ getAttachments(): Record; /** * Returns attachment definitions through the model contract shared with * frontend model classes. * @returns {Record} - Attachment definitions. */ attachmentDefinitions(): Record; /** * Runs get attachment by name. * @param {string} attachmentName - Attachment name. * @returns {RecordAttachmentConfiguration} - Attachment definition. */ getAttachmentByName(attachmentName: string): RecordAttachmentConfiguration; /** * Adds a belongs-to-relationship to the model. * @param {string} relationshipName The name of the relationship. * @param {RelationshipScopeCallback | object} [scopeOrOptions] The scope callback or options for the relationship. * @param {object} [options] The options for the relationship. */ belongsTo(relationshipName: string, scopeOrOptions?: RelationshipScopeCallback | object, options?: object): void; /** * Runs connection. * @param {object} [args] - Options. * @param {boolean} [args.enforceTenantDatabaseScope] - Whether tenant-switched models must resolve a tenant database identifier. * @returns {import("../drivers/base.js").default} - The connection. */ connection({ enforceTenantDatabaseScope, ...restArgs }?: { enforceTenantDatabaseScope?: boolean; }): import("../drivers/base.js").default; /** * Runs create. * @template {Record>} CreateAttributes * @template {VelociousDatabaseRecord} Model * @this {{new (changes?: CreateAttributes): Model} & typeof VelociousDatabaseRecord} * @param {CreateAttributes} [attributes] - Attributes. * @returns {Promise} - Resolves with the create. */ create>, Model extends VelociousDatabaseRecord>(this: { new (changes?: CreateAttributes): Model; } & typeof VelociousDatabaseRecord, attributes?: CreateAttributes): Promise; /** * Runs get configuration. * @returns {import("../../configuration.js").default} - The configuration. */ _getConfiguration(): import("../../configuration.js").default; _configuration: Configuration | undefined; /** * Adds a has-many-relationship to the model class. * @param {string} relationshipName The name of the relationship (e.g. "posts") * @param {RelationshipScopeCallback | object} [scopeOrOptions] The scope callback or options for the relationship. * @param {object} [options] The options for the relationship (e.g. {className: "Post"}) * @returns {void} - No return value. */ hasMany(relationshipName: string, scopeOrOptions?: RelationshipScopeCallback | object, options?: object): void; /** * Rails-style declaration that this model accepts nested-attribute writes * for a relationship when saved through a parent. Required — Velocious * will refuse nested writes for any relationship not listed here, even * if a frontend-model resource permits them. * * Options: * - allowDestroy: whether `_destroy: true` entries are allowed. Default false. * - limit: optional upper bound on the number of nested entries per request. * - rejectIf: optional predicate `(attributes) => boolean` that silently skips entries. * * Usage: * class Project extends Record {} * Project.hasMany("tasks") * Project.acceptsNestedAttributesFor("tasks", {allowDestroy: true}) * @param {string} relationshipName - Relationship name on this model. * @param {{allowDestroy?: boolean, limit?: number, rejectIf?: (attributes: Record>) => boolean}} [options] - Policy options. * @returns {void} */ acceptsNestedAttributesFor(relationshipName: string, options?: { allowDestroy?: boolean; limit?: number; rejectIf?: (attributes: Record>) => boolean; }): void; /** * Runs accepted nested attributes for. * @param {string} relationshipName - Relationship name. * @returns {{allowDestroy?: boolean, limit?: number, rejectIf?: (attributes: Record>) => boolean} | null} - Policy declared via `acceptsNestedAttributesFor`, or null when not accepted. */ acceptedNestedAttributesFor(relationshipName: string): { allowDestroy?: boolean; limit?: number; rejectIf?: (attributes: Record>) => boolean; } | null; /** * Adds a has-one-relationship to the model class. * @param {string} relationshipName The name of the relationship (e.g. "post") * @param {RelationshipScopeCallback | object} [scopeOrOptions] The scope callback or options for the relationship. * @param {object} [options] The options for the relationship (e.g. {className: "Post"}) * @returns {void} - No return value. */ hasOne(relationshipName: string, scopeOrOptions?: RelationshipScopeCallback | object, options?: object): void; /** * Runs define attachment. * @param {string} attachmentName - Attachment name. * @param {object} args - Attachment args. * @param {string | AttachmentDriverConstructor | Record>} [args.driver] - Attachment driver name, class, or instance. * @param {AttachmentSyncConfiguration} [args.sync] - Client-safe synchronized asset policy. * @param {"hasOne" | "hasMany"} args.type - Attachment type. * @returns {void} - No return value. */ _defineAttachment(attachmentName: string, { driver, sync, type }: { driver?: string | AttachmentDriverConstructor | Record>; sync?: AttachmentSyncConfiguration; type: "hasOne" | "hasMany"; }): void; /** * Adds a single attachment helper to the model. * @param {string} attachmentName - Attachment name. * @param {{driver?: string | AttachmentDriverConstructor | Record>, sync?: AttachmentSyncConfiguration}} [args] - Attachment options. * @returns {void} - No return value. */ hasOneAttachment(attachmentName: string, args?: { driver?: string | AttachmentDriverConstructor | Record>; sync?: AttachmentSyncConfiguration; }): void; /** * Adds a collection attachment helper to the model. * @param {string} attachmentName - Attachment name. * @param {{driver?: string | AttachmentDriverConstructor | Record>, sync?: AttachmentSyncConfiguration}} [args] - Attachment options. * @returns {void} - No return value. */ hasManyAttachments(attachmentName: string, args?: { driver?: string | AttachmentDriverConstructor | Record>; sync?: AttachmentSyncConfiguration; }): void; /** * Runs human attribute name. * @param {string} attributeName - Attribute name. * @returns {string} - The human attribute name. */ humanAttributeName(attributeName: string): string; /** * Runs get database type. * @returns {string} - The database type. */ getDatabaseType(): string; /** * Runs set eager load record metadata. * @param {boolean} eagerLoadRecordMetadata - Whether require-context initialization should load table metadata for this model. * @returns {void} - No return value. */ setEagerLoadRecordMetadata(eagerLoadRecordMetadata: boolean): void; /** * Runs get eager load record metadata. * @returns {boolean} - Whether require-context initialization should load table metadata for this model. */ getEagerLoadRecordMetadata(): boolean; /** * Runs reset record metadata. * @returns {void} - No return value. */ resetRecordMetadata(): void; _initialized: boolean | undefined; _databaseType: string | undefined; _table: import("../drivers/base-table.js").default | undefined; _columns: import("../drivers/base-column.js").default[] | undefined; /** * Static fields that belong to one physical database/schema generation. * @returns {Set} - Metadata property names. */ recordMetadataPropertyNames(): Set; /** * Reads one operation-bound metadata field. * @param {string} metadataKey - Physical database and schema generation key. * @param {string} property - Static metadata property. * @returns {RecordMetadataValue} - Stored metadata value. */ recordMetadataValue(metadataKey: string, property: string): RecordMetadataValue; /** * Writes one operation-bound metadata field. * @param {string} metadataKey - Physical database and schema generation key. * @param {string} property - Static metadata property. * @param {RecordMetadataValue} value - Metadata value. * @returns {void} */ setRecordMetadataValue(metadataKey: string, property: string, value: RecordMetadataValue): void; /** Clears every tenant/generation metadata snapshot for this model. */ clearRecordMetadataValues(): void; /** * Clears snapshots whose key belongs to one physical database identity. * @param {string} databaseIdentity - Logical identifier plus pool reuse key. * @returns {void} */ clearRecordMetadataValuesForDatabaseIdentity(databaseIdentity: string): void; /** * Registers the model class with a configuration without loading table metadata. * @param {object} args - Options object. * @param {import("../../configuration.js").default} args.configuration - Configuration instance. * @returns {void} - No return value. */ registerRecordClass({ configuration, ...restArgs }: { configuration: import("../../configuration.js").default; }): void; /** * Runs initialize record. * @param {object} args - Options object. * @param {import("../../configuration.js").default} args.configuration - Configuration instance. * @param {import("../drivers/base.js").default} [args.connection] - Explicit metadata connection. * @returns {Promise} - Resolves when complete. */ initializeRecord({ configuration, connection: explicitConnection, ...restArgs }: { configuration: import("../../configuration.js").default; connection?: import("../drivers/base.js").default; }): Promise; /** * Initializes the model class the first time an async record API needs table * metadata. Concurrent callers share the same initialization promise, and a * failed initialization can be retried by a later call. * @param {{configuration?: import("../../configuration.js").default, connection?: import("../drivers/base.js").default}} [args] - Optional configuration and explicit metadata connection. * @returns {Promise} - Resolves when the model class is initialized. */ ensureInitialized(args?: { configuration?: import("../../configuration.js").default; connection?: import("../drivers/base.js").default; }): Promise; /** * Runs is initialized. * @returns {boolean} - Whether initialized. */ isInitialized(): boolean; /** * Runs assert has been initialized. * @returns {void} - No return value. */ _assertHasBeenInitialized(): void; /** * Defines translation accessors and initializes the generated translation * class through the same metadata connection as the translated model. * @param {import("../drivers/base.js").default} connection - Metadata connection. * @returns {Promise} - Resolves when translation metadata is ready. */ _defineTranslationMethods(connection: import("../drivers/base.js").default): Promise; /** * Runs get configured database identifier. * @returns {string} - The configured non-tenant database identifier. */ getConfiguredDatabaseIdentifier(): string; /** * Runs get database identifier. * @param {object} [args] - Options. * @param {boolean} [args.enforceTenantDatabaseScope] - Whether tenant-switched models must resolve a tenant database identifier. * @param {object} [args.tenant] - Explicit tenant descriptor instead of the ambient tenant. * @returns {string} - The database identifier. */ getDatabaseIdentifier({ enforceTenantDatabaseScope, tenant, ...restArgs }?: { enforceTenantDatabaseScope?: boolean; tenant?: object; }): string; /** * Runs set database identifier. * @param {string} databaseIdentifier - Database identifier. * @returns {void} - No return value. */ setDatabaseIdentifier(databaseIdentifier: string): void; _databaseIdentifier: string | undefined; /** * Declares a tenant-aware database identifier resolver for this model class. * @param {string | ((args: {modelClass: typeof VelociousDatabaseRecord, tenant: Record | null | undefined}) => string | undefined)} databaseIdentifierOrResolver - Static identifier or resolver. * @returns {void} - No return value. */ switchesTenantDatabase(databaseIdentifierOrResolver: string | ((args: { modelClass: typeof VelociousDatabaseRecord; tenant: Record | null | undefined; }) => string | undefined)): void; _tenantDatabaseIdentifierResolver: string | ((args: { modelClass: typeof VelociousDatabaseRecord; tenant: Record | null | undefined; }) => string | undefined) | undefined; /** * Runs has tenant database identifier resolver. * @returns {boolean} - Whether this model resolves its database from the current tenant. */ hasTenantDatabaseIdentifierResolver(): boolean; /** * Runs get tenant database identifier. * @param {ReturnType} [tenant] - Tenant override. * @returns {string | undefined} - Tenant-scoped database identifier when configured. */ getTenantDatabaseIdentifier(tenant?: ReturnType): string | undefined; /** * Whether a declared `"boolean"` attribute cast is backed by an integer column (e.g. an MSSQL * `bit`), so booleans must be stored as 1/0. A native boolean column (e.g. Postgres `boolean`) * returns false and keeps `true`/`false` for the driver. * @param {string} attributeName - Attribute name. * @returns {boolean} - Whether the declared boolean is stored as an integer. */ _declaredBooleanStoresAsInteger(attributeName: string): boolean; /** * Runs get columns. * @returns {import("../drivers/base-column.js").default[]} - The columns. */ getColumns(): import("../drivers/base-column.js").default[]; /** * Runs get columns hash. * @returns {Record} - The columns hash. */ getColumnsHash(): Record; /** * Runs get column type by name. * @param {string} name - Name. * @returns {string | undefined} - The column type by name. */ getColumnTypeByName(name: string): string | undefined; /** * Runs is date like type. * @param {string} type - Type identifier. * @returns {boolean} - Whether date like type. */ _isDateLikeType(type: string): boolean; /** * Runs get column names. * @returns {Array} - The column names. */ getColumnNames(): Array; /** * Runs get table. * @returns {import("../drivers/base-table.js").default} - The table. */ _getTable(): import("../drivers/base-table.js").default; /** * Runs insert multiple. * @param {Array} columns - Column names. * @param {Array>>} rows - Rows to insert. * @param {object} [args] - Options object. * @param {boolean} [args.cast] - Whether to cast values based on column types. * @param {boolean} [args.retryIndividuallyOnFailure] - Retry rows individually if a batch insert fails. * @param {boolean} [args.returnResults] - Return succeeded/failed rows instead of throwing when retries fail. * @returns {Promise>>, failedRows: Array>>, errors: Array<{row: Array>, error: ReturnType}>}>} - Resolves when complete. */ insertMultiple(columns: Array, rows: Array>>, args?: { cast?: boolean; retryIndividuallyOnFailure?: boolean; returnResults?: boolean; }): Promise>>; failedRows: Array>>; errors: Array<{ row: Array>; error: ReturnType; }>; }>; /** * Runs normalize insert multiple rows. * @param {object} args - Options object. * @param {Array} args.columns - Column names. * @param {Array>>} args.rows - Rows to insert. * @returns {Array>>} - Normalized rows. */ _normalizeInsertMultipleRows({ columns, rows }: { columns: Array; rows: Array>>; }): Array>>; /** * Runs safe serialize insert row. * @param {Array>} row - Row to serialize. * @returns {string} - Safe row representation. */ _safeSerializeInsertRow(row: Array>): string; /** * Runs normalize insert value for column. * @param {object} args - Options object. * @param {string} args.columnName - Column name. * @param {ReturnType} args.value - Column value. * @returns {ReturnType} - Normalized value. */ _normalizeInsertValueForColumn({ columnName, value }: { columnName: string; value: ReturnType; }): ReturnType; /** * Runs is string type. * @param {string | undefined} columnType - Column type. * @returns {boolean} - Whether string-like type. */ _isStringType(columnType: string | undefined): boolean; /** * Runs is numeric type. * @param {string} columnType - Column type. * @returns {boolean} - Whether numeric-like type. */ _isNumericType(columnType: string): boolean; /** * Runs normalize numeric value. * @param {object} args - Options object. * @param {string} args.columnType - Column type. * @param {ReturnType} args.value - Value to normalize. * @returns {ReturnType} - Normalized value. */ _normalizeNumericValue({ columnType, value }: { columnType: string; value: ReturnType; }): ReturnType; /** * Runs normalize date value for insert. * @param {ReturnType} value - Value to normalize. * @returns {ReturnType} - Normalized value. */ _normalizeDateValueForInsert(value: ReturnType): ReturnType; /** * Runs normalize date string for insert. * @param {string} value - Date string value. * @returns {string | Date} - Parsed date or original string. */ _normalizeDateStringForInsert(value: string): string | Date; /** * Runs time zone for date writes. * @returns {string | undefined} - Active timezone identifier. */ _timeZoneForDateWrite(): string | undefined; /** * Runs normalize sqlite boolean value for insert. * @param {object} args - Options object. * @param {string | undefined} args.columnType - Column type. * @param {ReturnType} args.value - Value to normalize. * @returns {ReturnType} - Normalized value. */ _normalizeSqliteBooleanValueForInsert({ columnType, value }: { columnType: string | undefined; value: ReturnType; }): ReturnType; /** * Runs next primary key. * @returns {Promise} - Resolves with the next primary key. */ nextPrimaryKey(): Promise; /** * Runs set primary key. * @param {string | string[] | null} primaryKey - Primary key. * @returns {void} - No return value. */ setPrimaryKey(primaryKey: string | string[] | null): void; _primaryKey: string | string[] | null | undefined; /** * Returns this class's own attribute-cast map, creating it on the class itself * (never inherited from a parent) so subclasses don't share the same object. * @returns {Record} - Declared casts keyed by attribute name. */ getAttributeCastsMap(): Record; /** * Declares a Rails-style per-attribute cast so a column whose introspected type * isn't what the app wants (e.g. an MSSQL `bit` mapped to `number`) can be * exposed as another type with real runtime conversion. Currently fully * implements the `"boolean"` cast (0/1 <-> false/true); other types only record * the label so the effective type and generated typings reflect them. * @param {string} attributeName - Attribute name (camelCase), e.g. `"sichtbarVVK"`. * @param {string} type - Declared type, e.g. `"boolean"`. * @returns {void} - No return value. */ attribute(attributeName: string, type: string): void; /** * Returns the declared cast type for an attribute, if any. * @param {string} attributeName - Attribute name (camelCase). * @returns {string | undefined} - Declared cast type, or undefined when none is declared. */ getAttributeCast(attributeName: string): string | undefined; /** * Runs primary key. * @returns {string | string[]} - The primary key. */ primaryKey(): string | string[]; /** * Whether the model has a single primary key column. `setPrimaryKey(null)` (e.g. composite-key * legacy tables) declares no single primary key; `primaryKey()` still falls back to "id" for the * default case, so callers that must distinguish "no primary key" use this instead. * @returns {boolean} - False only when the primary key was explicitly set to null. */ hasPrimaryKey(): boolean; /** * Runs table name. * @returns {string} - The table name. */ tableName(): string; _tableName: string | undefined; /** * Runs set table name. * @param {string} tableName - Table name. * @returns {void} - No return value. */ setTableName(tableName: string): void; /** * Runs transaction. * @param {() => Promise} callback - Callback function. * @returns {Promise>} - Resolves with the transaction. */ transaction(callback: () => Promise): Promise>; /** * Prepares this model's attachment store before opening a model transaction. * @param {import("../drivers/base.js").default} connection - Model connection. * @returns {Promise} - Resolves when the attachment schema is current. */ _prepareAttachmentStoreSchema(connection: import("../drivers/base.js").default): Promise; /** * Runs the callback while holding a named advisory lock. Calls without * By default calls use the caller connection. Calls with `dedicatedConnection` * use a spawned lock connection that is released after the callback finishes, * while the callback itself still runs against the caller/model connection. * Calls with a positive `holdTimeoutMs` use a dedicated lock connection so * timeout cleanup can release the lock even when callback database work is * stuck. Advisory locks are cooperative and session-scoped: they serialize * callers that opt into the same `name`, without touching row or table locks, * so unrelated traffic is free to proceed. * * The lock is acquired before the callback runs and released in a * `finally` block afterwards, so the callback's return value is * propagated and thrown errors still release the lock. * @template T * @param {string} name - Lock name. * @param {() => Promise} callback - Callback to invoke while the lock is held. * @param {{timeoutMs?: number | null, holdTimeoutMs?: number | null, dedicatedConnection?: boolean}} [args] - `timeoutMs` caps how long we wait to acquire the lock; `holdTimeoutMs` caps how long the callback may hold it before the lock is released and `AdvisoryLockHoldTimeoutError` is thrown; `dedicatedConnection` spawns a separate lock session without enabling a hold timeout. * @returns {Promise} - Resolves with the callback's return value. * @throws {AdvisoryLockTimeoutError} - If `timeoutMs` elapses before the lock is granted. * @throws {AdvisoryLockHoldTimeoutError} - If `holdTimeoutMs` elapses while the callback holds the lock. */ withAdvisoryLock(name: string, callback: () => Promise, args?: { timeoutMs?: number | null; holdTimeoutMs?: number | null; dedicatedConnection?: boolean; }): Promise; /** * Runs the callback only if the named advisory lock can be acquired * immediately. If the lock is already held by any session, throws * `AdvisoryLockBusyError` without waiting. * Use this when contention is a signal that somebody else is already * doing the work and you want to bail out rather than queue up. * @template T * @param {string} name - Lock name. * @param {() => Promise} callback - Callback to invoke while the lock is held. * @param {{holdTimeoutMs?: number | null, dedicatedConnection?: boolean}} [args] - `holdTimeoutMs` caps how long the callback may hold the lock before it is released and `AdvisoryLockHoldTimeoutError` is thrown; `dedicatedConnection` spawns a separate lock session without enabling a hold timeout. * @returns {Promise} - Resolves with the callback's return value. * @throws {AdvisoryLockBusyError} - If the lock is already held. * @throws {AdvisoryLockHoldTimeoutError} - If `holdTimeoutMs` elapses while the callback holds the lock. */ withAdvisoryLockOrFail(name: string, callback: () => Promise, args?: { holdTimeoutMs?: number | null; dedicatedConnection?: boolean; }): Promise; /** * Runs `callback`, rejecting with `AdvisoryLockHoldTimeoutError` if it has * not settled within `holdTimeoutMs`. The callback is not cancelled — this is * a safety net, not cancellation. * @template T * @param {string} name - Lock name (for the error message). * @param {() => Promise} callback - Callback holding the lock. * @param {number | null} [holdTimeoutMs] - Max hold time; falsy disables the timeout. * @returns {Promise} - Callback result after the lock-protected operation. */ runWithAdvisoryLockHoldTimeout(name: string, callback: () => Promise, holdTimeoutMs?: number | null): Promise; /** * Returns true if the named advisory lock is currently held by any * session. Primarily useful as a diagnostic; callers that want to act * on the result should prefer `withAdvisoryLockOrFail` to avoid a * TOCTOU window between the check and the action. * @param {string} name - Lock name. * @returns {Promise} - Whether the advisory lock is currently held. */ hasAdvisoryLock(name: string): Promise; /** * Runs translates. * @param {...string} names - Names. * @returns {void} - No return value. */ translates(...names: string[]): void; /** * Runs current translation scope. * @param {ModelClassQuery} query - Translation query. * @returns {ModelClassQuery} - Scoped query. */ currentTranslationScope(query: ModelClassQuery): ModelClassQuery; /** * Runs get translation class. * @returns {typeof VelociousDatabaseRecord} - The translation class. */ getTranslationClass(): typeof VelociousDatabaseRecord; readonly name: string; _translationClass: /*elided*/ any | undefined; /** * Runs get translations table name. * @returns {string} - The translations table name. */ getTranslationsTableName(): string; /** * Runs has translations table. * @returns {Promise} - Resolves with Whether it has translations table. */ hasTranslationsTable(): Promise; /** * Adds a validation to an attribute. * @param {string} attributeName The name of the attribute to validate. * @param {Record>>} validators The validators to add. Key is the validator name, value is the validator arguments. */ validates(attributeName: string, validators: Record>>): Promise; /** * Registers gap-less positional list callbacks for a column scoped by * another column. Inserts and moves shift surrounding positions so the * list stays compact (1,2,3,...). Destroys close the resulting gap. * * Callers must ensure a UNIQUE index on (scopeColumn, positionColumn) * exists in the database — use `Migration.addActsAsList()` for the * schema half. * @param {string} positionColumn - camelCase position attribute (e.g. "rowNumber"). * @param {object} options - Options with a required scope attribute. * @param {string} options.scope - camelCase scope attribute (e.g. "boardColumnId"). */ actsAsList(positionColumn: string, options: { scope: string; }): void; /** * Runs new query. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {{driver?: import("../drivers/base.js").default | (() => import("../drivers/base.js").default), operation?: import("../operation.js").default}} [args] - Explicit query ownership. * @returns {ModelClassQuery} - The new query. */ _newQuery(this: MC, args?: { driver?: import("../drivers/base.js").default | (() => import("../drivers/base.js").default); operation?: import("../operation.js").default; }): ModelClassQuery; /** * Runs orderable column. * @returns {string} - The orderable column. */ orderableColumn(): string; /** * Runs all. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @returns {ModelClassQuery} - The all. */ all(this: MC): ModelClassQuery; /** * Runs accessible for. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {string} action - Ability action to scope by. * @param {import("../../authorization/ability.js").default | undefined} [ability] - Ability instance. * @returns {ModelClassQuery} - Authorized query. */ accessibleFor(this: MC, action: string, ability?: import("../../authorization/ability.js").default | undefined): ModelClassQuery; /** * Runs accessible. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../../authorization/ability.js").default | undefined} [ability] - Ability instance. * @returns {ModelClassQuery} - Authorized query. */ accessible(this: MC, ability?: import("../../authorization/ability.js").default | undefined): ModelClassQuery; /** * Runs accessible by. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../../authorization/ability.js").default} ability - Ability instance. * @returns {ModelClassQuery} - Authorized query. */ accessibleBy(this: MC, ability: import("../../authorization/ability.js").default): ModelClassQuery; /** * Runs count. * @returns {Promise} - Resolves with the count. */ count(): Promise; /** * Runs group. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {string} group - Group. * @returns {ModelClassQuery} - The group. */ group(this: MC, group: string): ModelClassQuery; destroyAll(): Promise; /** * Runs pluck. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {...string|string[]} columns - Column names. * @returns {Promise>>} - Resolves with the pluck. */ pluck(this: MC, ...columns: (string | string[])[]): Promise>>; /** * Runs find. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../../utils/model-primary-key.js").ModelPrimaryKeyValue} recordId - Record id. * @returns {Promise>} - Resolves with the find. */ find(this: MC, recordId: import("../../utils/model-primary-key.js").ModelPrimaryKeyValue): Promise>; /** * Runs find by. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {{[key: string]: string | number}} conditions - Conditions hash keyed by attribute name. * @returns {Promise | null>} - Resolves with the by. */ findBy(this: MC, conditions: { [key: string]: string | number; }): Promise | null>; /** * Runs find by or fail. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {{[key: string]: string | number}} conditions - Conditions hash keyed by attribute name. * @returns {Promise>} - Resolves with the by or fail. */ findByOrFail(this: MC, conditions: { [key: string]: string | number; }): Promise>; /** * Returns an immutable tenant-bound model scope. Eager helpers and explicit * databaseOperation/transaction callbacks execute from a captured physical * database configuration instead of ambient tenant state. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {object} tenant - Ordinary or null-prototype JSON-compatible tenant descriptor to scope the model to. * @returns {TenantModelScope} - Model scope bound to the captured tenant database. */ usingTenant(this: MC, tenant: object): TenantModelScope; /** * Runs find or create by. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {{[key: string]: string | number}} conditions - Conditions hash keyed by attribute name. * @param {() => void} [callback] - Callback function. * @returns {Promise>} - Resolves with the or create by. */ findOrCreateBy(this: MC, conditions: { [key: string]: string | number; }, callback?: () => void): Promise>; /** * Runs find or initialize by. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {Record} conditions - Conditions. * @param {(arg: InstanceType) => void} [callback] - Callback function. * @returns {Promise>} - Resolves with the or initialize by. */ findOrInitializeBy(this: MC, conditions: Record, callback?: (arg: InstanceType) => void): Promise>; /** * Runs first. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @returns {Promise>} - Resolves with the first. */ first(this: MC): Promise>; /** * Runs joins. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {string | import("../query/join-object.js").JoinObject} join - Join clause or join descriptor. * @returns {ModelClassQuery} - The joins. */ joins(this: MC, join: string | import("../query/join-object.js").JoinObject): ModelClassQuery; /** * Runs last. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @returns {Promise>} - Resolves with the last. */ last(this: MC): Promise>; /** * Runs limit. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {number} value - Value to use. * @returns {ModelClassQuery} - The limit. */ limit(this: MC, value: number): ModelClassQuery; /** * Runs order. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../query/index.js").OrderArgumentType} order - Order. * @returns {ModelClassQuery} - The order. */ order(this: MC, order: import("../query/index.js").OrderArgumentType): ModelClassQuery; /** * Runs distinct. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {boolean} [value] - Value to use. * @returns {ModelClassQuery} - The distinct. */ distinct(this: MC, value?: boolean): ModelClassQuery; /** * Runs preload. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../query/index.js").NestedPreloadRecord | string | Array} preload - Preload. * @returns {ModelClassQuery} - The preload. */ preload(this: MC, preload: import("../query/index.js").NestedPreloadRecord | string | Array): ModelClassQuery; /** * Runs select. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../query/index.js").SelectArgumentType} select - Select. * @returns {ModelClassQuery} - The select. */ select(this: MC, select: import("../query/index.js").SelectArgumentType): ModelClassQuery; /** * Runs to array. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @returns {Promise[]>} - Resolves with the array. */ toArray(this: MC): Promise[]>; /** * Runs load. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @returns {Promise[]>} - Resolves with the array. */ load(this: MC): Promise[]>; /** * Runs where. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../query/index.js").WhereArgumentType} where - Where. * @returns {ModelClassQuery} - The where. */ where(this: MC, where: import("../query/index.js").WhereArgumentType): ModelClassQuery; /** * Runs ransack. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {Record>} params - Ransack-style params hash. * @returns {ModelClassQuery} - Query with Ransack filters applied. */ ransack(this: MC, params: Record>): ModelClassQuery; } | undefined; _isNewRecord: boolean; _databaseIdentity: string | undefined; /** @type {Record | undefined} */ static _attributeNameToColumnName: Record | undefined; /** @type {Record | undefined} */ static _columnNameToAttributeName: Record | undefined; /** @type {Record | undefined} */ static _translations: Record | undefined; /** @type {Record | undefined} */ static _validators: Record | undefined; /** @type {Record | undefined} */ static _lifecycleCallbacks: Record | undefined; /** @type {Record | undefined} */ static _validatorTypes: Record | undefined; /** @type {Record | undefined} */ static _attachmentsMap: Record | undefined; /** @type {Record | undefined} */ static _relationships: Record | undefined; /** @type {Record | undefined} */ static _queryDataRegistrations: Record | undefined; /** @type {Record>) => boolean}> | undefined} */ static _acceptedNestedAttributes: Record>) => boolean; }> | undefined; /** @type {Record | undefined} */ static _attributeCasts: Record | undefined; /** @type {Record | undefined} */ static _columnsAsHash: Record | undefined; /** @type {Array | undefined} */ static _columnNames: Array | undefined; /** @type {Record | undefined} */ static _columnTypeByName: Record | undefined; /** * Narrows the runtime value to the documented type. * @type {string | undefined} */ static modelName: string | undefined; /** * Opt-in client sync declaration consumed by `SyncClient.fromConfiguration(...)`. * Declare `static sync = true` (all defaults) or a declaration object like * `static sync = {track: ["create", "update"], syncType: "upsert"}` to have the * sync client auto-discover this model and derive its resource config from * column metadata. * @type {import("../../sync/sync-client-types.js").ModelSyncDeclaration | undefined} */ static sync: import("../../sync/sync-client-types.js").ModelSyncDeclaration | undefined; /** * Narrows the runtime value to the documented type. * @type {Promise | null | undefined} */ static _initializeRecordPromise: Promise | null | undefined; /** @type {typeof VelociousDatabaseRecord | undefined} Canonical model class exposed only by an operation-bound metadata proxy. */ static _recordMetadataModelClass: typeof VelociousDatabaseRecord | undefined; /** @type {((modelClass: typeof VelociousDatabaseRecord) => typeof VelociousDatabaseRecord) | undefined} Binds related generated model classes to the same operation metadata generation. */ static _recordMetadataBinder: ((modelClass: typeof VelociousDatabaseRecord) => typeof VelociousDatabaseRecord) | undefined; /** @type {import("../operation.js").default | undefined} Operation exposed only by a constructing metadata proxy. */ static _recordMetadataOperation: import("../operation.js").default | undefined; /** * Narrows the runtime value to the documented type. * @type {boolean | undefined} */ static _eagerLoadRecordMetadata: boolean | undefined; /** * Narrows the runtime value to the documented type. * @type {Record | undefined} */ static _auditCallbacks: Record | undefined; /** * Narrows the runtime value to the documented type. * @type {boolean | undefined} */ static _auditLifecycleCallbacksRegistered: boolean | undefined; /** * Returns the model name, preferring an explicit `static modelName` declaration * over the JavaScript class `.name` property. This allows minified builds to * preserve correct model names without relying on `keep_classnames`. * @returns {string} - The model name. */ static getModelName(): string; static getAttributeNameToColumnNameMap(): Record; /** * Resolves the database column name for a record attribute name. * @param {string} attributeName - Attribute name to resolve. * @returns {string} - Mapped column name, or the underscored attribute name when no mapping exists. */ static getColumnNameForAttributeName(attributeName: string): string; /** * Resolves an incoming attribute or column name to the canonical attribute name this model exposes. * Accepts the canonical (deburred) attribute name, a raw umlaut/acronym column name, a pre-deburr * camelization, and camelCase casing variants (e.g. "vAFunktionID" vs "vAFunktionid"). Returns null * when nothing matches, so callers keep their own not-found handling. * @param {string} name - Attribute name or column name to resolve. * @returns {string | null} - Canonical attribute name, or null. */ static resolveAttributeName(name: string): string | null; /** * Finds the member name on a target's prototype chain matching `memberName`, falling back to a * case-insensitive match. Resolves setters when a read-only attribute alias differs only in camelCase * casing from the generated accessor (e.g. a "vAFunktionID" alias whose setter is "setVAFunktionid"). * @param {object} target - Instance or prototype to search. * @param {string} memberName - Member name to find. * @returns {string | null} - Matching member name, or null when absent. */ static findMemberNameInsensitive(target: object, memberName: string): string | null; /** * Runs define scope. * @param {(...args: Array>) => ReturnType} callback - Scope callback. * @returns {((...args: Array>) => import("../query/model-class-query.js").default) & {scope: (...args: Array>) => import("../../utils/model-scope.js").ModelScopeDescriptor}} - Scope helper. */ static defineScope(callback: (...args: Array>) => ReturnType): ((...args: Array>) => import("../query/model-class-query.js").default) & { scope: (...args: Array>) => import("../../utils/model-scope.js").ModelScopeDescriptor; }; /** * Returns the application model class behind an operation-bound metadata view. * @returns {typeof VelociousDatabaseRecord} - Canonical model class. */ static canonicalRecordMetadataModelClass(): typeof VelociousDatabaseRecord; /** * Binds a relationship target to this model class's metadata generation. * @param {typeof VelociousDatabaseRecord} modelClass - Relationship target. * @returns {typeof VelociousDatabaseRecord} - Generation-bound target, or the unchanged target for legacy queries. */ static bindRecordMetadataModelClass(modelClass: typeof VelociousDatabaseRecord): typeof VelociousDatabaseRecord; static getColumnNameToAttributeNameMap(): Record; static getTranslationsMap(): Record; static getValidatorsMap(): Record; /** * Runs get lifecycle callbacks map. * @returns {Record} - Lifecycle callbacks keyed by name. */ static getLifecycleCallbacksMap(): Record; static getValidatorTypesMap(): Record; /** * Runs get attachments map. * @returns {Record} - Attachment definitions keyed by name. */ static getAttachmentsMap(): Record; /** * Attributes. * @type {Record>} */ _attributes: Record>; /** * Unmapped result aliases explicitly selected by the query that hydrated this record. * @type {Set} */ _selectedAttributeAliases: Set; /** * Changes. * @type {Record>} */ _changes: Record>; /** * Whether primary-key reads are pinned to the stored attributes. * @type {boolean} */ _readsPersistedPrimaryKey: boolean; /** * Changes captured before a create audit is written. * @type {import("./auditing.js").AuditChanges | undefined} */ _pendingCreateAuditChanges: import("./auditing.js").AuditChanges | undefined; /** * Changes captured before an update audit is written. * @type {import("./auditing.js").AuditChanges | undefined} */ _pendingUpdateAuditChanges: import("./auditing.js").AuditChanges | undefined; /** * Attribute names explicitly assigned in the current update call. * @type {Set | undefined} */ _assignedAttributeNames: Set | undefined; /** * Columns as hash. * @type {Record} */ _columnsAsHash: Record; /** * Connection. * @type {import("../drivers/base.js").default | undefined} */ __connection: import("../drivers/base.js").default | undefined; /** * Explicit operation owning this record's database work. * @type {import("../operation.js").default | undefined} */ _databaseOperation: import("../operation.js").default | undefined; /** * Instance relationships. * @type {Record} */ _instanceRelationships: Record; /** * Attachments. * @type {Record} */ _attachments: Record; /** * Load cohort. * @type {Array | undefined} - Shared reference to sibling records loaded in the same batch. Used by auto-preload. */ _loadCohort: Array | undefined; /** * Table name. * @type {string | undefined} */ __tableName: string | undefined; /** * Validation errors. * @type {Record} */ _validationErrors: Record; static validatorTypes(): Record; /** * Runs register validator type. * @param {string} name - Name. * @param {typeof import("./validators/base.js").default} validatorClass - Validator class. */ static registerValidatorType(name: string, validatorClass: typeof import("./validators/base.js").default): void; /** * Runs register lifecycle callback. * @param {"afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation"} callbackName - Callback type. * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ static registerLifecycleCallback(callbackName: "afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation", callback: LifecycleCallbackType): void; /** * Runs unregister lifecycle callback. * @param {"afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation"} callbackName - Callback type. * @param {LifecycleCallbackType} callback - Previously registered callback. * @returns {void} */ static unregisterLifecycleCallback(callbackName: "afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation", callback: LifecycleCallbackType): void; /** * Runs before validation. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ static beforeValidation(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs before save. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ static beforeSave(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs before create. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ static beforeCreate(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs before update. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ static beforeUpdate(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs before destroy. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ static beforeDestroy(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs after save. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ static afterSave(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs after create. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ static afterCreate(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs after update. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ static afterUpdate(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Runs after destroy. * @template R * @this {ModelConstructor} * @param {LifecycleCallbackType} callback - Callback function or instance method name. * @returns {void} */ static afterDestroy(this: ModelConstructor, callback: LifecycleCallbackType): void; /** * Enables automatic create/update/destroy auditing for this model. * @returns {void} */ static audited(): void; /** * Declares an aasm-style state machine on this model: named states, events * (guarded transitions), and enter/exit + before/after transition hooks. See * `state-machine.js`. Generates `event()` / `eventAndSave()` / `canEvent()` * transition methods per declared event. * @param {import("./state-machine.js").StateMachineDefinition} definition - State machine definition. * @returns {void} */ static stateMachine(definition: import("./state-machine.js").StateMachineDefinition): void; /** * Returns this model's state machine definition, or null when it declares none. * `Model.stateMachine(...)` overrides this on classes that declare a machine. * @returns {import("./state-machine.js").StateMachineDefinition | null} - The state machine definition, or null when none is declared. */ static getStateMachineDefinition(): import("./state-machine.js").StateMachineDefinition | null; /** * Returns this model's state column, or null when it declares no state machine. * @returns {string | null} - The state column name, or null when no state machine is declared. */ static getStateMachineColumn(): string | null; /** * Returns this model's declared state names (empty when it has no state machine). * @returns {string[]} - The declared state names, or an empty array when no state machine is declared. */ static getStateMachineStateNames(): string[]; /** * Maintains a counter column on a `belongsTo` parent as the sum of a per-record * magnitude, kept current by atomic increments diffed on every create/update/ * destroy (and moved between parents when the foreign key changes). See * `counter-cache-magnitude.js`. * @param {import("./counter-cache-magnitude.js").MagnitudeCounterCacheDefinition} definition - Counter cache definition. * @returns {void} */ static magnitudeCounterCache(definition: import("./counter-cache-magnitude.js").MagnitudeCounterCacheDefinition): void; /** * Registers a callback invoked after this model writes an audit row for the action. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {string} action - Audit action name. * @param {import("./auditing.js").AuditCallback} callback - Callback to run after audit creation. * @returns {() => void} Unsubscribe function. */ static onAudit(this: MC, action: string, callback: import("./auditing.js").AuditCallback): () => void; /** * Returns records that do not have an audit row for the given action. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {string} action - Audit action name. * @returns {ModelClassQuery} Query scoped to records without that audit action. */ static withoutAudit(this: MC, action: string): ModelClassQuery; /** * Runs get validator type. * @param {string} validatorName - Validator name. * @returns {typeof import("./validators/base.js").default} - The validator type. */ static getValidatorType(validatorName: string): typeof import("./validators/base.js").default; /** * Runs relationship exists. * @param {string} relationshipName - Relationship name. * @returns {boolean} - Whether relationship exists. */ static _relationshipExists(relationshipName: string): boolean; /** * RelationshipScopeCallback type. * @typedef {(query: import("../query/model-class-query.js").default) => (import("../query/model-class-query.js").default | void)} RelationshipScopeCallback */ /** * RelationshipDataArgumentType type. * @typedef {object} RelationshipDataArgumentType * @property {boolean} [autoload] - Disable auto-batch-preload for this relationship by passing false. Default true. * @property {string} [className] - Model class name for the related record. * @property {string} [dependent] - Dependent action when parent is destroyed (e.g. "destroy"). * @property {typeof VelociousDatabaseRecord} [klass] - Model class for the related record. * @property {RelationshipScopeCallback} [scope] - Optional scope callback for the relationship. * @property {string} [type] - Relationship type (e.g. "hasMany", "belongsTo"). */ /** * Runs define relationship. * @param {string} relationshipName - Relationship name. * @param {RelationshipDataArgumentType} data - Data payload. */ static _defineRelationship(relationshipName: string, data: RelationshipDataArgumentType): void; /** * Runs normalize relationship args. * @param {RelationshipScopeCallback | object | undefined} scopeOrOptions - Scope callback or options. * @param {object | undefined} options - Options. * @returns {{scope: (RelationshipScopeCallback | undefined), relationshipOptions: object}} - Normalized arguments. */ static _normalizeRelationshipArgs(scopeOrOptions: RelationshipScopeCallback | object | undefined, options: object | undefined): { scope: (RelationshipScopeCallback | undefined); relationshipOptions: object; }; /** * Registers afterCreate, afterSave, and afterDestroy callbacks to sync * a counter cache column on the parent model. The column name follows * the convention `Count`. * @param {string} relationshipName - The belongsTo relationship name. */ static _registerCounterCacheCallbacks(relationshipName: string): void; /** * Runs get relationship by name. * @param {string} relationshipName - Relationship name. * @returns {import("./relationships/base.js").default} - The relationship by name. */ static getRelationshipByName(relationshipName: string): import("./relationships/base.js").default; /** * Runs get relationships. * @returns {Array} - The relationships. */ static getRelationships(): Array; /** * Runs get relationships map. * @returns {Record} - Relationship definitions keyed by name. */ static getRelationshipsMap(): Record; /** * Runs get relationship names. * @returns {Array} - The relationship names. */ static getRelationshipNames(): Array; /** * Register a consumer-defined queryData entry. The callback receives * a grouped query already joined down the relationship chain from the * root of `.queryData(...)` to this model, already filtered by the * root parent IDs, and with `parent_id` pre-selected — so the fn * only needs to add its own SELECT (and optionally joins/where). Any * aliases the fn selects are attached to each **root** record via * `record.queryData(aliasName)`. Multi-column selects are fine — one * alias maps to one queryData key. * * **Quote AS aliases on PostgreSQL.** PostgreSQL folds unquoted * identifiers (including SELECT aliases) to lowercase, so a * `... AS manualTasksCount` lands in the result row as * `manualtaskscount` while the lookup `record.queryData("manualTasksCount")` * never finds it. Use `driver.quoteColumn("manualTasksCount")` for the * alias to preserve the case on every supported driver: * query.select(`COUNT(...) AS ${driver.quoteColumn("manualTasksCount")}`) * @param {string} name - Identifier used in the `.queryData(...)` spec. * @param {import("../query/query-data.js").QueryDataFn} fn - Callback that mutates the query. * @returns {void} */ static queryData(name: string, fn: import("../query/query-data.js").QueryDataFn): void; /** * Runs get query data map. * @returns {Record} - queryData registrations keyed by name. */ static getQueryDataMap(): Record; /** * Runs get query data by name. * @param {string} name - queryData name. * @returns {import("../query/query-data.js").QueryDataFn | null} - Registered fn or null when not found. */ static getQueryDataByName(name: string): import("../query/query-data.js").QueryDataFn | null; /** * Runs get attachments. * @returns {Record} - Attachment definitions. */ static getAttachments(): Record; /** * Returns attachment definitions through the model contract shared with * frontend model classes. * @returns {Record} - Attachment definitions. */ static attachmentDefinitions(): Record; /** * Runs get attachment by name. * @param {string} attachmentName - Attachment name. * @returns {RecordAttachmentConfiguration} - Attachment definition. */ static getAttachmentByName(attachmentName: string): RecordAttachmentConfiguration; /** * Runs get relationship by name. * @param {string} relationshipName - Relationship name. * @returns {import("./instance-relationships/base.js").default} - The relationship by name. */ getRelationshipByName(relationshipName: string): import("./instance-relationships/base.js").default; /** * Preloads relationship(s) onto this already-loaded record. Accepts either a * query built via `Model.preload(...).select(...)` or a raw preload spec * (string / array / nested object). A relationship that is already preloaded * with all the required columns present is left untouched unless `force` is * set. Preloading onto the relationship cache lets later accessors reuse the * loaded data instead of issuing identical queries. * @param {import("../query/model-class-query.js").default | import("../query/index.js").NestedPreloadRecord | string | Array} queryOrSpec - Preload source. * @param {{force?: boolean}} [options] - Options. * @returns {Promise} - Resolves when preloading completes. */ preload(queryOrSpec: import("../query/model-class-query.js").default | import("../query/index.js").NestedPreloadRecord | string | Array, options?: { force?: boolean; }): Promise; /** * Runs load relationship. * @param {string} relationshipName - Relationship name. * @returns {Promise>} - Loaded relationship value. */ loadRelationship(relationshipName: string): Promise>; /** * Runs relationship or load. * @param {string} relationshipName - Relationship name. * @param {{preloadTranslations?: boolean}} [options] - Load options. * @returns {Promise>} - Loaded relationship value. */ relationshipOrLoad(relationshipName: string, options?: { preloadTranslations?: boolean; }): Promise>; /** * Preloads translations on a loaded relationship target when explicitly requested. * @param {ReturnType} loaded - Loaded relationship value. * @returns {Promise>} - Relationship value after translation preload. */ _preloadLoadedRelationshipTranslations(loaded: ReturnType): Promise>; /** * Runs get attachment by name. * @param {string} attachmentName - Attachment name. * @returns {RecordAttachmentHandle} - Attachment handle. */ getAttachmentByName(attachmentName: string): RecordAttachmentHandle; /** * Adds a belongs-to-relationship to the model. * @param {string} relationshipName The name of the relationship. * @param {RelationshipScopeCallback | object} [scopeOrOptions] The scope callback or options for the relationship. * @param {object} [options] The options for the relationship. */ static belongsTo(relationshipName: string, scopeOrOptions?: RelationshipScopeCallback | object, options?: object): void; /** * Runs connection. * @param {object} [args] - Options. * @param {boolean} [args.enforceTenantDatabaseScope] - Whether tenant-switched models must resolve a tenant database identifier. * @returns {import("../drivers/base.js").default} - The connection. */ static connection({ enforceTenantDatabaseScope, ...restArgs }?: { enforceTenantDatabaseScope?: boolean; }): import("../drivers/base.js").default; /** * Runs create. * @template {Record>} CreateAttributes * @template {VelociousDatabaseRecord} Model * @this {{new (changes?: CreateAttributes): Model} & typeof VelociousDatabaseRecord} * @param {CreateAttributes} [attributes] - Attributes. * @returns {Promise} - Resolves with the create. */ static create>, Model extends VelociousDatabaseRecord>(this: { new (changes?: CreateAttributes): Model; } & typeof VelociousDatabaseRecord, attributes?: CreateAttributes): Promise; /** * Runs get configuration. * @returns {import("../../configuration.js").default} - The configuration. */ static _getConfiguration(): import("../../configuration.js").default; /** * Runs get configuration. * @returns {import("../../configuration.js").default} - The configuration. */ _getConfiguration(): import("../../configuration.js").default; /** * Adds a has-many-relationship to the model class. * @param {string} relationshipName The name of the relationship (e.g. "posts") * @param {RelationshipScopeCallback | object} [scopeOrOptions] The scope callback or options for the relationship. * @param {object} [options] The options for the relationship (e.g. {className: "Post"}) * @returns {void} - No return value. */ static hasMany(relationshipName: string, scopeOrOptions?: RelationshipScopeCallback | object, options?: object): void; /** * Rails-style declaration that this model accepts nested-attribute writes * for a relationship when saved through a parent. Required — Velocious * will refuse nested writes for any relationship not listed here, even * if a frontend-model resource permits them. * * Options: * - allowDestroy: whether `_destroy: true` entries are allowed. Default false. * - limit: optional upper bound on the number of nested entries per request. * - rejectIf: optional predicate `(attributes) => boolean` that silently skips entries. * * Usage: * class Project extends Record {} * Project.hasMany("tasks") * Project.acceptsNestedAttributesFor("tasks", {allowDestroy: true}) * @param {string} relationshipName - Relationship name on this model. * @param {{allowDestroy?: boolean, limit?: number, rejectIf?: (attributes: Record>) => boolean}} [options] - Policy options. * @returns {void} */ static acceptsNestedAttributesFor(relationshipName: string, options?: { allowDestroy?: boolean; limit?: number; rejectIf?: (attributes: Record>) => boolean; }): void; /** * Runs accepted nested attributes for. * @param {string} relationshipName - Relationship name. * @returns {{allowDestroy?: boolean, limit?: number, rejectIf?: (attributes: Record>) => boolean} | null} - Policy declared via `acceptsNestedAttributesFor`, or null when not accepted. */ static acceptedNestedAttributesFor(relationshipName: string): { allowDestroy?: boolean; limit?: number; rejectIf?: (attributes: Record>) => boolean; } | null; /** * Adds a has-one-relationship to the model class. * @param {string} relationshipName The name of the relationship (e.g. "post") * @param {RelationshipScopeCallback | object} [scopeOrOptions] The scope callback or options for the relationship. * @param {object} [options] The options for the relationship (e.g. {className: "Post"}) * @returns {void} - No return value. */ static hasOne(relationshipName: string, scopeOrOptions?: RelationshipScopeCallback | object, options?: object): void; /** * Runs define attachment. * @param {string} attachmentName - Attachment name. * @param {object} args - Attachment args. * @param {string | AttachmentDriverConstructor | Record>} [args.driver] - Attachment driver name, class, or instance. * @param {AttachmentSyncConfiguration} [args.sync] - Client-safe synchronized asset policy. * @param {"hasOne" | "hasMany"} args.type - Attachment type. * @returns {void} - No return value. */ static _defineAttachment(attachmentName: string, { driver, sync, type }: { driver?: string | AttachmentDriverConstructor | Record>; sync?: AttachmentSyncConfiguration; type: "hasOne" | "hasMany"; }): void; /** * Adds a single attachment helper to the model. * @param {string} attachmentName - Attachment name. * @param {{driver?: string | AttachmentDriverConstructor | Record>, sync?: AttachmentSyncConfiguration}} [args] - Attachment options. * @returns {void} - No return value. */ static hasOneAttachment(attachmentName: string, args?: { driver?: string | AttachmentDriverConstructor | Record>; sync?: AttachmentSyncConfiguration; }): void; /** * Adds a collection attachment helper to the model. * @param {string} attachmentName - Attachment name. * @param {{driver?: string | AttachmentDriverConstructor | Record>, sync?: AttachmentSyncConfiguration}} [args] - Attachment options. * @returns {void} - No return value. */ static hasManyAttachments(attachmentName: string, args?: { driver?: string | AttachmentDriverConstructor | Record>; sync?: AttachmentSyncConfiguration; }): void; /** * Runs human attribute name. * @param {string} attributeName - Attribute name. * @returns {string} - The human attribute name. */ static humanAttributeName(attributeName: string): string; /** * Runs get database type. * @returns {string} - The database type. */ static getDatabaseType(): string; /** * Runs set eager load record metadata. * @param {boolean} eagerLoadRecordMetadata - Whether require-context initialization should load table metadata for this model. * @returns {void} - No return value. */ static setEagerLoadRecordMetadata(eagerLoadRecordMetadata: boolean): void; /** * Runs get eager load record metadata. * @returns {boolean} - Whether require-context initialization should load table metadata for this model. */ static getEagerLoadRecordMetadata(): boolean; /** * Runs reset record metadata. * @returns {void} - No return value. */ static resetRecordMetadata(): void; /** * Static fields that belong to one physical database/schema generation. * @returns {Set} - Metadata property names. */ static recordMetadataPropertyNames(): Set; /** * Reads one operation-bound metadata field. * @param {string} metadataKey - Physical database and schema generation key. * @param {string} property - Static metadata property. * @returns {RecordMetadataValue} - Stored metadata value. */ static recordMetadataValue(metadataKey: string, property: string): RecordMetadataValue; /** * Writes one operation-bound metadata field. * @param {string} metadataKey - Physical database and schema generation key. * @param {string} property - Static metadata property. * @param {RecordMetadataValue} value - Metadata value. * @returns {void} */ static setRecordMetadataValue(metadataKey: string, property: string, value: RecordMetadataValue): void; /** Clears every tenant/generation metadata snapshot for this model. */ static clearRecordMetadataValues(): void; /** * Clears snapshots whose key belongs to one physical database identity. * @param {string} databaseIdentity - Logical identifier plus pool reuse key. * @returns {void} */ static clearRecordMetadataValuesForDatabaseIdentity(databaseIdentity: string): void; /** * Registers the model class with a configuration without loading table metadata. * @param {object} args - Options object. * @param {import("../../configuration.js").default} args.configuration - Configuration instance. * @returns {void} - No return value. */ static registerRecordClass({ configuration, ...restArgs }: { configuration: import("../../configuration.js").default; }): void; /** * Runs initialize record. * @param {object} args - Options object. * @param {import("../../configuration.js").default} args.configuration - Configuration instance. * @param {import("../drivers/base.js").default} [args.connection] - Explicit metadata connection. * @returns {Promise} - Resolves when complete. */ static initializeRecord({ configuration, connection: explicitConnection, ...restArgs }: { configuration: import("../../configuration.js").default; connection?: import("../drivers/base.js").default; }): Promise; /** * Initializes the model class the first time an async record API needs table * metadata. Concurrent callers share the same initialization promise, and a * failed initialization can be retried by a later call. * @param {{configuration?: import("../../configuration.js").default, connection?: import("../drivers/base.js").default}} [args] - Optional configuration and explicit metadata connection. * @returns {Promise} - Resolves when the model class is initialized. */ static ensureInitialized(args?: { configuration?: import("../../configuration.js").default; connection?: import("../drivers/base.js").default; }): Promise; /** * Runs has attribute. * @param {ReturnType} value - Value to use. * @returns {boolean} - Whether attribute. */ _hasAttribute(value: ReturnType): boolean; /** * Runs is initialized. * @returns {boolean} - Whether initialized. */ static isInitialized(): boolean; /** * Runs assert has been initialized. * @returns {void} - No return value. */ static _assertHasBeenInitialized(): void; /** * Defines translation accessors and initializes the generated translation * class through the same metadata connection as the translated model. * @param {import("../drivers/base.js").default} connection - Metadata connection. * @returns {Promise} - Resolves when translation metadata is ready. */ static _defineTranslationMethods(connection: import("../drivers/base.js").default): Promise; /** * Runs get configured database identifier. * @returns {string} - The configured non-tenant database identifier. */ static getConfiguredDatabaseIdentifier(): string; /** * Runs get database identifier. * @param {object} [args] - Options. * @param {boolean} [args.enforceTenantDatabaseScope] - Whether tenant-switched models must resolve a tenant database identifier. * @param {object} [args.tenant] - Explicit tenant descriptor instead of the ambient tenant. * @returns {string} - The database identifier. */ static getDatabaseIdentifier({ enforceTenantDatabaseScope, tenant, ...restArgs }?: { enforceTenantDatabaseScope?: boolean; tenant?: object; }): string; /** * Runs set database identifier. * @param {string} databaseIdentifier - Database identifier. * @returns {void} - No return value. */ static setDatabaseIdentifier(databaseIdentifier: string): void; /** * Declares a tenant-aware database identifier resolver for this model class. * @param {string | ((args: {modelClass: typeof VelociousDatabaseRecord, tenant: Record | null | undefined}) => string | undefined)} databaseIdentifierOrResolver - Static identifier or resolver. * @returns {void} - No return value. */ static switchesTenantDatabase(databaseIdentifierOrResolver: string | ((args: { modelClass: typeof VelociousDatabaseRecord; tenant: Record | null | undefined; }) => string | undefined)): void; /** * Runs has tenant database identifier resolver. * @returns {boolean} - Whether this model resolves its database from the current tenant. */ static hasTenantDatabaseIdentifierResolver(): boolean; /** * Runs get tenant database identifier. * @param {ReturnType} [tenant] - Tenant override. * @returns {string | undefined} - Tenant-scoped database identifier when configured. */ static getTenantDatabaseIdentifier(tenant?: ReturnType): string | undefined; /** * Runs get attribute. * @param {string} name - Name. * @returns {ReturnType} - The attribute. */ getAttribute(name: string): ReturnType; /** * Runs get model class. * @abstract * @returns {typeof VelociousDatabaseRecord} - The model class. */ getModelClass(): typeof VelociousDatabaseRecord; /** * Runs set attribute. * @param {string} name - Name. * @param {ReturnType} newValue - New value. * @returns {void} - No return value. */ setAttribute(name: string, newValue: ReturnType): void; /** * Runs set column attribute. * @param {string} name - Name. * @param {ReturnType} newValue - New value. */ _setColumnAttribute(name: string, newValue: ReturnType): void; /** * Clears loaded belongs-to caches when callers assign the foreign key directly. * @param {string} columnName - Changed database column name. * @param {ReturnType} normalizedValue - New normalized column value. * @returns {void} - No return value. */ _clearBelongsToRelationshipForChangedForeignKey(columnName: string, normalizedValue: ReturnType): void; /** * Runs belongs to relationships for foreign key. * @param {string} columnName - Changed database column name. * @returns {Array>} - Loaded relationship instances that use the changed foreign key. */ _belongsToRelationshipsForForeignKey(columnName: string): Array>; /** * Runs belongs to relationship uses foreign key. * @param {object} args - Relationship match arguments. * @param {string} args.columnName - Changed database column name. * @param {ReturnType} args.relationship - Relationship instance. * @returns {boolean} - Whether the relationship is a belongs-to using the changed foreign key. */ _belongsToRelationshipUsesForeignKey({ columnName, relationship }: { columnName: string; relationship: ReturnType; }): boolean; /** * Runs belongs to relationship matches foreign key value. * @param {object} args - Relationship cache arguments. * @param {ReturnType} args.normalizedValue - New normalized column value. * @param {ReturnType} args.relationship - Relationship instance. * @returns {boolean} - Whether the loaded related record still matches the changed foreign key. */ _belongsToRelationshipMatchesForeignKeyValue({ normalizedValue, relationship }: { normalizedValue: ReturnType; relationship: ReturnType; }): boolean; /** * Returns the foreign key value for a belongs-to relationship assignment. * @param {object} args - Relationship assignment arguments. * @param {VelociousDatabaseRecord | null | undefined} args.model - Assigned model. * @param {import("./instance-relationships/base.js").default} args.relationship - Belongs-to relationship instance. * @returns {string | number | null | undefined} - Foreign key value for the assignment. */ _belongsToForeignKeyValue({ model, relationship }: { model: VelociousDatabaseRecord | null | undefined; relationship: import("./instance-relationships/base.js").default; }): string | number | null | undefined; /** * Runs clear loaded belongs to relationship. * @param {ReturnType} relationship - Relationship instance. * @returns {void} - No return value. */ _clearLoadedBelongsToRelationship(relationship: ReturnType): void; /** * Runs normalize date value. * @param {ReturnType} value - Value to use. * @returns {ReturnType} - The date value. */ _normalizeDateValue(value: ReturnType): ReturnType; /** * Runs normalize sqlite boolean value. * @param {object} args - Options object. * @param {string | undefined} args.columnType - Column type. * @param {ReturnType} args.value - Value to normalize. * @returns {ReturnType} - Normalized value. */ _normalizeSqliteBooleanValue({ columnType, value }: { columnType: string | undefined; value: ReturnType; }): ReturnType; /** * Normalizes a boolean value before storing. A declared `"boolean"` attribute cast stores * booleans as 1/0 only for integer-backed columns (e.g. an MSSQL `bit`). Columns whose * underlying type is already a native boolean (e.g. Postgres `boolean`) keep `true`/`false` * so the driver can emit the proper boolean literal; otherwise the sqlite-only normalizer applies. * @param {object} args - Options object. * @param {string} args.attributeName - Attribute name being written. * @param {string | undefined} args.columnType - Column type. * @param {ReturnType} args.value - Value to normalize. * @returns {ReturnType} - Normalized value. */ _normalizeBooleanValueForWrite({ attributeName, columnType, value }: { attributeName: string; columnType: string | undefined; value: ReturnType; }): ReturnType; /** * Whether a declared `"boolean"` attribute cast is backed by an integer column (e.g. an MSSQL * `bit`), so booleans must be stored as 1/0. A native boolean column (e.g. Postgres `boolean`) * returns false and keeps `true`/`false` for the driver. * @param {string} attributeName - Attribute name. * @returns {boolean} - Whether the declared boolean is stored as an integer. */ static _declaredBooleanStoresAsInteger(attributeName: string): boolean; /** * Runs get columns. * @returns {import("../drivers/base-column.js").default[]} - The columns. */ static getColumns(): import("../drivers/base-column.js").default[]; /** * Runs get columns hash. * @returns {Record} - The columns hash. */ static getColumnsHash(): Record; /** * Runs get column type by name. * @param {string} name - Name. * @returns {string | undefined} - The column type by name. */ static getColumnTypeByName(name: string): string | undefined; /** * Runs is date like type. * @param {string} type - Type identifier. * @returns {boolean} - Whether date like type. */ static _isDateLikeType(type: string): boolean; /** * Runs get column names. * @returns {Array} - The column names. */ static getColumnNames(): Array; /** * Runs get table. * @returns {import("../drivers/base-table.js").default} - The table. */ static _getTable(): import("../drivers/base-table.js").default; /** * Runs insert multiple. * @param {Array} columns - Column names. * @param {Array>>} rows - Rows to insert. * @param {object} [args] - Options object. * @param {boolean} [args.cast] - Whether to cast values based on column types. * @param {boolean} [args.retryIndividuallyOnFailure] - Retry rows individually if a batch insert fails. * @param {boolean} [args.returnResults] - Return succeeded/failed rows instead of throwing when retries fail. * @returns {Promise>>, failedRows: Array>>, errors: Array<{row: Array>, error: ReturnType}>}>} - Resolves when complete. */ static insertMultiple(columns: Array, rows: Array>>, args?: { cast?: boolean; retryIndividuallyOnFailure?: boolean; returnResults?: boolean; }): Promise>>; failedRows: Array>>; errors: Array<{ row: Array>; error: ReturnType; }>; }>; /** * Runs normalize insert multiple rows. * @param {object} args - Options object. * @param {Array} args.columns - Column names. * @param {Array>>} args.rows - Rows to insert. * @returns {Array>>} - Normalized rows. */ static _normalizeInsertMultipleRows({ columns, rows }: { columns: Array; rows: Array>>; }): Array>>; /** * Runs safe serialize insert row. * @param {Array>} row - Row to serialize. * @returns {string} - Safe row representation. */ static _safeSerializeInsertRow(row: Array>): string; /** * Runs normalize insert value for column. * @param {object} args - Options object. * @param {string} args.columnName - Column name. * @param {ReturnType} args.value - Column value. * @returns {ReturnType} - Normalized value. */ static _normalizeInsertValueForColumn({ columnName, value }: { columnName: string; value: ReturnType; }): ReturnType; /** * Runs is string type. * @param {string | undefined} columnType - Column type. * @returns {boolean} - Whether string-like type. */ static _isStringType(columnType: string | undefined): boolean; /** * Runs is numeric type. * @param {string} columnType - Column type. * @returns {boolean} - Whether numeric-like type. */ static _isNumericType(columnType: string): boolean; /** * Runs normalize numeric value. * @param {object} args - Options object. * @param {string} args.columnType - Column type. * @param {ReturnType} args.value - Value to normalize. * @returns {ReturnType} - Normalized value. */ static _normalizeNumericValue({ columnType, value }: { columnType: string; value: ReturnType; }): ReturnType; /** * Runs normalize date value for insert. * @param {ReturnType} value - Value to normalize. * @returns {ReturnType} - Normalized value. */ static _normalizeDateValueForInsert(value: ReturnType): ReturnType; /** * Runs normalize date string for insert. * @param {string} value - Date string value. * @returns {string | Date} - Parsed date or original string. */ static _normalizeDateStringForInsert(value: string): string | Date; /** * Runs time zone for date writes. * @returns {string | undefined} - Active timezone identifier. */ static _timeZoneForDateWrite(): string | undefined; /** * Runs normalize sqlite boolean value for insert. * @param {object} args - Options object. * @param {string | undefined} args.columnType - Column type. * @param {ReturnType} args.value - Value to normalize. * @returns {ReturnType} - Normalized value. */ static _normalizeSqliteBooleanValueForInsert({ columnType, value }: { columnType: string | undefined; value: ReturnType; }): ReturnType; /** * Runs next primary key. * @returns {Promise} - Resolves with the next primary key. */ static nextPrimaryKey(): Promise; /** * Runs set primary key. * @param {string | string[] | null} primaryKey - Primary key. * @returns {void} - No return value. */ static setPrimaryKey(primaryKey: string | string[] | null): void; /** * Returns this class's own attribute-cast map, creating it on the class itself * (never inherited from a parent) so subclasses don't share the same object. * @returns {Record} - Declared casts keyed by attribute name. */ static getAttributeCastsMap(): Record; /** * Declares a Rails-style per-attribute cast so a column whose introspected type * isn't what the app wants (e.g. an MSSQL `bit` mapped to `number`) can be * exposed as another type with real runtime conversion. Currently fully * implements the `"boolean"` cast (0/1 <-> false/true); other types only record * the label so the effective type and generated typings reflect them. * @param {string} attributeName - Attribute name (camelCase), e.g. `"sichtbarVVK"`. * @param {string} type - Declared type, e.g. `"boolean"`. * @returns {void} - No return value. */ static attribute(attributeName: string, type: string): void; /** * Returns the declared cast type for an attribute, if any. * @param {string} attributeName - Attribute name (camelCase). * @returns {string | undefined} - Declared cast type, or undefined when none is declared. */ static getAttributeCast(attributeName: string): string | undefined; /** * Runs primary key. * @returns {string | string[]} - The primary key. */ static primaryKey(): string | string[]; /** * Whether the model has a single primary key column. `setPrimaryKey(null)` (e.g. composite-key * legacy tables) declares no single primary key; `primaryKey()` still falls back to "id" for the * default case, so callers that must distinguish "no primary key" use this instead. * @returns {boolean} - False only when the primary key was explicitly set to null. */ static hasPrimaryKey(): boolean; /** * Runs save. * @returns {Promise} - Resolves when complete. */ save(): Promise; _autoSaveBelongsToRelationships(): Promise<{ savedCount: number; }>; _autoSaveHasManyAndHasOneRelationshipsToSave(): import("./instance-relationships/base.js").default[]; /** * Resolves a relationship foreign-key column to this model's public attribute name. * @param {import("./instance-relationships/base.js").default} instanceRelationship - Relationship instance. * @returns {string} Attribute name accepted by setAttribute/assign. */ _relationshipForeignKeyAttribute(instanceRelationship: import("./instance-relationships/base.js").default): string; /** * Runs auto save has many and has one relationships. * @param {object} args - Options object. * @param {boolean} args.isNewRecord - Whether is new record. */ _autoSaveHasManyAndHasOneRelationships({ isNewRecord }: { isNewRecord: boolean; }): Promise; /** * Runs auto save attachments. * @returns {Promise} - Resolves when pending attachments have been saved. */ _autoSaveAttachments(): Promise; /** * Runs table name. * @returns {string} - The table name. */ static tableName(): string; /** * Runs set table name. * @param {string} tableName - Table name. * @returns {void} - No return value. */ static setTableName(tableName: string): void; /** * Runs transaction. * @param {() => Promise} callback - Callback function. * @returns {Promise>} - Resolves with the transaction. */ static transaction(callback: () => Promise): Promise>; /** * Prepares this model's attachment store before opening a model transaction. * @param {import("../drivers/base.js").default} connection - Model connection. * @returns {Promise} - Resolves when the attachment schema is current. */ static _prepareAttachmentStoreSchema(connection: import("../drivers/base.js").default): Promise; /** * Runs the callback while holding a named advisory lock. Calls without * By default calls use the caller connection. Calls with `dedicatedConnection` * use a spawned lock connection that is released after the callback finishes, * while the callback itself still runs against the caller/model connection. * Calls with a positive `holdTimeoutMs` use a dedicated lock connection so * timeout cleanup can release the lock even when callback database work is * stuck. Advisory locks are cooperative and session-scoped: they serialize * callers that opt into the same `name`, without touching row or table locks, * so unrelated traffic is free to proceed. * * The lock is acquired before the callback runs and released in a * `finally` block afterwards, so the callback's return value is * propagated and thrown errors still release the lock. * @template T * @param {string} name - Lock name. * @param {() => Promise} callback - Callback to invoke while the lock is held. * @param {{timeoutMs?: number | null, holdTimeoutMs?: number | null, dedicatedConnection?: boolean}} [args] - `timeoutMs` caps how long we wait to acquire the lock; `holdTimeoutMs` caps how long the callback may hold it before the lock is released and `AdvisoryLockHoldTimeoutError` is thrown; `dedicatedConnection` spawns a separate lock session without enabling a hold timeout. * @returns {Promise} - Resolves with the callback's return value. * @throws {AdvisoryLockTimeoutError} - If `timeoutMs` elapses before the lock is granted. * @throws {AdvisoryLockHoldTimeoutError} - If `holdTimeoutMs` elapses while the callback holds the lock. */ static withAdvisoryLock(name: string, callback: () => Promise, args?: { timeoutMs?: number | null; holdTimeoutMs?: number | null; dedicatedConnection?: boolean; }): Promise; /** * Runs the callback only if the named advisory lock can be acquired * immediately. If the lock is already held by any session, throws * `AdvisoryLockBusyError` without waiting. * Use this when contention is a signal that somebody else is already * doing the work and you want to bail out rather than queue up. * @template T * @param {string} name - Lock name. * @param {() => Promise} callback - Callback to invoke while the lock is held. * @param {{holdTimeoutMs?: number | null, dedicatedConnection?: boolean}} [args] - `holdTimeoutMs` caps how long the callback may hold the lock before it is released and `AdvisoryLockHoldTimeoutError` is thrown; `dedicatedConnection` spawns a separate lock session without enabling a hold timeout. * @returns {Promise} - Resolves with the callback's return value. * @throws {AdvisoryLockBusyError} - If the lock is already held. * @throws {AdvisoryLockHoldTimeoutError} - If `holdTimeoutMs` elapses while the callback holds the lock. */ static withAdvisoryLockOrFail(name: string, callback: () => Promise, args?: { holdTimeoutMs?: number | null; dedicatedConnection?: boolean; }): Promise; /** * Runs `callback`, rejecting with `AdvisoryLockHoldTimeoutError` if it has * not settled within `holdTimeoutMs`. The callback is not cancelled — this is * a safety net, not cancellation. * @template T * @param {string} name - Lock name (for the error message). * @param {() => Promise} callback - Callback holding the lock. * @param {number | null} [holdTimeoutMs] - Max hold time; falsy disables the timeout. * @returns {Promise} - Callback result after the lock-protected operation. */ static runWithAdvisoryLockHoldTimeout(name: string, callback: () => Promise, holdTimeoutMs?: number | null): Promise; /** * Returns true if the named advisory lock is currently held by any * session. Primarily useful as a diagnostic; callers that want to act * on the result should prefer `withAdvisoryLockOrFail` to avoid a * TOCTOU window between the check and the action. * @param {string} name - Lock name. * @returns {Promise} - Whether the advisory lock is currently held. */ static hasAdvisoryLock(name: string): Promise; /** * Runs translates. * @param {...string} names - Names. * @returns {void} - No return value. */ static translates(...names: string[]): void; /** * Runs current translation scope. * @param {ModelClassQuery} query - Translation query. * @returns {ModelClassQuery} - Scoped query. */ static currentTranslationScope(query: ModelClassQuery): ModelClassQuery; /** * Runs get translation class. * @returns {typeof VelociousDatabaseRecord} - The translation class. */ static getTranslationClass(): typeof VelociousDatabaseRecord; /** * Runs get translations table name. * @returns {string} - The translations table name. */ static getTranslationsTableName(): string; /** * Runs has translations table. * @returns {Promise} - Resolves with Whether it has translations table. */ static hasTranslationsTable(): Promise; /** * Adds a validation to an attribute. * @param {string} attributeName The name of the attribute to validate. * @param {Record>>} validators The validators to add. Key is the validator name, value is the validator arguments. */ static validates(attributeName: string, validators: Record>>): Promise; /** * Registers gap-less positional list callbacks for a column scoped by * another column. Inserts and moves shift surrounding positions so the * list stays compact (1,2,3,...). Destroys close the resulting gap. * * Callers must ensure a UNIQUE index on (scopeColumn, positionColumn) * exists in the database — use `Migration.addActsAsList()` for the * schema half. * @param {string} positionColumn - camelCase position attribute (e.g. "rowNumber"). * @param {object} options - Options with a required scope attribute. * @param {string} options.scope - camelCase scope attribute (e.g. "boardColumnId"). */ static actsAsList(positionColumn: string, options: { scope: string; }): void; /** * Runs translations loaded. * @abstract * @returns {TranslationBase[]} - The translations loaded. */ translationsLoaded(): TranslationBase[]; /** * Runs get translated attribute. * @param {string} name - Name. * @param {string} locale - Locale. * @returns {string | undefined} - The translated attribute, if found. */ _getTranslatedAttribute(name: string, locale: string): string | undefined; /** * Runs get translated attribute with fallback. * @param {string} name - Name. * @param {string} locale - Locale. * @returns {string | undefined} - The translated attribute with fallback, if found. */ _getTranslatedAttributeWithFallback(name: string, locale: string): string | undefined; /** * Runs set translated attribute. * @param {string} name - Name. * @param {string} locale - Locale. * @param {ReturnType} newValue - New value. * @returns {void} - No return value. */ _setTranslatedAttribute(name: string, locale: string, newValue: ReturnType): void; /** * Runs new query. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {{driver?: import("../drivers/base.js").default | (() => import("../drivers/base.js").default), operation?: import("../operation.js").default}} [args] - Explicit query ownership. * @returns {ModelClassQuery} - The new query. */ static _newQuery(this: MC, args?: { driver?: import("../drivers/base.js").default | (() => import("../drivers/base.js").default); operation?: import("../operation.js").default; }): ModelClassQuery; /** * Runs orderable column. * @returns {string} - The orderable column. */ static orderableColumn(): string; /** * Runs all. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @returns {ModelClassQuery} - The all. */ static all(this: MC): ModelClassQuery; /** * Runs accessible for. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {string} action - Ability action to scope by. * @param {import("../../authorization/ability.js").default | undefined} [ability] - Ability instance. * @returns {ModelClassQuery} - Authorized query. */ static accessibleFor(this: MC, action: string, ability?: import("../../authorization/ability.js").default | undefined): ModelClassQuery; /** * Runs accessible. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../../authorization/ability.js").default | undefined} [ability] - Ability instance. * @returns {ModelClassQuery} - Authorized query. */ static accessible(this: MC, ability?: import("../../authorization/ability.js").default | undefined): ModelClassQuery; /** * Runs accessible by. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../../authorization/ability.js").default} ability - Ability instance. * @returns {ModelClassQuery} - Authorized query. */ static accessibleBy(this: MC, ability: import("../../authorization/ability.js").default): ModelClassQuery; /** * Runs count. * @returns {Promise} - Resolves with the count. */ static count(): Promise; /** * Runs group. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {string} group - Group. * @returns {ModelClassQuery} - The group. */ static group(this: MC, group: string): ModelClassQuery; static destroyAll(): Promise; /** * Runs pluck. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {...string|string[]} columns - Column names. * @returns {Promise>>} - Resolves with the pluck. */ static pluck(this: MC, ...columns: (string | string[])[]): Promise>>; /** * Runs find. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../../utils/model-primary-key.js").ModelPrimaryKeyValue} recordId - Record id. * @returns {Promise>} - Resolves with the find. */ static find(this: MC, recordId: import("../../utils/model-primary-key.js").ModelPrimaryKeyValue): Promise>; /** * Runs find by. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {{[key: string]: string | number}} conditions - Conditions hash keyed by attribute name. * @returns {Promise | null>} - Resolves with the by. */ static findBy(this: MC, conditions: { [key: string]: string | number; }): Promise | null>; /** * Runs find by or fail. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {{[key: string]: string | number}} conditions - Conditions hash keyed by attribute name. * @returns {Promise>} - Resolves with the by or fail. */ static findByOrFail(this: MC, conditions: { [key: string]: string | number; }): Promise>; /** * Returns an immutable tenant-bound model scope. Eager helpers and explicit * databaseOperation/transaction callbacks execute from a captured physical * database configuration instead of ambient tenant state. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {object} tenant - Ordinary or null-prototype JSON-compatible tenant descriptor to scope the model to. * @returns {TenantModelScope} - Model scope bound to the captured tenant database. */ static usingTenant(this: MC, tenant: object): TenantModelScope; /** * Runs find or create by. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {{[key: string]: string | number}} conditions - Conditions hash keyed by attribute name. * @param {() => void} [callback] - Callback function. * @returns {Promise>} - Resolves with the or create by. */ static findOrCreateBy(this: MC, conditions: { [key: string]: string | number; }, callback?: () => void): Promise>; /** * Runs find or initialize by. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {Record} conditions - Conditions. * @param {(arg: InstanceType) => void} [callback] - Callback function. * @returns {Promise>} - Resolves with the or initialize by. */ static findOrInitializeBy(this: MC, conditions: Record, callback?: (arg: InstanceType) => void): Promise>; /** * Runs first. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @returns {Promise>} - Resolves with the first. */ static first(this: MC): Promise>; /** * Runs joins. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {string | import("../query/join-object.js").JoinObject} join - Join clause or join descriptor. * @returns {ModelClassQuery} - The joins. */ static joins(this: MC, join: string | import("../query/join-object.js").JoinObject): ModelClassQuery; /** * Runs last. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @returns {Promise>} - Resolves with the last. */ static last(this: MC): Promise>; /** * Runs limit. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {number} value - Value to use. * @returns {ModelClassQuery} - The limit. */ static limit(this: MC, value: number): ModelClassQuery; /** * Runs order. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../query/index.js").OrderArgumentType} order - Order. * @returns {ModelClassQuery} - The order. */ static order(this: MC, order: import("../query/index.js").OrderArgumentType): ModelClassQuery; /** * Runs distinct. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {boolean} [value] - Value to use. * @returns {ModelClassQuery} - The distinct. */ static distinct(this: MC, value?: boolean): ModelClassQuery; /** * Runs preload. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../query/index.js").NestedPreloadRecord | string | Array} preload - Preload. * @returns {ModelClassQuery} - The preload. */ static preload(this: MC, preload: import("../query/index.js").NestedPreloadRecord | string | Array): ModelClassQuery; /** * Runs select. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../query/index.js").SelectArgumentType} select - Select. * @returns {ModelClassQuery} - The select. */ static select(this: MC, select: import("../query/index.js").SelectArgumentType): ModelClassQuery; /** * Runs to array. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @returns {Promise[]>} - Resolves with the array. */ static toArray(this: MC): Promise[]>; /** * Runs load. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @returns {Promise[]>} - Resolves with the array. */ static load(this: MC): Promise[]>; /** * Runs where. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {import("../query/index.js").WhereArgumentType} where - Where. * @returns {ModelClassQuery} - The where. */ static where(this: MC, where: import("../query/index.js").WhereArgumentType): ModelClassQuery; /** * Runs ransack. * @template {typeof VelociousDatabaseRecord} MC * @this {MC} * @param {Record>} params - Ransack-style params hash. * @returns {ModelClassQuery} - Query with Ransack filters applied. */ static ransack(this: MC, params: Record>): ModelClassQuery; /** * Runs constructor. * @param {WriteAttributes} changes - Changes. */ constructor(changes?: WriteAttributes); /** * Binds future query, lifecycle, relationship, and persistence work to an operation. * @param {import("../operation.js").default} operation - Owning operation. * @returns {this} - Bound record. */ bindDatabaseOperation(operation: import("../operation.js").default): this; /** * Captures and validates the physical database identity that owns this record. * @param {string} databaseIdentity - Opaque operation/connection identity. * @returns {this} This record. */ captureDatabaseIdentity(databaseIdentity: string): this; /** * Returns the captured physical database identity. * @returns {string | undefined} Captured physical database identity. */ databaseIdentity(): string | undefined; /** * Releases this record from a completed eager-helper operation while * preserving the legacy ambient follow-up behavior of `usingTenant` finders. * @param {import("../operation.js").default} operation - Releasing operation. * @returns {this} - Record. */ releaseDatabaseOperation(operation: import("../operation.js").default): this; /** * Returns the explicit operation owning this record, if any. * @returns {import("../operation.js").default | undefined} - Owning operation. */ databaseOperation(): import("../operation.js").default | undefined; /** * Binds a related record to the same operation as this record. * @template {VelociousDatabaseRecord} Model * @param {Model} record - Related record. * @returns {Model} - Related record. */ bindRelatedRecord(record: Model): Model; /** * Builds a model query preserving this record's operation ownership. * @template {typeof VelociousDatabaseRecord} MC * @param {MC} ModelClass - Target model class. * @returns {ModelClassQuery} - Target query. */ queryForModel(ModelClass: MC): ModelClassQuery; /** * Initializes a relationship/preload target without dropping this record's * explicit operation connection. * @param {typeof VelociousDatabaseRecord} ModelClass - Target model class. * @param {import("../../configuration.js").default} configuration - Owning configuration. * @returns {Promise} - Resolves when initialized. */ ensureModelClassInitialized(ModelClass: typeof VelociousDatabaseRecord, configuration: import("../../configuration.js").default): Promise; /** * Runs load existing record. * @param {Record>} attributes - Column-keyed database values. * @param {Set} [selectedAttributeAliases] - Explicit result aliases selected by the loading query. * @returns {void} - No return value. */ loadExistingRecord(attributes: Record>, selectedAttributeAliases?: Set): void; /** * Assigns the given attributes to the record. * @param {Record>} attributesToAssign - Attributes to assign. * @returns {void} - No return value. */ assign(attributesToAssign: Record>): void; /** * Returns a the current attributes of the record (original attributes from database plus changes) * @returns {Record>} - The attributes. */ attributes(): Record>; /** * Returns column-name keyed data (original attributes from database plus changes) * @returns {Record>} - The raw attributes. */ rawAttributes(): Record>; /** * Runs connection. * @returns {import("../drivers/base.js").default} - The connection. */ _connection(): import("../drivers/base.js").default; /** * Resolves the identity of an already selected concrete connection. * @param {import("../drivers/base.js").default} connection - Concrete connection. * @returns {string} Physical database identity. */ _databaseIdentityForConnection(connection: import("../drivers/base.js").default): string; /** * Returns the connection that owns this record's database work. * @returns {import("../drivers/base.js").default} - Connection. */ connection(): import("../drivers/base.js").default; /** * Counts dependent records for a `dependent: "restrict"` relationship. * @param {RestrictInstanceRelationship} instanceRelationship - Relationship instance to count. * @returns {Promise} - Dependent row count. */ _dependentRestrictCount(instanceRelationship: RestrictInstanceRelationship): Promise; /** * Counts tenant-scoped dependent records across all provider-listed tenants. * @param {RestrictInstanceRelationship} instanceRelationship - Relationship instance to count. * @param {typeof VelociousDatabaseRecord} TargetModelClass - Related model class. * @returns {Promise} - Dependent row count. */ _dependentRestrictTenantCount(instanceRelationship: RestrictInstanceRelationship, TargetModelClass: typeof VelociousDatabaseRecord): Promise; /** * Counts tenant-scoped dependent records for one configured tenant provider. * @param {RestrictInstanceRelationship} instanceRelationship - Relationship instance to count. * @param {typeof VelociousDatabaseRecord} TargetModelClass - Related model class. * @param {string} identifier - Tenant database identifier. * @param {TenantDatabaseProviderType} provider - Tenant database provider. * @returns {Promise} - Dependent row count. */ _dependentRestrictProviderCount(instanceRelationship: RestrictInstanceRelationship, TargetModelClass: typeof VelociousDatabaseRecord, identifier: string, provider: TenantDatabaseProviderType): Promise; /** * Lists restrict-check tenants for one configured tenant provider. * @param {RestrictInstanceRelationship} instanceRelationship - Relationship instance to count. * @param {typeof VelociousDatabaseRecord} TargetModelClass - Related model class. * @param {string} identifier - Tenant database identifier. * @param {TenantDatabaseProviderType} provider - Tenant database provider. * @returns {Promise>>} - Listed tenant objects. */ _dependentRestrictProviderTenants(instanceRelationship: RestrictInstanceRelationship, TargetModelClass: typeof VelociousDatabaseRecord, identifier: string, provider: TenantDatabaseProviderType): Promise>>; /** * Runs a callback while primary-key reads resolve to the persisted identity. * @param {() => Promise} callback - Callback that requires the stored identity. * @returns {Promise} - Resolves when the callback completes. */ _withPersistedPrimaryKey(callback: () => Promise): Promise; /** * Destroys the record in the database and all of its dependent records. * @returns {Promise} - Resolves when complete. */ destroy(): Promise; /** * Runs the destroy lifecycle after the persisted identity has been restored. * @returns {Promise} - Resolves when complete. */ _destroyPersistedRecord(): Promise; /** * Emits a committed record-change event after the surrounding transaction * commits, so live queries re-run uniformly for local writes, pull applies, and * realtime applies (which all end as local saves/destroys). Registered through * the connection's afterCommit hook so a rolled-back save emits nothing, and * skipped entirely when nothing observes this model class so server-side saves * stay free of live-query overhead. * @param {import("../record-changes.js").RecordChangeOperation} operation - The committed operation. * @returns {Promise} */ _emitRecordChangeAfterCommit(operation: import("../record-changes.js").RecordChangeOperation): Promise; /** * Stores an audit row for this record. * @param {import("./auditing.js").CreateAuditArgs} args - Audit row options. * @returns {Promise} Created audit row id. */ createAudit(args: import("./auditing.js").CreateAuditArgs): Promise; /** * Captures create changes before persistence clears the change set. * @returns {void} */ captureCreateAuditChanges(): void; /** * Writes the create audit row. * @returns {Promise} */ createCreateAudit(): Promise; /** * Captures update changes before persistence clears the change set. * @returns {void} */ captureUpdateAuditChanges(): void; /** * Writes the update audit row. * @returns {Promise} */ createUpdateAudit(): Promise; /** * Writes the destroy audit row. * @returns {Promise} */ createDestroyAudit(): Promise; /** * Runs run lifecycle callbacks. * @param {"afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation"} callbackName - Callback type. * @returns {Promise} */ _runLifecycleCallbacks(callbackName: "afterCreate" | "afterDestroy" | "afterSave" | "afterUpdate" | "beforeCreate" | "beforeDestroy" | "beforeSave" | "beforeUpdate" | "beforeValidation"): Promise; /** * Runs has changes. * @returns {boolean} - Whether changes. */ _hasChanges(): boolean; /** * Returns true if the model has been changed since it was loaded from the database. * @returns {boolean} - Whether changed. */ isChanged(): boolean; /** * Returns the changes that have been made to this record since it was loaded from the database. * @returns {Record>>} - The changes. */ changes(): Record>>; /** * Runs table name. * @returns {string} - The table name. */ _tableName(): string; /** * Reads an attribute value from the record. Read dynamically by name, so the value can be any * column type and may be overridden by a user-defined getter on the model. * @template V * @param {string} attributeName The name of the attribute to read. This is the attribute name, not the column name. * @returns {V} The attribute value, typed by the caller's accessor contract. */ readAttribute(attributeName: string): V; /** * Read an association count attached by `.withCount(...)`. Counts are * stored on a separate map from the record's `_attributes` so a * virtual count like `tasksCount` cannot silently shadow a real * column of the same name. Returns the attached number, or 0 when * `.withCount(...)` wasn't requested for this attribute. * @param {string} attributeName - Attribute name, e.g. `"tasksCount"` or a custom `"activeMembersCount"` from `.withCount({activeMembersCount: {...}})`. * @returns {number} - Attached association count, or zero when absent. */ readCount(attributeName: string): number; /** * Attach an association count to this record. Internal helper used by * the `withCount` runner; outside code should not call this directly. * @param {string} attributeName - Attribute name. * @param {number} value - Count value. * @returns {void} */ _setAssociationCount(attributeName: string, value: number): void; /** * All attached association counts as a plain object. Used by the * frontend-model serializer to ship counts alongside the record * attributes on the wire. * @returns {Record} - Association counts keyed by attribute name. */ associationCounts(): Record; /** * Read a value attached by `.queryData(...)`. Stored on a dedicated * map rather than on `_attributes`, so a virtual queryData key like * `transportSecondsSum` cannot silently shadow a real column of the * same name. Returns `null` when the key wasn't produced by any * registered fn for this record (e.g. no child rows matched the * aggregate). * @param {string} name - queryData attribute name (matches a SELECT alias from the registered fn). * @returns {ReturnType} - Attached query-data value. */ queryData(name: string): ReturnType; /** * Attach a queryData value to this record. Internal helper used by * the `queryData` runner and by frontend-model hydration; outside * code should not call this directly. * @param {string} name - queryData attribute name. * @param {ReturnType} value - Value to attach. * @returns {void} */ _setQueryData(name: string, value: ReturnType): void; /** * All attached queryData values as a plain object. Used by the * frontend-model serializer to ship queryData alongside the record * attributes on the wire. * @returns {Record>} - Query-data values keyed by name. */ queryDataValues(): Record>; /** * Read a per-record ability result attached by `.abilities(...)`. The * backend evaluates each requested action against the current ability * for this record instance and ships the result alongside the * record's attributes. Returns `false` when the action wasn't * requested for this record — so UI code can safely branch on * `record.can("update")` without first checking whether the ability * was loaded. * @param {string} action - Ability action name, e.g. `"update"`. * @returns {boolean} - Whether the requested ability is allowed. */ can(action: string): boolean; /** * Attach a per-record ability result to this record. Internal helper * used by the `abilities` runner and by frontend-model hydration; * outside code should not call this directly. * @param {string} action - Ability action name. * @param {boolean} value - Whether the current ability permits the action on this record. * @returns {void} */ _setComputedAbility(action: string, value: boolean): void; /** * All attached per-record ability results as a plain object. Used * by the frontend-model serializer to ship results alongside the * record attributes on the wire. * @returns {Record} - Ability results keyed by action. */ computedAbilities(): Record; /** * Reads a column value from the record. * @param {string} attributeName The name of the column to read. This is the column name, not the attribute name. * @returns {ReturnType} - The column. */ readColumn(attributeName: string): ReturnType; /** * Resolves any declared per-attribute cast for a database column name. * @param {string} columnName - Database column name. * @returns {string | undefined} - Declared cast type, or undefined when none is declared. */ _declaredAttributeCastForColumn(columnName: string): string | undefined; /** * Converts a stored value to a real boolean for a declared `"boolean"` cast. * Leaves null/undefined untouched; treats 1/true/"1" as true and 0/false/"0" as false. * @param {ReturnType} value - Stored database value. * @returns {ReturnType} - Converted boolean, or the original value when not recognized. */ _castDeclaredBooleanForRead(value: ReturnType): ReturnType; /** * Whether a column value is currently loaded on this record (either as a * persisted attribute or a pending change). Used to decide whether a preload * can be skipped because the required columns are already present. * @param {string} columnName - The column name to check. * @returns {boolean} - Whether the column is loaded. */ hasLoadedColumn(columnName: string): boolean; /** * Runs normalize boolean value for read. A declared `"boolean"` attribute cast converts the * stored value (e.g. an MSSQL `bit` 0/1) to a real boolean; otherwise the existing * introspected-type normalization applies (no behaviour change for non-declared columns). * @param {object} args - Options object. * @param {string} args.columnName - Database column name being read. * @param {string | undefined} args.columnType - Column type. * @param {ReturnType} args.value - Value to normalize. * @returns {ReturnType} - Normalized value. */ _normalizeBooleanValueForRead({ columnName, columnType, value }: { columnName: string; columnType: string | undefined; value: ReturnType; }): ReturnType; /** * Runs normalize date value for read. * @param {ReturnType} value - Value from database. * @returns {ReturnType} - Normalized value. */ _normalizeDateValueForRead(value: ReturnType): ReturnType; _belongsToChanges(): Record; /** * Runs create new record. * @returns {Promise} - Resolves when complete. */ _createNewRecord(): Promise; /** * Marks only relationships with in-memory loaded values as preloaded after create. * @returns {void} - No return value. */ _markLoadedRelationshipsPreloadedAfterCreate(): void; /** * Applies the database insert response to this record. * @param {{connection: import("../drivers/base.js").default, data: Record, insertResult: Array> | null | undefined, primaryKey: string | string[]}} options - Pinned insert connection, inserted data, connection result, and primary key column name. * @returns {Promise} - Resolves when complete. */ _applyInsertResult({ connection, data, insertResult, primaryKey }: { connection: import("../drivers/base.js").default; data: Record; insertResult: Array> | null | undefined; primaryKey: string | string[]; }): Promise; /** * Sets timestamp defaults for a new record insert. * @param {Record>} data - Column-keyed data. * @returns {void} - No return value. */ _setDefaultTimestampValues(data: Record>): void; /** * Runs normalize date values for write. * @param {Record>} data - Column-keyed data. * @returns {void} - No return value. */ _normalizeDateValuesForWrite(data: Record>): void; /** * Runs update record with changes. * @returns {Promise} - Resolves when complete. */ _updateRecordWithChanges(): Promise; /** * Runs id. * @returns {import("../../utils/model-primary-key.js").ModelPrimaryKeyValue} - The id. */ id(): import("../../utils/model-primary-key.js").ModelPrimaryKeyValue; /** * Returns the identity represented by the last persisted database attributes. * @returns {import("../../utils/model-primary-key.js").ModelPrimaryKeyValue} - Persisted identity. */ _persistedPrimaryKeyValue(): import("../../utils/model-primary-key.js").ModelPrimaryKeyValue; /** * Runs is persisted. * @returns {boolean} - Whether persisted. */ isPersisted(): boolean; /** * Runs is new record. * @returns {boolean} - Whether new record. */ isNewRecord(): boolean; /** * Runs set is new record. * @param {boolean} newIsNewRecord - New is new record. * @returns {void} - No return value. */ setIsNewRecord(newIsNewRecord: boolean): void; /** * Runs reload with id. * @template {typeof VelociousDatabaseRecord} MC * @param {import("../../utils/model-primary-key.js").ModelPrimaryKeyValue} id - Record identifier. * @returns {Promise} - Resolves when complete. */ _reloadWithId(id: import("../../utils/model-primary-key.js").ModelPrimaryKeyValue): Promise; /** * Runs reload. * @returns {Promise} - Resolves when complete. */ reload(): Promise; _runValidations(): Promise; /** * Runs full error messages. * @returns {string[]} - The full error messages. */ fullErrorMessages(): string[]; /** * Assigns the attributes to the record and saves it. * @param {WriteAttributes} attributesToAssign - The attributes to assign to the record. */ update(attributesToAssign: WriteAttributes): Promise; } export { AdvisoryLockBusyError, AdvisoryLockHoldTimeoutError, AdvisoryLockTimeoutError, TenantDatabaseScopeError, ValidationError }; export default VelociousDatabaseRecord; //# sourceMappingURL=index.d.ts.map