@secondlayer/sdk 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,28 +19,48 @@ const sl = new SecondLayer({
19
19
  });
20
20
  ```
21
21
 
22
+ ## Mental model
23
+
24
+ - `sl.streams` reads raw ordered L1 events from Stacks Streams.
25
+ - `sl.index` reads decoded L2 FT/NFT transfer events from Stacks Index.
26
+ - `sl.subgraphs` reads app-specific L3 tables from Stacks Subgraphs.
27
+
22
28
  ## Stacks Streams
23
29
 
24
- Typed HTTP client.
30
+ Typed L1 HTTP client.
25
31
 
26
32
  `sk-sl_streams_status_public` is a public, non-secret Free-tier key used by the
27
33
  Second Layer status page. Production apps should use their own Streams API key.
28
34
 
35
+ ```typescript
36
+ const tip = await sl.streams.tip();
37
+ const page = await sl.streams.events.list({
38
+ types: ["ft_transfer"],
39
+ contractId: "SP...sbtc-token",
40
+ limit: 10,
41
+ });
42
+
43
+ console.log({ tip, firstCursor: page.events[0]?.cursor });
44
+ ```
45
+
46
+ `createStreamsClient` remains available for focused Streams-only consumers:
47
+
29
48
  ```typescript
30
49
  import { createStreamsClient } from "@secondlayer/sdk";
31
50
 
