@secondlayer/sdk 6.22.0 → 6.23.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 +15 -9
- package/dist/index.d.ts +1068 -978
- package/dist/index.js +308 -218
- package/dist/index.js.map +7 -6
- package/dist/subgraphs/index.d.ts +1038 -977
- package/dist/subgraphs/index.js +307 -218
- package/dist/subgraphs/index.js.map +7 -6
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/errors.ts", "../src/base.ts", "../src/subgraphs/serialize.ts", "../src/subgraphs/client.ts", "../src/api-keys/client.ts", "../src/contracts/client.ts", "../src/
|
|
3
|
+
"sources": ["../src/errors.ts", "../src/base.ts", "../src/subgraphs/serialize.ts", "../src/subgraphs/client.ts", "../src/api-keys/client.ts", "../src/contracts/client.ts", "../src/streams/errors.ts", "../src/streams/cursor.ts", "../src/streams/consumer.ts", "../src/index-api/consumer.ts", "../src/index-api/client.ts", "../src/projects/client.ts", "../src/streams/client.ts", "../src/streams/dumps.ts", "../src/streams/subscribe.ts", "../src/subscriptions/client.ts", "../src/client.ts", "../src/subgraphs/get-subgraph.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { ByoBreakingChangeDetails } from \"@secondlayer/shared/errors\";\n\nexport type { ByoBreakingChangeDetails };\n\n/**\n * Error thrown by {@link SecondLayer} when an API request fails.\n * Includes the HTTP status code for programmatic error handling.\n *\n * @example\n * ```ts\n * try {\n * await client.subgraphs.get(\"my-subgraph\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Subgraph not found\");\n * }\n * }\n * ```\n */\nexport class ApiError extends Error {\n\tconstructor(\n\t\t/** HTTP status code (0 for network errors). */\n\t\tpublic status: number,\n\t\tmessage: string,\n\t\t/** Raw response body (parsed JSON if possible) — preserved for callers that need error details. */\n\t\tpublic body?: unknown,\n\t\t/** Stable machine-readable code from the API's `{error, code}` error envelope. */\n\t\tpublic code?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n\n/**\n * Thrown on optimistic-concurrency conflict when a deploy supplies an\n * `expectedVersion` that no longer matches the server's stored version.\n */\nexport class VersionConflictError extends ApiError {\n\tconstructor(\n\t\tpublic currentVersion: string,\n\t\tpublic expectedVersion: string,\n\t\tmessage = `Version conflict: expected ${expectedVersion}, current ${currentVersion}`,\n\t) {\n\t\tsuper(409, message, { currentVersion, expectedVersion });\n\t\tthis.name = \"VersionConflictError\";\n\t}\n}\n\n/**\n * Thrown when a BYO subgraph deploy is refused for a breaking schema change.\n * The deploy did NOT run — `details.plan` carries the DROP + rebuild DDL to run\n * manually on your own database, plus the breaking `reasons` and the `diff`.\n *\n * @example\n * ```ts\n * try {\n * await client.subgraphs.deploy(bundle);\n * } catch (err) {\n * if (err instanceof ByoBreakingChangeError) {\n * console.log(err.details.plan.dropStatement);\n * console.log(err.details.plan.statements.join(\";\\n\"));\n * }\n * }\n * ```\n */\nexport class ByoBreakingChangeError extends ApiError {\n\treadonly details: ByoBreakingChangeDetails;\n\tconstructor(message: string, details: ByoBreakingChangeDetails) {\n\t\tsuper(422, message, details, \"BYO_BREAKING_CHANGE\");\n\t\tthis.name = \"ByoBreakingChangeError\";\n\t\tthis.details = details;\n\t}\n}\n\n/** Narrow an unknown error body's `details` to {@link ByoBreakingChangeDetails}. */\nexport function isByoBreakingDetails(\n\tx: unknown,\n): x is ByoBreakingChangeDetails {\n\tif (!x || typeof x !== \"object\") return false;\n\tconst d = x as Record<string, unknown>;\n\tconst plan = d.plan as Record<string, unknown> | undefined;\n\treturn (\n\t\tArray.isArray(d.reasons) &&\n\t\t!!plan &&\n\t\ttypeof plan === \"object\" &&\n\t\ttypeof plan.dropStatement === \"string\"\n\t);\n}\n",
|
|
6
6
|
"import {\n\tApiError,\n\ttype ByoBreakingChangeDetails,\n\tByoBreakingChangeError,\n\tisByoBreakingDetails,\n} from \"./errors.ts\";\n\nexport type FetchLike = (\n\tinput: string | URL | Request,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nexport interface SecondLayerOptions {\n\t/** Base URL of the Secondlayer platform API (trailing slashes are stripped). */\n\tbaseUrl: string;\n\t/** Bearer token for authenticated requests. */\n\tapiKey?: string;\n\t/** Fetch implementation. Tests and edge runtimes can provide their own. */\n\tfetchImpl?: FetchLike;\n\t/** Public base URL for Streams bulk parquet dumps (the cold backfill plane).\n\t * Required for `streams.dumps.*`; without it the dumps client falls back to\n\t * its built-in default. */\n\tdumpsBaseUrl?: string;\n\t/** Deploy origin label sent as `x-sl-origin` (telemetry). Defaults to `cli`. */\n\torigin?: \"cli\" | \"mcp\" | \"session\";\n}\n\nconst DEFAULT_BASE_URL = \"https://api.secondlayer.tools\";\n\n/** Build a query-string suffix from name→value pairs. Skips null/undefined and\n * empty values; arrays are comma-joined. Returns \"\" (never a dangling \"?\") or\n * \"?a=1&b=2\" — the one canonical builder every list endpoint shares, so the\n * empty-query guard can't be forgotten per call site. */\nexport function buildQuery(\n\tparams: Record<\n\t\tstring,\n\t\tnumber | string | readonly string[] | null | undefined\n\t>,\n): string {\n\tconst search = new URLSearchParams();\n\tfor (const [name, value] of Object.entries(params)) {\n\t\tif (value === undefined || value === null) continue;\n\t\tconst serialized = Array.isArray(value) ? value.join(\",\") : String(value);\n\t\tif (serialized.length === 0) continue;\n\t\tsearch.set(name, serialized);\n\t}\n\tconst query = search.toString();\n\treturn query ? `?${query}` : \"\";\n}\n\nexport abstract class BaseClient {\n\tprotected baseUrl: string;\n\tprotected apiKey?: string;\n\tprotected origin: \"cli\" | \"mcp\" | \"session\";\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tthis.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n\t\tthis.apiKey = options.apiKey;\n\t\tthis.origin = options.origin ?? \"cli\";\n\t}\n\n\tstatic authHeaders(apiKey?: string): Record<string, string> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t};\n\t\tif (apiKey) {\n\t\t\theaders.Authorization = `Bearer ${apiKey}`;\n\t\t}\n\t\treturn headers;\n\t}\n\n\tprotected async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst response = await this.fetchResponse(method, path, body);\n\t\tif (response.status === 204) {\n\t\t\treturn undefined as T;\n\t\t}\n\t\treturn response.json() as Promise<T>;\n\t}\n\n\tprotected async requestText(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<string> {\n\t\tconst response = await this.fetchResponse(method, path, body);\n\t\treturn response.text();\n\t}\n\n\tprivate async fetchResponse(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<Response> {\n\t\tconst url = `${this.baseUrl}${path}`;\n\t\tconst headers = BaseClient.authHeaders(this.apiKey);\n\t\theaders[\"x-sl-origin\"] = this.origin;\n\n\t\t// Serialize the body BEFORE the network try so a body-encoding error\n\t\t// (e.g. unsupported BigInt) isn't misreported as \"Cannot reach API\".\n\t\t// BigInts are stringified — server schemas accept jsonb so the value\n\t\t// reaches the server intact, and any field that needs an actual bigint\n\t\t// at runtime is rehydrated by the consuming module (subgraph handler\n\t\t// code preserves the literal). See packages/subgraphs source-matcher\n\t\t// for the post-load shape.\n\t\tlet serializedBody: string | undefined;\n\t\tif (body !== undefined && body !== null) {\n\t\t\ttry {\n\t\t\t\tserializedBody = JSON.stringify(body, (_key, value) =>\n\t\t\t\t\ttypeof value === \"bigint\" ? value.toString() : value,\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tconst detail = err instanceof Error ? err.message : String(err);\n\t\t\t\tthrow new ApiError(0, `Failed to serialize request body: ${detail}`);\n\t\t\t}\n\t\t}\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await fetch(url, {\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\tbody: serializedBody,\n\t\t\t});\n\t\t} catch {\n\t\t\tthrow new ApiError(\n\t\t\t\t0,\n\t\t\t\t`Cannot reach API at ${this.baseUrl}. Check your connection or try again.`,\n\t\t\t);\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status === 401) {\n\t\t\t\tthrow new ApiError(401, \"API key invalid or expired.\");\n\t\t\t}\n\n\t\t\tif (response.status === 429) {\n\t\t\t\tconst retryAfter = response.headers.get(\"Retry-After\");\n\t\t\t\tconst msg = retryAfter\n\t\t\t\t\t? `Rate limited. Wait ${retryAfter} seconds.`\n\t\t\t\t\t: \"Rate limited. Try again later.\";\n\t\t\t\tthrow new ApiError(429, msg);\n\t\t\t}\n\n\t\t\tif (response.status >= 500) {\n\t\t\t\tthrow new ApiError(\n\t\t\t\t\tresponse.status,\n\t\t\t\t\t`Server error. Try again or check status at ${this.baseUrl}/health`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst errorBody = await response.text();\n\t\t\tlet message = `HTTP ${response.status}`;\n\t\t\tlet parsedBody: unknown = errorBody;\n\t\t\tlet code: string | undefined;\n\t\t\ttry {\n\t\t\t\tconst json = JSON.parse(errorBody);\n\t\t\t\tparsedBody = json;\n\t\t\t\tconst err = json.error ?? json.message;\n\t\t\t\tif (typeof err === \"string\") {\n\t\t\t\t\tmessage = err;\n\t\t\t\t} else if (err && typeof err === \"object\") {\n\t\t\t\t\tmessage = JSON.stringify(err);\n\t\t\t\t}\n\t\t\t\tif (typeof json.code === \"string\") {\n\t\t\t\t\tcode = json.code;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tif (errorBody) message = errorBody;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tresponse.status === 422 &&\n\t\t\t\tcode === \"BYO_BREAKING_CHANGE\" &&\n\t\t\t\tparsedBody &&\n\t\t\t\ttypeof parsedBody === \"object\" &&\n\t\t\t\tisByoBreakingDetails((parsedBody as { details?: unknown }).details)\n\t\t\t) {\n\t\t\t\tthrow new ByoBreakingChangeError(\n\t\t\t\t\tmessage,\n\t\t\t\t\t(parsedBody as { details: ByoBreakingChangeDetails }).details,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new ApiError(response.status, message, parsedBody, code);\n\t\t}\n\n\t\treturn response;\n\t}\n}\n",
|
|
@@ -8,19 +8,20 @@
|
|
|
8
8
|
"import type {\n\tReindexResponse,\n\tSubgraphAggregateParams,\n\tSubgraphAggregateResponse,\n\tSubgraphDetail,\n\tSubgraphGapsResponse,\n\tSubgraphQueryParams,\n\tSubgraphSummary,\n} from \"@secondlayer/shared/schemas\";\nimport type {\n\tDeploySubgraphRequest,\n\tDeploySubgraphResponse,\n} from \"@secondlayer/shared/schemas/subgraphs\";\nimport type {\n\tSubgraphAgentSchema,\n\tSubgraphSpecOptions,\n} from \"@secondlayer/shared/subgraphs/spec\";\nimport type {\n\tAggregateResult,\n\tAggregateSpec,\n\tFindManyOptions,\n\tInferSubgraphClient,\n\tSubscribeOptions,\n\tWhereInput,\n} from \"@secondlayer/subgraphs\";\nimport { BaseClient } from \"../base.ts\";\nimport { resolveOrderByColumn, serializeWhere } from \"./serialize.ts\";\n\nexport interface SubgraphSource {\n\tname: string;\n\tversion: string;\n\tsourceCode: string | null;\n\treadOnly: boolean;\n\treason?: string;\n\tupdatedAt: string;\n}\n\n/** Status of a tracked reindex/backfill operation (poll until terminal). */\nexport interface SubgraphOperationStatus {\n\tid: string;\n\tsubgraphName: string;\n\tkind: \"reindex\" | \"backfill\";\n\tstatus: \"queued\" | \"running\" | \"completed\" | \"failed\" | \"cancelled\";\n\tfromBlock: number | null;\n\ttoBlock: number | null;\n\tprocessedBlocks: number | null;\n\t/** 0–1 fraction; null when no denominator is known yet. 1 when completed. */\n\tprogress: number | null;\n\terror: string | null;\n\tstartedAt: string | null;\n\tfinishedAt: string | null;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\n/** /v1 cursor envelope for subgraph table reads. */\nexport interface SubgraphRowsEnvelope<T = unknown> {\n\trows: T[];\n\tnext_cursor: string | null;\n\ttip: {\n\t\tblock_height: number;\n\t\tsubgraph_height: number;\n\t\tblocks_behind: number;\n\t};\n}\n\nexport interface BundleSubgraphResponse {\n\tok: true;\n\tname: string;\n\tversion: string | null;\n\tdescription: string | null;\n\tsources: Record<string, Record<string, unknown>>;\n\tschema: Record<string, unknown>;\n\thandlerCode: string;\n\tsourceCode: string;\n\tbundleSize: number;\n}\n\nfunction buildSubgraphQueryString(params: SubgraphQueryParams): string {\n\tconst qs = new URLSearchParams();\n\tif (params.sort) qs.set(\"_sort\", params.sort);\n\tif (params.order) qs.set(\"_order\", params.order);\n\tif (params.limit !== undefined) qs.set(\"_limit\", String(params.limit));\n\tif (params.offset !== undefined) qs.set(\"_offset\", String(params.offset));\n\tif (params.fields) qs.set(\"_fields\", params.fields);\n\tif (params.filters) {\n\t\tfor (const [key, value] of Object.entries(params.filters)) {\n\t\t\tqs.set(key, String(value));\n\t\t}\n\t}\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nfunction buildAggregateQueryString(params: SubgraphAggregateParams): string {\n\tconst qs = new URLSearchParams();\n\tif (params.filters) {\n\t\tfor (const [key, value] of Object.entries(params.filters)) {\n\t\t\tqs.set(key, String(value));\n\t\t}\n\t}\n\tif (params.count) qs.set(\"_count\", \"true\");\n\tif (params.countDistinct?.length)\n\t\tqs.set(\"_countDistinct\", params.countDistinct.join(\",\"));\n\tif (params.sum?.length) qs.set(\"_sum\", params.sum.join(\",\"));\n\tif (params.min?.length) qs.set(\"_min\", params.min.join(\",\"));\n\tif (params.max?.length) qs.set(\"_max\", params.max.join(\",\"));\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nfunction buildSpecQueryString(options?: SubgraphSpecOptions): string {\n\tconst qs = new URLSearchParams();\n\tif (options?.serverUrl) qs.set(\"server\", options.serverUrl);\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nexport class Subgraphs extends BaseClient {\n\tasync list(): Promise<{ data: SubgraphSummary[] }> {\n\t\treturn this.request<{ data: SubgraphSummary[] }>(\"GET\", \"/api/subgraphs\");\n\t}\n\n\tasync get(name: string): Promise<SubgraphDetail> {\n\t\treturn this.request<SubgraphDetail>(\"GET\", `/api/subgraphs/${name}`);\n\t}\n\n\tasync openapi(\n\t\tname: string,\n\t\toptions?: SubgraphSpecOptions,\n\t): Promise<Record<string, unknown>> {\n\t\treturn this.request<Record<string, unknown>>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/openapi.json${buildSpecQueryString(options)}`,\n\t\t);\n\t}\n\n\tasync schema(\n\t\tname: string,\n\t\toptions?: SubgraphSpecOptions,\n\t): Promise<SubgraphAgentSchema> {\n\t\treturn this.request<SubgraphAgentSchema>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/schema.json${buildSpecQueryString(options)}`,\n\t\t);\n\t}\n\n\tasync markdown(name: string, options?: SubgraphSpecOptions): Promise<string> {\n\t\treturn this.requestText(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/docs.md${buildSpecQueryString(options)}`,\n\t\t);\n\t}\n\n\tasync reindex(\n\t\tname: string,\n\t\toptions?: { fromBlock?: number; toBlock?: number },\n\t): Promise<ReindexResponse> {\n\t\treturn this.request<ReindexResponse>(\n\t\t\t\"POST\",\n\t\t\t`/api/subgraphs/${name}/reindex`,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync stop(\n\t\tname: string,\n\t): Promise<{ message: string; operationId?: string; status?: string }> {\n\t\treturn this.request<{\n\t\t\tmessage: string;\n\t\t\toperationId?: string;\n\t\t\tstatus?: string;\n\t\t}>(\"POST\", `/api/subgraphs/${name}/stop`);\n\t}\n\n\tasync backfill(\n\t\tname: string,\n\t\toptions: { fromBlock: number; toBlock: number },\n\t): Promise<ReindexResponse> {\n\t\treturn this.request<ReindexResponse>(\n\t\t\t\"POST\",\n\t\t\t`/api/subgraphs/${name}/backfill`,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync gaps(\n\t\tname: string,\n\t\topts?: { limit?: number; offset?: number; resolved?: boolean },\n\t): Promise<SubgraphGapsResponse> {\n\t\tconst qs = new URLSearchParams();\n\t\tif (opts?.limit !== undefined) qs.set(\"_limit\", String(opts.limit));\n\t\tif (opts?.offset !== undefined) qs.set(\"_offset\", String(opts.offset));\n\t\tif (opts?.resolved !== undefined) qs.set(\"resolved\", String(opts.resolved));\n\t\tconst query = qs.toString();\n\t\treturn this.request<SubgraphGapsResponse>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/gaps${query ? `?${query}` : \"\"}`,\n\t\t);\n\t}\n\n\tasync delete(\n\t\tname: string,\n\t\toptions?: { force?: boolean },\n\t): Promise<{ message: string }> {\n\t\tconst qs = options?.force ? \"?force=true\" : \"\";\n\t\treturn this.request<{ message: string }>(\n\t\t\t\"DELETE\",\n\t\t\t`/api/subgraphs/${name}${qs}`,\n\t\t);\n\t}\n\n\t/**\n\t * Publish: claim the name in the global public namespace and open anon\n\t * reads on /v1/subgraphs/:name. 409 PUBLIC_NAME_TAKEN if another account\n\t * holds the public name.\n\t */\n\tasync publish(\n\t\tname: string,\n\t): Promise<{ name: string; visibility: \"public\"; url: string }> {\n\t\treturn this.request<{ name: string; visibility: \"public\"; url: string }>(\n\t\t\t\"POST\",\n\t\t\t`/api/subgraphs/${name}/publish`,\n\t\t);\n\t}\n\n\t/** Make reads private again (owning account's bearer key required). */\n\tasync unpublish(\n\t\tname: string,\n\t): Promise<{ name: string; visibility: \"private\" }> {\n\t\treturn this.request<{ name: string; visibility: \"private\" }>(\n\t\t\t\"POST\",\n\t\t\t`/api/subgraphs/${name}/unpublish`,\n\t\t);\n\t}\n\n\t/**\n\t * Open /v1 read: cursor-paginated rows. Anon works for public subgraphs;\n\t * pass an apiKey on the client for private ones. Resume with the returned\n\t * `next_cursor`.\n\t */\n\tasync rows<T = unknown>(\n\t\tname: string,\n\t\ttable: string,\n\t\tparams: Omit<SubgraphQueryParams, \"offset\" | \"sort\"> & {\n\t\t\tcursor?: string;\n\t\t} = {},\n\t): Promise<SubgraphRowsEnvelope<T>> {\n\t\tconst { cursor, ...rest } = params;\n\t\tconst qs = buildSubgraphQueryString(rest);\n\t\tconst sep = qs ? \"&\" : \"?\";\n\t\tconst cursorQs = cursor ? `${sep}cursor=${encodeURIComponent(cursor)}` : \"\";\n\t\treturn this.request<SubgraphRowsEnvelope<T>>(\n\t\t\t\"GET\",\n\t\t\t`/v1/subgraphs/${name}/${table}${qs}${cursorQs}`,\n\t\t);\n\t}\n\n\t/** Recent reindex/backfill operations for a subgraph, newest first. */\n\tasync operations(\n\t\tname: string,\n\t): Promise<{ operations: SubgraphOperationStatus[] }> {\n\t\treturn this.request<{ operations: SubgraphOperationStatus[] }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/operations`,\n\t\t);\n\t}\n\n\t/** Status of a single operation (poll the `operationId` returned by\n\t * reindex/backfill/stop until `status` is terminal). */\n\tasync getOperation(\n\t\tname: string,\n\t\toperationId: string,\n\t): Promise<SubgraphOperationStatus> {\n\t\treturn this.request<SubgraphOperationStatus>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/operations/${operationId}`,\n\t\t);\n\t}\n\n\tasync deploy(data: DeploySubgraphRequest): Promise<DeploySubgraphResponse> {\n\t\treturn this.request<DeploySubgraphResponse>(\"POST\", \"/api/subgraphs\", data);\n\t}\n\n\tasync getSource(name: string): Promise<SubgraphSource> {\n\t\treturn this.request<SubgraphSource>(\"GET\", `/api/subgraphs/${name}/source`);\n\t}\n\n\t/**\n\t * Bundle a TypeScript subgraph source on the server. Used by the web chat\n\t * authoring loop so Vercel's serverless runtime doesn't have to run esbuild.\n\t */\n\tasync bundle(data: { code: string }): Promise<BundleSubgraphResponse> {\n\t\treturn this.request<BundleSubgraphResponse>(\n\t\t\t\"POST\",\n\t\t\t\"/api/subgraphs/bundle\",\n\t\t\tdata,\n\t\t);\n\t}\n\n\tasync queryTable(\n\t\tname: string,\n\t\ttable: string,\n\t\tparams: SubgraphQueryParams = {},\n\t): Promise<unknown[]> {\n\t\tconst result = await this.request<{ data: unknown[] } | unknown[]>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/${table}${buildSubgraphQueryString(params)}`,\n\t\t);\n\t\treturn Array.isArray(result) ? result : result.data;\n\t}\n\n\tasync queryTableCount(\n\t\tname: string,\n\t\ttable: string,\n\t\tparams: SubgraphQueryParams = {},\n\t): Promise<{ count: number }> {\n\t\treturn this.request<{ count: number }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/${table}/count${buildSubgraphQueryString(params)}`,\n\t\t);\n\t}\n\n\tasync queryTableAggregate(\n\t\tname: string,\n\t\ttable: string,\n\t\tparams: SubgraphAggregateParams = {},\n\t): Promise<SubgraphAggregateResponse> {\n\t\treturn this.request<SubgraphAggregateResponse>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/${table}/aggregate${buildAggregateQueryString(params)}`,\n\t\t);\n\t}\n\n\t/**\n\t * Returns a typed client for a subgraph defined with `defineSubgraph()`.\n\t * Row types are inferred from the subgraph's schema literal types.\n\t *\n\t * @example\n\t * ```ts\n\t * import mySubgraph from './subgraphs/my-token-subgraph'\n\t * const client = sl.subgraphs.typed(mySubgraph)\n\t * const rows = await client.transfers.findMany({ where: { sender: 'SP...' } })\n\t * // rows: InferTableRow<typeof mySubgraph.schema.transfers>[]\n\t * ```\n\t */\n\ttyped<T extends { name: string; schema: Record<string, unknown> }>(\n\t\tdef: T,\n\t): InferSubgraphClient<T> {\n\t\tconst result: Record<string, unknown> = {};\n\n\t\tfor (const tableName of Object.keys(def.schema)) {\n\t\t\tresult[tableName] = this.createTableClient(def.name, tableName);\n\t\t}\n\n\t\treturn result as InferSubgraphClient<T>;\n\t}\n\n\tprivate createTableClient(subgraphName: string, tableName: string) {\n\t\tconst self = this;\n\n\t\treturn {\n\t\t\tasync findMany<TRow>(\n\t\t\t\toptions: FindManyOptions<TRow> = {},\n\t\t\t): Promise<TRow[]> {\n\t\t\t\tconst filters = options.where\n\t\t\t\t\t? serializeWhere(options.where as Record<string, unknown>)\n\t\t\t\t\t: undefined;\n\n\t\t\t\tlet sort: string | undefined;\n\t\t\t\tlet order: string | undefined;\n\t\t\t\tif (options.orderBy) {\n\t\t\t\t\t// Accept the object form `{ col: \"asc\" }` or the ordered array\n\t\t\t\t\t// form `[[col, \"asc\"], …]` for deterministic multi-column sort.\n\t\t\t\t\tconst entries: [string, \"asc\" | \"desc\"][] = Array.isArray(\n\t\t\t\t\t\toptions.orderBy,\n\t\t\t\t\t)\n\t\t\t\t\t\t? (options.orderBy as [string, \"asc\" | \"desc\"][])\n\t\t\t\t\t\t: (Object.entries(options.orderBy) as [string, \"asc\" | \"desc\"][]);\n\t\t\t\t\tif (entries.length > 0) {\n\t\t\t\t\t\t// Comma-joined parallel lists → `_sort=a,b&_order=asc,desc`.\n\t\t\t\t\t\tsort = entries.map(([col]) => resolveOrderByColumn(col)).join(\",\");\n\t\t\t\t\t\torder = entries.map(([, dir]) => dir ?? \"asc\").join(\",\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst params: SubgraphQueryParams = {\n\t\t\t\t\tsort,\n\t\t\t\t\torder,\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t\toffset: options.offset,\n\t\t\t\t\tfields: options.fields?.join(\",\"),\n\t\t\t\t\tfilters,\n\t\t\t\t};\n\n\t\t\t\treturn self.queryTable(subgraphName, tableName, params) as Promise<\n\t\t\t\t\tTRow[]\n\t\t\t\t>;\n\t\t\t},\n\n\t\t\tasync count<TRow>(where?: WhereInput<TRow>): Promise<number> {\n\t\t\t\tconst filters = where\n\t\t\t\t\t? serializeWhere(where as Record<string, unknown>)\n\t\t\t\t\t: undefined;\n\n\t\t\t\tconst result = await self.queryTableCount(subgraphName, tableName, {\n\t\t\t\t\tfilters,\n\t\t\t\t});\n\t\t\t\treturn result.count;\n\t\t\t},\n\n\t\t\tasync aggregate<TRow, const A extends AggregateSpec<TRow>>(\n\t\t\t\tspec: A,\n\t\t\t): Promise<AggregateResult<TRow, A>> {\n\t\t\t\tconst filters = spec.where\n\t\t\t\t\t? serializeWhere(spec.where as Record<string, unknown>)\n\t\t\t\t\t: undefined;\n\n\t\t\t\tconst result = await self.queryTableAggregate(subgraphName, tableName, {\n\t\t\t\t\tfilters,\n\t\t\t\t\tcount: spec.count,\n\t\t\t\t\tcountDistinct: spec.countDistinct,\n\t\t\t\t\tsum: spec.sum,\n\t\t\t\t\tmin: spec.min,\n\t\t\t\t\tmax: spec.max,\n\t\t\t\t});\n\t\t\t\treturn result as AggregateResult<TRow, A>;\n\t\t\t},\n\n\t\t\tsubscribe<TRow>(\n\t\t\t\tonRow: (row: TRow) => void,\n\t\t\t\toptions: SubscribeOptions<TRow> = {},\n\t\t\t): () => void {\n\t\t\t\tconst filters = options.where\n\t\t\t\t\t? serializeWhere(options.where as Record<string, unknown>)\n\t\t\t\t\t: {};\n\t\t\t\tconst qs = new URLSearchParams();\n\t\t\t\tfor (const [k, v] of Object.entries(filters)) qs.set(k, String(v));\n\t\t\t\tif (options.since != null) qs.set(\"since\", String(options.since));\n\t\t\t\tconst query = qs.toString();\n\t\t\t\tconst url = `${self.baseUrl}/api/subgraphs/${subgraphName}/${tableName}/stream${query ? `?${query}` : \"\"}`;\n\n\t\t\t\ttype EventSourceLike = {\n\t\t\t\t\tonmessage: ((ev: { data: string }) => void) | null;\n\t\t\t\t\tonerror: ((ev: unknown) => void) | null;\n\t\t\t\t\tclose(): void;\n\t\t\t\t};\n\t\t\t\tconst ES = (\n\t\t\t\t\tglobalThis as unknown as {\n\t\t\t\t\t\tEventSource?: new (url: string) => EventSourceLike;\n\t\t\t\t\t}\n\t\t\t\t).EventSource;\n\t\t\t\tif (!ES) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"subscribe() needs a global EventSource (available in browsers and Node >= 22).\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst es = new ES(url);\n\t\t\t\tes.onmessage = (ev) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tonRow(JSON.parse(ev.data) as TRow);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// ignore non-JSON frames (e.g. heartbeats)\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tif (options.onError) {\n\t\t\t\t\tconst handler = options.onError;\n\t\t\t\t\tes.onerror = (ev) => handler(ev);\n\t\t\t\t}\n\t\t\t\treturn () => es.close();\n\t\t\t},\n\t\t};\n\t}\n}\n",
|
|
9
9
|
"import { BaseClient, type SecondLayerOptions } from \"../base.ts\";\n\n/**\n * Typed client for the agent-reachable key mint (`POST /v1/api-keys`).\n *\n * Lets a headless agent self-provision a SCOPED `streams`/`index` read key\n * without the dashboard. Requires an owner credential — an account-level API\n * key (or a dashboard session). The minted key is always scoped (never an\n * account/superkey) and inherits the account plan's tier.\n */\n\n/** Scope of a minted read key. */\nexport type ScopedKeyProduct = \"streams\" | \"index\";\n\nexport interface CreateApiKeyParams {\n\t/** Scope of the minted key. Defaults to \"streams\". */\n\tproduct?: ScopedKeyProduct;\n\t/** Optional human-readable label for the key. */\n\tname?: string;\n}\n\nexport interface CreateApiKeyResponse {\n\t/** Plaintext key — returned ONCE. Store it now; only its hash is persisted. */\n\tkey: string;\n\tprefix: string;\n\tid: string;\n\tproduct: string;\n\ttier: string | null;\n\tcreatedAt: string;\n}\n\n/** A key as seen by {@link ApiKeys.list} — metadata only, never the plaintext. */\nexport interface ApiKeySummary {\n\tid: string;\n\tprefix: string;\n\tname: string | null;\n\tstatus: \"active\" | \"revoked\";\n\tproduct: string;\n\ttier: string | null;\n\tcreatedAt: string;\n\tlastUsedAt: string | null;\n}\n\nexport class ApiKeys extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/**\n\t * Mint a new scoped read key. The configured `apiKey` must be an\n\t * account-level (owner) key; the plaintext `key` in the response is shown\n\t * only once.\n\t */\n\tcreate(params: CreateApiKeyParams = {}): Promise<CreateApiKeyResponse> {\n\t\treturn this.request<CreateApiKeyResponse>(\"POST\", \"/v1/api-keys\", {\n\t\t\tproduct: params.product,\n\t\t\tname: params.name,\n\t\t});\n\t}\n\n\t/**\n\t * List the account's keys (metadata only — no plaintext). Requires an\n\t * account-level (owner) key or a dashboard session.\n\t */\n\tlist(): Promise<{ keys: ApiKeySummary[] }> {\n\t\treturn this.request<{ keys: ApiKeySummary[] }>(\"GET\", \"/api/keys\");\n\t}\n\n\t/** Revoke a key by id. Existing requests with that key stop working. */\n\trevoke(id: string): Promise<{ revoked: true; id: string }> {\n\t\treturn this.request<{ revoked: true; id: string }>(\n\t\t\t\"DELETE\",\n\t\t\t`/api/keys/${id}`,\n\t\t);\n\t}\n}\n",
|
|
10
10
|
"import { BaseClient, type SecondLayerOptions, buildQuery } from \"../base.ts\";\nimport { ApiError } from \"../errors.ts\";\n\n/**\n * Typed client for the contract-discovery API (`GET /v1/contracts`).\n *\n * \"Find all contracts conforming to a trait\" — backed by the contract registry:\n * `declared` traits parsed from Clarity source, `inferred` standards from static\n * ABI shape-matching. Anonymous public read. `trait` is required; the ABI blob is\n * omitted unless `include: \"abi\"` is passed.\n */\n\n/** Whether a trait match must be declared in source, inferred from ABI, or either. */\nexport type ContractConformance = \"declared\" | \"inferred\" | \"any\";\n\nexport interface ContractsListParams {\n\t/** Required. Trait identifier to match (e.g. \"sip-010\", or a fully-qualified trait). */\n\ttrait: string;\n\t/** Match source. Defaults to \"any\" server-side. */\n\tconformance?: ContractConformance;\n\t/** Set to \"abi\" to include the full ABI blob in each row. */\n\tinclude?: \"abi\";\n\t/** Page size, 1–500 (default 100 server-side). */\n\tlimit?: number;\n\t/** Opaque cursor from a prior response's `next_cursor`. */\n\tcursor?: string;\n}\n\nexport interface ContractSummary {\n\tcontract_id: string;\n\tdeployer: string;\n\tblock_height: number;\n\tdeclared_traits: string[] | null;\n\tinferred_standards: string[] | null;\n\tabi_status: string;\n\t/** Present only when `include: \"abi\"` was requested. */\n\tabi?: unknown;\n}\n\nexport interface ContractsEnvelope {\n\tcontracts: ContractSummary[];\n\tnext_cursor: string | null;\n}\n\nexport class Contracts extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/** Find contracts conforming to `trait`. `trait` is required (server 400s without it). */\n\tlist(params: ContractsListParams): Promise<ContractsEnvelope> {\n\t\treturn this.request<ContractsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/contracts${buildQuery({\n\t\t\t\ttrait: params.trait,\n\t\t\t\tconformance: params.conformance,\n\t\t\t\tinclude: params.include,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcursor: params.cursor,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\t/**\n\t * Fetch a single contract from the registry by id (the prod-safe ABI source).\n\t * Pass `{ includeAbi: true }` for the full ABI blob. Resolves null on 404.\n\t */\n\tasync get(\n\t\tcontractId: string,\n\t\topts: { includeAbi?: boolean } = {},\n\t): Promise<ContractSummary | null> {\n\t\ttry {\n\t\t\tconst { contract } = await this.request<{ contract: ContractSummary }>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/contracts/${encodeURIComponent(contractId)}${\n\t\t\t\t\topts.includeAbi ? \"?include=abi\" : \"\"\n\t\t\t\t}`,\n\t\t\t);\n\t\t\treturn contract;\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n",
|
|
11
|
-
"import type { InferredTopicSchema } from \"@secondlayer/subgraphs\";\nimport { BaseClient, buildQuery } from \"../base.ts\";\nimport type { SecondLayerOptions } from \"../base.ts\";\nimport { ApiError } from \"../errors.ts\";\nimport type { TransactionProof } from \"../proofs.ts\";\n\nexport type IndexTip = {\n\tblock_height: number;\n\tlag_seconds: number;\n};\n\n/**\n * A chain reorg overlapping a returned page's height range. Height-keyed feeds\n * (`/transactions`, `/contract-calls`, `/stacking`) populate this so a consumer\n * can reconcile: roll back the rows whose `block_height:tx_index` cursor falls in\n * `orphaned_range`, then re-fetch from `new_canonical_tip`. Empty when the page\n * spans no reorg.\n */\nexport type IndexReorg = {\n\tid: string;\n\tdetected_at: string;\n\tfork_point_height: number;\n\told_index_block_hash: string | null;\n\tnew_index_block_hash: string | null;\n\t/** Orphaned cursor span `<block_height>:<tx_index>`, inclusive. */\n\torphaned_range: { from: string; to: string };\n\t/** New canonical tip cursor to resume from. */\n\tnew_canonical_tip: string;\n};\n\nexport type IndexUsage = {\n\tproduct: \"index\";\n\ttier: string;\n\tlimits: { rate_limit_per_second: number | null };\n\tusage: { decoded_events_today: number; decoded_events_this_month: number };\n};\n\nexport type FtTransfer = {\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\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type FtTransfersEnvelope = {\n\tevents: FtTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n};\n\nexport type FtTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type FtTransfersWalkParams = Omit<FtTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nexport type NftTransfer = {\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\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type NftTransfersEnvelope = {\n\tevents: NftTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n};\n\nexport type NftTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tassetIdentifier?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type NftTransfersWalkParams = Omit<NftTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Generic decoded events (/v1/index/events) ──────────────────────\n\ntype IndexEventBase = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tcontract_id: string | null;\n};\n\nexport type IndexFtTransfer = IndexEventBase & {\n\tevent_type: \"ft_transfer\";\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexNftTransfer = IndexEventBase & {\n\tevent_type: \"nft_transfer\";\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\nexport type IndexStxTransfer = IndexEventBase & {\n\tevent_type: \"stx_transfer\";\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n\tmemo: string | null;\n};\nexport type IndexStxMint = IndexEventBase & {\n\tevent_type: \"stx_mint\";\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexStxBurn = IndexEventBase & {\n\tevent_type: \"stx_burn\";\n\tsender: string;\n\tamount: string;\n};\nexport type IndexStxLock = IndexEventBase & {\n\tevent_type: \"stx_lock\";\n\tsender: string;\n\tamount: string;\n\tpayload: { unlock_height: string | null };\n};\nexport type IndexFtMint = IndexEventBase & {\n\tevent_type: \"ft_mint\";\n\tasset_identifier: string;\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexFtBurn = IndexEventBase & {\n\tevent_type: \"ft_burn\";\n\tasset_identifier: string;\n\tsender: string;\n\tamount: string;\n};\nexport type IndexNftMint = IndexEventBase & {\n\tevent_type: \"nft_mint\";\n\tasset_identifier: string;\n\trecipient: string;\n\tvalue: string;\n};\nexport type IndexNftBurn = IndexEventBase & {\n\tevent_type: \"nft_burn\";\n\tasset_identifier: string;\n\tsender: string;\n\tvalue: string;\n};\nexport type IndexPrint = IndexEventBase & {\n\tevent_type: \"print\";\n\tpayload: { topic: string | null; value: unknown; raw_value: string | null };\n};\n\n/** Decoded chain event, discriminated by `event_type`. */\nexport type IndexEvent =\n\t| IndexFtTransfer\n\t| IndexNftTransfer\n\t| IndexStxTransfer\n\t| IndexStxMint\n\t| IndexStxBurn\n\t| IndexStxLock\n\t| IndexFtMint\n\t| IndexFtBurn\n\t| IndexNftMint\n\t| IndexNftBurn\n\t| IndexPrint;\n\nexport type IndexEventType = IndexEvent[\"event_type\"];\n\nexport type EventsEnvelope = {\n\tevents: IndexEvent[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n};\n\nexport type EventsListParams = {\n\t/** Required. One of the decoded event types. */\n\teventType: IndexEventType;\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tassetIdentifier?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n\t/** Restrict to contracts conforming to a trait/standard (e.g. \"sip-010\").\n\t * Mutually exclusive with contractId; contract-keyed event types only. */\n\ttrait?: string;\n};\n\nexport type EventsWalkParams = Omit<EventsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Contract calls (/v1/index/contract-calls) ──────────────────────\n\nexport type IndexContractCall = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_id: string;\n\ttx_index: number;\n\tcontract_id: string;\n\tfunction_name: string;\n\tsender: string;\n\tstatus: string;\n\targs: unknown[];\n\tresult: unknown;\n\tresult_hex: string | null;\n};\n\nexport type ContractCallsEnvelope = {\n\tcontract_calls: IndexContractCall[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n};\n\nexport type ContractCallsListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tfunctionName?: string;\n\tsender?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n\t/** Restrict to contracts conforming to a trait/standard (e.g. \"sip-010\").\n\t * Mutually exclusive with contractId. */\n\ttrait?: string;\n};\n\nexport type ContractCallsWalkParams = Omit<ContractCallsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Canonical block-hash map (/v1/index/canonical) ─────────────────\n\n/** One canonical block in the sync map. Lean by design — block + parent hash\n * for chain linkage, burn anchor for Bitcoin confirmations. Use `blocks` for\n * the full block resource. */\nexport type IndexCanonicalBlock = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string | null;\n};\n\nexport type CanonicalEnvelope = {\n\tcanonical: IndexCanonicalBlock[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type CanonicalListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type CanonicalWalkParams = Omit<CanonicalListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Blocks (/v1/index/blocks) ──────────────────────────────────────\n\n/** A block resource. Metadata is intentionally thin — only chain-linkage and\n * burn-anchor fields are persisted (no miner / tx_count / signer). */\nexport type IndexBlock = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string | null;\n\tblock_time: string | null;\n\tcanonical: boolean;\n};\n\nexport type BlocksEnvelope = {\n\tblocks: IndexBlock[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type BlockEnvelope = {\n\tblock: IndexBlock;\n\ttip: IndexTip;\n};\n\nexport type BlocksListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type BlocksWalkParams = Omit<BlocksListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Transactions (/v1/index/transactions) ──────────────────────────\n\nexport type IndexPostCondition =\n\t| {\n\t\t\ttype: \"stx\";\n\t\t\tprincipal: string;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t\t\tamount: string;\n\t }\n\t| {\n\t\t\ttype: \"ft\";\n\t\t\tprincipal: string;\n\t\t\tasset_identifier: string;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t\t\tamount: string;\n\t }\n\t| {\n\t\t\ttype: \"nft\";\n\t\t\tprincipal: string;\n\t\t\tasset_identifier: string;\n\t\t\tasset_value: unknown;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t };\n\n/** Full transaction document: columnar fields plus `raw_tx`-decoded enrichment.\n * Payload sub-objects are present only for the matching `tx_type`; enrichment\n * fields are null when `raw_tx` isn't decodable (e.g. burnchain ops). */\nexport type IndexTransaction = {\n\tcursor: string;\n\ttx_id: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_index: number;\n\ttx_type: string;\n\tsender: string;\n\tstatus: string;\n\tfee: string | null;\n\tnonce: string | null;\n\tsponsored: boolean | null;\n\tanchor_mode: string | null;\n\tpost_condition_mode: string | null;\n\tpost_conditions: IndexPostCondition[];\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t\t/** Raw hex-encoded ClarityValues; decode(function_args_hex[i]) === function_args[i]. */\n\t\tfunction_args_hex: string[];\n\t\tresult: unknown;\n\t\tresult_hex: string | null;\n\t};\n\ttoken_transfer?: { recipient: string; amount: string; memo: string };\n\tsmart_contract?: {\n\t\tcontract_id: string | null;\n\t\tclarity_version: number | null;\n\t};\n\tcoinbase?: { alt_recipient: string | null };\n\ttenure_change?: { cause: number };\n};\n\nexport type TransactionsEnvelope = {\n\ttransactions: IndexTransaction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n};\n\nexport type TransactionEnvelope = {\n\ttransaction: IndexTransaction;\n\ttip: IndexTip;\n};\n\nexport type TransactionsListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\ttype?: string;\n\tsender?: string;\n\tcontractId?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type TransactionsWalkParams = Omit<TransactionsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Stacking (/v1/index/stacking) ──────────────────────────────────\n\n/** A decoded PoX-4 stacking action (one per stacking contract call). */\nexport type IndexStackingAction = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\tburn_block_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tfunction_name: string;\n\tcaller: string;\n\tstacker: string | null;\n\tdelegate_to: string | null;\n\tamount_ustx: string | null;\n\tlock_period: number | null;\n\tpox_addr: {\n\t\tversion: number | null;\n\t\thashbytes: string | null;\n\t\tbtc: string | null;\n\t};\n\tstart_cycle: number | null;\n\tend_cycle: number | null;\n\treward_cycle: number | null;\n\tsigner_key: string | null;\n\tresult_ok: boolean;\n};\n\nexport type StackingEnvelope = {\n\tstacking: IndexStackingAction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n\t/** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */\n\tnotes?: string;\n};\n\nexport type StackingListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfunctionName?: string;\n\tstacker?: string;\n\tcaller?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type StackingWalkParams = Omit<StackingListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Mempool (/v1/index/mempool) ────────────────────────────────────\n\n/** A pending (unconfirmed) transaction. Like a transaction document but\n * pre-chain — no block_height/tx_index/result/events — with `received_at` and\n * a sequence cursor instead of a block position. */\nexport type IndexMempoolTransaction = {\n\tcursor: string;\n\ttx_id: string;\n\ttx_type: string;\n\tsender: string;\n\treceived_at?: string | null;\n\tfee: string | null;\n\tnonce: string | null;\n\tsponsored: boolean | null;\n\tanchor_mode: string | null;\n\tpost_condition_mode: string | null;\n\tpost_conditions: IndexPostCondition[];\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t};\n\ttoken_transfer?: { recipient: string; amount: string; memo: string };\n\tsmart_contract?: { clarity_version: number | null };\n\tcoinbase?: { alt_recipient: string | null };\n\ttenure_change?: { cause: number };\n};\n\nexport type MempoolEnvelope = {\n\tmempool: IndexMempoolTransaction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type MempoolTransactionEnvelope = {\n\ttransaction: IndexMempoolTransaction;\n\ttip: IndexTip;\n};\n\nexport type MempoolListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tsender?: string;\n\ttype?: string;\n\t/** Filter to pending calls to a single contract (e.g. `SP….contract`). */\n\tcontractId?: string;\n};\n\nexport type MempoolWalkParams = Omit<MempoolListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Print schema (/v1/index/contracts/:contract_id/print-schema) ───\n\n/**\n * Empirical per-topic print payload schema for a contract, inferred from\n * sampled on-chain events. `topics` is sorted by count desc; `sampled` is true\n * when the contract has more print events than the windows examined.\n */\nexport type PrintSchemaResponse = {\n\tcontract_id: string;\n\ttopics: InferredTopicSchema[];\n\tsampled: boolean;\n\ttotal_events: number;\n\t/** True when the count hit the server-side cap (total_events is the cap). */\n\ttotal_events_capped: boolean;\n\tsample: {\n\t\tsize: number;\n\t\tnewest_height: number | null;\n\t\toldest_height: number | null;\n\t};\n\ttip: IndexTip;\n};\n\nfunction firstWalkFromHeight(params: {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tfromHeight?: number;\n}): number | undefined {\n\tif (params.fromHeight !== undefined) return params.fromHeight;\n\tif (params.cursor || params.fromCursor) return undefined;\n\treturn 0;\n}\n\n/**\n * `index.ftTransfers` — callable shorthand for `.list()`, with `.list`/`.walk`\n * still available: `await sl.index.ftTransfers({ contractId })`.\n *\n * The API accepts `contract_id`/`sender`/`recipient` equality filters only —\n * no amount filtering and no asset-slug resolution on /v1/index/ft-transfers.\n */\nexport interface FtTransfersResource {\n\t(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;\n\tlist(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;\n\twalk(params?: FtTransfersWalkParams): AsyncIterable<FtTransfer>;\n}\n\n/** `index.nftTransfers` — callable shorthand for `.list()` (see {@link FtTransfersResource}). */\nexport interface NftTransfersResource {\n\t(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;\n\tlist(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;\n\twalk(params?: NftTransfersWalkParams): AsyncIterable<NftTransfer>;\n}\n\n/** `index.events` — callable shorthand for `.list()`; `eventType` is required. */\nexport interface IndexEventsResource {\n\t(params: EventsListParams): Promise<EventsEnvelope>;\n\tlist(params: EventsListParams): Promise<EventsEnvelope>;\n\twalk(params: EventsWalkParams): AsyncIterable<IndexEvent>;\n}\n\n/** Per-event-type filter vocabulary in the {@link IndexDiscovery} doc. */\nexport type IndexEventTypeFilters = {\n\tcolumns?: string[];\n\tallowed_filters?: string[];\n\tequality_filters?: string[];\n\trequired_non_null?: string[];\n};\n\n/** The `GET /v1/index` discovery doc — live endpoint + filter vocabulary.\n * Shape is intentionally open (the server may add fields); the agent-relevant\n * parts are the per-type filter rules. */\nexport type IndexDiscovery = {\n\tevent_type_filters?: Record<string, IndexEventTypeFilters>;\n\t[key: string]: unknown;\n};\n\nexport class Index extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/** Your own Index consumption (decoded events today + this month) and tier limits. */\n\tusage(): Promise<IndexUsage> {\n\t\treturn this.request<IndexUsage>(\"GET\", \"/v1/index/usage\");\n\t}\n\n\t/**\n\t * Index discovery doc — the live vocabulary: every endpoint, each event type's\n\t * columns, allowed/equality filters, and required-non-null fields. Read this to\n\t * learn what's queryable (and which types accept `trait`) instead of hardcoding.\n\t */\n\tdiscover(): Promise<IndexDiscovery> {\n\t\treturn this.request<IndexDiscovery>(\"GET\", \"/v1/index\");\n\t}\n\n\t/**\n\t * Empirical per-topic print payload schema for a contract — what topics it\n\t * emits and each field's observed Clarity/TS/column types. Anonymous read;\n\t * 404 → null.\n\t */\n\tasync printSchema(contractId: string): Promise<PrintSchemaResponse | null> {\n\t\ttry {\n\t\t\treturn await this.request<PrintSchemaResponse>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/contracts/${encodeURIComponent(contractId)}/print-schema`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\t/** Callable: `index.ftTransfers(params)` ≡ `index.ftTransfers.list(params)`. */\n\treadonly ftTransfers: FtTransfersResource = Object.assign(\n\t\t(params: FtTransfersListParams = {}): Promise<FtTransfersEnvelope> =>\n\t\t\tthis.listFtTransfers(params),\n\t\t{\n\t\t\tlist: (\n\t\t\t\tparams: FtTransfersListParams = {},\n\t\t\t): Promise<FtTransfersEnvelope> => this.listFtTransfers(params),\n\t\t\twalk: (params: FtTransfersWalkParams = {}): AsyncIterable<FtTransfer> =>\n\t\t\t\tthis.walkFtTransfers(params),\n\t\t},\n\t);\n\n\t/** Callable: `index.nftTransfers(params)` ≡ `index.nftTransfers.list(params)`. */\n\treadonly nftTransfers: NftTransfersResource = Object.assign(\n\t\t(params: NftTransfersListParams = {}): Promise<NftTransfersEnvelope> =>\n\t\t\tthis.listNftTransfers(params),\n\t\t{\n\t\t\tlist: (\n\t\t\t\tparams: NftTransfersListParams = {},\n\t\t\t): Promise<NftTransfersEnvelope> => this.listNftTransfers(params),\n\t\t\twalk: (params: NftTransfersWalkParams = {}): AsyncIterable<NftTransfer> =>\n\t\t\t\tthis.walkNftTransfers(params),\n\t\t},\n\t);\n\n\t/** Generic decoded events by `event_type` (the full /v1/index/events surface).\n\t * Callable: `index.events(params)` ≡ `index.events.list(params)`. */\n\treadonly events: IndexEventsResource = Object.assign(\n\t\t(params: EventsListParams): Promise<EventsEnvelope> =>\n\t\t\tthis.listEvents(params),\n\t\t{\n\t\t\tlist: (params: EventsListParams): Promise<EventsEnvelope> =>\n\t\t\t\tthis.listEvents(params),\n\t\t\twalk: (params: EventsWalkParams): AsyncIterable<IndexEvent> =>\n\t\t\t\tthis.walkEvents(params),\n\t\t},\n\t);\n\n\treadonly contractCalls: {\n\t\tlist: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>;\n\t\twalk: (\n\t\t\tparams?: ContractCallsWalkParams,\n\t\t) => AsyncIterable<IndexContractCall>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: ContractCallsListParams = {},\n\t\t): Promise<ContractCallsEnvelope> => this.listContractCalls(params),\n\t\twalk: (\n\t\t\tparams: ContractCallsWalkParams = {},\n\t\t): AsyncIterable<IndexContractCall> => this.walkContractCalls(params),\n\t};\n\n\t/** Canonical block-hash map — sync only the current canonical chain. */\n\treadonly canonical: {\n\t\tlist: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;\n\t\twalk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;\n\t} = {\n\t\tlist: (params: CanonicalListParams = {}): Promise<CanonicalEnvelope> =>\n\t\t\tthis.listCanonical(params),\n\t\twalk: (\n\t\t\tparams: CanonicalWalkParams = {},\n\t\t): AsyncIterable<IndexCanonicalBlock> => this.walkCanonical(params),\n\t};\n\n\t/** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash\n\t * (resolves to null on 404). */\n\treadonly blocks: {\n\t\tlist: (params?: BlocksListParams) => Promise<BlocksEnvelope>;\n\t\twalk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>;\n\t\tget: (ref: string | number) => Promise<BlockEnvelope | null>;\n\t} = {\n\t\tlist: (params: BlocksListParams = {}): Promise<BlocksEnvelope> =>\n\t\t\tthis.listBlocks(params),\n\t\twalk: (params: BlocksWalkParams = {}): AsyncIterable<IndexBlock> =>\n\t\t\tthis.walkBlocks(params),\n\t\tget: (ref: string | number): Promise<BlockEnvelope | null> =>\n\t\t\tthis.getBlock(ref),\n\t};\n\n\t/** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id\n\t * (resolves to null on 404). */\n\treadonly transactions: {\n\t\tlist: (params?: TransactionsListParams) => Promise<TransactionsEnvelope>;\n\t\twalk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>;\n\t\tget: (txId: string) => Promise<TransactionEnvelope | null>;\n\t\tgetProof: (txId: string) => Promise<TransactionProof | null>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: TransactionsListParams = {},\n\t\t): Promise<TransactionsEnvelope> => this.listTransactions(params),\n\t\twalk: (\n\t\t\tparams: TransactionsWalkParams = {},\n\t\t): AsyncIterable<IndexTransaction> => this.walkTransactions(params),\n\t\tget: (txId: string): Promise<TransactionEnvelope | null> =>\n\t\t\tthis.getTransaction(txId),\n\t\tgetProof: (txId: string): Promise<TransactionProof | null> =>\n\t\t\tthis.getTransactionProof(txId),\n\t};\n\n\t/** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the\n\t * platform's PoX-4 decoder is disabled. */\n\treadonly stacking: {\n\t\tlist: (params?: StackingListParams) => Promise<StackingEnvelope>;\n\t\twalk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;\n\t} = {\n\t\tlist: (params: StackingListParams = {}): Promise<StackingEnvelope> =>\n\t\t\tthis.listStacking(params),\n\t\twalk: (\n\t\t\tparams: StackingWalkParams = {},\n\t\t): AsyncIterable<IndexStackingAction> => this.walkStacking(params),\n\t};\n\n\t/** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by\n\t * tx_id (resolves to null when the tx has confirmed or dropped). */\n\treadonly mempool: {\n\t\tlist: (params?: MempoolListParams) => Promise<MempoolEnvelope>;\n\t\twalk: (\n\t\t\tparams?: MempoolWalkParams,\n\t\t) => AsyncIterable<IndexMempoolTransaction>;\n\t\tget: (txId: string) => Promise<MempoolTransactionEnvelope | null>;\n\t} = {\n\t\tlist: (params: MempoolListParams = {}): Promise<MempoolEnvelope> =>\n\t\t\tthis.listMempool(params),\n\t\twalk: (\n\t\t\tparams: MempoolWalkParams = {},\n\t\t): AsyncIterable<IndexMempoolTransaction> => this.walkMempool(params),\n\t\tget: (txId: string): Promise<MempoolTransactionEnvelope | null> =>\n\t\t\tthis.getMempoolTx(txId),\n\t};\n\n\tprivate async listFtTransfers(\n\t\tparams: FtTransfersListParams = {},\n\t): Promise<FtTransfersEnvelope> {\n\t\treturn this.request<FtTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/ft-transfers${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async listNftTransfers(\n\t\tparams: NftTransfersListParams = {},\n\t): Promise<NftTransfersEnvelope> {\n\t\treturn this.request<NftTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/nft-transfers${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkFtTransfers(\n\t\tparams: FtTransfersWalkParams = {},\n\t): AsyncGenerator<FtTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listFtTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async *walkNftTransfers(\n\t\tparams: NftTransfersWalkParams = {},\n\t): AsyncGenerator<NftTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listNftTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listEvents(params: EventsListParams): Promise<EventsEnvelope> {\n\t\treturn this.request<EventsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/events${buildQuery({\n\t\t\t\tevent_type: params.eventType,\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t\ttrait: params.trait,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkEvents(\n\t\tparams: EventsWalkParams,\n\t): AsyncGenerator<IndexEvent> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listEvents({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listContractCalls(\n\t\tparams: ContractCallsListParams = {},\n\t): Promise<ContractCallsEnvelope> {\n\t\treturn this.request<ContractCallsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/contract-calls${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tfunction_name: params.functionName,\n\t\t\t\tsender: params.sender,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t\ttrait: params.trait,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkContractCalls(\n\t\tparams: ContractCallsWalkParams = {},\n\t): AsyncGenerator<IndexContractCall> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listContractCalls({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const call of envelope.contract_calls) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield call;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.contract_calls.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listCanonical(\n\t\tparams: CanonicalListParams = {},\n\t): Promise<CanonicalEnvelope> {\n\t\treturn this.request<CanonicalEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/canonical${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkCanonical(\n\t\tparams: CanonicalWalkParams = {},\n\t): AsyncGenerator<IndexCanonicalBlock> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listCanonical({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const block of envelope.canonical) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield block;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.canonical.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listBlocks(\n\t\tparams: BlocksListParams = {},\n\t): Promise<BlocksEnvelope> {\n\t\treturn this.request<BlocksEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/blocks${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getBlock(ref: string | number): Promise<BlockEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<BlockEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/blocks/${encodeURIComponent(String(ref))}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkBlocks(\n\t\tparams: BlocksWalkParams = {},\n\t): AsyncGenerator<IndexBlock> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listBlocks({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const block of envelope.blocks) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield block;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.blocks.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listTransactions(\n\t\tparams: TransactionsListParams = {},\n\t): Promise<TransactionsEnvelope> {\n\t\treturn this.request<TransactionsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/transactions${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\ttype: params.type,\n\t\t\t\tsender: params.sender,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getTransaction(\n\t\ttxId: string,\n\t): Promise<TransactionEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<TransactionEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/transactions/${encodeURIComponent(txId)}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\t/** Fetch the inclusion proof for a tx (raw tx + Nakamoto header + merkle path)\n\t * to verify client-side with `verifyTransactionProof`. 404 → null. A 503\n\t * (`PROOF_TX_SET_INCOMPLETE` / `PROOF_NODE_UNAVAILABLE`) surfaces as an\n\t * ApiError — the proof can't be assembled on this deployment right now. */\n\tprivate async getTransactionProof(\n\t\ttxId: string,\n\t): Promise<TransactionProof | null> {\n\t\ttry {\n\t\t\treturn await this.request<TransactionProof>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/transactions/${encodeURIComponent(txId)}/proof`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkTransactions(\n\t\tparams: TransactionsWalkParams = {},\n\t): AsyncGenerator<IndexTransaction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listTransactions({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const tx of envelope.transactions) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield tx;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.transactions.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listStacking(\n\t\tparams: StackingListParams = {},\n\t): Promise<StackingEnvelope> {\n\t\treturn this.request<StackingEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/stacking${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfunction_name: params.functionName,\n\t\t\t\tstacker: params.stacker,\n\t\t\t\tcaller: params.caller,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkStacking(\n\t\tparams: StackingWalkParams = {},\n\t): AsyncGenerator<IndexStackingAction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listStacking({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const action of envelope.stacking) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield action;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.stacking.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listMempool(\n\t\tparams: MempoolListParams = {},\n\t): Promise<MempoolEnvelope> {\n\t\treturn this.request<MempoolEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/mempool${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tsender: params.sender,\n\t\t\t\ttype: params.type,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getMempoolTx(\n\t\ttxId: string,\n\t): Promise<MempoolTransactionEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<MempoolTransactionEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/mempool/${encodeURIComponent(txId)}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkMempool(\n\t\tparams: MempoolWalkParams = {},\n\t): AsyncGenerator<IndexMempoolTransaction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listMempool({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t});\n\n\t\t\tfor (const tx of envelope.mempool) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield tx;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.mempool.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n}\n",
|
|
12
|
-
"import { BaseClient, type SecondLayerOptions } from \"../base.ts\";\n\n/**\n * Typed client for project management (`/api/projects/*`).\n *\n * Projects are the account-scoped containers for work. Every method requires an\n * account-level (owner) API key or a dashboard session — scoped read keys are\n * rejected. Team mutations (invite/remove/role) are intentionally not exposed\n * here; only the read view ({@link Projects.team}) is.\n */\n\nexport interface Project {\n\tid: string;\n\tname: string;\n\tslug: string;\n\tnetwork: string;\n\tnodeRpc: string | null;\n\tsettings: Record<string, unknown> | null;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface ProjectTeamMember {\n\tid: string;\n\trole: string;\n\temail: string;\n\tdisplayName: string | null;\n\tavatarUrl: string | null;\n\tcreatedAt: string;\n}\n\nexport interface ProjectInvitation {\n\tid: string;\n\temail: string;\n\trole: string;\n\texpiresAt: string;\n\tcreatedAt: string;\n}\n\nexport interface ProjectTeam {\n\tmembers: ProjectTeamMember[];\n\tinvitations: ProjectInvitation[];\n}\n\nexport interface CreateProjectParams {\n\tname: string;\n\tslug?: string;\n\tnetwork?: string;\n\tnodeRpc?: string;\n}\n\nexport interface UpdateProjectParams {\n\tname?: string;\n\t/** Rename the project's URL slug. */\n\tslug?: string;\n\tnetwork?: string;\n\tnodeRpc?: string;\n\tsettings?: Record<string, unknown>;\n}\n\nexport class Projects extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/** All projects owned by the account, newest-relevant first. */\n\tlist(): Promise<{ projects: Project[] }> {\n\t\treturn this.request<{ projects: Project[] }>(\"GET\", \"/api/projects\");\n\t}\n\n\t/** A single project by slug. */\n\tget(slug: string): Promise<Project> {\n\t\treturn this.request<Project>(\"GET\", `/api/projects/${slug}`);\n\t}\n\n\t/** Create a project. The creator is added as the project owner. */\n\tcreate(params: CreateProjectParams): Promise<Project> {\n\t\treturn this.request<Project>(\"POST\", \"/api/projects\", params);\n\t}\n\n\t/** Update a project's name, slug (rename), network, RPC, or settings. */\n\tupdate(slug: string, patch: UpdateProjectParams): Promise<Project> {\n\t\treturn this.request<Project>(\"PATCH\", `/api/projects/${slug}`, patch);\n\t}\n\n\t/** Delete a project. The account's last remaining project cannot be deleted. */\n\tdelete(slug: string): Promise<{ ok: true }> {\n\t\treturn this.request<{ ok: true }>(\"DELETE\", `/api/projects/${slug}`);\n\t}\n\n\t/** Team members and pending invitations for a project. */\n\tteam(slug: string): Promise<ProjectTeam> {\n\t\treturn this.request<ProjectTeam>(\"GET\", `/api/projects/${slug}/team`);\n\t}\n}\n",
|
|
13
|
-
"import { ed25519 } from \"@secondlayer/shared\";\nimport { buildQuery } from \"../base.ts\";\nimport {\n\ttype StreamsEventsFetcher,\n\tconsumeStreamsEvents,\n\titerateStreamsBatches,\n\tstreamStreamsEvents,\n} from \"./consumer.ts\";\nimport { createStreamsDumps } from \"./dumps.ts\";\nimport {\n\tAuthError,\n\tRateLimitError,\n\tStreamsServerError,\n\tStreamsSignatureError,\n\tValidationError,\n} from \"./errors.ts\";\nimport { subscribeStreamsEvents } from \"./subscribe.ts\";\nimport type {\n\tFetchLike,\n\tStreamsCanonicalBlock,\n\tStreamsClient,\n\tStreamsConsumeParams,\n\tStreamsEventsConsumeParams,\n\tStreamsEventsEnvelope,\n\tStreamsEventsListEnvelope,\n\tStreamsEventsListParams,\n\tStreamsEventsReplayParams,\n\tStreamsEventsStreamParams,\n\tStreamsEventsSubscribeParams,\n\tStreamsReorgsListEnvelope,\n\tStreamsReorgsListParams,\n\tStreamsTip,\n\tStreamsUsage,\n} from \"./types.ts\";\n\n/** Parse a `<block>:<index>` cursor; null sorts before genesis. */\nfunction cursorTuple(cursor: string | null): [number, number] {\n\tif (!cursor) return [-1, -1];\n\tconst parts = cursor.split(\":\");\n\tconst [block, index] = parts.map(Number);\n\tif (\n\t\tparts.length !== 2 ||\n\t\t!Number.isInteger(block) ||\n\t\t!Number.isInteger(index)\n\t) {\n\t\tthrow new ValidationError(\n\t\t\t`Invalid stream cursor \"${cursor}\"; expected \"<block>:<index>\" (e.g. \"951475:3\").`,\n\t\t\t400,\n\t\t);\n\t}\n\treturn [block, index];\n}\n\n/** The greater of two cursors (later in the stream). */\nfunction maxCursor(a: string | null, b: string | null): string | null {\n\tconst [ah, ai] = cursorTuple(a);\n\tconst [bh, bi] = cursorTuple(b);\n\treturn ah > bh || (ah === bh && ai >= bi) ? a : b;\n}\n\nconst DEFAULT_STREAMS_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport type CreateStreamsClientOptions = {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetchImpl?: FetchLike;\n\t/**\n\t * Public base URL for bulk parquet dumps (the R2/CDN bucket root). Required\n\t * to use `client.dumps`. See `GET /public/streams/dumps/manifest`.\n\t */\n\tdumpsBaseUrl?: string;\n\t/**\n\t * Verify the ed25519 `X-Signature` on every response (default off). Pass\n\t * `true` to fetch the server's public key from\n\t * `/public/streams/signing-key`, or `{ publicKey }` to pin a known PEM. A\n\t * failed or missing signature throws `StreamsSignatureError`.\n\t */\n\tverify?: boolean | { publicKey: string };\n\t/**\n\t * Verify the bulk dumps manifest's ed25519 signature in `client.dumps.list()`\n\t * before trusting any file sha256 (default ON). Uses the same key source as\n\t * `verify` (fetches `/public/streams/signing-key`, or a pinned PEM). Pass\n\t * `false` to opt out. A missing or invalid signature throws\n\t * `StreamsSignatureError`.\n\t */\n\tverifyDumpsManifest?: boolean;\n};\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n\treturn baseUrl.replace(/\\/+$/, \"\");\n}\n\nasync function responseBody(response: Response): Promise<unknown> {\n\tconst text = await response.text();\n\tif (text.length === 0) return undefined;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch {\n\t\treturn text;\n\t}\n}\n\nfunction errorMessage(body: unknown, fallback: string): string {\n\tif (body && typeof body === \"object\") {\n\t\tconst record = body as Record<string, unknown>;\n\t\tconst message = record.error ?? record.message;\n\t\tif (typeof message === \"string\" && message.length > 0) return message;\n\t}\n\tif (typeof body === \"string\" && body.length > 0) return body;\n\treturn fallback;\n}\n\nasync function mapStreamsError(response: Response): Promise<never> {\n\tconst body = await responseBody(response);\n\n\tif (response.status === 401) {\n\t\tthrow new AuthError(errorMessage(body, \"API key invalid or expired.\"));\n\t}\n\n\tif (response.status === 429) {\n\t\tconst retryAfter = response.headers.get(\"Retry-After\") ?? undefined;\n\t\tthrow new RateLimitError(\n\t\t\terrorMessage(body, \"Rate limited. Try again later.\"),\n\t\t\tretryAfter,\n\t\t);\n\t}\n\n\tif (response.status >= 500) {\n\t\tthrow new StreamsServerError(\n\t\t\terrorMessage(body, `Streams server returned ${response.status}.`),\n\t\t\tresponse.status,\n\t\t\tbody,\n\t\t);\n\t}\n\n\tthrow new ValidationError(\n\t\terrorMessage(body, `Streams request returned ${response.status}.`),\n\t\tresponse.status,\n\t\tbody,\n\t);\n}\n\nexport function createStreamsClient(\n\toptions: CreateStreamsClientOptions,\n): StreamsClient {\n\tconst baseUrl = normalizeBaseUrl(options.baseUrl ?? DEFAULT_STREAMS_BASE_URL);\n\tconst fetchImpl = options.fetchImpl ?? ((input, init) => fetch(input, init));\n\tconst verify = options.verify ?? false;\n\n\t// Lazily resolve and cache the verification key alongside its id, so a\n\t// rotation (signalled by a changed `X-Signature-KeyId`) can be detected.\n\ttype VerificationKey = {\n\t\tkeyId: string;\n\t\tpublicKeyPem: string;\n\t\tpublicKey: ReturnType<typeof ed25519.loadEd25519PublicKey>;\n\t};\n\tlet keyPromise: Promise<VerificationKey> | null = null;\n\tfunction loadKey(): Promise<VerificationKey> {\n\t\tif (keyPromise) return keyPromise;\n\t\tkeyPromise = (async () => {\n\t\t\tif (typeof verify === \"object\") {\n\t\t\t\treturn {\n\t\t\t\t\tkeyId: ed25519.ed25519KeyId(verify.publicKey),\n\t\t\t\t\tpublicKeyPem: verify.publicKey,\n\t\t\t\t\tpublicKey: ed25519.loadEd25519PublicKey(verify.publicKey),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst res = await fetchImpl(`${baseUrl}/public/streams/signing-key`);\n\t\t\tif (!res.ok) {\n\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t`Could not fetch signing key (${res.status}).`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst body = (await res.json()) as {\n\t\t\t\tpublic_key_pem?: string;\n\t\t\t\tkey_id?: string;\n\t\t\t};\n\t\t\tif (!body.public_key_pem) {\n\t\t\t\tthrow new StreamsSignatureError(\"Signing key response missing key.\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkeyId: body.key_id ?? ed25519.ed25519KeyId(body.public_key_pem),\n\t\t\t\tpublicKeyPem: body.public_key_pem,\n\t\t\t\tpublicKey: ed25519.loadEd25519PublicKey(body.public_key_pem),\n\t\t\t};\n\t\t})();\n\t\treturn keyPromise;\n\t}\n\n\tconst dumps = createStreamsDumps({\n\t\tbaseUrl: options.dumpsBaseUrl,\n\t\tfetchImpl,\n\t\tverifyManifest: options.verifyDumpsManifest ?? true,\n\t\tloadPublicKeyPem: async () => (await loadKey()).publicKeyPem,\n\t});\n\n\tasync function request<T>(path: string): Promise<T> {\n\t\tconst response = await fetchImpl(`${baseUrl}${path}`, {\n\t\t\theaders: { Authorization: `Bearer ${options.apiKey}` },\n\t\t});\n\t\tif (!response.ok) await mapStreamsError(response);\n\t\tconst text = await response.text();\n\t\tif (verify) {\n\t\t\tconst signature = response.headers.get(\"X-Signature\");\n\t\t\tif (!signature) {\n\t\t\t\tthrow new StreamsSignatureError(\"Response is missing X-Signature.\");\n\t\t\t}\n\t\t\tconst responseKeyId = response.headers.get(\"X-Signature-KeyId\");\n\t\t\tlet key = await loadKey();\n\t\t\t// The server rotated to a key we haven't seen.\n\t\t\tif (responseKeyId && responseKeyId !== key.keyId) {\n\t\t\t\tif (typeof verify === \"object\") {\n\t\t\t\t\t// Pinned key: a different id is never the pinned key — fail closed.\n\t\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\t`Response signed with key '${responseKeyId}', expected pinned key '${key.keyId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Fetched key: refresh once. A still-mismatched id (no re-loop)\n\t\t\t\t// means the endpoint doesn't serve the signing key — fail closed.\n\t\t\t\tkeyPromise = null;\n\t\t\t\tkey = await loadKey();\n\t\t\t\tif (responseKeyId !== key.keyId) {\n\t\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\t`Response signed with key '${responseKeyId}' not served by the signing-key endpoint.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!ed25519.verifyEd25519(text, signature, key.publicKey)) {\n\t\t\t\tthrow new StreamsSignatureError();\n\t\t\t}\n\t\t}\n\t\treturn JSON.parse(text) as T;\n\t}\n\n\tconst fetchEvents: StreamsEventsFetcher = async ({\n\t\tcursor,\n\t\tlimit,\n\t\ttypes,\n\t\tnotTypes,\n\t\tcontractId,\n\t\tsender,\n\t\trecipient,\n\t\tassetIdentifier,\n\t}) => {\n\t\treturn listEvents({\n\t\t\tcursor,\n\t\t\tlimit,\n\t\t\ttypes,\n\t\t\tnotTypes,\n\t\t\tcontractId,\n\t\t\tsender,\n\t\t\trecipient,\n\t\t\tassetIdentifier,\n\t\t});\n\t};\n\n\tasync function listEvents(\n\t\tparams: StreamsEventsListParams = {},\n\t): Promise<StreamsEventsEnvelope> {\n\t\treturn request<StreamsEventsEnvelope>(\n\t\t\t`/v1/streams/events${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\ttypes: params.types,\n\t\t\t\tnot_types: params.notTypes,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\treturn {\n\t\tconsume(params: StreamsConsumeParams = {}) {\n\t\t\treturn iterateStreamsBatches({\n\t\t\t\tfromCursor: params.cursor,\n\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\tintervalMs: params.intervalMs ?? 2000,\n\t\t\t\ttypes: params.types,\n\t\t\t\tnotTypes: params.notTypes,\n\t\t\t\tcontractId: params.contractId,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\tsignal: params.signal,\n\t\t\t\tfetchEvents,\n\t\t\t});\n\t\t},\n\t\tevents: {\n\t\t\tlist: listEvents,\n\t\t\tbyTxId(txId: string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/events/${encodeURIComponent(txId)}`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tconsume(params: StreamsEventsConsumeParams) {\n\t\t\t\treturn consumeStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\tmode: params.mode,\n\t\t\t\t\tfinalizedOnly: params.finalizedOnly,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tnotTypes: params.notTypes,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tsender: params.sender,\n\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t\tonBatch: params.onBatch,\n\t\t\t\t\tonReorg: params.onReorg,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t});\n\t\t\t},\n\t\t\tstream(params: StreamsEventsStreamParams = {}) {\n\t\t\t\treturn streamStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tnotTypes: params.notTypes,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tsender: params.sender,\n\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t});\n\t\t\t},\n\t\t\tsubscribe(params: StreamsEventsSubscribeParams) {\n\t\t\t\treturn subscribeStreamsEvents({\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\tapiKey: options.apiKey,\n\t\t\t\t\tfetchImpl,\n\t\t\t\t\tverify: Boolean(verify),\n\t\t\t\t\tloadKey,\n\t\t\t\t\tparams,\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync replay(params: StreamsEventsReplayParams) {\n\t\t\t\tconst fromCursor =\n\t\t\t\t\tparams.from === \"genesis\" ? null : (params.from ?? null);\n\t\t\t\tconst fromBlock = fromCursor ? cursorTuple(fromCursor)[0] : 0;\n\t\t\t\tconst manifest = await dumps.list();\n\n\t\t\t\t// Hydrate finalized history from dumps, in block order.\n\t\t\t\tconst files = manifest.files\n\t\t\t\t\t.filter((file) => file.to_block >= fromBlock)\n\t\t\t\t\t.sort(\n\t\t\t\t\t\t(a, b) => a.from_block - b.from_block || a.to_block - b.to_block,\n\t\t\t\t\t);\n\t\t\t\tfor (const file of files) {\n\t\t\t\t\tif (params.signal?.aborted) break;\n\t\t\t\t\tawait params.onDumpFile(file);\n\t\t\t\t}\n\n\t\t\t\t// Seam: tail live from just past the dumped coverage. Cursor input is\n\t\t\t\t// exclusive, so the first live event is strictly after the last dump.\n\t\t\t\tconst seam = maxCursor(fromCursor, manifest.latest_finalized_cursor);\n\t\t\t\treturn consumeStreamsEvents({\n\t\t\t\t\tfromCursor: seam,\n\t\t\t\t\tmode: params.mode ?? \"tail\",\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t\tonBatch: params.onBatch,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\tblocks: {\n\t\t\tevents(heightOrHash: number | string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/blocks/${encodeURIComponent(String(heightOrHash))}/events`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\treorgs: {\n\t\t\tlist(params: StreamsReorgsListParams) {\n\t\t\t\treturn request<StreamsReorgsListEnvelope>(\n\t\t\t\t\t`/v1/streams/reorgs${buildQuery({\n\t\t\t\t\t\tsince: params.since,\n\t\t\t\t\t\tlimit: params.limit,\n\t\t\t\t\t})}`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tdumps,\n\t\tcanonical(height: number) {\n\t\t\treturn request<StreamsCanonicalBlock>(`/v1/streams/canonical/${height}`);\n\t\t},\n\t\ttip() {\n\t\t\treturn request<StreamsTip>(\"/v1/streams/tip\");\n\t\t},\n\t\tusage() {\n\t\t\treturn request<StreamsUsage>(\"/v1/streams/usage\");\n\t\t},\n\t};\n}\n",
|
|
14
11
|
"export class AuthError extends Error {\n\treadonly status = 401;\n\n\tconstructor(message = \"API key invalid or expired.\") {\n\t\tsuper(message);\n\t\tthis.name = \"AuthError\";\n\t}\n}\n\nexport class RateLimitError extends Error {\n\treadonly status = 429;\n\n\tconstructor(\n\t\tmessage = \"Rate limited. Try again later.\",\n\t\treadonly retryAfter?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"RateLimitError\";\n\t}\n}\n\nexport class ValidationError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly status: number,\n\t\treadonly body?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ValidationError\";\n\t}\n}\n\nexport class StreamsServerError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly status: number,\n\t\treadonly body?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"StreamsServerError\";\n\t}\n}\n\n/** Thrown when response signature verification is enabled and fails. */\nexport class StreamsSignatureError extends Error {\n\tconstructor(message = \"Streams response signature verification failed.\") {\n\t\tsuper(message);\n\t\tthis.name = \"StreamsSignatureError\";\n\t}\n}\n",
|
|
15
12
|
"import { ValidationError } from \"./errors.ts\";\n\n/**\n * Helpers for Streams cursors. A cursor is the opaque `<block>:<index>` string\n * that marks a position in the event stream; treat the format as an\n * implementation detail and go through these helpers instead of string-building\n * it at call sites.\n */\nexport const Cursor = {\n\t/**\n\t * Cursor at the foot of `height`. Resuming from it re-reads every event\n\t * strictly above block `height` (cursors are exclusive), so this is the\n\t * position to rewind to after a reorg whose fork point is `height`.\n\t */\n\tatHeight(height: number): string {\n\t\treturn `${height}:0`;\n\t},\n\n\t/** Parse a `<block>:<index>` cursor. Throws `ValidationError` if malformed. */\n\tparse(cursor: string): { blockHeight: number; eventIndex: number } {\n\t\tconst parts = cursor.split(\":\");\n\t\tconst blockHeight = Number(parts[0]);\n\t\tconst eventIndex = Number(parts[1]);\n\t\tif (\n\t\t\tparts.length !== 2 ||\n\t\t\t!Number.isInteger(blockHeight) ||\n\t\t\t!Number.isInteger(eventIndex)\n\t\t) {\n\t\t\tthrow new ValidationError(\n\t\t\t\t`Invalid stream cursor \"${cursor}\"; expected \"<block>:<index>\" (e.g. \"951475:3\").`,\n\t\t\t\t400,\n\t\t\t);\n\t\t}\n\t\treturn { blockHeight, eventIndex };\n\t},\n};\n",
|
|
16
13
|
"import { Cursor } from \"./cursor.ts\";\nimport type {\n\tStreamsBatch,\n\tStreamsEvent,\n\tStreamsEventType,\n\tStreamsEventsEnvelope,\n\tStreamsFilterValue,\n\tStreamsReorg,\n} from \"./types.ts\";\n\n/** Stable identity of a reorg, for in-memory dedup across re-reported pages. */\nfunction reorgKey(reorg: StreamsReorg): string {\n\treturn `${reorg.detected_at}|${reorg.fork_point_height}|${reorg.new_canonical_tip}`;\n}\n\ntype StreamsEventsFetchParams = {\n\tcursor?: string | null;\n\tlimit: number;\n\ttypes?: readonly StreamsEventType[];\n\tnotTypes?: readonly StreamsEventType[];\n\tcontractId?: StreamsFilterValue;\n\tsender?: StreamsFilterValue;\n\trecipient?: StreamsFilterValue;\n\tassetIdentifier?: string;\n};\n\nexport type StreamsEventsFetcher = (\n\tparams: StreamsEventsFetchParams,\n) => Promise<StreamsEventsEnvelope>;\n\nexport type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;\n\nexport async function defaultSleep(\n\tms: number,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tif (signal?.aborted) return;\n\n\tawait new Promise<void>((resolve) => {\n\t\tconst timeout = setTimeout(resolve, ms);\n\t\tif (!signal) return;\n\t\tsignal.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tresolve();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t});\n}\n\nexport async function consumeStreamsEvents(opts: {\n\tfromCursor?: string | null;\n\tmode?: \"tail\" | \"bounded\";\n\tfinalizedOnly?: boolean;\n\tbatchSize: number;\n\ttypes?: readonly StreamsEventType[];\n\tnotTypes?: readonly StreamsEventType[];\n\tcontractId?: StreamsFilterValue;\n\tsender?: StreamsFilterValue;\n\trecipient?: StreamsFilterValue;\n\tassetIdentifier?: string;\n\tfetchEvents: StreamsEventsFetcher;\n\tonBatch: (\n\t\tevents: StreamsEvent[],\n\t\tenvelope: StreamsEventsEnvelope,\n\t\tctx: { cursor: string | null },\n\t) =>\n\t\t| void\n\t\t| string\n\t\t| null\n\t\t| undefined\n\t\t| Promise<void>\n\t\t| Promise<string | null | undefined>;\n\tonReorg?: (\n\t\treorg: StreamsReorg,\n\t\tctx: { cursor: string },\n\t) => Promise<void> | void;\n\tsleep?: Sleep;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n}): Promise<{ cursor: string | null; pages: number; emptyPolls: number }> {\n\tconst sleep = opts.sleep ?? defaultSleep;\n\tconst mode = opts.mode ?? \"tail\";\n\tconst finalizedOnly = opts.finalizedOnly ?? false;\n\tconst emptyBackoffMs = opts.emptyBackoffMs ?? 500;\n\tconst maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;\n\tconst maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;\n\tlet cursor = opts.fromCursor ?? null;\n\t// In-memory only: rollback is idempotent, so a crash before the rewind is\n\t// re-detected and re-applied harmlessly on restart — no need to persist.\n\tconst handledReorgs = new Set<string>();\n\tlet pages = 0;\n\tlet emptyPolls = 0;\n\n\twhile (\n\t\tpages < maxPages &&\n\t\temptyPolls < maxEmptyPolls &&\n\t\t!opts.signal?.aborted\n\t) {\n\t\tconst envelope = await opts.fetchEvents({\n\t\t\tcursor,\n\t\t\tlimit: opts.batchSize,\n\t\t\ttypes: opts.types,\n\t\t\tnotTypes: opts.notTypes,\n\t\t\tcontractId: opts.contractId,\n\t\t\tsender: opts.sender,\n\t\t\trecipient: opts.recipient,\n\t\t\tassetIdentifier: opts.assetIdentifier,\n\t\t});\n\t\tpages++;\n\n\t\t// Reorgs: roll back each new fork, then rewind to the lowest fork point\n\t\t// and re-read the now-canonical run. Finalized data never reorgs, so\n\t\t// `finalizedOnly` skips this entirely.\n\t\tif (!finalizedOnly && opts.onReorg) {\n\t\t\tconst fresh = envelope.reorgs\n\t\t\t\t.filter((reorg) => !handledReorgs.has(reorgKey(reorg)))\n\t\t\t\t.sort((a, b) => a.fork_point_height - b.fork_point_height);\n\t\t\tif (fresh.length > 0) {\n\t\t\t\tconst forkPoint = Math.min(\n\t\t\t\t\t...fresh.map((reorg) => reorg.fork_point_height),\n\t\t\t\t);\n\t\t\t\tconst rewind = Cursor.atHeight(forkPoint);\n\t\t\t\tfor (const reorg of fresh) {\n\t\t\t\t\tawait opts.onReorg(reorg, { cursor: rewind });\n\t\t\t\t\thandledReorgs.add(reorgKey(reorg));\n\t\t\t\t}\n\t\t\t\tcursor = rewind;\n\t\t\t\temptyPolls = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tconst emitted = finalizedOnly\n\t\t\t? envelope.events.filter((event) => event.finalized)\n\t\t\t: envelope.events;\n\t\t// Only advance to the last finalized event in finalizedOnly mode; the\n\t\t// unfinalized tail is re-read next poll until it settles.\n\t\tconst checkpoint = finalizedOnly\n\t\t\t? (emitted.at(-1)?.cursor ?? cursor)\n\t\t\t: envelope.next_cursor;\n\n\t\tconst returnedCursor = await opts.onBatch(emitted, envelope, {\n\t\t\tcursor: checkpoint,\n\t\t});\n\t\tconst nextCursor = returnedCursor ?? checkpoint;\n\n\t\tif (nextCursor && nextCursor !== cursor) {\n\t\t\tcursor = nextCursor;\n\t\t\temptyPolls = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (emitted.length === 0) {\n\t\t\temptyPolls++;\n\t\t\tif (mode === \"bounded\") {\n\t\t\t\treturn { cursor, pages, emptyPolls };\n\t\t\t}\n\t\t\tawait sleep(emptyBackoffMs, opts.signal);\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn { cursor, pages, emptyPolls };\n\t}\n\n\treturn { cursor, pages, emptyPolls };\n}\n\n/**\n * Async-iterator form of the Streams pull loop, yielding one {@link StreamsBatch}\n * per fetched page. Each yield maps 1:1 onto a `GET /v1/streams/events` envelope\n * (`{ events, next_cursor, tip, reorgs }` → `{ events, cursor, tip, reorgs }`) —\n * no extra API calls, no regrouping. Pages with no events and no reorgs are not\n * yielded; the iterator sleeps `intervalMs` and re-polls the tip instead.\n */\nexport async function* iterateStreamsBatches(opts: {\n\tfromCursor?: string | null;\n\tbatchSize: number;\n\tintervalMs: number;\n\ttypes?: readonly StreamsEventType[];\n\tnotTypes?: readonly StreamsEventType[];\n\tcontractId?: StreamsFilterValue;\n\tsender?: StreamsFilterValue;\n\trecipient?: StreamsFilterValue;\n\tassetIdentifier?: string;\n\tfetchEvents: StreamsEventsFetcher;\n\tsleep?: Sleep;\n\tsignal?: AbortSignal;\n}): AsyncGenerator<StreamsBatch> {\n\tconst sleep = opts.sleep ?? defaultSleep;\n\tlet cursor = opts.fromCursor ?? null;\n\n\twhile (!opts.signal?.aborted) {\n\t\tconst envelope = await opts.fetchEvents({\n\t\t\tcursor,\n\t\t\tlimit: opts.batchSize,\n\t\t\ttypes: opts.types,\n\t\t\tnotTypes: opts.notTypes,\n\t\t\tcontractId: opts.contractId,\n\t\t\tsender: opts.sender,\n\t\t\trecipient: opts.recipient,\n\t\t\tassetIdentifier: opts.assetIdentifier,\n\t\t});\n\n\t\tconst checkpoint = envelope.next_cursor ?? cursor;\n\t\tif (envelope.events.length > 0 || envelope.reorgs.length > 0) {\n\t\t\tyield {\n\t\t\t\tevents: envelope.events,\n\t\t\t\tcursor: checkpoint,\n\t\t\t\ttip: envelope.tip,\n\t\t\t\treorgs: envelope.reorgs,\n\t\t\t};\n\t\t}\n\n\t\tconst advanced = checkpoint !== null && checkpoint !== cursor;\n\t\tcursor = checkpoint;\n\t\t// Caught up at the tip: wait one poll interval before re-reading.\n\t\tif (!advanced && envelope.events.length === 0) {\n\t\t\tif (opts.signal?.aborted) return;\n\t\t\tawait sleep(opts.intervalMs, opts.signal);\n\t\t}\n\t}\n}\n\nexport async function* streamStreamsEvents(opts: {\n\tfromCursor?: string | null;\n\tbatchSize: number;\n\ttypes?: readonly StreamsEventType[];\n\tnotTypes?: readonly StreamsEventType[];\n\tcontractId?: StreamsFilterValue;\n\tsender?: StreamsFilterValue;\n\trecipient?: StreamsFilterValue;\n\tassetIdentifier?: string;\n\tfetchEvents: StreamsEventsFetcher;\n\tsleep?: Sleep;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n}): AsyncGenerator<StreamsEvent> {\n\tconst sleep = opts.sleep ?? defaultSleep;\n\tconst emptyBackoffMs = opts.emptyBackoffMs ?? 500;\n\tconst maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;\n\tconst maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;\n\tlet cursor = opts.fromCursor ?? null;\n\tlet pages = 0;\n\tlet emptyPolls = 0;\n\n\twhile (\n\t\tpages < maxPages &&\n\t\temptyPolls < maxEmptyPolls &&\n\t\t!opts.signal?.aborted\n\t) {\n\t\tconst envelope = await opts.fetchEvents({\n\t\t\tcursor,\n\t\t\tlimit: opts.batchSize,\n\t\t\ttypes: opts.types,\n\t\t\tnotTypes: opts.notTypes,\n\t\t\tcontractId: opts.contractId,\n\t\t\tsender: opts.sender,\n\t\t\trecipient: opts.recipient,\n\t\t\tassetIdentifier: opts.assetIdentifier,\n\t\t});\n\t\tpages++;\n\n\t\tfor (const event of envelope.events) {\n\t\t\tif (opts.signal?.aborted) return;\n\t\t\tyield event;\n\t\t}\n\n\t\tconst nextCursor = envelope.next_cursor;\n\t\tif (nextCursor && nextCursor !== cursor) {\n\t\t\tcursor = nextCursor;\n\t\t\temptyPolls = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (envelope.events.length === 0) {\n\t\t\temptyPolls++;\n\t\t\tif (emptyPolls >= maxEmptyPolls || pages >= maxPages) return;\n\t\t\tawait sleep(emptyBackoffMs, opts.signal);\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn;\n\t}\n}\n",
|
|
14
|
+
"import { type Sleep, defaultSleep } from \"../streams/consumer.ts\";\nimport { Cursor } from \"../streams/cursor.ts\";\nimport type { IndexReorg, IndexTip } from \"./client.ts\";\n\n/** Minimum shape a consumed Index row must expose. */\nexport type IndexFeedItem = { cursor: string; block_height: number };\n\n/** Minimum envelope shape of a consumable Index feed page. */\nexport type IndexFeedEnvelope = {\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\treorgs: IndexReorg[];\n};\n\n/** One page fetch. `fromHeight` is only set on the first page of a fresh\n * consume (no cursor yet) — cursor and from_height are mutually exclusive\n * on the API. */\nexport type IndexFeedFetcher<TEnvelope extends IndexFeedEnvelope> = (params: {\n\tcursor: string | null;\n\tfromHeight?: number;\n\tlimit: number;\n}) => Promise<TEnvelope>;\n\n/** Consumer options shared by `index.events.consume` and\n * `index.contractCalls.consume`. Same contract as the Streams consumer:\n * commit your writes inside `onBatch`, return the cursor you committed. */\nexport type IndexConsumeOptions<\n\tTItem extends IndexFeedItem,\n\tTEnvelope extends IndexFeedEnvelope,\n> = {\n\t/** Resume from a committed checkpoint. Without it (and without\n\t * `fromHeight`) the API serves only the recent default window. */\n\tfromCursor?: string | null;\n\t/** Start a fresh sweep at this height (e.g. `0` for genesis backfill).\n\t * Ignored once a cursor exists. */\n\tfromHeight?: number;\n\t/** `tail` (default) keeps polling at the tip; `bounded` returns on the\n\t * first empty page. */\n\tmode?: \"tail\" | \"bounded\";\n\t/** Emit only rows at or below the tip's `finalized_height`; the\n\t * unfinalized tail is re-read each poll until it settles. Finalized data\n\t * never reorgs, so `onReorg` is skipped entirely. */\n\tfinalizedOnly?: boolean;\n\tbatchSize?: number;\n\tonBatch: (\n\t\titems: TItem[],\n\t\tenvelope: TEnvelope,\n\t\tctx: { cursor: string | null },\n\t) =>\n\t\t| void\n\t\t| string\n\t\t| null\n\t\t| undefined\n\t\t| Promise<void>\n\t\t| Promise<string | null | undefined>;\n\tonReorg?: (\n\t\treorg: IndexReorg,\n\t\tctx: { cursor: string },\n\t) => Promise<void> | void;\n\tsleep?: Sleep;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n};\n\n/**\n * Checkpointed pull loop over a cursor-paginated Index feed — the Index port\n * of `consumeStreamsEvents`, sharing its contract: at-least-once delivery,\n * client-owned checkpoints (`onBatch` may return the cursor it committed),\n * and automatic reorg rewind to the lowest fresh fork point.\n *\n * Differs from Streams in how finality is read: Index rows carry no\n * per-event `finalized` flag, so `finalizedOnly` gates by\n * `block_height <= tip.finalized_height` instead.\n */\nexport async function consumeIndexFeed<\n\tTItem extends IndexFeedItem,\n\tTEnvelope extends IndexFeedEnvelope,\n>(\n\topts: IndexConsumeOptions<TItem, TEnvelope> & {\n\t\tfetchPage: IndexFeedFetcher<TEnvelope>;\n\t\titemsOf: (envelope: TEnvelope) => TItem[];\n\t},\n): Promise<{ cursor: string | null; pages: number; emptyPolls: number }> {\n\tconst sleep = opts.sleep ?? defaultSleep;\n\tconst mode = opts.mode ?? \"tail\";\n\tconst finalizedOnly = opts.finalizedOnly ?? false;\n\tconst batchSize = opts.batchSize ?? 200;\n\tconst emptyBackoffMs = opts.emptyBackoffMs ?? 500;\n\tconst maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;\n\tconst maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;\n\tlet cursor = opts.fromCursor ?? null;\n\t// In-memory only: rollback is idempotent, so a crash before the rewind is\n\t// re-detected and re-applied harmlessly on restart — no need to persist.\n\tconst handledReorgs = new Set<string>();\n\tlet pages = 0;\n\tlet emptyPolls = 0;\n\n\twhile (\n\t\tpages < maxPages &&\n\t\temptyPolls < maxEmptyPolls &&\n\t\t!opts.signal?.aborted\n\t) {\n\t\tconst envelope = await opts.fetchPage({\n\t\t\tcursor,\n\t\t\tfromHeight: cursor === null ? opts.fromHeight : undefined,\n\t\t\tlimit: batchSize,\n\t\t});\n\t\tpages++;\n\n\t\t// Reorgs: roll back each new fork, then rewind to the lowest fork point\n\t\t// and re-read the now-canonical run. Finalized data never reorgs, so\n\t\t// `finalizedOnly` skips this entirely.\n\t\tif (!finalizedOnly && opts.onReorg) {\n\t\t\tconst fresh = envelope.reorgs\n\t\t\t\t.filter((reorg) => !handledReorgs.has(reorg.id))\n\t\t\t\t.sort((a, b) => a.fork_point_height - b.fork_point_height);\n\t\t\tif (fresh.length > 0) {\n\t\t\t\tconst forkPoint = Math.min(\n\t\t\t\t\t...fresh.map((reorg) => reorg.fork_point_height),\n\t\t\t\t);\n\t\t\t\tconst rewind = Cursor.atHeight(forkPoint);\n\t\t\t\tfor (const reorg of fresh) {\n\t\t\t\t\tawait opts.onReorg(reorg, { cursor: rewind });\n\t\t\t\t\thandledReorgs.add(reorg.id);\n\t\t\t\t}\n\t\t\t\tcursor = rewind;\n\t\t\t\temptyPolls = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tconst items = opts.itemsOf(envelope);\n\t\tconst emitted = finalizedOnly\n\t\t\t? items.filter(\n\t\t\t\t\t(item) => item.block_height <= envelope.tip.finalized_height,\n\t\t\t\t)\n\t\t\t: items;\n\t\t// Only advance to the last finalized row in finalizedOnly mode; the\n\t\t// unfinalized tail is re-read next poll until it settles.\n\t\tconst checkpoint = finalizedOnly\n\t\t\t? (emitted.at(-1)?.cursor ?? cursor)\n\t\t\t: envelope.next_cursor;\n\n\t\tconst returnedCursor = await opts.onBatch(emitted, envelope, {\n\t\t\tcursor: checkpoint,\n\t\t});\n\t\tconst nextCursor = returnedCursor ?? checkpoint;\n\n\t\tif (nextCursor && nextCursor !== cursor) {\n\t\t\tcursor = nextCursor;\n\t\t\temptyPolls = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (emitted.length === 0) {\n\t\t\temptyPolls++;\n\t\t\tif (mode === \"bounded\") {\n\t\t\t\treturn { cursor, pages, emptyPolls };\n\t\t\t}\n\t\t\tawait sleep(emptyBackoffMs, opts.signal);\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn { cursor, pages, emptyPolls };\n\t}\n\n\treturn { cursor, pages, emptyPolls };\n}\n",
|
|
15
|
+
"import type { InferredTopicSchema } from \"@secondlayer/subgraphs\";\nimport { BaseClient, buildQuery } from \"../base.ts\";\nimport type { SecondLayerOptions } from \"../base.ts\";\nimport { ApiError } from \"../errors.ts\";\nimport type { TransactionProof } from \"../proofs.ts\";\nimport { type IndexConsumeOptions, consumeIndexFeed } from \"./consumer.ts\";\n\nexport type IndexTip = {\n\tblock_height: number;\n\t/** Highest height treated as immutable (past the burn-confirmation\n\t * finality boundary). Rows at or below it never reorg — `finalizedOnly`\n\t * consumers gate on this, since Index rows carry no per-event flag. */\n\tfinalized_height: number;\n\tlag_seconds: number;\n};\n\n/**\n * A chain reorg overlapping a returned page's height range. Height-keyed feeds\n * (`/transactions`, `/contract-calls`, `/stacking`) populate this so a consumer\n * can reconcile: roll back the rows whose `block_height:tx_index` cursor falls in\n * `orphaned_range`, then re-fetch from `new_canonical_tip`. Empty when the page\n * spans no reorg.\n */\nexport type IndexReorg = {\n\tid: string;\n\tdetected_at: string;\n\tfork_point_height: number;\n\told_index_block_hash: string | null;\n\tnew_index_block_hash: string | null;\n\t/** Orphaned cursor span `<block_height>:<tx_index>`, inclusive. */\n\torphaned_range: { from: string; to: string };\n\t/** New canonical tip cursor to resume from. */\n\tnew_canonical_tip: string;\n};\n\nexport type IndexUsage = {\n\tproduct: \"index\";\n\ttier: string;\n\tlimits: { rate_limit_per_second: number | null };\n\tusage: { decoded_events_today: number; decoded_events_this_month: number };\n};\n\nexport type FtTransfer = {\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\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type FtTransfersEnvelope = {\n\tevents: FtTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n};\n\nexport type FtTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type FtTransfersWalkParams = Omit<FtTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nexport type NftTransfer = {\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\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type NftTransfersEnvelope = {\n\tevents: NftTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n};\n\nexport type NftTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tassetIdentifier?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type NftTransfersWalkParams = Omit<NftTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Generic decoded events (/v1/index/events) ──────────────────────\n\ntype IndexEventBase = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tcontract_id: string | null;\n};\n\nexport type IndexFtTransfer = IndexEventBase & {\n\tevent_type: \"ft_transfer\";\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexNftTransfer = IndexEventBase & {\n\tevent_type: \"nft_transfer\";\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\nexport type IndexStxTransfer = IndexEventBase & {\n\tevent_type: \"stx_transfer\";\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n\tmemo: string | null;\n};\nexport type IndexStxMint = IndexEventBase & {\n\tevent_type: \"stx_mint\";\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexStxBurn = IndexEventBase & {\n\tevent_type: \"stx_burn\";\n\tsender: string;\n\tamount: string;\n};\nexport type IndexStxLock = IndexEventBase & {\n\tevent_type: \"stx_lock\";\n\tsender: string;\n\tamount: string;\n\tpayload: { unlock_height: string | null };\n};\nexport type IndexFtMint = IndexEventBase & {\n\tevent_type: \"ft_mint\";\n\tasset_identifier: string;\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexFtBurn = IndexEventBase & {\n\tevent_type: \"ft_burn\";\n\tasset_identifier: string;\n\tsender: string;\n\tamount: string;\n};\nexport type IndexNftMint = IndexEventBase & {\n\tevent_type: \"nft_mint\";\n\tasset_identifier: string;\n\trecipient: string;\n\tvalue: string;\n};\nexport type IndexNftBurn = IndexEventBase & {\n\tevent_type: \"nft_burn\";\n\tasset_identifier: string;\n\tsender: string;\n\tvalue: string;\n};\nexport type IndexPrint = IndexEventBase & {\n\tevent_type: \"print\";\n\tpayload: { topic: string | null; value: unknown; raw_value: string | null };\n};\n\n/** Decoded chain event, discriminated by `event_type`. */\nexport type IndexEvent =\n\t| IndexFtTransfer\n\t| IndexNftTransfer\n\t| IndexStxTransfer\n\t| IndexStxMint\n\t| IndexStxBurn\n\t| IndexStxLock\n\t| IndexFtMint\n\t| IndexFtBurn\n\t| IndexNftMint\n\t| IndexNftBurn\n\t| IndexPrint;\n\nexport type IndexEventType = IndexEvent[\"event_type\"];\n\nexport type EventsEnvelope = {\n\tevents: IndexEvent[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n};\n\nexport type EventsListParams = {\n\t/** Required. One of the decoded event types. */\n\teventType: IndexEventType;\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tassetIdentifier?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n\t/** Restrict to contracts conforming to a trait/standard (e.g. \"sip-010\").\n\t * Mutually exclusive with contractId; contract-keyed event types only. */\n\ttrait?: string;\n};\n\nexport type EventsWalkParams = Omit<EventsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nexport type EventsConsumeParams = Omit<\n\tEventsListParams,\n\t\"cursor\" | \"fromCursor\" | \"limit\"\n> &\n\tIndexConsumeOptions<IndexEvent, EventsEnvelope>;\n\n// ── Contract calls (/v1/index/contract-calls) ──────────────────────\n\nexport type IndexContractCall = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_id: string;\n\ttx_index: number;\n\tcontract_id: string;\n\tfunction_name: string;\n\tsender: string;\n\tstatus: string;\n\targs: unknown[];\n\tresult: unknown;\n\tresult_hex: string | null;\n};\n\nexport type ContractCallsEnvelope = {\n\tcontract_calls: IndexContractCall[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n};\n\nexport type ContractCallsListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tfunctionName?: string;\n\tsender?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n\t/** Restrict to contracts conforming to a trait/standard (e.g. \"sip-010\").\n\t * Mutually exclusive with contractId. */\n\ttrait?: string;\n};\n\nexport type ContractCallsWalkParams = Omit<ContractCallsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nexport type ContractCallsConsumeParams = Omit<\n\tContractCallsListParams,\n\t\"cursor\" | \"fromCursor\" | \"limit\"\n> &\n\tIndexConsumeOptions<IndexContractCall, ContractCallsEnvelope>;\n\n// ── Canonical block-hash map (/v1/index/canonical) ─────────────────\n\n/** One canonical block in the sync map. Lean by design — block + parent hash\n * for chain linkage, burn anchor for Bitcoin confirmations. Use `blocks` for\n * the full block resource. */\nexport type IndexCanonicalBlock = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string | null;\n};\n\nexport type CanonicalEnvelope = {\n\tcanonical: IndexCanonicalBlock[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type CanonicalListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type CanonicalWalkParams = Omit<CanonicalListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Blocks (/v1/index/blocks) ──────────────────────────────────────\n\n/** A block resource. Metadata is intentionally thin — only chain-linkage and\n * burn-anchor fields are persisted (no miner / tx_count / signer). */\nexport type IndexBlock = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string | null;\n\tblock_time: string | null;\n\tcanonical: boolean;\n};\n\nexport type BlocksEnvelope = {\n\tblocks: IndexBlock[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type BlockEnvelope = {\n\tblock: IndexBlock;\n\ttip: IndexTip;\n};\n\nexport type BlocksListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type BlocksWalkParams = Omit<BlocksListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Transactions (/v1/index/transactions) ──────────────────────────\n\nexport type IndexPostCondition =\n\t| {\n\t\t\ttype: \"stx\";\n\t\t\tprincipal: string;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t\t\tamount: string;\n\t }\n\t| {\n\t\t\ttype: \"ft\";\n\t\t\tprincipal: string;\n\t\t\tasset_identifier: string;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t\t\tamount: string;\n\t }\n\t| {\n\t\t\ttype: \"nft\";\n\t\t\tprincipal: string;\n\t\t\tasset_identifier: string;\n\t\t\tasset_value: unknown;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t };\n\n/** Full transaction document: columnar fields plus `raw_tx`-decoded enrichment.\n * Payload sub-objects are present only for the matching `tx_type`; enrichment\n * fields are null when `raw_tx` isn't decodable (e.g. burnchain ops). */\nexport type IndexTransaction = {\n\tcursor: string;\n\ttx_id: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_index: number;\n\ttx_type: string;\n\tsender: string;\n\tstatus: string;\n\tfee: string | null;\n\tnonce: string | null;\n\tsponsored: boolean | null;\n\tanchor_mode: string | null;\n\tpost_condition_mode: string | null;\n\tpost_conditions: IndexPostCondition[];\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t\t/** Raw hex-encoded ClarityValues; decode(function_args_hex[i]) === function_args[i]. */\n\t\tfunction_args_hex: string[];\n\t\tresult: unknown;\n\t\tresult_hex: string | null;\n\t};\n\ttoken_transfer?: { recipient: string; amount: string; memo: string };\n\tsmart_contract?: {\n\t\tcontract_id: string | null;\n\t\tclarity_version: number | null;\n\t};\n\tcoinbase?: { alt_recipient: string | null };\n\ttenure_change?: { cause: number };\n};\n\nexport type TransactionsEnvelope = {\n\ttransactions: IndexTransaction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n};\n\nexport type TransactionEnvelope = {\n\ttransaction: IndexTransaction;\n\ttip: IndexTip;\n};\n\nexport type TransactionsListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\ttype?: string;\n\tsender?: string;\n\tcontractId?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type TransactionsWalkParams = Omit<TransactionsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Stacking (/v1/index/stacking) ──────────────────────────────────\n\n/** A decoded PoX-4 stacking action (one per stacking contract call). */\nexport type IndexStackingAction = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\tburn_block_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tfunction_name: string;\n\tcaller: string;\n\tstacker: string | null;\n\tdelegate_to: string | null;\n\tamount_ustx: string | null;\n\tlock_period: number | null;\n\tpox_addr: {\n\t\tversion: number | null;\n\t\thashbytes: string | null;\n\t\tbtc: string | null;\n\t};\n\tstart_cycle: number | null;\n\tend_cycle: number | null;\n\treward_cycle: number | null;\n\tsigner_key: string | null;\n\tresult_ok: boolean;\n};\n\nexport type StackingEnvelope = {\n\tstacking: IndexStackingAction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Chain reorgs overlapping this page's height range; empty when none.\n\treorgs: IndexReorg[];\n\t/** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */\n\tnotes?: string;\n};\n\nexport type StackingListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfunctionName?: string;\n\tstacker?: string;\n\tcaller?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type StackingWalkParams = Omit<StackingListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Mempool (/v1/index/mempool) ────────────────────────────────────\n\n/** A pending (unconfirmed) transaction. Like a transaction document but\n * pre-chain — no block_height/tx_index/result/events — with `received_at` and\n * a sequence cursor instead of a block position. */\nexport type IndexMempoolTransaction = {\n\tcursor: string;\n\ttx_id: string;\n\ttx_type: string;\n\tsender: string;\n\treceived_at?: string | null;\n\tfee: string | null;\n\tnonce: string | null;\n\tsponsored: boolean | null;\n\tanchor_mode: string | null;\n\tpost_condition_mode: string | null;\n\tpost_conditions: IndexPostCondition[];\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t};\n\ttoken_transfer?: { recipient: string; amount: string; memo: string };\n\tsmart_contract?: { clarity_version: number | null };\n\tcoinbase?: { alt_recipient: string | null };\n\ttenure_change?: { cause: number };\n};\n\nexport type MempoolEnvelope = {\n\tmempool: IndexMempoolTransaction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type MempoolTransactionEnvelope = {\n\ttransaction: IndexMempoolTransaction;\n\ttip: IndexTip;\n};\n\nexport type MempoolListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tsender?: string;\n\ttype?: string;\n\t/** Filter to pending calls to a single contract (e.g. `SP….contract`). */\n\tcontractId?: string;\n};\n\nexport type MempoolWalkParams = Omit<MempoolListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Print schema (/v1/index/contracts/:contract_id/print-schema) ───\n\n/**\n * Empirical per-topic print payload schema for a contract, inferred from\n * sampled on-chain events. `topics` is sorted by count desc; `sampled` is true\n * when the contract has more print events than the windows examined.\n */\nexport type PrintSchemaResponse = {\n\tcontract_id: string;\n\ttopics: InferredTopicSchema[];\n\tsampled: boolean;\n\ttotal_events: number;\n\t/** True when the count hit the server-side cap (total_events is the cap). */\n\ttotal_events_capped: boolean;\n\tsample: {\n\t\tsize: number;\n\t\tnewest_height: number | null;\n\t\toldest_height: number | null;\n\t};\n\ttip: IndexTip;\n};\n\nfunction firstWalkFromHeight(params: {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tfromHeight?: number;\n}): number | undefined {\n\tif (params.fromHeight !== undefined) return params.fromHeight;\n\tif (params.cursor || params.fromCursor) return undefined;\n\treturn 0;\n}\n\n/**\n * `index.ftTransfers` — callable shorthand for `.list()`, with `.list`/`.walk`\n * still available: `await sl.index.ftTransfers({ contractId })`.\n *\n * The API accepts `contract_id`/`sender`/`recipient` equality filters only —\n * no amount filtering and no asset-slug resolution on /v1/index/ft-transfers.\n */\nexport interface FtTransfersResource {\n\t(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;\n\tlist(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;\n\twalk(params?: FtTransfersWalkParams): AsyncIterable<FtTransfer>;\n}\n\n/** `index.nftTransfers` — callable shorthand for `.list()` (see {@link FtTransfersResource}). */\nexport interface NftTransfersResource {\n\t(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;\n\tlist(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;\n\twalk(params?: NftTransfersWalkParams): AsyncIterable<NftTransfer>;\n}\n\n/** `index.events` — callable shorthand for `.list()`; `eventType` is required. */\nexport interface IndexEventsResource {\n\t(params: EventsListParams): Promise<EventsEnvelope>;\n\tlist(params: EventsListParams): Promise<EventsEnvelope>;\n\twalk(params: EventsWalkParams): AsyncIterable<IndexEvent>;\n\tconsume(\n\t\tparams: EventsConsumeParams,\n\t): Promise<{ cursor: string | null; pages: number; emptyPolls: number }>;\n}\n\n/** Per-event-type filter vocabulary in the {@link IndexDiscovery} doc. */\nexport type IndexEventTypeFilters = {\n\tcolumns?: string[];\n\tallowed_filters?: string[];\n\tequality_filters?: string[];\n\trequired_non_null?: string[];\n};\n\n/** The `GET /v1/index` discovery doc — live endpoint + filter vocabulary.\n * Shape is intentionally open (the server may add fields); the agent-relevant\n * parts are the per-type filter rules. */\nexport type IndexDiscovery = {\n\tevent_type_filters?: Record<string, IndexEventTypeFilters>;\n\t[key: string]: unknown;\n};\n\nexport class Index extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/** Your own Index consumption (decoded events today + this month) and tier limits. */\n\tusage(): Promise<IndexUsage> {\n\t\treturn this.request<IndexUsage>(\"GET\", \"/v1/index/usage\");\n\t}\n\n\t/**\n\t * Index discovery doc — the live vocabulary: every endpoint, each event type's\n\t * columns, allowed/equality filters, and required-non-null fields. Read this to\n\t * learn what's queryable (and which types accept `trait`) instead of hardcoding.\n\t */\n\tdiscover(): Promise<IndexDiscovery> {\n\t\treturn this.request<IndexDiscovery>(\"GET\", \"/v1/index\");\n\t}\n\n\t/**\n\t * Empirical per-topic print payload schema for a contract — what topics it\n\t * emits and each field's observed Clarity/TS/column types. Anonymous read;\n\t * 404 → null.\n\t */\n\tasync printSchema(contractId: string): Promise<PrintSchemaResponse | null> {\n\t\ttry {\n\t\t\treturn await this.request<PrintSchemaResponse>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/contracts/${encodeURIComponent(contractId)}/print-schema`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\t/** Callable: `index.ftTransfers(params)` ≡ `index.ftTransfers.list(params)`. */\n\treadonly ftTransfers: FtTransfersResource = Object.assign(\n\t\t(params: FtTransfersListParams = {}): Promise<FtTransfersEnvelope> =>\n\t\t\tthis.listFtTransfers(params),\n\t\t{\n\t\t\tlist: (\n\t\t\t\tparams: FtTransfersListParams = {},\n\t\t\t): Promise<FtTransfersEnvelope> => this.listFtTransfers(params),\n\t\t\twalk: (params: FtTransfersWalkParams = {}): AsyncIterable<FtTransfer> =>\n\t\t\t\tthis.walkFtTransfers(params),\n\t\t},\n\t);\n\n\t/** Callable: `index.nftTransfers(params)` ≡ `index.nftTransfers.list(params)`. */\n\treadonly nftTransfers: NftTransfersResource = Object.assign(\n\t\t(params: NftTransfersListParams = {}): Promise<NftTransfersEnvelope> =>\n\t\t\tthis.listNftTransfers(params),\n\t\t{\n\t\t\tlist: (\n\t\t\t\tparams: NftTransfersListParams = {},\n\t\t\t): Promise<NftTransfersEnvelope> => this.listNftTransfers(params),\n\t\t\twalk: (params: NftTransfersWalkParams = {}): AsyncIterable<NftTransfer> =>\n\t\t\t\tthis.walkNftTransfers(params),\n\t\t},\n\t);\n\n\t/** Generic decoded events by `event_type` (the full /v1/index/events surface).\n\t * Callable: `index.events(params)` ≡ `index.events.list(params)`. */\n\treadonly events: IndexEventsResource = Object.assign(\n\t\t(params: EventsListParams): Promise<EventsEnvelope> =>\n\t\t\tthis.listEvents(params),\n\t\t{\n\t\t\tlist: (params: EventsListParams): Promise<EventsEnvelope> =>\n\t\t\t\tthis.listEvents(params),\n\t\t\twalk: (params: EventsWalkParams): AsyncIterable<IndexEvent> =>\n\t\t\t\tthis.walkEvents(params),\n\t\t\tconsume: (params: EventsConsumeParams) =>\n\t\t\t\tconsumeIndexFeed<IndexEvent, EventsEnvelope>({\n\t\t\t\t\t...params,\n\t\t\t\t\tfetchPage: ({ cursor, fromHeight, limit }) =>\n\t\t\t\t\t\tthis.listEvents({\n\t\t\t\t\t\t\teventType: params.eventType,\n\t\t\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\t\t\t\tsender: params.sender,\n\t\t\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\t\t\ttrait: params.trait,\n\t\t\t\t\t\t\ttoHeight: params.toHeight,\n\t\t\t\t\t\t\tcursor,\n\t\t\t\t\t\t\tfromHeight,\n\t\t\t\t\t\t\tlimit,\n\t\t\t\t\t\t}),\n\t\t\t\t\titemsOf: (envelope) => envelope.events,\n\t\t\t\t}),\n\t\t},\n\t);\n\n\treadonly contractCalls: {\n\t\tlist: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>;\n\t\twalk: (\n\t\t\tparams?: ContractCallsWalkParams,\n\t\t) => AsyncIterable<IndexContractCall>;\n\t\tconsume: (\n\t\t\tparams: ContractCallsConsumeParams,\n\t\t) => Promise<{ cursor: string | null; pages: number; emptyPolls: number }>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: ContractCallsListParams = {},\n\t\t): Promise<ContractCallsEnvelope> => this.listContractCalls(params),\n\t\twalk: (\n\t\t\tparams: ContractCallsWalkParams = {},\n\t\t): AsyncIterable<IndexContractCall> => this.walkContractCalls(params),\n\t\tconsume: (params: ContractCallsConsumeParams) =>\n\t\t\tconsumeIndexFeed<IndexContractCall, ContractCallsEnvelope>({\n\t\t\t\t...params,\n\t\t\t\tfetchPage: ({ cursor, fromHeight, limit }) =>\n\t\t\t\t\tthis.listContractCalls({\n\t\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\t\tfunctionName: params.functionName,\n\t\t\t\t\t\tsender: params.sender,\n\t\t\t\t\t\ttrait: params.trait,\n\t\t\t\t\t\ttoHeight: params.toHeight,\n\t\t\t\t\t\tcursor,\n\t\t\t\t\t\tfromHeight,\n\t\t\t\t\t\tlimit,\n\t\t\t\t\t}),\n\t\t\t\titemsOf: (envelope) => envelope.contract_calls,\n\t\t\t}),\n\t};\n\n\t/** Canonical block-hash map — sync only the current canonical chain. */\n\treadonly canonical: {\n\t\tlist: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;\n\t\twalk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;\n\t} = {\n\t\tlist: (params: CanonicalListParams = {}): Promise<CanonicalEnvelope> =>\n\t\t\tthis.listCanonical(params),\n\t\twalk: (\n\t\t\tparams: CanonicalWalkParams = {},\n\t\t): AsyncIterable<IndexCanonicalBlock> => this.walkCanonical(params),\n\t};\n\n\t/** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash\n\t * (resolves to null on 404). */\n\treadonly blocks: {\n\t\tlist: (params?: BlocksListParams) => Promise<BlocksEnvelope>;\n\t\twalk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>;\n\t\tget: (ref: string | number) => Promise<BlockEnvelope | null>;\n\t} = {\n\t\tlist: (params: BlocksListParams = {}): Promise<BlocksEnvelope> =>\n\t\t\tthis.listBlocks(params),\n\t\twalk: (params: BlocksWalkParams = {}): AsyncIterable<IndexBlock> =>\n\t\t\tthis.walkBlocks(params),\n\t\tget: (ref: string | number): Promise<BlockEnvelope | null> =>\n\t\t\tthis.getBlock(ref),\n\t};\n\n\t/** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id\n\t * (resolves to null on 404). */\n\treadonly transactions: {\n\t\tlist: (params?: TransactionsListParams) => Promise<TransactionsEnvelope>;\n\t\twalk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>;\n\t\tget: (txId: string) => Promise<TransactionEnvelope | null>;\n\t\tgetProof: (txId: string) => Promise<TransactionProof | null>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: TransactionsListParams = {},\n\t\t): Promise<TransactionsEnvelope> => this.listTransactions(params),\n\t\twalk: (\n\t\t\tparams: TransactionsWalkParams = {},\n\t\t): AsyncIterable<IndexTransaction> => this.walkTransactions(params),\n\t\tget: (txId: string): Promise<TransactionEnvelope | null> =>\n\t\t\tthis.getTransaction(txId),\n\t\tgetProof: (txId: string): Promise<TransactionProof | null> =>\n\t\t\tthis.getTransactionProof(txId),\n\t};\n\n\t/** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the\n\t * platform's PoX-4 decoder is disabled. */\n\treadonly stacking: {\n\t\tlist: (params?: StackingListParams) => Promise<StackingEnvelope>;\n\t\twalk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;\n\t} = {\n\t\tlist: (params: StackingListParams = {}): Promise<StackingEnvelope> =>\n\t\t\tthis.listStacking(params),\n\t\twalk: (\n\t\t\tparams: StackingWalkParams = {},\n\t\t): AsyncIterable<IndexStackingAction> => this.walkStacking(params),\n\t};\n\n\t/** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by\n\t * tx_id (resolves to null when the tx has confirmed or dropped). */\n\treadonly mempool: {\n\t\tlist: (params?: MempoolListParams) => Promise<MempoolEnvelope>;\n\t\twalk: (\n\t\t\tparams?: MempoolWalkParams,\n\t\t) => AsyncIterable<IndexMempoolTransaction>;\n\t\tget: (txId: string) => Promise<MempoolTransactionEnvelope | null>;\n\t} = {\n\t\tlist: (params: MempoolListParams = {}): Promise<MempoolEnvelope> =>\n\t\t\tthis.listMempool(params),\n\t\twalk: (\n\t\t\tparams: MempoolWalkParams = {},\n\t\t): AsyncIterable<IndexMempoolTransaction> => this.walkMempool(params),\n\t\tget: (txId: string): Promise<MempoolTransactionEnvelope | null> =>\n\t\t\tthis.getMempoolTx(txId),\n\t};\n\n\tprivate async listFtTransfers(\n\t\tparams: FtTransfersListParams = {},\n\t): Promise<FtTransfersEnvelope> {\n\t\treturn this.request<FtTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/ft-transfers${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async listNftTransfers(\n\t\tparams: NftTransfersListParams = {},\n\t): Promise<NftTransfersEnvelope> {\n\t\treturn this.request<NftTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/nft-transfers${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkFtTransfers(\n\t\tparams: FtTransfersWalkParams = {},\n\t): AsyncGenerator<FtTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listFtTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async *walkNftTransfers(\n\t\tparams: NftTransfersWalkParams = {},\n\t): AsyncGenerator<NftTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listNftTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listEvents(params: EventsListParams): Promise<EventsEnvelope> {\n\t\treturn this.request<EventsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/events${buildQuery({\n\t\t\t\tevent_type: params.eventType,\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t\ttrait: params.trait,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkEvents(\n\t\tparams: EventsWalkParams,\n\t): AsyncGenerator<IndexEvent> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listEvents({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listContractCalls(\n\t\tparams: ContractCallsListParams = {},\n\t): Promise<ContractCallsEnvelope> {\n\t\treturn this.request<ContractCallsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/contract-calls${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tfunction_name: params.functionName,\n\t\t\t\tsender: params.sender,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t\ttrait: params.trait,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkContractCalls(\n\t\tparams: ContractCallsWalkParams = {},\n\t): AsyncGenerator<IndexContractCall> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listContractCalls({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const call of envelope.contract_calls) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield call;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.contract_calls.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listCanonical(\n\t\tparams: CanonicalListParams = {},\n\t): Promise<CanonicalEnvelope> {\n\t\treturn this.request<CanonicalEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/canonical${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkCanonical(\n\t\tparams: CanonicalWalkParams = {},\n\t): AsyncGenerator<IndexCanonicalBlock> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listCanonical({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const block of envelope.canonical) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield block;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.canonical.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listBlocks(\n\t\tparams: BlocksListParams = {},\n\t): Promise<BlocksEnvelope> {\n\t\treturn this.request<BlocksEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/blocks${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getBlock(ref: string | number): Promise<BlockEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<BlockEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/blocks/${encodeURIComponent(String(ref))}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkBlocks(\n\t\tparams: BlocksWalkParams = {},\n\t): AsyncGenerator<IndexBlock> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listBlocks({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const block of envelope.blocks) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield block;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.blocks.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listTransactions(\n\t\tparams: TransactionsListParams = {},\n\t): Promise<TransactionsEnvelope> {\n\t\treturn this.request<TransactionsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/transactions${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\ttype: params.type,\n\t\t\t\tsender: params.sender,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getTransaction(\n\t\ttxId: string,\n\t): Promise<TransactionEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<TransactionEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/transactions/${encodeURIComponent(txId)}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\t/** Fetch the inclusion proof for a tx (raw tx + Nakamoto header + merkle path)\n\t * to verify client-side with `verifyTransactionProof`. 404 → null. A 503\n\t * (`PROOF_TX_SET_INCOMPLETE` / `PROOF_NODE_UNAVAILABLE`) surfaces as an\n\t * ApiError — the proof can't be assembled on this deployment right now. */\n\tprivate async getTransactionProof(\n\t\ttxId: string,\n\t): Promise<TransactionProof | null> {\n\t\ttry {\n\t\t\treturn await this.request<TransactionProof>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/transactions/${encodeURIComponent(txId)}/proof`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkTransactions(\n\t\tparams: TransactionsWalkParams = {},\n\t): AsyncGenerator<IndexTransaction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listTransactions({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const tx of envelope.transactions) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield tx;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.transactions.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listStacking(\n\t\tparams: StackingListParams = {},\n\t): Promise<StackingEnvelope> {\n\t\treturn this.request<StackingEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/stacking${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfunction_name: params.functionName,\n\t\t\t\tstacker: params.stacker,\n\t\t\t\tcaller: params.caller,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkStacking(\n\t\tparams: StackingWalkParams = {},\n\t): AsyncGenerator<IndexStackingAction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listStacking({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const action of envelope.stacking) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield action;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.stacking.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listMempool(\n\t\tparams: MempoolListParams = {},\n\t): Promise<MempoolEnvelope> {\n\t\treturn this.request<MempoolEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/mempool${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tsender: params.sender,\n\t\t\t\ttype: params.type,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getMempoolTx(\n\t\ttxId: string,\n\t): Promise<MempoolTransactionEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<MempoolTransactionEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/mempool/${encodeURIComponent(txId)}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkMempool(\n\t\tparams: MempoolWalkParams = {},\n\t): AsyncGenerator<IndexMempoolTransaction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listMempool({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t});\n\n\t\t\tfor (const tx of envelope.mempool) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield tx;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.mempool.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n}\n",
|
|
16
|
+
"import { BaseClient, type SecondLayerOptions } from \"../base.ts\";\n\n/**\n * Typed client for project management (`/api/projects/*`).\n *\n * Projects are the account-scoped containers for work. Every method requires an\n * account-level (owner) API key or a dashboard session — scoped read keys are\n * rejected. Team mutations (invite/remove/role) are intentionally not exposed\n * here; only the read view ({@link Projects.team}) is.\n */\n\nexport interface Project {\n\tid: string;\n\tname: string;\n\tslug: string;\n\tnetwork: string;\n\tnodeRpc: string | null;\n\tsettings: Record<string, unknown> | null;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface ProjectTeamMember {\n\tid: string;\n\trole: string;\n\temail: string;\n\tdisplayName: string | null;\n\tavatarUrl: string | null;\n\tcreatedAt: string;\n}\n\nexport interface ProjectInvitation {\n\tid: string;\n\temail: string;\n\trole: string;\n\texpiresAt: string;\n\tcreatedAt: string;\n}\n\nexport interface ProjectTeam {\n\tmembers: ProjectTeamMember[];\n\tinvitations: ProjectInvitation[];\n}\n\nexport interface CreateProjectParams {\n\tname: string;\n\tslug?: string;\n\tnetwork?: string;\n\tnodeRpc?: string;\n}\n\nexport interface UpdateProjectParams {\n\tname?: string;\n\t/** Rename the project's URL slug. */\n\tslug?: string;\n\tnetwork?: string;\n\tnodeRpc?: string;\n\tsettings?: Record<string, unknown>;\n}\n\nexport class Projects extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/** All projects owned by the account, newest-relevant first. */\n\tlist(): Promise<{ projects: Project[] }> {\n\t\treturn this.request<{ projects: Project[] }>(\"GET\", \"/api/projects\");\n\t}\n\n\t/** A single project by slug. */\n\tget(slug: string): Promise<Project> {\n\t\treturn this.request<Project>(\"GET\", `/api/projects/${slug}`);\n\t}\n\n\t/** Create a project. The creator is added as the project owner. */\n\tcreate(params: CreateProjectParams): Promise<Project> {\n\t\treturn this.request<Project>(\"POST\", \"/api/projects\", params);\n\t}\n\n\t/** Update a project's name, slug (rename), network, RPC, or settings. */\n\tupdate(slug: string, patch: UpdateProjectParams): Promise<Project> {\n\t\treturn this.request<Project>(\"PATCH\", `/api/projects/${slug}`, patch);\n\t}\n\n\t/** Delete a project. The account's last remaining project cannot be deleted. */\n\tdelete(slug: string): Promise<{ ok: true }> {\n\t\treturn this.request<{ ok: true }>(\"DELETE\", `/api/projects/${slug}`);\n\t}\n\n\t/** Team members and pending invitations for a project. */\n\tteam(slug: string): Promise<ProjectTeam> {\n\t\treturn this.request<ProjectTeam>(\"GET\", `/api/projects/${slug}/team`);\n\t}\n}\n",
|
|
17
|
+
"import { ed25519 } from \"@secondlayer/shared\";\nimport { buildQuery } from \"../base.ts\";\nimport {\n\ttype StreamsEventsFetcher,\n\tconsumeStreamsEvents,\n\titerateStreamsBatches,\n\tstreamStreamsEvents,\n} from \"./consumer.ts\";\nimport { createStreamsDumps } from \"./dumps.ts\";\nimport {\n\tAuthError,\n\tRateLimitError,\n\tStreamsServerError,\n\tStreamsSignatureError,\n\tValidationError,\n} from \"./errors.ts\";\nimport { subscribeStreamsEvents } from \"./subscribe.ts\";\nimport type {\n\tFetchLike,\n\tStreamsCanonicalBlock,\n\tStreamsClient,\n\tStreamsConsumeParams,\n\tStreamsEventsConsumeParams,\n\tStreamsEventsEnvelope,\n\tStreamsEventsListEnvelope,\n\tStreamsEventsListParams,\n\tStreamsEventsReplayParams,\n\tStreamsEventsStreamParams,\n\tStreamsEventsSubscribeParams,\n\tStreamsReorgsListEnvelope,\n\tStreamsReorgsListParams,\n\tStreamsTip,\n\tStreamsUsage,\n} from \"./types.ts\";\n\n/** Parse a `<block>:<index>` cursor; null sorts before genesis. */\nfunction cursorTuple(cursor: string | null): [number, number] {\n\tif (!cursor) return [-1, -1];\n\tconst parts = cursor.split(\":\");\n\tconst [block, index] = parts.map(Number);\n\tif (\n\t\tparts.length !== 2 ||\n\t\t!Number.isInteger(block) ||\n\t\t!Number.isInteger(index)\n\t) {\n\t\tthrow new ValidationError(\n\t\t\t`Invalid stream cursor \"${cursor}\"; expected \"<block>:<index>\" (e.g. \"951475:3\").`,\n\t\t\t400,\n\t\t);\n\t}\n\treturn [block, index];\n}\n\n/** The greater of two cursors (later in the stream). */\nfunction maxCursor(a: string | null, b: string | null): string | null {\n\tconst [ah, ai] = cursorTuple(a);\n\tconst [bh, bi] = cursorTuple(b);\n\treturn ah > bh || (ah === bh && ai >= bi) ? a : b;\n}\n\nconst DEFAULT_STREAMS_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport type CreateStreamsClientOptions = {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetchImpl?: FetchLike;\n\t/**\n\t * Public base URL for bulk parquet dumps (the R2/CDN bucket root). Required\n\t * to use `client.dumps`. See `GET /public/streams/dumps/manifest`.\n\t */\n\tdumpsBaseUrl?: string;\n\t/**\n\t * Verify the ed25519 `X-Signature` on every response (default off). Pass\n\t * `true` to fetch the server's public key from\n\t * `/public/streams/signing-key`, or `{ publicKey }` to pin a known PEM. A\n\t * failed or missing signature throws `StreamsSignatureError`.\n\t */\n\tverify?: boolean | { publicKey: string };\n\t/**\n\t * Verify the bulk dumps manifest's ed25519 signature in `client.dumps.list()`\n\t * before trusting any file sha256 (default ON). Uses the same key source as\n\t * `verify` (fetches `/public/streams/signing-key`, or a pinned PEM). Pass\n\t * `false` to opt out. A missing or invalid signature throws\n\t * `StreamsSignatureError`.\n\t */\n\tverifyDumpsManifest?: boolean;\n};\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n\treturn baseUrl.replace(/\\/+$/, \"\");\n}\n\nasync function responseBody(response: Response): Promise<unknown> {\n\tconst text = await response.text();\n\tif (text.length === 0) return undefined;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch {\n\t\treturn text;\n\t}\n}\n\nfunction errorMessage(body: unknown, fallback: string): string {\n\tif (body && typeof body === \"object\") {\n\t\tconst record = body as Record<string, unknown>;\n\t\tconst message = record.error ?? record.message;\n\t\tif (typeof message === \"string\" && message.length > 0) return message;\n\t}\n\tif (typeof body === \"string\" && body.length > 0) return body;\n\treturn fallback;\n}\n\nasync function mapStreamsError(response: Response): Promise<never> {\n\tconst body = await responseBody(response);\n\n\tif (response.status === 401) {\n\t\tthrow new AuthError(errorMessage(body, \"API key invalid or expired.\"));\n\t}\n\n\tif (response.status === 429) {\n\t\tconst retryAfter = response.headers.get(\"Retry-After\") ?? undefined;\n\t\tthrow new RateLimitError(\n\t\t\terrorMessage(body, \"Rate limited. Try again later.\"),\n\t\t\tretryAfter,\n\t\t);\n\t}\n\n\tif (response.status >= 500) {\n\t\tthrow new StreamsServerError(\n\t\t\terrorMessage(body, `Streams server returned ${response.status}.`),\n\t\t\tresponse.status,\n\t\t\tbody,\n\t\t);\n\t}\n\n\tthrow new ValidationError(\n\t\terrorMessage(body, `Streams request returned ${response.status}.`),\n\t\tresponse.status,\n\t\tbody,\n\t);\n}\n\nexport function createStreamsClient(\n\toptions: CreateStreamsClientOptions,\n): StreamsClient {\n\tconst baseUrl = normalizeBaseUrl(options.baseUrl ?? DEFAULT_STREAMS_BASE_URL);\n\tconst fetchImpl = options.fetchImpl ?? ((input, init) => fetch(input, init));\n\tconst verify = options.verify ?? false;\n\n\t// Lazily resolve and cache the verification key alongside its id, so a\n\t// rotation (signalled by a changed `X-Signature-KeyId`) can be detected.\n\ttype VerificationKey = {\n\t\tkeyId: string;\n\t\tpublicKeyPem: string;\n\t\tpublicKey: ReturnType<typeof ed25519.loadEd25519PublicKey>;\n\t};\n\tlet keyPromise: Promise<VerificationKey> | null = null;\n\tfunction loadKey(): Promise<VerificationKey> {\n\t\tif (keyPromise) return keyPromise;\n\t\tkeyPromise = (async () => {\n\t\t\tif (typeof verify === \"object\") {\n\t\t\t\treturn {\n\t\t\t\t\tkeyId: ed25519.ed25519KeyId(verify.publicKey),\n\t\t\t\t\tpublicKeyPem: verify.publicKey,\n\t\t\t\t\tpublicKey: ed25519.loadEd25519PublicKey(verify.publicKey),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst res = await fetchImpl(`${baseUrl}/public/streams/signing-key`);\n\t\t\tif (!res.ok) {\n\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t`Could not fetch signing key (${res.status}).`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst body = (await res.json()) as {\n\t\t\t\tpublic_key_pem?: string;\n\t\t\t\tkey_id?: string;\n\t\t\t};\n\t\t\tif (!body.public_key_pem) {\n\t\t\t\tthrow new StreamsSignatureError(\"Signing key response missing key.\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkeyId: body.key_id ?? ed25519.ed25519KeyId(body.public_key_pem),\n\t\t\t\tpublicKeyPem: body.public_key_pem,\n\t\t\t\tpublicKey: ed25519.loadEd25519PublicKey(body.public_key_pem),\n\t\t\t};\n\t\t})();\n\t\treturn keyPromise;\n\t}\n\n\tconst dumps = createStreamsDumps({\n\t\tbaseUrl: options.dumpsBaseUrl,\n\t\tfetchImpl,\n\t\tverifyManifest: options.verifyDumpsManifest ?? true,\n\t\tloadPublicKeyPem: async () => (await loadKey()).publicKeyPem,\n\t});\n\n\tasync function request<T>(path: string): Promise<T> {\n\t\tconst response = await fetchImpl(`${baseUrl}${path}`, {\n\t\t\theaders: { Authorization: `Bearer ${options.apiKey}` },\n\t\t});\n\t\tif (!response.ok) await mapStreamsError(response);\n\t\tconst text = await response.text();\n\t\tif (verify) {\n\t\t\tconst signature = response.headers.get(\"X-Signature\");\n\t\t\tif (!signature) {\n\t\t\t\tthrow new StreamsSignatureError(\"Response is missing X-Signature.\");\n\t\t\t}\n\t\t\tconst responseKeyId = response.headers.get(\"X-Signature-KeyId\");\n\t\t\tlet key = await loadKey();\n\t\t\t// The server rotated to a key we haven't seen.\n\t\t\tif (responseKeyId && responseKeyId !== key.keyId) {\n\t\t\t\tif (typeof verify === \"object\") {\n\t\t\t\t\t// Pinned key: a different id is never the pinned key — fail closed.\n\t\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\t`Response signed with key '${responseKeyId}', expected pinned key '${key.keyId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Fetched key: refresh once. A still-mismatched id (no re-loop)\n\t\t\t\t// means the endpoint doesn't serve the signing key — fail closed.\n\t\t\t\tkeyPromise = null;\n\t\t\t\tkey = await loadKey();\n\t\t\t\tif (responseKeyId !== key.keyId) {\n\t\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\t`Response signed with key '${responseKeyId}' not served by the signing-key endpoint.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!ed25519.verifyEd25519(text, signature, key.publicKey)) {\n\t\t\t\tthrow new StreamsSignatureError();\n\t\t\t}\n\t\t}\n\t\treturn JSON.parse(text) as T;\n\t}\n\n\tconst fetchEvents: StreamsEventsFetcher = async ({\n\t\tcursor,\n\t\tlimit,\n\t\ttypes,\n\t\tnotTypes,\n\t\tcontractId,\n\t\tsender,\n\t\trecipient,\n\t\tassetIdentifier,\n\t}) => {\n\t\treturn listEvents({\n\t\t\tcursor,\n\t\t\tlimit,\n\t\t\ttypes,\n\t\t\tnotTypes,\n\t\t\tcontractId,\n\t\t\tsender,\n\t\t\trecipient,\n\t\t\tassetIdentifier,\n\t\t});\n\t};\n\n\tasync function listEvents(\n\t\tparams: StreamsEventsListParams = {},\n\t): Promise<StreamsEventsEnvelope> {\n\t\treturn request<StreamsEventsEnvelope>(\n\t\t\t`/v1/streams/events${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\ttypes: params.types,\n\t\t\t\tnot_types: params.notTypes,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\treturn {\n\t\tconsume(params: StreamsConsumeParams = {}) {\n\t\t\treturn iterateStreamsBatches({\n\t\t\t\tfromCursor: params.cursor,\n\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\tintervalMs: params.intervalMs ?? 2000,\n\t\t\t\ttypes: params.types,\n\t\t\t\tnotTypes: params.notTypes,\n\t\t\t\tcontractId: params.contractId,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\tsignal: params.signal,\n\t\t\t\tfetchEvents,\n\t\t\t});\n\t\t},\n\t\tevents: {\n\t\t\tlist: listEvents,\n\t\t\tbyTxId(txId: string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/events/${encodeURIComponent(txId)}`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tconsume(params: StreamsEventsConsumeParams) {\n\t\t\t\treturn consumeStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\tmode: params.mode,\n\t\t\t\t\tfinalizedOnly: params.finalizedOnly,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tnotTypes: params.notTypes,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tsender: params.sender,\n\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t\tonBatch: params.onBatch,\n\t\t\t\t\tonReorg: params.onReorg,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t});\n\t\t\t},\n\t\t\tstream(params: StreamsEventsStreamParams = {}) {\n\t\t\t\treturn streamStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tnotTypes: params.notTypes,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tsender: params.sender,\n\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t});\n\t\t\t},\n\t\t\tsubscribe(params: StreamsEventsSubscribeParams) {\n\t\t\t\treturn subscribeStreamsEvents({\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\tapiKey: options.apiKey,\n\t\t\t\t\tfetchImpl,\n\t\t\t\t\tverify: Boolean(verify),\n\t\t\t\t\tloadKey,\n\t\t\t\t\tparams,\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync replay(params: StreamsEventsReplayParams) {\n\t\t\t\tconst fromCursor =\n\t\t\t\t\tparams.from === \"genesis\" ? null : (params.from ?? null);\n\t\t\t\tconst fromBlock = fromCursor ? cursorTuple(fromCursor)[0] : 0;\n\t\t\t\tconst manifest = await dumps.list();\n\n\t\t\t\t// Hydrate finalized history from dumps, in block order.\n\t\t\t\tconst files = manifest.files\n\t\t\t\t\t.filter((file) => file.to_block >= fromBlock)\n\t\t\t\t\t.sort(\n\t\t\t\t\t\t(a, b) => a.from_block - b.from_block || a.to_block - b.to_block,\n\t\t\t\t\t);\n\t\t\t\tfor (const file of files) {\n\t\t\t\t\tif (params.signal?.aborted) break;\n\t\t\t\t\tawait params.onDumpFile(file);\n\t\t\t\t}\n\n\t\t\t\t// Seam: tail live from just past the dumped coverage. Cursor input is\n\t\t\t\t// exclusive, so the first live event is strictly after the last dump.\n\t\t\t\tconst seam = maxCursor(fromCursor, manifest.latest_finalized_cursor);\n\t\t\t\treturn consumeStreamsEvents({\n\t\t\t\t\tfromCursor: seam,\n\t\t\t\t\tmode: params.mode ?? \"tail\",\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t\tonBatch: params.onBatch,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\tblocks: {\n\t\t\tevents(heightOrHash: number | string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/blocks/${encodeURIComponent(String(heightOrHash))}/events`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\treorgs: {\n\t\t\tlist(params: StreamsReorgsListParams) {\n\t\t\t\treturn request<StreamsReorgsListEnvelope>(\n\t\t\t\t\t`/v1/streams/reorgs${buildQuery({\n\t\t\t\t\t\tsince: params.since,\n\t\t\t\t\t\tlimit: params.limit,\n\t\t\t\t\t})}`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tdumps,\n\t\tcanonical(height: number) {\n\t\t\treturn request<StreamsCanonicalBlock>(`/v1/streams/canonical/${height}`);\n\t\t},\n\t\ttip() {\n\t\t\treturn request<StreamsTip>(\"/v1/streams/tip\");\n\t\t},\n\t\tusage() {\n\t\t\treturn request<StreamsUsage>(\"/v1/streams/usage\");\n\t\t},\n\t};\n}\n",
|
|
17
18
|
"import { createHash } from \"node:crypto\";\nimport { verifyStreamsBulkManifestSignature } from \"@secondlayer/shared/streams-bulk-manifest\";\nimport { StreamsServerError, StreamsSignatureError } from \"./errors.ts\";\nimport type {\n\tFetchLike,\n\tStreamsDumpFile,\n\tStreamsDumps,\n\tStreamsDumpsManifest,\n} from \"./types.ts\";\n\n/**\n * Bulk parquet dumps: the cold backfill path for \"download all the raw data\".\n *\n * The manifest lives at `<dumpsBaseUrl>/manifest/latest.json` and each file's\n * `path` is the object key under the same base. Downloads are verified against\n * the manifest sha256 so a truncated or tampered file is rejected.\n *\n * When `verifyManifest` is set (the default), the manifest's own ed25519\n * signature is checked (against the published Streams key) BEFORE any file sha256\n * is trusted — a sha256 is only as trustworthy as the manifest it came from.\n */\nexport function createStreamsDumps(opts: {\n\tbaseUrl?: string;\n\tfetchImpl: FetchLike;\n\tverifyManifest?: boolean;\n\tloadPublicKeyPem?: () => Promise<string>;\n}): StreamsDumps {\n\tconst baseUrl = opts.baseUrl?.replace(/\\/+$/, \"\");\n\n\tfunction requireBaseUrl(): string {\n\t\tif (!baseUrl) {\n\t\t\tthrow new StreamsServerError(\n\t\t\t\t\"Streams dumps require `dumpsBaseUrl` on createStreamsClient.\",\n\t\t\t\t0,\n\t\t\t);\n\t\t}\n\t\treturn baseUrl;\n\t}\n\n\tfunction fileUrl(file: StreamsDumpFile): string {\n\t\treturn `${requireBaseUrl()}/${file.path.replace(/^\\/+/, \"\")}`;\n\t}\n\n\tasync function list(): Promise<StreamsDumpsManifest> {\n\t\tconst url = `${requireBaseUrl()}/manifest/latest.json`;\n\t\tconst res = await opts.fetchImpl(url);\n\t\tif (!res.ok) {\n\t\t\tthrow new StreamsServerError(\n\t\t\t\t`Could not fetch dumps manifest (${res.status}).`,\n\t\t\t\tres.status,\n\t\t\t);\n\t\t}\n\t\tconst manifest = (await res.json()) as StreamsDumpsManifest;\n\t\tif (opts.verifyManifest) {\n\t\t\tif (!opts.loadPublicKeyPem) {\n\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\"Manifest verification is on but no signing key source is configured.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst publicKeyPem = await opts.loadPublicKeyPem();\n\t\t\tif (!verifyStreamsBulkManifestSignature(manifest, publicKeyPem)) {\n\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\"Dumps manifest signature is missing or invalid.\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn manifest;\n\t}\n\n\tasync function download(file: StreamsDumpFile): Promise<Uint8Array> {\n\t\tconst res = await opts.fetchImpl(fileUrl(file));\n\t\tif (!res.ok) {\n\t\t\tthrow new StreamsServerError(\n\t\t\t\t`Could not download dump ${file.path} (${res.status}).`,\n\t\t\t\tres.status,\n\t\t\t);\n\t\t}\n\t\tconst bytes = new Uint8Array(await res.arrayBuffer());\n\t\tconst digest = createHash(\"sha256\").update(bytes).digest(\"hex\");\n\t\tif (digest !== file.sha256) {\n\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t`Dump ${file.path} sha256 mismatch (expected ${file.sha256}, got ${digest}).`,\n\t\t\t);\n\t\t}\n\t\treturn bytes;\n\t}\n\n\treturn { list, fileUrl, download };\n}\n",
|
|
18
19
|
"import { ed25519 } from \"@secondlayer/shared\";\nimport { buildQuery } from \"../base.ts\";\nimport { StreamsServerError, StreamsSignatureError } from \"./errors.ts\";\nimport type {\n\tFetchLike,\n\tStreamsEvent,\n\tStreamsEventsSubscribeParams,\n} from \"./types.ts\";\n\ntype VerificationKey = {\n\tpublicKey: ReturnType<typeof ed25519.loadEd25519PublicKey>;\n};\n\n/**\n * Subscribe to the Streams SSE push surface (`GET /v1/streams/events/stream`).\n *\n * A fetch-based reader (not `EventSource`) so it can send the mandatory\n * `Authorization` header — Streams is key-mandatory and `EventSource` can't set\n * headers. Works in browsers and Node 18+. Reconnects from the last delivered\n * cursor on a dropped connection until the caller's signal aborts.\n */\nexport function subscribeStreamsEvents(opts: {\n\tbaseUrl: string;\n\tapiKey: string;\n\tfetchImpl: FetchLike;\n\tverify: boolean;\n\tloadKey: () => Promise<VerificationKey>;\n\treconnectDelayMs?: number;\n\tparams: StreamsEventsSubscribeParams;\n}): () => void {\n\tconst { params } = opts;\n\tconst controller = new AbortController();\n\tconst external = params.signal;\n\tif (external) {\n\t\tif (external.aborted) controller.abort();\n\t\telse\n\t\t\texternal.addEventListener(\"abort\", () => controller.abort(), {\n\t\t\t\tonce: true,\n\t\t\t});\n\t}\n\tlet cursor = params.fromCursor ?? null;\n\tconst reconnectDelayMs = opts.reconnectDelayMs ?? 1000;\n\n\tconst run = async (): Promise<void> => {\n\t\twhile (!controller.signal.aborted) {\n\t\t\ttry {\n\t\t\t\tconst url = `${opts.baseUrl}/v1/streams/events/stream${buildQuery({\n\t\t\t\t\tfrom_cursor: cursor ?? undefined,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tnot_types: params.notTypes,\n\t\t\t\t\tcontract_id: params.contractId,\n\t\t\t\t\tsender: params.sender,\n\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\t})}`;\n\t\t\t\tconst res = await opts.fetchImpl(url, {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${opts.apiKey}`,\n\t\t\t\t\t\tAccept: \"text/event-stream\",\n\t\t\t\t\t},\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t});\n\t\t\t\tif (!res.ok) {\n\t\t\t\t\tthrow new StreamsServerError(\n\t\t\t\t\t\t`Streams SSE returned ${res.status}.`,\n\t\t\t\t\t\tres.status,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!res.body) {\n\t\t\t\t\tthrow new StreamsServerError(\"Streams SSE response has no body.\", 0);\n\t\t\t\t}\n\t\t\t\tfor await (const frame of parseSseFrames(res.body, controller.signal)) {\n\t\t\t\t\tif (frame.event === \"ping\" || !frame.data) continue;\n\t\t\t\t\tlet parsed: { event?: StreamsEvent; sig?: string };\n\t\t\t\t\ttry {\n\t\t\t\t\t\tparsed = JSON.parse(frame.data);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tcontinue; // ignore non-JSON frames\n\t\t\t\t\t}\n\t\t\t\t\tif (!parsed.event) continue;\n\t\t\t\t\tif (opts.verify) {\n\t\t\t\t\t\tconst key = await opts.loadKey();\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!parsed.sig ||\n\t\t\t\t\t\t\t!ed25519.verifyEd25519(\n\t\t\t\t\t\t\t\tJSON.stringify(parsed.event),\n\t\t\t\t\t\t\t\tparsed.sig,\n\t\t\t\t\t\t\t\tkey.publicKey,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\t\t\t\"Streams SSE frame signature is missing or invalid.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcursor = (parsed.event as { cursor?: string }).cursor ?? cursor;\n\t\t\t\t\tawait params.onEvent(parsed.event);\n\t\t\t\t}\n\t\t\t\t// Clean end (server closed the stream): reconnect from `cursor`.\n\t\t\t} catch (err) {\n\t\t\t\tif (controller.signal.aborted) return;\n\t\t\t\tparams.onError?.(err);\n\t\t\t\tawait sleep(reconnectDelayMs, controller.signal);\n\t\t\t}\n\t\t}\n\t};\n\tvoid run();\n\treturn () => controller.abort();\n}\n\nfunction sleep(ms: number, signal: AbortSignal): Promise<void> {\n\treturn new Promise((resolve) => {\n\t\tif (signal.aborted) return resolve();\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timer);\n\t\t\tresolve();\n\t\t};\n\t\tconst timer = setTimeout(() => {\n\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\nasync function* parseSseFrames(\n\tbody: ReadableStream<Uint8Array>,\n\tsignal: AbortSignal,\n): AsyncGenerator<{ event?: string; data?: string }> {\n\tconst reader = body.getReader();\n\tconst decoder = new TextDecoder();\n\tlet buffer = \"\";\n\ttry {\n\t\twhile (!signal.aborted) {\n\t\t\tconst { value, done } = await reader.read();\n\t\t\tif (done) break;\n\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t\tlet sep = buffer.indexOf(\"\\n\\n\");\n\t\t\twhile (sep !== -1) {\n\t\t\t\tyield parseFrame(buffer.slice(0, sep));\n\t\t\t\tbuffer = buffer.slice(sep + 2);\n\t\t\t\tsep = buffer.indexOf(\"\\n\\n\");\n\t\t\t}\n\t\t}\n\t} finally {\n\t\ttry {\n\t\t\tawait reader.cancel();\n\t\t} catch {\n\t\t\t// best-effort\n\t\t}\n\t}\n}\n\nfunction parseFrame(raw: string): { event?: string; data?: string } {\n\tlet event: string | undefined;\n\tconst data: string[] = [];\n\tfor (const line of raw.split(\"\\n\")) {\n\t\tif (line.startsWith(\"data:\")) {\n\t\t\tdata.push(line.slice(line.startsWith(\"data: \") ? 6 : 5));\n\t\t} else if (line.startsWith(\"event:\")) {\n\t\t\tevent = line.slice(line.startsWith(\"event: \") ? 7 : 6).trim();\n\t\t}\n\t}\n\treturn { event, data: data.length > 0 ? data.join(\"\\n\") : undefined };\n}\n",
|
|
19
20
|
"import type {\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionSummary,\n\tSubscriptionTestResult,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\nimport { BaseClient } from \"../base.ts\";\n\nexport type {\n\tChainTrigger,\n\tChainTriggerType,\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionFormat,\n\tSubscriptionKind,\n\tSubscriptionRuntime,\n\tSubscriptionStatus,\n\tSubscriptionSummary,\n\tSubscriptionTestResult,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\n// `trigger.*` chain-trigger builders for direct chain-level subscriptions\n// (`create({ triggers: [trigger.contractCall({ ... })] })`).\nexport { trigger } from \"@secondlayer/shared/schemas/subscriptions\";\n\nexport class Subscriptions extends BaseClient {\n\tasync list(): Promise<{ data: SubscriptionSummary[] }> {\n\t\treturn this.request<{ data: SubscriptionSummary[] }>(\n\t\t\t\"GET\",\n\t\t\t\"/api/subscriptions\",\n\t\t);\n\t}\n\n\tasync get(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.request<SubscriptionDetail>(\"GET\", `/api/subscriptions/${id}`);\n\t}\n\n\tasync create(\n\t\tinput: CreateSubscriptionRequest,\n\t): Promise<CreateSubscriptionResponse> {\n\t\treturn this.request<CreateSubscriptionResponse>(\n\t\t\t\"POST\",\n\t\t\t\"/api/subscriptions\",\n\t\t\tinput,\n\t\t);\n\t}\n\n\tasync update(\n\t\tid: string,\n\t\tpatch: UpdateSubscriptionRequest,\n\t): Promise<SubscriptionDetail> {\n\t\treturn this.request<SubscriptionDetail>(\n\t\t\t\"PATCH\",\n\t\t\t`/api/subscriptions/${id}`,\n\t\t\tpatch,\n\t\t);\n\t}\n\n\tasync pause(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.request<SubscriptionDetail>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/pause`,\n\t\t);\n\t}\n\n\tasync resume(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.request<SubscriptionDetail>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/resume`,\n\t\t);\n\t}\n\n\tasync delete(id: string): Promise<{ ok: true }> {\n\t\treturn this.request<{ ok: true }>(\"DELETE\", `/api/subscriptions/${id}`);\n\t}\n\n\tasync rotateSecret(id: string): Promise<RotateSecretResponse> {\n\t\treturn this.request<RotateSecretResponse>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/rotate-secret`,\n\t\t);\n\t}\n\n\t/** Send a one-off test webhook to the subscription's URL (built for its\n\t * format, SSRF-guarded). Logged as a delivery row, visible via recentDeliveries. */\n\tasync test(id: string): Promise<SubscriptionTestResult> {\n\t\treturn this.request<SubscriptionTestResult>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/test`,\n\t\t);\n\t}\n\n\tasync recentDeliveries(id: string): Promise<{ data: DeliveryRow[] }> {\n\t\treturn this.request<{ data: DeliveryRow[] }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subscriptions/${id}/deliveries`,\n\t\t);\n\t}\n\n\tasync replay(\n\t\tid: string,\n\t\trange: { fromBlock: number; toBlock: number; force?: string },\n\t): Promise<ReplayResult> {\n\t\treturn this.request<ReplayResult>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/replay`,\n\t\t\trange,\n\t\t);\n\t}\n\n\tasync dead(id: string): Promise<{ data: DeadRow[] }> {\n\t\treturn this.request<{ data: DeadRow[] }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subscriptions/${id}/dead`,\n\t\t);\n\t}\n\n\tasync requeueDead(id: string, outboxId: string): Promise<{ ok: true }> {\n\t\treturn this.request<{ ok: true }>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/dead/${outboxId}/requeue`,\n\t\t);\n\t}\n}\n",
|
|
20
21
|
"import type { SubgraphSummary } from \"@secondlayer/shared/schemas\";\nimport { ApiKeys } from \"./api-keys/client.ts\";\nimport { BaseClient } from \"./base.ts\";\nimport type { SecondLayerOptions } from \"./base.ts\";\nimport { Contracts } from \"./contracts/client.ts\";\nimport { Index } from \"./index-api/client.ts\";\nimport type { IndexTip } from \"./index-api/client.ts\";\nimport { Projects } from \"./projects/client.ts\";\nimport { createStreamsClient } from \"./streams/client.ts\";\nimport type { StreamsClient, StreamsTip } from \"./streams/types.ts\";\nimport { Subgraphs } from \"./subgraphs/client.ts\";\nimport type { SubgraphOperationStatus } from \"./subgraphs/client.ts\";\nimport { Subscriptions } from \"./subscriptions/client.ts\";\n\nexport interface ContextAccount {\n\temail: string;\n\tplan: string;\n}\n\n/** Compact project view for {@link ContextSnapshot}. */\nexport interface ContextProject {\n\tname: string;\n\tslug: string;\n\tnetwork: string;\n}\n\n/** Compact API-key view for {@link ContextSnapshot} — never the plaintext. */\nexport interface ContextApiKey {\n\tprefix: string;\n\tname: string | null;\n\tstatus: string;\n\tproduct: string;\n}\n\nexport interface ActiveSubgraphOperation {\n\tsubgraph: string;\n\toperationId: string;\n\tkind: SubgraphOperationStatus[\"kind\"];\n\tstatus: SubgraphOperationStatus[\"status\"];\n\tprogress: number | null;\n}\n\n/**\n * A point-in-time orientation snapshot for an agent: who you are, the live tips,\n * and what you own. Each field is `null` when it couldn't be read (e.g. no key,\n * or a free-tier key for a Build+ surface) so the snapshot never throws.\n */\nexport interface ContextSnapshot {\n\taccount: ContextAccount | null;\n\tstreamsTip: StreamsTip | null;\n\tindexTip: IndexTip | null;\n\tsubgraphs: SubgraphSummary[] | null;\n\tsubscriptions: { count: number; byStatus: Record<string, number> } | null;\n\t/** The account's projects (null when unreadable — e.g. a scoped key). */\n\tprojects: ContextProject[] | null;\n\t/** The account's API keys, metadata only (null when unreadable). */\n\tapiKeys: ContextApiKey[] | null;\n\t/** In-flight reindex operations (bounded to subgraphs reporting `reindexing`). */\n\tactiveOperations: ActiveSubgraphOperation[] | null;\n}\n\nexport class SecondLayer extends BaseClient {\n\treadonly streams: StreamsClient;\n\treadonly index: Index;\n\treadonly contracts: Contracts;\n\treadonly subgraphs: Subgraphs;\n\treadonly subscriptions: Subscriptions;\n\treadonly apiKeys: ApiKeys;\n\treadonly projects: Projects;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t\tthis.streams = createStreamsClient({\n\t\t\tapiKey: options.apiKey ?? \"\",\n\t\t\tbaseUrl: options.baseUrl,\n\t\t\tfetchImpl: options.fetchImpl,\n\t\t\tdumpsBaseUrl: options.dumpsBaseUrl,\n\t\t});\n\t\tthis.index = new Index(options);\n\t\tthis.contracts = new Contracts(options);\n\t\tthis.subgraphs = new Subgraphs(options);\n\t\tthis.subscriptions = new Subscriptions(options);\n\t\tthis.apiKeys = new ApiKeys(options);\n\t\tthis.projects = new Projects(options);\n\t}\n\n\t/**\n\t * Assemble a {@link ContextSnapshot} — the same orientation an MCP agent reads\n\t * from `secondlayer://context`, but available to any SDK/CLI consumer. Reads\n\t * run concurrently and degrade to `null` per field on failure.\n\t */\n\t/**\n\t * Up to 10 public reads in one round trip (`POST /v1/batch`). Each item\n\t * keeps its own auth/quota/x402 semantics; forwarded credentials (API key,\n\t * PAYMENT-BALANCE/SESSION) apply to every item.\n\t */\n\tasync batch(\n\t\trequests: Array<{\n\t\t\tpath: string;\n\t\t\tparams?: Record<string, string | number | boolean>;\n\t\t}>,\n\t): Promise<{\n\t\tresults: Array<{ path: string | null; status: number; body: unknown }>;\n\t}> {\n\t\treturn this.request(\"POST\", \"/v1/batch\", { requests });\n\t}\n\n\tasync context(): Promise<ContextSnapshot> {\n\t\tconst safe = <T>(p: Promise<T>): Promise<T | null> =>\n\t\t\tp.then((v) => v).catch(() => null);\n\n\t\tconst [\n\t\t\taccount,\n\t\t\tstreamsTip,\n\t\t\tindexEnv,\n\t\t\tsubgraphsRes,\n\t\t\tsubscriptionsRes,\n\t\t\tprojectsRes,\n\t\t\tapiKeysRes,\n\t\t] = await Promise.all([\n\t\t\tsafe(this.request<ContextAccount>(\"GET\", \"/api/accounts/me\")),\n\t\t\tsafe(this.streams.tip()),\n\t\t\tsafe(this.index.canonical.list({ limit: 1 })),\n\t\t\tsafe(this.subgraphs.list()),\n\t\t\tsafe(this.subscriptions.list()),\n\t\t\tsafe(this.projects.list()),\n\t\t\tsafe(this.apiKeys.list()),\n\t\t]);\n\n\t\tconst subgraphs = subgraphsRes?.data ?? null;\n\n\t\tlet subscriptions: ContextSnapshot[\"subscriptions\"] = null;\n\t\tif (subscriptionsRes) {\n\t\t\tconst byStatus: Record<string, number> = {};\n\t\t\tfor (const s of subscriptionsRes.data) {\n\t\t\t\tbyStatus[s.status] = (byStatus[s.status] ?? 0) + 1;\n\t\t\t}\n\t\t\tsubscriptions = { count: subscriptionsRes.data.length, byStatus };\n\t\t}\n\n\t\t// In-flight ops: only probe subgraphs that report `reindexing`, so this\n\t\t// stays cheap (usually zero extra calls) instead of N+1 over every subgraph.\n\t\tlet activeOperations: ActiveSubgraphOperation[] | null = null;\n\t\tif (subgraphs) {\n\t\t\tconst probed = await Promise.all(\n\t\t\t\tsubgraphs\n\t\t\t\t\t.filter((s) => s.status === \"reindexing\")\n\t\t\t\t\t.map(async (s) => {\n\t\t\t\t\t\tconst res = await safe(this.subgraphs.operations(s.name));\n\t\t\t\t\t\tconst op = res?.operations.find(\n\t\t\t\t\t\t\t(o) => o.status === \"queued\" || o.status === \"running\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn op\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tsubgraph: s.name,\n\t\t\t\t\t\t\t\t\toperationId: op.id,\n\t\t\t\t\t\t\t\t\tkind: op.kind,\n\t\t\t\t\t\t\t\t\tstatus: op.status,\n\t\t\t\t\t\t\t\t\tprogress: op.progress,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t}),\n\t\t\t);\n\t\t\tactiveOperations = probed.filter(\n\t\t\t\t(o): o is ActiveSubgraphOperation => o !== null,\n\t\t\t);\n\t\t}\n\n\t\tconst projects: ContextProject[] | null = projectsRes\n\t\t\t? projectsRes.projects.map((p) => ({\n\t\t\t\t\tname: p.name,\n\t\t\t\t\tslug: p.slug,\n\t\t\t\t\tnetwork: p.network,\n\t\t\t\t}))\n\t\t\t: null;\n\n\t\tconst apiKeys: ContextApiKey[] | null = apiKeysRes\n\t\t\t? apiKeysRes.keys.map((k) => ({\n\t\t\t\t\tprefix: k.prefix,\n\t\t\t\t\tname: k.name,\n\t\t\t\t\tstatus: k.status,\n\t\t\t\t\tproduct: k.product,\n\t\t\t\t}))\n\t\t\t: null;\n\n\t\treturn {\n\t\t\taccount,\n\t\t\tstreamsTip,\n\t\t\tindexTip: indexEnv?.tip ?? null,\n\t\t\tsubgraphs,\n\t\t\tsubscriptions,\n\t\t\tprojects,\n\t\t\tapiKeys,\n\t\t\tactiveOperations,\n\t\t};\n\t}\n}\n",
|
|
21
22
|
"import type { InferSubgraphClient } from \"@secondlayer/subgraphs\";\nimport type { SecondLayerOptions } from \"../base.ts\";\nimport { SecondLayer } from \"../client.ts\";\nimport { Subgraphs } from \"./client.ts\";\n\n/**\n * Returns a typed client for a subgraph defined with `defineSubgraph()`.\n *\n * Accepts a plain options object, a `SecondLayer` instance, or a `Subgraphs` instance.\n *\n * @example\n * ```ts\n * import mySubgraph from './subgraphs/my-subgraph'\n * import { getSubgraph } from '@secondlayer/sdk'\n *\n * const client = getSubgraph(mySubgraph, { apiKey: 'sl_...' })\n * const rows = await client.transfers.findMany({ where: { sender: 'SP...' } })\n * ```\n */\nexport function getSubgraph<\n\tT extends { name: string; schema: Record<string, unknown> },\n>(\n\tdef: T,\n\toptions: Partial<SecondLayerOptions> | SecondLayer | Subgraphs = {},\n): InferSubgraphClient<T> {\n\tif (options instanceof Subgraphs) {\n\t\treturn options.typed(def);\n\t}\n\tif (options instanceof SecondLayer) {\n\t\treturn options.subgraphs.typed(def);\n\t}\n\treturn new Subgraphs(options).typed(def);\n}\n"
|
|
22
23
|
],
|
|
23
|
-
"mappings": ";AAmBO,MAAM,iBAAiB,MAAM;AAAA,EAG3B;AAAA,EAGA;AAAA,EAEA;AAAA,EAPR,WAAW,CAEH,QACP,SAEO,MAEA,MACN;AAAA,IACD,MAAM,OAAO;AAAA,IAPN;AAAA,IAGA;AAAA,IAEA;AAAA,IAGP,KAAK,OAAO;AAAA;AAEd;AAAA;AAMO,MAAM,6BAA6B,SAAS;AAAA,EAE1C;AAAA,EACA;AAAA,EAFR,WAAW,CACH,gBACA,iBACP,UAAU,8BAA8B,4BAA4B,kBACnE;AAAA,IACD,MAAM,KAA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