@secondlayer/sdk 14.5.1 → 15.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/README.md +21 -36
- package/dist/index.d.ts +10 -17
- package/dist/index.js +3 -23
- package/dist/index.js.map +5 -5
- package/dist/subgraphs/index.d.ts +7 -3
- package/dist/subgraphs/index.js.map +3 -3
- package/dist/webhooks/doctor.d.ts +1 -12
- package/dist/webhooks/doctor.js +3 -23
- package/dist/webhooks/doctor.js.map +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -517,46 +517,25 @@ by `_id`.
|
|
|
517
517
|
|
|
518
518
|
Deprecated aliases (`sl.subscriptions`, `Subscriptions`) keep working for one release cycle.
|
|
519
519
|
|
|
520
|
-
Signed HTTP POSTs.
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
starts at the chain tip and never backfills. The turnkey "webhook on a
|
|
525
|
-
contract / event / function / trait".
|
|
526
|
-
|
|
527
|
-
```typescript
|
|
528
|
-
// List / get
|
|
529
|
-
const { data } = await sl.webhooks.list();
|
|
530
|
-
const hook = await sl.webhooks.get(id);
|
|
531
|
-
|
|
532
|
-
// Create a SUBGRAPH webhook — sink a subgraph table to a signed endpoint.
|
|
533
|
-
// `signingSecret` is returned ONCE; store it in the receiver's env.
|
|
534
|
-
const { webhook, signingSecret } = await sl.webhooks.create({
|
|
535
|
-
name: "whale-alerts",
|
|
536
|
-
subgraphName: "transfers",
|
|
537
|
-
tableName: "events",
|
|
538
|
-
url: "https://example.com/hooks/transfers",
|
|
539
|
-
format: "standard-webhooks", // or inngest | trigger | cloudflare | cloudevents | raw
|
|
540
|
-
});
|
|
541
|
-
```
|
|
542
|
-
|
|
543
|
-
### Chain webhooks
|
|
544
|
-
|
|
545
|
-
Pass `triggers` instead of `subgraphName`/`tableName`. The `trigger.*` builders
|
|
546
|
-
are optional sugar — you can also pass raw objects (e.g.
|
|
547
|
-
`{ type: "contract_call", contractId: "SP....amm", functionName: "swap-*" }`).
|
|
548
|
-
All string fields accept `*` wildcards; `trait` scopes to contracts conforming
|
|
549
|
-
to a SIP/trait (e.g. `"sip-010"`); amounts are non-negative integer strings
|
|
550
|
-
(uint128-safe) or numbers.
|
|
520
|
+
Signed HTTP POSTs on raw chain events. A webhook starts at the chain tip and
|
|
521
|
+
never backfills; it is the turnkey "webhook on a contract / event / function /
|
|
522
|
+
trait". To react to your subgraph rows, watch the table from your own Postgres
|
|
523
|
+
or poll the subgraph API: see [React to your rows](https://www.secondlayer.tools/docs/subgraphs/reading#react-to-your-rows).
|
|
551
524
|
|
|
552
525
|
```typescript
|
|
553
526
|
import { SecondLayer, trigger } from "@secondlayer/sdk";
|
|
554
527
|
|
|
555
528
|
const sl = new SecondLayer({ apiKey: process.env.INSTANCE_TOKEN });
|
|
556
529
|
|
|
530
|
+
// List / get
|
|
531
|
+
const { data } = await sl.webhooks.list();
|
|
532
|
+
const hook = await sl.webhooks.get(id);
|
|
533
|
+
|
|
534
|
+
// Create. `signingSecret` is returned ONCE; store it in the receiver's env.
|
|
557
535
|
const { webhook, signingSecret } = await sl.webhooks.create({
|
|
558
536
|
name: "amm-swaps",
|
|
559
537
|
url: "https://my-app.com/webhook",
|
|
538
|
+
format: "standard-webhooks", // or inngest | trigger | cloudflare | cloudevents | raw
|
|
560
539
|
triggers: [
|
|
561
540
|
trigger.contractCall({ contractId: "SP....amm", functionName: "swap-*" }),
|
|
562
541
|
trigger.ftTransfer({ trait: "sip-010", minAmount: "1000000" }),
|
|
@@ -564,23 +543,29 @@ const { webhook, signingSecret } = await sl.webhooks.create({
|
|
|
564
543
|
});
|
|
565
544
|
```
|
|
566
545
|
|
|
546
|
+
The `trigger.*` builders are optional sugar: you can also pass raw objects
|
|
547
|
+
(e.g. `{ type: "contract_call", contractId: "SP....amm", functionName: "swap-*" }`).
|
|
548
|
+
All string fields accept `*` wildcards; `trait` scopes to contracts conforming
|
|
549
|
+
to a SIP/trait (e.g. `"sip-010"`); amounts are non-negative integer strings
|
|
550
|
+
(uint128-safe) or numbers.
|
|
551
|
+
|
|
567
552
|
One builder per event type:
|
|
568
553
|
`trigger.stxTransfer` / `stxMint` / `stxBurn` / `stxLock`,
|
|
569
554
|
`trigger.ftTransfer` / `ftMint` / `ftBurn`,
|
|
570
555
|
`trigger.nftTransfer` / `nftMint` / `nftBurn`,
|
|
571
556
|
`trigger.contractCall`, `trigger.contractDeploy`, `trigger.printEvent`.
|
|
572
557
|
|
|
573
|
-
Delivery envelope
|
|
558
|
+
Delivery envelope: each apply is `chain.{type}.apply` with
|
|
574
559
|
body `{ action: "apply", block_hash, block_height, tx_id, canonical, trigger,
|
|
575
560
|
event }`. On reorg you get `chain.reorg.rollback` with `{ action: "rollback",
|
|
576
561
|
fork_point_height, orphaned: [{ tx_id, event }] }`. Delivery is at-least-once: a
|
|
577
562
|
tx surviving a reorg re-delivers an apply under its new `block_hash`, so key
|
|
578
563
|
consumer state on `(tx_id, block_hash)`. Per-webhook HMAC signing (Standard
|
|
579
|
-
Webhooks) is unchanged
|
|
564
|
+
Webhooks) is unchanged.
|
|
580
565
|
|
|
581
566
|
```typescript
|
|
582
|
-
// Lifecycle
|
|
583
|
-
await sl.webhooks.update(id, {
|
|
567
|
+
// Lifecycle
|
|
568
|
+
await sl.webhooks.update(id, { maxRetries: 10 });
|
|
584
569
|
await sl.webhooks.pause(id);
|
|
585
570
|
await sl.webhooks.resume(id);
|
|
586
571
|
await sl.webhooks.rotateSecret(id); // returns new signing secret once
|
|
@@ -596,7 +581,7 @@ await sl.webhooks.requeue(id, outboxId);
|
|
|
596
581
|
|
|
597
582
|
### Verifying deliveries
|
|
598
583
|
|
|
599
|
-
Every delivery
|
|
584
|
+
Every delivery, any `format`, also carries a universal authenticity
|
|
600
585
|
signature you can verify with one published key, no per-webhook secret. The
|
|
601
586
|
headers are `webhook-id`, `x-secondlayer-signature`, and
|
|
602
587
|
`x-secondlayer-signature-keyid`; the signed content is `` `${webhook-id}.${rawBody}` ``
|
package/dist/index.d.ts
CHANGED
|
@@ -3011,6 +3011,7 @@ interface SubgraphOperationStatus {
|
|
|
3011
3011
|
/** /v1 cursor envelope for subgraph table reads. */
|
|
3012
3012
|
interface SubgraphRowsEnvelope<T = unknown> {
|
|
3013
3013
|
rows: T[];
|
|
3014
|
+
/** Set on every page that returned rows; `null` only on an empty page. */
|
|
3014
3015
|
next_cursor: string | null;
|
|
3015
3016
|
tip: {
|
|
3016
3017
|
block_height: number;
|
|
@@ -3072,8 +3073,10 @@ declare class Subgraphs extends BaseClient {
|
|
|
3072
3073
|
}>;
|
|
3073
3074
|
/**
|
|
3074
3075
|
* Open /v1 read: cursor-paginated rows. Anon works on an open instance;
|
|
3075
|
-
* pass an apiKey on the client where reads are closed.
|
|
3076
|
-
* returned `
|
|
3076
|
+
* pass an apiKey on the client where reads are closed. `next_cursor` is set
|
|
3077
|
+
* on every page that returned rows and is `null` only on an empty page, so a
|
|
3078
|
+
* poller tails with `cursor = page.next_cursor ?? cursor`. A paging loop
|
|
3079
|
+
* ends on an empty page (or one shorter than `limit`).
|
|
3077
3080
|
*/
|
|
3078
3081
|
rows<T = unknown>(name: string, table: string, params?: Omit<SubgraphQueryParams, "offset"> & {
|
|
3079
3082
|
cursor?: string;
|
|
@@ -3115,7 +3118,8 @@ declare class Subgraphs extends BaseClient {
|
|
|
3115
3118
|
* const client = sl.subgraphs.typed(mySubgraph)
|
|
3116
3119
|
* const page = await client.transfers.findMany({ where: { sender: 'SP...' } })
|
|
3117
3120
|
* // page.rows: InferTableRow<typeof mySubgraph.schema.transfers>[]
|
|
3118
|
-
* // page.nextCursor:
|
|
3121
|
+
* // page.nextCursor: set whenever rows came back, null on an empty page.
|
|
3122
|
+
* // Tail new rows: cursor = page.nextCursor ?? cursor
|
|
3119
3123
|
* ```
|
|
3120
3124
|
*/
|
|
3121
3125
|
typed<T extends {
|
|
@@ -3132,7 +3136,7 @@ declare class Subgraphs extends BaseClient {
|
|
|
3132
3136
|
private createTableClient;
|
|
3133
3137
|
}
|
|
3134
3138
|
import { CreateWebhookRequest, CreateWebhookResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, UpdateWebhookRequest, WebhookActivity, WebhookDeliveryDetail, WebhookDetail, WebhookSummary, WebhookTestResult } from "@secondlayer/shared/schemas/webhooks";
|
|
3135
|
-
import { ChainTrigger, ChainTriggerType, CreateWebhookRequest as CreateWebhookRequest2, CreateWebhookResponse as CreateWebhookResponse2, DeadRow as DeadRow2, DeliveryRow as DeliveryRow2, ReplayResult as ReplayResult2, RotateSecretResponse as RotateSecretResponse2, WebhookActivity as WebhookActivity2, WebhookActivityHour, WebhookAuth, WebhookDeliveryDetail as WebhookDeliveryDetail2, WebhookDetail as WebhookDetail2, WebhookFormat, WebhookKind,
|
|
3139
|
+
import { ChainTrigger, ChainTriggerType, CreateWebhookRequest as CreateWebhookRequest2, CreateWebhookResponse as CreateWebhookResponse2, DeadRow as DeadRow2, DeliveryRow as DeliveryRow2, ReplayResult as ReplayResult2, RotateSecretResponse as RotateSecretResponse2, WebhookActivity as WebhookActivity2, WebhookActivityHour, WebhookAuth, WebhookDeliveryDetail as WebhookDeliveryDetail2, WebhookDetail as WebhookDetail2, WebhookFormat, WebhookKind, WebhookStatus, WebhookSummary as WebhookSummary2, WebhookTestResult as WebhookTestResult2, UpdateWebhookRequest as UpdateWebhookRequest2 } from "@secondlayer/shared/schemas/webhooks";
|
|
3136
3140
|
import { trigger } from "@secondlayer/shared/schemas/webhooks";
|
|
3137
3141
|
declare class Webhooks extends BaseClient {
|
|
3138
3142
|
list(): Promise<{
|
|
@@ -3281,7 +3285,6 @@ declare function getSubgraph<T extends {
|
|
|
3281
3285
|
schema: Record<string, unknown>;
|
|
3282
3286
|
}>(def: T, options?: Partial<SecondLayerOptions> | SecondLayer | Subgraphs): InferSubgraphClient2<T>;
|
|
3283
3287
|
import { SubgraphAgentSchema as SubgraphAgentSchema3, SubgraphSpecFormat as SubgraphSpecFormat2, SubgraphSpecOptions as SubgraphSpecOptions3 } from "@secondlayer/shared/subgraphs/spec";
|
|
3284
|
-
import { SubgraphDetail as SubgraphDetail2 } from "@secondlayer/shared/schemas/subgraphs";
|
|
3285
3288
|
import { DeadRow as DeadRow3, DeliveryRow as DeliveryRow3, WebhookDetail as WebhookDetail3, WebhookSummary as WebhookSummary3 } from "@secondlayer/shared/schemas/webhooks";
|
|
3286
3289
|
/**
|
|
3287
3290
|
* Webhook diagnosis, shared by `secondlayer webhooks doctor` and the
|
|
@@ -3306,7 +3309,7 @@ interface DoctorFix {
|
|
|
3306
3309
|
/** Anchor into the docs' webhooks troubleshooting section. */
|
|
3307
3310
|
docsPath?: string;
|
|
3308
3311
|
}
|
|
3309
|
-
type DoctorIssueCode = "warning" | "paused" | "last_error" | "circuit" | "dead_letters" | "
|
|
3312
|
+
type DoctorIssueCode = "warning" | "paused" | "last_error" | "circuit" | "dead_letters" | "no_deliveries" | "receiver_rate_limited" | "receiver_down" | "receiver_rejects" | "receiver_slow" | "delivery_lag";
|
|
3310
3313
|
interface DoctorIssue {
|
|
3311
3314
|
code: DoctorIssueCode;
|
|
3312
3315
|
detail?: string;
|
|
@@ -3326,15 +3329,6 @@ interface DoctorReport {
|
|
|
3326
3329
|
last: DeliveryRow3 | null;
|
|
3327
3330
|
};
|
|
3328
3331
|
deadCount: number;
|
|
3329
|
-
subgraph: {
|
|
3330
|
-
name: string;
|
|
3331
|
-
status: string;
|
|
3332
|
-
syncStatus: string;
|
|
3333
|
-
lastProcessedBlock: number;
|
|
3334
|
-
chainTip: number;
|
|
3335
|
-
gapCount: number;
|
|
3336
|
-
integrity: string;
|
|
3337
|
-
} | null;
|
|
3338
3332
|
/** CLI-facing next steps, one per issue, in the same order as `issues`. */
|
|
3339
3333
|
hints: string[];
|
|
3340
3334
|
issues: DoctorIssue[];
|
|
@@ -3348,7 +3342,6 @@ declare function buildDoctorReport(input: {
|
|
|
3348
3342
|
webhook: WebhookDetail3;
|
|
3349
3343
|
deliveries: DeliveryRow3[];
|
|
3350
3344
|
dead: DeadRow3[];
|
|
3351
|
-
subgraph?: SubgraphDetail2 | null;
|
|
3352
3345
|
}): DoctorReport;
|
|
3353
3346
|
/**
|
|
3354
3347
|
* The list page's own reduced detector: computed from `WebhookSummary` alone
|
|
@@ -3795,4 +3788,4 @@ declare const Cursor: {
|
|
|
3795
3788
|
};
|
|
3796
3789
|
};
|
|
3797
3790
|
import { decodeClarityValue, toJsonSafe } from "@secondlayer/shared/streams-rows";
|
|
3798
|
-
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, DOWN_MIN_CONSECUTIVE, 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, DoctorEvidence, DoctorFix, DoctorIssue, DoctorIssueCode, DoctorReport, DoctorSeverity, 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, IndexBitcoinTip, IndexBlock, IndexBtcReorg, 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, IndexPoxCycleSigner, IndexPrint, IndexReorg, IndexRuneBalance, IndexRuneEntry, IndexRuneEvent, IndexRuneEventKind, IndexRuneRefSummary, IndexRuneTerms, IndexSbtcDeposit, IndexSbtcDepositDetail, IndexSbtcEvent, IndexSbtcSummary, IndexSbtcWithdrawal, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawalPhase, IndexStackingAction, IndexStateWrite, 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, Pox5EventsConsumeParams, Pox5EventsEnvelope, Pox5EventsListParams, Pox5EventsWalkParams, Pox5Resource, PoxCycleEnvelope, PoxCyclesEnvelope, PoxCyclesListParams, PoxCyclesWalkParams, PoxResource, PrintSchemaResponse, PublicStatus2 as PublicStatus, RateLimitError, ReplayResult2 as ReplayResult, RequestOptions, RewardSet2 as RewardSet, RotateSecretResponse2 as RotateSecretResponse, RuneActivityEnvelope, RuneActivityListParams, RuneActivityWalkParams, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneBalancesEnvelope, RuneBalancesListParams, RuneEnvelope, RuneEtchEntry, RuneEventPayload, RuneEventType, RuneId, RuneRef, RuneStreamsEvent, RunesEnvelope, RunesListParams, RunesResource, 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, StateWritesEnvelope, StateWritesListParams, StateWritesWalkParams, StreamsBatch, StreamsBatchContext, StreamsBitcoinCanonicalBlock, StreamsBitcoinTip, StreamsCanonicalBlock, StreamsClient, StreamsConsumeBitcoinParams, StreamsConsumeParams, StreamsConsumeStacksParams, StreamsDumpFile, StreamsDumps, StreamsDumpsManifest, StreamsEvent, StreamsEventPayload, StreamsEventType, StreamsEventsBitcoinListParams, StreamsEventsConsumeBitcoinParams, StreamsEventsConsumeParams, StreamsEventsConsumeResult, StreamsEventsEnvelope, StreamsEventsListEnvelope, StreamsEventsListParams, StreamsEventsStacksListParams, StreamsEventsStreamBitcoinParams, StreamsEventsStreamParams, StreamsEventsStreamStacksParams, StreamsEventsSubscribeBitcoinParams, StreamsEventsSubscribeParams, StreamsEventsSubscribeStacksParams, 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, WebhookActivity2 as WebhookActivity, WebhookActivityHour, WebhookAuth, WebhookDeliveryDetail2 as WebhookDeliveryDetail, WebhookDetail2 as WebhookDetail, WebhookFormat, WebhookHeaderInput, WebhookKind,
|
|
3791
|
+
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, DOWN_MIN_CONSECUTIVE, 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, DoctorEvidence, DoctorFix, DoctorIssue, DoctorIssueCode, DoctorReport, DoctorSeverity, 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, IndexBitcoinTip, IndexBlock, IndexBtcReorg, 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, IndexPoxCycleSigner, IndexPrint, IndexReorg, IndexRuneBalance, IndexRuneEntry, IndexRuneEvent, IndexRuneEventKind, IndexRuneRefSummary, IndexRuneTerms, IndexSbtcDeposit, IndexSbtcDepositDetail, IndexSbtcEvent, IndexSbtcSummary, IndexSbtcWithdrawal, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawalPhase, IndexStackingAction, IndexStateWrite, 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, Pox5EventsConsumeParams, Pox5EventsEnvelope, Pox5EventsListParams, Pox5EventsWalkParams, Pox5Resource, PoxCycleEnvelope, PoxCyclesEnvelope, PoxCyclesListParams, PoxCyclesWalkParams, PoxResource, PrintSchemaResponse, PublicStatus2 as PublicStatus, RateLimitError, ReplayResult2 as ReplayResult, RequestOptions, RewardSet2 as RewardSet, RotateSecretResponse2 as RotateSecretResponse, RuneActivityEnvelope, RuneActivityListParams, RuneActivityWalkParams, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneBalancesEnvelope, RuneBalancesListParams, RuneEnvelope, RuneEtchEntry, RuneEventPayload, RuneEventType, RuneId, RuneRef, RuneStreamsEvent, RunesEnvelope, RunesListParams, RunesResource, 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, StateWritesEnvelope, StateWritesListParams, StateWritesWalkParams, StreamsBatch, StreamsBatchContext, StreamsBitcoinCanonicalBlock, StreamsBitcoinTip, StreamsCanonicalBlock, StreamsClient, StreamsConsumeBitcoinParams, StreamsConsumeParams, StreamsConsumeStacksParams, StreamsDumpFile, StreamsDumps, StreamsDumpsManifest, StreamsEvent, StreamsEventPayload, StreamsEventType, StreamsEventsBitcoinListParams, StreamsEventsConsumeBitcoinParams, StreamsEventsConsumeParams, StreamsEventsConsumeResult, StreamsEventsEnvelope, StreamsEventsListEnvelope, StreamsEventsListParams, StreamsEventsStacksListParams, StreamsEventsStreamBitcoinParams, StreamsEventsStreamParams, StreamsEventsStreamStacksParams, StreamsEventsSubscribeBitcoinParams, StreamsEventsSubscribeParams, StreamsEventsSubscribeStacksParams, 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, WebhookActivity2 as WebhookActivity, WebhookActivityHour, WebhookAuth, WebhookDeliveryDetail2 as WebhookDeliveryDetail, WebhookDetail2 as WebhookDetail, WebhookFormat, WebhookHeaderInput, WebhookKind, WebhookStatus, WebhookSummary2 as WebhookSummary, WebhookTestResult2 as WebhookTestResult, Webhooks, WithSinkTx, buildDoctorReport, buildListIssue, consumeIndexFeed, consumerHealth, contextField, createArchiveClient, createStreamsClient, decode, decodeChainWebhook, decodeClarityValue, decodeFtBurn, decodeFtMint, decodeFtTransfer, decodeNftBurn, decodeNftMint, decodeNftTransfer, decodePrint, decodeStxBurn, decodeStxLock, decodeStxMint, decodeStxTransfer, fetchRewardSet, getSubgraph, isFtBurn, isFtMint, isFtTransfer, isHostedApiUrl, 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
|
@@ -3041,9 +3041,7 @@ var CODE_PRIORITY = [
|
|
|
3041
3041
|
"receiver_rate_limited",
|
|
3042
3042
|
"receiver_slow",
|
|
3043
3043
|
"delivery_lag",
|
|
3044
|
-
"no_deliveries"
|
|
3045
|
-
"subgraph_gaps",
|
|
3046
|
-
"subgraph_catching_up"
|
|
3044
|
+
"no_deliveries"
|
|
3047
3045
|
];
|
|
3048
3046
|
function pickPrimary(issues) {
|
|
3049
3047
|
if (issues.length === 0)
|
|
@@ -3063,15 +3061,6 @@ function hintFor(issue) {
|
|
|
3063
3061
|
function buildDoctorReport(input) {
|
|
3064
3062
|
const successful = input.deliveries.filter(isSuccessDelivery).length;
|
|
3065
3063
|
const failed = input.deliveries.length - successful;
|
|
3066
|
-
const subgraph = input.subgraph ? {
|
|
3067
|
-
name: input.subgraph.name,
|
|
3068
|
-
status: input.subgraph.status,
|
|
3069
|
-
syncStatus: input.subgraph.sync.status,
|
|
3070
|
-
lastProcessedBlock: input.subgraph.sync.lastProcessedBlock,
|
|
3071
|
-
chainTip: input.subgraph.sync.chainTip,
|
|
3072
|
-
gapCount: input.subgraph.sync.gaps.count,
|
|
3073
|
-
integrity: input.subgraph.sync.integrity
|
|
3074
|
-
} : null;
|
|
3075
3064
|
const hints = [];
|
|
3076
3065
|
const issues = [];
|
|
3077
3066
|
if (input.webhook.warning) {
|
|
@@ -3102,14 +3091,6 @@ function buildDoctorReport(input) {
|
|
|
3102
3091
|
hints.push(`Dead-letter rows exist; inspect with secondlayer webhooks dead ${input.webhook.id} and requeue selected rows.`);
|
|
3103
3092
|
issues.push({ code: "dead_letters", severity: "bad" });
|
|
3104
3093
|
}
|
|
3105
|
-
if (subgraph?.gapCount && subgraph.gapCount > 0) {
|
|
3106
|
-
hints.push(`Linked subgraph has gaps; run secondlayer subgraphs gaps ${input.webhook.subgraphName}.`);
|
|
3107
|
-
issues.push({ code: "subgraph_gaps", severity: "calm" });
|
|
3108
|
-
}
|
|
3109
|
-
if (subgraph?.syncStatus === "catching_up") {
|
|
3110
|
-
hints.push("Linked subgraph is still catching up; new matching rows may arrive later.");
|
|
3111
|
-
issues.push({ code: "subgraph_catching_up", severity: "calm" });
|
|
3112
|
-
}
|
|
3113
3094
|
for (const detector of [
|
|
3114
3095
|
detectReceiverRateLimited,
|
|
3115
3096
|
detectReceiverDown,
|
|
@@ -3128,7 +3109,7 @@ function buildDoctorReport(input) {
|
|
|
3128
3109
|
hints.push(hintFor(lagIssue));
|
|
3129
3110
|
}
|
|
3130
3111
|
if (input.deliveries.length === 0) {
|
|
3131
|
-
hints.push("No deliveries yet; confirm
|
|
3112
|
+
hints.push("No deliveries yet; confirm a chain event matching one of the triggers has happened since the webhook was created.");
|
|
3132
3113
|
issues.push({ code: "no_deliveries", severity: "calm" });
|
|
3133
3114
|
}
|
|
3134
3115
|
if (hints.length === 0) {
|
|
@@ -3143,7 +3124,6 @@ function buildDoctorReport(input) {
|
|
|
3143
3124
|
last: input.deliveries[0] ?? null
|
|
3144
3125
|
},
|
|
3145
3126
|
deadCount: input.dead.length,
|
|
3146
|
-
subgraph,
|
|
3147
3127
|
hints,
|
|
3148
3128
|
issues,
|
|
3149
3129
|
primary: pickPrimary(issues)
|
|
@@ -3477,5 +3457,5 @@ export {
|
|
|
3477
3457
|
verifyWebhookSignature
|
|
3478
3458
|
};
|
|
3479
3459
|
|
|
3480
|
-
//# debugId=
|
|
3460
|
+
//# debugId=1299ECB68A5C2FAD64756E2164756E21
|
|
3481
3461
|
//# sourceMappingURL=index.js.map
|