@secondlayer/cli 16.4.0 → 17.0.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,14 +12,14 @@ secondlayer --version
12
12
 
13
13
  ## Auth
14
14
 
15
- Default API is `http://127.0.0.1:3800`. Override with `SL_API_URL`.
15
+ Default API is `http://127.0.0.1:3800`. 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. Hosted API and archive credits use
19
19
  `SECONDLAYER_API_KEY` (`sk-sl_*`).
20
20
 
21
21
  ```bash
22
- export SL_API_URL=http://127.0.0.1:3800
22
+ export SECONDLAYER_API_URL=http://127.0.0.1:3800
23
23
  export INSTANCE_TOKEN=<from secondlayer init>
24
24
  ```
25
25
 
@@ -190,9 +190,9 @@ operates on both kinds.
190
190
  | Var | Purpose |
191
191
  |---|---|
192
192
  | `INSTANCE_TOKEN` | From `secondlayer init` for writes. Loopback reads need no token |
193
- | `SECONDLAYER_API_KEY` | Hosted account key (`sk-sl_*`). `SL_API_KEY` is a one-release hosted fallback |
194
- | `SL_API_URL` | Instance API. Default `http://127.0.0.1:3800` |
195
- | `SL_PLATFORM_API_URL` | Alias of `SL_API_URL` |
193
+ | `SECONDLAYER_API_KEY` | Hosted account key (`sk-sl_*`) |
194
+ | `SECONDLAYER_API_URL` | Instance API. Default `http://127.0.0.1:3800` |
195
+ | `SL_PLATFORM_API_URL` | Alias of `SECONDLAYER_API_URL` |
196
196
  | `STACKS_NETWORK` | Default network (also via `--network <mainnet\|testnet\|devnet>`) |
197
197
  | `DATABASE_URL` | Postgres that `bootstrap`, `verify`, `repair`, and `backup` connect to. `secondlayer setup` writes it into `.env` pointing at the compose Postgres; unset, the shared dev URL `postgres://postgres:postgres@localhost:5432/secondlayer_dev` is used |
198
198
  | `HIRO_API_KEY` | Used by `secondlayer codegen contracts` for remote contract fetches |
package/dist/cli.js CHANGED
@@ -2143,7 +2143,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2143
2143
 
2144
2144
  // src/lib/api-url.ts
2145
2145
  function resolveApiUrl() {
2146
- return (process.env.SECONDLAYER_API_URL ?? process.env.SL_API_URL ?? process.env.SL_PLATFORM_API_URL ?? LOCAL_API_URL).replace(/\/+$/, "");
2146
+ return (process.env.SECONDLAYER_API_URL ?? process.env.SL_PLATFORM_API_URL ?? LOCAL_API_URL).replace(/\/+$/, "");
2147
2147
  }
