@thru/indexer 0.2.29 → 0.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -369,6 +369,58 @@ interface EventStream<TSchema extends SchemaDefinition = SchemaDefinition> {
369
369
  */
370
370
  declare function defineEventStream<TSchema extends SchemaDefinition>(definition: EventStreamDefinition<TSchema>): EventStream<TSchema>;
371
371
 
372
+ /**
373
+ * Runtime status and health types for the indexer supervisor.
374
+ */
375
+ type IndexerStreamKind = "event" | "account";
376
+ type IndexerStreamState = "idle" | "starting" | "running" | "retrying" | "stopped";
377
+ type IndexerErrorPhase = "starting" | "backfill" | "live" | "parse" | "commit" | "filterBatch" | "onCommit" | "supervisor";
378
+ interface NormalizedIndexerError {
379
+ name: string;
380
+ message: string;
381
+ code?: string | number;
382
+ phase: IndexerErrorPhase;
383
+ retryable: boolean;
384
+ streamName: string;
385
+ streamKind: IndexerStreamKind;
386
+ startSlot?: string;
387
+ checkpointSlot?: string;
388
+ endpointLabel?: string;
389
+ }
390
+ interface IndexerStreamCounters {
391
+ eventsReceived: number;
392
+ parserNulls: number;
393
+ parserErrors: number;
394
+ parseValidationErrors: number;
395
+ commitErrors: number;
396
+ filterBatchErrors: number;
397
+ onCommitErrors: number;
398
+ recordsProcessed: number;
399
+ batchesCommitted: number;
400
+ }
401
+ interface IndexerStreamStatus {
402
+ name: string;
403
+ kind: IndexerStreamKind;
404
+ state: IndexerStreamState;
405
+ checkpointSlot: string | null;
406
+ lastProcessedSlot: string | null;
407
+ lastEventAt: string | null;
408
+ stale: boolean;
409
+ restartCount: number;
410
+ lastStartedAt: string | null;
411
+ lastErrorAt: string | null;
412
+ lastError: NormalizedIndexerError | null;
413
+ counters: IndexerStreamCounters;
414
+ }
415
+ interface IndexerStatus {
416
+ running: boolean;
417
+ shutdownRequested: boolean;
418
+ startedAt: string | null;
419
+ uptimeMs: number;
420
+ healthy: boolean;
421
+ streams: IndexerStreamStatus[];
422
+ }
423
+
372
424
  /**
373
425
  * Event stream processor.
374
426
  *
@@ -765,6 +817,14 @@ interface IndexerConfig {
765
817
  pageSize?: number;
766
818
  /** Log level (default: "info") */
767
819
  logLevel?: "debug" | "info" | "warn" | "error";
820
+ /** Human-readable endpoint label included in normalized stream errors */
821
+ endpointLabel?: string;
822
+ /** Initial supervisor restart backoff in milliseconds (default: 1000) */
823
+ supervisorInitialBackoffMs?: number;
824
+ /** Maximum supervisor restart backoff in milliseconds (default: 30000) */
825
+ supervisorMaxBackoffMs?: number;
826
+ /** Mark running streams unhealthy when no activity is seen for this long (default: 300000, disabled with 0) */
827
+ streamStaleMs?: number;
768
828
  /**
769
829
  * Validate parse output at runtime using Zod schemas.
770
830
  * Useful for development to catch type mismatches early.
@@ -829,6 +889,8 @@ declare class Indexer {
829
889
  private abortController;
830
890
  private running;
831
891
  private shutdownRequested;
892
+ private startedAtMs;
893
+ private streamStatuses;
832
894
  constructor(config: IndexerConfig);
833
895
  /**
834
896
  * Check if the checkpoint table exists in the database.
@@ -855,6 +917,22 @@ declare class Indexer {
855
917
  * Check if the indexer is currently running.
856
918
  */
857
919
  isRunning(): boolean;
920
+ /**
921
+ * Get the current in-memory runtime status for every configured stream.
922
+ */
923
+ getStatus(): IndexerStatus;
924
+ private initializeStreamStatuses;
925
+ private createInitialStreamStatus;
926
+ private statusKey;
927
+ private statusFor;
928
+ private resultForStream;
929
+ private createObserver;
930
+ private runEventStreamSupervisor;
931
+ private runAccountStreamSupervisor;
932
+ private runStreamSupervisor;
933
+ private supervisorBackoffMs;
934
+ private isStreamStale;
935
+ private delay;
858
936
  }
859
937
 
860
- export { type AccountStream, type AccountStreamDefinition, type AnyColumnDef, type ApiConfig, type Checkpoint, type ColumnBuilder, type ColumnDef, type Columns, type DatabaseClient, type EventStream, type EventStreamDefinition, type HookContext, Indexer, type IndexerConfig, type IndexerResult, type InferInsert, type InferRow, type SchemaDefinition, type StreamBatch, checkpointTable, columnBuilder, defineAccountStream, defineEventStream, deleteCheckpoint, generateZodSchema, getAllCheckpoints, getCheckpoint, getSchemaExports, t, updateCheckpoint, validateParsedData };
938
+ export { type AccountStream, type AccountStreamDefinition, type AnyColumnDef, type ApiConfig, type Checkpoint, type ColumnBuilder, type ColumnDef, type Columns, type DatabaseClient, type EventStream, type EventStreamDefinition, type HookContext, Indexer, type IndexerConfig, type IndexerResult, type IndexerStatus, type IndexerStreamKind, type IndexerStreamState, type IndexerStreamStatus, type InferInsert, type InferRow, type NormalizedIndexerError, type SchemaDefinition, type StreamBatch, checkpointTable, columnBuilder, defineAccountStream, defineEventStream, deleteCheckpoint, generateZodSchema, getAllCheckpoints, getCheckpoint, getSchemaExports, t, updateCheckpoint, validateParsedData };