import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core'; export type SmrtJobEventType = 'status' | 'progress' | 'log' | 'error' | string; export type SmrtJobEventLevel = 'debug' | 'info' | 'warn' | 'error'; export interface SmrtJobEventData { tenantId?: string | null; jobId: string; type?: SmrtJobEventType; level?: SmrtJobEventLevel; stage?: string | null; progress?: number | null; message?: string; data?: Record; createdAt?: Date; } export interface JobEventCursor { createdAt: string | Date; id: string; } export interface ListJobEventsOptions { tenantId?: string | null; limit?: number; since?: string | Date; afterId?: string; cursor?: string | JobEventCursor; } export declare class SmrtJobEvent extends SmrtObject { tenantId: string | null | undefined; jobId: string; type: SmrtJobEventType; level: SmrtJobEventLevel; stage: string | null; progress: number | null; message: string; data: Record; createdAt: Date; toCursor(): string; } export declare class SmrtJobEventCollection extends SmrtCollection { static readonly _itemClass: typeof SmrtJobEvent; initialize(): Promise; append(input: SmrtJobEventData): Promise; listByJob(jobId: string, options?: ListJobEventsOptions): Promise; listSinceCursor(options?: ListJobEventsOptions & { jobId?: string; }): Promise; latestProgressByJobIds(jobIds: string[], options?: { tenantId?: string | null; }): Promise>; private addTenantPredicate; /** * Delete job events recorded before a cutoff (#2375). * * `_smrt_job_events` is append-only — every log line, progress tick and * lifecycle transition of every job — so it outgrows `_smrt_jobs` by an * order of magnitude and had no prune path at all. Events are pruned on * their own clock rather than by following job deletion: a long-running job * accumulates events for as long as it runs. * * The cutoff uses the same engine-normalized `created_at` expression the * cursor reads use. On PostgreSQL that is the bare column, so * `idx_smrt_job_events_created_at` serves it; on SQLite the `strftime()` * wrapper makes the comparison non-sargable and the prune is a scan. That is * acceptable for a periodic maintenance pass and is preferable to comparing * two differently-formatted timestamps, which is what the wrapper exists to * prevent. * * @param options.before - Delete events created strictly before this time. * @param options.dryRun - Count matching events without deleting them. * @returns Number of events deleted (or, under `dryRun`, matched). */ cleanup(options: { before: Date; dryRun?: boolean; }): Promise; private createdAtComparableExpression; private resolveCursorCreatedAt; } export default SmrtJobEvent; //# sourceMappingURL=smrt-job-event.d.ts.map