@secondlayer/shared 8.0.0 → 10.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 (36) hide show
  1. package/dist/src/archive/range-digest.d.ts +16 -0
  2. package/dist/src/archive/semantic-digest-builder.d.ts +16 -0
  3. package/dist/src/archive/status.js +11 -3
  4. package/dist/src/archive/status.js.map +3 -3
  5. package/dist/src/coverage/index.d.ts +16 -13
  6. package/dist/src/coverage/index.js +1 -11
  7. package/dist/src/coverage/index.js.map +3 -3
  8. package/dist/src/db/index.d.ts +18 -1
  9. package/dist/src/db/index.js +2 -1
  10. package/dist/src/db/index.js.map +3 -3
  11. package/dist/src/db/queries/chain-reorgs.d.ts +16 -0
  12. package/dist/src/db/queries/chain-reorgs.js +2 -1
  13. package/dist/src/db/queries/chain-reorgs.js.map +3 -3
  14. package/dist/src/db/queries/contracts.d.ts +16 -0
  15. package/dist/src/db/queries/instance.d.ts +16 -0
  16. package/dist/src/db/queries/integrity.d.ts +16 -0
  17. package/dist/src/db/queries/subgraph-gaps.d.ts +16 -0
  18. package/dist/src/db/queries/subgraph-operations.d.ts +16 -0
  19. package/dist/src/db/queries/subgraphs.d.ts +16 -0
  20. package/dist/src/db/queries/subscriptions.d.ts +16 -0
  21. package/dist/src/db/queries/sync-scope.d.ts +1006 -0
  22. package/dist/src/db/queries/sync-scope.js +116 -0
  23. package/dist/src/db/queries/sync-scope.js.map +10 -0
  24. package/dist/src/db/schema.d.ts +17 -1
  25. package/dist/src/index.d.ts +18 -1
  26. package/dist/src/index.js +2 -1
  27. package/dist/src/index.js.map +3 -3
  28. package/dist/src/node/local-client.d.ts +16 -0
  29. package/dist/src/runtime/index.d.ts +188 -18
  30. package/dist/src/runtime/index.js +322 -38
  31. package/dist/src/runtime/index.js.map +10 -7
  32. package/migrations/0120_sync_scopes.ts +42 -0
  33. package/package.json +7 -6
  34. package/dist/src/x402.d.ts +0 -47
  35. package/dist/src/x402.js +0 -79
  36. package/dist/src/x402.js.map +0 -10
