import { type SubscriptionSettingKey } from "@opengeni/subscriptions"; import { type Database } from "./database.js"; /** * Settings transactions run at READ COMMITTED whatever the connection * default: 0724's guard and lock writer refuse a widening write or a lock * change under an older snapshot, which could miss a concurrent lock. */ export declare const SUBSCRIPTION_SETTINGS_TRANSACTION: { readonly isolationLevel: "read committed"; }; /** The write would override settings the organization locked. */ export declare class SubscriptionSettingsLockedError extends Error { readonly settings: readonly SubscriptionSettingKey[]; constructor(settings: readonly SubscriptionSettingKey[]); } /** * The settings named by a lock refusal from the 0724 guard, found in the * error or its causes; null when the error is not a lock refusal. Every * writer of `subscription_settings` meets the guard, so callers that treat * 42501 as "not visible" must check this first. */ export declare function subscriptionSettingLockRefusal(error: unknown): SubscriptionSettingKey[] | null; /** Rethrows a lock refusal as `SubscriptionSettingsLockedError`; returns otherwise. */ export declare function throwIfSubscriptionSettingLocked(error: unknown): void; /** * Take the organization's settings lock: the transaction advisory lock 0724's * guard (shared) and lock writer (exclusive) use. The repository's workspace * writers take it shared before any row lock, and a lock change queues for it * exclusively before any row lock, so later widening writes queue behind the * change instead of starving it. Holding it exclusively, a lock change never * waits for a workspace row (0724 locks them NOWAIT): a writer outside the * repository (an older release during a rolling upgrade, a raw or migration * writer) may hold a row while it waits for this lock. */ export declare function lockSubscriptionSettings(tx: Database, accountId: string, mode: "shared" | "exclusive"): Promise; /** * A lock change kept yielding to in-flight workspace writes; nothing was * written and the change can be retried. */ export declare class SubscriptionSettingsBusyError extends Error { constructor(); } /** Whether the error, or one of its causes, is 0724's lock-writer yield. */ export declare function isSubscriptionSettingsLockBusy(error: unknown): boolean;