@secondlayer/sdk 12.0.0 → 12.2.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/index.d.ts +53 -1
- package/dist/index.js +76 -3
- package/dist/index.js.map +7 -6
- package/dist/streams/index.d.ts +11 -0
- package/dist/streams/index.js +7 -3
- package/dist/streams/index.js.map +5 -5
- package/dist/subgraphs/index.d.ts +11 -0
- package/dist/subgraphs/index.js +7 -3
- package/dist/subgraphs/index.js.map +4 -4
- package/dist/webhooks/doctor.d.ts +42 -0
- package/dist/webhooks/doctor.js +74 -0
- package/dist/webhooks/doctor.js.map +10 -0
- package/package.json +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -871,6 +871,17 @@ type StreamsEventsConsumeParams<
|
|
|
871
871
|
maxPages?: number;
|
|
872
872
|
maxEmptyPolls?: number;
|
|
873
873
|
signal?: AbortSignal;
|
|
874
|
+
/**
|
|
875
|
+
* Cuts the empty-poll backoff short: on an empty page, the loop races
|
|
876
|
+
* `emptyBackoffMs` against this promise instead of sleeping the full
|
|
877
|
+
* amount. Pass a function that resolves once when new data MIGHT be
|
|
878
|
+
* available (e.g. a Postgres NOTIFY listener) — it is called fresh on
|
|
879
|
+
* every empty page, never awaited more than once concurrently per page.
|
|
880
|
+
* The backoff timer still runs underneath, so a wake source that never
|
|
881
|
+
* resolves (or a `wake` this call omits) degrades to the same polling
|
|
882
|
+
* behavior as before.
|
|
883
|
+
*/
|
|
884
|
+
wake?: () => Promise<void>;
|
|
874
885
|
};
|
|
875
886
|
/**
|
|
876
887
|
* One yielded page from {@link StreamsClient.consume} — the
|
|
@@ -2788,6 +2799,47 @@ declare function getSubgraph<T extends {
|
|
|
2788
2799
|
schema: Record<string, unknown>;
|
|
2789
2800
|
}>(def: T, options?: Partial<SecondLayerOptions> | SecondLayer | Subgraphs): InferSubgraphClient2<T>;
|
|
2790
2801
|
import { SubgraphAgentSchema as SubgraphAgentSchema3, SubgraphSpecFormat as SubgraphSpecFormat2, SubgraphSpecOptions as SubgraphSpecOptions3 } from "@secondlayer/shared/subgraphs/spec";
|
|
2802
|
+
import { SubgraphDetail as SubgraphDetail2 } from "@secondlayer/shared/schemas/subgraphs";
|
|
2803
|
+
import { DeadRow as DeadRow3, DeliveryRow as DeliveryRow3, WebhookDetail as WebhookDetail3 } from "@secondlayer/shared/schemas/webhooks";
|
|
2804
|
+
/**
|
|
2805
|
+
* Webhook diagnosis, shared by `secondlayer webhooks doctor` and the
|
|
2806
|
+
* dashboard's webhook detail page. Moved out of the CLI (unchanged behavior)
|
|
2807
|
+
* so the web can build the same judgment without printing CLI-command text.
|
|
2808
|
+
*/
|
|
2809
|
+
declare function isSuccessDelivery(row: DeliveryRow3): boolean;
|
|
2810
|
+
type DoctorIssueCode = "warning" | "paused" | "last_error" | "circuit" | "dead_letters" | "subgraph_gaps" | "subgraph_catching_up" | "no_deliveries";
|
|
2811
|
+
interface DoctorIssue {
|
|
2812
|
+
code: DoctorIssueCode;
|
|
2813
|
+
detail?: string;
|
|
2814
|
+
}
|
|
2815
|
+
interface DoctorReport {
|
|
2816
|
+
webhook: WebhookDetail3;
|
|
2817
|
+
deliverySummary: {
|
|
2818
|
+
total: number;
|
|
2819
|
+
successful: number;
|
|
2820
|
+
failed: number;
|
|
2821
|
+
last: DeliveryRow3 | null;
|
|
2822
|
+
};
|
|
2823
|
+
deadCount: number;
|
|
2824
|
+
subgraph: {
|
|
2825
|
+
name: string;
|
|
2826
|
+
status: string;
|
|
2827
|
+
syncStatus: string;
|
|
2828
|
+
lastProcessedBlock: number;
|
|
2829
|
+
chainTip: number;
|
|
2830
|
+
gapCount: number;
|
|
2831
|
+
integrity: string;
|
|
2832
|
+
} | null;
|
|
2833
|
+
/** CLI-facing next steps, one per issue, in the same order as `issues`. */
|
|
2834
|
+
hints: string[];
|
|
2835
|
+
issues: DoctorIssue[];
|
|
2836
|
+
}
|
|
2837
|
+
declare function buildDoctorReport(input: {
|
|
2838
|
+
webhook: WebhookDetail3;
|
|
2839
|
+
deliveries: DeliveryRow3[];
|
|
2840
|
+
dead: DeadRow3[];
|
|
2841
|
+
subgraph?: SubgraphDetail2 | null;
|
|
2842
|
+
}): DoctorReport;
|
|
2791
2843
|
/**
|
|
2792
2844
|
* The two pieces every "deploy a consumer" guide leaves out, packaged:
|
|
2793
2845
|
* a liveness endpoint and a graceful-shutdown signal. Both are
|
|
@@ -3217,4 +3269,4 @@ declare const Cursor: {
|
|
|
3217
3269
|
};
|
|
3218
3270
|
};
|
|
3219
3271
|
import { decodeClarityValue, toJsonSafe } from "@secondlayer/shared/streams-rows";
|
|
3220
|
-
export { ACCOUNT_KEY_ENV, ActiveSubgraphOperation, ApiError, ArchiveAuthError, ArchiveClient, ArchiveCreditsBalance, ArchiveDataset, ArchiveFetchItem, ArchiveFetchResult, ArchiveFlow, ArchiveGateNotConfiguredError, ArchiveLoadOptions, ArchiveManifest, ArchivePartition, ArchiveQuote, ArchiveSignatureError, ArchiveStatus, ArchiveVerifyInput, ArchiveVerifyRangeStatus, ArchiveVerifyResult, AuthError, BlockEnvelope, BlocksEnvelope, BlocksListParams, BlocksWalkParams, CanonicalEnvelope, CanonicalListParams, CanonicalWalkParams, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTrigger, ChainTriggerType, ChainTxLevelEvent, ChainWebhookDelivery2 as ChainWebhookDelivery, ChainWebhookEnvelope, ConsumerBatchContext, ConsumerHealth, ConsumerSink, ContextAccount, ContextField, ContextFieldError, ContextSnapshot, ContractCallsConsumeParams, ContractCallsEnvelope, ContractCallsListParams, ContractCallsWalkParams, ContractConformance, ContractSummary, Contracts, ContractsEnvelope, ContractsListParams, CreateArchiveClientOptions, CreateWebhookRequest2 as CreateWebhookRequest, CreateWebhookResponse2 as CreateWebhookResponse, Cursor, DEFAULT_REQUEST_TIMEOUT_MS, DeadRow2 as DeadRow, DecodedEventColumns, DecodedEventRow, DecodedFtBurn, DecodedFtBurnPayload, DecodedFtMint, DecodedFtMintPayload, DecodedFtTransfer, DecodedFtTransferPayload, DecodedNftBurn, DecodedNftBurnPayload, DecodedNftMint, DecodedNftMintPayload, DecodedNftTransfer, DecodedNftTransferPayload, DecodedPrint, DecodedPrintPayload, DecodedPrintValue, DecodedStxBurn, DecodedStxBurnPayload, DecodedStxLock, DecodedStxLockPayload, DecodedStxMint, DecodedStxMintPayload, DecodedStxTransfer, DecodedStxTransferPayload, DeliveryRow2 as DeliveryRow, EtagCache, EtagEntry, EventsConsumeParams, EventsEnvelope, EventsListParams, EventsWalkParams, FetchLike2 as FetchLike, FtTransfer, FtTransferEvent, FtTransferPayload2 as FtTransferPayload, FtTransfersEnvelope, FtTransfersListParams, FtTransfersResource, FtTransfersWalkParams, INDEX_MAX_PAGE_SIZE, INSTANCE_TOKEN_ENV, Index, IndexAlwaysFields, IndexBlock, IndexCanonicalBlock, IndexConsumeOptions, IndexContractCall, IndexDiscovery, IndexEvent, IndexEventFields, IndexEventOf, IndexEventType, IndexEventTypeFilters, IndexEventsResource, IndexFeedEnvelope, IndexFeedFetcher, IndexFeedItem, IndexFtBurn, IndexFtMint, IndexFtTransfer, IndexMapDelete, IndexMapInsert, IndexMapSet, IndexMempoolTransaction, IndexNestedContractCall, IndexNftBurn, IndexNftMint, IndexNftTransfer, IndexPostCondition, IndexPox5Event, IndexPox5EventTopic, IndexPoxCycle, IndexPoxFunctionCount, IndexPrint, IndexReorg, IndexSbtcDeposit, IndexSbtcDepositDetail, IndexSbtcEvent, IndexSbtcSummary, IndexSbtcWithdrawal, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawalPhase, IndexStackingAction, IndexStxBurn, IndexStxLock, IndexStxMint, IndexStxTransfer, IndexTip, IndexTransaction, IndexVarSet, InstanceClient, InstanceDiagnosis3 as InstanceDiagnosis, InstanceIssue, InstanceState, InstanceStatus, InsufficientArchiveCreditsError, LOCAL_API_URL, LoadedArchive, MemoryEtagCache, MempoolEnvelope, MempoolListParams, MempoolTransactionEnvelope, MempoolWalkParams, NftTransfer, NftTransferEvent, NftTransferPayload2 as NftTransferPayload, NftTransfersEnvelope, NftTransfersListParams, NftTransfersResource, NftTransfersWalkParams, Pox5EventsEnvelope, Pox5EventsListParams, Pox5EventsWalkParams, Pox5Resource, PoxCycleEnvelope, PoxCyclesEnvelope, PoxCyclesListParams, PoxCyclesWalkParams, PoxResource, PrintSchemaResponse, PublicStatus2 as PublicStatus, RateLimitError, ReplayResult2 as ReplayResult, RequestOptions, RewardSet2 as RewardSet, RotateSecretResponse2 as RotateSecretResponse, SbtcDepositEnvelope, SbtcDepositEvent, SbtcDepositsConsumeParams, SbtcDepositsEnvelope, SbtcDepositsListParams, SbtcDepositsWalkParams, SbtcEventTopic2 as SbtcEventTopic, SbtcEventsConsumeParams, SbtcEventsEnvelope, SbtcEventsListParams, SbtcEventsWalkParams, SbtcResource, SbtcSummaryEnvelope, SbtcWithdrawalEnvelope, SbtcWithdrawalEvent, SbtcWithdrawalStatus, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalsEnvelope, SbtcWithdrawalsListParams, SbtcWithdrawalsWalkParams, SecondLayer, SecondLayerArchive, SecondLayerError, SecondLayerErrorOptions, SecondLayerOptions, SinkTx, StackingEnvelope, StackingListParams, StackingWalkParams, StandardWebhooksHeaders2 as StandardWebhooksHeaders, StreamsBatch, StreamsBatchContext, StreamsCanonicalBlock, StreamsClient, StreamsConsumeParams, StreamsDumpFile, StreamsDumps, StreamsDumpsManifest, StreamsEvent, StreamsEventPayload, StreamsEventType, StreamsEventsConsumeParams, StreamsEventsConsumeResult, StreamsEventsEnvelope, StreamsEventsListEnvelope, StreamsEventsListParams, StreamsEventsStreamParams, StreamsEventsSubscribeParams, StreamsReorg, StreamsReorgContext, StreamsReorgsListEnvelope, StreamsReorgsListParams, StreamsServerError, StreamsSignatureError, StreamsSubscription, StreamsTip, StreamsWireEvent2 as StreamsWireEvent, SubgraphAgentSchema3 as SubgraphAgentSchema, SubgraphOperationStatus, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphSpecOptions3 as SubgraphSpecOptions, Subgraphs, TransactionEnvelope, TransactionProof, TransactionProofVerifyResult, TransactionsEnvelope, TransactionsListParams, TransactionsWalkParams, UpdateWebhookRequest2 as UpdateWebhookRequest, ValidationError, VmStreamsEvent, WalkOptions, WebhookDetail2 as WebhookDetail, WebhookFormat, WebhookHeaderInput, WebhookKind, WebhookRuntime, WebhookStatus, WebhookSummary2 as WebhookSummary, WebhookTestResult2 as WebhookTestResult, Webhooks, WithSinkTx, consumeIndexFeed, consumerHealth, contextField, createArchiveClient, createStreamsClient, decode, decodeChainWebhook, decodeClarityValue, decodeFtBurn, decodeFtMint, decodeFtTransfer, decodeNftBurn, decodeNftMint, decodeNftTransfer, decodePrint, decodeStxBurn, decodeStxLock, decodeStxMint, decodeStxTransfer, fetchRewardSet, getSubgraph, isFtBurn, isFtMint, isFtTransfer, isNftBurn, isNftMint, isNftTransfer, isPrint, isStxBurn, isStxLock, isStxMint, isStxTransfer, parseRetryAfter, resolveAccountKey, resolveApiKey, resolveBaseUrl, shutdownSignal, toJsonSafe, trigger, verifySecondlayerSignature, verify as verifyStandardWebhooksHeaders, verifyTransactionProof, verifyWebhookSignature };
|
|
3272
|
+
export { ACCOUNT_KEY_ENV, ActiveSubgraphOperation, ApiError, ArchiveAuthError, ArchiveClient, ArchiveCreditsBalance, ArchiveDataset, ArchiveFetchItem, ArchiveFetchResult, ArchiveFlow, ArchiveGateNotConfiguredError, ArchiveLoadOptions, ArchiveManifest, ArchivePartition, ArchiveQuote, ArchiveSignatureError, ArchiveStatus, ArchiveVerifyInput, ArchiveVerifyRangeStatus, ArchiveVerifyResult, AuthError, BlockEnvelope, BlocksEnvelope, BlocksListParams, BlocksWalkParams, CanonicalEnvelope, CanonicalListParams, CanonicalWalkParams, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTrigger, ChainTriggerType, ChainTxLevelEvent, ChainWebhookDelivery2 as ChainWebhookDelivery, ChainWebhookEnvelope, ConsumerBatchContext, ConsumerHealth, ConsumerSink, ContextAccount, ContextField, ContextFieldError, ContextSnapshot, ContractCallsConsumeParams, ContractCallsEnvelope, ContractCallsListParams, ContractCallsWalkParams, ContractConformance, ContractSummary, Contracts, ContractsEnvelope, ContractsListParams, CreateArchiveClientOptions, CreateWebhookRequest2 as CreateWebhookRequest, CreateWebhookResponse2 as CreateWebhookResponse, Cursor, DEFAULT_REQUEST_TIMEOUT_MS, DeadRow2 as DeadRow, DecodedEventColumns, DecodedEventRow, DecodedFtBurn, DecodedFtBurnPayload, DecodedFtMint, DecodedFtMintPayload, DecodedFtTransfer, DecodedFtTransferPayload, DecodedNftBurn, DecodedNftBurnPayload, DecodedNftMint, DecodedNftMintPayload, DecodedNftTransfer, DecodedNftTransferPayload, DecodedPrint, DecodedPrintPayload, DecodedPrintValue, DecodedStxBurn, DecodedStxBurnPayload, DecodedStxLock, DecodedStxLockPayload, DecodedStxMint, DecodedStxMintPayload, DecodedStxTransfer, DecodedStxTransferPayload, DeliveryRow2 as DeliveryRow, DoctorIssue, DoctorIssueCode, DoctorReport, EtagCache, EtagEntry, EventsConsumeParams, EventsEnvelope, EventsListParams, EventsWalkParams, FetchLike2 as FetchLike, FtTransfer, FtTransferEvent, FtTransferPayload2 as FtTransferPayload, FtTransfersEnvelope, FtTransfersListParams, FtTransfersResource, FtTransfersWalkParams, INDEX_MAX_PAGE_SIZE, INSTANCE_TOKEN_ENV, Index, IndexAlwaysFields, IndexBlock, IndexCanonicalBlock, IndexConsumeOptions, IndexContractCall, IndexDiscovery, IndexEvent, IndexEventFields, IndexEventOf, IndexEventType, IndexEventTypeFilters, IndexEventsResource, IndexFeedEnvelope, IndexFeedFetcher, IndexFeedItem, IndexFtBurn, IndexFtMint, IndexFtTransfer, IndexMapDelete, IndexMapInsert, IndexMapSet, IndexMempoolTransaction, IndexNestedContractCall, IndexNftBurn, IndexNftMint, IndexNftTransfer, IndexPostCondition, IndexPox5Event, IndexPox5EventTopic, IndexPoxCycle, IndexPoxFunctionCount, IndexPrint, IndexReorg, IndexSbtcDeposit, IndexSbtcDepositDetail, IndexSbtcEvent, IndexSbtcSummary, IndexSbtcWithdrawal, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawalPhase, IndexStackingAction, IndexStxBurn, IndexStxLock, IndexStxMint, IndexStxTransfer, IndexTip, IndexTransaction, IndexVarSet, InstanceClient, InstanceDiagnosis3 as InstanceDiagnosis, InstanceIssue, InstanceState, InstanceStatus, InsufficientArchiveCreditsError, LOCAL_API_URL, LoadedArchive, MemoryEtagCache, MempoolEnvelope, MempoolListParams, MempoolTransactionEnvelope, MempoolWalkParams, NftTransfer, NftTransferEvent, NftTransferPayload2 as NftTransferPayload, NftTransfersEnvelope, NftTransfersListParams, NftTransfersResource, NftTransfersWalkParams, Pox5EventsEnvelope, Pox5EventsListParams, Pox5EventsWalkParams, Pox5Resource, PoxCycleEnvelope, PoxCyclesEnvelope, PoxCyclesListParams, PoxCyclesWalkParams, PoxResource, PrintSchemaResponse, PublicStatus2 as PublicStatus, RateLimitError, ReplayResult2 as ReplayResult, RequestOptions, RewardSet2 as RewardSet, RotateSecretResponse2 as RotateSecretResponse, SbtcDepositEnvelope, SbtcDepositEvent, SbtcDepositsConsumeParams, SbtcDepositsEnvelope, SbtcDepositsListParams, SbtcDepositsWalkParams, SbtcEventTopic2 as SbtcEventTopic, SbtcEventsConsumeParams, SbtcEventsEnvelope, SbtcEventsListParams, SbtcEventsWalkParams, SbtcResource, SbtcSummaryEnvelope, SbtcWithdrawalEnvelope, SbtcWithdrawalEvent, SbtcWithdrawalStatus, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalsEnvelope, SbtcWithdrawalsListParams, SbtcWithdrawalsWalkParams, SecondLayer, SecondLayerArchive, SecondLayerError, SecondLayerErrorOptions, SecondLayerOptions, SinkTx, StackingEnvelope, StackingListParams, StackingWalkParams, StandardWebhooksHeaders2 as StandardWebhooksHeaders, StreamsBatch, StreamsBatchContext, StreamsCanonicalBlock, StreamsClient, StreamsConsumeParams, StreamsDumpFile, StreamsDumps, StreamsDumpsManifest, StreamsEvent, StreamsEventPayload, StreamsEventType, StreamsEventsConsumeParams, StreamsEventsConsumeResult, StreamsEventsEnvelope, StreamsEventsListEnvelope, StreamsEventsListParams, StreamsEventsStreamParams, StreamsEventsSubscribeParams, StreamsReorg, StreamsReorgContext, StreamsReorgsListEnvelope, StreamsReorgsListParams, StreamsServerError, StreamsSignatureError, StreamsSubscription, StreamsTip, StreamsWireEvent2 as StreamsWireEvent, SubgraphAgentSchema3 as SubgraphAgentSchema, SubgraphOperationStatus, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphSpecOptions3 as SubgraphSpecOptions, Subgraphs, TransactionEnvelope, TransactionProof, TransactionProofVerifyResult, TransactionsEnvelope, TransactionsListParams, TransactionsWalkParams, UpdateWebhookRequest2 as UpdateWebhookRequest, ValidationError, VmStreamsEvent, WalkOptions, WebhookDetail2 as WebhookDetail, WebhookFormat, WebhookHeaderInput, WebhookKind, WebhookRuntime, WebhookStatus, WebhookSummary2 as WebhookSummary, WebhookTestResult2 as WebhookTestResult, Webhooks, WithSinkTx, buildDoctorReport, consumeIndexFeed, consumerHealth, contextField, createArchiveClient, createStreamsClient, decode, decodeChainWebhook, decodeClarityValue, decodeFtBurn, decodeFtMint, decodeFtTransfer, decodeNftBurn, decodeNftMint, decodeNftTransfer, decodePrint, decodeStxBurn, decodeStxLock, decodeStxMint, decodeStxTransfer, fetchRewardSet, getSubgraph, isFtBurn, isFtMint, isFtTransfer, isNftBurn, isNftMint, isNftTransfer, isPrint, isStxBurn, isStxLock, isStxMint, isStxTransfer, isSuccessDelivery, parseRetryAfter, resolveAccountKey, resolveApiKey, resolveBaseUrl, shutdownSignal, toJsonSafe, trigger, verifySecondlayerSignature, verify as verifyStandardWebhooksHeaders, verifyTransactionProof, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -970,7 +970,10 @@ async function consumeStreamsEvents(opts) {
|
|
|
970
970
|
if (mode === "bounded") {
|
|
971
971
|
return { cursor, pages, emptyPolls };
|
|
972
972
|
}
|
|
973
|
-
await
|
|
973
|
+
await (opts.wake ? Promise.race([
|
|
974
|
+
sleep(emptyBackoffMs, opts.signal),
|
|
975
|
+
opts.wake().catch(() => new Promise(() => {}))
|
|
976
|
+
]) : sleep(emptyBackoffMs, opts.signal));
|
|
974
977
|
continue;
|
|
975
978
|
}
|
|
976
979
|
return { cursor, pages, emptyPolls };
|
|
@@ -2117,7 +2120,8 @@ function createStreamsClient(options) {
|
|
|
2117
2120
|
signal: params.signal,
|
|
2118
2121
|
retryCount: params.retryCount,
|
|
2119
2122
|
retryDelay: params.retryDelay,
|
|
2120
|
-
onError: params.onError
|
|
2123
|
+
onError: params.onError,
|
|
2124
|
+
wake: params.wake
|
|
2121
2125
|
});
|
|
2122
2126
|
}
|
|
2123
2127
|
return {
|
|
@@ -2666,6 +2670,73 @@ function getSubgraph(def, options = {}) {
|
|
|
2666
2670
|
}
|
|
2667
2671
|
return new Subgraphs(options).typed(def);
|
|
2668
2672
|
}
|
|
2673
|
+
// src/webhooks/doctor.ts
|
|
2674
|
+
function isSuccessDelivery(row) {
|
|
2675
|
+
return row.statusCode !== null && row.statusCode >= 200 && row.statusCode < 300;
|
|
2676
|
+
}
|
|
2677
|
+
function buildDoctorReport(input) {
|
|
2678
|
+
const successful = input.deliveries.filter(isSuccessDelivery).length;
|
|
2679
|
+
const failed = input.deliveries.length - successful;
|
|
2680
|
+
const subgraph = input.subgraph ? {
|
|
2681
|
+
name: input.subgraph.name,
|
|
2682
|
+
status: input.subgraph.status,
|
|
2683
|
+
syncStatus: input.subgraph.sync.status,
|
|
2684
|
+
lastProcessedBlock: input.subgraph.sync.lastProcessedBlock,
|
|
2685
|
+
chainTip: input.subgraph.sync.chainTip,
|
|
2686
|
+
gapCount: input.subgraph.sync.gaps.count,
|
|
2687
|
+
integrity: input.subgraph.sync.integrity
|
|
2688
|
+
} : null;
|
|
2689
|
+
const hints = [];
|
|
2690
|
+
const issues = [];
|
|
2691
|
+
if (input.webhook.warning) {
|
|
2692
|
+
hints.push(input.webhook.warning);
|
|
2693
|
+
issues.push({ code: "warning", detail: input.webhook.warning });
|
|
2694
|
+
}
|
|
2695
|
+
if (input.webhook.status === "paused") {
|
|
2696
|
+
hints.push(`Resume when the receiver is healthy: secondlayer webhooks resume ${input.webhook.id}`);
|
|
2697
|
+
issues.push({ code: "paused" });
|
|
2698
|
+
}
|
|
2699
|
+
if (input.webhook.lastError) {
|
|
2700
|
+
hints.push("Run secondlayer webhooks test to reproduce the receiver request.");
|
|
2701
|
+
issues.push({ code: "last_error", detail: input.webhook.lastError });
|
|
2702
|
+
}
|
|
2703
|
+
if (input.webhook.circuitOpenedAt || input.webhook.circuitFailures > 0) {
|
|
2704
|
+
hints.push("Circuit breaker has failures; inspect receiver logs and delivery status codes.");
|
|
2705
|
+
issues.push({ code: "circuit" });
|
|
2706
|
+
}
|
|
2707
|
+
if (input.dead.length > 0) {
|
|
2708
|
+
hints.push(`Dead-letter rows exist; inspect with secondlayer webhooks dead ${input.webhook.id} and requeue selected rows.`);
|
|
2709
|
+
issues.push({ code: "dead_letters" });
|
|
2710
|
+
}
|
|
2711
|
+
if (subgraph?.gapCount && subgraph.gapCount > 0) {
|
|
2712
|
+
hints.push(`Linked subgraph has gaps; run secondlayer subgraphs gaps ${input.webhook.subgraphName}.`);
|
|
2713
|
+
issues.push({ code: "subgraph_gaps" });
|
|
2714
|
+
}
|
|
2715
|
+
if (subgraph?.syncStatus === "catching_up") {
|
|
2716
|
+
hints.push("Linked subgraph is still catching up; new matching rows may arrive later.");
|
|
2717
|
+
issues.push({ code: "subgraph_catching_up" });
|
|
2718
|
+
}
|
|
2719
|
+
if (input.deliveries.length === 0) {
|
|
2720
|
+
hints.push("No deliveries yet; confirm the table is receiving inserted rows that match the filter.");
|
|
2721
|
+
issues.push({ code: "no_deliveries" });
|
|
2722
|
+
}
|
|
2723
|
+
if (hints.length === 0) {
|
|
2724
|
+
hints.push("No immediate action needed.");
|
|
2725
|
+
}
|
|
2726
|
+
return {
|
|
2727
|
+
webhook: input.webhook,
|
|
2728
|
+
deliverySummary: {
|
|
2729
|
+
total: input.deliveries.length,
|
|
2730
|
+
successful,
|
|
2731
|
+
failed,
|
|
2732
|
+
last: input.deliveries[0] ?? null
|
|
2733
|
+
},
|
|
2734
|
+
deadCount: input.dead.length,
|
|
2735
|
+
subgraph,
|
|
2736
|
+
hints,
|
|
2737
|
+
issues
|
|
2738
|
+
};
|
|
2739
|
+
}
|
|
2669
2740
|
// src/consumer-ops.ts
|
|
2670
2741
|
function consumerHealth(options = {}) {
|
|
2671
2742
|
const staleAfterMs = options.staleAfterMs ?? 120000;
|
|
@@ -2918,6 +2989,7 @@ export {
|
|
|
2918
2989
|
Subgraphs,
|
|
2919
2990
|
ValidationError,
|
|
2920
2991
|
Webhooks,
|
|
2992
|
+
buildDoctorReport,
|
|
2921
2993
|
consumeIndexFeed,
|
|
2922
2994
|
consumerHealth,
|
|
2923
2995
|
contextField,
|
|
@@ -2950,6 +3022,7 @@ export {
|
|
|
2950
3022
|
isStxLock,
|
|
2951
3023
|
isStxMint,
|
|
2952
3024
|
isStxTransfer,
|
|
3025
|
+
isSuccessDelivery,
|
|
2953
3026
|
parseRetryAfter,
|
|
2954
3027
|
resolveAccountKey,
|
|
2955
3028
|
resolveApiKey,
|
|
@@ -2963,5 +3036,5 @@ export {
|
|
|
2963
3036
|
verifyWebhookSignature
|
|
2964
3037
|
};
|
|
2965
3038
|
|
|
2966
|
-
//# debugId=
|
|
3039
|
+
//# debugId=0DD763C5B88AC34564756E2164756E21
|
|
2967
3040
|
//# sourceMappingURL=index.js.map
|