@secondlayer/shared 11.5.0 → 11.6.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.
@@ -137,7 +137,6 @@ interface SubgraphsTable {
137
137
  expires_at: Date | null;
138
138
  /** (event type, contract) probe pairs persisted at deploy for weight classification. */
139
139
  sparse_probe_targets: unknown | null;
140
- database_url_enc: ColumnType<Buffer | null, Buffer | null | undefined, Buffer | null>;
141
140
  sandbox_workers: Generated<boolean>;
142
141
  created_at: Generated<Date>;
143
142
  updated_at: Generated<Date>;
@@ -233,7 +232,7 @@ interface AccountsTable {
233
232
  email: string | null;
234
233
  /** True for anonymous self-serve accounts until claimed via magic link. */
235
234
  ghost: Generated<boolean>;
236
- /** Stacks principal owning a wallet-ghost account (x402-paid deploys). */
235
+ /** Stacks principal owning a wallet-ghost account. */
237
236
  wallet_principal: string | null;
238
237
  display_name: string | null;
239
238
  bio: string | null;
@@ -812,8 +811,6 @@ interface Database {
812
811
  bns_names: BnsNamesTable;
813
812
  bns_namespaces: BnsNamespacesTable;
814
813
  service_heartbeats: ServiceHeartbeatsTable;
815
- x402_payments: X402PaymentsTable;
816
- x402_balances: X402BalancesTable;
817
814
  chain_read_cache: ChainReadCacheTable;
818
815
  pending_fork_blocks: PendingForkBlocksTable;
819
816
  observer_journal: ObserverJournalTable;
@@ -825,46 +822,10 @@ interface Database {
825
822
  stage_failures: StageFailuresTable;
826
823
  archive_fetches: ArchiveFetchesTable;
827
824
  }
828
- /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
829
- interface X402BalancesTable {
830
- principal: string;
831
- balance_usd_micros: Generated<string | number | bigint>;
832
- /** Month bucket ("YYYY-MM") the spend counter applies to. */
833
- spent_month: string | null;
834
- spent_month_usd_micros: Generated<string | number | bigint>;
835
- updated_at: Generated<Date>;
836
- }
837
825
  interface ServiceHeartbeatsTable {
838
826
  name: string;
839
827
  updated_at: Generated<Date>;
840
828
  }
841
- /** x402 pay-per-request ledger (control plane). One row per settled payment,
842
- * keyed by challenge nonce + settled txid. `state` tracks confirmed-tier
843
- * settlement and post-serve reorg reversal. */
844
- interface X402PaymentsTable {
845
- id: Generated<string>;
846
- nonce: string;
847
- txid: string;
848
- asset: string;
849
- amount: string;
850
- payer: string;
851
- surface: string;
852
- state: Generated<"pending" | "confirmed" | "reverted">;
853
- created_at: Generated<Date>;
854
- updated_at: Generated<Date>;
855
- /** "payment" = per-call settle; "deposit" = prepaid balance top-up. */
856
- kind: Generated<string>;
857
- /** Linked claimed account once the paying wallet is attached (continuity). */
858
- account_id: string | null;
859
- /** USD-micros to credit on confirmation, for deposit rows the reconciler
860
- * settles asynchronously. NULL for per-call settles (credit nothing). */
861
- credit_usd_micros: string | null;
862
- /** Idempotency key: stamped exactly once when this row's credit is applied.
863
- * NULL means never credited (or not a credit-bearing row). Pre-migration
864
- * non-pending deposit rows are backfilled to a non-null sentinel so the
865
- * reconciler's heal path can never double-credit them. */
866
- credited_at: Generated<Date> | null;
867
- }
868
829
  interface AccountSpendCapsTable {
869
830
  account_id: string;
870
831
  monthly_cap_cents: number | null;
@@ -875,7 +836,7 @@ interface AccountSpendCapsTable {
875
836
  frozen_at: Date | null;
876
837
  updated_at: Generated<Date>;
877
838
  }
878
- /** Prepaid dev credits — card-funded balance per account (peer to x402_balances). */
839
+ /** Prepaid dev credits — card-funded balance per account. */
879
840
  interface AccountCreditsTable {
880
841
  account_id: string;
881
842
  balance_usd_micros: Generated<string | number | bigint>;
@@ -137,7 +137,6 @@ interface SubgraphsTable {
137
137
  expires_at: Date | null;
138
138
  /** (event type, contract) probe pairs persisted at deploy for weight classification. */
139
139
  sparse_probe_targets: unknown | null;
140
- database_url_enc: ColumnType<Buffer | null, Buffer | null | undefined, Buffer | null>;
141
140
  sandbox_workers: Generated<boolean>;
142
141
  created_at: Generated<Date>;
143
142
  updated_at: Generated<Date>;
@@ -233,7 +232,7 @@ interface AccountsTable {
233
232
  email: string | null;
234
233
  /** True for anonymous self-serve accounts until claimed via magic link. */
235
234
  ghost: Generated<boolean>;
236
- /** Stacks principal owning a wallet-ghost account (x402-paid deploys). */
235
+ /** Stacks principal owning a wallet-ghost account. */
237
236
  wallet_principal: string | null;
238
237
  display_name: string | null;
239
238
  bio: string | null;
@@ -812,8 +811,6 @@ interface Database {
812
811
  bns_names: BnsNamesTable;
813
812
  bns_namespaces: BnsNamespacesTable;
814
813
  service_heartbeats: ServiceHeartbeatsTable;
815
- x402_payments: X402PaymentsTable;
816
- x402_balances: X402BalancesTable;
817
814
  chain_read_cache: ChainReadCacheTable;
818
815
  pending_fork_blocks: PendingForkBlocksTable;
819
816
  observer_journal: ObserverJournalTable;
@@ -825,46 +822,10 @@ interface Database {
825
822
  stage_failures: StageFailuresTable;
826
823
  archive_fetches: ArchiveFetchesTable;
827
824
  }
828
- /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
829
- interface X402BalancesTable {
830
- principal: string;
831
- balance_usd_micros: Generated<string | number | bigint>;
832
- /** Month bucket ("YYYY-MM") the spend counter applies to. */
833
- spent_month: string | null;
834
- spent_month_usd_micros: Generated<string | number | bigint>;
835
- updated_at: Generated<Date>;
836
- }
837
825
  interface ServiceHeartbeatsTable {
838
826
  name: string;
839
827
  updated_at: Generated<Date>;
840
828
  }
841
- /** x402 pay-per-request ledger (control plane). One row per settled payment,
842
- * keyed by challenge nonce + settled txid. `state` tracks confirmed-tier
843
- * settlement and post-serve reorg reversal. */
844
- interface X402PaymentsTable {
845
- id: Generated<string>;
846
- nonce: string;
847
- txid: string;
848
- asset: string;
849
- amount: string;
850
- payer: string;
851
- surface: string;
852
- state: Generated<"pending" | "confirmed" | "reverted">;
853
- created_at: Generated<Date>;
854
- updated_at: Generated<Date>;
855
- /** "payment" = per-call settle; "deposit" = prepaid balance top-up. */
856
- kind: Generated<string>;
857
- /** Linked claimed account once the paying wallet is attached (continuity). */
858
- account_id: string | null;
859
- /** USD-micros to credit on confirmation, for deposit rows the reconciler
860
- * settles asynchronously. NULL for per-call settles (credit nothing). */
861
- credit_usd_micros: string | null;
862
- /** Idempotency key: stamped exactly once when this row's credit is applied.
863
- * NULL means never credited (or not a credit-bearing row). Pre-migration
864
- * non-pending deposit rows are backfilled to a non-null sentinel so the
865
- * reconciler's heal path can never double-credit them. */
866
- credited_at: Generated<Date> | null;
867
- }
868
829
  interface AccountSpendCapsTable {
869
830
  account_id: string;
870
831
  monthly_cap_cents: number | null;
@@ -875,7 +836,7 @@ interface AccountSpendCapsTable {
875
836
  frozen_at: Date | null;
876
837
  updated_at: Generated<Date>;
877
838
  }
878
- /** Prepaid dev credits — card-funded balance per account (peer to x402_balances). */
839
+ /** Prepaid dev credits — card-funded balance per account. */
879
840
  interface AccountCreditsTable {
880
841
  account_id: string;
881
842
  balance_usd_micros: Generated<string | number | bigint>;
@@ -137,7 +137,6 @@ interface SubgraphsTable {
137
137
  expires_at: Date | null;
138
138
  /** (event type, contract) probe pairs persisted at deploy for weight classification. */
139
139
  sparse_probe_targets: unknown | null;
140
- database_url_enc: ColumnType<Buffer | null, Buffer | null | undefined, Buffer | null>;
141
140
  sandbox_workers: Generated<boolean>;
142
141
  created_at: Generated<Date>;
143
142
  updated_at: Generated<Date>;
@@ -233,7 +232,7 @@ interface AccountsTable {
233
232
  email: string | null;
234
233
  /** True for anonymous self-serve accounts until claimed via magic link. */
235
234
  ghost: Generated<boolean>;
236
- /** Stacks principal owning a wallet-ghost account (x402-paid deploys). */
235
+ /** Stacks principal owning a wallet-ghost account. */
237
236
  wallet_principal: string | null;
238
237
  display_name: string | null;
239
238
  bio: string | null;
@@ -812,8 +811,6 @@ interface Database {
812
811
  bns_names: BnsNamesTable;
813
812
  bns_namespaces: BnsNamespacesTable;
814
813
  service_heartbeats: ServiceHeartbeatsTable;
815
- x402_payments: X402PaymentsTable;
816
- x402_balances: X402BalancesTable;
817
814
  chain_read_cache: ChainReadCacheTable;
818
815
  pending_fork_blocks: PendingForkBlocksTable;
819
816
  observer_journal: ObserverJournalTable;
@@ -825,46 +822,10 @@ interface Database {
825
822
  stage_failures: StageFailuresTable;
826
823
  archive_fetches: ArchiveFetchesTable;
827
824
  }
828
- /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
829
- interface X402BalancesTable {
830
- principal: string;
831
- balance_usd_micros: Generated<string | number | bigint>;
832
- /** Month bucket ("YYYY-MM") the spend counter applies to. */
833
- spent_month: string | null;
834
- spent_month_usd_micros: Generated<string | number | bigint>;
835
- updated_at: Generated<Date>;
836
- }
837
825
  interface ServiceHeartbeatsTable {
838
826
  name: string;
839
827
  updated_at: Generated<Date>;
840
828
  }
841
- /** x402 pay-per-request ledger (control plane). One row per settled payment,
842
- * keyed by challenge nonce + settled txid. `state` tracks confirmed-tier
843
- * settlement and post-serve reorg reversal. */
844
- interface X402PaymentsTable {
845
- id: Generated<string>;
846
- nonce: string;
847
- txid: string;
848
- asset: string;
849
- amount: string;
850
- payer: string;
851
- surface: string;
852
- state: Generated<"pending" | "confirmed" | "reverted">;
853
- created_at: Generated<Date>;
854
- updated_at: Generated<Date>;
855
- /** "payment" = per-call settle; "deposit" = prepaid balance top-up. */
856
- kind: Generated<string>;
857
- /** Linked claimed account once the paying wallet is attached (continuity). */
858
- account_id: string | null;
859
- /** USD-micros to credit on confirmation, for deposit rows the reconciler
860
- * settles asynchronously. NULL for per-call settles (credit nothing). */
861
- credit_usd_micros: string | null;
862
- /** Idempotency key: stamped exactly once when this row's credit is applied.
863
- * NULL means never credited (or not a credit-bearing row). Pre-migration
864
- * non-pending deposit rows are backfilled to a non-null sentinel so the
865
- * reconciler's heal path can never double-credit them. */
866
- credited_at: Generated<Date> | null;
867
- }
868
829
  interface AccountSpendCapsTable {
869
830
  account_id: string;
870
831
  monthly_cap_cents: number | null;
@@ -875,7 +836,7 @@ interface AccountSpendCapsTable {
875
836
  frozen_at: Date | null;
876
837
  updated_at: Generated<Date>;
877
838
  }
878
- /** Prepaid dev credits — card-funded balance per account (peer to x402_balances). */
839
+ /** Prepaid dev credits — card-funded balance per account. */
879
840
  interface AccountCreditsTable {
880
841
  account_id: string;
881
842
  balance_usd_micros: Generated<string | number | bigint>;
@@ -96,8 +96,7 @@ async function registerSubgraph(db, data) {
96
96
  handler_code: data.handlerCode ?? null,
97
97
  source_code: data.sourceCode ?? null,
98
98
  schema_name: data.schemaName ?? null,
99
- start_block: data.startBlock ?? 0,
100
- database_url_enc: null
99
+ start_block: data.startBlock ?? 0
101
100
  };
102
101
  const updateSet = {
103
102
  version: data.version,
@@ -108,7 +107,6 @@ async function registerSubgraph(db, data) {
108
107
  source_code: data.sourceCode ?? null,
109
108
  schema_name: data.schemaName ?? null,
110
109
  start_block: data.startBlock ?? 0,
111
- database_url_enc: null,
112
110
  updated_at: new Date
113
111
  };
114
112
  if (!isPlatformMode()) {
@@ -224,5 +222,5 @@ export {
224
222
  deleteSubgraph
225
223
  };
226
224
 
227
- //# debugId=0C7267DDF02AF5D764756E2164756E21
225
+ //# debugId=4A4D32D3E754A61364756E2164756E21
228
226
  //# sourceMappingURL=subgraphs.js.map
@@ -4,9 +4,9 @@
4
4
  "sourcesContent": [
5
5
  "/**\n * Instance modes for the Secondlayer platform.\n *\n * - `oss`: self-hosted, single-tenant. No auth middleware, no platform routes\n * (projects, admin). Everything runs against a single `DATABASE_URL`.\n * Intended for `docker compose up`.\n *\n * - `platform`: the metered archive deployment. Magic-link auth, API keys,\n * accounts, credits, and metered `/v1` reads (Index + Streams + subgraphs)\n * against a single shared DB. No paid tier ladder — one metered `free`\n * tier plus first-party internal service credentials.\n */\n\nexport type InstanceMode = \"oss\" | \"platform\";\n\n/** What the operator wrote in the env — `archive` is the honest name for the\n * metered public-archive deployment and aliases `platform` behaviorally. */\nexport type DeclaredInstanceMode = InstanceMode | \"archive\";\n\nconst VALID_MODES: readonly DeclaredInstanceMode[] = [\n\t\"oss\",\n\t\"platform\",\n\t\"archive\",\n];\n\nfunction declaredMode(): DeclaredInstanceMode {\n\tconst raw = process.env.INSTANCE_MODE?.trim().toLowerCase();\n\tif (raw && (VALID_MODES as readonly string[]).includes(raw)) {\n\t\treturn raw as DeclaredInstanceMode;\n\t}\n\treturn \"oss\";\n}\n\n/**\n * Resolve the active instance mode from `process.env.INSTANCE_MODE`.\n * Defaults to `\"oss\"` — the safest default for self-hosters who deploy\n * without setting the variable. `archive` normalizes to `platform` here so\n * every behavioral branch stays a two-way choice; use\n * `getDeclaredInstanceMode()` for display surfaces.\n */\nexport function getInstanceMode(): InstanceMode {\n\tconst declared = declaredMode();\n\treturn declared === \"archive\" ? \"platform\" : declared;\n}\n\n/** The mode as declared in the env, for status/identity surfaces. */\nexport function getDeclaredInstanceMode(): DeclaredInstanceMode {\n\treturn declaredMode();\n}\n\n/**\n * True when public reads are credit-metered (the free window, retention, and\n * credits gates arm). Platform/archive deployments meter by default;\n * self-host never does unless the operator explicitly sets\n * `METERED_READS=true`. `METERED_READS=false` disarms a metered deployment.\n */\nexport function isMeteredReads(): boolean {\n\tconst override = process.env.METERED_READS?.trim().toLowerCase();\n\tif (override === \"true\") return true;\n\tif (override === \"false\") return false;\n\treturn getInstanceMode() === \"platform\";\n}\n\n/** True when the active mode is `\"platform\"` (shared multi-tenant). */\nexport function isPlatformMode(): boolean {\n\treturn getInstanceMode() === \"platform\";\n}\n\n/** True when the active mode is `\"oss\"` (self-hosted). */\nexport function isOssMode(): boolean {\n\treturn getInstanceMode() === \"oss\";\n}\n",
6
6
  "import { type RawBuilder, sql } from \"kysely\";\n\n/**\n * Safely encode a JS value as a JSONB literal for Kysely inserts/updates.\n * Kysely + postgres.js double-encodes JSON when using parameterized queries\n * with ::jsonb casts. This uses sql.raw to inline a properly escaped literal.\n *\n * Generic parameter lets callers set the RawBuilder's output type so they\n * don't need to cast at the insert site. Default is `unknown` — widen at\n * the call site when the column type is narrower, e.g. `jsonb<MyShape>(...)`.\n */\nexport function jsonb<T = unknown>(value: T): RawBuilder<T> {\n\tconst escaped = JSON.stringify(value, (_k, v) =>\n\t\ttypeof v === \"bigint\" ? v.toString() : v,\n\t).replace(/'/g, \"''\");\n\treturn sql`${sql.raw(`'${escaped}'::jsonb`)}`;\n}\n\n/**\n * Safely parse a JSONB value from the database.\n * Handles double-encoded strings where postgres.js returns a JSON string\n * instead of a parsed object.\n */\nexport function parseJsonb<T = unknown>(value: unknown): T {\n\tif (typeof value === \"string\") {\n\t\ttry {\n\t\t\treturn JSON.parse(value) as T;\n\t\t} catch {\n\t\t\treturn value as T;\n\t\t}\n\t}\n\treturn (value ?? {}) as T;\n}\n",
7
- "import { type Kysely, sql } from \"kysely\";\nimport { isPlatformMode } from \"../../mode.ts\";\nimport { jsonb } from \"../jsonb.ts\";\nimport type { Database, Subgraph } from \"../types.ts\";\n\n/**\n * Convert a subgraph name to its PostgreSQL schema name (legacy form).\n * Pre shared-rip every tenant DB had its own schema namespace so disambiguation\n * was implicit. Kept for oss mode (single-tenant) and legacy-row fallback.\n * Platform-mode deploys use `pgSchemaNameFor(accountId, name)`.\n */\nexport function pgSchemaName(subgraphName: string): string {\n\tconst safeName = subgraphName.replace(/-/g, \"_\");\n\treturn `subgraph_${safeName}`;\n}\n\n/** OSS writes empty account_id — name is the local unique key. */\nexport function localSubgraphAccountId(accountId?: string): string {\n\tif (!isPlatformMode()) return \"\";\n\treturn accountId ?? \"\";\n}\n\n/**\n * Account-scoped schema name. Matches migration 0028's rename pattern:\n * subgraph_{first8charsOfAccountId, dashes-as-underscores}_{name}\n * Empty accountId falls back to legacy form (oss mode).\n */\nexport function pgSchemaNameFor(\n\taccountId: string,\n\tsubgraphName: string,\n): string {\n\tif (!accountId) return pgSchemaName(subgraphName);\n\tconst accountPrefix = accountId.slice(0, 8).replace(/-/g, \"_\");\n\tconst safeName = subgraphName.replace(/-/g, \"_\");\n\treturn `subgraph_${accountPrefix}_${safeName}`;\n}\n\nexport async function registerSubgraph(\n\tdb: Kysely<Database>,\n\tdata: {\n\t\tname: string;\n\t\tversion: string;\n\t\tdefinition: Record<string, unknown>;\n\t\tschemaHash: string;\n\t\thandlerPath: string;\n\t\tapiKeyId?: string;\n\t\taccountId?: string;\n\t\tschemaName?: string;\n\t\tstartBlock?: number;\n\t\thandlerCode?: string;\n\t\tsourceCode?: string;\n\t},\n): Promise<Subgraph> {\n\tconst accountId = localSubgraphAccountId(data.accountId);\n\tconst values = {\n\t\tname: data.name,\n\t\tversion: data.version,\n\t\tdefinition: jsonb<Record<string, unknown>>(data.definition),\n\t\tschema_hash: data.schemaHash,\n\t\thandler_path: data.handlerPath,\n\t\taccount_id: accountId,\n\t\thandler_code: data.handlerCode ?? null,\n\t\tsource_code: data.sourceCode ?? null,\n\t\tschema_name: data.schemaName ?? null,\n\t\tstart_block: data.startBlock ?? 0,\n\t\tdatabase_url_enc: null,\n\t};\n\tconst updateSet = {\n\t\tversion: data.version,\n\t\tdefinition: jsonb<Record<string, unknown>>(data.definition),\n\t\tschema_hash: data.schemaHash,\n\t\thandler_path: data.handlerPath,\n\t\thandler_code: data.handlerCode ?? null,\n\t\tsource_code: data.sourceCode ?? null,\n\t\tschema_name: data.schemaName ?? null,\n\t\tstart_block: data.startBlock ?? 0,\n\t\tdatabase_url_enc: null,\n\t\tupdated_at: new Date(),\n\t};\n\n\t// OSS: name is unique. Upsert by name so leftover rows with a non-empty\n\t// account_id (pre-local-namespace deploys) don't insert a second row.\n\tif (!isPlatformMode()) {\n\t\tconst existing = await db\n\t\t\t.selectFrom(\"subgraphs\")\n\t\t\t.select(\"id\")\n\t\t\t.where(\"name\", \"=\", data.name)\n\t\t\t.executeTakeFirst();\n\t\tif (existing) {\n\t\t\treturn await db\n\t\t\t\t.updateTable(\"subgraphs\")\n\t\t\t\t.set({ ...updateSet, account_id: \"\" })\n\t\t\t\t.where(\"id\", \"=\", existing.id)\n\t\t\t\t.returningAll()\n\t\t\t\t.executeTakeFirstOrThrow();\n\t\t}\n\t\treturn await db\n\t\t\t.insertInto(\"subgraphs\")\n\t\t\t.values(values)\n\t\t\t.returningAll()\n\t\t\t.executeTakeFirstOrThrow();\n\t}\n\n\treturn await db\n\t\t.insertInto(\"subgraphs\")\n\t\t.values(values)\n\t\t.onConflict((oc) =>\n\t\t\toc.columns([\"name\", \"account_id\"]).doUpdateSet(updateSet),\n\t\t)\n\t\t.returningAll()\n\t\t.executeTakeFirstOrThrow();\n}\n\nexport async function getSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId?: string,\n): Promise<Subgraph | null> {\n\tlet query = db.selectFrom(\"subgraphs\").selectAll().where(\"name\", \"=\", name);\n\n\tif (isPlatformMode() && accountId !== undefined) {\n\t\tquery = query.where(\"account_id\", \"=\", accountId);\n\t}\n\n\treturn (await query.executeTakeFirst()) ?? null;\n}\n\nexport async function listSubgraphs(\n\tdb: Kysely<Database>,\n\taccountId?: string,\n): Promise<Subgraph[]> {\n\tlet query = db.selectFrom(\"subgraphs\").selectAll();\n\tif (isPlatformMode() && accountId !== undefined) {\n\t\tquery = query.where(\"account_id\", \"=\", accountId);\n\t}\n\treturn query.execute();\n}\n\nexport async function updateSubgraphStatus(\n\tdb: Kysely<Database>,\n\tname: string,\n\tstatus: string,\n\tlastProcessedBlock?: number,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tstatus,\n\t\t\t...(lastProcessedBlock !== undefined\n\t\t\t\t? { last_processed_block: lastProcessedBlock }\n\t\t\t\t: {}),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n\n/** Account-scoped pause. Only active/reindexing rows flip; name-only\n * {@link updateSubgraphStatus} is unsafe on platform (name, account_id). */\nexport async function pauseSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({ status: \"paused\", updated_at: new Date() })\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"status\", \"in\", [\"active\", \"reindexing\"])\n\t\t.execute();\n}\n\n/** Resume every paused subgraph for an account (claim / Stripe top-up). */\nexport async function resumePausedSubgraphs(\n\tdb: Kysely<Database>,\n\taccountId: string,\n): Promise<number> {\n\tconst res = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({ status: \"active\", updated_at: new Date() })\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"status\", \"=\", \"paused\")\n\t\t.executeTakeFirst();\n\treturn Number(res.numUpdatedRows ?? 0);\n}\n\n/** Live-walk ERROR write (f069): a block whose handlers ALL failed\n * (`processed === 0 && errors > 0`, `block-processor.ts`'s `applyProgress`)\n * is stamped 'error' and its height is recorded as processed, same as\n * `updateSubgraphStatus(db, name, \"error\", blockHeight)` — except the\n * cursor half of that write now goes through the same conditional `<`\n * guard as {@link recordLiveProgress}. Marking a subgraph 'error' is not\n * itself replay-sensitive, but it shares the `last_processed_block` column\n * with the replay guard: an unconditional write here could regress the\n * cursor a racing (successful) writer already advanced past, which is\n * exactly the regress-then-re-walk loop this guard exists to close. In\n * practice `ctx.rollbackTo` (`runner.ts`) means an all-failed block never\n * flushes writes, so a lost race here is always a silent no-op, never a\n * case that needs `CursorRaceLostError`-style tx abort. Returns whether\n * the write applied. Live path only — reindex/backfill's error stamping\n * goes through {@link updateSubgraphStatus} unconditionally, as before. */\nexport async function recordLiveError(\n\tdb: Kysely<Database>,\n\tname: string,\n\tblockHeight: number,\n): Promise<boolean> {\n\tconst result = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tstatus: \"error\",\n\t\t\tlast_processed_block: blockHeight,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"last_processed_block\", \"<\", blockHeight)\n\t\t.executeTakeFirst();\n\treturn Number(result.numUpdatedRows ?? 0n) > 0;\n}\n\nexport async function recordSubgraphProcessed(\n\tdb: Kysely<Database>,\n\tname: string,\n\tprocessed: number,\n\terrors: number,\n\tlastError?: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\ttotal_processed: sql`total_processed + ${processed}`,\n\t\t\ttotal_errors: sql`total_errors + ${errors}`,\n\t\t\t...(lastError\n\t\t\t\t? { last_error: lastError, last_error_at: new Date() }\n\t\t\t\t: {}),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n\nexport async function updateSubgraphHandlerPath(\n\tdb: Kysely<Database>,\n\tname: string,\n\thandlerPath: string,\n\topts?: { handlerCode?: string; sourceCode?: string },\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\thandler_path: handlerPath,\n\t\t\t...(opts?.handlerCode != null ? { handler_code: opts.handlerCode } : {}),\n\t\t\t...(opts?.sourceCode != null ? { source_code: opts.sourceCode } : {}),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n\nexport async function deleteSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId?: string,\n): Promise<Subgraph | null> {\n\tconst subgraph = await getSubgraph(db, name, accountId);\n\tif (!subgraph) return null;\n\n\t// Use stored schema_name if available, otherwise compute\n\tconst schemaName = subgraph.schema_name ?? pgSchemaName(name);\n\n\t// Cascade to webhooks: a webhook pointing at a deleted\n\t// subgraph + table will throw `relation does not exist` on every\n\t// subsequent emission. Pause active subs and purge any pending outbox\n\t// rows so receivers don't get phantom replays. We don't delete the\n\t// webhooks themselves — operators may want to repoint them at a\n\t// resurrected subgraph; we just stop them firing.\n\tawait db\n\t\t.updateTable(\"webhooks\")\n\t\t.set({\n\t\t\tstatus: \"paused\",\n\t\t\tlast_error: `Subgraph \"${name}\" deleted; webhook auto-paused.`,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"subgraph_name\", \"=\", name)\n\t\t.execute();\n\tawait db\n\t\t.deleteFrom(\"webhook_outbox\")\n\t\t.where(\"status\", \"=\", \"pending\")\n\t\t.where(\"webhook_id\", \"in\", (qb) =>\n\t\t\tqb.selectFrom(\"webhooks\").select(\"id\").where(\"subgraph_name\", \"=\", name),\n\t\t)\n\t\t.execute();\n\n\t// Drop the subgraph's schema (CASCADE drops all tables within).\n\tawait sql`DROP SCHEMA IF EXISTS ${sql.raw(`\"${schemaName}\"`)} CASCADE`.execute(\n\t\tdb,\n\t);\n\n\t// Remove from registry\n\tawait db.deleteFrom(\"subgraphs\").where(\"id\", \"=\", subgraph.id).execute();\n\n\treturn subgraph;\n}\n\n/** Set or clear a paid subgraph's expiry (NULL = no expiry, e.g. on claim). */\nexport async function updateSubgraphExpiry(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId: string,\n\texpiresAt: Date | null,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({ expires_at: expiresAt })\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.execute();\n}\n\n/** Live-walk progress write: advances the cursor and PROMOTES toward\n * 'active' (deploying/error → active keeps reorg eligibility, reorg.ts gates\n * on it) but never overwrites an explicit 'reindexing' park — unconditional\n * status stamping let catch-up flap a parked subgraph back into its own path\n * per block, fighting the queued reindex op.\n *\n * `last_processed_block` is now written CONDITIONALLY — `WHERE\n * last_processed_block < lastProcessedBlock`, mirroring\n * `advanceOperationCursor`'s (`subgraph-operations.ts`) comparison shape —\n * and returns whether THIS call actually advanced it. This used to be\n * unconditional by design, on the premise that the only two writers able to\n * advance/rewind a given subgraph's cursor concurrently (the catch-up walk\n * and the reorg handler) serialize on an in-process per-subgraph lock +\n * reorg epoch guard (`packages/subgraphs/src/runtime/catchup.ts`,\n * `subgraphBlockLockHeld` / `reorgEpoch`; f057). That guard is in-process\n * only. The f068 investigation\n * (`docs/internal/audits/asset-holdings-unreproducible-balances-f068.md`)\n * found a cross-process sequence it does not cover: a catch-up leader that\n * loses its advisory-lock connection mid-walk keeps writing (leadership is\n * checked only at walk entry, not per-iteration) while a new leader takes\n * over and walks the same range — both commit increments for overlapping\n * heights, and every regressed cursor write from the laggard re-triggers a\n * full re-walk, growing per-height application without bound. The\n * conditional advance here (paired with the fast-path replay guard armed on\n * the live path in `block-processor.ts`) is now the cross-process\n * guarantee: a block at/below the current cursor can never re-advance it,\n * so a laggard's commits can no longer regress-then-retrigger.\n *\n * This conditionality is why the reorg rewind can no longer go through this\n * function — a rewind's whole point is to move the cursor *backward*, which\n * the `<` guard would silently refuse. Reorg mode calls\n * {@link rewindLiveProgress} instead, which keeps the old unconditional\n * semantics and is safe specifically because the reorg path takes a\n * transaction-scoped advisory lock (`reorg.ts`) other writers can't cross. */\nexport async function recordLiveProgress(\n\tdb: Kysely<Database>,\n\tname: string,\n\tlastProcessedBlock: number,\n): Promise<boolean> {\n\tconst result = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tlast_processed_block: lastProcessedBlock,\n\t\t\tstatus: sql`CASE WHEN status = 'reindexing' THEN status ELSE 'active' END`,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"last_processed_block\", \"<\", lastProcessedBlock)\n\t\t.executeTakeFirst();\n\treturn Number(result.numUpdatedRows ?? 0n) > 0;\n}\n\n/** Reorg-rewind progress write: the OLD unconditional `recordLiveProgress`\n * semantics, verbatim — moves `last_processed_block` to the fork height\n * regardless of its current value, because that is by definition a\n * backward move the conditional `<` guard in `recordLiveProgress` would\n * refuse. Same status-promotion CASE (never unparks an explicit\n * 'reindexing').\n *\n * Callers: exclusively the subgraph-reorg path\n * (`packages/subgraphs/src/runtime/reorg.ts`, via `block-processor.ts`'s\n * `reorgRewind` mode), which is safe from the cross-process race this\n * function reintroduces because it holds a transaction-scoped Postgres\n * advisory lock (`pg_advisory_xact_lock`) for the whole\n * delete+reprocess+rewind sequence — no other writer can interleave a\n * forward write between the rewind and the fork block's reprocess. Do not\n * call this from the live catch-up path. */\nexport async function rewindLiveProgress(\n\tdb: Kysely<Database>,\n\tname: string,\n\tlastProcessedBlock: number,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tlast_processed_block: lastProcessedBlock,\n\t\t\tstatus: sql`CASE WHEN status = 'reindexing' THEN status ELSE 'active' END`,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n"
7
+ "import { type Kysely, sql } from \"kysely\";\nimport { isPlatformMode } from \"../../mode.ts\";\nimport { jsonb } from \"../jsonb.ts\";\nimport type { Database, Subgraph } from \"../types.ts\";\n\n/**\n * Convert a subgraph name to its PostgreSQL schema name (legacy form).\n * Pre shared-rip every tenant DB had its own schema namespace so disambiguation\n * was implicit. Kept for oss mode (single-tenant) and legacy-row fallback.\n * Platform-mode deploys use `pgSchemaNameFor(accountId, name)`.\n */\nexport function pgSchemaName(subgraphName: string): string {\n\tconst safeName = subgraphName.replace(/-/g, \"_\");\n\treturn `subgraph_${safeName}`;\n}\n\n/** OSS writes empty account_id — name is the local unique key. */\nexport function localSubgraphAccountId(accountId?: string): string {\n\tif (!isPlatformMode()) return \"\";\n\treturn accountId ?? \"\";\n}\n\n/**\n * Account-scoped schema name. Matches migration 0028's rename pattern:\n * subgraph_{first8charsOfAccountId, dashes-as-underscores}_{name}\n * Empty accountId falls back to legacy form (oss mode).\n */\nexport function pgSchemaNameFor(\n\taccountId: string,\n\tsubgraphName: string,\n): string {\n\tif (!accountId) return pgSchemaName(subgraphName);\n\tconst accountPrefix = accountId.slice(0, 8).replace(/-/g, \"_\");\n\tconst safeName = subgraphName.replace(/-/g, \"_\");\n\treturn `subgraph_${accountPrefix}_${safeName}`;\n}\n\nexport async function registerSubgraph(\n\tdb: Kysely<Database>,\n\tdata: {\n\t\tname: string;\n\t\tversion: string;\n\t\tdefinition: Record<string, unknown>;\n\t\tschemaHash: string;\n\t\thandlerPath: string;\n\t\tapiKeyId?: string;\n\t\taccountId?: string;\n\t\tschemaName?: string;\n\t\tstartBlock?: number;\n\t\thandlerCode?: string;\n\t\tsourceCode?: string;\n\t},\n): Promise<Subgraph> {\n\tconst accountId = localSubgraphAccountId(data.accountId);\n\tconst values = {\n\t\tname: data.name,\n\t\tversion: data.version,\n\t\tdefinition: jsonb<Record<string, unknown>>(data.definition),\n\t\tschema_hash: data.schemaHash,\n\t\thandler_path: data.handlerPath,\n\t\taccount_id: accountId,\n\t\thandler_code: data.handlerCode ?? null,\n\t\tsource_code: data.sourceCode ?? null,\n\t\tschema_name: data.schemaName ?? null,\n\t\tstart_block: data.startBlock ?? 0,\n\t};\n\tconst updateSet = {\n\t\tversion: data.version,\n\t\tdefinition: jsonb<Record<string, unknown>>(data.definition),\n\t\tschema_hash: data.schemaHash,\n\t\thandler_path: data.handlerPath,\n\t\thandler_code: data.handlerCode ?? null,\n\t\tsource_code: data.sourceCode ?? null,\n\t\tschema_name: data.schemaName ?? null,\n\t\tstart_block: data.startBlock ?? 0,\n\t\tupdated_at: new Date(),\n\t};\n\n\t// OSS: name is unique. Upsert by name so leftover rows with a non-empty\n\t// account_id (pre-local-namespace deploys) don't insert a second row.\n\tif (!isPlatformMode()) {\n\t\tconst existing = await db\n\t\t\t.selectFrom(\"subgraphs\")\n\t\t\t.select(\"id\")\n\t\t\t.where(\"name\", \"=\", data.name)\n\t\t\t.executeTakeFirst();\n\t\tif (existing) {\n\t\t\treturn await db\n\t\t\t\t.updateTable(\"subgraphs\")\n\t\t\t\t.set({ ...updateSet, account_id: \"\" })\n\t\t\t\t.where(\"id\", \"=\", existing.id)\n\t\t\t\t.returningAll()\n\t\t\t\t.executeTakeFirstOrThrow();\n\t\t}\n\t\treturn await db\n\t\t\t.insertInto(\"subgraphs\")\n\t\t\t.values(values)\n\t\t\t.returningAll()\n\t\t\t.executeTakeFirstOrThrow();\n\t}\n\n\treturn await db\n\t\t.insertInto(\"subgraphs\")\n\t\t.values(values)\n\t\t.onConflict((oc) =>\n\t\t\toc.columns([\"name\", \"account_id\"]).doUpdateSet(updateSet),\n\t\t)\n\t\t.returningAll()\n\t\t.executeTakeFirstOrThrow();\n}\n\nexport async function getSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId?: string,\n): Promise<Subgraph | null> {\n\tlet query = db.selectFrom(\"subgraphs\").selectAll().where(\"name\", \"=\", name);\n\n\tif (isPlatformMode() && accountId !== undefined) {\n\t\tquery = query.where(\"account_id\", \"=\", accountId);\n\t}\n\n\treturn (await query.executeTakeFirst()) ?? null;\n}\n\nexport async function listSubgraphs(\n\tdb: Kysely<Database>,\n\taccountId?: string,\n): Promise<Subgraph[]> {\n\tlet query = db.selectFrom(\"subgraphs\").selectAll();\n\tif (isPlatformMode() && accountId !== undefined) {\n\t\tquery = query.where(\"account_id\", \"=\", accountId);\n\t}\n\treturn query.execute();\n}\n\nexport async function updateSubgraphStatus(\n\tdb: Kysely<Database>,\n\tname: string,\n\tstatus: string,\n\tlastProcessedBlock?: number,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tstatus,\n\t\t\t...(lastProcessedBlock !== undefined\n\t\t\t\t? { last_processed_block: lastProcessedBlock }\n\t\t\t\t: {}),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n\n/** Account-scoped pause. Only active/reindexing rows flip; name-only\n * {@link updateSubgraphStatus} is unsafe on platform (name, account_id). */\nexport async function pauseSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({ status: \"paused\", updated_at: new Date() })\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"status\", \"in\", [\"active\", \"reindexing\"])\n\t\t.execute();\n}\n\n/** Resume every paused subgraph for an account (claim / Stripe top-up). */\nexport async function resumePausedSubgraphs(\n\tdb: Kysely<Database>,\n\taccountId: string,\n): Promise<number> {\n\tconst res = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({ status: \"active\", updated_at: new Date() })\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"status\", \"=\", \"paused\")\n\t\t.executeTakeFirst();\n\treturn Number(res.numUpdatedRows ?? 0);\n}\n\n/** Live-walk ERROR write (f069): a block whose handlers ALL failed\n * (`processed === 0 && errors > 0`, `block-processor.ts`'s `applyProgress`)\n * is stamped 'error' and its height is recorded as processed, same as\n * `updateSubgraphStatus(db, name, \"error\", blockHeight)` — except the\n * cursor half of that write now goes through the same conditional `<`\n * guard as {@link recordLiveProgress}. Marking a subgraph 'error' is not\n * itself replay-sensitive, but it shares the `last_processed_block` column\n * with the replay guard: an unconditional write here could regress the\n * cursor a racing (successful) writer already advanced past, which is\n * exactly the regress-then-re-walk loop this guard exists to close. In\n * practice `ctx.rollbackTo` (`runner.ts`) means an all-failed block never\n * flushes writes, so a lost race here is always a silent no-op, never a\n * case that needs `CursorRaceLostError`-style tx abort. Returns whether\n * the write applied. Live path only — reindex/backfill's error stamping\n * goes through {@link updateSubgraphStatus} unconditionally, as before. */\nexport async function recordLiveError(\n\tdb: Kysely<Database>,\n\tname: string,\n\tblockHeight: number,\n): Promise<boolean> {\n\tconst result = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tstatus: \"error\",\n\t\t\tlast_processed_block: blockHeight,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"last_processed_block\", \"<\", blockHeight)\n\t\t.executeTakeFirst();\n\treturn Number(result.numUpdatedRows ?? 0n) > 0;\n}\n\nexport async function recordSubgraphProcessed(\n\tdb: Kysely<Database>,\n\tname: string,\n\tprocessed: number,\n\terrors: number,\n\tlastError?: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\ttotal_processed: sql`total_processed + ${processed}`,\n\t\t\ttotal_errors: sql`total_errors + ${errors}`,\n\t\t\t...(lastError\n\t\t\t\t? { last_error: lastError, last_error_at: new Date() }\n\t\t\t\t: {}),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n\nexport async function updateSubgraphHandlerPath(\n\tdb: Kysely<Database>,\n\tname: string,\n\thandlerPath: string,\n\topts?: { handlerCode?: string; sourceCode?: string },\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\thandler_path: handlerPath,\n\t\t\t...(opts?.handlerCode != null ? { handler_code: opts.handlerCode } : {}),\n\t\t\t...(opts?.sourceCode != null ? { source_code: opts.sourceCode } : {}),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n\nexport async function deleteSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId?: string,\n): Promise<Subgraph | null> {\n\tconst subgraph = await getSubgraph(db, name, accountId);\n\tif (!subgraph) return null;\n\n\t// Use stored schema_name if available, otherwise compute\n\tconst schemaName = subgraph.schema_name ?? pgSchemaName(name);\n\n\t// Cascade to webhooks: a webhook pointing at a deleted\n\t// subgraph + table will throw `relation does not exist` on every\n\t// subsequent emission. Pause active subs and purge any pending outbox\n\t// rows so receivers don't get phantom replays. We don't delete the\n\t// webhooks themselves — operators may want to repoint them at a\n\t// resurrected subgraph; we just stop them firing.\n\tawait db\n\t\t.updateTable(\"webhooks\")\n\t\t.set({\n\t\t\tstatus: \"paused\",\n\t\t\tlast_error: `Subgraph \"${name}\" deleted; webhook auto-paused.`,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"subgraph_name\", \"=\", name)\n\t\t.execute();\n\tawait db\n\t\t.deleteFrom(\"webhook_outbox\")\n\t\t.where(\"status\", \"=\", \"pending\")\n\t\t.where(\"webhook_id\", \"in\", (qb) =>\n\t\t\tqb.selectFrom(\"webhooks\").select(\"id\").where(\"subgraph_name\", \"=\", name),\n\t\t)\n\t\t.execute();\n\n\t// Drop the subgraph's schema (CASCADE drops all tables within).\n\tawait sql`DROP SCHEMA IF EXISTS ${sql.raw(`\"${schemaName}\"`)} CASCADE`.execute(\n\t\tdb,\n\t);\n\n\t// Remove from registry\n\tawait db.deleteFrom(\"subgraphs\").where(\"id\", \"=\", subgraph.id).execute();\n\n\treturn subgraph;\n}\n\n/** Set or clear a paid subgraph's expiry (NULL = no expiry, e.g. on claim). */\nexport async function updateSubgraphExpiry(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId: string,\n\texpiresAt: Date | null,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({ expires_at: expiresAt })\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.execute();\n}\n\n/** Live-walk progress write: advances the cursor and PROMOTES toward\n * 'active' (deploying/error → active keeps reorg eligibility, reorg.ts gates\n * on it) but never overwrites an explicit 'reindexing' park — unconditional\n * status stamping let catch-up flap a parked subgraph back into its own path\n * per block, fighting the queued reindex op.\n *\n * `last_processed_block` is now written CONDITIONALLY — `WHERE\n * last_processed_block < lastProcessedBlock`, mirroring\n * `advanceOperationCursor`'s (`subgraph-operations.ts`) comparison shape —\n * and returns whether THIS call actually advanced it. This used to be\n * unconditional by design, on the premise that the only two writers able to\n * advance/rewind a given subgraph's cursor concurrently (the catch-up walk\n * and the reorg handler) serialize on an in-process per-subgraph lock +\n * reorg epoch guard (`packages/subgraphs/src/runtime/catchup.ts`,\n * `subgraphBlockLockHeld` / `reorgEpoch`; f057). That guard is in-process\n * only. The f068 investigation\n * (`docs/internal/audits/asset-holdings-unreproducible-balances-f068.md`)\n * found a cross-process sequence it does not cover: a catch-up leader that\n * loses its advisory-lock connection mid-walk keeps writing (leadership is\n * checked only at walk entry, not per-iteration) while a new leader takes\n * over and walks the same range — both commit increments for overlapping\n * heights, and every regressed cursor write from the laggard re-triggers a\n * full re-walk, growing per-height application without bound. The\n * conditional advance here (paired with the fast-path replay guard armed on\n * the live path in `block-processor.ts`) is now the cross-process\n * guarantee: a block at/below the current cursor can never re-advance it,\n * so a laggard's commits can no longer regress-then-retrigger.\n *\n * This conditionality is why the reorg rewind can no longer go through this\n * function — a rewind's whole point is to move the cursor *backward*, which\n * the `<` guard would silently refuse. Reorg mode calls\n * {@link rewindLiveProgress} instead, which keeps the old unconditional\n * semantics and is safe specifically because the reorg path takes a\n * transaction-scoped advisory lock (`reorg.ts`) other writers can't cross. */\nexport async function recordLiveProgress(\n\tdb: Kysely<Database>,\n\tname: string,\n\tlastProcessedBlock: number,\n): Promise<boolean> {\n\tconst result = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tlast_processed_block: lastProcessedBlock,\n\t\t\tstatus: sql`CASE WHEN status = 'reindexing' THEN status ELSE 'active' END`,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"last_processed_block\", \"<\", lastProcessedBlock)\n\t\t.executeTakeFirst();\n\treturn Number(result.numUpdatedRows ?? 0n) > 0;\n}\n\n/** Reorg-rewind progress write: the OLD unconditional `recordLiveProgress`\n * semantics, verbatim — moves `last_processed_block` to the fork height\n * regardless of its current value, because that is by definition a\n * backward move the conditional `<` guard in `recordLiveProgress` would\n * refuse. Same status-promotion CASE (never unparks an explicit\n * 'reindexing').\n *\n * Callers: exclusively the subgraph-reorg path\n * (`packages/subgraphs/src/runtime/reorg.ts`, via `block-processor.ts`'s\n * `reorgRewind` mode), which is safe from the cross-process race this\n * function reintroduces because it holds a transaction-scoped Postgres\n * advisory lock (`pg_advisory_xact_lock`) for the whole\n * delete+reprocess+rewind sequence — no other writer can interleave a\n * forward write between the rewind and the fork block's reprocess. Do not\n * call this from the live catch-up path. */\nexport async function rewindLiveProgress(\n\tdb: Kysely<Database>,\n\tname: string,\n\tlastProcessedBlock: number,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tlast_processed_block: lastProcessedBlock,\n\t\t\tstatus: sql`CASE WHEN status = 'reindexing' THEN status ELSE 'active' END`,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n"
8
8
  ],
9
- "mappings": ";;;;;;;;;;;;;;;;;AAmBA,IAAM,cAA+C;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACD;AAEA,SAAS,YAAY,GAAyB;AAAA,EAC7C,MAAM,MAAM,QAAQ,IAAI,eAAe,KAAK,EAAE,YAAY;AAAA,EAC1D,IAAI,OAAQ,YAAkC,SAAS,GAAG,GAAG;AAAA,IAC5D,OAAO;AAAA,EACR;AAAA,EACA,OAAO;AAAA;AAUD,SAAS,eAAe,GAAiB;AAAA,EAC/C,MAAM,WAAW,aAAa;AAAA,EAC9B,OAAO,aAAa,YAAY,aAAa;AAAA;AAIvC,SAAS,uBAAuB,GAAyB;AAAA,EAC/D,OAAO,aAAa;AAAA;AASd,SAAS,cAAc,GAAY;AAAA,EACzC,MAAM,WAAW,QAAQ,IAAI,eAAe,KAAK,EAAE,YAAY;AAAA,EAC/D,IAAI,aAAa;AAAA,IAAQ,OAAO;AAAA,EAChC,IAAI,aAAa;AAAA,IAAS,OAAO;AAAA,EACjC,OAAO,gBAAgB,MAAM;AAAA;AAIvB,SAAS,cAAc,GAAY;AAAA,EACzC,OAAO,gBAAgB,MAAM;AAAA;AAIvB,SAAS,SAAS,GAAY;AAAA,EACpC,OAAO,gBAAgB,MAAM;AAAA;;;ACtE9B;AAWO,SAAS,KAAkB,CAAC,OAAyB;AAAA,EAC3D,MAAM,UAAU,KAAK,UAAU,OAAO,CAAC,IAAI,MAC1C,OAAO,MAAM,WAAW,EAAE,SAAS,IAAI,CACxC,EAAE,QAAQ,MAAM,IAAI;AAAA,EACpB,OAAO,MAAM,IAAI,IAAI,IAAI,iBAAiB;AAAA;AAQpC,SAAS,UAAuB,CAAC,OAAmB;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iBAAiB;AAAA,EACnB,OAAO,OAAO,OAAO,kBAAkB,EAAE,IAAI;AAAA;AAkB9C,eAAsB,kBAAkB,CACvC,IACA,MACA,oBACgB;AAAA,EAChB,MAAM,GACJ,YAAY,WAAW,EACvB,IAAI;AAAA,IACJ,sBAAsB;AAAA,IACtB,QAAQ;AAAA,IACR,YAAY,IAAI;AAAA,EACjB,CAAC,EACA,MAAM,QAAQ,KAAK,IAAI,EACvB,QAAQ;AAAA;",
10
+ "debugId": "4A4D32D3E754A61364756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -147,7 +147,6 @@ interface SubgraphsTable {
147
147
  expires_at: Date | null;
148
148
  /** (event type, contract) probe pairs persisted at deploy for weight classification. */
149
149
  sparse_probe_targets: unknown | null;
150
- database_url_enc: ColumnType<Buffer | null, Buffer | null | undefined, Buffer | null>;
151
150
  sandbox_workers: Generated<boolean>;
152
151
  created_at: Generated<Date>;
153
152
  updated_at: Generated<Date>;
@@ -243,7 +242,7 @@ interface AccountsTable {
243
242
  email: string | null;
244
243
  /** True for anonymous self-serve accounts until claimed via magic link. */
245
244
  ghost: Generated<boolean>;
246
- /** Stacks principal owning a wallet-ghost account (x402-paid deploys). */
245
+ /** Stacks principal owning a wallet-ghost account. */
247
246
  wallet_principal: string | null;
248
247
  display_name: string | null;
249
248
  bio: string | null;
@@ -822,8 +821,6 @@ interface Database {
822
821
  bns_names: BnsNamesTable;
823
822
  bns_namespaces: BnsNamespacesTable;
824
823
  service_heartbeats: ServiceHeartbeatsTable;
825
- x402_payments: X402PaymentsTable;
826
- x402_balances: X402BalancesTable;
827
824
  chain_read_cache: ChainReadCacheTable;
828
825
  pending_fork_blocks: PendingForkBlocksTable;
829
826
  observer_journal: ObserverJournalTable;
@@ -835,46 +832,10 @@ interface Database {
835
832
  stage_failures: StageFailuresTable;
836
833
  archive_fetches: ArchiveFetchesTable;
837
834
  }
838
- /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
839
- interface X402BalancesTable {
840
- principal: string;
841
- balance_usd_micros: Generated<string | number | bigint>;
842
- /** Month bucket ("YYYY-MM") the spend counter applies to. */
843
- spent_month: string | null;
844
- spent_month_usd_micros: Generated<string | number | bigint>;
845
- updated_at: Generated<Date>;
846
- }
847
835
  interface ServiceHeartbeatsTable {
848
836
  name: string;
849
837
  updated_at: Generated<Date>;
850
838
  }
851
- /** x402 pay-per-request ledger (control plane). One row per settled payment,
852
- * keyed by challenge nonce + settled txid. `state` tracks confirmed-tier
853
- * settlement and post-serve reorg reversal. */
854
- interface X402PaymentsTable {
855
- id: Generated<string>;
856
- nonce: string;
857
- txid: string;
858
- asset: string;
859
- amount: string;
860
- payer: string;
861
- surface: string;
862
- state: Generated<"pending" | "confirmed" | "reverted">;
863
- created_at: Generated<Date>;
864
- updated_at: Generated<Date>;
865
- /** "payment" = per-call settle; "deposit" = prepaid balance top-up. */
866
- kind: Generated<string>;
867
- /** Linked claimed account once the paying wallet is attached (continuity). */
868
- account_id: string | null;
869
- /** USD-micros to credit on confirmation, for deposit rows the reconciler
870
- * settles asynchronously. NULL for per-call settles (credit nothing). */
871
- credit_usd_micros: string | null;
872
- /** Idempotency key: stamped exactly once when this row's credit is applied.
873
- * NULL means never credited (or not a credit-bearing row). Pre-migration
874
- * non-pending deposit rows are backfilled to a non-null sentinel so the
875
- * reconciler's heal path can never double-credit them. */
876
- credited_at: Generated<Date> | null;
877
- }
878
839
  interface AccountSpendCapsTable {
879
840
  account_id: string;
880
841
  monthly_cap_cents: number | null;
@@ -885,7 +846,7 @@ interface AccountSpendCapsTable {
885
846
  frozen_at: Date | null;
886
847
  updated_at: Generated<Date>;
887
848
  }
888
- /** Prepaid dev credits — card-funded balance per account (peer to x402_balances). */
849
+ /** Prepaid dev credits — card-funded balance per account. */
889
850
  interface AccountCreditsTable {
890
851
  account_id: string;
891
852
  balance_usd_micros: Generated<string | number | bigint>;
@@ -137,7 +137,6 @@ interface SubgraphsTable {
137
137
  expires_at: Date | null;
138
138
  /** (event type, contract) probe pairs persisted at deploy for weight classification. */
139
139
  sparse_probe_targets: unknown | null;
140
- database_url_enc: ColumnType<Buffer | null, Buffer | null | undefined, Buffer | null>;
141
140
  sandbox_workers: Generated<boolean>;
142
141
  created_at: Generated<Date>;
143
142
  updated_at: Generated<Date>;
@@ -233,7 +232,7 @@ interface AccountsTable {
233
232
  email: string | null;
234
233
  /** True for anonymous self-serve accounts until claimed via magic link. */
235
234
  ghost: Generated<boolean>;
236
- /** Stacks principal owning a wallet-ghost account (x402-paid deploys). */
235
+ /** Stacks principal owning a wallet-ghost account. */
237
236
  wallet_principal: string | null;
238
237
  display_name: string | null;
239
238
  bio: string | null;
@@ -812,8 +811,6 @@ interface Database {
812
811
  bns_names: BnsNamesTable;
813
812
  bns_namespaces: BnsNamespacesTable;
814
813
  service_heartbeats: ServiceHeartbeatsTable;
815
- x402_payments: X402PaymentsTable;
816
- x402_balances: X402BalancesTable;
817
814
  chain_read_cache: ChainReadCacheTable;
818
815
  pending_fork_blocks: PendingForkBlocksTable;
819
816
  observer_journal: ObserverJournalTable;
@@ -825,46 +822,10 @@ interface Database {
825
822
  stage_failures: StageFailuresTable;
826
823
  archive_fetches: ArchiveFetchesTable;
827
824
  }
828
- /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
829
- interface X402BalancesTable {
830
- principal: string;
831
- balance_usd_micros: Generated<string | number | bigint>;
832
- /** Month bucket ("YYYY-MM") the spend counter applies to. */
833
- spent_month: string | null;
834
- spent_month_usd_micros: Generated<string | number | bigint>;
835
- updated_at: Generated<Date>;
836
- }
837
825
  interface ServiceHeartbeatsTable {
838
826
  name: string;
839
827
  updated_at: Generated<Date>;
840
828
  }
841
- /** x402 pay-per-request ledger (control plane). One row per settled payment,
842
- * keyed by challenge nonce + settled txid. `state` tracks confirmed-tier
843
- * settlement and post-serve reorg reversal. */
844
- interface X402PaymentsTable {
845
- id: Generated<string>;
846
- nonce: string;
847
- txid: string;
848
- asset: string;
849
- amount: string;
850
- payer: string;
851
- surface: string;
852
- state: Generated<"pending" | "confirmed" | "reverted">;
853
- created_at: Generated<Date>;
854
- updated_at: Generated<Date>;
855
- /** "payment" = per-call settle; "deposit" = prepaid balance top-up. */
856
- kind: Generated<string>;
857
- /** Linked claimed account once the paying wallet is attached (continuity). */
858
- account_id: string | null;
859
- /** USD-micros to credit on confirmation, for deposit rows the reconciler
860
- * settles asynchronously. NULL for per-call settles (credit nothing). */
861
- credit_usd_micros: string | null;
862
- /** Idempotency key: stamped exactly once when this row's credit is applied.
863
- * NULL means never credited (or not a credit-bearing row). Pre-migration
864
- * non-pending deposit rows are backfilled to a non-null sentinel so the
865
- * reconciler's heal path can never double-credit them. */
866
- credited_at: Generated<Date> | null;
867
- }
868
829
  interface AccountSpendCapsTable {
869
830
  account_id: string;
870
831
  monthly_cap_cents: number | null;
@@ -875,7 +836,7 @@ interface AccountSpendCapsTable {
875
836
  frozen_at: Date | null;
876
837
  updated_at: Generated<Date>;
877
838
  }
878
- /** Prepaid dev credits — card-funded balance per account (peer to x402_balances). */
839
+ /** Prepaid dev credits — card-funded balance per account. */
879
840
  interface AccountCreditsTable {
880
841
  account_id: string;
881
842
  balance_usd_micros: Generated<string | number | bigint>;
@@ -136,7 +136,6 @@ interface SubgraphsTable {
136
136
  expires_at: Date | null;
137
137
  /** (event type, contract) probe pairs persisted at deploy for weight classification. */
138
138
  sparse_probe_targets: unknown | null;
139
- database_url_enc: ColumnType<Buffer | null, Buffer | null | undefined, Buffer | null>;
140
139
  sandbox_workers: Generated<boolean>;
141
140
  created_at: Generated<Date>;
142
141
  updated_at: Generated<Date>;
@@ -232,7 +231,7 @@ interface AccountsTable {
232
231
  email: string | null;
233
232
  /** True for anonymous self-serve accounts until claimed via magic link. */
234
233
  ghost: Generated<boolean>;
235
- /** Stacks principal owning a wallet-ghost account (x402-paid deploys). */
234
+ /** Stacks principal owning a wallet-ghost account. */
236
235
  wallet_principal: string | null;
237
236
  display_name: string | null;
238
237
  bio: string | null;
@@ -811,8 +810,6 @@ interface Database {
811
810
  bns_names: BnsNamesTable;
812
811
  bns_namespaces: BnsNamespacesTable;
813
812
  service_heartbeats: ServiceHeartbeatsTable;
814
- x402_payments: X402PaymentsTable;
815
- x402_balances: X402BalancesTable;
816
813
  chain_read_cache: ChainReadCacheTable;
817
814
  pending_fork_blocks: PendingForkBlocksTable;
818
815
  observer_journal: ObserverJournalTable;
@@ -824,46 +821,10 @@ interface Database {
824
821
  stage_failures: StageFailuresTable;
825
822
  archive_fetches: ArchiveFetchesTable;
826
823
  }
827
- /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
828
- interface X402BalancesTable {
829
- principal: string;
830
- balance_usd_micros: Generated<string | number | bigint>;
831
- /** Month bucket ("YYYY-MM") the spend counter applies to. */
832
- spent_month: string | null;
833
- spent_month_usd_micros: Generated<string | number | bigint>;
834
- updated_at: Generated<Date>;
835
- }
836
824
  interface ServiceHeartbeatsTable {
837
825
  name: string;
838
826
  updated_at: Generated<Date>;
839
827
  }
840
- /** x402 pay-per-request ledger (control plane). One row per settled payment,
841
- * keyed by challenge nonce + settled txid. `state` tracks confirmed-tier
842
- * settlement and post-serve reorg reversal. */
843
- interface X402PaymentsTable {
844
- id: Generated<string>;
845
- nonce: string;
846
- txid: string;
847
- asset: string;
848
- amount: string;
849
- payer: string;
850
- surface: string;
851
- state: Generated<"pending" | "confirmed" | "reverted">;
852
- created_at: Generated<Date>;
853
- updated_at: Generated<Date>;
854
- /** "payment" = per-call settle; "deposit" = prepaid balance top-up. */
855
- kind: Generated<string>;
856
- /** Linked claimed account once the paying wallet is attached (continuity). */
857
- account_id: string | null;
858
- /** USD-micros to credit on confirmation, for deposit rows the reconciler
859
- * settles asynchronously. NULL for per-call settles (credit nothing). */
860
- credit_usd_micros: string | null;
861
- /** Idempotency key: stamped exactly once when this row's credit is applied.
862
- * NULL means never credited (or not a credit-bearing row). Pre-migration
863
- * non-pending deposit rows are backfilled to a non-null sentinel so the
864
- * reconciler's heal path can never double-credit them. */
865
- credited_at: Generated<Date> | null;
866
- }
867
828
  interface AccountSpendCapsTable {
868
829
  account_id: string;
869
830
  monthly_cap_cents: number | null;
@@ -877,7 +838,7 @@ interface AccountSpendCapsTable {
877
838
  type AccountSpendCap = Selectable<AccountSpendCapsTable>;
878
839
  type InsertAccountSpendCap = Insertable<AccountSpendCapsTable>;
879
840
  type UpdateAccountSpendCap = Updateable<AccountSpendCapsTable>;
880
- /** Prepaid dev credits — card-funded balance per account (peer to x402_balances). */
841
+ /** Prepaid dev credits — card-funded balance per account. */
881
842
  interface AccountCreditsTable {
882
843
  account_id: string;
883
844
  balance_usd_micros: Generated<string | number | bigint>;
@@ -1060,4 +1021,4 @@ interface TriggerEvaluatorStateTable {
1060
1021
  updated_at: Generated<Date>;
1061
1022
  }
1062
1023
  type TriggerEvaluatorState = Selectable<TriggerEvaluatorStateTable>;
1063
- export { X402PaymentsTable, X402BalancesTable, WebhooksTable, WebhookStatus, WebhookRuntime, WebhookOutboxTable, WebhookOutbox, WebhookKind, WebhookFormat, WebhookDelivery, WebhookDeliveriesTable, Webhook, UpdateWebhookOutbox, UpdateWebhook, UpdateTransaction, UpdateSubgraphOperation, UpdateSubgraph, UpdateIndexProgress, UpdateHostedMeterDay, UpdateEvent, UpdateContract, UpdateClaimToken, UpdateBlock, UpdateArchiveFetch, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, SyncScopesTable, SubgraphsTable, SubgraphViolationsTable, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, StageRunsTable, StageRegistryTable, StageKind, StageFailuresTable, StageBlockReceiptsTable, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, RunStatus, RetryState, RepairMode, ProcessedStripeEventsTable, Pox5EventsTable, Pox5EventTopic, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PlayProvisionsTable, PlayProvision, PendingForkBlocksTable, OutboxStatus, ObserverJournalTable, ObserverJournalStatus, NativeClock, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, InstancesTable, InsertWebhookOutbox, InsertWebhookDelivery, InsertWebhook, InsertTransaction, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertPlayProvision, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertHostedMeterDay, InsertEvent, InsertContract, InsertClaimToken, InsertBlock, InsertArchiveFetch, InsertApiKey, InsertAccountSpendCap, InsertAccountCredits, InsertAccount, IndexProgressTable, IndexProgress, HostedMeterDaysTable, HostedMeterDay, FailureUnit, FailureClass, EventsTable, EventsArchiveTable, Event, DecoderCheckpointsTable, DecodedEventsTable, DeadLetterEventsTable, Database, CoverageSegmentsTable, ContractsTable, Contract, ClaimTokensTable, ClaimToken, ChainReorgsTable, ChainReadCacheTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ArchiveFetchesTable, ArchiveFetch, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountCreditsTable, AccountCredits, Account };
1024
+ export { WebhooksTable, WebhookStatus, WebhookRuntime, WebhookOutboxTable, WebhookOutbox, WebhookKind, WebhookFormat, WebhookDelivery, WebhookDeliveriesTable, Webhook, UpdateWebhookOutbox, UpdateWebhook, UpdateTransaction, UpdateSubgraphOperation, UpdateSubgraph, UpdateIndexProgress, UpdateHostedMeterDay, UpdateEvent, UpdateContract, UpdateClaimToken, UpdateBlock, UpdateArchiveFetch, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, SyncScopesTable, SubgraphsTable, SubgraphViolationsTable, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, StageRunsTable, StageRegistryTable, StageKind, StageFailuresTable, StageBlockReceiptsTable, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, RunStatus, RetryState, RepairMode, ProcessedStripeEventsTable, Pox5EventsTable, Pox5EventTopic, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PlayProvisionsTable, PlayProvision, PendingForkBlocksTable, OutboxStatus, ObserverJournalTable, ObserverJournalStatus, NativeClock, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, InstancesTable, InsertWebhookOutbox, InsertWebhookDelivery, InsertWebhook, InsertTransaction, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertPlayProvision, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertHostedMeterDay, InsertEvent, InsertContract, InsertClaimToken, InsertBlock, InsertArchiveFetch, InsertApiKey, InsertAccountSpendCap, InsertAccountCredits, InsertAccount, IndexProgressTable, IndexProgress, HostedMeterDaysTable, HostedMeterDay, FailureUnit, FailureClass, EventsTable, EventsArchiveTable, Event, DecoderCheckpointsTable, DecodedEventsTable, DeadLetterEventsTable, Database, CoverageSegmentsTable, ContractsTable, Contract, ClaimTokensTable, ClaimToken, ChainReorgsTable, ChainReadCacheTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ArchiveFetchesTable, ArchiveFetch, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountCreditsTable, AccountCredits, Account };