@secondlayer/shared 11.4.2 → 11.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +4 -4
  2. package/dist/src/archive/derived-stage-report.d.ts +2 -2
  3. package/dist/src/archive/derived-stage-report.js.map +1 -1
  4. package/dist/src/archive/instance-diagnosis.js +2 -2
  5. package/dist/src/archive/instance-diagnosis.js.map +2 -2
  6. package/dist/src/archive/range-digest.d.ts +25 -25
  7. package/dist/src/archive/semantic-digest-builder.d.ts +25 -25
  8. package/dist/src/archive/status.d.ts +32 -7
  9. package/dist/src/archive/status.js +20 -3
  10. package/dist/src/archive/status.js.map +3 -3
  11. package/dist/src/coverage/index.d.ts +25 -25
  12. package/dist/src/coverage/index.js.map +1 -1
  13. package/dist/src/crypto/secondlayer-webhook.d.ts +2 -2
  14. package/dist/src/crypto/secondlayer-webhook.js.map +1 -1
  15. package/dist/src/crypto/secrets.js.map +1 -1
  16. package/dist/src/db/index.d.ts +37 -37
  17. package/dist/src/db/index.js +4 -4
  18. package/dist/src/db/index.js.map +3 -3
  19. package/dist/src/db/queries/chain-reorgs.d.ts +25 -25
  20. package/dist/src/db/queries/chain-reorgs.js +4 -4
  21. package/dist/src/db/queries/chain-reorgs.js.map +3 -3
  22. package/dist/src/db/queries/contracts.d.ts +25 -25
  23. package/dist/src/db/queries/instance.d.ts +25 -25
  24. package/dist/src/db/queries/integrity.d.ts +25 -25
  25. package/dist/src/db/queries/subgraph-gaps.d.ts +25 -25
  26. package/dist/src/db/queries/subgraph-operations.d.ts +25 -25
  27. package/dist/src/db/queries/subgraphs.d.ts +25 -25
  28. package/dist/src/db/queries/subgraphs.js +4 -4
  29. package/dist/src/db/queries/subgraphs.js.map +3 -3
  30. package/dist/src/db/queries/sync-scope.d.ts +25 -25
  31. package/dist/src/db/queries/{subscriptions.d.ts → webhooks.d.ts} +58 -58
  32. package/dist/src/db/queries/{subscriptions.js → webhooks.js} +38 -38
  33. package/dist/src/db/queries/webhooks.js.map +13 -0
  34. package/dist/src/db/schema.d.ts +34 -34
  35. package/dist/src/index.d.ts +109 -107
  36. package/dist/src/index.js +51 -54
  37. package/dist/src/index.js.map +6 -6
  38. package/dist/src/leader.d.ts +4 -4
  39. package/dist/src/leader.js +3 -3
  40. package/dist/src/leader.js.map +3 -3
  41. package/dist/src/node/local-client.d.ts +25 -25
  42. package/dist/src/queue/listener.d.ts +2 -2
  43. package/dist/src/queue/listener.js.map +1 -1
  44. package/dist/src/runtime/index.js +2 -6
  45. package/dist/src/runtime/index.js.map +4 -4
  46. package/dist/src/schemas/index.d.ts +61 -61
  47. package/dist/src/schemas/index.js +48 -51
  48. package/dist/src/schemas/index.js.map +5 -5
  49. package/dist/src/schemas/subgraphs.d.ts +2 -2
  50. package/dist/src/schemas/subgraphs.js.map +1 -1
  51. package/dist/src/schemas/{subscriptions.d.ts → webhooks.d.ts} +63 -63
  52. package/dist/src/schemas/{subscriptions.js → webhooks.js} +49 -52
  53. package/dist/src/schemas/webhooks.js.map +10 -0
  54. package/migrations/0126_rename_subscriptions_to_webhooks.ts +96 -0
  55. package/migrations/0127_rename_webhook_catalog_names.ts +55 -0
  56. package/package.json +8 -8
  57. package/dist/src/db/queries/subscriptions.js.map +0 -13
  58. package/dist/src/schemas/subscriptions.js.map +0 -10
