@dudousxd/nestjs-telescope
Version:
Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.
35 lines • 1.82 kB
TypeScript
import type { RecordInput } from '../entry/entry.js';
/**
* A free-function record sink for boot-time integrations that need to emit
* Telescope entries before Nest DI has constructed `TelescopeService` — most
* notably a MikroORM query logger, which MikroORM constructs (and can start
* calling) at `MikroORM.init()`, well before `TelescopeModule` has wired
* anything. `telescopeRecord` forwards to a module-level sink that
* `TelescopeService`'s constructor binds automatically (and
* `onApplicationShutdown` clears) — mirrors `telescopeDump`'s pattern
* (`../dump/telescope-dump.js`).
*
* Entries emitted before the sink is bound — or after it's cleared — are
* DROPPED, not queued: there is no unbounded buffer waiting to replay boot
* noise once the module comes up. That's by design: buffering until bound
* risks unbounded memory growth if `TelescopeModule` is never imported, or
* takes a long time to boot. Boot noise is expected to be dropped, not
* delayed.
*/
type RecordSink = (input: RecordInput) => void;
/**
* Install (or clear, with `null`) the record sink. Called by
* `TelescopeService`'s lifecycle (constructor binds, shutdown clears) —
* hosts should not call this directly; it's also usable by tests/hosts that
* need to override the bound sink explicitly.
*/
export declare function setTelescopeRecordSink(fn: RecordSink | null): void;
/**
* Forward a boot-time record to the installed sink. A no-op — never throws,
* never buffers — until `TelescopeModule` has wired the sink (or after it's
* cleared on shutdown). Safe to call from anywhere, including code paths
* that run before Nest DI exists (ORM loggers, process hooks).
*/
export declare function telescopeRecord(input: RecordInput): void;
export {};
//# sourceMappingURL=telescope-record.d.ts.map