@secondlayer/cli 5.4.2 → 5.4.4
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/cli.js +19 -28
- package/dist/cli.js.map +10 -10
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -2518,8 +2518,8 @@ var init_session = __esm(() => {
|
|
|
2518
2518
|
SESSION_PATH = join(SESSION_DIR, "session.json");
|
|
2519
2519
|
});
|
|
2520
2520
|
|
|
2521
|
-
// src/lib/resolve-
|
|
2522
|
-
async function
|
|
2521
|
+
// src/lib/resolve-auth.ts
|
|
2522
|
+
async function resolveAuth() {
|
|
2523
2523
|
const envUrl = process.env.SL_API_URL;
|
|
2524
2524
|
const envKey = process.env.SL_SERVICE_KEY;
|
|
2525
2525
|
if (envUrl && envKey) {
|
|
@@ -2538,7 +2538,7 @@ async function resolveActiveTenant(_opts = {}) {
|
|
|
2538
2538
|
};
|
|
2539
2539
|
}
|
|
2540
2540
|
var PLATFORM_API_URL2;
|
|
2541
|
-
var
|
|
2541
|
+
var init_resolve_auth = __esm(() => {
|
|
2542
2542
|
init_session();
|
|
2543
2543
|
PLATFORM_API_URL2 = process.env.SL_PLATFORM_API_URL ?? "https://api.secondlayer.tools";
|
|
2544
2544
|
});
|
|
@@ -12888,7 +12888,7 @@ class StacksApiClient {
|
|
|
12888
12888
|
async ensureProxy() {
|
|
12889
12889
|
if (!this.useProxy || this.baseUrl)
|
|
12890
12890
|
return;
|
|
12891
|
-
const { apiUrl, ephemeralKey } = await
|
|
12891
|
+
const { apiUrl, ephemeralKey } = await resolveAuth();
|
|
12892
12892
|
this.baseUrl = apiUrl.replace(/\/$/, "");
|
|
12893
12893
|
this.headers = { authorization: `Bearer ${ephemeralKey}` };
|
|
12894
12894
|
}
|
|
@@ -12937,7 +12937,7 @@ class StacksApiClient {
|
|
|
12937
12937
|
var contractFetch;
|
|
12938
12938
|
var init_api = __esm(() => {
|
|
12939
12939
|
init_source3();
|
|
12940
|
-
|
|
12940
|
+
init_resolve_auth();
|
|
12941
12941
|
contractFetch = source_default2.extend({
|
|
12942
12942
|
timeout: { request: 15000 },
|
|
12943
12943
|
retry: {
|
|
@@ -32321,7 +32321,7 @@ var {
|
|
|
32321
32321
|
// package.json
|
|
32322
32322
|
var package_default = {
|
|
32323
32323
|
name: "@secondlayer/cli",
|
|
32324
|
-
version: "5.4.
|
|
32324
|
+
version: "5.4.4",
|
|
32325
32325
|
description: "CLI for subgraphs and blockchain indexing on Stacks",
|
|
32326
32326
|
type: "module",
|
|
32327
32327
|
bin: {
|
|
@@ -32365,7 +32365,7 @@ var package_default = {
|
|
|
32365
32365
|
"@inquirer/prompts": "^8.2.0",
|
|
32366
32366
|
"@secondlayer/bundler": "^0.3.5",
|
|
32367
32367
|
"@secondlayer/sdk": "^3.6.0",
|
|
32368
|
-
"@secondlayer/shared": "^6.4.
|
|
32368
|
+
"@secondlayer/shared": "^6.4.3",
|
|
32369
32369
|
"@secondlayer/stacks": "^2.2.0",
|
|
32370
32370
|
"@secondlayer/subgraphs": "^2.0.3",
|
|
32371
32371
|
"@biomejs/js-api": "^0.7.0",
|
|
@@ -32451,7 +32451,7 @@ async function httpPlatformAnon(path2, opts = {}) {
|
|
|
32451
32451
|
}
|
|
32452
32452
|
|
|
32453
32453
|
// src/lib/api-client.ts
|
|
32454
|
-
|
|
32454
|
+
init_resolve_auth();
|
|
32455
32455
|
function handleApiError(err, action) {
|
|
32456
32456
|
if (err instanceof CliHttpError) {
|
|
32457
32457
|
if (err.code === "SESSION_EXPIRED") {
|
|
@@ -32480,7 +32480,7 @@ function withErrorHandling(fn, options) {
|
|
|
32480
32480
|
};
|
|
32481
32481
|
}
|
|
32482
32482
|
async function getPlatformClient() {
|
|
32483
|
-
const { apiUrl, ephemeralKey } = await
|
|
32483
|
+
const { apiUrl, ephemeralKey } = await resolveAuth();
|
|
32484
32484
|
return new SecondLayer({ baseUrl: apiUrl, apiKey: ephemeralKey });
|
|
32485
32485
|
}
|
|
32486
32486
|
async function listSubgraphsApi() {
|
|
@@ -33075,7 +33075,7 @@ function parseSubscriptionFilter(args) {
|
|
|
33075
33075
|
|
|
33076
33076
|
// src/commands/create.ts
|
|
33077
33077
|
init_output();
|
|
33078
|
-
|
|
33078
|
+
init_resolve_auth();
|
|
33079
33079
|
|
|
33080
33080
|
// src/lib/subscription-validation.ts
|
|
33081
33081
|
import {
|
|
@@ -33274,7 +33274,7 @@ SIGNING_SECRET=${signingSecret}
|
|
|
33274
33274
|
}
|
|
33275
33275
|
let dashboardLine = "";
|
|
33276
33276
|
try {
|
|
33277
|
-
const { apiUrl } = await
|
|
33277
|
+
const { apiUrl } = await resolveAuth();
|
|
33278
33278
|
const base = deriveBaseUrl(apiUrl);
|
|
33279
33279
|
dashboardLine = subscriptionId ? `Dashboard: ${base}/platform/subgraphs/${subgraph}/subscriptions/${subscriptionId}
|
|
33280
33280
|
` : `Dashboard: ${base}/platform/subgraphs/${subgraph}/subscriptions
|
|
@@ -33300,7 +33300,7 @@ function resolveSubscriptionClientConfig(opts, env = process.env, resolved) {
|
|
|
33300
33300
|
throw new Error("No service key available. Run `sl login` from an active project or pass --service-key.");
|
|
33301
33301
|
}
|
|
33302
33302
|
if (!baseUrl) {
|
|
33303
|
-
throw new Error("No
|
|
33303
|
+
throw new Error("No API URL available. Run `sl login` or pass --base-url.");
|
|
33304
33304
|
}
|
|
33305
33305
|
return { needsTenantResolution: false, baseUrl, apiKey };
|
|
33306
33306
|
}
|
|
@@ -33309,10 +33309,10 @@ async function getSubscriptionClient(opts) {
|
|
|
33309
33309
|
if (!config.needsTenantResolution) {
|
|
33310
33310
|
return new SecondLayer2({ baseUrl: config.baseUrl, apiKey: config.apiKey });
|
|
33311
33311
|
}
|
|
33312
|
-
const resolved = await
|
|
33312
|
+
const resolved = await resolveAuth();
|
|
33313
33313
|
const resolvedConfig = resolveSubscriptionClientConfig(opts, process.env, resolved);
|
|
33314
33314
|
if (resolvedConfig.needsTenantResolution) {
|
|
33315
|
-
throw new Error("Could not resolve
|
|
33315
|
+
throw new Error("Could not resolve credentials — run `sl login`.");
|
|
33316
33316
|
}
|
|
33317
33317
|
return new SecondLayer2({
|
|
33318
33318
|
baseUrl: resolvedConfig.baseUrl,
|
|
@@ -34659,6 +34659,7 @@ async function requireAuth() {
|
|
|
34659
34659
|
}
|
|
34660
34660
|
|
|
34661
34661
|
// src/commands/subgraphs.ts
|
|
34662
|
+
init_resolve_auth();
|
|
34662
34663
|
init_clarity();
|
|
34663
34664
|
|
|
34664
34665
|
// src/templates/subgraph.ts
|
|
@@ -35031,7 +35032,6 @@ function decodeBuffUtf8(value: unknown): string | null {
|
|
|
35031
35032
|
|
|
35032
35033
|
// src/commands/subgraphs.ts
|
|
35033
35034
|
init_api();
|
|
35034
|
-
init_resolve_tenant();
|
|
35035
35035
|
async function loadSubgraphWithDepCheck(absPath) {
|
|
35036
35036
|
try {
|
|
35037
35037
|
return await import(absPath);
|
|
@@ -35431,6 +35431,7 @@ Stopped watching.`);
|
|
|
35431
35431
|
});
|
|
35432
35432
|
return;
|
|
35433
35433
|
}
|
|
35434
|
+
const deployStartBlock = startBlock ?? effectiveDef.startBlock;
|
|
35434
35435
|
const result = await deploySubgraphApi({
|
|
35435
35436
|
name: effectiveDef.name,
|
|
35436
35437
|
version: undefined,
|
|
@@ -35439,11 +35440,11 @@ Stopped watching.`);
|
|
|
35439
35440
|
schema: effectiveDef.schema,
|
|
35440
35441
|
handlerCode,
|
|
35441
35442
|
sourceCode: source,
|
|
35442
|
-
...
|
|
35443
|
+
...deployStartBlock !== undefined ? { startBlock: deployStartBlock } : {}
|
|
35443
35444
|
});
|
|
35444
35445
|
const printDeployFooter = async () => {
|
|
35445
35446
|
try {
|
|
35446
|
-
const { apiUrl } = await
|
|
35447
|
+
const { apiUrl } = await resolveAuth();
|
|
35447
35448
|
const baseUrl = deriveBaseUrl(apiUrl);
|
|
35448
35449
|
const firstTable = Object.keys(effectiveDef.schema ?? {})[0];
|
|
35449
35450
|
info(` Dashboard: ${baseUrl}/platform/subgraphs/${effectiveDef.name}`);
|
|
@@ -36927,16 +36928,6 @@ function registerWhoamiCommand(program2) {
|
|
|
36927
36928
|
} else {
|
|
36928
36929
|
rows.push(["Project", dim("(none — run `sl project create <name>`)")]);
|
|
36929
36930
|
}
|
|
36930
|
-
try {
|
|
36931
|
-
const tenant = await httpPlatform("/api/tenants/me");
|
|
36932
|
-
if (tenant.tenant) {
|
|
36933
|
-
rows.push(["Instance", tenant.tenant.apiUrl]);
|
|
36934
|
-
rows.push(["Plan", tenant.tenant.plan]);
|
|
36935
|
-
rows.push(["Status", tenant.tenant.status]);
|
|
36936
|
-
} else {
|
|
36937
|
-
rows.push(["Plan", dim("open beta (shared platform)")]);
|
|
36938
|
-
}
|
|
36939
|
-
} catch {}
|
|
36940
36931
|
console.log(formatKeyValue(rows));
|
|
36941
36932
|
});
|
|
36942
36933
|
}
|
|
@@ -37104,5 +37095,5 @@ registerAccountCommand(program);
|
|
|
37104
37095
|
registerBillingCommand(program);
|
|
37105
37096
|
program.parse();
|
|
37106
37097
|
|
|
37107
|
-
//# debugId=
|
|
37098
|
+
//# debugId=200225BF0391B2CF64756E2164756E21
|
|
37108
37099
|
//# sourceMappingURL=cli.js.map
|