@secondlayer/shared 18.0.1 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/src/archive/range-digest.d.ts +8 -0
  2. package/dist/src/archive/semantic-digest-builder.d.ts +8 -0
  3. package/dist/src/coverage/index.d.ts +9 -341
  4. package/dist/src/coverage/index.js +2 -751
  5. package/dist/src/coverage/index.js.map +4 -13
  6. package/dist/src/db/index.d.ts +10 -1
  7. package/dist/src/db/index.js +2 -1
  8. package/dist/src/db/index.js.map +4 -4
  9. package/dist/src/db/queries/api-keys.d.ts +38 -0
  10. package/dist/src/db/queries/api-keys.js +89 -0
  11. package/dist/src/db/queries/api-keys.js.map +11 -0
  12. package/dist/src/db/queries/chain-reorgs.d.ts +8 -0
  13. package/dist/src/db/queries/chain-reorgs.js +2 -1
  14. package/dist/src/db/queries/chain-reorgs.js.map +4 -4
  15. package/dist/src/db/queries/contracts.d.ts +8 -0
  16. package/dist/src/db/queries/contracts.js.map +2 -2
  17. package/dist/src/db/queries/instance.d.ts +8 -0
  18. package/dist/src/db/queries/integrity.d.ts +8 -0
  19. package/dist/src/db/queries/subgraph-gaps.d.ts +8 -0
  20. package/dist/src/db/queries/subgraph-operations.d.ts +8 -0
  21. package/dist/src/db/queries/subgraphs.d.ts +8 -0
  22. package/dist/src/db/queries/sync-scope.d.ts +8 -0
  23. package/dist/src/db/queries/webhook-replays.d.ts +8 -0
  24. package/dist/src/db/queries/webhooks.d.ts +8 -0
  25. package/dist/src/db/schema.d.ts +9 -1
  26. package/dist/src/db/schema.js.map +2 -2
  27. package/dist/src/index.d.ts +10 -1
  28. package/dist/src/index.js +2 -1
  29. package/dist/src/index.js.map +4 -4
  30. package/dist/src/insights/index.d.ts +8 -0
  31. package/dist/src/leader.js +2 -1
  32. package/dist/src/leader.js.map +4 -4
  33. package/dist/src/node/local-client.d.ts +8 -0
  34. package/dist/src/queue/listener.js +2 -1
  35. package/dist/src/queue/listener.js.map +4 -4
  36. package/dist/src/runtime/index.d.ts +1 -120
  37. package/dist/src/runtime/index.js +1 -310
  38. package/dist/src/runtime/index.js.map +3 -7
  39. package/dist/src/streams-rows/index.d.ts +0 -12
  40. package/dist/src/streams-rows/index.js +2 -3
  41. package/dist/src/streams-rows/index.js.map +8 -8
  42. package/migrations/0216_events_total_baseline.ts +26 -0
  43. package/package.json +6 -2
