@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.
- package/README.md +4 -4
- package/dist/src/archive/derived-stage-report.d.ts +2 -2
- package/dist/src/archive/derived-stage-report.js.map +1 -1
- package/dist/src/archive/instance-diagnosis.js +2 -2
- package/dist/src/archive/instance-diagnosis.js.map +2 -2
- package/dist/src/archive/range-digest.d.ts +25 -25
- package/dist/src/archive/semantic-digest-builder.d.ts +25 -25
- package/dist/src/archive/status.d.ts +32 -7
- package/dist/src/archive/status.js +20 -3
- package/dist/src/archive/status.js.map +3 -3
- package/dist/src/coverage/index.d.ts +25 -25
- package/dist/src/coverage/index.js.map +1 -1
- package/dist/src/crypto/secondlayer-webhook.d.ts +2 -2
- package/dist/src/crypto/secondlayer-webhook.js.map +1 -1
- package/dist/src/crypto/secrets.js.map +1 -1
- package/dist/src/db/index.d.ts +37 -37
- package/dist/src/db/index.js +4 -4
- package/dist/src/db/index.js.map +3 -3
- package/dist/src/db/queries/chain-reorgs.d.ts +25 -25
- package/dist/src/db/queries/chain-reorgs.js +4 -4
- package/dist/src/db/queries/chain-reorgs.js.map +3 -3
- package/dist/src/db/queries/contracts.d.ts +25 -25
- package/dist/src/db/queries/instance.d.ts +25 -25
- package/dist/src/db/queries/integrity.d.ts +25 -25
- package/dist/src/db/queries/subgraph-gaps.d.ts +25 -25
- package/dist/src/db/queries/subgraph-operations.d.ts +25 -25
- package/dist/src/db/queries/subgraphs.d.ts +25 -25
- package/dist/src/db/queries/subgraphs.js +4 -4
- package/dist/src/db/queries/subgraphs.js.map +3 -3
- package/dist/src/db/queries/sync-scope.d.ts +25 -25
- package/dist/src/db/queries/{subscriptions.d.ts → webhooks.d.ts} +58 -58
- package/dist/src/db/queries/{subscriptions.js → webhooks.js} +38 -38
- package/dist/src/db/queries/webhooks.js.map +13 -0
- package/dist/src/db/schema.d.ts +34 -34
- package/dist/src/index.d.ts +109 -107
- package/dist/src/index.js +51 -54
- package/dist/src/index.js.map +6 -6
- package/dist/src/leader.d.ts +4 -4
- package/dist/src/leader.js +3 -3
- package/dist/src/leader.js.map +3 -3
- package/dist/src/node/local-client.d.ts +25 -25
- package/dist/src/queue/listener.d.ts +2 -2
- package/dist/src/queue/listener.js.map +1 -1
- package/dist/src/runtime/index.js +2 -6
- package/dist/src/runtime/index.js.map +4 -4
- package/dist/src/schemas/index.d.ts +61 -61
- package/dist/src/schemas/index.js +48 -51
- package/dist/src/schemas/index.js.map +5 -5
- package/dist/src/schemas/subgraphs.d.ts +2 -2
- package/dist/src/schemas/subgraphs.js.map +1 -1
- package/dist/src/schemas/{subscriptions.d.ts → webhooks.d.ts} +63 -63
- package/dist/src/schemas/{subscriptions.js → webhooks.js} +49 -52
- package/dist/src/schemas/webhooks.js.map +10 -0
- package/migrations/0126_rename_subscriptions_to_webhooks.ts +96 -0
- package/migrations/0127_rename_webhook_catalog_names.ts +55 -0
- package/package.json +8 -8
- package/dist/src/db/queries/subscriptions.js.map +0 -13
- package/dist/src/schemas/subscriptions.js.map +0 -10
|
@@ -789,9 +789,9 @@ interface Database {
|
|
|
789
789
|
account_spend_caps: AccountSpendCapsTable;
|
|
790
790
|
account_credits: AccountCreditsTable;
|
|
791
791
|
hosted_meter_days: HostedMeterDaysTable;
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
792
|
+
webhooks: WebhooksTable;
|
|
793
|
+
webhook_outbox: WebhookOutboxTable;
|
|
794
|
+
webhook_deliveries: WebhookDeliveriesTable;
|
|
795
795
|
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
796
796
|
decoded_events: DecodedEventsTable;
|
|
797
797
|
decoder_checkpoints: DecoderCheckpointsTable;
|
|
@@ -912,31 +912,31 @@ interface ArchiveFetchesTable {
|
|
|
912
912
|
charged_at: Generated<Date>;
|
|
913
913
|
}
|
|
914
914
|
type Contract = Selectable<ContractsTable>;
|
|
915
|
-
type
|
|
916
|
-
/** Polymorphic
|
|
915
|
+
type WebhookStatus = "active" | "paused" | "error";
|
|
916
|
+
/** Polymorphic webhook mode: `subgraph` reacts to processed table rows;
|
|
917
917
|
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
918
918
|
* clock (no subgraph). See migration 0088. */
|
|
919
|
-
type
|
|
920
|
-
type
|
|
921
|
-
type
|
|
922
|
-
interface
|
|
919
|
+
type WebhookKind = "subgraph" | "chain";
|
|
920
|
+
type WebhookFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
921
|
+
type WebhookRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
922
|
+
interface WebhooksTable {
|
|
923
923
|
id: Generated<string>;
|
|
924
924
|
account_id: string;
|
|
925
925
|
project_id: string | null;
|
|
926
926
|
name: string;
|
|
927
|
-
status: ColumnType<
|
|
928
|
-
kind: ColumnType<
|
|
929
|
-
/** Null for chain
|
|
927
|
+
status: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;
|
|
928
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
929
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
930
930
|
subgraph_name: string | null;
|
|
931
|
-
/** Null for chain
|
|
931
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
932
932
|
table_name: string | null;
|
|
933
933
|
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
934
|
-
* subgraph
|
|
935
|
-
* import cycle; the Zod schema in schemas/
|
|
934
|
+
* subgraph webhooks. Typed loosely here to avoid a shared→subgraphs
|
|
935
|
+
* import cycle; the Zod schema in schemas/webhooks.ts owns the shape. */
|
|
936
936
|
triggers: unknown | null;
|
|
937
937
|
filter: Generated<unknown>;
|
|
938
|
-
format: ColumnType<
|
|
939
|
-
runtime:
|
|
938
|
+
format: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;
|
|
939
|
+
runtime: WebhookRuntime | null;
|
|
940
940
|
url: string;
|
|
941
941
|
signing_secret_enc: Buffer;
|
|
942
942
|
auth_config: Generated<unknown>;
|
|
@@ -952,13 +952,13 @@ interface SubscriptionsTable {
|
|
|
952
952
|
updated_at: Generated<Date>;
|
|
953
953
|
}
|
|
954
954
|
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
955
|
-
interface
|
|
955
|
+
interface WebhookOutboxTable {
|
|
956
956
|
id: Generated<string>;
|
|
957
|
-
|
|
958
|
-
kind: ColumnType<
|
|
959
|
-
/** Null for chain-
|
|
957
|
+
webhook_id: string;
|
|
958
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
959
|
+
/** Null for chain-webhook rows. */
|
|
960
960
|
subgraph_name: string | null;
|
|
961
|
-
/** Null for chain-
|
|
961
|
+
/** Null for chain-webhook rows. */
|
|
962
962
|
table_name: string | null;
|
|
963
963
|
block_height: number | bigint;
|
|
964
964
|
tx_id: string | null;
|
|
@@ -976,12 +976,12 @@ interface SubscriptionOutboxTable {
|
|
|
976
976
|
locked_until: Date | null;
|
|
977
977
|
created_at: Generated<Date>;
|
|
978
978
|
}
|
|
979
|
-
interface
|
|
979
|
+
interface WebhookDeliveriesTable {
|
|
980
980
|
id: Generated<string>;
|
|
981
981
|
/** Nullable after migration 0077 — outbox row may be cleaned up while
|
|
982
982
|
* delivery telemetry is retained. */
|
|
983
983
|
outbox_id: string | null;
|
|
984
|
-
|
|
984
|
+
webhook_id: string;
|
|
985
985
|
attempt: number;
|
|
986
986
|
status_code: number | null;
|
|
987
987
|
response_headers: unknown | null;
|
|
@@ -991,7 +991,7 @@ interface SubscriptionDeliveriesTable {
|
|
|
991
991
|
dispatched_at: Generated<Date>;
|
|
992
992
|
}
|
|
993
993
|
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
994
|
-
* One loop serves all chain
|
|
994
|
+
* One loop serves all chain webhooks, so the cursor is global. */
|
|
995
995
|
interface TriggerEvaluatorStateTable {
|
|
996
996
|
id: Generated<boolean>;
|
|
997
997
|
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
@@ -789,9 +789,9 @@ interface Database {
|
|
|
789
789
|
account_spend_caps: AccountSpendCapsTable;
|
|
790
790
|
account_credits: AccountCreditsTable;
|
|
791
791
|
hosted_meter_days: HostedMeterDaysTable;
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
792
|
+
webhooks: WebhooksTable;
|
|
793
|
+
webhook_outbox: WebhookOutboxTable;
|
|
794
|
+
webhook_deliveries: WebhookDeliveriesTable;
|
|
795
795
|
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
796
796
|
decoded_events: DecodedEventsTable;
|
|
797
797
|
decoder_checkpoints: DecoderCheckpointsTable;
|
|
@@ -911,31 +911,31 @@ interface ArchiveFetchesTable {
|
|
|
911
911
|
via_allowance: Generated<boolean>;
|
|
912
912
|
charged_at: Generated<Date>;
|
|
913
913
|
}
|
|
914
|
-
type
|
|
915
|
-
/** Polymorphic
|
|
914
|
+
type WebhookStatus = "active" | "paused" | "error";
|
|
915
|
+
/** Polymorphic webhook mode: `subgraph` reacts to processed table rows;
|
|
916
916
|
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
917
917
|
* clock (no subgraph). See migration 0088. */
|
|
918
|
-
type
|
|
919
|
-
type
|
|
920
|
-
type
|
|
921
|
-
interface
|
|
918
|
+
type WebhookKind = "subgraph" | "chain";
|
|
919
|
+
type WebhookFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
920
|
+
type WebhookRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
921
|
+
interface WebhooksTable {
|
|
922
922
|
id: Generated<string>;
|
|
923
923
|
account_id: string;
|
|
924
924
|
project_id: string | null;
|
|
925
925
|
name: string;
|
|
926
|
-
status: ColumnType<
|
|
927
|
-
kind: ColumnType<
|
|
928
|
-
/** Null for chain
|
|
926
|
+
status: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;
|
|
927
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
928
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
929
929
|
subgraph_name: string | null;
|
|
930
|
-
/** Null for chain
|
|
930
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
931
931
|
table_name: string | null;
|
|
932
932
|
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
933
|
-
* subgraph
|
|
934
|
-
* import cycle; the Zod schema in schemas/
|
|
933
|
+
* subgraph webhooks. Typed loosely here to avoid a shared→subgraphs
|
|
934
|
+
* import cycle; the Zod schema in schemas/webhooks.ts owns the shape. */
|
|
935
935
|
triggers: unknown | null;
|
|
936
936
|
filter: Generated<unknown>;
|
|
937
|
-
format: ColumnType<
|
|
938
|
-
runtime:
|
|
937
|
+
format: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;
|
|
938
|
+
runtime: WebhookRuntime | null;
|
|
939
939
|
url: string;
|
|
940
940
|
signing_secret_enc: Buffer;
|
|
941
941
|
auth_config: Generated<unknown>;
|
|
@@ -951,13 +951,13 @@ interface SubscriptionsTable {
|
|
|
951
951
|
updated_at: Generated<Date>;
|
|
952
952
|
}
|
|
953
953
|
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
954
|
-
interface
|
|
954
|
+
interface WebhookOutboxTable {
|
|
955
955
|
id: Generated<string>;
|
|
956
|
-
|
|
957
|
-
kind: ColumnType<
|
|
958
|
-
/** Null for chain-
|
|
956
|
+
webhook_id: string;
|
|
957
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
958
|
+
/** Null for chain-webhook rows. */
|
|
959
959
|
subgraph_name: string | null;
|
|
960
|
-
/** Null for chain-
|
|
960
|
+
/** Null for chain-webhook rows. */
|
|
961
961
|
table_name: string | null;
|
|
962
962
|
block_height: number | bigint;
|
|
963
963
|
tx_id: string | null;
|
|
@@ -975,12 +975,12 @@ interface SubscriptionOutboxTable {
|
|
|
975
975
|
locked_until: Date | null;
|
|
976
976
|
created_at: Generated<Date>;
|
|
977
977
|
}
|
|
978
|
-
interface
|
|
978
|
+
interface WebhookDeliveriesTable {
|
|
979
979
|
id: Generated<string>;
|
|
980
980
|
/** Nullable after migration 0077 — outbox row may be cleaned up while
|
|
981
981
|
* delivery telemetry is retained. */
|
|
982
982
|
outbox_id: string | null;
|
|
983
|
-
|
|
983
|
+
webhook_id: string;
|
|
984
984
|
attempt: number;
|
|
985
985
|
status_code: number | null;
|
|
986
986
|
response_headers: unknown | null;
|
|
@@ -990,7 +990,7 @@ interface SubscriptionDeliveriesTable {
|
|
|
990
990
|
dispatched_at: Generated<Date>;
|
|
991
991
|
}
|
|
992
992
|
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
993
|
-
* One loop serves all chain
|
|
993
|
+
* One loop serves all chain webhooks, so the cursor is global. */
|
|
994
994
|
interface TriggerEvaluatorStateTable {
|
|
995
995
|
id: Generated<boolean>;
|
|
996
996
|
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
@@ -789,9 +789,9 @@ interface Database {
|
|
|
789
789
|
account_spend_caps: AccountSpendCapsTable;
|
|
790
790
|
account_credits: AccountCreditsTable;
|
|
791
791
|
hosted_meter_days: HostedMeterDaysTable;
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
792
|
+
webhooks: WebhooksTable;
|
|
793
|
+
webhook_outbox: WebhookOutboxTable;
|
|
794
|
+
webhook_deliveries: WebhookDeliveriesTable;
|
|
795
795
|
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
796
796
|
decoded_events: DecodedEventsTable;
|
|
797
797
|
decoder_checkpoints: DecoderCheckpointsTable;
|
|
@@ -911,31 +911,31 @@ interface ArchiveFetchesTable {
|
|
|
911
911
|
via_allowance: Generated<boolean>;
|
|
912
912
|
charged_at: Generated<Date>;
|
|
913
913
|
}
|
|
914
|
-
type
|
|
915
|
-
/** Polymorphic
|
|
914
|
+
type WebhookStatus = "active" | "paused" | "error";
|
|
915
|
+
/** Polymorphic webhook mode: `subgraph` reacts to processed table rows;
|
|
916
916
|
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
917
917
|
* clock (no subgraph). See migration 0088. */
|
|
918
|
-
type
|
|
919
|
-
type
|
|
920
|
-
type
|
|
921
|
-
interface
|
|
918
|
+
type WebhookKind = "subgraph" | "chain";
|
|
919
|
+
type WebhookFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
920
|
+
type WebhookRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
921
|
+
interface WebhooksTable {
|
|
922
922
|
id: Generated<string>;
|
|
923
923
|
account_id: string;
|
|
924
924
|
project_id: string | null;
|
|
925
925
|
name: string;
|
|
926
|
-
status: ColumnType<
|
|
927
|
-
kind: ColumnType<
|
|
928
|
-
/** Null for chain
|
|
926
|
+
status: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;
|
|
927
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
928
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
929
929
|
subgraph_name: string | null;
|
|
930
|
-
/** Null for chain
|
|
930
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
931
931
|
table_name: string | null;
|
|
932
932
|
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
933
|
-
* subgraph
|
|
934
|
-
* import cycle; the Zod schema in schemas/
|
|
933
|
+
* subgraph webhooks. Typed loosely here to avoid a shared→subgraphs
|
|
934
|
+
* import cycle; the Zod schema in schemas/webhooks.ts owns the shape. */
|
|
935
935
|
triggers: unknown | null;
|
|
936
936
|
filter: Generated<unknown>;
|
|
937
|
-
format: ColumnType<
|
|
938
|
-
runtime:
|
|
937
|
+
format: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;
|
|
938
|
+
runtime: WebhookRuntime | null;
|
|
939
939
|
url: string;
|
|
940
940
|
signing_secret_enc: Buffer;
|
|
941
941
|
auth_config: Generated<unknown>;
|
|
@@ -951,13 +951,13 @@ interface SubscriptionsTable {
|
|
|
951
951
|
updated_at: Generated<Date>;
|
|
952
952
|
}
|
|
953
953
|
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
954
|
-
interface
|
|
954
|
+
interface WebhookOutboxTable {
|
|
955
955
|
id: Generated<string>;
|
|
956
|
-
|
|
957
|
-
kind: ColumnType<
|
|
958
|
-
/** Null for chain-
|
|
956
|
+
webhook_id: string;
|
|
957
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
958
|
+
/** Null for chain-webhook rows. */
|
|
959
959
|
subgraph_name: string | null;
|
|
960
|
-
/** Null for chain-
|
|
960
|
+
/** Null for chain-webhook rows. */
|
|
961
961
|
table_name: string | null;
|
|
962
962
|
block_height: number | bigint;
|
|
963
963
|
tx_id: string | null;
|
|
@@ -975,12 +975,12 @@ interface SubscriptionOutboxTable {
|
|
|
975
975
|
locked_until: Date | null;
|
|
976
976
|
created_at: Generated<Date>;
|
|
977
977
|
}
|
|
978
|
-
interface
|
|
978
|
+
interface WebhookDeliveriesTable {
|
|
979
979
|
id: Generated<string>;
|
|
980
980
|
/** Nullable after migration 0077 — outbox row may be cleaned up while
|
|
981
981
|
* delivery telemetry is retained. */
|
|
982
982
|
outbox_id: string | null;
|
|
983
|
-
|
|
983
|
+
webhook_id: string;
|
|
984
984
|
attempt: number;
|
|
985
985
|
status_code: number | null;
|
|
986
986
|
response_headers: unknown | null;
|
|
@@ -990,7 +990,7 @@ interface SubscriptionDeliveriesTable {
|
|
|
990
990
|
dispatched_at: Generated<Date>;
|
|
991
991
|
}
|
|
992
992
|
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
993
|
-
* One loop serves all chain
|
|
993
|
+
* One loop serves all chain webhooks, so the cursor is global. */
|
|
994
994
|
interface TriggerEvaluatorStateTable {
|
|
995
995
|
id: Generated<boolean>;
|
|
996
996
|
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
@@ -789,9 +789,9 @@ interface Database {
|
|
|
789
789
|
account_spend_caps: AccountSpendCapsTable;
|
|
790
790
|
account_credits: AccountCreditsTable;
|
|
791
791
|
hosted_meter_days: HostedMeterDaysTable;
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
792
|
+
webhooks: WebhooksTable;
|
|
793
|
+
webhook_outbox: WebhookOutboxTable;
|
|
794
|
+
webhook_deliveries: WebhookDeliveriesTable;
|
|
795
795
|
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
796
796
|
decoded_events: DecodedEventsTable;
|
|
797
797
|
decoder_checkpoints: DecoderCheckpointsTable;
|
|
@@ -911,31 +911,31 @@ interface ArchiveFetchesTable {
|
|
|
911
911
|
via_allowance: Generated<boolean>;
|
|
912
912
|
charged_at: Generated<Date>;
|
|
913
913
|
}
|
|
914
|
-
type
|
|
915
|
-
/** Polymorphic
|
|
914
|
+
type WebhookStatus = "active" | "paused" | "error";
|
|
915
|
+
/** Polymorphic webhook mode: `subgraph` reacts to processed table rows;
|
|
916
916
|
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
917
917
|
* clock (no subgraph). See migration 0088. */
|
|
918
|
-
type
|
|
919
|
-
type
|
|
920
|
-
type
|
|
921
|
-
interface
|
|
918
|
+
type WebhookKind = "subgraph" | "chain";
|
|
919
|
+
type WebhookFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
920
|
+
type WebhookRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
921
|
+
interface WebhooksTable {
|
|
922
922
|
id: Generated<string>;
|
|
923
923
|
account_id: string;
|
|
924
924
|
project_id: string | null;
|
|
925
925
|
name: string;
|
|
926
|
-
status: ColumnType<
|
|
927
|
-
kind: ColumnType<
|
|
928
|
-
/** Null for chain
|
|
926
|
+
status: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;
|
|
927
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
928
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
929
929
|
subgraph_name: string | null;
|
|
930
|
-
/** Null for chain
|
|
930
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
931
931
|
table_name: string | null;
|
|
932
932
|
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
933
|
-
* subgraph
|
|
934
|
-
* import cycle; the Zod schema in schemas/
|
|
933
|
+
* subgraph webhooks. Typed loosely here to avoid a shared→subgraphs
|
|
934
|
+
* import cycle; the Zod schema in schemas/webhooks.ts owns the shape. */
|
|
935
935
|
triggers: unknown | null;
|
|
936
936
|
filter: Generated<unknown>;
|
|
937
|
-
format: ColumnType<
|
|
938
|
-
runtime:
|
|
937
|
+
format: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;
|
|
938
|
+
runtime: WebhookRuntime | null;
|
|
939
939
|
url: string;
|
|
940
940
|
signing_secret_enc: Buffer;
|
|
941
941
|
auth_config: Generated<unknown>;
|
|
@@ -951,13 +951,13 @@ interface SubscriptionsTable {
|
|
|
951
951
|
updated_at: Generated<Date>;
|
|
952
952
|
}
|
|
953
953
|
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
954
|
-
interface
|
|
954
|
+
interface WebhookOutboxTable {
|
|
955
955
|
id: Generated<string>;
|
|
956
|
-
|
|
957
|
-
kind: ColumnType<
|
|
958
|
-
/** Null for chain-
|
|
956
|
+
webhook_id: string;
|
|
957
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
958
|
+
/** Null for chain-webhook rows. */
|
|
959
959
|
subgraph_name: string | null;
|
|
960
|
-
/** Null for chain-
|
|
960
|
+
/** Null for chain-webhook rows. */
|
|
961
961
|
table_name: string | null;
|
|
962
962
|
block_height: number | bigint;
|
|
963
963
|
tx_id: string | null;
|
|
@@ -975,12 +975,12 @@ interface SubscriptionOutboxTable {
|
|
|
975
975
|
locked_until: Date | null;
|
|
976
976
|
created_at: Generated<Date>;
|
|
977
977
|
}
|
|
978
|
-
interface
|
|
978
|
+
interface WebhookDeliveriesTable {
|
|
979
979
|
id: Generated<string>;
|
|
980
980
|
/** Nullable after migration 0077 — outbox row may be cleaned up while
|
|
981
981
|
* delivery telemetry is retained. */
|
|
982
982
|
outbox_id: string | null;
|
|
983
|
-
|
|
983
|
+
webhook_id: string;
|
|
984
984
|
attempt: number;
|
|
985
985
|
status_code: number | null;
|
|
986
986
|
response_headers: unknown | null;
|
|
@@ -990,7 +990,7 @@ interface SubscriptionDeliveriesTable {
|
|
|
990
990
|
dispatched_at: Generated<Date>;
|
|
991
991
|
}
|
|
992
992
|
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
993
|
-
* One loop serves all chain
|
|
993
|
+
* One loop serves all chain webhooks, so the cursor is global. */
|
|
994
994
|
interface TriggerEvaluatorStateTable {
|
|
995
995
|
id: Generated<boolean>;
|
|
996
996
|
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
@@ -789,9 +789,9 @@ interface Database {
|
|
|
789
789
|
account_spend_caps: AccountSpendCapsTable;
|
|
790
790
|
account_credits: AccountCreditsTable;
|
|
791
791
|
hosted_meter_days: HostedMeterDaysTable;
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
792
|
+
webhooks: WebhooksTable;
|
|
793
|
+
webhook_outbox: WebhookOutboxTable;
|
|
794
|
+
webhook_deliveries: WebhookDeliveriesTable;
|
|
795
795
|
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
796
796
|
decoded_events: DecodedEventsTable;
|
|
797
797
|
decoder_checkpoints: DecoderCheckpointsTable;
|
|
@@ -912,31 +912,31 @@ interface ArchiveFetchesTable {
|
|
|
912
912
|
charged_at: Generated<Date>;
|
|
913
913
|
}
|
|
914
914
|
type SubgraphOperation = Selectable<SubgraphOperationsTable>;
|
|
915
|
-
type
|
|
916
|
-
/** Polymorphic
|
|
915
|
+
type WebhookStatus = "active" | "paused" | "error";
|
|
916
|
+
/** Polymorphic webhook mode: `subgraph` reacts to processed table rows;
|
|
917
917
|
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
918
918
|
* clock (no subgraph). See migration 0088. */
|
|
919
|
-
type
|
|
920
|
-
type
|
|
921
|
-
type
|
|
922
|
-
interface
|
|
919
|
+
type WebhookKind = "subgraph" | "chain";
|
|
920
|
+
type WebhookFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
921
|
+
type WebhookRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
922
|
+
interface WebhooksTable {
|
|
923
923
|
id: Generated<string>;
|
|
924
924
|
account_id: string;
|
|
925
925
|
project_id: string | null;
|
|
926
926
|
name: string;
|
|
927
|
-
status: ColumnType<
|
|
928
|
-
kind: ColumnType<
|
|
929
|
-
/** Null for chain
|
|
927
|
+
status: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;
|
|
928
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
929
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
930
930
|
subgraph_name: string | null;
|
|
931
|
-
/** Null for chain
|
|
931
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
932
932
|
table_name: string | null;
|
|
933
933
|
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
934
|
-
* subgraph
|
|
935
|
-
* import cycle; the Zod schema in schemas/
|
|
934
|
+
* subgraph webhooks. Typed loosely here to avoid a shared→subgraphs
|
|
935
|
+
* import cycle; the Zod schema in schemas/webhooks.ts owns the shape. */
|
|
936
936
|
triggers: unknown | null;
|
|
937
937
|
filter: Generated<unknown>;
|
|
938
|
-
format: ColumnType<
|
|
939
|
-
runtime:
|
|
938
|
+
format: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;
|
|
939
|
+
runtime: WebhookRuntime | null;
|
|
940
940
|
url: string;
|
|
941
941
|
signing_secret_enc: Buffer;
|
|
942
942
|
auth_config: Generated<unknown>;
|
|
@@ -952,13 +952,13 @@ interface SubscriptionsTable {
|
|
|
952
952
|
updated_at: Generated<Date>;
|
|
953
953
|
}
|
|
954
954
|
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
955
|
-
interface
|
|
955
|
+
interface WebhookOutboxTable {
|
|
956
956
|
id: Generated<string>;
|
|
957
|
-
|
|
958
|
-
kind: ColumnType<
|
|
959
|
-
/** Null for chain-
|
|
957
|
+
webhook_id: string;
|
|
958
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
959
|
+
/** Null for chain-webhook rows. */
|
|
960
960
|
subgraph_name: string | null;
|
|
961
|
-
/** Null for chain-
|
|
961
|
+
/** Null for chain-webhook rows. */
|
|
962
962
|
table_name: string | null;
|
|
963
963
|
block_height: number | bigint;
|
|
964
964
|
tx_id: string | null;
|
|
@@ -976,12 +976,12 @@ interface SubscriptionOutboxTable {
|
|
|
976
976
|
locked_until: Date | null;
|
|
977
977
|
created_at: Generated<Date>;
|
|
978
978
|
}
|
|
979
|
-
interface
|
|
979
|
+
interface WebhookDeliveriesTable {
|
|
980
980
|
id: Generated<string>;
|
|
981
981
|
/** Nullable after migration 0077 — outbox row may be cleaned up while
|
|
982
982
|
* delivery telemetry is retained. */
|
|
983
983
|
outbox_id: string | null;
|
|
984
|
-
|
|
984
|
+
webhook_id: string;
|
|
985
985
|
attempt: number;
|
|
986
986
|
status_code: number | null;
|
|
987
987
|
response_headers: unknown | null;
|
|
@@ -991,7 +991,7 @@ interface SubscriptionDeliveriesTable {
|
|
|
991
991
|
dispatched_at: Generated<Date>;
|
|
992
992
|
}
|
|
993
993
|
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
994
|
-
* One loop serves all chain
|
|
994
|
+
* One loop serves all chain webhooks, so the cursor is global. */
|
|
995
995
|
interface TriggerEvaluatorStateTable {
|
|
996
996
|
id: Generated<boolean>;
|
|
997
997
|
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
@@ -789,9 +789,9 @@ interface Database {
|
|
|
789
789
|
account_spend_caps: AccountSpendCapsTable;
|
|
790
790
|
account_credits: AccountCreditsTable;
|
|
791
791
|
hosted_meter_days: HostedMeterDaysTable;
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
792
|
+
webhooks: WebhooksTable;
|
|
793
|
+
webhook_outbox: WebhookOutboxTable;
|
|
794
|
+
webhook_deliveries: WebhookDeliveriesTable;
|
|
795
795
|
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
796
796
|
decoded_events: DecodedEventsTable;
|
|
797
797
|
decoder_checkpoints: DecoderCheckpointsTable;
|
|
@@ -912,31 +912,31 @@ interface ArchiveFetchesTable {
|
|
|
912
912
|
charged_at: Generated<Date>;
|
|
913
913
|
}
|
|
914
914
|
type Subgraph = Selectable<SubgraphsTable>;
|
|
915
|
-
type
|
|
916
|
-
/** Polymorphic
|
|
915
|
+
type WebhookStatus = "active" | "paused" | "error";
|
|
916
|
+
/** Polymorphic webhook mode: `subgraph` reacts to processed table rows;
|
|
917
917
|
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
918
918
|
* clock (no subgraph). See migration 0088. */
|
|
919
|
-
type
|
|
920
|
-
type
|
|
921
|
-
type
|
|
922
|
-
interface
|
|
919
|
+
type WebhookKind = "subgraph" | "chain";
|
|
920
|
+
type WebhookFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
921
|
+
type WebhookRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
922
|
+
interface WebhooksTable {
|
|
923
923
|
id: Generated<string>;
|
|
924
924
|
account_id: string;
|
|
925
925
|
project_id: string | null;
|
|
926
926
|
name: string;
|
|
927
|
-
status: ColumnType<
|
|
928
|
-
kind: ColumnType<
|
|
929
|
-
/** Null for chain
|
|
927
|
+
status: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;
|
|
928
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
929
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
930
930
|
subgraph_name: string | null;
|
|
931
|
-
/** Null for chain
|
|
931
|
+
/** Null for chain webhooks (CHECK webhooks_kind_shape). */
|
|
932
932
|
table_name: string | null;
|
|
933
933
|
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
934
|
-
* subgraph
|
|
935
|
-
* import cycle; the Zod schema in schemas/
|
|
934
|
+
* subgraph webhooks. Typed loosely here to avoid a shared→subgraphs
|
|
935
|
+
* import cycle; the Zod schema in schemas/webhooks.ts owns the shape. */
|
|
936
936
|
triggers: unknown | null;
|
|
937
937
|
filter: Generated<unknown>;
|
|
938
|
-
format: ColumnType<
|
|
939
|
-
runtime:
|
|
938
|
+
format: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;
|
|
939
|
+
runtime: WebhookRuntime | null;
|
|
940
940
|
url: string;
|
|
941
941
|
signing_secret_enc: Buffer;
|
|
942
942
|
auth_config: Generated<unknown>;
|
|
@@ -952,13 +952,13 @@ interface SubscriptionsTable {
|
|
|
952
952
|
updated_at: Generated<Date>;
|
|
953
953
|
}
|
|
954
954
|
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
955
|
-
interface
|
|
955
|
+
interface WebhookOutboxTable {
|
|
956
956
|
id: Generated<string>;
|
|
957
|
-
|
|
958
|
-
kind: ColumnType<
|
|
959
|
-
/** Null for chain-
|
|
957
|
+
webhook_id: string;
|
|
958
|
+
kind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;
|
|
959
|
+
/** Null for chain-webhook rows. */
|
|
960
960
|
subgraph_name: string | null;
|
|
961
|
-
/** Null for chain-
|
|
961
|
+
/** Null for chain-webhook rows. */
|
|
962
962
|
table_name: string | null;
|
|
963
963
|
block_height: number | bigint;
|
|
964
964
|
tx_id: string | null;
|
|
@@ -976,12 +976,12 @@ interface SubscriptionOutboxTable {
|
|
|
976
976
|
locked_until: Date | null;
|
|
977
977
|
created_at: Generated<Date>;
|
|
978
978
|
}
|
|
979
|
-
interface
|
|
979
|
+
interface WebhookDeliveriesTable {
|
|
980
980
|
id: Generated<string>;
|
|
981
981
|
/** Nullable after migration 0077 — outbox row may be cleaned up while
|
|
982
982
|
* delivery telemetry is retained. */
|
|
983
983
|
outbox_id: string | null;
|
|
984
|
-
|
|
984
|
+
webhook_id: string;
|
|
985
985
|
attempt: number;
|
|
986
986
|
status_code: number | null;
|
|
987
987
|
response_headers: unknown | null;
|
|
@@ -991,7 +991,7 @@ interface SubscriptionDeliveriesTable {
|
|
|
991
991
|
dispatched_at: Generated<Date>;
|
|
992
992
|
}
|
|
993
993
|
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
994
|
-
* One loop serves all chain
|
|
994
|
+
* One loop serves all chain webhooks, so the cursor is global. */
|
|
995
995
|
interface TriggerEvaluatorStateTable {
|
|
996
996
|
id: Generated<boolean>;
|
|
997
997
|
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
@@ -177,12 +177,12 @@ async function deleteSubgraph(db, name, accountId) {
|
|
|
177
177
|
if (!subgraph)
|
|
178
178
|
return null;
|
|
179
179
|
const schemaName = subgraph.schema_name ?? pgSchemaName(name);
|
|
180
|
-
await db.updateTable("
|
|
180
|
+
await db.updateTable("webhooks").set({
|
|
181
181
|
status: "paused",
|
|
182
|
-
last_error: `Subgraph "${name}" deleted;
|
|
182
|
+
last_error: `Subgraph "${name}" deleted; webhook auto-paused.`,
|
|
183
183
|
updated_at: new Date
|
|
184
184
|
}).where("subgraph_name", "=", name).execute();
|
|
185
|
-
await db.deleteFrom("
|
|
185
|
+
await db.deleteFrom("webhook_outbox").where("status", "=", "pending").where("webhook_id", "in", (qb) => qb.selectFrom("webhooks").select("id").where("subgraph_name", "=", name)).execute();
|
|
186
186
|
await sql2`DROP SCHEMA IF EXISTS ${sql2.raw(`"${schemaName}"`)} CASCADE`.execute(db);
|
|
187
187
|
await db.deleteFrom("subgraphs").where("id", "=", subgraph.id).execute();
|
|
188
188
|
return subgraph;
|
|
@@ -224,5 +224,5 @@ export {
|
|
|
224
224
|
deleteSubgraph
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
//# debugId=
|
|
227
|
+
//# debugId=0C7267DDF02AF5D764756E2164756E21
|
|
228
228
|
//# sourceMappingURL=subgraphs.js.map
|