@secondlayer/cli 23.1.0 → 23.2.1

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 CHANGED
@@ -12,7 +12,7 @@ secondlayer --version
12
12
 
13
13
  ## Auth
14
14
 
15
- Default API is `http://127.0.0.1:3800`. Override with `SECONDLAYER_API_URL`.
15
+ Default API is `http://127.0.0.1:3800`, or the hosted API when only `SECONDLAYER_API_KEY` is set. Override with `SECONDLAYER_API_URL`.
16
16
 
17
17
  Writes against a published bind use `INSTANCE_TOKEN` from `secondlayer init`.
18
18
  Loopback reads need no token. Your hosted account (credits, archive fetches)
@@ -191,7 +191,7 @@ or poll the subgraph API: see
191
191
  |---|---|
192
192
  | `INSTANCE_TOKEN` | From `secondlayer init` for writes. Loopback reads need no token |
193
193
  | `SECONDLAYER_API_KEY` | Hosted account key (`sk-sl_*`) |
194
- | `SECONDLAYER_API_URL` | Instance API. Default `http://127.0.0.1:3800` |
194
+ | `SECONDLAYER_API_URL` | API URL. Default `http://127.0.0.1:3800`, or hosted with only `SECONDLAYER_API_KEY` set |
195
195
  | `STACKS_NETWORK` | Default network (also via `--network <mainnet\|testnet\|devnet>`) |
196
196
  | `DATABASE_URL` | Postgres that `bootstrap`, `verify`, `repair`, and `backup` connect to. Point it at the compose Postgres (`postgres://secondlayer:<POSTGRES_PASSWORD>@127.0.0.1:5432/secondlayer`); unset, the shared dev URL `postgres://postgres:postgres@localhost:5432/secondlayer_dev` is used |
197
197
  | `HIRO_API_KEY` | Used by `secondlayer codegen contracts` for remote contract fetches |
package/dist/cli.js CHANGED
@@ -2129,9 +2129,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2129
2129
  });
2130
2130
 
2131
2131
  // src/lib/api-url.ts
2132
- import { isHostedApiUrl } from "@secondlayer/sdk";
2132
+ import { isHostedApiUrl, resolveBaseUrl } from "@secondlayer/sdk";
2133
2133
  function resolveApiUrl() {
2134
- return (process.env.SECONDLAYER_API_URL ?? LOCAL_API_URL).replace(/\/+$/, "");
2134
+ return resolveBaseUrl();
2135
2135
  }
