@secondlayer/sdk 14.5.1 → 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.
@@ -125,6 +125,7 @@ interface SubgraphOperationStatus {
125
125
  /** /v1 cursor envelope for subgraph table reads. */
126
126
  interface SubgraphRowsEnvelope<T = unknown> {
127
127
  rows: T[];
128
+ /** Set on every page that returned rows; `null` only on an empty page. */
128
129
  next_cursor: string | null;
129
130
  tip: {
130
131
  block_height: number;
@@ -143,26 +144,54 @@ interface BundleSubgraphResponse {
143
144
  bundleSize: number;
144
145
  }
145
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
+ */
146
152
  list(): Promise<{
147
153
  data: SubgraphSummary[];
148
154
  }>;
149
155
  /**
150
- * The subgraph's current state — health, sync position, tables. The verify
151
- * step after a deploy, reindex, or backfill: poll it until `sync` catches
152
- * 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.
153
160
  */
154
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
+ */
155
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
+ */
156
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
+ */
157
179
  markdown(name: string, options?: SubgraphSpecOptions): Promise<string>;
158
180
  /**
159
- * 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
160
184
  * block range; the API rejects one with `REINDEX_RANGE_NOT_SUPPORTED`.
161
185
  * Use {@link backfill} to process a specific range. While a reindex or
162
186
  * backfill is already running the API answers 409 with code
163
187
  * `OPERATION_IN_PROGRESS`; poll {@link operations} until it finishes.
164
188
  */
165
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
+ */
166
195
  stop(name: string): Promise<{
167
196
  message: string;
168
197
  operationId?: string;
@@ -174,20 +203,34 @@ declare class Subgraphs extends BaseClient {
174
203
  fromBlock: number;
175
204
  toBlock: number;
176
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
+ */
177
211
  gaps(name: string, opts?: {
178
212
  limit?: number;
179
213
  offset?: number;
180
214
  resolved?: boolean;
181
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
+ */
182
221
  delete(name: string, options?: {
183
222
  force?: boolean;
184
223
  }): Promise<{
185
224
  message: string;
186
225
  }>;
187
226
  /**
188
- * Open /v1 read: cursor-paginated rows. Anon works on an open instance;
189
- * pass an apiKey on the client where reads are closed. Resume with the
190
- * returned `next_cursor`.
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
231
+ * on every page that returned rows and is `null` only on an empty page, so a
232
+ * poller tails with `cursor = page.next_cursor ?? cursor`. A paging loop
233
+ * ends on an empty page (or one shorter than `limit`).
191
234
  */
192
235
  rows<T = unknown>(name: string, table: string, params?: Omit<SubgraphQueryParams, "offset"> & {
193
236
  cursor?: string;
@@ -196,13 +239,20 @@ declare class Subgraphs extends BaseClient {
196
239
  operations(name: string): Promise<{
197
240
  operations: SubgraphOperationStatus[];
198
241
  }>;
199
- /** Status of a single operation (poll the `operationId` returned by
200
- * 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. */
201
246
  getOperation(name: string, operationId: string): Promise<SubgraphOperationStatus>;
202
247
  /** Create or update a subgraph. A deploy that needs a rebuild queues one;
203
248
  * if a reindex or backfill is already running the API answers 409 with
204
249
  * code `OPERATION_IN_PROGRESS` (an `ApiError`, not a dedicated class). */
205
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
+ */
206
256
  getSource(name: string): Promise<SubgraphSource>;
207
257
  /**
208
258
  * Bundle a TypeScript subgraph source on the server. Used by the web chat
@@ -211,13 +261,15 @@ declare class Subgraphs extends BaseClient {
211
261
  bundle(data: {
212
262
  code: string;
213
263
  }): Promise<BundleSubgraphResponse>;
214
- /** Open /v1 read: exact row count for a filtered set. Same auth posture as
215
- * {@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}. */
216
267
  count(name: string, table: string, params?: Pick<SubgraphQueryParams, "filters">): Promise<{
217
268
  count: number;
218
269
  }>;
219
- /** Open /v1 read: scalar aggregates over a filtered set. Same auth posture
220
- * as {@link rows}. */
270
+ /** Compute scalar aggregates over a table's matching rows.
271
+ *
272
+ * Same auth posture as {@link rows}. */
221
273
  aggregate(name: string, table: string, params?: SubgraphAggregateParams): Promise<SubgraphAggregateResponse>;
222
274
  /**
223
275
  * Returns a typed client for a subgraph defined with `defineSubgraph()`.
@@ -229,7 +281,8 @@ declare class Subgraphs extends BaseClient {
229
281
  * const client = sl.subgraphs.typed(mySubgraph)
230
282
  * const page = await client.transfers.findMany({ where: { sender: 'SP...' } })
231
283
  * // page.rows: InferTableRow<typeof mySubgraph.schema.transfers>[]
232
- * // page.nextCursor: string | null — pass back as `cursor` to resume
284
+ * // page.nextCursor: set whenever rows came back, null on an empty page.
285
+ * // Tail new rows: cursor = page.nextCursor ?? cursor
233
286
  * ```
234
287
  */
235
288
  typed<T extends {
@@ -252,7 +305,17 @@ import { InstanceDiagnosis, PublicStatus } from "@secondlayer/shared/archive/ins
252
305
  /** Structural `/public/status` payload. Extra fields are ignored by diagnosis. */
253
306
  type InstanceStatus = PublicStatus;
254
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
+ */
255
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
+ */
256
319
  diagnose(): Promise<InstanceDiagnosis>;
257
320
  };
258
321
  type ArchiveVerifyInput = {
@@ -355,33 +418,83 @@ type ArchiveLoadOptions = {
355
418
  insecure?: boolean;
356
419
  };
357
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
+ */
358
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
+ */
359
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
+ */
360
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
+ */
361
444
  partitions(ref: LoadedArchive, filter?: {
362
445
  dataset?: ArchiveDataset;
363
446
  fromBlock?: number;
364
447
  toBlock?: number;
365
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
+ */
366
454
  quote(input: {
367
455
  paths: string[];
368
456
  flow: ArchiveFlow;
369
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
+ */
370
463
  fetch(input: {
371
464
  paths: string[];
372
465
  flow: ArchiveFlow;
373
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
+ */
374
472
  download(partition: ArchivePartition, opts?: {
375
473
  url?: string;
376
474
  }): Promise<Uint8Array>;
377
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
+ */
378
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
+ */
379
487
  checkout(input: {
380
488
  email: string;
381
489
  pack: 10 | 25 | 50 | 100;
382
490
  }): Promise<{
383
491
  url: string;
384
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
+ */
385
498
  refill(input: {
386
499
  belowUsd: number;
387
500
  packUsd: 10 | 25 | 50 | 100;
@@ -395,6 +508,11 @@ type ArchiveClient = {
395
508
  };
396
509
  /** Hosted archive client plus instance `verify`. `status()` is still the public archive tree. */
397
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
+ */
398
516
  verify(input: ArchiveVerifyInput): Promise<ArchiveVerifyResult>;
399
517
  };
400
518
  /**
@@ -438,8 +556,10 @@ declare class Contracts extends BaseClient {
438
556
  /** Find contracts conforming to `trait`. `trait` is required (server 400s without it). */
439
557
  list(params: ContractsListParams): Promise<ContractsEnvelope>;
440
558
  /**
441
- * Fetch a single contract from the registry by id (the prod-safe ABI source).
442
- * 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.
443
563
  */
444
564
  get(contractId: string, opts?: {
445
565
  includeAbi?: boolean;
@@ -633,7 +753,7 @@ type StreamsTip = {
633
753
  /** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
634
754
  oldest_cursor?: string | null;
635
755
  };
636
- /** `chain=bitcoin` tip (plan 059) — no `burn_block_height`/retention fields,
756
+ /** `chain=bitcoin` tip — no `burn_block_height`/retention fields,
637
757
  * since Bitcoin has no burn chain of its own and Runes reads have no
638
758
  * retention ladder. Returned by `tip({ chain: "bitcoin" })`. */
639
759
  type StreamsBitcoinTip = {
@@ -649,7 +769,7 @@ type StreamsCanonicalBlock = {
649
769
  burn_block_hash: string | null;
650
770
  is_canonical: true;
651
771
  };
652
- /** `chain=bitcoin` canonical block (plan 059) — no burn-chain fields. */
772
+ /** `chain=bitcoin` canonical block — no burn-chain fields. */
653
773
  type StreamsBitcoinCanonicalBlock = {
654
774
  block_height: number;
655
775
  block_hash: string;
@@ -732,8 +852,8 @@ type StreamsEventsListParamsCommon = {
732
852
  toHeight?: number;
733
853
  limit?: number;
734
854
  };
735
- /** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since
736
- * before plan 059. */
855
+ /** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since before Runes events
856
+ * were added. */
737
857
  type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
738
858
  chain?: "stacks";
739
859
  /** `vm` reads ordinal. Omit for Streams 1.0. */
@@ -753,7 +873,7 @@ type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
753
873
  filters?: StreamsFilterMap;
754
874
  };
755
875
  /**
756
- * `chain: "bitcoin"` (plan 059) — Runes events, own cursor space. `types` is
876
+ * `chain: "bitcoin"` — Runes events, own cursor space. `types` is
757
877
  * restricted to {@link RuneEventType} at the type level, so e.g.
758
878
  * `{ chain: "bitcoin", types: ["ft_transfer"] }` is a compile error rather
759
879
  * than a silent 400 at request time. `contractId`/`sender`/`recipient`/
@@ -791,7 +911,7 @@ type StreamsEventsStreamStacksParams = StreamsEventsStreamCommon & {
791
911
  /** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
792
912
  filters?: StreamsFilterMap;
793
913
  };
794
- /** `chain: "bitcoin"` (plan 059/061) — Runes events, tailed the same way as
914
+ /** `chain: "bitcoin"` — Runes events, tailed the same way as
795
915
  * the Stacks default. `types` is restricted to {@link RuneEventType} at the
796
916
  * type level, matching {@link StreamsEventsBitcoinListParams}.
797
917
  * `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
@@ -849,7 +969,7 @@ type StreamsEventsSubscribeStacksParams = StreamsEventsSubscribeCommon & {
849
969
  */
850
970
  onEvent: (event: StreamsEvent) => void | Promise<void>;
851
971
  };
852
- /** `chain: "bitcoin"` (plan 059/061) — Runes events pushed live, on their own
972
+ /** `chain: "bitcoin"` — Runes events pushed live, on their own
853
973
  * cursor space. `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters`
854
974
  * don't exist on this branch — they're Stacks-only. */
855
975
  type StreamsEventsSubscribeBitcoinParams = StreamsEventsSubscribeCommon & {
@@ -1058,7 +1178,7 @@ type StreamsEventsConsumeParams<
1058
1178
  wake?: () => Promise<void>;
1059
1179
  };
1060
1180
  /**
1061
- * `chain: "bitcoin"` (plan 059/061) — the checkpointed sweep over Runes
1181
+ * `chain: "bitcoin"` — the checkpointed sweep over Runes
1062
1182
  * events. A separate, simpler type from {@link StreamsEventsConsumeParams}
1063
1183
  * rather than a widened union member: `filters`/`on`/`decoded` are Stacks-only
1064
1184
  * concepts (labelled OR-groups and Index-shaped projection have no Runes
@@ -1136,7 +1256,7 @@ type StreamsConsumeStacksParams = StreamsConsumeCommon & {
1136
1256
  * event echoes the labels it matched. */
1137
1257
  filters?: StreamsFilterMap;
1138
1258
  };
1139
- /** `chain: "bitcoin"` (plan 059/061) — Runes batches, own cursor space.
1259
+ /** `chain: "bitcoin"` — Runes batches, own cursor space.
1140
1260
  * `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
1141
1261
  * on this branch — they're Stacks-only. */
1142
1262
  type StreamsConsumeBitcoinParams = StreamsConsumeCommon & {
@@ -1239,38 +1359,43 @@ type StreamsDumps = {
1239
1359
  };
1240
1360
  type StreamsClient = {
1241
1361
  /**
1242
- * 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.
1243
1367
  *
1244
- * Yields one {@link StreamsBatch} per `GET /v1/streams/events` page — the
1245
- * existing envelope (`events`, `next_cursor` → `cursor`, `tip`, `reorgs`)
1246
- * with zero extra API calls. Batches are chosen over per-block groupings
1247
- * because the envelope is page-keyed, so every yield is exactly one fetch.
1248
- * Empty pages are skipped; at the tip the iterator re-polls every
1249
- * `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.
1250
1370
  *
1251
- * Reorgs are surfaced on the batch (`batch.reorgs`) but the cursor is not
1252
- * rewound automatically — use `events.consume` with `onReorg` for managed
1253
- * 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.
1254
1373
  */
1255
- /** `chain: "bitcoin"` — batches carry Runes rows only, on the bitcoin tip
1256
- * shape (plan 059/061). */
1257
1374
  consume(params: StreamsConsumeBitcoinParams): AsyncIterableIterator<StreamsBatch<RuneStreamsEvent, StreamsBitcoinTip>>;
1258
- /** Narrowing overload: a literal `types` array narrows every batch's
1259
- * event union to exactly those members. */
1260
1375
  consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeStacksParams & {
1261
1376
  types: T;
1262
1377
  }): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>;
1263
1378
  consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>;
1264
1379
  events: {
1265
- /** `clock: "vm"` pages carry vm rows only (a parallel vocabulary,
1266
- * `event_index` = `ordinal`). Never `StreamsEvent`. Stacks-only —
1267
- * `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
+ */
1268
1396
  list(params: StreamsEventsStacksListParams & {
1269
1397
  clock: "vm";
1270
1398
  }): Promise<StreamsEventsEnvelope<VmStreamsEvent>>;
1271
- /** Narrowing overload, matching `consume`. Classic clock only —
1272
- * `clock: "vm"` is overload 1, and a general `StreamsEventsListParams`
1273
- * variable (clock unresolved) is the wire-union fallback. */
1274
1399
  list<const T extends readonly StreamsEventType[]>(params: Omit<StreamsEventsStacksListParams, "clock" | "types" | "notTypes"> & {
1275
1400
  types: T;
1276
1401
  notTypes?: readonly StreamsEventType[];
@@ -1281,27 +1406,35 @@ type StreamsClient = {
1281
1406
  notTypes?: readonly StreamsEventType[];
1282
1407
  clock?: "classic";
1283
1408
  }): Promise<StreamsEventsEnvelope>;
1284
- /** `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip
1285
- * shape (plan 059). */
1286
1409
  list(params: StreamsEventsBitcoinListParams): Promise<StreamsEventsEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
1287
- /** Unresolved `chain`/`clock` on a general params variable: the wire union. */
1288
1410
  list(params: StreamsEventsListParams): Promise<StreamsEventsEnvelope<StreamsWireEvent>>;
1289
- /** `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
+ */
1290
1419
  byTxId(txId: string, opts: {
1291
1420
  chain: "bitcoin";
1292
1421
  }): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
1293
1422
  byTxId(txId: string): Promise<StreamsEventsListEnvelope>;
1294
1423
  /**
1295
- * Pull pages from Streams and call `onBatch` after each page.
1424
+ * Run a checkpointed indexer that rewinds on reorgs.
1296
1425
  *
1297
- * Use `consume` for indexers and ETL jobs that own checkpointing. Return
1298
- * the checkpoint cursor from `onBatch`. Default `mode: "tail"` keeps
1299
- * polling when caught up; `mode: "bounded"` exits on the first empty page.
1300
- * The consumer also exits when `maxPages`, `maxEmptyPolls`, or `signal`
1301
- * 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}.
1302
1437
  */
1303
- /** `chain: "bitcoin"` — the checkpointed sweep over Runes events; see
1304
- * {@link StreamsEventsConsumeBitcoinParams}. */
1305
1438
  consume<TTx = never>(params: StreamsEventsConsumeBitcoinParams<TTx> & {
1306
1439
  sink?: ConsumerSink<TTx>;
1307
1440
  }): Promise<StreamsEventsConsumeResult>;
@@ -1313,46 +1446,66 @@ type StreamsClient = {
1313
1446
  sink?: ConsumerSink<TTx>;
1314
1447
  }): Promise<StreamsEventsConsumeResult>;
1315
1448
  /**
1316
- * Backfill from bulk dumps, then continue live from the dump→live seam in
1317
- * one call. Iterates finalized dump files (via `onDumpFile`) in block
1318
- * order, then tails live from the manifest's `latest_finalized_cursor`
1319
- * (exclusive input → no gap or duplicate at the seam). Requires
1320
- * `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`.
1321
1455
  */
1322
1456
  replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>;
1323
1457
  /**
1324
- * Follow Streams as an async iterator.
1458
+ * Read events one at a time as an async iterator.
1325
1459
  *
1326
- * Use `stream` for live processors and watch-style apps. It tails
1327
- * indefinitely by default and stops when its `AbortSignal`, `maxPages`, or
1328
- * `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.
1329
1467
  */
1330
- /** `chain: "bitcoin"` — Runes events only (plan 059/061). */
1331
1468
  stream(params: StreamsEventsStreamBitcoinParams): AsyncIterable<RuneStreamsEvent>;
1332
- /** Narrowing overload, matching `consume`. */
1333
1469
  stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamStacksParams & {
1334
1470
  types: T;
1335
1471
  }): AsyncIterable<StreamsEventOfTypes<T>>;
1336
1472
  stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>;
1337
1473
  /**
1338
- * Subscribe to the real-time SSE push surface. Calls `onEvent` for each new
1339
- * canonical event as the server pushes it (chain cadence, not poll-bounded),
1340
- * and verifies each frame's inline ed25519 signature when the client was
1341
- * created with `verify`. Returns an unsubscribe function whose `done`
1342
- * settles when the loop ends. Not reorg-aware: an event delivered then
1343
- * 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`.
1344
1483
  */
1345
- /** `chain: "bitcoin"` — `onEvent` receives Runes rows (plan 059/061). */
1346
1484
  subscribe(params: StreamsEventsSubscribeBitcoinParams): StreamsSubscription;
1347
1485
  subscribe(params: StreamsEventsSubscribeStacksParams): StreamsSubscription;
1348
1486
  };
1349
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
+ */
1350
1495
  events(heightOrHash: number | string, opts: {
1351
1496
  chain: "bitcoin";
1352
1497
  }): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
1353
1498
  events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>;
1354
1499
  };
1355
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
+ */
1356
1509
  list(params: StreamsReorgsListParams & {
1357
1510
  chain: "bitcoin";
1358
1511
  }): Promise<StreamsReorgsListEnvelope>;
@@ -1360,10 +1513,27 @@ type StreamsClient = {
1360
1513
  };
1361
1514
  /** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
1362
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
+ */
1363
1523
  canonical(height: number, opts: {
1364
1524
  chain: "bitcoin";
1365
1525
  }): Promise<StreamsBitcoinCanonicalBlock>;
1366
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
+ */
1367
1537
  tip(opts: {
1368
1538
  chain: "bitcoin";
1369
1539
  }): Promise<StreamsBitcoinTip>;
@@ -2364,15 +2534,27 @@ type SbtcDepositsConsumeParams<TTx = never> = Omit<SbtcDepositsListParams, "curs
2364
2534
  * events, scoreboard). The only productized decoded sBTC peg feed on Stacks. */
2365
2535
  interface SbtcResource {
2366
2536
  deposits: {
2367
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2368
- * 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
+ */
2369
2542
  list<const F extends keyof IndexSbtcDeposit & string>(params: SbtcDepositsListParams & {
2370
2543
  fields: readonly F[];
2371
2544
  }): Promise<SbtcDepositsEnvelope<SbtcDepositFields<F>>>;
2372
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
+ */
2373
2551
  walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>;
2374
- /** Checkpointed sweep of completed deposits — append-only, so safe to
2375
- * 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
+ */
2376
2558
  consume<TTx = never>(params: SbtcDepositsConsumeParams<TTx> & {
2377
2559
  sink?: ConsumerSink<TTx>;
2378
2560
  }): Promise<{
@@ -2384,21 +2566,43 @@ interface SbtcResource {
2384
2566
  get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>;
2385
2567
  };
2386
2568
  withdrawals: {
2387
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2388
- * 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
+ */
2389
2574
  list<const F extends keyof IndexSbtcWithdrawal & string>(params: SbtcWithdrawalsListParams & {
2390
2575
  fields: readonly F[];
2391
2576
  }): Promise<SbtcWithdrawalsEnvelope<SbtcWithdrawalFields<F>>>;
2392
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
+ */
2393
2583
  walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>;
2394
2584
  /** Fetch a withdrawal's full lifecycle by request id; 404 → null. */
2395
2585
  get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>;
2396
2586
  };
2397
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
+ */
2398
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
+ */
2399
2599
  walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>;
2400
- /** Checkpointed sweep of the raw peg event log — append-only across all
2401
- * 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
+ */
2402
2606
  consume<TTx = never>(params: SbtcEventsConsumeParams<TTx> & {
2403
2607
  sink?: ConsumerSink<TTx>;
2404
2608
  }): Promise<{
@@ -2407,7 +2611,11 @@ interface SbtcResource {
2407
2611
  emptyPolls: number;
2408
2612
  }>;
2409
2613
  };
2410
- /** 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
+ */
2411
2619
  summary(): Promise<SbtcSummaryEnvelope>;
2412
2620
  }
2413
2621
  /** One pox-5 reward cycle, exact to the node. */
@@ -2488,10 +2696,24 @@ type PoxCyclesWalkParams = Omit<PoxCyclesListParams, "limit"> & WalkOptions;
2488
2696
  /** `index.pox` — reward cycles of the current PoX (PoX-5). */
2489
2697
  interface PoxResource {
2490
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
+ */
2491
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
+ */
2492
2710
  walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>;
2493
- /** Fetch one reward cycle by number; 404 (unknown cycle, or below pox-5's
2494
- * 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
+ */
2495
2717
  get(rewardCycle: number): Promise<PoxCycleEnvelope | null>;
2496
2718
  };
2497
2719
  }
@@ -2566,15 +2788,27 @@ type Pox5EventsConsumeParams<TTx = never> = Omit<Pox5EventsListParams, "cursor"
2566
2788
  * epoch 4.0 hard fork onward (PoX-4's `index.stacking` stream ends there). */
2567
2789
  interface Pox5Resource {
2568
2790
  events: {
2569
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2570
- * 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
+ */
2571
2796
  list<const F extends keyof IndexPox5Event & string>(params: Pox5EventsListParams & {
2572
2797
  fields: readonly F[];
2573
2798
  }): Promise<Pox5EventsEnvelope<Pox5EventFields<F>>>;
2574
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
+ */
2575
2805
  walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event>;
2576
- /** Checkpointed sweep of the pox-5 print log — append-only across all
2577
- * 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
+ */
2578
2812
  consume<TTx = never>(params: Pox5EventsConsumeParams<TTx> & {
2579
2813
  sink?: ConsumerSink<TTx>;
2580
2814
  }): Promise<{
@@ -2752,14 +2986,28 @@ interface RunesResource {
2752
2986
  /** The rune catalog. `search` prefix-matches the name; `sort` is etch
2753
2987
  * order (default) or busiest-first. */
2754
2988
  list(params?: RunesListParams): Promise<RunesEnvelope>;
2755
- /** One rune's full entry by id or name; `null` on 404 (no such rune, or
2756
- * 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
+ */
2757
2995
  get(rune: RuneRef): Promise<RuneEnvelope | null>;
2758
2996
  /** Current per-outpoint rune balances by address or outpoint. */
2759
2997
  balances(params: RuneBalancesListParams): Promise<RuneBalancesEnvelope>;
2760
2998
  /** Etch/mint/transfer/burn events, cursor `<block_height>:<event_index>`. */
2761
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
+ */
2762
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
+ */
2763
3011
  walk(params?: RuneActivityWalkParams): AsyncIterable<IndexRuneEvent>;
2764
3012
  };
2765
3013
  }
@@ -2777,15 +3025,20 @@ interface FtTransfersResource {
2777
3025
  fields: readonly F[];
2778
3026
  }): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
2779
3027
  (params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
2780
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2781
- * 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
+ */
2782
3033
  list<const F extends keyof FtTransfer & string>(params: FtTransfersListParams & {
2783
3034
  fields: readonly F[];
2784
3035
  }): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
2785
3036
  list(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
2786
- /** Narrowing overload, matching `list`: `walk` forwards `fields` to the
2787
- * wire, so without this the yielded rows are stripped while the type
2788
- * 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
+ */
2789
3042
  walk<const F extends keyof FtTransfer & string>(params: FtTransfersWalkParams & {
2790
3043
  fields: readonly F[];
2791
3044
  }): AsyncIterable<FtTransferFields<F>>;
@@ -2799,13 +3052,20 @@ interface NftTransfersResource {
2799
3052
  fields: readonly F[];
2800
3053
  }): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
2801
3054
  (params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
2802
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2803
- * 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
+ */
2804
3060
  list<const F extends keyof NftTransfer & string>(params: NftTransfersListParams & {
2805
3061
  fields: readonly F[];
2806
3062
  }): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
2807
3063
  list(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
2808
- /** 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
+ */
2809
3069
  walk<const F extends keyof NftTransfer & string>(params: NftTransfersWalkParams & {
2810
3070
  fields: readonly F[];
2811
3071
  }): AsyncIterable<NftTransferFields<F>>;
@@ -2822,9 +3082,11 @@ interface IndexEventsResource {
2822
3082
  fields: readonly F[];
2823
3083
  }): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
2824
3084
  <T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
2825
- /** Narrowing overload: `fields` shrinks the returned row type to exactly
2826
- * the requested columns plus {@link IndexAlwaysFields}. `const F` means no
2827
- * `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
+ */
2828
3090
  list<
2829
3091
  T extends IndexEventType,
2830
3092
  const F extends keyof IndexEventOf<T> & string
@@ -2832,9 +3094,11 @@ interface IndexEventsResource {
2832
3094
  fields: readonly F[];
2833
3095
  }): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
2834
3096
  list<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
2835
- /** Narrowing overload, matching `list`: `walk` forwards `fields` to the
2836
- * wire, so without this the yielded rows are stripped while the type
2837
- * 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
+ */
2838
3102
  walk<
2839
3103
  T extends IndexEventType,
2840
3104
  const F extends keyof IndexEventOf<T> & string
@@ -2842,6 +3106,11 @@ interface IndexEventsResource {
2842
3106
  fields: readonly F[];
2843
3107
  }): AsyncIterable<IndexEventFields<T, F>>;
2844
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
+ */
2845
3114
  consume<
2846
3115
  T extends IndexEventType,
2847
3116
  TTx = never
@@ -2870,15 +3139,19 @@ type IndexDiscovery = {
2870
3139
  declare class Index extends BaseClient {
2871
3140
  constructor(options?: Partial<SecondLayerOptions>);
2872
3141
  /**
2873
- * Index discovery doc — the live vocabulary: every endpoint, each event type's
2874
- * columns, allowed/equality filters, and required-non-null fields. Read this to
2875
- * 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.
2876
3148
  */
2877
3149
  discover(): Promise<IndexDiscovery>;
2878
3150
  /**
2879
- * Empirical per-topic print payload schema for a contract — what topics it
2880
- * emits and each field's observed Clarity/TS/column types. Anonymous read;
2881
- * 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.
2882
3155
  */
2883
3156
  printSchema(contractId: string): Promise<PrintSchemaResponse | null>;
2884
3157
  /** Callable: `index.ftTransfers(params)` ≡ `index.ftTransfers.list(params)`. */
@@ -2889,8 +3162,23 @@ declare class Index extends BaseClient {
2889
3162
  * Callable: `index.events(params)` ≡ `index.events.list(params)`. */
2890
3163
  readonly events: IndexEventsResource;
2891
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
+ */
2892
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
+ */
2893
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
+ */
2894
3182
  consume: <TTx = never>(params: ContractCallsConsumeParams<TTx> & {
2895
3183
  sink?: ConsumerSink<TTx>;
2896
3184
  }) => Promise<{
@@ -2901,49 +3189,125 @@ declare class Index extends BaseClient {
2901
3189
  };
2902
3190
  /** Canonical block-hash map — sync only the current canonical chain. */
2903
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
+ */
2904
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
+ */
2905
3203
  walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;
2906
3204
  };
2907
3205
  /** Exact MARF writes per canonical block (`/v1/index/state-writes`). */
2908
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
+ */
2909
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
+ */
2910
3218
  walk: (params?: StateWritesWalkParams) => AsyncIterable<IndexStateWrite>;
2911
3219
  };
2912
3220
  /** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash
2913
3221
  * (resolves to null on 404). */
2914
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
+ */
2915
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
+ */
2916
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
+ */
2917
3240
  get: (ref: string | number) => Promise<BlockEnvelope | null>;
2918
3241
  };
2919
3242
  /** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id
2920
3243
  * (resolves to null on 404). */
2921
3244
  readonly transactions: {
2922
- /** Narrowing overload: `fields` shrinks the row type to exactly the
2923
- * requested columns plus {@link TransactionAlwaysFields}. Declared as
2924
- * an overloaded call signature because an arrow property cannot carry
2925
- * 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
+ */
2926
3250
  list: {
2927
3251
  <const F extends keyof IndexTransaction & string>(params: TransactionsListParams & {
2928
3252
  fields: readonly F[];
2929
3253
  }): Promise<TransactionsEnvelope<TransactionFields<F>>>;
2930
3254
  (params?: TransactionsListParams): Promise<TransactionsEnvelope>;
2931
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
+ */
2932
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
+ */
2933
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
+ */
2934
3273
  getProof: (txId: string) => Promise<TransactionProof | null>;
2935
3274
  };
2936
3275
  /** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the
2937
3276
  * platform's PoX-4 decoder is disabled. */
2938
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
+ */
2939
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
+ */
2940
3289
  walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;
2941
3290
  };
2942
3291
  /** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
2943
3292
  * tx_id (resolves to null when the tx has confirmed or dropped). */
2944
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
+ */
2945
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
+ */
2946
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
+ */
2947
3311
  get: (txId: string) => Promise<MempoolTransactionEnvelope | null>;
2948
3312
  };
2949
3313
  /** Decoded sBTC peg surface — the only productized decoded sBTC peg feed on
@@ -3018,37 +3382,93 @@ declare class Index extends BaseClient {
3018
3382
  }
3019
3383
  import { CreateWebhookRequest, CreateWebhookResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, UpdateWebhookRequest, WebhookActivity, WebhookDeliveryDetail, WebhookDetail, WebhookSummary, WebhookTestResult } from "@secondlayer/shared/schemas/webhooks";
3020
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
+ */
3021
3390
  list(): Promise<{
3022
3391
  data: WebhookSummary[];
3023
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
+ */
3024
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
+ */
3025
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
+ */
3026
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
+ */
3027
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
+ */
3028
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
+ */
3029
3428
  delete(id: string): Promise<{
3030
3429
  ok: true;
3031
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
+ */
3032
3436
  rotateSecret(id: string): Promise<RotateSecretResponse>;
3033
- /** Send a one-off test webhook to the webhook's URL (built for its
3034
- * 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`. */
3035
3441
  test(id: string): Promise<WebhookTestResult>;
3036
3442
  /** The last 100 delivery attempts, newest first. The server caps the window;
3037
3443
  * there is nothing to page. */
3038
3444
  deliveries(id: string): Promise<{
3039
3445
  data: DeliveryRow[];
3040
3446
  }>;
3041
- /** Hourly delivered/waiting/gave-up counts for the last 7 days, plus the
3042
- * 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. */
3043
3451
  activity(id: string): Promise<WebhookActivity>;
3044
- /** One delivery attempt with its outbox context (payload, response
3045
- * 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. */
3046
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
+ */
3047
3462
  replay(id: string, range: {
3048
3463
  fromBlock: number;
3049
3464
  toBlock: number;
3050
3465
  force?: string;
3051
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
+ */
3052
3472
  dead(id: string): Promise<{
3053
3473
  data: DeadRow[];
3054
3474
  }>;
@@ -3118,8 +3538,12 @@ declare class SecondLayer extends BaseClient {
3118
3538
  readonly instance: InstanceClient;
3119
3539
  constructor(options?: Partial<SecondLayerOptions>);
3120
3540
  /**
3121
- * Up to 10 public reads in one round trip (`POST /v1/batch`). Each item
3122
- * 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.
3123
3547
  */
3124
3548
  batch(requests: Array<{
3125
3549
  path: string;
@@ -3132,10 +3556,12 @@ declare class SecondLayer extends BaseClient {
3132
3556
  }>;
3133
3557
  }>;
3134
3558
  /**
3135
- * Assemble a {@link ContextSnapshot}: the same orientation an MCP agent
3136
- * reads from `secondlayer://context`, available to any SDK/CLI consumer.
3137
- * Reads run concurrently; a failed read lands as `{ value: null, error }`
3138
- * 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.
3139
3565
  */
3140
3566
  context(): Promise<ContextSnapshot>;
3141
3567
  }