export type AttachmentDriverConstructor = import("../../../configuration-types.js").AttachmentDriverConstructor; /** * Returns the attachment store used before a model-level transaction starts. * @param {typeof import("../index.js").default} modelClass - Model class opening the transaction. * @param {import("../../drivers/base.js").default} connection - Selected physical connection. * @returns {RecordAttachmentsStore} - Store instance. */ export declare function recordAttachmentsStoreForModelClass(modelClass: typeof import("../index.js").default, connection: import("../../drivers/base.js").default): RecordAttachmentsStore; /** * Runs the recordAttachmentsStoreForModel helper. * @param {import("../index.js").default} model - Model instance. * @returns {RecordAttachmentsStore} - Store instance. */ export declare function recordAttachmentsStoreForModel(model: import("../index.js").default): RecordAttachmentsStore; /** * Attachment persistence store. */ export default class RecordAttachmentsStore { configuration: import("../../../configuration.js").default; databaseIdentifier: string; _readyPromise: Promise | null; _schemaUpgradePromise: Promise | null; /** @type {number | undefined} */ _schemaReadyGeneration: number | undefined; _driverColumnsAvailable: boolean; _contentBase64Nullable: boolean; /** * Narrows the runtime value to the documented type. * @type {Map>>} */ _attachmentDriversByName: Map>>; /** * Narrows the runtime value to the documented type. * @type {Map>, Record>>} */ _attachmentDriversByReference: Map>, Record>>; /** * Runs constructor. * @param {object} args - Options. * @param {import("../../../configuration.js").default} args.configuration - Configuration instance. * @param {string} args.databaseIdentifier - Database identifier. */ constructor({ configuration, databaseIdentifier }: { configuration: import("../../../configuration.js").default; databaseIdentifier: string; }); /** * Runs ensure ready. * @param {import("../index.js").default} [model] - Operation-owning model. * @returns {Promise} - Resolves when schema is ready. */ ensureReady(model?: import("../index.js").default): Promise; /** * Ensures attachment schema through an already-owned connection. * @param {import("../../drivers/base.js").default} db - Database connection. * @returns {Promise} - Resolves when schema is ready. */ ensureSchema(db: import("../../drivers/base.js").default): Promise; /** * Runs attach. * @param {object} args - Options. * @param {import("../index.js").default} args.model - Model instance. * @param {string} args.name - Attachment name. * @param {ReturnType} args.input - Attachment input. * @param {boolean} args.replace - Whether to replace existing attachments. * @returns {Promise} - Resolves when complete. */ attach({ input, model, name, replace }: { model: import("../index.js").default; name: string; input: ReturnType; replace: boolean; }): Promise; /** * Materializes path content once when a legacy schema requires Base64. * @param {import("./normalize-input.js").NormalizedAttachmentInput} normalizedInput - Normalized attachment input. * @returns {Promise} - Input used by the driver and database. */ persistenceInputFor(normalizedInput: import("./normalize-input.js").NormalizedAttachmentInput): Promise; /** * Persists one normalized attachment while its path source remains open. * @param {object} args - Options. * @param {import("../index.js").default} args.model - Model instance. * @param {string} args.name - Attachment name. * @param {import("./normalize-input.js").NormalizedAttachmentInput} args.normalizedInput - Normalized attachment. * @param {boolean} args.replace - Whether to replace existing attachments. * @returns {Promise} - Resolves after persistence. */ persistNormalizedAttachment({ model, name, normalizedInput, replace }: { model: import("../index.js").default; name: string; normalizedInput: import("./normalize-input.js").NormalizedAttachmentInput; replace: boolean; }): Promise; /** * Resolves the database content_base64 value for current and legacy schemas. * @param {import("./normalize-input.js").NormalizedAttachmentInput} normalizedInput - Normalized attachment input. * @returns {Promise} - Nullable or legacy Base64 database value. */ databaseContentBase64For(normalizedInput: import("./normalize-input.js").NormalizedAttachmentInput): Promise; /** * Runs ensure attachment store schema. * @param {object} args - Options. * @param {import("../../../database/drivers/base.js").default} args.db - DB connection. * @returns {Promise} - Resolves when schema columns are ensured. */ ensureAttachmentStoreSchema({ db }: { db: import("../../../database/drivers/base.js").default; }): Promise; /** * Returns the schema-cache generation for the connection's physical database. * @param {import("../../../database/drivers/base.js").default} db - DB connection. * @returns {number} - Current schema-cache generation. */ _schemaCacheGeneration(db: import("../../../database/drivers/base.js").default): number; /** * Ensures attachment columns and indexes after schema-upgrade serialization is acquired. * @param {object} args - Options. * @param {import("../../../database/drivers/base.js").default} args.db - DB connection. * @returns {Promise} - Resolves when schema columns are ensured. */ _ensureAttachmentStoreSchema({ db }: { db: import("../../../database/drivers/base.js").default; }): Promise; /** * Backfills bounded attachment owner digests in small batches. * @param {import("../../../database/drivers/base.js").default} db - Database connection. * @returns {Promise} - Resolves when every existing row has a digest. */ backfillAttachmentRecordIdDigests(db: import("../../../database/drivers/base.js").default): Promise; /** * Makes the backfilled attachment owner digest required. * @param {import("../../../database/drivers/base.js").default} db - Database connection. * @returns {Promise} - Resolves when the digest column is non-nullable. */ ensureAttachmentRecordIdDigestNotNull(db: import("../../../database/drivers/base.js").default): Promise; /** * Ensures attachment owner queries retain a bounded composite index. * @param {import("../../../database/drivers/base.js").default} db - Database connection. * @returns {Promise} - Resolves when the owner index exists. */ ensureAttachmentOwnerIndex(db: import("../../../database/drivers/base.js").default): Promise; /** * Runs read attachment row. * @param {object} args - Options. * @param {import("../index.js").default} args.model - Model instance. * @param {string} args.name - Attachment name. * @param {Record>} args.row - Attachment row. * @returns {Promise} - Attachment bytes. */ readAttachmentRow({ model, name, row }: { model: import("../index.js").default; name: string; row: Record>; }): Promise; /** * Runs attachment row url. * @param {object} args - Options. * @param {import("../index.js").default} args.model - Model instance. * @param {string} args.name - Attachment name. * @param {Record>} args.row - Attachment row. * @returns {Promise} - Attachment URL. */ attachmentRowUrl({ model, name, row }: { model: import("../index.js").default; name: string; row: Record>; }): Promise; /** * Runs find one. * @param {object} args - Options. * @param {import("../index.js").default} args.model - Model instance. * @param {string} args.name - Attachment name. * @param {string} [args.id] - Optional attachment id. * @returns {Promise> | null>} - Attachment row. */ findOne({ id, model, name }: { model: import("../index.js").default; name: string; id?: string; }): Promise> | null>; /** * Runs find many. * @param {object} args - Options. * @param {import("../index.js").default} args.model - Model instance. * @param {string} args.name - Attachment name. * @returns {Promise>>>} - Attachment rows. */ findMany({ model, name }: { model: import("../index.js").default; name: string; }): Promise>>>; /** * Prepares attachment schema before a record transaction can migrate ownership. * @param {object} args - Options. * @param {import("../../drivers/base.js").default} args.connection - Record-owning database connection. * @returns {Promise} - Resolves when existing attachment schema is current. */ prepareRecordIdentityMigration({ connection }: { connection: import("../../drivers/base.js").default; }): Promise; /** * Moves every attachment row to a record's new primary-key identity. * @param {object} args - Options. * @param {import("../../drivers/base.js").default} args.connection - Transaction-owning database connection. * @param {import("../index.js").default} args.model - Attachment owner after the key change. * @param {import("../../../utils/model-primary-key.js").ModelPrimaryKeyValue} args.nextIdentity - New owner identity. * @param {import("../../../utils/model-primary-key.js").ModelPrimaryKeyValue} args.previousIdentity - Persisted owner identity. * @returns {Promise} - Resolves after ownership is migrated. */ migrateRecordIdentity({ connection, model, nextIdentity, previousIdentity }: { connection: import("../../drivers/base.js").default; model: import("../index.js").default; nextIdentity: import("../../../utils/model-primary-key.js").ModelPrimaryKeyValue; previousIdentity: import("../../../utils/model-primary-key.js").ModelPrimaryKeyValue; }): Promise; /** * Runs delete attachment row storage. * @param {object} args - Options. * @param {import("../index.js").default} args.model - Model instance. * @param {string} args.name - Attachment name. * @param {Record>} args.row - Attachment row. * @returns {Promise} - Resolves when row storage has been deleted. */ deleteAttachmentRowStorage({ model, name, row }: { model: import("../index.js").default; name: string; row: Record>; }): Promise; /** * Purges every attachment stored under (model, name): deletes each row's * backing storage and then removes the attachment rows. Used to clean up an * owner record's attachments before/when the owner is destroyed. * @param {object} args - Options. * @param {import("../index.js").default} args.model - Model instance. * @param {string} args.name - Attachment name. * @returns {Promise} - Number of attachments purged. */ purgeAll({ model, name }: { model: import("../index.js").default; name: string; }): Promise; /** * Runs attachment driver by name. * @param {string} driverName - Driver name. * @returns {Promise>>} - Attachment storage driver instance. */ attachmentDriverByName(driverName: string): Promise>>; /** * Runs attachment driver by reference. * @param {object} args - Options. * @param {AttachmentDriverConstructor | Record>} args.driverReference - Driver class or instance. * @param {string} args.attachmentName - Attachment name. * @param {typeof import("../index.js").default} args.modelClass - Model class. * @returns {Record>} - Attachment driver instance. */ attachmentDriverByReference({ attachmentName, driverReference, modelClass }: { driverReference: AttachmentDriverConstructor | Record>; attachmentName: string; modelClass: typeof import("../index.js").default; }): Record>; /** * Runs attachment driver name for. * @param {object} args - Options. * @param {import("../index.js").default} args.model - Model instance. * @param {string} args.name - Attachment name. * @returns {string} - Attachment driver name. */ _attachmentDriverNameFor({ model, name }: { model: import("../index.js").default; name: string; }): string; /** * Runs resolve attachment driver. * @param {object} args - Options. * @param {import("../index.js").default} args.model - Model instance. * @param {string} args.name - Attachment name. * @param {Record>} [args.row] - Attachment row. * @returns {Promise>>} - Attachment storage driver instance. */ resolveAttachmentDriver({ model, name, row }: { model: import("../index.js").default; name: string; row?: Record>; }): Promise>>; /** * Runs next position. * @param {object} args - Options. * @param {import("../../../database/drivers/base.js").default} args.db - DB connection. * @param {string} args.name - Attachment name. * @param {string} args.recordId - Record id. * @param {string} args.recordType - Record type. * @returns {Promise} - Next position. */ _nextPosition({ db, name, recordId, recordType }: { db: import("../../../database/drivers/base.js").default; name: string; recordId: string; recordType: string; }): Promise; /** * Runs with db. * @template T * @param {(db: import("../../../database/drivers/base.js").default) => Promise} callback - Callback. * @param {import("../index.js").default} [model] - Operation-owning model. * @returns {Promise} - Callback result. */ _withDb(callback: (db: import("../../../database/drivers/base.js").default) => Promise, model?: import("../index.js").default): Promise; } //# sourceMappingURL=store.d.ts.map