@@ -1,22 +1,18 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/db/transition.ts", "../src/runtime/modules.ts", "../src/runtime/supervisor.ts", "../src/runtime/isolate.ts", "../src/runtime/migrate-embed.ts", "../src/runtime/config.ts", "../src/runtime/status.ts", "../src/runtime/backup.ts", "../src/runtime/upgrade.ts", "../src/runtime/guardrails.ts", "../src/runtime/resources.ts", "../src/runtime/preflight.ts", "../src/runtime/commands.ts"],
3
+ "sources": ["../src/db/transition.ts", "../src/runtime/modules.ts", "../src/runtime/supervisor.ts", "../src/runtime/config.ts", "../src/runtime/backup.ts", "../src/runtime/guardrails.ts", "../src/runtime/resources.ts", "../src/runtime/preflight.ts", "../src/runtime/commands.ts"],
4
4
  "sourcesContent": [
5
5
  "import { type Kysely, sql } from \"kysely\";\n\n/**\n * The one convention for state machines: states are a const array (mirrored by\n * a DB CHECK), transitions are a table next to the states, and every status\n * write goes through `casTransition`.\n */\n\nexport interface Machine<S extends string> {\n\treadonly states: readonly S[];\n\tcanTransition(from: S, to: S): boolean;\n\t/** Throws on an illegal move. */\n\tassert(from: S, to: S): void;\n}\n\n/** Pure transition table. `transitions` lists, per state, the states it may move to. */\nexport function defineMachine<const S extends string>(def: {\n\tstates: readonly S[];\n\ttransitions: { readonly [K in S]?: readonly S[] };\n}): Machine<S> {\n\tconst canTransition = (from: S, to: S) =>\n\t\tdef.transitions[from]?.includes(to) ?? false;\n\treturn {\n\t\tstates: def.states,\n\t\tcanTransition,\n\t\tassert(from, to) {\n\t\t\tif (!canTransition(from, to)) {\n\t\t\t\tthrow new Error(`illegal transition ${from} -> ${to}`);\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport interface CasTransition<S extends string> {\n\ttable: string;\n\t/** Value of the row key. */\n\tid: string | number;\n\t/** Row key column, `id` unless the table is addressed by another unique column (`name`). */\n\tkey?: string;\n\t/** Status column, `status` unless the machine lives in another column. */\n\tcolumn?: string;\n\t/** The row moves only if it is currently in one of these states. */\n\tfrom: readonly S[];\n\tto: S;\n\t/** Extra columns written in the same statement. Wrap jsonb values with `jsonb()`. */\n\tset?: Record<string, unknown>;\n\t/** Stamp `updated_at = now()`. Pass `false` for tables without that column. */\n\tstampUpdatedAt?: boolean;\n\t/** Columns to return, `*` unless the row carries a large payload (`[\"sequence\"]`). */\n\treturning?: readonly string[];\n}\n\n/**\n * Compare-and-swap a status column: `UPDATE ... WHERE key = ? AND column = ANY(from)`.\n * Returns the updated row (or the `returning` columns), or `null` when the row was missing or not in a `from`\n * state (a lost race). The caller decides what `null` means; usually log and stop.\n * Works with `db` and inside a transaction (`trx`).\n */\nexport async function casTransition<\n\tS extends string,\n\t// biome-ignore lint/suspicious/noExplicitAny: dynamic table name, row shape is the caller's\n\tRow = Record<string, any>,\n>(\n\t// biome-ignore lint/suspicious/noExplicitAny: accepts Kysely<Database> and Transaction<Database>\n\tdb: Kysely<any>,\n\tt: CasTransition<S>,\n): Promise<Row | null> {\n\tconst column = sql.id(t.column ?? \"status\");\n\tconst assignments = [sql`${column} = ${t.to}`];\n\tif (t.stampUpdatedAt !== false) assignments.push(sql`updated_at = now()`);\n\tfor (const [key, value] of Object.entries(t.set ?? {})) {\n\t\tassignments.push(sql`${sql.id(key)} = ${value}`);\n\t}\n\n\tconst returning = t.returning\n\t\t? sql.join(t.returning.map((c) => sql.id(c)))\n\t\t: sql.raw(\"*\");\n\n\tconst { rows } = await sql<Row>`\n\t\tUPDATE ${sql.table(t.table)}\n\t\tSET ${sql.join(assignments)}\n\t\tWHERE ${sql.id(t.key ?? \"id\")} = ${t.id} AND ${column} = ANY(${sql.val([...t.from])})\n\t\tRETURNING ${returning}\n\t`.execute(db);\n\treturn rows[0] ?? null;\n}\n",
6
6
  "/**\n * Lifecycle modules — each runtime plane exposes start/stop/health so a\n * supervisor can restart one without taking the others down.\n */\n\nimport { type Machine, defineMachine } from \"../db/transition.ts\";\n\nexport const MODULE_IDS = [\n\t\"api\",\n\t\"ingest\",\n\t\"decoder\",\n\t\"subgraph\",\n\t\"notification\",\n\t\"publisher\",\n] as const;\nexport type ModuleId = (typeof MODULE_IDS)[number];\n\nexport const MODULE_STATES = [\n\t\"stopped\",\n\t\"starting\",\n\t\"running\",\n\t\"degraded\",\n\t\"failed\",\n] as const;\nexport type ModuleState = (typeof MODULE_STATES)[number];\n\n/**\n * Legal module moves. `starting` is only entered from `stopped` or `failed`,\n * so a second `start` of a live module is a no-op instead of a double start;\n * every state can be stopped except `stopped` itself.\n */\nexport const MODULE_MACHINE: Machine<ModuleState> = defineMachine({\n\tstates: MODULE_STATES,\n\ttransitions: {\n\t\tstopped: [\"starting\"],\n\t\tstarting: [\"running\", \"degraded\", \"failed\", \"stopped\"],\n\t\trunning: [\"degraded\", \"failed\", \"stopped\"],\n\t\tdegraded: [\"running\", \"failed\", \"stopped\"],\n\t\tfailed: [\"starting\", \"stopped\"],\n\t},\n});\n\nexport type ModuleHealth = {\n\tid: ModuleId;\n\tstate: ModuleState;\n\tdetail: string | null;\n\trestarts: number;\n};\n\nexport type RuntimeModule = {\n\tid: ModuleId;\n\tstart: () => Promise<void>;\n\tstop: () => Promise<void>;\n\thealth: () => ModuleHealth;\n};\n\nexport const DEFAULT_PROFILE: readonly ModuleId[] = [\n\t\"api\",\n\t\"ingest\",\n\t\"decoder\",\n\t\"subgraph\",\n\t\"notification\",\n];\n\nexport const PUBLISHER_PROFILE: readonly ModuleId[] = [\"publisher\"];\n\nexport function isModuleId(value: string): value is ModuleId {\n\treturn (MODULE_IDS as readonly string[]).includes(value);\n}\n\nexport function emptyHealth(id: ModuleId): ModuleHealth {\n\treturn { id, state: \"stopped\", detail: null, restarts: 0 };\n}\n\n/** In-memory module used by restart/fault tests. */\nexport function createMemoryModule(\n\tid: ModuleId,\n\topts?: {\n\t\tfailStart?: boolean;\n\t\tloop?: boolean;\n\t\tonStart?: () => void;\n\t\tonStop?: () => void;\n\t},\n): RuntimeModule & { setState: (state: ModuleState, detail?: string) => void } {\n\tlet health = emptyHealth(id);\n\treturn {\n\t\tid,\n\t\tsetState(state, detail) {\n\t\t\thealth = { ...health, state, detail: detail ?? health.detail };\n\t\t},\n\t\tasync start() {\n\t\t\tif (opts?.failStart) {\n\t\t\t\thealth = {\n\t\t\t\t\t...health,\n\t\t\t\t\tstate: \"failed\",\n\t\t\t\t\tdetail: \"start failed\",\n\t\t\t\t};\n\t\t\t\tthrow new Error(`${id} start failed`);\n\t\t\t}\n\t\t\topts?.onStart?.();\n\t\t\thealth = {\n\t\t\t\t...health,\n\t\t\t\tstate: opts?.loop ? \"failed\" : \"running\",\n\t\t\t\tdetail: opts?.loop ? \"loop contained\" : null,\n\t\t\t\trestarts: health.restarts,\n\t\t\t};\n\t\t\tif (opts?.loop) throw new Error(`${id} loop`);\n\t\t},\n\t\tasync stop() {\n\t\t\topts?.onStop?.();\n\t\t\thealth = { ...health, state: \"stopped\" };\n\t\t},\n\t\thealth: () => health,\n\t};\n}\n",
7
7
  "/**\n * Unified supervisor — start a profile, contain per-module faults, aggregate\n * health so unrelated reads stay up when one loop dies.\n */\n\nimport {\n\tMODULE_MACHINE,\n\ttype ModuleHealth,\n\ttype ModuleId,\n\ttype RuntimeModule,\n\temptyHealth,\n} from \"./modules.ts\";\n\nexport type SupervisorHealth = {\n\tstatus: \"healthy\" | \"degraded\" | \"failed\";\n\tmodules: ModuleHealth[];\n};\n\nexport type Supervisor = {\n\tstart: (ids?: readonly ModuleId[]) => Promise<void>;\n\tstop: (id?: ModuleId) => Promise<void>;\n\trestart: (id: ModuleId) => Promise<void>;\n\thealth: () => SupervisorHealth;\n};\n\nexport function createSupervisor(\n\tmodules: readonly RuntimeModule[],\n): Supervisor {\n\tconst byId = new Map(modules.map((m) => [m.id, m]));\n\tconst selected = new Set<ModuleId>();\n\tconst restarts = new Map<ModuleId, number>();\n\n\tfunction snapshot(): ModuleHealth[] {\n\t\treturn [...byId.values()].map((mod) => {\n\t\t\tconst health = selected.has(mod.id) ? mod.health() : emptyHealth(mod.id);\n\t\t\treturn { ...health, restarts: restarts.get(mod.id) ?? health.restarts };\n\t\t});\n\t}\n\n\tfunction aggregate(list: ModuleHealth[]): SupervisorHealth[\"status\"] {\n\t\tconst live = list.filter((m) => selected.has(m.id));\n\t\tif (live.length === 0) return \"failed\";\n\t\tif (live.every((m) => m.state === \"failed\" || m.state === \"stopped\")) {\n\t\t\treturn \"failed\";\n\t\t}\n\t\tif (live.some((m) => m.state === \"failed\" || m.state === \"degraded\")) {\n\t\t\treturn \"degraded\";\n\t\t}\n\t\tif (live.every((m) => m.state === \"running\")) return \"healthy\";\n\t\treturn \"degraded\";\n\t}\n\n\t/** Stop a module unless it is already stopped. */\n\tasync function stopIfLive(mod: RuntimeModule): Promise<void> {\n\t\tif (MODULE_MACHINE.canTransition(mod.health().state, \"stopped\")) {\n\t\t\tawait mod.stop();\n\t\t}\n\t}\n\n\treturn {\n\t\tasync start(ids) {\n\t\t\tconst targets = ids ?? [...byId.keys()];\n\t\t\tfor (const id of targets) {\n\t\t\t\tconst mod = byId.get(id);\n\t\t\t\tif (!mod) continue;\n\t\t\t\tselected.add(id);\n\t\t\t\t// A live module is already started; starting it twice would run its\n\t\t\t\t// loops twice.\n\t\t\t\tif (!MODULE_MACHINE.canTransition(mod.health().state, \"starting\")) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait mod.start();\n\t\t\t\t} catch {\n\t\t\t\t\t// contained — other modules still start\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tasync stop(id) {\n\t\t\tif (id) {\n\t\t\t\tconst mod = byId.get(id);\n\t\t\t\tif (mod && selected.has(id)) await stopIfLive(mod);\n\t\t\t\tselected.delete(id);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (const mid of [...selected]) {\n\t\t\t\tconst mod = byId.get(mid);\n\t\t\t\tif (mod) await stopIfLive(mod);\n\t\t\t\tselected.delete(mid);\n\t\t\t}\n\t\t},\n\t\tasync restart(id) {\n\t\t\tconst mod = byId.get(id);\n\t\t\tif (!mod) throw new Error(`unknown module ${id}`);\n\t\t\tif (selected.has(id)) await stopIfLive(mod);\n\t\t\tselected.add(id);\n\t\t\trestarts.set(id, (restarts.get(id) ?? 0) + 1);\n\t\t\ttry {\n\t\t\t\tawait mod.start();\n\t\t\t} catch {\n\t\t\t\t// contained\n\t\t\t}\n\t\t},\n\t\thealth() {\n\t\t\tconst modules = snapshot();\n\t\t\treturn { status: aggregate(modules), modules };\n\t\t},\n\t};\n}\n",
8
- "/**\n * Handler isolation — untrusted subgraph handlers run behind a timeout,\n * optional network deny, and cannot take down the host process.\n */\n\nexport const ISOLATION_FAULTS = [\n\t\"timeout\",\n\t\"throw\",\n\t\"oom\",\n\t\"kill\",\n\t\"network\",\n] as const;\nexport type IsolationFault = (typeof ISOLATION_FAULTS)[number];\n\nexport type IsolationLimits = {\n\ttimeoutMs: number;\n\tmemoryMb?: number;\n\tallowNetwork?: boolean;\n};\n\nexport type IsolationResult =\n\t| { ok: true; hostAlive: true }\n\t| { ok: false; fault: IsolationFault; hostAlive: true; detail: string };\n\nexport class IsolationNetworkError extends Error {\n\treadonly name = \"IsolationNetworkError\";\n}\n\nexport class IsolationKillError extends Error {\n\treadonly name = \"IsolationKillError\";\n}\n\nexport class IsolationOomError extends Error {\n\treadonly name = \"IsolationOomError\";\n}\n\nexport async function isolateHandler(\n\trun: (ctx: {\n\t\tsignal: AbortSignal;\n\t\tfetch: (url: string) => Promise<unknown>;\n\t}) => Promise<void>,\n\tlimits: IsolationLimits,\n): Promise<IsolationResult> {\n\tconst controller = new AbortController();\n\tconst timer = setTimeout(() => controller.abort(), limits.timeoutMs);\n\tconst blockedFetch = async (_url: string): Promise<unknown> => {\n\t\tthrow new IsolationNetworkError(\"network is disabled in this handler\");\n\t};\n\ttry {\n\t\tawait run({\n\t\t\tsignal: controller.signal,\n\t\t\tfetch: limits.allowNetwork ? (url: string) => fetch(url) : blockedFetch,\n\t\t});\n\t\tif (controller.signal.aborted) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tfault: \"timeout\",\n\t\t\t\thostAlive: true,\n\t\t\t\tdetail: `exceeded ${limits.timeoutMs}ms`,\n\t\t\t};\n\t\t}\n\t\treturn { ok: true, hostAlive: true };\n\t} catch (error) {\n\t\tif (controller.signal.aborted || isAbort(error)) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tfault: \"timeout\",\n\t\t\t\thostAlive: true,\n\t\t\t\tdetail: `exceeded ${limits.timeoutMs}ms`,\n\t\t\t};\n\t\t}\n\t\tif (error instanceof IsolationNetworkError) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tfault: \"network\",\n\t\t\t\thostAlive: true,\n\t\t\t\tdetail: error.message,\n\t\t\t};\n\t\t}\n\t\tif (error instanceof IsolationKillError) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tfault: \"kill\",\n\t\t\t\thostAlive: true,\n\t\t\t\tdetail: error.message,\n\t\t\t};\n\t\t}\n\t\tif (error instanceof IsolationOomError) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tfault: \"oom\",\n\t\t\t\thostAlive: true,\n\t\t\t\tdetail: error.message,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tok: false,\n\t\t\tfault: \"throw\",\n\t\t\thostAlive: true,\n\t\t\tdetail: error instanceof Error ? error.message : String(error),\n\t\t};\n\t} finally {\n\t\tclearTimeout(timer);\n\t}\n}\n\nfunction isAbort(error: unknown): boolean {\n\treturn error instanceof Error && error.name === \"AbortError\";\n}\n",
9
- "/**\n * Embedded migration — advisory-locked before listeners/workers start.\n * Concurrent boots serialize. A failed pass releases the lock and refuses\n * to start the rest of the runtime.\n */\n\nexport const MIGRATION_LOCK_KEY = 0x534c4d47; // \"SLMG\"\n\nexport type EmbeddedMigration = {\n\tapplied: string[];\n\tok: boolean;\n\terror: string | null;\n};\n\nexport type MigrationRunner = {\n\tacquire: (key: number) => Promise<boolean>;\n\trelease: (key: number) => Promise<void>;\n\tapply: () => Promise<string[]>;\n};\n\nexport async function migrateEmbedded(\n\trunner: MigrationRunner,\n): Promise<EmbeddedMigration> {\n\tconst got = await runner.acquire(MIGRATION_LOCK_KEY);\n\tif (!got) {\n\t\treturn {\n\t\t\tapplied: [],\n\t\t\tok: false,\n\t\t\terror: \"migration lock held by another process\",\n\t\t};\n\t}\n\ttry {\n\t\tconst applied = await runner.apply();\n\t\treturn { applied, ok: true, error: null };\n\t} catch (error) {\n\t\treturn {\n\t\t\tapplied: [],\n\t\t\tok: false,\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t};\n\t} finally {\n\t\tawait runner.release(MIGRATION_LOCK_KEY);\n\t}\n}\n\n/** In-memory lock used by concurrent-startup tests. */\nexport function createMemoryMigrationRunner(opts?: {\n\tfail?: boolean;\n\tdelayMs?: number;\n\tsleep?: (ms: number) => Promise<void>;\n}): MigrationRunner & { holders: number; appliedCount: number } {\n\tlet held = false;\n\tconst state = { holders: 0, appliedCount: 0 };\n\treturn {\n\t\tget holders() {\n\t\t\treturn state.holders;\n\t\t},\n\t\tget appliedCount() {\n\t\t\treturn state.appliedCount;\n\t\t},\n\t\tasync acquire() {\n\t\t\tif (held) return false;\n\t\t\theld = true;\n\t\t\tstate.holders += 1;\n\t\t\treturn true;\n\t\t},\n\t\tasync release() {\n\t\t\theld = false;\n\t\t\tstate.holders = Math.max(0, state.holders - 1);\n\t\t},\n\t\tasync apply() {\n\t\t\tif (opts?.delayMs) await (opts.sleep ?? delay)(opts.delayMs);\n\t\t\tif (opts?.fail) throw new Error(\"migration failed\");\n\t\t\tstate.appliedCount += 1;\n\t\t\treturn [\"0116_coverage_schema\"];\n\t\t},\n\t};\n}\n\nfunction delay(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n",
10
8
  "/**\n * Minimal runtime config — six or fewer required non-secret values.\n * Unknown or contradictory values fail before ingest starts.\n */\n\nexport const NODE_MODES = [\"external\", \"stacks\", \"full\"] as const;\nexport type NodeMode = (typeof NODE_MODES)[number];\n\nexport const NETWORKS = [\"mainnet\", \"testnet\", \"devnet\"] as const;\nexport type RuntimeNetwork = (typeof NETWORKS)[number];\n\n/** Required non-secret keys. Secrets (tokens, signing keys) come from `sl init`. */\nexport const REQUIRED_KEYS = [\n\t\"NETWORK\",\n\t\"DATABASE_URL\",\n\t\"NODE_MODE\",\n\t\"DATA_DIR\",\n\t\"API_PORT\",\n\t\"INDEXER_PORT\",\n] as const;\nexport type RequiredConfigKey = (typeof REQUIRED_KEYS)[number];\n\nexport const OPTIONAL_KEYS = [\n\t\"STACKS_NODE_RPC_URL\",\n\t\"LISTEN_HOST\",\n\t\"LOG_LEVEL\",\n\t\"INSTANCE_MODE\",\n\t\"BITCOIN_DATABASE_URL\",\n] as const;\n\nexport const SECRET_KEYS = [\n\t\"INSTANCE_TOKEN\",\n\t\"API_KEY\",\n\t\"SECONDLAYER_SECRETS_KEY\",\n\t\"STREAMS_SIGNING_PRIVATE_KEY\",\n\t\"SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY\",\n\t\"POSTGRES_PASSWORD\",\n\t\"BITCOIN_RPC_PASSWORD\",\n] as const;\n\nexport type RuntimeConfig = {\n\tNETWORK: RuntimeNetwork;\n\tDATABASE_URL: string;\n\tNODE_MODE: NodeMode;\n\tDATA_DIR: string;\n\tAPI_PORT: number;\n\tINDEXER_PORT: number;\n\tSTACKS_NODE_RPC_URL: string | null;\n\tLISTEN_HOST: string;\n\tLOG_LEVEL: string;\n};\n\nexport type ConfigResult =\n\t| { ok: true; config: RuntimeConfig }\n\t| { ok: false; errors: string[] };\n\nconst KNOWN = new Set<string>([\n\t...REQUIRED_KEYS,\n\t...OPTIONAL_KEYS,\n\t...SECRET_KEYS,\n\t\"SOURCE_DATABASE_URL\",\n\t\"TARGET_DATABASE_URL\",\n\t\"INSTANCE_MODE\",\n\t\"NODE_ENV\",\n\t\"ALLOW_UNSIGNED_WEBHOOKS\",\n\t\"OBSERVER_JOURNAL_ENABLED\",\n\t\"STACKS_NETWORK\",\n\t// Set by the shipped image/compose (docker/oss/docker-compose.yml).\n\t\"STREAMS_API_URL\",\n\t\"STREAMS_INTERNAL_API_KEY\",\n\t\"SUBGRAPH_SOURCE\",\n\t\"SUBGRAPH_INDEX_API_URL\",\n\t\"SBTC_DECODER_ENABLED\",\n\t\"BNS_DECODER_ENABLED\",\n\t// Archive publishing. Both sit inside the ARCHIVE_ namespace the refusal\n\t// patrols, so an operator who sets them on a one-box runtime would be told\n\t// their valid config is a typo unless they are named here.\n\t\"ARCHIVE_DIR\",\n\t\"ARCHIVE_PUBLIC_DIR\",\n\t// Escape hatch for the boot-time resource preflight. Setting it is exactly\n\t// the moment an operator must not also be told it is an unknown key.\n\t\"SECONDLAYER_ALLOW_UNDERSIZED\",\n\t// Forward-only instances declare where their history starts; refusing it as\n\t// unknown would block the only way to say \"the prefix is absent on purpose\".\n\t\"SECONDLAYER_SYNC_START_HEIGHT\",\n\t// Read by the webhook emitter (packages/subgraphs/src/runtime/emitter.ts).\n\t// Local and devnet stacks deliver to localhost receivers, which the emitter\n\t// blocks by default, so the compose must be able to lift that block.\n\t\"SECONDLAYER_ALLOW_PRIVATE_EGRESS\",\n]);\n\n/**\n * Namespaces the unknown-key refusal patrols. A real container environ\n * carries dozens of ambient ALL_CAPS vars (PATH, HOME, HOSTNAME, PORT,\n * BUN_*, …) that are not config and must not fail the boot — the refusal\n * exists to catch a misspelled *Secondlayer* key, so it only fires inside\n * our own vocabulary. Required keys are validated separately, so a typo'd\n * required key still fails via its missing-value error.\n */\nconst OWN_PREFIXES = [\n\t\"SECONDLAYER_\",\n\t\"STACKS_\",\n\t\"BITCOIN_\",\n\t\"STREAMS_\",\n\t\"SUBGRAPH_\",\n\t\"OBSERVER_\",\n\t\"INSTANCE_\",\n\t\"ARCHIVE_\",\n] as const;\n\nfunction isOwnNamespace(key: string): boolean {\n\tif (KNOWN.has(key)) return true;\n\treturn OWN_PREFIXES.some((prefix) => key.startsWith(prefix));\n}\n\nexport function parseRuntimeConfig(\n\tenv: Record<string, string | undefined>,\n): ConfigResult {\n\tconst errors: string[] = [];\n\tfor (const key of Object.keys(env)) {\n\t\tif (env[key] === undefined) continue;\n\t\tif (key.startsWith(\"SL_\") || key.startsWith(\"POSTGRES_\")) continue;\n\t\tif (!KNOWN.has(key) && isRuntimeish(key) && isOwnNamespace(key)) {\n\t\t\terrors.push(`unknown config ${key}`);\n\t\t}\n\t}\n\n\tconst network = (env.NETWORK ?? env.STACKS_NETWORK ?? \"\").trim();\n\tif (!isNetwork(network)) {\n\t\terrors.push(\"NETWORK must be mainnet | testnet | devnet\");\n\t}\n\tconst database = (env.DATABASE_URL ?? \"\").trim();\n\tif (!database) errors.push(\"DATABASE_URL is required\");\n\tconst mode = (env.NODE_MODE ?? \"\").trim();\n\tif (!isNodeMode(mode)) {\n\t\terrors.push(\"NODE_MODE must be external | stacks | full\");\n\t}\n\tconst dataDir = (env.DATA_DIR ?? \"/data\").trim();\n\tconst apiPort = parsePort(env.API_PORT ?? \"3800\", \"API_PORT\", errors);\n\tconst indexerPort = parsePort(\n\t\tenv.INDEXER_PORT ?? \"3700\",\n\t\t\"INDEXER_PORT\",\n\t\terrors,\n\t);\n\n\t// The bitcoind password is required with the bundled node, and allowed in\n\t// every mode: the Runes follower reads any Bitcoin node with it.\n\tif (mode === \"full\" && !env.BITCOIN_RPC_PASSWORD) {\n\t\terrors.push(\"NODE_MODE=full requires BITCOIN_RPC_PASSWORD\");\n\t}\n\n\tif (errors.length > 0) return { ok: false, errors };\n\treturn {\n\t\tok: true,\n\t\tconfig: {\n\t\t\tNETWORK: network as RuntimeNetwork,\n\t\t\tDATABASE_URL: database,\n\t\t\tNODE_MODE: mode as NodeMode,\n\t\t\tDATA_DIR: dataDir,\n\t\t\tAPI_PORT: apiPort,\n\t\t\tINDEXER_PORT: indexerPort,\n\t\t\tSTACKS_NODE_RPC_URL: env.STACKS_NODE_RPC_URL?.trim() || null,\n\t\t\tLISTEN_HOST: env.LISTEN_HOST?.trim() || \"0.0.0.0\",\n\t\t\tLOG_LEVEL: env.LOG_LEVEL?.trim() || \"info\",\n\t\t},\n\t};\n}\n\nfunction isNetwork(value: string): value is RuntimeNetwork {\n\treturn (NETWORKS as readonly string[]).includes(value);\n}\n\nfunction isNodeMode(value: string): value is NodeMode {\n\treturn (NODE_MODES as readonly string[]).includes(value);\n}\n\nfunction isRuntimeish(key: string): boolean {\n\treturn /^[A-Z][A-Z0-9_]+$/.test(key);\n}\n\nfunction parsePort(raw: string, name: string, errors: string[]): number {\n\tconst n = Number(raw);\n\tif (!Number.isInteger(n) || n < 1 || n > 65535) {\n\t\terrors.push(`${name} must be a TCP port`);\n\t\treturn 0;\n\t}\n\treturn n;\n}\n",
11
- "/**\n * Status UX — node, raw, decoder, subgraph, queue, archive import, disk,\n * and coverage, each with a next action.\n */\n\nimport type { CoverageState } from \"../coverage/evaluate.ts\";\nimport type { ModuleHealth, ModuleId } from \"./modules.ts\";\nimport type { SupervisorHealth } from \"./supervisor.ts\";\n\nexport const STATUS_PLANES = [\n\t\"node\",\n\t\"raw\",\n\t\"decoder\",\n\t\"subgraph\",\n\t\"queue\",\n\t\"archive\",\n\t\"disk\",\n\t\"coverage\",\n] as const;\nexport type StatusPlane = (typeof STATUS_PLANES)[number];\n\nexport type PlaneStatus = {\n\tplane: StatusPlane;\n\tstate: string;\n\taction: string;\n};\n\nexport type RuntimeStatusReport = {\n\tstatus: SupervisorHealth[\"status\"];\n\tmodules: ModuleHealth[];\n\tplanes: PlaneStatus[];\n};\n\nconst MODULE_TO_PLANE: Partial<Record<ModuleId, StatusPlane>> = {\n\tingest: \"raw\",\n\tdecoder: \"decoder\",\n\tsubgraph: \"subgraph\",\n\tnotification: \"queue\",\n};\n\nexport function reportRuntimeStatus(input: {\n\tsupervisor: SupervisorHealth;\n\tnode?: string;\n\tarchive?: string;\n\tdisk?: string;\n\tcoverage?: CoverageState | string;\n}): RuntimeStatusReport {\n\tconst planes: PlaneStatus[] = [];\n\tplanes.push({\n\t\tplane: \"node\",\n\t\tstate: input.node ?? \"unknown\",\n\t\taction: actionFor(\"node\", input.node ?? \"unknown\"),\n\t});\n\tfor (const mod of input.supervisor.modules) {\n\t\tconst plane = MODULE_TO_PLANE[mod.id];\n\t\tif (!plane) continue;\n\t\tplanes.push({\n\t\t\tplane,\n\t\t\tstate: mod.state,\n\t\t\taction: actionFor(plane, mod.state),\n\t\t});\n\t}\n\tplanes.push({\n\t\tplane: \"archive\",\n\t\tstate: input.archive ?? \"idle\",\n\t\taction: actionFor(\"archive\", input.archive ?? \"idle\"),\n\t});\n\tplanes.push({\n\t\tplane: \"disk\",\n\t\tstate: input.disk ?? \"ok\",\n\t\taction: actionFor(\"disk\", input.disk ?? \"ok\"),\n\t});\n\tplanes.push({\n\t\tplane: \"coverage\",\n\t\tstate: input.coverage ?? \"unknown\",\n\t\taction: actionFor(\"coverage\", String(input.coverage ?? \"unknown\")),\n\t});\n\treturn {\n\t\tstatus: input.supervisor.status,\n\t\tmodules: input.supervisor.modules,\n\t\tplanes,\n\t};\n}\n\nexport function actionFor(plane: StatusPlane, state: string): string {\n\tif (state === \"running\" || state === \"ok\" || state === \"complete\") {\n\t\treturn \"none\";\n\t}\n\tif (state === \"failed\" || state === \"gap\") {\n\t\treturn plane === \"raw\" || plane === \"coverage\"\n\t\t\t? \"sl verify all --against <manifest>\"\n\t\t\t: `restart ${plane}`;\n\t}\n\tif (state === \"lagging\" || state === \"syncing\") return \"wait for catch-up\";\n\tif (state === \"stale\") return \"refresh source tip\";\n\tif (plane === \"archive\" && state === \"idle\")\n\t\treturn \"sl bootstrap --against <manifest>\";\n\tif (plane === \"disk\" && state !== \"ok\") return \"free disk and retry\";\n\tif (plane === \"node\" && state === \"unknown\") return \"sl observer\";\n\treturn \"inspect logs\";\n}\n",
12
9
  "/**\n * Backup bundle — the index, the operator's keys, and the scope they cover.\n *\n * This file holds the pure parts: manifest shape, validation, bundle\n * encryption, and the key canary. The IO (pg_dump, pg_restore, reading and\n * writing bundle files) lives in the CLI command, so everything here stays\n * testable without a database or a filesystem.\n *\n * ## Why there is a canary\n *\n * `SECONDLAYER_SECRETS_KEY` encrypts columns in the database — subgraph\n * connection strings, webhook signing secrets. In OSS mode, if that key is\n * missing when something first needs it, the runtime GENERATES A NEW ONE and\n * persists it (see `crypto/secrets.ts`). That behaviour is right for a fresh\n * install and catastrophic for a restore: bring the database back without its\n * original key and the runtime quietly mints a different one, leaving every\n * encrypted column permanently unreadable. Nothing errors. You find out later.\n *\n * So a backup seals a known plaintext under the live key and stores the\n * ciphertext in the manifest. Restore opens it with the key it is about to\n * install, and refuses if it does not match. That converts a silent, permanent\n * data loss into a loud failure before anything is written.\n */\nimport {\n\tcreateCipheriv,\n\tcreateDecipheriv,\n\trandomBytes,\n\tscryptSync,\n\ttimingSafeEqual,\n} from \"node:crypto\";\n\nexport const BACKUP_MANIFEST_VERSION = 1;\n\nexport const BACKUP_PARTS = [\n\t\"db\",\n\t\"config\",\n\t\"keys\",\n\t\"handlers\",\n\t\"scope\",\n] as const;\nexport type BackupPart = (typeof BACKUP_PARTS)[number];\n\n/**\n * Sealed under the secrets key at backup time and opened at restore time. The\n * value is arbitrary; only the round-trip matters.\n */\nconst CANARY_PLAINTEXT = \"secondlayer-secrets-key-canary-v1\";\n\nconst IV_LEN = 12;\nconst TAG_LEN = 16;\nconst SALT_LEN = 16;\n/** Deliberately expensive: bundle passphrases are chosen by humans. */\nconst SCRYPT_COST = 2 ** 15;\n/**\n * scrypt needs ~128 * N * r bytes (r defaults to 8), which is just over Node's\n * 32 MB default cap at this cost. Raising the ceiling rather than weakening the\n * KDF — the whole point of the cost is that it is uncomfortable.\n */\nconst SCRYPT_MAXMEM = 64 * 1024 * 1024;\nconst SCRYPT_OPTS = { N: SCRYPT_COST, maxmem: SCRYPT_MAXMEM } as const;\n\nexport type BackupManifest = {\n\tschema_version: number;\n\tcreated_at: string;\n\tnetwork: string;\n\tparts: BackupPart[];\n\tencrypted: boolean;\n\tscope: { from_height: number; to_height: number | null };\n\tdb: {\n\t\tfile: string;\n\t\tsha256: string;\n\t\tbytes: number;\n\t\tformat: string;\n\t} | null;\n\t/** Never the secrets themselves — only how to check them. */\n\tsecrets: {\n\t\tfile: string;\n\t\tencrypted: boolean;\n\t\tcanary: string;\n\t} | null;\n\tsignature?: string;\n\tkey_id?: string;\n};\n\nexport type BackupPlan =\n\t| { ok: true; manifest: BackupManifest }\n\t| { ok: false; reason: string };\n\n/**\n * Validate a backup before any bytes are written. Refusing early is the whole\n * point: a bundle that omits the keys looks like a backup and is not one.\n */\nexport function planBackup(input: {\n\tnetwork: string;\n\tfromHeight: number;\n\ttoHeight?: number | null;\n\tincludeSecrets: boolean;\n\tsecretsEncrypted: boolean;\n\tcanary?: string;\n\tnow?: string;\n}): BackupPlan {\n\tif (input.fromHeight < 0) {\n\t\treturn { ok: false, reason: \"scope from_height must be >= 0\" };\n\t}\n\tif (\n\t\tinput.toHeight !== null &&\n\t\tinput.toHeight !== undefined &&\n\t\tinput.toHeight < input.fromHeight\n\t) {\n\t\treturn { ok: false, reason: \"scope to_height is below from_height\" };\n\t}\n\tif (input.includeSecrets && !input.secretsEncrypted) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason:\n\t\t\t\t\"refusing to write plaintext secrets; supply a passphrase or pass the explicit plaintext override\",\n\t\t};\n\t}\n\tif (input.includeSecrets && !input.canary) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason:\n\t\t\t\t\"secrets bundle requires a key canary so a restore can prove the key matches\",\n\t\t};\n\t}\n\n\tconst parts: BackupPart[] = input.includeSecrets\n\t\t? [...BACKUP_PARTS]\n\t\t: BACKUP_PARTS.filter((p) => p !== \"keys\");\n\n\treturn {\n\t\tok: true,\n\t\tmanifest: {\n\t\t\tschema_version: BACKUP_MANIFEST_VERSION,\n\t\t\tcreated_at: input.now ?? new Date().toISOString(),\n\t\t\tnetwork: input.network,\n\t\t\tparts,\n\t\t\tencrypted: input.secretsEncrypted,\n\t\t\tscope: {\n\t\t\t\tfrom_height: input.fromHeight,\n\t\t\t\tto_height: input.toHeight ?? null,\n\t\t\t},\n\t\t\tdb: null,\n\t\t\tsecrets: null,\n\t\t},\n\t};\n}\n\nfunction secretsKeyBuffer(hexKey: string): Buffer {\n\tconst key = Buffer.from(hexKey.trim(), \"hex\");\n\tif (key.length !== 32) {\n\t\tthrow new Error(\"SECONDLAYER_SECRETS_KEY must be 32 bytes hex\");\n\t}\n\treturn key;\n}\n\n/**\n * Seal the canary under an EXPLICIT key.\n *\n * Deliberately not reusing `crypto/secrets.ts`: that module resolves the key\n * from the ambient environment and, in OSS mode, generates and persists one as\n * a side effect when it is missing. Calling it here would mean a backup could\n * mint the very key it is supposed to be preserving.\n */\nexport function sealKeyCanary(secretsKeyHex: string): string {\n\tconst key = secretsKeyBuffer(secretsKeyHex);\n\tconst iv = randomBytes(IV_LEN);\n\tconst cipher = createCipheriv(\"aes-256-gcm\", key, iv);\n\tconst ciphertext = Buffer.concat([\n\t\tcipher.update(CANARY_PLAINTEXT, \"utf8\"),\n\t\tcipher.final(),\n\t]);\n\treturn Buffer.concat([iv, cipher.getAuthTag(), ciphertext]).toString(\n\t\t\"base64\",\n\t);\n}\n\n/** True only when `secretsKeyHex` is the key the canary was sealed with. */\nexport function keyMatchesCanary(\n\tcanaryBase64: string,\n\tsecretsKeyHex: string,\n): boolean {\n\ttry {\n\t\tconst key = secretsKeyBuffer(secretsKeyHex);\n\t\tconst envelope = Buffer.from(canaryBase64, \"base64\");\n\t\tconst iv = envelope.subarray(0, IV_LEN);\n\t\tconst tag = envelope.subarray(IV_LEN, IV_LEN + TAG_LEN);\n\t\tconst ciphertext = envelope.subarray(IV_LEN + TAG_LEN);\n\t\tconst decipher = createDecipheriv(\"aes-256-gcm\", key, iv);\n\t\tdecipher.setAuthTag(tag);\n\t\tconst plaintext = Buffer.concat([\n\t\t\tdecipher.update(ciphertext),\n\t\t\tdecipher.final(),\n\t\t]);\n\t\tconst expected = Buffer.from(CANARY_PLAINTEXT, \"utf8\");\n\t\treturn (\n\t\t\tplaintext.length === expected.length &&\n\t\t\ttimingSafeEqual(plaintext, expected)\n\t\t);\n\t} catch {\n\t\t// A wrong key fails the GCM auth tag, which throws. That is a mismatch,\n\t\t// not an error to propagate.\n\t\treturn false;\n\t}\n}\n\n/**\n * Encrypt the secrets bundle under an operator passphrase.\n * Layout: `salt(16) || iv(12) || authTag(16) || ciphertext`.\n */\nexport function encryptBundle(plaintext: string, passphrase: string): Buffer {\n\tif (!passphrase) throw new Error(\"passphrase is required\");\n\tconst salt = randomBytes(SALT_LEN);\n\tconst key = scryptSync(passphrase, salt, 32, SCRYPT_OPTS);\n\tconst iv = randomBytes(IV_LEN);\n\tconst cipher = createCipheriv(\"aes-256-gcm\", key, iv);\n\tconst ciphertext = Buffer.concat([\n\t\tcipher.update(plaintext, \"utf8\"),\n\t\tcipher.final(),\n\t]);\n\treturn Buffer.concat([salt, iv, cipher.getAuthTag(), ciphertext]);\n}\n\nexport function decryptBundle(envelope: Buffer, passphrase: string): string {\n\tconst salt = envelope.subarray(0, SALT_LEN);\n\tconst iv = envelope.subarray(SALT_LEN, SALT_LEN + IV_LEN);\n\tconst tag = envelope.subarray(SALT_LEN + IV_LEN, SALT_LEN + IV_LEN + TAG_LEN);\n\tconst ciphertext = envelope.subarray(SALT_LEN + IV_LEN + TAG_LEN);\n\tconst key = scryptSync(passphrase, salt, 32, SCRYPT_OPTS);\n\tconst decipher = createDecipheriv(\"aes-256-gcm\", key, iv);\n\tdecipher.setAuthTag(tag);\n\treturn decipher.update(ciphertext).toString(\"utf8\") + decipher.final(\"utf8\");\n}\n\nexport type RestorePrecheck =\n\t| { ok: true }\n\t| { ok: false; reason: string; fatal: boolean };\n\n/**\n * Everything that must hold before a restore writes anything.\n *\n * `fatal` distinguishes \"this bundle can never restore here\" from \"this needs\n * an explicit override\" — the caller surfaces them differently.\n */\nexport function precheckRestore(input: {\n\tmanifest: BackupManifest;\n\ttargetNetwork: string;\n\ttargetIsEmpty: boolean;\n\tforce: boolean;\n\tsecretsKeyHex?: string;\n}): RestorePrecheck {\n\tif (input.manifest.schema_version !== BACKUP_MANIFEST_VERSION) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tfatal: true,\n\t\t\treason: `bundle schema_version ${input.manifest.schema_version} is not supported (expected ${BACKUP_MANIFEST_VERSION})`,\n\t\t};\n\t}\n\tif (input.manifest.network !== input.targetNetwork) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tfatal: true,\n\t\t\treason: `bundle is ${input.manifest.network}; this instance is ${input.targetNetwork}`,\n\t\t};\n\t}\n\tif (!input.targetIsEmpty && !input.force) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tfatal: false,\n\t\t\treason:\n\t\t\t\t\"target database already holds chain data; restoring would overwrite it\",\n\t\t};\n\t}\n\tconst secrets = input.manifest.secrets;\n\tif (secrets) {\n\t\tif (!input.secretsKeyHex) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tfatal: false,\n\t\t\t\treason:\n\t\t\t\t\t\"bundle carries encrypted columns but no secrets key was supplied; restoring now would leave them unreadable\",\n\t\t\t};\n\t\t}\n\t\tif (!keyMatchesCanary(secrets.canary, input.secretsKeyHex)) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tfatal: true,\n\t\t\t\treason:\n\t\t\t\t\t\"the supplied SECONDLAYER_SECRETS_KEY does not match the one this backup was taken with; encrypted columns would be permanently unreadable\",\n\t\t\t};\n\t\t}\n\t}\n\treturn { ok: true };\n}\n",
13
- "/**\n * Upgrade contract — pin image, preflight schema/disk, backup first,\n * migrate, health/verify, document rollback limits.\n *\n * PLANNER ONLY — `applyUpgrade` returns `{applied:true}` without pulling an\n * image, running a preflight, or migrating anything. Nothing in the product\n * calls it. The upgrade operators actually perform is `docker compose pull &&\n * up -d`, with migrations applied at boot by the runtime entrypoint.\n *\n * Same caution as the sibling backup planner: this step list was published as\n * an operator procedure in the self-host docs until 2026-08-15. Make it do the\n * work before presenting it as one.\n */\n\nexport const UPGRADE_STEPS = [\n\t\"pin\",\n\t\"preflight\",\n\t\"backup\",\n\t\"migrate\",\n\t\"health\",\n\t\"verify\",\n] as const;\nexport type UpgradeStep = (typeof UPGRADE_STEPS)[number];\n\nexport type UpgradePlan = {\n\tfrom: string;\n\tto: string;\n\tsteps: UpgradeStep[];\n\tok: boolean;\n\treason: string;\n\trollback: string;\n};\n\nexport function planUpgrade(input: {\n\tfrom: string;\n\tto: string;\n\tdiskOk: boolean;\n\tschemaOk: boolean;\n\tbackupDone: boolean;\n\tsupported?: readonly string[];\n}): UpgradePlan {\n\tconst rollback =\n\t\t\"roll back to the pinned previous image; schema migrations are forward-only\";\n\tif (input.from === input.to) {\n\t\treturn {\n\t\t\tfrom: input.from,\n\t\t\tto: input.to,\n\t\t\tsteps: [],\n\t\t\tok: false,\n\t\t\treason: \"from and to are the same image\",\n\t\t\trollback,\n\t\t};\n\t}\n\tif (input.supported && !input.supported.includes(input.to)) {\n\t\treturn {\n\t\t\tfrom: input.from,\n\t\t\tto: input.to,\n\t\t\tsteps: [],\n\t\t\tok: false,\n\t\t\treason: `image ${input.to} is not in the supported matrix`,\n\t\t\trollback,\n\t\t};\n\t}\n\tif (!input.diskOk) {\n\t\treturn {\n\t\t\tfrom: input.from,\n\t\t\tto: input.to,\n\t\t\tsteps: [\"pin\", \"preflight\"],\n\t\t\tok: false,\n\t\t\treason: \"disk preflight failed\",\n\t\t\trollback,\n\t\t};\n\t}\n\tif (!input.schemaOk) {\n\t\treturn {\n\t\t\tfrom: input.from,\n\t\t\tto: input.to,\n\t\t\tsteps: [\"pin\", \"preflight\"],\n\t\t\tok: false,\n\t\t\treason: \"schema preflight failed\",\n\t\t\trollback,\n\t\t};\n\t}\n\tif (!input.backupDone) {\n\t\treturn {\n\t\t\tfrom: input.from,\n\t\t\tto: input.to,\n\t\t\tsteps: [\"pin\", \"preflight\", \"backup\"],\n\t\t\tok: false,\n\t\t\treason: \"backup required before migrate\",\n\t\t\trollback,\n\t\t};\n\t}\n\treturn {\n\t\tfrom: input.from,\n\t\tto: input.to,\n\t\tsteps: [...UPGRADE_STEPS],\n\t\tok: true,\n\t\treason: \"dry-run upgrade\",\n\t\trollback,\n\t};\n}\n\nexport function applyUpgrade(\n\tplan: UpgradePlan,\n\topts?: { apply?: boolean },\n): { ok: boolean; applied: boolean; reason: string } {\n\tif (!plan.ok) return { ok: false, applied: false, reason: plan.reason };\n\tif (!opts?.apply) return { ok: true, applied: false, reason: plan.reason };\n\treturn { ok: true, applied: true, reason: \"upgrade applied\" };\n}\n",
14
10
  "/**\n * Resource guardrails — preflight RAM/disk/Postgres and estimate growth.\n * Constrained fixtures fail early.\n *\n * The disk numbers here were wrong by 3-6x until 2026-08-15: they promised a\n * full-history mainnet index would fit in 80 GB, and estimated growth at 1 GB\n * per 100k blocks. The reference index measured 504 GB at height 8,771,873.\n * An operator who sized a box from these figures would have filled the disk\n * partway through their first bootstrap, so every constant below now cites what\n * it was measured against.\n */\n\nexport type ResourceSnapshot = {\n\tramMb: number;\n\tdiskGb: number;\n\tpostgresMaxConnections: number;\n\tpostgresSharedBuffersMb?: number;\n};\n\nexport type DiskEstimates = {\n\t/** blocks + transactions + events, no decoded plane. */\n\tdiskGbPer100kBlocks: number;\n\t/** Same, plus a broad decoder set writing `decoded_events`. */\n\tdiskGbPer100kBlocksDecoded: number;\n};\n\nexport type GuardrailResult =\n\t| { ok: true; estimates: DiskEstimates }\n\t| { ok: false; errors: string[] };\n\nexport type GuardrailNetwork = \"mainnet\" | \"testnet\" | \"devnet\";\n\n/**\n * Measured on the mainnet reference index at height 8,771,873 (2026-08-15):\n * `blocks` 3.5 GB + `transactions` 55 GB + `events` 189 GB = 247 GB of core\n * datasets, and 504 GB total with a broad decoder set (`decoded_events` alone\n * is 253 GB).\n *\n * These are averages over all history, and history is not uniform — early\n * heights are far sparser than recent ones, so a forward-looking operator\n * should treat them as a lower bound on future growth rather than a constant.\n */\nconst MEASURED_DISK: DiskEstimates = {\n\tdiskGbPer100kBlocks: 3,\n\tdiskGbPer100kBlocksDecoded: 6,\n};\n\nexport const FLOORS = {\n\tappRamMb: 4096,\n\tfullRamMb: 98304,\n\t/**\n\t * Mainnet full history: 504 GB measured today, growing ~0.5 GB/day at the\n\t * observed block rate. 600 leaves roughly six months of headroom, which is\n\t * the point of a floor — a box that fits exactly today fails within weeks.\n\t */\n\tmainnetAppDiskGb: 600,\n\t/**\n\t * Testnet/devnet carry a fraction of mainnet's history. Unmeasured; retained\n\t * as the long-standing default rather than replaced with a fresh guess.\n\t */\n\tappDiskGb: 80,\n\t/**\n\t * Bundled node on mainnet. The Stacks chainstate alone measured 1.3 TB on\n\t * the reference node (2026-08-15), and the index adds ~500 GB; bitcoind is\n\t * additional and not measured here. The previous 1.5 TB floor was below the\n\t * two components we HAVE measured.\n\t */\n\tmainnetFullDiskGb: 2500,\n\t/** Bundled node, non-mainnet. Unmeasured; retained default. */\n\tfullDiskGb: 1500,\n\tpostgresMaxConnections: 50,\n} as const;\n\n/** The disk floor that applies to a given mode and network. */\nexport function diskFloorGb(\n\tmode: \"external\" | \"stacks\" | \"full\",\n\tnetwork: GuardrailNetwork,\n): number {\n\tif (mode === \"full\") {\n\t\treturn network === \"mainnet\" ? FLOORS.mainnetFullDiskGb : FLOORS.fullDiskGb;\n\t}\n\treturn network === \"mainnet\" ? FLOORS.mainnetAppDiskGb : FLOORS.appDiskGb;\n}\n\n/**\n * A dimension the caller could not measure is absent, not zero. Skipping it\n * keeps an unreadable `statfs` from presenting as a 0 GB disk and refusing a\n * perfectly adequate box.\n */\nexport function preflightResources(\n\tsnap: Partial<ResourceSnapshot>,\n\tmode: \"external\" | \"stacks\" | \"full\",\n\t// Defaults to the strictest network: an unspecified caller should be told it\n\t// needs more disk than it does, never less.\n\tnetwork: GuardrailNetwork = \"mainnet\",\n): GuardrailResult {\n\tconst errors: string[] = [];\n\tconst ramFloor = mode === \"full\" ? FLOORS.fullRamMb : FLOORS.appRamMb;\n\tconst diskFloor = diskFloorGb(mode, network);\n\tif (snap.ramMb !== undefined && snap.ramMb < ramFloor) {\n\t\terrors.push(\n\t\t\t`RAM ${snap.ramMb}MB below ${ramFloor}MB for NODE_MODE=${mode}`,\n\t\t);\n\t}\n\tif (snap.diskGb !== undefined && snap.diskGb < diskFloor) {\n\t\terrors.push(\n\t\t\t`disk ${snap.diskGb}GB below ${diskFloor}GB for NODE_MODE=${mode} on ${network}`,\n\t\t);\n\t}\n\tif (\n\t\tsnap.postgresMaxConnections !== undefined &&\n\t\tsnap.postgresMaxConnections < FLOORS.postgresMaxConnections\n\t) {\n\t\terrors.push(\n\t\t\t`Postgres max_connections ${snap.postgresMaxConnections} below ${FLOORS.postgresMaxConnections}`,\n\t\t);\n\t}\n\tif (errors.length > 0) return { ok: false, errors };\n\treturn { ok: true, estimates: MEASURED_DISK };\n}\n",
15
11
  "/**\n * Measure the box the runtime is actually running on, so the guardrail floors\n * in `guardrails.ts` can be enforced instead of merely documented.\n *\n * Two decisions here are load-bearing and easy to get backwards:\n *\n * 1. Disk is measured as TOTAL filesystem capacity, never free space. A healthy\n * mainnet instance legitimately occupies most of its disk — checking free\n * space would refuse to restart the very installs that are working, which is\n * a far worse failure than the undersizing this guards against.\n *\n * 2. An unmeasurable dimension is reported as unknown and skipped, never\n * treated as zero. Failing to boot because `statfs` was unavailable would\n * turn a diagnostic into an outage.\n *\n * Attribution caveat: in the shipped one-box compose, Postgres and the runtime\n * hold separate Docker named volumes that share one host filesystem, so the\n * filesystem behind DATA_DIR is a sound proxy for where the index will land.\n * An operator who deliberately bind-mounts the database onto a different disk\n * is measuring the wrong volume — which is why undersizing warns loudly and\n * stays overridable rather than being treated as ground truth.\n */\nimport { statfs } from \"node:fs/promises\";\nimport { totalmem } from \"node:os\";\nimport type { ResourceSnapshot } from \"./guardrails.ts\";\n\nconst BYTES_PER_MB = 1024 * 1024;\nconst BYTES_PER_GB = 1024 * 1024 * 1024;\n\nexport type MeasuredResources = {\n\tsnapshot: Partial<ResourceSnapshot>;\n\t/** Dimensions we could not read, with why. Never guessed at. */\n\tunknown: string[];\n};\n\nexport async function measureRamMb(): Promise<number | null> {\n\ttry {\n\t\tconst total = totalmem();\n\t\treturn total > 0 ? Math.floor(total / BYTES_PER_MB) : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/** Total capacity of the filesystem holding `path`. Not free space — see above. */\nexport async function measureDiskGb(path: string): Promise<number | null> {\n\ttry {\n\t\tconst stats = await statfs(path);\n\t\tconst totalBytes = Number(stats.blocks) * Number(stats.bsize);\n\t\treturn totalBytes > 0 ? Math.floor(totalBytes / BYTES_PER_GB) : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * `max_connections` as Postgres reports it. Takes an executor rather than\n * importing the db module so this stays unit-testable without a database.\n */\nexport async function measurePostgresMaxConnections(\n\tquery: (sql: string) => Promise<Array<Record<string, unknown>>>,\n): Promise<number | null> {\n\ttry {\n\t\tconst rows = await query(\"SHOW max_connections\");\n\t\tconst raw = rows[0]?.max_connections;\n\t\tconst value = Number(raw);\n\t\treturn Number.isFinite(value) && value > 0 ? value : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function measureResources(input: {\n\tdataDir: string;\n\tquery?: (sql: string) => Promise<Array<Record<string, unknown>>>;\n}): Promise<MeasuredResources> {\n\tconst unknown: string[] = [];\n\tconst snapshot: Partial<ResourceSnapshot> = {};\n\n\tconst ramMb = await measureRamMb();\n\tif (ramMb === null) unknown.push(\"RAM\");\n\telse snapshot.ramMb = ramMb;\n\n\tconst diskGb = await measureDiskGb(input.dataDir);\n\tif (diskGb === null) unknown.push(`disk (${input.dataDir} unreadable)`);\n\telse snapshot.diskGb = diskGb;\n\n\tif (input.query) {\n\t\tconst conns = await measurePostgresMaxConnections(input.query);\n\t\tif (conns === null) unknown.push(\"Postgres max_connections\");\n\t\telse snapshot.postgresMaxConnections = conns;\n\t} else {\n\t\tunknown.push(\"Postgres max_connections (no database handle)\");\n\t}\n\n\treturn { snapshot, unknown };\n}\n",
16
12
  "/**\n * Boot-time resource preflight — the thing that makes the guardrail floors real.\n *\n * `preflightResources` existed and was correct for a long time, but nothing\n * called it, so the self-host docs claimed \"constrained boxes fail at start\"\n * while no box ever did. This module closes that gap.\n *\n * The refusal is deliberately overridable. Enforcing a floor on a runtime that\n * is already released can stop a running install from coming back up after an\n * upgrade — a box that was undersized yesterday is still undersized today, and\n * discovering that during a restart is the worst possible moment. So an\n * operator can proceed past the refusal with SECONDLAYER_ALLOW_UNDERSIZED,\n * which converts a silent risk into an acknowledged one. That is the honest\n * trade: we refuse by default, and we never take away the operator's ability to\n * run their own box.\n */\nimport { type GuardrailNetwork, preflightResources } from \"./guardrails.ts\";\nimport { type MeasuredResources, measureResources } from \"./resources.ts\";\n\nexport const UNDERSIZED_OVERRIDE = \"SECONDLAYER_ALLOW_UNDERSIZED\";\n\nexport type PreflightDecision = {\n\taction: \"pass\" | \"warn\" | \"refuse\";\n\tmessages: string[];\n};\n\nfunction isOverridden(env: Record<string, string | undefined>): boolean {\n\treturn env[UNDERSIZED_OVERRIDE]?.trim().toLowerCase() === \"true\";\n}\n\nexport function decidePreflight(input: {\n\tmeasured: MeasuredResources;\n\tmode: \"external\" | \"stacks\" | \"full\";\n\tnetwork: GuardrailNetwork;\n\tenv?: Record<string, string | undefined>;\n}): PreflightDecision {\n\tconst env = input.env ?? {};\n\tconst result = preflightResources(\n\t\tinput.measured.snapshot,\n\t\tinput.mode,\n\t\tinput.network,\n\t);\n\n\tconst messages: string[] = [];\n\t// Say what we could not see. An operator debugging a surprising pass\n\t// deserves to know the check was partial.\n\tif (input.measured.unknown.length > 0) {\n\t\tmessages.push(\n\t\t\t`resource preflight could not measure: ${input.measured.unknown.join(\", \")}`,\n\t\t);\n\t}\n\n\tif (result.ok) {\n\t\treturn { action: messages.length > 0 ? \"warn\" : \"pass\", messages };\n\t}\n\n\tmessages.push(...result.errors);\n\tif (isOverridden(env)) {\n\t\tmessages.push(\n\t\t\t`${UNDERSIZED_OVERRIDE}=true — starting anyway. This box is below the documented floor; expect to run out of disk as history accumulates.`,\n\t\t);\n\t\treturn { action: \"warn\", messages };\n\t}\n\n\tmessages.push(\n\t\t`Refusing to start. Resize the box, or set ${UNDERSIZED_OVERRIDE}=true to proceed at your own risk. Sizing guidance: https://www.secondlayer.tools/docs/self-host/hardware`,\n\t);\n\treturn { action: \"refuse\", messages };\n}\n\n/** Measure this box and decide. Returns the decision; the caller exits. */\nexport async function runPreflight(input: {\n\tdataDir: string;\n\tmode: \"external\" | \"stacks\" | \"full\";\n\tnetwork: GuardrailNetwork;\n\tquery?: (sql: string) => Promise<Array<Record<string, unknown>>>;\n\tenv?: Record<string, string | undefined>;\n}): Promise<PreflightDecision> {\n\tconst measured = await measureResources({\n\t\tdataDir: input.dataDir,\n\t\tquery: input.query,\n\t});\n\treturn decidePreflight({\n\t\tmeasured,\n\t\tmode: input.mode,\n\t\tnetwork: input.network,\n\t\tenv: input.env,\n\t});\n}\n",
17
13
  "/**\n * Child-process commands the one-box supervisor starts.\n * Publisher stays off the default profile.\n */\n\nimport type { ModuleId } from \"./modules.ts\";\n\nexport const MODULE_COMMANDS: Record<ModuleId, readonly string[]> = {\n\tapi: [\"bun\", \"run\", \"packages/api/src/index.ts\"],\n\tingest: [\"bun\", \"run\", \"packages/indexer/src/index.ts\"],\n\tdecoder: [\"bun\", \"run\", \"packages/indexer/src/decode/service.ts\"],\n\tsubgraph: [\"bun\", \"run\", \"packages/subgraphs/src/service.ts\"],\n\tnotification: [\"bun\", \"run\", \"packages/subgraphs/src/webhook-service.ts\"],\n\tpublisher: [\"bun\", \"run\", \"packages/indexer/src/streams-bulk/scheduler.ts\"],\n};\n\nexport function commandFor(id: ModuleId): readonly string[] {\n\treturn MODULE_COMMANDS[id];\n}\n"
18
14
  ],
