@secondlayer/cli 5.4.1 → 5.4.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/dist/cli.js +27 -33
- package/dist/cli.js.map +10 -10
- package/package.json +3 -3
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.3",
|
|
32325
32325
|
description: "CLI for subgraphs and blockchain indexing on Stacks",
|
|
32326
32326
|
type: "module",
|
|
32327
32327
|
bin: {
|
|
@@ -32365,9 +32365,9 @@ 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.2",
|
|
32369
32369
|
"@secondlayer/stacks": "^2.2.0",
|
|
32370
|
-
"@secondlayer/subgraphs": "^2.0.
|
|
32370
|
+
"@secondlayer/subgraphs": "^2.0.3",
|
|
32371
32371
|
"@biomejs/js-api": "^0.7.0",
|
|
32372
32372
|
"@biomejs/wasm-nodejs": "^1.9.0",
|
|
32373
32373
|
esbuild: "^0.19.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,
|
|
@@ -35031,7 +35031,7 @@ function decodeBuffUtf8(value: unknown): string | null {
|
|
|
35031
35031
|
|
|
35032
35032
|
// src/commands/subgraphs.ts
|
|
35033
35033
|
init_api();
|
|
35034
|
-
|
|
35034
|
+
init_resolve_auth();
|
|
35035
35035
|
async function loadSubgraphWithDepCheck(absPath) {
|
|
35036
35036
|
try {
|
|
35037
35037
|
return await import(absPath);
|
|
@@ -35389,7 +35389,7 @@ Stopped watching.`);
|
|
|
35389
35389
|
});
|
|
35390
35390
|
await new Promise(() => {});
|
|
35391
35391
|
});
|
|
35392
|
-
subgraphs.command("deploy <file>").description("Deploy a subgraph definition file").option("--
|
|
35392
|
+
subgraphs.command("deploy <file>").description("Deploy a subgraph definition file").option("--start-block <n>", "Override the subgraph definition startBlock for this deploy").option("--dry-run", "Validate and preview deploy without writing changes").option("--preview", "Alias for --dry-run").option("--force", "Skip confirmation prompt for reindex operations").option("--strict", "Run `tsc --noEmit` against the handler before deploy (slower; catches TS type errors)").action(async (file, options2) => {
|
|
35393
35393
|
try {
|
|
35394
35394
|
const absPath = resolve2(file);
|
|
35395
35395
|
const config = await loadConfig();
|
|
@@ -35421,7 +35421,7 @@ Stopped watching.`);
|
|
|
35421
35421
|
if (dryRun) {
|
|
35422
35422
|
printSubgraphDeployPreview(createSubgraphDeployPreview({
|
|
35423
35423
|
...validated,
|
|
35424
|
-
version:
|
|
35424
|
+
version: validated.version
|
|
35425
35425
|
}, {
|
|
35426
35426
|
bundleBytes: Buffer.byteLength(handlerCode, "utf8")
|
|
35427
35427
|
}), {
|
|
@@ -35433,7 +35433,7 @@ Stopped watching.`);
|
|
|
35433
35433
|
}
|
|
35434
35434
|
const result = await deploySubgraphApi({
|
|
35435
35435
|
name: effectiveDef.name,
|
|
35436
|
-
version:
|
|
35436
|
+
version: undefined,
|
|
35437
35437
|
description: effectiveDef.description,
|
|
35438
35438
|
sources: effectiveDef.sources,
|
|
35439
35439
|
schema: effectiveDef.schema,
|
|
@@ -35443,7 +35443,7 @@ Stopped watching.`);
|
|
|
35443
35443
|
});
|
|
35444
35444
|
const printDeployFooter = async () => {
|
|
35445
35445
|
try {
|
|
35446
|
-
const { apiUrl } = await
|
|
35446
|
+
const { apiUrl } = await resolveAuth();
|
|
35447
35447
|
const baseUrl = deriveBaseUrl(apiUrl);
|
|
35448
35448
|
const firstTable = Object.keys(effectiveDef.schema ?? {})[0];
|
|
35449
35449
|
info(` Dashboard: ${baseUrl}/platform/subgraphs/${effectiveDef.name}`);
|
|
@@ -35455,6 +35455,8 @@ Stopped watching.`);
|
|
|
35455
35455
|
};
|
|
35456
35456
|
if (result.action === "unchanged") {
|
|
35457
35457
|
info(`Subgraph "${effectiveDef.name}" is up to date (v${result.version} — no changes)`);
|
|
35458
|
+
} else if (result.action === "handler_updated") {
|
|
35459
|
+
success(`Subgraph "${effectiveDef.name}" handler updated (v${result.version} — schema unchanged, no reindex needed)`);
|
|
35458
35460
|
} else if (result.action === "created") {
|
|
35459
35461
|
success(`Subgraph "${effectiveDef.name}" created → v${result.version}`);
|
|
35460
35462
|
await printDeployFooter();
|
|
@@ -35497,7 +35499,7 @@ Stopped watching.`);
|
|
|
35497
35499
|
if (dryRun) {
|
|
35498
35500
|
printSubgraphDeployPreview(createSubgraphDeployPreview({
|
|
35499
35501
|
...validated,
|
|
35500
|
-
version:
|
|
35502
|
+
version: validated.version
|
|
35501
35503
|
}), {
|
|
35502
35504
|
network: config.network,
|
|
35503
35505
|
file: absPath,
|
|
@@ -35509,11 +35511,13 @@ Stopped watching.`);
|
|
|
35509
35511
|
const { getDb: getDb2, closeDb } = await import("@secondlayer/shared/db");
|
|
35510
35512
|
const db = getDb2();
|
|
35511
35513
|
const result = await deploySchema(db, effectiveDef, absPath, {
|
|
35512
|
-
version:
|
|
35514
|
+
version: undefined,
|
|
35513
35515
|
forceReindex: startBlock !== undefined
|
|
35514
35516
|
});
|
|
35515
35517
|
if (result.action === "unchanged") {
|
|
35516
35518
|
info(`Subgraph "${effectiveDef.name}" is up to date (v${result.version} — no changes)`);
|
|
35519
|
+
} else if (result.action === "handler_updated") {
|
|
35520
|
+
success(`Subgraph "${effectiveDef.name}" handler updated (v${result.version} — schema unchanged, no reindex needed)`);
|
|
35517
35521
|
} else if (result.action === "created") {
|
|
35518
35522
|
success(`Subgraph "${effectiveDef.name}" created → v${result.version}`);
|
|
35519
35523
|
} else if (result.action === "reindexed") {
|
|
@@ -36923,16 +36927,6 @@ function registerWhoamiCommand(program2) {
|
|
|
36923
36927
|
} else {
|
|
36924
36928
|
rows.push(["Project", dim("(none — run `sl project create <name>`)")]);
|
|
36925
36929
|
}
|
|
36926
|
-
try {
|
|
36927
|
-
const tenant = await httpPlatform("/api/tenants/me");
|
|
36928
|
-
if (tenant.tenant) {
|
|
36929
|
-
rows.push(["Instance", tenant.tenant.apiUrl]);
|
|
36930
|
-
rows.push(["Plan", tenant.tenant.plan]);
|
|
36931
|
-
rows.push(["Status", tenant.tenant.status]);
|
|
36932
|
-
} else {
|
|
36933
|
-
rows.push(["Plan", dim("open beta (shared platform)")]);
|
|
36934
|
-
}
|
|
36935
|
-
} catch {}
|
|
36936
36930
|
console.log(formatKeyValue(rows));
|
|
36937
36931
|
});
|
|
36938
36932
|
}
|
|
@@ -37100,5 +37094,5 @@ registerAccountCommand(program);
|
|
|
37100
37094
|
registerBillingCommand(program);
|
|
37101
37095
|
program.parse();
|
|
37102
37096
|
|
|
37103
|
-
//# debugId=
|
|
37097
|
+
//# debugId=28D6666040039CE464756E2164756E21
|
|
37104
37098
|
//# sourceMappingURL=cli.js.map
|