@@ -117,8 +117,7 @@ export type HandlerArgs<TBlock> = {
117117 abortSignal ?: AbortSignal ;
118118} ;
119119
120- export type IndexerConfig < TFilter , TBlock > = {
121- streamUrl ?: string ;
120+ export type BaseIndexerConfig < TFilter , TBlock > = {
122121 filter : TFilter ;
123122 finality ?: DataFinality ;
124123 clientOptions ?: CreateClientOptions ;
@@ -131,43 +130,68 @@ export type IndexerConfig<TFilter, TBlock> = {
131130 debug ?: boolean ;
132131} & IndexerStartingCursor ;
133132
133+ export type IndexerConfig < TFilter , TBlock > = BaseIndexerConfig <
134+ TFilter ,
135+ TBlock
136+ > & {
137+ streamUrl : string ;
138+ } ;
139+
140+ export type RpcIndexerConfig < TFilter , TBlock > = BaseIndexerConfig <
141+ TFilter ,
142+ TBlock
143+ > & {
144+ streamUrl ?: string ;
145+ } ;
146+
134147export type IndexerStreamConfig < TFilter , TBlock > =
135148 | StreamConfig < TFilter , TBlock >
136149 | RpcStreamConfig < TFilter , TBlock > ;
137150
138- export type IndexerWithStreamConfig < TFilter , TBlock > = IndexerConfig <
151+ export type IndexerWithDnaStreamConfig < TFilter , TBlock > = IndexerConfig <
139152 TFilter ,
140153 TBlock
141154> & {
142- streamConfig : IndexerStreamConfig < TFilter , TBlock > ;
155+ streamConfig : StreamConfig < TFilter , TBlock > ;
143156} ;
144157
158+ export type IndexerWithRpcStreamConfig < TFilter , TBlock > = RpcIndexerConfig <
159+ TFilter ,
160+ TBlock
161+ > & {
162+ streamConfig : RpcStreamConfig < TFilter , TBlock > ;
163+ } ;
164+
165+ export type IndexerWithStreamConfig < TFilter , TBlock > =
166+ | IndexerWithDnaStreamConfig < TFilter , TBlock >
167+ | IndexerWithRpcStreamConfig < TFilter , TBlock > ;
168+
145169export function defineIndexer < TFilter , TBlock > (
146170 streamConfig : StreamConfig < TFilter , TBlock > ,
147171) : (
148- config : IndexerConfig < TFilter , TBlock > & { streamUrl : string } ,
149- ) => IndexerWithStreamConfig < TFilter , TBlock > ;
172+ config : IndexerConfig < TFilter , TBlock > ,
173+ ) => IndexerWithDnaStreamConfig < TFilter , TBlock > ;
150174
151175export function defineIndexer < TFilter , TBlock > (
152176 streamConfig : RpcStreamConfig < TFilter , TBlock > ,
153177) : (
154- config : IndexerConfig < TFilter , TBlock > ,
155- ) => IndexerWithStreamConfig < TFilter , TBlock > ;
178+ config : RpcIndexerConfig < TFilter , TBlock > ,
179+ ) => IndexerWithRpcStreamConfig < TFilter , TBlock > ;
156180
157181export function defineIndexer < TFilter , TBlock > (
158182 streamConfig : IndexerStreamConfig < TFilter , TBlock > ,
159- ) {
183+ ) : unknown {
160184 return (
161- config : IndexerConfig < TFilter , TBlock > ,
162- ) : IndexerWithStreamConfig < TFilter , TBlock > => ( {
185+ config : IndexerConfig < TFilter , TBlock > | RpcIndexerConfig < TFilter , TBlock > ,
186+ ) => ( {
163187 streamConfig,
164188 ...config ,
165189 } ) ;
166190}
167191
168192export interface Indexer < TFilter , TBlock > {
169193 streamConfig : IndexerStreamConfig < TFilter , TBlock > ;
170- options : IndexerConfig < TFilter , TBlock > ;
194+ options : IndexerConfig < TFilter , TBlock > | RpcIndexerConfig < TFilter , TBlock > ;
171195 hooks : Hookable < IndexerHooks < TFilter , TBlock > > ;
172196}
173197
0 commit comments