19
- "mappings": ";AAAA;AAgBO,SAAS,aAAqC,CAAC,KAGvC;AAAA,EACd,MAAM,gBAAgB,CAAC,MAAS,OAC/B,IAAI,YAAY,OAAO,SAAS,EAAE,KAAK;AAAA,EACxC,OAAO;AAAA,IACN,QAAQ,IAAI;AAAA,IACZ;AAAA,IACA,MAAM,CAAC,MAAM,IAAI;AAAA,MAChB,IAAI,CAAC,cAAc,MAAM,EAAE,GAAG;AAAA,QAC7B,MAAM,IAAI,MAAM,sBAAsB,WAAW,IAAI;AAAA,MACtD;AAAA;AAAA,EAEF;AAAA;AA4BD,eAAsB,aAIrB,CAEA,IACA,GACsB;AAAA,EACtB,MAAM,SAAS,IAAI,GAAG,EAAE,UAAU,QAAQ;AAAA,EAC1C,MAAM,cAAc,CAAC,MAAM,YAAY,EAAE,IAAI;AAAA,EAC7C,IAAI,EAAE,mBAAmB;AAAA,IAAO,YAAY,KAAK,uBAAuB;AAAA,EACxE,YAAY,KAAK,UAAU,OAAO,QAAQ,EAAE,OAAO,CAAC,CAAC,GAAG;AAAA,IACvD,YAAY,KAAK,MAAM,IAAI,GAAG,GAAG,OAAO,OAAO;AAAA,EAChD;AAAA,EAEA,MAAM,YAAY,EAAE,YACjB,IAAI,KAAK,EAAE,UAAU,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,IAC1C,IAAI,IAAI,GAAG;AAAA,EAEd,QAAQ,SAAS,MAAM;AAAA,WACb,IAAI,MAAM,EAAE,KAAK;AAAA,QACpB,IAAI,KAAK,WAAW;AAAA,UAClB,IAAI,GAAG,EAAE,OAAO,IAAI,OAAO,EAAE,UAAU,gBAAgB,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC;AAAA,cAC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
22
18
  }
