@secondlayer/shared 7.11.2 → 9.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.
- package/dist/src/archive/range-digest.d.ts +16 -169
- package/dist/src/archive/semantic-digest-builder.d.ts +16 -169
- package/dist/src/archive/status.js +11 -3
- package/dist/src/archive/status.js.map +3 -3
- package/dist/src/coverage/index.d.ts +15 -169
- package/dist/src/crypto/secrets.js +22 -3
- package/dist/src/crypto/secrets.js.map +3 -3
- package/dist/src/db/index.d.ts +18 -211
- package/dist/src/db/index.js +23 -16
- package/dist/src/db/index.js.map +4 -4
- package/dist/src/db/queries/chain-reorgs.d.ts +16 -169
- package/dist/src/db/queries/chain-reorgs.js +23 -16
- package/dist/src/db/queries/chain-reorgs.js.map +4 -4
- package/dist/src/db/queries/contracts.d.ts +16 -169
- package/dist/src/db/queries/instance.d.ts +16 -169
- package/dist/src/db/queries/integrity.d.ts +16 -169
- package/dist/src/db/queries/subgraph-gaps.d.ts +16 -169
- package/dist/src/db/queries/subgraph-operations.d.ts +17 -170
- package/dist/src/db/queries/subgraph-operations.js +1 -15
- package/dist/src/db/queries/subgraph-operations.js.map +3 -3
- package/dist/src/db/queries/subgraphs.d.ts +17 -191
- package/dist/src/db/queries/subgraphs.js +30 -1068
- package/dist/src/db/queries/subgraphs.js.map +5 -12
- package/dist/src/db/queries/subscriptions.d.ts +16 -169
- package/dist/src/db/queries/subscriptions.js +22 -3
- package/dist/src/db/queries/subscriptions.js.map +3 -3
- package/dist/src/db/queries/sync-scope.d.ts +1006 -0
- package/dist/src/db/queries/sync-scope.js +116 -0
- package/dist/src/db/queries/sync-scope.js.map +10 -0
- package/dist/src/db/schema.d.ts +17 -198
- package/dist/src/errors.d.ts +1 -22
- package/dist/src/errors.js +2 -4
- package/dist/src/errors.js.map +3 -3
- package/dist/src/index.d.ts +22 -256
- package/dist/src/index.js +24 -20
- package/dist/src/index.js.map +6 -6
- package/dist/src/mode.d.ts +16 -2
- package/dist/src/mode.js +25 -4
- package/dist/src/mode.js.map +3 -3
- package/dist/src/node/local-client.d.ts +16 -169
- package/dist/src/runtime/index.d.ts +137 -18
- package/dist/src/runtime/index.js +261 -41
- package/dist/src/runtime/index.js.map +9 -7
- package/dist/src/schemas/index.d.ts +5 -25
- package/dist/src/schemas/index.js +1 -2
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/subgraphs.d.ts +5 -25
- package/dist/src/schemas/subgraphs.js +1 -2
- package/dist/src/schemas/subgraphs.js.map +3 -3
- package/dist/src/streams-rows/index.d.ts +399 -0
- package/dist/src/streams-rows/index.js +336 -0
- package/dist/src/streams-rows/index.js.map +17 -0
- package/dist/src/subgraphs/spec.d.ts +0 -9
- package/migrations/0118_drop_retired_control_tables.ts +53 -0
- package/migrations/0119_drop_accounts_plan.ts +29 -0
- package/migrations/0120_sync_scopes.ts +42 -0
- package/package.json +10 -6
- package/dist/src/x402.d.ts +0 -47
- package/dist/src/x402.js +0 -79
- package/dist/src/x402.js.map +0 -10
package/dist/src/index.d.ts
CHANGED
|
@@ -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;
|
|
@@ -222,11 +223,9 @@ interface AccountsTable {
|
|
|
222
223
|
ghost: Generated<boolean>;
|
|
223
224
|
/** Stacks principal owning a wallet-ghost account (x402-paid deploys). */
|
|
224
225
|
wallet_principal: string | null;
|
|
225
|
-
plan: Generated<string>;
|
|
226
226
|
display_name: string | null;
|
|
227
227
|
bio: string | null;
|
|
228
228
|
avatar_url: string | null;
|
|
229
|
-
slug: string | null;
|
|
230
229
|
stripe_customer_id: string | null;
|
|
231
230
|
/** Opt-out toggle for the subgraph reindex-completion email. Defaults true. */
|
|
232
231
|
notify_reindex_complete: Generated<boolean>;
|
|
@@ -243,19 +242,6 @@ interface SessionsTable {
|
|
|
243
242
|
last_used_at: Date | null;
|
|
244
243
|
created_at: Generated<Date>;
|
|
245
244
|
}
|
|
246
|
-
/**
|
|
247
|
-
* One-time claim tokens for ghost accounts. The raw token only ever appears in
|
|
248
|
-
* the claim URL returned at mint time; we store its sha256. A used token marks
|
|
249
|
-
* the account as claimed (or merged into an existing account).
|
|
250
|
-
*/
|
|
251
|
-
interface ClaimTokensTable {
|
|
252
|
-
id: Generated<string>;
|
|
253
|
-
account_id: string;
|
|
254
|
-
token_hash: string;
|
|
255
|
-
created_at: Generated<Date>;
|
|
256
|
-
expires_at: Date;
|
|
257
|
-
used_at: Date | null;
|
|
258
|
-
}
|
|
259
245
|
interface MagicLinksTable {
|
|
260
246
|
id: Generated<string>;
|
|
261
247
|
email: string;
|
|
@@ -266,47 +252,6 @@ interface MagicLinksTable {
|
|
|
266
252
|
failed_attempts: Generated<number>;
|
|
267
253
|
created_at: Generated<Date>;
|
|
268
254
|
}
|
|
269
|
-
interface UsageDailyTable {
|
|
270
|
-
account_id: string;
|
|
271
|
-
tenant_id: string | null;
|
|
272
|
-
date: string;
|
|
273
|
-
api_requests: Generated<number>;
|
|
274
|
-
deliveries: Generated<number>;
|
|
275
|
-
streams_events_returned: Generated<number>;
|
|
276
|
-
index_decoded_events_returned: Generated<number>;
|
|
277
|
-
}
|
|
278
|
-
interface UsageSnapshotsTable {
|
|
279
|
-
id: Generated<string>;
|
|
280
|
-
account_id: string;
|
|
281
|
-
measured_at: Generated<Date>;
|
|
282
|
-
storage_bytes: Generated<number>;
|
|
283
|
-
}
|
|
284
|
-
interface AccountInsightsTable {
|
|
285
|
-
id: Generated<string>;
|
|
286
|
-
account_id: string;
|
|
287
|
-
category: string;
|
|
288
|
-
insight_type: string;
|
|
289
|
-
resource_id: string | null;
|
|
290
|
-
severity: string;
|
|
291
|
-
title: string;
|
|
292
|
-
body: string;
|
|
293
|
-
data: unknown;
|
|
294
|
-
dismissed_at: Date | null;
|
|
295
|
-
expires_at: Date | null;
|
|
296
|
-
created_at: Generated<Date>;
|
|
297
|
-
}
|
|
298
|
-
interface AccountAgentRunsTable {
|
|
299
|
-
id: Generated<string>;
|
|
300
|
-
account_id: string;
|
|
301
|
-
started_at: Generated<Date>;
|
|
302
|
-
completed_at: Date | null;
|
|
303
|
-
status: Generated<string>;
|
|
304
|
-
input_tokens: Generated<number>;
|
|
305
|
-
output_tokens: Generated<number>;
|
|
306
|
-
cost_usd: Generated<number>;
|
|
307
|
-
insights_created: Generated<number>;
|
|
308
|
-
error: string | null;
|
|
309
|
-
}
|
|
310
255
|
interface SubgraphProcessingStatsTable {
|
|
311
256
|
id: Generated<string>;
|
|
312
257
|
subgraph_name: string;
|
|
@@ -339,41 +284,6 @@ interface SubgraphHealthSnapshotsTable {
|
|
|
339
284
|
last_processed_block: number | null;
|
|
340
285
|
captured_at: Generated<Date>;
|
|
341
286
|
}
|
|
342
|
-
interface SubgraphUsageDailyTable {
|
|
343
|
-
subgraph_id: string;
|
|
344
|
-
date: string;
|
|
345
|
-
query_count: Generated<number>;
|
|
346
|
-
}
|
|
347
|
-
interface ProjectsTable {
|
|
348
|
-
id: Generated<string>;
|
|
349
|
-
name: string;
|
|
350
|
-
slug: string;
|
|
351
|
-
account_id: string;
|
|
352
|
-
settings: Generated<Record<string, unknown>>;
|
|
353
|
-
network: Generated<string>;
|
|
354
|
-
node_rpc: string | null;
|
|
355
|
-
created_at: Generated<Date>;
|
|
356
|
-
updated_at: Generated<Date>;
|
|
357
|
-
}
|
|
358
|
-
interface TeamMembersTable {
|
|
359
|
-
id: Generated<string>;
|
|
360
|
-
project_id: string;
|
|
361
|
-
account_id: string;
|
|
362
|
-
role: Generated<string>;
|
|
363
|
-
invited_by: string | null;
|
|
364
|
-
created_at: Generated<Date>;
|
|
365
|
-
}
|
|
366
|
-
interface TeamInvitationsTable {
|
|
367
|
-
id: Generated<string>;
|
|
368
|
-
project_id: string;
|
|
369
|
-
email: string;
|
|
370
|
-
role: Generated<string>;
|
|
371
|
-
token: string;
|
|
372
|
-
invited_by: string | null;
|
|
373
|
-
expires_at: Date;
|
|
374
|
-
accepted_at: Date | null;
|
|
375
|
-
created_at: Generated<Date>;
|
|
376
|
-
}
|
|
377
287
|
interface ProcessedStripeEventsTable {
|
|
378
288
|
event_id: string;
|
|
379
289
|
event_type: string;
|
|
@@ -810,6 +720,20 @@ interface StageFailuresTable {
|
|
|
810
720
|
resolved_at: Date | null;
|
|
811
721
|
retain_until: Generated<Date>;
|
|
812
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
|
+
}
|
|
813
737
|
interface Database {
|
|
814
738
|
blocks: BlocksTable;
|
|
815
739
|
transactions: TransactionsTable;
|
|
@@ -826,27 +750,14 @@ interface Database {
|
|
|
826
750
|
accounts: AccountsTable;
|
|
827
751
|
sessions: SessionsTable;
|
|
828
752
|
magic_links: MagicLinksTable;
|
|
829
|
-
claim_tokens: ClaimTokensTable;
|
|
830
|
-
usage_daily: UsageDailyTable;
|
|
831
|
-
usage_snapshots: UsageSnapshotsTable;
|
|
832
|
-
account_insights: AccountInsightsTable;
|
|
833
|
-
account_agent_runs: AccountAgentRunsTable;
|
|
834
753
|
subgraph_health_snapshots: SubgraphHealthSnapshotsTable;
|
|
835
754
|
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
836
755
|
subgraph_table_snapshots: SubgraphTableSnapshotsTable;
|
|
837
756
|
subgraph_gaps: SubgraphGapsTable;
|
|
838
757
|
subgraph_operations: SubgraphOperationsTable;
|
|
839
|
-
subgraph_usage_daily: SubgraphUsageDailyTable;
|
|
840
|
-
projects: ProjectsTable;
|
|
841
|
-
team_members: TeamMembersTable;
|
|
842
|
-
team_invitations: TeamInvitationsTable;
|
|
843
758
|
processed_stripe_events: ProcessedStripeEventsTable;
|
|
844
|
-
tenants: TenantsTable;
|
|
845
|
-
tenant_usage_monthly: TenantUsageMonthlyTable;
|
|
846
|
-
tenant_compute_addons: TenantComputeAddonsTable;
|
|
847
759
|
account_spend_caps: AccountSpendCapsTable;
|
|
848
760
|
account_credits: AccountCreditsTable;
|
|
849
|
-
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
850
761
|
subscriptions: SubscriptionsTable;
|
|
851
762
|
subscription_outbox: SubscriptionOutboxTable;
|
|
852
763
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
@@ -875,6 +786,7 @@ interface Database {
|
|
|
875
786
|
chain_read_cache: ChainReadCacheTable;
|
|
876
787
|
pending_fork_blocks: PendingForkBlocksTable;
|
|
877
788
|
observer_journal: ObserverJournalTable;
|
|
789
|
+
sync_scopes: SyncScopesTable;
|
|
878
790
|
stage_registry: StageRegistryTable;
|
|
879
791
|
stage_runs: StageRunsTable;
|
|
880
792
|
stage_block_receipts: StageBlockReceiptsTable;
|
|
@@ -921,66 +833,6 @@ interface X402PaymentsTable {
|
|
|
921
833
|
* reconciler's heal path can never double-credit them. */
|
|
922
834
|
credited_at: Generated<Date> | null;
|
|
923
835
|
}
|
|
924
|
-
type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
|
|
925
|
-
interface TenantsTable {
|
|
926
|
-
id: Generated<string>;
|
|
927
|
-
account_id: string;
|
|
928
|
-
slug: string;
|
|
929
|
-
status: ColumnType<TenantStatus, TenantStatus | undefined, TenantStatus>;
|
|
930
|
-
plan: string;
|
|
931
|
-
cpus: ColumnType<number, number | string, number | string>;
|
|
932
|
-
memory_mb: number;
|
|
933
|
-
storage_limit_mb: number;
|
|
934
|
-
storage_used_mb: number | null;
|
|
935
|
-
pg_container_id: string | null;
|
|
936
|
-
api_container_id: string | null;
|
|
937
|
-
processor_container_id: string | null;
|
|
938
|
-
target_database_url_enc: Buffer;
|
|
939
|
-
tenant_jwt_secret_enc: Buffer;
|
|
940
|
-
anon_key_enc: Buffer;
|
|
941
|
-
service_key_enc: Buffer;
|
|
942
|
-
api_url_internal: string;
|
|
943
|
-
api_url_public: string;
|
|
944
|
-
suspended_at: Date | null;
|
|
945
|
-
last_health_check_at: Date | null;
|
|
946
|
-
last_active_at: Generated<Date>;
|
|
947
|
-
service_gen: Generated<number>;
|
|
948
|
-
anon_gen: Generated<number>;
|
|
949
|
-
project_id: string | null;
|
|
950
|
-
created_at: Generated<Date>;
|
|
951
|
-
updated_at: Generated<Date>;
|
|
952
|
-
}
|
|
953
|
-
type Tenant = Selectable<TenantsTable>;
|
|
954
|
-
type InsertTenant = Insertable<TenantsTable>;
|
|
955
|
-
type UpdateTenant = Updateable<TenantsTable>;
|
|
956
|
-
interface TenantUsageMonthlyTable {
|
|
957
|
-
id: Generated<string>;
|
|
958
|
-
tenant_id: string;
|
|
959
|
-
period_month: Date;
|
|
960
|
-
storage_peak_mb: Generated<number>;
|
|
961
|
-
storage_avg_mb: Generated<number>;
|
|
962
|
-
storage_last_mb: Generated<number>;
|
|
963
|
-
measurements: Generated<number>;
|
|
964
|
-
first_at: Generated<Date>;
|
|
965
|
-
last_at: Generated<Date>;
|
|
966
|
-
}
|
|
967
|
-
type TenantUsageMonthly = Selectable<TenantUsageMonthlyTable>;
|
|
968
|
-
type InsertTenantUsageMonthly = Insertable<TenantUsageMonthlyTable>;
|
|
969
|
-
type UpdateTenantUsageMonthly = Updateable<TenantUsageMonthlyTable>;
|
|
970
|
-
interface TenantComputeAddonsTable {
|
|
971
|
-
id: Generated<string>;
|
|
972
|
-
tenant_id: string;
|
|
973
|
-
memory_mb_delta: Generated<number>;
|
|
974
|
-
cpu_delta: Generated<number | string>;
|
|
975
|
-
storage_mb_delta: Generated<number>;
|
|
976
|
-
effective_from: Generated<Date>;
|
|
977
|
-
effective_until: Date | null;
|
|
978
|
-
stripe_subscription_item_id: string | null;
|
|
979
|
-
created_at: Generated<Date>;
|
|
980
|
-
}
|
|
981
|
-
type TenantComputeAddon = Selectable<TenantComputeAddonsTable>;
|
|
982
|
-
type InsertTenantComputeAddon = Insertable<TenantComputeAddonsTable>;
|
|
983
|
-
type UpdateTenantComputeAddon = Updateable<TenantComputeAddonsTable>;
|
|
984
836
|
interface AccountSpendCapsTable {
|
|
985
837
|
account_id: string;
|
|
986
838
|
monthly_cap_cents: number | null;
|
|
@@ -1010,22 +862,6 @@ interface AccountCreditsTable {
|
|
|
1010
862
|
type AccountCredits = Selectable<AccountCreditsTable>;
|
|
1011
863
|
type InsertAccountCredits = Insertable<AccountCreditsTable>;
|
|
1012
864
|
type UpdateAccountCredits = Updateable<AccountCreditsTable>;
|
|
1013
|
-
type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
|
|
1014
|
-
type ProvisioningAuditStatus = "ok" | "error";
|
|
1015
|
-
interface ProvisioningAuditLogTable {
|
|
1016
|
-
id: Generated<string>;
|
|
1017
|
-
tenant_id: string | null;
|
|
1018
|
-
tenant_slug: string | null;
|
|
1019
|
-
account_id: string | null;
|
|
1020
|
-
actor: string;
|
|
1021
|
-
event: ProvisioningAuditEvent;
|
|
1022
|
-
status: ProvisioningAuditStatus;
|
|
1023
|
-
detail: unknown | null;
|
|
1024
|
-
error: string | null;
|
|
1025
|
-
created_at: Generated<Date>;
|
|
1026
|
-
}
|
|
1027
|
-
type ProvisioningAuditLog = Selectable<ProvisioningAuditLogTable>;
|
|
1028
|
-
type InsertProvisioningAuditLog = Insertable<ProvisioningAuditLogTable>;
|
|
1029
865
|
type Block = Selectable<BlocksTable>;
|
|
1030
866
|
type InsertBlock = Insertable<BlocksTable>;
|
|
1031
867
|
type UpdateBlock = Updateable<BlocksTable>;
|
|
@@ -1056,29 +892,12 @@ type Account = Selectable<AccountsTable>;
|
|
|
1056
892
|
type InsertAccount = Insertable<AccountsTable>;
|
|
1057
893
|
type MagicLink = Selectable<MagicLinksTable>;
|
|
1058
894
|
type InsertMagicLink = Insertable<MagicLinksTable>;
|
|
1059
|
-
type ClaimToken = Selectable<ClaimTokensTable>;
|
|
1060
|
-
type InsertClaimToken = Insertable<ClaimTokensTable>;
|
|
1061
895
|
type Session = Selectable<SessionsTable>;
|
|
1062
896
|
type InsertSession = Insertable<SessionsTable>;
|
|
1063
|
-
type UsageDaily = Selectable<UsageDailyTable>;
|
|
1064
|
-
type UsageSnapshot = Selectable<UsageSnapshotsTable>;
|
|
1065
|
-
type AccountInsight = Selectable<AccountInsightsTable>;
|
|
1066
|
-
type InsertAccountInsight = Insertable<AccountInsightsTable>;
|
|
1067
|
-
type AccountAgentRun = Selectable<AccountAgentRunsTable>;
|
|
1068
|
-
type InsertAccountAgentRun = Insertable<AccountAgentRunsTable>;
|
|
1069
897
|
type SubgraphHealthSnapshot = Selectable<SubgraphHealthSnapshotsTable>;
|
|
1070
898
|
type InsertSubgraphHealthSnapshot = Insertable<SubgraphHealthSnapshotsTable>;
|
|
1071
899
|
type SubgraphGap = Selectable<SubgraphGapsTable>;
|
|
1072
900
|
type InsertSubgraphGap = Insertable<SubgraphGapsTable>;
|
|
1073
|
-
type SubgraphUsageDaily = Selectable<SubgraphUsageDailyTable>;
|
|
1074
|
-
type InsertSubgraphUsageDaily = Insertable<SubgraphUsageDailyTable>;
|
|
1075
|
-
type Project = Selectable<ProjectsTable>;
|
|
1076
|
-
type InsertProject = Insertable<ProjectsTable>;
|
|
1077
|
-
type UpdateProject = Updateable<ProjectsTable>;
|
|
1078
|
-
type TeamMember = Selectable<TeamMembersTable>;
|
|
1079
|
-
type InsertTeamMember = Insertable<TeamMembersTable>;
|
|
1080
|
-
type TeamInvitation = Selectable<TeamInvitationsTable>;
|
|
1081
|
-
type InsertTeamInvitation = Insertable<TeamInvitationsTable>;
|
|
1082
901
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
1083
902
|
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
1084
903
|
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
@@ -2125,6 +1944,7 @@ declare const TABLE_TO_DB: {
|
|
|
2125
1944
|
chain_read_cache: string
|
|
2126
1945
|
pending_fork_blocks: string
|
|
2127
1946
|
observer_journal: string
|
|
1947
|
+
sync_scopes: string
|
|
2128
1948
|
stage_registry: string
|
|
2129
1949
|
stage_runs: string
|
|
2130
1950
|
stage_block_receipts: string
|
|
@@ -2152,20 +1972,8 @@ declare const TABLE_TO_DB: {
|
|
|
2152
1972
|
api_keys: string
|
|
2153
1973
|
sessions: string
|
|
2154
1974
|
magic_links: string
|
|
2155
|
-
claim_tokens: string
|
|
2156
|
-
usage_daily: string
|
|
2157
|
-
usage_snapshots: string
|
|
2158
|
-
account_insights: string
|
|
2159
|
-
account_agent_runs: string
|
|
2160
1975
|
account_spend_caps: string
|
|
2161
1976
|
processed_stripe_events: string
|
|
2162
|
-
tenants: string
|
|
2163
|
-
tenant_usage_monthly: string
|
|
2164
|
-
tenant_compute_addons: string
|
|
2165
|
-
provisioning_audit_log: string
|
|
2166
|
-
projects: string
|
|
2167
|
-
team_members: string
|
|
2168
|
-
team_invitations: string
|
|
2169
1977
|
subscriptions: string
|
|
2170
1978
|
subscription_outbox: string
|
|
2171
1979
|
subscription_deliveries: string
|
|
@@ -2174,7 +1982,6 @@ declare const TABLE_TO_DB: {
|
|
|
2174
1982
|
subgraph_operations: string
|
|
2175
1983
|
subgraph_health_snapshots: string
|
|
2176
1984
|
subgraph_gaps: string
|
|
2177
|
-
subgraph_usage_daily: string
|
|
2178
1985
|
subgraph_processing_stats: string
|
|
2179
1986
|
subgraph_table_snapshots: string
|
|
2180
1987
|
x402_payments: string
|
|
@@ -2267,27 +2074,6 @@ declare const ErrorCodes: {
|
|
|
2267
2074
|
readonly INSTANCE_EXISTS: "INSTANCE_EXISTS"
|
|
2268
2075
|
};
|
|
2269
2076
|
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
2270
|
-
/**
|
|
2271
|
-
* Structured payload carried on a refused BYO breaking-change deploy. Single-sourced
|
|
2272
|
-
* here so subgraphs (thrower), api (body), sdk (typed error), and cli (renderer) all
|
|
2273
|
-
* agree on shape. The deploy is still refused — this only describes the manual
|
|
2274
|
-
* DROP + rebuild the user must run themselves.
|
|
2275
|
-
*/
|
|
2276
|
-
interface ByoBreakingChangeDetails {
|
|
2277
|
-
reasons: string[];
|
|
2278
|
-
diff: {
|
|
2279
|
-
addedTables: string[]
|
|
2280
|
-
removedTables: string[]
|
|
2281
|
-
addedColumns: Record<string, string[]>
|
|
2282
|
-
breakingChanges: string[]
|
|
2283
|
-
};
|
|
2284
|
-
plan: {
|
|
2285
|
-
schemaName: string
|
|
2286
|
-
dropStatement: string
|
|
2287
|
-
statements: string[]
|
|
2288
|
-
grantScript: string
|
|
2289
|
-
};
|
|
2290
|
-
}
|
|
2291
2077
|
/** Base error class for all Secondlayer errors. */
|
|
2292
2078
|
declare class SecondLayerError extends Error {
|
|
2293
2079
|
code: ErrorCode;
|
|
@@ -2375,19 +2161,11 @@ interface DeploySubgraphRequest {
|
|
|
2375
2161
|
startBlock?: number;
|
|
2376
2162
|
/** Original TypeScript source, persisted so chat can read/diff/edit later. */
|
|
2377
2163
|
sourceCode?: string;
|
|
2378
|
-
/**
|
|
2379
|
-
* BYO data plane: a user-owned Postgres connection string. When set, the
|
|
2380
|
-
* subgraph's schema, handler writes, and serving reads live in this DB instead
|
|
2381
|
-
* of the managed one. Stored encrypted at rest, never returned.
|
|
2382
|
-
*/
|
|
2383
|
-
databaseUrl?: string;
|
|
2384
|
-
/** Validate the connection + print the DDL/grant plan without deploying. */
|
|
2164
|
+
/** Validate the definition + print the DDL plan without deploying. */
|
|
2385
2165
|
dryRun?: boolean;
|
|
2386
2166
|
/**
|
|
2387
|
-
* Read visibility. Server-side
|
|
2388
|
-
*
|
|
2389
|
-
* BYO-database deploys → private (public reads hit the user's own
|
|
2390
|
-
* Postgres, so going public is an explicit choice).
|
|
2167
|
+
* Read visibility. Server-side default: deploys → public (anon reads on
|
|
2168
|
+
* /v1/subgraphs, name claimed in the global public namespace).
|
|
2391
2169
|
*/
|
|
2392
2170
|
visibility?: "public" | "private";
|
|
2393
2171
|
}
|
|
@@ -2398,10 +2176,8 @@ interface DeploySubgraphResponse {
|
|
|
2398
2176
|
version: string;
|
|
2399
2177
|
visibility?: "public" | "private";
|
|
2400
2178
|
message: string;
|
|
2401
|
-
/** Effective indexing start height
|
|
2179
|
+
/** Effective indexing start height. */
|
|
2402
2180
|
start_block?: number;
|
|
2403
|
-
/** True when the free-tier forward-only policy adjusted the start. */
|
|
2404
|
-
start_block_clamped?: boolean;
|
|
2405
2181
|
operationId?: string;
|
|
2406
2182
|
reindexStarted?: boolean;
|
|
2407
2183
|
/** Bounded candidate-event denominator for the reindex just started, when the
|
|
@@ -2432,7 +2208,6 @@ interface SubgraphSummary {
|
|
|
2432
2208
|
progress: number;
|
|
2433
2209
|
blocksRemaining?: number;
|
|
2434
2210
|
syncMode?: "sync" | "reindex";
|
|
2435
|
-
resourceWarning?: SubgraphResourceWarning;
|
|
2436
2211
|
gapCount: number;
|
|
2437
2212
|
/** history_filling = expected gaps while a tip-first backfill op runs. */
|
|
2438
2213
|
integrity: "complete" | "gaps_detected" | "history_filling";
|
|
@@ -2480,7 +2255,6 @@ interface SubgraphSyncInfo {
|
|
|
2480
2255
|
estimatedEvents?: number;
|
|
2481
2256
|
processedEvents?: number;
|
|
2482
2257
|
etaSeconds?: number | null;
|
|
2483
|
-
resourceWarning?: SubgraphResourceWarning;
|
|
2484
2258
|
gaps: {
|
|
2485
2259
|
count: number
|
|
2486
2260
|
totalMissingBlocks: number
|
|
@@ -2489,14 +2263,6 @@ interface SubgraphSyncInfo {
|
|
|
2489
2263
|
/** history_filling = expected gaps while a tip-first backfill op runs. */
|
|
2490
2264
|
integrity: "complete" | "gaps_detected" | "history_filling";
|
|
2491
2265
|
}
|
|
2492
|
-
interface SubgraphResourceWarning {
|
|
2493
|
-
code: string;
|
|
2494
|
-
message: string;
|
|
2495
|
-
plan?: string;
|
|
2496
|
-
blockRange: number;
|
|
2497
|
-
processorMemoryMb: number;
|
|
2498
|
-
recommendedPlan: "launch";
|
|
2499
|
-
}
|
|
2500
2266
|
interface SubgraphDetail {
|
|
2501
2267
|
name: string;
|
|
2502
2268
|
version: string;
|
|
@@ -3254,4 +3020,4 @@ interface ChainTestDelivery {
|
|
|
3254
3020
|
* "Chain subscription webhook payloads" doc.
|
|
3255
3021
|
*/
|
|
3256
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;
|
|
3257
|
-
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,
|
|
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
|
@@ -138,14 +138,33 @@ class Logger {
|
|
|
138
138
|
var logger = new Logger;
|
|
139
139
|
|
|
140
140
|
// src/mode.ts
|
|
141
|
-
var VALID_MODES = [
|
|
142
|
-
|
|
141
|
+
var VALID_MODES = [
|
|
142
|
+
"oss",
|
|
143
|
+
"platform",
|
|
144
|
+
"archive"
|
|
145
|
+
];
|
|
146
|
+
function declaredMode() {
|
|
143
147
|
const raw = process.env.INSTANCE_MODE?.trim().toLowerCase();
|
|
144
148
|
if (raw && VALID_MODES.includes(raw)) {
|
|
145
149
|
return raw;
|
|
146
150
|
}
|
|
147
151
|
return "oss";
|
|
148
152
|
}
|
|
153
|
+
function getInstanceMode() {
|
|
154
|
+
const declared = declaredMode();
|
|
155
|
+
return declared === "archive" ? "platform" : declared;
|
|
156
|
+
}
|
|
157
|
+
function getDeclaredInstanceMode() {
|
|
158
|
+
return declaredMode();
|
|
159
|
+
}
|
|
160
|
+
function isMeteredReads() {
|
|
161
|
+
const override = process.env.METERED_READS?.trim().toLowerCase();
|
|
162
|
+
if (override === "true")
|
|
163
|
+
return true;
|
|
164
|
+
if (override === "false")
|
|
165
|
+
return false;
|
|
166
|
+
return getInstanceMode() === "platform";
|
|
167
|
+
}
|
|
149
168
|
function isPlatformMode() {
|
|
150
169
|
return getInstanceMode() === "platform";
|
|
151
170
|
}
|
|
@@ -721,6 +740,7 @@ var TABLE_TO_DB = {
|
|
|
721
740
|
chain_read_cache: "source",
|
|
722
741
|
pending_fork_blocks: "source",
|
|
723
742
|
observer_journal: "source",
|
|
743
|
+
sync_scopes: "source",
|
|
724
744
|
stage_registry: "source",
|
|
725
745
|
stage_runs: "source",
|
|
726
746
|
stage_block_receipts: "source",
|
|
@@ -748,20 +768,8 @@ var TABLE_TO_DB = {
|
|
|
748
768
|
api_keys: "target",
|
|
749
769
|
sessions: "target",
|
|
750
770
|
magic_links: "target",
|
|
751
|
-
claim_tokens: "target",
|
|
752
|
-
usage_daily: "target",
|
|
753
|
-
usage_snapshots: "target",
|
|
754
|
-
account_insights: "target",
|
|
755
|
-
account_agent_runs: "target",
|
|
756
771
|
account_spend_caps: "target",
|
|
757
772
|
processed_stripe_events: "target",
|
|
758
|
-
tenants: "target",
|
|
759
|
-
tenant_usage_monthly: "target",
|
|
760
|
-
tenant_compute_addons: "target",
|
|
761
|
-
provisioning_audit_log: "target",
|
|
762
|
-
projects: "target",
|
|
763
|
-
team_members: "target",
|
|
764
|
-
team_invitations: "target",
|
|
765
773
|
subscriptions: "target",
|
|
766
774
|
subscription_outbox: "target",
|
|
767
775
|
subscription_deliveries: "target",
|
|
@@ -770,7 +778,6 @@ var TABLE_TO_DB = {
|
|
|
770
778
|
subgraph_operations: "target",
|
|
771
779
|
subgraph_health_snapshots: "target",
|
|
772
780
|
subgraph_gaps: "target",
|
|
773
|
-
subgraph_usage_daily: "target",
|
|
774
781
|
subgraph_processing_stats: "target",
|
|
775
782
|
subgraph_table_snapshots: "target",
|
|
776
783
|
x402_payments: "target",
|
|
@@ -1079,10 +1086,8 @@ var CODE_TO_STATUS = {
|
|
|
1079
1086
|
NO_TENANT_FOR_PROJECT: 404,
|
|
1080
1087
|
INSTANCE_EXISTS: 409,
|
|
1081
1088
|
SUBGRAPH_NOT_FOUND: 404,
|
|
1082
|
-
BYO_BREAKING_CHANGE: 422,
|
|
1083
1089
|
PUBLIC_NAME_TAKEN: 409,
|
|
1084
|
-
GHOST_KEY_READ_ONLY: 403
|
|
1085
|
-
GENESIS_BACKFILL_REQUIRES_PLAN: 403
|
|
1090
|
+
GHOST_KEY_READ_ONLY: 403
|
|
1086
1091
|
};
|
|
1087
1092
|
function getErrorMessage(err) {
|
|
1088
1093
|
return err instanceof Error ? err.message : String(err);
|
|
@@ -1099,7 +1104,6 @@ var DeploySubgraphRequestSchema = z2.object({
|
|
|
1099
1104
|
handlerCode: z2.string().max(1048576, "handler code exceeds 1MB limit"),
|
|
1100
1105
|
startBlock: z2.number().int().nonnegative().optional(),
|
|
1101
1106
|
sourceCode: z2.string().max(1048576, "source code exceeds 1MB limit").optional(),
|
|
1102
|
-
databaseUrl: z2.string().url().refine((u) => u.startsWith("postgres://") || u.startsWith("postgresql://"), "must be a postgres:// connection string").optional(),
|
|
1103
1107
|
dryRun: z2.boolean().optional(),
|
|
1104
1108
|
visibility: z2.enum(["public", "private"]).optional()
|
|
1105
1109
|
});
|
|
@@ -2143,5 +2147,5 @@ export {
|
|
|
2143
2147
|
AuthenticationError
|
|
2144
2148
|
};
|
|
2145
2149
|
|
|
2146
|
-
//# debugId=
|
|
2150
|
+
//# debugId=8F376771928DF15764756E2164756E21
|
|
2147
2151
|
//# sourceMappingURL=index.js.map
|