@secondlayer/sdk 16.1.0 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +14 -15
- package/dist/index.js.map +5 -5
- package/dist/sinks/bun-sqlite.js +5 -3
- package/dist/sinks/bun-sqlite.js.map +3 -3
- package/dist/sinks/core.js +5 -3
- package/dist/sinks/core.js.map +3 -3
- package/dist/sinks/drizzle.js +5 -3
- package/dist/sinks/drizzle.js.map +3 -3
- package/dist/sinks/kysely.js +5 -3
- package/dist/sinks/kysely.js.map +3 -3
- package/dist/streams/index.js +14 -15
- package/dist/streams/index.js.map +5 -5
- package/dist/subgraphs/index.js +14 -15
- package/dist/subgraphs/index.js.map +5 -5
- package/package.json +1 -1
package/dist/subgraphs/index.js
CHANGED
|
@@ -53,7 +53,9 @@ ${detailBlocks.join(`
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
function statusRetryable(status) {
|
|
56
|
+
function statusRetryable(status, code) {
|
|
57
|
+
if (code === "STACK_ASLEEP")
|
|
58
|
+
return false;
|
|
57
59
|
return status === 429 || status >= 500;
|
|
58
60
|
}
|
|
59
61
|
function docsFor(status, code) {
|
|
@@ -70,7 +72,7 @@ class ApiError extends SecondLayerError {
|
|
|
70
72
|
constructor(status, message, body, code, options = {}) {
|
|
71
73
|
super(message, {
|
|
72
74
|
code,
|
|
73
|
-
retryable: options.retryable ?? statusRetryable(status),
|
|
75
|
+
retryable: options.retryable ?? statusRetryable(status, code),
|
|
74
76
|
docsUrl: options.docsUrl ?? docsFor(status, code),
|
|
75
77
|
...options.cause ? { cause: options.cause } : {},
|
|
76
78
|
...options.details ? { details: options.details } : {},
|
|
@@ -210,18 +212,15 @@ var LOCAL_API_URL = "http://127.0.0.1:3800";
|
|
|
210
212
|
var HOSTED_API_URL = "https://api.secondlayer.tools";
|
|
211
213
|
var INSTANCE_TOKEN_ENV = "INSTANCE_TOKEN";
|
|
212
214
|
var ACCOUNT_KEY_ENV = "SECONDLAYER_API_KEY";
|
|
213
|
-
function resolveBaseUrl(explicit) {
|
|
215
|
+
function resolveBaseUrl(explicit, apiKey) {
|
|
214
216
|
if (explicit && explicit.length > 0)
|
|
215
217
|
return explicit.replace(/\/+$/, "");
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return LOCAL_API_URL;
|
|
218
|
+
const env = typeof process !== "undefined" ? process.env : undefined;
|
|
219
|
+
const primary = env?.SECONDLAYER_API_URL || undefined;
|
|
220
|
+
if (primary)
|
|
221
|
+
return primary.replace(/\/+$/, "");
|
|
222
|
+
const key = apiKey ?? (env?.[INSTANCE_TOKEN_ENV] ? undefined : env?.[ACCOUNT_KEY_ENV]);
|
|
223
|
+
return key?.startsWith("sk-sl_") ? HOSTED_API_URL : LOCAL_API_URL;
|
|
225
224
|
}
|
|
226
225
|
function isHostedApiUrl(url) {
|
|
227
226
|
try {
|
|
@@ -293,7 +292,7 @@ class BaseClient {
|
|
|
293
292
|
requestTimeoutMs;
|
|
294
293
|
etagCache;
|
|
295
294
|
constructor(options = {}) {
|
|
296
|
-
this.baseUrl = resolveBaseUrl(options.baseUrl);
|
|
295
|
+
this.baseUrl = resolveBaseUrl(options.baseUrl, options.apiKey);
|
|
297
296
|
this.apiKey = resolveApiKey(options.apiKey, this.baseUrl);
|
|
298
297
|
this.origin = options.origin ?? "cli";
|
|
299
298
|
this.requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
@@ -2350,7 +2349,7 @@ function isLoopbackUrl(baseUrl) {
|
|
|
2350
2349
|
}
|
|
2351
2350
|
}
|
|
2352
2351
|
function createStreamsClient(options) {
|
|
2353
|
-
const baseUrl = normalizeBaseUrl(resolveBaseUrl(options.baseUrl));
|
|
2352
|
+
const baseUrl = normalizeBaseUrl(resolveBaseUrl(options.baseUrl, options.apiKey));
|
|
2354
2353
|
const apiKey = resolveApiKey(options.apiKey, baseUrl);
|
|
2355
2354
|
const origin = options.origin ?? "cli";
|
|
2356
2355
|
const authHeaders = () => ({
|
|
@@ -2847,5 +2846,5 @@ export {
|
|
|
2847
2846
|
getSubgraph
|
|
2848
2847
|
};
|
|
2849
2848
|
|
|
2850
|
-
//# debugId=
|
|
2849
|
+
//# debugId=4BBCD55406927B9364756E2164756E21
|
|
2851
2850
|
//# sourceMappingURL=index.js.map
|