@secondlayer/sdk 6.54.1 → 7.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.
@@ -1,16 +1,10 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["src/streams/_payload.ts", "src/streams/ft-transfer.ts", "src/streams/nft-transfer.ts", "src/clarity.ts", "src/streams/print.ts", "src/streams/stx-events.ts", "src/streams/token-mint-burn.ts"],
3
+ "sources": ["src/streams/rows.ts"],
4
4
  "sourcesContent": [
5
- "import type { StreamsEvent } from \"./types.ts\";\n\n/** Superset of the columns the decoded_events table holds. Every decoded\n * event's `decoded_payload` is assignable to this, so the indexer's writer\n * can map columns generically instead of per-event-type. */\nexport type DecodedEventColumns = {\n\tcontract_id?: string | null;\n\tasset_identifier?: string | null;\n\tsender?: string | null;\n\trecipient?: string | null;\n\tamount?: string | null;\n\tvalue?: string | null;\n\tmemo?: string | null;\n\t/** JSONB overflow for non-flat types (e.g. print's decoded value). */\n\tpayload?: unknown;\n};\n\nexport function requireString(\n\tpayload: Record<string, unknown>,\n\tfield: string,\n\teventType: string,\n): string {\n\tconst value = payload[field];\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new Error(`${eventType} payload missing ${field}`);\n\t}\n\treturn value;\n}\n\nexport function optionalString(value: unknown): string | null {\n\treturn typeof value === \"string\" && value.length > 0 ? value : null;\n}\n\nexport function requireAmountField(\n\tpayload: Record<string, unknown>,\n\tfield: string,\n\teventType: string,\n): string {\n\tconst amount = requireString(payload, field, eventType);\n\tif (!/^(0|[1-9]\\d*)$/.test(amount)) {\n\t\tthrow new Error(`${eventType} payload has malformed ${field}`);\n\t}\n\treturn amount;\n}\n\nexport function requireAmount(\n\tpayload: Record<string, unknown>,\n\teventType: string,\n): string {\n\treturn requireAmountField(payload, \"amount\", eventType);\n}\n\nexport function parseAssetIdentifier(\n\tassetIdentifier: string,\n\teventType: string,\n): { contract_id: string; token_name: string | null } {\n\tconst [contractId, tokenName] = assetIdentifier.split(\"::\");\n\tif (!contractId) {\n\t\tthrow new Error(`${eventType} payload has malformed asset_identifier`);\n\t}\n\treturn {\n\t\tcontract_id: contractId,\n\t\ttoken_name: tokenName && tokenName.length > 0 ? tokenName : null,\n\t};\n}\n\n/** NFT token id: live streams emits a typed Clarity value at `value` and the\n * canonical hex at `raw_value`; prefer raw_value when present. */\nexport function requireHexValue(\n\tpayload: Record<string, unknown>,\n\teventType: string,\n): string {\n\tconst rawValue = payload.raw_value;\n\tif (typeof rawValue === \"string\") {\n\t\tif (!/^0x[0-9a-fA-F]*$/.test(rawValue)) {\n\t\t\tthrow new Error(`${eventType} payload has malformed value`);\n\t\t}\n\t\treturn rawValue;\n\t}\n\n\tconst value = payload.value;\n\tconst hex =\n\t\ttypeof value === \"string\"\n\t\t\t? value\n\t\t\t: value &&\n\t\t\t\t\ttypeof value === \"object\" &&\n\t\t\t\t\ttypeof (value as { hex?: unknown }).hex === \"string\"\n\t\t\t\t? (value as { hex: string }).hex\n\t\t\t\t: null;\n\n\tif (!hex) {\n\t\tthrow new Error(`${eventType} payload missing value`);\n\t}\n\tif (!/^0x[0-9a-fA-F]*$/.test(hex)) {\n\t\tthrow new Error(`${eventType} payload has malformed value`);\n\t}\n\treturn hex;\n}\n\n/** Common envelope fields shared by every decoded event, lifted off the\n * source StreamsEvent. The decoder supplies event_type + decoded_payload. */\nexport function decodedRow<T extends string, P>(\n\tevent: StreamsEvent,\n\teventType: T,\n\tdecoded_payload: P,\n): {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: T;\n\tdecoded_payload: P;\n\tsource_cursor: string;\n} {\n\treturn {\n\t\tcursor: event.cursor,\n\t\tblock_height: event.block_height,\n\t\ttx_id: event.tx_id,\n\t\ttx_index: event.tx_index,\n\t\tevent_index: event.event_index,\n\t\tevent_type: eventType,\n\t\tdecoded_payload,\n\t\tsource_cursor: event.cursor,\n\t};\n}\n",
6
- "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireAmount,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./types.ts\";\n\nexport type { FtTransferPayload } from \"./types.ts\";\n\nexport type FtTransferEvent = Extract<\n\tStreamsEvent,\n\t{ event_type: \"ft_transfer\" }\n>;\n\nexport type DecodedFtTransferPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedFtTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_transfer\";\n\tdecoded_payload: DecodedFtTransferPayload;\n\tsource_cursor: string;\n};\n\nexport function isFtTransfer(event: StreamsEvent): event is FtTransferEvent {\n\treturn event.event_type === \"ft_transfer\";\n}\n\nexport function decodeFtTransfer(event: StreamsEvent): DecodedFtTransfer {\n\tif (!isFtTransfer(event)) {\n\t\tthrow new Error(`Expected ft_transfer event, got ${event.event_type}`);\n\t}\n\n\tconst payload = event.payload;\n\tconst assetIdentifier = requireString(\n\t\tpayload,\n\t\t\"asset_identifier\",\n\t\t\"ft_transfer\",\n\t);\n\tconst sender = requireString(payload, \"sender\", \"ft_transfer\");\n\tconst recipient = requireString(payload, \"recipient\", \"ft_transfer\");\n\tconst amount = requireAmount(payload, \"ft_transfer\");\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\t\"ft_transfer\",\n\t);\n\n\treturn decodedRow(event, \"ft_transfer\", {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t\tsender,\n\t\trecipient,\n\t\tamount,\n\t});\n}\n",
7
- "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireHexValue,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./types.ts\";\n\nexport type { NftTransferPayload } from \"./types.ts\";\n\nexport type NftTransferEvent = Extract<\n\tStreamsEvent,\n\t{ event_type: \"nft_transfer\" }\n>;\n\nexport type DecodedNftTransferPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type DecodedNftTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_transfer\";\n\tdecoded_payload: DecodedNftTransferPayload;\n\tsource_cursor: string;\n};\n\nexport function isNftTransfer(event: StreamsEvent): event is NftTransferEvent {\n\treturn event.event_type === \"nft_transfer\";\n}\n\nexport function decodeNftTransfer(event: StreamsEvent): DecodedNftTransfer {\n\tif (!isNftTransfer(event)) {\n\t\tthrow new Error(`Expected nft_transfer event, got ${event.event_type}`);\n\t}\n\n\tconst payload = event.payload;\n\tconst assetIdentifier = requireString(\n\t\tpayload,\n\t\t\"asset_identifier\",\n\t\t\"nft_transfer\",\n\t);\n\tconst sender = requireString(payload, \"sender\", \"nft_transfer\");\n\tconst recipient = requireString(payload, \"recipient\", \"nft_transfer\");\n\tconst value = requireHexValue(payload, \"nft_transfer\");\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\t\"nft_transfer\",\n\t);\n\n\treturn decodedRow(event, \"nft_transfer\", {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t\tsender,\n\t\trecipient,\n\t\tvalue,\n\t});\n}\n",
8
- "import { cvToValue, deserializeCV } from \"@secondlayer/stacks/clarity\";\n\n/** Make a cvToValue result JSON-serializable: Clarity (u)ints decode to bigint,\n * which JSON.stringify can't handle — convert recursively to strings. */\nexport function toJsonSafe(value: unknown): unknown {\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (Array.isArray(value)) return value.map(toJsonSafe);\n\tif (value && typeof value === \"object\") {\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const [key, val] of Object.entries(value)) {\n\t\t\tout[key] = toJsonSafe(val);\n\t\t}\n\t\treturn out;\n\t}\n\treturn value;\n}\n\n/** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,\n * buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */\nexport function decodeClarityValue(hex: string): unknown {\n\ttry {\n\t\tconst clean = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n\t\treturn toJsonSafe(cvToValue(deserializeCV(clean)));\n\t} catch {\n\t\treturn hex;\n\t}\n}\n",
9
- "import { decodeClarityValue, toJsonSafe } from \"../clarity.ts\";\nimport { decodedRow, optionalString } from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./types.ts\";\n\n/** Decoded form of a Clarity `print` event:\n * - `topic`: the print topic, when the contract emits a `{ topic, ... }` tuple\n * - `value`: the Clarity value decoded to JSON (uints as strings, buffers as\n * `0x…` hex, tuples as objects)\n * - `raw_value`: the canonical serialized hex, for byte-exact consumers */\nexport type DecodedPrintValue = {\n\ttopic: string | null;\n\tvalue: unknown;\n\traw_value: string | null;\n};\n\nexport type DecodedPrintPayload = {\n\tcontract_id: string | null;\n\tpayload: DecodedPrintValue;\n};\n\nexport type DecodedPrint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"print\";\n\tdecoded_payload: DecodedPrintPayload;\n\tsource_cursor: string;\n};\n\nfunction printValueHex(payload: Record<string, unknown>): string | null {\n\tif (typeof payload.raw_value === \"string\") return payload.raw_value;\n\tconst value = payload.value;\n\tif (typeof value === \"string\" && value.startsWith(\"0x\")) return value;\n\tif (\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\ttypeof (value as { hex?: unknown }).hex === \"string\"\n\t) {\n\t\treturn (value as { hex: string }).hex;\n\t}\n\treturn null;\n}\n\nexport function isPrint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"print\" } {\n\treturn event.event_type === \"print\";\n}\n\nexport function decodePrint(event: StreamsEvent): DecodedPrint {\n\tif (!isPrint(event)) {\n\t\tthrow new Error(`Expected print event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\tconst topic = optionalString(payload.topic);\n\tconst rawValue = printValueHex(payload);\n\n\tconst value = rawValue\n\t\t? decodeClarityValue(rawValue)\n\t\t: toJsonSafe(payload.value ?? null);\n\n\treturn decodedRow(event, \"print\", {\n\t\tcontract_id: event.contract_id ?? optionalString(payload.contract_id),\n\t\tpayload: { topic, value, raw_value: rawValue },\n\t});\n}\n",
10
- "import {\n\tdecodedRow,\n\toptionalString,\n\trequireAmount,\n\trequireAmountField,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./types.ts\";\n\nexport type DecodedStxTransferPayload = {\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n\tmemo: string | null;\n};\n\nexport type DecodedStxTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_transfer\";\n\tdecoded_payload: DecodedStxTransferPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedStxMintPayload = {\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedStxMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_mint\";\n\tdecoded_payload: DecodedStxMintPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedStxBurnPayload = {\n\tsender: string;\n\tamount: string;\n};\n\nexport type DecodedStxBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_burn\";\n\tdecoded_payload: DecodedStxBurnPayload;\n\tsource_cursor: string;\n};\n\nexport function isStxTransfer(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_transfer\" } {\n\treturn event.event_type === \"stx_transfer\";\n}\n\nexport function decodeStxTransfer(event: StreamsEvent): DecodedStxTransfer {\n\tif (!isStxTransfer(event)) {\n\t\tthrow new Error(`Expected stx_transfer event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_transfer\", {\n\t\tsender: requireString(payload, \"sender\", \"stx_transfer\"),\n\t\trecipient: requireString(payload, \"recipient\", \"stx_transfer\"),\n\t\tamount: requireAmount(payload, \"stx_transfer\"),\n\t\tmemo: optionalString(payload.memo),\n\t});\n}\n\nexport function isStxMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_mint\" } {\n\treturn event.event_type === \"stx_mint\";\n}\n\nexport function decodeStxMint(event: StreamsEvent): DecodedStxMint {\n\tif (!isStxMint(event)) {\n\t\tthrow new Error(`Expected stx_mint event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_mint\", {\n\t\trecipient: requireString(payload, \"recipient\", \"stx_mint\"),\n\t\tamount: requireAmount(payload, \"stx_mint\"),\n\t});\n}\n\nexport function isStxBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_burn\" } {\n\treturn event.event_type === \"stx_burn\";\n}\n\nexport function decodeStxBurn(event: StreamsEvent): DecodedStxBurn {\n\tif (!isStxBurn(event)) {\n\t\tthrow new Error(`Expected stx_burn event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_burn\", {\n\t\tsender: requireString(payload, \"sender\", \"stx_burn\"),\n\t\tamount: requireAmount(payload, \"stx_burn\"),\n\t});\n}\n\nexport type DecodedStxLockPayload = {\n\t// The locked principal maps to `sender` and the locked uSTX to `amount` so\n\t// stx_lock is filterable like the other STX types; the lock-specific\n\t// unlock_height rides in the jsonb `payload` overflow.\n\tsender: string;\n\tamount: string;\n\tpayload: { unlock_height: string | null };\n};\n\nexport type DecodedStxLock = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_lock\";\n\tdecoded_payload: DecodedStxLockPayload;\n\tsource_cursor: string;\n};\n\nexport function isStxLock(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_lock\" } {\n\treturn event.event_type === \"stx_lock\";\n}\n\nexport function decodeStxLock(event: StreamsEvent): DecodedStxLock {\n\tif (!isStxLock(event)) {\n\t\tthrow new Error(`Expected stx_lock event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_lock\", {\n\t\tsender: requireString(payload, \"locked_address\", \"stx_lock\"),\n\t\tamount: requireAmountField(payload, \"locked_amount\", \"stx_lock\"),\n\t\tpayload: { unlock_height: optionalString(payload.unlock_height) },\n\t});\n}\n",
11
- "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireAmount,\n\trequireHexValue,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./types.ts\";\n\nexport type DecodedFtMintPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedFtMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_mint\";\n\tdecoded_payload: DecodedFtMintPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedFtBurnPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\tamount: string;\n};\n\nexport type DecodedFtBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_burn\";\n\tdecoded_payload: DecodedFtBurnPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedNftMintPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type DecodedNftMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_mint\";\n\tdecoded_payload: DecodedNftMintPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedNftBurnPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\tvalue: string;\n};\n\nexport type DecodedNftBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_burn\";\n\tdecoded_payload: DecodedNftBurnPayload;\n\tsource_cursor: string;\n};\n\nfunction assetFields(event: StreamsEvent, eventType: string) {\n\tconst assetIdentifier = requireString(\n\t\tevent.payload,\n\t\t\"asset_identifier\",\n\t\teventType,\n\t);\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\teventType,\n\t);\n\treturn {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t};\n}\n\nexport function isFtMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"ft_mint\" } {\n\treturn event.event_type === \"ft_mint\";\n}\n\nexport function decodeFtMint(event: StreamsEvent): DecodedFtMint {\n\tif (!isFtMint(event)) {\n\t\tthrow new Error(`Expected ft_mint event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"ft_mint\", {\n\t\t...assetFields(event, \"ft_mint\"),\n\t\trecipient: requireString(event.payload, \"recipient\", \"ft_mint\"),\n\t\tamount: requireAmount(event.payload, \"ft_mint\"),\n\t});\n}\n\nexport function isFtBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"ft_burn\" } {\n\treturn event.event_type === \"ft_burn\";\n}\n\nexport function decodeFtBurn(event: StreamsEvent): DecodedFtBurn {\n\tif (!isFtBurn(event)) {\n\t\tthrow new Error(`Expected ft_burn event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"ft_burn\", {\n\t\t...assetFields(event, \"ft_burn\"),\n\t\tsender: requireString(event.payload, \"sender\", \"ft_burn\"),\n\t\tamount: requireAmount(event.payload, \"ft_burn\"),\n\t});\n}\n\nexport function isNftMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"nft_mint\" } {\n\treturn event.event_type === \"nft_mint\";\n}\n\nexport function decodeNftMint(event: StreamsEvent): DecodedNftMint {\n\tif (!isNftMint(event)) {\n\t\tthrow new Error(`Expected nft_mint event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"nft_mint\", {\n\t\t...assetFields(event, \"nft_mint\"),\n\t\trecipient: requireString(event.payload, \"recipient\", \"nft_mint\"),\n\t\tvalue: requireHexValue(event.payload, \"nft_mint\"),\n\t});\n}\n\nexport function isNftBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"nft_burn\" } {\n\treturn event.event_type === \"nft_burn\";\n}\n\nexport function decodeNftBurn(event: StreamsEvent): DecodedNftBurn {\n\tif (!isNftBurn(event)) {\n\t\tthrow new Error(`Expected nft_burn event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"nft_burn\", {\n\t\t...assetFields(event, \"nft_burn\"),\n\t\tsender: requireString(event.payload, \"sender\", \"nft_burn\"),\n\t\tvalue: requireHexValue(event.payload, \"nft_burn\"),\n\t});\n}\n"
5
+ "/**\n * `@secondlayer/sdk/streams/rows` — the per-type guard + decode pairs that\n * produce **database row** shapes (`decoded_payload` nested, `source_cursor`\n * carried), as opposed to the flat API rows `decode()` returns.\n *\n * These are a lower-level API and the subpath says so: you have to reach for\n * it. Reach for it when you are building a `decoded_events`-shaped projection\n * and need the storage shape — which is what our own decoder does.\n *\n * If you are writing a consumer, you almost certainly want the root instead:\n * `decode(event)` for one call returning the same flat, `event_type`-\n * discriminated row Index serves, or `decoded: true` on\n * `streams.events.consume` so decoding never appears in your handler at all.\n *\n * The primitives themselves live in `@secondlayer/shared/streams-rows`\n * (canonical home, shared with the indexer); this subpath re-exports them\n * unchanged.\n */\nexport {\n\tdecodeFtTransfer,\n\tisFtTransfer,\n\tdecodeNftTransfer,\n\tisNftTransfer,\n\tdecodePrint,\n\tisPrint,\n\tdecodeStxBurn,\n\tdecodeStxLock,\n\tdecodeStxMint,\n\tdecodeStxTransfer,\n\tisStxBurn,\n\tisStxLock,\n\tisStxMint,\n\tisStxTransfer,\n\tdecodeFtBurn,\n\tdecodeFtMint,\n\tdecodeNftBurn,\n\tdecodeNftMint,\n\tisFtBurn,\n\tisFtMint,\n\tisNftBurn,\n\tisNftMint,\n} from \"@secondlayer/shared/streams-rows\";\n\nexport type {\n\tDecodedEventColumns,\n\tDecodedEventRow,\n\tDecodedFtBurn,\n\tDecodedFtMint,\n\tDecodedFtTransfer,\n\tDecodedFtTransferPayload,\n\tDecodedNftBurn,\n\tDecodedNftMint,\n\tDecodedNftTransfer,\n\tDecodedNftTransferPayload,\n\tDecodedPrint,\n\tDecodedPrintPayload,\n\tDecodedStxBurn,\n\tDecodedStxLock,\n\tDecodedStxMint,\n\tDecodedStxTransfer,\n} from \"@secondlayer/shared/streams-rows\";\n"
12
6
  ],
