@secondlayer/shared 6.14.1 → 6.16.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/dist/src/db/index.d.ts +28 -5
- package/dist/src/db/queries/chain-reorgs.d.ts +26 -4
- package/dist/src/db/queries/contracts.d.ts +26 -4
- package/dist/src/db/queries/integrity.d.ts +26 -4
- package/dist/src/db/queries/subgraph-gaps.d.ts +26 -4
- package/dist/src/db/queries/subgraph-operations.d.ts +26 -4
- package/dist/src/db/queries/subgraphs.d.ts +26 -4
- package/dist/src/db/queries/subscriptions.d.ts +41 -7
- package/dist/src/db/queries/subscriptions.js +10 -3
- package/dist/src/db/queries/subscriptions.js.map +3 -3
- package/dist/src/db/schema.d.ts +28 -5
- package/dist/src/index-http.d.ts +110 -0
- package/dist/src/index-http.js +93 -0
- package/dist/src/index-http.js.map +11 -0
- package/dist/src/index-internal-auth.d.ts +3 -0
- package/dist/src/index-internal-auth.js +29 -0
- package/dist/src/index-internal-auth.js.map +10 -0
- package/dist/src/index.d.ts +110 -10
- package/dist/src/index.js +177 -4
- package/dist/src/index.js.map +3 -3
- package/dist/src/node/local-client.d.ts +26 -4
- package/dist/src/schemas/index.d.ts +82 -5
- package/dist/src/schemas/index.js +177 -4
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/subscriptions.d.ts +117 -6
- package/dist/src/schemas/subscriptions.js +182 -5
- package/dist/src/schemas/subscriptions.js.map +3 -3
- package/migrations/0088_chain_subscriptions.ts +86 -0
- package/package.json +9 -1
package/dist/src/db/index.d.ts
CHANGED
|
@@ -654,6 +654,7 @@ interface Database {
|
|
|
654
654
|
subscriptions: SubscriptionsTable;
|
|
655
655
|
subscription_outbox: SubscriptionOutboxTable;
|
|
656
656
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
657
|
+
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
657
658
|
decoded_events: DecodedEventsTable;
|
|
658
659
|
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
659
660
|
chain_reorgs: ChainReorgsTable;
|
|
@@ -822,6 +823,10 @@ type UpdateChatSession = Updateable<ChatSessionsTable>;
|
|
|
822
823
|
type ChatMessage = Selectable<ChatMessagesTable>;
|
|
823
824
|
type InsertChatMessage = Insertable<ChatMessagesTable>;
|
|
824
825
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
826
|
+
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
827
|
+
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
828
|
+
* clock (no subgraph). See migration 0088. */
|
|
829
|
+
type SubscriptionKind = "subgraph" | "chain";
|
|
825
830
|
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
826
831
|
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
827
832
|
interface SubscriptionsTable {
|
|
@@ -830,8 +835,15 @@ interface SubscriptionsTable {
|
|
|
830
835
|
project_id: string | null;
|
|
831
836
|
name: string;
|
|
832
837
|
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
833
|
-
|
|
834
|
-
|
|
838
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
839
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
840
|
+
subgraph_name: string | null;
|
|
841
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
842
|
+
table_name: string | null;
|
|
843
|
+
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
844
|
+
* subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
|
|
845
|
+
* import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
|
|
846
|
+
triggers: unknown | null;
|
|
835
847
|
filter: Generated<unknown>;
|
|
836
848
|
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
837
849
|
runtime: SubscriptionRuntime | null;
|
|
@@ -856,8 +868,11 @@ type OutboxStatus = "pending" | "delivered" | "dead";
|
|
|
856
868
|
interface SubscriptionOutboxTable {
|
|
857
869
|
id: Generated<string>;
|
|
858
870
|
subscription_id: string;
|
|
859
|
-
|
|
860
|
-
|
|
871
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
872
|
+
/** Null for chain-subscription rows. */
|
|
873
|
+
subgraph_name: string | null;
|
|
874
|
+
/** Null for chain-subscription rows. */
|
|
875
|
+
table_name: string | null;
|
|
861
876
|
block_height: number | bigint;
|
|
862
877
|
tx_id: string | null;
|
|
863
878
|
row_pk: unknown;
|
|
@@ -893,6 +908,14 @@ interface SubscriptionDeliveriesTable {
|
|
|
893
908
|
}
|
|
894
909
|
type SubscriptionDelivery = Selectable<SubscriptionDeliveriesTable>;
|
|
895
910
|
type InsertSubscriptionDelivery = Insertable<SubscriptionDeliveriesTable>;
|
|
911
|
+
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
912
|
+
* One loop serves all chain subscriptions, so the cursor is global. */
|
|
913
|
+
interface TriggerEvaluatorStateTable {
|
|
914
|
+
id: Generated<boolean>;
|
|
915
|
+
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
916
|
+
updated_at: Generated<Date>;
|
|
917
|
+
}
|
|
918
|
+
type TriggerEvaluatorState = Selectable<TriggerEvaluatorStateTable>;
|
|
896
919
|
import { sql } from "kysely";
|
|
897
920
|
/**
|
|
898
921
|
* Kysely instance for the SOURCE DB (block/tx/event reads from the shared
|
|
@@ -925,4 +948,4 @@ declare function getRawClient(role?: "source" | "target"): ReturnType<typeof pos
|
|
|
925
948
|
declare function getRawClientFor(url: string): ReturnType<typeof postgres>;
|
|
926
949
|
/** Close all DB connection pools. Call in CLI commands to allow process exit. */
|
|
927
950
|
declare function closeDb(): Promise<void>;
|
|
928
|
-
export { sql, parseJsonb, jsonb, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getDb, closeDb, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateChatSession, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcEventsTable, SbtcEventTopic, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, OutboxStatus, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, L2DecoderCheckpointsTable, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertChatSession, InsertChatMessage, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, EventsTable, EventsArchiveTable, Event, DecodedEventsTable, DeadLetterEventsTable, Database, ContractsTable, Contract, ChatSessionsTable, ChatSession, ChatMessagesTable, ChatMessage, ChainReorgsTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountAgentRunsTable, AccountAgentRun, Account };
|
|
951
|
+
export { sql, parseJsonb, jsonb, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getDb, closeDb, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateChatSession, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcEventsTable, SbtcEventTopic, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, OutboxStatus, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, L2DecoderCheckpointsTable, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertChatSession, InsertChatMessage, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, EventsTable, EventsArchiveTable, Event, DecodedEventsTable, DeadLetterEventsTable, Database, ContractsTable, Contract, ChatSessionsTable, ChatSession, ChatMessagesTable, ChatMessage, ChainReorgsTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountAgentRunsTable, AccountAgentRun, Account };
|
|
@@ -635,6 +635,7 @@ interface Database {
|
|
|
635
635
|
subscriptions: SubscriptionsTable;
|
|
636
636
|
subscription_outbox: SubscriptionOutboxTable;
|
|
637
637
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
638
|
+
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
638
639
|
decoded_events: DecodedEventsTable;
|
|
639
640
|
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
640
641
|
chain_reorgs: ChainReorgsTable;
|
|
@@ -733,6 +734,10 @@ interface ProvisioningAuditLogTable {
|
|
|
733
734
|
created_at: Generated<Date>;
|
|
734
735
|
}
|
|
735
736
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
737
|
+
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
738
|
+
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
739
|
+
* clock (no subgraph). See migration 0088. */
|
|
740
|
+
type SubscriptionKind = "subgraph" | "chain";
|
|
736
741
|
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
737
742
|
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
738
743
|
interface SubscriptionsTable {
|
|
@@ -741,8 +746,15 @@ interface SubscriptionsTable {
|
|
|
741
746
|
project_id: string | null;
|
|
742
747
|
name: string;
|
|
743
748
|
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
744
|
-
|
|
745
|
-
|
|
749
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
750
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
751
|
+
subgraph_name: string | null;
|
|
752
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
753
|
+
table_name: string | null;
|
|
754
|
+
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
755
|
+
* subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
|
|
756
|
+
* import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
|
|
757
|
+
triggers: unknown | null;
|
|
746
758
|
filter: Generated<unknown>;
|
|
747
759
|
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
748
760
|
runtime: SubscriptionRuntime | null;
|
|
@@ -764,8 +776,11 @@ type OutboxStatus = "pending" | "delivered" | "dead";
|
|
|
764
776
|
interface SubscriptionOutboxTable {
|
|
765
777
|
id: Generated<string>;
|
|
766
778
|
subscription_id: string;
|
|
767
|
-
|
|
768
|
-
|
|
779
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
780
|
+
/** Null for chain-subscription rows. */
|
|
781
|
+
subgraph_name: string | null;
|
|
782
|
+
/** Null for chain-subscription rows. */
|
|
783
|
+
table_name: string | null;
|
|
769
784
|
block_height: number | bigint;
|
|
770
785
|
tx_id: string | null;
|
|
771
786
|
row_pk: unknown;
|
|
@@ -796,6 +811,13 @@ interface SubscriptionDeliveriesTable {
|
|
|
796
811
|
duration_ms: number | null;
|
|
797
812
|
dispatched_at: Generated<Date>;
|
|
798
813
|
}
|
|
814
|
+
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
815
|
+
* One loop serves all chain subscriptions, so the cursor is global. */
|
|
816
|
+
interface TriggerEvaluatorStateTable {
|
|
817
|
+
id: Generated<boolean>;
|
|
818
|
+
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
819
|
+
updated_at: Generated<Date>;
|
|
820
|
+
}
|
|
799
821
|
import { Kysely, Transaction as Transaction2 } from "kysely";
|
|
800
822
|
type ChainReorgCursor = {
|
|
801
823
|
block_height: number
|
|
@@ -636,6 +636,7 @@ interface Database {
|
|
|
636
636
|
subscriptions: SubscriptionsTable;
|
|
637
637
|
subscription_outbox: SubscriptionOutboxTable;
|
|
638
638
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
639
|
+
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
639
640
|
decoded_events: DecodedEventsTable;
|
|
640
641
|
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
641
642
|
chain_reorgs: ChainReorgsTable;
|
|
@@ -735,6 +736,10 @@ interface ProvisioningAuditLogTable {
|
|
|
735
736
|
}
|
|
736
737
|
type Contract = Selectable<ContractsTable>;
|
|
737
738
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
739
|
+
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
740
|
+
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
741
|
+
* clock (no subgraph). See migration 0088. */
|
|
742
|
+
type SubscriptionKind = "subgraph" | "chain";
|
|
738
743
|
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
739
744
|
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
740
745
|
interface SubscriptionsTable {
|
|
@@ -743,8 +748,15 @@ interface SubscriptionsTable {
|
|
|
743
748
|
project_id: string | null;
|
|
744
749
|
name: string;
|
|
745
750
|
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
746
|
-
|
|
747
|
-
|
|
751
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
752
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
753
|
+
subgraph_name: string | null;
|
|
754
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
755
|
+
table_name: string | null;
|
|
756
|
+
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
757
|
+
* subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
|
|
758
|
+
* import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
|
|
759
|
+
triggers: unknown | null;
|
|
748
760
|
filter: Generated<unknown>;
|
|
749
761
|
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
750
762
|
runtime: SubscriptionRuntime | null;
|
|
@@ -766,8 +778,11 @@ type OutboxStatus = "pending" | "delivered" | "dead";
|
|
|
766
778
|
interface SubscriptionOutboxTable {
|
|
767
779
|
id: Generated<string>;
|
|
768
780
|
subscription_id: string;
|
|
769
|
-
|
|
770
|
-
|
|
781
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
782
|
+
/** Null for chain-subscription rows. */
|
|
783
|
+
subgraph_name: string | null;
|
|
784
|
+
/** Null for chain-subscription rows. */
|
|
785
|
+
table_name: string | null;
|
|
771
786
|
block_height: number | bigint;
|
|
772
787
|
tx_id: string | null;
|
|
773
788
|
row_pk: unknown;
|
|
@@ -798,6 +813,13 @@ interface SubscriptionDeliveriesTable {
|
|
|
798
813
|
duration_ms: number | null;
|
|
799
814
|
dispatched_at: Generated<Date>;
|
|
800
815
|
}
|
|
816
|
+
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
817
|
+
* One loop serves all chain subscriptions, so the cursor is global. */
|
|
818
|
+
interface TriggerEvaluatorStateTable {
|
|
819
|
+
id: Generated<boolean>;
|
|
820
|
+
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
821
|
+
updated_at: Generated<Date>;
|
|
822
|
+
}
|
|
801
823
|
/**
|
|
802
824
|
* Contract registry queries — backing for trait-based discovery. Populated from
|
|
803
825
|
* contract deploys; ABI fetched async; standards inferred by static analysis.
|
|
@@ -636,6 +636,7 @@ interface Database {
|
|
|
636
636
|
subscriptions: SubscriptionsTable;
|
|
637
637
|
subscription_outbox: SubscriptionOutboxTable;
|
|
638
638
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
639
|
+
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
639
640
|
decoded_events: DecodedEventsTable;
|
|
640
641
|
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
641
642
|
chain_reorgs: ChainReorgsTable;
|
|
@@ -734,6 +735,10 @@ interface ProvisioningAuditLogTable {
|
|
|
734
735
|
created_at: Generated<Date>;
|
|
735
736
|
}
|
|
736
737
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
738
|
+
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
739
|
+
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
740
|
+
* clock (no subgraph). See migration 0088. */
|
|
741
|
+
type SubscriptionKind = "subgraph" | "chain";
|
|
737
742
|
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
738
743
|
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
739
744
|
interface SubscriptionsTable {
|
|
@@ -742,8 +747,15 @@ interface SubscriptionsTable {
|
|
|
742
747
|
project_id: string | null;
|
|
743
748
|
name: string;
|
|
744
749
|
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
745
|
-
|
|
746
|
-
|
|
750
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
751
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
752
|
+
subgraph_name: string | null;
|
|
753
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
754
|
+
table_name: string | null;
|
|
755
|
+
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
756
|
+
* subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
|
|
757
|
+
* import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
|
|
758
|
+
triggers: unknown | null;
|
|
747
759
|
filter: Generated<unknown>;
|
|
748
760
|
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
749
761
|
runtime: SubscriptionRuntime | null;
|
|
@@ -765,8 +777,11 @@ type OutboxStatus = "pending" | "delivered" | "dead";
|
|
|
765
777
|
interface SubscriptionOutboxTable {
|
|
766
778
|
id: Generated<string>;
|
|
767
779
|
subscription_id: string;
|
|
768
|
-
|
|
769
|
-
|
|
780
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
781
|
+
/** Null for chain-subscription rows. */
|
|
782
|
+
subgraph_name: string | null;
|
|
783
|
+
/** Null for chain-subscription rows. */
|
|
784
|
+
table_name: string | null;
|
|
770
785
|
block_height: number | bigint;
|
|
771
786
|
tx_id: string | null;
|
|
772
787
|
row_pk: unknown;
|
|
@@ -797,6 +812,13 @@ interface SubscriptionDeliveriesTable {
|
|
|
797
812
|
duration_ms: number | null;
|
|
798
813
|
dispatched_at: Generated<Date>;
|
|
799
814
|
}
|
|
815
|
+
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
816
|
+
* One loop serves all chain subscriptions, so the cursor is global. */
|
|
817
|
+
interface TriggerEvaluatorStateTable {
|
|
818
|
+
id: Generated<boolean>;
|
|
819
|
+
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
820
|
+
updated_at: Generated<Date>;
|
|
821
|
+
}
|
|
800
822
|
interface Gap {
|
|
801
823
|
gapStart: number;
|
|
802
824
|
gapEnd: number;
|
|
@@ -636,6 +636,7 @@ interface Database {
|
|
|
636
636
|
subscriptions: SubscriptionsTable;
|
|
637
637
|
subscription_outbox: SubscriptionOutboxTable;
|
|
638
638
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
639
|
+
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
639
640
|
decoded_events: DecodedEventsTable;
|
|
640
641
|
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
641
642
|
chain_reorgs: ChainReorgsTable;
|
|
@@ -734,6 +735,10 @@ interface ProvisioningAuditLogTable {
|
|
|
734
735
|
created_at: Generated<Date>;
|
|
735
736
|
}
|
|
736
737
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
738
|
+
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
739
|
+
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
740
|
+
* clock (no subgraph). See migration 0088. */
|
|
741
|
+
type SubscriptionKind = "subgraph" | "chain";
|
|
737
742
|
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
738
743
|
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
739
744
|
interface SubscriptionsTable {
|
|
@@ -742,8 +747,15 @@ interface SubscriptionsTable {
|
|
|
742
747
|
project_id: string | null;
|
|
743
748
|
name: string;
|
|
744
749
|
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
745
|
-
|
|
746
|
-
|
|
750
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
751
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
752
|
+
subgraph_name: string | null;
|
|
753
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
754
|
+
table_name: string | null;
|
|
755
|
+
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
756
|
+
* subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
|
|
757
|
+
* import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
|
|
758
|
+
triggers: unknown | null;
|
|
747
759
|
filter: Generated<unknown>;
|
|
748
760
|
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
749
761
|
runtime: SubscriptionRuntime | null;
|
|
@@ -765,8 +777,11 @@ type OutboxStatus = "pending" | "delivered" | "dead";
|
|
|
765
777
|
interface SubscriptionOutboxTable {
|
|
766
778
|
id: Generated<string>;
|
|
767
779
|
subscription_id: string;
|
|
768
|
-
|
|
769
|
-
|
|
780
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
781
|
+
/** Null for chain-subscription rows. */
|
|
782
|
+
subgraph_name: string | null;
|
|
783
|
+
/** Null for chain-subscription rows. */
|
|
784
|
+
table_name: string | null;
|
|
770
785
|
block_height: number | bigint;
|
|
771
786
|
tx_id: string | null;
|
|
772
787
|
row_pk: unknown;
|
|
@@ -797,6 +812,13 @@ interface SubscriptionDeliveriesTable {
|
|
|
797
812
|
duration_ms: number | null;
|
|
798
813
|
dispatched_at: Generated<Date>;
|
|
799
814
|
}
|
|
815
|
+
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
816
|
+
* One loop serves all chain subscriptions, so the cursor is global. */
|
|
817
|
+
interface TriggerEvaluatorStateTable {
|
|
818
|
+
id: Generated<boolean>;
|
|
819
|
+
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
820
|
+
updated_at: Generated<Date>;
|
|
821
|
+
}
|
|
800
822
|
interface GapRange {
|
|
801
823
|
start: number;
|
|
802
824
|
end: number;
|
|
@@ -636,6 +636,7 @@ interface Database {
|
|
|
636
636
|
subscriptions: SubscriptionsTable;
|
|
637
637
|
subscription_outbox: SubscriptionOutboxTable;
|
|
638
638
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
639
|
+
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
639
640
|
decoded_events: DecodedEventsTable;
|
|
640
641
|
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
641
642
|
chain_reorgs: ChainReorgsTable;
|
|
@@ -735,6 +736,10 @@ interface ProvisioningAuditLogTable {
|
|
|
735
736
|
}
|
|
736
737
|
type SubgraphOperation = Selectable<SubgraphOperationsTable>;
|
|
737
738
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
739
|
+
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
740
|
+
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
741
|
+
* clock (no subgraph). See migration 0088. */
|
|
742
|
+
type SubscriptionKind = "subgraph" | "chain";
|
|
738
743
|
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
739
744
|
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
740
745
|
interface SubscriptionsTable {
|
|
@@ -743,8 +748,15 @@ interface SubscriptionsTable {
|
|
|
743
748
|
project_id: string | null;
|
|
744
749
|
name: string;
|
|
745
750
|
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
746
|
-
|
|
747
|
-
|
|
751
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
752
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
753
|
+
subgraph_name: string | null;
|
|
754
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
755
|
+
table_name: string | null;
|
|
756
|
+
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
757
|
+
* subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
|
|
758
|
+
* import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
|
|
759
|
+
triggers: unknown | null;
|
|
748
760
|
filter: Generated<unknown>;
|
|
749
761
|
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
750
762
|
runtime: SubscriptionRuntime | null;
|
|
@@ -766,8 +778,11 @@ type OutboxStatus = "pending" | "delivered" | "dead";
|
|
|
766
778
|
interface SubscriptionOutboxTable {
|
|
767
779
|
id: Generated<string>;
|
|
768
780
|
subscription_id: string;
|
|
769
|
-
|
|
770
|
-
|
|
781
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
782
|
+
/** Null for chain-subscription rows. */
|
|
783
|
+
subgraph_name: string | null;
|
|
784
|
+
/** Null for chain-subscription rows. */
|
|
785
|
+
table_name: string | null;
|
|
771
786
|
block_height: number | bigint;
|
|
772
787
|
tx_id: string | null;
|
|
773
788
|
row_pk: unknown;
|
|
@@ -798,6 +813,13 @@ interface SubscriptionDeliveriesTable {
|
|
|
798
813
|
duration_ms: number | null;
|
|
799
814
|
dispatched_at: Generated<Date>;
|
|
800
815
|
}
|
|
816
|
+
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
817
|
+
* One loop serves all chain subscriptions, so the cursor is global. */
|
|
818
|
+
interface TriggerEvaluatorStateTable {
|
|
819
|
+
id: Generated<boolean>;
|
|
820
|
+
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
821
|
+
updated_at: Generated<Date>;
|
|
822
|
+
}
|
|
801
823
|
declare function isActiveSubgraphOperationConflict(err: unknown): boolean;
|
|
802
824
|
declare function createSubgraphOperation(db: Kysely<Database>, data: {
|
|
803
825
|
subgraphId: string
|
|
@@ -637,6 +637,7 @@ interface Database {
|
|
|
637
637
|
subscriptions: SubscriptionsTable;
|
|
638
638
|
subscription_outbox: SubscriptionOutboxTable;
|
|
639
639
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
640
|
+
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
640
641
|
decoded_events: DecodedEventsTable;
|
|
641
642
|
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
642
643
|
chain_reorgs: ChainReorgsTable;
|
|
@@ -736,6 +737,10 @@ interface ProvisioningAuditLogTable {
|
|
|
736
737
|
}
|
|
737
738
|
type Subgraph = Selectable<SubgraphsTable>;
|
|
738
739
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
740
|
+
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
741
|
+
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
742
|
+
* clock (no subgraph). See migration 0088. */
|
|
743
|
+
type SubscriptionKind = "subgraph" | "chain";
|
|
739
744
|
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
740
745
|
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
741
746
|
interface SubscriptionsTable {
|
|
@@ -744,8 +749,15 @@ interface SubscriptionsTable {
|
|
|
744
749
|
project_id: string | null;
|
|
745
750
|
name: string;
|
|
746
751
|
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
747
|
-
|
|
748
|
-
|
|
752
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
753
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
754
|
+
subgraph_name: string | null;
|
|
755
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
756
|
+
table_name: string | null;
|
|
757
|
+
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
758
|
+
* subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
|
|
759
|
+
* import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
|
|
760
|
+
triggers: unknown | null;
|
|
749
761
|
filter: Generated<unknown>;
|
|
750
762
|
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
751
763
|
runtime: SubscriptionRuntime | null;
|
|
@@ -767,8 +779,11 @@ type OutboxStatus = "pending" | "delivered" | "dead";
|
|
|
767
779
|
interface SubscriptionOutboxTable {
|
|
768
780
|
id: Generated<string>;
|
|
769
781
|
subscription_id: string;
|
|
770
|
-
|
|
771
|
-
|
|
782
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
783
|
+
/** Null for chain-subscription rows. */
|
|
784
|
+
subgraph_name: string | null;
|
|
785
|
+
/** Null for chain-subscription rows. */
|
|
786
|
+
table_name: string | null;
|
|
772
787
|
block_height: number | bigint;
|
|
773
788
|
tx_id: string | null;
|
|
774
789
|
row_pk: unknown;
|
|
@@ -799,6 +814,13 @@ interface SubscriptionDeliveriesTable {
|
|
|
799
814
|
duration_ms: number | null;
|
|
800
815
|
dispatched_at: Generated<Date>;
|
|
801
816
|
}
|
|
817
|
+
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
818
|
+
* One loop serves all chain subscriptions, so the cursor is global. */
|
|
819
|
+
interface TriggerEvaluatorStateTable {
|
|
820
|
+
id: Generated<boolean>;
|
|
821
|
+
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
822
|
+
updated_at: Generated<Date>;
|
|
823
|
+
}
|
|
802
824
|
/**
|
|
803
825
|
* BYO data plane helpers. A subgraph's user-owned Postgres connection string is
|
|
804
826
|
* stored encrypted at rest in `database_url_enc` (AES-GCM envelope). Plaintext
|
|
@@ -636,6 +636,7 @@ interface Database {
|
|
|
636
636
|
subscriptions: SubscriptionsTable;
|
|
637
637
|
subscription_outbox: SubscriptionOutboxTable;
|
|
638
638
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
639
|
+
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
639
640
|
decoded_events: DecodedEventsTable;
|
|
640
641
|
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
641
642
|
chain_reorgs: ChainReorgsTable;
|
|
@@ -734,6 +735,10 @@ interface ProvisioningAuditLogTable {
|
|
|
734
735
|
created_at: Generated<Date>;
|
|
735
736
|
}
|
|
736
737
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
738
|
+
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
739
|
+
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
740
|
+
* clock (no subgraph). See migration 0088. */
|
|
741
|
+
type SubscriptionKind = "subgraph" | "chain";
|
|
737
742
|
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
738
743
|
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
739
744
|
interface SubscriptionsTable {
|
|
@@ -742,8 +747,15 @@ interface SubscriptionsTable {
|
|
|
742
747
|
project_id: string | null;
|
|
743
748
|
name: string;
|
|
744
749
|
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
745
|
-
|
|
746
|
-
|
|
750
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
751
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
752
|
+
subgraph_name: string | null;
|
|
753
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
754
|
+
table_name: string | null;
|
|
755
|
+
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
756
|
+
* subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
|
|
757
|
+
* import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
|
|
758
|
+
triggers: unknown | null;
|
|
747
759
|
filter: Generated<unknown>;
|
|
748
760
|
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
749
761
|
runtime: SubscriptionRuntime | null;
|
|
@@ -766,8 +778,11 @@ type OutboxStatus = "pending" | "delivered" | "dead";
|
|
|
766
778
|
interface SubscriptionOutboxTable {
|
|
767
779
|
id: Generated<string>;
|
|
768
780
|
subscription_id: string;
|
|
769
|
-
|
|
770
|
-
|
|
781
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
782
|
+
/** Null for chain-subscription rows. */
|
|
783
|
+
subgraph_name: string | null;
|
|
784
|
+
/** Null for chain-subscription rows. */
|
|
785
|
+
table_name: string | null;
|
|
771
786
|
block_height: number | bigint;
|
|
772
787
|
tx_id: string | null;
|
|
773
788
|
row_pk: unknown;
|
|
@@ -798,6 +813,13 @@ interface SubscriptionDeliveriesTable {
|
|
|
798
813
|
duration_ms: number | null;
|
|
799
814
|
dispatched_at: Generated<Date>;
|
|
800
815
|
}
|
|
816
|
+
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
817
|
+
* One loop serves all chain subscriptions, so the cursor is global. */
|
|
818
|
+
interface TriggerEvaluatorStateTable {
|
|
819
|
+
id: Generated<boolean>;
|
|
820
|
+
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
821
|
+
updated_at: Generated<Date>;
|
|
822
|
+
}
|
|
801
823
|
/**
|
|
802
824
|
* Subscription CRUD. `signing_secret_enc` is transparently encrypted via
|
|
803
825
|
* `encryptSecret`/`decryptSecret`. Plaintext secrets only leave via the
|
|
@@ -807,8 +829,14 @@ interface CreateSubscriptionInput {
|
|
|
807
829
|
accountId: string;
|
|
808
830
|
projectId?: string | null;
|
|
809
831
|
name: string;
|
|
810
|
-
|
|
811
|
-
|
|
832
|
+
/** Defaults to "subgraph". Chain subscriptions set kind="chain" + triggers. */
|
|
833
|
+
kind?: SubscriptionKind;
|
|
834
|
+
/** Required for subgraph subscriptions; omitted for chain. */
|
|
835
|
+
subgraphName?: string | null;
|
|
836
|
+
/** Required for subgraph subscriptions; omitted for chain. */
|
|
837
|
+
tableName?: string | null;
|
|
838
|
+
/** Chain-trigger filter array. Required for chain subscriptions. */
|
|
839
|
+
triggers?: unknown;
|
|
812
840
|
filter?: unknown;
|
|
813
841
|
format?: SubscriptionFormat;
|
|
814
842
|
runtime?: SubscriptionRuntime | null;
|
|
@@ -825,6 +853,12 @@ interface CreateSubscriptionResult {
|
|
|
825
853
|
}
|
|
826
854
|
declare function createSubscription(db: Kysely<Database>, input: CreateSubscriptionInput): Promise<CreateSubscriptionResult>;
|
|
827
855
|
declare function listSubscriptions(db: Kysely<Database>, accountId: string): Promise<Subscription[]>;
|
|
856
|
+
/**
|
|
857
|
+
* All active chain subscriptions across every account — the input to the global
|
|
858
|
+
* trigger evaluator (one loop serves them all). Subgraph subscriptions are
|
|
859
|
+
* excluded; they emit via the subgraph flush path.
|
|
860
|
+
*/
|
|
861
|
+
declare function listActiveChainSubscriptions(db: Kysely<Database>): Promise<Subscription[]>;
|
|
828
862
|
declare function getSubscription(db: Kysely<Database>, accountId: string, id: string): Promise<Subscription | null>;
|
|
829
863
|
declare function getSubscriptionByName(db: Kysely<Database>, accountId: string, name: string): Promise<Subscription | null>;
|
|
830
864
|
interface UpdateSubscriptionInput {
|
|
@@ -850,4 +884,4 @@ declare function rotateSubscriptionSecret(db: Kysely<Database>, accountId: strin
|
|
|
850
884
|
declare function getSubscriptionSigningSecret(sub: Subscription): string;
|
|
851
885
|
/** Fire `subscriptions:changed` notify so the emitter hot-reloads its cache. */
|
|
852
886
|
declare function notifySubscriptionsChanged(db: Kysely<Database>, accountId: string): Promise<void>;
|
|
853
|
-
export { updateSubscription, toggleSubscriptionStatus, rotateSubscriptionSecret, notifySubscriptionsChanged, listSubscriptions, getSubscriptionSigningSecret, getSubscriptionByName, getSubscription, deleteSubscription, createSubscription, UpdateSubscriptionInput, RotateSecretResult, CreateSubscriptionResult, CreateSubscriptionInput };
|
|
887
|
+
export { updateSubscription, toggleSubscriptionStatus, rotateSubscriptionSecret, notifySubscriptionsChanged, listSubscriptions, listActiveChainSubscriptions, getSubscriptionSigningSecret, getSubscriptionByName, getSubscription, deleteSubscription, createSubscription, UpdateSubscriptionInput, RotateSecretResult, CreateSubscriptionResult, CreateSubscriptionInput };
|
|
@@ -203,13 +203,16 @@ function generateSecretsKey() {
|
|
|
203
203
|
import { sql } from "kysely";
|
|
204
204
|
async function createSubscription(db, input) {
|
|
205
205
|
const signingSecret = generateSecret();
|
|
206
|
+
const kind = input.kind ?? "subgraph";
|
|
206
207
|
const row = {
|
|
207
208
|
account_id: input.accountId,
|
|
208
209
|
project_id: input.projectId ?? null,
|
|
209
210
|
name: input.name,
|
|
210
211
|
status: "active",
|
|
211
|
-
|
|
212
|
-
|
|
212
|
+
kind,
|
|
213
|
+
subgraph_name: input.subgraphName ?? null,
|
|
214
|
+
table_name: input.tableName ?? null,
|
|
215
|
+
triggers: kind === "chain" ? input.triggers ?? [] : null,
|
|
213
216
|
filter: input.filter ?? {},
|
|
214
217
|
format: input.format ?? "standard-webhooks",
|
|
215
218
|
runtime: input.runtime ?? null,
|
|
@@ -226,6 +229,9 @@ async function createSubscription(db, input) {
|
|
|
226
229
|
async function listSubscriptions(db, accountId) {
|
|
227
230
|
return db.selectFrom("subscriptions").selectAll().where("account_id", "=", accountId).orderBy("created_at", "desc").execute();
|
|
228
231
|
}
|
|
232
|
+
async function listActiveChainSubscriptions(db) {
|
|
233
|
+
return db.selectFrom("subscriptions").selectAll().where("kind", "=", "chain").where("status", "=", "active").execute();
|
|
234
|
+
}
|
|
229
235
|
async function getSubscription(db, accountId, id) {
|
|
230
236
|
const row = await db.selectFrom("subscriptions").selectAll().where("account_id", "=", accountId).where("id", "=", id).executeTakeFirst();
|
|
231
237
|
return row ?? null;
|
|
@@ -294,6 +300,7 @@ export {
|
|
|
294
300
|
rotateSubscriptionSecret,
|
|
295
301
|
notifySubscriptionsChanged,
|
|
296
302
|
listSubscriptions,
|
|
303
|
+
listActiveChainSubscriptions,
|
|
297
304
|
getSubscriptionSigningSecret,
|
|
298
305
|
getSubscriptionByName,
|
|
299
306
|
getSubscription,
|
|
@@ -301,5 +308,5 @@ export {
|
|
|
301
308
|
createSubscription
|
|
302
309
|
};
|
|
303
310
|
|
|
304
|
-
//# debugId=
|
|
311
|
+
//# debugId=DA0C831A6692C10B64756E2164756E21
|
|
305
312
|
//# sourceMappingURL=subscriptions.js.map
|