@secondlayer/shared 6.33.3 → 6.35.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.
@@ -196,7 +196,11 @@ var CHAIN_TRIGGER_TYPES = [
196
196
  "nft_burn",
197
197
  "contract_call",
198
198
  "contract_deploy",
199
- "print_event"
199
+ "print_event",
200
+ "sbtc_deposit",
201
+ "sbtc_withdrawal_create",
202
+ "sbtc_withdrawal_accept",
203
+ "sbtc_withdrawal_reject"
200
204
  ];
201
205
  var triggerAmount = z3.union([
202
206
  z3.string().trim().regex(/^\d+$/, "must be a non-negative integer string"),
@@ -285,6 +289,30 @@ var ChainTriggerSchema = z3.discriminatedUnion("type", [
285
289
  contractId: triggerPattern.optional(),
286
290
  topic: triggerPattern.optional(),
287
291
  trait: trait.optional()
292
+ }).strict(),
293
+ z3.object({
294
+ type: z3.literal("sbtc_deposit"),
295
+ sender: triggerPattern.optional(),
296
+ minAmount: triggerAmount.optional(),
297
+ maxAmount: triggerAmount.optional(),
298
+ bitcoinTxid: triggerPattern.optional(),
299
+ requestId: z3.number().int().nonnegative().optional()
300
+ }).strict(),
301
+ z3.object({
302
+ type: z3.literal("sbtc_withdrawal_create"),
303
+ sender: triggerPattern.optional(),
304
+ minAmount: triggerAmount.optional(),
305
+ maxAmount: triggerAmount.optional(),
306
+ requestId: z3.number().int().nonnegative().optional()
307
+ }).strict(),
308
+ z3.object({
309
+ type: z3.literal("sbtc_withdrawal_accept"),
310
+ requestId: z3.number().int().nonnegative().optional(),
311
+ sweepTxid: triggerPattern.optional()
312
+ }).strict(),
313
+ z3.object({
314
+ type: z3.literal("sbtc_withdrawal_reject"),
315
+ requestId: z3.number().int().nonnegative().optional()
288
316
  }).strict()
289
317
  ]);
290
318
  var ChainTriggersSchema = z3.array(ChainTriggerSchema).min(1).max(50);
@@ -393,6 +421,22 @@ var trigger = {
393
421
  printEvent: (f = {}) => ({
394
422
  type: "print_event",
395
423
  ...f
424
+ }),
425
+ sbtcDeposit: (f = {}) => ({
426
+ type: "sbtc_deposit",
427
+ ...f
428
+ }),
429
+ sbtcWithdrawalCreate: (f = {}) => ({
430
+ type: "sbtc_withdrawal_create",
431
+ ...f
432
+ }),
433
+ sbtcWithdrawalAccept: (f = {}) => ({
434
+ type: "sbtc_withdrawal_accept",
435
+ ...f
436
+ }),
437
+ sbtcWithdrawalReject: (f = {}) => ({
438
+ type: "sbtc_withdrawal_reject",
439
+ ...f
396
440
  })
397
441
  };