2136
2136
  function resolveArchiveOpsUrl() {
2137
2137
  return (process.env.SL_CREDITS_API_URL ?? ARCHIVE_OPS_API_URL).replace(/\/+$/, "");
@@ -2142,8 +2142,9 @@ function isMerchantUrl(url = resolveApiUrl()) {
2142
2142
  function assertInstanceUrl(url = resolveApiUrl()) {
2143
2143
  if (!isMerchantUrl(url))
2144
2144
  return;
2145
+ const fix = process.env.SECONDLAYER_API_URL ? "unset SECONDLAYER_API_URL" : "set INSTANCE_TOKEN";
2145
2146
  throw new Error(`this command runs on your instance, not api.secondlayer.tools.
2146
- unset SECONDLAYER_API_URL, or pass --api-url http://127.0.0.1:3800`);
2147
+ ${fix}, or pass --api-url http://127.0.0.1:3800`);
2147
2148
  }
2148
2149
  var LOCAL_API_URL = "http://127.0.0.1:3800", ARCHIVE_OPS_API_URL = "https://api.secondlayer.tools";
2149
2150
  var init_api_url = () => {};
@@ -2359,7 +2360,7 @@ function ignoredEnvKeyNote(ignored) {
2359
2360
  return ignored ? " INSTANCE_TOKEN was ignored: it unlocks this instance, not your account." : "";
2360
2361
  }
2361
2362
  async function httpArchiveOps(path, opts = {}) {
2362
- const { bearer, ignoredEnvKey } = await resolveArchiveOpsBearer();
2363
+ const { bearer, source, ignoredEnvKey } = await resolveArchiveOpsBearer();
2363
2364
  if (!bearer) {
2364
2365
  throw new CliHttpError(401, "SESSION_EXPIRED", { error: "Not logged in" }, `This needs your Secondlayer account. ${ARCHIVE_AUTH_HINT}${ignoredEnvKeyNote(ignoredEnvKey)}`);
2365
2366
  }
@@ -2370,7 +2371,8 @@ async function httpArchiveOps(path, opts = {}) {
2370
2371
  });
2371
2372
  } catch (err) {
2372
2373
  if (err instanceof CliHttpError && err.status === 401) {
2373
- throw new CliHttpError(401, err.code, err.body, `Your account rejected the credential (${err.message}). ${ARCHIVE_AUTH_HINT}${ignoredEnvKeyNote(ignoredEnvKey)}`);
2374
+ const remedy = source === "session" ? `Your saved login was rejected (${err.message}). Run \`secondlayer login\`, or \`secondlayer logout\` to use SECONDLAYER_API_KEY.` : `Your account rejected the credential (${err.message}). ${ARCHIVE_AUTH_HINT}${ignoredEnvKeyNote(ignoredEnvKey)}`;
2375
+ throw new CliHttpError(401, err.code, err.body, remedy);
2374
2376
  }
2375
2377
  throw err;
2376
2378
  }
@@ -2539,9 +2541,11 @@ var init_output = __esm(() => {
2539
2541
 
2540
2542
  // src/lib/api-client.ts
2541
2543
  import { ApiError, SecondLayer } from "@secondlayer/sdk";
2542
- function nextStepHint(status, detail) {
2544
+ function nextStepHint(status, detail, code) {
2543
2545
  if (status === undefined)
2544
2546
  return;
2547
+ if (code === "STACK_ASLEEP")
2548
+ return "Any write starts it, such as creating or updating a webhook.";
2545
2549
  if (status === 402)
2546
2550
  return detail === "spend_cap_reached" ? `You reached your monthly spend cap. Raise it: ${CREDITS_URL}` : `Add credits to create webhooks and deploy subgraphs: ${CREDITS_URL}`;
2547
2551
  if (status === 403)
@@ -2581,7 +2585,7 @@ function handleApiError(err, action) {
2581
2585
  }
2582
2586
  const detail = err instanceof Error ? err.message : String(err);
2583
2587
  printError(`Failed to ${action}: ${detail}`, {
2584
- hint: nextStepHint(status, detail)
2588
+ hint: nextStepHint(status, detail, code)
2585
2589
  });
2586
2590
  process.exit(1);
2587
2591
  }
@@ -29542,7 +29546,7 @@ export default defineSubgraph({
29542
29546
  import { createHash as createHash4 } from "node:crypto";
29543
29547
  import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
29544
29548
  import { dirname as dirname4, resolve as resolve3 } from "node:path";
29545
- import { Index, resolveApiKey as resolveApiKey3, resolveBaseUrl } from "@secondlayer/sdk";
29549
+ import { Index, resolveApiKey as resolveApiKey3, resolveBaseUrl as resolveBaseUrl2 } from "@secondlayer/sdk";
29546
29550
  import {
29547
29551
  DECODED_EVENT_TYPES,
29548
29552
  VM_EVENT_TYPES
@@ -29591,7 +29595,7 @@ function eventTypeFor(filter) {
29591
29595
  return null;
29592
29596
  }
29593
29597
  function indexApiUrl() {
29594
- return resolveBaseUrl();
29598
+ return resolveBaseUrl2();
29595
29599
  }
29596
29600
  function indexReadFailure(err, ctx) {
29597
29601
  const e = err;
@@ -29808,7 +29812,7 @@ import { existsSync as existsSync3 } from "node:fs";
29808
29812
  import { resolve as resolve4 } from "node:path";
29809
29813
  import {
29810
29814
  Index as Index2,
29811
- resolveBaseUrl as resolveBaseUrl2
29815
+ resolveBaseUrl as resolveBaseUrl3
29812
29816
  } from "@secondlayer/sdk";
29813
29817
  import {
29814
29818
  DECODED_EVENT_TYPES as DECODED_EVENT_TYPES2
@@ -29903,7 +29907,7 @@ async function runSubgraphPreview(file, options) {
29903
29907
  source: name,
29904
29908
  fromHeight,
29905
29909
  toHeight,
29906
- apiUrl: resolveBaseUrl2(),
29910
+ apiUrl: resolveBaseUrl3(),
29907
29911
  file
29908
29912
  });
29909
29913
  printError(failure.message, { hint: failure.hint });
@@ -29934,7 +29938,7 @@ async function runSubgraphPreview(file, options) {
29934
29938
  source: name,
29935
29939
  fromHeight,
29936
29940
  toHeight,
29937
- apiUrl: resolveBaseUrl2(),
29941
+ apiUrl: resolveBaseUrl3(),
29938
29942
  file
29939
29943
  });
29940
29944
  printError(failure.message, { hint: failure.hint });
@@ -31888,7 +31892,7 @@ var {
31888
31892
  // package.json
31889
31893
  var package_default = {
31890
31894
  name: "@secondlayer/cli",
31891
- version: "23.1.0",
31895
+ version: "23.2.1",
31892
31896
  description: "Run a Stacks index on your own hardware — set it up, restore verified history, and keep it current.",
31893
31897
  repository: {
31894
31898
  type: "git",
@@ -31937,7 +31941,7 @@ var package_default = {
31937
31941
  "@inquirer/prompts": "^8.2.0",
31938
31942
  "@secondlayer/bundler": "^0.7.3",
31939
31943
  "@secondlayer/scaffold": "^1.6.3",
31940
- "@secondlayer/sdk": "^16.0.0",
31944
+ "@secondlayer/sdk": "^16.2.0",
31941
31945
  "@secondlayer/shared": "^15.0.0",
31942
31946
  "@secondlayer/stacks": "^6.5.3",
31943
31947
  "@secondlayer/subgraphs": "^8.0.1",
@@ -35960,7 +35964,7 @@ function dockerCompose(composePath, args) {
35960
35964
  });
35961
35965
  return res.status ?? 1;
35962
35966
  }
35963
- var API_URL = resolveApiUrl();
35967
+ var API_URL = (process.env.SECONDLAYER_API_URL || LOCAL_API_URL).replace(/\/+$/, "");
35964
35968
  var INDEXER_URL = process.env.INDEXER_URL ?? "http://localhost:3700";
35965
35969
  var SERVICES = [
35966
35970
  "indexer",
@@ -37777,5 +37781,5 @@ registerCreditsCommand(program);
37777
37781
  registerArchiveCommand(program);
37778
37782
  program.parse();
37779
37783
 
37780
- //# debugId=0DC9F45DD895F4A264756E2164756E21
37784
+ //# debugId=F92A663889BDE04D64756E2164756E21
37781
37785
  //# sourceMappingURL=cli.js.map