export type TenantDescriptorValue = null | boolean | number | string | TenantDescriptorValue[] | { [key: string]: TenantDescriptorValue; }; export type TenantDescriptor = { [key: string]: TenantDescriptorValue; }; export type TenantSqliteLifecycleSnapshot = { databaseIdentifier: string; dirty: boolean; lastUsed: number; pinCount: number; ready: boolean; schemaGeneration: string | undefined; state: "closed" | "closing" | "deleting" | "open" | "opening"; }; /** * Live-query source whose query is rebuilt inside one captured tenant operation * for every run. * @template {typeof import("../database/record/index.js").default} MC */ declare class TenantLiveQuerySource { _databaseIdentifier: string; _handle: TenantHandle; _modelClass: MC; _query: ((query: import("../database/query/model-class-query.js").default) => import("../database/query/model-class-query.js").default | void) | undefined; /** * Creates a live-query source bound to an immutable tenant handle. * @param {object} args - Source arguments. * @param {string} args.databaseIdentifier - Captured logical database. * @param {TenantHandle} args.handle - Owning immutable tenant handle. * @param {MC} args.modelClass - Root model class. * @param {(query: import("../database/query/model-class-query.js").default) => import("../database/query/model-class-query.js").default | void} [args.query] - Query builder. */ constructor({ databaseIdentifier, handle, modelClass, query }: { databaseIdentifier: string; handle: TenantHandle; modelClass: MC; query?: (query: import("../database/query/model-class-query.js").default) => import("../database/query/model-class-query.js").default | void; }); /** * Returns the root model class. * @returns {MC} Root model class. */ getModelClass(): MC; /** * Returns the captured physical identity for one observed model. * @param {typeof import("../database/record/index.js").default} modelClass - Observed model class. * @returns {string} Physical database identity. */ databaseIdentityForModel(modelClass: typeof import("../database/record/index.js").default): string; /** * Loads the current tenant rows through a fresh captured operation. * @returns {Promise>>} Current tenant rows. */ toArray(): Promise>>; } /** * Immutable tenant/database handle. Physical database configurations are * resolved and captured at construction, so later ambient tenant changes * cannot redirect work performed through this handle. */ export default class TenantHandle { _configuration: import("../configuration.js").default; _databaseConfigurations: Readonly>; _tenant: TenantDescriptor; /** @type {WeakMap} */ _metadataModelClasses: WeakMap; /** * Runs constructor. * @param {object} args - Handle arguments. * @param {import("../configuration.js").default} args.configuration - Owning configuration. * @param {object} args.tenant - Ordinary or null-prototype JSON-compatible application tenant descriptor. */ constructor({ configuration, tenant }: { configuration: import("../configuration.js").default; tenant: object; }); /** * Returns the captured tenant descriptor. Routing never re-resolves physical * identity from this value after handle construction. * @returns {TenantDescriptor} - Tenant descriptor. */ tenant(): TenantDescriptor; /** * Rejects using this handle with a different Configuration instance. * @param {import("../configuration.js").default} configuration - Expected owner. * @returns {void} */ assertConfiguration(configuration: import("../configuration.js").default): void; /** * Returns the captured physical configuration for an active identifier. * @param {string} databaseIdentifier - Logical database identifier. * @returns {import("../configuration-types.js").DatabaseConfigurationType} - Captured resolved configuration. */ databaseConfiguration(databaseIdentifier: string): import("../configuration-types.js").DatabaseConfigurationType; /** * Returns the opaque captured physical database identity used by events, * live queries, and tenant-scoped sync state. * @param {string} databaseIdentifier - Logical database identifier. * @returns {string} Stable physical database identity. */ databaseIdentity(databaseIdentifier: string): string; /** * Builds a live-query source permanently bound to this captured tenant. * @template {typeof import("../database/record/index.js").default} MC * @param {object} args - Live-query source arguments. * @param {string} args.databaseIdentifier - Logical tenant database. * @param {MC} args.modelClass - Root model class. * @param {(query: import("../database/query/model-class-query.js").default) => import("../database/query/model-class-query.js").default | void} [args.query] - Query builder run inside each captured operation. * @returns {TenantLiveQuerySource} Tenant-bound source. */ liveQuery({ databaseIdentifier, modelClass, query }: { databaseIdentifier: string; modelClass: MC; query?: (query: import("../database/query/model-class-query.js").default) => import("../database/query/model-class-query.js").default | void; }): TenantLiveQuerySource; /** * Returns a read-only model-class metadata view for this handle's ready * physical schema generation. Runtime queries must still use an operation. * @template {typeof import("../database/record/index.js").default} MC * @param {object} args - Metadata arguments. * @param {string} args.databaseIdentifier - Logical tenant database. * @param {MC} args.modelClass - Canonical model class. * @returns {MC} Generation-bound metadata view. */ metadataModelClass({ databaseIdentifier, modelClass }: { databaseIdentifier: string; modelClass: MC; }): MC; /** * Opens this captured SQLite identity. * @param {{databaseIdentifier: string}} options - Lifecycle options. * @returns {Promise>} - Safe lifecycle snapshot. */ open(options: { databaseIdentifier: string; }): Promise>; /** * Opens, migrates, and initializes record metadata for one captured physical * tenant SQLite database and application schema generation. * @param {object} options - Initialization options. * @param {string} options.databaseIdentifier - Tenant-only logical database identifier. * @param {import("../database/migrator/types.js").RequireMigrationContextType} options.migrations - Frontend migration require context. * @param {string} options.schemaGeneration - Stable application schema generation. * @returns {Promise>} - Ready lifecycle snapshot. */ initialize({ databaseIdentifier, migrations, schemaGeneration }: { databaseIdentifier: string; migrations: import("../database/migrator/types.js").RequireMigrationContextType; schemaGeneration: string; }): Promise>; /** * Flushes this captured SQLite identity. * @param {{databaseIdentifier: string}} options - Lifecycle options. * @returns {Promise>} - Safe lifecycle snapshot. */ flush(options: { databaseIdentifier: string; }): Promise>; /** * Closes this captured SQLite identity. * @param {{databaseIdentifier: string, flush?: boolean}} options - Lifecycle options. * @returns {Promise>} - Safe lifecycle snapshot. */ close(options: { databaseIdentifier: string; flush?: boolean; }): Promise>; /** * Deletes this captured SQLite identity. * @param {{databaseIdentifier: string}} options - Lifecycle options. * @returns {Promise>} - Closed lifecycle snapshot. */ delete(options: { databaseIdentifier: string; }): Promise>; /** * Inspects this captured SQLite identity. * @param {{databaseIdentifier: string}} options - Lifecycle options. * @returns {Readonly} - Safe lifecycle snapshot. */ inspect(options: { databaseIdentifier: string; }): Readonly; /** * Runs work while this captured SQLite identity is protected from eviction. * @template T * @param {{databaseIdentifier: string}} options - Lifecycle options. * @param {() => Promise} callback - Pinned work. * @returns {Promise} - Callback result. */ withPin({ databaseIdentifier }: { databaseIdentifier: string; }, callback: () => Promise): Promise; /** * Runs explicit ORM work on one pinned connection for this handle's captured * physical database. Use `operation.forModel(ModelClass)` for queries and * writes; loaded records and association/preload work retain that operation. * @template T * @param {{databaseIdentifier: string, name?: string}} options - Logical database and checkout name. * @param {(operation: import("../database/operation.js").default) => Promise} callback - Owned work callback. * @returns {Promise} - Callback result. */ databaseOperation({ databaseIdentifier, name }: { databaseIdentifier: string; name?: string; }, callback: (operation: import("../database/operation.js").default) => Promise): Promise; /** * Runs a captured operation with explicit readiness policy. Initialization is * the only caller allowed to enter an unready schema generation. * @template T * @param {{databaseIdentifier: string, name: string, requireReady: boolean, schemaGeneration?: string}} options - Internal operation options. * @param {(operation: import("../database/operation.js").default) => Promise} callback - Operation callback. * @returns {Promise} - Callback result. */ _databaseOperation({ databaseIdentifier, name, requireReady, schemaGeneration }: { databaseIdentifier: string; name: string; requireReady: boolean; schemaGeneration?: string; }, callback: (operation: import("../database/operation.js").default) => Promise): Promise; /** * Runs explicit ORM work in a transaction pinned to this handle's captured * physical database. * @template T * @param {{databaseIdentifier: string, name?: string}} options - Logical database and checkout name. * @param {(operation: import("../database/operation.js").default) => Promise} callback - Transaction callback. * @returns {Promise} - Callback result. */ transaction({ databaseIdentifier, name }: { databaseIdentifier: string; name?: string; }, callback: (operation: import("../database/operation.js").default) => Promise): Promise; } export {}; //# sourceMappingURL=tenant-handle.d.ts.map