@secondlayer/sdk 8.0.1 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/index.d.ts +41 -15
- package/dist/index.js +17 -5
- package/dist/index.js.map +6 -6
- package/dist/sinks/bun-sqlite.js.map +1 -1
- package/dist/sinks/core.js.map +1 -1
- package/dist/sinks/drizzle.js.map +1 -1
- package/dist/sinks/kysely.js.map +1 -1
- package/dist/streams/index.d.ts +1 -1
- package/dist/streams/index.js +13 -2
- package/dist/streams/index.js.map +4 -4
- package/dist/subgraphs/index.d.ts +16 -7
- package/dist/subgraphs/index.js +16 -5
- package/dist/subgraphs/index.js.map +6 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -345,7 +345,7 @@ Subgraphs and subscriptions live on the platform API alongside Streams and Index
|
|
|
345
345
|
const { data } = await sl.subgraphs.list();
|
|
346
346
|
|
|
347
347
|
// Get
|
|
348
|
-
const subgraph = await sl.subgraphs.
|
|
348
|
+
const subgraph = await sl.subgraphs.status("my-subgraph");
|
|
349
349
|
|
|
350
350
|
// Open read (/v1) — keyless for public subgraphs; pass apiKey for your private ones
|
|
351
351
|
const { rows, next_cursor, tip } = await sl.subgraphs.rows("my-subgraph", "transfers", {
|
|
@@ -370,8 +370,8 @@ const spec = await sl.subgraphs.openapi("my-subgraph");
|
|
|
370
370
|
const source = await sl.subgraphs.getSource("my-subgraph");
|
|
371
371
|
const gaps = await sl.subgraphs.gaps("my-subgraph");
|
|
372
372
|
|
|
373
|
-
// Deploy
|
|
374
|
-
const result = await sl.subgraphs.deploy({ name, sources, schema, handlerCode
|
|
373
|
+
// Deploy
|
|
374
|
+
const result = await sl.subgraphs.deploy({ name, sources, schema, handlerCode });
|
|
375
375
|
```
|
|
376
376
|
|
|
377
377
|
Stream rows live with the typed client — each table exposes `subscribe`
|
|
@@ -467,14 +467,14 @@ await sl.subscriptions.update(id, { filter: { amount: { gte: "1000000" } } });
|
|
|
467
467
|
await sl.subscriptions.pause(id);
|
|
468
468
|
await sl.subscriptions.resume(id);
|
|
469
469
|
await sl.subscriptions.rotateSecret(id); // returns new signing secret once
|
|
470
|
-
const { data: deliveries } = await sl.subscriptions.
|
|
470
|
+
const { data: deliveries } = await sl.subscriptions.deliveries(id);
|
|
471
471
|
|
|
472
472
|
// Replay historical block range
|
|
473
473
|
await sl.subscriptions.replay(id, { fromBlock: 180000, toBlock: 181000 });
|
|
474
474
|
|
|
475
475
|
// Dead-letter inspection + requeue
|
|
476
476
|
const { data: dead } = await sl.subscriptions.dead(id);
|
|
477
|
-
await sl.subscriptions.
|
|
477
|
+
await sl.subscriptions.requeue(id, outboxId);
|
|
478
478
|
```
|
|
479
479
|
|
|
480
480
|
### Verifying deliveries
|
|
@@ -561,7 +561,7 @@ is rolling out). Discover capabilities at `GET /x402/supported`.
|
|
|
561
561
|
import { ApiError } from "@secondlayer/sdk";
|
|
562
562
|
|
|
563
563
|
try {
|
|
564
|
-
await sl.subgraphs.
|
|
564
|
+
await sl.subgraphs.status("nonexistent");
|
|
565
565
|
} catch (err) {
|
|
566
566
|
if (err instanceof ApiError) {
|
|
567
567
|
console.log(err.status); // 404
|
package/dist/index.d.ts
CHANGED
|
@@ -20,12 +20,29 @@ interface SecondLayerOptions {
|
|
|
20
20
|
/** Product default: the local one-box API. Override with `baseUrl` or `SL_API_URL`. */
|
|
21
21
|
declare const LOCAL_API_URL = "http://127.0.0.1:3800";
|
|
22
22
|
declare function resolveBaseUrl(explicit?: string): string;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
/** Credential env vars, highest precedence first. `INSTANCE_TOKEN` is the
|
|
24
|
+
* canonical name — it is what `secondlayer init` writes into `.env.local` and
|
|
25
|
+
* what the instance API validates bearer tokens against. `SL_API_KEY` is a
|
|
26
|
+
* legacy alias, kept working so existing exports and CI secrets don't break. */
|
|
27
|
+
declare const CREDENTIAL_ENV_VARS: readonly ["INSTANCE_TOKEN", "SL_API_KEY"];
|
|
28
|
+
/** Resolve the credential a client should use. Precedence, highest first:
|
|
29
|
+
*
|
|
30
|
+
* 1. an explicit `apiKey` option — including an explicit `""`, which is how
|
|
31
|
+
* you opt a client back into keyless reads on a machine that has a key
|
|
32
|
+
* exported;
|
|
33
|
+
* 2. `INSTANCE_TOKEN` — the canonical credential var, shared with the CLI
|
|
34
|
+
* and MCP server;
|
|
35
|
+
* 3. `SL_API_KEY` — legacy alias for the same value.
|
|
36
|
+
*
|
|
37
|
+
* Env values that are empty strings count as unset. Falling back to the env at
|
|
38
|
+
* all is what stops `new Index()` from silently running keyless and 402-ing on
|
|
39
|
+
* the first deep-history read.
|
|
40
|
+
*
|
|
41
|
+
* When both env vars are set to *different* non-empty values there is no
|
|
42
|
+
* correct silent answer, so `INSTANCE_TOKEN` wins and we warn once on stderr —
|
|
43
|
+
* the whole point of this precedence is that a misconfigured credential should
|
|
44
|
+
* never authenticate as nobody without saying so.
|
|
45
|
+
*
|
|
29
46
|
* Guarded for browsers and edge runtimes, where `process` is undefined. */
|
|
30
47
|
declare function resolveApiKey(apiKey?: string): string | undefined;
|
|
31
48
|
declare abstract class BaseClient {
|
|
@@ -92,7 +109,12 @@ declare class Subgraphs extends BaseClient {
|
|
|
92
109
|
list(): Promise<{
|
|
93
110
|
data: SubgraphSummary[];
|
|
94
111
|
}>;
|
|
95
|
-
|
|
112
|
+
/**
|
|
113
|
+
* The subgraph's current state — health, sync position, tables. The verify
|
|
114
|
+
* step after a deploy, reindex, or backfill: poll it until `sync` catches
|
|
115
|
+
* the tip.
|
|
116
|
+
*/
|
|
117
|
+
status(name: string): Promise<SubgraphDetail>;
|
|
96
118
|
openapi(name: string, options?: SubgraphSpecOptions): Promise<Record<string, unknown>>;
|
|
97
119
|
schema(name: string, options?: SubgraphSpecOptions): Promise<SubgraphAgentSchema>;
|
|
98
120
|
markdown(name: string, options?: SubgraphSpecOptions): Promise<string>;
|
|
@@ -122,9 +144,9 @@ declare class Subgraphs extends BaseClient {
|
|
|
122
144
|
message: string;
|
|
123
145
|
}>;
|
|
124
146
|
/**
|
|
125
|
-
* Open /v1 read: cursor-paginated rows. Anon works
|
|
126
|
-
* pass an apiKey on the client
|
|
127
|
-
* `next_cursor`.
|
|
147
|
+
* Open /v1 read: cursor-paginated rows. Anon works on an open instance;
|
|
148
|
+
* pass an apiKey on the client where reads are closed. Resume with the
|
|
149
|
+
* returned `next_cursor`.
|
|
128
150
|
*/
|
|
129
151
|
rows<T = unknown>(name: string, table: string, params?: Omit<SubgraphQueryParams, "offset" | "sort"> & {
|
|
130
152
|
cursor?: string;
|
|
@@ -2317,9 +2339,11 @@ declare class Subscriptions extends BaseClient {
|
|
|
2317
2339
|
}>;
|
|
2318
2340
|
rotateSecret(id: string): Promise<RotateSecretResponse>;
|
|
2319
2341
|
/** Send a one-off test webhook to the subscription's URL (built for its
|
|
2320
|
-
* format, SSRF-guarded). Logged as a delivery row, visible via
|
|
2342
|
+
* format, SSRF-guarded). Logged as a delivery row, visible via deliveries. */
|
|
2321
2343
|
test(id: string): Promise<SubscriptionTestResult>;
|
|
2322
|
-
|
|
2344
|
+
/** The last 100 delivery attempts, newest first. The server caps the window;
|
|
2345
|
+
* there is nothing to page. */
|
|
2346
|
+
deliveries(id: string): Promise<{
|
|
2323
2347
|
data: DeliveryRow[];
|
|
2324
2348
|
}>;
|
|
2325
2349
|
replay(id: string, range: {
|
|
@@ -2330,7 +2354,9 @@ declare class Subscriptions extends BaseClient {
|
|
|
2330
2354
|
dead(id: string): Promise<{
|
|
2331
2355
|
data: DeadRow[];
|
|
2332
2356
|
}>;
|
|
2333
|
-
|
|
2357
|
+
/** Push one dead-lettered event back onto the delivery queue. `outboxId` is
|
|
2358
|
+
* the `id` of a row from {@link dead}. */
|
|
2359
|
+
requeue(id: string, outboxId: string): Promise<{
|
|
2334
2360
|
ok: true;
|
|
2335
2361
|
}>;
|
|
2336
2362
|
}
|
|
@@ -2523,7 +2549,7 @@ declare class SecondLayerError extends Error {
|
|
|
2523
2549
|
* @example
|
|
2524
2550
|
* ```ts
|
|
2525
2551
|
* try {
|
|
2526
|
-
* await client.subgraphs.
|
|
2552
|
+
* await client.subgraphs.status("my-subgraph");
|
|
2527
2553
|
* } catch (err) {
|
|
2528
2554
|
* if (err instanceof ApiError && err.status === 404) {
|
|
2529
2555
|
* console.log("Subgraph not found");
|
|
@@ -2806,4 +2832,4 @@ declare function verifySecondlayerSignature(rawBody: string, headers: WebhookHea
|
|
|
2806
2832
|
declare function decodeChainWebhook(rawBody: string): ChainWebhookDelivery;
|
|
2807
2833
|
import { RewardSet as RewardSet2 } from "@secondlayer/shared/node/consensus";
|
|
2808
2834
|
import { decodeClarityValue, toJsonSafe } from "@secondlayer/shared/streams-rows";
|
|
2809
|
-
export { verifyWebhookSignature, verifyTransactionProof, verify as verifyStandardWebhooksHeaders, verifySecondlayerSignature, trigger, toJsonSafe, shutdownSignal, resolveBaseUrl, resolveApiKey, parseRetryAfter, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, fetchRewardSet, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, decodeChainWebhook, decode, createStreamsClient, consumerHealth, consumeIndexFeed, WithSinkTx, WebhookHeaderInput, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionKind, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StandardWebhooksHeaders2 as StandardWebhooksHeaders, StackingWalkParams, StackingListParams, StackingEnvelope, SinkTx, SecondLayerOptions, SecondLayerErrorOptions, SecondLayerError, SecondLayer, SbtcWithdrawalsWalkParams, SbtcWithdrawalsListParams, SbtcWithdrawalsEnvelope, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalStatus, SbtcWithdrawalEvent, SbtcWithdrawalEnvelope, SbtcSummaryEnvelope, SbtcResource, SbtcEventsWalkParams, SbtcEventsListParams, SbtcEventsEnvelope, SbtcEventsConsumeParams, SbtcEventTopic2 as SbtcEventTopic, SbtcDepositsWalkParams, SbtcDepositsListParams, SbtcDepositsEnvelope, SbtcDepositsConsumeParams, SbtcDepositEvent, SbtcDepositEnvelope, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, ReplayResult2 as ReplayResult, RateLimitError, PrintSchemaResponse, PoxResource, PoxCyclesWalkParams, PoxCyclesListParams, PoxCyclesEnvelope, PoxCycleEnvelope, Pox5Resource, Pox5EventsWalkParams, Pox5EventsListParams, Pox5EventsEnvelope, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload2 as NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, LOCAL_API_URL, IndexTransaction, IndexTip, IndexStxTransfer, IndexStxMint, IndexStxLock, IndexStxBurn, IndexStackingAction, IndexSbtcWithdrawalPhase, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawal, IndexSbtcSummary, IndexSbtcEvent, IndexSbtcDepositDetail, IndexSbtcDeposit, IndexReorg, IndexPrint, IndexPoxFunctionCount, IndexPoxCycle, IndexPox5EventTopic, IndexPox5Event, IndexPostCondition, IndexNftTransfer, IndexNftMint, IndexNftBurn, IndexMempoolTransaction, IndexFtTransfer, IndexFtMint, IndexFtBurn, IndexFeedItem, IndexFeedFetcher, IndexFeedEnvelope, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEventOf, IndexEventFields, IndexEvent, IndexDiscovery, IndexContractCall, IndexConsumeOptions, IndexCanonicalBlock, IndexBlock, IndexAlwaysFields, Index, FtTransfersWalkParams, FtTransfersResource, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload2 as FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, EventsWalkParams, EventsListParams, EventsEnvelope, EventsConsumeParams, DeliveryRow2 as DeliveryRow, DecodedStxTransferPayload, DecodedStxTransfer, DecodedStxMintPayload, DecodedStxMint, DecodedStxLockPayload, DecodedStxLock, DecodedStxBurnPayload, DecodedStxBurn, DecodedPrintValue, DecodedPrintPayload, DecodedPrint, DecodedNftTransferPayload, DecodedNftTransfer, DecodedNftMintPayload, DecodedNftMint, DecodedNftBurnPayload, DecodedNftBurn, DecodedFtTransferPayload, DecodedFtTransfer, DecodedFtMintPayload, DecodedFtMint, DecodedFtBurnPayload, DecodedFtBurn, DecodedEventRow, DecodedEventColumns, DeadRow2 as DeadRow, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContractCallsConsumeParams, ContextSnapshot, ContextAccount, ConsumerSink, ConsumerHealth, ConsumerBatchContext, ChainWebhookEnvelope, ChainWebhookDelivery2 as ChainWebhookDelivery, ChainTxLevelEvent, ChainTriggerType, ChainTrigger, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, ChainApplyDeliveryOf, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ApiError, ActiveSubgraphOperation };
|
|
2835
|
+
export { verifyWebhookSignature, verifyTransactionProof, verify as verifyStandardWebhooksHeaders, verifySecondlayerSignature, trigger, toJsonSafe, shutdownSignal, resolveBaseUrl, resolveApiKey, parseRetryAfter, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, fetchRewardSet, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, decodeChainWebhook, decode, createStreamsClient, consumerHealth, consumeIndexFeed, WithSinkTx, WebhookHeaderInput, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionKind, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StandardWebhooksHeaders2 as StandardWebhooksHeaders, StackingWalkParams, StackingListParams, StackingEnvelope, SinkTx, SecondLayerOptions, SecondLayerErrorOptions, SecondLayerError, SecondLayer, SbtcWithdrawalsWalkParams, SbtcWithdrawalsListParams, SbtcWithdrawalsEnvelope, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalStatus, SbtcWithdrawalEvent, SbtcWithdrawalEnvelope, SbtcSummaryEnvelope, SbtcResource, SbtcEventsWalkParams, SbtcEventsListParams, SbtcEventsEnvelope, SbtcEventsConsumeParams, SbtcEventTopic2 as SbtcEventTopic, SbtcDepositsWalkParams, SbtcDepositsListParams, SbtcDepositsEnvelope, SbtcDepositsConsumeParams, SbtcDepositEvent, SbtcDepositEnvelope, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, ReplayResult2 as ReplayResult, RateLimitError, PrintSchemaResponse, PoxResource, PoxCyclesWalkParams, PoxCyclesListParams, PoxCyclesEnvelope, PoxCycleEnvelope, Pox5Resource, Pox5EventsWalkParams, Pox5EventsListParams, Pox5EventsEnvelope, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload2 as NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, LOCAL_API_URL, IndexTransaction, IndexTip, IndexStxTransfer, IndexStxMint, IndexStxLock, IndexStxBurn, IndexStackingAction, IndexSbtcWithdrawalPhase, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawal, IndexSbtcSummary, IndexSbtcEvent, IndexSbtcDepositDetail, IndexSbtcDeposit, IndexReorg, IndexPrint, IndexPoxFunctionCount, IndexPoxCycle, IndexPox5EventTopic, IndexPox5Event, IndexPostCondition, IndexNftTransfer, IndexNftMint, IndexNftBurn, IndexMempoolTransaction, IndexFtTransfer, IndexFtMint, IndexFtBurn, IndexFeedItem, IndexFeedFetcher, IndexFeedEnvelope, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEventOf, IndexEventFields, IndexEvent, IndexDiscovery, IndexContractCall, IndexConsumeOptions, IndexCanonicalBlock, IndexBlock, IndexAlwaysFields, Index, FtTransfersWalkParams, FtTransfersResource, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload2 as FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, EventsWalkParams, EventsListParams, EventsEnvelope, EventsConsumeParams, DeliveryRow2 as DeliveryRow, DecodedStxTransferPayload, DecodedStxTransfer, DecodedStxMintPayload, DecodedStxMint, DecodedStxLockPayload, DecodedStxLock, DecodedStxBurnPayload, DecodedStxBurn, DecodedPrintValue, DecodedPrintPayload, DecodedPrint, DecodedNftTransferPayload, DecodedNftTransfer, DecodedNftMintPayload, DecodedNftMint, DecodedNftBurnPayload, DecodedNftBurn, DecodedFtTransferPayload, DecodedFtTransfer, DecodedFtMintPayload, DecodedFtMint, DecodedFtBurnPayload, DecodedFtBurn, DecodedEventRow, DecodedEventColumns, DeadRow2 as DeadRow, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContractCallsConsumeParams, ContextSnapshot, ContextAccount, ConsumerSink, ConsumerHealth, ConsumerBatchContext, ChainWebhookEnvelope, ChainWebhookDelivery2 as ChainWebhookDelivery, ChainTxLevelEvent, ChainTriggerType, ChainTrigger, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, ChainApplyDeliveryOf, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, CREDENTIAL_ENV_VARS, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ApiError, ActiveSubgraphOperation };
|
package/dist/index.js
CHANGED
|
@@ -145,12 +145,23 @@ function resolveBaseUrl(explicit) {
|
|
|
145
145
|
}
|
|
146
146
|
return LOCAL_API_URL;
|
|
147
147
|
}
|
|
148
|
+
var CREDENTIAL_ENV_VARS = ["INSTANCE_TOKEN", "SL_API_KEY"];
|
|
149
|
+
var warnedConflicts = new Set;
|
|
148
150
|
function resolveApiKey(apiKey) {
|
|
149
151
|
if (apiKey !== undefined)
|
|
150
152
|
return apiKey;
|
|
151
153
|
if (typeof process === "undefined")
|
|
152
154
|
return;
|
|
153
|
-
|
|
155
|
+
const instanceToken = process.env?.INSTANCE_TOKEN || undefined;
|
|
156
|
+
const legacyKey = process.env?.SL_API_KEY || undefined;
|
|
157
|
+
if (instanceToken && legacyKey && instanceToken !== legacyKey) {
|
|
158
|
+
const pair = `${instanceToken}\x00${legacyKey}`;
|
|
159
|
+
if (!warnedConflicts.has(pair)) {
|
|
160
|
+
warnedConflicts.add(pair);
|
|
161
|
+
console.warn("[secondlayer] INSTANCE_TOKEN and SL_API_KEY are set to different values — using INSTANCE_TOKEN (SL_API_KEY is a legacy alias for it).");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return instanceToken ?? legacyKey;
|
|
154
165
|
}
|
|
155
166
|
function buildQuery(params) {
|
|
156
167
|
const search = new URLSearchParams;
|
|
@@ -340,7 +351,7 @@ class Subgraphs extends BaseClient {
|
|
|
340
351
|
async list() {
|
|
341
352
|
return this.request("GET", "/api/subgraphs");
|
|
342
353
|
}
|
|
343
|
-
async
|
|
354
|
+
async status(name) {
|
|
344
355
|
return this.request("GET", `/api/subgraphs/${name}`);
|
|
345
356
|
}
|
|
346
357
|
async openapi(name, options) {
|
|
@@ -1887,7 +1898,7 @@ class Subscriptions extends BaseClient {
|
|
|
1887
1898
|
async test(id) {
|
|
1888
1899
|
return this.request("POST", `/api/subscriptions/${id}/test`);
|
|
1889
1900
|
}
|
|
1890
|
-
async
|
|
1901
|
+
async deliveries(id) {
|
|
1891
1902
|
return this.request("GET", `/api/subscriptions/${id}/deliveries`);
|
|
1892
1903
|
}
|
|
1893
1904
|
async replay(id, range) {
|
|
@@ -1896,7 +1907,7 @@ class Subscriptions extends BaseClient {
|
|
|
1896
1907
|
async dead(id) {
|
|
1897
1908
|
return this.request("GET", `/api/subscriptions/${id}/dead`);
|
|
1898
1909
|
}
|
|
1899
|
-
async
|
|
1910
|
+
async requeue(id, outboxId) {
|
|
1900
1911
|
return this.request("POST", `/api/subscriptions/${id}/dead/${outboxId}/requeue`);
|
|
1901
1912
|
}
|
|
1902
1913
|
}
|
|
@@ -2260,9 +2271,10 @@ export {
|
|
|
2260
2271
|
Index,
|
|
2261
2272
|
Cursor,
|
|
2262
2273
|
Contracts,
|
|
2274
|
+
CREDENTIAL_ENV_VARS,
|
|
2263
2275
|
AuthError,
|
|
2264
2276
|
ApiError
|
|
2265
2277
|
};
|
|
2266
2278
|
|
|
2267
|
-
//# debugId=
|
|
2279
|
+
//# debugId=968797F41364DCA764756E2164756E21
|
|
2268
2280
|
//# sourceMappingURL=index.js.map
|