@secondlayer/sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -2
- package/dist/index.js +18 -3
- package/dist/index.js.map +9 -9
- package/dist/streams/index.d.ts +1 -1
- package/dist/streams/index.js +4 -2
- package/dist/streams/index.js.map +5 -5
- package/dist/subgraphs/index.d.ts +7 -2
- package/dist/subgraphs/index.js +18 -3
- package/dist/subgraphs/index.js.map +9 -9
- package/package.json +40 -40
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BulkPauseResponse, BulkResumeResponse, CreateStream, CreateStreamResponse, ListStreamsResponse, StreamResponse, UpdateStream } from "@secondlayer/shared/schemas";
|
|
2
2
|
interface SecondLayerOptions {
|
|
3
3
|
/** Base URL of the Secondlayer API (trailing slashes are stripped). */
|
|
4
4
|
baseUrl: string;
|
|
@@ -54,7 +54,7 @@ declare class Streams extends BaseClient {
|
|
|
54
54
|
pauseAll(): Promise<BulkPauseResponse>;
|
|
55
55
|
resumeAll(): Promise<BulkResumeResponse>;
|
|
56
56
|
}
|
|
57
|
-
import {
|
|
57
|
+
import { ReindexResponse, SubgraphDetail, SubgraphGapsResponse, SubgraphQueryParams, SubgraphSummary } from "@secondlayer/shared/schemas";
|
|
58
58
|
import { DeploySubgraphRequest, DeploySubgraphResponse } from "@secondlayer/shared/schemas/subgraphs";
|
|
59
59
|
import { InferSubgraphClient } from "@secondlayer/subgraphs";
|
|
60
60
|
declare class Subgraphs extends BaseClient {
|
|
@@ -70,6 +70,11 @@ declare class Subgraphs extends BaseClient {
|
|
|
70
70
|
fromBlock: number
|
|
71
71
|
toBlock: number
|
|
72
72
|
}): Promise<ReindexResponse>;
|
|
73
|
+
gaps(name: string, opts?: {
|
|
74
|
+
limit?: number
|
|
75
|
+
offset?: number
|
|
76
|
+
resolved?: boolean
|
|
77
|
+
}): Promise<SubgraphGapsResponse>;
|
|
73
78
|
delete(name: string): Promise<{
|
|
74
79
|
message: string
|
|
75
80
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,9 @@ class BaseClient {
|
|
|
19
19
|
this.apiKey = options.apiKey;
|
|
20
20
|
}
|
|
21
21
|
static authHeaders(apiKey) {
|
|
22
|
-
const headers = {
|
|
22
|
+
const headers = {
|
|
23
|
+
"Content-Type": "application/json"
|
|
24
|
+
};
|
|
23
25
|
if (apiKey) {
|
|
24
26
|
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
25
27
|
}
|
|
@@ -226,6 +228,17 @@ class Subgraphs extends BaseClient {
|
|
|
226
228
|
async backfill(name, options) {
|
|
227
229
|
return this.request("POST", `/api/subgraphs/${name}/backfill`, options);
|
|
228
230
|
}
|
|
231
|
+
async gaps(name, opts) {
|
|
232
|
+
const qs = new URLSearchParams;
|
|
233
|
+
if (opts?.limit !== undefined)
|
|
234
|
+
qs.set("_limit", String(opts.limit));
|
|
235
|
+
if (opts?.offset !== undefined)
|
|
236
|
+
qs.set("_offset", String(opts.offset));
|
|
237
|
+
if (opts?.resolved !== undefined)
|
|
238
|
+
qs.set("resolved", String(opts.resolved));
|
|
239
|
+
const query = qs.toString();
|
|
240
|
+
return this.request("GET", `/api/subgraphs/${name}/gaps${query ? `?${query}` : ""}`);
|
|
241
|
+
}
|
|
229
242
|
async delete(name) {
|
|
230
243
|
return this.request("DELETE", `/api/subgraphs/${name}`);
|
|
231
244
|
}
|
|
@@ -277,7 +290,9 @@ class Subgraphs extends BaseClient {
|
|
|
277
290
|
},
|
|
278
291
|
async count(where) {
|
|
279
292
|
const filters = where ? serializeWhere(where) : undefined;
|
|
280
|
-
const result = await self.queryTableCount(subgraphName, tableName, {
|
|
293
|
+
const result = await self.queryTableCount(subgraphName, tableName, {
|
|
294
|
+
filters
|
|
295
|
+
});
|
|
281
296
|
return result.count;
|
|
282
297
|
}
|
|
283
298
|
};
|
|
@@ -316,5 +331,5 @@ export {
|
|
|
316
331
|
ApiError
|
|
317
332
|
};
|
|
318
333
|
|
|
319
|
-
//# debugId=
|
|
334
|
+
//# debugId=ABB486321CC084CC64756E2164756E21
|
|
320
335
|
//# 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/streams/client.ts", "../src/subgraphs/serialize.ts", "../src/subgraphs/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.streams.get(\"abc123\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Stream not found\");\n * }\n * }\n * ```\n */\nexport class ApiError extends Error {\n
|
|
6
|
-
"import { ApiError } from \"./errors.ts\";\n\nexport interface SecondLayerOptions {\n
|
|
7
|
-
"import type {\n
|
|
8
|
-
"/**\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
|
|
9
|
-
"import type {\n
|
|
10
|
-
"import type { QueueStats } from \"@secondlayer/shared/types\";\nimport { BaseClient } from \"./base.ts\";\nimport type { SecondLayerOptions } from \"./base.ts\";\nimport { Streams } from \"./streams/client.ts\";\nimport { Subgraphs } from \"./subgraphs/client.ts\";\n\nexport class SecondLayer extends BaseClient {\n
|
|
11
|
-
"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
|
|
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.streams.get(\"abc123\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Stream 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) {\n\t\tsuper(message);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n",
|
|
6
|
+
"import { ApiError } from \"./errors.ts\";\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}\n\nconst DEFAULT_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport abstract class BaseClient {\n\tprotected baseUrl: string;\n\tprotected apiKey?: string;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tthis.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n\t\tthis.apiKey = options.apiKey;\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 url = `${this.baseUrl}${path}`;\n\t\tconst headers = BaseClient.authHeaders(this.apiKey);\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 ${this.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 ${this.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\ttry {\n\t\t\t\tconst json = JSON.parse(errorBody);\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} catch {\n\t\t\t\tif (errorBody) message = errorBody;\n\t\t\t}\n\t\t\tthrow new ApiError(response.status, message);\n\t\t}\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",
|
|
7
|
+
"import type {\n\tBulkPauseResponse,\n\tBulkResumeResponse,\n\tCreateStream,\n\tCreateStreamResponse,\n\tListStreamsResponse,\n\tStreamResponse,\n\tUpdateStream,\n} from \"@secondlayer/shared/schemas\";\nimport { BaseClient } from \"../base.ts\";\nimport { ApiError } from \"../errors.ts\";\n\nexport interface DeliverySummary {\n\tid: string;\n\tblockHeight: number;\n\tstatus: string;\n\tstatusCode: number | null;\n\tresponseTimeMs: number | null;\n\tattempts: number;\n\terror: string | null;\n\tcreatedAt: string;\n}\n\nexport interface DeliveryDetail extends DeliverySummary {\n\tpayload: unknown;\n}\n\nexport interface DeliveriesResponse {\n\tdeliveries: DeliverySummary[];\n}\n\nexport class Streams extends BaseClient {\n\tprivate async requestWithStreamId<T>(\n\t\tmethod: string,\n\t\tpathTemplate: (id: string) => string,\n\t\tid: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst fullId = await this.resolveStreamId(id);\n\t\treturn this.request<T>(method, pathTemplate(fullId), body);\n\t}\n\n\tasync resolveStreamId(partialId: string): Promise<string> {\n\t\tif (partialId.length === 36 && partialId.includes(\"-\")) {\n\t\t\treturn partialId;\n\t\t}\n\n\t\tconst { streams } = await this.list();\n\t\tconst matches = streams.filter((s) => s.id.startsWith(partialId));\n\n\t\tif (matches.length === 0) {\n\t\t\tthrow new ApiError(404, `No stream found matching \"${partialId}\"`);\n\t\t}\n\t\tif (matches.length > 1) {\n\t\t\tthrow new ApiError(\n\t\t\t\t400,\n\t\t\t\t`Multiple streams match \"${partialId}\": ${matches.map((s) => s.id.slice(0, 8)).join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\treturn matches[0]!.id;\n\t}\n\n\tasync create(data: CreateStream): Promise<CreateStreamResponse> {\n\t\treturn this.request<CreateStreamResponse>(\"POST\", \"/api/streams\", data);\n\t}\n\n\tasync update(id: string, data: UpdateStream): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"PATCH\",\n\t\t\t(id) => `/api/streams/${id}`,\n\t\t\tid,\n\t\t\tdata,\n\t\t);\n\t}\n\n\tasync updateByName(\n\t\tname: string,\n\t\tdata: CreateStream,\n\t): Promise<StreamResponse> {\n\t\tconst { streams } = await this.list();\n\t\tconst existing = streams.find((s) => s.name === name);\n\t\tif (!existing) {\n\t\t\tthrow new ApiError(404, `Stream with name \"${name}\" not found`);\n\t\t}\n\t\treturn this.update(existing.id, data);\n\t}\n\n\tasync list(params?: { status?: string }): Promise<ListStreamsResponse> {\n\t\tconst searchParams = new URLSearchParams();\n\t\tif (params?.status) searchParams.set(\"status\", params.status);\n\t\tconst query = searchParams.toString();\n\t\tconst path = query ? `/api/streams?${query}` : \"/api/streams\";\n\t\treturn this.request<ListStreamsResponse>(\"GET\", path);\n\t}\n\n\tasync get(id: string): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\"GET\", (id) => `/api/streams/${id}`, id);\n\t}\n\n\tasync delete(id: string): Promise<void> {\n\t\treturn this.requestWithStreamId(\"DELETE\", (id) => `/api/streams/${id}`, id);\n\t}\n\n\tasync enable(id: string): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"POST\",\n\t\t\t(id) => `/api/streams/${id}/enable`,\n\t\t\tid,\n\t\t);\n\t}\n\n\tasync disable(id: string): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"POST\",\n\t\t\t(id) => `/api/streams/${id}/disable`,\n\t\t\tid,\n\t\t);\n\t}\n\n\tasync rotateSecret(id: string): Promise<{ secret: string }> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"POST\",\n\t\t\t(id) => `/api/streams/${id}/rotate-secret`,\n\t\t\tid,\n\t\t);\n\t}\n\n\t// ── Deliveries ─────────────────────────────────────────────────────\n\n\t/** List recent deliveries for a stream. */\n\tasync listDeliveries(\n\t\tid: string,\n\t\tparams?: { limit?: number; status?: string },\n\t): Promise<DeliveriesResponse> {\n\t\tconst qs = new URLSearchParams();\n\t\tif (params?.limit !== undefined) qs.set(\"limit\", String(params.limit));\n\t\tif (params?.status) qs.set(\"status\", params.status);\n\t\tconst query = qs.toString();\n\t\treturn this.requestWithStreamId(\n\t\t\t\"GET\",\n\t\t\t(id) => `/api/streams/${id}/deliveries${query ? `?${query}` : \"\"}`,\n\t\t\tid,\n\t\t);\n\t}\n\n\t/** Get a single delivery with full payload. */\n\tasync getDelivery(\n\t\tstreamId: string,\n\t\tdeliveryId: string,\n\t): Promise<DeliveryDetail> {\n\t\tconst fullId = await this.resolveStreamId(streamId);\n\t\treturn this.request<DeliveryDetail>(\n\t\t\t\"GET\",\n\t\t\t`/api/streams/${fullId}/deliveries/${deliveryId}`,\n\t\t);\n\t}\n\n\tasync pauseAll(): Promise<BulkPauseResponse> {\n\t\treturn this.request<BulkPauseResponse>(\"POST\", \"/api/streams/pause\");\n\t}\n\n\tasync resumeAll(): Promise<BulkResumeResponse> {\n\t\treturn this.request<BulkResumeResponse>(\"POST\", \"/api/streams/resume\");\n\t}\n}\n",
|
|
8
|
+
"/**\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",
|
|
9
|
+
"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\tFindManyOptions,\n\tInferSubgraphClient,\n\tWhereInput,\n} from \"@secondlayer/subgraphs\";\nimport { BaseClient } from \"../base.ts\";\nimport { resolveOrderByColumn, serializeWhere } from \"./serialize.ts\";\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\nexport class Subgraphs extends BaseClient {\n\tasync list(): Promise<{ data: SubgraphSummary[] }> {\n\t\treturn this.request<{ data: SubgraphSummary[] }>(\"GET\", \"/api/subgraphs\");\n\t}\n\n\tasync get(name: string): Promise<SubgraphDetail> {\n\t\treturn this.request<SubgraphDetail>(\"GET\", `/api/subgraphs/${name}`);\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.request<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 backfill(\n\t\tname: string,\n\t\toptions: { fromBlock: number; toBlock: number },\n\t): Promise<ReindexResponse> {\n\t\treturn this.request<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.request<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(name: string): Promise<{ message: string }> {\n\t\treturn this.request<{ message: string }>(\n\t\t\t\"DELETE\",\n\t\t\t`/api/subgraphs/${name}`,\n\t\t);\n\t}\n\n\tasync deploy(data: DeploySubgraphRequest): Promise<DeploySubgraphResponse> {\n\t\treturn this.request<DeploySubgraphResponse>(\"POST\", \"/api/subgraphs\", data);\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.request<{ 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.request<{ 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 [col, dir] = entries[0]!;\n\t\t\t\t\t\tsort = resolveOrderByColumn(col);\n\t\t\t\t\t\torder = dir ?? \"asc\";\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",
|
|
10
|
+
"import type { QueueStats } from \"@secondlayer/shared/types\";\nimport { BaseClient } from \"./base.ts\";\nimport type { SecondLayerOptions } from \"./base.ts\";\nimport { Streams } from \"./streams/client.ts\";\nimport { Subgraphs } from \"./subgraphs/client.ts\";\n\nexport class SecondLayer extends BaseClient {\n\treadonly streams: Streams;\n\treadonly subgraphs: Subgraphs;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t\tthis.streams = new Streams(options);\n\t\tthis.subgraphs = new Subgraphs(options);\n\t}\n\n\tasync getQueueStats(): Promise<QueueStats> {\n\t\tconst status = await this.request<{ queue: QueueStats }>(\"GET\", \"/status\");\n\t\treturn status.queue;\n\t}\n}\n",
|
|
11
|
+
"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"
|
|
12
12
|
],
|
|
13
|
-
"mappings": ";AAeO,MAAM,iBAAiB,MAAM;AAAA,
|
|
14
|
-
"debugId": "
|
|
13
|
+
"mappings": ";AAeO,MAAM,iBAAiB,MAAM;AAAA,EAG3B;AAAA,EAFR,WAAW,CAEH,QACP,SACC;AAAA,IACD,MAAM,OAAO;AAAA,IAHN;AAAA,IAIP,KAAK,OAAO;AAAA;AAEd;;;ACfA,IAAM,mBAAmB;AAAA;AAElB,MAAe,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,E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ACb,eAAe,KAAgC,IAC/C;AAAA,QAEH,MAAM,SAAS,MAAM,KAAK,gBAAgB,cAAc,WAAW;AAAA,UAClE;AAAA,QACD,CAAC;AAAA,QACD,OAAO,OAAO;AAAA;AAAA,IAEhB;AAAA;AAEF;;ACjMO,MAAM,oBAAoB,WAAW;AAAA,EAClC;AAAA,EACA;AAAA,EAET,WAAW,CAAC,UAAuC,CAAC,GAAG;AAAA,IACtD,MAAM,OAAO;AAAA,IACb,KAAK,UAAU,IAAI,QAAQ,OAAO;AAAA,IAClC,KAAK,YAAY,IAAI,UAAU,OAAO;AAAA;AAAA,OAGjC,cAAa,GAAwB;AAAA,IAC1C,MAAM,SAAS,MAAM,KAAK,QAA+B,OAAO,SAAS;AAAA,IACzE,OAAO,OAAO;AAAA;AAEhB;;;ACDO,SAAS,WAEf,CACA,KACA,UAAiE,CAAC,GACzC;AAAA,EACzB,IAAI,mBAAmB,WAAW;AAAA,IACjC,OAAO,QAAQ,MAAM,GAAG;AAAA,EACzB;AAAA,EACA,IAAI,mBAAmB,aAAa;AAAA,IACnC,OAAO,QAAQ,UAAU,MAAM,GAAG;AAAA,EACnC;AAAA,EACA,OAAO,IAAI,UAAU,OAAO,EAAE,MAAM,GAAG;AAAA;",
|
|
14
|
+
"debugId": "ABB486321CC084CC64756E2164756E21",
|
|
15
15
|
"names": []
|
|
16
16
|
}
|
package/dist/streams/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BulkPauseResponse, BulkResumeResponse, CreateStream, CreateStreamResponse, ListStreamsResponse, StreamResponse, UpdateStream } from "@secondlayer/shared/schemas";
|
|
2
2
|
interface SecondLayerOptions {
|
|
3
3
|
/** Base URL of the Secondlayer API (trailing slashes are stripped). */
|
|
4
4
|
baseUrl: string;
|
package/dist/streams/index.js
CHANGED
|
@@ -19,7 +19,9 @@ class BaseClient {
|
|
|
19
19
|
this.apiKey = options.apiKey;
|
|
20
20
|
}
|
|
21
21
|
static authHeaders(apiKey) {
|
|
22
|
-
const headers = {
|
|
22
|
+
const headers = {
|
|
23
|
+
"Content-Type": "application/json"
|
|
24
|
+
};
|
|
23
25
|
if (apiKey) {
|
|
24
26
|
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
25
27
|
}
|
|
@@ -154,5 +156,5 @@ export {
|
|
|
154
156
|
Streams
|
|
155
157
|
};
|
|
156
158
|
|
|
157
|
-
//# debugId=
|
|
159
|
+
//# debugId=C6255FAFEE54D50164756E2164756E21
|
|
158
160
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/errors.ts", "../src/base.ts", "../src/streams/client.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.streams.get(\"abc123\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Stream not found\");\n * }\n * }\n * ```\n */\nexport class ApiError extends Error {\n
|
|
6
|
-
"import { ApiError } from \"./errors.ts\";\n\nexport interface SecondLayerOptions {\n
|
|
7
|
-
"import type {\n
|
|
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.streams.get(\"abc123\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Stream 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) {\n\t\tsuper(message);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n",
|
|
6
|
+
"import { ApiError } from \"./errors.ts\";\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}\n\nconst DEFAULT_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport abstract class BaseClient {\n\tprotected baseUrl: string;\n\tprotected apiKey?: string;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tthis.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n\t\tthis.apiKey = options.apiKey;\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 url = `${this.baseUrl}${path}`;\n\t\tconst headers = BaseClient.authHeaders(this.apiKey);\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 ${this.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 ${this.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\ttry {\n\t\t\t\tconst json = JSON.parse(errorBody);\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} catch {\n\t\t\t\tif (errorBody) message = errorBody;\n\t\t\t}\n\t\t\tthrow new ApiError(response.status, message);\n\t\t}\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",
|
|
7
|
+
"import type {\n\tBulkPauseResponse,\n\tBulkResumeResponse,\n\tCreateStream,\n\tCreateStreamResponse,\n\tListStreamsResponse,\n\tStreamResponse,\n\tUpdateStream,\n} from \"@secondlayer/shared/schemas\";\nimport { BaseClient } from \"../base.ts\";\nimport { ApiError } from \"../errors.ts\";\n\nexport interface DeliverySummary {\n\tid: string;\n\tblockHeight: number;\n\tstatus: string;\n\tstatusCode: number | null;\n\tresponseTimeMs: number | null;\n\tattempts: number;\n\terror: string | null;\n\tcreatedAt: string;\n}\n\nexport interface DeliveryDetail extends DeliverySummary {\n\tpayload: unknown;\n}\n\nexport interface DeliveriesResponse {\n\tdeliveries: DeliverySummary[];\n}\n\nexport class Streams extends BaseClient {\n\tprivate async requestWithStreamId<T>(\n\t\tmethod: string,\n\t\tpathTemplate: (id: string) => string,\n\t\tid: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst fullId = await this.resolveStreamId(id);\n\t\treturn this.request<T>(method, pathTemplate(fullId), body);\n\t}\n\n\tasync resolveStreamId(partialId: string): Promise<string> {\n\t\tif (partialId.length === 36 && partialId.includes(\"-\")) {\n\t\t\treturn partialId;\n\t\t}\n\n\t\tconst { streams } = await this.list();\n\t\tconst matches = streams.filter((s) => s.id.startsWith(partialId));\n\n\t\tif (matches.length === 0) {\n\t\t\tthrow new ApiError(404, `No stream found matching \"${partialId}\"`);\n\t\t}\n\t\tif (matches.length > 1) {\n\t\t\tthrow new ApiError(\n\t\t\t\t400,\n\t\t\t\t`Multiple streams match \"${partialId}\": ${matches.map((s) => s.id.slice(0, 8)).join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\treturn matches[0]!.id;\n\t}\n\n\tasync create(data: CreateStream): Promise<CreateStreamResponse> {\n\t\treturn this.request<CreateStreamResponse>(\"POST\", \"/api/streams\", data);\n\t}\n\n\tasync update(id: string, data: UpdateStream): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"PATCH\",\n\t\t\t(id) => `/api/streams/${id}`,\n\t\t\tid,\n\t\t\tdata,\n\t\t);\n\t}\n\n\tasync updateByName(\n\t\tname: string,\n\t\tdata: CreateStream,\n\t): Promise<StreamResponse> {\n\t\tconst { streams } = await this.list();\n\t\tconst existing = streams.find((s) => s.name === name);\n\t\tif (!existing) {\n\t\t\tthrow new ApiError(404, `Stream with name \"${name}\" not found`);\n\t\t}\n\t\treturn this.update(existing.id, data);\n\t}\n\n\tasync list(params?: { status?: string }): Promise<ListStreamsResponse> {\n\t\tconst searchParams = new URLSearchParams();\n\t\tif (params?.status) searchParams.set(\"status\", params.status);\n\t\tconst query = searchParams.toString();\n\t\tconst path = query ? `/api/streams?${query}` : \"/api/streams\";\n\t\treturn this.request<ListStreamsResponse>(\"GET\", path);\n\t}\n\n\tasync get(id: string): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\"GET\", (id) => `/api/streams/${id}`, id);\n\t}\n\n\tasync delete(id: string): Promise<void> {\n\t\treturn this.requestWithStreamId(\"DELETE\", (id) => `/api/streams/${id}`, id);\n\t}\n\n\tasync enable(id: string): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"POST\",\n\t\t\t(id) => `/api/streams/${id}/enable`,\n\t\t\tid,\n\t\t);\n\t}\n\n\tasync disable(id: string): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"POST\",\n\t\t\t(id) => `/api/streams/${id}/disable`,\n\t\t\tid,\n\t\t);\n\t}\n\n\tasync rotateSecret(id: string): Promise<{ secret: string }> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"POST\",\n\t\t\t(id) => `/api/streams/${id}/rotate-secret`,\n\t\t\tid,\n\t\t);\n\t}\n\n\t// ── Deliveries ─────────────────────────────────────────────────────\n\n\t/** List recent deliveries for a stream. */\n\tasync listDeliveries(\n\t\tid: string,\n\t\tparams?: { limit?: number; status?: string },\n\t): Promise<DeliveriesResponse> {\n\t\tconst qs = new URLSearchParams();\n\t\tif (params?.limit !== undefined) qs.set(\"limit\", String(params.limit));\n\t\tif (params?.status) qs.set(\"status\", params.status);\n\t\tconst query = qs.toString();\n\t\treturn this.requestWithStreamId(\n\t\t\t\"GET\",\n\t\t\t(id) => `/api/streams/${id}/deliveries${query ? `?${query}` : \"\"}`,\n\t\t\tid,\n\t\t);\n\t}\n\n\t/** Get a single delivery with full payload. */\n\tasync getDelivery(\n\t\tstreamId: string,\n\t\tdeliveryId: string,\n\t): Promise<DeliveryDetail> {\n\t\tconst fullId = await this.resolveStreamId(streamId);\n\t\treturn this.request<DeliveryDetail>(\n\t\t\t\"GET\",\n\t\t\t`/api/streams/${fullId}/deliveries/${deliveryId}`,\n\t\t);\n\t}\n\n\tasync pauseAll(): Promise<BulkPauseResponse> {\n\t\treturn this.request<BulkPauseResponse>(\"POST\", \"/api/streams/pause\");\n\t}\n\n\tasync resumeAll(): Promise<BulkResumeResponse> {\n\t\treturn this.request<BulkResumeResponse>(\"POST\", \"/api/streams/resume\");\n\t}\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";AAeO,MAAM,iBAAiB,MAAM;AAAA,
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";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,KAAK,oBACX,QACA,CAAC,QAAO,gBAAgB,cACxB,EACD;AAAA;AAAA,OAGK,QAAO,CAAC,IAAqC;AAAA,IAClD,OAAO,KAAK,oBACX,QACA,CAAC,QAAO,gBAAgB,eACxB,EACD;AAAA;AAAA,OAGK,aAAY,CAAC,IAAyC;AAAA,IAC3D,OAAO,KAAK,oBACX,QACA,CAAC,QAAO,gBAAgB,qBACxB,EACD;AAAA;AAAA,OAMK,eAAc,CACnB,IACA,QAC8B;AAAA,IAC9B,MAAM,KAAK,IAAI;AAAA,IACf,IAAI,QAAQ,UAAU;AAAA,MAAW,GAAG,IAAI,SAAS,OAAO,OAAO,KAAK,CAAC;AAAA,IACrE,IAAI,QAAQ;AAAA,MAAQ,GAAG,IAAI,UAAU,OAAO,MAAM;AAAA,IAClD,MAAM,QAAQ,GAAG,SAAS;AAAA,IAC1B,OAAO,KAAK,oBACX,OACA,CAAC,QAAO,gBAAgB,iBAAgB,QAAQ,IAAI,UAAU,MAC9D,EACD;AAAA;AAAA,OAIK,YAAW,CAChB,UACA,YAC0B;AAAA,IAC1B,MAAM,SAAS,MAAM,KAAK,gBAAgB,QAAQ;AAAA,IAClD,OAAO,KAAK,QACX,OACA,gBAAgB,qBAAqB,YACtC;AAAA;AAAA,OAGK,SAAQ,GAA+B;AAAA,IAC5C,OAAO,KAAK,QAA2B,QAAQ,oBAAoB;AAAA;AAAA,OAG9D,UAAS,GAAgC;AAAA,IAC9C,OAAO,KAAK,QAA4B,QAAQ,qBAAqB;AAAA;AAEvE;",
|
|
10
|
+
"debugId": "C6255FAFEE54D50164756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReindexResponse, SubgraphDetail, SubgraphGapsResponse, SubgraphQueryParams, SubgraphSummary } from "@secondlayer/shared/schemas";
|
|
2
2
|
import { DeploySubgraphRequest, DeploySubgraphResponse } from "@secondlayer/shared/schemas/subgraphs";
|
|
3
3
|
import { InferSubgraphClient } from "@secondlayer/subgraphs";
|
|
4
4
|
interface SecondLayerOptions {
|
|
@@ -27,6 +27,11 @@ declare class Subgraphs extends BaseClient {
|
|
|
27
27
|
fromBlock: number
|
|
28
28
|
toBlock: number
|
|
29
29
|
}): Promise<ReindexResponse>;
|
|
30
|
+
gaps(name: string, opts?: {
|
|
31
|
+
limit?: number
|
|
32
|
+
offset?: number
|
|
33
|
+
resolved?: boolean
|
|
34
|
+
}): Promise<SubgraphGapsResponse>;
|
|
30
35
|
delete(name: string): Promise<{
|
|
31
36
|
message: string
|
|
32
37
|
}>;
|
|
@@ -55,7 +60,7 @@ declare class Subgraphs extends BaseClient {
|
|
|
55
60
|
}
|
|
56
61
|
import { InferSubgraphClient as InferSubgraphClient2 } from "@secondlayer/subgraphs";
|
|
57
62
|
import { QueueStats } from "@secondlayer/shared/types";
|
|
58
|
-
import {
|
|
63
|
+
import { BulkPauseResponse, BulkResumeResponse, CreateStream, CreateStreamResponse, ListStreamsResponse, StreamResponse, UpdateStream } from "@secondlayer/shared/schemas";
|
|
59
64
|
interface DeliverySummary {
|
|
60
65
|
id: string;
|
|
61
66
|
blockHeight: number;
|
package/dist/subgraphs/index.js
CHANGED
|
@@ -19,7 +19,9 @@ class BaseClient {
|
|
|
19
19
|
this.apiKey = options.apiKey;
|
|
20
20
|
}
|
|
21
21
|
static authHeaders(apiKey) {
|
|
22
|
-
const headers = {
|
|
22
|
+
const headers = {
|
|
23
|
+
"Content-Type": "application/json"
|
|
24
|
+
};
|
|
23
25
|
if (apiKey) {
|
|
24
26
|
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
25
27
|
}
|
|
@@ -149,6 +151,17 @@ class Subgraphs extends BaseClient {
|
|
|
149
151
|
async backfill(name, options) {
|
|
150
152
|
return this.request("POST", `/api/subgraphs/${name}/backfill`, options);
|
|
151
153
|
}
|
|
154
|
+
async gaps(name, opts) {
|
|
155
|
+
const qs = new URLSearchParams;
|
|
156
|
+
if (opts?.limit !== undefined)
|
|
157
|
+
qs.set("_limit", String(opts.limit));
|
|
158
|
+
if (opts?.offset !== undefined)
|
|
159
|
+
qs.set("_offset", String(opts.offset));
|
|
160
|
+
if (opts?.resolved !== undefined)
|
|
161
|
+
qs.set("resolved", String(opts.resolved));
|
|
162
|
+
const query = qs.toString();
|
|
163
|
+
return this.request("GET", `/api/subgraphs/${name}/gaps${query ? `?${query}` : ""}`);
|
|
164
|
+
}
|
|
152
165
|
async delete(name) {
|
|
153
166
|
return this.request("DELETE", `/api/subgraphs/${name}`);
|
|
154
167
|
}
|
|
@@ -200,7 +213,9 @@ class Subgraphs extends BaseClient {
|
|
|
200
213
|
},
|
|
201
214
|
async count(where) {
|
|
202
215
|
const filters = where ? serializeWhere(where) : undefined;
|
|
203
|
-
const result = await self.queryTableCount(subgraphName, tableName, {
|
|
216
|
+
const result = await self.queryTableCount(subgraphName, tableName, {
|
|
217
|
+
filters
|
|
218
|
+
});
|
|
204
219
|
return result.count;
|
|
205
220
|
}
|
|
206
221
|
};
|
|
@@ -314,5 +329,5 @@ export {
|
|
|
314
329
|
Subgraphs
|
|
315
330
|
};
|
|
316
331
|
|
|
317
|
-
//# debugId=
|
|
332
|
+
//# debugId=48D7673D1282BA1664756E2164756E21
|
|
318
333
|
//# sourceMappingURL=index.js.map
|
|
@@ -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/streams/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.streams.get(\"abc123\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Stream not found\");\n * }\n * }\n * ```\n */\nexport class ApiError extends Error {\n
|
|
6
|
-
"import { ApiError } from \"./errors.ts\";\n\nexport interface SecondLayerOptions {\n
|
|
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
|
|
8
|
-
"import type {\n
|
|
9
|
-
"import type {\n
|
|
10
|
-
"import type { QueueStats } from \"@secondlayer/shared/types\";\nimport { BaseClient } from \"./base.ts\";\nimport type { SecondLayerOptions } from \"./base.ts\";\nimport { Streams } from \"./streams/client.ts\";\nimport { Subgraphs } from \"./subgraphs/client.ts\";\n\nexport class SecondLayer extends BaseClient {\n
|
|
11
|
-
"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
|
|
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.streams.get(\"abc123\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Stream 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) {\n\t\tsuper(message);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n",
|
|
6
|
+
"import { ApiError } from \"./errors.ts\";\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}\n\nconst DEFAULT_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport abstract class BaseClient {\n\tprotected baseUrl: string;\n\tprotected apiKey?: string;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tthis.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n\t\tthis.apiKey = options.apiKey;\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 url = `${this.baseUrl}${path}`;\n\t\tconst headers = BaseClient.authHeaders(this.apiKey);\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 ${this.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 ${this.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\ttry {\n\t\t\t\tconst json = JSON.parse(errorBody);\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} catch {\n\t\t\t\tif (errorBody) message = errorBody;\n\t\t\t}\n\t\t\tthrow new ApiError(response.status, message);\n\t\t}\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",
|
|
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\tFindManyOptions,\n\tInferSubgraphClient,\n\tWhereInput,\n} from \"@secondlayer/subgraphs\";\nimport { BaseClient } from \"../base.ts\";\nimport { resolveOrderByColumn, serializeWhere } from \"./serialize.ts\";\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\nexport class Subgraphs extends BaseClient {\n\tasync list(): Promise<{ data: SubgraphSummary[] }> {\n\t\treturn this.request<{ data: SubgraphSummary[] }>(\"GET\", \"/api/subgraphs\");\n\t}\n\n\tasync get(name: string): Promise<SubgraphDetail> {\n\t\treturn this.request<SubgraphDetail>(\"GET\", `/api/subgraphs/${name}`);\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.request<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 backfill(\n\t\tname: string,\n\t\toptions: { fromBlock: number; toBlock: number },\n\t): Promise<ReindexResponse> {\n\t\treturn this.request<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.request<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(name: string): Promise<{ message: string }> {\n\t\treturn this.request<{ message: string }>(\n\t\t\t\"DELETE\",\n\t\t\t`/api/subgraphs/${name}`,\n\t\t);\n\t}\n\n\tasync deploy(data: DeploySubgraphRequest): Promise<DeploySubgraphResponse> {\n\t\treturn this.request<DeploySubgraphResponse>(\"POST\", \"/api/subgraphs\", data);\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.request<{ 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.request<{ 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 [col, dir] = entries[0]!;\n\t\t\t\t\t\tsort = resolveOrderByColumn(col);\n\t\t\t\t\t\torder = dir ?? \"asc\";\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
|
+
"import type {\n\tBulkPauseResponse,\n\tBulkResumeResponse,\n\tCreateStream,\n\tCreateStreamResponse,\n\tListStreamsResponse,\n\tStreamResponse,\n\tUpdateStream,\n} from \"@secondlayer/shared/schemas\";\nimport { BaseClient } from \"../base.ts\";\nimport { ApiError } from \"../errors.ts\";\n\nexport interface DeliverySummary {\n\tid: string;\n\tblockHeight: number;\n\tstatus: string;\n\tstatusCode: number | null;\n\tresponseTimeMs: number | null;\n\tattempts: number;\n\terror: string | null;\n\tcreatedAt: string;\n}\n\nexport interface DeliveryDetail extends DeliverySummary {\n\tpayload: unknown;\n}\n\nexport interface DeliveriesResponse {\n\tdeliveries: DeliverySummary[];\n}\n\nexport class Streams extends BaseClient {\n\tprivate async requestWithStreamId<T>(\n\t\tmethod: string,\n\t\tpathTemplate: (id: string) => string,\n\t\tid: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst fullId = await this.resolveStreamId(id);\n\t\treturn this.request<T>(method, pathTemplate(fullId), body);\n\t}\n\n\tasync resolveStreamId(partialId: string): Promise<string> {\n\t\tif (partialId.length === 36 && partialId.includes(\"-\")) {\n\t\t\treturn partialId;\n\t\t}\n\n\t\tconst { streams } = await this.list();\n\t\tconst matches = streams.filter((s) => s.id.startsWith(partialId));\n\n\t\tif (matches.length === 0) {\n\t\t\tthrow new ApiError(404, `No stream found matching \"${partialId}\"`);\n\t\t}\n\t\tif (matches.length > 1) {\n\t\t\tthrow new ApiError(\n\t\t\t\t400,\n\t\t\t\t`Multiple streams match \"${partialId}\": ${matches.map((s) => s.id.slice(0, 8)).join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\treturn matches[0]!.id;\n\t}\n\n\tasync create(data: CreateStream): Promise<CreateStreamResponse> {\n\t\treturn this.request<CreateStreamResponse>(\"POST\", \"/api/streams\", data);\n\t}\n\n\tasync update(id: string, data: UpdateStream): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"PATCH\",\n\t\t\t(id) => `/api/streams/${id}`,\n\t\t\tid,\n\t\t\tdata,\n\t\t);\n\t}\n\n\tasync updateByName(\n\t\tname: string,\n\t\tdata: CreateStream,\n\t): Promise<StreamResponse> {\n\t\tconst { streams } = await this.list();\n\t\tconst existing = streams.find((s) => s.name === name);\n\t\tif (!existing) {\n\t\t\tthrow new ApiError(404, `Stream with name \"${name}\" not found`);\n\t\t}\n\t\treturn this.update(existing.id, data);\n\t}\n\n\tasync list(params?: { status?: string }): Promise<ListStreamsResponse> {\n\t\tconst searchParams = new URLSearchParams();\n\t\tif (params?.status) searchParams.set(\"status\", params.status);\n\t\tconst query = searchParams.toString();\n\t\tconst path = query ? `/api/streams?${query}` : \"/api/streams\";\n\t\treturn this.request<ListStreamsResponse>(\"GET\", path);\n\t}\n\n\tasync get(id: string): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\"GET\", (id) => `/api/streams/${id}`, id);\n\t}\n\n\tasync delete(id: string): Promise<void> {\n\t\treturn this.requestWithStreamId(\"DELETE\", (id) => `/api/streams/${id}`, id);\n\t}\n\n\tasync enable(id: string): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"POST\",\n\t\t\t(id) => `/api/streams/${id}/enable`,\n\t\t\tid,\n\t\t);\n\t}\n\n\tasync disable(id: string): Promise<StreamResponse> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"POST\",\n\t\t\t(id) => `/api/streams/${id}/disable`,\n\t\t\tid,\n\t\t);\n\t}\n\n\tasync rotateSecret(id: string): Promise<{ secret: string }> {\n\t\treturn this.requestWithStreamId(\n\t\t\t\"POST\",\n\t\t\t(id) => `/api/streams/${id}/rotate-secret`,\n\t\t\tid,\n\t\t);\n\t}\n\n\t// ── Deliveries ─────────────────────────────────────────────────────\n\n\t/** List recent deliveries for a stream. */\n\tasync listDeliveries(\n\t\tid: string,\n\t\tparams?: { limit?: number; status?: string },\n\t): Promise<DeliveriesResponse> {\n\t\tconst qs = new URLSearchParams();\n\t\tif (params?.limit !== undefined) qs.set(\"limit\", String(params.limit));\n\t\tif (params?.status) qs.set(\"status\", params.status);\n\t\tconst query = qs.toString();\n\t\treturn this.requestWithStreamId(\n\t\t\t\"GET\",\n\t\t\t(id) => `/api/streams/${id}/deliveries${query ? `?${query}` : \"\"}`,\n\t\t\tid,\n\t\t);\n\t}\n\n\t/** Get a single delivery with full payload. */\n\tasync getDelivery(\n\t\tstreamId: string,\n\t\tdeliveryId: string,\n\t): Promise<DeliveryDetail> {\n\t\tconst fullId = await this.resolveStreamId(streamId);\n\t\treturn this.request<DeliveryDetail>(\n\t\t\t\"GET\",\n\t\t\t`/api/streams/${fullId}/deliveries/${deliveryId}`,\n\t\t);\n\t}\n\n\tasync pauseAll(): Promise<BulkPauseResponse> {\n\t\treturn this.request<BulkPauseResponse>(\"POST\", \"/api/streams/pause\");\n\t}\n\n\tasync resumeAll(): Promise<BulkResumeResponse> {\n\t\treturn this.request<BulkResumeResponse>(\"POST\", \"/api/streams/resume\");\n\t}\n}\n",
|
|
10
|
+
"import type { QueueStats } from \"@secondlayer/shared/types\";\nimport { BaseClient } from \"./base.ts\";\nimport type { SecondLayerOptions } from \"./base.ts\";\nimport { Streams } from \"./streams/client.ts\";\nimport { Subgraphs } from \"./subgraphs/client.ts\";\n\nexport class SecondLayer extends BaseClient {\n\treadonly streams: Streams;\n\treadonly subgraphs: Subgraphs;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t\tthis.streams = new Streams(options);\n\t\tthis.subgraphs = new Subgraphs(options);\n\t}\n\n\tasync getQueueStats(): Promise<QueueStats> {\n\t\tconst status = await this.request<{ queue: QueueStats }>(\"GET\", \"/status\");\n\t\treturn status.queue;\n\t}\n}\n",
|
|
11
|
+
"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"
|
|
12
12
|
],
|
|
13
|
-
"mappings": ";AAeO,MAAM,iBAAiB,MAAM;AAAA,
|
|
14
|
-
"debugId": "
|
|
13
|
+
"mappings": ";AAeO,MAAM,iBAAiB,MAAM;AAAA,EAG3B;AAAA,EAFR,WAAW,CAEH,QACP,SACC;AAAA,IACD,MAAM,OAAO;AAAA,IAHN;AAAA,IAIP,KAAK,OAAO;AAAA;AAEd;;;ACfA,IAAM,mBAAmB;AAAA;AAElB,MAAe,WAAW;AAAA,EACtB;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;AAAA,SAGhB,WAAW,CAAC,QAAyC;AAAA,IAC3D,MAAM,UAAkC;AAAA,MACvC,gBAAgB;AAAA,IACjB;AAAA,IACA,IAAI,QAAQ;AAAA,MACX,QAAQ,mBAAmB,UAAU;AAAA,IACtC;AAAA,IACA,OAAO;AAAA;AAAA,OAGQ,QAAU,CACzB,QACA,MACA,MACa;AAAA,IACb,MAAM,MAAM,GAAG,KAAK,UAAU;AAAA,IAC9B,MAAM,UAAU,WAAW,YAAY,KAAK,MAAM;AAAA,IAElD,IAAI;AAAA,IACJ,IAAI;AAAA,MACH,WAAW,MAAM,MAAM,KAAK;AAAA,QAC3B;AAAA,QACA;AAAA,QACA,MAAM,OAAO,KAAK,UAAU,IAAI,IAA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,QAAQ,MAAM,GAAG;AAAA,EACzB;AAAA,EACA,IAAI,mBAAmB,aAAa;AAAA,IACnC,OAAO,QAAQ,UAAU,MAAM,GAAG;AAAA,EACnC;AAAA,EACA,OAAO,IAAI,UAAU,OAAO,EAAE,MAAM,GAAG;AAAA;",
|
|
14
|
+
"debugId": "48D7673D1282BA1664756E2164756E21",
|
|
15
15
|
"names": []
|
|
16
16
|
}
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
2
|
+
"name": "@secondlayer/sdk",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./streams": {
|
|
13
|
+
"types": "./dist/streams/index.d.ts",
|
|
14
|
+
"import": "./dist/streams/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./subgraphs": {
|
|
17
|
+
"types": "./dist/subgraphs/index.d.ts",
|
|
18
|
+
"import": "./dist/subgraphs/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "bunup",
|
|
26
|
+
"dev": "bunup --watch",
|
|
27
|
+
"test": "bun test",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"prepublishOnly": "bun run build"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@secondlayer/shared": "^0.8.0",
|
|
33
|
+
"@secondlayer/subgraphs": "^0.7.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/bun": "latest",
|
|
37
|
+
"typescript": "^5"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
42
|
}
|