13
- "mappings": ";AAiBO,SAAS,aAAa,CAC5B,SACA,OACA,WACS;AAAA,EACT,MAAM,QAAQ,QAAQ;AAAA,EACtB,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG;AAAA,IACpD,MAAM,IAAI,MAAM,GAAG,6BAA6B,OAAO;AAAA,EACxD;AAAA,EACA,OAAO;AAAA;AAGD,SAAS,cAAc,CAAC,OAA+B;AAAA,EAC7D,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AAAA;AAGzD,SAAS,kBAAkB,CACjC,SACA,OACA,WACS;AAAA,EACT,MAAM,SAAS,cAAc,SAAS,OAAO,SAAS;AAAA,EACtD,IAAI,CAAC,iBAAiB,KAAK,MAAM,GAAG;AAAA,IACnC,MAAM,IAAI,MAAM,GAAG,mCAAmC,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AM,SAAS,UAAU,UAAU;AAAA,IACzD,OAAO,gBAAgB,MAAM,SAAS,UAAU;AAAA,EACjD,CAAC;AAAA;",
14
- "debugId": "1297EE104E5B35B464756E2164756E21",
7
+ "mappings": ";AAkBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
8
+ "debugId": "06C07B68A4D02ABE64756E2164756E21",
15
9
  "names": []