398
442
  var SCALAR_COLUMN_TYPES = new Set([
@@ -484,5 +528,5 @@ export {
484
528
  CHAIN_TRIGGER_FIELDS
485
529
  };
486
530
 
487
- //# debugId=F665E4F1EA910F7E64756E2164756E21
531
+ //# debugId=22D096AD79F5539A64756E2164756E21
488
532
  //# 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\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\t/** Effective indexing start height after plan policy. */\n\tstart_block?: number;\n\t/** True when the free-tier forward-only policy adjusted the start. */\n\tstart_block_clamped?: boolean;\n\toperationId?: string;\n\treindexStarted?: boolean;\n\t/** Non-blocking deploy lints (e.g. handler reads a print field never observed on-chain). */\n\twarnings?: string[];\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\t/** history_filling = expected gaps while a tip-first backfill op runs. */\n\tintegrity: \"complete\" | \"gaps_detected\" | \"history_filling\";\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\t/** Present while the populating operation is queued: approximate claim\n\t * position + honest event denominator + naive start estimate. */\n\tqueue?: {\n\t\tposition: number | null;\n\t\testimatedEvents: number | null;\n\t\testimatedStartSeconds: number | null;\n\t};\n\t/** Event-based progress for sparse syncs (block pct is meaningless when\n\t * most heights are skipped). */\n\testimatedEvents?: number;\n\tprocessedEvents?: number;\n\tetaSeconds?: number | null;\n\tresourceWarning?: SubgraphResourceWarning;\n\tgaps: {\n\t\tcount: number;\n\t\ttotalMissingBlocks: number;\n\t\tranges: SubgraphGapRange[];\n\t};\n\t/** history_filling = expected gaps while a tip-first backfill op runs. */\n\tintegrity: \"complete\" | \"gaps_detected\" | \"history_filling\";\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
- "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"
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\t/** Effective indexing start height after plan policy. */\n\tstart_block?: number;\n\t/** True when the free-tier forward-only policy adjusted the start. */\n\tstart_block_clamped?: boolean;\n\toperationId?: string;\n\treindexStarted?: boolean;\n\t/** Non-blocking deploy lints (e.g. handler reads a print field never observed on-chain). */\n\twarnings?: string[];\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\ttotalRows?: 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\t/** history_filling = expected gaps while a tip-first backfill op runs. */\n\tintegrity: \"complete\" | \"gaps_detected\" | \"history_filling\";\n\tvisibility?: \"public\" | \"private\";\n\t/** Most recent indexing error reason + when it occurred, if any. */\n\tlastError?: string | null;\n\tlastErrorAt?: string | null;\n\t/** Last row mutation timestamp; powers per-card freshness. */\n\tupdatedAt?: string | null;\n\t/** Number of subscriptions attached to this subgraph. */\n\tsubscriptionCount?: number;\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\t/** Present while the populating operation is queued: approximate claim\n\t * position + honest event denominator + naive start estimate. */\n\tqueue?: {\n\t\tposition: number | null;\n\t\testimatedEvents: number | null;\n\t\testimatedStartSeconds: number | null;\n\t};\n\t/** Event-based progress for sparse syncs (block pct is meaningless when\n\t * most heights are skipped). */\n\testimatedEvents?: number;\n\tprocessedEvents?: number;\n\tetaSeconds?: number | null;\n\tresourceWarning?: SubgraphResourceWarning;\n\tgaps: {\n\t\tcount: number;\n\t\ttotalMissingBlocks: number;\n\t\tranges: SubgraphGapRange[];\n\t};\n\t/** history_filling = expected gaps while a tip-first backfill op runs. */\n\tintegrity: \"complete\" | \"gaps_detected\" | \"history_filling\";\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
+ "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\t\"sbtc_deposit\",\n\t\"sbtc_withdrawal_create\",\n\t\"sbtc_withdrawal_accept\",\n\t\"sbtc_withdrawal_reject\",\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\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_deposit\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t\tbitcoinTxid: triggerPattern.optional(),\n\t\t\t\trequestId: z.number().int().nonnegative().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(\"sbtc_withdrawal_create\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t\trequestId: z.number().int().nonnegative().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(\"sbtc_withdrawal_accept\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t\tsweepTxid: 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(\"sbtc_withdrawal_reject\"),\n\t\t\t\trequestId: z.number().int().nonnegative().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\t| {\n\t\t\ttype: \"sbtc_deposit\";\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t\t\tbitcoinTxid?: string;\n\t\t\trequestId?: number;\n\t }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_create\";\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t\t\trequestId?: number;\n\t }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_accept\";\n\t\t\trequestId?: number;\n\t\t\tsweepTxid?: string;\n\t }\n\t| { type: \"sbtc_withdrawal_reject\"; requestId?: number };\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\tsbtcDeposit: (f: TriggerArgs<\"sbtc_deposit\"> = {}): ChainTrigger => ({\n\t\ttype: \"sbtc_deposit\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalCreate: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_create\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_create\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalAccept: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_accept\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_accept\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalReject: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_reject\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_reject\",\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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@@ interface SubgraphSummary {
54
54
  status: string;
55
55
  lastProcessedBlock: number;
56
56
  totalProcessed: number;
57
+ totalRows?: number;
57
58
  totalErrors: number;
58
59
  tables: string[];
59
60
  chainTip: number;
@@ -67,6 +68,13 @@ interface SubgraphSummary {
67
68
  /** history_filling = expected gaps while a tip-first backfill op runs. */
68
69
  integrity: "complete" | "gaps_detected" | "history_filling";
69
70
  visibility?: "public" | "private";
71
+ /** Most recent indexing error reason + when it occurred, if any. */
72
+ lastError?: string | null;
73
+ lastErrorAt?: string | null;
74
+ /** Last row mutation timestamp; powers per-card freshness. */
75
+ updatedAt?: string | null;
76
+ /** Number of subscriptions attached to this subgraph. */
77
+ subscriptionCount?: number;
70
78
  createdAt: string;
71
79
  }
72
80
  interface SubgraphGapRange {
@@ -2,7 +2,7 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/schemas/subgraphs.ts"],
4
4
  "sourcesContent": [
5
- "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\t/** Effective indexing start height after plan policy. */\n\tstart_block?: number;\n\t/** True when the free-tier forward-only policy adjusted the start. */\n\tstart_block_clamped?: boolean;\n\toperationId?: string;\n\treindexStarted?: boolean;\n\t/** Non-blocking deploy lints (e.g. handler reads a print field never observed on-chain). */\n\twarnings?: string[];\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\t/** history_filling = expected gaps while a tip-first backfill op runs. */\n\tintegrity: \"complete\" | \"gaps_detected\" | \"history_filling\";\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\t/** Present while the populating operation is queued: approximate claim\n\t * position + honest event denominator + naive start estimate. */\n\tqueue?: {\n\t\tposition: number | null;\n\t\testimatedEvents: number | null;\n\t\testimatedStartSeconds: number | null;\n\t};\n\t/** Event-based progress for sparse syncs (block pct is meaningless when\n\t * most heights are skipped). */\n\testimatedEvents?: number;\n\tprocessedEvents?: number;\n\tetaSeconds?: number | null;\n\tresourceWarning?: SubgraphResourceWarning;\n\tgaps: {\n\t\tcount: number;\n\t\ttotalMissingBlocks: number;\n\t\tranges: SubgraphGapRange[];\n\t};\n\t/** history_filling = expected gaps while a tip-first backfill op runs. */\n\tintegrity: \"complete\" | \"gaps_detected\" | \"history_filling\";\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"
5
+ "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\t/** Effective indexing start height after plan policy. */\n\tstart_block?: number;\n\t/** True when the free-tier forward-only policy adjusted the start. */\n\tstart_block_clamped?: boolean;\n\toperationId?: string;\n\treindexStarted?: boolean;\n\t/** Non-blocking deploy lints (e.g. handler reads a print field never observed on-chain). */\n\twarnings?: string[];\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\ttotalRows?: 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\t/** history_filling = expected gaps while a tip-first backfill op runs. */\n\tintegrity: \"complete\" | \"gaps_detected\" | \"history_filling\";\n\tvisibility?: \"public\" | \"private\";\n\t/** Most recent indexing error reason + when it occurred, if any. */\n\tlastError?: string | null;\n\tlastErrorAt?: string | null;\n\t/** Last row mutation timestamp; powers per-card freshness. */\n\tupdatedAt?: string | null;\n\t/** Number of subscriptions attached to this subgraph. */\n\tsubscriptionCount?: number;\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\t/** Present while the populating operation is queued: approximate claim\n\t * position + honest event denominator + naive start estimate. */\n\tqueue?: {\n\t\tposition: number | null;\n\t\testimatedEvents: number | null;\n\t\testimatedStartSeconds: number | null;\n\t};\n\t/** Event-based progress for sparse syncs (block pct is meaningless when\n\t * most heights are skipped). */\n\testimatedEvents?: number;\n\tprocessedEvents?: number;\n\tetaSeconds?: number | null;\n\tresourceWarning?: SubgraphResourceWarning;\n\tgaps: {\n\t\tcount: number;\n\t\ttotalMissingBlocks: number;\n\t\tranges: SubgraphGapRange[];\n\t};\n\t/** history_filling = expected gaps while a tip-first backfill op runs. */\n\tintegrity: \"complete\" | \"gaps_detected\" | \"history_filling\";\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"
6
6
  ],
7
7
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAgCO,IAAM,8BACZ,EAAE,OAAO;AAAA,EACR,MAAM,EACJ,OAAO,EACP,MAAM,gBAAgB,uCAAuC,EAC7D,IAAI,EAAE;AAAA,EACR,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,SAAS,EACP,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,EACpD,OACA,CAAC,MAAM,OAAO,KAAK,CAAC,EAAE,SAAS,GAC/B,+BACD;AAAA,EACD,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;AAAA,EACxC,aAAa,EAAE,OAAO,EAAE,IAAI,SAAW,gCAAgC;AAAA,EACvE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS;AAAA,EACpD,YAAY,EACV,OAAO,EACP,IAAI,SAAW,+BAA+B,EAC9C,SAAS;AAAA,EACX,aAAa,EACX,OAAO,EACP,IAAI,EACJ,OACA,CAAC,MAAM,EAAE,WAAW,aAAa,KAAK,EAAE,WAAW,eAAe,GAClE,yCACD,EACC,SAAS;AAAA,EACX,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC7B,YAAY,EAAE,KAAK,CAAC,UAAU,SAAS,CAAC,EAAE,SAAS;AACpD,CAAC;",
8
8
  "debugId": "53B5E18D3DA61A3D64756E2164756E21",
@@ -10,7 +10,7 @@ declare const SubscriptionFilterPrimitiveSchema: z.ZodType<SubscriptionFilterPri
10
10
  declare const SubscriptionFilterOperatorSchema: z.ZodType<SubscriptionFilterOperator>;
11
11
  declare const SubscriptionFilterClauseSchema: z.ZodType<SubscriptionFilterClause>;
12
12
  declare const SubscriptionFilterSchema: z.ZodType<SubscriptionFilter>;
13
- declare const CHAIN_TRIGGER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "contract_call", "contract_deploy", "print_event"];
13
+ declare const CHAIN_TRIGGER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "contract_call", "contract_deploy", "print_event", "sbtc_deposit", "sbtc_withdrawal_create", "sbtc_withdrawal_accept", "sbtc_withdrawal_reject"];
14
14
  declare const ChainTriggerSchema: z.ZodType<ChainTrigger>;
15
15
  declare const ChainTriggersSchema: z.ZodType<ChainTrigger[]>;
16
16
  /**
@@ -112,7 +112,27 @@ type ChainTrigger = {
112
112
  type: "print_event"
113
113
  contractId?: string
114
114
  topic?: string
115
- } & TraitScoped);
115
+ } & TraitScoped) | {
116
+ type: "sbtc_deposit"
117
+ sender?: string
118
+ minAmount?: ChainTriggerAmount
119
+ maxAmount?: ChainTriggerAmount
120
+ bitcoinTxid?: string
121
+ requestId?: number
122
+ } | {
123
+ type: "sbtc_withdrawal_create"
124
+ sender?: string
125
+ minAmount?: ChainTriggerAmount
126
+ maxAmount?: ChainTriggerAmount
127
+ requestId?: number
128
+ } | {
129
+ type: "sbtc_withdrawal_accept"
130
+ requestId?: number
131
+ sweepTxid?: string
132
+ } | {
133
+ type: "sbtc_withdrawal_reject"
134
+ requestId?: number
135
+ };
116
136
  /** Args for a chain-trigger builder — every field of a variant except `type`. */
117
137
  type TriggerArgs<T extends ChainTrigger["type"]> = Omit<Extract<ChainTrigger, {
118
138
  type: T
@@ -142,6 +162,10 @@ declare const trigger: {
142
162
  readonly contractCall: (f?: TriggerArgs<"contract_call">) => ChainTrigger
143
163
  readonly contractDeploy: (f?: TriggerArgs<"contract_deploy">) => ChainTrigger
144
164
  readonly printEvent: (f?: TriggerArgs<"print_event">) => ChainTrigger
165
+ readonly sbtcDeposit: (f?: TriggerArgs<"sbtc_deposit">) => ChainTrigger
166
+ readonly sbtcWithdrawalCreate: (f?: TriggerArgs<"sbtc_withdrawal_create">) => ChainTrigger
167
+ readonly sbtcWithdrawalAccept: (f?: TriggerArgs<"sbtc_withdrawal_accept">) => ChainTrigger
168
+ readonly sbtcWithdrawalReject: (f?: TriggerArgs<"sbtc_withdrawal_reject">) => ChainTrigger
145
169
  };
146
170
  interface CreateSubscriptionRequest {
147
171
  name: string;
@@ -76,7 +76,11 @@ var CHAIN_TRIGGER_TYPES = [
76
76
  "nft_burn",
77
77
  "contract_call",
78
78
  "contract_deploy",
79
- "print_event"
79
+ "print_event",
80
+ "sbtc_deposit",
81
+ "sbtc_withdrawal_create",
82
+ "sbtc_withdrawal_accept",
83
+ "sbtc_withdrawal_reject"
80
84
  ];
81
85
  var triggerAmount = z.union([
82
86
  z.string().trim().regex(/^\d+$/, "must be a non-negative integer string"),
@@ -165,6 +169,30 @@ var ChainTriggerSchema = z.discriminatedUnion("type", [
165
169
  contractId: triggerPattern.optional(),
166
170
  topic: triggerPattern.optional(),
167
171
  trait: trait.optional()
172
+ }).strict(),
173
+ z.object({
174
+ type: z.literal("sbtc_deposit"),
175
+ sender: triggerPattern.optional(),
176
+ minAmount: triggerAmount.optional(),
177
+ maxAmount: triggerAmount.optional(),
178
+ bitcoinTxid: triggerPattern.optional(),
179
+ requestId: z.number().int().nonnegative().optional()
180
+ }).strict(),
181
+ z.object({
182
+ type: z.literal("sbtc_withdrawal_create"),
183
+ sender: triggerPattern.optional(),
184
+ minAmount: triggerAmount.optional(),
185
+ maxAmount: triggerAmount.optional(),
186
+ requestId: z.number().int().nonnegative().optional()
187
+ }).strict(),
188
+ z.object({
189
+ type: z.literal("sbtc_withdrawal_accept"),
190
+ requestId: z.number().int().nonnegative().optional(),
191
+ sweepTxid: triggerPattern.optional()
192
+ }).strict(),
193
+ z.object({
194
+ type: z.literal("sbtc_withdrawal_reject"),
195
+ requestId: z.number().int().nonnegative().optional()
168
196
  }).strict()
169
197
  ]);
170
198
  var ChainTriggersSchema = z.array(ChainTriggerSchema).min(1).max(50);
@@ -273,6 +301,22 @@ var trigger = {
273
301
  printEvent: (f = {}) => ({
274
302
  type: "print_event",
275
303
  ...f
304
+ }),
305
+ sbtcDeposit: (f = {}) => ({
306
+ type: "sbtc_deposit",
307
+ ...f
308
+ }),
309
+ sbtcWithdrawalCreate: (f = {}) => ({
310
+ type: "sbtc_withdrawal_create",
311
+ ...f
312
+ }),
313
+ sbtcWithdrawalAccept: (f = {}) => ({
314
+ type: "sbtc_withdrawal_accept",
315
+ ...f
316
+ }),
317
+ sbtcWithdrawalReject: (f = {}) => ({
318
+ type: "sbtc_withdrawal_reject",
319
+ ...f
276
320
  })
277
321
  };
278
322
  var SCALAR_COLUMN_TYPES = new Set([
@@ -352,5 +396,5 @@ export {
352
396
  CHAIN_TRIGGER_FIELDS
353
397
  };
354
398
 
355
- //# debugId=2BF3213BC57C9A8864756E2164756E21
399
+ //# debugId=7157A4AE0CB7FAC164756E2164756E21
356
400
  //# sourceMappingURL=subscriptions.js.map