@secondlayer/sdk 15.0.0 → 15.0.2

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.
@@ -147,6 +147,7 @@ type IndexEventBase = {
147
147
  tx_contract_id?: string | null;
148
148
  tx_function_name?: string | null;
149
149
  };
150
+ /** A fungible-token transfer event. */
150
151
  type IndexFtTransfer = IndexEventBase & {
151
152
  event_type: "ft_transfer";
152
153
  asset_identifier: string;
@@ -154,6 +155,7 @@ type IndexFtTransfer = IndexEventBase & {
154
155
  recipient: string;
155
156
  amount: string;
156
157
  };
158
+ /** A non-fungible-token transfer event. */
157
159
  type IndexNftTransfer = IndexEventBase & {
158
160
  event_type: "nft_transfer";
159
161
  asset_identifier: string;
@@ -161,6 +163,7 @@ type IndexNftTransfer = IndexEventBase & {
161
163
  recipient: string;
162
164
  value: string;
163
165
  };
166
+ /** An STX transfer event. */
164
167
  type IndexStxTransfer = IndexEventBase & {
165
168
  event_type: "stx_transfer";
166
169
  sender: string;
@@ -168,16 +171,19 @@ type IndexStxTransfer = IndexEventBase & {
168
171
  amount: string;
169
172
  memo: string | null;
170
173
  };
174
+ /** An STX mint event. */
171
175
  type IndexStxMint = IndexEventBase & {
172
176
  event_type: "stx_mint";
173
177
  recipient: string;
174
178
  amount: string;
175
179
  };
180
+ /** An STX burn event. */
176
181
  type IndexStxBurn = IndexEventBase & {
177
182
  event_type: "stx_burn";
178
183
  sender: string;
179
184
  amount: string;
180
185
  };
186
+ /** An STX lock event with its unlock height. */
181
187
  type IndexStxLock = IndexEventBase & {
182
188
  event_type: "stx_lock";
183
189
  sender: string;
@@ -186,30 +192,35 @@ type IndexStxLock = IndexEventBase & {
186
192
  unlock_height: string | null;
187
193
  };
188
194
  };
195
+ /** A fungible-token mint event. */
189
196
  type IndexFtMint = IndexEventBase & {
190
197
  event_type: "ft_mint";
191
198
  asset_identifier: string;
192
199
  recipient: string;
193
200
  amount: string;
194
201
  };
202
+ /** A fungible-token burn event. */
195
203
  type IndexFtBurn = IndexEventBase & {
196
204
  event_type: "ft_burn";
197
205
  asset_identifier: string;
198
206
  sender: string;
199
207
  amount: string;
200
208
  };
209
+ /** A non-fungible-token mint event. */
201
210
  type IndexNftMint = IndexEventBase & {
202
211
  event_type: "nft_mint";
203
212
  asset_identifier: string;
204
213
  recipient: string;
205
214
  value: string;
206
215
  };
216
+ /** A non-fungible-token burn event. */
207
217
  type IndexNftBurn = IndexEventBase & {
208
218
  event_type: "nft_burn";
209
219
  asset_identifier: string;
210
220
  sender: string;
211
221
  value: string;
212
222
  };
223
+ /** A contract `print` event with its topic and value. */
213
224
  type IndexPrint = IndexEventBase & {
214
225
  event_type: "print";
215
226
  payload: {
@@ -218,6 +229,7 @@ type IndexPrint = IndexEventBase & {
218
229
  raw_value: string | null;
219
230
  };
220
231
  };
232
+ /** A contract call made from inside another contract call. */
221
233
  type IndexNestedContractCall = IndexEventBase & {
222
234
  event_type: "nested_contract_call";
223
235
  sender: string | null;
@@ -226,23 +238,27 @@ type IndexNestedContractCall = IndexEventBase & {
226
238
  function_args: unknown;
227
239
  raw_result: string | null;
228
240
  };
241
+ /** A contract data variable write. */
229
242
  type IndexVarSet = IndexEventBase & {
230
243
  event_type: "var_set";
231
244
  var_name: string;
232
245
  raw_value: string;
233
246
  };
247
+ /** A contract map entry overwrite. */
234
248
  type IndexMapSet = IndexEventBase & {
235
249
  event_type: "map_set";
236
250
  map: string;
237
251
  raw_key: string;
238
252
  raw_value: string;
239
253
  };
254
+ /** A new contract map entry. */
240
255
  type IndexMapInsert = IndexEventBase & {
241
256
  event_type: "map_insert";
242
257
  map: string;
243
258
  raw_key: string;
244
259
  raw_value: string;
245
260
  };
261
+ /** A contract map entry deletion. */
246
262
  type IndexMapDelete = IndexEventBase & {
247
263
  event_type: "map_delete";
248
264
  map: string;
@@ -251,6 +267,7 @@ type IndexMapDelete = IndexEventBase & {
251
267
  /** Decoded chain event, discriminated by `event_type`. */
252
268
  type IndexEvent = IndexFtTransfer | IndexNftTransfer | IndexStxTransfer | IndexStxMint | IndexStxBurn | IndexStxLock | IndexFtMint | IndexFtBurn | IndexNftMint | IndexNftBurn | IndexPrint | IndexNestedContractCall | IndexVarSet | IndexMapSet | IndexMapInsert | IndexMapDelete;
253
269
  import { StreamsWireEvent as StreamsWireEvent2, RuneEtchEntry, RuneEventPayload, StreamsEventPayload } from "@secondlayer/shared/streams-rows";
270
+ /** The chain tip: latest block, Bitcoin anchor, and finality boundary. */
254
271
  type StreamsTip = {
255
272
  block_height: number;
256
273
  block_hash: string;
@@ -270,15 +287,19 @@ type StreamsTip = {
270
287
  /** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
271
288
  oldest_cursor?: string | null;
272
289
  };
273
- /** `chain=bitcoin` tip (plan 059) — no `burn_block_height`/retention fields,
274
- * since Bitcoin has no burn chain of its own and Runes reads have no
275
- * retention ladder. Returned by `tip({ chain: "bitcoin" })`. */
290
+ /**
291
+ * The Bitcoin tip, without burn-chain or retention fields.
292
+ *
293
+ * Bitcoin has no burn chain of its own, and Runes reads have no retention
294
+ * ladder. Returned by `tip({ chain: "bitcoin" })`.
295
+ */
276
296
  type StreamsBitcoinTip = {
277
297
  block_height: number;
278
298
  block_hash: string;
279
299
  finalized_height: number;
280
300
  lag_seconds: number;
281
301
  };
302
+ /** A canonical Stacks block with its Bitcoin anchor. */
282
303
  type StreamsCanonicalBlock = {
283
304
  block_height: number;
284
305
  block_hash: string;
@@ -286,7 +307,7 @@ type StreamsCanonicalBlock = {
286
307
  burn_block_hash: string | null;
287
308
  is_canonical: true;
288
309
  };
289
- /** `chain=bitcoin` canonical block (plan 059) — no burn-chain fields. */
310
+ /** A Bitcoin canonical block, without burn-chain fields. */
290
311
  type StreamsBitcoinCanonicalBlock = {
291
312
  block_height: number;
292
313
  block_hash: string;
@@ -307,6 +328,7 @@ type StreamsReorg = {
307
328
  */
308
329
  new_canonical_tip: string;
309
330
  };
331
+ /** One page of events with the next cursor, tip, and reorgs. */
310
332
  type StreamsEventsEnvelope<
311
333
  TEvent = StreamsEvent,
312
334
  TTip = StreamsTip
@@ -316,24 +338,30 @@ type StreamsEventsEnvelope<
316
338
  tip: TTip;
317
339
  reorgs: StreamsReorg[];
318
340
  };
341
+ /** One page of events with the tip and reorgs, no cursor. */
319
342
  type StreamsEventsListEnvelope<
320
343
  TEvent = StreamsEvent,
321
344
  TTip = StreamsTip
322
345
  > = Omit<StreamsEventsEnvelope<TEvent, TTip>, "next_cursor">;
323
- /** The StreamsEvent union narrowed to a `types` selection — what a
324
- * const-generic `types: ["ft_transfer"]` buys at the type level. */
346
+ /**
347
+ * The event union narrowed to a `types` selection.
348
+ *
349
+ * A const-generic `types: ["ft_transfer"]` narrows the event type.
350
+ */
325
351
  type StreamsEventOfTypes<T extends readonly StreamsEventType[]> = Extract<StreamsEvent, {
326
352
  event_type: T[number];
327
353
  }>;
354
+ /** A starting point and limit for listing reorgs. */
328
355
  type StreamsReorgsListParams = {
329
356
  since: string;
330
357
  limit?: number;
331
358
  };
359
+ /** A list of reorgs and the cursor to resume from. */
332
360
  type StreamsReorgsListEnvelope = {
333
361
  reorgs: StreamsReorg[];
334
362
  next_since: string | null;
335
363
  };
336
- /** A filter that matches a single value or any value in a list. */
364
+ /** A single value or a list of values to match. */
337
365
  type StreamsFilterValue = string | readonly string[];
338
366
  /**
339
367
  * One labelled filter group. Fields inside a group AND together; groups in a
@@ -363,14 +391,15 @@ type StreamsEventForFilter<
363
391
  }> : Extract<StreamsEvent, {
364
392
  event_type: T;
365
393
  }> : D extends true ? IndexEvent : StreamsEvent;
394
+ /** Cursor, height range, and limit shared by every list call. */
366
395
  type StreamsEventsListParamsCommon = {
367
396
  cursor?: string | null;
368
397
  fromHeight?: number;
369
398
  toHeight?: number;
370
399
  limit?: number;
371
400
  };
372
- /** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since
373
- * before plan 059. */
401
+ /** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since before Runes events
402
+ * were added. */
374
403
  type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
375
404
  chain?: "stacks";
376
405
  /** `vm` reads ordinal. Omit for Streams 1.0. */
@@ -390,12 +419,13 @@ type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
390
419
  filters?: StreamsFilterMap;
391
420
  };
392
421
  /**
393
- * `chain: "bitcoin"` (plan 059) — Runes events, own cursor space. `types` is
394
- * restricted to {@link RuneEventType} at the type level, so e.g.
395
- * `{ chain: "bitcoin", types: ["ft_transfer"] }` is a compile error rather
396
- * than a silent 400 at request time. `contractId`/`sender`/`recipient`/
397
- * `assetIdentifier`/`filters`/`clock` don't exist on this branch — they're
398
- * Stacks-only (the server 400s on them too).
422
+ * List options for Runes events, with their own cursor space.
423
+ *
424
+ * `types` is restricted to `RuneEventType` at the type level, so e.g. `{ chain:
425
+ * "bitcoin", types: ["ft_transfer"] }` is a compile error rather than a silent
426
+ * 400 at request time. `contractId`, `sender`, `recipient`, `assetIdentifier`,
427
+ * `filters`, and `clock` don't exist on this branch; they're Stacks-only (the
428
+ * server 400s on them too).
399
429
  */
400
430
  type StreamsEventsBitcoinListParams = StreamsEventsListParamsCommon & {
401
431
  chain: "bitcoin";
@@ -406,7 +436,9 @@ type StreamsEventsBitcoinListParams = StreamsEventsListParamsCommon & {
406
436
  /** A mainnet address. */
407
437
  address?: string;
408
438
  };
439
+ /** Chain, cursor, height range, and filters for listing Streams events. */
409
440
  type StreamsEventsListParams = StreamsEventsStacksListParams | StreamsEventsBitcoinListParams;
441
+ /** Cursor, batching, and stop options shared by every event stream. */
410
442
  type StreamsEventsStreamCommon = {
411
443
  fromCursor?: string | null;
412
444
  batchSize?: number;
@@ -415,8 +447,12 @@ type StreamsEventsStreamCommon = {
415
447
  maxEmptyPolls?: number;
416
448
  signal?: AbortSignal;
417
449
  };
418
- /** `chain: "stacks"` (default, omit `chain` entirely) — matches
419
- * {@link StreamsEventsStacksListParams}. */
450
+ /**
451
+ * Stream options for Stacks events, the default chain.
452
+ *
453
+ * `chain: "stacks"` is the default, so omit `chain` entirely. Matches
454
+ * `StreamsEventsStacksListParams`.
455
+ */
420
456
  type StreamsEventsStreamStacksParams = StreamsEventsStreamCommon & {
421
457
  chain?: "stacks";
422
458
  types?: readonly StreamsEventType[];
@@ -428,11 +464,14 @@ type StreamsEventsStreamStacksParams = StreamsEventsStreamCommon & {
428
464
  /** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
429
465
  filters?: StreamsFilterMap;
430
466
  };
431
- /** `chain: "bitcoin"` (plan 059/061) — Runes events, tailed the same way as
432
- * the Stacks default. `types` is restricted to {@link RuneEventType} at the
433
- * type level, matching {@link StreamsEventsBitcoinListParams}.
434
- * `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
435
- * on this branch — they're Stacks-only. */
467
+ /**
468
+ * Stream options for Runes events, tailed like the Stacks default.
469
+ *
470
+ * `types` is restricted to `RuneEventType` at the type level, matching
471
+ * `StreamsEventsBitcoinListParams`. `contractId`, `sender`, `recipient`,
472
+ * `assetIdentifier`, and `filters` don't exist on this branch; they're
473
+ * Stacks-only.
474
+ */
436
475
  type StreamsEventsStreamBitcoinParams = StreamsEventsStreamCommon & {
437
476
  chain: "bitcoin";
438
477
  types?: readonly RuneEventType[];
@@ -486,9 +525,12 @@ type StreamsEventsSubscribeStacksParams = StreamsEventsSubscribeCommon & {
486
525
  */
487
526
  onEvent: (event: StreamsEvent) => void | Promise<void>;
488
527
  };
489
- /** `chain: "bitcoin"` (plan 059/061) — Runes events pushed live, on their own
490
- * cursor space. `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters`
491
- * don't exist on this branch — they're Stacks-only. */
528
+ /**
529
+ * Options for pushing Runes events live, on their own cursor space.
530
+ *
531
+ * `contractId`, `sender`, `recipient`, `assetIdentifier`, and `filters` don't
532
+ * exist on this branch; they're Stacks-only.
533
+ */
492
534
  type StreamsEventsSubscribeBitcoinParams = StreamsEventsSubscribeCommon & {
493
535
  chain: "bitcoin";
494
536
  types?: readonly RuneEventType[];
@@ -579,6 +621,7 @@ type StreamsBatchContext = ConsumerBatchContext;
579
621
  type StreamsReorgContext = {
580
622
  cursor: string | null;
581
623
  };
624
+ /** Options for consuming Streams events: cursor, batching, filters, handler. */
582
625
  type StreamsEventsConsumeParams<
583
626
  TTx = never,
584
627
  D extends boolean = false,
@@ -696,13 +739,14 @@ type StreamsEventsConsumeParams<
696
739
  wake?: () => Promise<void>;
697
740
  };
698
741
  /**
699
- * `chain: "bitcoin"` (plan 059/061) — the checkpointed sweep over Runes
700
- * events. A separate, simpler type from {@link StreamsEventsConsumeParams}
701
- * rather than a widened union member: `filters`/`on`/`decoded` are Stacks-only
702
- * concepts (labelled OR-groups and Index-shaped projection have no Runes
703
- * equivalent yet), so `onBatch` is the only way in and is required. Reorg
704
- * rewind still works the same way (bitcoin reorgs carry the same
705
- * `fork_point_height` + `new_canonical_tip` shape as Stacks ones).
742
+ * Options for the checkpointed sweep over Runes events.
743
+ *
744
+ * A separate, simpler type from `StreamsEventsConsumeParams` rather than a
745
+ * widened union member: `filters`, `on`, and `decoded` are Stacks-only concepts
746
+ * (labelled OR-groups and Index-shaped projection have no Runes equivalent
747
+ * yet), so `onBatch` is the only way in and is required. Reorg rewind still
748
+ * works the same way (bitcoin reorgs carry the same `fork_point_height` and
749
+ * `new_canonical_tip` shape as Stacks ones).
706
750
  */
707
751
  type StreamsEventsConsumeBitcoinParams<TTx = never> = {
708
752
  chain: "bitcoin";
@@ -735,9 +779,10 @@ type StreamsEventsConsumeBitcoinParams<TTx = never> = {
735
779
  wake?: () => Promise<void>;
736
780
  };
737
781
  /**
738
- * One yielded page from {@link StreamsClient.consume} — the
739
- * `GET /v1/streams/events` envelope verbatim, with `next_cursor` renamed to
740
- * `cursor` (the checkpoint to persist and resume from).
782
+ * One page yielded by `consume`, with `cursor` to persist and resume.
783
+ *
784
+ * It is the `GET /v1/streams/events` envelope verbatim, with `next_cursor`
785
+ * renamed to `cursor`.
741
786
  */
742
787
  type StreamsBatch<
743
788
  TEvent = StreamsEvent,
@@ -751,6 +796,7 @@ type StreamsBatch<
751
796
  /** Chain reorgs reported alongside this page; empty when none. */
752
797
  reorgs: StreamsReorg[];
753
798
  };
799
+ /** Cursor, batch size, and polling options shared by every consume loop. */
754
800
  type StreamsConsumeCommon = {
755
801
  /** Resume strictly after this cursor; omit to start from the oldest seekable page. */
756
802
  cursor?: string | null;
@@ -774,9 +820,12 @@ type StreamsConsumeStacksParams = StreamsConsumeCommon & {
774
820
  * event echoes the labels it matched. */
775
821
  filters?: StreamsFilterMap;
776
822
  };
777
- /** `chain: "bitcoin"` (plan 059/061) — Runes batches, own cursor space.
778
- * `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
779
- * on this branch — they're Stacks-only. */
823
+ /**
824
+ * Consume options for Runes batches, with their own cursor space.
825
+ *
826
+ * `contractId`, `sender`, `recipient`, `assetIdentifier`, and `filters` don't
827
+ * exist on this branch; they're Stacks-only.
828
+ */
780
829
  type StreamsConsumeBitcoinParams = StreamsConsumeCommon & {
781
830
  chain: "bitcoin";
782
831
  types?: readonly RuneEventType[];
@@ -787,11 +836,13 @@ type StreamsConsumeBitcoinParams = StreamsConsumeCommon & {
787
836
  address?: string;
788
837
  };
789
838
  type StreamsConsumeParams = StreamsConsumeStacksParams | StreamsConsumeBitcoinParams;
839
+ /** Where a consume loop stopped: cursor, pages read, empty polls. */
790
840
  type StreamsEventsConsumeResult = {
791
841
  cursor: string | null;
792
842
  pages: number;
793
843
  emptyPolls: number;
794
844
  };
845
+ /** Options for replaying history from dump files, then tailing live. */
795
846
  type StreamsEventsReplayParams = {
796
847
  /** Start point: `"genesis"` (default) or a `<block>:<index>` cursor. */
797
848
  from?: "genesis" | string;
@@ -847,6 +898,7 @@ type StreamsDumpFile = {
847
898
  schema_version: number;
848
899
  created_at: string;
849
900
  };
901
+ /** The index of finalized Parquet dump files for one dataset. */
850
902
  type StreamsDumpsManifest = {
851
903
  dataset: string;
852
904
  network: string;
@@ -878,38 +930,43 @@ type StreamsDumps = {
878
930
  };
879
931
  type StreamsClient = {
880
932
  /**
881
- * Follow Streams as an async iterator of page batches.
933
+ * Read Streams page by page as an async iterator.
934
+ *
935
+ * Yields one {@link StreamsBatch} per events page, so each yield is exactly
936
+ * one API call. Empty pages are skipped; at the tip the iterator polls again
937
+ * every `intervalMs` (default 2000) until `signal` aborts.
882
938
  *
883
- * Yields one {@link StreamsBatch} per `GET /v1/streams/events` page — the
884
- * existing envelope (`events`, `next_cursor` → `cursor`, `tip`, `reorgs`)
885
- * with zero extra API calls. Batches are chosen over per-block groupings
886
- * because the envelope is page-keyed, so every yield is exactly one fetch.
887
- * Empty pages are skipped; at the tip the iterator re-polls every
888
- * `intervalMs` (default 2000) until aborted via `signal`.
939
+ * Reorgs appear on `batch.reorgs`, but the cursor is not rewound for you.
940
+ * Use `events.consume` with `onReorg` when you need rollback.
889
941
  *
890
- * Reorgs are surfaced on the batch (`batch.reorgs`) but the cursor is not
891
- * rewound automatically — use `events.consume` with `onReorg` for managed
892
- * rollback semantics.
942
+ * A literal `types` array narrows every batch's event union to those types.
943
+ * `chain: "bitcoin"` batches carry Runes rows only, on the bitcoin tip shape.
893
944
  */
894
- /** `chain: "bitcoin"` — batches carry Runes rows only, on the bitcoin tip
895
- * shape (plan 059/061). */
896
945
  consume(params: StreamsConsumeBitcoinParams): AsyncIterableIterator<StreamsBatch<RuneStreamsEvent, StreamsBitcoinTip>>;
897
- /** Narrowing overload: a literal `types` array narrows every batch's
898
- * event union to exactly those members. */
899
946
  consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeStacksParams & {
900
947
  types: T;
901
948
  }): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>;
902
949
  consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>;
903
950
  events: {
904
- /** `clock: "vm"` pages carry vm rows only (a parallel vocabulary,
905
- * `event_index` = `ordinal`). Never `StreamsEvent`. Stacks-only —
906
- * `chain: "bitcoin"` has no `clock`. */
951
+ /**
952
+ * Read one page of chain events and the next cursor.
953
+ *
954
+ * Narrow with `types`, `notTypes`, `contractId`, `sender`, `recipient`,
955
+ * `assetIdentifier`, `fromHeight`/`toHeight`, or labelled `filters`.
956
+ * Filters match exactly, and an event type without a given field never
957
+ * matches it. Pass `next_cursor` back as `cursor` to continue. The
958
+ * envelope also carries the `tip` and any `reorgs`. To write the events
959
+ * somewhere with a checkpoint, use `events.consume` instead.
960
+ *
961
+ * A literal `types` array narrows every row to those event types.
962
+ * `clock: "vm"` pages carry vm rows only (a parallel vocabulary,
963
+ * `event_index` = `ordinal`), never `StreamsEvent`; it is Stacks only.
964
+ * `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip shape,
965
+ * and filter by `rune` or `address`.
966
+ */
907
967
  list(params: StreamsEventsStacksListParams & {
908
968
  clock: "vm";
909
969
  }): Promise<StreamsEventsEnvelope<VmStreamsEvent>>;
910
- /** Narrowing overload, matching `consume`. Classic clock only —
911
- * `clock: "vm"` is overload 1, and a general `StreamsEventsListParams`
912
- * variable (clock unresolved) is the wire-union fallback. */
913
970
  list<const T extends readonly StreamsEventType[]>(params: Omit<StreamsEventsStacksListParams, "clock" | "types" | "notTypes"> & {
914
971
  types: T;
915
972
  notTypes?: readonly StreamsEventType[];
@@ -920,27 +977,35 @@ type StreamsClient = {
920
977
  notTypes?: readonly StreamsEventType[];
921
978
  clock?: "classic";
922
979
  }): Promise<StreamsEventsEnvelope>;
923
- /** `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip
924
- * shape (plan 059). */
925
980
  list(params: StreamsEventsBitcoinListParams): Promise<StreamsEventsEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
926
- /** Unresolved `chain`/`clock` on a general params variable: the wire union. */
927
981
  list(params: StreamsEventsListParams): Promise<StreamsEventsEnvelope<StreamsWireEvent>>;
928
- /** `chain: "bitcoin"` — Runes events for one transaction. */
982
+ /**
983
+ * Read every event a transaction emitted.
984
+ *
985
+ * Returns the events and the `tip`, with no `next_cursor`: one transaction
986
+ * is one response.
987
+ *
988
+ * `chain: "bitcoin"` returns the Runes events for one Bitcoin transaction.
989
+ */
929
990
  byTxId(txId: string, opts: {
930
991
  chain: "bitcoin";
931
992
  }): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
932
993
  byTxId(txId: string): Promise<StreamsEventsListEnvelope>;
933
994
  /**
934
- * Pull pages from Streams and call `onBatch` after each page.
995
+ * Run a checkpointed indexer that rewinds on reorgs.
935
996
  *
936
- * Use `consume` for indexers and ETL jobs that own checkpointing. Return
937
- * the checkpoint cursor from `onBatch`. Default `mode: "tail"` keeps
938
- * polling when caught up; `mode: "bounded"` exits on the first empty page.
939
- * The consumer also exits when `maxPages`, `maxEmptyPolls`, or `signal`
940
- * stops it.
997
+ * Write your rows in `onBatch` and commit `ctx.cursor` in the same
998
+ * transaction; resume with `fromCursor`. Reorgs at or below your checkpoint
999
+ * call `onReorg`, then the loop re-reads from the fork point. Delivery is
1000
+ * at-least-once, so keep writes idempotent. With a `sink`, the checkpoint
1001
+ * and rollback are handled for you. `mode: "tail"` (default) keeps polling
1002
+ * at the tip; `mode: "bounded"` returns on the first empty page. It also
1003
+ * stops on `maxPages`, `maxEmptyPolls`, or `signal`. Pass `finalizedOnly`
1004
+ * to skip reorg handling entirely.
1005
+ *
1006
+ * `chain: "bitcoin"` sweeps Runes events; see
1007
+ * {@link StreamsEventsConsumeBitcoinParams}.
941
1008
  */
942
- /** `chain: "bitcoin"` — the checkpointed sweep over Runes events; see
943
- * {@link StreamsEventsConsumeBitcoinParams}. */
944
1009
  consume<TTx = never>(params: StreamsEventsConsumeBitcoinParams<TTx> & {
945
1010
  sink?: ConsumerSink<TTx>;
946
1011
  }): Promise<StreamsEventsConsumeResult>;
@@ -952,46 +1017,66 @@ type StreamsClient = {
952
1017
  sink?: ConsumerSink<TTx>;
953
1018
  }): Promise<StreamsEventsConsumeResult>;
954
1019
  /**
955
- * Backfill from bulk dumps, then continue live from the dump→live seam in
956
- * one call. Iterates finalized dump files (via `onDumpFile`) in block
957
- * order, then tails live from the manifest's `latest_finalized_cursor`
958
- * (exclusive input → no gap or duplicate at the seam). Requires
959
- * `dumpsBaseUrl`.
1020
+ * Backfill from bulk dumps, then continue live in one call.
1021
+ *
1022
+ * Hands each finalized dump file to `onDumpFile` in block order, then tails
1023
+ * live from the manifest's `latest_finalized_cursor`, with no gap or
1024
+ * duplicate at the seam. A file that straddles `from` is delivered whole,
1025
+ * so skip the rows at or below it. Requires `dumpsBaseUrl`.
960
1026
  */
961
1027
  replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>;
962
1028
  /**
963
- * Follow Streams as an async iterator.
1029
+ * Read events one at a time as an async iterator.
1030
+ *
1031
+ * For live processors and watch-style apps that keep their own state. It
1032
+ * tails indefinitely and stops when `signal`, `maxPages`, or
1033
+ * `maxEmptyPolls` ends it. There is no checkpoint or reorg handling; use
1034
+ * `events.consume` for that.
964
1035
  *
965
- * Use `stream` for live processors and watch-style apps. It tails
966
- * indefinitely by default and stops when its `AbortSignal`, `maxPages`, or
967
- * `maxEmptyPolls` stops it.
1036
+ * A literal `types` array narrows every event to those types.
1037
+ * `chain: "bitcoin"` yields Runes events only.
968
1038
  */
969
- /** `chain: "bitcoin"` — Runes events only (plan 059/061). */
970
1039
  stream(params: StreamsEventsStreamBitcoinParams): AsyncIterable<RuneStreamsEvent>;
971
- /** Narrowing overload, matching `consume`. */
972
1040
  stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamStacksParams & {
973
1041
  types: T;
974
1042
  }): AsyncIterable<StreamsEventOfTypes<T>>;
975
1043
  stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>;
976
1044
  /**
977
- * Subscribe to the real-time SSE push surface. Calls `onEvent` for each new
978
- * canonical event as the server pushes it (chain cadence, not poll-bounded),
979
- * and verifies each frame's inline ed25519 signature when the client was
980
- * created with `verify`. Returns an unsubscribe function whose `done`
981
- * settles when the loop ends. Not reorg-aware: an event delivered then
982
- * orphaned is never retracted. Durable writers use `consume()`.
1045
+ * Get each new event pushed to `onEvent` as it lands.
1046
+ *
1047
+ * Reconnects from the last handled cursor after a transport error, and
1048
+ * verifies each frame's ed25519 signature when the client has `verify` on.
1049
+ * Returns an unsubscribe function whose `done` promise settles when the
1050
+ * loop ends. Not reorg-aware: an event delivered and then orphaned is never
1051
+ * retracted. Durable writers use `events.consume`.
1052
+ *
1053
+ * `chain: "bitcoin"` delivers Runes rows to `onEvent`.
983
1054
  */
984
- /** `chain: "bitcoin"` — `onEvent` receives Runes rows (plan 059/061). */
985
1055
  subscribe(params: StreamsEventsSubscribeBitcoinParams): StreamsSubscription;
986
1056
  subscribe(params: StreamsEventsSubscribeStacksParams): StreamsSubscription;
987
1057
  };
988
1058
  blocks: {
1059
+ /**
1060
+ * Read every event in one block, by height or hash.
1061
+ *
1062
+ * Returns the events and the `tip`, with no `next_cursor`.
1063
+ *
1064
+ * `chain: "bitcoin"` returns the Runes events in one Bitcoin block.
1065
+ */
989
1066
  events(heightOrHash: number | string, opts: {
990
1067
  chain: "bitcoin";
991
1068
  }): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
992
1069
  events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>;
993
1070
  };
994
1071
  reorgs: {
1072
+ /**
1073
+ * List chain reorgs since a cursor.
1074
+ *
1075
+ * `since` is required. Each reorg gives its `fork_point_height` and the
1076
+ * orphaned range. Page with `next_since`.
1077
+ *
1078
+ * `chain: "bitcoin"` lists Bitcoin reorgs, on their own cursor space.
1079
+ */
995
1080
  list(params: StreamsReorgsListParams & {
996
1081
  chain: "bitcoin";
997
1082
  }): Promise<StreamsReorgsListEnvelope>;
@@ -999,10 +1084,27 @@ type StreamsClient = {
999
1084
  };
1000
1085
  /** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
1001
1086
  dumps: StreamsDumps;
1087
+ /**
1088
+ * Get the canonical block at a height.
1089
+ *
1090
+ * Returns the block hash and, on Stacks, the burn block it anchors to.
1091
+ *
1092
+ * `chain: "bitcoin"` returns the Bitcoin block, without burn-chain fields.
1093
+ */
1002
1094
  canonical(height: number, opts: {
1003
1095
  chain: "bitcoin";
1004
1096
  }): Promise<StreamsBitcoinCanonicalBlock>;
1005
1097
  canonical(height: number): Promise<StreamsCanonicalBlock>;
1098
+ /**
1099
+ * Get the current chain tip.
1100
+ *
1101
+ * Returns the tip height and hash, `finalized_height`, and `lag_seconds`. On
1102
+ * Stacks it also reports the oldest height your tier can seek; older reads
1103
+ * come from the bulk dumps.
1104
+ *
1105
+ * `chain: "bitcoin"` returns the Bitcoin tip, without burn-chain or retention
1106
+ * fields.
1107
+ */
1006
1108
  tip(opts: {
1007
1109
  chain: "bitcoin";
1008
1110
  }): Promise<StreamsBitcoinTip>;