@secondlayer/sdk 3.5.2 → 3.5.3
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 +19 -1
- package/dist/index.d.ts +28 -2
- package/dist/index.js +80 -36
- package/dist/index.js.map +6 -6
- package/dist/subgraphs/index.d.ts +25 -1
- package/dist/subgraphs/index.js +80 -36
- package/dist/subgraphs/index.js.map +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -172,6 +172,17 @@ for await (const transfer of sl.index.ftTransfers.walk({
|
|
|
172
172
|
|
|
173
173
|
Deploy and query app-specific L3 tables.
|
|
174
174
|
|
|
175
|
+
Subgraphs and subscriptions live on per-tenant containers (`https://<slug>.api.secondlayer.tools`), not on the platform `api.secondlayer.tools`. The SDK transparently resolves your tenant URL on the first subgraph or subscription call by hitting `/api/tenants/me` with your API key, then caches the result. You don't need to know the URL — just pass your normal `apiKey`.
|
|
176
|
+
|
|
177
|
+
If you already know your tenant URL (OSS, staging, or a custom routing setup), skip the lookup with `tenantBaseUrl`:
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
const sl = new SecondLayer({
|
|
181
|
+
apiKey: "sk-sl_...",
|
|
182
|
+
tenantBaseUrl: "https://myslug.api.secondlayer.tools", // optional
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
175
186
|
```typescript
|
|
176
187
|
// List
|
|
177
188
|
const { data } = await sl.subgraphs.list();
|
|
@@ -243,7 +254,14 @@ try {
|
|
|
243
254
|
} catch (err) {
|
|
244
255
|
if (err instanceof ApiError) {
|
|
245
256
|
console.log(err.status); // 404
|
|
246
|
-
console.log(err.
|
|
257
|
+
console.log(err.code); // "NOT_FOUND" (from API's {error, code} envelope, if present)
|
|
258
|
+
console.log(err.message); // "Subgraph not found"
|
|
259
|
+
console.log(err.body); // full parsed envelope
|
|
247
260
|
}
|
|
248
261
|
}
|
|
249
262
|
```
|
|
263
|
+
|
|
264
|
+
Tenant-resolution failures surface as `ApiError` with distinctive codes:
|
|
265
|
+
|
|
266
|
+
- `code: "TENANT_SUSPENDED"` — your tenant is suspended (see `err.message` for the limit reason)
|
|
267
|
+
- `code: "NO_TENANT"` — your account has no provisioned tenant yet
|
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,16 @@ import { SubgraphAgentSchema, SubgraphSpecOptions } from "@secondlayer/shared/su
|
|
|
4
4
|
import { InferSubgraphClient } from "@secondlayer/subgraphs";
|
|
5
5
|
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
6
6
|
interface SecondLayerOptions {
|
|
7
|
-
/** Base URL of the Secondlayer API (trailing slashes are stripped). */
|
|
7
|
+
/** Base URL of the Secondlayer platform API (trailing slashes are stripped). */
|
|
8
8
|
baseUrl: string;
|
|
9
9
|
/** Bearer token for authenticated requests. */
|
|
10
10
|
apiKey?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Explicit tenant API base URL — bypass the auto-resolution that calls
|
|
13
|
+
* `/api/tenants/me` on first tenant-resource request. Use when you already
|
|
14
|
+
* know your tenant URL (OSS, staging, or any custom routing setup).
|
|
15
|
+
*/
|
|
16
|
+
tenantBaseUrl?: string;
|
|
11
17
|
/** Fetch implementation. Tests and edge runtimes can provide their own. */
|
|
12
18
|
fetchImpl?: FetchLike;
|
|
13
19
|
/** Deploy origin label sent as `x-sl-origin` (telemetry). Defaults to `cli`. */
|
|
@@ -17,10 +23,28 @@ declare abstract class BaseClient {
|
|
|
17
23
|
protected baseUrl: string;
|
|
18
24
|
protected apiKey?: string;
|
|
19
25
|
protected origin: "cli" | "mcp" | "session";
|
|
26
|
+
protected tenantBaseUrlOverride?: string;
|
|
27
|
+
private _tenantBaseUrlPromise;
|
|
20
28
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
21
29
|
static authHeaders(apiKey?: string): Record<string, string>;
|
|
22
30
|
protected request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
31
|
+
protected requestAt<T>(baseUrl: string, method: string, path: string, body?: unknown): Promise<T>;
|
|
23
32
|
protected requestText(method: string, path: string, body?: unknown): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve and cache the tenant API base URL for tenant-resource calls
|
|
35
|
+
* (subgraphs, subscriptions). On the platform API, those routes are not
|
|
36
|
+
* mounted — they live on per-tenant containers at
|
|
37
|
+
* `https://<slug>.api.secondlayer.tools`. This method asks
|
|
38
|
+
* `/api/tenants/me` (against the platform baseUrl) for the apiUrl that
|
|
39
|
+
* belongs to the authenticated account.
|
|
40
|
+
*
|
|
41
|
+
* The result is cached on the client instance. Failures are NOT cached, so
|
|
42
|
+
* a flaky platform call doesn't permanently break the SDK.
|
|
43
|
+
*/
|
|
44
|
+
protected getTenantBaseUrl(): Promise<string>;
|
|
45
|
+
private resolveTenantBaseUrl;
|
|
46
|
+
protected requestAtTenant<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
47
|
+
protected requestTextAtTenant(method: string, path: string, body?: unknown): Promise<string>;
|
|
24
48
|
private fetchResponse;
|
|
25
49
|
}
|
|
26
50
|
interface SubgraphSource {
|
|
@@ -475,7 +499,9 @@ declare class ApiError extends Error {
|
|
|
475
499
|
status: number;
|
|
476
500
|
/** Raw response body (parsed JSON if possible) — preserved for callers that need error details. */
|
|
477
501
|
body?: unknown;
|
|
478
|
-
|
|
502
|
+
/** Stable machine-readable code from the API's `{error, code}` error envelope. */
|
|
503
|
+
code?: string;
|
|
504
|
+
constructor(status: number, message: string, body?: unknown, code?: string);
|
|
479
505
|
}
|
|
480
506
|
/**
|
|
481
507
|
* Thrown on optimistic-concurrency conflict when a deploy supplies an
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
class ApiError extends Error {
|
|
3
3
|
status;
|
|
4
4
|
body;
|
|
5
|
-
|
|
5
|
+
code;
|
|
6
|
+
constructor(status, message, body, code) {
|
|
6
7
|
super(message);
|
|
7
8
|
this.status = status;
|
|
8
9
|
this.body = body;
|
|
10
|
+
this.code = code;
|
|
9
11
|
this.name = "ApiError";
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -28,10 +30,13 @@ class BaseClient {
|
|
|
28
30
|
baseUrl;
|
|
29
31
|
apiKey;
|
|
30
32
|
origin;
|
|
33
|
+
tenantBaseUrlOverride;
|
|
34
|
+
_tenantBaseUrlPromise = null;
|
|
31
35
|
constructor(options = {}) {
|
|
32
36
|
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
33
37
|
this.apiKey = options.apiKey;
|
|
34
38
|
this.origin = options.origin ?? "cli";
|
|
39
|
+
this.tenantBaseUrlOverride = options.tenantBaseUrl?.replace(/\/+$/, "");
|
|
35
40
|
}
|
|
36
41
|
static authHeaders(apiKey) {
|
|
37
42
|
const headers = {
|
|
@@ -43,18 +48,53 @@ class BaseClient {
|
|
|
43
48
|
return headers;
|
|
44
49
|
}
|
|
45
50
|
async request(method, path, body) {
|
|
46
|
-
|
|
51
|
+
return this.requestAt(this.baseUrl, method, path, body);
|
|
52
|
+
}
|
|
53
|
+
async requestAt(baseUrl, method, path, body) {
|
|
54
|
+
const response = await this.fetchResponse(baseUrl, method, path, body);
|
|
47
55
|
if (response.status === 204) {
|
|
48
56
|
return;
|
|
49
57
|
}
|
|
50
58
|
return response.json();
|
|
51
59
|
}
|
|
52
60
|
async requestText(method, path, body) {
|
|
53
|
-
const response = await this.fetchResponse(method, path, body);
|
|
61
|
+
const response = await this.fetchResponse(this.baseUrl, method, path, body);
|
|
62
|
+
return response.text();
|
|
63
|
+
}
|
|
64
|
+
getTenantBaseUrl() {
|
|
65
|
+
if (this.tenantBaseUrlOverride) {
|
|
66
|
+
return Promise.resolve(this.tenantBaseUrlOverride);
|
|
67
|
+
}
|
|
68
|
+
if (!this._tenantBaseUrlPromise) {
|
|
69
|
+
this._tenantBaseUrlPromise = this.resolveTenantBaseUrl().catch((err) => {
|
|
70
|
+
this._tenantBaseUrlPromise = null;
|
|
71
|
+
throw err;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return this._tenantBaseUrlPromise;
|
|
75
|
+
}
|
|
76
|
+
async resolveTenantBaseUrl() {
|
|
77
|
+
const body = await this.request("GET", "/api/tenants/me");
|
|
78
|
+
const tenant = body.tenant;
|
|
79
|
+
if (tenant.suspendedAt) {
|
|
80
|
+
throw new ApiError(403, `Tenant ${tenant.slug} is suspended${tenant.limitReason ? `: ${tenant.limitReason}` : ""}.`, body, "TENANT_SUSPENDED");
|
|
81
|
+
}
|
|
82
|
+
if (!tenant.apiUrl) {
|
|
83
|
+
throw new ApiError(404, "No tenant API URL available for this account. Provision a tenant at https://secondlayer.tools/platform.", body, "NO_TENANT");
|
|
84
|
+
}
|
|
85
|
+
return tenant.apiUrl.replace(/\/+$/, "");
|
|
86
|
+
}
|
|
87
|
+
async requestAtTenant(method, path, body) {
|
|
88
|
+
const tenantUrl = await this.getTenantBaseUrl();
|
|
89
|
+
return this.requestAt(tenantUrl, method, path, body);
|
|
90
|
+
}
|
|
91
|
+
async requestTextAtTenant(method, path, body) {
|
|
92
|
+
const tenantUrl = await this.getTenantBaseUrl();
|
|
93
|
+
const response = await this.fetchResponse(tenantUrl, method, path, body);
|
|
54
94
|
return response.text();
|
|
55
95
|
}
|
|
56
|
-
async fetchResponse(method, path, body) {
|
|
57
|
-
const url = `${
|
|
96
|
+
async fetchResponse(baseUrl, method, path, body) {
|
|
97
|
+
const url = `${baseUrl}${path}`;
|
|
58
98
|
const headers = BaseClient.authHeaders(this.apiKey);
|
|
59
99
|
headers["x-sl-origin"] = this.origin;
|
|
60
100
|
let response;
|
|
@@ -65,7 +105,7 @@ class BaseClient {
|
|
|
65
105
|
body: body ? JSON.stringify(body) : undefined
|
|
66
106
|
});
|
|
67
107
|
} catch {
|
|
68
|
-
throw new ApiError(0, `Cannot reach API at ${
|
|
108
|
+
throw new ApiError(0, `Cannot reach API at ${baseUrl}. Check your connection or try again.`);
|
|
69
109
|
}
|
|
70
110
|
if (!response.ok) {
|
|
71
111
|
if (response.status === 401) {
|
|
@@ -77,11 +117,12 @@ class BaseClient {
|
|
|
77
117
|
throw new ApiError(429, msg);
|
|
78
118
|
}
|
|
79
119
|
if (response.status >= 500) {
|
|
80
|
-
throw new ApiError(response.status, `Server error. Try again or check status at ${
|
|
120
|
+
throw new ApiError(response.status, `Server error. Try again or check status at ${baseUrl}/health`);
|
|
81
121
|
}
|
|
82
122
|
const errorBody = await response.text();
|
|
83
123
|
let message = `HTTP ${response.status}`;
|
|
84
124
|
let parsedBody = errorBody;
|
|
125
|
+
let code;
|
|
85
126
|
try {
|
|
86
127
|
const json = JSON.parse(errorBody);
|
|
87
128
|
parsedBody = json;
|
|
@@ -91,11 +132,14 @@ class BaseClient {
|
|
|
91
132
|
} else if (err && typeof err === "object") {
|
|
92
133
|
message = JSON.stringify(err);
|
|
93
134
|
}
|
|
135
|
+
if (typeof json.code === "string") {
|
|
136
|
+
code = json.code;
|
|
137
|
+
}
|
|
94
138
|
} catch {
|
|
95
139
|
if (errorBody)
|
|
96
140
|
message = errorBody;
|
|
97
141
|
}
|
|
98
|
-
throw new ApiError(response.status, message, parsedBody);
|
|
142
|
+
throw new ApiError(response.status, message, parsedBody, code);
|
|
99
143
|
}
|
|
100
144
|
return response;
|
|
101
145
|
}
|
|
@@ -173,28 +217,28 @@ function buildSpecQueryString(options) {
|
|
|
173
217
|
|
|
174
218
|
class Subgraphs extends BaseClient {
|
|
175
219
|
async list() {
|
|
176
|
-
return this.
|
|
220
|
+
return this.requestAtTenant("GET", "/api/subgraphs");
|
|
177
221
|
}
|
|
178
222
|
async get(name) {
|
|
179
|
-
return this.
|
|
223
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}`);
|
|
180
224
|
}
|
|
181
225
|
async openapi(name, options) {
|
|
182
|
-
return this.
|
|
226
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}/openapi.json${buildSpecQueryString(options)}`);
|
|
183
227
|
}
|
|
184
228
|
async schema(name, options) {
|
|
185
|
-
return this.
|
|
229
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}/schema.json${buildSpecQueryString(options)}`);
|
|
186
230
|
}
|
|
187
231
|
async markdown(name, options) {
|
|
188
|
-
return this.
|
|
232
|
+
return this.requestTextAtTenant("GET", `/api/subgraphs/${name}/docs.md${buildSpecQueryString(options)}`);
|
|
189
233
|
}
|
|
190
234
|
async reindex(name, options) {
|
|
191
|
-
return this.
|
|
235
|
+
return this.requestAtTenant("POST", `/api/subgraphs/${name}/reindex`, options);
|
|
192
236
|
}
|
|
193
237
|
async stop(name) {
|
|
194
|
-
return this.
|
|
238
|
+
return this.requestAtTenant("POST", `/api/subgraphs/${name}/stop`);
|
|
195
239
|
}
|
|
196
240
|
async backfill(name, options) {
|
|
197
|
-
return this.
|
|
241
|
+
return this.requestAtTenant("POST", `/api/subgraphs/${name}/backfill`, options);
|
|
198
242
|
}
|
|
199
243
|
async gaps(name, opts) {
|
|
200
244
|
const qs = new URLSearchParams;
|
|
@@ -205,27 +249,27 @@ class Subgraphs extends BaseClient {
|
|
|
205
249
|
if (opts?.resolved !== undefined)
|
|
206
250
|
qs.set("resolved", String(opts.resolved));
|
|
207
251
|
const query = qs.toString();
|
|
208
|
-
return this.
|
|
252
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}/gaps${query ? `?${query}` : ""}`);
|
|
209
253
|
}
|
|
210
254
|
async delete(name, options) {
|
|
211
255
|
const qs = options?.force ? "?force=true" : "";
|
|
212
|
-
return this.
|
|
256
|
+
return this.requestAtTenant("DELETE", `/api/subgraphs/${name}${qs}`);
|
|
213
257
|
}
|
|
214
258
|
async deploy(data) {
|
|
215
|
-
return this.
|
|
259
|
+
return this.requestAtTenant("POST", "/api/subgraphs", data);
|
|
216
260
|
}
|
|
217
261
|
async getSource(name) {
|
|
218
|
-
return this.
|
|
262
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}/source`);
|
|
219
263
|
}
|
|
220
264
|
async bundle(data) {
|
|
221
|
-
return this.
|
|
265
|
+
return this.requestAtTenant("POST", "/api/subgraphs/bundle", data);
|
|
222
266
|
}
|
|
223
267
|
async queryTable(name, table, params = {}) {
|
|
224
|
-
const result = await this.
|
|
268
|
+
const result = await this.requestAtTenant("GET", `/api/subgraphs/${name}/${table}${buildSubgraphQueryString(params)}`);
|
|
225
269
|
return Array.isArray(result) ? result : result.data;
|
|
226
270
|
}
|
|
227
271
|
async queryTableCount(name, table, params = {}) {
|
|
228
|
-
return this.
|
|
272
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}/${table}/count${buildSubgraphQueryString(params)}`);
|
|
229
273
|
}
|
|
230
274
|
typed(def) {
|
|
231
275
|
const result = {};
|
|
@@ -648,40 +692,40 @@ function createStreamsClient(options) {
|
|
|
648
692
|
// src/subscriptions/client.ts
|
|
649
693
|
class Subscriptions extends BaseClient {
|
|
650
694
|
async list() {
|
|
651
|
-
return this.
|
|
695
|
+
return this.requestAtTenant("GET", "/api/subscriptions");
|
|
652
696
|
}
|
|
653
697
|
async get(id) {
|
|
654
|
-
return this.
|
|
698
|
+
return this.requestAtTenant("GET", `/api/subscriptions/${id}`);
|
|
655
699
|
}
|
|
656
700
|
async create(input) {
|
|
657
|
-
return this.
|
|
701
|
+
return this.requestAtTenant("POST", "/api/subscriptions", input);
|
|
658
702
|
}
|
|
659
703
|
async update(id, patch) {
|
|
660
|
-
return this.
|
|
704
|
+
return this.requestAtTenant("PATCH", `/api/subscriptions/${id}`, patch);
|
|
661
705
|
}
|
|
662
706
|
async pause(id) {
|
|
663
|
-
return this.
|
|
707
|
+
return this.requestAtTenant("POST", `/api/subscriptions/${id}/pause`);
|
|
664
708
|
}
|
|
665
709
|
async resume(id) {
|
|
666
|
-
return this.
|
|
710
|
+
return this.requestAtTenant("POST", `/api/subscriptions/${id}/resume`);
|
|
667
711
|
}
|
|
668
712
|
async delete(id) {
|
|
669
|
-
return this.
|
|
713
|
+
return this.requestAtTenant("DELETE", `/api/subscriptions/${id}`);
|
|
670
714
|
}
|
|
671
715
|
async rotateSecret(id) {
|
|
672
|
-
return this.
|
|
716
|
+
return this.requestAtTenant("POST", `/api/subscriptions/${id}/rotate-secret`);
|
|
673
717
|
}
|
|
674
718
|
async recentDeliveries(id) {
|
|
675
|
-
return this.
|
|
719
|
+
return this.requestAtTenant("GET", `/api/subscriptions/${id}/deliveries`);
|
|
676
720
|
}
|
|
677
721
|
async replay(id, range) {
|
|
678
|
-
return this.
|
|
722
|
+
return this.requestAtTenant("POST", `/api/subscriptions/${id}/replay`, range);
|
|
679
723
|
}
|
|
680
724
|
async dead(id) {
|
|
681
|
-
return this.
|
|
725
|
+
return this.requestAtTenant("GET", `/api/subscriptions/${id}/dead`);
|
|
682
726
|
}
|
|
683
727
|
async requeueDead(id, outboxId) {
|
|
684
|
-
return this.
|
|
728
|
+
return this.requestAtTenant("POST", `/api/subscriptions/${id}/dead/${outboxId}/requeue`);
|
|
685
729
|
}
|
|
686
730
|
}
|
|
687
731
|
|
|
@@ -872,5 +916,5 @@ export {
|
|
|
872
916
|
ApiError
|
|
873
917
|
};
|
|
874
918
|
|
|
875
|
-
//# debugId=
|
|
919
|
+
//# debugId=AA41F0EF16B7740B64756E2164756E21
|
|
876
920
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/errors.ts", "../src/base.ts", "../src/subgraphs/serialize.ts", "../src/subgraphs/client.ts", "../src/index-api/client.ts", "../src/streams/consumer.ts", "../src/streams/errors.ts", "../src/streams/client.ts", "../src/subscriptions/client.ts", "../src/client.ts", "../src/subgraphs/get-subgraph.ts", "../src/streams/ft-transfer.ts", "../src/streams/nft-transfer.ts", "../src/streams/types.ts", "../src/webhooks.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Error thrown by {@link SecondLayer} when an API request fails.\n * Includes the HTTP status code for programmatic error handling.\n *\n * @example\n * ```ts\n * try {\n * await client.subgraphs.get(\"my-subgraph\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Subgraph not found\");\n * }\n * }\n * ```\n */\nexport class ApiError extends Error {\n\tconstructor(\n\t\t/** HTTP status code (0 for network errors). */\n\t\tpublic status: number,\n\t\tmessage: string,\n\t\t/** Raw response body (parsed JSON if possible) — preserved for callers that need error details. */\n\t\tpublic body?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n\n/**\n * Thrown on optimistic-concurrency conflict when a deploy supplies an\n * `expectedVersion` that no longer matches the server's stored version.\n */\nexport class VersionConflictError extends ApiError {\n\tconstructor(\n\t\tpublic currentVersion: string,\n\t\tpublic expectedVersion: string,\n\t\tmessage = `Version conflict: expected ${expectedVersion}, current ${currentVersion}`,\n\t) {\n\t\tsuper(409, message, { currentVersion, expectedVersion });\n\t\tthis.name = \"VersionConflictError\";\n\t}\n}\n",
|
|
6
|
-
"import { ApiError } from \"./errors.ts\";\n\nexport type FetchLike = (\n\tinput: string | URL | Request,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nexport interface SecondLayerOptions {\n\t/** Base URL of the Secondlayer API (trailing slashes are stripped). */\n\tbaseUrl: string;\n\t/** Bearer token for authenticated requests. */\n\tapiKey?: string;\n\t/** Fetch implementation. Tests and edge runtimes can provide their own. */\n\tfetchImpl?: FetchLike;\n\t/** Deploy origin label sent as `x-sl-origin` (telemetry). Defaults to `cli`. */\n\torigin?: \"cli\" | \"mcp\" | \"session\";\n}\n\nconst DEFAULT_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport abstract class BaseClient {\n\tprotected baseUrl: string;\n\tprotected apiKey?: string;\n\tprotected origin: \"cli\" | \"mcp\" | \"session\";\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tthis.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n\t\tthis.apiKey = options.apiKey;\n\t\tthis.origin = options.origin ?? \"cli\";\n\t}\n\n\tstatic authHeaders(apiKey?: string): Record<string, string> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t};\n\t\tif (apiKey) {\n\t\t\theaders.Authorization = `Bearer ${apiKey}`;\n\t\t}\n\t\treturn headers;\n\t}\n\n\tprotected async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst response = await this.fetchResponse(method, path, body);\n\n\t\tif (response.status === 204) {\n\t\t\treturn undefined as T;\n\t\t}\n\n\t\treturn response.json() as Promise<T>;\n\t}\n\n\tprotected async requestText(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<string> {\n\t\tconst response = await this.fetchResponse(method, path, body);\n\t\treturn response.text();\n\t}\n\n\tprivate async fetchResponse(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<Response> {\n\t\tconst url = `${
|
|
5
|
+
"/**\n * Error thrown by {@link SecondLayer} when an API request fails.\n * Includes the HTTP status code for programmatic error handling.\n *\n * @example\n * ```ts\n * try {\n * await client.subgraphs.get(\"my-subgraph\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Subgraph not found\");\n * }\n * }\n * ```\n */\nexport class ApiError extends Error {\n\tconstructor(\n\t\t/** HTTP status code (0 for network errors). */\n\t\tpublic status: number,\n\t\tmessage: string,\n\t\t/** Raw response body (parsed JSON if possible) — preserved for callers that need error details. */\n\t\tpublic body?: unknown,\n\t\t/** Stable machine-readable code from the API's `{error, code}` error envelope. */\n\t\tpublic code?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n\n/**\n * Thrown on optimistic-concurrency conflict when a deploy supplies an\n * `expectedVersion` that no longer matches the server's stored version.\n */\nexport class VersionConflictError extends ApiError {\n\tconstructor(\n\t\tpublic currentVersion: string,\n\t\tpublic expectedVersion: string,\n\t\tmessage = `Version conflict: expected ${expectedVersion}, current ${currentVersion}`,\n\t) {\n\t\tsuper(409, message, { currentVersion, expectedVersion });\n\t\tthis.name = \"VersionConflictError\";\n\t}\n}\n",
|
|
6
|
+
"import { ApiError } from \"./errors.ts\";\n\nexport type FetchLike = (\n\tinput: string | URL | Request,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nexport interface SecondLayerOptions {\n\t/** Base URL of the Secondlayer platform API (trailing slashes are stripped). */\n\tbaseUrl: string;\n\t/** Bearer token for authenticated requests. */\n\tapiKey?: string;\n\t/**\n\t * Explicit tenant API base URL — bypass the auto-resolution that calls\n\t * `/api/tenants/me` on first tenant-resource request. Use when you already\n\t * know your tenant URL (OSS, staging, or any custom routing setup).\n\t */\n\ttenantBaseUrl?: string;\n\t/** Fetch implementation. Tests and edge runtimes can provide their own. */\n\tfetchImpl?: FetchLike;\n\t/** Deploy origin label sent as `x-sl-origin` (telemetry). Defaults to `cli`. */\n\torigin?: \"cli\" | \"mcp\" | \"session\";\n}\n\nconst DEFAULT_BASE_URL = \"https://api.secondlayer.tools\";\n\ntype TenantMeResponse = {\n\ttenant: {\n\t\tslug: string;\n\t\tapiUrl: string | null;\n\t\tsuspendedAt: string | null;\n\t\tlimitReason: string | null;\n\t};\n};\n\nexport abstract class BaseClient {\n\tprotected baseUrl: string;\n\tprotected apiKey?: string;\n\tprotected origin: \"cli\" | \"mcp\" | \"session\";\n\tprotected tenantBaseUrlOverride?: string;\n\tprivate _tenantBaseUrlPromise: Promise<string> | null = null;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tthis.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n\t\tthis.apiKey = options.apiKey;\n\t\tthis.origin = options.origin ?? \"cli\";\n\t\tthis.tenantBaseUrlOverride = options.tenantBaseUrl?.replace(/\\/+$/, \"\");\n\t}\n\n\tstatic authHeaders(apiKey?: string): Record<string, string> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t};\n\t\tif (apiKey) {\n\t\t\theaders.Authorization = `Bearer ${apiKey}`;\n\t\t}\n\t\treturn headers;\n\t}\n\n\tprotected async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\treturn this.requestAt<T>(this.baseUrl, method, path, body);\n\t}\n\n\tprotected async requestAt<T>(\n\t\tbaseUrl: string,\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst response = await this.fetchResponse(baseUrl, method, path, body);\n\n\t\tif (response.status === 204) {\n\t\t\treturn undefined as T;\n\t\t}\n\n\t\treturn response.json() as Promise<T>;\n\t}\n\n\tprotected async requestText(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<string> {\n\t\tconst response = await this.fetchResponse(this.baseUrl, method, path, body);\n\t\treturn response.text();\n\t}\n\n\t/**\n\t * Resolve and cache the tenant API base URL for tenant-resource calls\n\t * (subgraphs, subscriptions). On the platform API, those routes are not\n\t * mounted — they live on per-tenant containers at\n\t * `https://<slug>.api.secondlayer.tools`. This method asks\n\t * `/api/tenants/me` (against the platform baseUrl) for the apiUrl that\n\t * belongs to the authenticated account.\n\t *\n\t * The result is cached on the client instance. Failures are NOT cached, so\n\t * a flaky platform call doesn't permanently break the SDK.\n\t */\n\tprotected getTenantBaseUrl(): Promise<string> {\n\t\tif (this.tenantBaseUrlOverride) {\n\t\t\treturn Promise.resolve(this.tenantBaseUrlOverride);\n\t\t}\n\t\tif (!this._tenantBaseUrlPromise) {\n\t\t\tthis._tenantBaseUrlPromise = this.resolveTenantBaseUrl().catch((err) => {\n\t\t\t\tthis._tenantBaseUrlPromise = null;\n\t\t\t\tthrow err;\n\t\t\t});\n\t\t}\n\t\treturn this._tenantBaseUrlPromise;\n\t}\n\n\tprivate async resolveTenantBaseUrl(): Promise<string> {\n\t\tconst body = await this.request<TenantMeResponse>(\"GET\", \"/api/tenants/me\");\n\t\tconst tenant = body.tenant;\n\t\tif (tenant.suspendedAt) {\n\t\t\tthrow new ApiError(\n\t\t\t\t403,\n\t\t\t\t`Tenant ${tenant.slug} is suspended${tenant.limitReason ? `: ${tenant.limitReason}` : \"\"}.`,\n\t\t\t\tbody,\n\t\t\t\t\"TENANT_SUSPENDED\",\n\t\t\t);\n\t\t}\n\t\tif (!tenant.apiUrl) {\n\t\t\tthrow new ApiError(\n\t\t\t\t404,\n\t\t\t\t\"No tenant API URL available for this account. Provision a tenant at https://secondlayer.tools/platform.\",\n\t\t\t\tbody,\n\t\t\t\t\"NO_TENANT\",\n\t\t\t);\n\t\t}\n\t\treturn tenant.apiUrl.replace(/\\/+$/, \"\");\n\t}\n\n\tprotected async requestAtTenant<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst tenantUrl = await this.getTenantBaseUrl();\n\t\treturn this.requestAt<T>(tenantUrl, method, path, body);\n\t}\n\n\tprotected async requestTextAtTenant(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<string> {\n\t\tconst tenantUrl = await this.getTenantBaseUrl();\n\t\tconst response = await this.fetchResponse(tenantUrl, method, path, body);\n\t\treturn response.text();\n\t}\n\n\tprivate async fetchResponse(\n\t\tbaseUrl: string,\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<Response> {\n\t\tconst url = `${baseUrl}${path}`;\n\t\tconst headers = BaseClient.authHeaders(this.apiKey);\n\t\theaders[\"x-sl-origin\"] = this.origin;\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await fetch(url, {\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\tbody: body ? JSON.stringify(body) : undefined,\n\t\t\t});\n\t\t} catch {\n\t\t\tthrow new ApiError(\n\t\t\t\t0,\n\t\t\t\t`Cannot reach API at ${baseUrl}. Check your connection or try again.`,\n\t\t\t);\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status === 401) {\n\t\t\t\tthrow new ApiError(401, \"API key invalid or expired.\");\n\t\t\t}\n\n\t\t\tif (response.status === 429) {\n\t\t\t\tconst retryAfter = response.headers.get(\"Retry-After\");\n\t\t\t\tconst msg = retryAfter\n\t\t\t\t\t? `Rate limited. Wait ${retryAfter} seconds.`\n\t\t\t\t\t: \"Rate limited. Try again later.\";\n\t\t\t\tthrow new ApiError(429, msg);\n\t\t\t}\n\n\t\t\tif (response.status >= 500) {\n\t\t\t\tthrow new ApiError(\n\t\t\t\t\tresponse.status,\n\t\t\t\t\t`Server error. Try again or check status at ${baseUrl}/health`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst errorBody = await response.text();\n\t\t\tlet message = `HTTP ${response.status}`;\n\t\t\tlet parsedBody: unknown = errorBody;\n\t\t\tlet code: string | undefined;\n\t\t\ttry {\n\t\t\t\tconst json = JSON.parse(errorBody);\n\t\t\t\tparsedBody = json;\n\t\t\t\tconst err = json.error ?? json.message;\n\t\t\t\tif (typeof err === \"string\") {\n\t\t\t\t\tmessage = err;\n\t\t\t\t} else if (err && typeof err === \"object\") {\n\t\t\t\t\tmessage = JSON.stringify(err);\n\t\t\t\t}\n\t\t\t\tif (typeof json.code === \"string\") {\n\t\t\t\t\tcode = json.code;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tif (errorBody) message = errorBody;\n\t\t\t}\n\t\t\tthrow new ApiError(response.status, message, parsedBody, code);\n\t\t}\n\n\t\treturn response;\n\t}\n}\n",
|
|
7
7
|
"/**\n * Maps camelCase system column names (with or without `_` prefix) to the\n * actual snake_case DB column names used in query params.\n */\nconst SYSTEM_COLUMN_MAP: Record<string, string> = {\n\t// underscore-prefixed camelCase (canonical row shape)\n\t_blockHeight: \"_block_height\",\n\t_txId: \"_tx_id\",\n\t_createdAt: \"_created_at\",\n\t_id: \"_id\",\n\t// no-prefix aliases\n\tblockHeight: \"_block_height\",\n\ttxId: \"_tx_id\",\n\tcreatedAt: \"_created_at\",\n\tid: \"_id\",\n};\n\nfunction resolveColumn(col: string): string {\n\treturn SYSTEM_COLUMN_MAP[col] ?? col;\n}\n\n/**\n * Serializes a WhereInput object into the flat filter map expected by\n * SubgraphQueryParams.filters (and the REST API query string).\n *\n * Scalar values → `{ column: \"value\" }`\n * Comparison objects → `{ \"column.gte\": \"100\", \"column.lt\": \"200\" }`\n * System column aliases → `blockHeight` / `_blockHeight` both → `_block_height`\n */\nexport function serializeWhere(\n\twhere: Record<string, unknown>,\n): Record<string, string> {\n\tconst filters: Record<string, string> = {};\n\n\tfor (const [column, value] of Object.entries(where)) {\n\t\tif (value === null || value === undefined) continue;\n\n\t\tconst col = resolveColumn(column);\n\n\t\tif (typeof value === \"object\" && !Array.isArray(value)) {\n\t\t\tconst ops = value as Record<string, unknown>;\n\t\t\tfor (const [op, opValue] of Object.entries(ops)) {\n\t\t\t\tif (opValue === null || opValue === undefined) continue;\n\t\t\t\tif (op === \"eq\") {\n\t\t\t\t\tfilters[col] = String(opValue);\n\t\t\t\t} else if ([\"neq\", \"gt\", \"gte\", \"lt\", \"lte\"].includes(op)) {\n\t\t\t\t\tfilters[`${col}.${op}`] = String(opValue);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfilters[col] = String(value);\n\t\t}\n\t}\n\n\treturn filters;\n}\n\n/**\n * Resolves an orderBy column name (either alias or canonical) to the DB column name.\n */\nexport function resolveOrderByColumn(col: string): string {\n\treturn resolveColumn(col);\n}\n",
|
|
8
|
-
"import type {\n\tReindexResponse,\n\tSubgraphDetail,\n\tSubgraphGapsResponse,\n\tSubgraphQueryParams,\n\tSubgraphSummary,\n} from \"@secondlayer/shared/schemas\";\nimport type {\n\tDeploySubgraphRequest,\n\tDeploySubgraphResponse,\n} from \"@secondlayer/shared/schemas/subgraphs\";\nimport type {\n\tSubgraphAgentSchema,\n\tSubgraphSpecOptions,\n} from \"@secondlayer/shared/subgraphs/spec\";\nimport type {\n\tFindManyOptions,\n\tInferSubgraphClient,\n\tWhereInput,\n} from \"@secondlayer/subgraphs\";\nimport { BaseClient } from \"../base.ts\";\nimport { resolveOrderByColumn, serializeWhere } from \"./serialize.ts\";\n\nexport interface SubgraphSource {\n\tname: string;\n\tversion: string;\n\tsourceCode: string | null;\n\treadOnly: boolean;\n\treason?: string;\n\tupdatedAt: string;\n}\n\nexport interface BundleSubgraphResponse {\n\tok: true;\n\tname: string;\n\tversion: string | null;\n\tdescription: string | null;\n\tsources: Record<string, Record<string, unknown>>;\n\tschema: Record<string, unknown>;\n\thandlerCode: string;\n\tsourceCode: string;\n\tbundleSize: number;\n}\n\nfunction buildSubgraphQueryString(params: SubgraphQueryParams): string {\n\tconst qs = new URLSearchParams();\n\tif (params.sort) qs.set(\"_sort\", params.sort);\n\tif (params.order) qs.set(\"_order\", params.order);\n\tif (params.limit !== undefined) qs.set(\"_limit\", String(params.limit));\n\tif (params.offset !== undefined) qs.set(\"_offset\", String(params.offset));\n\tif (params.fields) qs.set(\"_fields\", params.fields);\n\tif (params.filters) {\n\t\tfor (const [key, value] of Object.entries(params.filters)) {\n\t\t\tqs.set(key, String(value));\n\t\t}\n\t}\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nfunction buildSpecQueryString(options?: SubgraphSpecOptions): string {\n\tconst qs = new URLSearchParams();\n\tif (options?.serverUrl) qs.set(\"server\", options.serverUrl);\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nexport class Subgraphs extends BaseClient {\n\tasync list(): Promise<{ data: SubgraphSummary[] }> {\n\t\treturn this.
|
|
8
|
+
"import type {\n\tReindexResponse,\n\tSubgraphDetail,\n\tSubgraphGapsResponse,\n\tSubgraphQueryParams,\n\tSubgraphSummary,\n} from \"@secondlayer/shared/schemas\";\nimport type {\n\tDeploySubgraphRequest,\n\tDeploySubgraphResponse,\n} from \"@secondlayer/shared/schemas/subgraphs\";\nimport type {\n\tSubgraphAgentSchema,\n\tSubgraphSpecOptions,\n} from \"@secondlayer/shared/subgraphs/spec\";\nimport type {\n\tFindManyOptions,\n\tInferSubgraphClient,\n\tWhereInput,\n} from \"@secondlayer/subgraphs\";\nimport { BaseClient } from \"../base.ts\";\nimport { resolveOrderByColumn, serializeWhere } from \"./serialize.ts\";\n\nexport interface SubgraphSource {\n\tname: string;\n\tversion: string;\n\tsourceCode: string | null;\n\treadOnly: boolean;\n\treason?: string;\n\tupdatedAt: string;\n}\n\nexport interface BundleSubgraphResponse {\n\tok: true;\n\tname: string;\n\tversion: string | null;\n\tdescription: string | null;\n\tsources: Record<string, Record<string, unknown>>;\n\tschema: Record<string, unknown>;\n\thandlerCode: string;\n\tsourceCode: string;\n\tbundleSize: number;\n}\n\nfunction buildSubgraphQueryString(params: SubgraphQueryParams): string {\n\tconst qs = new URLSearchParams();\n\tif (params.sort) qs.set(\"_sort\", params.sort);\n\tif (params.order) qs.set(\"_order\", params.order);\n\tif (params.limit !== undefined) qs.set(\"_limit\", String(params.limit));\n\tif (params.offset !== undefined) qs.set(\"_offset\", String(params.offset));\n\tif (params.fields) qs.set(\"_fields\", params.fields);\n\tif (params.filters) {\n\t\tfor (const [key, value] of Object.entries(params.filters)) {\n\t\t\tqs.set(key, String(value));\n\t\t}\n\t}\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nfunction buildSpecQueryString(options?: SubgraphSpecOptions): string {\n\tconst qs = new URLSearchParams();\n\tif (options?.serverUrl) qs.set(\"server\", options.serverUrl);\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nexport class Subgraphs extends BaseClient {\n\tasync list(): Promise<{ data: SubgraphSummary[] }> {\n\t\treturn this.requestAtTenant<{ data: SubgraphSummary[] }>(\n\t\t\t\"GET\",\n\t\t\t\"/api/subgraphs\",\n\t\t);\n\t}\n\n\tasync get(name: string): Promise<SubgraphDetail> {\n\t\treturn this.requestAtTenant<SubgraphDetail>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}`,\n\t\t);\n\t}\n\n\tasync openapi(\n\t\tname: string,\n\t\toptions?: SubgraphSpecOptions,\n\t): Promise<Record<string, unknown>> {\n\t\treturn this.requestAtTenant<Record<string, unknown>>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/openapi.json${buildSpecQueryString(options)}`,\n\t\t);\n\t}\n\n\tasync schema(\n\t\tname: string,\n\t\toptions?: SubgraphSpecOptions,\n\t): Promise<SubgraphAgentSchema> {\n\t\treturn this.requestAtTenant<SubgraphAgentSchema>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/schema.json${buildSpecQueryString(options)}`,\n\t\t);\n\t}\n\n\tasync markdown(name: string, options?: SubgraphSpecOptions): Promise<string> {\n\t\treturn this.requestTextAtTenant(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/docs.md${buildSpecQueryString(options)}`,\n\t\t);\n\t}\n\n\tasync reindex(\n\t\tname: string,\n\t\toptions?: { fromBlock?: number; toBlock?: number },\n\t): Promise<ReindexResponse> {\n\t\treturn this.requestAtTenant<ReindexResponse>(\n\t\t\t\"POST\",\n\t\t\t`/api/subgraphs/${name}/reindex`,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync stop(\n\t\tname: string,\n\t): Promise<{ message: string; operationId?: string; status?: string }> {\n\t\treturn this.requestAtTenant<{\n\t\t\tmessage: string;\n\t\t\toperationId?: string;\n\t\t\tstatus?: string;\n\t\t}>(\"POST\", `/api/subgraphs/${name}/stop`);\n\t}\n\n\tasync backfill(\n\t\tname: string,\n\t\toptions: { fromBlock: number; toBlock: number },\n\t): Promise<ReindexResponse> {\n\t\treturn this.requestAtTenant<ReindexResponse>(\n\t\t\t\"POST\",\n\t\t\t`/api/subgraphs/${name}/backfill`,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync gaps(\n\t\tname: string,\n\t\topts?: { limit?: number; offset?: number; resolved?: boolean },\n\t): Promise<SubgraphGapsResponse> {\n\t\tconst qs = new URLSearchParams();\n\t\tif (opts?.limit !== undefined) qs.set(\"_limit\", String(opts.limit));\n\t\tif (opts?.offset !== undefined) qs.set(\"_offset\", String(opts.offset));\n\t\tif (opts?.resolved !== undefined) qs.set(\"resolved\", String(opts.resolved));\n\t\tconst query = qs.toString();\n\t\treturn this.requestAtTenant<SubgraphGapsResponse>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/gaps${query ? `?${query}` : \"\"}`,\n\t\t);\n\t}\n\n\tasync delete(\n\t\tname: string,\n\t\toptions?: { force?: boolean },\n\t): Promise<{ message: string }> {\n\t\tconst qs = options?.force ? \"?force=true\" : \"\";\n\t\treturn this.requestAtTenant<{ message: string }>(\n\t\t\t\"DELETE\",\n\t\t\t`/api/subgraphs/${name}${qs}`,\n\t\t);\n\t}\n\n\tasync deploy(data: DeploySubgraphRequest): Promise<DeploySubgraphResponse> {\n\t\treturn this.requestAtTenant<DeploySubgraphResponse>(\n\t\t\t\"POST\",\n\t\t\t\"/api/subgraphs\",\n\t\t\tdata,\n\t\t);\n\t}\n\n\tasync getSource(name: string): Promise<SubgraphSource> {\n\t\treturn this.requestAtTenant<SubgraphSource>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/source`,\n\t\t);\n\t}\n\n\t/**\n\t * Bundle a TypeScript subgraph source on the server. Used by the web chat\n\t * authoring loop so Vercel's serverless runtime doesn't have to run esbuild.\n\t */\n\tasync bundle(data: { code: string }): Promise<BundleSubgraphResponse> {\n\t\treturn this.requestAtTenant<BundleSubgraphResponse>(\n\t\t\t\"POST\",\n\t\t\t\"/api/subgraphs/bundle\",\n\t\t\tdata,\n\t\t);\n\t}\n\n\tasync queryTable(\n\t\tname: string,\n\t\ttable: string,\n\t\tparams: SubgraphQueryParams = {},\n\t): Promise<unknown[]> {\n\t\tconst result = await this.requestAtTenant<{ data: unknown[] } | unknown[]>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/${table}${buildSubgraphQueryString(params)}`,\n\t\t);\n\t\treturn Array.isArray(result) ? result : result.data;\n\t}\n\n\tasync queryTableCount(\n\t\tname: string,\n\t\ttable: string,\n\t\tparams: SubgraphQueryParams = {},\n\t): Promise<{ count: number }> {\n\t\treturn this.requestAtTenant<{ count: number }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/${table}/count${buildSubgraphQueryString(params)}`,\n\t\t);\n\t}\n\n\t/**\n\t * Returns a typed client for a subgraph defined with `defineSubgraph()`.\n\t * Row types are inferred from the subgraph's schema literal types.\n\t *\n\t * @example\n\t * ```ts\n\t * import mySubgraph from './subgraphs/my-token-subgraph'\n\t * const client = sl.subgraphs.typed(mySubgraph)\n\t * const rows = await client.transfers.findMany({ where: { sender: 'SP...' } })\n\t * // rows: InferTableRow<typeof mySubgraph.schema.transfers>[]\n\t * ```\n\t */\n\ttyped<T extends { name: string; schema: Record<string, unknown> }>(\n\t\tdef: T,\n\t): InferSubgraphClient<T> {\n\t\tconst result: Record<string, unknown> = {};\n\n\t\tfor (const tableName of Object.keys(def.schema)) {\n\t\t\tresult[tableName] = this.createTableClient(def.name, tableName);\n\t\t}\n\n\t\treturn result as InferSubgraphClient<T>;\n\t}\n\n\tprivate createTableClient(subgraphName: string, tableName: string) {\n\t\tconst self = this;\n\n\t\treturn {\n\t\t\tasync findMany<TRow>(\n\t\t\t\toptions: FindManyOptions<TRow> = {},\n\t\t\t): Promise<TRow[]> {\n\t\t\t\tconst filters = options.where\n\t\t\t\t\t? serializeWhere(options.where as Record<string, unknown>)\n\t\t\t\t\t: undefined;\n\n\t\t\t\tlet sort: string | undefined;\n\t\t\t\tlet order: string | undefined;\n\t\t\t\tif (options.orderBy) {\n\t\t\t\t\tconst entries = Object.entries(options.orderBy) as [\n\t\t\t\t\t\tstring,\n\t\t\t\t\t\t\"asc\" | \"desc\",\n\t\t\t\t\t][];\n\t\t\t\t\tif (entries.length > 0) {\n\t\t\t\t\t\tif (entries.length > 1) {\n\t\t\t\t\t\t\tconst extra = entries\n\t\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t\t.map(([col]) => col)\n\t\t\t\t\t\t\t\t.join(\", \");\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`orderBy supports only one column; remove extra keys: ${extra}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst first = entries[0];\n\t\t\t\t\t\tif (first) {\n\t\t\t\t\t\t\tconst [col, dir] = first;\n\t\t\t\t\t\t\tsort = resolveOrderByColumn(col);\n\t\t\t\t\t\t\torder = dir ?? \"asc\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst params: SubgraphQueryParams = {\n\t\t\t\t\tsort,\n\t\t\t\t\torder,\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t\toffset: options.offset,\n\t\t\t\t\tfields: options.fields?.join(\",\"),\n\t\t\t\t\tfilters,\n\t\t\t\t};\n\n\t\t\t\treturn self.queryTable(subgraphName, tableName, params) as Promise<\n\t\t\t\t\tTRow[]\n\t\t\t\t>;\n\t\t\t},\n\n\t\t\tasync count<TRow>(where?: WhereInput<TRow>): Promise<number> {\n\t\t\t\tconst filters = where\n\t\t\t\t\t? serializeWhere(where as Record<string, unknown>)\n\t\t\t\t\t: undefined;\n\n\t\t\t\tconst result = await self.queryTableCount(subgraphName, tableName, {\n\t\t\t\t\tfilters,\n\t\t\t\t});\n\t\t\t\treturn result.count;\n\t\t\t},\n\t\t};\n\t}\n}\n",
|
|
9
9
|
"import { BaseClient } from \"../base.ts\";\nimport type { SecondLayerOptions } from \"../base.ts\";\n\nexport type IndexTip = {\n\tblock_height: number;\n\tlag_seconds: number;\n};\n\nexport type FtTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_transfer\";\n\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type FtTransfersEnvelope = {\n\tevents: FtTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Reserved envelope field. v1 currently always emits [].\n\treorgs: never[];\n};\n\nexport type FtTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type FtTransfersWalkParams = Omit<FtTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nexport type NftTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_transfer\";\n\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type NftTransfersEnvelope = {\n\tevents: NftTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Reserved envelope field. v1 currently always emits [].\n\treorgs: never[];\n};\n\nexport type NftTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tassetIdentifier?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type NftTransfersWalkParams = Omit<NftTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nfunction appendSearchParam(\n\tparams: URLSearchParams,\n\tname: string,\n\tvalue: number | string | null | undefined,\n): void {\n\tif (value === undefined || value === null) return;\n\tparams.set(name, String(value));\n}\n\nfunction firstWalkFromHeight(params: {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tfromHeight?: number;\n}): number | undefined {\n\tif (params.fromHeight !== undefined) return params.fromHeight;\n\tif (params.cursor || params.fromCursor) return undefined;\n\treturn 0;\n}\n\nexport class Index extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\treadonly ftTransfers: {\n\t\tlist: (params?: FtTransfersListParams) => Promise<FtTransfersEnvelope>;\n\t\twalk: (params?: FtTransfersWalkParams) => AsyncIterable<FtTransfer>;\n\t} = {\n\t\tlist: (params: FtTransfersListParams = {}): Promise<FtTransfersEnvelope> =>\n\t\t\tthis.listFtTransfers(params),\n\t\twalk: (params: FtTransfersWalkParams = {}): AsyncIterable<FtTransfer> =>\n\t\t\tthis.walkFtTransfers(params),\n\t};\n\n\treadonly nftTransfers: {\n\t\tlist: (params?: NftTransfersListParams) => Promise<NftTransfersEnvelope>;\n\t\twalk: (params?: NftTransfersWalkParams) => AsyncIterable<NftTransfer>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: NftTransfersListParams = {},\n\t\t): Promise<NftTransfersEnvelope> => this.listNftTransfers(params),\n\t\twalk: (params: NftTransfersWalkParams = {}): AsyncIterable<NftTransfer> =>\n\t\t\tthis.walkNftTransfers(params),\n\t};\n\n\tprivate async listFtTransfers(\n\t\tparams: FtTransfersListParams = {},\n\t): Promise<FtTransfersEnvelope> {\n\t\tconst searchParams = new URLSearchParams();\n\t\tappendSearchParam(searchParams, \"cursor\", params.cursor);\n\t\tappendSearchParam(searchParams, \"from_cursor\", params.fromCursor);\n\t\tappendSearchParam(searchParams, \"limit\", params.limit);\n\t\tappendSearchParam(searchParams, \"contract_id\", params.contractId);\n\t\tappendSearchParam(searchParams, \"sender\", params.sender);\n\t\tappendSearchParam(searchParams, \"recipient\", params.recipient);\n\t\tappendSearchParam(searchParams, \"from_height\", params.fromHeight);\n\t\tappendSearchParam(searchParams, \"to_height\", params.toHeight);\n\n\t\tconst query = searchParams.toString();\n\t\treturn this.request<FtTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/ft-transfers${query ? `?${query}` : \"\"}`,\n\t\t);\n\t}\n\n\tprivate async listNftTransfers(\n\t\tparams: NftTransfersListParams = {},\n\t): Promise<NftTransfersEnvelope> {\n\t\tconst searchParams = new URLSearchParams();\n\t\tappendSearchParam(searchParams, \"cursor\", params.cursor);\n\t\tappendSearchParam(searchParams, \"from_cursor\", params.fromCursor);\n\t\tappendSearchParam(searchParams, \"limit\", params.limit);\n\t\tappendSearchParam(searchParams, \"contract_id\", params.contractId);\n\t\tappendSearchParam(searchParams, \"asset_identifier\", params.assetIdentifier);\n\t\tappendSearchParam(searchParams, \"sender\", params.sender);\n\t\tappendSearchParam(searchParams, \"recipient\", params.recipient);\n\t\tappendSearchParam(searchParams, \"from_height\", params.fromHeight);\n\t\tappendSearchParam(searchParams, \"to_height\", params.toHeight);\n\n\t\tconst query = searchParams.toString();\n\t\treturn this.request<NftTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/nft-transfers${query ? `?${query}` : \"\"}`,\n\t\t);\n\t}\n\n\tprivate async *walkFtTransfers(\n\t\tparams: FtTransfersWalkParams = {},\n\t): AsyncGenerator<FtTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listFtTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async *walkNftTransfers(\n\t\tparams: NftTransfersWalkParams = {},\n\t): AsyncGenerator<NftTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listNftTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n}\n",
|
|
10
10
|
"import type {\n\tStreamsEvent,\n\tStreamsEventType,\n\tStreamsEventsEnvelope,\n} from \"./types.ts\";\n\ntype StreamsEventsFetchParams = {\n\tcursor?: string | null;\n\tlimit: number;\n\ttypes?: readonly StreamsEventType[];\n\tcontractId?: string;\n};\n\nexport type StreamsEventsFetcher = (\n\tparams: StreamsEventsFetchParams,\n) => Promise<StreamsEventsEnvelope>;\n\nexport type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;\n\nexport async function defaultSleep(\n\tms: number,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tif (signal?.aborted) return;\n\n\tawait new Promise<void>((resolve) => {\n\t\tconst timeout = setTimeout(resolve, ms);\n\t\tif (!signal) return;\n\t\tsignal.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tresolve();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t});\n}\n\nexport async function consumeStreamsEvents(opts: {\n\tfromCursor?: string | null;\n\tmode?: \"tail\" | \"bounded\";\n\tbatchSize: number;\n\ttypes?: readonly StreamsEventType[];\n\tcontractId?: string;\n\tfetchEvents: StreamsEventsFetcher;\n\tonBatch: (\n\t\tevents: StreamsEvent[],\n\t\tenvelope: StreamsEventsEnvelope,\n\t) => Promise<string | null | undefined> | string | null | undefined;\n\tsleep?: Sleep;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n}): Promise<{ cursor: string | null; pages: number; emptyPolls: number }> {\n\tconst sleep = opts.sleep ?? defaultSleep;\n\tconst mode = opts.mode ?? \"tail\";\n\tconst emptyBackoffMs = opts.emptyBackoffMs ?? 500;\n\tconst maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;\n\tconst maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;\n\tlet cursor = opts.fromCursor ?? null;\n\tlet pages = 0;\n\tlet emptyPolls = 0;\n\n\twhile (\n\t\tpages < maxPages &&\n\t\temptyPolls < maxEmptyPolls &&\n\t\t!opts.signal?.aborted\n\t) {\n\t\tconst envelope = await opts.fetchEvents({\n\t\t\tcursor,\n\t\t\tlimit: opts.batchSize,\n\t\t\ttypes: opts.types,\n\t\t\tcontractId: opts.contractId,\n\t\t});\n\t\tpages++;\n\n\t\tconst returnedCursor = await opts.onBatch(envelope.events, envelope);\n\t\tconst nextCursor = returnedCursor ?? envelope.next_cursor;\n\n\t\tif (nextCursor && nextCursor !== cursor) {\n\t\t\tcursor = nextCursor;\n\t\t\temptyPolls = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (envelope.events.length === 0) {\n\t\t\temptyPolls++;\n\t\t\tif (mode === \"bounded\") {\n\t\t\t\treturn { cursor, pages, emptyPolls };\n\t\t\t}\n\t\t\tawait sleep(emptyBackoffMs, opts.signal);\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn { cursor, pages, emptyPolls };\n\t}\n\n\treturn { cursor, pages, emptyPolls };\n}\n\nexport async function* streamStreamsEvents(opts: {\n\tfromCursor?: string | null;\n\tbatchSize: number;\n\ttypes?: readonly StreamsEventType[];\n\tcontractId?: string;\n\tfetchEvents: StreamsEventsFetcher;\n\tsleep?: Sleep;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n}): AsyncGenerator<StreamsEvent> {\n\tconst sleep = opts.sleep ?? defaultSleep;\n\tconst emptyBackoffMs = opts.emptyBackoffMs ?? 500;\n\tconst maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;\n\tconst maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;\n\tlet cursor = opts.fromCursor ?? null;\n\tlet pages = 0;\n\tlet emptyPolls = 0;\n\n\twhile (\n\t\tpages < maxPages &&\n\t\temptyPolls < maxEmptyPolls &&\n\t\t!opts.signal?.aborted\n\t) {\n\t\tconst envelope = await opts.fetchEvents({\n\t\t\tcursor,\n\t\t\tlimit: opts.batchSize,\n\t\t\ttypes: opts.types,\n\t\t\tcontractId: opts.contractId,\n\t\t});\n\t\tpages++;\n\n\t\tfor (const event of envelope.events) {\n\t\t\tif (opts.signal?.aborted) return;\n\t\t\tyield event;\n\t\t}\n\n\t\tconst nextCursor = envelope.next_cursor;\n\t\tif (nextCursor && nextCursor !== cursor) {\n\t\t\tcursor = nextCursor;\n\t\t\temptyPolls = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (envelope.events.length === 0) {\n\t\t\temptyPolls++;\n\t\t\tif (emptyPolls >= maxEmptyPolls || pages >= maxPages) return;\n\t\t\tawait sleep(emptyBackoffMs, opts.signal);\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn;\n\t}\n}\n",
|
|
11
11
|
"export class AuthError extends Error {\n\treadonly status = 401;\n\n\tconstructor(message = \"API key invalid or expired.\") {\n\t\tsuper(message);\n\t\tthis.name = \"AuthError\";\n\t}\n}\n\nexport class RateLimitError extends Error {\n\treadonly status = 429;\n\n\tconstructor(\n\t\tmessage = \"Rate limited. Try again later.\",\n\t\treadonly retryAfter?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"RateLimitError\";\n\t}\n}\n\nexport class ValidationError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly status: number,\n\t\treadonly body?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ValidationError\";\n\t}\n}\n\nexport class StreamsServerError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly status: number,\n\t\treadonly body?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"StreamsServerError\";\n\t}\n}\n",
|
|
12
12
|
"import {\n\ttype StreamsEventsFetcher,\n\tconsumeStreamsEvents,\n\tstreamStreamsEvents,\n} from \"./consumer.ts\";\nimport {\n\tAuthError,\n\tRateLimitError,\n\tStreamsServerError,\n\tValidationError,\n} from \"./errors.ts\";\nimport type {\n\tFetchLike,\n\tStreamsCanonicalBlock,\n\tStreamsClient,\n\tStreamsEventsConsumeParams,\n\tStreamsEventsEnvelope,\n\tStreamsEventsListEnvelope,\n\tStreamsEventsListParams,\n\tStreamsEventsStreamParams,\n\tStreamsReorgsListEnvelope,\n\tStreamsReorgsListParams,\n\tStreamsTip,\n} from \"./types.ts\";\n\nconst DEFAULT_STREAMS_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport type CreateStreamsClientOptions = {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetchImpl?: FetchLike;\n};\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n\treturn baseUrl.replace(/\\/+$/, \"\");\n}\n\nfunction appendSearchParam(\n\tparams: URLSearchParams,\n\tname: string,\n\tvalue: number | string | null | undefined,\n): void {\n\tif (value === undefined || value === null) return;\n\tparams.set(name, String(value));\n}\n\nasync function responseBody(response: Response): Promise<unknown> {\n\tconst text = await response.text();\n\tif (text.length === 0) return undefined;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch {\n\t\treturn text;\n\t}\n}\n\nfunction errorMessage(body: unknown, fallback: string): string {\n\tif (body && typeof body === \"object\") {\n\t\tconst record = body as Record<string, unknown>;\n\t\tconst message = record.error ?? record.message;\n\t\tif (typeof message === \"string\" && message.length > 0) return message;\n\t}\n\tif (typeof body === \"string\" && body.length > 0) return body;\n\treturn fallback;\n}\n\nasync function mapStreamsError(response: Response): Promise<never> {\n\tconst body = await responseBody(response);\n\n\tif (response.status === 401) {\n\t\tthrow new AuthError(errorMessage(body, \"API key invalid or expired.\"));\n\t}\n\n\tif (response.status === 429) {\n\t\tconst retryAfter = response.headers.get(\"Retry-After\") ?? undefined;\n\t\tthrow new RateLimitError(\n\t\t\terrorMessage(body, \"Rate limited. Try again later.\"),\n\t\t\tretryAfter,\n\t\t);\n\t}\n\n\tif (response.status >= 500) {\n\t\tthrow new StreamsServerError(\n\t\t\terrorMessage(body, `Streams server returned ${response.status}.`),\n\t\t\tresponse.status,\n\t\t\tbody,\n\t\t);\n\t}\n\n\tthrow new ValidationError(\n\t\terrorMessage(body, `Streams request returned ${response.status}.`),\n\t\tresponse.status,\n\t\tbody,\n\t);\n}\n\nexport function createStreamsClient(\n\toptions: CreateStreamsClientOptions,\n): StreamsClient {\n\tconst baseUrl = normalizeBaseUrl(options.baseUrl ?? DEFAULT_STREAMS_BASE_URL);\n\tconst fetchImpl = options.fetchImpl ?? ((input, init) => fetch(input, init));\n\n\tasync function request<T>(path: string): Promise<T> {\n\t\tconst response = await fetchImpl(`${baseUrl}${path}`, {\n\t\t\theaders: { Authorization: `Bearer ${options.apiKey}` },\n\t\t});\n\t\tif (!response.ok) await mapStreamsError(response);\n\t\treturn (await response.json()) as T;\n\t}\n\n\tconst fetchEvents: StreamsEventsFetcher = async ({\n\t\tcursor,\n\t\tlimit,\n\t\ttypes,\n\t\tcontractId,\n\t}) => {\n\t\treturn listEvents({ cursor, limit, types, contractId });\n\t};\n\n\tasync function listEvents(\n\t\tparams: StreamsEventsListParams = {},\n\t): Promise<StreamsEventsEnvelope> {\n\t\tconst searchParams = new URLSearchParams();\n\t\tappendSearchParam(searchParams, \"cursor\", params.cursor);\n\t\tappendSearchParam(searchParams, \"from_height\", params.fromHeight);\n\t\tappendSearchParam(searchParams, \"to_height\", params.toHeight);\n\t\tappendSearchParam(searchParams, \"limit\", params.limit);\n\t\tappendSearchParam(searchParams, \"contract_id\", params.contractId);\n\t\tif (params.types?.length) {\n\t\t\tsearchParams.set(\"types\", params.types.join(\",\"));\n\t\t}\n\n\t\tconst query = searchParams.toString();\n\t\treturn request<StreamsEventsEnvelope>(\n\t\t\t`/v1/streams/events${query ? `?${query}` : \"\"}`,\n\t\t);\n\t}\n\n\treturn {\n\t\tevents: {\n\t\t\tlist: listEvents,\n\t\t\tbyTxId(txId: string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/events/${encodeURIComponent(txId)}`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tconsume(params: StreamsEventsConsumeParams) {\n\t\t\t\treturn consumeStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\tmode: params.mode,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t\tonBatch: params.onBatch,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t});\n\t\t\t},\n\t\t\tstream(params: StreamsEventsStreamParams = {}) {\n\t\t\t\treturn streamStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\tblocks: {\n\t\t\tevents(heightOrHash: number | string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/blocks/${encodeURIComponent(String(heightOrHash))}/events`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\treorgs: {\n\t\t\tlist(params: StreamsReorgsListParams) {\n\t\t\t\tconst searchParams = new URLSearchParams();\n\t\t\t\tappendSearchParam(searchParams, \"since\", params.since);\n\t\t\t\tappendSearchParam(searchParams, \"limit\", params.limit);\n\t\t\t\tconst query = searchParams.toString();\n\t\t\t\treturn request<StreamsReorgsListEnvelope>(\n\t\t\t\t\t`/v1/streams/reorgs${query ? `?${query}` : \"\"}`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tcanonical(height: number) {\n\t\t\treturn request<StreamsCanonicalBlock>(`/v1/streams/canonical/${height}`);\n\t\t},\n\t\ttip() {\n\t\t\treturn request<StreamsTip>(\"/v1/streams/tip\");\n\t\t},\n\t};\n}\n",
|
|
13
|
-
"import type {\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionSummary,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\nimport { BaseClient } from \"../base.ts\";\n\nexport type {\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionFormat,\n\tSubscriptionRuntime,\n\tSubscriptionStatus,\n\tSubscriptionSummary,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\n\nexport class Subscriptions extends BaseClient {\n\tasync list(): Promise<{ data: SubscriptionSummary[] }> {\n\t\treturn this.
|
|
13
|
+
"import type {\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionSummary,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\nimport { BaseClient } from \"../base.ts\";\n\nexport type {\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionFormat,\n\tSubscriptionRuntime,\n\tSubscriptionStatus,\n\tSubscriptionSummary,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\n\nexport class Subscriptions extends BaseClient {\n\tasync list(): Promise<{ data: SubscriptionSummary[] }> {\n\t\treturn this.requestAtTenant<{ data: SubscriptionSummary[] }>(\n\t\t\t\"GET\",\n\t\t\t\"/api/subscriptions\",\n\t\t);\n\t}\n\n\tasync get(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.requestAtTenant<SubscriptionDetail>(\n\t\t\t\"GET\",\n\t\t\t`/api/subscriptions/${id}`,\n\t\t);\n\t}\n\n\tasync create(\n\t\tinput: CreateSubscriptionRequest,\n\t): Promise<CreateSubscriptionResponse> {\n\t\treturn this.requestAtTenant<CreateSubscriptionResponse>(\n\t\t\t\"POST\",\n\t\t\t\"/api/subscriptions\",\n\t\t\tinput,\n\t\t);\n\t}\n\n\tasync update(\n\t\tid: string,\n\t\tpatch: UpdateSubscriptionRequest,\n\t): Promise<SubscriptionDetail> {\n\t\treturn this.requestAtTenant<SubscriptionDetail>(\n\t\t\t\"PATCH\",\n\t\t\t`/api/subscriptions/${id}`,\n\t\t\tpatch,\n\t\t);\n\t}\n\n\tasync pause(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.requestAtTenant<SubscriptionDetail>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/pause`,\n\t\t);\n\t}\n\n\tasync resume(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.requestAtTenant<SubscriptionDetail>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/resume`,\n\t\t);\n\t}\n\n\tasync delete(id: string): Promise<{ ok: true }> {\n\t\treturn this.requestAtTenant<{ ok: true }>(\n\t\t\t\"DELETE\",\n\t\t\t`/api/subscriptions/${id}`,\n\t\t);\n\t}\n\n\tasync rotateSecret(id: string): Promise<RotateSecretResponse> {\n\t\treturn this.requestAtTenant<RotateSecretResponse>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/rotate-secret`,\n\t\t);\n\t}\n\n\tasync recentDeliveries(id: string): Promise<{ data: DeliveryRow[] }> {\n\t\treturn this.requestAtTenant<{ data: DeliveryRow[] }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subscriptions/${id}/deliveries`,\n\t\t);\n\t}\n\n\tasync replay(\n\t\tid: string,\n\t\trange: { fromBlock: number; toBlock: number },\n\t): Promise<ReplayResult> {\n\t\treturn this.requestAtTenant<ReplayResult>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/replay`,\n\t\t\trange,\n\t\t);\n\t}\n\n\tasync dead(id: string): Promise<{ data: DeadRow[] }> {\n\t\treturn this.requestAtTenant<{ data: DeadRow[] }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subscriptions/${id}/dead`,\n\t\t);\n\t}\n\n\tasync requeueDead(id: string, outboxId: string): Promise<{ ok: true }> {\n\t\treturn this.requestAtTenant<{ ok: true }>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/dead/${outboxId}/requeue`,\n\t\t);\n\t}\n}\n",
|
|
14
14
|
"import { BaseClient } from \"./base.ts\";\nimport type { SecondLayerOptions } from \"./base.ts\";\nimport { Index } from \"./index-api/client.ts\";\nimport { createStreamsClient } from \"./streams/client.ts\";\nimport type { StreamsClient } from \"./streams/types.ts\";\nimport { Subgraphs } from \"./subgraphs/client.ts\";\nimport { Subscriptions } from \"./subscriptions/client.ts\";\n\nexport class SecondLayer extends BaseClient {\n\treadonly streams: StreamsClient;\n\treadonly index: Index;\n\treadonly subgraphs: Subgraphs;\n\treadonly subscriptions: Subscriptions;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t\tthis.streams = createStreamsClient({\n\t\t\tapiKey: options.apiKey ?? \"\",\n\t\t\tbaseUrl: options.baseUrl,\n\t\t\tfetchImpl: options.fetchImpl,\n\t\t});\n\t\tthis.index = new Index(options);\n\t\tthis.subgraphs = new Subgraphs(options);\n\t\tthis.subscriptions = new Subscriptions(options);\n\t}\n}\n",
|
|
15
15
|
"import type { InferSubgraphClient } from \"@secondlayer/subgraphs\";\nimport type { SecondLayerOptions } from \"../base.ts\";\nimport { SecondLayer } from \"../client.ts\";\nimport { Subgraphs } from \"./client.ts\";\n\n/**\n * Returns a typed client for a subgraph defined with `defineSubgraph()`.\n *\n * Accepts a plain options object, a `SecondLayer` instance, or a `Subgraphs` instance.\n *\n * @example\n * ```ts\n * import mySubgraph from './subgraphs/my-subgraph'\n * import { getSubgraph } from '@secondlayer/sdk'\n *\n * const client = getSubgraph(mySubgraph, { apiKey: 'sl_...' })\n * const rows = await client.transfers.findMany({ where: { sender: 'SP...' } })\n * ```\n */\nexport function getSubgraph<\n\tT extends { name: string; schema: Record<string, unknown> },\n>(\n\tdef: T,\n\toptions: Partial<SecondLayerOptions> | SecondLayer | Subgraphs = {},\n): InferSubgraphClient<T> {\n\tif (options instanceof Subgraphs) {\n\t\treturn options.typed(def);\n\t}\n\tif (options instanceof SecondLayer) {\n\t\treturn options.subgraphs.typed(def);\n\t}\n\treturn new Subgraphs(options).typed(def);\n}\n",
|
|
16
16
|
"import type { StreamsEvent } from \"./types.ts\";\n\nexport type FtTransferPayload = {\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type FtTransferEvent = StreamsEvent & {\n\tevent_type: \"ft_transfer\";\n\tpayload: FtTransferPayload;\n};\n\nexport type DecodedFtTransferPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedFtTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_transfer\";\n\tdecoded_payload: DecodedFtTransferPayload;\n\tsource_cursor: string;\n};\n\nfunction requireString(\n\tpayload: Record<string, unknown>,\n\tfield: keyof FtTransferPayload,\n): string {\n\tconst value = payload[field];\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new Error(`ft_transfer payload missing ${field}`);\n\t}\n\treturn value;\n}\n\nfunction parseAssetIdentifier(assetIdentifier: string): {\n\tcontract_id: string;\n\ttoken_name: string | null;\n} {\n\tconst [contractId, tokenName] = assetIdentifier.split(\"::\");\n\tif (!contractId) {\n\t\tthrow new Error(\"ft_transfer payload has malformed asset_identifier\");\n\t}\n\treturn {\n\t\tcontract_id: contractId,\n\t\ttoken_name: tokenName && tokenName.length > 0 ? tokenName : null,\n\t};\n}\n\nexport function isFtTransfer(event: StreamsEvent): event is FtTransferEvent {\n\treturn event.event_type === \"ft_transfer\";\n}\n\nexport function decodeFtTransfer(event: StreamsEvent): DecodedFtTransfer {\n\tif (!isFtTransfer(event)) {\n\t\tthrow new Error(`Expected ft_transfer event, got ${event.event_type}`);\n\t}\n\n\tconst payload = event.payload;\n\tconst assetIdentifier = requireString(payload, \"asset_identifier\");\n\tconst sender = requireString(payload, \"sender\");\n\tconst recipient = requireString(payload, \"recipient\");\n\tconst amount = requireString(payload, \"amount\");\n\tif (!/^(0|[1-9]\\d*)$/.test(amount)) {\n\t\tthrow new Error(\"ft_transfer payload has malformed amount\");\n\t}\n\n\tconst { contract_id, token_name } = parseAssetIdentifier(assetIdentifier);\n\n\treturn {\n\t\tcursor: event.cursor,\n\t\tblock_height: event.block_height,\n\t\ttx_id: event.tx_id,\n\t\ttx_index: event.tx_index,\n\t\tevent_index: event.event_index,\n\t\tevent_type: event.event_type,\n\t\tdecoded_payload: {\n\t\t\tasset_identifier: assetIdentifier,\n\t\t\tcontract_id: event.contract_id ?? contract_id,\n\t\t\ttoken_name,\n\t\t\tsender,\n\t\t\trecipient,\n\t\t\tamount,\n\t\t},\n\t\tsource_cursor: event.cursor,\n\t};\n}\n",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"export const STREAMS_EVENT_TYPES = [\n\t\"stx_transfer\",\n\t\"stx_mint\",\n\t\"stx_burn\",\n\t\"stx_lock\",\n\t\"ft_transfer\",\n\t\"ft_mint\",\n\t\"ft_burn\",\n\t\"nft_transfer\",\n\t\"nft_mint\",\n\t\"nft_burn\",\n\t\"print\",\n] as const;\n\nexport type StreamsEventType = (typeof STREAMS_EVENT_TYPES)[number];\n\nexport type StreamsEventPayload = Record<string, unknown>;\n\nexport type StreamsEvent = {\n\tcursor: string;\n\tblock_height: number;\n\tindex_block_hash: string;\n\tburn_block_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: StreamsEventType;\n\tcontract_id: string | null;\n\tpayload: StreamsEventPayload;\n\tts: string;\n};\n\nexport type StreamsTip = {\n\tblock_height: number;\n\tindex_block_hash: string;\n\tburn_block_height: number;\n\tlag_seconds: number;\n};\n\nexport type StreamsCanonicalBlock = {\n\tblock_height: number;\n\tindex_block_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string | null;\n\tis_canonical: true;\n};\n\nexport type StreamsReorg = {\n\tdetected_at: string;\n\tfork_point_height: number;\n\torphaned_range: { from: string; to: string };\n\tnew_canonical_tip: string;\n};\n\nexport type StreamsEventsEnvelope = {\n\tevents: StreamsEvent[];\n\tnext_cursor: string | null;\n\ttip: StreamsTip;\n\treorgs: StreamsReorg[];\n};\n\nexport type StreamsEventsListEnvelope = Omit<\n\tStreamsEventsEnvelope,\n\t\"next_cursor\"\n>;\n\nexport type StreamsReorgsListParams = {\n\tsince: string;\n\tlimit?: number;\n};\n\nexport type StreamsReorgsListEnvelope = {\n\treorgs: StreamsReorg[];\n\tnext_since: string | null;\n};\n\nexport type StreamsEventsListParams = {\n\tcursor?: string | null;\n\tfromHeight?: number;\n\ttoHeight?: number;\n\ttypes?: readonly StreamsEventType[];\n\tcontractId?: string;\n\tlimit?: number;\n};\n\nexport type StreamsEventsStreamParams = {\n\tfromCursor?: string | null;\n\ttypes?: readonly StreamsEventType[];\n\tcontractId?: string;\n\tbatchSize?: number;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n};\n\nexport type StreamsEventsConsumeParams = {\n\tfromCursor?: string | null;\n\tmode?: \"tail\" | \"bounded\";\n\ttypes?: readonly StreamsEventType[];\n\tcontractId?: string;\n\tbatchSize?: number;\n\tonBatch: (\n\t\tevents: StreamsEvent[],\n\t\tenvelope: StreamsEventsEnvelope,\n\t) => Promise<string | null | undefined> | string | null | undefined;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n};\n\nexport type StreamsEventsConsumeResult = {\n\tcursor: string | null;\n\tpages: number;\n\temptyPolls: number;\n};\n\nexport type FetchLike = (\n\tinput: string | URL | Request,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nexport type StreamsClient = {\n\tevents: {\n\t\tlist(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>;\n\t\tbyTxId(txId: string): Promise<StreamsEventsListEnvelope>;\n\t\t/**\n\t\t * Pull pages from Streams and call `onBatch` after each page.\n\t\t *\n\t\t * Use `consume` for indexers and ETL jobs that own checkpointing. Return\n\t\t * the checkpoint cursor from `onBatch`. Default `mode: \"tail\"` keeps\n\t\t * polling when caught up; `mode: \"bounded\"` exits on the first empty page.\n\t\t * The consumer also exits when `maxPages`, `maxEmptyPolls`, or `signal`\n\t\t * stops it.\n\t\t */\n\t\tconsume(\n\t\t\tparams: StreamsEventsConsumeParams,\n\t\t): Promise<StreamsEventsConsumeResult>;\n\t\t/**\n\t\t * Follow Streams as an async iterator.\n\t\t *\n\t\t * Use `stream` for live processors and watch-style apps. It tails\n\t\t * indefinitely by default and stops when its `AbortSignal`, `maxPages`, or\n\t\t * `maxEmptyPolls` stops it.\n\t\t */\n\t\tstream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>;\n\t};\n\tblocks: {\n\t\tevents(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>;\n\t};\n\treorgs: {\n\t\tlist(params: StreamsReorgsListParams): Promise<StreamsReorgsListEnvelope>;\n\t};\n\tcanonical(height: number): Promise<StreamsCanonicalBlock>;\n\ttip(): Promise<StreamsTip>;\n};\n",
|
|
19
19
|
"import { verifySignatureHeader } from \"@secondlayer/shared/crypto/hmac\";\n\nexport { verifySignatureHeader };\n\n/**\n * Verify a webhook delivery signature from Secondlayer.\n *\n * Every delivery includes an `x-secondlayer-signature` header in the format\n * `t=<timestamp>,v1=<hmac>`. This function verifies the HMAC and checks\n * the timestamp is within the tolerance window (default 5 minutes).\n *\n * @param rawBody - The raw request body as a string (not parsed JSON)\n * @param signatureHeader - The value of the `x-secondlayer-signature` header\n * @param secret - Your signing secret\n * @param toleranceSeconds - Max age of signature in seconds (default 300)\n * @returns true if the signature is valid\n *\n * @example\n * ```ts\n * import { verifyWebhookSignature } from \"@secondlayer/sdk\";\n *\n * app.post(\"/webhook\", (req, res) => {\n * const sig = req.headers[\"x-secondlayer-signature\"];\n * const raw = JSON.stringify(req.body);\n * if (!verifyWebhookSignature(raw, sig, process.env.SIGNING_SECRET!)) {\n * return res.status(401).send(\"Invalid signature\");\n * }\n * // Process the event...\n * });\n * ```\n */\nexport function verifyWebhookSignature(\n\trawBody: string,\n\tsignatureHeader: string,\n\tsecret: string,\n\ttoleranceSeconds = 300,\n): boolean {\n\treturn verifySignatureHeader(\n\t\trawBody,\n\t\tsignatureHeader,\n\t\tsecret,\n\t\ttoleranceSeconds,\n\t);\n}\n"
|
|
20
20
|
],
|
|
21
|
-
"mappings": ";AAeO,MAAM,iBAAiB,MAAM;AAAA,EAG3B;AAAA,EAGA;AAAA,EALR,WAAW,CAEH,QACP,SAEO,MACN;AAAA,IACD,MAAM,OAAO;AAAA,IALN;AAAA,IAGA;AAAA,IAGP,KAAK,OAAO;AAAA;AAEd;AAAA;AAMO,MAAM,6BAA6B,SAAS;AAAA,EAE1C;AAAA,EACA;AAAA,EAFR,WAAW,CACH,gBACA,iBACP,UAAU,8BAA8B,4BAA4B,kBACnE;AAAA,IACD,MAAM,KAAK,SAAS,EAAE,gBAAgB,gBAAgB,CAAC;AAAA,IAJhD;AAAA,IACA;AAAA,IAIP,KAAK,OAAO;AAAA;AAEd;;;ACvBA,IAAM,mBAAmB;AAAA;AAElB,MAAe,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EAEV,WAAW,CAAC,UAAuC,CAAC,GAAG;AAAA,IACtD,KAAK,WAAW,QAAQ,WAAW,kBAAkB,QAAQ,QAAQ,EAAE;AAAA,IACvE,KAAK,SAAS,QAAQ;AAAA,IACtB,KAAK,SAAS,QAAQ,UAAU;AAAA;AAAA,SAG1B,WAAW,CAAC,QAAyC;AAAA,IAC3D,MAAM,UAAkC;AAAA,MACvC,gBAAgB;AAAA,IACjB;AAAA,IACA,IAAI,QAAQ;AAAA,MACX,QAAQ,gBAAgB,UAAU;AAAA,IACnC;AAAA,IACA,OAAO;AAAA;AAAA,OAGQ,QAAU,CACzB,QACA,MACA,MACa;AAAA,IACb,MAAM,W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ACV,OAAO,sBACN,SACA,iBACA,QACA,gBACD;AAAA;",
|
|
22
|
+
"debugId": "AA41F0EF16B7740B64756E2164756E21",
|
|
23
23
|
"names": []
|
|
24
24
|
}
|
|
@@ -4,10 +4,16 @@ import { SubgraphAgentSchema, SubgraphSpecOptions } from "@secondlayer/shared/su
|
|
|
4
4
|
import { InferSubgraphClient } from "@secondlayer/subgraphs";
|
|
5
5
|
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
6
6
|
interface SecondLayerOptions {
|
|
7
|
-
/** Base URL of the Secondlayer API (trailing slashes are stripped). */
|
|
7
|
+
/** Base URL of the Secondlayer platform API (trailing slashes are stripped). */
|
|
8
8
|
baseUrl: string;
|
|
9
9
|
/** Bearer token for authenticated requests. */
|
|
10
10
|
apiKey?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Explicit tenant API base URL — bypass the auto-resolution that calls
|
|
13
|
+
* `/api/tenants/me` on first tenant-resource request. Use when you already
|
|
14
|
+
* know your tenant URL (OSS, staging, or any custom routing setup).
|
|
15
|
+
*/
|
|
16
|
+
tenantBaseUrl?: string;
|
|
11
17
|
/** Fetch implementation. Tests and edge runtimes can provide their own. */
|
|
12
18
|
fetchImpl?: FetchLike;
|
|
13
19
|
/** Deploy origin label sent as `x-sl-origin` (telemetry). Defaults to `cli`. */
|
|
@@ -17,10 +23,28 @@ declare abstract class BaseClient {
|
|
|
17
23
|
protected baseUrl: string;
|
|
18
24
|
protected apiKey?: string;
|
|
19
25
|
protected origin: "cli" | "mcp" | "session";
|
|
26
|
+
protected tenantBaseUrlOverride?: string;
|
|
27
|
+
private _tenantBaseUrlPromise;
|
|
20
28
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
21
29
|
static authHeaders(apiKey?: string): Record<string, string>;
|
|
22
30
|
protected request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
31
|
+
protected requestAt<T>(baseUrl: string, method: string, path: string, body?: unknown): Promise<T>;
|
|
23
32
|
protected requestText(method: string, path: string, body?: unknown): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve and cache the tenant API base URL for tenant-resource calls
|
|
35
|
+
* (subgraphs, subscriptions). On the platform API, those routes are not
|
|
36
|
+
* mounted — they live on per-tenant containers at
|
|
37
|
+
* `https://<slug>.api.secondlayer.tools`. This method asks
|
|
38
|
+
* `/api/tenants/me` (against the platform baseUrl) for the apiUrl that
|
|
39
|
+
* belongs to the authenticated account.
|
|
40
|
+
*
|
|
41
|
+
* The result is cached on the client instance. Failures are NOT cached, so
|
|
42
|
+
* a flaky platform call doesn't permanently break the SDK.
|
|
43
|
+
*/
|
|
44
|
+
protected getTenantBaseUrl(): Promise<string>;
|
|
45
|
+
private resolveTenantBaseUrl;
|
|
46
|
+
protected requestAtTenant<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
47
|
+
protected requestTextAtTenant(method: string, path: string, body?: unknown): Promise<string>;
|
|
24
48
|
private fetchResponse;
|
|
25
49
|
}
|
|
26
50
|
interface SubgraphSource {
|
package/dist/subgraphs/index.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
class ApiError extends Error {
|
|
3
3
|
status;
|
|
4
4
|
body;
|
|
5
|
-
|
|
5
|
+
code;
|
|
6
|
+
constructor(status, message, body, code) {
|
|
6
7
|
super(message);
|
|
7
8
|
this.status = status;
|
|
8
9
|
this.body = body;
|
|
10
|
+
this.code = code;
|
|
9
11
|
this.name = "ApiError";
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -28,10 +30,13 @@ class BaseClient {
|
|
|
28
30
|
baseUrl;
|
|
29
31
|
apiKey;
|
|
30
32
|
origin;
|
|
33
|
+
tenantBaseUrlOverride;
|
|
34
|
+
_tenantBaseUrlPromise = null;
|
|
31
35
|
constructor(options = {}) {
|
|
32
36
|
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
33
37
|
this.apiKey = options.apiKey;
|
|
34
38
|
this.origin = options.origin ?? "cli";
|
|
39
|
+
this.tenantBaseUrlOverride = options.tenantBaseUrl?.replace(/\/+$/, "");
|
|
35
40
|
}
|
|
36
41
|
static authHeaders(apiKey) {
|
|
37
42
|
const headers = {
|
|
@@ -43,18 +48,53 @@ class BaseClient {
|
|
|
43
48
|
return headers;
|
|
44
49
|
}
|
|
45
50
|
async request(method, path, body) {
|
|
46
|
-
|
|
51
|
+
return this.requestAt(this.baseUrl, method, path, body);
|
|
52
|
+
}
|
|
53
|
+
async requestAt(baseUrl, method, path, body) {
|
|
54
|
+
const response = await this.fetchResponse(baseUrl, method, path, body);
|
|
47
55
|
if (response.status === 204) {
|
|
48
56
|
return;
|
|
49
57
|
}
|
|
50
58
|
return response.json();
|
|
51
59
|
}
|
|
52
60
|
async requestText(method, path, body) {
|
|
53
|
-
const response = await this.fetchResponse(method, path, body);
|
|
61
|
+
const response = await this.fetchResponse(this.baseUrl, method, path, body);
|
|
62
|
+
return response.text();
|
|
63
|
+
}
|
|
64
|
+
getTenantBaseUrl() {
|
|
65
|
+
if (this.tenantBaseUrlOverride) {
|
|
66
|
+
return Promise.resolve(this.tenantBaseUrlOverride);
|
|
67
|
+
}
|
|
68
|
+
if (!this._tenantBaseUrlPromise) {
|
|
69
|
+
this._tenantBaseUrlPromise = this.resolveTenantBaseUrl().catch((err) => {
|
|
70
|
+
this._tenantBaseUrlPromise = null;
|
|
71
|
+
throw err;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return this._tenantBaseUrlPromise;
|
|
75
|
+
}
|
|
76
|
+
async resolveTenantBaseUrl() {
|
|
77
|
+
const body = await this.request("GET", "/api/tenants/me");
|
|
78
|
+
const tenant = body.tenant;
|
|
79
|
+
if (tenant.suspendedAt) {
|
|
80
|
+
throw new ApiError(403, `Tenant ${tenant.slug} is suspended${tenant.limitReason ? `: ${tenant.limitReason}` : ""}.`, body, "TENANT_SUSPENDED");
|
|
81
|
+
}
|
|
82
|
+
if (!tenant.apiUrl) {
|
|
83
|
+
throw new ApiError(404, "No tenant API URL available for this account. Provision a tenant at https://secondlayer.tools/platform.", body, "NO_TENANT");
|
|
84
|
+
}
|
|
85
|
+
return tenant.apiUrl.replace(/\/+$/, "");
|
|
86
|
+
}
|
|
87
|
+
async requestAtTenant(method, path, body) {
|
|
88
|
+
const tenantUrl = await this.getTenantBaseUrl();
|
|
89
|
+
return this.requestAt(tenantUrl, method, path, body);
|
|
90
|
+
}
|
|
91
|
+
async requestTextAtTenant(method, path, body) {
|
|
92
|
+
const tenantUrl = await this.getTenantBaseUrl();
|
|
93
|
+
const response = await this.fetchResponse(tenantUrl, method, path, body);
|
|
54
94
|
return response.text();
|
|
55
95
|
}
|
|
56
|
-
async fetchResponse(method, path, body) {
|
|
57
|
-
const url = `${
|
|
96
|
+
async fetchResponse(baseUrl, method, path, body) {
|
|
97
|
+
const url = `${baseUrl}${path}`;
|
|
58
98
|
const headers = BaseClient.authHeaders(this.apiKey);
|
|
59
99
|
headers["x-sl-origin"] = this.origin;
|
|
60
100
|
let response;
|
|
@@ -65,7 +105,7 @@ class BaseClient {
|
|
|
65
105
|
body: body ? JSON.stringify(body) : undefined
|
|
66
106
|
});
|
|
67
107
|
} catch {
|
|
68
|
-
throw new ApiError(0, `Cannot reach API at ${
|
|
108
|
+
throw new ApiError(0, `Cannot reach API at ${baseUrl}. Check your connection or try again.`);
|
|
69
109
|
}
|
|
70
110
|
if (!response.ok) {
|
|
71
111
|
if (response.status === 401) {
|
|
@@ -77,11 +117,12 @@ class BaseClient {
|
|
|
77
117
|
throw new ApiError(429, msg);
|
|
78
118
|
}
|
|
79
119
|
if (response.status >= 500) {
|
|
80
|
-
throw new ApiError(response.status, `Server error. Try again or check status at ${
|
|
120
|
+
throw new ApiError(response.status, `Server error. Try again or check status at ${baseUrl}/health`);
|
|
81
121
|
}
|
|
82
122
|
const errorBody = await response.text();
|
|
83
123
|
let message = `HTTP ${response.status}`;
|
|
84
124
|
let parsedBody = errorBody;
|
|
125
|
+
let code;
|
|
85
126
|
try {
|
|
86
127
|
const json = JSON.parse(errorBody);
|
|
87
128
|
parsedBody = json;
|
|
@@ -91,11 +132,14 @@ class BaseClient {
|
|
|
91
132
|
} else if (err && typeof err === "object") {
|
|
92
133
|
message = JSON.stringify(err);
|
|
93
134
|
}
|
|
135
|
+
if (typeof json.code === "string") {
|
|
136
|
+
code = json.code;
|
|
137
|
+
}
|
|
94
138
|
} catch {
|
|
95
139
|
if (errorBody)
|
|
96
140
|
message = errorBody;
|
|
97
141
|
}
|
|
98
|
-
throw new ApiError(response.status, message, parsedBody);
|
|
142
|
+
throw new ApiError(response.status, message, parsedBody, code);
|
|
99
143
|
}
|
|
100
144
|
return response;
|
|
101
145
|
}
|
|
@@ -173,28 +217,28 @@ function buildSpecQueryString(options) {
|
|
|
173
217
|
|
|
174
218
|
class Subgraphs extends BaseClient {
|
|
175
219
|
async list() {
|
|
176
|
-
return this.
|
|
220
|
+
return this.requestAtTenant("GET", "/api/subgraphs");
|
|
177
221
|
}
|
|
178
222
|
async get(name) {
|
|
179
|
-
return this.
|
|
223
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}`);
|
|
180
224
|
}
|
|
181
225
|
async openapi(name, options) {
|
|
182
|
-
return this.
|
|
226
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}/openapi.json${buildSpecQueryString(options)}`);
|
|
183
227
|
}
|
|
184
228
|
async schema(name, options) {
|
|
185
|
-
return this.
|
|
229
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}/schema.json${buildSpecQueryString(options)}`);
|
|
186
230
|
}
|
|
187
231
|
async markdown(name, options) {
|
|
188
|
-
return this.
|
|
232
|
+
return this.requestTextAtTenant("GET", `/api/subgraphs/${name}/docs.md${buildSpecQueryString(options)}`);
|
|
189
233
|
}
|
|
190
234
|
async reindex(name, options) {
|
|
191
|
-
return this.
|
|
235
|
+
return this.requestAtTenant("POST", `/api/subgraphs/${name}/reindex`, options);
|
|
192
236
|
}
|
|
193
237
|
async stop(name) {
|
|
194
|
-
return this.
|
|
238
|
+
return this.requestAtTenant("POST", `/api/subgraphs/${name}/stop`);
|
|
195
239
|
}
|
|
196
240
|
async backfill(name, options) {
|
|
197
|
-
return this.
|
|
241
|
+
return this.requestAtTenant("POST", `/api/subgraphs/${name}/backfill`, options);
|
|
198
242
|
}
|
|
199
243
|
async gaps(name, opts) {
|
|
200
244
|
const qs = new URLSearchParams;
|
|
@@ -205,27 +249,27 @@ class Subgraphs extends BaseClient {
|
|
|
205
249
|
if (opts?.resolved !== undefined)
|
|
206
250
|
qs.set("resolved", String(opts.resolved));
|
|
207
251
|
const query = qs.toString();
|
|
208
|
-
return this.
|
|
252
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}/gaps${query ? `?${query}` : ""}`);
|
|
209
253
|
}
|
|
210
254
|
async delete(name, options) {
|
|
211
255
|
const qs = options?.force ? "?force=true" : "";
|
|
212
|
-
return this.
|
|
256
|
+
return this.requestAtTenant("DELETE", `/api/subgraphs/${name}${qs}`);
|
|
213
257
|
}
|
|
214
258
|
async deploy(data) {
|
|
215
|
-
return this.
|
|
259
|
+
return this.requestAtTenant("POST", "/api/subgraphs", data);
|
|
216
260
|
}
|
|
217
261
|
async getSource(name) {
|
|
218
|
-
return this.
|
|
262
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}/source`);
|
|
219
263
|
}
|
|
220
264
|
async bundle(data) {
|
|
221
|
-
return this.
|
|
265
|
+
return this.requestAtTenant("POST", "/api/subgraphs/bundle", data);
|
|
222
266
|
}
|
|
223
267
|
async queryTable(name, table, params = {}) {
|
|
224
|
-
const result = await this.
|
|
268
|
+
const result = await this.requestAtTenant("GET", `/api/subgraphs/${name}/${table}${buildSubgraphQueryString(params)}`);
|
|
225
269
|
return Array.isArray(result) ? result : result.data;
|
|
226
270
|
}
|
|
227
271
|
async queryTableCount(name, table, params = {}) {
|
|
228
|
-
return this.
|
|
272
|
+
return this.requestAtTenant("GET", `/api/subgraphs/${name}/${table}/count${buildSubgraphQueryString(params)}`);
|
|
229
273
|
}
|
|
230
274
|
typed(def) {
|
|
231
275
|
const result = {};
|
|
@@ -648,40 +692,40 @@ function createStreamsClient(options) {
|
|
|
648
692
|
// src/subscriptions/client.ts
|
|
649
693
|
class Subscriptions extends BaseClient {
|
|
650
694
|
async list() {
|
|
651
|
-
return this.
|
|
695
|
+
return this.requestAtTenant("GET", "/api/subscriptions");
|
|
652
696
|
}
|
|
653
697
|
async get(id) {
|
|
654
|
-
return this.
|
|
698
|
+
return this.requestAtTenant("GET", `/api/subscriptions/${id}`);
|
|
655
699
|
}
|
|
656
700
|
async create(input) {
|
|
657
|
-
return this.
|
|
701
|
+
return this.requestAtTenant("POST", "/api/subscriptions", input);
|
|
658
702
|
}
|
|
659
703
|
async update(id, patch) {
|
|
660
|
-
return this.
|
|
704
|
+
return this.requestAtTenant("PATCH", `/api/subscriptions/${id}`, patch);
|
|
661
705
|
}
|
|
662
706
|
async pause(id) {
|
|
663
|
-
return this.
|
|
707
|
+
return this.requestAtTenant("POST", `/api/subscriptions/${id}/pause`);
|
|
664
708
|
}
|
|
665
709
|
async resume(id) {
|
|
666
|
-
return this.
|
|
710
|
+
return this.requestAtTenant("POST", `/api/subscriptions/${id}/resume`);
|
|
667
711
|
}
|
|
668
712
|
async delete(id) {
|
|
669
|
-
return this.
|
|
713
|
+
return this.requestAtTenant("DELETE", `/api/subscriptions/${id}`);
|
|
670
714
|
}
|
|
671
715
|
async rotateSecret(id) {
|
|
672
|
-
return this.
|
|
716
|
+
return this.requestAtTenant("POST", `/api/subscriptions/${id}/rotate-secret`);
|
|
673
717
|
}
|
|
674
718
|
async recentDeliveries(id) {
|
|
675
|
-
return this.
|
|
719
|
+
return this.requestAtTenant("GET", `/api/subscriptions/${id}/deliveries`);
|
|
676
720
|
}
|
|
677
721
|
async replay(id, range) {
|
|
678
|
-
return this.
|
|
722
|
+
return this.requestAtTenant("POST", `/api/subscriptions/${id}/replay`, range);
|
|
679
723
|
}
|
|
680
724
|
async dead(id) {
|
|
681
|
-
return this.
|
|
725
|
+
return this.requestAtTenant("GET", `/api/subscriptions/${id}/dead`);
|
|
682
726
|
}
|
|
683
727
|
async requeueDead(id, outboxId) {
|
|
684
|
-
return this.
|
|
728
|
+
return this.requestAtTenant("POST", `/api/subscriptions/${id}/dead/${outboxId}/requeue`);
|
|
685
729
|
}
|
|
686
730
|
}
|
|
687
731
|
|
|
@@ -719,5 +763,5 @@ export {
|
|
|
719
763
|
Subgraphs
|
|
720
764
|
};
|
|
721
765
|
|
|
722
|
-
//# debugId=
|
|
766
|
+
//# debugId=86B95991163DE2B864756E2164756E21
|
|
723
767
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/errors.ts", "../src/base.ts", "../src/subgraphs/serialize.ts", "../src/subgraphs/client.ts", "../src/index-api/client.ts", "../src/streams/consumer.ts", "../src/streams/errors.ts", "../src/streams/client.ts", "../src/subscriptions/client.ts", "../src/client.ts", "../src/subgraphs/get-subgraph.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Error thrown by {@link SecondLayer} when an API request fails.\n * Includes the HTTP status code for programmatic error handling.\n *\n * @example\n * ```ts\n * try {\n * await client.subgraphs.get(\"my-subgraph\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Subgraph not found\");\n * }\n * }\n * ```\n */\nexport class ApiError extends Error {\n\tconstructor(\n\t\t/** HTTP status code (0 for network errors). */\n\t\tpublic status: number,\n\t\tmessage: string,\n\t\t/** Raw response body (parsed JSON if possible) — preserved for callers that need error details. */\n\t\tpublic body?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n\n/**\n * Thrown on optimistic-concurrency conflict when a deploy supplies an\n * `expectedVersion` that no longer matches the server's stored version.\n */\nexport class VersionConflictError extends ApiError {\n\tconstructor(\n\t\tpublic currentVersion: string,\n\t\tpublic expectedVersion: string,\n\t\tmessage = `Version conflict: expected ${expectedVersion}, current ${currentVersion}`,\n\t) {\n\t\tsuper(409, message, { currentVersion, expectedVersion });\n\t\tthis.name = \"VersionConflictError\";\n\t}\n}\n",
|
|
6
|
-
"import { ApiError } from \"./errors.ts\";\n\nexport type FetchLike = (\n\tinput: string | URL | Request,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nexport interface SecondLayerOptions {\n\t/** Base URL of the Secondlayer API (trailing slashes are stripped). */\n\tbaseUrl: string;\n\t/** Bearer token for authenticated requests. */\n\tapiKey?: string;\n\t/** Fetch implementation. Tests and edge runtimes can provide their own. */\n\tfetchImpl?: FetchLike;\n\t/** Deploy origin label sent as `x-sl-origin` (telemetry). Defaults to `cli`. */\n\torigin?: \"cli\" | \"mcp\" | \"session\";\n}\n\nconst DEFAULT_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport abstract class BaseClient {\n\tprotected baseUrl: string;\n\tprotected apiKey?: string;\n\tprotected origin: \"cli\" | \"mcp\" | \"session\";\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tthis.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n\t\tthis.apiKey = options.apiKey;\n\t\tthis.origin = options.origin ?? \"cli\";\n\t}\n\n\tstatic authHeaders(apiKey?: string): Record<string, string> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t};\n\t\tif (apiKey) {\n\t\t\theaders.Authorization = `Bearer ${apiKey}`;\n\t\t}\n\t\treturn headers;\n\t}\n\n\tprotected async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst response = await this.fetchResponse(method, path, body);\n\n\t\tif (response.status === 204) {\n\t\t\treturn undefined as T;\n\t\t}\n\n\t\treturn response.json() as Promise<T>;\n\t}\n\n\tprotected async requestText(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<string> {\n\t\tconst response = await this.fetchResponse(method, path, body);\n\t\treturn response.text();\n\t}\n\n\tprivate async fetchResponse(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<Response> {\n\t\tconst url = `${
|
|
5
|
+
"/**\n * Error thrown by {@link SecondLayer} when an API request fails.\n * Includes the HTTP status code for programmatic error handling.\n *\n * @example\n * ```ts\n * try {\n * await client.subgraphs.get(\"my-subgraph\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Subgraph not found\");\n * }\n * }\n * ```\n */\nexport class ApiError extends Error {\n\tconstructor(\n\t\t/** HTTP status code (0 for network errors). */\n\t\tpublic status: number,\n\t\tmessage: string,\n\t\t/** Raw response body (parsed JSON if possible) — preserved for callers that need error details. */\n\t\tpublic body?: unknown,\n\t\t/** Stable machine-readable code from the API's `{error, code}` error envelope. */\n\t\tpublic code?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n\n/**\n * Thrown on optimistic-concurrency conflict when a deploy supplies an\n * `expectedVersion` that no longer matches the server's stored version.\n */\nexport class VersionConflictError extends ApiError {\n\tconstructor(\n\t\tpublic currentVersion: string,\n\t\tpublic expectedVersion: string,\n\t\tmessage = `Version conflict: expected ${expectedVersion}, current ${currentVersion}`,\n\t) {\n\t\tsuper(409, message, { currentVersion, expectedVersion });\n\t\tthis.name = \"VersionConflictError\";\n\t}\n}\n",
|
|
6
|
+
"import { ApiError } from \"./errors.ts\";\n\nexport type FetchLike = (\n\tinput: string | URL | Request,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nexport interface SecondLayerOptions {\n\t/** Base URL of the Secondlayer platform API (trailing slashes are stripped). */\n\tbaseUrl: string;\n\t/** Bearer token for authenticated requests. */\n\tapiKey?: string;\n\t/**\n\t * Explicit tenant API base URL — bypass the auto-resolution that calls\n\t * `/api/tenants/me` on first tenant-resource request. Use when you already\n\t * know your tenant URL (OSS, staging, or any custom routing setup).\n\t */\n\ttenantBaseUrl?: string;\n\t/** Fetch implementation. Tests and edge runtimes can provide their own. */\n\tfetchImpl?: FetchLike;\n\t/** Deploy origin label sent as `x-sl-origin` (telemetry). Defaults to `cli`. */\n\torigin?: \"cli\" | \"mcp\" | \"session\";\n}\n\nconst DEFAULT_BASE_URL = \"https://api.secondlayer.tools\";\n\ntype TenantMeResponse = {\n\ttenant: {\n\t\tslug: string;\n\t\tapiUrl: string | null;\n\t\tsuspendedAt: string | null;\n\t\tlimitReason: string | null;\n\t};\n};\n\nexport abstract class BaseClient {\n\tprotected baseUrl: string;\n\tprotected apiKey?: string;\n\tprotected origin: \"cli\" | \"mcp\" | \"session\";\n\tprotected tenantBaseUrlOverride?: string;\n\tprivate _tenantBaseUrlPromise: Promise<string> | null = null;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tthis.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n\t\tthis.apiKey = options.apiKey;\n\t\tthis.origin = options.origin ?? \"cli\";\n\t\tthis.tenantBaseUrlOverride = options.tenantBaseUrl?.replace(/\\/+$/, \"\");\n\t}\n\n\tstatic authHeaders(apiKey?: string): Record<string, string> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t};\n\t\tif (apiKey) {\n\t\t\theaders.Authorization = `Bearer ${apiKey}`;\n\t\t}\n\t\treturn headers;\n\t}\n\n\tprotected async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\treturn this.requestAt<T>(this.baseUrl, method, path, body);\n\t}\n\n\tprotected async requestAt<T>(\n\t\tbaseUrl: string,\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst response = await this.fetchResponse(baseUrl, method, path, body);\n\n\t\tif (response.status === 204) {\n\t\t\treturn undefined as T;\n\t\t}\n\n\t\treturn response.json() as Promise<T>;\n\t}\n\n\tprotected async requestText(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<string> {\n\t\tconst response = await this.fetchResponse(this.baseUrl, method, path, body);\n\t\treturn response.text();\n\t}\n\n\t/**\n\t * Resolve and cache the tenant API base URL for tenant-resource calls\n\t * (subgraphs, subscriptions). On the platform API, those routes are not\n\t * mounted — they live on per-tenant containers at\n\t * `https://<slug>.api.secondlayer.tools`. This method asks\n\t * `/api/tenants/me` (against the platform baseUrl) for the apiUrl that\n\t * belongs to the authenticated account.\n\t *\n\t * The result is cached on the client instance. Failures are NOT cached, so\n\t * a flaky platform call doesn't permanently break the SDK.\n\t */\n\tprotected getTenantBaseUrl(): Promise<string> {\n\t\tif (this.tenantBaseUrlOverride) {\n\t\t\treturn Promise.resolve(this.tenantBaseUrlOverride);\n\t\t}\n\t\tif (!this._tenantBaseUrlPromise) {\n\t\t\tthis._tenantBaseUrlPromise = this.resolveTenantBaseUrl().catch((err) => {\n\t\t\t\tthis._tenantBaseUrlPromise = null;\n\t\t\t\tthrow err;\n\t\t\t});\n\t\t}\n\t\treturn this._tenantBaseUrlPromise;\n\t}\n\n\tprivate async resolveTenantBaseUrl(): Promise<string> {\n\t\tconst body = await this.request<TenantMeResponse>(\"GET\", \"/api/tenants/me\");\n\t\tconst tenant = body.tenant;\n\t\tif (tenant.suspendedAt) {\n\t\t\tthrow new ApiError(\n\t\t\t\t403,\n\t\t\t\t`Tenant ${tenant.slug} is suspended${tenant.limitReason ? `: ${tenant.limitReason}` : \"\"}.`,\n\t\t\t\tbody,\n\t\t\t\t\"TENANT_SUSPENDED\",\n\t\t\t);\n\t\t}\n\t\tif (!tenant.apiUrl) {\n\t\t\tthrow new ApiError(\n\t\t\t\t404,\n\t\t\t\t\"No tenant API URL available for this account. Provision a tenant at https://secondlayer.tools/platform.\",\n\t\t\t\tbody,\n\t\t\t\t\"NO_TENANT\",\n\t\t\t);\n\t\t}\n\t\treturn tenant.apiUrl.replace(/\\/+$/, \"\");\n\t}\n\n\tprotected async requestAtTenant<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst tenantUrl = await this.getTenantBaseUrl();\n\t\treturn this.requestAt<T>(tenantUrl, method, path, body);\n\t}\n\n\tprotected async requestTextAtTenant(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<string> {\n\t\tconst tenantUrl = await this.getTenantBaseUrl();\n\t\tconst response = await this.fetchResponse(tenantUrl, method, path, body);\n\t\treturn response.text();\n\t}\n\n\tprivate async fetchResponse(\n\t\tbaseUrl: string,\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<Response> {\n\t\tconst url = `${baseUrl}${path}`;\n\t\tconst headers = BaseClient.authHeaders(this.apiKey);\n\t\theaders[\"x-sl-origin\"] = this.origin;\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await fetch(url, {\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\tbody: body ? JSON.stringify(body) : undefined,\n\t\t\t});\n\t\t} catch {\n\t\t\tthrow new ApiError(\n\t\t\t\t0,\n\t\t\t\t`Cannot reach API at ${baseUrl}. Check your connection or try again.`,\n\t\t\t);\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status === 401) {\n\t\t\t\tthrow new ApiError(401, \"API key invalid or expired.\");\n\t\t\t}\n\n\t\t\tif (response.status === 429) {\n\t\t\t\tconst retryAfter = response.headers.get(\"Retry-After\");\n\t\t\t\tconst msg = retryAfter\n\t\t\t\t\t? `Rate limited. Wait ${retryAfter} seconds.`\n\t\t\t\t\t: \"Rate limited. Try again later.\";\n\t\t\t\tthrow new ApiError(429, msg);\n\t\t\t}\n\n\t\t\tif (response.status >= 500) {\n\t\t\t\tthrow new ApiError(\n\t\t\t\t\tresponse.status,\n\t\t\t\t\t`Server error. Try again or check status at ${baseUrl}/health`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst errorBody = await response.text();\n\t\t\tlet message = `HTTP ${response.status}`;\n\t\t\tlet parsedBody: unknown = errorBody;\n\t\t\tlet code: string | undefined;\n\t\t\ttry {\n\t\t\t\tconst json = JSON.parse(errorBody);\n\t\t\t\tparsedBody = json;\n\t\t\t\tconst err = json.error ?? json.message;\n\t\t\t\tif (typeof err === \"string\") {\n\t\t\t\t\tmessage = err;\n\t\t\t\t} else if (err && typeof err === \"object\") {\n\t\t\t\t\tmessage = JSON.stringify(err);\n\t\t\t\t}\n\t\t\t\tif (typeof json.code === \"string\") {\n\t\t\t\t\tcode = json.code;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tif (errorBody) message = errorBody;\n\t\t\t}\n\t\t\tthrow new ApiError(response.status, message, parsedBody, code);\n\t\t}\n\n\t\treturn response;\n\t}\n}\n",
|
|
7
7
|
"/**\n * Maps camelCase system column names (with or without `_` prefix) to the\n * actual snake_case DB column names used in query params.\n */\nconst SYSTEM_COLUMN_MAP: Record<string, string> = {\n\t// underscore-prefixed camelCase (canonical row shape)\n\t_blockHeight: \"_block_height\",\n\t_txId: \"_tx_id\",\n\t_createdAt: \"_created_at\",\n\t_id: \"_id\",\n\t// no-prefix aliases\n\tblockHeight: \"_block_height\",\n\ttxId: \"_tx_id\",\n\tcreatedAt: \"_created_at\",\n\tid: \"_id\",\n};\n\nfunction resolveColumn(col: string): string {\n\treturn SYSTEM_COLUMN_MAP[col] ?? col;\n}\n\n/**\n * Serializes a WhereInput object into the flat filter map expected by\n * SubgraphQueryParams.filters (and the REST API query string).\n *\n * Scalar values → `{ column: \"value\" }`\n * Comparison objects → `{ \"column.gte\": \"100\", \"column.lt\": \"200\" }`\n * System column aliases → `blockHeight` / `_blockHeight` both → `_block_height`\n */\nexport function serializeWhere(\n\twhere: Record<string, unknown>,\n): Record<string, string> {\n\tconst filters: Record<string, string> = {};\n\n\tfor (const [column, value] of Object.entries(where)) {\n\t\tif (value === null || value === undefined) continue;\n\n\t\tconst col = resolveColumn(column);\n\n\t\tif (typeof value === \"object\" && !Array.isArray(value)) {\n\t\t\tconst ops = value as Record<string, unknown>;\n\t\t\tfor (const [op, opValue] of Object.entries(ops)) {\n\t\t\t\tif (opValue === null || opValue === undefined) continue;\n\t\t\t\tif (op === \"eq\") {\n\t\t\t\t\tfilters[col] = String(opValue);\n\t\t\t\t} else if ([\"neq\", \"gt\", \"gte\", \"lt\", \"lte\"].includes(op)) {\n\t\t\t\t\tfilters[`${col}.${op}`] = String(opValue);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfilters[col] = String(value);\n\t\t}\n\t}\n\n\treturn filters;\n}\n\n/**\n * Resolves an orderBy column name (either alias or canonical) to the DB column name.\n */\nexport function resolveOrderByColumn(col: string): string {\n\treturn resolveColumn(col);\n}\n",
|
|
8
|
-
"import type {\n\tReindexResponse,\n\tSubgraphDetail,\n\tSubgraphGapsResponse,\n\tSubgraphQueryParams,\n\tSubgraphSummary,\n} from \"@secondlayer/shared/schemas\";\nimport type {\n\tDeploySubgraphRequest,\n\tDeploySubgraphResponse,\n} from \"@secondlayer/shared/schemas/subgraphs\";\nimport type {\n\tSubgraphAgentSchema,\n\tSubgraphSpecOptions,\n} from \"@secondlayer/shared/subgraphs/spec\";\nimport type {\n\tFindManyOptions,\n\tInferSubgraphClient,\n\tWhereInput,\n} from \"@secondlayer/subgraphs\";\nimport { BaseClient } from \"../base.ts\";\nimport { resolveOrderByColumn, serializeWhere } from \"./serialize.ts\";\n\nexport interface SubgraphSource {\n\tname: string;\n\tversion: string;\n\tsourceCode: string | null;\n\treadOnly: boolean;\n\treason?: string;\n\tupdatedAt: string;\n}\n\nexport interface BundleSubgraphResponse {\n\tok: true;\n\tname: string;\n\tversion: string | null;\n\tdescription: string | null;\n\tsources: Record<string, Record<string, unknown>>;\n\tschema: Record<string, unknown>;\n\thandlerCode: string;\n\tsourceCode: string;\n\tbundleSize: number;\n}\n\nfunction buildSubgraphQueryString(params: SubgraphQueryParams): string {\n\tconst qs = new URLSearchParams();\n\tif (params.sort) qs.set(\"_sort\", params.sort);\n\tif (params.order) qs.set(\"_order\", params.order);\n\tif (params.limit !== undefined) qs.set(\"_limit\", String(params.limit));\n\tif (params.offset !== undefined) qs.set(\"_offset\", String(params.offset));\n\tif (params.fields) qs.set(\"_fields\", params.fields);\n\tif (params.filters) {\n\t\tfor (const [key, value] of Object.entries(params.filters)) {\n\t\t\tqs.set(key, String(value));\n\t\t}\n\t}\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nfunction buildSpecQueryString(options?: SubgraphSpecOptions): string {\n\tconst qs = new URLSearchParams();\n\tif (options?.serverUrl) qs.set(\"server\", options.serverUrl);\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nexport class Subgraphs extends BaseClient {\n\tasync list(): Promise<{ data: SubgraphSummary[] }> {\n\t\treturn this.
|
|
8
|
+
"import type {\n\tReindexResponse,\n\tSubgraphDetail,\n\tSubgraphGapsResponse,\n\tSubgraphQueryParams,\n\tSubgraphSummary,\n} from \"@secondlayer/shared/schemas\";\nimport type {\n\tDeploySubgraphRequest,\n\tDeploySubgraphResponse,\n} from \"@secondlayer/shared/schemas/subgraphs\";\nimport type {\n\tSubgraphAgentSchema,\n\tSubgraphSpecOptions,\n} from \"@secondlayer/shared/subgraphs/spec\";\nimport type {\n\tFindManyOptions,\n\tInferSubgraphClient,\n\tWhereInput,\n} from \"@secondlayer/subgraphs\";\nimport { BaseClient } from \"../base.ts\";\nimport { resolveOrderByColumn, serializeWhere } from \"./serialize.ts\";\n\nexport interface SubgraphSource {\n\tname: string;\n\tversion: string;\n\tsourceCode: string | null;\n\treadOnly: boolean;\n\treason?: string;\n\tupdatedAt: string;\n}\n\nexport interface BundleSubgraphResponse {\n\tok: true;\n\tname: string;\n\tversion: string | null;\n\tdescription: string | null;\n\tsources: Record<string, Record<string, unknown>>;\n\tschema: Record<string, unknown>;\n\thandlerCode: string;\n\tsourceCode: string;\n\tbundleSize: number;\n}\n\nfunction buildSubgraphQueryString(params: SubgraphQueryParams): string {\n\tconst qs = new URLSearchParams();\n\tif (params.sort) qs.set(\"_sort\", params.sort);\n\tif (params.order) qs.set(\"_order\", params.order);\n\tif (params.limit !== undefined) qs.set(\"_limit\", String(params.limit));\n\tif (params.offset !== undefined) qs.set(\"_offset\", String(params.offset));\n\tif (params.fields) qs.set(\"_fields\", params.fields);\n\tif (params.filters) {\n\t\tfor (const [key, value] of Object.entries(params.filters)) {\n\t\t\tqs.set(key, String(value));\n\t\t}\n\t}\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nfunction buildSpecQueryString(options?: SubgraphSpecOptions): string {\n\tconst qs = new URLSearchParams();\n\tif (options?.serverUrl) qs.set(\"server\", options.serverUrl);\n\tconst str = qs.toString();\n\treturn str ? `?${str}` : \"\";\n}\n\nexport class Subgraphs extends BaseClient {\n\tasync list(): Promise<{ data: SubgraphSummary[] }> {\n\t\treturn this.requestAtTenant<{ data: SubgraphSummary[] }>(\n\t\t\t\"GET\",\n\t\t\t\"/api/subgraphs\",\n\t\t);\n\t}\n\n\tasync get(name: string): Promise<SubgraphDetail> {\n\t\treturn this.requestAtTenant<SubgraphDetail>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}`,\n\t\t);\n\t}\n\n\tasync openapi(\n\t\tname: string,\n\t\toptions?: SubgraphSpecOptions,\n\t): Promise<Record<string, unknown>> {\n\t\treturn this.requestAtTenant<Record<string, unknown>>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/openapi.json${buildSpecQueryString(options)}`,\n\t\t);\n\t}\n\n\tasync schema(\n\t\tname: string,\n\t\toptions?: SubgraphSpecOptions,\n\t): Promise<SubgraphAgentSchema> {\n\t\treturn this.requestAtTenant<SubgraphAgentSchema>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/schema.json${buildSpecQueryString(options)}`,\n\t\t);\n\t}\n\n\tasync markdown(name: string, options?: SubgraphSpecOptions): Promise<string> {\n\t\treturn this.requestTextAtTenant(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/docs.md${buildSpecQueryString(options)}`,\n\t\t);\n\t}\n\n\tasync reindex(\n\t\tname: string,\n\t\toptions?: { fromBlock?: number; toBlock?: number },\n\t): Promise<ReindexResponse> {\n\t\treturn this.requestAtTenant<ReindexResponse>(\n\t\t\t\"POST\",\n\t\t\t`/api/subgraphs/${name}/reindex`,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync stop(\n\t\tname: string,\n\t): Promise<{ message: string; operationId?: string; status?: string }> {\n\t\treturn this.requestAtTenant<{\n\t\t\tmessage: string;\n\t\t\toperationId?: string;\n\t\t\tstatus?: string;\n\t\t}>(\"POST\", `/api/subgraphs/${name}/stop`);\n\t}\n\n\tasync backfill(\n\t\tname: string,\n\t\toptions: { fromBlock: number; toBlock: number },\n\t): Promise<ReindexResponse> {\n\t\treturn this.requestAtTenant<ReindexResponse>(\n\t\t\t\"POST\",\n\t\t\t`/api/subgraphs/${name}/backfill`,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync gaps(\n\t\tname: string,\n\t\topts?: { limit?: number; offset?: number; resolved?: boolean },\n\t): Promise<SubgraphGapsResponse> {\n\t\tconst qs = new URLSearchParams();\n\t\tif (opts?.limit !== undefined) qs.set(\"_limit\", String(opts.limit));\n\t\tif (opts?.offset !== undefined) qs.set(\"_offset\", String(opts.offset));\n\t\tif (opts?.resolved !== undefined) qs.set(\"resolved\", String(opts.resolved));\n\t\tconst query = qs.toString();\n\t\treturn this.requestAtTenant<SubgraphGapsResponse>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/gaps${query ? `?${query}` : \"\"}`,\n\t\t);\n\t}\n\n\tasync delete(\n\t\tname: string,\n\t\toptions?: { force?: boolean },\n\t): Promise<{ message: string }> {\n\t\tconst qs = options?.force ? \"?force=true\" : \"\";\n\t\treturn this.requestAtTenant<{ message: string }>(\n\t\t\t\"DELETE\",\n\t\t\t`/api/subgraphs/${name}${qs}`,\n\t\t);\n\t}\n\n\tasync deploy(data: DeploySubgraphRequest): Promise<DeploySubgraphResponse> {\n\t\treturn this.requestAtTenant<DeploySubgraphResponse>(\n\t\t\t\"POST\",\n\t\t\t\"/api/subgraphs\",\n\t\t\tdata,\n\t\t);\n\t}\n\n\tasync getSource(name: string): Promise<SubgraphSource> {\n\t\treturn this.requestAtTenant<SubgraphSource>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/source`,\n\t\t);\n\t}\n\n\t/**\n\t * Bundle a TypeScript subgraph source on the server. Used by the web chat\n\t * authoring loop so Vercel's serverless runtime doesn't have to run esbuild.\n\t */\n\tasync bundle(data: { code: string }): Promise<BundleSubgraphResponse> {\n\t\treturn this.requestAtTenant<BundleSubgraphResponse>(\n\t\t\t\"POST\",\n\t\t\t\"/api/subgraphs/bundle\",\n\t\t\tdata,\n\t\t);\n\t}\n\n\tasync queryTable(\n\t\tname: string,\n\t\ttable: string,\n\t\tparams: SubgraphQueryParams = {},\n\t): Promise<unknown[]> {\n\t\tconst result = await this.requestAtTenant<{ data: unknown[] } | unknown[]>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/${table}${buildSubgraphQueryString(params)}`,\n\t\t);\n\t\treturn Array.isArray(result) ? result : result.data;\n\t}\n\n\tasync queryTableCount(\n\t\tname: string,\n\t\ttable: string,\n\t\tparams: SubgraphQueryParams = {},\n\t): Promise<{ count: number }> {\n\t\treturn this.requestAtTenant<{ count: number }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subgraphs/${name}/${table}/count${buildSubgraphQueryString(params)}`,\n\t\t);\n\t}\n\n\t/**\n\t * Returns a typed client for a subgraph defined with `defineSubgraph()`.\n\t * Row types are inferred from the subgraph's schema literal types.\n\t *\n\t * @example\n\t * ```ts\n\t * import mySubgraph from './subgraphs/my-token-subgraph'\n\t * const client = sl.subgraphs.typed(mySubgraph)\n\t * const rows = await client.transfers.findMany({ where: { sender: 'SP...' } })\n\t * // rows: InferTableRow<typeof mySubgraph.schema.transfers>[]\n\t * ```\n\t */\n\ttyped<T extends { name: string; schema: Record<string, unknown> }>(\n\t\tdef: T,\n\t): InferSubgraphClient<T> {\n\t\tconst result: Record<string, unknown> = {};\n\n\t\tfor (const tableName of Object.keys(def.schema)) {\n\t\t\tresult[tableName] = this.createTableClient(def.name, tableName);\n\t\t}\n\n\t\treturn result as InferSubgraphClient<T>;\n\t}\n\n\tprivate createTableClient(subgraphName: string, tableName: string) {\n\t\tconst self = this;\n\n\t\treturn {\n\t\t\tasync findMany<TRow>(\n\t\t\t\toptions: FindManyOptions<TRow> = {},\n\t\t\t): Promise<TRow[]> {\n\t\t\t\tconst filters = options.where\n\t\t\t\t\t? serializeWhere(options.where as Record<string, unknown>)\n\t\t\t\t\t: undefined;\n\n\t\t\t\tlet sort: string | undefined;\n\t\t\t\tlet order: string | undefined;\n\t\t\t\tif (options.orderBy) {\n\t\t\t\t\tconst entries = Object.entries(options.orderBy) as [\n\t\t\t\t\t\tstring,\n\t\t\t\t\t\t\"asc\" | \"desc\",\n\t\t\t\t\t][];\n\t\t\t\t\tif (entries.length > 0) {\n\t\t\t\t\t\tif (entries.length > 1) {\n\t\t\t\t\t\t\tconst extra = entries\n\t\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t\t.map(([col]) => col)\n\t\t\t\t\t\t\t\t.join(\", \");\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`orderBy supports only one column; remove extra keys: ${extra}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst first = entries[0];\n\t\t\t\t\t\tif (first) {\n\t\t\t\t\t\t\tconst [col, dir] = first;\n\t\t\t\t\t\t\tsort = resolveOrderByColumn(col);\n\t\t\t\t\t\t\torder = dir ?? \"asc\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst params: SubgraphQueryParams = {\n\t\t\t\t\tsort,\n\t\t\t\t\torder,\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t\toffset: options.offset,\n\t\t\t\t\tfields: options.fields?.join(\",\"),\n\t\t\t\t\tfilters,\n\t\t\t\t};\n\n\t\t\t\treturn self.queryTable(subgraphName, tableName, params) as Promise<\n\t\t\t\t\tTRow[]\n\t\t\t\t>;\n\t\t\t},\n\n\t\t\tasync count<TRow>(where?: WhereInput<TRow>): Promise<number> {\n\t\t\t\tconst filters = where\n\t\t\t\t\t? serializeWhere(where as Record<string, unknown>)\n\t\t\t\t\t: undefined;\n\n\t\t\t\tconst result = await self.queryTableCount(subgraphName, tableName, {\n\t\t\t\t\tfilters,\n\t\t\t\t});\n\t\t\t\treturn result.count;\n\t\t\t},\n\t\t};\n\t}\n}\n",
|
|
9
9
|
"import { BaseClient } from \"../base.ts\";\nimport type { SecondLayerOptions } from \"../base.ts\";\n\nexport type IndexTip = {\n\tblock_height: number;\n\tlag_seconds: number;\n};\n\nexport type FtTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_transfer\";\n\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type FtTransfersEnvelope = {\n\tevents: FtTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Reserved envelope field. v1 currently always emits [].\n\treorgs: never[];\n};\n\nexport type FtTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type FtTransfersWalkParams = Omit<FtTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nexport type NftTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_transfer\";\n\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type NftTransfersEnvelope = {\n\tevents: NftTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Reserved envelope field. v1 currently always emits [].\n\treorgs: never[];\n};\n\nexport type NftTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tassetIdentifier?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type NftTransfersWalkParams = Omit<NftTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nfunction appendSearchParam(\n\tparams: URLSearchParams,\n\tname: string,\n\tvalue: number | string | null | undefined,\n): void {\n\tif (value === undefined || value === null) return;\n\tparams.set(name, String(value));\n}\n\nfunction firstWalkFromHeight(params: {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tfromHeight?: number;\n}): number | undefined {\n\tif (params.fromHeight !== undefined) return params.fromHeight;\n\tif (params.cursor || params.fromCursor) return undefined;\n\treturn 0;\n}\n\nexport class Index extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\treadonly ftTransfers: {\n\t\tlist: (params?: FtTransfersListParams) => Promise<FtTransfersEnvelope>;\n\t\twalk: (params?: FtTransfersWalkParams) => AsyncIterable<FtTransfer>;\n\t} = {\n\t\tlist: (params: FtTransfersListParams = {}): Promise<FtTransfersEnvelope> =>\n\t\t\tthis.listFtTransfers(params),\n\t\twalk: (params: FtTransfersWalkParams = {}): AsyncIterable<FtTransfer> =>\n\t\t\tthis.walkFtTransfers(params),\n\t};\n\n\treadonly nftTransfers: {\n\t\tlist: (params?: NftTransfersListParams) => Promise<NftTransfersEnvelope>;\n\t\twalk: (params?: NftTransfersWalkParams) => AsyncIterable<NftTransfer>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: NftTransfersListParams = {},\n\t\t): Promise<NftTransfersEnvelope> => this.listNftTransfers(params),\n\t\twalk: (params: NftTransfersWalkParams = {}): AsyncIterable<NftTransfer> =>\n\t\t\tthis.walkNftTransfers(params),\n\t};\n\n\tprivate async listFtTransfers(\n\t\tparams: FtTransfersListParams = {},\n\t): Promise<FtTransfersEnvelope> {\n\t\tconst searchParams = new URLSearchParams();\n\t\tappendSearchParam(searchParams, \"cursor\", params.cursor);\n\t\tappendSearchParam(searchParams, \"from_cursor\", params.fromCursor);\n\t\tappendSearchParam(searchParams, \"limit\", params.limit);\n\t\tappendSearchParam(searchParams, \"contract_id\", params.contractId);\n\t\tappendSearchParam(searchParams, \"sender\", params.sender);\n\t\tappendSearchParam(searchParams, \"recipient\", params.recipient);\n\t\tappendSearchParam(searchParams, \"from_height\", params.fromHeight);\n\t\tappendSearchParam(searchParams, \"to_height\", params.toHeight);\n\n\t\tconst query = searchParams.toString();\n\t\treturn this.request<FtTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/ft-transfers${query ? `?${query}` : \"\"}`,\n\t\t);\n\t}\n\n\tprivate async listNftTransfers(\n\t\tparams: NftTransfersListParams = {},\n\t): Promise<NftTransfersEnvelope> {\n\t\tconst searchParams = new URLSearchParams();\n\t\tappendSearchParam(searchParams, \"cursor\", params.cursor);\n\t\tappendSearchParam(searchParams, \"from_cursor\", params.fromCursor);\n\t\tappendSearchParam(searchParams, \"limit\", params.limit);\n\t\tappendSearchParam(searchParams, \"contract_id\", params.contractId);\n\t\tappendSearchParam(searchParams, \"asset_identifier\", params.assetIdentifier);\n\t\tappendSearchParam(searchParams, \"sender\", params.sender);\n\t\tappendSearchParam(searchParams, \"recipient\", params.recipient);\n\t\tappendSearchParam(searchParams, \"from_height\", params.fromHeight);\n\t\tappendSearchParam(searchParams, \"to_height\", params.toHeight);\n\n\t\tconst query = searchParams.toString();\n\t\treturn this.request<NftTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/nft-transfers${query ? `?${query}` : \"\"}`,\n\t\t);\n\t}\n\n\tprivate async *walkFtTransfers(\n\t\tparams: FtTransfersWalkParams = {},\n\t): AsyncGenerator<FtTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listFtTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async *walkNftTransfers(\n\t\tparams: NftTransfersWalkParams = {},\n\t): AsyncGenerator<NftTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listNftTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n}\n",
|
|
10
10
|
"import type {\n\tStreamsEvent,\n\tStreamsEventType,\n\tStreamsEventsEnvelope,\n} from \"./types.ts\";\n\ntype StreamsEventsFetchParams = {\n\tcursor?: string | null;\n\tlimit: number;\n\ttypes?: readonly StreamsEventType[];\n\tcontractId?: string;\n};\n\nexport type StreamsEventsFetcher = (\n\tparams: StreamsEventsFetchParams,\n) => Promise<StreamsEventsEnvelope>;\n\nexport type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;\n\nexport async function defaultSleep(\n\tms: number,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tif (signal?.aborted) return;\n\n\tawait new Promise<void>((resolve) => {\n\t\tconst timeout = setTimeout(resolve, ms);\n\t\tif (!signal) return;\n\t\tsignal.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tresolve();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t});\n}\n\nexport async function consumeStreamsEvents(opts: {\n\tfromCursor?: string | null;\n\tmode?: \"tail\" | \"bounded\";\n\tbatchSize: number;\n\ttypes?: readonly StreamsEventType[];\n\tcontractId?: string;\n\tfetchEvents: StreamsEventsFetcher;\n\tonBatch: (\n\t\tevents: StreamsEvent[],\n\t\tenvelope: StreamsEventsEnvelope,\n\t) => Promise<string | null | undefined> | string | null | undefined;\n\tsleep?: Sleep;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n}): Promise<{ cursor: string | null; pages: number; emptyPolls: number }> {\n\tconst sleep = opts.sleep ?? defaultSleep;\n\tconst mode = opts.mode ?? \"tail\";\n\tconst emptyBackoffMs = opts.emptyBackoffMs ?? 500;\n\tconst maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;\n\tconst maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;\n\tlet cursor = opts.fromCursor ?? null;\n\tlet pages = 0;\n\tlet emptyPolls = 0;\n\n\twhile (\n\t\tpages < maxPages &&\n\t\temptyPolls < maxEmptyPolls &&\n\t\t!opts.signal?.aborted\n\t) {\n\t\tconst envelope = await opts.fetchEvents({\n\t\t\tcursor,\n\t\t\tlimit: opts.batchSize,\n\t\t\ttypes: opts.types,\n\t\t\tcontractId: opts.contractId,\n\t\t});\n\t\tpages++;\n\n\t\tconst returnedCursor = await opts.onBatch(envelope.events, envelope);\n\t\tconst nextCursor = returnedCursor ?? envelope.next_cursor;\n\n\t\tif (nextCursor && nextCursor !== cursor) {\n\t\t\tcursor = nextCursor;\n\t\t\temptyPolls = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (envelope.events.length === 0) {\n\t\t\temptyPolls++;\n\t\t\tif (mode === \"bounded\") {\n\t\t\t\treturn { cursor, pages, emptyPolls };\n\t\t\t}\n\t\t\tawait sleep(emptyBackoffMs, opts.signal);\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn { cursor, pages, emptyPolls };\n\t}\n\n\treturn { cursor, pages, emptyPolls };\n}\n\nexport async function* streamStreamsEvents(opts: {\n\tfromCursor?: string | null;\n\tbatchSize: number;\n\ttypes?: readonly StreamsEventType[];\n\tcontractId?: string;\n\tfetchEvents: StreamsEventsFetcher;\n\tsleep?: Sleep;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n}): AsyncGenerator<StreamsEvent> {\n\tconst sleep = opts.sleep ?? defaultSleep;\n\tconst emptyBackoffMs = opts.emptyBackoffMs ?? 500;\n\tconst maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;\n\tconst maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;\n\tlet cursor = opts.fromCursor ?? null;\n\tlet pages = 0;\n\tlet emptyPolls = 0;\n\n\twhile (\n\t\tpages < maxPages &&\n\t\temptyPolls < maxEmptyPolls &&\n\t\t!opts.signal?.aborted\n\t) {\n\t\tconst envelope = await opts.fetchEvents({\n\t\t\tcursor,\n\t\t\tlimit: opts.batchSize,\n\t\t\ttypes: opts.types,\n\t\t\tcontractId: opts.contractId,\n\t\t});\n\t\tpages++;\n\n\t\tfor (const event of envelope.events) {\n\t\t\tif (opts.signal?.aborted) return;\n\t\t\tyield event;\n\t\t}\n\n\t\tconst nextCursor = envelope.next_cursor;\n\t\tif (nextCursor && nextCursor !== cursor) {\n\t\t\tcursor = nextCursor;\n\t\t\temptyPolls = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (envelope.events.length === 0) {\n\t\t\temptyPolls++;\n\t\t\tif (emptyPolls >= maxEmptyPolls || pages >= maxPages) return;\n\t\t\tawait sleep(emptyBackoffMs, opts.signal);\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn;\n\t}\n}\n",
|
|
11
11
|
"export class AuthError extends Error {\n\treadonly status = 401;\n\n\tconstructor(message = \"API key invalid or expired.\") {\n\t\tsuper(message);\n\t\tthis.name = \"AuthError\";\n\t}\n}\n\nexport class RateLimitError extends Error {\n\treadonly status = 429;\n\n\tconstructor(\n\t\tmessage = \"Rate limited. Try again later.\",\n\t\treadonly retryAfter?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"RateLimitError\";\n\t}\n}\n\nexport class ValidationError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly status: number,\n\t\treadonly body?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ValidationError\";\n\t}\n}\n\nexport class StreamsServerError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly status: number,\n\t\treadonly body?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"StreamsServerError\";\n\t}\n}\n",
|
|
12
12
|
"import {\n\ttype StreamsEventsFetcher,\n\tconsumeStreamsEvents,\n\tstreamStreamsEvents,\n} from \"./consumer.ts\";\nimport {\n\tAuthError,\n\tRateLimitError,\n\tStreamsServerError,\n\tValidationError,\n} from \"./errors.ts\";\nimport type {\n\tFetchLike,\n\tStreamsCanonicalBlock,\n\tStreamsClient,\n\tStreamsEventsConsumeParams,\n\tStreamsEventsEnvelope,\n\tStreamsEventsListEnvelope,\n\tStreamsEventsListParams,\n\tStreamsEventsStreamParams,\n\tStreamsReorgsListEnvelope,\n\tStreamsReorgsListParams,\n\tStreamsTip,\n} from \"./types.ts\";\n\nconst DEFAULT_STREAMS_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport type CreateStreamsClientOptions = {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetchImpl?: FetchLike;\n};\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n\treturn baseUrl.replace(/\\/+$/, \"\");\n}\n\nfunction appendSearchParam(\n\tparams: URLSearchParams,\n\tname: string,\n\tvalue: number | string | null | undefined,\n): void {\n\tif (value === undefined || value === null) return;\n\tparams.set(name, String(value));\n}\n\nasync function responseBody(response: Response): Promise<unknown> {\n\tconst text = await response.text();\n\tif (text.length === 0) return undefined;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch {\n\t\treturn text;\n\t}\n}\n\nfunction errorMessage(body: unknown, fallback: string): string {\n\tif (body && typeof body === \"object\") {\n\t\tconst record = body as Record<string, unknown>;\n\t\tconst message = record.error ?? record.message;\n\t\tif (typeof message === \"string\" && message.length > 0) return message;\n\t}\n\tif (typeof body === \"string\" && body.length > 0) return body;\n\treturn fallback;\n}\n\nasync function mapStreamsError(response: Response): Promise<never> {\n\tconst body = await responseBody(response);\n\n\tif (response.status === 401) {\n\t\tthrow new AuthError(errorMessage(body, \"API key invalid or expired.\"));\n\t}\n\n\tif (response.status === 429) {\n\t\tconst retryAfter = response.headers.get(\"Retry-After\") ?? undefined;\n\t\tthrow new RateLimitError(\n\t\t\terrorMessage(body, \"Rate limited. Try again later.\"),\n\t\t\tretryAfter,\n\t\t);\n\t}\n\n\tif (response.status >= 500) {\n\t\tthrow new StreamsServerError(\n\t\t\terrorMessage(body, `Streams server returned ${response.status}.`),\n\t\t\tresponse.status,\n\t\t\tbody,\n\t\t);\n\t}\n\n\tthrow new ValidationError(\n\t\terrorMessage(body, `Streams request returned ${response.status}.`),\n\t\tresponse.status,\n\t\tbody,\n\t);\n}\n\nexport function createStreamsClient(\n\toptions: CreateStreamsClientOptions,\n): StreamsClient {\n\tconst baseUrl = normalizeBaseUrl(options.baseUrl ?? DEFAULT_STREAMS_BASE_URL);\n\tconst fetchImpl = options.fetchImpl ?? ((input, init) => fetch(input, init));\n\n\tasync function request<T>(path: string): Promise<T> {\n\t\tconst response = await fetchImpl(`${baseUrl}${path}`, {\n\t\t\theaders: { Authorization: `Bearer ${options.apiKey}` },\n\t\t});\n\t\tif (!response.ok) await mapStreamsError(response);\n\t\treturn (await response.json()) as T;\n\t}\n\n\tconst fetchEvents: StreamsEventsFetcher = async ({\n\t\tcursor,\n\t\tlimit,\n\t\ttypes,\n\t\tcontractId,\n\t}) => {\n\t\treturn listEvents({ cursor, limit, types, contractId });\n\t};\n\n\tasync function listEvents(\n\t\tparams: StreamsEventsListParams = {},\n\t): Promise<StreamsEventsEnvelope> {\n\t\tconst searchParams = new URLSearchParams();\n\t\tappendSearchParam(searchParams, \"cursor\", params.cursor);\n\t\tappendSearchParam(searchParams, \"from_height\", params.fromHeight);\n\t\tappendSearchParam(searchParams, \"to_height\", params.toHeight);\n\t\tappendSearchParam(searchParams, \"limit\", params.limit);\n\t\tappendSearchParam(searchParams, \"contract_id\", params.contractId);\n\t\tif (params.types?.length) {\n\t\t\tsearchParams.set(\"types\", params.types.join(\",\"));\n\t\t}\n\n\t\tconst query = searchParams.toString();\n\t\treturn request<StreamsEventsEnvelope>(\n\t\t\t`/v1/streams/events${query ? `?${query}` : \"\"}`,\n\t\t);\n\t}\n\n\treturn {\n\t\tevents: {\n\t\t\tlist: listEvents,\n\t\t\tbyTxId(txId: string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/events/${encodeURIComponent(txId)}`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tconsume(params: StreamsEventsConsumeParams) {\n\t\t\t\treturn consumeStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\tmode: params.mode,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t\tonBatch: params.onBatch,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t});\n\t\t\t},\n\t\t\tstream(params: StreamsEventsStreamParams = {}) {\n\t\t\t\treturn streamStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\tblocks: {\n\t\t\tevents(heightOrHash: number | string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/blocks/${encodeURIComponent(String(heightOrHash))}/events`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\treorgs: {\n\t\t\tlist(params: StreamsReorgsListParams) {\n\t\t\t\tconst searchParams = new URLSearchParams();\n\t\t\t\tappendSearchParam(searchParams, \"since\", params.since);\n\t\t\t\tappendSearchParam(searchParams, \"limit\", params.limit);\n\t\t\t\tconst query = searchParams.toString();\n\t\t\t\treturn request<StreamsReorgsListEnvelope>(\n\t\t\t\t\t`/v1/streams/reorgs${query ? `?${query}` : \"\"}`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tcanonical(height: number) {\n\t\t\treturn request<StreamsCanonicalBlock>(`/v1/streams/canonical/${height}`);\n\t\t},\n\t\ttip() {\n\t\t\treturn request<StreamsTip>(\"/v1/streams/tip\");\n\t\t},\n\t};\n}\n",
|
|
13
|
-
"import type {\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionSummary,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\nimport { BaseClient } from \"../base.ts\";\n\nexport type {\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionFormat,\n\tSubscriptionRuntime,\n\tSubscriptionStatus,\n\tSubscriptionSummary,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\n\nexport class Subscriptions extends BaseClient {\n\tasync list(): Promise<{ data: SubscriptionSummary[] }> {\n\t\treturn this.
|
|
13
|
+
"import type {\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionSummary,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\nimport { BaseClient } from \"../base.ts\";\n\nexport type {\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionFormat,\n\tSubscriptionRuntime,\n\tSubscriptionStatus,\n\tSubscriptionSummary,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\n\nexport class Subscriptions extends BaseClient {\n\tasync list(): Promise<{ data: SubscriptionSummary[] }> {\n\t\treturn this.requestAtTenant<{ data: SubscriptionSummary[] }>(\n\t\t\t\"GET\",\n\t\t\t\"/api/subscriptions\",\n\t\t);\n\t}\n\n\tasync get(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.requestAtTenant<SubscriptionDetail>(\n\t\t\t\"GET\",\n\t\t\t`/api/subscriptions/${id}`,\n\t\t);\n\t}\n\n\tasync create(\n\t\tinput: CreateSubscriptionRequest,\n\t): Promise<CreateSubscriptionResponse> {\n\t\treturn this.requestAtTenant<CreateSubscriptionResponse>(\n\t\t\t\"POST\",\n\t\t\t\"/api/subscriptions\",\n\t\t\tinput,\n\t\t);\n\t}\n\n\tasync update(\n\t\tid: string,\n\t\tpatch: UpdateSubscriptionRequest,\n\t): Promise<SubscriptionDetail> {\n\t\treturn this.requestAtTenant<SubscriptionDetail>(\n\t\t\t\"PATCH\",\n\t\t\t`/api/subscriptions/${id}`,\n\t\t\tpatch,\n\t\t);\n\t}\n\n\tasync pause(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.requestAtTenant<SubscriptionDetail>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/pause`,\n\t\t);\n\t}\n\n\tasync resume(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.requestAtTenant<SubscriptionDetail>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/resume`,\n\t\t);\n\t}\n\n\tasync delete(id: string): Promise<{ ok: true }> {\n\t\treturn this.requestAtTenant<{ ok: true }>(\n\t\t\t\"DELETE\",\n\t\t\t`/api/subscriptions/${id}`,\n\t\t);\n\t}\n\n\tasync rotateSecret(id: string): Promise<RotateSecretResponse> {\n\t\treturn this.requestAtTenant<RotateSecretResponse>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/rotate-secret`,\n\t\t);\n\t}\n\n\tasync recentDeliveries(id: string): Promise<{ data: DeliveryRow[] }> {\n\t\treturn this.requestAtTenant<{ data: DeliveryRow[] }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subscriptions/${id}/deliveries`,\n\t\t);\n\t}\n\n\tasync replay(\n\t\tid: string,\n\t\trange: { fromBlock: number; toBlock: number },\n\t): Promise<ReplayResult> {\n\t\treturn this.requestAtTenant<ReplayResult>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/replay`,\n\t\t\trange,\n\t\t);\n\t}\n\n\tasync dead(id: string): Promise<{ data: DeadRow[] }> {\n\t\treturn this.requestAtTenant<{ data: DeadRow[] }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subscriptions/${id}/dead`,\n\t\t);\n\t}\n\n\tasync requeueDead(id: string, outboxId: string): Promise<{ ok: true }> {\n\t\treturn this.requestAtTenant<{ ok: true }>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/dead/${outboxId}/requeue`,\n\t\t);\n\t}\n}\n",
|
|
14
14
|
"import { BaseClient } from \"./base.ts\";\nimport type { SecondLayerOptions } from \"./base.ts\";\nimport { Index } from \"./index-api/client.ts\";\nimport { createStreamsClient } from \"./streams/client.ts\";\nimport type { StreamsClient } from \"./streams/types.ts\";\nimport { Subgraphs } from \"./subgraphs/client.ts\";\nimport { Subscriptions } from \"./subscriptions/client.ts\";\n\nexport class SecondLayer extends BaseClient {\n\treadonly streams: StreamsClient;\n\treadonly index: Index;\n\treadonly subgraphs: Subgraphs;\n\treadonly subscriptions: Subscriptions;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t\tthis.streams = createStreamsClient({\n\t\t\tapiKey: options.apiKey ?? \"\",\n\t\t\tbaseUrl: options.baseUrl,\n\t\t\tfetchImpl: options.fetchImpl,\n\t\t});\n\t\tthis.index = new Index(options);\n\t\tthis.subgraphs = new Subgraphs(options);\n\t\tthis.subscriptions = new Subscriptions(options);\n\t}\n}\n",
|
|
15
15
|
"import type { InferSubgraphClient } from \"@secondlayer/subgraphs\";\nimport type { SecondLayerOptions } from \"../base.ts\";\nimport { SecondLayer } from \"../client.ts\";\nimport { Subgraphs } from \"./client.ts\";\n\n/**\n * Returns a typed client for a subgraph defined with `defineSubgraph()`.\n *\n * Accepts a plain options object, a `SecondLayer` instance, or a `Subgraphs` instance.\n *\n * @example\n * ```ts\n * import mySubgraph from './subgraphs/my-subgraph'\n * import { getSubgraph } from '@secondlayer/sdk'\n *\n * const client = getSubgraph(mySubgraph, { apiKey: 'sl_...' })\n * const rows = await client.transfers.findMany({ where: { sender: 'SP...' } })\n * ```\n */\nexport function getSubgraph<\n\tT extends { name: string; schema: Record<string, unknown> },\n>(\n\tdef: T,\n\toptions: Partial<SecondLayerOptions> | SecondLayer | Subgraphs = {},\n): InferSubgraphClient<T> {\n\tif (options instanceof Subgraphs) {\n\t\treturn options.typed(def);\n\t}\n\tif (options instanceof SecondLayer) {\n\t\treturn options.subgraphs.typed(def);\n\t}\n\treturn new Subgraphs(options).typed(def);\n}\n"
|
|
16
16
|
],
|
|
17
|
-
"mappings": ";AAeO,MAAM,iBAAiB,MAAM;AAAA,EAG3B;AAAA,EAGA;AAAA,EALR,WAAW,CAEH,QACP,SAEO,MACN;AAAA,IACD,MAAM,OAAO;AAAA,IALN;AAAA,IAGA;AAAA,IAGP,KAAK,OAAO;AAAA;AAEd;AAAA;AAMO,MAAM,6BAA6B,SAAS;AAAA,EAE1C;AAAA,EACA;AAAA,EAFR,WAAW,CACH,gBACA,iBACP,UAAU,8BAA8B,4BAA4B,kBACnE;AAAA,IACD,MAAM,KAAK,SAAS,EAAE,gBAAgB,gBAAgB,CAA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