{"version":3,"file":"index.cjs","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n  BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n  BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n  Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n  TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n  EclesiaIndexer,\n} from \"../indexer\";\nimport {\n  CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EclesiaIndexerConfig = {\n  startHeight?: number                                           // Block height to start indexing from\n  endHeight?: number                                             // Block height to stop indexing at (optional)\n  batchSize: number                                              // Number of blocks to process in parallel\n  modules: string[]                                              // List of module names to enable\n  getNextHeight: () => number | PromiseLike<number>             // Function to determine next block to process\n  logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n  rpcUrl: string                                                 // Tendermint RPC endpoint URL\n  chainId?: string                                               // Refuse to index if the RPC reports a different network\n  shouldProcessGenesis: () => Promise<boolean>                   // Whether to process genesis state\n  genesisPath?: string                                           // Path to genesis file\n  usePolling?: boolean                                           // Use polling instead of WebSocket subscription\n  pollingInterval?: number                                       // Interval between polls in milliseconds\n  minimal?: boolean                                              // Use minimal indexing mode (blocks only)\n  enableHealthcheck?: boolean                                    // Enable health check HTTP server\n  healthCheckPort?: number                                       // Port for health check HTTP server (default: 8888)\n  enablePrometheus?: boolean                                     // Enable Prometheus metrics server\n  prometheusPort?: number                                        // Port for Prometheus metrics server (default: 9090)\n  healthCheckHost?: string                                       // Address the health check server binds to (default: 0.0.0.0)\n  prometheusHost?: string                                        // Address the metrics server binds to (default: 0.0.0.0)\n  logFormat?: \"text\" | \"json\"                                    // Console log format (default: text)\n  maxRetries?: number                                            // Emit fatal-error after this many consecutive failed restarts; unlimited when unset\n  maxFailuresPerBlock?: number                                   // Consecutive processing failures on one block before fatal-error (default: 5)\n  onGenesisStart?: () => Promise<void>                           // Called before the genesis import begins, outside any transaction\n  onGenesisComplete?: () => Promise<void>                        // Called inside the final genesis transaction, right before it commits\n  init?: () => Promise<void>                                     // Custom initialization function\n  beginTransaction: () => Promise<void>                          // Function to begin database transaction\n  endTransaction: (status: boolean) => Promise<void>             // Function to end database transaction\n};\n\n/** @deprecated Misspelling kept for compatibility, use EclesiaIndexerConfig. Removed in 3.0. */\nexport type EcleciaIndexerConfig = EclesiaIndexerConfig;\n\n/** Queue for full indexing mode with validator data */\nexport type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;\n\n/** Queue for minimal indexing mode without validator data */\nexport type MinimalBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse]>;\n\n/** Union type for block queues */\nexport type BlockQueue = FullBlockQueue | MinimalBlockQueue;\n\n/** Utility type to add height, timestamp, and UUID to event types */\nexport type WithHeightAndUUID<T> = {\n  [K in keyof T]: T[K] & {\n    uuid?: string      // Unique identifier for event tracking\n    height?: number    // Block height when event occurred\n    timestamp?: string // Block timestamp when event occurred\n  };\n};\n\n/** Function signature for emitting events asynchronously */\nexport type EmitFunc<K extends keyof WithHeightAndUUID<EventMap>> = (\n  t: K,\n  e: WithHeightAndUUID<EventMap>[K],\n) => Promise<void | void[]>;\n\nexport type LogEvent = {\n  type: \"log\" | \"info\" | \"warning\" | \"error\" | \"verbose\" | \"transient\"\n  message: string\n};\nexport type UUIDEvent = {\n  uuid: string\n  error?: string\n  status: boolean\n};\nexport type Events = {\n  log: LogEvent\n  uuid: UUIDEvent\n  \"fatal-error\": {\n    error: Error\n    message: string\n    retryCount?: number\n    height?: number   // Set when one block failed repeatedly\n  }\n  begin_block: {\n    value: {\n      events: BlockResultsResponse[\"beginBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n      validators: Validator[] | undefined\n    }\n  }\n\n  block: {\n    value: {\n      block: BlockResponse\n      block_results: BlockResultsResponse | BlockResultsResponse38\n    }\n  }\n  end_block: {\n    value: BlockResultsResponse[\"endBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n  }\n  tx_events: {\n    value: BlockResultsResponse[\"results\"] | BlockResultsResponse38[\"results\"]\n  }\n  tx_memo: {\n    value: {\n      txHash: string\n      txBody: TxBody\n    }\n  }\n  _unhandled: {\n    type: string\n    event: unknown\n  }\n  \"periodic/small\": {\n    value: null\n  }\n  \"periodic/medium\": {\n    value: null\n  }\n  \"periodic/large\": {\n    value: null\n  }\n};\nexport type TxResult<T> = {\n  tx: T\n  events: Event[]\n};\n\n/** Interface that all indexing modules must implement */\nexport interface IndexingModule {\n  indexer: EclesiaIndexer                    // Reference to the main indexer instance\n  name: string                               // Unique module name\n  depends: string[]                          // Array of module names this module depends on\n  provides: string[]                         // Array of capabilities this module provides\n  setup: () => Promise<void>                 // Async setup function for database schema initialization\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  init: (...args: any[]) => void            // Initialization function called by the indexer\n}\n\n/**\n * Global event map. Modules add their own events through declaration merging:\n *\n *   declare global { interface EventMap extends MyModule.Events {} }\n *\n * Declared in a regular module (not an ambient .d.ts) so it is emitted into the\n * published declarations and consumers get typed events without extra setup.\n */\ndeclare global {\n  // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n  interface EventMap extends Events {\n  }\n}\n"],"mappings":""}