16
10
  }
@@ -111,21 +111,6 @@ declare class Subgraphs extends BaseClient {
111
111
  message: string;
112
112
  }>;
113
113
  /**
114
- * Publish: claim the name in the global public namespace and open anon
115
- * reads on /v1/subgraphs/:name. 409 PUBLIC_NAME_TAKEN if another account
116
- * holds the public name.
117
- */
118
- publish(name: string): Promise<{
119
- name: string;
120
- visibility: "public";
121
- url: string;
122
- }>;
123
- /** Make reads private again (owning account's bearer key required). */
124
- unpublish(name: string): Promise<{
125
- name: string;
126
- visibility: "private";
127
- }>;
128
- /**
129
114
  * Open /v1 read: cursor-paginated rows. Anon works for public subgraphs;
130
115
  * pass an apiKey on the client for private ones. Resume with the returned
131
116
  * `next_cursor`.
@@ -175,63 +160,6 @@ declare class Subgraphs extends BaseClient {
175
160
  import { InferSubgraphClient as InferSubgraphClient2 } from "@secondlayer/subgraphs";
176
161
  import { SubgraphSummary as SubgraphSummary2 } from "@secondlayer/shared/schemas";
177
162
  /**
178
- * Typed client for the agent-reachable key mint (`POST /v1/api-keys`).
179
- *
180
- * Lets a headless agent self-provision a SCOPED `streams`/`index` read key
181
- * without the dashboard. Requires an owner credential — an account-level API
182
- * key (or a dashboard session). The minted key is always scoped (never an
183
- * account/superkey) and inherits the account plan's tier.
184
- */
185
- /** Scope of a minted read key. */
186
- type ScopedKeyProduct = "streams" | "index";
187
- interface CreateApiKeyParams {
188
- /** Scope of the minted key. Defaults to "streams". */
189
- product?: ScopedKeyProduct;
190
- /** Optional human-readable label for the key. */
191
- name?: string;
192
- }
193
- interface CreateApiKeyResponse {
194
- /** Plaintext key — returned ONCE. Store it now; only its hash is persisted. */
195
- key: string;
196
- prefix: string;
197
- id: string;
198
- product: string;
199
- tier: string | null;
200
- createdAt: string;
201
- }
202
- /** A key as seen by {@link ApiKeys.list} — metadata only, never the plaintext. */
203
- interface ApiKeySummary {
204
- id: string;
205
- prefix: string;
206
- name: string | null;
207
- status: "active" | "revoked";
208
- product: string;
209
- tier: string | null;
210
- createdAt: string;
211
- lastUsedAt: string | null;
212
- }
213
- declare class ApiKeys extends BaseClient {
214
- constructor(options?: Partial<SecondLayerOptions>);
215
- /**
216
- * Mint a new scoped read key. The configured `apiKey` must be an
217
- * account-level (owner) key; the plaintext `key` in the response is shown
218
- * only once.
219
- */
220
- create(params?: CreateApiKeyParams): Promise<CreateApiKeyResponse>;
221
- /**
222
- * List the account's keys (metadata only — no plaintext). Requires an
223
- * account-level (owner) key or a dashboard session.
224
- */
225
- list(): Promise<{
226
- keys: ApiKeySummary[];
227
- }>;
228
- /** Revoke a key by id. Existing requests with that key stop working. */
229
- revoke(id: string): Promise<{
230
- revoked: true;
231
- id: string;
232
- }>;
233
- }
234
- /**
235
163
  * Typed client for the contract-discovery API (`GET /v1/contracts`).
236
164
  *
237
165
  * "Find all contracts conforming to a trait" — backed by the contract registry:
@@ -443,111 +371,7 @@ interface ConsumerSink<Tx = unknown> {
443
371
  type WithSinkTx<TTx> = [TTx] extends [never] ? unknown : {
444
372
  tx: TTx;
445
373
  };
446
- import { StreamsEventType } from "@secondlayer/shared";
447
- /** A Clarity value as Streams serves it: the canonical hex string, a typed
448
- * object carrying that hex (`{ hex }`), or a decoded Clarity-JSON object.
449
- * Decode helpers (`decodeNftTransfer`, etc.) resolve it to a concrete value. */
450
- type StreamsClarityValue = string | {
451
- hex: string;
452
- } | Record<string, unknown>;
453
- type StxTransferPayload = {
454
- sender: string;
455
- recipient: string;
456
- amount: string;
457
- memo?: string;
458
- };
459
- type StxMintPayload = {
460
- recipient: string;
461
- amount: string;
462
- };
463
- type StxBurnPayload = {
464
- sender: string;
465
- amount: string;
466
- };
467
- type StxLockPayload = {
468
- locked_address: string;
469
- locked_amount: string;
470
- unlock_height: string;
471
- };
472
- type FtTransferPayload = {
473
- asset_identifier: string;
474
- sender: string;
475
- recipient: string;
476
- amount: string;
477
- };
478
- type FtMintPayload = {
479
- asset_identifier: string;
480
- recipient: string;
481
- amount: string;
482
- };
483
- type FtBurnPayload = {
484
- asset_identifier: string;
485
- sender: string;
486
- amount: string;
487
- };
488
- type NftTransferPayload = {
489
- asset_identifier: string;
490
- sender: string;
491
- recipient: string;
492
- value: StreamsClarityValue;
493
- /** Canonical serialized hex of `value`, when the stream carries it. */
494
- raw_value?: string;
495
- };
496
- type NftMintPayload = {
497
- asset_identifier: string;
498
- recipient: string;
499
- value: StreamsClarityValue;
500
- raw_value?: string;
501
- };
502
- type NftBurnPayload = {
503
- asset_identifier: string;
504
- sender: string;
505
- value: StreamsClarityValue;
506
- raw_value?: string;
507
- };
508
- type PrintPayload = {
509
- contract_id?: string | null;
510
- topic?: string;
511
- value?: unknown;
512
- raw_value?: string;
513
- };
514
- type StreamsEventBase = {
515
- /**
516
- * Globally unique, monotonic position of this event (`<block>:<index>`). Use
517
- * it as the primary key of your projection rows — replaying a batch then
518
- * upserts cleanly. Don't synthesize your own id from `tx_id`/`event_index`.
519
- */
520
- cursor: string;
521
- block_height: number;
522
- block_hash: string;
523
- burn_block_height: number;
524
- tx_id: string;
525
- tx_index: number;
526
- event_index: number;
527
- contract_id: string | null;
528
- ts: string;
529
- /**
530
- * True when this event's block is past the finality boundary (immutable).
531
- * Optional for back-compat; the API always sets it on Streams responses.
532
- */
533
- finalized?: boolean;
534
- /**
535
- * Labels whose filter group this event satisfied, present only when the
536
- * request used a labelled `filters` map. The SDK dispatches on it for you
537
- * (`on.<label>`), so handlers rarely read it directly.
538
- */
539
- matched?: string[];
540
- };
541
- type StreamsEventOf<
542
- T extends StreamsEventType,
543
- P
544
- > = StreamsEventBase & {
545
- event_type: T;
546
- payload: P;
547
- };
548
- /** A raw Streams event. Discriminated on `event_type`, so `event.payload`
549
- * narrows to the matching payload shape once the type is checked. */
550
- type StreamsEvent = StreamsEventOf<"stx_transfer", StxTransferPayload> | StreamsEventOf<"stx_mint", StxMintPayload> | StreamsEventOf<"stx_burn", StxBurnPayload> | StreamsEventOf<"stx_lock", StxLockPayload> | StreamsEventOf<"ft_transfer", FtTransferPayload> | StreamsEventOf<"ft_mint", FtMintPayload> | StreamsEventOf<"ft_burn", FtBurnPayload> | StreamsEventOf<"nft_transfer", NftTransferPayload> | StreamsEventOf<"nft_mint", NftMintPayload> | StreamsEventOf<"nft_burn", NftBurnPayload> | StreamsEventOf<"print", PrintPayload>;
374
+ import { StreamsEvent, StreamsEventType } from "@secondlayer/shared/streams-rows";
551
375
  type StreamsTip = {
552
376
  block_height: number;
553
377
  block_hash: string;
@@ -1043,20 +867,6 @@ type StreamsClient = {
1043
867
  dumps: StreamsDumps;
1044
868
  canonical(height: number): Promise<StreamsCanonicalBlock>;
1045
869
  tip(): Promise<StreamsTip>;
1046
- /** Your own Streams consumption (events today + this month) and tier limits. */
1047
- usage(): Promise<StreamsUsage>;
1048
- };
1049
- type StreamsUsage = {
1050
- product: "streams";
1051
- tier: string;
1052
- limits: {
1053
- rate_limit_per_second: number | null;
1054
- retention_days: number | null;
1055
- };
1056
- usage: {
1057
- events_today: number;
1058
- events_this_month: number;
1059
- };
1060
870
  };
1061
871
  type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;
1062
872
  /** Options shared by both consume loops' page-fetch retry. Vocabulary matches
@@ -1179,17 +989,6 @@ type IndexReorg = {
1179
989
  */
1180
990
  new_canonical_tip: string;
1181
991
  };
