export type SyncScopeRow = { /** * - Scope attribute conditions. */ conditions: Record>; /** * - Persisted cursor JSON payload. */ cursorPayload: string | null; /** * - Scope row id. */ id: string; /** * - Scope resource/model name, or null for the all-types (user) scope. */ resourceType: string | null; /** * - Fixed-size deterministic digest of the canonical scope key. */ scopeDigest: string; /** * - Scope state ("active" or "removed"). */ state: string; /** * - Physical store identity owning this row. */ storeIdentity: string; }; /** * Framework-owned local persistence for declared sync scopes and their cursors. * * Backed by an auto-created `velocious_sync_scopes` table on the configured * database, with a process-local memory fallback when no database is * configured (mirroring the server change-feed store). */ export default class SyncScopeStore { configuration: import("../configuration.js").default; databaseIdentifier: string; tenantHandle: import("../tenants/tenant-handle.js").default | undefined; storeIdentity: string; /** @type {Map} */ _memoryScopes: Map; _isReady: boolean; /** @type {Promise | null} */ _readyPromise: Promise | null; /** @type {WeakMap, promise: Promise}>} */ _transactionReadyPromises: WeakMap; promise: Promise; }>; /** * Creates a sync scope store. * @param {object} args - Options. * @param {import("../configuration.js").default} args.configuration - Configuration owning the database. * @param {string} [args.databaseIdentifier] - Database identifier. * @param {import("../tenants/tenant-handle.js").default} [args.tenantHandle] - Immutable tenant handle owning the physical store. */ constructor({ configuration, databaseIdentifier, tenantHandle }: { configuration: import("../configuration.js").default; databaseIdentifier?: string; tenantHandle?: import("../tenants/tenant-handle.js").default; }); /** * Ensures the backing table exists. * @returns {Promise} Resolves when ready. */ ensureReady(): Promise; /** * Coordinates durable and transaction-local readiness on one connection. * @param {import("../database/drivers/base.js").default} db - Database connection. * @returns {Promise} Resolves when this caller can use the table. */ _ensureReadyWithDb(db: import("../database/drivers/base.js").default): Promise; /** * Finds or creates the scope row for a serialized scope, reactivating removed scopes. * @param {import("./sync-client-types.js").SerializedSyncScope} scope - Serialized sync scope. * @returns {Promise} Persisted scope row. */ findOrCreateScope(scope: import("./sync-client-types.js").SerializedSyncScope): Promise; /** * Returns all active scope rows. * @returns {Promise} Active scope rows. */ activeScopes(): Promise; /** * Loads the persisted cursor payload for a scope row. * @param {SyncScopeRow} scopeRow - Scope row. * @returns {Promise} Cursor JSON payload. */ loadCursor(scopeRow: SyncScopeRow): Promise; /** * Persists the acknowledged cursor for a scope row. * @param {SyncScopeRow} scopeRow - Scope row. * @param {import("./sync-api-client-types.js").SyncCursor} cursor - Acknowledged cursor. * @returns {Promise} */ saveCursor(scopeRow: SyncScopeRow, cursor: import("./sync-api-client-types.js").SyncCursor): Promise; /** * Deactivates the scope row for a serialized scope. * @param {import("./sync-client-types.js").SerializedSyncScope} scope - Serialized sync scope. * @returns {Promise} */ deactivate(scope: import("./sync-client-types.js").SerializedSyncScope): Promise; /** * Atomically deactivates selected scopes, clears their cursors and rotates * their row identities. A cursor save carrying a pre-reset row identity can * therefore never repopulate the reset scope. The optional cleanup hook runs * inside the same database transaction, allowing an app to purge the local * rows owned by those scopes without a cursor/cache split. * @param {import("./sync-client-types.js").SerializedSyncScope[]} scopes - Selected scopes to reset. * @param {object} [options] - Reset options. * @param {(args: {connection: import("../database/drivers/base.js").default | null, scopes: import("./sync-client-types.js").SerializedSyncScope[]}) => Promise | void} [options.cleanup] - App-owned local-row cleanup hook. * @returns {Promise} */ reset(scopes: import("./sync-client-types.js").SerializedSyncScope[], { cleanup }?: { cleanup?: (args: { connection: import("../database/drivers/base.js").default | null; scopes: import("./sync-client-types.js").SerializedSyncScope[]; }) => Promise | void; }): Promise; /** * Resets one memory-backed scope while preserving repeated-reset idempotence. * @param {import("./sync-client-types.js").SerializedSyncScope} scope - Scope to reset. * @returns {void} */ _resetMemoryScope(scope: import("./sync-client-types.js").SerializedSyncScope): void; /** * Resets one database-backed scope while preserving repeated-reset idempotence. * @param {{db: import("../database/drivers/base.js").default, scope: import("./sync-client-types.js").SerializedSyncScope}} args - Database and scope. * @returns {Promise} */ _resetDatabaseScope({ db, scope }: { db: import("../database/drivers/base.js").default; scope: import("./sync-client-types.js").SerializedSyncScope; }): Promise; /** * Whether the store runs without a configured database. * @returns {boolean} Whether memory storage is used. */ _usesMemoryStorage(): boolean; /** * Runs a callback with a database connection. * @template Result * @param {(db: import("../database/drivers/base.js").default) => Promise} callback - Database callback. * @returns {Promise} Callback result. */ _withDb(callback: (db: import("../database/drivers/base.js").default) => Promise): Promise; /** * Ensures the scopes table exists. * @param {import("../database/drivers/base.js").default} db - Database connection. * @returns {Promise} Whether the table had to be created. */ _ensureScopesTable(db: import("../database/drivers/base.js").default): Promise; /** * Resolves a scope row by its digest. * @param {import("../database/drivers/base.js").default} db - Database connection. * @param {string} digest - Fixed-size scope digest. * @returns {Promise} Scope row or null. */ _rowByScopeDigest(db: import("../database/drivers/base.js").default, digest: string): Promise; /** * Normalizes a raw scope table row. * @param {Record>} row - Raw table row. * @returns {SyncScopeRow} Normalized scope row. */ _normalizeScopeRow(row: Record>): SyncScopeRow; /** * Rejects passing a scope row captured from another physical store. * @param {SyncScopeRow} scopeRow - Scope row to validate. * @returns {void} */ _assertScopeRow(scopeRow: SyncScopeRow): void; } //# sourceMappingURL=sync-scope-store.d.ts.map