export type JsonPrimitive = string | number | boolean | null export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue } export interface Notification { id: number channel: string payload: JsonValue createdAt?: number | null } export interface ScheduledFire { name: string queue: string fire_at: number job_id: number } export interface ScheduleRow { name: string queue: string cron_expr: string payload: string priority: number expires_s: number | null next_fire_at: number enabled: boolean max_attempts: number } export interface StreamEvent { offset: number topic: string key: string | null payload: JsonValue createdAt: number | null } export class CheckpointMigrationError extends Error { readonly code: 'HONKER_CHECKPOINT_MIGRATION_UNVERIFIABLE' readonly stream: string readonly consumer: string readonly offset: number } export interface QueueOptions { visibilityTimeoutS?: number maxAttempts?: number } export interface EnqueueOptions { tx?: Transaction | any runAt?: number | null delay?: number | null priority?: number expires?: number | null } export interface SchedulerAddOptions { name: string queue: string schedule?: string | null cron?: string | null payload: JsonValue priority?: number expiresS?: number | null maxAttempts?: number } export interface SchedulerUpdateOptions { schedule?: string | null cron?: string | null payload?: JsonValue priority?: number | null expiresS?: number | null maxAttempts?: number | null } export class Transaction { raw(): any execute(sql: string, params?: JsonValue[] | null): number query(sql: string, params?: JsonValue[] | null): Array> notify(channel: string, payload: JsonValue): number commit(): void rollback(): void } export class UpdateEvents { raw(): any /** Wait for the next database update. Resolves on the next commit; * rejects when the watcher dies or close() cuts the subscription. * Concurrent calls share one native wait and settle together, so * racing next() against your own timeout never starts extra native * waits. */ next(): Promise close(): void } export class Lock { readonly name: string readonly owner: string release(): boolean heartbeat(ttlS: number): boolean } export class Job { readonly id: number readonly queue: string readonly payload: JsonValue readonly workerId: string readonly attempts: number readonly claimExpiresAt: number | null ack(): boolean retry(delayS?: number, error?: string): boolean fail(error?: string): boolean heartbeat(extendS: number): boolean } export class ClaimWaker { next(workerId: string, opts?: { signal?: AbortSignal }): Promise close(): void } export class StreamSubscription implements AsyncIterableIterator { next(): Promise> [Symbol.asyncIterator](): AsyncIterableIterator close(): void } export class Stream { publish(payload: JsonValue): number publishWithKey(key: string, payload: JsonValue): number publishTx(tx: Transaction | any, payload: JsonValue, key?: string | null): number readSince(offset: number, limit: number): StreamEvent[] readFromConsumer(consumer: string, limit: number): StreamEvent[] saveOffset(consumer: string, offset: number): boolean saveOffsetTx(tx: Transaction | any, consumer: string, offset: number): boolean getOffset(consumer: string): number subscribe( consumer: string, opts?: { saveEveryN?: number; saveEveryS?: number; signal?: AbortSignal } ): StreamSubscription } export class Listener implements AsyncIterableIterator { next(): Promise> [Symbol.asyncIterator](): AsyncIterableIterator close(): void } export class Scheduler { add(opts: SchedulerAddOptions): number | null remove(name: string): number pause(name: string): boolean resume(name: string): boolean list(): ScheduleRow[] update(name: string, opts?: SchedulerUpdateOptions): boolean tick(now?: number): ScheduledFire[] soonest(): number | null run(owner: string, signal?: AbortSignal): Promise } export class Queue { readonly name: string readonly visibilityTimeoutS: number readonly maxAttempts: number enqueue(payload: JsonValue, opts?: EnqueueOptions): number enqueueTx(tx: Transaction | any, payload: JsonValue, opts?: EnqueueOptions): number claimBatch(workerId: string, n: number): Job[] claimOne(workerId: string): Job | null claim(workerId: string, opts?: { idlePollS?: number | null, signal?: AbortSignal }): AsyncIterableIterator ackBatch(ids: number[], workerId: string): number sweepExpired(): number claimWaker(opts?: { idlePollS?: number | null }): ClaimWaker } export interface OutboxOptions { visibilityTimeoutS?: number maxAttempts?: number baseBackoffS?: number } export class Outbox { readonly name: string readonly queue: Queue readonly maxAttempts: number readonly baseBackoffS: number enqueue(payload: JsonValue, opts?: EnqueueOptions): number enqueueTx(tx: Transaction | any, payload: JsonValue, opts?: EnqueueOptions): number runWorker(workerId: string, opts?: { idlePollS?: number | null, signal?: AbortSignal }): Promise } export class Database { raw(): any transaction(): Transaction query(sql: string, params?: JsonValue[] | null): Array> updateEvents(): UpdateEvents close(): void pruneNotifications(olderThanS?: number | null, maxKeep?: number | null): number notify(channel: string, payload: JsonValue): number notifyTx(tx: Transaction | any, channel: string, payload: JsonValue): number queue(name: string, opts?: QueueOptions): Queue outbox(name: string, delivery: (payload: JsonValue, job: Job) => any | Promise, opts?: OutboxOptions): Outbox stream(name: string): Stream listen(channel: string, opts?: { fallbackPollS?: number | null }): Listener scheduler(): Scheduler tryLock(name: string, owner: string, ttlS: number): Lock | null tryRateLimit(name: string, limit: number, per: number): boolean sweepRateLimits(olderThanS: number): number saveResult(jobId: number, value: string, ttlS: number): void getResult(jobId: number): string | null sweepResults(): number } export interface OpenOptions { maxReaders?: number | null watcherBackend?: string | null watcherPollIntervalMs?: number | null } export function open(path: string, options?: OpenOptions): Database export function open(path: string, maxReaders?: number | null, watcherBackend?: string | null, watcherPollIntervalMs?: number | null): Database export const native: any export const NativeDatabase: any export const NativeTransaction: any export const NativeUpdateEvents: any