32
- const client = createStreamsClient({
51
+ const streams = createStreamsClient({
33
52
  apiKey: process.env.SECONDLAYER_API_KEY!,
34
- baseUrl: process.env.SECONDLAYER_API_URL,
35
53
  });
54
+ ```
36
55
 
37
- const tip = await client.tip();
38
- const page = await client.events.list({
39
- types: ["ft_transfer"],
40
- limit: 10,
41
- });
56
+ Convenience reads:
42
57
 
43
- console.log({ tip, firstCursor: page.events[0]?.cursor });
58
+ ```typescript
59
+ await sl.streams.canonical(182431);
60
+ await sl.streams.events.byTxId("0x...");
61
+ await sl.streams.blocks.events(182431);
62
+ await sl.streams.blocks.events("0xindex-block-hash");
63
+ await sl.streams.reorgs.list({ since: "2026-05-03T00:00:00.000Z" });
44
64
  ```
45
65
 
46
66
  Checkpointed consumer.
@@ -120,9 +140,37 @@ the decoder. Decoders throw when the event type or payload is malformed. Add new
120
140
  helpers beside `src/streams/ft-transfer.ts` and export them through
121
141
  `src/streams/index.ts`.
122
142
 
123
- ## Subgraphs
143
+ ## Stacks Index
124
144
 
125
- Deploy and query subgraphs (custom indexers).
145
+ Decoded L2 transfer events.
146
+
147
+ ```typescript
148
+ const ftPage = await sl.index.ftTransfers.list({
149
+ contractId: "SP...sbtc-token",
150
+ sender: "SP...",
151
+ limit: 100,
152
+ });
153
+
154
+ const nftPage = await sl.index.nftTransfers.list({
155
+ assetIdentifier: "SP...collection::token",
156
+ recipient: "SP...",
157
+ });
158
+ ```
159
+
160
+ Backfill with SDK walkers:
161
+
162
+ ```typescript
163
+ for await (const transfer of sl.index.ftTransfers.walk({
164
+ fromHeight: 0,
165
+ batchSize: 500,
166
+ })) {
167
+ console.log(transfer.cursor, transfer.amount);
168
+ }
169
+ ```
170
+
171
+ ## Stacks Subgraphs
172
+
173
+ Deploy and query app-specific L3 tables.
126
174
 
127
175
  ```typescript
128
176
  // List
@@ -138,6 +186,15 @@ const rows = await sl.subgraphs.queryTable("my-subgraph", "transfers", {
138
186
  limit: 50,
139
187
  });
140
188
 
189
+ const { count } = await sl.subgraphs.queryTableCount(
190
+ "my-subgraph",
191
+ "transfers",
192
+ );
193
+
194
+ const spec = await sl.subgraphs.openapi("my-subgraph");
195
+ const source = await sl.subgraphs.getSource("my-subgraph");
196
+ const gaps = await sl.subgraphs.gaps("my-subgraph");
197
+
141
198
  // Deploy
142
199
  const result = await sl.subgraphs.deploy({ name, sources, schema, handlerCode });
143
200
  ```
package/dist/index.d.ts CHANGED
@@ -2,11 +2,14 @@ import { ReindexResponse, SubgraphDetail, SubgraphGapsResponse, SubgraphQueryPar
2
2
  import { DeploySubgraphRequest, DeploySubgraphResponse } from "@secondlayer/shared/schemas/subgraphs";
3
3
  import { SubgraphAgentSchema, SubgraphSpecOptions } from "@secondlayer/shared/subgraphs/spec";
4
4
  import { InferSubgraphClient } from "@secondlayer/subgraphs";
5
+ type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
5
6
  interface SecondLayerOptions {
6
7
  /** Base URL of the Secondlayer API (trailing slashes are stripped). */
7
8
  baseUrl: string;
8
9
  /** Bearer token for authenticated requests. */
9
10
  apiKey?: string;
11
+ /** Fetch implementation. Tests and edge runtimes can provide their own. */
12
+ fetchImpl?: FetchLike;
10
13
  /** Deploy origin label sent as `x-sl-origin` (telemetry). Defaults to `cli`. */
11
14
  origin?: "cli" | "mcp" | "session";
12
15
  }
@@ -188,59 +191,6 @@ declare class Index extends BaseClient {
188
191
  private walkFtTransfers;
189
192
  private walkNftTransfers;
190
193
  }
191
- import { CreateSubscriptionRequest, CreateSubscriptionResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, SubscriptionDetail, SubscriptionSummary, UpdateSubscriptionRequest } from "@secondlayer/shared/schemas/subscriptions";
192
- import { CreateSubscriptionRequest as CreateSubscriptionRequest2, CreateSubscriptionResponse as CreateSubscriptionResponse2, DeadRow as DeadRow2, DeliveryRow as DeliveryRow2, ReplayResult as ReplayResult2, RotateSecretResponse as RotateSecretResponse2, SubscriptionDetail as SubscriptionDetail2, SubscriptionFormat, SubscriptionRuntime, SubscriptionStatus, SubscriptionSummary as SubscriptionSummary2, UpdateSubscriptionRequest as UpdateSubscriptionRequest2 } from "@secondlayer/shared/schemas/subscriptions";
193
- declare class Subscriptions extends BaseClient {
194
- list(): Promise<{
195
- data: SubscriptionSummary[]
196
- }>;
197
- get(id: string): Promise<SubscriptionDetail>;
198
- create(input: CreateSubscriptionRequest): Promise<CreateSubscriptionResponse>;
199
- update(id: string, patch: UpdateSubscriptionRequest): Promise<SubscriptionDetail>;
200
- pause(id: string): Promise<SubscriptionDetail>;
201
- resume(id: string): Promise<SubscriptionDetail>;
202
- delete(id: string): Promise<{
203
- ok: true
204
- }>;
205
- rotateSecret(id: string): Promise<RotateSecretResponse>;
206
- recentDeliveries(id: string): Promise<{
207
- data: DeliveryRow[]
208
- }>;
209
- replay(id: string, range: {
210
- fromBlock: number
211
- toBlock: number
212
- }): Promise<ReplayResult>;
213
- dead(id: string): Promise<{
214
- data: DeadRow[]
215
- }>;
216
- requeueDead(id: string, outboxId: string): Promise<{
217
- ok: true
218
- }>;
219
- }
220
- declare class SecondLayer extends BaseClient {
221
- readonly index: Index;
222
- readonly subgraphs: Subgraphs;
223
- readonly subscriptions: Subscriptions;
224
- constructor(options?: Partial<SecondLayerOptions>);
225
- }
226
- /**
227
- * Returns a typed client for a subgraph defined with `defineSubgraph()`.
228
- *
229
- * Accepts a plain options object, a `SecondLayer` instance, or a `Subgraphs` instance.
230
- *
231
- * @example
232
- * ```ts
233
- * import mySubgraph from './subgraphs/my-subgraph'
234
- * import { getSubgraph } from '@secondlayer/sdk'
235
- *
236
- * const client = getSubgraph(mySubgraph, { apiKey: 'sl_...' })
237
- * const rows = await client.transfers.findMany({ where: { sender: 'SP...' } })
238
- * ```
239
- */
240
- declare function getSubgraph<T extends {
241
- name: string
242
- schema: Record<string, unknown>
243
- }>(def: T, options?: Partial<SecondLayerOptions> | SecondLayer | Subgraphs): InferSubgraphClient2<T>;
244
194
  declare const STREAMS_EVENT_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "print"];
245
195
  type StreamsEventType = (typeof STREAMS_EVENT_TYPES)[number];
246
196
  type StreamsEventPayload = Record<string, unknown>;
@@ -263,6 +213,13 @@ type StreamsTip = {
263
213
  burn_block_height: number
264
214
  lag_seconds: number
265
215
  };
216
+ type StreamsCanonicalBlock = {
217
+ block_height: number
218
+ index_block_hash: string
219
+ burn_block_height: number
220
+ burn_block_hash: string | null
221
+ is_canonical: true
222
+ };
266
223
  type StreamsReorg = {
267
224
  detected_at: string
268
225
  fork_point_height: number
@@ -278,11 +235,21 @@ type StreamsEventsEnvelope = {
278
235
  tip: StreamsTip
279
236
  reorgs: StreamsReorg[]
280
237
  };
238
+ type StreamsEventsListEnvelope = Omit<StreamsEventsEnvelope, "next_cursor">;
239
+ type StreamsReorgsListParams = {
240
+ since: string
241
+ limit?: number
242
+ };
243
+ type StreamsReorgsListEnvelope = {
244
+ reorgs: StreamsReorg[]
245
+ next_since: string | null
246
+ };
281
247
  type StreamsEventsListParams = {
282
248
  cursor?: string | null
283
249
  fromHeight?: number
284
250
  toHeight?: number
285
251
  types?: readonly StreamsEventType[]
252
+ contractId?: string
286
253
  limit?: number
287
254
  };
288
255
  type StreamsEventsStreamParams = {
@@ -310,10 +277,11 @@ type StreamsEventsConsumeResult = {
310
277
  pages: number
311
278
  emptyPolls: number
312
279
  };
313
- type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
280
+ type FetchLike2 = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
314
281
  type StreamsClient = {
315
282
  events: {
316
283
  list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>
284
+ byTxId(txId: string): Promise<StreamsEventsListEnvelope>
317
285
  /**
318
286
  * Pull pages from Streams and call `onBatch` after each page.
319
287
  *
@@ -333,12 +301,73 @@ type StreamsClient = {
333
301
  */
334
302
  stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>
335
303
  }
304
+ blocks: {
305
+ events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>
306
+ }
307
+ reorgs: {
308
+ list(params: StreamsReorgsListParams): Promise<StreamsReorgsListEnvelope>
309
+ }
310
+ canonical(height: number): Promise<StreamsCanonicalBlock>
336
311
  tip(): Promise<StreamsTip>
337
312
  };
313
+ import { CreateSubscriptionRequest, CreateSubscriptionResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, SubscriptionDetail, SubscriptionSummary, UpdateSubscriptionRequest } from "@secondlayer/shared/schemas/subscriptions";
314
+ import { CreateSubscriptionRequest as CreateSubscriptionRequest2, CreateSubscriptionResponse as CreateSubscriptionResponse2, DeadRow as DeadRow2, DeliveryRow as DeliveryRow2, ReplayResult as ReplayResult2, RotateSecretResponse as RotateSecretResponse2, SubscriptionDetail as SubscriptionDetail2, SubscriptionFormat, SubscriptionRuntime, SubscriptionStatus, SubscriptionSummary as SubscriptionSummary2, UpdateSubscriptionRequest as UpdateSubscriptionRequest2 } from "@secondlayer/shared/schemas/subscriptions";
315
+ declare class Subscriptions extends BaseClient {
316
+ list(): Promise<{
317
+ data: SubscriptionSummary[]
318
+ }>;
319
+ get(id: string): Promise<SubscriptionDetail>;
320
+ create(input: CreateSubscriptionRequest): Promise<CreateSubscriptionResponse>;
321
+ update(id: string, patch: UpdateSubscriptionRequest): Promise<SubscriptionDetail>;
322
+ pause(id: string): Promise<SubscriptionDetail>;
323
+ resume(id: string): Promise<SubscriptionDetail>;
324
+ delete(id: string): Promise<{
325
+ ok: true
326
+ }>;
327
+ rotateSecret(id: string): Promise<RotateSecretResponse>;
328
+ recentDeliveries(id: string): Promise<{
329
+ data: DeliveryRow[]
330
+ }>;
331
+ replay(id: string, range: {
332
+ fromBlock: number
333
+ toBlock: number
334
+ }): Promise<ReplayResult>;
335
+ dead(id: string): Promise<{
336
+ data: DeadRow[]
337
+ }>;
338
+ requeueDead(id: string, outboxId: string): Promise<{
339
+ ok: true
340
+ }>;
341
+ }
342
+ declare class SecondLayer extends BaseClient {
343
+ readonly streams: StreamsClient;
344
+ readonly index: Index;
345
+ readonly subgraphs: Subgraphs;
346
+ readonly subscriptions: Subscriptions;
347
+ constructor(options?: Partial<SecondLayerOptions>);
348
+ }
349
+ /**
350
+ * Returns a typed client for a subgraph defined with `defineSubgraph()`.
351
+ *
352
+ * Accepts a plain options object, a `SecondLayer` instance, or a `Subgraphs` instance.
353
+ *
354
+ * @example
355
+ * ```ts
356
+ * import mySubgraph from './subgraphs/my-subgraph'
357
+ * import { getSubgraph } from '@secondlayer/sdk'
358
+ *
359
+ * const client = getSubgraph(mySubgraph, { apiKey: 'sl_...' })
360
+ * const rows = await client.transfers.findMany({ where: { sender: 'SP...' } })
361
+ * ```
362
+ */
363
+ declare function getSubgraph<T extends {
364
+ name: string
365
+ schema: Record<string, unknown>
366
+ }>(def: T, options?: Partial<SecondLayerOptions> | SecondLayer | Subgraphs): InferSubgraphClient2<T>;
338
367
  type CreateStreamsClientOptions = {
339
368
  apiKey: string
340
369
  baseUrl?: string
341
- fetchImpl?: FetchLike
370
+ fetchImpl?: FetchLike2
342
371
  };
343
372
  declare function createStreamsClient(options: CreateStreamsClientOptions): StreamsClient;
344
373
  declare class AuthError extends Error {
@@ -483,4 +512,4 @@ declare class VersionConflictError extends ApiError {
483
512
  * ```
484
513
  */
485
514
  declare function verifyWebhookSignature(rawBody: string, signatureHeader: string, secret: string, toleranceSeconds?: number): boolean;
486
- export { verifyWebhookSignature, isNftTransfer, isFtTransfer, getSubgraph, decodeNftTransfer, decodeFtTransfer, createStreamsClient, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsServerError, StreamsReorg, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsClient, SecondLayerOptions, SecondLayer, RotateSecretResponse2 as RotateSecretResponse, ReplayResult2 as ReplayResult, RateLimitError, NftTransfersWalkParams, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, IndexTip, Index, FtTransfersWalkParams, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike, DeliveryRow2 as DeliveryRow, DecodedNftTransferPayload, DecodedNftTransfer, DecodedFtTransferPayload, DecodedFtTransfer, DecodedEventRow, DeadRow2 as DeadRow, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, AuthError, ApiError };
515
+ export { verifyWebhookSignature, isNftTransfer, isFtTransfer, getSubgraph, decodeNftTransfer, decodeFtTransfer, createStreamsClient, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorg, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsClient, StreamsCanonicalBlock, SecondLayerOptions, SecondLayer, RotateSecretResponse2 as RotateSecretResponse, ReplayResult2 as ReplayResult, RateLimitError, NftTransfersWalkParams, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, IndexTip, Index, FtTransfersWalkParams, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, DeliveryRow2 as DeliveryRow, DecodedNftTransferPayload, DecodedNftTransfer, DecodedFtTransferPayload, DecodedFtTransfer, DecodedEventRow, DeadRow2 as DeadRow, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, AuthError, ApiError };
package/dist/index.js CHANGED
@@ -381,69 +381,6 @@ class Index extends BaseClient {
381
381
  }
382
382
  }
383
383
 
384
- // src/subscriptions/client.ts
385
- class Subscriptions extends BaseClient {
386
- async list() {
387
- return this.request("GET", "/api/subscriptions");
388
- }
389
- async get(id) {
390
- return this.request("GET", `/api/subscriptions/${id}`);
391
- }
392
- async create(input) {
393
- return this.request("POST", "/api/subscriptions", input);
394
- }
395
- async update(id, patch) {
396
- return this.request("PATCH", `/api/subscriptions/${id}`, patch);
397
- }
398
- async pause(id) {
399
- return this.request("POST", `/api/subscriptions/${id}/pause`);
400
- }
401
- async resume(id) {
402
- return this.request("POST", `/api/subscriptions/${id}/resume`);
403
- }
404
- async delete(id) {
405
- return this.request("DELETE", `/api/subscriptions/${id}`);
406
- }
407
- async rotateSecret(id) {
408
- return this.request("POST", `/api/subscriptions/${id}/rotate-secret`);
409
- }
410
- async recentDeliveries(id) {
411
- return this.request("GET", `/api/subscriptions/${id}/deliveries`);
412
- }
413
- async replay(id, range) {
414
- return this.request("POST", `/api/subscriptions/${id}/replay`, range);
415
- }
416
- async dead(id) {
417
- return this.request("GET", `/api/subscriptions/${id}/dead`);
418
- }
419
- async requeueDead(id, outboxId) {
420
- return this.request("POST", `/api/subscriptions/${id}/dead/${outboxId}/requeue`);
421
- }
422
- }
423
-
424
- // src/client.ts
425
- class SecondLayer extends BaseClient {
426
- index;
427
- subgraphs;
428
- subscriptions;
429
- constructor(options = {}) {
430
- super(options);
431
- this.index = new Index(options);
432
- this.subgraphs = new Subgraphs(options);
433
- this.subscriptions = new Subscriptions(options);
434
- }
435
- }
436
-
437
- // src/subgraphs/get-subgraph.ts
438
- function getSubgraph(def, options = {}) {
439
- if (options instanceof Subgraphs) {
440
- return options.typed(def);
441
- }
442
- if (options instanceof SecondLayer) {
443
- return options.subgraphs.typed(def);
444
- }
445
- return new Subgraphs(options).typed(def);
446
- }
447
384
  // src/streams/consumer.ts
448
385
  async function defaultSleep(ms, signal) {
449
386
  if (signal?.aborted)
@@ -640,6 +577,7 @@ function createStreamsClient(options) {
640
577
  appendSearchParam2(searchParams, "from_height", params.fromHeight);
641
578
  appendSearchParam2(searchParams, "to_height", params.toHeight);
642
579
  appendSearchParam2(searchParams, "limit", params.limit);
580
+ appendSearchParam2(searchParams, "contract_id", params.contractId);
643
581
  if (params.types?.length) {
644
582
  searchParams.set("types", params.types.join(","));
645
583
  }
@@ -649,6 +587,9 @@ function createStreamsClient(options) {
649
587
  return {
650
588
  events: {
651
589
  list: listEvents,
590
+ byTxId(txId) {
591
+ return request(`/v1/streams/events/${encodeURIComponent(txId)}`);
592
+ },
652
593
  consume(params) {
653
594
  return consumeStreamsEvents({
654
595
  fromCursor: params.fromCursor,
@@ -676,11 +617,98 @@ function createStreamsClient(options) {
676
617
  });
677
618
  }
678
619
  },
620
+ blocks: {
621
+ events(heightOrHash) {
622
+ return request(`/v1/streams/blocks/${encodeURIComponent(String(heightOrHash))}/events`);
623
+ }
624
+ },
625
+ reorgs: {
626
+ list(params) {
627
+ const searchParams = new URLSearchParams;
628
+ appendSearchParam2(searchParams, "since", params.since);
629
+ appendSearchParam2(searchParams, "limit", params.limit);
630
+ const query = searchParams.toString();
631
+ return request(`/v1/streams/reorgs${query ? `?${query}` : ""}`);
632
+ }
633
+ },
634
+ canonical(height) {
635
+ return request(`/v1/streams/canonical/${height}`);
636
+ },
679
637
  tip() {
680
638
  return request("/v1/streams/tip");
681
639
  }
682
640
  };
683
641
  }
642
+
643
+ // src/subscriptions/client.ts
644
+ class Subscriptions extends BaseClient {
645
+ async list() {
646
+ return this.request("GET", "/api/subscriptions");
647
+ }
648
+ async get(id) {
649
+ return this.request("GET", `/api/subscriptions/${id}`);
650
+ }
651
+ async create(input) {
652
+ return this.request("POST", "/api/subscriptions", input);
653
+ }
654
+ async update(id, patch) {
655
+ return this.request("PATCH", `/api/subscriptions/${id}`, patch);
656
+ }
657
+ async pause(id) {
658
+ return this.request("POST", `/api/subscriptions/${id}/pause`);
659
+ }
660
+ async resume(id) {
661
+ return this.request("POST", `/api/subscriptions/${id}/resume`);
662
+ }
663
+ async delete(id) {
664
+ return this.request("DELETE", `/api/subscriptions/${id}`);
665
+ }
666
+ async rotateSecret(id) {
667
+ return this.request("POST", `/api/subscriptions/${id}/rotate-secret`);
668
+ }
669
+ async recentDeliveries(id) {
670
+ return this.request("GET", `/api/subscriptions/${id}/deliveries`);
671
+ }
672
+ async replay(id, range) {
673
+ return this.request("POST", `/api/subscriptions/${id}/replay`, range);
674
+ }
675
+ async dead(id) {
676
+ return this.request("GET", `/api/subscriptions/${id}/dead`);
677
+ }
678
+ async requeueDead(id, outboxId) {
679
+ return this.request("POST", `/api/subscriptions/${id}/dead/${outboxId}/requeue`);
680
+ }
681
+ }
682
+
683
+ // src/client.ts
684
+ class SecondLayer extends BaseClient {
685
+ streams;
686
+ index;
687
+ subgraphs;
688
+ subscriptions;
689
+ constructor(options = {}) {
690
+ super(options);
691
+ this.streams = createStreamsClient({
692
+ apiKey: options.apiKey ?? "",
693
+ baseUrl: options.baseUrl,
694
+ fetchImpl: options.fetchImpl
695
+ });
696
+ this.index = new Index(options);
697
+ this.subgraphs = new Subgraphs(options);
698
+ this.subscriptions = new Subscriptions(options);
699
+ }
700
+ }
701
+
702
+ // src/subgraphs/get-subgraph.ts
703
+ function getSubgraph(def, options = {}) {
704
+ if (options instanceof Subgraphs) {
705
+ return options.typed(def);
706
+ }
707
+ if (options instanceof SecondLayer) {
708
+ return options.subgraphs.typed(def);
709
+ }
710
+ return new Subgraphs(options).typed(def);
711
+ }
684
712
  // src/streams/ft-transfer.ts
685
713
  function requireString(payload, field) {
686
714
  const value = payload[field];
@@ -832,5 +860,5 @@ export {
832
860
  ApiError
833
861
  };
834
862
 
835
- //# debugId=2771C8998C150B3F64756E2164756E21
863
+ //# debugId=EEEF1F40FE614E8264756E2164756E21
836
864
  //# sourceMappingURL=index.js.map