@secondlayer/sdk 11.0.0 → 12.1.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 +43 -3
- package/dist/index.js +71 -25
- package/dist/index.js.map +6 -5
- package/dist/streams/index.js +2 -25
- package/dist/streams/index.js.map +4 -4
- package/dist/subgraphs/index.js +2 -25
- 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 +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -234,8 +234,7 @@ declare function resolveBaseUrl(explicit?: string): string;
|
|
|
234
234
|
* env vars. Guarded for browsers and edge runtimes. */
|
|
235
235
|
declare function resolveApiKey(apiKey?: string): string | undefined;
|
|
236
236
|
/** Resolve the hosted account key for archive quote/fetch/credits.
|
|
237
|
-
* Precedence: explicit `accountKey` → `SECONDLAYER_API_KEY
|
|
238
|
-
* `SL_ARCHIVE_API_KEY` (one-release warn-fallbacks). Does not read
|
|
237
|
+
* Precedence: explicit `accountKey` → `SECONDLAYER_API_KEY`. Does not read
|
|
239
238
|
* `INSTANCE_TOKEN`. */
|
|
240
239
|
declare function resolveAccountKey(accountKey?: string): string | undefined;
|
|
241
240
|
declare abstract class BaseClient {
|
|
@@ -2789,6 +2788,47 @@ declare function getSubgraph<T extends {
|
|
|
2789
2788
|
schema: Record<string, unknown>;
|
|
2790
2789
|
}>(def: T, options?: Partial<SecondLayerOptions> | SecondLayer | Subgraphs): InferSubgraphClient2<T>;
|
|
2791
2790
|
import { SubgraphAgentSchema as SubgraphAgentSchema3, SubgraphSpecFormat as SubgraphSpecFormat2, SubgraphSpecOptions as SubgraphSpecOptions3 } from "@secondlayer/shared/subgraphs/spec";
|
|
2791
|
+
import { SubgraphDetail as SubgraphDetail2 } from "@secondlayer/shared/schemas/subgraphs";
|
|
2792
|
+
import { DeadRow as DeadRow3, DeliveryRow as DeliveryRow3, WebhookDetail as WebhookDetail3 } from "@secondlayer/shared/schemas/webhooks";
|
|
2793
|
+
/**
|
|
2794
|
+
* Webhook diagnosis, shared by `secondlayer webhooks doctor` and the
|
|
2795
|
+
* dashboard's webhook detail page. Moved out of the CLI (unchanged behavior)
|
|
2796
|
+
* so the web can build the same judgment without printing CLI-command text.
|
|
2797
|
+
*/
|
|
2798
|
+
declare function isSuccessDelivery(row: DeliveryRow3): boolean;
|
|
2799
|
+
type DoctorIssueCode = "warning" | "paused" | "last_error" | "circuit" | "dead_letters" | "subgraph_gaps" | "subgraph_catching_up" | "no_deliveries";
|
|
2800
|
+
interface DoctorIssue {
|
|
2801
|
+
code: DoctorIssueCode;
|
|
2802
|
+
detail?: string;
|
|
2803
|
+
}
|
|
2804
|
+
interface DoctorReport {
|
|
2805
|
+
webhook: WebhookDetail3;
|
|
2806
|
+
deliverySummary: {
|
|
2807
|
+
total: number;
|
|
2808
|
+
successful: number;
|
|
2809
|
+
failed: number;
|
|
2810
|
+
last: DeliveryRow3 | null;
|
|
2811
|
+
};
|
|
2812
|
+
deadCount: number;
|
|
2813
|
+
subgraph: {
|
|
2814
|
+
name: string;
|
|
2815
|
+
status: string;
|
|
2816
|
+
syncStatus: string;
|
|
2817
|
+
lastProcessedBlock: number;
|
|
2818
|
+
chainTip: number;
|
|
2819
|
+
gapCount: number;
|
|
2820
|
+
integrity: string;
|
|
2821
|
+
} | null;
|
|
2822
|
+
/** CLI-facing next steps, one per issue, in the same order as `issues`. */
|
|
2823
|
+
hints: string[];
|
|
2824
|
+
issues: DoctorIssue[];
|
|
2825
|
+
}
|
|
2826
|
+
declare function buildDoctorReport(input: {
|
|
2827
|
+
webhook: WebhookDetail3;
|
|
2828
|
+
deliveries: DeliveryRow3[];
|
|
2829
|
+
dead: DeadRow3[];
|
|
2830
|
+
subgraph?: SubgraphDetail2 | null;
|
|
2831
|
+
}): DoctorReport;
|
|
2792
2832
|
/**
|
|
2793
2833
|
* The two pieces every "deploy a consumer" guide leaves out, packaged:
|
|
2794
2834
|
* a liveness endpoint and a graceful-shutdown signal. Both are
|
|
@@ -3218,4 +3258,4 @@ declare const Cursor: {
|
|
|
3218
3258
|
};
|
|
3219
3259
|
};
|
|
3220
3260
|
import { decodeClarityValue, toJsonSafe } from "@secondlayer/shared/streams-rows";
|
|
3221
|
-
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 };
|
|
3261
|
+
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
|
@@ -205,7 +205,6 @@ function raceAbort(promise, signal) {
|
|
|
205
205
|
var LOCAL_API_URL = "http://127.0.0.1:3800";
|
|
206
206
|
var INSTANCE_TOKEN_ENV = "INSTANCE_TOKEN";
|
|
207
207
|
var ACCOUNT_KEY_ENV = "SECONDLAYER_API_KEY";
|
|
208
|
-
var warnedUrlAlias = false;
|
|
209
208
|
function resolveBaseUrl(explicit) {
|
|
210
209
|
if (explicit && explicit.length > 0)
|
|
211
210
|
return explicit.replace(/\/+$/, "");
|
|
@@ -213,14 +212,6 @@ function resolveBaseUrl(explicit) {
|
|
|
213
212
|
const primary = process.env?.SECONDLAYER_API_URL || undefined;
|
|
214
213
|
if (primary)
|
|
215
214
|
return primary.replace(/\/+$/, "");
|
|
216
|
-
const legacy = process.env?.SL_API_URL || undefined;
|
|
217
|
-
if (legacy) {
|
|
218
|
-
if (!warnedUrlAlias) {
|
|
219
|
-
warnedUrlAlias = true;
|
|
220
|
-
console.warn("[secondlayer] SL_API_URL is a legacy alias of SECONDLAYER_API_URL; using the alias this once.");
|
|
221
|
-
}
|
|
222
|
-
return legacy.replace(/\/+$/, "");
|
|
223
|
-
}
|
|
224
215
|
}
|
|
225
216
|
return LOCAL_API_URL;
|
|
226
217
|
}
|
|
@@ -232,26 +223,12 @@ function resolveApiKey(apiKey) {
|
|
|
232
223
|
const token = process.env?.INSTANCE_TOKEN || undefined;
|
|
233
224
|
return token;
|
|
234
225
|
}
|
|
235
|
-
var warnedArchiveAlias = false;
|
|
236
226
|
function resolveAccountKey(accountKey) {
|
|
237
227
|
if (accountKey !== undefined)
|
|
238
228
|
return accountKey;
|
|
239
229
|
if (typeof process === "undefined")
|
|
240
230
|
return;
|
|
241
|
-
|
|
242
|
-
const slAlias = process.env?.SL_API_KEY || undefined;
|
|
243
|
-
const archiveAlias = process.env?.SL_ARCHIVE_API_KEY || undefined;
|
|
244
|
-
if (primary)
|
|
245
|
-
return primary;
|
|
246
|
-
const legacy = slAlias ?? archiveAlias;
|
|
247
|
-
if (legacy) {
|
|
248
|
-
if (!warnedArchiveAlias) {
|
|
249
|
-
warnedArchiveAlias = true;
|
|
250
|
-
console.warn("[secondlayer] SL_API_KEY / SL_ARCHIVE_API_KEY are legacy aliases of SECONDLAYER_API_KEY; using the alias this once.");
|
|
251
|
-
}
|
|
252
|
-
return legacy;
|
|
253
|
-
}
|
|
254
|
-
return;
|
|
231
|
+
return process.env?.SECONDLAYER_API_KEY || undefined;
|
|
255
232
|
}
|
|
256
233
|
function seg(value) {
|
|
257
234
|
return encodeURIComponent(String(value));
|
|
@@ -2689,6 +2666,73 @@ function getSubgraph(def, options = {}) {
|
|
|
2689
2666
|
}
|
|
2690
2667
|
return new Subgraphs(options).typed(def);
|
|
2691
2668
|
}
|
|
2669
|
+
// src/webhooks/doctor.ts
|
|
2670
|
+
function isSuccessDelivery(row) {
|
|
2671
|
+
return row.statusCode !== null && row.statusCode >= 200 && row.statusCode < 300;
|
|
2672
|
+
}
|
|
2673
|
+
function buildDoctorReport(input) {
|
|
2674
|
+
const successful = input.deliveries.filter(isSuccessDelivery).length;
|
|
2675
|
+
const failed = input.deliveries.length - successful;
|
|
2676
|
+
const subgraph = input.subgraph ? {
|
|
2677
|
+
name: input.subgraph.name,
|
|
2678
|
+
status: input.subgraph.status,
|
|
2679
|
+
syncStatus: input.subgraph.sync.status,
|
|
2680
|
+
lastProcessedBlock: input.subgraph.sync.lastProcessedBlock,
|
|
2681
|
+
chainTip: input.subgraph.sync.chainTip,
|
|
2682
|
+
gapCount: input.subgraph.sync.gaps.count,
|
|
2683
|
+
integrity: input.subgraph.sync.integrity
|
|
2684
|
+
} : null;
|
|
2685
|
+
const hints = [];
|
|
2686
|
+
const issues = [];
|
|
2687
|
+
if (input.webhook.warning) {
|
|
2688
|
+
hints.push(input.webhook.warning);
|
|
2689
|
+
issues.push({ code: "warning", detail: input.webhook.warning });
|
|
2690
|
+
}
|
|
2691
|
+
if (input.webhook.status === "paused") {
|
|
2692
|
+
hints.push(`Resume when the receiver is healthy: secondlayer webhooks resume ${input.webhook.id}`);
|
|
2693
|
+
issues.push({ code: "paused" });
|
|
2694
|
+
}
|
|
2695
|
+
if (input.webhook.lastError) {
|
|
2696
|
+
hints.push("Run secondlayer webhooks test to reproduce the receiver request.");
|
|
2697
|
+
issues.push({ code: "last_error", detail: input.webhook.lastError });
|
|
2698
|
+
}
|
|
2699
|
+
if (input.webhook.circuitOpenedAt || input.webhook.circuitFailures > 0) {
|
|
2700
|
+
hints.push("Circuit breaker has failures; inspect receiver logs and delivery status codes.");
|
|
2701
|
+
issues.push({ code: "circuit" });
|
|
2702
|
+
}
|
|
2703
|
+
if (input.dead.length > 0) {
|
|
2704
|
+
hints.push(`Dead-letter rows exist; inspect with secondlayer webhooks dead ${input.webhook.id} and requeue selected rows.`);
|
|
2705
|
+
issues.push({ code: "dead_letters" });
|
|
2706
|
+
}
|
|
2707
|
+
if (subgraph?.gapCount && subgraph.gapCount > 0) {
|
|
2708
|
+
hints.push(`Linked subgraph has gaps; run secondlayer subgraphs gaps ${input.webhook.subgraphName}.`);
|
|
2709
|
+
issues.push({ code: "subgraph_gaps" });
|
|
2710
|
+
}
|
|
2711
|
+
if (subgraph?.syncStatus === "catching_up") {
|
|
2712
|
+
hints.push("Linked subgraph is still catching up; new matching rows may arrive later.");
|
|
2713
|
+
issues.push({ code: "subgraph_catching_up" });
|
|
2714
|
+
}
|
|
2715
|
+
if (input.deliveries.length === 0) {
|
|
2716
|
+
hints.push("No deliveries yet; confirm the table is receiving inserted rows that match the filter.");
|
|
2717
|
+
issues.push({ code: "no_deliveries" });
|
|
2718
|
+
}
|
|
2719
|
+
if (hints.length === 0) {
|
|
2720
|
+
hints.push("No immediate action needed.");
|
|
2721
|
+
}
|
|
2722
|
+
return {
|
|
2723
|
+
webhook: input.webhook,
|
|
2724
|
+
deliverySummary: {
|
|
2725
|
+
total: input.deliveries.length,
|
|
2726
|
+
successful,
|
|
2727
|
+
failed,
|
|
2728
|
+
last: input.deliveries[0] ?? null
|
|
2729
|
+
},
|
|
2730
|
+
deadCount: input.dead.length,
|
|
2731
|
+
subgraph,
|
|
2732
|
+
hints,
|
|
2733
|
+
issues
|
|
2734
|
+
};
|
|
2735
|
+
}
|
|
2692
2736
|
// src/consumer-ops.ts
|
|
2693
2737
|
function consumerHealth(options = {}) {
|
|
2694
2738
|
const staleAfterMs = options.staleAfterMs ?? 120000;
|
|
@@ -2941,6 +2985,7 @@ export {
|
|
|
2941
2985
|
Subgraphs,
|
|
2942
2986
|
ValidationError,
|
|
2943
2987
|
Webhooks,
|
|
2988
|
+
buildDoctorReport,
|
|
2944
2989
|
consumeIndexFeed,
|
|
2945
2990
|
consumerHealth,
|
|
2946
2991
|
contextField,
|
|
@@ -2973,6 +3018,7 @@ export {
|
|
|
2973
3018
|
isStxLock,
|
|
2974
3019
|
isStxMint,
|
|
2975
3020
|
isStxTransfer,
|
|
3021
|
+
isSuccessDelivery,
|
|
2976
3022
|
parseRetryAfter,
|
|
2977
3023
|
resolveAccountKey,
|
|
2978
3024
|
resolveApiKey,
|
|
@@ -2986,5 +3032,5 @@ export {
|
|
|
2986
3032
|
verifyWebhookSignature
|
|
2987
3033
|
};
|
|
2988
3034
|
|
|
2989
|
-
//# debugId=
|
|
3035
|
+
//# debugId=AE812DACE82FC03C64756E2164756E21
|
|
2990
3036
|
//# sourceMappingURL=index.js.map
|