@secondlayer/shared 11.24.1 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/src/archive/range-digest.d.ts +27 -19
  2. package/dist/src/archive/semantic-digest-builder.d.ts +27 -19
  3. package/dist/src/coverage/index.d.ts +27 -19
  4. package/dist/src/db/index.d.ts +31 -20
  5. package/dist/src/db/index.js +2 -1
  6. package/dist/src/db/index.js.map +3 -3
  7. package/dist/src/db/queries/chain-reorgs.d.ts +27 -19
  8. package/dist/src/db/queries/chain-reorgs.js +2 -1
  9. package/dist/src/db/queries/chain-reorgs.js.map +3 -3
  10. package/dist/src/db/queries/contracts.d.ts +27 -19
  11. package/dist/src/db/queries/instance.d.ts +27 -19
  12. package/dist/src/db/queries/integrity.d.ts +27 -19
  13. package/dist/src/db/queries/subgraph-gaps.d.ts +27 -19
  14. package/dist/src/db/queries/subgraph-operations.d.ts +27 -19
  15. package/dist/src/db/queries/subgraphs.d.ts +27 -19
  16. package/dist/src/db/queries/subgraphs.js +1 -7
  17. package/dist/src/db/queries/subgraphs.js.map +4 -4
  18. package/dist/src/db/queries/sync-scope.d.ts +27 -19
  19. package/dist/src/db/queries/webhooks.d.ts +30 -33
  20. package/dist/src/db/queries/webhooks.js +3 -12
  21. package/dist/src/db/queries/webhooks.js.map +3 -3
  22. package/dist/src/db/schema.d.ts +30 -20
  23. package/dist/src/email/index.d.ts +2 -0
  24. package/dist/src/email/index.js +3 -2
  25. package/dist/src/email/index.js.map +3 -3
  26. package/dist/src/index.d.ts +37 -81
  27. package/dist/src/index.js +4 -108
  28. package/dist/src/index.js.map +5 -5
  29. package/dist/src/node/local-client.d.ts +27 -19
  30. package/dist/src/queue/listener.js +2 -1
  31. package/dist/src/queue/listener.js.map +3 -3
  32. package/dist/src/schemas/index.d.ts +7 -62
  33. package/dist/src/schemas/index.js +3 -108
  34. package/dist/src/schemas/index.js.map +4 -4
  35. package/dist/src/schemas/subgraphs.d.ts +0 -2
  36. package/dist/src/schemas/subgraphs.js.map +1 -1
  37. package/dist/src/schemas/webhooks.d.ts +10 -65
  38. package/dist/src/schemas/webhooks.js +2 -107
  39. package/dist/src/schemas/webhooks.js.map +3 -3
  40. package/migrations/0159_drop_subgraph_row_webhooks.ts +91 -0
  41. package/migrations/0160_contact_requests.ts +43 -0
  42. package/package.json +1 -1
@@ -109,8 +109,6 @@ interface SubgraphSummary {
109
109
  lastErrorAt?: string | null;
110
110
  /** Last row mutation timestamp; powers per-card freshness. */
111
111
  updatedAt?: string | null;
112
- /** Number of webhooks attached to this subgraph. */
113
- webhookCount?: number;
114
112
  createdAt: string;
115
113
  }