1182
- type IndexUsage = {
1183
- product: "index";
1184
- tier: string;
1185
- limits: {
1186
- rate_limit_per_second: number | null;
1187
- };
1188
- usage: {
1189
- decoded_events_today: number;
1190
- decoded_events_this_month: number;
1191
- };
1192
- };
1193
992
  type FtTransfer = {
1194
993
  cursor: string;
1195
994
  block_height: number;
@@ -2284,8 +2083,6 @@ type IndexDiscovery = {
2284
2083
  };
2285
2084
  declare class Index extends BaseClient {
2286
2085
  constructor(options?: Partial<SecondLayerOptions>);
2287
- /** Your own Index consumption (decoded events today + this month) and tier limits. */
2288
- usage(): Promise<IndexUsage>;
2289
2086
  /**
2290
2087
  * Index discovery doc — the live vocabulary: every endpoint, each event type's
2291
2088
  * columns, allowed/equality filters, and required-non-null fields. Read this to
@@ -2414,76 +2211,6 @@ declare class Index extends BaseClient {
2414
2211
  private walkPoxCycles;
2415
2212
  private getPoxCycle;
2416
2213
  }
2417
- /**
2418
- * Typed client for project management (`/api/projects/*`).
2419
- *
2420
- * Projects are the account-scoped containers for work. Every method requires an
2421
- * account-level (owner) API key or a dashboard session — scoped read keys are
2422
- * rejected. Team mutations (invite/remove/role) are intentionally not exposed
2423
- * here; only the read view ({@link Projects.team}) is.
2424
- */
2425
- interface Project {
2426
- id: string;
2427
- name: string;
2428
- slug: string;
2429
- network: string;
2430
- nodeRpc: string | null;
2431
- settings: Record<string, unknown> | null;
2432
- createdAt: string;
2433
- updatedAt: string;
2434
- }
2435
- interface ProjectTeamMember {
2436
- id: string;
2437
- role: string;
2438
- email: string;
2439
- displayName: string | null;
2440
- avatarUrl: string | null;
2441
- createdAt: string;
2442
- }
2443
- interface ProjectInvitation {
2444
- id: string;
2445
- email: string;
2446
- role: string;
2447
- expiresAt: string;
2448
- createdAt: string;
2449
- }
2450
- interface ProjectTeam {
2451
- members: ProjectTeamMember[];
2452
- invitations: ProjectInvitation[];
2453
- }
2454
- interface CreateProjectParams {
2455
- name: string;
2456
- slug?: string;
2457
- network?: string;
2458
- nodeRpc?: string;
2459
- }
2460
- interface UpdateProjectParams {
2461
- name?: string;
2462
- /** Rename the project's URL slug. */
2463
- slug?: string;
2464
- network?: string;
2465
- nodeRpc?: string;
2466
- settings?: Record<string, unknown>;
2467
- }
2468
- declare class Projects extends BaseClient {
2469
- constructor(options?: Partial<SecondLayerOptions>);
2470
- /** All projects owned by the account, newest-relevant first. */
2471
- list(): Promise<{
2472
- projects: Project[];
2473
- }>;
2474
- /** A single project by slug. */
2475
- get(slug: string): Promise<Project>;
2476
- /** Create a project. The creator is added as the project owner. */
2477
- create(params: CreateProjectParams): Promise<Project>;
2478
- /** Update a project's name, slug (rename), network, RPC, or settings. */
2479
- update(slug: string, patch: UpdateProjectParams): Promise<Project>;
2480
- /** Delete a project. The account's last remaining project cannot be deleted. */
2481
- delete(slug: string): Promise<{
2482
- ok: true;
2483
- }>;
2484
- /** Team members and pending invitations for a project. */
2485
- team(slug: string): Promise<ProjectTeam>;
2486
- }
2487
2214
  import { CreateSubscriptionRequest, CreateSubscriptionResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, SubscriptionDetail, SubscriptionSummary, SubscriptionTestResult, UpdateSubscriptionRequest } from "@secondlayer/shared/schemas/subscriptions";
2488
2215
  declare class Subscriptions extends BaseClient {
2489
2216
  list(): Promise<{
@@ -2518,20 +2245,6 @@ declare class Subscriptions extends BaseClient {
2518
2245
  }
2519
2246
  interface ContextAccount {
2520
2247
  email: string;
2521
- plan: string;
2522
- }
2523
- /** Compact project view for {@link ContextSnapshot}. */
2524
- interface ContextProject {
2525
- name: string;
2526
- slug: string;
2527
- network: string;
2528
- }
2529
- /** Compact API-key view for {@link ContextSnapshot} — never the plaintext. */
2530
- interface ContextApiKey {
2531
- prefix: string;
2532
- name: string | null;
2533
- status: string;
2534
- product: string;
2535
2248
  }
2536
2249
  interface ActiveSubgraphOperation {
2537
2250
  subgraph: string;
@@ -2554,10 +2267,6 @@ interface ContextSnapshot {
2554
2267
  count: number;
2555
2268
  byStatus: Record<string, number>;
2556
2269
  } | null;
2557
- /** The account's projects (null when unreadable — e.g. a scoped key). */
2558
- projects: ContextProject[] | null;
2559
- /** The account's API keys, metadata only (null when unreadable). */
2560
- apiKeys: ContextApiKey[] | null;
2561
2270
  /** In-flight reindex operations (bounded to subgraphs reporting `reindexing`). */
2562
2271
  activeOperations: ActiveSubgraphOperation[] | null;
2563
2272
  }
@@ -2567,8 +2276,6 @@ declare class SecondLayer extends BaseClient {
2567
2276
  readonly contracts: Contracts;
2568
2277
  readonly subgraphs: Subgraphs;
2569
2278
  readonly subscriptions: Subscriptions;
2570
- readonly apiKeys: ApiKeys;
2571
- readonly projects: Projects;
2572
2279
  constructor(options?: Partial<SecondLayerOptions>);
2573
2280
  /**
2574
2281
  * Assemble a {@link ContextSnapshot} — the same orientation an MCP agent reads