import * as api from '@actual-app/api'; /** * Build the `api.init()` config from environment variables. * * `ACTUAL_SESSION_TOKEN` takes precedence over `ACTUAL_PASSWORD`. A session token is * the only way to authenticate against a server where password login is disabled, * e.g. when OpenID is enforced with `ACTUAL_OPENID_ENFORCE=true`. * * @param dataDir - Local directory for budget data * @returns The init config for `@actual-app/api` */ export declare function buildInitConfig(dataDir: string): InitConfig; type ActualApi = Awaited>; type InitConfig = NonNullable[0]>; export declare class ActualConnection { private state; private inflightInit; private inflightSync; private lastSyncAt; private queueTail; private closePromise; private actualLib; private apiOpened; private isClosingOrClosed; /** Add work to the shared lifecycle queue without letting a failure block later work. */ private enqueue; /** * Ensure readiness, then run an operation after all preceding operations. * * `operation` must call raw `api.*` functions. Calling an actual-api facade * wrapper would re-enter this queue and wait for its own queued operation. * * @param operation - The raw Actual API operation to execute. * @returns The operation result. */ run(operation: (actualLib: ActualApi) => Promise): Promise; /** * Ensure the connection is initialized and (when already ready) not stale. * Concurrent callers share one in-flight init; a failed attempt is not * cached — the next call starts a fresh attempt. */ ensureReady(): Promise; private syncTtlMs; /** * Pull remote changes into local data when the TTL has elapsed. Concurrent * stale callers share one in-flight sync. A failed sync is logged, not thrown: * answering from slightly stale data beats failing the call. */ private syncIfStale; /** * Stop accepting new operations, await all in-flight work (init, sync, and * the operation queue), then shut down the underlying API. Idempotent. */ drainAndClose(): Promise; /** * Open the API, pick a budget, and download it. On any failure after `api.init()` * has opened handles, releases them before rethrowing so a retry starts clean. */ private doInit; } /** Process-wide connection accessor. */ export declare function getActualConnection(): ActualConnection; /** Test-only: discard the singleton so each test starts from a clean state. */ export declare function resetActualConnectionForTests(): void; export {}; //# sourceMappingURL=connection.d.ts.map