UNPKG

@dudousxd/nestjs-telescope

Version:

Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.

53 lines 2.61 kB
import type { ModuleRef } from '@nestjs/core'; import type { ResolvedCoreConfig } from '../config/options.js'; export type ScheduleKind = 'cron' | 'interval' | 'timeout'; export declare const SCHEDULE_KINDS: readonly ScheduleKind[]; export declare function isScheduleKind(value: unknown): value is ScheduleKind; export type ScheduleRunStatus = 'completed' | 'failed'; /** * A registered `@nestjs/schedule` task as surfaced to the Schedule console. * `schedule` is the cron expression for crons, or a `"every Nms"` label for * intervals/timeouts. Last-run fields come from the watcher's recorded runs and * are `null` until a run has been observed (or when no manager tracks them). */ export interface ScheduledTask { name: string; kind: ScheduleKind; schedule: string; /** ISO timestamp of the next fire, or null when unknown (intervals/timeouts). */ nextRunAt: string | null; /** * Whether the task is currently active (started/enabled). For crons this is the * underlying `CronJob.running` flag — `false` means the cron is registered but * stopped, so it WON'T fire even though it has a schedule. `null` when the * source can't report it (intervals/timeouts expose only their name through * `SchedulerRegistry`, so their running state is unknowable). */ running: boolean | null; /** ISO timestamp of the last observed run, or null. */ lastRunAt: string | null; lastDurationMs: number | null; lastStatus: ScheduleRunStatus | null; } /** Handed to each ScheduleManager at boot (mirrors QueueManagerContext). */ export interface ScheduleManagerContext { readonly moduleRef: ModuleRef; readonly config: ResolvedCoreConfig; } /** * SPI for a source of scheduled tasks. The `@nestjs/schedule` watcher implements * this directly (it already discovers the tasks + records runs), reading * `SchedulerRegistry` for schedule + next-run and merging its own last-run map. * * A `watchers` entry that structurally implements this SPI (has a `listTasks` * function) is auto-registered by `ScheduleManagerRegistry` — you do NOT also * need to list it in `TelescopeModuleOptions.scheduleManagers`. That option * remains for a standalone manager that isn't itself a `Watcher`. Listing the * same instance in both `watchers` and `scheduleManagers` is safe (it's inited * exactly once, deduped by identity). */ export interface ScheduleManager { init?(ctx: ScheduleManagerContext): void | Promise<void>; listTasks(ctx: ScheduleManagerContext): Promise<ScheduledTask[]>; } //# sourceMappingURL=schedule-manager.d.ts.map