@secondlayer/sdk 10.5.0 → 11.0.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
@@ -412,7 +412,9 @@ Exported types: `TransactionProof`, `TransactionProofVerifyResult`, `RewardSet`.
412
412
 
413
413
  Deploy and query app-specific tables.
414
414
 
415
- Subgraphs and webhooks live on the instance API alongside Streams and Index. Everything here except `rows` and the typed `subscribe` calls `/api`, which needs `INSTANCE_TOKEN` once one is configured (init always configures one), loopback included.
415
+ Subgraphs and webhooks live on the instance API alongside Streams and Index. Reads (`rows`, `count`, `aggregate`, typed `findMany`/`count`/`aggregate`, and `subscribe`) all hit the open `/v1` surface — keyless on loopback, `INSTANCE_TOKEN` once the API is bound beyond it. Everything else here (deploy, status, ops) calls `/api`, which needs `INSTANCE_TOKEN` once one is configured (init always configures one), loopback included.
416
+
417
+ `/v1` paginates by cursor, not offset: `rows`/`count`/`aggregate` take no `offset` param — pass the previous page's `next_cursor` back as `cursor` to resume.
416
418
 
417
419
  ```typescript
418
420
  // List
@@ -421,25 +423,18 @@ const { data } = await sl.subgraphs.list();
421
423
  // Get
422
424
  const subgraph = await sl.subgraphs.status("my-subgraph");
423
425
 
424
- // Open read (/v1): keyless on loopback; needs the token once the API is bound beyond it
426
+ // Untyped row read (/v1)
425
427
  const { rows, next_cursor, tip } = await sl.subgraphs.rows("my-subgraph", "transfers", {
428
+ sort: "block_height",
426
429
  order: "desc",
427
430
  limit: 50,
428
431
  // cursor: next_cursor — pass back to resume
429
432
  });
430
433
 
431
- // Authed control-plane query (/api)
432
- const page = await sl.subgraphs.queryTable("my-subgraph", "transfers", {
433
- sort: "block_height",
434
- order: "desc",
435
- limit: 50,
434
+ const { count } = await sl.subgraphs.count("my-subgraph", "transfers", {
435
+ filters: { status: "active" },
436
436
  });
437
437
 
438
- const { count } = await sl.subgraphs.queryTableCount(
439
- "my-subgraph",
440
- "transfers",
441
- );
442
-
443
438
  const spec = await sl.subgraphs.openapi("my-subgraph");
444
439
  const source = await sl.subgraphs.getSource("my-subgraph");
445
440
  const gaps = await sl.subgraphs.gaps("my-subgraph");
@@ -455,11 +450,22 @@ system column only when your table declares no column of that name; a declared
455
450
  `id` column is always your `id`.
456
451
 
457
452
  Stream rows live with the typed client — each table exposes `subscribe`
458
- alongside `findMany`/`count`:
453
+ alongside `findMany`/`count`/`aggregate`:
459
454
 
460
455
  ```typescript
461
456
  const subgraph = sl.subgraphs.typed(myDefinition); // { transfers, ... }
462
457
 
458
+ // findMany returns a page, not a bare array — `nextCursor` resumes it.
459
+ // `orderBy` sorts one column only (the /v1 keyset cursor pairs it with `_id`
460
+ // as a tiebreaker); a second key throws.
461
+ const page = await subgraph.transfers.findMany({
462
+ where: { amount: { gte: "1000000" } },
463
+ orderBy: { blockHeight: "desc" },
464
+ limit: 50,
465
+ // cursor: page.nextCursor — pass back to resume
466
+ });
467
+ // page.rows, page.nextCursor, page.tip
468
+
463
469
  const unsubscribe = subgraph.transfers.subscribe(
464
470
  (row) => console.log(row),
465
471
  {