@secondlayer/shared 6.28.1 → 6.29.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 (42) hide show
  1. package/dist/src/db/index.d.ts +40 -2
  2. package/dist/src/db/index.js +3 -1
  3. package/dist/src/db/index.js.map +3 -3
  4. package/dist/src/db/queries/chain-reorgs.d.ts +35 -1
  5. package/dist/src/db/queries/chain-reorgs.js +3 -1
  6. package/dist/src/db/queries/chain-reorgs.js.map +3 -3
  7. package/dist/src/db/queries/contracts.d.ts +35 -1
  8. package/dist/src/db/queries/integrity.d.ts +35 -1
  9. package/dist/src/db/queries/subgraph-gaps.d.ts +35 -1
  10. package/dist/src/db/queries/subgraph-operations.d.ts +35 -1
  11. package/dist/src/db/queries/subgraphs.d.ts +43 -2
  12. package/dist/src/db/queries/subgraphs.js +11 -1
  13. package/dist/src/db/queries/subgraphs.js.map +4 -4
  14. package/dist/src/db/queries/subscriptions.d.ts +35 -1
  15. package/dist/src/db/schema.d.ts +38 -2
  16. package/dist/src/errors.d.ts +11 -2
  17. package/dist/src/errors.js +13 -2
  18. package/dist/src/errors.js.map +3 -3
  19. package/dist/src/index.d.ts +62 -3
  20. package/dist/src/index.js +99 -38
  21. package/dist/src/index.js.map +6 -6
  22. package/dist/src/node/hiro-client.d.ts +15 -1
  23. package/dist/src/node/hiro-client.js +10 -1
  24. package/dist/src/node/hiro-client.js.map +3 -3
  25. package/dist/src/node/local-client.d.ts +35 -1
  26. package/dist/src/schemas/index.d.ts +10 -0
  27. package/dist/src/schemas/index.js +3 -2
  28. package/dist/src/schemas/index.js.map +3 -3
  29. package/dist/src/schemas/subgraphs.d.ts +10 -0
  30. package/dist/src/schemas/subgraphs.js +3 -2
  31. package/dist/src/schemas/subgraphs.js.map +3 -3
  32. package/dist/src/subgraphs/spec.d.ts +3 -0
  33. package/dist/src/subgraphs/spec.js +83 -36
  34. package/dist/src/subgraphs/spec.js.map +3 -3
  35. package/dist/src/x402.d.ts +38 -0
  36. package/dist/src/x402.js +74 -0
  37. package/dist/src/x402.js.map +10 -0
  38. package/migrations/0090_events_streams_filter_idx.ts +8 -0
  39. package/migrations/0091_x402_payments.ts +41 -0
  40. package/migrations/0092_subgraph_visibility.ts +33 -0
  41. package/migrations/0093_ghost_accounts.ts +47 -0
  42. package/package.json +6 -2
@@ -21,6 +21,14 @@ interface HiroBlockTxsResponse {
21
21
  total: number;
22
22
  results: HiroTxResponse[];
23
23
  }
