@secondlayer/shared 11.24.0 → 12.0.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 (34) hide show
  1. package/dist/src/archive/range-digest.d.ts +8 -19
  2. package/dist/src/archive/semantic-digest-builder.d.ts +8 -19
  3. package/dist/src/coverage/index.d.ts +8 -19
  4. package/dist/src/db/index.d.ts +9 -20
  5. package/dist/src/db/queries/chain-reorgs.d.ts +8 -19
  6. package/dist/src/db/queries/contracts.d.ts +8 -19
  7. package/dist/src/db/queries/instance.d.ts +8 -19
  8. package/dist/src/db/queries/integrity.d.ts +8 -19
  9. package/dist/src/db/queries/subgraph-gaps.d.ts +8 -19
  10. package/dist/src/db/queries/subgraph-operations.d.ts +8 -19
  11. package/dist/src/db/queries/subgraphs.d.ts +8 -19
  12. package/dist/src/db/queries/subgraphs.js +1 -7
  13. package/dist/src/db/queries/subgraphs.js.map +4 -4
  14. package/dist/src/db/queries/sync-scope.d.ts +8 -19
  15. package/dist/src/db/queries/webhooks.d.ts +11 -33
  16. package/dist/src/db/queries/webhooks.js +3 -12
  17. package/dist/src/db/queries/webhooks.js.map +3 -3
  18. package/dist/src/db/schema.d.ts +9 -20
  19. package/dist/src/index.d.ts +15 -81
  20. package/dist/src/index.js +3 -108
  21. package/dist/src/index.js.map +4 -4
  22. package/dist/src/node/local-client.d.ts +8 -19
  23. package/dist/src/runtime/index.js +2 -2
  24. package/dist/src/runtime/index.js.map +3 -3
  25. package/dist/src/schemas/index.d.ts +7 -62
  26. package/dist/src/schemas/index.js +3 -108
  27. package/dist/src/schemas/index.js.map +4 -4
  28. package/dist/src/schemas/subgraphs.d.ts +0 -2
  29. package/dist/src/schemas/subgraphs.js.map +1 -1
  30. package/dist/src/schemas/webhooks.d.ts +10 -65
  31. package/dist/src/schemas/webhooks.js +2 -107
  32. package/dist/src/schemas/webhooks.js.map +3 -3
  33. package/migrations/0159_drop_subgraph_row_webhooks.ts +91 -0
  34. 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 {
@@ -1234,12 +1232,11 @@ type InsertSubgraphHealthSnapshot = Insertable<SubgraphHealthSnapshotsTable>;
1234
1232
  type SubgraphGap = Selectable<SubgraphGapsTable>;
1235
1233
  type InsertSubgraphGap = Insertable<SubgraphGapsTable>;
1236
1234
  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";
1235
+ /** Webhooks react to raw chain events matched directly off the Index/Streams
1236
+ * clock. `chain` is the only kind since migration 0159 removed subgraph-row
1237
+ * webhooks; the column stays as the discriminator. */
1238
+ type WebhookKind = "chain";
1241
1239
  type WebhookFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
1242
- type WebhookRuntime = "inngest" | "trigger" | "cloudflare" | "node";
1243
1240
  interface WebhooksTable {
1244
1241
  id: Generated<string>;
1245
1242
  account_id: string;
@@ -1247,17 +1244,11 @@ interface WebhooksTable {
1247
1244
  name: string;
1248
1245
  status: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;
1249
1246
  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>;
1247
+ /** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Typed
1248
+ * loosely here to avoid a shared→subgraphs import cycle; the Zod schema in
1249
+ * schemas/webhooks.ts owns the shape. */
1250
+ triggers: unknown;
1259
1251
  format: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;
1260
- runtime: WebhookRuntime | null;
1261
1252
  url: string;
1262
1253
  signing_secret_enc: Buffer;
1263
1254
  auth_config: Generated<unknown>;
@@ -1280,10 +1271,6 @@ interface WebhookOutboxTable {
1280
1271
  id: Generated<string>;
1281
1272
  webhook_id: string;
1282
1273
  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
1274
  block_height: number | bigint;
1288
1275
  tx_id: string | null;
1289
1276
  row_pk: unknown;
@@ -2695,16 +2682,9 @@ declare class Logger {
2695
2682
  declare const logger: Logger;
2696
2683
  import { z as z3 } from "zod";
2697
2684
  declare const WEBHOOK_FORMATS: readonly ["standard-webhooks", "inngest", "trigger", "cloudflare", "cloudevents", "raw"];
2698
- declare const WEBHOOK_RUNTIMES: readonly ["inngest", "trigger", "cloudflare", "node"];
2699
2685
  declare const WEBHOOK_STATUSES: readonly ["active", "paused", "error"];
2700
- declare const WEBHOOK_FILTER_OPERATORS: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "in"];
2701
2686
  declare const WebhookStatusSchema: z3.ZodType<WebhookStatus2>;
2702
2687
  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
2688
  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
2689
  /**
2710
2690
  * Per-type accepted filter fields for chain triggers, DERIVED from
@@ -2716,28 +2696,9 @@ declare const CreateWebhookRequestSchema: z3.ZodType<ParsedCreateWebhookRequest>
2716
2696
  declare const UpdateWebhookRequestSchema: z3.ZodType<UpdateWebhookRequest>;
2717
2697
  declare const ReplayWebhookRequestSchema: z3.ZodType<ReplayWebhookRequest>;
2718
2698
  type WebhookStatus2 = (typeof WEBHOOK_STATUSES)[number];
2719
- /** Polymorphic webhook mode (mirrors db/types `WebhookKind`). */
2720
- type WebhookKind2 = "subgraph" | "chain";
2699
+ /** Webhook kind (mirrors db/types `WebhookKind`). Chain events only. */
2700
+ type WebhookKind2 = "chain";
2721
2701
  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
2702
  /** Non-negative integer amount over JSON (string for uint128 safety, or number). */
2742
2703
  type ChainTriggerAmount = string | number;
2743
2704
  interface TraitScoped {
@@ -2867,15 +2828,9 @@ type ChainTrigger = {
2867
2828
  };
2868
2829
  interface CreateWebhookRequest {
2869
2830
  name: string;
2870
- /** Subgraph mode. */
2871
- subgraphName?: string;
2872
- tableName?: string;
2873
- filter?: WebhookFilter;
2874
- /** Chain mode. */
2875
- triggers?: ChainTrigger[];
2831
+ triggers: ChainTrigger[];
2876
2832
  url: string;
2877
2833
  format?: WebhookFormat2;
2878
- runtime?: WebhookRuntime2 | null;
2879
2834
  authConfig?: Record<string, unknown>;
2880
2835
  maxRetries?: number;
2881
2836
  timeoutMs?: number;
@@ -2887,9 +2842,7 @@ interface ParsedCreateWebhookRequest extends Omit<CreateWebhookRequest, "format"
2887
2842
  interface UpdateWebhookRequest {
2888
2843
  name?: string;
2889
2844
  url?: string;
2890
- filter?: WebhookFilter;
2891
2845
  format?: WebhookFormat2;
2892
- runtime?: WebhookRuntime2 | null;
2893
2846
  authConfig?: Record<string, unknown>;
2894
2847
  maxRetries?: number;
2895
2848
  timeoutMs?: number;
@@ -2907,12 +2860,7 @@ interface WebhookSummary {
2907
2860
  name: string;
2908
2861
  status: WebhookStatus2;
2909
2862
  kind: WebhookKind2;
2910
- /** Null for chain webhooks. */
2911
- subgraphName: string | null;
2912
- /** Null for chain webhooks. */
2913
- tableName: string | null;
2914
2863
  format: WebhookFormat2;
2915
- runtime: WebhookRuntime2 | null;
2916
2864
  url: string;
2917
2865
  lastDeliveryAt: string | null;
2918
2866
  lastSuccessAt: string | null;
@@ -2940,15 +2888,14 @@ interface WebhookAuth {
2940
2888
  hasSecret: boolean;
2941
2889
  }
2942
2890
  interface WebhookDetail extends WebhookSummary {
2943
- filter: Record<string, unknown>;
2944
- /** Chain-trigger filters (chain webhooks only). */
2945
- triggers: ChainTrigger[] | null;
2891
+ /** Chain-trigger filters. */
2892
+ triggers: ChainTrigger[];
2946
2893
  auth: WebhookAuth;
2947
2894
  maxRetries: number;
2948
2895
  timeoutMs: number;
2949
2896
  concurrency: number;
2950
2897
  lastError: string | null;
2951
- /** Set on a `kind="chain"` webhook when this instance's chain-trigger
2898
+ /** Set when this instance's chain-trigger
2952
2899
  * evaluator isn't running (`SUBGRAPH_SOURCE` != `streams-index`) — the
2953
2900
  * webhook will never fire until that's fixed. Null otherwise. Surfaced
2954
2901
  * on create (so it's seen immediately) and on every read (so `secondlayer
@@ -3003,20 +2950,7 @@ interface DeadRow {
3003
2950
  failedAt: string | null;
3004
2951
  createdAt: string;
3005
2952
  }
3006
- interface WebhookSchemaColumn {
3007
- type?: unknown;
3008
- }
3009
- interface WebhookSchemaTable {
3010
- columns: Record<string, WebhookSchemaColumn>;
3011
- }
3012
- type WebhookSchemaTables = Record<string, WebhookSchemaTable>;
3013
2953
  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
2954
  type SubgraphSpecFormat = "openapi" | "agent" | "markdown";
3021
2955
  interface SubgraphSpecOptions {
3022
2956
  serverUrl?: string;
@@ -3450,4 +3384,4 @@ declare function publicKeyPemFromPrivate(privateKeyPem: string): string;
3450
3384
  declare function ed25519KeyId(publicKeyPem: string): string;
3451
3385
  declare function signEd25519(payload: string, privateKey: KeyObject): string;
3452
3386
  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 };
3387
+ 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_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
@@ -1266,12 +1266,6 @@ var WEBHOOK_FORMATS = [
1266
1266
  "cloudevents",
1267
1267
  "raw"
1268
1268
  ];
1269
- var WEBHOOK_RUNTIMES = [
1270
- "inngest",
1271
- "trigger",
1272
- "cloudflare",
1273
- "node"
1274
- ];
1275
1269
  var WEBHOOK_STATUSES = ["active", "paused", "error"];
1276
1270
  var WEBHOOK_MAX_RETRIES_CEILING_DEFAULT = 100;
1277
1271
  var WEBHOOK_TIMEOUT_MS_CEILING_DEFAULT = 300000;
@@ -1314,35 +1308,10 @@ function timeoutMsField() {
1314
1308
  }
1315
1309
  });
1316
1310
  }
1317
- var WEBHOOK_FILTER_OPERATORS = [
1318
- "eq",
1319
- "neq",
1320
- "gt",
1321
- "gte",
1322
- "lt",
1323
- "lte",
1324
- "in"
1325
- ];
1326
1311
  var webhookUrl = z3.string().trim().min(1).refine((value) => value.startsWith("http://") || value.startsWith("https://"), "must be an http(s) URL");
1327
1312
  var name = z3.string().trim().min(1).max(128);
1328
- var resourceName = z3.string().trim().min(1).max(128);
1329
1313
  var WebhookStatusSchema = z3.enum(WEBHOOK_STATUSES);
1330
1314
  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
1315
  var CHAIN_TRIGGER_TYPES = [
1347
1316
  "stx_transfer",
1348
1317
  "stx_mint",
@@ -1549,37 +1518,18 @@ var CHAIN_TRIGGER_FIELDS = Object.fromEntries(ChainTriggerSchema._zod.def.option
1549
1518
  }));
1550
1519
  var CreateWebhookRequestSchema = z3.object({
1551
1520
  name,
1552
- subgraphName: resourceName.optional(),
1553
- tableName: resourceName.optional(),
1554
- filter: WebhookFilterSchema.optional(),
1555
- triggers: ChainTriggersSchema.optional(),
1521
+ triggers: ChainTriggersSchema,
1556
1522
  url: webhookUrl,
1557
1523
  format: WebhookFormatSchema.default("standard-webhooks"),
1558
- runtime: WebhookRuntimeSchema.nullable().optional(),
1559
1524
  authConfig: z3.record(z3.string(), z3.unknown()).optional(),
1560
1525
  maxRetries: maxRetriesField(),
1561
1526
  timeoutMs: timeoutMsField(),
1562
1527
  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
1528
  });
1577
1529
  var UpdateWebhookRequestSchema = z3.object({
1578
1530
  name: name.optional(),
1579
1531
  url: webhookUrl.optional(),
1580
- filter: WebhookFilterSchema.optional(),
1581
1532
  format: WebhookFormatSchema.optional(),
1582
- runtime: WebhookRuntimeSchema.nullable().optional(),
1583
1533
  authConfig: z3.record(z3.string(), z3.unknown()).optional(),
1584
1534
  maxRetries: maxRetriesField(),
1585
1535
  timeoutMs: timeoutMsField(),
@@ -1685,59 +1635,12 @@ var trigger = {
1685
1635
  ...f
1686
1636
  })
1687
1637
  };
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
1638
  function formatIssuePath(path) {
1698
1639
  return path.length > 0 ? `${path.map(String).join(".")}: ` : "";
1699
1640
  }
1700
1641
  function formatWebhookSchemaErrors(error) {
1701
1642
  return error.issues.map((issue) => `${formatIssuePath(issue.path)}${issue.message}`);
1702
1643
  }
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
1644
  // src/subgraphs/spec.ts
1742
1645
  var SYSTEM_COLUMNS = ["_id", "_block_height", "_tx_id", "_created_at"];
1743
1646
  var BASE_QUERY_PARAMS = ["_limit", "cursor", "_order", "_fields"];
@@ -2221,16 +2124,9 @@ export {
2221
2124
  VM_STORED_TO_NODE_TYPE,
2222
2125
  ValidationError,
2223
2126
  VersionConflictError,
2224
- WEBHOOK_FILTER_OPERATORS,
2225
2127
  WEBHOOK_FORMATS,
2226
- WEBHOOK_RUNTIMES,
2227
2128
  WEBHOOK_STATUSES,
2228
- WebhookFilterClauseSchema,
2229
- WebhookFilterOperatorSchema,
2230
- WebhookFilterPrimitiveSchema,
2231
- WebhookFilterSchema,
2232
2129
  WebhookFormatSchema,
2233
- WebhookRuntimeSchema,
2234
2130
  WebhookStatusSchema,
2235
2131
  applicationDatabaseUrl,
2236
2132
  assertDbSplit,
@@ -2273,9 +2169,8 @@ export {
2273
2169
  resolveSourceUrl,
2274
2170
  resolveTargetUrl,
2275
2171
  setMigrationRole,
2276
- sql2 as sql,
2277
- validateWebhookFilterForTable
2172
+ sql2 as sql
2278
2173
  };
2279
2174
 
2280
- //# debugId=77D2A28970490BCD64756E2164756E21
2175
+ //# debugId=27D3F58AD44EB36764756E2164756E21
2281
2176
  //# sourceMappingURL=index.js.map