@@ -300,7 +300,6 @@ declare function decodedRow<
300
300
  event_index: number
301
301
  event_type: T
302
302
  decoded_payload: P
303
- source_cursor: string
304
303
  };
305
304
  type FtTransferEvent = Extract<StreamsEvent, {
306
305
  event_type: "ft_transfer"
@@ -321,7 +320,6 @@ type DecodedFtTransfer = {
321
320
  event_index: number
322
321
  event_type: "ft_transfer"
323
322
  decoded_payload: DecodedFtTransferPayload
324
- source_cursor: string
325
323
  };
326
324
  declare function isFtTransfer(event: StreamsEvent): event is FtTransferEvent;
327
325
  declare function decodeFtTransfer(event: StreamsEvent): DecodedFtTransfer;
@@ -344,7 +342,6 @@ type DecodedNftTransfer = {
344
342
  event_index: number
345
343
  event_type: "nft_transfer"
346
344
  decoded_payload: DecodedNftTransferPayload
347
- source_cursor: string
348
345
  };
349
346
  declare function isNftTransfer(event: StreamsEvent): event is NftTransferEvent;
350
347
  declare function decodeNftTransfer(event: StreamsEvent): DecodedNftTransfer;
@@ -370,7 +367,6 @@ type DecodedPrint = {
370
367
  event_index: number
371
368
  event_type: "print"
372
369
  decoded_payload: DecodedPrintPayload
373
- source_cursor: string
374
370
  };
375
371
  declare function isPrint(event: StreamsEvent): event is StreamsEvent & {
376
372
  event_type: "print"
@@ -390,7 +386,6 @@ type DecodedStxTransfer = {
390
386
  event_index: number
391
387
  event_type: "stx_transfer"
392
388
  decoded_payload: DecodedStxTransferPayload
393
- source_cursor: string
394
389
  };
395
390
  type DecodedStxMintPayload = {
396
391
  recipient: string
@@ -404,7 +399,6 @@ type DecodedStxMint = {
404
399
  event_index: number
405
400
  event_type: "stx_mint"
406
401
  decoded_payload: DecodedStxMintPayload
407
- source_cursor: string
408
402
  };
409
403
  type DecodedStxBurnPayload = {
410
404
  sender: string
@@ -418,7 +412,6 @@ type DecodedStxBurn = {
418
412
  event_index: number
419
413
  event_type: "stx_burn"
420
414
  decoded_payload: DecodedStxBurnPayload
421
- source_cursor: string
422
415
  };
423
416
  declare function isStxTransfer(event: StreamsEvent): event is StreamsEvent & {
424
417
  event_type: "stx_transfer"
@@ -447,7 +440,6 @@ type DecodedStxLock = {
447
440
  event_index: number
448
441
  event_type: "stx_lock"
449
442
  decoded_payload: DecodedStxLockPayload
450
- source_cursor: string
451
443
  };
452
444
  declare function isStxLock(event: StreamsEvent): event is StreamsEvent & {
453
445
  event_type: "stx_lock"
@@ -468,7 +460,6 @@ type DecodedFtMint = {
468
460
  event_index: number
469
461
  event_type: "ft_mint"
470
462
  decoded_payload: DecodedFtMintPayload
471
- source_cursor: string
472
463
  };
473
464
  type DecodedFtBurnPayload = {
474
465
  asset_identifier: string
@@ -485,7 +476,6 @@ type DecodedFtBurn = {
485
476
  event_index: number
486
477
  event_type: "ft_burn"
487
478
  decoded_payload: DecodedFtBurnPayload
488
- source_cursor: string
489
479
  };
490
480
  type DecodedNftMintPayload = {
491
481
  asset_identifier: string
@@ -502,7 +492,6 @@ type DecodedNftMint = {
502
492
  event_index: number
503
493
  event_type: "nft_mint"
504
494
  decoded_payload: DecodedNftMintPayload
505
- source_cursor: string
506
495
  };
507
496
  type DecodedNftBurnPayload = {
508
497
  asset_identifier: string
@@ -519,7 +508,6 @@ type DecodedNftBurn = {
519
508
  event_index: number
520
509
  event_type: "nft_burn"
521
510
  decoded_payload: DecodedNftBurnPayload
522
- source_cursor: string
523
511
  };
524
512
  declare function isFtMint(event: StreamsEvent): event is StreamsEvent & {
525
513
  event_type: "ft_mint"
@@ -115,8 +115,7 @@ function decodedRow(event, eventType, decoded_payload) {
115
115
  tx_index: event.tx_index,
116
116
  event_index: event.event_index,
117
117
  event_type: eventType,
118
- decoded_payload,
119
- source_cursor: event.cursor
118
+ decoded_payload
120
119
  };
121
120
  }
122
121
  // src/streams-rows/ft-transfer.ts
@@ -338,5 +337,5 @@ export {
338
337
  toJsonSafe
339
338
  };
340
339
 
341
- //# debugId=7D4E3A3C6B9DB6E864756E2164756E21
340
+ //# debugId=69717F294297602464756E2164756E21
342
341
  //# sourceMappingURL=index.js.map
@@ -4,14 +4,14 @@
4
4
  "sourcesContent": [
5
5
  "import { cvToValue, deserializeCV } from \"@secondlayer/stacks/clarity\";\n\n/** Make a cvToValue result JSON-serializable: Clarity (u)ints decode to bigint,\n * which JSON.stringify can't handle — convert recursively to strings. */\nexport function toJsonSafe(value: unknown): unknown {\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (Array.isArray(value)) return value.map(toJsonSafe);\n\tif (value && typeof value === \"object\") {\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const [key, val] of Object.entries(value)) {\n\t\t\tout[key] = toJsonSafe(val);\n\t\t}\n\t\treturn out;\n\t}\n\treturn value;\n}\n\n/** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,\n * buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */\nexport function decodeClarityValue(hex: string): unknown {\n\ttry {\n\t\tconst clean = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n\t\treturn toJsonSafe(cvToValue(deserializeCV(clean)));\n\t} catch {\n\t\treturn hex;\n\t}\n}\n",
6
6
  "// The decoded event-type vocabulary — canonical home is now\n// `@secondlayer/stacks/filters` (the LEAF of the dependency graph: shared\n// depends on stacks, never the reverse, so no package can drift a private\n// copy upward). Re-exported here so every existing `@secondlayer/shared`\n// import keeps working unchanged.\nimport {\n\tDECODED_EVENT_TYPES,\n\ttype VM_NODE_TO_STORED_TYPE,\n} from \"@secondlayer/stacks/filters\";\nimport type { DecodedEventType } from \"@secondlayer/stacks/filters\";\n\nexport {\n\tDECODED_EVENT_TYPES,\n\tVM_EVENT_TYPES,\n\tVM_NODE_TO_STORED_TYPE,\n\ttype DecodedEventType,\n\ttype VmEventType,\n\ttype VmNodeEventType,\n} from \"@secondlayer/stacks/filters\";\n\ntype VmStoredToNode = {\n\t[K in keyof typeof VM_NODE_TO_STORED_TYPE as (typeof VM_NODE_TO_STORED_TYPE)[K]]: K;\n};\n\n/** Inverse of {@link VM_NODE_TO_STORED_TYPE}. Replay reconstruction emits the\n * node-shaped `/new_block.vm_events` body, so ingest can re-parse it. */\nexport const VM_STORED_TO_NODE_TYPE: VmStoredToNode = {\n\tnested_contract_call: \"contract_call_event\",\n\tvar_set: \"var_set_event\",\n\tmap_set: \"map_set_event\",\n\tmap_insert: \"map_insert_event\",\n\tmap_delete: \"map_delete_event\",\n};\n\n/** Alias kept for the Streams surface (identical to {@link DECODED_EVENT_TYPES}).\n * Explicit type annotation required — isolatedDeclarations emits `unknown` for\n * a bare const-to-const alias. */\nexport const STREAMS_EVENT_TYPES: typeof DECODED_EVENT_TYPES =\n\tDECODED_EVENT_TYPES;\nexport type StreamsEventType = DecodedEventType;\n\n/**\n * Wire vocabulary for `chain=bitcoin` Streams events (plan 059) — Runes\n * activity, mirroring the Stacks `ft_*` family. Same four kinds as 058's\n * `RuneEventKind` (`packages/api/src/index/runes.ts`), duplicated here as the\n * canonical shared const rather than imported from the api package (shared\n * never depends on api); the DB `kind` column (`etch|mint|transfer|burn`) is\n * mapped at the edge in both readers.\n */\nexport const RUNE_EVENT_TYPES = [\n\t\"rune_etch\",\n\t\"rune_mint\",\n\t\"rune_transfer\",\n\t\"rune_burn\",\n] as const;\nexport type RuneEventType = (typeof RUNE_EVENT_TYPES)[number];\n",
7
- "import type { StreamsEvent } from \"./events.ts\";\n\n/** Superset of the columns the decoded_events table holds. Every decoded\n * event's `decoded_payload` is assignable to this, so the indexer's writer\n * can map columns generically instead of per-event-type. */\nexport type DecodedEventColumns = {\n\tcontract_id?: string | null;\n\tasset_identifier?: string | null;\n\tsender?: string | null;\n\trecipient?: string | null;\n\tamount?: string | null;\n\tvalue?: string | null;\n\tmemo?: string | null;\n\t/** JSONB overflow for non-flat types (e.g. print's decoded value). */\n\tpayload?: unknown;\n};\n\nexport function requireString(\n\tpayload: Record<string, unknown>,\n\tfield: string,\n\teventType: string,\n): string {\n\tconst value = payload[field];\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new Error(`${eventType} payload missing ${field}`);\n\t}\n\treturn value;\n}\n\nexport function optionalString(value: unknown): string | null {\n\treturn typeof value === \"string\" && value.length > 0 ? value : null;\n}\n\nexport function requireAmountField(\n\tpayload: Record<string, unknown>,\n\tfield: string,\n\teventType: string,\n): string {\n\tconst amount = requireString(payload, field, eventType);\n\tif (!/^(0|[1-9]\\d*)$/.test(amount)) {\n\t\tthrow new Error(`${eventType} payload has malformed ${field}`);\n\t}\n\treturn amount;\n}\n\nexport function requireAmount(\n\tpayload: Record<string, unknown>,\n\teventType: string,\n): string {\n\treturn requireAmountField(payload, \"amount\", eventType);\n}\n\nexport function parseAssetIdentifier(\n\tassetIdentifier: string,\n\teventType: string,\n): { contract_id: string; token_name: string | null } {\n\tconst [contractId, tokenName] = assetIdentifier.split(\"::\");\n\tif (!contractId) {\n\t\tthrow new Error(`${eventType} payload has malformed asset_identifier`);\n\t}\n\treturn {\n\t\tcontract_id: contractId,\n\t\ttoken_name: tokenName && tokenName.length > 0 ? tokenName : null,\n\t};\n}\n\nconst HEX_BODY = /^[0-9a-fA-F]*$/;\n\n/** The canonical `0x` hex of a payload's Clarity value, from whichever field\n * the row's ingestion era wrote: `raw_value` (from ~7.46M), a `0x` string at\n * `value` (before that), or a typed `{ hex }` object. Null when none is hex. */\nexport function clarityHexOf(payload: Record<string, unknown>): string | null {\n\tconst rawValue = payload.raw_value;\n\tif (typeof rawValue === \"string\") return rawValue;\n\tconst value = payload.value;\n\tif (typeof value === \"string\" && value.startsWith(\"0x\")) return value;\n\tif (\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\ttypeof (value as { hex?: unknown }).hex === \"string\"\n\t) {\n\t\treturn (value as { hex: string }).hex;\n\t}\n\treturn null;\n}\n\n/** NFT token id as canonical `0x` hex; throws when missing or malformed. */\nexport function requireHexValue(\n\tpayload: Record<string, unknown>,\n\teventType: string,\n): string {\n\tconst hex =\n\t\tclarityHexOf(payload) ??\n\t\t(typeof payload.value === \"string\" ? payload.value : null);\n\tif (!hex) {\n\t\tthrow new Error(`${eventType} payload missing value`);\n\t}\n\tif (!/^0x[0-9a-fA-F]*$/.test(hex)) {\n\t\tthrow new Error(`${eventType} payload has malformed value`);\n\t}\n\treturn hex;\n}\n\n/**\n * A transfer memo as `0x` hex, or null when the transfer carried none.\n *\n * Stored memos come in three spellings depending on ingestion era: `0x…`\n * (before ~7.4M), bare hex (after), and missing or `\"\"` for transfers made\n * without a memo. Non-hex strings pass through untouched.\n */\nexport function normalizeMemoHex(memo: unknown): string | null {\n\tif (typeof memo !== \"string\") return null;\n\tconst body = memo.startsWith(\"0x\") ? memo.slice(2) : memo;\n\tif (body.length === 0) return null;\n\treturn HEX_BODY.test(body) ? `0x${body}` : memo;\n}\n\n/** Common envelope fields shared by every decoded event, lifted off the\n * source StreamsEvent. The decoder supplies event_type + decoded_payload. */\nexport function decodedRow<T extends string, P>(\n\tevent: StreamsEvent,\n\teventType: T,\n\tdecoded_payload: P,\n): {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: T;\n\tdecoded_payload: P;\n\tsource_cursor: string;\n} {\n\treturn {\n\t\tcursor: event.cursor,\n\t\tblock_height: event.block_height,\n\t\ttx_id: event.tx_id,\n\t\ttx_index: event.tx_index,\n\t\tevent_index: event.event_index,\n\t\tevent_type: eventType,\n\t\tdecoded_payload,\n\t\tsource_cursor: event.cursor,\n\t};\n}\n",
8
- "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireAmount,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type { FtTransferPayload } from \"./events.ts\";\n\nexport type FtTransferEvent = Extract<\n\tStreamsEvent,\n\t{ event_type: \"ft_transfer\" }\n>;\n\nexport type DecodedFtTransferPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedFtTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_transfer\";\n\tdecoded_payload: DecodedFtTransferPayload;\n\tsource_cursor: string;\n};\n\nexport function isFtTransfer(event: StreamsEvent): event is FtTransferEvent {\n\treturn event.event_type === \"ft_transfer\";\n}\n\nexport function decodeFtTransfer(event: StreamsEvent): DecodedFtTransfer {\n\tif (!isFtTransfer(event)) {\n\t\tthrow new Error(`Expected ft_transfer event, got ${event.event_type}`);\n\t}\n\n\tconst payload = event.payload;\n\tconst assetIdentifier = requireString(\n\t\tpayload,\n\t\t\"asset_identifier\",\n\t\t\"ft_transfer\",\n\t);\n\tconst sender = requireString(payload, \"sender\", \"ft_transfer\");\n\tconst recipient = requireString(payload, \"recipient\", \"ft_transfer\");\n\tconst amount = requireAmount(payload, \"ft_transfer\");\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\t\"ft_transfer\",\n\t);\n\n\treturn decodedRow(event, \"ft_transfer\", {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t\tsender,\n\t\trecipient,\n\t\tamount,\n\t});\n}\n",
9
- "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireHexValue,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type { NftTransferPayload } from \"./events.ts\";\n\nexport type NftTransferEvent = Extract<\n\tStreamsEvent,\n\t{ event_type: \"nft_transfer\" }\n>;\n\nexport type DecodedNftTransferPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type DecodedNftTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_transfer\";\n\tdecoded_payload: DecodedNftTransferPayload;\n\tsource_cursor: string;\n};\n\nexport function isNftTransfer(event: StreamsEvent): event is NftTransferEvent {\n\treturn event.event_type === \"nft_transfer\";\n}\n\nexport function decodeNftTransfer(event: StreamsEvent): DecodedNftTransfer {\n\tif (!isNftTransfer(event)) {\n\t\tthrow new Error(`Expected nft_transfer event, got ${event.event_type}`);\n\t}\n\n\tconst payload = event.payload;\n\tconst assetIdentifier = requireString(\n\t\tpayload,\n\t\t\"asset_identifier\",\n\t\t\"nft_transfer\",\n\t);\n\tconst sender = requireString(payload, \"sender\", \"nft_transfer\");\n\tconst recipient = requireString(payload, \"recipient\", \"nft_transfer\");\n\tconst value = requireHexValue(payload, \"nft_transfer\");\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\t\"nft_transfer\",\n\t);\n\n\treturn decodedRow(event, \"nft_transfer\", {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t\tsender,\n\t\trecipient,\n\t\tvalue,\n\t});\n}\n",
10
- "import { clarityHexOf, decodedRow, optionalString } from \"./_payload.ts\";\nimport { decodeClarityValue, toJsonSafe } from \"./clarity.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\n/** Decoded form of a Clarity `print` event:\n * - `topic`: the print topic, when the contract emits a `{ topic, ... }` tuple\n * - `value`: the Clarity value decoded to JSON (uints as strings, buffers as\n * `0x…` hex, tuples as objects)\n * - `raw_value`: the canonical serialized hex, for byte-exact consumers */\nexport type DecodedPrintValue = {\n\ttopic: string | null;\n\tvalue: unknown;\n\traw_value: string | null;\n};\n\nexport type DecodedPrintPayload = {\n\tcontract_id: string | null;\n\tpayload: DecodedPrintValue;\n};\n\nexport type DecodedPrint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"print\";\n\tdecoded_payload: DecodedPrintPayload;\n\tsource_cursor: string;\n};\n\nexport function isPrint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"print\" } {\n\treturn event.event_type === \"print\";\n}\n\nexport function decodePrint(event: StreamsEvent): DecodedPrint {\n\tif (!isPrint(event)) {\n\t\tthrow new Error(`Expected print event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\tconst topic = optionalString(payload.topic);\n\tconst rawValue = clarityHexOf(payload);\n\n\tconst value = rawValue\n\t\t? decodeClarityValue(rawValue)\n\t\t: toJsonSafe(payload.value ?? null);\n\n\treturn decodedRow(event, \"print\", {\n\t\tcontract_id: event.contract_id ?? optionalString(payload.contract_id),\n\t\tpayload: { topic, value, raw_value: rawValue },\n\t});\n}\n",
11
- "import {\n\tdecodedRow,\n\tnormalizeMemoHex,\n\toptionalString,\n\trequireAmount,\n\trequireAmountField,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type DecodedStxTransferPayload = {\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n\tmemo: string | null;\n};\n\nexport type DecodedStxTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_transfer\";\n\tdecoded_payload: DecodedStxTransferPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedStxMintPayload = {\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedStxMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_mint\";\n\tdecoded_payload: DecodedStxMintPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedStxBurnPayload = {\n\tsender: string;\n\tamount: string;\n};\n\nexport type DecodedStxBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_burn\";\n\tdecoded_payload: DecodedStxBurnPayload;\n\tsource_cursor: string;\n};\n\nexport function isStxTransfer(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_transfer\" } {\n\treturn event.event_type === \"stx_transfer\";\n}\n\nexport function decodeStxTransfer(event: StreamsEvent): DecodedStxTransfer {\n\tif (!isStxTransfer(event)) {\n\t\tthrow new Error(`Expected stx_transfer event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_transfer\", {\n\t\tsender: requireString(payload, \"sender\", \"stx_transfer\"),\n\t\trecipient: requireString(payload, \"recipient\", \"stx_transfer\"),\n\t\tamount: requireAmount(payload, \"stx_transfer\"),\n\t\tmemo: normalizeMemoHex(payload.memo),\n\t});\n}\n\nexport function isStxMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_mint\" } {\n\treturn event.event_type === \"stx_mint\";\n}\n\nexport function decodeStxMint(event: StreamsEvent): DecodedStxMint {\n\tif (!isStxMint(event)) {\n\t\tthrow new Error(`Expected stx_mint event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_mint\", {\n\t\trecipient: requireString(payload, \"recipient\", \"stx_mint\"),\n\t\tamount: requireAmount(payload, \"stx_mint\"),\n\t});\n}\n\nexport function isStxBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_burn\" } {\n\treturn event.event_type === \"stx_burn\";\n}\n\nexport function decodeStxBurn(event: StreamsEvent): DecodedStxBurn {\n\tif (!isStxBurn(event)) {\n\t\tthrow new Error(`Expected stx_burn event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_burn\", {\n\t\tsender: requireString(payload, \"sender\", \"stx_burn\"),\n\t\tamount: requireAmount(payload, \"stx_burn\"),\n\t});\n}\n\nexport type DecodedStxLockPayload = {\n\t// The locked principal maps to `sender` and the locked uSTX to `amount` so\n\t// stx_lock is filterable like the other STX types; the lock-specific\n\t// unlock_height rides in the jsonb `payload` overflow.\n\tsender: string;\n\tamount: string;\n\tpayload: { unlock_height: string | null };\n};\n\nexport type DecodedStxLock = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_lock\";\n\tdecoded_payload: DecodedStxLockPayload;\n\tsource_cursor: string;\n};\n\nexport function isStxLock(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_lock\" } {\n\treturn event.event_type === \"stx_lock\";\n}\n\nexport function decodeStxLock(event: StreamsEvent): DecodedStxLock {\n\tif (!isStxLock(event)) {\n\t\tthrow new Error(`Expected stx_lock event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_lock\", {\n\t\tsender: requireString(payload, \"locked_address\", \"stx_lock\"),\n\t\tamount: requireAmountField(payload, \"locked_amount\", \"stx_lock\"),\n\t\tpayload: { unlock_height: optionalString(payload.unlock_height) },\n\t});\n}\n",
12
- "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireAmount,\n\trequireHexValue,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type DecodedFtMintPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedFtMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_mint\";\n\tdecoded_payload: DecodedFtMintPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedFtBurnPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\tamount: string;\n};\n\nexport type DecodedFtBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_burn\";\n\tdecoded_payload: DecodedFtBurnPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedNftMintPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type DecodedNftMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_mint\";\n\tdecoded_payload: DecodedNftMintPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedNftBurnPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\tvalue: string;\n};\n\nexport type DecodedNftBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_burn\";\n\tdecoded_payload: DecodedNftBurnPayload;\n\tsource_cursor: string;\n};\n\nfunction assetFields(event: StreamsEvent, eventType: string) {\n\tconst assetIdentifier = requireString(\n\t\tevent.payload,\n\t\t\"asset_identifier\",\n\t\teventType,\n\t);\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\teventType,\n\t);\n\treturn {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t};\n}\n\nexport function isFtMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"ft_mint\" } {\n\treturn event.event_type === \"ft_mint\";\n}\n\nexport function decodeFtMint(event: StreamsEvent): DecodedFtMint {\n\tif (!isFtMint(event)) {\n\t\tthrow new Error(`Expected ft_mint event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"ft_mint\", {\n\t\t...assetFields(event, \"ft_mint\"),\n\t\trecipient: requireString(event.payload, \"recipient\", \"ft_mint\"),\n\t\tamount: requireAmount(event.payload, \"ft_mint\"),\n\t});\n}\n\nexport function isFtBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"ft_burn\" } {\n\treturn event.event_type === \"ft_burn\";\n}\n\nexport function decodeFtBurn(event: StreamsEvent): DecodedFtBurn {\n\tif (!isFtBurn(event)) {\n\t\tthrow new Error(`Expected ft_burn event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"ft_burn\", {\n\t\t...assetFields(event, \"ft_burn\"),\n\t\tsender: requireString(event.payload, \"sender\", \"ft_burn\"),\n\t\tamount: requireAmount(event.payload, \"ft_burn\"),\n\t});\n}\n\nexport function isNftMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"nft_mint\" } {\n\treturn event.event_type === \"nft_mint\";\n}\n\nexport function decodeNftMint(event: StreamsEvent): DecodedNftMint {\n\tif (!isNftMint(event)) {\n\t\tthrow new Error(`Expected nft_mint event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"nft_mint\", {\n\t\t...assetFields(event, \"nft_mint\"),\n\t\trecipient: requireString(event.payload, \"recipient\", \"nft_mint\"),\n\t\tvalue: requireHexValue(event.payload, \"nft_mint\"),\n\t});\n}\n\nexport function isNftBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"nft_burn\" } {\n\treturn event.event_type === \"nft_burn\";\n}\n\nexport function decodeNftBurn(event: StreamsEvent): DecodedNftBurn {\n\tif (!isNftBurn(event)) {\n\t\tthrow new Error(`Expected nft_burn event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"nft_burn\", {\n\t\t...assetFields(event, \"nft_burn\"),\n\t\tsender: requireString(event.payload, \"sender\", \"nft_burn\"),\n\t\tvalue: requireHexValue(event.payload, \"nft_burn\"),\n\t});\n}\n"
7
+ "import type { StreamsEvent } from \"./events.ts\";\n\n/** Superset of the columns the decoded_events table holds. Every decoded\n * event's `decoded_payload` is assignable to this, so the indexer's writer\n * can map columns generically instead of per-event-type. */\nexport type DecodedEventColumns = {\n\tcontract_id?: string | null;\n\tasset_identifier?: string | null;\n\tsender?: string | null;\n\trecipient?: string | null;\n\tamount?: string | null;\n\tvalue?: string | null;\n\tmemo?: string | null;\n\t/** JSONB overflow for non-flat types (e.g. print's decoded value). */\n\tpayload?: unknown;\n};\n\nexport function requireString(\n\tpayload: Record<string, unknown>,\n\tfield: string,\n\teventType: string,\n): string {\n\tconst value = payload[field];\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new Error(`${eventType} payload missing ${field}`);\n\t}\n\treturn value;\n}\n\nexport function optionalString(value: unknown): string | null {\n\treturn typeof value === \"string\" && value.length > 0 ? value : null;\n}\n\nexport function requireAmountField(\n\tpayload: Record<string, unknown>,\n\tfield: string,\n\teventType: string,\n): string {\n\tconst amount = requireString(payload, field, eventType);\n\tif (!/^(0|[1-9]\\d*)$/.test(amount)) {\n\t\tthrow new Error(`${eventType} payload has malformed ${field}`);\n\t}\n\treturn amount;\n}\n\nexport function requireAmount(\n\tpayload: Record<string, unknown>,\n\teventType: string,\n): string {\n\treturn requireAmountField(payload, \"amount\", eventType);\n}\n\nexport function parseAssetIdentifier(\n\tassetIdentifier: string,\n\teventType: string,\n): { contract_id: string; token_name: string | null } {\n\tconst [contractId, tokenName] = assetIdentifier.split(\"::\");\n\tif (!contractId) {\n\t\tthrow new Error(`${eventType} payload has malformed asset_identifier`);\n\t}\n\treturn {\n\t\tcontract_id: contractId,\n\t\ttoken_name: tokenName && tokenName.length > 0 ? tokenName : null,\n\t};\n}\n\nconst HEX_BODY = /^[0-9a-fA-F]*$/;\n\n/** The canonical `0x` hex of a payload's Clarity value, from whichever field\n * the row's ingestion era wrote: `raw_value` (from ~7.46M), a `0x` string at\n * `value` (before that), or a typed `{ hex }` object. Null when none is hex. */\nexport function clarityHexOf(payload: Record<string, unknown>): string | null {\n\tconst rawValue = payload.raw_value;\n\tif (typeof rawValue === \"string\") return rawValue;\n\tconst value = payload.value;\n\tif (typeof value === \"string\" && value.startsWith(\"0x\")) return value;\n\tif (\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\ttypeof (value as { hex?: unknown }).hex === \"string\"\n\t) {\n\t\treturn (value as { hex: string }).hex;\n\t}\n\treturn null;\n}\n\n/** NFT token id as canonical `0x` hex; throws when missing or malformed. */\nexport function requireHexValue(\n\tpayload: Record<string, unknown>,\n\teventType: string,\n): string {\n\tconst hex =\n\t\tclarityHexOf(payload) ??\n\t\t(typeof payload.value === \"string\" ? payload.value : null);\n\tif (!hex) {\n\t\tthrow new Error(`${eventType} payload missing value`);\n\t}\n\tif (!/^0x[0-9a-fA-F]*$/.test(hex)) {\n\t\tthrow new Error(`${eventType} payload has malformed value`);\n\t}\n\treturn hex;\n}\n\n/**\n * A transfer memo as `0x` hex, or null when the transfer carried none.\n *\n * Stored memos come in three spellings depending on ingestion era: `0x…`\n * (before ~7.4M), bare hex (after), and missing or `\"\"` for transfers made\n * without a memo. Non-hex strings pass through untouched.\n */\nexport function normalizeMemoHex(memo: unknown): string | null {\n\tif (typeof memo !== \"string\") return null;\n\tconst body = memo.startsWith(\"0x\") ? memo.slice(2) : memo;\n\tif (body.length === 0) return null;\n\treturn HEX_BODY.test(body) ? `0x${body}` : memo;\n}\n\n/** Common envelope fields shared by every decoded event, lifted off the\n * source StreamsEvent. The decoder supplies event_type + decoded_payload. */\nexport function decodedRow<T extends string, P>(\n\tevent: StreamsEvent,\n\teventType: T,\n\tdecoded_payload: P,\n): {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: T;\n\tdecoded_payload: P;\n} {\n\treturn {\n\t\tcursor: event.cursor,\n\t\tblock_height: event.block_height,\n\t\ttx_id: event.tx_id,\n\t\ttx_index: event.tx_index,\n\t\tevent_index: event.event_index,\n\t\tevent_type: eventType,\n\t\tdecoded_payload,\n\t};\n}\n",
8
+ "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireAmount,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type { FtTransferPayload } from \"./events.ts\";\n\nexport type FtTransferEvent = Extract<\n\tStreamsEvent,\n\t{ event_type: \"ft_transfer\" }\n>;\n\nexport type DecodedFtTransferPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedFtTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_transfer\";\n\tdecoded_payload: DecodedFtTransferPayload;\n};\n\nexport function isFtTransfer(event: StreamsEvent): event is FtTransferEvent {\n\treturn event.event_type === \"ft_transfer\";\n}\n\nexport function decodeFtTransfer(event: StreamsEvent): DecodedFtTransfer {\n\tif (!isFtTransfer(event)) {\n\t\tthrow new Error(`Expected ft_transfer event, got ${event.event_type}`);\n\t}\n\n\tconst payload = event.payload;\n\tconst assetIdentifier = requireString(\n\t\tpayload,\n\t\t\"asset_identifier\",\n\t\t\"ft_transfer\",\n\t);\n\tconst sender = requireString(payload, \"sender\", \"ft_transfer\");\n\tconst recipient = requireString(payload, \"recipient\", \"ft_transfer\");\n\tconst amount = requireAmount(payload, \"ft_transfer\");\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\t\"ft_transfer\",\n\t);\n\n\treturn decodedRow(event, \"ft_transfer\", {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t\tsender,\n\t\trecipient,\n\t\tamount,\n\t});\n}\n",
9
+ "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireHexValue,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type { NftTransferPayload } from \"./events.ts\";\n\nexport type NftTransferEvent = Extract<\n\tStreamsEvent,\n\t{ event_type: \"nft_transfer\" }\n>;\n\nexport type DecodedNftTransferPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type DecodedNftTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_transfer\";\n\tdecoded_payload: DecodedNftTransferPayload;\n};\n\nexport function isNftTransfer(event: StreamsEvent): event is NftTransferEvent {\n\treturn event.event_type === \"nft_transfer\";\n}\n\nexport function decodeNftTransfer(event: StreamsEvent): DecodedNftTransfer {\n\tif (!isNftTransfer(event)) {\n\t\tthrow new Error(`Expected nft_transfer event, got ${event.event_type}`);\n\t}\n\n\tconst payload = event.payload;\n\tconst assetIdentifier = requireString(\n\t\tpayload,\n\t\t\"asset_identifier\",\n\t\t\"nft_transfer\",\n\t);\n\tconst sender = requireString(payload, \"sender\", \"nft_transfer\");\n\tconst recipient = requireString(payload, \"recipient\", \"nft_transfer\");\n\tconst value = requireHexValue(payload, \"nft_transfer\");\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\t\"nft_transfer\",\n\t);\n\n\treturn decodedRow(event, \"nft_transfer\", {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t\tsender,\n\t\trecipient,\n\t\tvalue,\n\t});\n}\n",
10
+ "import { clarityHexOf, decodedRow, optionalString } from \"./_payload.ts\";\nimport { decodeClarityValue, toJsonSafe } from \"./clarity.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\n/** Decoded form of a Clarity `print` event:\n * - `topic`: the print topic, when the contract emits a `{ topic, ... }` tuple\n * - `value`: the Clarity value decoded to JSON (uints as strings, buffers as\n * `0x…` hex, tuples as objects)\n * - `raw_value`: the canonical serialized hex, for byte-exact consumers */\nexport type DecodedPrintValue = {\n\ttopic: string | null;\n\tvalue: unknown;\n\traw_value: string | null;\n};\n\nexport type DecodedPrintPayload = {\n\tcontract_id: string | null;\n\tpayload: DecodedPrintValue;\n};\n\nexport type DecodedPrint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"print\";\n\tdecoded_payload: DecodedPrintPayload;\n};\n\nexport function isPrint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"print\" } {\n\treturn event.event_type === \"print\";\n}\n\nexport function decodePrint(event: StreamsEvent): DecodedPrint {\n\tif (!isPrint(event)) {\n\t\tthrow new Error(`Expected print event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\tconst topic = optionalString(payload.topic);\n\tconst rawValue = clarityHexOf(payload);\n\n\tconst value = rawValue\n\t\t? decodeClarityValue(rawValue)\n\t\t: toJsonSafe(payload.value ?? null);\n\n\treturn decodedRow(event, \"print\", {\n\t\tcontract_id: event.contract_id ?? optionalString(payload.contract_id),\n\t\tpayload: { topic, value, raw_value: rawValue },\n\t});\n}\n",
11
+ "import {\n\tdecodedRow,\n\tnormalizeMemoHex,\n\toptionalString,\n\trequireAmount,\n\trequireAmountField,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type DecodedStxTransferPayload = {\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n\tmemo: string | null;\n};\n\nexport type DecodedStxTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_transfer\";\n\tdecoded_payload: DecodedStxTransferPayload;\n};\n\nexport type DecodedStxMintPayload = {\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedStxMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_mint\";\n\tdecoded_payload: DecodedStxMintPayload;\n};\n\nexport type DecodedStxBurnPayload = {\n\tsender: string;\n\tamount: string;\n};\n\nexport type DecodedStxBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_burn\";\n\tdecoded_payload: DecodedStxBurnPayload;\n};\n\nexport function isStxTransfer(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_transfer\" } {\n\treturn event.event_type === \"stx_transfer\";\n}\n\nexport function decodeStxTransfer(event: StreamsEvent): DecodedStxTransfer {\n\tif (!isStxTransfer(event)) {\n\t\tthrow new Error(`Expected stx_transfer event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_transfer\", {\n\t\tsender: requireString(payload, \"sender\", \"stx_transfer\"),\n\t\trecipient: requireString(payload, \"recipient\", \"stx_transfer\"),\n\t\tamount: requireAmount(payload, \"stx_transfer\"),\n\t\tmemo: normalizeMemoHex(payload.memo),\n\t});\n}\n\nexport function isStxMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_mint\" } {\n\treturn event.event_type === \"stx_mint\";\n}\n\nexport function decodeStxMint(event: StreamsEvent): DecodedStxMint {\n\tif (!isStxMint(event)) {\n\t\tthrow new Error(`Expected stx_mint event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_mint\", {\n\t\trecipient: requireString(payload, \"recipient\", \"stx_mint\"),\n\t\tamount: requireAmount(payload, \"stx_mint\"),\n\t});\n}\n\nexport function isStxBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_burn\" } {\n\treturn event.event_type === \"stx_burn\";\n}\n\nexport function decodeStxBurn(event: StreamsEvent): DecodedStxBurn {\n\tif (!isStxBurn(event)) {\n\t\tthrow new Error(`Expected stx_burn event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_burn\", {\n\t\tsender: requireString(payload, \"sender\", \"stx_burn\"),\n\t\tamount: requireAmount(payload, \"stx_burn\"),\n\t});\n}\n\nexport type DecodedStxLockPayload = {\n\t// The locked principal maps to `sender` and the locked uSTX to `amount` so\n\t// stx_lock is filterable like the other STX types; the lock-specific\n\t// unlock_height rides in the jsonb `payload` overflow.\n\tsender: string;\n\tamount: string;\n\tpayload: { unlock_height: string | null };\n};\n\nexport type DecodedStxLock = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_lock\";\n\tdecoded_payload: DecodedStxLockPayload;\n};\n\nexport function isStxLock(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_lock\" } {\n\treturn event.event_type === \"stx_lock\";\n}\n\nexport function decodeStxLock(event: StreamsEvent): DecodedStxLock {\n\tif (!isStxLock(event)) {\n\t\tthrow new Error(`Expected stx_lock event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_lock\", {\n\t\tsender: requireString(payload, \"locked_address\", \"stx_lock\"),\n\t\tamount: requireAmountField(payload, \"locked_amount\", \"stx_lock\"),\n\t\tpayload: { unlock_height: optionalString(payload.unlock_height) },\n\t});\n}\n",
12
+ "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireAmount,\n\trequireHexValue,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type DecodedFtMintPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedFtMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_mint\";\n\tdecoded_payload: DecodedFtMintPayload;\n};\n\nexport type DecodedFtBurnPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\tamount: string;\n};\n\nexport type DecodedFtBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_burn\";\n\tdecoded_payload: DecodedFtBurnPayload;\n};\n\nexport type DecodedNftMintPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type DecodedNftMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_mint\";\n\tdecoded_payload: DecodedNftMintPayload;\n};\n\nexport type DecodedNftBurnPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\tvalue: string;\n};\n\nexport type DecodedNftBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_burn\";\n\tdecoded_payload: DecodedNftBurnPayload;\n};\n\nfunction assetFields(event: StreamsEvent, eventType: string) {\n\tconst assetIdentifier = requireString(\n\t\tevent.payload,\n\t\t\"asset_identifier\",\n\t\teventType,\n\t);\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\teventType,\n\t);\n\treturn {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t};\n}\n\nexport function isFtMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"ft_mint\" } {\n\treturn event.event_type === \"ft_mint\";\n}\n\nexport function decodeFtMint(event: StreamsEvent): DecodedFtMint {\n\tif (!isFtMint(event)) {\n\t\tthrow new Error(`Expected ft_mint event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"ft_mint\", {\n\t\t...assetFields(event, \"ft_mint\"),\n\t\trecipient: requireString(event.payload, \"recipient\", \"ft_mint\"),\n\t\tamount: requireAmount(event.payload, \"ft_mint\"),\n\t});\n}\n\nexport function isFtBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"ft_burn\" } {\n\treturn event.event_type === \"ft_burn\";\n}\n\nexport function decodeFtBurn(event: StreamsEvent): DecodedFtBurn {\n\tif (!isFtBurn(event)) {\n\t\tthrow new Error(`Expected ft_burn event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"ft_burn\", {\n\t\t...assetFields(event, \"ft_burn\"),\n\t\tsender: requireString(event.payload, \"sender\", \"ft_burn\"),\n\t\tamount: requireAmount(event.payload, \"ft_burn\"),\n\t});\n}\n\nexport function isNftMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"nft_mint\" } {\n\treturn event.event_type === \"nft_mint\";\n}\n\nexport function decodeNftMint(event: StreamsEvent): DecodedNftMint {\n\tif (!isNftMint(event)) {\n\t\tthrow new Error(`Expected nft_mint event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"nft_mint\", {\n\t\t...assetFields(event, \"nft_mint\"),\n\t\trecipient: requireString(event.payload, \"recipient\", \"nft_mint\"),\n\t\tvalue: requireHexValue(event.payload, \"nft_mint\"),\n\t});\n}\n\nexport function isNftBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"nft_burn\" } {\n\treturn event.event_type === \"nft_burn\";\n}\n\nexport function decodeNftBurn(event: StreamsEvent): DecodedNftBurn {\n\tif (!isNftBurn(event)) {\n\t\tthrow new Error(`Expected nft_burn event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"nft_burn\", {\n\t\t...assetFields(event, \"nft_burn\"),\n\t\tsender: requireString(event.payload, \"sender\", \"nft_burn\"),\n\t\tvalue: requireHexValue(event.payload, \"nft_burn\"),\n\t});\n}\n"
13
13
  ],
14
- "mappings": ";AAAA;AAIO,SAAS,UAAU,CAAC,OAAyB;AAAA,EACnD,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,MAAM,SAAS;AAAA,EACrD,IAAI,MAAM,QAAQ,KAAK;AAAA,IAAG,OAAO,MAAM,IAAI,UAAU;AAAA,EACrD,IAAI,SAAS,OAAO,UAAU,UAAU;AAAA,IACvC,MAAM,MAA+B,CAAC;AAAA,IACtC,YAAY,KAAK,QAAQ,OAAO,QAAQ,KAAK,GAAG;AAAA,MAC/C,IAAI,OAAO,WAAW,GAAG;AAAA,IAC1B;AAAA,IACA,OAAO;AAAA,EACR;AAAA,EACA,OAAO;AAAA;AAKD,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AAAA,OACjC,YAAY,OAAO,UAAU;AAAA,IAChC,QAAQ,cAAc,MAAM,SAAS,UAAU,UAAU;AAAA,IACzD,OAAO,gBAAgB,MAAM,SAAS,UAAU;AAAA,EACjD,CAAC;AAAA;",
15
+ "debugId": "69717F294297602464756E2164756E21",
16
16
  "names": []
17
17
  }
@@ -0,0 +1,26 @@
1
+ import { type Kysely, sql } from "kysely";
2
+ import { onChainPlane } from "../src/db/migration-role.ts";
3
+
4
+ // One row: the canonical-events count through a finalized height, shared by
5
+ // every API process so a new process extends it instead of recounting all of
6
+ // `events`. `claimed_at` marks the one process running a full recount.
7
+ export async function up(db: Kysely<unknown>): Promise<void> {
8
+ await sql`SET lock_timeout = '30s'`.execute(db);
9
+ await onChainPlane(async () => {
10
+ await sql`
11
+ CREATE TABLE IF NOT EXISTS events_total_baseline (
12
+ id BOOLEAN PRIMARY KEY DEFAULT TRUE CHECK (id = TRUE),
13
+ through BIGINT,
14
+ count BIGINT,
15
+ taken_at TIMESTAMPTZ,
16
+ claimed_at TIMESTAMPTZ
17
+ )
18
+ `.execute(db);
19
+ });
20
+ }
21
+
22
+ export async function down(db: Kysely<unknown>): Promise<void> {
23
+ await onChainPlane(async () => {
24
+ await sql`DROP TABLE IF EXISTS events_total_baseline`.execute(db);
25
+ });
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secondlayer/shared",
3
- "version": "18.0.1",
3
+ "version": "19.0.0",
4
4
  "description": "Internal building blocks shared across Secondlayer packages.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -93,6 +93,10 @@
93
93
  "types": "./dist/src/db/queries/webhook-replays.d.ts",
94
94
  "import": "./dist/src/db/queries/webhook-replays.js"
95
95
  },
96
+ "./db/queries/api-keys": {
97
+ "types": "./dist/src/db/queries/api-keys.d.ts",
98
+ "import": "./dist/src/db/queries/api-keys.js"
99
+ },
96
100
  "./crypto/standard-webhooks": {
97
101
  "types": "./dist/src/crypto/standard-webhooks.d.ts",
98
102
  "import": "./dist/src/crypto/standard-webhooks.js"
@@ -273,7 +277,7 @@
273
277
  "prepublishOnly": "bun run build"
274
278
  },
275
279
  "dependencies": {
276
- "@secondlayer/stacks": "^7.0.0",
280
+ "@secondlayer/stacks": "^7.2.0",
277
281
  "kysely": "0.28.17",
278
282
  "kysely-postgres-js": "3.0.0",
279
283
  "postgres": "^3.4.6",