24
+ /** Minimal shape returned by `HiroClient.getTransaction` (extended `/v1/tx`). */
25
+ interface HiroTransaction {
26
+ tx_id: string;
27
+ tx_status: string;
28
+ block_height: number | null;
29
+ canonical?: boolean;
30
+ is_unanchored?: boolean;
31
+ }
24
32
  interface HiroTxResponse {
25
33
  tx_id: string;
26
34
  tx_type: string;
@@ -173,6 +181,12 @@ declare class HiroClient {
173
181
  /** Fetch with retry on 429/5xx using exponential backoff */
174
182
  private fetchWithRetry;
175
183
  /**
184
+ * Fetch a single transaction's status by txid (Hiro extended `/v1/tx`).
185
+ * Used by the x402 reconciler to advance/revert ledger rows. Returns null on
186
+ * 404 (unknown/not-yet-indexed tx).
187
+ */
188
+ getTransaction(txId: string): Promise<HiroTransaction | null>;
189
+ /**
176
190
  * Fetch a complete block by height, including all transactions and events,
177
191
  * transformed into the NewBlockPayload format our indexer expects.
178
192
  *
@@ -196,4 +210,4 @@ declare class HiroClient {
196
210
  isHealthy(): Promise<boolean>;
197
211
  getApiUrl(): string;
198
212
  }
199
- export { NewBlockPayload, HiroTxResponse, HiroEventsResponse, HiroEvent, HiroClient, HiroBlockTxsResponse, HiroBlockResponse, GetBlockOptions };
213
+ export { NewBlockPayload, HiroTxResponse, HiroTransaction, HiroEventsResponse, HiroEvent, HiroClient, HiroBlockTxsResponse, HiroBlockResponse, GetBlockOptions };
@@ -174,6 +174,15 @@ class HiroClient {
174
174
  signal: AbortSignal.timeout(timeoutMs)
175
175
  });
176
176
  }
177
+ async getTransaction(txId) {
178
+ const res = await this.fetchWithRetry(`${this.apiUrl}/extended/v1/tx/${txId}`);
179
+ if (res.status === 404)
180
+ return null;
181
+ if (!res.ok) {
182
+ throw new Error(`Hiro getTransaction ${txId} failed: ${res.status}`);
183
+ }
184
+ return await res.json();
185
+ }
177
186
  async getBlockForIndexer(height, options) {
178
187
  let block = await this.fetchBlock(height);
179
188
  const fallbackUrl = this.fallbackUrl;
@@ -513,5 +522,5 @@ export {
513
522
  HiroClient
514
523
  };
515
524
 
516
- //# debugId=A7EB98626EEF033664756E2164756E21
525
+ //# debugId=6E7B17F342C8088D64756E2164756E21
517
526
  //# sourceMappingURL=hiro-client.js.map
@@ -4,9 +4,9 @@
4
4
  "sourcesContent": [
5
5
  "import { z } from \"zod/v4\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(): boolean {\n\treturn process.env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n// Export for testing\nexport { envSchema };\n",
6
6
  "import { getEnv } from \"./env.ts\";\n\ntype LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n};\n\nclass Logger {\n\tprivate _level?: LogLevel;\n\tprivate _isProduction?: boolean;\n\tprivate _initialized = false;\n\n\tprivate init() {\n\t\tif (this._initialized) return;\n\t\tthis._initialized = true;\n\t\ttry {\n\t\t\tconst env = getEnv();\n\t\t\tthis._level = env.LOG_LEVEL;\n\t\t\tthis._isProduction = env.NODE_ENV === \"production\";\n\t\t} catch {\n\t\t\t// Fallback when env is unavailable (e.g. tests without DATABASE_URL)\n\t\t\tthis._level = \"info\";\n\t\t\tthis._isProduction = false;\n\t\t}\n\t}\n\n\tprivate get level(): LogLevel {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._level!;\n\t}\n\n\tprivate get isProduction(): boolean {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._isProduction!;\n\t}\n\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn LOG_LEVELS[level] >= LOG_LEVELS[this.level];\n\t}\n\n\tprivate formatMessage(\n\t\tlevel: LogLevel,\n\t\tmessage: string,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tmeta?: Record<string, any>,\n\t) {\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tif (this.isProduction) {\n\t\t\t// JSON output for production\n\t\t\treturn JSON.stringify({\n\t\t\t\ttimestamp,\n\t\t\t\tlevel,\n\t\t\t\tmessage,\n\t\t\t\t...meta,\n\t\t\t});\n\t\t}\n\n\t\t// Human-readable output for development\n\t\tconst metaStr = meta ? ` ${JSON.stringify(meta)}` : \"\";\n\t\treturn `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tdebug(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"debug\")) {\n\t\t\tconsole.debug(this.formatMessage(\"debug\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tinfo(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"info\")) {\n\t\t\tconsole.info(this.formatMessage(\"info\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\twarn(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"warn\")) {\n\t\t\tconsole.warn(this.formatMessage(\"warn\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\terror(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"error\")) {\n\t\t\tconsole.error(this.formatMessage(\"error\", message, meta));\n\t\t}\n\t}\n}\n\n// Export singleton instance\nexport const logger: Logger = new Logger();\n",
7
- "/**\n * Hiro public API client for backfilling historical block data.\n *\n * The stacks-node RPC `/v2/blocks/{height}` only returns block headers + tx IDs,\n * not full transaction data or events. The Hiro API serves complete block data\n * that we can transform into the NewBlockPayload format our indexer expects.\n */\n\nimport { logger } from \"../logger.ts\";\n\nconst DEFAULT_HIRO_API_URL = \"https://api.mainnet.hiro.so\";\n\n/** v2 /extended/v2/blocks/{height} response */\nexport interface HiroBlockResponse {\n\tcanonical: boolean;\n\theight: number;\n\thash: string;\n\tblock_time: number;\n\tblock_time_iso: string;\n\tindex_block_hash: string;\n\tparent_block_hash: string;\n\tparent_index_block_hash: string;\n\tburn_block_hash: string;\n\tburn_block_height: number;\n\tburn_block_time: number;\n\tminer_txid: string;\n\ttx_count: number;\n}\n\n/** v2 /extended/v2/blocks/{height}/transactions response */\nexport interface HiroBlockTxsResponse {\n\tlimit: number;\n\toffset: number;\n\ttotal: number;\n\tresults: HiroTxResponse[];\n}\n\nexport interface HiroTxResponse {\n\ttx_id: string;\n\ttx_type: string;\n\ttx_status: string;\n\tsender_address: string;\n\tfee_rate: string;\n\tnonce: number;\n\tblock_hash: string;\n\tblock_height: number;\n\tburn_block_height: number;\n\ttx_index: number;\n\tevent_count: number;\n\ttoken_transfer?: {\n\t\trecipient_address: string;\n\t\tamount: string;\n\t\tmemo: string;\n\t};\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t};\n\tsmart_contract?: {\n\t\tcontract_id: string;\n\t\tsource_code: string;\n\t};\n}\n\nexport interface HiroEvent {\n\tevent_index: number;\n\tevent_type: string; // \"stx_asset\" | \"fungible_token_asset\" | \"non_fungible_token_asset\" | \"smart_contract_log\"\n\ttx_id: string;\n\tasset?: {\n\t\tasset_event_type: string; // \"transfer\" | \"mint\" | \"burn\"\n\t\tsender?: string;\n\t\trecipient?: string;\n\t\tamount?: string;\n\t\tmemo?: string;\n\t\tasset_id?: string;\n\t\tvalue?: unknown;\n\t};\n\tcontract_log?: {\n\t\tcontract_id: string;\n\t\ttopic: string;\n\t\tvalue: unknown;\n\t};\n}\n\nexport interface HiroEventsResponse {\n\tlimit: number;\n\toffset: number;\n\tevents: HiroEvent[];\n}\n\n/** Shape our indexer expects at POST /new_block */\nexport interface NewBlockPayload {\n\tblock_hash: string;\n\tblock_height: number;\n\tindex_block_hash: string;\n\tparent_block_hash: string;\n\tparent_index_block_hash: string;\n\tburn_block_hash: string;\n\tburn_block_height: number;\n\tburn_block_timestamp: number;\n\tminer_txid: string;\n\ttimestamp: number;\n\ttransactions: TransactionPayload[];\n\tevents: TransactionEventPayload[];\n}\n\ninterface TransactionPayload {\n\ttxid: string;\n\traw_tx: string;\n\tstatus: string;\n\ttx_index: number;\n\ttx_type?: string;\n\tsender_address?: string;\n}\n\ninterface TransactionEventPayload {\n\ttxid: string;\n\tevent_index: number;\n\tcommitted: boolean;\n\ttype: string;\n\tstx_transfer_event?: {\n\t\tsender: string;\n\t\trecipient: string;\n\t\tamount: string;\n\t\tmemo?: string;\n\t};\n\tstx_mint_event?: { recipient: string; amount: string };\n\tstx_burn_event?: { sender: string; amount: string };\n\tstx_lock_event?: {\n\t\tlocked_amount: string;\n\t\tunlock_height: string;\n\t\tlocked_address: string;\n\t};\n\tft_transfer_event?: {\n\t\tasset_identifier: string;\n\t\tsender: string;\n\t\trecipient: string;\n\t\tamount: string;\n\t};\n\tft_mint_event?: {\n\t\tasset_identifier: string;\n\t\trecipient: string;\n\t\tamount: string;\n\t};\n\tft_burn_event?: { asset_identifier: string; sender: string; amount: string };\n\tnft_transfer_event?: {\n\t\tasset_identifier: string;\n\t\tsender: string;\n\t\trecipient: string;\n\t\tvalue: unknown;\n\t};\n\tnft_mint_event?: {\n\t\tasset_identifier: string;\n\t\trecipient: string;\n\t\tvalue: unknown;\n\t};\n\tnft_burn_event?: { asset_identifier: string; sender: string; value: unknown };\n\tsmart_contract_event?: {\n\t\tcontract_identifier: string;\n\t\ttopic: string;\n\t\tvalue: unknown;\n\t};\n}\n\nexport interface GetBlockOptions {\n\t/** Fetch actual raw_tx hex for each transaction (instead of \"0x00\" placeholder) */\n\tincludeRawTx?: boolean;\n\t/** Max concurrent raw_tx fetches per block (default: 10) */\n\trawTxConcurrency?: number;\n}\n\nexport class HiroClient {\n\tprivate apiUrl: string;\n\tprivate fallbackUrl: string | undefined;\n\tprivate apiKey: string | undefined;\n\tprivate maxRetries: number;\n\n\tconstructor(apiUrl?: string, maxRetries = 5) {\n\t\tthis.apiUrl = apiUrl || process.env.HIRO_API_URL || DEFAULT_HIRO_API_URL;\n\t\tthis.fallbackUrl = process.env.HIRO_FALLBACK_URL;\n\t\tthis.apiKey = process.env.HIRO_API_KEY;\n\t\tthis.maxRetries = maxRetries;\n\t}\n\n\tprivate get headers(): Record<string, string> {\n\t\treturn this.apiKey ? { \"x-hiro-api-key\": this.apiKey } : {};\n\t}\n\n\t/** Fetch with retry on 429/5xx using exponential backoff */\n\tprivate async fetchWithRetry(\n\t\turl: string,\n\t\ttimeoutMs = 120_000,\n\t): Promise<Response> {\n\t\tfor (let attempt = 0; attempt < this.maxRetries; attempt++) {\n\t\t\tconst res = await fetch(url, {\n\t\t\t\theaders: this.headers,\n\t\t\t\tsignal: AbortSignal.timeout(timeoutMs),\n\t\t\t});\n\n\t\t\tif (res.ok || res.status === 404) return res;\n\n\t\t\tif (res.status === 429 || res.status >= 500) {\n\t\t\t\tconst delay = Math.min(1000 * 2 ** attempt, 10_000);\n\t\t\t\tlogger.info(\"Rate limited, retrying\", {\n\t\t\t\t\turl: url.split(\"/\").slice(-2).join(\"/\"),\n\t\t\t\t\tattempt,\n\t\t\t\t\tdelay,\n\t\t\t\t});\n\t\t\t\tawait new Promise((r) => setTimeout(r, delay));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// 4xx (not 404/429) — don't retry\n\t\t\treturn res;\n\t\t}\n\n\t\t// Final attempt\n\t\treturn fetch(url, {\n\t\t\theaders: this.headers,\n\t\t\tsignal: AbortSignal.timeout(timeoutMs),\n\t\t});\n\t}\n\n\t/**\n\t * Fetch a complete block by height, including all transactions and events,\n\t * transformed into the NewBlockPayload format our indexer expects.\n\t *\n\t * Uses 3-step approach:\n\t * 1. GET /extended/v2/blocks/{height} — block metadata\n\t * 2. GET /extended/v2/blocks/{height}/transactions — all txs (paginated)\n\t * 3. GET /extended/v1/tx/events?tx_id={txId} — events per tx (only for txs with events)\n\t */\n\tasync getBlockForIndexer(\n\t\theight: number,\n\t\toptions?: GetBlockOptions,\n\t): Promise<NewBlockPayload | null> {\n\t\t// 1. Fetch block metadata (try primary, fallback on 404)\n\t\tlet block = await this.fetchBlock(height);\n\t\tconst fallbackUrl = this.fallbackUrl;\n\t\tlet usingFallback = false;\n\t\tif (!block && fallbackUrl) {\n\t\t\tblock = await this.fetchBlock(height, fallbackUrl);\n\t\t\tif (block) usingFallback = true;\n\t\t}\n\t\tif (!block) return null;\n\n\t\t// 2. Fetch all transactions via v2 block/transactions endpoint\n\t\tconst baseUrl = usingFallback && fallbackUrl ? fallbackUrl : this.apiUrl;\n\t\tconst hiroTxs = await this.fetchBlockTransactions(height, baseUrl);\n\n\t\tconst txPayloads: TransactionPayload[] = [];\n\t\tconst eventPayloads: TransactionEventPayload[] = [];\n\n\t\tfor (const hiroTx of hiroTxs) {\n\t\t\ttxPayloads.push({\n\t\t\t\ttxid: hiroTx.tx_id,\n\t\t\t\traw_tx: \"0x00\",\n\t\t\t\tstatus: mapTxStatus(hiroTx.tx_status),\n\t\t\t\ttx_index: hiroTx.tx_index ?? 0,\n\t\t\t\ttx_type: mapTxType(hiroTx.tx_type),\n\t\t\t\tsender_address: hiroTx.sender_address,\n\t\t\t});\n\n\t\t\t// 3. Fetch events only for txs that have them\n\t\t\tif (hiroTx.event_count > 0) {\n\t\t\t\tif (hiroTx.event_count > 1000) {\n\t\t\t\t\tlogger.info(\"Fetching large event set\", {\n\t\t\t\t\t\ttxId: hiroTx.tx_id,\n\t\t\t\t\t\teventCount: hiroTx.event_count,\n\t\t\t\t\t\theight,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst events = await this.fetchAllEvents(hiroTx.tx_id, baseUrl);\n\t\t\t\t\teventPayloads.push(...events);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tlogger.warn(\"Failed to fetch events for backfill\", {\n\t\t\t\t\t\ttxId: hiroTx.tx_id,\n\t\t\t\t\t\terror: String(err),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// 4. Optionally fetch raw_tx for all transactions\n\t\tif (options?.includeRawTx && txPayloads.length > 0) {\n\t\t\tconst txIds = txPayloads.map((t) => t.txid);\n\t\t\tconst rawTxMap = await this.fetchRawTxBatch(\n\t\t\t\ttxIds,\n\t\t\t\toptions.rawTxConcurrency,\n\t\t\t);\n\t\t\tfor (const txPayload of txPayloads) {\n\t\t\t\tconst raw = rawTxMap.get(txPayload.txid);\n\t\t\t\tif (raw) txPayload.raw_tx = raw;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tblock_hash: block.hash,\n\t\t\tblock_height: block.height,\n\t\t\tindex_block_hash: block.index_block_hash,\n\t\t\tparent_block_hash: block.parent_block_hash,\n\t\t\tparent_index_block_hash: block.parent_index_block_hash,\n\t\t\tburn_block_hash: block.burn_block_hash,\n\t\t\tburn_block_height: block.burn_block_height,\n\t\t\tburn_block_timestamp: block.burn_block_time,\n\t\t\tminer_txid: block.miner_txid,\n\t\t\ttimestamp: block.block_time,\n\t\t\ttransactions: txPayloads,\n\t\t\tevents: eventPayloads,\n\t\t};\n\t}\n\n\t/** v2 block metadata */\n\tprivate async fetchBlock(\n\t\theight: number,\n\t\tbaseUrl?: string,\n\t): Promise<HiroBlockResponse | null> {\n\t\tconst url = baseUrl || this.apiUrl;\n\t\tconst res = await this.fetchWithRetry(\n\t\t\t`${url}/extended/v2/blocks/${height}`,\n\t\t);\n\t\tif (res.status === 404) return null;\n\t\tif (!res.ok)\n\t\t\tthrow new Error(`Hiro API block/${height} returned ${res.status}`);\n\t\treturn res.json() as Promise<HiroBlockResponse>;\n\t}\n\n\t/** v2 block transactions (paginated) */\n\tprivate async fetchBlockTransactions(\n\t\theight: number,\n\t\tbaseUrl?: string,\n\t): Promise<HiroTxResponse[]> {\n\t\tconst url = baseUrl || this.apiUrl;\n\t\tconst txs: HiroTxResponse[] = [];\n\t\tlet offset = 0;\n\t\tconst limit = 50;\n\n\t\twhile (true) {\n\t\t\tconst res = await this.fetchWithRetry(\n\t\t\t\t`${url}/extended/v2/blocks/${height}/transactions?limit=${limit}&offset=${offset}`,\n\t\t\t);\n\t\t\tif (!res.ok)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hiro API block/${height}/transactions returned ${res.status}`,\n\t\t\t\t);\n\n\t\t\tconst data = (await res.json()) as HiroBlockTxsResponse;\n\t\t\ttxs.push(...data.results);\n\n\t\t\tif (txs.length >= data.total || data.results.length < limit) break;\n\t\t\toffset += limit;\n\t\t}\n\n\t\treturn txs;\n\t}\n\n\tprivate async fetchAllEvents(\n\t\ttxId: string,\n\t\tbaseUrl?: string,\n\t\t_maxEvents?: number,\n\t): Promise<TransactionEventPayload[]> {\n\t\tconst url = baseUrl || this.apiUrl;\n\t\tconst events: TransactionEventPayload[] = [];\n\t\tlet offset = 0;\n\t\tconst limit = 100;\n\n\t\twhile (true) {\n\t\t\tconst res = await this.fetchWithRetry(\n\t\t\t\t`${url}/extended/v1/tx/events?tx_id=${txId}&limit=${limit}&offset=${offset}`,\n\t\t\t);\n\t\t\tif (!res.ok) {\n\t\t\t\tlogger.warn(\"Failed to fetch events from Hiro\", {\n\t\t\t\t\ttxId,\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst data = (await res.json()) as HiroEventsResponse;\n\t\t\tfor (const hEvent of data.events) {\n\t\t\t\tconst converted = convertHiroEvent(hEvent);\n\t\t\t\tif (converted) events.push(converted);\n\t\t\t}\n\n\t\t\tif (data.events.length < limit) break;\n\t\t\toffset += limit;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t/** Fetch raw_tx hex for a single transaction */\n\tasync fetchRawTx(txId: string): Promise<string | null> {\n\t\ttry {\n\t\t\tconst res = await this.fetchWithRetry(\n\t\t\t\t`${this.apiUrl}/extended/v1/tx/${txId}/raw`,\n\t\t\t\t10_000,\n\t\t\t);\n\t\t\tif (!res.ok) return null;\n\t\t\tconst data = (await res.json()) as { raw_tx: string };\n\t\t\treturn data.raw_tx || null;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/** Fetch raw_tx for multiple transactions with bounded concurrency */\n\tasync fetchRawTxBatch(\n\t\ttxIds: string[],\n\t\tconcurrency = 10,\n\t): Promise<Map<string, string>> {\n\t\tconst results = new Map<string, string>();\n\t\tfor (let i = 0; i < txIds.length; i += concurrency) {\n\t\t\tconst chunk = txIds.slice(i, i + concurrency);\n\t\t\tconst settled = await Promise.allSettled(\n\t\t\t\tchunk.map(async (txId) => {\n\t\t\t\t\tconst raw = await this.fetchRawTx(txId);\n\t\t\t\t\treturn { txId, raw };\n\t\t\t\t}),\n\t\t\t);\n\t\t\tfor (const result of settled) {\n\t\t\t\tif (result.status === \"fulfilled\" && result.value.raw) {\n\t\t\t\t\tresults.set(result.value.txId, result.value.raw);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\t/** Fetch current chain tip height from Hiro API status endpoint */\n\tasync fetchChainTip(): Promise<number> {\n\t\tconst res = await this.fetchWithRetry(`${this.apiUrl}/extended/v1/status`);\n\t\tif (!res.ok) throw new Error(`Hiro API /status returned ${res.status}`);\n\t\tconst data = (await res.json()) as {\n\t\t\tchain_tip?: { block_height: number };\n\t\t\tstacks_tip_height?: number;\n\t\t};\n\t\treturn data.chain_tip?.block_height ?? data.stacks_tip_height ?? 0;\n\t}\n\n\tasync isHealthy(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst res = await fetch(`${this.apiUrl}/extended/v1/status`, {\n\t\t\t\theaders: this.headers,\n\t\t\t\tsignal: AbortSignal.timeout(10_000),\n\t\t\t});\n\t\t\t// 429 = rate limited but reachable\n\t\t\treturn res.ok || res.status === 429;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tgetApiUrl(): string {\n\t\treturn this.apiUrl;\n\t}\n}\n\n/** Map Hiro tx_status to our indexer's expected format */\nfunction mapTxStatus(status: string): string {\n\tswitch (status) {\n\t\tcase \"success\":\n\t\t\treturn \"success\";\n\t\tcase \"abort_by_response\":\n\t\tcase \"abort_by_post_condition\":\n\t\t\treturn status;\n\t\tdefault:\n\t\t\treturn \"success\";\n\t}\n}\n\n/** Map Hiro tx_type to node event tx_type */\nfunction mapTxType(type: string): string {\n\tswitch (type) {\n\t\tcase \"token_transfer\":\n\t\t\treturn \"token_transfer\";\n\t\tcase \"contract_call\":\n\t\t\treturn \"contract_call\";\n\t\tcase \"smart_contract\":\n\t\t\treturn \"smart_contract\";\n\t\tcase \"coinbase\":\n\t\t\treturn \"coinbase\";\n\t\tcase \"tenure_change\":\n\t\t\treturn \"tenure_change\";\n\t\tcase \"poison_microblock\":\n\t\t\treturn \"poison_microblock\";\n\t\tdefault:\n\t\t\treturn type;\n\t}\n}\n\n/**\n * Convert a Hiro API event to our indexer's TransactionEvent format.\n *\n * Hiro uses:\n * event_type: \"stx_asset\" | \"fungible_token_asset\" | \"non_fungible_token_asset\" | \"smart_contract_log\"\n * asset.asset_event_type: \"transfer\" | \"mint\" | \"burn\" | \"lock\"\n *\n * Our indexer expects:\n * type: \"stx_transfer_event\" | \"stx_mint_event\" | \"ft_transfer_event\" | \"smart_contract_event\" | ...\n */\nfunction convertHiroEvent(hEvent: HiroEvent): TransactionEventPayload | null {\n\tconst base = {\n\t\ttxid: hEvent.tx_id,\n\t\tevent_index: hEvent.event_index,\n\t\tcommitted: true,\n\t};\n\n\tif (hEvent.event_type === \"stx_asset\" && hEvent.asset) {\n\t\tconst a = hEvent.asset;\n\t\tswitch (a.asset_event_type) {\n\t\t\tcase \"transfer\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_transfer_event\",\n\t\t\t\t\tstx_transfer_event: {\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t\tmemo: a.memo,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"mint\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_mint_event\",\n\t\t\t\t\tstx_mint_event: {\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"burn\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_burn_event\",\n\t\t\t\t\tstx_burn_event: { sender: a.sender ?? \"\", amount: a.amount ?? \"0\" },\n\t\t\t\t};\n\t\t\tcase \"lock\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_lock_event\",\n\t\t\t\t\tstx_lock_event: {\n\t\t\t\t\t\tlocked_amount: a.amount ?? \"0\",\n\t\t\t\t\t\tunlock_height: \"0\",\n\t\t\t\t\t\tlocked_address: a.sender ?? \"\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t}\n\t}\n\n\tif (hEvent.event_type === \"fungible_token_asset\" && hEvent.asset) {\n\t\tconst a = hEvent.asset;\n\t\tconst assetId = a.asset_id || \"\";\n\t\tswitch (a.asset_event_type) {\n\t\t\tcase \"transfer\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"ft_transfer_event\",\n\t\t\t\t\tft_transfer_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"mint\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"ft_mint_event\",\n\t\t\t\t\tft_mint_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"burn\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"ft_burn_event\",\n\t\t\t\t\tft_burn_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t}\n\t}\n\n\tif (hEvent.event_type === \"non_fungible_token_asset\" && hEvent.asset) {\n\t\tconst a = hEvent.asset;\n\t\tconst assetId = a.asset_id || \"\";\n\t\tswitch (a.asset_event_type) {\n\t\t\tcase \"transfer\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"nft_transfer_event\",\n\t\t\t\t\tnft_transfer_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tvalue: a.value,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"mint\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"nft_mint_event\",\n\t\t\t\t\tnft_mint_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tvalue: a.value,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"burn\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"nft_burn_event\",\n\t\t\t\t\tnft_burn_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\tvalue: a.value,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t}\n\t}\n\n\tif (hEvent.event_type === \"smart_contract_log\" && hEvent.contract_log) {\n\t\treturn {\n\t\t\t...base,\n\t\t\ttype: \"smart_contract_event\",\n\t\t\tsmart_contract_event: {\n\t\t\t\tcontract_identifier: hEvent.contract_log.contract_id,\n\t\t\t\ttopic: hEvent.contract_log.topic,\n\t\t\t\tvalue: hEvent.contract_log.value,\n\t\t\t},\n\t\t};\n\t}\n\n\tlogger.debug(\"Unknown Hiro event type, skipping\", {\n\t\teventType: hEvent.event_type,\n\t\ttxId: hEvent.tx_id,\n\t});\n\treturn null;\n}\n"
7
+ "/**\n * Hiro public API client for backfilling historical block data.\n *\n * The stacks-node RPC `/v2/blocks/{height}` only returns block headers + tx IDs,\n * not full transaction data or events. The Hiro API serves complete block data\n * that we can transform into the NewBlockPayload format our indexer expects.\n */\n\nimport { logger } from \"../logger.ts\";\n\nconst DEFAULT_HIRO_API_URL = \"https://api.mainnet.hiro.so\";\n\n/** v2 /extended/v2/blocks/{height} response */\nexport interface HiroBlockResponse {\n\tcanonical: boolean;\n\theight: number;\n\thash: string;\n\tblock_time: number;\n\tblock_time_iso: string;\n\tindex_block_hash: string;\n\tparent_block_hash: string;\n\tparent_index_block_hash: string;\n\tburn_block_hash: string;\n\tburn_block_height: number;\n\tburn_block_time: number;\n\tminer_txid: string;\n\ttx_count: number;\n}\n\n/** v2 /extended/v2/blocks/{height}/transactions response */\nexport interface HiroBlockTxsResponse {\n\tlimit: number;\n\toffset: number;\n\ttotal: number;\n\tresults: HiroTxResponse[];\n}\n\n/** Minimal shape returned by `HiroClient.getTransaction` (extended `/v1/tx`). */\nexport interface HiroTransaction {\n\ttx_id: string;\n\ttx_status: string;\n\tblock_height: number | null;\n\tcanonical?: boolean;\n\tis_unanchored?: boolean;\n}\n\nexport interface HiroTxResponse {\n\ttx_id: string;\n\ttx_type: string;\n\ttx_status: string;\n\tsender_address: string;\n\tfee_rate: string;\n\tnonce: number;\n\tblock_hash: string;\n\tblock_height: number;\n\tburn_block_height: number;\n\ttx_index: number;\n\tevent_count: number;\n\ttoken_transfer?: {\n\t\trecipient_address: string;\n\t\tamount: string;\n\t\tmemo: string;\n\t};\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t};\n\tsmart_contract?: {\n\t\tcontract_id: string;\n\t\tsource_code: string;\n\t};\n}\n\nexport interface HiroEvent {\n\tevent_index: number;\n\tevent_type: string; // \"stx_asset\" | \"fungible_token_asset\" | \"non_fungible_token_asset\" | \"smart_contract_log\"\n\ttx_id: string;\n\tasset?: {\n\t\tasset_event_type: string; // \"transfer\" | \"mint\" | \"burn\"\n\t\tsender?: string;\n\t\trecipient?: string;\n\t\tamount?: string;\n\t\tmemo?: string;\n\t\tasset_id?: string;\n\t\tvalue?: unknown;\n\t};\n\tcontract_log?: {\n\t\tcontract_id: string;\n\t\ttopic: string;\n\t\tvalue: unknown;\n\t};\n}\n\nexport interface HiroEventsResponse {\n\tlimit: number;\n\toffset: number;\n\tevents: HiroEvent[];\n}\n\n/** Shape our indexer expects at POST /new_block */\nexport interface NewBlockPayload {\n\tblock_hash: string;\n\tblock_height: number;\n\tindex_block_hash: string;\n\tparent_block_hash: string;\n\tparent_index_block_hash: string;\n\tburn_block_hash: string;\n\tburn_block_height: number;\n\tburn_block_timestamp: number;\n\tminer_txid: string;\n\ttimestamp: number;\n\ttransactions: TransactionPayload[];\n\tevents: TransactionEventPayload[];\n}\n\ninterface TransactionPayload {\n\ttxid: string;\n\traw_tx: string;\n\tstatus: string;\n\ttx_index: number;\n\ttx_type?: string;\n\tsender_address?: string;\n}\n\ninterface TransactionEventPayload {\n\ttxid: string;\n\tevent_index: number;\n\tcommitted: boolean;\n\ttype: string;\n\tstx_transfer_event?: {\n\t\tsender: string;\n\t\trecipient: string;\n\t\tamount: string;\n\t\tmemo?: string;\n\t};\n\tstx_mint_event?: { recipient: string; amount: string };\n\tstx_burn_event?: { sender: string; amount: string };\n\tstx_lock_event?: {\n\t\tlocked_amount: string;\n\t\tunlock_height: string;\n\t\tlocked_address: string;\n\t};\n\tft_transfer_event?: {\n\t\tasset_identifier: string;\n\t\tsender: string;\n\t\trecipient: string;\n\t\tamount: string;\n\t};\n\tft_mint_event?: {\n\t\tasset_identifier: string;\n\t\trecipient: string;\n\t\tamount: string;\n\t};\n\tft_burn_event?: { asset_identifier: string; sender: string; amount: string };\n\tnft_transfer_event?: {\n\t\tasset_identifier: string;\n\t\tsender: string;\n\t\trecipient: string;\n\t\tvalue: unknown;\n\t};\n\tnft_mint_event?: {\n\t\tasset_identifier: string;\n\t\trecipient: string;\n\t\tvalue: unknown;\n\t};\n\tnft_burn_event?: { asset_identifier: string; sender: string; value: unknown };\n\tsmart_contract_event?: {\n\t\tcontract_identifier: string;\n\t\ttopic: string;\n\t\tvalue: unknown;\n\t};\n}\n\nexport interface GetBlockOptions {\n\t/** Fetch actual raw_tx hex for each transaction (instead of \"0x00\" placeholder) */\n\tincludeRawTx?: boolean;\n\t/** Max concurrent raw_tx fetches per block (default: 10) */\n\trawTxConcurrency?: number;\n}\n\nexport class HiroClient {\n\tprivate apiUrl: string;\n\tprivate fallbackUrl: string | undefined;\n\tprivate apiKey: string | undefined;\n\tprivate maxRetries: number;\n\n\tconstructor(apiUrl?: string, maxRetries = 5) {\n\t\tthis.apiUrl = apiUrl || process.env.HIRO_API_URL || DEFAULT_HIRO_API_URL;\n\t\tthis.fallbackUrl = process.env.HIRO_FALLBACK_URL;\n\t\tthis.apiKey = process.env.HIRO_API_KEY;\n\t\tthis.maxRetries = maxRetries;\n\t}\n\n\tprivate get headers(): Record<string, string> {\n\t\treturn this.apiKey ? { \"x-hiro-api-key\": this.apiKey } : {};\n\t}\n\n\t/** Fetch with retry on 429/5xx using exponential backoff */\n\tprivate async fetchWithRetry(\n\t\turl: string,\n\t\ttimeoutMs = 120_000,\n\t): Promise<Response> {\n\t\tfor (let attempt = 0; attempt < this.maxRetries; attempt++) {\n\t\t\tconst res = await fetch(url, {\n\t\t\t\theaders: this.headers,\n\t\t\t\tsignal: AbortSignal.timeout(timeoutMs),\n\t\t\t});\n\n\t\t\tif (res.ok || res.status === 404) return res;\n\n\t\t\tif (res.status === 429 || res.status >= 500) {\n\t\t\t\tconst delay = Math.min(1000 * 2 ** attempt, 10_000);\n\t\t\t\tlogger.info(\"Rate limited, retrying\", {\n\t\t\t\t\turl: url.split(\"/\").slice(-2).join(\"/\"),\n\t\t\t\t\tattempt,\n\t\t\t\t\tdelay,\n\t\t\t\t});\n\t\t\t\tawait new Promise((r) => setTimeout(r, delay));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// 4xx (not 404/429) — don't retry\n\t\t\treturn res;\n\t\t}\n\n\t\t// Final attempt\n\t\treturn fetch(url, {\n\t\t\theaders: this.headers,\n\t\t\tsignal: AbortSignal.timeout(timeoutMs),\n\t\t});\n\t}\n\n\t/**\n\t * Fetch a single transaction's status by txid (Hiro extended `/v1/tx`).\n\t * Used by the x402 reconciler to advance/revert ledger rows. Returns null on\n\t * 404 (unknown/not-yet-indexed tx).\n\t */\n\tasync getTransaction(txId: string): Promise<HiroTransaction | null> {\n\t\tconst res = await this.fetchWithRetry(\n\t\t\t`${this.apiUrl}/extended/v1/tx/${txId}`,\n\t\t);\n\t\tif (res.status === 404) return null;\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`Hiro getTransaction ${txId} failed: ${res.status}`);\n\t\t}\n\t\treturn (await res.json()) as HiroTransaction;\n\t}\n\n\t/**\n\t * Fetch a complete block by height, including all transactions and events,\n\t * transformed into the NewBlockPayload format our indexer expects.\n\t *\n\t * Uses 3-step approach:\n\t * 1. GET /extended/v2/blocks/{height} — block metadata\n\t * 2. GET /extended/v2/blocks/{height}/transactions — all txs (paginated)\n\t * 3. GET /extended/v1/tx/events?tx_id={txId} — events per tx (only for txs with events)\n\t */\n\tasync getBlockForIndexer(\n\t\theight: number,\n\t\toptions?: GetBlockOptions,\n\t): Promise<NewBlockPayload | null> {\n\t\t// 1. Fetch block metadata (try primary, fallback on 404)\n\t\tlet block = await this.fetchBlock(height);\n\t\tconst fallbackUrl = this.fallbackUrl;\n\t\tlet usingFallback = false;\n\t\tif (!block && fallbackUrl) {\n\t\t\tblock = await this.fetchBlock(height, fallbackUrl);\n\t\t\tif (block) usingFallback = true;\n\t\t}\n\t\tif (!block) return null;\n\n\t\t// 2. Fetch all transactions via v2 block/transactions endpoint\n\t\tconst baseUrl = usingFallback && fallbackUrl ? fallbackUrl : this.apiUrl;\n\t\tconst hiroTxs = await this.fetchBlockTransactions(height, baseUrl);\n\n\t\tconst txPayloads: TransactionPayload[] = [];\n\t\tconst eventPayloads: TransactionEventPayload[] = [];\n\n\t\tfor (const hiroTx of hiroTxs) {\n\t\t\ttxPayloads.push({\n\t\t\t\ttxid: hiroTx.tx_id,\n\t\t\t\traw_tx: \"0x00\",\n\t\t\t\tstatus: mapTxStatus(hiroTx.tx_status),\n\t\t\t\ttx_index: hiroTx.tx_index ?? 0,\n\t\t\t\ttx_type: mapTxType(hiroTx.tx_type),\n\t\t\t\tsender_address: hiroTx.sender_address,\n\t\t\t});\n\n\t\t\t// 3. Fetch events only for txs that have them\n\t\t\tif (hiroTx.event_count > 0) {\n\t\t\t\tif (hiroTx.event_count > 1000) {\n\t\t\t\t\tlogger.info(\"Fetching large event set\", {\n\t\t\t\t\t\ttxId: hiroTx.tx_id,\n\t\t\t\t\t\teventCount: hiroTx.event_count,\n\t\t\t\t\t\theight,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst events = await this.fetchAllEvents(hiroTx.tx_id, baseUrl);\n\t\t\t\t\teventPayloads.push(...events);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tlogger.warn(\"Failed to fetch events for backfill\", {\n\t\t\t\t\t\ttxId: hiroTx.tx_id,\n\t\t\t\t\t\terror: String(err),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// 4. Optionally fetch raw_tx for all transactions\n\t\tif (options?.includeRawTx && txPayloads.length > 0) {\n\t\t\tconst txIds = txPayloads.map((t) => t.txid);\n\t\t\tconst rawTxMap = await this.fetchRawTxBatch(\n\t\t\t\ttxIds,\n\t\t\t\toptions.rawTxConcurrency,\n\t\t\t);\n\t\t\tfor (const txPayload of txPayloads) {\n\t\t\t\tconst raw = rawTxMap.get(txPayload.txid);\n\t\t\t\tif (raw) txPayload.raw_tx = raw;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tblock_hash: block.hash,\n\t\t\tblock_height: block.height,\n\t\t\tindex_block_hash: block.index_block_hash,\n\t\t\tparent_block_hash: block.parent_block_hash,\n\t\t\tparent_index_block_hash: block.parent_index_block_hash,\n\t\t\tburn_block_hash: block.burn_block_hash,\n\t\t\tburn_block_height: block.burn_block_height,\n\t\t\tburn_block_timestamp: block.burn_block_time,\n\t\t\tminer_txid: block.miner_txid,\n\t\t\ttimestamp: block.block_time,\n\t\t\ttransactions: txPayloads,\n\t\t\tevents: eventPayloads,\n\t\t};\n\t}\n\n\t/** v2 block metadata */\n\tprivate async fetchBlock(\n\t\theight: number,\n\t\tbaseUrl?: string,\n\t): Promise<HiroBlockResponse | null> {\n\t\tconst url = baseUrl || this.apiUrl;\n\t\tconst res = await this.fetchWithRetry(\n\t\t\t`${url}/extended/v2/blocks/${height}`,\n\t\t);\n\t\tif (res.status === 404) return null;\n\t\tif (!res.ok)\n\t\t\tthrow new Error(`Hiro API block/${height} returned ${res.status}`);\n\t\treturn res.json() as Promise<HiroBlockResponse>;\n\t}\n\n\t/** v2 block transactions (paginated) */\n\tprivate async fetchBlockTransactions(\n\t\theight: number,\n\t\tbaseUrl?: string,\n\t): Promise<HiroTxResponse[]> {\n\t\tconst url = baseUrl || this.apiUrl;\n\t\tconst txs: HiroTxResponse[] = [];\n\t\tlet offset = 0;\n\t\tconst limit = 50;\n\n\t\twhile (true) {\n\t\t\tconst res = await this.fetchWithRetry(\n\t\t\t\t`${url}/extended/v2/blocks/${height}/transactions?limit=${limit}&offset=${offset}`,\n\t\t\t);\n\t\t\tif (!res.ok)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hiro API block/${height}/transactions returned ${res.status}`,\n\t\t\t\t);\n\n\t\t\tconst data = (await res.json()) as HiroBlockTxsResponse;\n\t\t\ttxs.push(...data.results);\n\n\t\t\tif (txs.length >= data.total || data.results.length < limit) break;\n\t\t\toffset += limit;\n\t\t}\n\n\t\treturn txs;\n\t}\n\n\tprivate async fetchAllEvents(\n\t\ttxId: string,\n\t\tbaseUrl?: string,\n\t\t_maxEvents?: number,\n\t): Promise<TransactionEventPayload[]> {\n\t\tconst url = baseUrl || this.apiUrl;\n\t\tconst events: TransactionEventPayload[] = [];\n\t\tlet offset = 0;\n\t\tconst limit = 100;\n\n\t\twhile (true) {\n\t\t\tconst res = await this.fetchWithRetry(\n\t\t\t\t`${url}/extended/v1/tx/events?tx_id=${txId}&limit=${limit}&offset=${offset}`,\n\t\t\t);\n\t\t\tif (!res.ok) {\n\t\t\t\tlogger.warn(\"Failed to fetch events from Hiro\", {\n\t\t\t\t\ttxId,\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst data = (await res.json()) as HiroEventsResponse;\n\t\t\tfor (const hEvent of data.events) {\n\t\t\t\tconst converted = convertHiroEvent(hEvent);\n\t\t\t\tif (converted) events.push(converted);\n\t\t\t}\n\n\t\t\tif (data.events.length < limit) break;\n\t\t\toffset += limit;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t/** Fetch raw_tx hex for a single transaction */\n\tasync fetchRawTx(txId: string): Promise<string | null> {\n\t\ttry {\n\t\t\tconst res = await this.fetchWithRetry(\n\t\t\t\t`${this.apiUrl}/extended/v1/tx/${txId}/raw`,\n\t\t\t\t10_000,\n\t\t\t);\n\t\t\tif (!res.ok) return null;\n\t\t\tconst data = (await res.json()) as { raw_tx: string };\n\t\t\treturn data.raw_tx || null;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/** Fetch raw_tx for multiple transactions with bounded concurrency */\n\tasync fetchRawTxBatch(\n\t\ttxIds: string[],\n\t\tconcurrency = 10,\n\t): Promise<Map<string, string>> {\n\t\tconst results = new Map<string, string>();\n\t\tfor (let i = 0; i < txIds.length; i += concurrency) {\n\t\t\tconst chunk = txIds.slice(i, i + concurrency);\n\t\t\tconst settled = await Promise.allSettled(\n\t\t\t\tchunk.map(async (txId) => {\n\t\t\t\t\tconst raw = await this.fetchRawTx(txId);\n\t\t\t\t\treturn { txId, raw };\n\t\t\t\t}),\n\t\t\t);\n\t\t\tfor (const result of settled) {\n\t\t\t\tif (result.status === \"fulfilled\" && result.value.raw) {\n\t\t\t\t\tresults.set(result.value.txId, result.value.raw);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\t/** Fetch current chain tip height from Hiro API status endpoint */\n\tasync fetchChainTip(): Promise<number> {\n\t\tconst res = await this.fetchWithRetry(`${this.apiUrl}/extended/v1/status`);\n\t\tif (!res.ok) throw new Error(`Hiro API /status returned ${res.status}`);\n\t\tconst data = (await res.json()) as {\n\t\t\tchain_tip?: { block_height: number };\n\t\t\tstacks_tip_height?: number;\n\t\t};\n\t\treturn data.chain_tip?.block_height ?? data.stacks_tip_height ?? 0;\n\t}\n\n\tasync isHealthy(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst res = await fetch(`${this.apiUrl}/extended/v1/status`, {\n\t\t\t\theaders: this.headers,\n\t\t\t\tsignal: AbortSignal.timeout(10_000),\n\t\t\t});\n\t\t\t// 429 = rate limited but reachable\n\t\t\treturn res.ok || res.status === 429;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tgetApiUrl(): string {\n\t\treturn this.apiUrl;\n\t}\n}\n\n/** Map Hiro tx_status to our indexer's expected format */\nfunction mapTxStatus(status: string): string {\n\tswitch (status) {\n\t\tcase \"success\":\n\t\t\treturn \"success\";\n\t\tcase \"abort_by_response\":\n\t\tcase \"abort_by_post_condition\":\n\t\t\treturn status;\n\t\tdefault:\n\t\t\treturn \"success\";\n\t}\n}\n\n/** Map Hiro tx_type to node event tx_type */\nfunction mapTxType(type: string): string {\n\tswitch (type) {\n\t\tcase \"token_transfer\":\n\t\t\treturn \"token_transfer\";\n\t\tcase \"contract_call\":\n\t\t\treturn \"contract_call\";\n\t\tcase \"smart_contract\":\n\t\t\treturn \"smart_contract\";\n\t\tcase \"coinbase\":\n\t\t\treturn \"coinbase\";\n\t\tcase \"tenure_change\":\n\t\t\treturn \"tenure_change\";\n\t\tcase \"poison_microblock\":\n\t\t\treturn \"poison_microblock\";\n\t\tdefault:\n\t\t\treturn type;\n\t}\n}\n\n/**\n * Convert a Hiro API event to our indexer's TransactionEvent format.\n *\n * Hiro uses:\n * event_type: \"stx_asset\" | \"fungible_token_asset\" | \"non_fungible_token_asset\" | \"smart_contract_log\"\n * asset.asset_event_type: \"transfer\" | \"mint\" | \"burn\" | \"lock\"\n *\n * Our indexer expects:\n * type: \"stx_transfer_event\" | \"stx_mint_event\" | \"ft_transfer_event\" | \"smart_contract_event\" | ...\n */\nfunction convertHiroEvent(hEvent: HiroEvent): TransactionEventPayload | null {\n\tconst base = {\n\t\ttxid: hEvent.tx_id,\n\t\tevent_index: hEvent.event_index,\n\t\tcommitted: true,\n\t};\n\n\tif (hEvent.event_type === \"stx_asset\" && hEvent.asset) {\n\t\tconst a = hEvent.asset;\n\t\tswitch (a.asset_event_type) {\n\t\t\tcase \"transfer\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_transfer_event\",\n\t\t\t\t\tstx_transfer_event: {\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t\tmemo: a.memo,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"mint\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_mint_event\",\n\t\t\t\t\tstx_mint_event: {\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"burn\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_burn_event\",\n\t\t\t\t\tstx_burn_event: { sender: a.sender ?? \"\", amount: a.amount ?? \"0\" },\n\t\t\t\t};\n\t\t\tcase \"lock\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_lock_event\",\n\t\t\t\t\tstx_lock_event: {\n\t\t\t\t\t\tlocked_amount: a.amount ?? \"0\",\n\t\t\t\t\t\tunlock_height: \"0\",\n\t\t\t\t\t\tlocked_address: a.sender ?? \"\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t}\n\t}\n\n\tif (hEvent.event_type === \"fungible_token_asset\" && hEvent.asset) {\n\t\tconst a = hEvent.asset;\n\t\tconst assetId = a.asset_id || \"\";\n\t\tswitch (a.asset_event_type) {\n\t\t\tcase \"transfer\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"ft_transfer_event\",\n\t\t\t\t\tft_transfer_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"mint\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"ft_mint_event\",\n\t\t\t\t\tft_mint_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"burn\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"ft_burn_event\",\n\t\t\t\t\tft_burn_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t}\n\t}\n\n\tif (hEvent.event_type === \"non_fungible_token_asset\" && hEvent.asset) {\n\t\tconst a = hEvent.asset;\n\t\tconst assetId = a.asset_id || \"\";\n\t\tswitch (a.asset_event_type) {\n\t\t\tcase \"transfer\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"nft_transfer_event\",\n\t\t\t\t\tnft_transfer_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tvalue: a.value,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"mint\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"nft_mint_event\",\n\t\t\t\t\tnft_mint_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tvalue: a.value,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"burn\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"nft_burn_event\",\n\t\t\t\t\tnft_burn_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\tvalue: a.value,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t}\n\t}\n\n\tif (hEvent.event_type === \"smart_contract_log\" && hEvent.contract_log) {\n\t\treturn {\n\t\t\t...base,\n\t\t\ttype: \"smart_contract_event\",\n\t\t\tsmart_contract_event: {\n\t\t\t\tcontract_identifier: hEvent.contract_log.contract_id,\n\t\t\t\ttopic: hEvent.contract_log.topic,\n\t\t\t\tvalue: hEvent.contract_log.value,\n\t\t\t},\n\t\t};\n\t}\n\n\tlogger.debug(\"Unknown Hiro event type, skipping\", {\n\t\teventType: hEvent.event_type,\n\t\ttxId: hEvent.tx_id,\n\t});\n\treturn null;\n}\n"
8
8
  ],
9
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ;AAAA,EACpD,MAAM,WAAW,IACf,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AAAA,EAChB,MAAM,QAAQ,CAAC,WAAW,SAAS;AAAA,EACnC,WAAW,KAAK,UAAU;AAAA,IACzB,IAAI,CAAC,MAAM,SAAS,CAAC,GAAG;AAAA,MACvB,MAAM,IAAI,MACT,oBAAoB,sBAAsB,MAAM,KAAK,IAAI,GAC1D;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA,CACP;AAsBD,IAAM,YAAwC,EAAE,OAAO;AAAA,EACtD,cAAc,EAAE,WACf,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,SAAS,EAAE,KAAK,CAAC,WAAW,SAAS,CAAC,EAAE,SAAS;AAAA,EACjD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O,eAAe,wBAAwB,OAAO,cAAc;AAAA,IACtE,OAAO;AAAA,SACH;AAAA,MACH,MAAM;AAAA,MACN,sBAAsB;AAAA,QACrB,qBAAqB,OAAO,aAAa;AAAA,QACzC,OAAO,OAAO,aAAa;AAAA,QAC3B,OAAO,OAAO,aAAa;AAAA,MAC5B;AAAA,IACD;AAAA,EACD;AAAA,EAEA,OAAO,MAAM,qCAAqC;AAAA,IACjD,WAAW,OAAO;AAAA,IAClB,MAAM,OAAO;AAAA,EACd,CAAC;AAAA,EACD,OAAO;AAAA;",
10
+ "debugId": "6E7B17F342C8088D64756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -113,6 +113,7 @@ interface SubgraphsTable {
113
113
  handler_code: string | null;
114
114
  source_code: string | null;
115
115
  project_id: string | null;
116
+ visibility: Generated<string>;
116
117
  database_url_enc: ColumnType<Buffer | null, Buffer | null | undefined, Buffer | null>;
117
118
  created_at: Generated<Date>;
118
119
  updated_at: Generated<Date>;
@@ -177,7 +178,10 @@ interface ApiKeysTable {
177
178
  }
178
179
  interface AccountsTable {
179
180
  id: Generated<string>;
180
- email: string;
181
+ /** NULL for unclaimed ghost accounts (anonymous self-serve keys). */
182
+ email: string | null;
183
+ /** True for anonymous self-serve accounts until claimed via magic link. */
184
+ ghost: Generated<boolean>;
181
185
  plan: Generated<string>;
182
186
  display_name: string | null;
183
187
  bio: string | null;
@@ -197,6 +201,19 @@ interface SessionsTable {
197
201
  last_used_at: Date | null;
198
202
  created_at: Generated<Date>;
199
203
  }
204
+ /**
205
+ * One-time claim tokens for ghost accounts. The raw token only ever appears in
206
+ * the claim URL returned at mint time; we store its sha256. A used token marks
207
+ * the account as claimed (or merged into an existing account).
208
+ */
209
+ interface ClaimTokensTable {
210
+ id: Generated<string>;
211
+ account_id: string;
212
+ token_hash: string;
213
+ created_at: Generated<Date>;
214
+ expires_at: Date;
215
+ used_at: Date | null;
216
+ }
200
217
  interface MagicLinksTable {
201
218
  id: Generated<string>;
202
219
  email: string;
@@ -614,6 +631,7 @@ interface Database {
614
631
  accounts: AccountsTable;
615
632
  sessions: SessionsTable;
616
633
  magic_links: MagicLinksTable;
634
+ claim_tokens: ClaimTokensTable;
617
635
  usage_daily: UsageDailyTable;
618
636
  usage_snapshots: UsageSnapshotsTable;
619
637
  account_insights: AccountInsightsTable;
@@ -656,11 +674,27 @@ interface Database {
656
674
  bns_names: BnsNamesTable;
657
675
  bns_namespaces: BnsNamespacesTable;
658
676
  service_heartbeats: ServiceHeartbeatsTable;
677
+ x402_payments: X402PaymentsTable;
659
678
  }
660
679
  interface ServiceHeartbeatsTable {
661
680
  name: string;
662
681
  updated_at: Generated<Date>;
663
682
  }
683
+ /** x402 pay-per-request ledger (control plane). One row per settled payment,
684
+ * keyed by challenge nonce + settled txid. `state` tracks confirmed-tier
685
+ * settlement and post-serve reorg reversal. */
686
+ interface X402PaymentsTable {
687
+ id: Generated<string>;
688
+ nonce: string;
689
+ txid: string;
690
+ asset: string;
691
+ amount: string;
692
+ payer: string;
693
+ surface: string;
694
+ state: Generated<"pending" | "confirmed" | "reverted">;
695
+ created_at: Generated<Date>;
696
+ updated_at: Generated<Date>;
697
+ }
664
698
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
665
699
  interface TenantsTable {
666
700
  id: Generated<string>;
@@ -111,12 +111,20 @@ interface DeploySubgraphRequest {
111
111
  databaseUrl?: string;
112
112
  /** Validate the connection + print the DDL/grant plan without deploying. */
113
113
  dryRun?: boolean;
114
+ /**
115
+ * Read visibility. Server-side defaults: managed deploys → public (anon
116
+ * reads on /v1/subgraphs, name claimed in the global public namespace);
117
+ * BYO-database deploys → private (public reads hit the user's own
118
+ * Postgres, so going public is an explicit choice).
119
+ */
120
+ visibility?: "public" | "private";
114
121
  }
115
122
  declare const DeploySubgraphRequestSchema: z2.ZodType<DeploySubgraphRequest>;
116
123
  interface DeploySubgraphResponse {
117
124
  action: "created" | "unchanged" | "handler_updated" | "updated" | "reindexed";
118
125
  subgraphId: string;
119
126
  version: string;
127
+ visibility?: "public" | "private";
120
128
  message: string;
121
129
  operationId?: string;
122
130
  reindexStarted?: boolean;
@@ -144,6 +152,7 @@ interface SubgraphSummary {
144
152
  resourceWarning?: SubgraphResourceWarning;
145
153
  gapCount: number;
146
154
  integrity: "complete" | "gaps_detected";
155
+ visibility?: "public" | "private";
147
156
  createdAt: string;
148
157
  }
149
158
  interface SubgraphGapRange {
@@ -189,6 +198,7 @@ interface SubgraphDetail {
189
198
  version: string;
190
199
  schemaHash?: string;
191
200
  status: string;
201
+ visibility?: "public" | "private";
192
202
  lastProcessedBlock: number;
193
203
  description?: string;
194
204
  sources?: Record<string, unknown>;
@@ -130,7 +130,8 @@ var DeploySubgraphRequestSchema = z2.object({
130
130
  startBlock: z2.number().int().nonnegative().optional(),
131
131
  sourceCode: z2.string().max(1048576, "source code exceeds 1MB limit").optional(),
132
132
  databaseUrl: z2.string().url().refine((u) => u.startsWith("postgres://") || u.startsWith("postgresql://"), "must be a postgres:// connection string").optional(),
133
- dryRun: z2.boolean().optional()
133
+ dryRun: z2.boolean().optional(),
134
+ visibility: z2.enum(["public", "private"]).optional()
134
135
  });
135
136
 
136
137
  // src/schemas/subscriptions.ts
@@ -483,5 +484,5 @@ export {
483
484
  CHAIN_TRIGGER_FIELDS
484
485
  };
485
486
 
486
- //# debugId=C1D8F212526451F464756E2164756E21
487
+ //# debugId=F665E4F1EA910F7E64756E2164756E21
487
488
  //# sourceMappingURL=index.js.map
@@ -3,10 +3,10 @@
3
3
  "sources": ["../src/schemas/filters.ts", "../src/schemas/subgraphs.ts", "../src/schemas/subscriptions.ts"],
4
4
  "sourcesContent": [
5
5
  "import { isValidAddress as _isValidAddress } from \"@secondlayer/stacks\";\nimport { z } from \"zod/v4\";\n\nconst isValidAddress = _isValidAddress as (addr: string) => boolean;\n\n/** Validate a Stacks principal (standard or contract, e.g. SP2J...ABC or SP2J...ABC.contract-name) */\nconst stacksPrincipal = z.string().refine((val) => {\n\tconst parts = val.split(\".\");\n\tif (parts.length > 2) return false;\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\treturn isValidAddress(parts[0]!);\n}, \"Invalid Stacks principal address\");\n\n// Base filter with common fields\nconst baseFilter = {\n\t// Optional: filter by sender\n\tsender: stacksPrincipal.optional(),\n\t// Optional: filter by recipient\n\trecipient: stacksPrincipal.optional(),\n};\n\n// Type exports — defined first so they can annotate schemas\nexport interface StxTransferFilter {\n\ttype: \"stx_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tminAmount?: number;\n\tmaxAmount?: number;\n}\n\nexport interface StxMintFilter {\n\ttype: \"stx_mint\";\n\trecipient?: string;\n\tminAmount?: number;\n}\n\nexport interface StxBurnFilter {\n\ttype: \"stx_burn\";\n\tsender?: string;\n\tminAmount?: number;\n}\n\nexport interface StxLockFilter {\n\ttype: \"stx_lock\";\n\tlockedAddress?: string;\n\tminAmount?: number;\n}\n\nexport interface FtTransferFilter {\n\ttype: \"ft_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface FtMintFilter {\n\ttype: \"ft_mint\";\n\trecipient?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface FtBurnFilter {\n\ttype: \"ft_burn\";\n\tsender?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface NftTransferFilter {\n\ttype: \"nft_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface NftMintFilter {\n\ttype: \"nft_mint\";\n\trecipient?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface NftBurnFilter {\n\ttype: \"nft_burn\";\n\tsender?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface ContractCallFilter {\n\ttype: \"contract_call\";\n\tcontractId?: string;\n\tfunctionName?: string;\n\tcaller?: string;\n}\n\nexport interface ContractDeployFilter {\n\ttype: \"contract_deploy\";\n\tdeployer?: string;\n\tcontractName?: string;\n}\n\nexport interface PrintEventFilter {\n\ttype: \"print_event\";\n\tcontractId?: string;\n\ttopic?: string;\n\tcontains?: string;\n}\n\nexport type EventFilter =\n\t| StxTransferFilter\n\t| StxMintFilter\n\t| StxBurnFilter\n\t| StxLockFilter\n\t| FtTransferFilter\n\t| FtMintFilter\n\t| FtBurnFilter\n\t| NftTransferFilter\n\t| NftMintFilter\n\t| NftBurnFilter\n\t| ContractCallFilter\n\t| ContractDeployFilter\n\t| PrintEventFilter;\n\n// STX Transfer Filter\nexport const StxTransferFilterSchema: z.ZodType<StxTransferFilter> = z.object({\n\ttype: z.literal(\"stx_transfer\"),\n\t...baseFilter,\n\t// Optional: minimum amount in microSTX\n\tminAmount: z.coerce.number().int().positive().optional(),\n\t// Optional: maximum amount in microSTX\n\tmaxAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Mint Filter\nexport const StxMintFilterSchema: z.ZodType<StxMintFilter> = z.object({\n\ttype: z.literal(\"stx_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Burn Filter\nexport const StxBurnFilterSchema: z.ZodType<StxBurnFilter> = z.object({\n\ttype: z.literal(\"stx_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Lock Filter\nexport const StxLockFilterSchema: z.ZodType<StxLockFilter> = z.object({\n\ttype: z.literal(\"stx_lock\"),\n\tlockedAddress: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Transfer Filter\nexport const FtTransferFilterSchema: z.ZodType<FtTransferFilter> = z.object({\n\ttype: z.literal(\"ft_transfer\"),\n\t...baseFilter,\n\t// Contract that defines the token (e.g., SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx)\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Mint Filter\nexport const FtMintFilterSchema: z.ZodType<FtMintFilter> = z.object({\n\ttype: z.literal(\"ft_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Burn Filter\nexport const FtBurnFilterSchema: z.ZodType<FtBurnFilter> = z.object({\n\ttype: z.literal(\"ft_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// NFT Transfer Filter\nexport const NftTransferFilterSchema: z.ZodType<NftTransferFilter> = z.object({\n\ttype: z.literal(\"nft_transfer\"),\n\t...baseFilter,\n\tassetIdentifier: z.string().optional(),\n\t// Optional: filter by specific token ID (Clarity value as hex)\n\ttokenId: z.string().optional(),\n});\n\n// NFT Mint Filter\nexport const NftMintFilterSchema: z.ZodType<NftMintFilter> = z.object({\n\ttype: z.literal(\"nft_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\ttokenId: z.string().optional(),\n});\n\n// NFT Burn Filter\nexport const NftBurnFilterSchema: z.ZodType<NftBurnFilter> = z.object({\n\ttype: z.literal(\"nft_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\ttokenId: z.string().optional(),\n});\n\n// Contract Call Filter\nexport const ContractCallFilterSchema: z.ZodType<ContractCallFilter> = z.object(\n\t{\n\t\ttype: z.literal(\"contract_call\"),\n\t\t// Contract being called\n\t\tcontractId: stacksPrincipal.optional(),\n\t\t// Function name (supports wildcards with *)\n\t\tfunctionName: z.string().optional(),\n\t\t// Caller address\n\t\tcaller: stacksPrincipal.optional(),\n\t},\n);\n\n// Contract Deploy Filter\nexport const ContractDeployFilterSchema: z.ZodType<ContractDeployFilter> =\n\tz.object({\n\t\ttype: z.literal(\"contract_deploy\"),\n\t\t// Deployer address\n\t\tdeployer: stacksPrincipal.optional(),\n\t\t// Contract name pattern (supports wildcards)\n\t\tcontractName: z.string().optional(),\n\t});\n\n// Print Event Filter (smart contract events)\nexport const PrintEventFilterSchema: z.ZodType<PrintEventFilter> = z.object({\n\ttype: z.literal(\"print_event\"),\n\t// Contract emitting the event\n\tcontractId: stacksPrincipal.optional(),\n\t// Topic/name of the event\n\ttopic: z.string().optional(),\n\t// Search for substring in event data\n\tcontains: z.string().optional(),\n});\n\n// Union of all filter types\nexport const EventFilterSchema: z.ZodType<EventFilter> = z.discriminatedUnion(\n\t\"type\",\n\t[\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxTransferFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxMintFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxBurnFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxLockFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tFtTransferFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tFtMintFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tFtBurnFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tNftTransferFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tNftMintFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tNftBurnFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tContractCallFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tContractDeployFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tPrintEventFilterSchema as any,\n\t],\n);\n",
6
- "import { z } from \"zod/v4\";\n\n// ── Deploy Subgraph Request ─────────────────────────────────────────────────\n\nexport interface DeploySubgraphRequest {\n\tname: string;\n\tversion?: string;\n\tdescription?: string;\n\tsources: Record<string, Record<string, unknown>>;\n\tschema: Record<string, unknown>;\n\thandlerCode: string;\n\t/** Override the definition's startBlock for this deploy only. */\n\tstartBlock?: number;\n\t/** Original TypeScript source, persisted so chat can read/diff/edit later. */\n\tsourceCode?: string;\n\t/**\n\t * BYO data plane: a user-owned Postgres connection string. When set, the\n\t * subgraph's schema, handler writes, and serving reads live in this DB instead\n\t * of the managed one. Stored encrypted at rest, never returned.\n\t */\n\tdatabaseUrl?: string;\n\t/** Validate the connection + print the DDL/grant plan without deploying. */\n\tdryRun?: boolean;\n}\n\nexport const DeploySubgraphRequestSchema: z.ZodType<DeploySubgraphRequest> =\n\tz.object({\n\t\tname: z\n\t\t\t.string()\n\t\t\t.regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\")\n\t\t\t.max(63),\n\t\tversion: z.string().optional(),\n\t\tdescription: z.string().optional(),\n\t\tsources: z\n\t\t\t.record(z.string(), z.record(z.string(), z.unknown()))\n\t\t\t.refine(\n\t\t\t\t(s) => Object.keys(s).length > 0,\n\t\t\t\t\"Must have at least one source\",\n\t\t\t),\n\t\tschema: z.record(z.string(), z.unknown()),\n\t\thandlerCode: z.string().max(1_048_576, \"handler code exceeds 1MB limit\"),\n\t\tstartBlock: z.number().int().nonnegative().optional(),\n\t\tsourceCode: z\n\t\t\t.string()\n\t\t\t.max(1_048_576, \"source code exceeds 1MB limit\")\n\t\t\t.optional(),\n\t\tdatabaseUrl: z\n\t\t\t.string()\n\t\t\t.url()\n\t\t\t.refine(\n\t\t\t\t(u) => u.startsWith(\"postgres://\") || u.startsWith(\"postgresql://\"),\n\t\t\t\t\"must be a postgres:// connection string\",\n\t\t\t)\n\t\t\t.optional(),\n\t\tdryRun: z.boolean().optional(),\n\t});\n\nexport interface DeploySubgraphResponse {\n\taction: \"created\" | \"unchanged\" | \"handler_updated\" | \"updated\" | \"reindexed\";\n\tsubgraphId: string;\n\tversion: string;\n\tmessage: string;\n\toperationId?: string;\n\treindexStarted?: boolean;\n\tdiff?: {\n\t\taddedTables: string[];\n\t\tremovedTables: string[];\n\t\taddedColumns: Record<string, string[]>;\n\t\tbreakingChanges: string[];\n\t};\n}\n\n// Subgraph API response types\n\nexport interface SubgraphSummary {\n\tname: string;\n\tversion: string;\n\tstatus: string;\n\tlastProcessedBlock: number;\n\ttotalProcessed: number;\n\ttotalErrors: number;\n\ttables: string[];\n\tchainTip: number;\n\tsourceChainTip?: number;\n\ttargetBlock?: number;\n\tprogress: number;\n\tblocksRemaining?: number;\n\tsyncMode?: \"sync\" | \"reindex\";\n\tresourceWarning?: SubgraphResourceWarning;\n\tgapCount: number;\n\tintegrity: \"complete\" | \"gaps_detected\";\n\tcreatedAt: string;\n}\n\nexport interface SubgraphGapRange {\n\tstart: number;\n\tend: number;\n\tsize: number;\n\treason: string;\n}\n\nexport interface SubgraphSyncInfo {\n\tstatus: \"synced\" | \"catching_up\" | \"reindexing\" | \"error\";\n\tmode?: \"sync\" | \"reindex\";\n\tstartBlock: number;\n\tlastProcessedBlock: number;\n\t/**\n\t * Backward-compatible denominator for progress displays. During reindexing,\n\t * this is the reindex target block rather than the live source chain tip.\n\t */\n\tchainTip: number;\n\tsourceChainTip?: number;\n\ttargetBlock?: number;\n\tblocksRemaining: number;\n\tprocessedBlocks?: number;\n\ttotalBlocks?: number;\n\tprogress: number;\n\tresourceWarning?: SubgraphResourceWarning;\n\tgaps: {\n\t\tcount: number;\n\t\ttotalMissingBlocks: number;\n\t\tranges: SubgraphGapRange[];\n\t};\n\tintegrity: \"complete\" | \"gaps_detected\";\n}\n\nexport interface SubgraphResourceWarning {\n\tcode: string;\n\tmessage: string;\n\tplan?: string;\n\tblockRange: number;\n\tprocessorMemoryMb: number;\n\trecommendedPlan: \"launch\";\n}\n\nexport interface SubgraphDetail {\n\tname: string;\n\tversion: string;\n\tschemaHash?: string;\n\tstatus: string;\n\tlastProcessedBlock: number;\n\tdescription?: string;\n\tsources?: Record<string, unknown>;\n\tdefinition?: Record<string, unknown>;\n\thealth: {\n\t\ttotalProcessed: number;\n\t\ttotalErrors: number;\n\t\terrorRate: number;\n\t\tlastError: string | null;\n\t\tlastErrorAt: string | null;\n\t};\n\tsync: SubgraphSyncInfo;\n\ttables: Record<\n\t\tstring,\n\t\t{\n\t\t\tendpoint: string;\n\t\t\tcolumns: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\ttype: string;\n\t\t\t\t\tnullable?: boolean;\n\t\t\t\t\tindexed?: boolean;\n\t\t\t\t\tsearchable?: boolean;\n\t\t\t\t\tdefault?: string | number | boolean;\n\t\t\t\t}\n\t\t\t>;\n\t\t\trowCount: number;\n\t\t\texample: string;\n\t\t\tindexes?: string[][];\n\t\t\tuniqueKeys?: string[][];\n\t\t}\n\t>;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface SubgraphGapEntry {\n\tstart: number;\n\tend: number;\n\tsize: number;\n\treason: string;\n\tdetectedAt: string;\n\tresolvedAt: string | null;\n}\n\nexport interface SubgraphGapsResponse {\n\tdata: SubgraphGapEntry[];\n\tmeta: {\n\t\ttotal: number;\n\t\ttotalMissingBlocks: number;\n\t\tlimit: number;\n\t\toffset: number;\n\t};\n}\n\nexport interface ReindexResponse {\n\tmessage: string;\n\tfromBlock: number;\n\ttoBlock: number | string;\n\toperationId?: string;\n\tstatus?: \"queued\" | \"running\" | \"cancel_requested\";\n}\n\nexport interface SubgraphQueryParams {\n\tsort?: string;\n\torder?: string;\n\tlimit?: number;\n\toffset?: number;\n\tfields?: string;\n\tfilters?: Record<string, string>;\n}\n\n/**\n * Request shape for `GET /api/subgraphs/:subgraphName/:tableName/aggregate`.\n * `filters` reuses the list/count where-surface; the rest name the columns to\n * aggregate. SUM/MIN/MAX columns must be numeric (uint/int, plus `_block_height`).\n */\nexport interface SubgraphAggregateParams {\n\tfilters?: Record<string, string>;\n\tcount?: boolean;\n\tcountDistinct?: string[];\n\tsum?: string[];\n\tmin?: string[];\n\tmax?: string[];\n}\n\n/**\n * Aggregate response. Keys are present only for requested aggregates.\n * `count`/`countDistinct` are JSON numbers (counts << 2^53); `sum`/`min`/`max`\n * are lossless strings (NUMERIC `::text`). `sum` of an empty set is `\"0\"`;\n * `min`/`max` are `null` when the filtered set is empty or all-null.\n */\nexport interface SubgraphAggregateResponse {\n\tcount?: number;\n\tcountDistinct?: Record<string, number>;\n\tsum?: Record<string, string>;\n\tmin?: Record<string, string | null>;\n\tmax?: Record<string, string | null>;\n}\n",
6
+ "import { z } from \"zod/v4\";\n\n// ── Deploy Subgraph Request ─────────────────────────────────────────────────\n\nexport interface DeploySubgraphRequest {\n\tname: string;\n\tversion?: string;\n\tdescription?: string;\n\tsources: Record<string, Record<string, unknown>>;\n\tschema: Record<string, unknown>;\n\thandlerCode: string;\n\t/** Override the definition's startBlock for this deploy only. */\n\tstartBlock?: number;\n\t/** Original TypeScript source, persisted so chat can read/diff/edit later. */\n\tsourceCode?: string;\n\t/**\n\t * BYO data plane: a user-owned Postgres connection string. When set, the\n\t * subgraph's schema, handler writes, and serving reads live in this DB instead\n\t * of the managed one. Stored encrypted at rest, never returned.\n\t */\n\tdatabaseUrl?: string;\n\t/** Validate the connection + print the DDL/grant plan without deploying. */\n\tdryRun?: boolean;\n\t/**\n\t * Read visibility. Server-side defaults: managed deploys → public (anon\n\t * reads on /v1/subgraphs, name claimed in the global public namespace);\n\t * BYO-database deploys → private (public reads hit the user's own\n\t * Postgres, so going public is an explicit choice).\n\t */\n\tvisibility?: \"public\" | \"private\";\n}\n\nexport const DeploySubgraphRequestSchema: z.ZodType<DeploySubgraphRequest> =\n\tz.object({\n\t\tname: z\n\t\t\t.string()\n\t\t\t.regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\")\n\t\t\t.max(63),\n\t\tversion: z.string().optional(),\n\t\tdescription: z.string().optional(),\n\t\tsources: z\n\t\t\t.record(z.string(), z.record(z.string(), z.unknown()))\n\t\t\t.refine(\n\t\t\t\t(s) => Object.keys(s).length > 0,\n\t\t\t\t\"Must have at least one source\",\n\t\t\t),\n\t\tschema: z.record(z.string(), z.unknown()),\n\t\thandlerCode: z.string().max(1_048_576, \"handler code exceeds 1MB limit\"),\n\t\tstartBlock: z.number().int().nonnegative().optional(),\n\t\tsourceCode: z\n\t\t\t.string()\n\t\t\t.max(1_048_576, \"source code exceeds 1MB limit\")\n\t\t\t.optional(),\n\t\tdatabaseUrl: z\n\t\t\t.string()\n\t\t\t.url()\n\t\t\t.refine(\n\t\t\t\t(u) => u.startsWith(\"postgres://\") || u.startsWith(\"postgresql://\"),\n\t\t\t\t\"must be a postgres:// connection string\",\n\t\t\t)\n\t\t\t.optional(),\n\t\tdryRun: z.boolean().optional(),\n\t\tvisibility: z.enum([\"public\", \"private\"]).optional(),\n\t});\n\nexport interface DeploySubgraphResponse {\n\taction: \"created\" | \"unchanged\" | \"handler_updated\" | \"updated\" | \"reindexed\";\n\tsubgraphId: string;\n\tversion: string;\n\tvisibility?: \"public\" | \"private\";\n\tmessage: string;\n\toperationId?: string;\n\treindexStarted?: boolean;\n\tdiff?: {\n\t\taddedTables: string[];\n\t\tremovedTables: string[];\n\t\taddedColumns: Record<string, string[]>;\n\t\tbreakingChanges: string[];\n\t};\n}\n\n// Subgraph API response types\n\nexport interface SubgraphSummary {\n\tname: string;\n\tversion: string;\n\tstatus: string;\n\tlastProcessedBlock: number;\n\ttotalProcessed: number;\n\ttotalErrors: number;\n\ttables: string[];\n\tchainTip: number;\n\tsourceChainTip?: number;\n\ttargetBlock?: number;\n\tprogress: number;\n\tblocksRemaining?: number;\n\tsyncMode?: \"sync\" | \"reindex\";\n\tresourceWarning?: SubgraphResourceWarning;\n\tgapCount: number;\n\tintegrity: \"complete\" | \"gaps_detected\";\n\tvisibility?: \"public\" | \"private\";\n\tcreatedAt: string;\n}\n\nexport interface SubgraphGapRange {\n\tstart: number;\n\tend: number;\n\tsize: number;\n\treason: string;\n}\n\nexport interface SubgraphSyncInfo {\n\tstatus: \"synced\" | \"catching_up\" | \"reindexing\" | \"error\";\n\tmode?: \"sync\" | \"reindex\";\n\tstartBlock: number;\n\tlastProcessedBlock: number;\n\t/**\n\t * Backward-compatible denominator for progress displays. During reindexing,\n\t * this is the reindex target block rather than the live source chain tip.\n\t */\n\tchainTip: number;\n\tsourceChainTip?: number;\n\ttargetBlock?: number;\n\tblocksRemaining: number;\n\tprocessedBlocks?: number;\n\ttotalBlocks?: number;\n\tprogress: number;\n\tresourceWarning?: SubgraphResourceWarning;\n\tgaps: {\n\t\tcount: number;\n\t\ttotalMissingBlocks: number;\n\t\tranges: SubgraphGapRange[];\n\t};\n\tintegrity: \"complete\" | \"gaps_detected\";\n}\n\nexport interface SubgraphResourceWarning {\n\tcode: string;\n\tmessage: string;\n\tplan?: string;\n\tblockRange: number;\n\tprocessorMemoryMb: number;\n\trecommendedPlan: \"launch\";\n}\n\nexport interface SubgraphDetail {\n\tname: string;\n\tversion: string;\n\tschemaHash?: string;\n\tstatus: string;\n\tvisibility?: \"public\" | \"private\";\n\tlastProcessedBlock: number;\n\tdescription?: string;\n\tsources?: Record<string, unknown>;\n\tdefinition?: Record<string, unknown>;\n\thealth: {\n\t\ttotalProcessed: number;\n\t\ttotalErrors: number;\n\t\terrorRate: number;\n\t\tlastError: string | null;\n\t\tlastErrorAt: string | null;\n\t};\n\tsync: SubgraphSyncInfo;\n\ttables: Record<\n\t\tstring,\n\t\t{\n\t\t\tendpoint: string;\n\t\t\tcolumns: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\ttype: string;\n\t\t\t\t\tnullable?: boolean;\n\t\t\t\t\tindexed?: boolean;\n\t\t\t\t\tsearchable?: boolean;\n\t\t\t\t\tdefault?: string | number | boolean;\n\t\t\t\t}\n\t\t\t>;\n\t\t\trowCount: number;\n\t\t\texample: string;\n\t\t\tindexes?: string[][];\n\t\t\tuniqueKeys?: string[][];\n\t\t}\n\t>;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface SubgraphGapEntry {\n\tstart: number;\n\tend: number;\n\tsize: number;\n\treason: string;\n\tdetectedAt: string;\n\tresolvedAt: string | null;\n}\n\nexport interface SubgraphGapsResponse {\n\tdata: SubgraphGapEntry[];\n\tmeta: {\n\t\ttotal: number;\n\t\ttotalMissingBlocks: number;\n\t\tlimit: number;\n\t\toffset: number;\n\t};\n}\n\nexport interface ReindexResponse {\n\tmessage: string;\n\tfromBlock: number;\n\ttoBlock: number | string;\n\toperationId?: string;\n\tstatus?: \"queued\" | \"running\" | \"cancel_requested\";\n}\n\nexport interface SubgraphQueryParams {\n\tsort?: string;\n\torder?: string;\n\tlimit?: number;\n\toffset?: number;\n\tfields?: string;\n\tfilters?: Record<string, string>;\n}\n\n/**\n * Request shape for `GET /api/subgraphs/:subgraphName/:tableName/aggregate`.\n * `filters` reuses the list/count where-surface; the rest name the columns to\n * aggregate. SUM/MIN/MAX columns must be numeric (uint/int, plus `_block_height`).\n */\nexport interface SubgraphAggregateParams {\n\tfilters?: Record<string, string>;\n\tcount?: boolean;\n\tcountDistinct?: string[];\n\tsum?: string[];\n\tmin?: string[];\n\tmax?: string[];\n}\n\n/**\n * Aggregate response. Keys are present only for requested aggregates.\n * `count`/`countDistinct` are JSON numbers (counts << 2^53); `sum`/`min`/`max`\n * are lossless strings (NUMERIC `::text`). `sum` of an empty set is `\"0\"`;\n * `min`/`max` are `null` when the filtered set is empty or all-null.\n */\nexport interface SubgraphAggregateResponse {\n\tcount?: number;\n\tcountDistinct?: Record<string, number>;\n\tsum?: Record<string, string>;\n\tmin?: Record<string, string | null>;\n\tmax?: Record<string, string | null>;\n}\n",
7
7
  "import { z } from \"zod/v4\";\n\nexport const SUBSCRIPTION_FORMATS = [\n\t\"standard-webhooks\",\n\t\"inngest\",\n\t\"trigger\",\n\t\"cloudflare\",\n\t\"cloudevents\",\n\t\"raw\",\n] as const;\n\nexport const SUBSCRIPTION_RUNTIMES = [\n\t\"inngest\",\n\t\"trigger\",\n\t\"cloudflare\",\n\t\"node\",\n] as const;\n\nexport const SUBSCRIPTION_STATUSES = [\"active\", \"paused\", \"error\"] as const;\n\nexport const SUBSCRIPTION_FILTER_OPERATORS = [\n\t\"eq\",\n\t\"neq\",\n\t\"gt\",\n\t\"gte\",\n\t\"lt\",\n\t\"lte\",\n\t\"in\",\n] as const;\n\nconst webhookUrl = z\n\t.string()\n\t.trim()\n\t.min(1)\n\t.refine(\n\t\t(value) => value.startsWith(\"http://\") || value.startsWith(\"https://\"),\n\t\t\"must be an http(s) URL\",\n\t);\n\nconst name = z.string().trim().min(1).max(128);\nconst resourceName = z.string().trim().min(1).max(128);\n\nexport const SubscriptionStatusSchema: z.ZodType<SubscriptionStatus> = z.enum(\n\tSUBSCRIPTION_STATUSES,\n);\nexport const SubscriptionFormatSchema: z.ZodType<SubscriptionFormat> =\n\tz.enum(SUBSCRIPTION_FORMATS);\nexport const SubscriptionRuntimeSchema: z.ZodType<SubscriptionRuntime> = z.enum(\n\tSUBSCRIPTION_RUNTIMES,\n);\n\nexport const SubscriptionFilterPrimitiveSchema: z.ZodType<SubscriptionFilterPrimitive> =\n\tz.union([z.string(), z.number().finite(), z.boolean()]);\n\nexport const SubscriptionFilterOperatorSchema: z.ZodType<SubscriptionFilterOperator> =\n\tz.union([\n\t\tz.object({ eq: SubscriptionFilterPrimitiveSchema }).strict(),\n\t\tz.object({ neq: SubscriptionFilterPrimitiveSchema }).strict(),\n\t\tz.object({ gt: z.union([z.string(), z.number().finite()]) }).strict(),\n\t\tz.object({ gte: z.union([z.string(), z.number().finite()]) }).strict(),\n\t\tz.object({ lt: z.union([z.string(), z.number().finite()]) }).strict(),\n\t\tz.object({ lte: z.union([z.string(), z.number().finite()]) }).strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\tin: z.array(SubscriptionFilterPrimitiveSchema).min(1),\n\t\t\t})\n\t\t\t.strict(),\n\t]);\n\nexport const SubscriptionFilterClauseSchema: z.ZodType<SubscriptionFilterClause> =\n\tz.union([\n\t\tSubscriptionFilterPrimitiveSchema,\n\t\tSubscriptionFilterOperatorSchema,\n\t]);\n\nexport const SubscriptionFilterSchema: z.ZodType<SubscriptionFilter> = z.record(\n\tz.string().min(1),\n\tSubscriptionFilterClauseSchema,\n);\n\n// --- Chain triggers (direct chain-level subscriptions) -----------------------\n// A chain subscription reacts to raw chain events matched directly off the\n// Index/Streams clock (no subgraph). `triggers` is an array of these filters —\n// the JSON mirror of the subgraph runtime's `SubgraphFilter` union. Defined\n// here (not imported from @secondlayer/subgraphs) to avoid a shared→subgraphs\n// cycle; the evaluator maps these to `SubgraphFilter` at match time. Amounts are\n// non-negative integer strings (uint128 can exceed JS safe-int) or numbers.\n\nexport const CHAIN_TRIGGER_TYPES = [\n\t\"stx_transfer\",\n\t\"stx_mint\",\n\t\"stx_burn\",\n\t\"stx_lock\",\n\t\"ft_transfer\",\n\t\"ft_mint\",\n\t\"ft_burn\",\n\t\"nft_transfer\",\n\t\"nft_mint\",\n\t\"nft_burn\",\n\t\"contract_call\",\n\t\"contract_deploy\",\n\t\"print_event\",\n] as const;\n\nconst triggerAmount = z.union([\n\tz.string().trim().regex(/^\\d+$/, \"must be a non-negative integer string\"),\n\tz.number().int().nonnegative(),\n]);\n/** Principal/identifier/name patterns — `*` wildcards allowed (matched by the\n * evaluator). */\nconst triggerPattern = z.string().trim().min(1);\nconst trait = z.string().trim().min(1);\n\nexport const ChainTriggerSchema: z.ZodType<ChainTrigger> = z.discriminatedUnion(\n\t\"type\",\n\t[\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_transfer\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_mint\"),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_burn\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_lock\"),\n\t\t\t\tlockedAddress: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_transfer\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_mint\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_burn\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_transfer\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_mint\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_burn\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"contract_call\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tfunctionName: triggerPattern.optional(),\n\t\t\t\tcaller: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"contract_deploy\"),\n\t\t\t\tdeployer: triggerPattern.optional(),\n\t\t\t\tcontractName: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"print_event\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\ttopic: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t],\n);\n\nexport const ChainTriggersSchema: z.ZodType<ChainTrigger[]> = z\n\t.array(ChainTriggerSchema)\n\t.min(1)\n\t.max(50);\n\n/**\n * Per-type accepted filter fields for chain triggers, DERIVED from\n * {@link ChainTriggerSchema} so the agent-facing reference can never drift behind\n * the validator. `{ stx_transfer: [\"sender\",\"recipient\",\"minAmount\",\"maxAmount\"], ... }`.\n */\nexport const CHAIN_TRIGGER_FIELDS: Record<string, string[]> =\n\tObject.fromEntries(\n\t\t// biome-ignore lint/suspicious/noExplicitAny: zod-internal introspection of this module's own discriminated union\n\t\t((ChainTriggerSchema as any)._zod.def.options as any[]).map((opt) => {\n\t\t\tconst shape = opt._zod.def.shape as Record<string, unknown>;\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: literal value lives on the zod-internal def\n\t\t\tconst type = (shape.type as any)._zod.def.values[0] as string;\n\t\t\treturn [type, Object.keys(shape).filter((k) => k !== \"type\")];\n\t\t}),\n\t);\n\nexport const CreateSubscriptionRequestSchema: z.ZodType<ParsedCreateSubscriptionRequest> =\n\tz\n\t\t.object({\n\t\t\tname,\n\t\t\t// Subgraph mode (kind=subgraph): subgraphName + tableName + optional filter.\n\t\t\tsubgraphName: resourceName.optional(),\n\t\t\ttableName: resourceName.optional(),\n\t\t\tfilter: SubscriptionFilterSchema.optional(),\n\t\t\t// Chain mode (kind=chain): triggers.\n\t\t\ttriggers: ChainTriggersSchema.optional(),\n\t\t\turl: webhookUrl,\n\t\t\tformat: SubscriptionFormatSchema.default(\"standard-webhooks\"),\n\t\t\truntime: SubscriptionRuntimeSchema.nullable().optional(),\n\t\t\tauthConfig: z.record(z.string(), z.unknown()).optional(),\n\t\t\tmaxRetries: z.number().int().min(0).max(100).optional(),\n\t\t\ttimeoutMs: z.number().int().min(100).max(300_000).optional(),\n\t\t\tconcurrency: z.number().int().min(1).max(100).optional(),\n\t\t})\n\t\t.refine(\n\t\t\t(v) => {\n\t\t\t\tconst subgraphMode =\n\t\t\t\t\tv.subgraphName !== undefined || v.tableName !== undefined;\n\t\t\t\tconst chainMode = v.triggers !== undefined;\n\t\t\t\tif (chainMode && subgraphMode) return false;\n\t\t\t\tif (chainMode) return true;\n\t\t\t\t// Subgraph mode requires BOTH subgraphName and tableName.\n\t\t\t\treturn v.subgraphName !== undefined && v.tableName !== undefined;\n\t\t\t},\n\t\t\t{\n\t\t\t\tmessage:\n\t\t\t\t\t\"provide either { subgraphName, tableName } for a subgraph subscription OR { triggers } for a chain subscription — not both\",\n\t\t\t},\n\t\t)\n\t\t.refine((v) => v.filter === undefined || v.triggers === undefined, {\n\t\t\tmessage:\n\t\t\t\t\"`filter` applies to subgraph subscriptions; chain subscriptions use `triggers`\",\n\t\t\tpath: [\"filter\"],\n\t\t});\n\nexport const UpdateSubscriptionRequestSchema: z.ZodType<UpdateSubscriptionRequest> =\n\tz\n\t\t.object({\n\t\t\tname: name.optional(),\n\t\t\turl: webhookUrl.optional(),\n\t\t\tfilter: SubscriptionFilterSchema.optional(),\n\t\t\tformat: SubscriptionFormatSchema.optional(),\n\t\t\truntime: SubscriptionRuntimeSchema.nullable().optional(),\n\t\t\tauthConfig: z.record(z.string(), z.unknown()).optional(),\n\t\t\tmaxRetries: z.number().int().min(0).max(100).optional(),\n\t\t\ttimeoutMs: z.number().int().min(100).max(300_000).optional(),\n\t\t\tconcurrency: z.number().int().min(1).max(100).optional(),\n\t\t})\n\t\t.refine((value) => Object.keys(value).length > 0, {\n\t\t\tmessage: \"At least one field must be provided\",\n\t\t});\n\nexport const ReplaySubscriptionRequestSchema: z.ZodType<ReplaySubscriptionRequest> =\n\tz\n\t\t.object({\n\t\t\tfromBlock: z.number().int().nonnegative(),\n\t\t\ttoBlock: z.number().int().nonnegative(),\n\t\t\tforce: z.string().trim().min(1).max(64).optional(),\n\t\t})\n\t\t.refine((value) => value.fromBlock <= value.toBlock, {\n\t\t\tmessage: \"fromBlock must be less than or equal to toBlock\",\n\t\t\tpath: [\"toBlock\"],\n\t\t});\n\nexport type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[number];\n/** Polymorphic subscription mode (mirrors db/types `SubscriptionKind`). */\nexport type SubscriptionKind = \"subgraph\" | \"chain\";\nexport type SubscriptionFormat = (typeof SUBSCRIPTION_FORMATS)[number];\nexport type SubscriptionRuntime = (typeof SUBSCRIPTION_RUNTIMES)[number];\nexport type SubscriptionFilterPrimitive = string | number | boolean;\nexport type SubscriptionFilterOperator =\n\t| { eq: SubscriptionFilterPrimitive }\n\t| { neq: SubscriptionFilterPrimitive }\n\t| { gt: string | number }\n\t| { gte: string | number }\n\t| { lt: string | number }\n\t| { lte: string | number }\n\t| { in: SubscriptionFilterPrimitive[] };\nexport type SubscriptionFilterClause =\n\t| SubscriptionFilterPrimitive\n\t| SubscriptionFilterOperator;\nexport type SubscriptionFilter = Record<string, SubscriptionFilterClause>;\n\nexport type ChainTriggerType = (typeof CHAIN_TRIGGER_TYPES)[number];\n/** Non-negative integer amount over JSON (string for uint128 safety, or number). */\nexport type ChainTriggerAmount = string | number;\n\ninterface TraitScoped {\n\ttrait?: string;\n}\n\n/** JSON mirror of the subgraph runtime's `SubgraphFilter` union. */\nexport type ChainTrigger =\n\t| {\n\t\t\ttype: \"stx_transfer\";\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t }\n\t| { type: \"stx_mint\"; recipient?: string; minAmount?: ChainTriggerAmount }\n\t| { type: \"stx_burn\"; sender?: string; minAmount?: ChainTriggerAmount }\n\t| {\n\t\t\ttype: \"stx_lock\";\n\t\t\tlockedAddress?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t }\n\t| ({\n\t\t\ttype: \"ft_transfer\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"ft_mint\";\n\t\t\tassetIdentifier?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"ft_burn\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_transfer\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_mint\";\n\t\t\tassetIdentifier?: string;\n\t\t\trecipient?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_burn\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"contract_call\";\n\t\t\tcontractId?: string;\n\t\t\tfunctionName?: string;\n\t\t\tcaller?: string;\n\t } & TraitScoped)\n\t| { type: \"contract_deploy\"; deployer?: string; contractName?: string }\n\t| ({\n\t\t\ttype: \"print_event\";\n\t\t\tcontractId?: string;\n\t\t\ttopic?: string;\n\t } & TraitScoped);\n\n/** Args for a chain-trigger builder — every field of a variant except `type`. */\ntype TriggerArgs<T extends ChainTrigger[\"type\"]> = Omit<\n\tExtract<ChainTrigger, { type: T }>,\n\t\"type\"\n>;\n\n/**\n * Ergonomic chain-trigger constructors for `subscriptions.create({ triggers })`.\n * Each returns a bare `ChainTrigger` (the wire shape the API expects):\n *\n * ```ts\n * client.subscriptions.create({\n * url: \"https://my.app/webhook\",\n * triggers: [trigger.contractCall({ contractId: \"SP....amm\", functionName: \"swap-*\" })],\n * });\n * ```\n */\nexport const trigger = {\n\tstxTransfer: (f: TriggerArgs<\"stx_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_transfer\",\n\t\t...f,\n\t}),\n\tstxMint: (f: TriggerArgs<\"stx_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_mint\",\n\t\t...f,\n\t}),\n\tstxBurn: (f: TriggerArgs<\"stx_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_burn\",\n\t\t...f,\n\t}),\n\tstxLock: (f: TriggerArgs<\"stx_lock\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_lock\",\n\t\t...f,\n\t}),\n\tftTransfer: (f: TriggerArgs<\"ft_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_transfer\",\n\t\t...f,\n\t}),\n\tftMint: (f: TriggerArgs<\"ft_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_mint\",\n\t\t...f,\n\t}),\n\tftBurn: (f: TriggerArgs<\"ft_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_burn\",\n\t\t...f,\n\t}),\n\tnftTransfer: (f: TriggerArgs<\"nft_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_transfer\",\n\t\t...f,\n\t}),\n\tnftMint: (f: TriggerArgs<\"nft_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_mint\",\n\t\t...f,\n\t}),\n\tnftBurn: (f: TriggerArgs<\"nft_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_burn\",\n\t\t...f,\n\t}),\n\tcontractCall: (f: TriggerArgs<\"contract_call\"> = {}): ChainTrigger => ({\n\t\ttype: \"contract_call\",\n\t\t...f,\n\t}),\n\tcontractDeploy: (f: TriggerArgs<\"contract_deploy\"> = {}): ChainTrigger => ({\n\t\ttype: \"contract_deploy\",\n\t\t...f,\n\t}),\n\tprintEvent: (f: TriggerArgs<\"print_event\"> = {}): ChainTrigger => ({\n\t\ttype: \"print_event\",\n\t\t...f,\n\t}),\n} as const;\n\nexport interface CreateSubscriptionRequest {\n\tname: string;\n\t/** Subgraph mode. */\n\tsubgraphName?: string;\n\ttableName?: string;\n\tfilter?: SubscriptionFilter;\n\t/** Chain mode. */\n\ttriggers?: ChainTrigger[];\n\turl: string;\n\tformat?: SubscriptionFormat;\n\truntime?: SubscriptionRuntime | null;\n\tauthConfig?: Record<string, unknown>;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport interface ParsedCreateSubscriptionRequest\n\textends Omit<CreateSubscriptionRequest, \"format\"> {\n\tformat: SubscriptionFormat;\n}\n\nexport interface UpdateSubscriptionRequest {\n\tname?: string;\n\turl?: string;\n\tfilter?: SubscriptionFilter;\n\tformat?: SubscriptionFormat;\n\truntime?: SubscriptionRuntime | null;\n\tauthConfig?: Record<string, unknown>;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport type ParsedUpdateSubscriptionRequest = UpdateSubscriptionRequest;\n\nexport interface ReplaySubscriptionRequest {\n\tfromBlock: number;\n\ttoBlock: number;\n\tforce?: string;\n}\n\nexport type ParsedReplaySubscriptionRequest = ReplaySubscriptionRequest;\n\nexport interface SubscriptionSummary {\n\tid: string;\n\tname: string;\n\tstatus: SubscriptionStatus;\n\tkind: SubscriptionKind;\n\t/** Null for chain subscriptions. */\n\tsubgraphName: string | null;\n\t/** Null for chain subscriptions. */\n\ttableName: string | null;\n\tformat: SubscriptionFormat;\n\truntime: SubscriptionRuntime | null;\n\turl: string;\n\tlastDeliveryAt: string | null;\n\tlastSuccessAt: string | null;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface SubscriptionDetail extends SubscriptionSummary {\n\tfilter: Record<string, unknown>;\n\t/** Chain-trigger filters (chain subscriptions only). */\n\ttriggers: ChainTrigger[] | null;\n\tauthConfig: Record<string, unknown>;\n\tmaxRetries: number;\n\ttimeoutMs: number;\n\tconcurrency: number;\n\tcircuitFailures: number;\n\tcircuitOpenedAt: string | null;\n\tlastError: string | null;\n}\n\nexport interface CreateSubscriptionResponse {\n\tsubscription: SubscriptionDetail;\n\t/** Plaintext signing secret — surfaced ONCE. Store it server-side. */\n\tsigningSecret: string;\n}\n\nexport interface RotateSecretResponse {\n\tsubscription: SubscriptionDetail;\n\tsigningSecret: string;\n}\n\nexport interface DeliveryRow {\n\tid: string;\n\tattempt: number;\n\tstatusCode: number | null;\n\terrorMessage: string | null;\n\tdurationMs: number | null;\n\tresponseBody: string | null;\n\tdispatchedAt: string;\n}\n\nexport interface ReplayResult {\n\treplayId: string;\n\tenqueuedCount: number;\n\tscannedCount: number;\n}\n\n/** Result of a one-off test delivery (`POST /:id/test`). Logged as a delivery\n * row (with a null outbox_id) so it shows up under the subscription's deliveries. */\nexport interface SubscriptionTestResult {\n\tok: boolean;\n\tstatusCode: number | null;\n\terror: string | null;\n\tdurationMs: number;\n\tdeliveryId: string;\n}\n\nexport interface DeadRow {\n\tid: string;\n\teventType: string;\n\tattempt: number;\n\tblockHeight: number;\n\ttxId: string | null;\n\tpayload: Record<string, unknown>;\n\tfailedAt: string | null;\n\tcreatedAt: string;\n}\n\nexport interface SubscriptionSchemaColumn {\n\ttype?: unknown;\n}\n\nexport interface SubscriptionSchemaTable {\n\tcolumns: Record<string, SubscriptionSchemaColumn>;\n}\n\nexport type SubscriptionSchemaTables = Record<string, SubscriptionSchemaTable>;\n\nconst SCALAR_COLUMN_TYPES = new Set([\n\t\"text\",\n\t\"uint\",\n\t\"int\",\n\t\"principal\",\n\t\"boolean\",\n\t\"timestamp\",\n]);\n\nconst COMPARISON_COLUMN_TYPES = new Set([\"uint\", \"int\", \"timestamp\"]);\n\nfunction formatIssuePath(path: PropertyKey[]): string {\n\treturn path.length > 0 ? `${path.map(String).join(\".\")}: ` : \"\";\n}\n\nexport function formatSubscriptionSchemaErrors(error: z.ZodError): string[] {\n\treturn error.issues.map(\n\t\t(issue) => `${formatIssuePath(issue.path)}${issue.message}`,\n\t);\n}\n\nfunction operatorForClause(clause: SubscriptionFilterClause): string {\n\tif (clause === null || typeof clause !== \"object\" || Array.isArray(clause)) {\n\t\treturn \"eq\";\n\t}\n\treturn Object.keys(clause)[0] ?? \"eq\";\n}\n\nexport function validateSubscriptionFilterForTable(input: {\n\tsubgraphName?: string;\n\ttableName: string;\n\tfilter?: unknown;\n\ttables: SubscriptionSchemaTables;\n}): string[] {\n\tconst errors: string[] = [];\n\tconst table = input.tables[input.tableName];\n\tif (!table) {\n\t\tconst names = Object.keys(input.tables);\n\t\terrors.push(\n\t\t\t`Unknown table \"${input.tableName}\"${\n\t\t\t\tinput.subgraphName ? ` in subgraph \"${input.subgraphName}\"` : \"\"\n\t\t\t}.${names.length > 0 ? ` Available tables: ${names.join(\", \")}.` : \"\"}`,\n\t\t);\n\t\treturn errors;\n\t}\n\n\tif (input.filter === undefined) return errors;\n\n\tconst parsed = SubscriptionFilterSchema.safeParse(input.filter);\n\tif (!parsed.success) {\n\t\treturn formatSubscriptionSchemaErrors(parsed.error);\n\t}\n\n\tfor (const [field, clause] of Object.entries(parsed.data)) {\n\t\tconst column = table.columns[field];\n\t\tif (!column) {\n\t\t\terrors.push(\n\t\t\t\t`Unknown filter field \"${field}\" on table \"${input.tableName}\".`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst columnType =\n\t\t\ttypeof column.type === \"string\" ? column.type.toLowerCase() : \"\";\n\t\tif (!SCALAR_COLUMN_TYPES.has(columnType)) {\n\t\t\terrors.push(\n\t\t\t\t`Filter field \"${field}\" has unsupported type \"${columnType || \"unknown\"}\"; subscription filters require scalar columns.`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst operator = operatorForClause(clause);\n\t\tif (\n\t\t\t(operator === \"gt\" ||\n\t\t\t\toperator === \"gte\" ||\n\t\t\t\toperator === \"lt\" ||\n\t\t\t\toperator === \"lte\") &&\n\t\t\t!COMPARISON_COLUMN_TYPES.has(columnType)\n\t\t) {\n\t\t\terrors.push(\n\t\t\t\t`Operator \"${operator}\" is not supported for ${columnType} field \"${field}\".`,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn errors;\n}\n"
8
8
  ],
9
- "mappings": ";;;;;;;;;;;;;;;;;AAAA,2BAAS;AACT;AAEA,IAAM,iBAAiB;AAGvB,IAAM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,EACjC,IAAI,CAAC,OAAO;AAAA,IACX,MAAM,QAAQ,OAAO,KAAK,MAAM,MAAM;AAAA,IACtC,OAAO,KACN,kBAAkB,MAAM,aACvB,MAAM,eAAe,iBAAiB,MAAM,kBAAkB,MAC3D,MAAM,SAAS,IAAI,sBAAsB,MAAM,KAAK,IAAI,OAAO,IACpE;AAAA,IACA,OAAO;AAAA,EACR;AAAA,EAEA,IAAI,MAAM,WAAW;AAAA,IAAW,OAAO;AAAA,EAEvC,MAAM,SAAS,yBAAyB,UAAU,MAAM,MAAM;AAAA,EAC9D,IAAI,CAAC,OAAO,SAAS;AAAA,IACpB,OAAO,+BAA+B,OAAO,KAAK;AAAA,EACnD;AAAA,EAEA,YAAY,OAAO,WAAW,OAAO,QAAQ,OAAO,IAAI,GAAG;AAAA,IAC1D,MAAM,SAAS,MAAM,QAAQ;AAAA,IAC7B,IAAI,CAAC,QAAQ;AAAA,MACZ,OAAO,KACN,yBAAyB,oBAAoB,MAAM,aACpD;AAAA,MACA;AAAA,IACD;AAAA,IAEA,MAAM,aACL,OAAO,OAAO,SAAS,WAAW,OAAO,KAAK,YAAY,IAAI;AAAA,IAC/D,IAAI,CAAC,oBAAoB,IAAI,UAAU,GAAG;AAAA,MACzC,OAAO,KACN,iBAAiB,gCAAgC,cAAc,0DAChE;AAAA,MACA;AAAA,IACD;AAAA,IAEA,MAAM,WAAW,kBAAkB,MAAM;AAAA,IACzC,KACE,aAAa,QACb,aAAa,SACb,aAAa,QACb,aAAa,UACd,CAAC,wBAAwB,IAAI,UAAU,GACtC;AAAA,MACD,OAAO,KACN,aAAa,kCAAkC,qBAAqB,SACrE;AAAA,IACD;AAAA,EACD;AAAA,EAEA,OAAO;AAAA;",
10
+ "debugId": "F665E4F1EA910F7E64756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -18,12 +18,20 @@ interface DeploySubgraphRequest {
18
18
  databaseUrl?: string;
19
19
  /** Validate the connection + print the DDL/grant plan without deploying. */
20
20
  dryRun?: boolean;
21
+ /**
22
+ * Read visibility. Server-side defaults: managed deploys → public (anon
23
+ * reads on /v1/subgraphs, name claimed in the global public namespace);
24
+ * BYO-database deploys → private (public reads hit the user's own
25
+ * Postgres, so going public is an explicit choice).
26
+ */
27
+ visibility?: "public" | "private";
21
28
  }
22
29
  declare const DeploySubgraphRequestSchema: z.ZodType<DeploySubgraphRequest>;
23
30
  interface DeploySubgraphResponse {
24
31
  action: "created" | "unchanged" | "handler_updated" | "updated" | "reindexed";
25
32
  subgraphId: string;
26
33
  version: string;
34
+ visibility?: "public" | "private";
27
35
  message: string;
28
36
  operationId?: string;
29
37
  reindexStarted?: boolean;
@@ -51,6 +59,7 @@ interface SubgraphSummary {
51
59
  resourceWarning?: SubgraphResourceWarning;
52
60
  gapCount: number;
53
61
  integrity: "complete" | "gaps_detected";
62
+ visibility?: "public" | "private";
54
63
  createdAt: string;
55
64
  }
56
65
  interface SubgraphGapRange {
@@ -96,6 +105,7 @@ interface SubgraphDetail {
96
105
  version: string;
97
106
  schemaHash?: string;
98
107
  status: string;
108
+ visibility?: "public" | "private";
99
109
  lastProcessedBlock: number;
100
110
  description?: string;
101
111
  sources?: Record<string, unknown>;
@@ -26,11 +26,12 @@ var DeploySubgraphRequestSchema = z.object({
26
26
  startBlock: z.number().int().nonnegative().optional(),
27
27
  sourceCode: z.string().max(1048576, "source code exceeds 1MB limit").optional(),
28
28
  databaseUrl: z.string().url().refine((u) => u.startsWith("postgres://") || u.startsWith("postgresql://"), "must be a postgres:// connection string").optional(),
29
- dryRun: z.boolean().optional()
29
+ dryRun: z.boolean().optional(),
30
+ visibility: z.enum(["public", "private"]).optional()
30
31
  });
31
32
  export {
32
33
  DeploySubgraphRequestSchema
33
34
  };
34
35
 
35
- //# debugId=914B1C03F7A3693864756E2164756E21
36
+ //# debugId=53B5E18D3DA61A3D64756E2164756E21
36
37
  //# sourceMappingURL=subgraphs.js.map