@thru/replay 0.2.21 → 0.2.22

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.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Transport, Interceptor, CallOptions } from '@connectrpc/connect';
2
- import { ListBlocksRequest, ListBlocksResponse, StreamBlocksRequest, StreamBlocksResponse, ListTransactionsRequest, ListTransactionsResponse, StreamTransactionsRequest, StreamTransactionsResponse, ListEventsRequest, ListEventsResponse, StreamEventsRequest, StreamEventsResponse, GetAccountRequest, Account, ListAccountsRequest, ListAccountsResponse, StreamAccountUpdatesRequest, StreamAccountUpdatesResponse, GetHeightResponse, Filter, BlockView, ConsensusStatus, Block, Transaction, Event, AccountView, AccountMeta, AccountUpdate } from '@thru/proto';
3
- export { Account, AccountFlags, AccountMeta, AccountPage, AccountUpdate, AccountView, BlockFinished, Event, Filter, FilterParamValue, FilterParamValueSchema, FilterSchema, GetAccountRequest, ListAccountsRequest, ListAccountsResponse, Pubkey as ProtoPubkey, Signature as ProtoSignature, StreamAccountUpdatesRequest, StreamAccountUpdatesResponse } from '@thru/proto';
2
+ import { GetAccountRequest, Account, ListAccountsRequest, ListAccountsResponse, StreamAccountUpdatesRequest, StreamAccountUpdatesResponse, ListBlocksRequest, ListBlocksResponse, StreamBlocksRequest, StreamBlocksResponse, ListTransactionsRequest, ListTransactionsResponse, StreamTransactionsRequest, StreamTransactionsResponse, ListEventsRequest, ListEventsResponse, StreamEventsRequest, StreamEventsResponse, GetHeightResponse, GetChainInfoRequest, GetChainInfoResponse, Filter, BlockView, ConsensusStatus, Block, Transaction, Event, AccountMeta, AccountView, AccountUpdate } from '@thru/sdk/proto';
3
+ export { Account, AccountFlags, AccountMeta, AccountPage, AccountUpdate, AccountView, BlockFinished, Event, Filter, FilterParamValue, FilterParamValueSchema, FilterSchema, GetAccountRequest, ListAccountsRequest, ListAccountsResponse, Pubkey as ProtoPubkey, Signature as ProtoSignature, StreamAccountUpdatesRequest, StreamAccountUpdatesResponse } from '@thru/sdk/proto';
4
4
 
