@secondlayer/sdk 15.0.0 → 15.0.1

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.
@@ -144,26 +144,54 @@ interface BundleSubgraphResponse {
144
144
  bundleSize: number;
145
145
  }
146
146
  declare class Subgraphs extends BaseClient {
147
+ /**
148
+ * List the subgraphs deployed to this instance.
149
+ *
150
+ * Each summary has the status, the last processed block against the chain tip, progress, `gapCount`, and an `integrity` flag.
151
+ */
147
152
  list(): Promise<{
148
153
  data: SubgraphSummary[];
149
154
  }>;
150
155
  /**
151
- * The subgraph's current state — health, sync position, tables. The verify
152
- * step after a deploy, reindex, or backfill: poll it until `sync` catches
153
- * the tip.
156
+ * Get a subgraph's health, sync position, and tables.
157
+ *
158
+ * The verify step after a deploy, reindex, or backfill: poll it until
159
+ * `sync` catches the tip.
154
160
  */
155
161
  status(name: string): Promise<SubgraphDetail>;
162
+ /**
163
+ * Get a subgraph's OpenAPI spec.
164
+ *
165
+ * Describes the REST routes generated for each table. Pass `serverUrl` to set the server the spec advertises.
166
+ */
156
167
  openapi(name: string, options?: SubgraphSpecOptions): Promise<Record<string, unknown>>;
168
+ /**
169
+ * Get a subgraph's schema as JSON, shaped for agents.
170
+ *
171
+ * Per table: the endpoints, columns, indexes, which fields are sortable, selectable, searchable, or filterable, and a ready example query. Pass `serverUrl` to set the server the endpoints use.
172
+ */
157
173
  schema(name: string, options?: SubgraphSpecOptions): Promise<SubgraphAgentSchema>;
174
+ /**
175
+ * Get a subgraph's generated API docs as Markdown text.
176
+ *
177
+ * Pass `serverUrl` to set the server the examples use.
178
+ */
158
179
  markdown(name: string, options?: SubgraphSpecOptions): Promise<string>;
159
180
  /**
160
- * Reindex always drops and rebuilds the whole subgraph, so it takes no
181
+ * Rebuild a subgraph from scratch.
182
+ *
183
+ * A reindex always drops and rebuilds the whole subgraph, so it takes no
161
184
  * block range; the API rejects one with `REINDEX_RANGE_NOT_SUPPORTED`.
162
185
  * Use {@link backfill} to process a specific range. While a reindex or
163
186
  * backfill is already running the API answers 409 with code
164
187
  * `OPERATION_IN_PROGRESS`; poll {@link operations} until it finishes.
165
188
  */
166
189
  reindex(name: string): Promise<ReindexResponse>;
190
+ /**
191
+ * Stop a running reindex or backfill.
192
+ *
193
+ * Requests the cancel and resolves with the `operationId` and a `cancel_requested` status. Poll {@link getOperation} until `status` is terminal. Throws a 404 with code `NO_OPERATION` when nothing is running.
194
+ */
167
195
  stop(name: string): Promise<{
168
196
  message: string;
169
197
  operationId?: string;
@@ -175,19 +203,31 @@ declare class Subgraphs extends BaseClient {
175
203
  fromBlock: number;
176
204
  toBlock: number;
177
205
  }): Promise<ReindexResponse>;
206
+ /**
207
+ * List the block ranges a subgraph is missing.
208
+ *
209
+ * Each gap has its `start`, `end`, `size`, `reason`, and when it was detected and resolved. `resolved` filters to resolved or open gaps; page with `limit` and `offset`. `meta` reports the total gap count and total missing blocks.
210
+ */
178
211
  gaps(name: string, opts?: {
179
212
  limit?: number;
180
213
  offset?: number;
181
214
  resolved?: boolean;
182
215
  }): Promise<SubgraphGapsResponse>;
216
+ /**
217
+ * Delete a subgraph and its tables.
218
+ *
219
+ * Permanent. The API cancels any running reindex or backfill first, waits up to 5 seconds for it to stop, then drops the subgraph's tables and registry entry. `force: true` is sent as `?force=true`.
220
+ */
183
221
  delete(name: string, options?: {
184
222
  force?: boolean;
185
223
  }): Promise<{
186
224
  message: string;
187
225
  }>;
188
226
  /**
189
- * Open /v1 read: cursor-paginated rows. Anon works on an open instance;
190
- * pass an apiKey on the client where reads are closed. `next_cursor` is set
227
+ * Read a table's rows, one cursor page at a time.
228
+ *
229
+ * Anon works on an open instance; pass an apiKey on the client where reads
230
+ * are closed. `next_cursor` is set
191
231
  * on every page that returned rows and is `null` only on an empty page, so a
192
232
  * poller tails with `cursor = page.next_cursor ?? cursor`. A paging loop
193
233
  * ends on an empty page (or one shorter than `limit`).
@@ -199,13 +239,20 @@ declare class Subgraphs extends BaseClient {
199
239
  operations(name: string): Promise<{
200
240
  operations: SubgraphOperationStatus[];
201
241
  }>;
202
- /** Status of a single operation (poll the `operationId` returned by
203
- * reindex/backfill/stop until `status` is terminal). */
242
+ /** Get the status of one reindex, backfill, or stop operation.
243
+ *
244
+ * Poll the `operationId` returned by `reindex`, `backfill`, or `stop`
245
+ * until `status` is terminal. */
204
246
  getOperation(name: string, operationId: string): Promise<SubgraphOperationStatus>;
205
247
  /** Create or update a subgraph. A deploy that needs a rebuild queues one;
206
248
  * if a reindex or backfill is already running the API answers 409 with
207
249
  * code `OPERATION_IN_PROGRESS` (an `ApiError`, not a dedicated class). */
208
250
  deploy(data: DeploySubgraphRequest): Promise<DeploySubgraphResponse>;
251
+ /**
252
+ * Get a deployed subgraph's source.
253
+ *
254
+ * Returns `sourceCode`, the bundled `handlerCode` the runtime executes, and the `pin` hash of what you deployed. `handlerCode` and `pin` are `null` for local deploys. A subgraph deployed before source was captured returns `sourceCode: null` and `readOnly: true` with a `reason`; redeploy it to capture the source.
255
+ */
209
256
  getSource(name: string): Promise<SubgraphSource>;
210
257
  /**
211
258
  * Bundle a TypeScript subgraph source on the server. Used by the web chat
@@ -214,13 +261,15 @@ declare class Subgraphs extends BaseClient {
214
261
  bundle(data: {
215
262
  code: string;
216
263
  }): Promise<BundleSubgraphResponse>;
217
- /** Open /v1 read: exact row count for a filtered set. Same auth posture as
218
- * {@link rows}. */
264
+ /** Count the rows in a table that match a filter.
265
+ *
266
+ * The count is exact. Same auth posture as {@link rows}. */
219
267
  count(name: string, table: string, params?: Pick<SubgraphQueryParams, "filters">): Promise<{
220
268
  count: number;
221
269
  }>;
222
- /** Open /v1 read: scalar aggregates over a filtered set. Same auth posture
223
- * as {@link rows}. */
270
+ /** Compute scalar aggregates over a table's matching rows.
271
+ *
272
+ * Same auth posture as {@link rows}. */
224
273
  aggregate(name: string, table: string, params?: SubgraphAggregateParams): Promise<SubgraphAggregateResponse>;
225
274
  /**
226
275
  * Returns a typed client for a subgraph defined with `defineSubgraph()`.
@@ -256,7 +305,17 @@ import { InstanceDiagnosis, PublicStatus } from "@secondlayer/shared/archive/ins
256
305
  /** Structural `/public/status` payload. Extra fields are ignored by diagnosis. */
257
306
  type InstanceStatus = PublicStatus;
258
307
  type InstanceClient = {
308
+ /**
309
+ * Get the instance's public status report.
310
+ *
311
+ * Reads `GET /public/status`: the overall status, chain tip, chain integrity, and the state of each service and decoder.
312
+ */
259
313
  status(): Promise<InstanceStatus>;
314
+ /**
315
+ * Turn the status report into a verdict with next steps.
316
+ *
317
+ * Resolves to a `state` (`healthy`, `empty-index`, or `degraded`), the API's own `overall` status, and a list of issues, each with the commands that resolve it. A fresh instance with no blocks indexed reads as `empty-index`, not broken.
318
+ */
260
319
  diagnose(): Promise<InstanceDiagnosis>;
261
320
  };
262
321
  type ArchiveVerifyInput = {
@@ -359,33 +418,83 @@ type ArchiveLoadOptions = {
359
418
  insecure?: boolean;
360
419
  };
361
420
  type ArchiveClient = {
421
+ /**
422
+ * Load the latest signed archive manifest.
423
+ *
424
+ * Reads `<archive>/latest.json` unless `against` names another manifest URL. The manifest's ed25519 signature is checked against the archive signing key, and a missing or invalid one throws `ArchiveSignatureError`. `insecure: true` skips the check; `signature.verified` on the result says whether it held.
425
+ */
362
426
  latest(against?: string, opts?: ArchiveLoadOptions): Promise<LoadedArchive>;
427
+ /**
428
+ * Load an archive manifest from a URL.
429
+ *
430
+ * Takes http(s) URLs only; a local path throws a `ValidationError` and stays on the CLI. The signature check is the same as {@link latest}.
431
+ */
363
432
  load(against: string, opts?: ArchiveLoadOptions): Promise<LoadedArchive>;
433
+ /**
434
+ * Get the archive's current operational state.
435
+ *
436
+ * Reads the public `status.json`: `fresh`, `lagging`, `stale`, `gap`, `failed-audit`, or `source-unavailable`, plus how far the last signed publish reaches.
437
+ */
364
438
  status(): Promise<ArchiveStatus>;
439
+ /**
440
+ * List a loaded archive's partitions, optionally filtered.
441
+ *
442
+ * Runs locally on the manifest you already loaded and makes no request. Filter by `dataset` (`blocks`, `transactions`, or `events`) and a block range.
443
+ */
365
444
  partitions(ref: LoadedArchive, filter?: {
366
445
  dataset?: ArchiveDataset;
367
446
  fromBlock?: number;
368
447
  toBlock?: number;
369
448
  }): ArchivePartition[];
449
+ /**
450
+ * Price a fetch against your balance before you pay for it.
451
+ *
452
+ * Nothing is charged. `flow` is `bootstrap` or `repair`. The quote has the bundle count, the price in USD, the free repair allowance applied, your balance, and `sufficient`. Needs an account key (`sk-sl_*`), not an instance token.
453
+ */
370
454
  quote(input: {
371
455
  paths: string[];
372
456
  flow: ArchiveFlow;
373
457
  }): Promise<ArchiveQuote>;
458
+ /**
459
+ * Get presigned download URLs for archive partitions.
460
+ *
461
+ * Draws credits per partition bundle; your first six repair bundles each month are free. Lists longer than 64 paths go out in batches of 64. Each URL is short-lived (`expiresAt`); pass it to {@link download}. An empty balance throws `InsufficientArchiveCreditsError` with the shortfall. Needs an account key (`sk-sl_*`).
462
+ */
374
463
  fetch(input: {
375
464
  paths: string[];
376
465
  flow: ArchiveFlow;
377
466
  }): Promise<ArchiveFetchResult>;
467
+ /**
468
+ * Download a partition's bytes and verify them.
469
+ *
470
+ * The sha256 is checked against the manifest, and a mismatch throws `ArchiveSignatureError`. On the official archive host you must pass the presigned `url` from {@link fetch}, or it throws a `ValidationError`; any other host downloads straight from its archive tree.
471
+ */
378
472
  download(partition: ArchivePartition, opts?: {
379
473
  url?: string;
380
474
  }): Promise<Uint8Array>;
381
475
  credits: {
476
+ /**
477
+ * Get your archive credit balance.
478
+ *
479
+ * Returns `creditsUsdMicros` (millionths of a dollar, as a string) and your auto-refill setting. Needs an account key (`sk-sl_*`).
480
+ */
382
481
  balance(): Promise<ArchiveCreditsBalance>;
482
+ /**
483
+ * Start a card checkout for a credit pack.
484
+ *
485
+ * `pack` is the dollar amount: 10, 25, 50, or 100. Resolves to the checkout `url`. Needs no account key.
486
+ */
383
487
  checkout(input: {
384
488
  email: string;
385
489
  pack: 10 | 25 | 50 | 100;
386
490
  }): Promise<{
387
491
  url: string;
388
492
  }>;
493
+ /**
494
+ * Set or turn off automatic credit refill.
495
+ *
496
+ * Pass `belowUsd` and `packUsd` to buy a pack whenever the balance drops below the threshold, or `{ off: true }` to stop. Needs an account key (`sk-sl_*`).
497
+ */
389
498
  refill(input: {
390
499
  belowUsd: number;
391
500
  packUsd: 10 | 25 | 50 | 100;
@@ -399,6 +508,11 @@ type ArchiveClient = {
399
508
  };
400
509
  /** Hosted archive client plus instance `verify`. `status()` is still the public archive tree. */
401
510
  type SecondLayerArchive = ArchiveClient & {
511
+ /**
512
+ * Check your instance's data against a signed archive.
513
+ *
514
+ * Runs `POST /v1/archive/verify` on your instance: read-only, and it compares raw identity digests only (the deep semantic check is CLI-only). Resolves to `clean`, `diverged`, or `unanchored`; a failed signature is `unanchored`, never `clean`. Narrow the check with `fromBlock` and `toBlock`. Verification is free.
515
+ */
402
516
  verify(input: ArchiveVerifyInput): Promise<ArchiveVerifyResult>;
403
517
  };
404
518
  /**
@@ -442,8 +556,10 @@ declare class Contracts extends BaseClient {
442
556
  /** Find contracts conforming to `trait`. `trait` is required (server 400s without it). */
443
557
  list(params: ContractsListParams): Promise<ContractsEnvelope>;
444
558
  /**
445
- * Fetch a single contract from the registry by id (the prod-safe ABI source).
446
- * Pass `{ includeAbi: true }` for the full ABI blob. Resolves null on 404.
559
+ * Get one contract from the registry by id, or `null`.
560
+ *
561
+ * The prod-safe ABI source. Pass `{ includeAbi: true }` for the full ABI
562
+ * blob. Resolves to `null` on 404.
447
563
  */
448
564
  get(contractId: string, opts?: {
449
565
  includeAbi?: boolean;
@@ -637,7 +753,7 @@ type StreamsTip = {
637
753
  /** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
638
754
  oldest_cursor?: string | null;
639
755
  };
640
- /** `chain=bitcoin` tip (plan 059) — no `burn_block_height`/retention fields,
756
+ /** `chain=bitcoin` tip — no `burn_block_height`/retention fields,
641
757
  * since Bitcoin has no burn chain of its own and Runes reads have no
642
758
  * retention ladder. Returned by `tip({ chain: "bitcoin" })`. */
643
759
  type StreamsBitcoinTip = {
@@ -653,7 +769,7 @@ type StreamsCanonicalBlock = {
653
769
  burn_block_hash: string | null;
654
770
  is_canonical: true;
655
771
  };
656
- /** `chain=bitcoin` canonical block (plan 059) — no burn-chain fields. */
772
+ /** `chain=bitcoin` canonical block — no burn-chain fields. */
657
773
  type StreamsBitcoinCanonicalBlock = {
658
774
  block_height: number;
659
775
  block_hash: string;
@@ -736,8 +852,8 @@ type StreamsEventsListParamsCommon = {
736
852
  toHeight?: number;
737
853
  limit?: number;
738
854
  };
739
- /** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since
740
- * before plan 059. */
855
+ /** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since before Runes events
856
+ * were added. */
741
857
  type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
742
858
  chain?: "stacks";
743
859
  /** `vm` reads ordinal. Omit for Streams 1.0. */
@@ -757,7 +873,7 @@ type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
757
873
  filters?: StreamsFilterMap;
758
874
  };
759
875
  /**
760
- * `chain: "bitcoin"` (plan 059) — Runes events, own cursor space. `types` is
876
+ * `chain: "bitcoin"` — Runes events, own cursor space. `types` is
761
877
  * restricted to {@link RuneEventType} at the type level, so e.g.
762
878
  * `{ chain: "bitcoin", types: ["ft_transfer"] }` is a compile error rather
763
879
  * than a silent 400 at request time. `contractId`/`sender`/`recipient`/
@@ -795,7 +911,7 @@ type StreamsEventsStreamStacksParams = StreamsEventsStreamCommon & {
795
911
  /** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
796
912
  filters?: StreamsFilterMap;
797
913
  };
798
- /** `chain: "bitcoin"` (plan 059/061) — Runes events, tailed the same way as
914
+ /** `chain: "bitcoin"` — Runes events, tailed the same way as
799
915
  * the Stacks default. `types` is restricted to {@link RuneEventType} at the
800
916
  * type level, matching {@link StreamsEventsBitcoinListParams}.
801
917
  * `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
@@ -853,7 +969,7 @@ type StreamsEventsSubscribeStacksParams = StreamsEventsSubscribeCommon & {
853
969
  */
854
970
  onEvent: (event: StreamsEvent) => void | Promise<void>;
855
971
  };
856
- /** `chain: "bitcoin"` (plan 059/061) — Runes events pushed live, on their own
972
+ /** `chain: "bitcoin"` — Runes events pushed live, on their own
857
973
  * cursor space. `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters`
858
974
  * don't exist on this branch — they're Stacks-only. */
859
975
  type StreamsEventsSubscribeBitcoinParams = StreamsEventsSubscribeCommon & {
@@ -1062,7 +1178,7 @@ type StreamsEventsConsumeParams<
1062
1178
  wake?: () => Promise<void>;
1063
1179
  };
1064
1180
  /**
1065
- * `chain: "bitcoin"` (plan 059/061) — the checkpointed sweep over Runes
1181
+ * `chain: "bitcoin"` — the checkpointed sweep over Runes
1066
1182
  * events. A separate, simpler type from {@link StreamsEventsConsumeParams}
1067
1183
  * rather than a widened union member: `filters`/`on`/`decoded` are Stacks-only
1068
1184
  * concepts (labelled OR-groups and Index-shaped projection have no Runes
@@ -1140,7 +1256,7 @@ type StreamsConsumeStacksParams = StreamsConsumeCommon & {
1140
1256
  * event echoes the labels it matched. */
1141
1257
  filters?: StreamsFilterMap;
1142
1258
  };
1143
- /** `chain: "bitcoin"` (plan 059/061) — Runes batches, own cursor space.
1259
+ /** `chain: "bitcoin"` — Runes batches, own cursor space.
1144
1260
  * `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
1145
1261
  * on this branch — they're Stacks-only. */
1146
1262
  type StreamsConsumeBitcoinParams = StreamsConsumeCommon & {
@@ -1243,38 +1359,43 @@ type StreamsDumps = {
1243
1359
  };
1244
1360
  type StreamsClient = {
1245
1361
  /**
1246
- * Follow Streams as an async iterator of page batches.
1362
+ * Read Streams page by page as an async iterator.
1363
+ *
1364
+ * Yields one {@link StreamsBatch} per events page, so each yield is exactly
1365
+ * one API call. Empty pages are skipped; at the tip the iterator polls again
1366
+ * every `intervalMs` (default 2000) until `signal` aborts.
1247
1367
  *
1248
- * Yields one {@link StreamsBatch} per `GET /v1/streams/events` page — the
1249
- * existing envelope (`events`, `next_cursor` → `cursor`, `tip`, `reorgs`)
1250
- * with zero extra API calls. Batches are chosen over per-block groupings
1251
- * because the envelope is page-keyed, so every yield is exactly one fetch.
1252
- * Empty pages are skipped; at the tip the iterator re-polls every
1253
- * `intervalMs` (default 2000) until aborted via `signal`.
1368
+ * Reorgs appear on `batch.reorgs`, but the cursor is not rewound for you.
1369
+ * Use `events.consume` with `onReorg` when you need rollback.
1254
1370
  *
1255
- * Reorgs are surfaced on the batch (`batch.reorgs`) but the cursor is not
1256
- * rewound automatically — use `events.consume` with `onReorg` for managed
1257
- * rollback semantics.
1371
+ * A literal `types` array narrows every batch's event union to those types.
1372
+ * `chain: "bitcoin"` batches carry Runes rows only, on the bitcoin tip shape.
1258
1373
  */
1259
- /** `chain: "bitcoin"` — batches carry Runes rows only, on the bitcoin tip
1260
- * shape (plan 059/061). */
1261
1374
  consume(params: StreamsConsumeBitcoinParams): AsyncIterableIterator<StreamsBatch<RuneStreamsEvent, StreamsBitcoinTip>>;
1262
- /** Narrowing overload: a literal `types` array narrows every batch's
1263
- * event union to exactly those members. */
1264
1375
  consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeStacksParams & {
1265
1376
  types: T;
1266
1377
  }): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>;
1267
1378
  consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>;
1268
1379
  events: {
1269
- /** `clock: "vm"` pages carry vm rows only (a parallel vocabulary,
1270
- * `event_index` = `ordinal`). Never `StreamsEvent`. Stacks-only —
1271
- * `chain: "bitcoin"` has no `clock`. */
1380
+ /**
1381
+ * Read one page of chain events and the next cursor.
1382
+ *
1383
+ * Narrow with `types`, `notTypes`, `contractId`, `sender`, `recipient`,
1384
+ * `assetIdentifier`, `fromHeight`/`toHeight`, or labelled `filters`.
1385
+ * Filters match exactly, and an event type without a given field never
1386
+ * matches it. Pass `next_cursor` back as `cursor` to continue. The
1387
+ * envelope also carries the `tip` and any `reorgs`. To write the events
1388
+ * somewhere with a checkpoint, use `events.consume` instead.
1389
+ *
1390
+ * A literal `types` array narrows every row to those event types.
1391
+ * `clock: "vm"` pages carry vm rows only (a parallel vocabulary,
1392
+ * `event_index` = `ordinal`), never `StreamsEvent`; it is Stacks only.
1393
+ * `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip shape,
1394
+ * and filter by `rune` or `address`.
1395
+ */
1272
1396
  list(params: StreamsEventsStacksListParams & {
1273
1397
  clock: "vm";
1274
1398
  }): Promise<StreamsEventsEnvelope<VmStreamsEvent>>;
1275
- /** Narrowing overload, matching `consume`. Classic clock only —
1276
- * `clock: "vm"` is overload 1, and a general `StreamsEventsListParams`
1277
- * variable (clock unresolved) is the wire-union fallback. */
1278
1399
  list<const T extends readonly StreamsEventType[]>(params: Omit<StreamsEventsStacksListParams, "clock" | "types" | "notTypes"> & {
1279
1400
  types: T;
1280
1401
  notTypes?: readonly StreamsEventType[];
@@ -1285,27 +1406,35 @@ type StreamsClient = {
1285
1406
  notTypes?: readonly StreamsEventType[];
1286
1407
  clock?: "classic";
1287
1408
  }): Promise<StreamsEventsEnvelope>;
1288
- /** `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip
1289
- * shape (plan 059). */
1290
1409
  list(params: StreamsEventsBitcoinListParams): Promise<StreamsEventsEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
1291
- /** Unresolved `chain`/`clock` on a general params variable: the wire union. */
1292
1410
  list(params: StreamsEventsListParams): Promise<StreamsEventsEnvelope<StreamsWireEvent>>;
1293
- /** `chain: "bitcoin"` — Runes events for one transaction. */
1411
+ /**
1412
+ * Read every event a transaction emitted.
1413
+ *
1414
+ * Returns the events and the `tip`, with no `next_cursor`: one transaction
1415
+ * is one response.
1416
+ *
1417
+ * `chain: "bitcoin"` returns the Runes events for one Bitcoin transaction.
1418
+ */
1294
1419
  byTxId(txId: string, opts: {
1295
1420
  chain: "bitcoin";
1296
1421
  }): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
1297
1422
  byTxId(txId: string): Promise<StreamsEventsListEnvelope>;
1298
1423
  /**
1299
- * Pull pages from Streams and call `onBatch` after each page.
1424
+ * Run a checkpointed indexer that rewinds on reorgs.
1300
1425
  *
1301
- * Use `consume` for indexers and ETL jobs that own checkpointing. Return
1302
- * the checkpoint cursor from `onBatch`. Default `mode: "tail"` keeps
1303
- * polling when caught up; `mode: "bounded"` exits on the first empty page.
1304
- * The consumer also exits when `maxPages`, `maxEmptyPolls`, or `signal`
1305
- * stops it.
1426
+ * Write your rows in `onBatch` and commit `ctx.cursor` in the same
1427
+ * transaction; resume with `fromCursor`. Reorgs at or below your checkpoint
1428
+ * call `onReorg`, then the loop re-reads from the fork point. Delivery is
1429
+ * at-least-once, so keep writes idempotent. With a `sink`, the checkpoint
1430
+ * and rollback are handled for you. `mode: "tail"` (default) keeps polling
1431
+ * at the tip; `mode: "bounded"` returns on the first empty page. It also
1432
+ * stops on `maxPages`, `maxEmptyPolls`, or `signal`. Pass `finalizedOnly`
1433
+ * to skip reorg handling entirely.
1434
+ *
1435
+ * `chain: "bitcoin"` sweeps Runes events; see
1436
+ * {@link StreamsEventsConsumeBitcoinParams}.
1306
1437
  */
1307
- /** `chain: "bitcoin"` — the checkpointed sweep over Runes events; see
1308
- * {@link StreamsEventsConsumeBitcoinParams}. */
1309
1438
  consume<TTx = never>(params: StreamsEventsConsumeBitcoinParams<TTx> & {
1310
1439
  sink?: ConsumerSink<TTx>;
1311
1440
  }): Promise<StreamsEventsConsumeResult>;
@@ -1317,46 +1446,66 @@ type StreamsClient = {
1317
1446
  sink?: ConsumerSink<TTx>;
1318
1447
  }): Promise<StreamsEventsConsumeResult>;
1319
1448
  /**
1320
- * Backfill from bulk dumps, then continue live from the dump→live seam in
1321
- * one call. Iterates finalized dump files (via `onDumpFile`) in block
1322
- * order, then tails live from the manifest's `latest_finalized_cursor`
1323
- * (exclusive input → no gap or duplicate at the seam). Requires
1324
- * `dumpsBaseUrl`.
1449
+ * Backfill from bulk dumps, then continue live in one call.
1450
+ *
1451
+ * Hands each finalized dump file to `onDumpFile` in block order, then tails
1452
+ * live from the manifest's `latest_finalized_cursor`, with no gap or
1453
+ * duplicate at the seam. A file that straddles `from` is delivered whole,
1454
+ * so skip the rows at or below it. Requires `dumpsBaseUrl`.
1325
1455
  */
1326
1456
  replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>;
1327
1457
  /**
1328
- * Follow Streams as an async iterator.
1458
+ * Read events one at a time as an async iterator.
1329
1459
  *
1330
- * Use `stream` for live processors and watch-style apps. It tails
1331
- * indefinitely by default and stops when its `AbortSignal`, `maxPages`, or
1332
- * `maxEmptyPolls` stops it.
1460
+ * For live processors and watch-style apps that keep their own state. It
1461
+ * tails indefinitely and stops when `signal`, `maxPages`, or
1462
+ * `maxEmptyPolls` ends it. There is no checkpoint or reorg handling; use
1463
+ * `events.consume` for that.
1464
+ *
1465
+ * A literal `types` array narrows every event to those types.
1466
+ * `chain: "bitcoin"` yields Runes events only.
1333
1467
  */
1334
- /** `chain: "bitcoin"` — Runes events only (plan 059/061). */
1335
1468
  stream(params: StreamsEventsStreamBitcoinParams): AsyncIterable<RuneStreamsEvent>;
1336
- /** Narrowing overload, matching `consume`. */
1337
1469
  stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamStacksParams & {
1338
1470
  types: T;
1339
1471
  }): AsyncIterable<StreamsEventOfTypes<T>>;
1340
1472
  stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>;
1341
1473
  /**
1342
- * Subscribe to the real-time SSE push surface. Calls `onEvent` for each new
1343
- * canonical event as the server pushes it (chain cadence, not poll-bounded),
1344
- * and verifies each frame's inline ed25519 signature when the client was
1345
- * created with `verify`. Returns an unsubscribe function whose `done`
1346
- * settles when the loop ends. Not reorg-aware: an event delivered then
1347
- * orphaned is never retracted. Durable writers use `consume()`.
1474
+ * Get each new event pushed to `onEvent` as it lands.
1475
+ *
1476
+ * Reconnects from the last handled cursor after a transport error, and
1477
+ * verifies each frame's ed25519 signature when the client has `verify` on.
1478
+ * Returns an unsubscribe function whose `done` promise settles when the
1479
+ * loop ends. Not reorg-aware: an event delivered and then orphaned is never
1480
+ * retracted. Durable writers use `events.consume`.
1481
+ *
1482
+ * `chain: "bitcoin"` delivers Runes rows to `onEvent`.
1348
1483
  */
1349
- /** `chain: "bitcoin"` — `onEvent` receives Runes rows (plan 059/061). */
1350
1484
  subscribe(params: StreamsEventsSubscribeBitcoinParams): StreamsSubscription;
1351
1485
  subscribe(params: StreamsEventsSubscribeStacksParams): StreamsSubscription;
1352
1486
  };
1353
1487
  blocks: {
1488
+ /**
1489
+ * Read every event in one block, by height or hash.
1490
+ *
1491
+ * Returns the events and the `tip`, with no `next_cursor`.
1492
+ *
1493
+ * `chain: "bitcoin"` returns the Runes events in one Bitcoin block.
1494
+ */
1354
1495
  events(heightOrHash: number | string, opts: {
1355
1496
  chain: "bitcoin";
1356
1497
  }): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
1357
1498
  events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>;
1358
1499
  };
1359
1500
  reorgs: {
1501
+ /**
1502
+ * List chain reorgs since a cursor.
1503
+ *
1504
+ * `since` is required. Each reorg gives its `fork_point_height` and the
1505
+ * orphaned range. Page with `next_since`.
1506
+ *
1507
+ * `chain: "bitcoin"` lists Bitcoin reorgs, on their own cursor space.
1508
+ */
1360
1509
  list(params: StreamsReorgsListParams & {
1361
1510
  chain: "bitcoin";
1362
1511
  }): Promise<StreamsReorgsListEnvelope>;
@@ -1364,10 +1513,27 @@ type StreamsClient = {
1364
1513
  };
1365
1514
  /** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
1366
1515
  dumps: StreamsDumps;
1516
+ /**
1517
+ * Get the canonical block at a height.
1518
+ *
1519
+ * Returns the block hash and, on Stacks, the burn block it anchors to.
1520
+ *
1521
+ * `chain: "bitcoin"` returns the Bitcoin block, without burn-chain fields.
1522
+ */
1367
1523
  canonical(height: number, opts: {
1368
1524
  chain: "bitcoin";
1369
1525
  }): Promise<StreamsBitcoinCanonicalBlock>;
1370
1526
  canonical(height: number): Promise<StreamsCanonicalBlock>;
1527
+ /**
1528
+ * Get the current chain tip.
1529
+ *
1530
+ * Returns the tip height and hash, `finalized_height`, and `lag_seconds`. On
1531
+ * Stacks it also reports the oldest height your tier can seek; older reads
1532
+ * come from the bulk dumps.
1533
+ *
1534
+ * `chain: "bitcoin"` returns the Bitcoin tip, without burn-chain or retention
1535
+ * fields.
1536
+ */
1371
1537
  tip(opts: {
1372
1538
  chain: "bitcoin";
1373
1539
  }): Promise<StreamsBitcoinTip>;
@@ -2368,15 +2534,27 @@ type SbtcDepositsConsumeParams<TTx = never> = Omit<SbtcDepositsListParams, "curs
2368
2534
  * events, scoreboard). The only productized decoded sBTC peg feed on Stacks. */
2369
2535
  interface SbtcResource {
2370
2536
  deposits: {
2371
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2372
- * requested columns plus {@link SbtcDepositAlwaysFields}. */
2537
+ /**
2538
+ * Read one page of completed sBTC deposits.
2539
+ *
2540
+ * Filter by `sender`, `bitcoinTxid`, and a height range. `confirmed: true` keeps only deposits past the finality boundary. `fields` returns only those columns and narrows the row type; `cursor` and `block_height` always come back.
2541
+ */
2373
2542
  list<const F extends keyof IndexSbtcDeposit & string>(params: SbtcDepositsListParams & {
2374
2543
  fields: readonly F[];
2375
2544
  }): Promise<SbtcDepositsEnvelope<SbtcDepositFields<F>>>;
2376
2545
  list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>;
2546
+ /**
2547
+ * Iterate every completed sBTC deposit, paging for you.
2548
+ *
2549
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
2550
+ */
2377
2551
  walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>;
2378
- /** Checkpointed sweep of completed deposits — append-only, so safe to
2379
- * mirror. See {@link IndexConsumeOptions}. */
2552
+ /**
2553
+ * Run a checkpointed, reorg-aware indexer over completed deposits.
2554
+ *
2555
+ * Deposits are append-only, so they are safe to mirror. See
2556
+ * {@link IndexConsumeOptions}.
2557
+ */
2380
2558
  consume<TTx = never>(params: SbtcDepositsConsumeParams<TTx> & {
2381
2559
  sink?: ConsumerSink<TTx>;
2382
2560
  }): Promise<{
@@ -2388,21 +2566,43 @@ interface SbtcResource {
2388
2566
  get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>;
2389
2567
  };
2390
2568
  withdrawals: {
2391
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2392
- * requested columns plus {@link SbtcWithdrawalAlwaysFields}. */
2569
+ /**
2570
+ * Read one page of sBTC withdrawals, each with its current status.
2571
+ *
2572
+ * Filter by `status` (`REQUESTED`, `ACCEPTED`, `REJECTED`), `sender`, `requestId`, `settlementConfirmed`, and a height range. A row changes as the peg-out moves along, which is why withdrawals have no `consume`. `fields` returns only those columns and narrows the row type; `cursor` and `request_id` always come back.
2573
+ */
2393
2574
  list<const F extends keyof IndexSbtcWithdrawal & string>(params: SbtcWithdrawalsListParams & {
2394
2575
  fields: readonly F[];
2395
2576
  }): Promise<SbtcWithdrawalsEnvelope<SbtcWithdrawalFields<F>>>;
2396
2577
  list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>;
2578
+ /**
2579
+ * Iterate every sBTC withdrawal, paging for you.
2580
+ *
2581
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
2582
+ */
2397
2583
  walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>;
2398
2584
  /** Fetch a withdrawal's full lifecycle by request id; 404 → null. */
2399
2585
  get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>;
2400
2586
  };
2401
2587
  events: {
2588
+ /**
2589
+ * Read one page of the raw sBTC peg event log.
2590
+ *
2591
+ * Filter by `topic`, `sender`, `requestId`, `bitcoinTxid`, and a height range. `confirmed: true` keeps only events past the finality boundary.
2592
+ */
2402
2593
  list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>;
2594
+ /**
2595
+ * Iterate every sBTC peg event, paging for you.
2596
+ *
2597
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
2598
+ */
2403
2599
  walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>;
2404
- /** Checkpointed sweep of the raw peg event log — append-only across all
2405
- * six topics. See {@link IndexConsumeOptions}. */
2600
+ /**
2601
+ * Run a checkpointed, reorg-aware indexer over the raw peg event log.
2602
+ *
2603
+ * The log is append-only across all six topics. See
2604
+ * {@link IndexConsumeOptions}.
2605
+ */
2406
2606
  consume<TTx = never>(params: SbtcEventsConsumeParams<TTx> & {
2407
2607
  sink?: ConsumerSink<TTx>;
2408
2608
  }): Promise<{
@@ -2411,7 +2611,11 @@ interface SbtcResource {
2411
2611
  emptyPolls: number;
2412
2612
  }>;
2413
2613
  };
2414
- /** The peg scoreboard — a single all-time aggregate (no pagination). */
2614
+ /**
2615
+ * Get the all-time sBTC peg scoreboard.
2616
+ *
2617
+ * A single aggregate, with no pagination.
2618
+ */
2415
2619
  summary(): Promise<SbtcSummaryEnvelope>;
2416
2620
  }
2417
2621
  /** One pox-5 reward cycle, exact to the node. */
@@ -2492,10 +2696,24 @@ type PoxCyclesWalkParams = Omit<PoxCyclesListParams, "limit"> & WalkOptions;
2492
2696
  /** `index.pox` — reward cycles of the current PoX (PoX-5). */
2493
2697
  interface PoxResource {
2494
2698
  cycles: {
2699
+ /**
2700
+ * Read one page of PoX reward cycles, newest first.
2701
+ *
2702
+ * `cursor` is a `reward_cycle` number, and the page returns the cycles below it. `next_cursor` is the next cycle number to page from, or `null` at the end. This reports the current PoX (PoX-5); PoX-4 history is not served here, so read `stacking` for it.
2703
+ */
2495
2704
  list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>;
2705
+ /**
2706
+ * Iterate every reward cycle, paging for you.
2707
+ *
2708
+ * Takes the same filters as `list` (it pages by reward cycle number). Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
2709
+ */
2496
2710
  walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>;
2497
- /** Fetch one reward cycle by number; 404 (unknown cycle, or below pox-5's
2498
- * first reward cycle 141 — final PoX-4 history, not served here) → null. */
2711
+ /**
2712
+ * Get one reward cycle by number, or `null`.
2713
+ *
2714
+ * Resolves to `null` on 404: an unknown cycle, or one below pox-5's first
2715
+ * reward cycle (141), whose PoX-4 history is final and not served here.
2716
+ */
2499
2717
  get(rewardCycle: number): Promise<PoxCycleEnvelope | null>;
2500
2718
  };
2501
2719
  }
@@ -2570,15 +2788,27 @@ type Pox5EventsConsumeParams<TTx = never> = Omit<Pox5EventsListParams, "cursor"
2570
2788
  * epoch 4.0 hard fork onward (PoX-4's `index.stacking` stream ends there). */
2571
2789
  interface Pox5Resource {
2572
2790
  events: {
2573
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2574
- * requested columns plus {@link Pox5EventAlwaysFields}. */
2791
+ /**
2792
+ * Read one page of decoded PoX-5 staking events.
2793
+ *
2794
+ * Filter by `topic`, `staker`, `signer`, `signerManager`, `bondIndex`, `rewardCycle`, and a height range. `confirmed: true` keeps only rows past the finality boundary. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `topic` always come back.
2795
+ */
2575
2796
  list<const F extends keyof IndexPox5Event & string>(params: Pox5EventsListParams & {
2576
2797
  fields: readonly F[];
2577
2798
  }): Promise<Pox5EventsEnvelope<Pox5EventFields<F>>>;
2578
2799
  list(params?: Pox5EventsListParams): Promise<Pox5EventsEnvelope>;
2800
+ /**
2801
+ * Iterate every PoX-5 event, paging for you.
2802
+ *
2803
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
2804
+ */
2579
2805
  walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event>;
2580
- /** Checkpointed sweep of the pox-5 print log — append-only across all
2581
- * 19 topics. See {@link IndexConsumeOptions}. */
2806
+ /**
2807
+ * Run a checkpointed, reorg-aware indexer over PoX-5 events.
2808
+ *
2809
+ * The pox-5 print log is append-only across all 19 topics. See
2810
+ * {@link IndexConsumeOptions}.
2811
+ */
2582
2812
  consume<TTx = never>(params: Pox5EventsConsumeParams<TTx> & {
2583
2813
  sink?: ConsumerSink<TTx>;
2584
2814
  }): Promise<{
@@ -2756,14 +2986,28 @@ interface RunesResource {
2756
2986
  /** The rune catalog. `search` prefix-matches the name; `sort` is etch
2757
2987
  * order (default) or busiest-first. */
2758
2988
  list(params?: RunesListParams): Promise<RunesEnvelope>;
2759
- /** One rune's full entry by id or name; `null` on 404 (no such rune, or
2760
- * Runes isn't configured on this instance). */
2989
+ /**
2990
+ * Get one rune by id or name, or `null`.
2991
+ *
2992
+ * Resolves to `null` on 404: no such rune, or Runes isn't configured on
2993
+ * this instance.
2994
+ */
2761
2995
  get(rune: RuneRef): Promise<RuneEnvelope | null>;
2762
2996
  /** Current per-outpoint rune balances by address or outpoint. */
2763
2997
  balances(params: RuneBalancesListParams): Promise<RuneBalancesEnvelope>;
2764
2998
  /** Etch/mint/transfer/burn events, cursor `<block_height>:<event_index>`. */
2765
2999
  activity: {
3000
+ /**
3001
+ * Read one page of Rune etch, mint, transfer, and burn events.
3002
+ *
3003
+ * Filter by `rune` (an id or a name), `address`, `kind`, `txid`, and a height range. The cursor is `<block_height>:<event_index>`, and the envelope's tip is a Bitcoin tip. `notes` says so when Runes is not configured on the instance.
3004
+ */
2766
3005
  list(params?: RuneActivityListParams): Promise<RuneActivityEnvelope>;
3006
+ /**
3007
+ * Iterate every Rune event, paging for you.
3008
+ *
3009
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3010
+ */
2767
3011
  walk(params?: RuneActivityWalkParams): AsyncIterable<IndexRuneEvent>;
2768
3012
  };
2769
3013
  }
@@ -2781,15 +3025,20 @@ interface FtTransfersResource {
2781
3025
  fields: readonly F[];
2782
3026
  }): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
2783
3027
  (params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
2784
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2785
- * requested columns plus {@link FtTransferAlwaysFields}. */
3028
+ /**
3029
+ * Read one page of fungible-token transfers, plus the cursor for the next.
3030
+ *
3031
+ * Filter by `contractId`, `assetIdentifier`, `sender`, `recipient`, and a height range. Filters are equality only: there is no amount filter. Pass `next_cursor` back as `cursor` to continue. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `event_type` always come back. `reorgs` on the envelope lists forks that overlap the page.
3032
+ */
2786
3033
  list<const F extends keyof FtTransfer & string>(params: FtTransfersListParams & {
2787
3034
  fields: readonly F[];
2788
3035
  }): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
2789
3036
  list(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
2790
- /** Narrowing overload, matching `list`: `walk` forwards `fields` to the
2791
- * wire, so without this the yielded rows are stripped while the type
2792
- * still promises every column. */
3037
+ /**
3038
+ * Iterate every fungible-token transfer, paging for you.
3039
+ *
3040
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3041
+ */
2793
3042
  walk<const F extends keyof FtTransfer & string>(params: FtTransfersWalkParams & {
2794
3043
  fields: readonly F[];
2795
3044
  }): AsyncIterable<FtTransferFields<F>>;
@@ -2803,13 +3052,20 @@ interface NftTransfersResource {
2803
3052
  fields: readonly F[];
2804
3053
  }): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
2805
3054
  (params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
2806
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2807
- * requested columns plus {@link NftTransferAlwaysFields}. */
3055
+ /**
3056
+ * Read one page of NFT transfers, plus the cursor for the next.
3057
+ *
3058
+ * Filter by `contractId`, `assetIdentifier`, `sender`, `recipient`, and a height range. Pass `next_cursor` back as `cursor` to continue. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `event_type` always come back.
3059
+ */
2808
3060
  list<const F extends keyof NftTransfer & string>(params: NftTransfersListParams & {
2809
3061
  fields: readonly F[];
2810
3062
  }): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
2811
3063
  list(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
2812
- /** Narrowing overload, matching `list` (see {@link FtTransfersResource}). */
3064
+ /**
3065
+ * Iterate every NFT transfer, paging for you.
3066
+ *
3067
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3068
+ */
2813
3069
  walk<const F extends keyof NftTransfer & string>(params: NftTransfersWalkParams & {
2814
3070
  fields: readonly F[];
2815
3071
  }): AsyncIterable<NftTransferFields<F>>;
@@ -2826,9 +3082,11 @@ interface IndexEventsResource {
2826
3082
  fields: readonly F[];
2827
3083
  }): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
2828
3084
  <T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
2829
- /** Narrowing overload: `fields` shrinks the returned row type to exactly
2830
- * the requested columns plus {@link IndexAlwaysFields}. `const F` means no
2831
- * `as const` at the call site. */
3085
+ /**
3086
+ * Read one page of decoded events of one type.
3087
+ *
3088
+ * `eventType` is required: a decoded type (`ft_transfer`, `print`, ...) or a VM type (`nested_contract_call`, `map_set`, ...), and a literal narrows the row type. Scope with `contractId` (one id or up to 20) or `trait`, never both, plus `assetIdentifier`, `sender`, `recipient`, `functionName`, `caller`, `map`, `varName`, `txId`, and a height range. `txContext: true` joins the submitting transaction onto each event. `fields` returns only those columns and narrows the row type; it saves wire bytes but does not change what you are billed, since rows are metered, not columns.
3089
+ */
2832
3090
  list<
2833
3091
  T extends IndexEventType,
2834
3092
  const F extends keyof IndexEventOf<T> & string
@@ -2836,9 +3094,11 @@ interface IndexEventsResource {
2836
3094
  fields: readonly F[];
2837
3095
  }): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
2838
3096
  list<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
2839
- /** Narrowing overload, matching `list`: `walk` forwards `fields` to the
2840
- * wire, so without this the yielded rows are stripped while the type
2841
- * still promises every column. */
3097
+ /**
3098
+ * Iterate every decoded event of one type, paging for you.
3099
+ *
3100
+ * Takes the same filters as `list`, including `eventType`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3101
+ */
2842
3102
  walk<
2843
3103
  T extends IndexEventType,
2844
3104
  const F extends keyof IndexEventOf<T> & string
@@ -2846,6 +3106,11 @@ interface IndexEventsResource {
2846
3106
  fields: readonly F[];
2847
3107
  }): AsyncIterable<IndexEventFields<T, F>>;
2848
3108
  walk<T extends IndexEventType>(params: EventsWalkParams<T>): AsyncIterable<IndexEventOf<T>>;
3109
+ /**
3110
+ * Run a checkpointed, reorg-aware indexer over decoded events.
3111
+ *
3112
+ * Write your rows in `onBatch` and commit `ctx.cursor` in the same transaction; resume with `fromCursor`. Without `fromCursor` or `fromHeight` the API serves only its recent default window, so pass `fromHeight: 0` for a full backfill. A reorg at or below your checkpoint calls `onReorg`, then the loop re-reads from the fork point. Delivery is at-least-once, so keep writes idempotent. With a `sink`, the checkpoint and rollback are handled for you. `finalizedOnly` holds delivery to finalized rows, so no reorg handling is needed. `mode: "tail"` (default) keeps polling at the tip; `mode: "bounded"` returns on the first empty page. Resolves to `{ cursor, pages, emptyPolls }`.
3113
+ */
2849
3114
  consume<
2850
3115
  T extends IndexEventType,
2851
3116
  TTx = never
@@ -2874,15 +3139,19 @@ type IndexDiscovery = {
2874
3139
  declare class Index extends BaseClient {
2875
3140
  constructor(options?: Partial<SecondLayerOptions>);
2876
3141
  /**
2877
- * Index discovery doc — the live vocabulary: every endpoint, each event type's
2878
- * columns, allowed/equality filters, and required-non-null fields. Read this to
2879
- * learn what's queryable (and which types accept `trait`) instead of hardcoding.
3142
+ * Get the live vocabulary of what Index can query.
3143
+ *
3144
+ * The discovery doc lists every endpoint and each event type's columns,
3145
+ * allowed and equality filters, and required-non-null fields. Read it to
3146
+ * learn what's queryable (and which types accept `trait`) instead of
3147
+ * hardcoding.
2880
3148
  */
2881
3149
  discover(): Promise<IndexDiscovery>;
2882
3150
  /**
2883
- * Empirical per-topic print payload schema for a contract — what topics it
2884
- * emits and each field's observed Clarity/TS/column types. Anonymous read;
2885
- * 404 → null.
3151
+ * Get the print payload schema a contract actually emits.
3152
+ *
3153
+ * Lists the topics it emits and each field's observed Clarity, TS, and
3154
+ * column types. Anonymous read; resolves to `null` on 404.
2886
3155
  */
2887
3156
  printSchema(contractId: string): Promise<PrintSchemaResponse | null>;
2888
3157
  /** Callable: `index.ftTransfers(params)` ≡ `index.ftTransfers.list(params)`. */
@@ -2893,8 +3162,23 @@ declare class Index extends BaseClient {
2893
3162
  * Callable: `index.events(params)` ≡ `index.events.list(params)`. */
2894
3163
  readonly events: IndexEventsResource;
2895
3164
  readonly contractCalls: {
3165
+ /**
3166
+ * Read one page of decoded contract calls.
3167
+ *
3168
+ * Filter by `contractId` (one id or up to 20) or `trait`, never both, plus `functionName`, `sender`, and a height range. Each row has the function name, arguments, result, and status. Pass `next_cursor` back as `cursor` to continue.
3169
+ */
2896
3170
  list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>;
3171
+ /**
3172
+ * Iterate every decoded contract call, paging for you.
3173
+ *
3174
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3175
+ */
2897
3176
  walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>;
3177
+ /**
3178
+ * Run a checkpointed, reorg-aware indexer over contract calls.
3179
+ *
3180
+ * Write your rows in `onBatch` and commit `ctx.cursor` in the same transaction; resume with `fromCursor`. Without `fromCursor` or `fromHeight` the API serves only its recent default window, so pass `fromHeight: 0` for a full backfill. A reorg at or below your checkpoint calls `onReorg`, then the loop re-reads from the fork point. Delivery is at-least-once, so keep writes idempotent. With a `sink`, the checkpoint and rollback are handled for you. `finalizedOnly` holds delivery to finalized rows, so no reorg handling is needed. `mode: "tail"` (default) keeps polling at the tip; `mode: "bounded"` returns on the first empty page. Resolves to `{ cursor, pages, emptyPolls }`. Calls already carry `sender` and `function_name`, so there is no `txContext`.
3181
+ */
2898
3182
  consume: <TTx = never>(params: ContractCallsConsumeParams<TTx> & {
2899
3183
  sink?: ConsumerSink<TTx>;
2900
3184
  }) => Promise<{
@@ -2905,49 +3189,125 @@ declare class Index extends BaseClient {
2905
3189
  };
2906
3190
  /** Canonical block-hash map — sync only the current canonical chain. */
2907
3191
  readonly canonical: {
3192
+ /**
3193
+ * Read one page of the canonical block-hash map.
3194
+ *
3195
+ * Each row is a block's hash, its parent hash, and its burn-chain anchor. Compare it with your own tables to confirm you follow the current chain.
3196
+ */
2908
3197
  list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;
3198
+ /**
3199
+ * Iterate every canonical block hash, paging for you.
3200
+ *
3201
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3202
+ */
2909
3203
  walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;
2910
3204
  };
2911
3205
  /** Exact MARF writes per canonical block (`/v1/index/state-writes`). */
2912
3206
  readonly stateWrites: {
3207
+ /**
3208
+ * Read one page of the contract-state writes each block committed.
3209
+ *
3210
+ * Rows are the exact key and value writes, in the node's write order (`ordinal`), so you can see which key a transaction changed when events alone do not show it. Filter by `blockHeight` (excludes `fromHeight` and `toHeight`) or `contractId`. `txContext: true` joins the writing transaction. Rows exist only from the height your node first subscribed to state writes.
3211
+ */
2913
3212
  list: (params?: StateWritesListParams) => Promise<StateWritesEnvelope>;
3213
+ /**
3214
+ * Iterate every state write, paging for you.
3215
+ *
3216
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3217
+ */
2914
3218
  walk: (params?: StateWritesWalkParams) => AsyncIterable<IndexStateWrite>;
2915
3219
  };
2916
3220
  /** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash
2917
3221
  * (resolves to null on 404). */
2918
3222
  readonly blocks: {
3223
+ /**
3224
+ * Read one page of canonical blocks.
3225
+ *
3226
+ * Each block has its hash, parent hash, burn-chain anchor, and `block_time`. Filter by a height range.
3227
+ */
2919
3228
  list: (params?: BlocksListParams) => Promise<BlocksEnvelope>;
3229
+ /**
3230
+ * Iterate every canonical block, paging for you.
3231
+ *
3232
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3233
+ */
2920
3234
  walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>;
3235
+ /**
3236
+ * Get one block by height or hash, or `null`.
3237
+ *
3238
+ * Resolves to `null` when no such block exists (404).
3239
+ */
2921
3240
  get: (ref: string | number) => Promise<BlockEnvelope | null>;
2922
3241
  };
2923
3242
  /** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id
2924
3243
  * (resolves to null on 404). */
2925
3244
  readonly transactions: {
2926
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2927
- * requested columns plus {@link TransactionAlwaysFields}. Declared as
2928
- * an overloaded call signature because an arrow property cannot carry
2929
- * overloads. */
3245
+ /**
3246
+ * Read one page of full transaction documents.
3247
+ *
3248
+ * Filter by `type`, `sender`, `contractId`, and a height range. Each document has the decoded post conditions and the payload for its `tx_type`; enrichment fields are null when the raw transaction cannot be decoded. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `tx_id` always come back.
3249
+ */
2930
3250
  list: {
2931
3251
  <const F extends keyof IndexTransaction & string>(params: TransactionsListParams & {
2932
3252
  fields: readonly F[];
2933
3253
  }): Promise<TransactionsEnvelope<TransactionFields<F>>>;
2934
3254
  (params?: TransactionsListParams): Promise<TransactionsEnvelope>;
2935
3255
  };
3256
+ /**
3257
+ * Iterate every transaction document, paging for you.
3258
+ *
3259
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3260
+ */
2936
3261
  walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>;
3262
+ /**
3263
+ * Get one transaction by id, or `null`.
3264
+ *
3265
+ * Resolves to `null` when the transaction is not found (404).
3266
+ */
2937
3267
  get: (txId: string) => Promise<TransactionEnvelope | null>;
3268
+ /**
3269
+ * Get a transaction's inclusion proof, or `null`.
3270
+ *
3271
+ * The proof is the raw transaction, the Nakamoto block header, and the merkle path. Check it yourself with `verifyTransactionProof`; nothing in it needs to be trusted. Resolves to `null` on 404. A 503 (`PROOF_TX_SET_INCOMPLETE` or `PROOF_NODE_UNAVAILABLE`) throws an `ApiError`: the proof cannot be assembled on this deployment right now.
3272
+ */
2938
3273
  getProof: (txId: string) => Promise<TransactionProof | null>;
2939
3274
  };
2940
3275
  /** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the
2941
3276
  * platform's PoX-4 decoder is disabled. */
2942
3277
  readonly stacking: {
3278
+ /**
3279
+ * Read one page of decoded PoX-4 stacking actions.
3280
+ *
3281
+ * One row per stacking contract call. Filter by `functionName`, `stacker`, `caller`, and a height range. The feed is empty, with a `notes` hint, when the instance's PoX-4 decoder is disabled. For the current PoX, use `pox5.events` and `pox.cycles`.
3282
+ */
2943
3283
  list: (params?: StackingListParams) => Promise<StackingEnvelope>;
3284
+ /**
3285
+ * Iterate every PoX-4 stacking action, paging for you.
3286
+ *
3287
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3288
+ */
2944
3289
  walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;
2945
3290
  };
2946
3291
  /** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
2947
3292
  * tx_id (resolves to null when the tx has confirmed or dropped). */
2948
3293
  readonly mempool: {
3294
+ /**
3295
+ * Read one page of pending, unconfirmed transactions.
3296
+ *
3297
+ * Filter by `sender`, `type`, `contractId`, and `functionName`. There is no height filter: rows carry `received_at` and a sequence cursor instead of a block position.
3298
+ */
2949
3299
  list: (params?: MempoolListParams) => Promise<MempoolEnvelope>;
3300
+ /**
3301
+ * Iterate every pending transaction, paging for you.
3302
+ *
3303
+ * Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
3304
+ */
2950
3305
  walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>;
3306
+ /**
3307
+ * Get one pending transaction, or `null`.
3308
+ *
3309
+ * Resolves to `null` once the transaction has confirmed or dropped.
3310
+ */
2951
3311
  get: (txId: string) => Promise<MempoolTransactionEnvelope | null>;
2952
3312
  };
2953
3313
  /** Decoded sBTC peg surface — the only productized decoded sBTC peg feed on
@@ -3022,37 +3382,93 @@ declare class Index extends BaseClient {
3022
3382
  }
3023
3383
  import { CreateWebhookRequest, CreateWebhookResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, UpdateWebhookRequest, WebhookActivity, WebhookDeliveryDetail, WebhookDetail, WebhookSummary, WebhookTestResult } from "@secondlayer/shared/schemas/webhooks";
3024
3384
  declare class Webhooks extends BaseClient {
3385
+ /**
3386
+ * List your webhooks.
3387
+ *
3388
+ * Each summary has the status, format, URL, last delivery and last success, and the circuit breaker state (`circuitFailures`, `circuitOpenedAt`).
3389
+ */
3025
3390
  list(): Promise<{
3026
3391
  data: WebhookSummary[];
3027
3392
  }>;
3393
+ /**
3394
+ * Get one webhook's full configuration.
3395
+ *
3396
+ * Adds the triggers, the receiver's auth (redacted to header names and whether a secret is set), the retry and timeout limits, `lastError`, and a `warning` when this instance's trigger evaluator is not running.
3397
+ */
3028
3398
  get(id: string): Promise<WebhookDetail>;
3399
+ /**
3400
+ * Create a webhook that POSTs chain events to your URL.
3401
+ *
3402
+ * Takes a `name`, a `url`, and `triggers` built with `trigger.*`; each trigger is validated before anything is provisioned, and an invalid one is a 400. The signing secret comes back once in `signingSecret`, so store it. A webhook starts at the chain tip and never backfills: use {@link replay} for history. Hosted accounts cap `maxRetries` at 7 and `timeoutMs` at 30000.
3403
+ */
3029
3404
  create(input: CreateWebhookRequest): Promise<CreateWebhookResponse>;
3405
+ /**
3406
+ * Change a webhook's name, URL, format, auth, or delivery limits.
3407
+ *
3408
+ * Send only the fields to change: `name`, `url`, `format`, `authConfig`, `maxRetries`, `timeoutMs`, `concurrency`. Triggers are not part of an update. Resolves to the updated webhook.
3409
+ */
3030
3410
  update(id: string, patch: UpdateWebhookRequest): Promise<WebhookDetail>;
3411
+ /**
3412
+ * Stop deliveries without deleting the webhook.
3413
+ *
3414
+ * Resolves to the updated webhook. {@link resume} turns it back on.
3415
+ */
3031
3416
  pause(id: string): Promise<WebhookDetail>;
3417
+ /**
3418
+ * Start delivering again after a pause.
3419
+ *
3420
+ * Also clears a circuit-breaker pause, which happens after 20 straight failed deliveries. Resolves to the updated webhook.
3421
+ */
3032
3422
  resume(id: string): Promise<WebhookDetail>;
3423
+ /**
3424
+ * Delete a webhook.
3425
+ *
3426
+ * Resolves to `{ ok: true }`. Throws a 404 when the webhook does not exist.
3427
+ */
3033
3428
  delete(id: string): Promise<{
3034
3429
  ok: true;
3035
3430
  }>;
3431
+ /**
3432
+ * Issue a new signing secret.
3433
+ *
3434
+ * The new secret comes back once in `signingSecret`. Update the receiver that calls `verifyWebhookSignature` with it: deliveries are signed with the new secret from now on.
3435
+ */
3036
3436
  rotateSecret(id: string): Promise<RotateSecretResponse>;
3037
- /** Send a one-off test webhook to the webhook's URL (built for its
3038
- * format, SSRF-guarded). Logged as a delivery row, visible via deliveries. */
3437
+ /** Send a one-off test delivery to a webhook's URL.
3438
+ *
3439
+ * Built for the webhook's format and SSRF-guarded. Logged as a delivery
3440
+ * row, visible via `deliveries`. */
3039
3441
  test(id: string): Promise<WebhookTestResult>;
3040
3442
  /** The last 100 delivery attempts, newest first. The server caps the window;
3041
3443
  * there is nothing to page. */
3042
3444
  deliveries(id: string): Promise<{
3043
3445
  data: DeliveryRow[];
3044
3446
  }>;
3045
- /** Hourly delivered/waiting/gave-up counts for the last 7 days, plus the
3046
- * current queue depth — the events chart on the detail page. */
3447
+ /** Get a webhook's hourly delivery counts for the last 7 days.
3448
+ *
3449
+ * Each hour has delivered, waiting, and gave-up counts, plus the current
3450
+ * queue depth. This is the events chart on the detail page. */
3047
3451
  activity(id: string): Promise<WebhookActivity>;
3048
- /** One delivery attempt with its outbox context (payload, response
3049
- * headers) — the delivery card on the detail page. */
3452
+ /** Get one delivery attempt with its payload and response.
3453
+ *
3454
+ * Includes the outbox context (payload, response headers). This is the
3455
+ * delivery card on the detail page. */
3050
3456
  delivery(id: string, deliveryId: string): Promise<WebhookDeliveryDetail>;
3457
+ /**
3458
+ * Re-deliver historical events over an existing webhook.
3459
+ *
3460
+ * Pass `fromBlock` and `toBlock`; the range is capped at 100,000 blocks. A replay is historical only and never moves the live cursor. It is idempotent: the same range twice is a no-op, so pass any string as `force` to re-deliver it. Replays carry `is_replay` and use the standard `chain.{type}.apply` envelope. Resolves to `replayId`, `enqueuedCount`, and `scannedCount`. A second replay while one is running is a 409. `sbtc_withdrawal_swept_confirmed` is forward-only and never replayed. Hosted accounts get 5 replays an hour.
3461
+ */
3051
3462
  replay(id: string, range: {
3052
3463
  fromBlock: number;
3053
3464
  toBlock: number;
3054
3465
  force?: string;
3055
3466
  }): Promise<ReplayResult>;
3467
+ /**
3468
+ * List the events a webhook gave up delivering.
3469
+ *
3470
+ * Returns up to 100 dead-lettered events, newest failure first. Each row's `id` is what {@link requeue} takes.
3471
+ */
3056
3472
  dead(id: string): Promise<{
3057
3473
  data: DeadRow[];
3058
3474
  }>;
@@ -3122,8 +3538,12 @@ declare class SecondLayer extends BaseClient {
3122
3538
  readonly instance: InstanceClient;
3123
3539
  constructor(options?: Partial<SecondLayerOptions>);
3124
3540
  /**
3125
- * Up to 10 public reads in one round trip (`POST /v1/batch`). Each item
3126
- * is authorized on its own; the client's bearer token applies to every item.
3541
+ * Run up to 10 public reads in one round trip (`POST /v1/batch`).
3542
+ *
3543
+ * Each item is authorized on its own; the client's bearer token applies to
3544
+ * every item. Results come back in order as `{ path, status, body }`. Only
3545
+ * paths under `/v1/index/`, `/v1/subgraphs`, `/v1/streams/`, and
3546
+ * `/v1/contracts` are allowed; anything else is a per-item 400.
3127
3547
  */
3128
3548
  batch(requests: Array<{
3129
3549
  path: string;
@@ -3136,10 +3556,12 @@ declare class SecondLayer extends BaseClient {
3136
3556
  }>;
3137
3557
  }>;
3138
3558
  /**
3139
- * Assemble a {@link ContextSnapshot}: the same orientation an MCP agent
3140
- * reads from `secondlayer://context`, available to any SDK/CLI consumer.
3141
- * Reads run concurrently; a failed read lands as `{ value: null, error }`
3142
- * on its field rather than rejecting the whole snapshot.
3559
+ * Get a one-call snapshot of your account and instance.
3560
+ *
3561
+ * Returns a {@link ContextSnapshot}: the same orientation an MCP agent reads
3562
+ * from `secondlayer://context`, available to any SDK or CLI consumer. Reads
3563
+ * run concurrently; a failed read lands as `{ value: null, error }` on its
3564
+ * field rather than rejecting the whole snapshot.
3143
3565
  */
3144
3566
  context(): Promise<ContextSnapshot>;
3145
3567
  }