@secondlayer/shared 13.2.1 → 13.4.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 +45 -0
- package/dist/src/archive/semantic-digest-builder.d.ts +45 -0
- package/dist/src/coverage/index.d.ts +45 -0
- package/dist/src/db/index.d.ts +50 -1
- package/dist/src/db/index.js +3 -1
- package/dist/src/db/index.js.map +3 -3
- package/dist/src/db/queries/chain-reorgs.d.ts +45 -0
- package/dist/src/db/queries/chain-reorgs.js +3 -1
- package/dist/src/db/queries/chain-reorgs.js.map +3 -3
- package/dist/src/db/queries/contracts.d.ts +45 -0
- package/dist/src/db/queries/instance.d.ts +45 -0
- package/dist/src/db/queries/integrity.d.ts +45 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +45 -0
- package/dist/src/db/queries/subgraph-operations.d.ts +45 -0
- package/dist/src/db/queries/subgraphs.d.ts +45 -0
- package/dist/src/db/queries/sync-scope.d.ts +45 -0
- package/dist/src/db/queries/webhooks.d.ts +45 -0
- package/dist/src/db/schema.d.ts +48 -1
- package/dist/src/index.d.ts +78 -1
- package/dist/src/index.js +69 -1
- package/dist/src/index.js.map +6 -5
- package/dist/src/node/local-client.d.ts +45 -0
- package/dist/src/queue/listener.js +3 -1
- package/dist/src/queue/listener.js.map +3 -3
- package/dist/src/schemas/index.d.ts +7 -0
- package/dist/src/schemas/index.js +11 -1
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/webhooks.d.ts +46 -1
- package/dist/src/schemas/webhooks.js +13 -1
- package/dist/src/schemas/webhooks.js.map +3 -3
- package/migrations/0166_webhook_receiver_cert.ts +31 -0
- package/migrations/0167_usage_ledger_api_key_id.ts +29 -0
- package/migrations/0168_api_request_log.ts +49 -0
- package/migrations/0169_subgraph_health_history.ts +54 -0
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -577,8 +577,26 @@ interface SubgraphHealthSnapshotsTable {
|
|
|
577
577
|
total_processed: number;
|
|
578
578
|
total_errors: number;
|
|
579
579
|
last_processed_block: number | null;
|
|
580
|
+
chain_tip: string | number | null;
|
|
581
|
+
rows_written_total: string | number | null;
|
|
582
|
+
storage_bytes: string | number | null;
|
|
580
583
|
captured_at: Generated<Date>;
|
|
581
584
|
}
|
|
585
|
+
/** Handler errors grouped by fingerprint. Cap 50/subgraph. */
|
|
586
|
+
interface SubgraphErrorGroupsTable {
|
|
587
|
+
id: Generated<string>;
|
|
588
|
+
subgraph_name: string;
|
|
589
|
+
fingerprint: string;
|
|
590
|
+
source_name: string;
|
|
591
|
+
event_type: string | null;
|
|
592
|
+
message: string;
|
|
593
|
+
frame: string | null;
|
|
594
|
+
count: Generated<string | number>;
|
|
595
|
+
sample_tx_id: string | null;
|
|
596
|
+
sample_block_height: string | number | null;
|
|
597
|
+
first_seen: Generated<Date>;
|
|
598
|
+
last_seen: Generated<Date>;
|
|
599
|
+
}
|
|
582
600
|
interface ProcessedStripeEventsTable {
|
|
583
601
|
event_id: string;
|
|
584
602
|
event_type: string;
|
|
@@ -1055,6 +1073,7 @@ interface Database {
|
|
|
1055
1073
|
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
1056
1074
|
subgraph_gaps: SubgraphGapsTable;
|
|
1057
1075
|
subgraph_violations: SubgraphViolationsTable;
|
|
1076
|
+
subgraph_error_groups: SubgraphErrorGroupsTable;
|
|
1058
1077
|
subgraph_operations: SubgraphOperationsTable;
|
|
1059
1078
|
processed_stripe_events: ProcessedStripeEventsTable;
|
|
1060
1079
|
account_spend_caps: AccountSpendCapsTable;
|
|
@@ -1098,6 +1117,7 @@ interface Database {
|
|
|
1098
1117
|
waitlist_signups: WaitlistSignupsTable;
|
|
1099
1118
|
contact_requests: ContactRequestsTable;
|
|
1100
1119
|
api_failed_requests: ApiFailedRequestsTable;
|
|
1120
|
+
api_request_log: ApiRequestLogTable;
|
|
1101
1121
|
feedback_tickets: FeedbackTicketsTable;
|
|
1102
1122
|
}
|
|
1103
1123
|
interface ServiceHeartbeatsTable {
|
|
@@ -1171,6 +1191,8 @@ interface UsageLedgerTable {
|
|
|
1171
1191
|
usd_micros: string | number | bigint;
|
|
1172
1192
|
debited: Generated<boolean>;
|
|
1173
1193
|
source: string;
|
|
1194
|
+
/** API key behind a metered read; null for non-read units and older rows. */
|
|
1195
|
+
api_key_id: string | null;
|
|
1174
1196
|
idempotency_key: string;
|
|
1175
1197
|
occurred_at: Generated<Date>;
|
|
1176
1198
|
recorded_at: Generated<Date>;
|
|
@@ -1269,6 +1291,9 @@ interface WebhooksTable {
|
|
|
1269
1291
|
last_delivery_at: Date | null;
|
|
1270
1292
|
last_success_at: Date | null;
|
|
1271
1293
|
last_error: string | null;
|
|
1294
|
+
/** Receiver TLS leaf certificate expiry, from the emitter's periodic probe. */
|
|
1295
|
+
receiver_cert_expires_at: Date | null;
|
|
1296
|
+
receiver_cert_checked_at: Date | null;
|
|
1272
1297
|
created_at: Generated<Date>;
|
|
1273
1298
|
updated_at: Generated<Date>;
|
|
1274
1299
|
}
|
|
@@ -1398,6 +1423,28 @@ interface ApiFailedRequestsTable {
|
|
|
1398
1423
|
type ApiFailedRequest = Selectable<ApiFailedRequestsTable>;
|
|
1399
1424
|
type InsertApiFailedRequest = Insertable<ApiFailedRequestsTable>;
|
|
1400
1425
|
/**
|
|
1426
|
+
* 7-day hosted log of account-attributed Index/Streams reads. Query values
|
|
1427
|
+
* are stored only as hashes; never bodies, headers or tokens.
|
|
1428
|
+
*/
|
|
1429
|
+
interface ApiRequestLogTable {
|
|
1430
|
+
id: Generated<string>;
|
|
1431
|
+
request_id: string | null;
|
|
1432
|
+
account_id: string;
|
|
1433
|
+
api_key_id: string | null;
|
|
1434
|
+
method: string;
|
|
1435
|
+
path: string;
|
|
1436
|
+
path_template: string;
|
|
1437
|
+
params_hash: string | null;
|
|
1438
|
+
cursor_hash: string | null;
|
|
1439
|
+
page_size: number | null;
|
|
1440
|
+
rows: number | null;
|
|
1441
|
+
status: number;
|
|
1442
|
+
duration_ms: number;
|
|
1443
|
+
created_at: Generated<Date>;
|
|
1444
|
+
}
|
|
1445
|
+
type ApiRequestLogRow = Selectable<ApiRequestLogTable>;
|
|
1446
|
+
type InsertApiRequestLogRow = Insertable<ApiRequestLogTable>;
|
|
1447
|
+
/**
|
|
1401
1448
|
* Hosted problem report. `attempted` is the server's own copy of the failed
|
|
1402
1449
|
* request (never caller-supplied); `status` starts `new` until classified.
|
|
1403
1450
|
*/
|
|
@@ -2447,6 +2494,7 @@ declare const TABLE_TO_DB: {
|
|
|
2447
2494
|
subgraph_health_snapshots: string
|
|
2448
2495
|
subgraph_gaps: string
|
|
2449
2496
|
subgraph_violations: string
|
|
2497
|
+
subgraph_error_groups: string
|
|
2450
2498
|
subgraph_processing_stats: string
|
|
2451
2499
|
account_credits: string
|
|
2452
2500
|
archive_fetches: string
|
|
@@ -2457,6 +2505,7 @@ declare const TABLE_TO_DB: {
|
|
|
2457
2505
|
waitlist_signups: string
|
|
2458
2506
|
contact_requests: string
|
|
2459
2507
|
api_failed_requests: string
|
|
2508
|
+
api_request_log: string
|
|
2460
2509
|
feedback_tickets: string
|
|
2461
2510
|
service_heartbeats: string
|
|
2462
2511
|
};
|
|
@@ -2900,6 +2949,9 @@ interface WebhookSummary {
|
|
|
2900
2949
|
* summary so the list can show a failing receiver per row without a
|
|
2901
2950
|
* per-row fetch. */
|
|
2902
2951
|
circuitFailures: number;
|
|
2952
|
+
/** Owning product, derived from the name prefix (`MANAGED_NAME_PREFIXES`).
|
|
2953
|
+
* When non-null the API refuses to rename the webhook. */
|
|
2954
|
+
managedBy: string | null;
|
|
2903
2955
|
createdAt: string;
|
|
2904
2956
|
updatedAt: string;
|
|
2905
2957
|
}
|
|
@@ -2924,6 +2976,10 @@ interface WebhookDetail extends WebhookSummary {
|
|
|
2924
2976
|
timeoutMs: number;
|
|
2925
2977
|
concurrency: number;
|
|
2926
2978
|
lastError: string | null;
|
|
2979
|
+
/** When the receiver's TLS certificate expires, from the periodic probe.
|
|
2980
|
+
* Null for http receivers, refused or unreachable hosts, and webhooks not
|
|
2981
|
+
* probed yet. */
|
|
2982
|
+
receiverCertExpiresAt: string | null;
|
|
2927
2983
|
/** Set when this instance's chain-trigger
|
|
2928
2984
|
* evaluator isn't running (`SUBGRAPH_SOURCE` != `streams-index`) — the
|
|
2929
2985
|
* webhook will never fire until that's fixed. Null otherwise. Surfaced
|
|
@@ -3030,6 +3086,27 @@ declare function generateSubgraphAgentSchema(detail: SubgraphDetail, options?: S
|
|
|
3030
3086
|
declare function generateSubgraphOpenApi(detail: SubgraphDetail, options?: SubgraphSpecOptions): Record<string, unknown>;
|
|
3031
3087
|
declare function generateSubgraphMarkdown(detail: SubgraphDetail, options?: SubgraphSpecOptions): string;
|
|
3032
3088
|
declare function generateSubgraphSpec(detail: SubgraphDetail, format: SubgraphSpecFormat, options?: SubgraphSpecOptions): Record<string, unknown> | SubgraphAgentSchema | string;
|
|
3089
|
+
interface HealthSnapshotPoint {
|
|
3090
|
+
captured_at: Date | string;
|
|
3091
|
+
chain_tip: string | number | null;
|
|
3092
|
+
last_processed_block: string | number | null;
|
|
3093
|
+
rows_written_total: string | number | null;
|
|
3094
|
+
total_errors: string | number;
|
|
3095
|
+
total_processed: string | number;
|
|
3096
|
+
}
|
|
3097
|
+
interface HealthHour {
|
|
3098
|
+
hour: string;
|
|
3099
|
+
lagBlocks: number | null;
|
|
3100
|
+
rowsWritten: number;
|
|
3101
|
+
errors: number;
|
|
3102
|
+
eventsHandled: number;
|
|
3103
|
+
}
|
|
3104
|
+
/**
|
|
3105
|
+
* Bucket snapshots into the last `hours` UTC hours (oldest first, ending with
|
|
3106
|
+
* the hour containing `now`). The delta for an hour also spans the boundary
|
|
3107
|
+
* from the previous hour's last snapshot, so no growth falls between buckets.
|
|
3108
|
+
*/
|
|
3109
|
+
declare function bucketHourly(snapshots: HealthSnapshotPoint[], hours: number, now?: number): HealthHour[];
|
|
3033
3110
|
/** The etch a `rune_etch` event created — everything a consumer needs to
|
|
3034
3111
|
* render a fresh rune without a second lookup, minus what the envelope
|
|
3035
3112
|
* already carries (`rune_id`). Mirrors 058's `RuneEntry` shape
|
|
@@ -3420,4 +3497,4 @@ declare function publicKeyPemFromPrivate(privateKeyPem: string): string;
|
|
|
3420
3497
|
declare function ed25519KeyId(publicKeyPem: string): string;
|
|
3421
3498
|
declare function signEd25519(payload: string, privateKey: KeyObject): string;
|
|
3422
3499
|
declare function verifyEd25519(payload: string, signatureBase64: string, publicKey: KeyObject): boolean;
|
|
3423
|
-
export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeysTable, ArchiveFetch, ArchiveFetchesTable, AuthenticationError, AuthorizationError, BILLING_PAUSED_PREFIX, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, CHAIN_TRIGGER_FIELDS, CHAIN_TRIGGER_TYPES, CODE_TO_STATUS, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReadCacheTable, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainReorgsTable, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTxLevelEvent, ChainWebhookDelivery, ChainWebhookEnvelope, ContactRequest, ContactRequestsTable, Contract, ContractsTable, CoverageSegmentsTable, CreateWebhookRequest, CreateWebhookRequestSchema, CreateWebhookResponse, DB_TO_STREAMS_EVENT_TYPE, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DEFAULT_BTC_CONFIRMATIONS, Database, DatabaseError, DbPlane, DbReadRow, DbSplitStatus, DeadLetterEventsTable, DeadRow, DecodedEventType2 as DecodedEventType, DecodedEventsTable, DecoderCheckpointsTable, DeliveryRow, DeploySubgraphRequest, DeploySubgraphRequestSchema, DeploySubgraphResponse, EMPTY_RANGE_EVENT_INDEX_SENTINEL, Env, ErrorCode, ErrorCodes, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, ForbiddenError, IndexColumn, IndexColumnType, IndexPrimaryKey, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertArchiveFetch, InsertBlock, InsertContactRequest, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, KeyRotatedError, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, MigrationRole, NativeClock, NotFoundError, NumericAsText, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, ParsedCreateWebhookRequest, ParsedReplayWebhookRequest, ParsedUpdateWebhookRequest, PaymentRequiredError, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RUNE_EVENT_TYPES, RateLimitError, ReindexResponse, RepairMode, ReplayResult, ReplayWebhookRequest, ReplayWebhookRequestSchema, RetryState, RotateSecretResponse, RunStatus, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneEventType, SOURCE_READ_COLUMNS, SOURCE_READ_PKS, SOURCE_READ_TYPES, STREAMS_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_TO_DB_EVENT_TYPES, SbtcDepositEvent, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SbtcWithdrawalEvent, SbtcWithdrawalSweptConfirmedEvent, SecondLayerError, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, StreamsCursor, StreamsDbEventType, StreamsEventType, Subgraph, SubgraphAgentSchema, SubgraphAggregateParams, SubgraphAggregateResponse, SubgraphDetail, SubgraphGap, SubgraphGapEntry, SubgraphGapRange, SubgraphGapsResponse, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphQueryParams, SubgraphSpecFormat, SubgraphSpecOptions, SubgraphSummary, SubgraphSyncInfo, SubgraphVerification, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, TABLE_TO_DB, TenantSuspendedError, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UpdateWebhookRequest, UpdateWebhookRequestSchema, UsageLedgerRow, UsageLedgerTable, VM_EVENT_TYPES, VM_NODE_TO_STORED_TYPE2 as VM_NODE_TO_STORED_TYPE, VM_STORED_TO_NODE_TYPE, ValidationError, VersionConflictError, VmEvent, VmEventType, VmEventsArchiveTable, VmEventsTable, VmNodeEventType, WEBHOOK_FORMATS, WEBHOOK_STATUSES, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookDetail, WebhookFormat, WebhookFormatSchema, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookStatus, WebhookStatusSchema, WebhookSummary, WebhooksTable, applicationDatabaseUrl, assertDbSplit, billingPausedCode, blockEndCursor, closeDb, closeDbOrTimeout, committedHeight, compareStreamsCursor, exports_hmac as crypto, decodeStreamsCursor, describeDbUrl, exports_ed25519 as ed25519, encodeStreamsCursor, finalizedBurnHeight, formatWebhookSchemaErrors, generateSubgraphAgentSchema, generateSubgraphMarkdown, generateSubgraphOpenApi, generateSubgraphSpec, getDb, getDbSplitStatus, getEnv, getErrorMessage, getMigrationRole, getRawClient, getSourceDb, getTargetDb, isBnsDecoderEnabled, isEmptyRangeCursor, isPox4DecoderEnabled, isPox5DecoderEnabled, isSbtcDecoderEnabled, jsonb, logger, onChainPlane, onControlPlane, parseJsonb, resolveSourceUrl, resolveTargetUrl, setMigrationRole, sql };
|
|
3500
|
+
export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeysTable, ApiRequestLogRow, ApiRequestLogTable, ArchiveFetch, ArchiveFetchesTable, AuthenticationError, AuthorizationError, BILLING_PAUSED_PREFIX, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, CHAIN_TRIGGER_FIELDS, CHAIN_TRIGGER_TYPES, CODE_TO_STATUS, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReadCacheTable, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainReorgsTable, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTxLevelEvent, ChainWebhookDelivery, ChainWebhookEnvelope, ContactRequest, ContactRequestsTable, Contract, ContractsTable, CoverageSegmentsTable, CreateWebhookRequest, CreateWebhookRequestSchema, CreateWebhookResponse, DB_TO_STREAMS_EVENT_TYPE, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DEFAULT_BTC_CONFIRMATIONS, Database, DatabaseError, DbPlane, DbReadRow, DbSplitStatus, DeadLetterEventsTable, DeadRow, DecodedEventType2 as DecodedEventType, DecodedEventsTable, DecoderCheckpointsTable, DeliveryRow, DeploySubgraphRequest, DeploySubgraphRequestSchema, DeploySubgraphResponse, EMPTY_RANGE_EVENT_INDEX_SENTINEL, Env, ErrorCode, ErrorCodes, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, ForbiddenError, HealthHour, HealthSnapshotPoint, IndexColumn, IndexColumnType, IndexPrimaryKey, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertApiRequestLogRow, InsertArchiveFetch, InsertBlock, InsertContactRequest, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, KeyRotatedError, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, MigrationRole, NativeClock, NotFoundError, NumericAsText, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, ParsedCreateWebhookRequest, ParsedReplayWebhookRequest, ParsedUpdateWebhookRequest, PaymentRequiredError, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RUNE_EVENT_TYPES, RateLimitError, ReindexResponse, RepairMode, ReplayResult, ReplayWebhookRequest, ReplayWebhookRequestSchema, RetryState, RotateSecretResponse, RunStatus, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneEventType, SOURCE_READ_COLUMNS, SOURCE_READ_PKS, SOURCE_READ_TYPES, STREAMS_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_TO_DB_EVENT_TYPES, SbtcDepositEvent, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SbtcWithdrawalEvent, SbtcWithdrawalSweptConfirmedEvent, SecondLayerError, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, StreamsCursor, StreamsDbEventType, StreamsEventType, Subgraph, SubgraphAgentSchema, SubgraphAggregateParams, SubgraphAggregateResponse, SubgraphDetail, SubgraphErrorGroupsTable, SubgraphGap, SubgraphGapEntry, SubgraphGapRange, SubgraphGapsResponse, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphQueryParams, SubgraphSpecFormat, SubgraphSpecOptions, SubgraphSummary, SubgraphSyncInfo, SubgraphVerification, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, TABLE_TO_DB, TenantSuspendedError, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UpdateWebhookRequest, UpdateWebhookRequestSchema, UsageLedgerRow, UsageLedgerTable, VM_EVENT_TYPES, VM_NODE_TO_STORED_TYPE2 as VM_NODE_TO_STORED_TYPE, VM_STORED_TO_NODE_TYPE, ValidationError, VersionConflictError, VmEvent, VmEventType, VmEventsArchiveTable, VmEventsTable, VmNodeEventType, WEBHOOK_FORMATS, WEBHOOK_STATUSES, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookDetail, WebhookFormat, WebhookFormatSchema, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookStatus, WebhookStatusSchema, WebhookSummary, WebhooksTable, applicationDatabaseUrl, assertDbSplit, billingPausedCode, blockEndCursor, bucketHourly, closeDb, closeDbOrTimeout, committedHeight, compareStreamsCursor, exports_hmac as crypto, decodeStreamsCursor, describeDbUrl, exports_ed25519 as ed25519, encodeStreamsCursor, finalizedBurnHeight, formatWebhookSchemaErrors, generateSubgraphAgentSchema, generateSubgraphMarkdown, generateSubgraphOpenApi, generateSubgraphSpec, getDb, getDbSplitStatus, getEnv, getErrorMessage, getMigrationRole, getRawClient, getSourceDb, getTargetDb, isBnsDecoderEnabled, isEmptyRangeCursor, isPox4DecoderEnabled, isPox5DecoderEnabled, isSbtcDecoderEnabled, jsonb, logger, onChainPlane, onControlPlane, parseJsonb, resolveSourceUrl, resolveTargetUrl, setMigrationRole, sql };
|
package/dist/src/index.js
CHANGED
|
@@ -854,6 +854,7 @@ var TABLE_TO_DB = {
|
|
|
854
854
|
subgraph_health_snapshots: "target",
|
|
855
855
|
subgraph_gaps: "target",
|
|
856
856
|
subgraph_violations: "target",
|
|
857
|
+
subgraph_error_groups: "target",
|
|
857
858
|
subgraph_processing_stats: "target",
|
|
858
859
|
account_credits: "target",
|
|
859
860
|
archive_fetches: "target",
|
|
@@ -864,6 +865,7 @@ var TABLE_TO_DB = {
|
|
|
864
865
|
waitlist_signups: "target",
|
|
865
866
|
contact_requests: "target",
|
|
866
867
|
api_failed_requests: "target",
|
|
868
|
+
api_request_log: "target",
|
|
867
869
|
feedback_tickets: "target",
|
|
868
870
|
service_heartbeats: "both"
|
|
869
871
|
};
|
|
@@ -1308,6 +1310,16 @@ function timeoutMsField() {
|
|
|
1308
1310
|
}
|
|
1309
1311
|
var webhookUrl = z3.string().trim().min(1).refine((value) => value.startsWith("http://") || value.startsWith("https://"), "must be an http(s) URL");
|
|
1310
1312
|
var name = z3.string().trim().min(1).max(128);
|
|
1313
|
+
var MANAGED_NAME_PREFIXES = {
|
|
1314
|
+
"sentinel:": "Sentinel"
|
|
1315
|
+
};
|
|
1316
|
+
function managedByForName(name) {
|
|
1317
|
+
for (const [prefix, owner] of Object.entries(MANAGED_NAME_PREFIXES)) {
|
|
1318
|
+
if (name.startsWith(prefix))
|
|
1319
|
+
return owner;
|
|
1320
|
+
}
|
|
1321
|
+
return null;
|
|
1322
|
+
}
|
|
1311
1323
|
var WebhookStatusSchema = z3.enum(WEBHOOK_STATUSES);
|
|
1312
1324
|
var WebhookFormatSchema = z3.enum(WEBHOOK_FORMATS);
|
|
1313
1325
|
var CHAIN_TRIGGER_TYPES = [
|
|
@@ -1986,6 +1998,61 @@ function generateSubgraphSpec(detail, format, options = {}) {
|
|
|
1986
1998
|
return generateSubgraphAgentSchema(detail, options);
|
|
1987
1999
|
return generateSubgraphMarkdown(detail, options);
|
|
1988
2000
|
}
|
|
2001
|
+
// src/subgraphs/health.ts
|
|
2002
|
+
var HOUR_MS = 3600000;
|
|
2003
|
+
function positiveDeltas(values) {
|
|
2004
|
+
let total = 0;
|
|
2005
|
+
let prev = null;
|
|
2006
|
+
for (const value of values) {
|
|
2007
|
+
if (value === null)
|
|
2008
|
+
continue;
|
|
2009
|
+
if (prev !== null && value > prev)
|
|
2010
|
+
total += value - prev;
|
|
2011
|
+
prev = value;
|
|
2012
|
+
}
|
|
2013
|
+
return total;
|
|
2014
|
+
}
|
|
2015
|
+
function toNumber(value) {
|
|
2016
|
+
if (value === null)
|
|
2017
|
+
return null;
|
|
2018
|
+
const n = Number(value);
|
|
2019
|
+
return Number.isFinite(n) ? n : null;
|
|
2020
|
+
}
|
|
2021
|
+
function bucketHourly(snapshots, hours, now = Date.now()) {
|
|
2022
|
+
const sorted = snapshots.map((s) => ({ ...s, at: new Date(s.captured_at).getTime() })).sort((a, b) => a.at - b.at);
|
|
2023
|
+
const currentHourStart = Math.floor(now / HOUR_MS) * HOUR_MS;
|
|
2024
|
+
const out = [];
|
|
2025
|
+
for (let i = hours - 1;i >= 0; i--) {
|
|
2026
|
+
const start = currentHourStart - i * HOUR_MS;
|
|
2027
|
+
const end = start + HOUR_MS;
|
|
2028
|
+
const inHour = sorted.filter((s) => s.at >= start && s.at < end);
|
|
2029
|
+
if (inHour.length === 0) {
|
|
2030
|
+
out.push({
|
|
2031
|
+
hour: new Date(start).toISOString(),
|
|
2032
|
+
lagBlocks: null,
|
|
2033
|
+
rowsWritten: 0,
|
|
2034
|
+
errors: 0,
|
|
2035
|
+
eventsHandled: 0
|
|
2036
|
+
});
|
|
2037
|
+
continue;
|
|
2038
|
+
}
|
|
2039
|
+
const before = sorted.filter((s) => s.at < start).at(-1);
|
|
2040
|
+
const series = before ? [before, ...inHour] : inHour;
|
|
2041
|
+
const lags = inHour.map((s) => {
|
|
2042
|
+
const tip = toNumber(s.chain_tip);
|
|
2043
|
+
const cursor = toNumber(s.last_processed_block);
|
|
2044
|
+
return tip === null || cursor === null ? null : Math.max(0, tip - cursor);
|
|
2045
|
+
}).filter((lag) => lag !== null);
|
|
2046
|
+
out.push({
|
|
2047
|
+
hour: new Date(start).toISOString(),
|
|
2048
|
+
lagBlocks: lags.length > 0 ? Math.max(...lags) : null,
|
|
2049
|
+
rowsWritten: positiveDeltas(series.map((s) => toNumber(s.rows_written_total))),
|
|
2050
|
+
errors: positiveDeltas(series.map((s) => toNumber(s.total_errors))),
|
|
2051
|
+
eventsHandled: positiveDeltas(series.map((s) => toNumber(s.total_processed)))
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
return out;
|
|
2055
|
+
}
|
|
1989
2056
|
// src/crypto/hmac.ts
|
|
1990
2057
|
var exports_hmac = {};
|
|
1991
2058
|
__export(exports_hmac, {
|
|
@@ -2136,6 +2203,7 @@ export {
|
|
|
2136
2203
|
assertDbSplit,
|
|
2137
2204
|
billingPausedCode,
|
|
2138
2205
|
blockEndCursor,
|
|
2206
|
+
bucketHourly,
|
|
2139
2207
|
closeDb,
|
|
2140
2208
|
closeDbOrTimeout,
|
|
2141
2209
|
committedHeight,
|
|
@@ -2175,5 +2243,5 @@ export {
|
|
|
2175
2243
|
sql2 as sql
|
|
2176
2244
|
};
|
|
2177
2245
|
|
|
2178
|
-
//# debugId=
|
|
2246
|
+
//# debugId=E1550FF128BCB8A064756E2164756E21
|
|
2179
2247
|
//# sourceMappingURL=index.js.map
|