@@ -788,9 +788,9 @@ interface Database {
788
788
  account_spend_caps: AccountSpendCapsTable;
789
789
  account_credits: AccountCreditsTable;
790
790
  hosted_meter_days: HostedMeterDaysTable;
791
- subscriptions: SubscriptionsTable;
792
- subscription_outbox: SubscriptionOutboxTable;
793
- subscription_deliveries: SubscriptionDeliveriesTable;
791
+ webhooks: WebhooksTable;
792
+ webhook_outbox: WebhookOutboxTable;
793
+ webhook_deliveries: WebhookDeliveriesTable;
794
794
  trigger_evaluator_state: TriggerEvaluatorStateTable;
795
795
  decoded_events: DecodedEventsTable;
796
796
  decoder_checkpoints: DecoderCheckpointsTable;
@@ -963,31 +963,31 @@ type SubgraphHealthSnapshot = Selectable<SubgraphHealthSnapshotsTable>;
963
963
  type InsertSubgraphHealthSnapshot = Insertable<SubgraphHealthSnapshotsTable>;
964
964
  type SubgraphGap = Selectable<SubgraphGapsTable>;
965
965
  type InsertSubgraphGap = Insertable<SubgraphGapsTable>;
966
- type SubscriptionStatus = "active" | "paused" | "error";
967
- /** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
966
+ type WebhookStatus = "active" | "paused" | "error";
967
+ /** Polymorphic webhook mode: `subgraph` reacts to processed table rows;
968
968
  * `chain` reacts to raw chain events matched directly off the Index/Streams
969
969
  * clock (no subgraph). See migration 0088. */
970
- type SubscriptionKind = "subgraph" | "chain";
971
- type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
972
- type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
973
- interface SubscriptionsTable {
970
+ type WebhookKind = "subgraph" | "chain";
971
+ type WebhookFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
972
+ type WebhookRuntime = "inngest" | "trigger" | "cloudflare" | "node";
973
+ interface WebhooksTable {
974
974
  id: Generated<string>;
975
975
  account_id: string;
976
976
  project_id: string | null;
977
977
  name: string;
978
- status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
979
- kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
980
- /** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
978
+ status: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;
979
+ kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
980
+ /** Null for chain webhooks (CHECK webhooks_kind_shape). */
981
981
  subgraph_name: string | null;
982
- /** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
982
+ /** Null for chain webhooks (CHECK webhooks_kind_shape). */
983
983
  table_name: string | null;
984
984
  /** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
985
- * subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
986
- * import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
985
+ * subgraph webhooks. Typed loosely here to avoid a shared→subgraphs
986
+ * import cycle; the Zod schema in schemas/webhooks.ts owns the shape. */
987
987
  triggers: unknown | null;
988
988
  filter: Generated<unknown>;
989
- format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
990
- runtime: SubscriptionRuntime | null;
989
+ format: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;
990
+ runtime: WebhookRuntime | null;
991
991
  url: string;
992
992
  signing_secret_enc: Buffer;
993
993
  auth_config: Generated<unknown>;
@@ -1002,17 +1002,17 @@ interface SubscriptionsTable {
1002
1002
  created_at: Generated<Date>;
1003
1003
  updated_at: Generated<Date>;
1004
1004
  }
1005
- type Subscription = Selectable<SubscriptionsTable>;
1006
- type InsertSubscription = Insertable<SubscriptionsTable>;
1007
- type UpdateSubscription = Updateable<SubscriptionsTable>;
1005
+ type Webhook = Selectable<WebhooksTable>;
1006
+ type InsertWebhook = Insertable<WebhooksTable>;
1007
+ type UpdateWebhook = Updateable<WebhooksTable>;
1008
1008
  type OutboxStatus = "pending" | "delivered" | "dead";
1009
- interface SubscriptionOutboxTable {
1009
+ interface WebhookOutboxTable {
1010
1010
  id: Generated<string>;
1011
- subscription_id: string;
1012
- kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
1013
- /** Null for chain-subscription rows. */
1011
+ webhook_id: string;
1012
+ kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
1013
+ /** Null for chain-webhook rows. */
1014
1014
  subgraph_name: string | null;
1015
- /** Null for chain-subscription rows. */
1015
+ /** Null for chain-webhook rows. */
1016
1016
  table_name: string | null;
1017
1017
  block_height: number | bigint;
1018
1018
  tx_id: string | null;
@@ -1030,15 +1030,15 @@ interface SubscriptionOutboxTable {
1030
1030
  locked_until: Date | null;
1031
1031
  created_at: Generated<Date>;
1032
1032
  }
1033
- type SubscriptionOutbox = Selectable<SubscriptionOutboxTable>;
1034
- type InsertSubscriptionOutbox = Insertable<SubscriptionOutboxTable>;
1035
- type UpdateSubscriptionOutbox = Updateable<SubscriptionOutboxTable>;
1036
- interface SubscriptionDeliveriesTable {
1033
+ type WebhookOutbox = Selectable<WebhookOutboxTable>;
1034
+ type InsertWebhookOutbox = Insertable<WebhookOutboxTable>;
1035
+ type UpdateWebhookOutbox = Updateable<WebhookOutboxTable>;
1036
+ interface WebhookDeliveriesTable {
1037
1037
  id: Generated<string>;
1038
1038
  /** Nullable after migration 0077 — outbox row may be cleaned up while
1039
1039
  * delivery telemetry is retained. */
1040
1040
  outbox_id: string | null;
1041
- subscription_id: string;
1041
+ webhook_id: string;
1042
1042
  attempt: number;
1043
1043
  status_code: number | null;
1044
1044
  response_headers: unknown | null;
@@ -1047,10 +1047,10 @@ interface SubscriptionDeliveriesTable {
1047
1047
  duration_ms: number | null;
1048
1048
  dispatched_at: Generated<Date>;
1049
1049
  }
1050
- type SubscriptionDelivery = Selectable<SubscriptionDeliveriesTable>;
1051
- type InsertSubscriptionDelivery = Insertable<SubscriptionDeliveriesTable>;
1050
+ type WebhookDelivery = Selectable<WebhookDeliveriesTable>;
1051
+ type InsertWebhookDelivery = Insertable<WebhookDeliveriesTable>;
1052
1052
  /** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
1053
- * One loop serves all chain subscriptions, so the cursor is global. */
1053
+ * One loop serves all chain webhooks, so the cursor is global. */
1054
1054
  interface TriggerEvaluatorStateTable {
1055
1055
  id: Generated<boolean>;
1056
1056
  last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
@@ -2046,9 +2046,9 @@ declare const TABLE_TO_DB: {
2046
2046
  play_provisions: string
2047
2047
  account_spend_caps: string
2048
2048
  processed_stripe_events: string
2049
- subscriptions: string
2050
- subscription_outbox: string
2051
- subscription_deliveries: string
2049
+ webhooks: string
2050
+ webhook_outbox: string
2051
+ webhook_deliveries: string
2052
2052
  trigger_evaluator_state: string
2053
2053
  subgraphs: string
2054
2054
  subgraph_operations: string
@@ -2289,8 +2289,8 @@ interface SubgraphSummary {
2289
2289
  lastErrorAt?: string | null;
2290
2290
  /** Last row mutation timestamp; powers per-card freshness. */
2291
2291
  updatedAt?: string | null;
2292
- /** Number of subscriptions attached to this subgraph. */
2293
- subscriptionCount?: number;
2292
+ /** Number of webhooks attached to this subgraph. */
2293
+ webhookCount?: number;
2294
2294
  createdAt: string;
2295
2295
  }
2296
2296
  interface SubgraphGapRange {
@@ -2431,17 +2431,17 @@ interface SubgraphAggregateResponse {
2431
2431
  max?: Record<string, string | null>;
2432
2432
  }
2433
2433
  import { z as z3 } from "zod";
2434
- declare const SUBSCRIPTION_FORMATS: readonly ["standard-webhooks", "inngest", "trigger", "cloudflare", "cloudevents", "raw"];
2435
- declare const SUBSCRIPTION_RUNTIMES: readonly ["inngest", "trigger", "cloudflare", "node"];
2436
- declare const SUBSCRIPTION_STATUSES: readonly ["active", "paused", "error"];
2437
- declare const SUBSCRIPTION_FILTER_OPERATORS: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "in"];
2438
- declare const SubscriptionStatusSchema: z3.ZodType<SubscriptionStatus2>;
2439
- declare const SubscriptionFormatSchema: z3.ZodType<SubscriptionFormat2>;
2440
- declare const SubscriptionRuntimeSchema: z3.ZodType<SubscriptionRuntime2>;
2441
- declare const SubscriptionFilterPrimitiveSchema: z3.ZodType<SubscriptionFilterPrimitive>;
2442
- declare const SubscriptionFilterOperatorSchema: z3.ZodType<SubscriptionFilterOperator>;
2443
- declare const SubscriptionFilterClauseSchema: z3.ZodType<SubscriptionFilterClause>;
2444
- declare const SubscriptionFilterSchema: z3.ZodType<SubscriptionFilter>;
2434
+ declare const WEBHOOK_FORMATS: readonly ["standard-webhooks", "inngest", "trigger", "cloudflare", "cloudevents", "raw"];
2435
+ declare const WEBHOOK_RUNTIMES: readonly ["inngest", "trigger", "cloudflare", "node"];
2436
+ declare const WEBHOOK_STATUSES: readonly ["active", "paused", "error"];
2437
+ declare const WEBHOOK_FILTER_OPERATORS: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "in"];
2438
+ declare const WebhookStatusSchema: z3.ZodType<WebhookStatus2>;
2439
+ declare const WebhookFormatSchema: z3.ZodType<WebhookFormat2>;
2440
+ declare const WebhookRuntimeSchema: z3.ZodType<WebhookRuntime2>;
2441
+ declare const WebhookFilterPrimitiveSchema: z3.ZodType<WebhookFilterPrimitive>;
2442
+ declare const WebhookFilterOperatorSchema: z3.ZodType<WebhookFilterOperator>;
2443
+ declare const WebhookFilterClauseSchema: z3.ZodType<WebhookFilterClause>;
2444
+ declare const WebhookFilterSchema: z3.ZodType<WebhookFilter>;
2445
2445
  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", "sbtc_withdrawal_swept_confirmed"];
2446
2446
  /**
2447
2447
  * Per-type accepted filter fields for chain triggers, DERIVED from
@@ -2449,19 +2449,19 @@ declare const CHAIN_TRIGGER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_bu
2449
2449
  * the validator. `{ stx_transfer: ["sender","recipient","minAmount","maxAmount"], ... }`.
2450
2450
  */
2451
2451
  declare const CHAIN_TRIGGER_FIELDS: Record<string, string[]>;
2452
- declare const CreateSubscriptionRequestSchema: z3.ZodType<ParsedCreateSubscriptionRequest>;
2453
- declare const UpdateSubscriptionRequestSchema: z3.ZodType<UpdateSubscriptionRequest>;
2454
- declare const ReplaySubscriptionRequestSchema: z3.ZodType<ReplaySubscriptionRequest>;
2455
- type SubscriptionStatus2 = (typeof SUBSCRIPTION_STATUSES)[number];
2456
- /** Polymorphic subscription mode (mirrors db/types `SubscriptionKind`). */
2457
- type SubscriptionKind2 = "subgraph" | "chain";
2458
- type SubscriptionFormat2 = (typeof SUBSCRIPTION_FORMATS)[number];
2459
- type SubscriptionRuntime2 = (typeof SUBSCRIPTION_RUNTIMES)[number];
2460
- type SubscriptionFilterPrimitive = string | number | boolean;
2461
- type SubscriptionFilterOperator = {
2462
- eq: SubscriptionFilterPrimitive
2452
+ declare const CreateWebhookRequestSchema: z3.ZodType<ParsedCreateWebhookRequest>;
2453
+ declare const UpdateWebhookRequestSchema: z3.ZodType<UpdateWebhookRequest>;
2454
+ declare const ReplayWebhookRequestSchema: z3.ZodType<ReplayWebhookRequest>;
2455
+ type WebhookStatus2 = (typeof WEBHOOK_STATUSES)[number];
2456
+ /** Polymorphic webhook mode (mirrors db/types `WebhookKind`). */
2457
+ type WebhookKind2 = "subgraph" | "chain";
2458
+ type WebhookFormat2 = (typeof WEBHOOK_FORMATS)[number];
2459
+ type WebhookRuntime2 = (typeof WEBHOOK_RUNTIMES)[number];
2460
+ type WebhookFilterPrimitive = string | number | boolean;
2461
+ type WebhookFilterOperator = {
2462
+ eq: WebhookFilterPrimitive
2463
2463
  } | {
2464
- neq: SubscriptionFilterPrimitive
2464
+ neq: WebhookFilterPrimitive
2465
2465
  } | {
2466
2466
  gt: string | number
2467
2467
  } | {
@@ -2471,10 +2471,10 @@ type SubscriptionFilterOperator = {
2471
2471
  } | {
2472
2472
  lte: string | number
2473
2473
  } | {
2474
- in: SubscriptionFilterPrimitive[]
2474
+ in: WebhookFilterPrimitive[]
2475
2475
  };
2476
- type SubscriptionFilterClause = SubscriptionFilterPrimitive | SubscriptionFilterOperator;
2477
- type SubscriptionFilter = Record<string, SubscriptionFilterClause>;
2476
+ type WebhookFilterClause = WebhookFilterPrimitive | WebhookFilterOperator;
2477
+ type WebhookFilter = Record<string, WebhookFilterClause>;
2478
2478
  /** Non-negative integer amount over JSON (string for uint128 safety, or number). */
2479
2479
  type ChainTriggerAmount = string | number;
2480
2480
  interface TraitScoped {
@@ -2566,63 +2566,63 @@ type ChainTrigger = {
2566
2566
  requestId?: number
2567
2567
  sweepTxid?: string
2568
2568
  };
2569
- interface CreateSubscriptionRequest {
2569
+ interface CreateWebhookRequest {
2570
2570
  name: string;
2571
2571
  /** Subgraph mode. */
2572
2572
  subgraphName?: string;
2573
2573
  tableName?: string;
2574
- filter?: SubscriptionFilter;
2574
+ filter?: WebhookFilter;
2575
2575
  /** Chain mode. */
2576
2576
  triggers?: ChainTrigger[];
2577
2577
  url: string;
2578
- format?: SubscriptionFormat2;
2579
- runtime?: SubscriptionRuntime2 | null;
2578
+ format?: WebhookFormat2;
2579
+ runtime?: WebhookRuntime2 | null;
2580
2580
  authConfig?: Record<string, unknown>;
2581
2581
  maxRetries?: number;
2582
2582
  timeoutMs?: number;
2583
2583
  concurrency?: number;
2584
2584
  }
2585
- interface ParsedCreateSubscriptionRequest extends Omit<CreateSubscriptionRequest, "format"> {
2586
- format: SubscriptionFormat2;
2585
+ interface ParsedCreateWebhookRequest extends Omit<CreateWebhookRequest, "format"> {
2586
+ format: WebhookFormat2;
2587
2587
  }
2588
- interface UpdateSubscriptionRequest {
2588
+ interface UpdateWebhookRequest {
2589
2589
  name?: string;
2590
2590
  url?: string;
2591
- filter?: SubscriptionFilter;
2592
- format?: SubscriptionFormat2;
2593
- runtime?: SubscriptionRuntime2 | null;
2591
+ filter?: WebhookFilter;
2592
+ format?: WebhookFormat2;
2593
+ runtime?: WebhookRuntime2 | null;
2594
2594
  authConfig?: Record<string, unknown>;
2595
2595
  maxRetries?: number;
2596
2596
  timeoutMs?: number;
2597
2597
  concurrency?: number;
2598
2598
  }
2599
- type ParsedUpdateSubscriptionRequest = UpdateSubscriptionRequest;
2600
- interface ReplaySubscriptionRequest {
2599
+ type ParsedUpdateWebhookRequest = UpdateWebhookRequest;
2600
+ interface ReplayWebhookRequest {
2601
2601
  fromBlock: number;
2602
2602
  toBlock: number;
2603
2603
  force?: string;
2604
2604
  }
2605
- type ParsedReplaySubscriptionRequest = ReplaySubscriptionRequest;
2606
- interface SubscriptionSummary {
2605
+ type ParsedReplayWebhookRequest = ReplayWebhookRequest;
2606
+ interface WebhookSummary {
2607
2607
  id: string;
2608
2608
  name: string;
2609
- status: SubscriptionStatus2;
2610
- kind: SubscriptionKind2;
2611
- /** Null for chain subscriptions. */
2609
+ status: WebhookStatus2;
2610
+ kind: WebhookKind2;
2611
+ /** Null for chain webhooks. */
2612
2612
  subgraphName: string | null;
2613
- /** Null for chain subscriptions. */
2613
+ /** Null for chain webhooks. */
2614
2614
  tableName: string | null;
2615
- format: SubscriptionFormat2;
2616
- runtime: SubscriptionRuntime2 | null;
2615
+ format: WebhookFormat2;
2616
+ runtime: WebhookRuntime2 | null;
2617
2617
  url: string;
2618
2618
  lastDeliveryAt: string | null;
2619
2619
  lastSuccessAt: string | null;
2620
2620
  createdAt: string;
2621
2621
  updatedAt: string;
2622
2622
  }
2623
- interface SubscriptionDetail extends SubscriptionSummary {
2623
+ interface WebhookDetail extends WebhookSummary {
2624
2624
  filter: Record<string, unknown>;
2625
- /** Chain-trigger filters (chain subscriptions only). */
2625
+ /** Chain-trigger filters (chain webhooks only). */
2626
2626
  triggers: ChainTrigger[] | null;
2627
2627
  authConfig: Record<string, unknown>;
2628
2628
  maxRetries: number;
@@ -2632,13 +2632,13 @@ interface SubscriptionDetail extends SubscriptionSummary {
2632
2632
  circuitOpenedAt: string | null;
2633
2633
  lastError: string | null;
2634
2634
  }
2635
- interface CreateSubscriptionResponse {
2636
- subscription: SubscriptionDetail;
2635
+ interface CreateWebhookResponse {
2636
+ webhook: WebhookDetail;
2637
2637
  /** Plaintext signing secret — surfaced ONCE. Store it server-side. */
2638
2638
  signingSecret: string;
2639
2639
  }
2640
2640
  interface RotateSecretResponse {
2641
- subscription: SubscriptionDetail;
2641
+ webhook: WebhookDetail;
2642
2642
  signingSecret: string;
2643
2643
  }
2644
2644
  interface DeliveryRow {
@@ -2665,19 +2665,19 @@ interface DeadRow {
2665
2665
  failedAt: string | null;
2666
2666
  createdAt: string;
2667
2667
  }
2668
- interface SubscriptionSchemaColumn {
2668
+ interface WebhookSchemaColumn {
2669
2669
  type?: unknown;
2670
2670
  }
2671
- interface SubscriptionSchemaTable {
2672
- columns: Record<string, SubscriptionSchemaColumn>;
2671
+ interface WebhookSchemaTable {
2672
+ columns: Record<string, WebhookSchemaColumn>;
2673
2673
  }
2674
- type SubscriptionSchemaTables = Record<string, SubscriptionSchemaTable>;
2675
- declare function formatSubscriptionSchemaErrors(error: z3.ZodError): string[];
2676
- declare function validateSubscriptionFilterForTable(input: {
2674
+ type WebhookSchemaTables = Record<string, WebhookSchemaTable>;
2675
+ declare function formatWebhookSchemaErrors(error: z3.ZodError): string[];
2676
+ declare function validateWebhookFilterForTable(input: {
2677
2677
  subgraphName?: string
2678
2678
  tableName: string
2679
2679
  filter?: unknown
2680
- tables: SubscriptionSchemaTables
2680
+ tables: WebhookSchemaTables
2681
2681
  }): string[];
2682
2682
  type SubgraphSpecFormat = "openapi" | "agent" | "markdown";
2683
2683
  interface SubgraphSpecOptions {
@@ -2908,7 +2908,7 @@ interface ChainReorgOrphanedEntry {
2908
2908
  event: unknown;
2909
2909
  }
2910
2910
  /**
2911
- * Delivered once per affected subscription on a reorg
2911
+ * Delivered once per affected webhook on a reorg
2912
2912
  * (`event_type: "chain.reorg.rollback"`). Lists the previously-delivered applies
2913
2913
  * at or above `fork_point_height` that are now orphaned, so the consumer can undo
2914
2914
  * them precisely. `orphaned` is capped (currently 500); `truncated` flags overflow.
@@ -2919,7 +2919,7 @@ interface ChainReorgRollbackEnvelope {
2919
2919
  orphaned: ChainReorgOrphanedEntry[];
2920
2920
  truncated: boolean;
2921
2921
  }
2922
- /** Any chain-subscription webhook body. Discriminate on `action`. */
2922
+ /** Any chain-webhook webhook body. Discriminate on `action`. */
2923
2923
  type ChainWebhookEnvelope = ChainApplyEnvelope | ChainReorgRollbackEnvelope;
2924
2924
  /** `event.data` for a `stx_transfer` delivery. */
2925
2925
  interface ChainStxTransferData {
@@ -3054,26 +3054,28 @@ type ChainApplyDeliveryOf<
3054
3054
  timestamp: string
3055
3055
  data: ChainApplyEnvelopeOf<TTrigger, TEvent>
3056
3056
  };
3057
- /** Delivered once per affected subscription on a reorg (`type: "chain.reorg.rollback"`). */
3057
+ /** Delivered once per affected webhook on a reorg (`type: "chain.reorg.rollback"`). */
3058
3058
  interface ChainReorgRollbackDelivery {
3059
3059
  type: "chain.reorg.rollback";
3060
3060
  timestamp: string;
3061
3061
  data: ChainReorgRollbackEnvelope;
3062
3062
  }
3063
- /** The `POST /subscriptions/:id/test` ping (`type: "chain.test.apply"`) — not a real chain event. */
3063
+ /** The `POST /webhooks/:id/test` ping (`type: "chain.test.apply"`) — not a real chain event. */
3064
3064
  interface ChainTestDelivery {
3065
3065
  type: "chain.test.apply";
3066
3066
  timestamp: string;
3067
3067
  data: {
3068
3068
  test: true
3069
3069
  message: string
3070
- subscription_id: string
3070
+ webhook_id: string
3071
+ /** @deprecated Use webhook_id. Removed next minor. */
3072
+ subscription_id?: string
3071
3073
  sent_at: string
3072
3074
  };
3073
3075
  }
3074
3076
  /**
3075
- * The full wire body of a chain-subscription webhook delivery, as sent to a
3076
- * `format: "standard-webhooks"` subscription (the default) — `{ type,
3077
+ * The full wire body of a chain-webhook webhook delivery, as sent to a
3078
+ * `format: "standard-webhooks"` webhook (the default) — `{ type,
3077
3079
  * timestamp, data }`. Discriminate on `data.trigger` (or the top-level `type`)
3078
3080
  * to narrow `data.event`:
3079
3081
  *
@@ -3093,14 +3095,14 @@ interface ChainTestDelivery {
3093
3095
  *
3094
3096
  * NOTE: this is the DELIVERED webhook body, not a Streams/Index event — those
3095
3097
  * have an unrelated `{ event_type, payload }` shape (see `StreamsEvent` in
3096
- * `@secondlayer/sdk`). Do not parse a chain-subscription delivery as a Streams
3098
+ * `@secondlayer/sdk`). Do not parse a chain-webhook delivery as a Streams
3097
3099
  * event or vice versa — mixing them up is the exact bug this type exists to
3098
3100
  * prevent.
3099
3101
  *
3100
- * Other subscription `format`s (`raw`, `cloudevents`, `inngest`, `trigger`,
3102
+ * Other webhook `format`s (`raw`, `cloudevents`, `inngest`, `trigger`,
3101
3103
  * `cloudflare`) carry the same `data` value (a `ChainApplyEnvelope` /
3102
3104
  * `ChainReorgRollbackEnvelope`) under a different outer envelope — see the
3103
- * "Chain subscription webhook payloads" doc.
3105
+ * "Chain webhook webhook payloads" doc.
3104
3106
  */
3105
3107
  type ChainWebhookDelivery = ChainApplyDeliveryOf<"stx_transfer", ChainEventEnvelope<"stx_transfer_event", ChainStxTransferData>> | ChainApplyDeliveryOf<"stx_mint", ChainEventEnvelope<"stx_mint_event", ChainStxMintData>> | ChainApplyDeliveryOf<"stx_burn", ChainEventEnvelope<"stx_burn_event", ChainStxBurnData>> | ChainApplyDeliveryOf<"stx_lock", ChainEventEnvelope<"stx_lock_event", ChainStxLockData>> | ChainApplyDeliveryOf<"ft_transfer", ChainEventEnvelope<"ft_transfer_event", ChainFtTransferData>> | ChainApplyDeliveryOf<"ft_mint", ChainEventEnvelope<"ft_mint_event", ChainFtMintData>> | ChainApplyDeliveryOf<"ft_burn", ChainEventEnvelope<"ft_burn_event", ChainFtBurnData>> | ChainApplyDeliveryOf<"nft_transfer", ChainEventEnvelope<"nft_transfer_event", ChainNftTransferData>> | ChainApplyDeliveryOf<"nft_mint", ChainEventEnvelope<"nft_mint_event", ChainNftMintData>> | ChainApplyDeliveryOf<"nft_burn", ChainEventEnvelope<"nft_burn_event", ChainNftBurnData>> | ChainApplyDeliveryOf<"print_event", ChainEventEnvelope<"contract_event", ChainPrintEventData>> | ChainApplyDeliveryOf<"contract_call", ChainTxLevelEvent> | ChainApplyDeliveryOf<"contract_deploy", ChainTxLevelEvent> | ChainApplyDeliveryOf<"sbtc_deposit", SbtcDepositEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_create", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_accept", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_reject", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_swept_confirmed", SbtcWithdrawalSweptConfirmedEvent> | ChainReorgRollbackDelivery | ChainTestDelivery;
3106
- export { validateSubscriptionFilterForTable, sql, setMigrationRole, parseJsonb, onControlPlane, onChainPlane, logger, jsonb, isSbtcDecoderEnabled, isPox5DecoderEnabled, isPox4DecoderEnabled, isEmptyRangeCursor, isBnsDecoderEnabled, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getMigrationRole, getErrorMessage, getEnv, getDbSplitStatus, getDb, generateSubgraphSpec, generateSubgraphOpenApi, generateSubgraphMarkdown, generateSubgraphAgentSchema, formatSubscriptionSchemaErrors, finalizedBurnHeight, encodeStreamsCursor, exports_ed25519 as ed25519, decodeStreamsCursor, exports_hmac as crypto, compareStreamsCursor, closeDb, blockEndCursor, assertDbSplit, applicationDatabaseUrl, X402PaymentsTable, X402BalancesTable, VersionConflictError, ValidationError, UpdateTransaction, UpdateSubscriptionRequestSchema, UpdateSubscriptionRequest, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateIndexProgress, UpdateHostedMeterDay, UpdateEvent, UpdateContract, UpdateClaimToken, UpdateBlock, UpdateArchiveFetch, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantSuspendedError, TABLE_TO_DB, SyncScopesTable, SubscriptionsTable, SubscriptionSummary, SubscriptionStatusSchema, SubscriptionStatus, SubscriptionSchemaTables, SubscriptionSchemaTable, SubscriptionSchemaColumn, SubscriptionRuntimeSchema, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormatSchema, SubscriptionFormat, SubscriptionFilterSchema, SubscriptionFilterPrimitiveSchema, SubscriptionFilterPrimitive, SubscriptionFilterOperatorSchema, SubscriptionFilterOperator, SubscriptionFilterClauseSchema, SubscriptionFilterClause, SubscriptionFilter, SubscriptionDetail, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphViolationsTable, SubgraphTableSnapshotsTable, SubgraphSyncInfo, SubgraphSummary, SubgraphSpecOptions, SubgraphSpecFormat, SubgraphQueryParams, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphGap, SubgraphDetail, SubgraphAggregateResponse, SubgraphAggregateParams, SubgraphAgentSchema, Subgraph, StreamsEventType, StreamsDbEventType, StreamsCursor, StageRunsTable, StageRegistryTable, StageKind, StageFailuresTable, StageBlockReceiptsTable, SessionsTable, Session, ServiceHeartbeatsTable, SecondLayerError, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalEvent, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, SbtcDepositEvent, SUBSCRIPTION_STATUSES, SUBSCRIPTION_RUNTIMES, SUBSCRIPTION_FORMATS, SUBSCRIPTION_FILTER_OPERATORS, STREAMS_TO_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_DB_EVENT_TYPES, SOURCE_READ_TYPES, SOURCE_READ_PKS, SOURCE_READ_COLUMNS, RunStatus, RotateSecretResponse, RetryState, ReplaySubscriptionRequestSchema, ReplaySubscriptionRequest, ReplayResult, RepairMode, ReindexResponse, RateLimitError, ProcessedStripeEventsTable, Pox5EventsTable, Pox5EventTopic, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PlayProvisionsTable, PlayProvision, PendingForkBlocksTable, PaymentRequiredError, ParsedUpdateSubscriptionRequest, ParsedReplaySubscriptionRequest, ParsedCreateSubscriptionRequest, OutboxStatus, ObserverJournalTable, ObserverJournalStatus, NumericAsText, NotFoundError, NativeClock, MigrationRole, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, KeyRotatedError, InstancesTable, InsertTransaction, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertPlayProvision, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertHostedMeterDay, InsertEvent, InsertContract, InsertClaimToken, InsertBlock, InsertArchiveFetch, InsertApiKey, InsertAccountSpendCap, InsertAccountCredits, InsertAccount, IndexProgressTable, IndexProgress, IndexPrimaryKey, IndexColumnType, IndexColumn, HostedMeterDaysTable, HostedMeterDay, ForbiddenError, FailureUnit, FailureClass, EventsTable, EventsArchiveTable, Event, ErrorCodes, ErrorCode, Env, EMPTY_RANGE_EVENT_INDEX_SENTINEL, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DecoderCheckpointsTable, DecodedEventsTable, DecodedEventType2 as DecodedEventType, DeadRow, DeadLetterEventsTable, DbSplitStatus, DbReadRow, DbPlane, DatabaseError, Database, DEFAULT_BTC_CONFIRMATIONS, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DB_TO_STREAMS_EVENT_TYPE, CreateSubscriptionResponse, CreateSubscriptionRequestSchema, CreateSubscriptionRequest, CoverageSegmentsTable, ContractsTable, Contract, ClaimTokensTable, ClaimToken, ChainWebhookEnvelope, ChainWebhookDelivery, ChainTxLevelEvent, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgsTable, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainReadCacheTable, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, ChainApplyDeliveryOf, CODE_TO_STATUS, CHAIN_TRIGGER_TYPES, CHAIN_TRIGGER_FIELDS, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, AuthorizationError, AuthenticationError, ArchiveFetchesTable, ArchiveFetch, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountCreditsTable, AccountCredits, Account };
3108
+ export { validateWebhookFilterForTable, sql, setMigrationRole, parseJsonb, onControlPlane, onChainPlane, logger, jsonb, isSbtcDecoderEnabled, isPox5DecoderEnabled, isPox4DecoderEnabled, isEmptyRangeCursor, isBnsDecoderEnabled, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getMigrationRole, getErrorMessage, getEnv, getDbSplitStatus, getDb, generateSubgraphSpec, generateSubgraphOpenApi, generateSubgraphMarkdown, generateSubgraphAgentSchema, formatWebhookSchemaErrors, finalizedBurnHeight, encodeStreamsCursor, exports_ed25519 as ed25519, decodeStreamsCursor, exports_hmac as crypto, compareStreamsCursor, closeDb, blockEndCursor, assertDbSplit, applicationDatabaseUrl, X402PaymentsTable, X402BalancesTable, WebhooksTable, WebhookSummary, WebhookStatusSchema, WebhookStatus, WebhookSchemaTables, WebhookSchemaTable, WebhookSchemaColumn, WebhookRuntimeSchema, WebhookRuntime, WebhookOutboxTable, WebhookOutbox, WebhookKind, WebhookFormatSchema, WebhookFormat, WebhookFilterSchema, WebhookFilterPrimitiveSchema, WebhookFilterPrimitive, WebhookFilterOperatorSchema, WebhookFilterOperator, WebhookFilterClauseSchema, WebhookFilterClause, WebhookFilter, WebhookDetail, WebhookDelivery, WebhookDeliveriesTable, Webhook, WEBHOOK_STATUSES, WEBHOOK_RUNTIMES, WEBHOOK_FORMATS, WEBHOOK_FILTER_OPERATORS, VersionConflictError, ValidationError, UpdateWebhookRequestSchema, UpdateWebhookRequest, UpdateWebhookOutbox, UpdateWebhook, UpdateTransaction, UpdateSubgraphOperation, UpdateSubgraph, UpdateIndexProgress, UpdateHostedMeterDay, UpdateEvent, UpdateContract, UpdateClaimToken, UpdateBlock, UpdateArchiveFetch, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantSuspendedError, TABLE_TO_DB, SyncScopesTable, SubgraphsTable, SubgraphViolationsTable, SubgraphTableSnapshotsTable, SubgraphSyncInfo, SubgraphSummary, SubgraphSpecOptions, SubgraphSpecFormat, SubgraphQueryParams, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphGap, SubgraphDetail, SubgraphAggregateResponse, SubgraphAggregateParams, SubgraphAgentSchema, Subgraph, StreamsEventType, StreamsDbEventType, StreamsCursor, StageRunsTable, StageRegistryTable, StageKind, StageFailuresTable, StageBlockReceiptsTable, SessionsTable, Session, ServiceHeartbeatsTable, SecondLayerError, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalEvent, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, SbtcDepositEvent, STREAMS_TO_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_DB_EVENT_TYPES, SOURCE_READ_TYPES, SOURCE_READ_PKS, SOURCE_READ_COLUMNS, RunStatus, RotateSecretResponse, RetryState, ReplayWebhookRequestSchema, ReplayWebhookRequest, ReplayResult, RepairMode, ReindexResponse, RateLimitError, ProcessedStripeEventsTable, Pox5EventsTable, Pox5EventTopic, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PlayProvisionsTable, PlayProvision, PendingForkBlocksTable, PaymentRequiredError, ParsedUpdateWebhookRequest, ParsedReplayWebhookRequest, ParsedCreateWebhookRequest, OutboxStatus, ObserverJournalTable, ObserverJournalStatus, NumericAsText, NotFoundError, NativeClock, MigrationRole, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, KeyRotatedError, InstancesTable, InsertWebhookOutbox, InsertWebhookDelivery, InsertWebhook, InsertTransaction, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertPlayProvision, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertHostedMeterDay, InsertEvent, InsertContract, InsertClaimToken, InsertBlock, InsertArchiveFetch, InsertApiKey, InsertAccountSpendCap, InsertAccountCredits, InsertAccount, IndexProgressTable, IndexProgress, IndexPrimaryKey, IndexColumnType, IndexColumn, HostedMeterDaysTable, HostedMeterDay, ForbiddenError, FailureUnit, FailureClass, EventsTable, EventsArchiveTable, Event, ErrorCodes, ErrorCode, Env, EMPTY_RANGE_EVENT_INDEX_SENTINEL, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DecoderCheckpointsTable, DecodedEventsTable, DecodedEventType2 as DecodedEventType, DeadRow, DeadLetterEventsTable, DbSplitStatus, DbReadRow, DbPlane, DatabaseError, Database, DEFAULT_BTC_CONFIRMATIONS, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DB_TO_STREAMS_EVENT_TYPE, CreateWebhookResponse, CreateWebhookRequestSchema, CreateWebhookRequest, CoverageSegmentsTable, ContractsTable, Contract, ClaimTokensTable, ClaimToken, ChainWebhookEnvelope, ChainWebhookDelivery, ChainTxLevelEvent, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgsTable, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainReadCacheTable, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, ChainApplyDeliveryOf, CODE_TO_STATUS, CHAIN_TRIGGER_TYPES, CHAIN_TRIGGER_FIELDS, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, AuthorizationError, AuthenticationError, ArchiveFetchesTable, ArchiveFetch, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountCreditsTable, AccountCredits, Account };