2148
2148
  function resolveArchiveOpsUrl() {
2149
2149
  return (process.env.SL_CREDITS_API_URL ?? ARCHIVE_OPS_API_URL).replace(/\/+$/, "");
@@ -2258,7 +2258,6 @@ function resolveEnvKey() {
2258
2258
  function applyApiKeyFlag(apiKey) {
2259
2259
  if (/^s[ks]-sl_/.test(apiKey)) {
2260
2260
  process.env.SECONDLAYER_API_KEY = apiKey;
2261
- process.env.SL_API_KEY = apiKey;
2262
2261
  } else {
2263
2262
  process.env.INSTANCE_TOKEN = apiKey;
2264
2263
  }
@@ -198407,13 +198406,13 @@ function indexReadFailure(err, ctx) {
198407
198406
  const credential = resolveApiKey3() ? "INSTANCE_TOKEN is set in this shell" : "no INSTANCE_TOKEN is set in this shell";
198408
198407
  return {
198409
198408
  message: `Index read rejected (HTTP ${status}) while ${where}.`,
198410
- hint: `${credential}. This read uses the same SL_API_URL + INSTANCE_TOKEN pair as \`secondlayer subgraphs deploy\` — confirm both point at the instance you deployed to (\`secondlayer status\`), then retry. ${offlineHint}`
198409
+ hint: `${credential}. This read uses the same SECONDLAYER_API_URL + INSTANCE_TOKEN pair as \`secondlayer subgraphs deploy\` — confirm both point at the instance you deployed to (\`secondlayer status\`), then retry. ${offlineHint}`
198411
198410
  };
198412
198411
  }
198413
198412
  if (status === 404) {
198414
198413
  return {
198415
198414
  message: `Index read returned 404 while ${where}.`,
198416
- hint: `${ctx.apiUrl} answered but serves no /v1/index/events — check SL_API_URL points at a Secondlayer instance, not a Stacks node.`
198415
+ hint: `${ctx.apiUrl} answered but serves no /v1/index/events — check SECONDLAYER_API_URL points at a Secondlayer instance, not a Stacks node.`
198417
198416
  };
198418
198417
  }
198419
198418
  if (status === 429) {
@@ -202496,7 +202495,7 @@ var {
202496
202495
  // package.json
202497
202496
  var package_default = {
202498
202497
  name: "@secondlayer/cli",
202499
- version: "16.4.0",
202498
+ version: "17.0.1",
202500
202499
  description: "Run a Stacks index on your own hardware — set it up, restore verified history, and keep it current.",
202501
202500
  repository: {
202502
202501
  type: "git",
@@ -202535,8 +202534,8 @@ var package_default = {
202535
202534
  "@inquirer/prompts": "^8.2.0",
202536
202535
  "@secondlayer/bundler": "^0.6.1",
202537
202536
  "@secondlayer/scaffold": "^1.6.1",
202538
- "@secondlayer/sdk": "^11.0.0",
202539
- "@secondlayer/shared": "^11.8.1",
202537
+ "@secondlayer/sdk": "^12.1.0",
202538
+ "@secondlayer/shared": "^11.10.1",
202540
202539
  "@secondlayer/stacks": "^6.1.0",
202541
202540
  "@secondlayer/subgraphs": "^6.1.0",
202542
202541
  esbuild: "^0.28.2",
@@ -204802,6 +204801,7 @@ init_api_client();
204802
204801
  init_filter_params();
204803
204802
  init_output();
204804
204803
  init_resolve_auth();
204804
+ import { buildDoctorReport, isSuccessDelivery } from "@secondlayer/sdk";
204805
204805
  import { sign } from "@secondlayer/shared/crypto/standard-webhooks";
204806
204806
 
204807
204807
  // src/lib/webhook-validation.ts
@@ -205180,9 +205180,6 @@ function truncate(value, max = 48) {
205180
205180
  function formatMaybeDate(value) {
205181
205181
  return value ? value.replace("T", " ").slice(0, 19) : dim("-");
205182
205182
  }
205183
- function isSuccessDelivery(row) {
205184
- return row.statusCode !== null && row.statusCode >= 200 && row.statusCode < 300;
205185
- }
205186
205183
  function printJson(value) {
205187
205184
  console.log(JSON.stringify(value, null, 2));
205188
205185
  }
@@ -205281,59 +205278,6 @@ Auth config:`));
205281
205278
  console.log(JSON.stringify(sub.authConfig, null, 2));
205282
205279
  }
205283
205280
  }
205284
- function buildDoctorReport(input) {
205285
- const successful = input.deliveries.filter(isSuccessDelivery).length;
205286
- const failed = input.deliveries.length - successful;
205287
- const subgraph = input.subgraph ? {
205288
- name: input.subgraph.name,
205289
- status: input.subgraph.status,
205290
- syncStatus: input.subgraph.sync.status,
205291
- lastProcessedBlock: input.subgraph.sync.lastProcessedBlock,
205292
- chainTip: input.subgraph.sync.chainTip,
205293
- gapCount: input.subgraph.sync.gaps.count,
205294
- integrity: input.subgraph.sync.integrity
205295
- } : null;
205296
- const hints = [];
205297
- if (input.webhook.warning) {
205298
- hints.push(input.webhook.warning);
205299
- }
205300
- if (input.webhook.status === "paused") {
205301
- hints.push(`Resume when the receiver is healthy: secondlayer webhooks resume ${input.webhook.id}`);
205302
- }
205303
- if (input.webhook.lastError) {
205304
- hints.push("Run secondlayer webhooks test to reproduce the receiver request.");
205305
- }
205306
- if (input.webhook.circuitOpenedAt || input.webhook.circuitFailures > 0) {
205307
- hints.push("Circuit breaker has failures; inspect receiver logs and delivery status codes.");
205308
- }
205309
- if (input.dead.length > 0) {
205310
- hints.push(`Dead-letter rows exist; inspect with secondlayer webhooks dead ${input.webhook.id} and requeue selected rows.`);
205311
- }
205312
- if (subgraph?.gapCount && subgraph.gapCount > 0) {
205313
- hints.push(`Linked subgraph has gaps; run secondlayer subgraphs gaps ${input.webhook.subgraphName}.`);
205314
- }
205315
- if (subgraph?.syncStatus === "catching_up") {
205316
- hints.push("Linked subgraph is still catching up; new matching rows may arrive later.");
205317
- }
205318
- if (input.deliveries.length === 0) {
205319
- hints.push("No deliveries yet; confirm the table is receiving inserted rows that match the filter.");
205320
- }
205321
- if (hints.length === 0) {
205322
- hints.push("No immediate action needed.");
205323
- }
205324
- return {
205325
- webhook: input.webhook,
205326
- deliverySummary: {
205327
- total: input.deliveries.length,
205328
- successful,
205329
- failed,
205330
- last: input.deliveries[0] ?? null
205331
- },
205332
- deadCount: input.dead.length,
205333
- subgraph,
205334
- hints
205335
- };
205336
- }
205337
205281
  function printDoctorReport(report) {
205338
205282
  const sub = report.webhook;
205339
205283
  console.log(formatKeyValue([
@@ -206164,7 +206108,7 @@ function dockerCompose(composePath, args) {
206164
206108
  });
206165
206109
  return res.status ?? 1;
206166
206110
  }
206167
- var API_URL = process.env.SL_API_URL ?? "http://localhost:3800";
206111
+ var API_URL = resolveApiUrl();
206168
206112
  var INDEXER_URL = process.env.INDEXER_URL ?? "http://localhost:3700";
206169
206113
  var SERVICES = [
206170
206114
  "indexer",
@@ -206241,7 +206185,7 @@ ${bold("Secondlayer stack up")}`);
206241
206185
  console.log(`
206242
206186
  ${bold("Next:")}`);
206243
206187
  console.log(` ${yellow("clarinet devnet start")} ${dim("# auto-deploys + streams to the indexer")}`);
206244
- console.log(` ${yellow(`SL_API_URL=http://localhost:3800 INSTANCE_TOKEN=${DEV_INSTANCE_TOKEN} secondlayer subgraphs deploy ./subgraph.ts`)}`);
206188
+ console.log(` ${yellow(`SECONDLAYER_API_URL=http://localhost:3800 INSTANCE_TOKEN=${DEV_INSTANCE_TOKEN} secondlayer subgraphs deploy ./subgraph.ts`)}`);
206245
206189
  console.log(dim(`
206246
206190
  The api is published on 127.0.0.1 only: /v1 reads need no credential.
206247
206191
  Writes (deploys, webhooks) send INSTANCE_TOKEN=${DEV_INSTANCE_TOKEN}.`));
@@ -206940,7 +206884,7 @@ async function runInstanceDoctor(jsonOutput) {
206940
206884
  detail: unreachableError ?? undefined,
206941
206885
  nextSteps: [
206942
206886
  "Start the instance from docker/oss: docker compose up -d",
206943
- `If it runs elsewhere, point the CLI at it: SL_API_URL=<url> (currently ${apiUrl})`
206887
+ `If it runs elsewhere, point the CLI at it: SECONDLAYER_API_URL=<url> (currently ${apiUrl})`
206944
206888
  ]
206945
206889
  }
206946
206890
  ];
@@ -207432,14 +207376,12 @@ function readEnvValue(envPath, key) {
207432
207376
  return match ? unescapeEnvValue(match[1]) : null;
207433
207377
  }
207434
207378
  function buildInstanceEnv(input) {
207435
- const existingAlias = input.existing?.SL_API_KEY;
207436
- const aliasIsHex = existingAlias && !existingAlias.startsWith("sk-sl_") && !existingAlias.startsWith("ss-sl_");
207437
- const token = input.existing?.INSTANCE_TOKEN || (aliasIsHex ? existingAlias : undefined) || generateInstanceToken();
207379
+ const token = input.existing?.INSTANCE_TOKEN || generateInstanceToken();
207438
207380
  const secrets = input.existing?.SECONDLAYER_SECRETS_KEY || generateSecretsKey();
207439
207381
  const signing = input.existing?.STREAMS_SIGNING_PRIVATE_KEY || input.existing?.SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY || generateSigningPrivateKey();
207440
- const apiUrl = input.existing?.SECONDLAYER_API_URL || input.existing?.SL_API_URL || input.apiUrl || "http://127.0.0.1:3800";
207382
+ const apiUrl = input.existing?.SECONDLAYER_API_URL || input.apiUrl || "http://127.0.0.1:3800";
207441
207383
  const archiveKey = input.existing?.ARCHIVE_SIGNING_PUBLIC_KEY || input.archivePublicKeyPem || ARCHIVE_ROOT_PUBLIC_KEY_PEM;
207442
- const hostedCandidate = input.existing?.SECONDLAYER_API_KEY || input.existing?.SL_API_KEY || undefined;
207384
+ const hostedCandidate = input.existing?.SECONDLAYER_API_KEY || undefined;
207443
207385
  const hostedKey = hostedCandidate && isHostedAccountKey(hostedCandidate) ? hostedCandidate : undefined;
207444
207386
  return {
207445
207387
  INSTANCE_MODE: "oss",
@@ -207450,8 +207392,7 @@ function buildInstanceEnv(input) {
207450
207392
  SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY: signing,
207451
207393
  ALLOW_UNSIGNED_WEBHOOKS: "false",
207452
207394
  SECONDLAYER_API_URL: apiUrl,
207453
- SL_API_URL: apiUrl,
207454
- ...hostedKey ? { SECONDLAYER_API_KEY: hostedKey, SL_API_KEY: hostedKey } : {},
207395
+ ...hostedKey ? { SECONDLAYER_API_KEY: hostedKey } : {},
207455
207396
  ARCHIVE_SIGNING_PUBLIC_KEY: archiveKey
207456
207397
  };
207457
207398
  }
@@ -207467,11 +207408,10 @@ function renderInstanceEnv(env) {
207467
207408
  `STREAMS_SIGNING_PRIVATE_KEY=${escapeEnvValue(env.STREAMS_SIGNING_PRIVATE_KEY)}`,
207468
207409
  `SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY=${escapeEnvValue(env.SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY)}`,
207469
207410
  `ALLOW_UNSIGNED_WEBHOOKS=${env.ALLOW_UNSIGNED_WEBHOOKS}`,
207470
- `SECONDLAYER_API_URL=${env.SECONDLAYER_API_URL}`,
207471
- `SL_API_URL=${env.SL_API_URL}`
207411
+ `SECONDLAYER_API_URL=${env.SECONDLAYER_API_URL}`
207472
207412
  ];
207473
207413
  if (env.SECONDLAYER_API_KEY) {
207474
- lines.push("# Hosted account key for archive credits (sk-sl_*).", `SECONDLAYER_API_KEY=${env.SECONDLAYER_API_KEY}`, `SL_API_KEY=${env.SL_API_KEY ?? env.SECONDLAYER_API_KEY}`);
207414
+ lines.push("# Hosted account key for archive credits (sk-sl_*).", `SECONDLAYER_API_KEY=${env.SECONDLAYER_API_KEY}`);
207475
207415
  }
207476
207416
  lines.push("# Archive trust root: bootstrap, verify, and repair check manifests", "# against this key. Replace it to pin a different archive.", `ARCHIVE_SIGNING_PUBLIC_KEY=${escapeEnvValue(env.ARCHIVE_SIGNING_PUBLIC_KEY)}`, "");
207477
207417
  return lines.join(`
@@ -207490,9 +207430,7 @@ function loadExistingInstanceEnv(cwd, file = INSTANCE_ENV_FILE) {
207490
207430
  STREAMS_SIGNING_PRIVATE_KEY: readEnvValue(path, "STREAMS_SIGNING_PRIVATE_KEY"),
207491
207431
  SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY: readEnvValue(path, "SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY"),
207492
207432
  SECONDLAYER_API_URL: readEnvValue(path, "SECONDLAYER_API_URL"),
207493
- SL_API_URL: readEnvValue(path, "SL_API_URL"),
207494
207433
  SECONDLAYER_API_KEY: readEnvValue(path, "SECONDLAYER_API_KEY"),
207495
- SL_API_KEY: readEnvValue(path, "SL_API_KEY"),
207496
207434
  ARCHIVE_SIGNING_PUBLIC_KEY: readEnvValue(path, "ARCHIVE_SIGNING_PUBLIC_KEY")
207497
207435
  };
207498
207436
  }
@@ -207653,7 +207591,7 @@ var SECRET_ENV_KEYS = [
207653
207591
  "SECONDLAYER_SECRETS_KEY",
207654
207592
  "STREAMS_SIGNING_PRIVATE_KEY",
207655
207593
  "SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY",
207656
- "SL_API_KEY",
207594
+ "SECONDLAYER_API_KEY",
207657
207595
  "ARCHIVE_SIGNING_PUBLIC_KEY"
207658
207596
  ];
207659
207597
  function readSecretsKey() {
@@ -207955,7 +207893,7 @@ flags (see \`secondlayer --help\`). Defaults: mainnet, http://127.0.0.1:3800.
207955
207893
  const env = buildInstanceEnv({
207956
207894
  network,
207957
207895
  existing,
207958
- apiUrl: process.env.SL_API_URL ?? DEFAULT_INIT_API_URL,
207896
+ apiUrl: process.env.SECONDLAYER_API_URL ?? DEFAULT_INIT_API_URL,
207959
207897
  archivePublicKeyPem: await resolveArchivePublicKey({
207960
207898
  envPem: process.env.ARCHIVE_SIGNING_PUBLIC_KEY ?? process.env.STREAMS_SIGNING_PUBLIC_KEY,
207961
207899
  allowHostedApi: !isOssMode()
@@ -207965,7 +207903,7 @@ flags (see \`secondlayer --help\`). Defaults: mainnet, http://127.0.0.1:3800.
207965
207903
  success(`Wrote ${INSTANCE_ENV_FILE}`);
207966
207904
  note(formatKeyValue([
207967
207905
  ["network", env.STACKS_NETWORK],
207968
- ["api", env.SL_API_URL],
207906
+ ["api", env.SECONDLAYER_API_URL],
207969
207907
  ["env", path]
207970
207908
  ]));
207971
207909
  note("Export these or pass --env-file to compose. Do not commit the file.");
@@ -208343,9 +208281,7 @@ function resolveSecrets(config) {
208343
208281
  STREAMS_SIGNING_PRIVATE_KEY: existing.STREAMS_SIGNING_PRIVATE_KEY,
208344
208282
  SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY: existing.SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY,
208345
208283
  SECONDLAYER_API_URL: existing.SECONDLAYER_API_URL,
208346
- SL_API_URL: existing.SL_API_URL,
208347
208284
  SECONDLAYER_API_KEY: existing.SECONDLAYER_API_KEY,
208348
- SL_API_KEY: existing.SL_API_KEY,
208349
208285
  ARCHIVE_SIGNING_PUBLIC_KEY: existing.ARCHIVE_SIGNING_PUBLIC_KEY
208350
208286
  },
208351
208287
  apiUrl: `http://${normalizeLoopbackHost(config.apiPort)}`,
@@ -208414,11 +208350,10 @@ function renderSetupEnv(config, secrets) {
208414
208350
  `STREAMS_SIGNING_PRIVATE_KEY=${escapeEnvValue(i.STREAMS_SIGNING_PRIVATE_KEY)}`,
208415
208351
  `SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY=${escapeEnvValue(i.SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY)}`,
208416
208352
  `ALLOW_UNSIGNED_WEBHOOKS=${i.ALLOW_UNSIGNED_WEBHOOKS}`,
208417
- `SECONDLAYER_API_URL=${i.SECONDLAYER_API_URL}`,
208418
- `SL_API_URL=${i.SL_API_URL}`
208353
+ `SECONDLAYER_API_URL=${i.SECONDLAYER_API_URL}`
208419
208354
  ];
208420
208355
  if (i.SECONDLAYER_API_KEY) {
208421
- lines.push("# Hosted account key for archive credits (sk-sl_*).", `SECONDLAYER_API_KEY=${i.SECONDLAYER_API_KEY}`, `SL_API_KEY=${i.SL_API_KEY ?? i.SECONDLAYER_API_KEY}`);
208356
+ lines.push("# Hosted account key for archive credits (sk-sl_*).", `SECONDLAYER_API_KEY=${i.SECONDLAYER_API_KEY}`);
208422
208357
  }
208423
208358
  lines.push("# Archive trust root: bootstrap, verify, and repair check manifests", "# against this key. Replace it to pin a different archive.", `ARCHIVE_SIGNING_PUBLIC_KEY=${escapeEnvValue(i.ARCHIVE_SIGNING_PUBLIC_KEY)}`);
208424
208359
  if (config.nodeMode === "full") {
@@ -208537,7 +208472,7 @@ function cliEntry() {
208537
208472
  var CHILD_ENV_KEYS = [
208538
208473
  "DATABASE_URL",
208539
208474
  "ARCHIVE_SIGNING_PUBLIC_KEY",
208540
- "SL_API_URL",
208475
+ "SECONDLAYER_API_URL",
208541
208476
  "INSTANCE_TOKEN"
208542
208477
  ];
208543
208478
  function buildChildEnv(envPath, base = process.env) {
@@ -209023,7 +208958,6 @@ program.hook("preAction", (thisCommand) => {
209023
208958
  applyApiKeyFlag(apiKey);
209024
208959
  if (apiUrl) {
209025
208960
  process.env.SECONDLAYER_API_URL = apiUrl;
209026
- process.env.SL_API_URL = apiUrl;
209027
208961
  }
209028
208962
  });
209029
208963
  program.addHelpText("after", `
@@ -209069,5 +209003,5 @@ registerCreditsCommand(program);
209069
209003
  registerArchiveCommand(program);
209070
209004
  program.parse();
209071
209005
 
209072
- //# debugId=92A36ED6CC78319F64756E2164756E21
209006
+ //# debugId=AE6E7533FECA57AE64756E2164756E21
209073
209007
  //# sourceMappingURL=cli.js.map