116
114
  interface SubgraphGapRange {
@@ -1090,6 +1088,7 @@ interface Database {
1090
1088
  sentinel_accounts: SentinelAccountsTable;
1091
1089
  waitlists: WaitlistsTable;
1092
1090
  waitlist_signups: WaitlistSignupsTable;
1091
+ contact_requests: ContactRequestsTable;
1093
1092
  api_failed_requests: ApiFailedRequestsTable;
1094
1093
  feedback_tickets: FeedbackTicketsTable;
1095
1094
  }
@@ -1234,12 +1233,11 @@ type InsertSubgraphHealthSnapshot = Insertable<SubgraphHealthSnapshotsTable>;
1234
1233
  type SubgraphGap = Selectable<SubgraphGapsTable>;
1235
1234
  type InsertSubgraphGap = Insertable<SubgraphGapsTable>;
1236
1235
  type WebhookStatus = "active" | "paused" | "error";
1237
- /** Polymorphic webhook mode: `subgraph` reacts to processed table rows;
1238
- * `chain` reacts to raw chain events matched directly off the Index/Streams
1239
- * clock (no subgraph). See migration 0088. */
1240
- type WebhookKind = "subgraph" | "chain";
1236
+ /** Webhooks react to raw chain events matched directly off the Index/Streams
1237
+ * clock. `chain` is the only kind since migration 0159 removed subgraph-row
1238
+ * webhooks; the column stays as the discriminator. */
1239
+ type WebhookKind = "chain";
1241
1240
  type WebhookFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
1242
- type WebhookRuntime = "inngest" | "trigger" | "cloudflare" | "node";
1243
1241
  interface WebhooksTable {
1244
1242
  id: Generated<string>;
1245
1243
  account_id: string;
@@ -1247,17 +1245,11 @@ interface WebhooksTable {
1247
1245
  name: string;
1248
1246
  status: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;
1249
1247
  kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
1250
- /** Null for chain webhooks (CHECK webhooks_kind_shape). */
1251
- subgraph_name: string | null;
1252
- /** Null for chain webhooks (CHECK webhooks_kind_shape). */
1253
- table_name: string | null;
1254
- /** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
1255
- * subgraph webhooks. Typed loosely here to avoid a shared→subgraphs
1256
- * import cycle; the Zod schema in schemas/webhooks.ts owns the shape. */
1257
- triggers: unknown | null;
1258
- filter: Generated<unknown>;
1248
+ /** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Typed
1249
+ * loosely here to avoid a shared→subgraphs import cycle; the Zod schema in
1250
+ * schemas/webhooks.ts owns the shape. */
1251
+ triggers: unknown;
1259
1252
  format: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;
1260
- runtime: WebhookRuntime | null;
1261
1253
  url: string;
1262
1254
  signing_secret_enc: Buffer;
1263
1255
  auth_config: Generated<unknown>;
@@ -1280,10 +1272,6 @@ interface WebhookOutboxTable {
1280
1272
  id: Generated<string>;
1281
1273
  webhook_id: string;
1282
1274
  kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
1283
- /** Null for chain-webhook rows. */
1284
- subgraph_name: string | null;
1285
- /** Null for chain-webhook rows. */
1286
- table_name: string | null;
1287
1275
  block_height: number | bigint;
1288
1276
  tx_id: string | null;
1289
1277
  row_pk: unknown;
@@ -1366,6 +1354,24 @@ interface WaitlistSignupsTable {
1366
1354
  created_at: Generated<Date>;
1367
1355
  }
1368
1356
  /**
1357
+ * A "Talk to us" message. Stored before the operator is emailed;
1358
+ * `notified_at` stays null until the email goes out.
1359
+ */
1360
+ interface ContactRequestsTable {
1361
+ id: Generated<string>;
1362
+ name: string;
1363
+ email: string;
1364
+ company: string | null;
1365
+ volume: "lt10m" | "10m-100m" | "100m-1b" | "gt1b" | "unsure" | null;
1366
+ message: string;
1367
+ source_page: string | null;
1368
+ account_id: string | null;
1369
+ /** Hex sha256 of the client IP, never the address. */
1370
+ ip_hash: string | null;
1371
+ notified_at: Date | null;
1372
+ created_at: Generated<Date>;
1373
+ }
1374
+ /**
1369
1375
  * 24h hosted record of a failed API request, keyed by `request_id` and
1370
1376
  * scoped to the account that made it. `query` is redacted before insert.
1371
1377
  */
@@ -1409,6 +1415,8 @@ type InsertFeedbackTicket = Insertable<FeedbackTicketsTable>;
1409
1415
  type Waitlist = Selectable<WaitlistsTable>;
1410
1416
  type WaitlistSignup = Selectable<WaitlistSignupsTable>;
1411
1417
  type InsertWaitlistSignup = Insertable<WaitlistSignupsTable>;
1418
+ type ContactRequest = Selectable<ContactRequestsTable>;
1419
+ type InsertContactRequest = Insertable<ContactRequestsTable>;
1412
1420
  interface EnvSchemaOutput {
1413
1421
  DATABASE_URL?: string;
1414
1422
  /**
@@ -2439,6 +2447,7 @@ declare const TABLE_TO_DB: {
2439
2447
  sentinel_accounts: string
2440
2448
  waitlists: string
2441
2449
  waitlist_signups: string
2450
+ contact_requests: string
2442
2451
  api_failed_requests: string
2443
2452
  feedback_tickets: string
2444
2453
  service_heartbeats: string
@@ -2695,16 +2704,9 @@ declare class Logger {
2695
2704
  declare const logger: Logger;
2696
2705
  import { z as z3 } from "zod";
2697
2706
  declare const WEBHOOK_FORMATS: readonly ["standard-webhooks", "inngest", "trigger", "cloudflare", "cloudevents", "raw"];
2698
- declare const WEBHOOK_RUNTIMES: readonly ["inngest", "trigger", "cloudflare", "node"];
2699
2707
  declare const WEBHOOK_STATUSES: readonly ["active", "paused", "error"];
2700
- declare const WEBHOOK_FILTER_OPERATORS: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "in"];
2701
2708
  declare const WebhookStatusSchema: z3.ZodType<WebhookStatus2>;
2702
2709
  declare const WebhookFormatSchema: z3.ZodType<WebhookFormat2>;
2703
- declare const WebhookRuntimeSchema: z3.ZodType<WebhookRuntime2>;
2704
- declare const WebhookFilterPrimitiveSchema: z3.ZodType<WebhookFilterPrimitive>;
2705
- declare const WebhookFilterOperatorSchema: z3.ZodType<WebhookFilterOperator>;
2706
- declare const WebhookFilterClauseSchema: z3.ZodType<WebhookFilterClause>;
2707
- declare const WebhookFilterSchema: z3.ZodType<WebhookFilter>;
2708
2710
  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", "nested_contract_call", "var_set", "map_set", "map_insert", "map_delete", "sbtc_deposit", "sbtc_withdrawal_create", "sbtc_withdrawal_accept", "sbtc_withdrawal_reject", "sbtc_withdrawal_swept_confirmed", "rune_etch", "rune_mint", "rune_transfer", "rune_burn"];
2709
2711
  /**
2710
2712
  * Per-type accepted filter fields for chain triggers, DERIVED from
@@ -2716,28 +2718,9 @@ declare const CreateWebhookRequestSchema: z3.ZodType<ParsedCreateWebhookRequest>
2716
2718
  declare const UpdateWebhookRequestSchema: z3.ZodType<UpdateWebhookRequest>;
2717
2719
  declare const ReplayWebhookRequestSchema: z3.ZodType<ReplayWebhookRequest>;
2718
2720
  type WebhookStatus2 = (typeof WEBHOOK_STATUSES)[number];
2719
- /** Polymorphic webhook mode (mirrors db/types `WebhookKind`). */
2720
- type WebhookKind2 = "subgraph" | "chain";
2721
+ /** Webhook kind (mirrors db/types `WebhookKind`). Chain events only. */
2722
+ type WebhookKind2 = "chain";
2721
2723
  type WebhookFormat2 = (typeof WEBHOOK_FORMATS)[number];
2722
- type WebhookRuntime2 = (typeof WEBHOOK_RUNTIMES)[number];
2723
- type WebhookFilterPrimitive = string | number | boolean;
2724
- type WebhookFilterOperator = {
2725
- eq: WebhookFilterPrimitive
2726
- } | {
2727
- neq: WebhookFilterPrimitive
2728
- } | {
2729
- gt: string | number
2730
- } | {
2731
- gte: string | number
2732
- } | {
2733
- lt: string | number
2734
- } | {
2735
- lte: string | number
2736
- } | {
2737
- in: WebhookFilterPrimitive[]
2738
- };
2739
- type WebhookFilterClause = WebhookFilterPrimitive | WebhookFilterOperator;
2740
- type WebhookFilter = Record<string, WebhookFilterClause>;
2741
2724
  /** Non-negative integer amount over JSON (string for uint128 safety, or number). */
2742
2725
  type ChainTriggerAmount = string | number;
2743
2726
  interface TraitScoped {
@@ -2867,15 +2850,9 @@ type ChainTrigger = {
2867
2850
  };
2868
2851
  interface CreateWebhookRequest {
2869
2852
  name: string;
2870
- /** Subgraph mode. */
2871
- subgraphName?: string;
2872
- tableName?: string;
2873
- filter?: WebhookFilter;
2874
- /** Chain mode. */
2875
- triggers?: ChainTrigger[];
2853
+ triggers: ChainTrigger[];
2876
2854
  url: string;
2877
2855
  format?: WebhookFormat2;
2878
- runtime?: WebhookRuntime2 | null;
2879
2856
  authConfig?: Record<string, unknown>;
2880
2857
  maxRetries?: number;
2881
2858
  timeoutMs?: number;
@@ -2887,9 +2864,7 @@ interface ParsedCreateWebhookRequest extends Omit<CreateWebhookRequest, "format"
2887
2864
  interface UpdateWebhookRequest {
2888
2865
  name?: string;
2889
2866
  url?: string;
2890
- filter?: WebhookFilter;
2891
2867
  format?: WebhookFormat2;
2892
- runtime?: WebhookRuntime2 | null;
2893
2868
  authConfig?: Record<string, unknown>;
2894
2869
  maxRetries?: number;
2895
2870
  timeoutMs?: number;
@@ -2907,12 +2882,7 @@ interface WebhookSummary {
2907
2882
  name: string;
2908
2883
  status: WebhookStatus2;
2909
2884
  kind: WebhookKind2;
2910
- /** Null for chain webhooks. */
2911
- subgraphName: string | null;
2912
- /** Null for chain webhooks. */
2913
- tableName: string | null;
2914
2885
  format: WebhookFormat2;
2915
- runtime: WebhookRuntime2 | null;
2916
2886
  url: string;
2917
2887
  lastDeliveryAt: string | null;
2918
2888
  lastSuccessAt: string | null;
@@ -2940,15 +2910,14 @@ interface WebhookAuth {
2940
2910
  hasSecret: boolean;
2941
2911
  }
2942
2912
  interface WebhookDetail extends WebhookSummary {
2943
- filter: Record<string, unknown>;
2944
- /** Chain-trigger filters (chain webhooks only). */
2945
- triggers: ChainTrigger[] | null;
2913
+ /** Chain-trigger filters. */
2914
+ triggers: ChainTrigger[];
2946
2915
  auth: WebhookAuth;
2947
2916
  maxRetries: number;
2948
2917
  timeoutMs: number;
2949
2918
  concurrency: number;
2950
2919
  lastError: string | null;
2951
- /** Set on a `kind="chain"` webhook when this instance's chain-trigger
2920
+ /** Set when this instance's chain-trigger
2952
2921
  * evaluator isn't running (`SUBGRAPH_SOURCE` != `streams-index`) — the
2953
2922
  * webhook will never fire until that's fixed. Null otherwise. Surfaced
2954
2923
  * on create (so it's seen immediately) and on every read (so `secondlayer
@@ -3003,20 +2972,7 @@ interface DeadRow {
3003
2972
  failedAt: string | null;
3004
2973
  createdAt: string;
3005
2974
  }
3006
- interface WebhookSchemaColumn {
3007
- type?: unknown;
3008
- }
3009
- interface WebhookSchemaTable {
3010
- columns: Record<string, WebhookSchemaColumn>;
3011
- }
3012
- type WebhookSchemaTables = Record<string, WebhookSchemaTable>;
3013
2975
  declare function formatWebhookSchemaErrors(error: z3.ZodError): string[];
3014
- declare function validateWebhookFilterForTable(input: {
3015
- subgraphName?: string
3016
- tableName: string
3017
- filter?: unknown
3018
- tables: WebhookSchemaTables
3019
- }): string[];
3020
2976
  type SubgraphSpecFormat = "openapi" | "agent" | "markdown";
3021
2977
  interface SubgraphSpecOptions {
3022
2978
  serverUrl?: string;
@@ -3450,4 +3406,4 @@ declare function publicKeyPemFromPrivate(privateKeyPem: string): string;
3450
3406
  declare function ed25519KeyId(publicKeyPem: string): string;
3451
3407
  declare function signEd25519(payload: string, privateKey: KeyObject): string;
3452
3408
  declare function verifyEd25519(payload: string, signatureBase64: string, publicKey: KeyObject): boolean;
3453
- export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeysTable, ArchiveFetch, ArchiveFetchesTable, AuthenticationError, AuthorizationError, BILLING_PAUSED_PREFIX, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, CHAIN_TRIGGER_FIELDS, CHAIN_TRIGGER_TYPES, CODE_TO_STATUS, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReadCacheTable, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainReorgsTable, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTxLevelEvent, ChainWebhookDelivery, ChainWebhookEnvelope, Contract, ContractsTable, CoverageSegmentsTable, CreateWebhookRequest, CreateWebhookRequestSchema, CreateWebhookResponse, DB_TO_STREAMS_EVENT_TYPE, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DEFAULT_BTC_CONFIRMATIONS, Database, DatabaseError, DbPlane, DbReadRow, DbSplitStatus, DeadLetterEventsTable, DeadRow, DecodedEventType2 as DecodedEventType, DecodedEventsTable, DecoderCheckpointsTable, DeliveryRow, DeploySubgraphRequest, DeploySubgraphRequestSchema, DeploySubgraphResponse, EMPTY_RANGE_EVENT_INDEX_SENTINEL, Env, ErrorCode, ErrorCodes, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, ForbiddenError, IndexColumn, IndexColumnType, IndexPrimaryKey, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertArchiveFetch, InsertBlock, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, KeyRotatedError, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, MigrationRole, NativeClock, NotFoundError, NumericAsText, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, ParsedCreateWebhookRequest, ParsedReplayWebhookRequest, ParsedUpdateWebhookRequest, PaymentRequiredError, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RUNE_EVENT_TYPES, RateLimitError, ReindexResponse, RepairMode, ReplayResult, ReplayWebhookRequest, ReplayWebhookRequestSchema, RetryState, RotateSecretResponse, RunStatus, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneEventType, SOURCE_READ_COLUMNS, SOURCE_READ_PKS, SOURCE_READ_TYPES, STREAMS_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_TO_DB_EVENT_TYPES, SbtcDepositEvent, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SbtcWithdrawalEvent, SbtcWithdrawalSweptConfirmedEvent, SecondLayerError, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, StreamsCursor, StreamsDbEventType, StreamsEventType, Subgraph, SubgraphAgentSchema, SubgraphAggregateParams, SubgraphAggregateResponse, SubgraphDetail, SubgraphGap, SubgraphGapEntry, SubgraphGapRange, SubgraphGapsResponse, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphQueryParams, SubgraphSpecFormat, SubgraphSpecOptions, SubgraphSummary, SubgraphSyncInfo, SubgraphVerification, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, TABLE_TO_DB, TenantSuspendedError, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UpdateWebhookRequest, UpdateWebhookRequestSchema, UsageLedgerRow, UsageLedgerTable, VM_EVENT_TYPES, VM_NODE_TO_STORED_TYPE2 as VM_NODE_TO_STORED_TYPE, VM_STORED_TO_NODE_TYPE, ValidationError, VersionConflictError, VmEvent, VmEventType, VmEventsArchiveTable, VmEventsTable, VmNodeEventType, WEBHOOK_FILTER_OPERATORS, WEBHOOK_FORMATS, WEBHOOK_RUNTIMES, WEBHOOK_STATUSES, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookDetail, WebhookFilter, WebhookFilterClause, WebhookFilterClauseSchema, WebhookFilterOperator, WebhookFilterOperatorSchema, WebhookFilterPrimitive, WebhookFilterPrimitiveSchema, WebhookFilterSchema, WebhookFormat, WebhookFormatSchema, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookRuntime, WebhookRuntimeSchema, WebhookSchemaColumn, WebhookSchemaTable, WebhookSchemaTables, WebhookStatus, WebhookStatusSchema, WebhookSummary, WebhooksTable, applicationDatabaseUrl, assertDbSplit, billingPausedCode, blockEndCursor, closeDb, closeDbOrTimeout, committedHeight, compareStreamsCursor, exports_hmac as crypto, decodeStreamsCursor, describeDbUrl, exports_ed25519 as ed25519, encodeStreamsCursor, finalizedBurnHeight, formatWebhookSchemaErrors, generateSubgraphAgentSchema, generateSubgraphMarkdown, generateSubgraphOpenApi, generateSubgraphSpec, getDb, getDbSplitStatus, getEnv, getErrorMessage, getMigrationRole, getRawClient, getRawClientFor, getSourceDb, getTargetDb, isBnsDecoderEnabled, isEmptyRangeCursor, isPox4DecoderEnabled, isPox5DecoderEnabled, isSbtcDecoderEnabled, jsonb, logger, onChainPlane, onControlPlane, parseJsonb, resolveSourceUrl, resolveTargetUrl, setMigrationRole, sql, validateWebhookFilterForTable };
3409
+ export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeysTable, ArchiveFetch, ArchiveFetchesTable, AuthenticationError, AuthorizationError, BILLING_PAUSED_PREFIX, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, CHAIN_TRIGGER_FIELDS, CHAIN_TRIGGER_TYPES, CODE_TO_STATUS, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReadCacheTable, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainReorgsTable, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTxLevelEvent, ChainWebhookDelivery, ChainWebhookEnvelope, ContactRequest, ContactRequestsTable, Contract, ContractsTable, CoverageSegmentsTable, CreateWebhookRequest, CreateWebhookRequestSchema, CreateWebhookResponse, DB_TO_STREAMS_EVENT_TYPE, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DEFAULT_BTC_CONFIRMATIONS, Database, DatabaseError, DbPlane, DbReadRow, DbSplitStatus, DeadLetterEventsTable, DeadRow, DecodedEventType2 as DecodedEventType, DecodedEventsTable, DecoderCheckpointsTable, DeliveryRow, DeploySubgraphRequest, DeploySubgraphRequestSchema, DeploySubgraphResponse, EMPTY_RANGE_EVENT_INDEX_SENTINEL, Env, ErrorCode, ErrorCodes, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, ForbiddenError, IndexColumn, IndexColumnType, IndexPrimaryKey, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertArchiveFetch, InsertBlock, InsertContactRequest, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, KeyRotatedError, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, MigrationRole, NativeClock, NotFoundError, NumericAsText, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, ParsedCreateWebhookRequest, ParsedReplayWebhookRequest, ParsedUpdateWebhookRequest, PaymentRequiredError, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RUNE_EVENT_TYPES, RateLimitError, ReindexResponse, RepairMode, ReplayResult, ReplayWebhookRequest, ReplayWebhookRequestSchema, RetryState, RotateSecretResponse, RunStatus, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneEventType, SOURCE_READ_COLUMNS, SOURCE_READ_PKS, SOURCE_READ_TYPES, STREAMS_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_TO_DB_EVENT_TYPES, SbtcDepositEvent, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SbtcWithdrawalEvent, SbtcWithdrawalSweptConfirmedEvent, SecondLayerError, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, StreamsCursor, StreamsDbEventType, StreamsEventType, Subgraph, SubgraphAgentSchema, SubgraphAggregateParams, SubgraphAggregateResponse, SubgraphDetail, SubgraphGap, SubgraphGapEntry, SubgraphGapRange, SubgraphGapsResponse, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphQueryParams, SubgraphSpecFormat, SubgraphSpecOptions, SubgraphSummary, SubgraphSyncInfo, SubgraphVerification, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, TABLE_TO_DB, TenantSuspendedError, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UpdateWebhookRequest, UpdateWebhookRequestSchema, UsageLedgerRow, UsageLedgerTable, VM_EVENT_TYPES, VM_NODE_TO_STORED_TYPE2 as VM_NODE_TO_STORED_TYPE, VM_STORED_TO_NODE_TYPE, ValidationError, VersionConflictError, VmEvent, VmEventType, VmEventsArchiveTable, VmEventsTable, VmNodeEventType, WEBHOOK_FORMATS, WEBHOOK_STATUSES, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookDetail, WebhookFormat, WebhookFormatSchema, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookStatus, WebhookStatusSchema, WebhookSummary, WebhooksTable, applicationDatabaseUrl, assertDbSplit, billingPausedCode, blockEndCursor, closeDb, closeDbOrTimeout, committedHeight, compareStreamsCursor, exports_hmac as crypto, decodeStreamsCursor, describeDbUrl, exports_ed25519 as ed25519, encodeStreamsCursor, finalizedBurnHeight, formatWebhookSchemaErrors, generateSubgraphAgentSchema, generateSubgraphMarkdown, generateSubgraphOpenApi, generateSubgraphSpec, getDb, getDbSplitStatus, getEnv, getErrorMessage, getMigrationRole, getRawClient, getRawClientFor, getSourceDb, getTargetDb, isBnsDecoderEnabled, isEmptyRangeCursor, isPox4DecoderEnabled, isPox5DecoderEnabled, isSbtcDecoderEnabled, jsonb, logger, onChainPlane, onControlPlane, parseJsonb, resolveSourceUrl, resolveTargetUrl, setMigrationRole, sql };
package/dist/src/index.js CHANGED
@@ -862,6 +862,7 @@ var TABLE_TO_DB = {
862
862
  sentinel_accounts: "target",
863
863
  waitlists: "target",
864
864
  waitlist_signups: "target",
865
+ contact_requests: "target",
865
866
  api_failed_requests: "target",
866
867
  feedback_tickets: "target",
867
868
  service_heartbeats: "both"
@@ -1266,12 +1267,6 @@ var WEBHOOK_FORMATS = [
1266
1267
  "cloudevents",
1267
1268
  "raw"
1268
1269
  ];
1269
- var WEBHOOK_RUNTIMES = [
1270
- "inngest",
1271
- "trigger",
1272
- "cloudflare",
1273
- "node"
1274
- ];
1275
1270
  var WEBHOOK_STATUSES = ["active", "paused", "error"];
1276
1271
  var WEBHOOK_MAX_RETRIES_CEILING_DEFAULT = 100;
1277
1272
  var WEBHOOK_TIMEOUT_MS_CEILING_DEFAULT = 300000;
@@ -1314,35 +1309,10 @@ function timeoutMsField() {
1314
1309
  }
1315
1310
  });
1316
1311
  }
1317
- var WEBHOOK_FILTER_OPERATORS = [
1318
- "eq",
1319
- "neq",
1320
- "gt",
1321
- "gte",
1322
- "lt",
1323
- "lte",
1324
- "in"
1325
- ];
1326
1312
  var webhookUrl = z3.string().trim().min(1).refine((value) => value.startsWith("http://") || value.startsWith("https://"), "must be an http(s) URL");
1327
1313
  var name = z3.string().trim().min(1).max(128);
1328
- var resourceName = z3.string().trim().min(1).max(128);
1329
1314
  var WebhookStatusSchema = z3.enum(WEBHOOK_STATUSES);
1330
1315
  var WebhookFormatSchema = z3.enum(WEBHOOK_FORMATS);
1331
- var WebhookRuntimeSchema = z3.enum(WEBHOOK_RUNTIMES);
1332
- var WebhookFilterPrimitiveSchema = z3.union([z3.string(), z3.number().finite(), z3.boolean()]);
1333
- var WebhookFilterOperatorSchema = z3.union([
1334
- z3.object({ eq: WebhookFilterPrimitiveSchema }).strict(),
1335
- z3.object({ neq: WebhookFilterPrimitiveSchema }).strict(),
1336
- z3.object({ gt: z3.union([z3.string(), z3.number().finite()]) }).strict(),
1337
- z3.object({ gte: z3.union([z3.string(), z3.number().finite()]) }).strict(),
1338
- z3.object({ lt: z3.union([z3.string(), z3.number().finite()]) }).strict(),
1339
- z3.object({ lte: z3.union([z3.string(), z3.number().finite()]) }).strict(),
1340
- z3.object({
1341
- in: z3.array(WebhookFilterPrimitiveSchema).min(1)
1342
- }).strict()
1343
- ]);
1344
- var WebhookFilterClauseSchema = z3.union([WebhookFilterPrimitiveSchema, WebhookFilterOperatorSchema]);
1345
- var WebhookFilterSchema = z3.record(z3.string().min(1), WebhookFilterClauseSchema);
1346
1316
  var CHAIN_TRIGGER_TYPES = [
1347
1317
  "stx_transfer",
1348
1318
  "stx_mint",
@@ -1549,37 +1519,18 @@ var CHAIN_TRIGGER_FIELDS = Object.fromEntries(ChainTriggerSchema._zod.def.option
1549
1519
  }));
1550
1520
  var CreateWebhookRequestSchema = z3.object({
1551
1521
  name,
1552
- subgraphName: resourceName.optional(),
1553
- tableName: resourceName.optional(),
1554
- filter: WebhookFilterSchema.optional(),
1555
- triggers: ChainTriggersSchema.optional(),
1522
+ triggers: ChainTriggersSchema,
1556
1523
  url: webhookUrl,
1557
1524
  format: WebhookFormatSchema.default("standard-webhooks"),
1558
- runtime: WebhookRuntimeSchema.nullable().optional(),
1559
1525
  authConfig: z3.record(z3.string(), z3.unknown()).optional(),
1560
1526
  maxRetries: maxRetriesField(),
1561
1527
  timeoutMs: timeoutMsField(),
1562
1528
  concurrency: z3.number().int().min(1).max(100).optional()
1563
- }).refine((v) => {
1564
- const subgraphMode = v.subgraphName !== undefined || v.tableName !== undefined;
1565
- const chainMode = v.triggers !== undefined;
1566
- if (chainMode && subgraphMode)
1567
- return false;
1568
- if (chainMode)
1569
- return true;
1570
- return v.subgraphName !== undefined && v.tableName !== undefined;
1571
- }, {
1572
- message: "provide either { subgraphName, tableName } for a subgraph webhook OR { triggers } for a chain webhook — not both"
1573
- }).refine((v) => v.filter === undefined || v.triggers === undefined, {
1574
- message: "`filter` applies to subgraph webhooks; chain webhooks use `triggers`",
1575
- path: ["filter"]
1576
1529
  });
1577
1530
  var UpdateWebhookRequestSchema = z3.object({
1578
1531
  name: name.optional(),
1579
1532
  url: webhookUrl.optional(),
1580
- filter: WebhookFilterSchema.optional(),
1581
1533
  format: WebhookFormatSchema.optional(),
1582
- runtime: WebhookRuntimeSchema.nullable().optional(),
1583
1534
  authConfig: z3.record(z3.string(), z3.unknown()).optional(),
1584
1535
  maxRetries: maxRetriesField(),
1585
1536
  timeoutMs: timeoutMsField(),
@@ -1685,59 +1636,12 @@ var trigger = {
1685
1636
  ...f
1686
1637
  })
1687
1638
  };
1688
- var SCALAR_COLUMN_TYPES = new Set([
1689
- "text",
1690
- "uint",
1691
- "int",
1692
- "principal",
1693
- "boolean",
1694
- "timestamp"
1695
- ]);
1696
- var COMPARISON_COLUMN_TYPES = new Set(["uint", "int", "timestamp"]);
1697
1639
  function formatIssuePath(path) {
1698
1640
  return path.length > 0 ? `${path.map(String).join(".")}: ` : "";
1699
1641
  }
1700
1642
  function formatWebhookSchemaErrors(error) {
1701
1643
  return error.issues.map((issue) => `${formatIssuePath(issue.path)}${issue.message}`);
1702
1644
  }
1703
- function operatorForClause(clause) {
1704
- if (clause === null || typeof clause !== "object" || Array.isArray(clause)) {
1705
- return "eq";
1706
- }
1707
- return Object.keys(clause)[0] ?? "eq";
1708
- }
1709
- function validateWebhookFilterForTable(input) {
1710
- const errors = [];
1711
- const table = input.tables[input.tableName];
1712
- if (!table) {
1713
- const names = Object.keys(input.tables);
1714
- errors.push(`Unknown table "${input.tableName}"${input.subgraphName ? ` in subgraph "${input.subgraphName}"` : ""}.${names.length > 0 ? ` Available tables: ${names.join(", ")}.` : ""}`);
1715
- return errors;
1716
- }
1717
- if (input.filter === undefined)
1718
- return errors;
1719
- const parsed = WebhookFilterSchema.safeParse(input.filter);
1720
- if (!parsed.success) {
1721
- return formatWebhookSchemaErrors(parsed.error);
1722
- }
1723
- for (const [field, clause] of Object.entries(parsed.data)) {
1724
- const column = table.columns[field];
1725
- if (!column) {
1726
- errors.push(`Unknown filter field "${field}" on table "${input.tableName}".`);
1727
- continue;
1728
- }
1729
- const columnType = typeof column.type === "string" ? column.type.toLowerCase() : "";
1730
- if (!SCALAR_COLUMN_TYPES.has(columnType)) {
1731
- errors.push(`Filter field "${field}" has unsupported type "${columnType || "unknown"}"; webhook filters require scalar columns.`);
1732
- continue;
1733
- }
1734
- const operator = operatorForClause(clause);
1735
- if ((operator === "gt" || operator === "gte" || operator === "lt" || operator === "lte") && !COMPARISON_COLUMN_TYPES.has(columnType)) {
1736
- errors.push(`Operator "${operator}" is not supported for ${columnType} field "${field}".`);
1737
- }
1738
- }
1739
- return errors;
1740
- }
1741
1645
  // src/subgraphs/spec.ts
1742
1646
  var SYSTEM_COLUMNS = ["_id", "_block_height", "_tx_id", "_created_at"];
1743
1647
  var BASE_QUERY_PARAMS = ["_limit", "cursor", "_order", "_fields"];
@@ -2221,16 +2125,9 @@ export {
2221
2125
  VM_STORED_TO_NODE_TYPE,
2222
2126
  ValidationError,
2223
2127
  VersionConflictError,
2224
- WEBHOOK_FILTER_OPERATORS,
2225
2128
  WEBHOOK_FORMATS,
2226
- WEBHOOK_RUNTIMES,
2227
2129
  WEBHOOK_STATUSES,
2228
- WebhookFilterClauseSchema,
2229
- WebhookFilterOperatorSchema,
2230
- WebhookFilterPrimitiveSchema,
2231
- WebhookFilterSchema,
2232
2130
  WebhookFormatSchema,
2233
- WebhookRuntimeSchema,
2234
2131
  WebhookStatusSchema,
2235
2132
  applicationDatabaseUrl,
2236
2133
  assertDbSplit,
@@ -2273,9 +2170,8 @@ export {
2273
2170
  resolveSourceUrl,
2274
2171
  resolveTargetUrl,
2275
2172
  setMigrationRole,
2276
- sql2 as sql,
2277
- validateWebhookFilterForTable
2173
+ sql2 as sql
2278
2174
  };
2279
2175
 
2280
- //# debugId=77D2A28970490BCD64756E2164756E21
2176
+ //# debugId=DB410467D2166C4B64756E2164756E21
2281
2177
  //# sourceMappingURL=index.js.map