@@ -0,0 +1,116 @@
1
+ import { createRequire } from "node:module";
2
+ var __defProp = Object.defineProperty;
3
+ var __returnValue = (v) => v;
4
+ function __exportSetter(name, newValue) {
5
+ this[name] = __returnValue.bind(null, newValue);
6
+ }
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true,
12
+ configurable: true,
13
+ set: __exportSetter.bind(all, name)
14
+ });
15
+ };
16
+
17
+ // src/db/queries/sync-scope.ts
18
+ var SYNC_START_HEIGHT_ENV = "SECONDLAYER_SYNC_START_HEIGHT";
19
+
20
+ class InvalidSyncStartHeightError extends Error {
21
+ value;
22
+ name = "InvalidSyncStartHeightError";
23
+ constructor(value) {
24
+ super(`${SYNC_START_HEIGHT_ENV} must be a non-negative integer (got ${value})`);
25
+ this.value = value;
26
+ }
27
+ }
28
+ function syncStartHeightFromEnv(env = process.env) {
29
+ const raw = env[SYNC_START_HEIGHT_ENV];
30
+ if (raw === undefined || raw.trim() === "")
31
+ return null;
32
+ const height = Number(raw.trim());
33
+ if (!Number.isInteger(height) || height < 0) {
34
+ throw new InvalidSyncStartHeightError(raw);
35
+ }
36
+ return height;
37
+ }
38
+ function toScope(row) {
39
+ return {
40
+ network: row.network,
41
+ start_height: Number(row.start_height),
42
+ target_height: row.target_height === null ? null : Number(row.target_height),
43
+ bootstrap: {
44
+ source: row.bootstrap_source,
45
+ manifest_digest: row.bootstrap_manifest_digest,
46
+ genesis_hash: row.genesis_hash
47
+ }
48
+ };
49
+ }
50
+ async function getSyncScope(db, network) {
51
+ const row = await db.selectFrom("sync_scopes").select([
52
+ "network",
53
+ "start_height",
54
+ "target_height",
55
+ "bootstrap_source",
56
+ "bootstrap_manifest_digest",
57
+ "genesis_hash"
58
+ ]).where("network", "=", network).executeTakeFirst();
59
+ return row ? toScope(row) : null;
60
+ }
61
+ async function upsertSyncScope(db, scope) {
62
+ const row = await db.insertInto("sync_scopes").values({
63
+ network: scope.network,
64
+ start_height: scope.start_height,
65
+ target_height: scope.target_height,
66
+ bootstrap_source: scope.bootstrap.source,
67
+ bootstrap_manifest_digest: scope.bootstrap.manifest_digest,
68
+ genesis_hash: scope.bootstrap.genesis_hash
69
+ }).onConflict((oc) => oc.column("network").doUpdateSet({
70
+ start_height: scope.start_height,
71
+ target_height: scope.target_height,
72
+ bootstrap_source: scope.bootstrap.source,
73
+ bootstrap_manifest_digest: scope.bootstrap.manifest_digest,
74
+ genesis_hash: scope.bootstrap.genesis_hash,
75
+ updated_at: new Date
76
+ })).returning([
77
+ "network",
78
+ "start_height",
79
+ "target_height",
80
+ "bootstrap_source",
81
+ "bootstrap_manifest_digest",
82
+ "genesis_hash"
83
+ ]).executeTakeFirstOrThrow();
84
+ return toScope(row);
85
+ }
86
+ async function resolveSyncScope(db, network) {
87
+ const persisted = await getSyncScope(db, network);
88
+ if (persisted)
89
+ return persisted;
90
+ const declaredStart = syncStartHeightFromEnv();
91
+ const lowest = await db.selectFrom("blocks").select(({ fn }) => fn.min("height").as("min")).where("canonical", "=", true).executeTakeFirst();
92
+ const lowestStored = lowest?.min === null || lowest?.min === undefined ? null : Number(lowest.min);
93
+ const startHeight = declaredStart ?? lowestStored ?? 0;
94
+ const genesis = startHeight === 0 ? await db.selectFrom("blocks").select("hash").where("canonical", "=", true).where("height", "=", 0).executeTakeFirst() : undefined;
95
+ return {
96
+ network,
97
+ start_height: startHeight,
98
+ target_height: null,
99
+ bootstrap: {
100
+ source: startHeight === 0 ? "genesis" : "import",
101
+ manifest_digest: null,
102
+ genesis_hash: genesis?.hash ?? null
103
+ }
104
+ };
105
+ }
106
+ export {
107
+ upsertSyncScope,
108
+ syncStartHeightFromEnv,
109
+ resolveSyncScope,
110
+ getSyncScope,
111
+ SYNC_START_HEIGHT_ENV,
112
+ InvalidSyncStartHeightError
113
+ };
114
+
115
+ //# debugId=A8458ACA2A49456264756E2164756E21
116
+ //# sourceMappingURL=sync-scope.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/db/queries/sync-scope.ts"],
4
+ "sourcesContent": [
5
+ "import type { Kysely } from \"kysely\";\nimport type { BootstrapSource, SyncScope } from \"../../coverage/evaluate.ts\";\nimport type { Database } from \"../types.ts\";\n\n/**\n * The instance's declared sync scope.\n *\n * An instance that starts at height N is not an instance missing the first N\n * blocks — but nothing in the schema said so, so every consumer had to guess\n * from `MIN(height)`. `sync_scopes` records the declaration; this module is the\n * only place that reads it, and it always answers in the `SyncScope` shape the\n * coverage evaluator consumes.\n *\n * `resolveSyncScope` never fails on an instance that predates the table: with\n * no row it derives a scope from what the database already shows, so an\n * existing install keeps working without a backfill dance.\n */\n\n/**\n * Declares a forward-only instance: history below this height is deliberately\n * absent, not lost. Read only when no `sync_scopes` row exists — a recorded\n * scope always wins, because it is the one an operator committed to.\n */\nexport const SYNC_START_HEIGHT_ENV = \"SECONDLAYER_SYNC_START_HEIGHT\";\n\nexport class InvalidSyncStartHeightError extends Error {\n\treadonly name = \"InvalidSyncStartHeightError\";\n\tconstructor(readonly value: string) {\n\t\tsuper(\n\t\t\t`${SYNC_START_HEIGHT_ENV} must be a non-negative integer (got ${value})`,\n\t\t);\n\t}\n}\n\n/**\n * Throws rather than ignoring a malformed value: a typo'd start height that\n * silently falls back to genesis would report a real forward-only instance as\n * an 8M-block gap, which is the exact confusion this table exists to end.\n */\nexport function syncStartHeightFromEnv(\n\tenv: NodeJS.ProcessEnv = process.env,\n): number | null {\n\tconst raw = env[SYNC_START_HEIGHT_ENV];\n\tif (raw === undefined || raw.trim() === \"\") return null;\n\tconst height = Number(raw.trim());\n\tif (!Number.isInteger(height) || height < 0) {\n\t\tthrow new InvalidSyncStartHeightError(raw);\n\t}\n\treturn height;\n}\n\nfunction toScope(row: {\n\tnetwork: string;\n\tstart_height: number | string;\n\ttarget_height: number | string | null;\n\tbootstrap_source: BootstrapSource;\n\tbootstrap_manifest_digest: string | null;\n\tgenesis_hash: string | null;\n}): SyncScope {\n\treturn {\n\t\tnetwork: row.network,\n\t\tstart_height: Number(row.start_height),\n\t\ttarget_height:\n\t\t\trow.target_height === null ? null : Number(row.target_height),\n\t\tbootstrap: {\n\t\t\tsource: row.bootstrap_source,\n\t\t\tmanifest_digest: row.bootstrap_manifest_digest,\n\t\t\tgenesis_hash: row.genesis_hash,\n\t\t},\n\t};\n}\n\nexport async function getSyncScope(\n\tdb: Kysely<Database>,\n\tnetwork: string,\n): Promise<SyncScope | null> {\n\tconst row = await db\n\t\t.selectFrom(\"sync_scopes\")\n\t\t.select([\n\t\t\t\"network\",\n\t\t\t\"start_height\",\n\t\t\t\"target_height\",\n\t\t\t\"bootstrap_source\",\n\t\t\t\"bootstrap_manifest_digest\",\n\t\t\t\"genesis_hash\",\n\t\t])\n\t\t.where(\"network\", \"=\", network)\n\t\t.executeTakeFirst();\n\treturn row ? toScope(row) : null;\n}\n\n/**\n * Record (or restate) the scope for a network. Bootstrap and re-bootstrap are\n * the writers; the upsert is idempotent so re-running a restore over the same\n * archive does not fork the declaration.\n */\nexport async function upsertSyncScope(\n\tdb: Kysely<Database>,\n\tscope: SyncScope,\n): Promise<SyncScope> {\n\tconst row = await db\n\t\t.insertInto(\"sync_scopes\")\n\t\t.values({\n\t\t\tnetwork: scope.network,\n\t\t\tstart_height: scope.start_height,\n\t\t\ttarget_height: scope.target_height,\n\t\t\tbootstrap_source: scope.bootstrap.source,\n\t\t\tbootstrap_manifest_digest: scope.bootstrap.manifest_digest,\n\t\t\tgenesis_hash: scope.bootstrap.genesis_hash,\n\t\t})\n\t\t.onConflict((oc) =>\n\t\t\toc.column(\"network\").doUpdateSet({\n\t\t\t\tstart_height: scope.start_height,\n\t\t\t\ttarget_height: scope.target_height,\n\t\t\t\tbootstrap_source: scope.bootstrap.source,\n\t\t\t\tbootstrap_manifest_digest: scope.bootstrap.manifest_digest,\n\t\t\t\tgenesis_hash: scope.bootstrap.genesis_hash,\n\t\t\t\tupdated_at: new Date(),\n\t\t\t}),\n\t\t)\n\t\t.returning([\n\t\t\t\"network\",\n\t\t\t\"start_height\",\n\t\t\t\"target_height\",\n\t\t\t\"bootstrap_source\",\n\t\t\t\"bootstrap_manifest_digest\",\n\t\t\t\"genesis_hash\",\n\t\t])\n\t\t.executeTakeFirstOrThrow();\n\treturn toScope(row);\n}\n\n/**\n * The persisted scope, or one derived from the database when none was ever\n * recorded.\n *\n * The derivation is deliberately conservative: it claims only what the data\n * already shows (the lowest canonical block, the genesis hash if genesis is\n * present) and never invents provenance — an instance whose history starts\n * above genesis with no recorded bootstrap is an `import`, not an archive\n * restore we can vouch for.\n */\nexport async function resolveSyncScope(\n\tdb: Kysely<Database>,\n\tnetwork: string,\n): Promise<SyncScope> {\n\tconst persisted = await getSyncScope(db, network);\n\tif (persisted) return persisted;\n\n\tconst declaredStart = syncStartHeightFromEnv();\n\tconst lowest = await db\n\t\t.selectFrom(\"blocks\")\n\t\t.select(({ fn }) => fn.min(\"height\").as(\"min\"))\n\t\t.where(\"canonical\", \"=\", true)\n\t\t.executeTakeFirst();\n\tconst lowestStored =\n\t\tlowest?.min === null || lowest?.min === undefined\n\t\t\t? null\n\t\t\t: Number(lowest.min);\n\tconst startHeight = declaredStart ?? lowestStored ?? 0;\n\n\tconst genesis =\n\t\tstartHeight === 0\n\t\t\t? await db\n\t\t\t\t\t.selectFrom(\"blocks\")\n\t\t\t\t\t.select(\"hash\")\n\t\t\t\t\t.where(\"canonical\", \"=\", true)\n\t\t\t\t\t.where(\"height\", \"=\", 0)\n\t\t\t\t\t.executeTakeFirst()\n\t\t\t: undefined;\n\n\treturn {\n\t\tnetwork,\n\t\tstart_height: startHeight,\n\t\ttarget_height: null,\n\t\tbootstrap: {\n\t\t\tsource: startHeight === 0 ? \"genesis\" : \"import\",\n\t\t\tmanifest_digest: null,\n\t\t\tgenesis_hash: genesis?.hash ?? null,\n\t\t},\n\t};\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;AAuBO,IAAM,wBAA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MACxC,iBAAiB;AAAA,MACjB,cAAc,SAAS,QAAQ;AAAA,IAChC;AAAA,EACD;AAAA;",
8
+ "debugId": "A8458ACA2A49456264756E2164756E21",
9
+ "names": []
10
+ }
@@ -17,6 +17,7 @@ declare const FAILURE_CLASSES: readonly ["omission", "version", "digest_mismatch
17
17
  type FailureClass = (typeof FAILURE_CLASSES)[number];
18
18
  declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
19
19
  type RetryState = (typeof RETRY_STATES)[number];
20
+ type BootstrapSource = "archive" | "genesis" | "import";
20
21
  interface BlocksTable {
21
22
  height: number;
22
23
  hash: string;
@@ -719,6 +720,20 @@ interface StageFailuresTable {
719
720
  resolved_at: Date | null;
720
721
  retain_until: Generated<Date>;
721
722
  }
723
+ /**
724
+ * The instance's declared scope — one row per network. `start_height` is what
725
+ * makes missing history below it deliberate rather than a gap.
726
+ */
727
+ interface SyncScopesTable {
728
+ network: string;
729
+ start_height: number;
730
+ target_height: number | null;
731
+ bootstrap_source: BootstrapSource;
732
+ bootstrap_manifest_digest: string | null;
733
+ genesis_hash: string | null;
734
+ created_at: Generated<Date>;
735
+ updated_at: Generated<Date>;
736
+ }
722
737
  interface Database {
723
738
  blocks: BlocksTable;
724
739
  transactions: TransactionsTable;
@@ -771,6 +786,7 @@ interface Database {
771
786
  chain_read_cache: ChainReadCacheTable;
772
787
  pending_fork_blocks: PendingForkBlocksTable;
773
788
  observer_journal: ObserverJournalTable;
789
+ sync_scopes: SyncScopesTable;
774
790
  stage_registry: StageRegistryTable;
775
791
  stage_runs: StageRunsTable;
776
792
  stage_block_receipts: StageBlockReceiptsTable;
@@ -979,4 +995,4 @@ interface TriggerEvaluatorStateTable {
979
995
  updated_at: Generated<Date>;
980
996
  }
981
997
  type TriggerEvaluatorState = Selectable<TriggerEvaluatorStateTable>;
982
- export { X402PaymentsTable, X402BalancesTable, UpdateTransaction, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, StageRunsTable, StageRegistryTable, StageKind, StageFailuresTable, StageBlockReceiptsTable, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, RunStatus, RetryState, RepairMode, ProcessedStripeEventsTable, Pox5EventsTable, Pox5EventTopic, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PendingForkBlocksTable, OutboxStatus, ObserverJournalTable, ObserverJournalStatus, NativeClock, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, InstancesTable, InsertTransaction, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountCredits, InsertAccount, IndexProgressTable, IndexProgress, FailureUnit, FailureClass, EventsTable, EventsArchiveTable, Event, DecoderCheckpointsTable, DecodedEventsTable, DeadLetterEventsTable, Database, CoverageSegmentsTable, ContractsTable, Contract, ChainReorgsTable, ChainReadCacheTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountCreditsTable, AccountCredits, Account };
998
+ export { X402PaymentsTable, X402BalancesTable, UpdateTransaction, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, SyncScopesTable, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, StageRunsTable, StageRegistryTable, StageKind, StageFailuresTable, StageBlockReceiptsTable, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, RunStatus, RetryState, RepairMode, ProcessedStripeEventsTable, Pox5EventsTable, Pox5EventTopic, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PendingForkBlocksTable, OutboxStatus, ObserverJournalTable, ObserverJournalStatus, NativeClock, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, InstancesTable, InsertTransaction, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountCredits, InsertAccount, IndexProgressTable, IndexProgress, FailureUnit, FailureClass, EventsTable, EventsArchiveTable, Event, DecoderCheckpointsTable, DecodedEventsTable, DeadLetterEventsTable, Database, CoverageSegmentsTable, ContractsTable, Contract, ChainReorgsTable, ChainReadCacheTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountCreditsTable, AccountCredits, Account };
@@ -17,6 +17,7 @@ declare const FAILURE_CLASSES: readonly ["omission", "version", "digest_mismatch
17
17
  type FailureClass = (typeof FAILURE_CLASSES)[number];
18
18
  declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
19
19
  type RetryState = (typeof RETRY_STATES)[number];
20
+ type BootstrapSource = "archive" | "genesis" | "import";
20
21
  interface BlocksTable {
21
22
  height: number;
22
23
  hash: string;
@@ -719,6 +720,20 @@ interface StageFailuresTable {
719
720
  resolved_at: Date | null;
720
721
  retain_until: Generated<Date>;
721
722
  }
723
+ /**
724
+ * The instance's declared scope — one row per network. `start_height` is what
725
+ * makes missing history below it deliberate rather than a gap.
726
+ */
727
+ interface SyncScopesTable {
728
+ network: string;
729
+ start_height: number;
730
+ target_height: number | null;
731
+ bootstrap_source: BootstrapSource;
732
+ bootstrap_manifest_digest: string | null;
733
+ genesis_hash: string | null;
734
+ created_at: Generated<Date>;
735
+ updated_at: Generated<Date>;
736
+ }
722
737
  interface Database {
723
738
  blocks: BlocksTable;
724
739
  transactions: TransactionsTable;
@@ -771,6 +786,7 @@ interface Database {
771
786
  chain_read_cache: ChainReadCacheTable;
772
787
  pending_fork_blocks: PendingForkBlocksTable;
773
788
  observer_journal: ObserverJournalTable;
789
+ sync_scopes: SyncScopesTable;
774
790
  stage_registry: StageRegistryTable;
775
791
  stage_runs: StageRunsTable;
776
792
  stage_block_receipts: StageBlockReceiptsTable;
@@ -1928,6 +1944,7 @@ declare const TABLE_TO_DB: {
1928
1944
  chain_read_cache: string
1929
1945
  pending_fork_blocks: string
1930
1946
  observer_journal: string
1947
+ sync_scopes: string
1931
1948
  stage_registry: string
1932
1949
  stage_runs: string
1933
1950
  stage_block_receipts: string
@@ -3003,4 +3020,4 @@ interface ChainTestDelivery {
3003
3020
  * "Chain subscription webhook payloads" doc.
3004
3021
  */
3005
3022
  type ChainWebhookDelivery = ChainApplyDeliveryOf<"stx_transfer", ChainEventEnvelope<"stx_transfer_event", ChainStxTransferData>> | ChainApplyDeliveryOf<"stx_mint", ChainEventEnvelope<"stx_mint_event", ChainStxMintData>> | ChainApplyDeliveryOf<"stx_burn", ChainEventEnvelope<"stx_burn_event", ChainStxBurnData>> | ChainApplyDeliveryOf<"stx_lock", ChainEventEnvelope<"stx_lock_event", ChainStxLockData>> | ChainApplyDeliveryOf<"ft_transfer", ChainEventEnvelope<"ft_transfer_event", ChainFtTransferData>> | ChainApplyDeliveryOf<"ft_mint", ChainEventEnvelope<"ft_mint_event", ChainFtMintData>> | ChainApplyDeliveryOf<"ft_burn", ChainEventEnvelope<"ft_burn_event", ChainFtBurnData>> | ChainApplyDeliveryOf<"nft_transfer", ChainEventEnvelope<"nft_transfer_event", ChainNftTransferData>> | ChainApplyDeliveryOf<"nft_mint", ChainEventEnvelope<"nft_mint_event", ChainNftMintData>> | ChainApplyDeliveryOf<"nft_burn", ChainEventEnvelope<"nft_burn_event", ChainNftBurnData>> | ChainApplyDeliveryOf<"print_event", ChainEventEnvelope<"contract_event", ChainPrintEventData>> | ChainApplyDeliveryOf<"contract_call", ChainTxLevelEvent> | ChainApplyDeliveryOf<"contract_deploy", ChainTxLevelEvent> | ChainApplyDeliveryOf<"sbtc_deposit", SbtcDepositEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_create", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_accept", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_reject", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_swept_confirmed", SbtcWithdrawalSweptConfirmedEvent> | ChainReorgRollbackDelivery | ChainTestDelivery;
3006
- export { validateSubscriptionFilterForTable, sql, setMigrationRole, parseJsonb, onControlPlane, onChainPlane, logger, jsonb, isPox5DecoderEnabled, isPox4DecoderEnabled, isEmptyRangeCursor, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getMigrationRole, getErrorMessage, getEnv, getDbSplitStatus, getDb, generateSubgraphSpec, generateSubgraphOpenApi, generateSubgraphMarkdown, generateSubgraphAgentSchema, formatSubscriptionSchemaErrors, finalizedBurnHeight, encodeStreamsCursor, exports_ed25519 as ed25519, decodeStreamsCursor, exports_hmac as crypto, compareStreamsCursor, closeDb, blockEndCursor, assertDbSplit, applicationDatabaseUrl, X402PaymentsTable, X402BalancesTable, VersionConflictError, ValidationError, UpdateTransaction, UpdateSubscriptionRequestSchema, UpdateSubscriptionRequest, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantSuspendedError, TABLE_TO_DB, SubscriptionsTable, SubscriptionSummary, SubscriptionStatusSchema, SubscriptionStatus, SubscriptionSchemaTables, SubscriptionSchemaTable, SubscriptionSchemaColumn, SubscriptionRuntimeSchema, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormatSchema, SubscriptionFormat, SubscriptionFilterSchema, SubscriptionFilterPrimitiveSchema, SubscriptionFilterPrimitive, SubscriptionFilterOperatorSchema, SubscriptionFilterOperator, SubscriptionFilterClauseSchema, SubscriptionFilterClause, SubscriptionFilter, SubscriptionDetail, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphTableSnapshotsTable, SubgraphSyncInfo, SubgraphSummary, SubgraphSpecOptions, SubgraphSpecFormat, SubgraphQueryParams, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphGap, SubgraphDetail, SubgraphAggregateResponse, SubgraphAggregateParams, SubgraphAgentSchema, Subgraph, StreamsEventType, StreamsDbEventType, StreamsCursor, StageRunsTable, StageRegistryTable, StageKind, StageFailuresTable, StageBlockReceiptsTable, SessionsTable, Session, ServiceHeartbeatsTable, SecondLayerError, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalEvent, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, SbtcDepositEvent, SUBSCRIPTION_STATUSES, SUBSCRIPTION_RUNTIMES, SUBSCRIPTION_FORMATS, SUBSCRIPTION_FILTER_OPERATORS, STREAMS_TO_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_DB_EVENT_TYPES, SOURCE_READ_TYPES, SOURCE_READ_PKS, SOURCE_READ_COLUMNS, RunStatus, RotateSecretResponse, RetryState, ReplaySubscriptionRequestSchema, ReplaySubscriptionRequest, ReplayResult, RepairMode, ReindexResponse, RateLimitError, ProcessedStripeEventsTable, Pox5EventsTable, Pox5EventTopic, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PendingForkBlocksTable, PaymentRequiredError, ParsedUpdateSubscriptionRequest, ParsedReplaySubscriptionRequest, ParsedCreateSubscriptionRequest, OutboxStatus, ObserverJournalTable, ObserverJournalStatus, NumericAsText, NotFoundError, NativeClock, MigrationRole, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, KeyRotatedError, InstancesTable, InsertTransaction, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountCredits, InsertAccount, IndexProgressTable, IndexProgress, IndexPrimaryKey, IndexColumnType, IndexColumn, ForbiddenError, FailureUnit, FailureClass, EventsTable, EventsArchiveTable, Event, ErrorCodes, ErrorCode, Env, EMPTY_RANGE_EVENT_INDEX_SENTINEL, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DecoderCheckpointsTable, DecodedEventsTable, DecodedEventType2 as DecodedEventType, DeadRow, DeadLetterEventsTable, DbSplitStatus, DbReadRow, DbPlane, DatabaseError, Database, DEFAULT_BTC_CONFIRMATIONS, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DB_TO_STREAMS_EVENT_TYPE, CreateSubscriptionResponse, CreateSubscriptionRequestSchema, CreateSubscriptionRequest, CoverageSegmentsTable, ContractsTable, Contract, ChainWebhookEnvelope, ChainWebhookDelivery, ChainTxLevelEvent, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgsTable, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainReadCacheTable, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, ChainApplyDeliveryOf, CODE_TO_STATUS, CHAIN_TRIGGER_TYPES, CHAIN_TRIGGER_FIELDS, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, AuthorizationError, AuthenticationError, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountCreditsTable, AccountCredits, Account };
3023
+ export { validateSubscriptionFilterForTable, sql, setMigrationRole, parseJsonb, onControlPlane, onChainPlane, logger, jsonb, isPox5DecoderEnabled, isPox4DecoderEnabled, isEmptyRangeCursor, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getMigrationRole, getErrorMessage, getEnv, getDbSplitStatus, getDb, generateSubgraphSpec, generateSubgraphOpenApi, generateSubgraphMarkdown, generateSubgraphAgentSchema, formatSubscriptionSchemaErrors, finalizedBurnHeight, encodeStreamsCursor, exports_ed25519 as ed25519, decodeStreamsCursor, exports_hmac as crypto, compareStreamsCursor, closeDb, blockEndCursor, assertDbSplit, applicationDatabaseUrl, X402PaymentsTable, X402BalancesTable, VersionConflictError, ValidationError, UpdateTransaction, UpdateSubscriptionRequestSchema, UpdateSubscriptionRequest, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantSuspendedError, TABLE_TO_DB, SyncScopesTable, SubscriptionsTable, SubscriptionSummary, SubscriptionStatusSchema, SubscriptionStatus, SubscriptionSchemaTables, SubscriptionSchemaTable, SubscriptionSchemaColumn, SubscriptionRuntimeSchema, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormatSchema, SubscriptionFormat, SubscriptionFilterSchema, SubscriptionFilterPrimitiveSchema, SubscriptionFilterPrimitive, SubscriptionFilterOperatorSchema, SubscriptionFilterOperator, SubscriptionFilterClauseSchema, SubscriptionFilterClause, SubscriptionFilter, SubscriptionDetail, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphTableSnapshotsTable, SubgraphSyncInfo, SubgraphSummary, SubgraphSpecOptions, SubgraphSpecFormat, SubgraphQueryParams, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphGap, SubgraphDetail, SubgraphAggregateResponse, SubgraphAggregateParams, SubgraphAgentSchema, Subgraph, StreamsEventType, StreamsDbEventType, StreamsCursor, StageRunsTable, StageRegistryTable, StageKind, StageFailuresTable, StageBlockReceiptsTable, SessionsTable, Session, ServiceHeartbeatsTable, SecondLayerError, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalEvent, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, SbtcDepositEvent, SUBSCRIPTION_STATUSES, SUBSCRIPTION_RUNTIMES, SUBSCRIPTION_FORMATS, SUBSCRIPTION_FILTER_OPERATORS, STREAMS_TO_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_DB_EVENT_TYPES, SOURCE_READ_TYPES, SOURCE_READ_PKS, SOURCE_READ_COLUMNS, RunStatus, RotateSecretResponse, RetryState, ReplaySubscriptionRequestSchema, ReplaySubscriptionRequest, ReplayResult, RepairMode, ReindexResponse, RateLimitError, ProcessedStripeEventsTable, Pox5EventsTable, Pox5EventTopic, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PendingForkBlocksTable, PaymentRequiredError, ParsedUpdateSubscriptionRequest, ParsedReplaySubscriptionRequest, ParsedCreateSubscriptionRequest, OutboxStatus, ObserverJournalTable, ObserverJournalStatus, NumericAsText, NotFoundError, NativeClock, MigrationRole, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, KeyRotatedError, InstancesTable, InsertTransaction, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountCredits, InsertAccount, IndexProgressTable, IndexProgress, IndexPrimaryKey, IndexColumnType, IndexColumn, ForbiddenError, FailureUnit, FailureClass, EventsTable, EventsArchiveTable, Event, ErrorCodes, ErrorCode, Env, EMPTY_RANGE_EVENT_INDEX_SENTINEL, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DecoderCheckpointsTable, DecodedEventsTable, DecodedEventType2 as DecodedEventType, DeadRow, DeadLetterEventsTable, DbSplitStatus, DbReadRow, DbPlane, DatabaseError, Database, DEFAULT_BTC_CONFIRMATIONS, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DB_TO_STREAMS_EVENT_TYPE, CreateSubscriptionResponse, CreateSubscriptionRequestSchema, CreateSubscriptionRequest, CoverageSegmentsTable, ContractsTable, Contract, ChainWebhookEnvelope, ChainWebhookDelivery, ChainTxLevelEvent, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgsTable, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainReadCacheTable, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, ChainApplyDeliveryOf, CODE_TO_STATUS, CHAIN_TRIGGER_TYPES, CHAIN_TRIGGER_FIELDS, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, AuthorizationError, AuthenticationError, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountCreditsTable, AccountCredits, Account };
package/dist/src/index.js CHANGED
@@ -740,6 +740,7 @@ var TABLE_TO_DB = {
740
740
  chain_read_cache: "source",
741
741
  pending_fork_blocks: "source",
742
742
  observer_journal: "source",
743
+ sync_scopes: "source",
743
744
  stage_registry: "source",
744
745
  stage_runs: "source",
745
746
  stage_block_receipts: "source",
@@ -2146,5 +2147,5 @@ export {
2146
2147
  AuthenticationError
2147
2148
  };
2148
2149
 
2149
- //# debugId=95914A05F165D58164756E2164756E21
2150
+ //# debugId=8F376771928DF15764756E2164756E21
2150
2151
  //# sourceMappingURL=index.js.map