5
5
  interface ChainClientOptions {
6
6
  baseUrl?: string;
@@ -39,7 +39,24 @@ declare class ChainClient implements ReplayDataSource {
39
39
  private readonly query;
40
40
  private readonly streaming;
41
41
  private readonly callOptions?;
42
+ /**
43
+ * The HTTP/2 session manager owned by this client. Only set when the client
44
+ * created its own gRPC transport (i.e., `options.transport` was not provided).
45
+ * `close()` uses this to tear down the underlying persistent connection.
46
+ */
47
+ private readonly sessionManager;
48
+ private closed;
42
49
  constructor(options: ChainClientOptions);
50
+ /**
51
+ * Close the underlying HTTP/2 session, if this client owns one. Idempotent.
52
+ *
53
+ * Callers are responsible for ensuring that no in-flight RPCs or streams
54
+ * are still being awaited on this client — pending requests will fail.
55
+ *
56
+ * If the client was constructed with an externally-supplied `transport`,
57
+ * `close()` is a no-op; the caller owns the transport's lifecycle.
58
+ */
59
+ close(): void;
43
60
  getAccount(request: Partial<GetAccountRequest>): Promise<Account>;
44
61
  listAccounts(request: Partial<ListAccountsRequest>): Promise<ListAccountsResponse>;
45
62
  listBlocks(request: Partial<ListBlocksRequest>): Promise<ListBlocksResponse>;
@@ -48,10 +65,11 @@ declare class ChainClient implements ReplayDataSource {
48
65
  streamTransactions(request: Partial<StreamTransactionsRequest>): AsyncIterable<StreamTransactionsResponse>;
49
66
  listEvents(request: Partial<ListEventsRequest>): Promise<ListEventsResponse>;
50
67
  streamEvents(request: Partial<StreamEventsRequest>): AsyncIterable<StreamEventsResponse>;
51
- private createTransport;
68
+ private createOwnedTransport;
52
69
  private createHeaderInterceptor;
53
70
  streamAccountUpdates(request: Partial<StreamAccountUpdatesRequest>): AsyncIterable<StreamAccountUpdatesResponse>;
54
71
  getHeight(): Promise<GetHeightResponse>;
72
+ getChainInfo(request?: Partial<GetChainInfoRequest>): Promise<GetChainInfoResponse>;
55
73
  }
56
74
 
57
75
  type Slot = bigint;
@@ -101,6 +119,7 @@ interface ReplayMetrics {
101
119
  interface ReconnectSources<T, Cursor = unknown> {
102
120
  subscribeLive: LiveSubscriber<T>;
103
121
  fetchBackfill?: BackfillFetcher<T, Cursor>;
122
+ dispose?: () => void;
104
123
  }
105
124
  interface ReplayConfig<T, Cursor = unknown> {
106
125
  startSlot: Slot;
@@ -111,6 +130,8 @@ interface ReplayConfig<T, Cursor = unknown> {
111
130
  extractKey?: (item: T) => string;
112
131
  logger?: ReplayLogger;
113
132
  resubscribeOnEnd?: boolean;
133
+ signal?: AbortSignal;
134
+ dispose?: () => void;
114
135
  /**
115
136
  * Called on reconnection to get fresh data sources.
116
137
  * When provided, creates new client/transport for each reconnection attempt.
@@ -143,11 +164,15 @@ interface BlockReplayOptions {
143
164
  minConsensus?: ConsensusStatus;
144
165
  logger?: ReplayLogger;
145
166
  resubscribeOnEnd?: boolean;
167
+ signal?: AbortSignal;
146
168
  }
147
169
  declare function createBlockReplay(options: BlockReplayOptions): ReplayStream<Block, string>;
148
170
 
149
171
  interface TransactionReplayOptions {
150
- client: TransactionSource;
172
+ /** Client instance for initial connection. Optional if clientFactory provided. */
173
+ client?: TransactionSource;
174
+ /** Factory to create fresh clients on reconnection. Enables robust reconnection. */
175
+ clientFactory?: () => TransactionSource;
151
176
  startSlot: Slot;
152
177
  safetyMargin?: bigint;
153
178
  pageSize?: number;
@@ -156,6 +181,7 @@ interface TransactionReplayOptions {
156
181
  returnEvents?: boolean;
157
182
  logger?: ReplayLogger;
158
183
  resubscribeOnEnd?: boolean;
184
+ signal?: AbortSignal;
159
185
  }
160
186
  declare function createTransactionReplay(options: TransactionReplayOptions): ReplayStream<Transaction, string>;
161
187
 
@@ -175,6 +201,7 @@ interface EventReplayOptions {
175
201
  filter?: Filter;
176
202
  logger?: ReplayLogger;
177
203
  resubscribeOnEnd?: boolean;
204
+ signal?: AbortSignal;
178
205
  }
179
206
  declare function createEventReplay(options: EventReplayOptions): ReplayStream<Event, string>;
180
207
 
@@ -287,6 +314,8 @@ interface AccountsByOwnerReplayOptions {
287
314
  onBackfillComplete?: (highestSlot: bigint) => void;
288
315
  /** Logger for debug/info/warn/error messages (default: NOOP_LOGGER) */
289
316
  logger?: ReplayLogger;
317
+ /** Optional signal to stop backfill/streaming without reconnecting. */
318
+ signal?: AbortSignal;
290
319
  }
291
320
  /**
292
321
  * Create an async iterable that replays all accounts owned by a program.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Transport, Interceptor, CallOptions } from '@connectrpc/connect';
2
- import { ListBlocksRequest, ListBlocksResponse, StreamBlocksRequest, StreamBlocksResponse, ListTransactionsRequest, ListTransactionsResponse, StreamTransactionsRequest, StreamTransactionsResponse, ListEventsRequest, ListEventsResponse, StreamEventsRequest, StreamEventsResponse, GetAccountRequest, Account, ListAccountsRequest, ListAccountsResponse, StreamAccountUpdatesRequest, StreamAccountUpdatesResponse, GetHeightResponse, Filter, BlockView, ConsensusStatus, Block, Transaction, Event, AccountView, AccountMeta, AccountUpdate } from '@thru/proto';
3
- export { Account, AccountFlags, AccountMeta, AccountPage, AccountUpdate, AccountView, BlockFinished, Event, Filter, FilterParamValue, FilterParamValueSchema, FilterSchema, GetAccountRequest, ListAccountsRequest, ListAccountsResponse, Pubkey as ProtoPubkey, Signature as ProtoSignature, StreamAccountUpdatesRequest, StreamAccountUpdatesResponse } from '@thru/proto';
2
+ import { GetAccountRequest, Account, ListAccountsRequest, ListAccountsResponse, StreamAccountUpdatesRequest, StreamAccountUpdatesResponse, ListBlocksRequest, ListBlocksResponse, StreamBlocksRequest, StreamBlocksResponse, ListTransactionsRequest, ListTransactionsResponse, StreamTransactionsRequest, StreamTransactionsResponse, ListEventsRequest, ListEventsResponse, StreamEventsRequest, StreamEventsResponse, GetHeightResponse, GetChainInfoRequest, GetChainInfoResponse, Filter, BlockView, ConsensusStatus, Block, Transaction, Event, AccountMeta, AccountView, AccountUpdate } from '@thru/sdk/proto';
3
+ export { Account, AccountFlags, AccountMeta, AccountPage, AccountUpdate, AccountView, BlockFinished, Event, Filter, FilterParamValue, FilterParamValueSchema, FilterSchema, GetAccountRequest, ListAccountsRequest, ListAccountsResponse, Pubkey as ProtoPubkey, Signature as ProtoSignature, StreamAccountUpdatesRequest, StreamAccountUpdatesResponse } from '@thru/sdk/proto';
4
4
 
5
5
  interface ChainClientOptions {
6
6
  baseUrl?: string;
@@ -39,7 +39,24 @@ declare class ChainClient implements ReplayDataSource {
39
39
  private readonly query;
40
40
  private readonly streaming;
41
41
  private readonly callOptions?;
42
+ /**
43
+ * The HTTP/2 session manager owned by this client. Only set when the client
44
+ * created its own gRPC transport (i.e., `options.transport` was not provided).
45
+ * `close()` uses this to tear down the underlying persistent connection.
46
+ */
47
+ private readonly sessionManager;
48
+ private closed;
42
49
  constructor(options: ChainClientOptions);
50
+ /**
51
+ * Close the underlying HTTP/2 session, if this client owns one. Idempotent.
52
+ *
53
+ * Callers are responsible for ensuring that no in-flight RPCs or streams
54
+ * are still being awaited on this client — pending requests will fail.
55
+ *
56
+ * If the client was constructed with an externally-supplied `transport`,
57
+ * `close()` is a no-op; the caller owns the transport's lifecycle.
58
+ */
59
+ close(): void;
43
60
  getAccount(request: Partial<GetAccountRequest>): Promise<Account>;
44
61
  listAccounts(request: Partial<ListAccountsRequest>): Promise<ListAccountsResponse>;
45
62
  listBlocks(request: Partial<ListBlocksRequest>): Promise<ListBlocksResponse>;
@@ -48,10 +65,11 @@ declare class ChainClient implements ReplayDataSource {
48
65
  streamTransactions(request: Partial<StreamTransactionsRequest>): AsyncIterable<StreamTransactionsResponse>;
49
66
  listEvents(request: Partial<ListEventsRequest>): Promise<ListEventsResponse>;
50
67
  streamEvents(request: Partial<StreamEventsRequest>): AsyncIterable<StreamEventsResponse>;
51
- private createTransport;
68
+ private createOwnedTransport;
52
69
  private createHeaderInterceptor;
53
70
  streamAccountUpdates(request: Partial<StreamAccountUpdatesRequest>): AsyncIterable<StreamAccountUpdatesResponse>;
54
71
  getHeight(): Promise<GetHeightResponse>;
72
+ getChainInfo(request?: Partial<GetChainInfoRequest>): Promise<GetChainInfoResponse>;
55
73
  }
56
74
 
57
75
  type Slot = bigint;
@@ -101,6 +119,7 @@ interface ReplayMetrics {
101
119
  interface ReconnectSources<T, Cursor = unknown> {
102
120
  subscribeLive: LiveSubscriber<T>;
103
121
  fetchBackfill?: BackfillFetcher<T, Cursor>;
122
+ dispose?: () => void;
104
123
  }
105
124
  interface ReplayConfig<T, Cursor = unknown> {
106
125
  startSlot: Slot;
@@ -111,6 +130,8 @@ interface ReplayConfig<T, Cursor = unknown> {
111
130
  extractKey?: (item: T) => string;
112
131
  logger?: ReplayLogger;
113
132
  resubscribeOnEnd?: boolean;
133
+ signal?: AbortSignal;
134
+ dispose?: () => void;
114
135
  /**
115
136
  * Called on reconnection to get fresh data sources.
116
137
  * When provided, creates new client/transport for each reconnection attempt.
@@ -143,11 +164,15 @@ interface BlockReplayOptions {
143
164
  minConsensus?: ConsensusStatus;
144
165
  logger?: ReplayLogger;
145
166
  resubscribeOnEnd?: boolean;
167
+ signal?: AbortSignal;
146
168
  }
147
169
  declare function createBlockReplay(options: BlockReplayOptions): ReplayStream<Block, string>;
148
170
 
149
171
  interface TransactionReplayOptions {
150
- client: TransactionSource;
172
+ /** Client instance for initial connection. Optional if clientFactory provided. */
173
+ client?: TransactionSource;
174
+ /** Factory to create fresh clients on reconnection. Enables robust reconnection. */
175
+ clientFactory?: () => TransactionSource;
151
176
  startSlot: Slot;
152
177
  safetyMargin?: bigint;
153
178
  pageSize?: number;
@@ -156,6 +181,7 @@ interface TransactionReplayOptions {
156
181
  returnEvents?: boolean;
157
182
  logger?: ReplayLogger;
158
183
  resubscribeOnEnd?: boolean;
184
+ signal?: AbortSignal;
159
185
  }
160
186
  declare function createTransactionReplay(options: TransactionReplayOptions): ReplayStream<Transaction, string>;
161
187
 
@@ -175,6 +201,7 @@ interface EventReplayOptions {
175
201
  filter?: Filter;
176
202
  logger?: ReplayLogger;
177
203
  resubscribeOnEnd?: boolean;
204
+ signal?: AbortSignal;
178
205
  }
179
206
  declare function createEventReplay(options: EventReplayOptions): ReplayStream<Event, string>;
180
207
 
@@ -287,6 +314,8 @@ interface AccountsByOwnerReplayOptions {
287
314
  onBackfillComplete?: (highestSlot: bigint) => void;
288
315
  /** Logger for debug/info/warn/error messages (default: NOOP_LOGGER) */
289
316
  logger?: ReplayLogger;
317
+ /** Optional signal to stop backfill/streaming without reconnecting. */
318
+ signal?: AbortSignal;
290
319
  }
291
320
  /**
292
321
  * Create an async iterable that replays all accounts owned by a program.