@secondlayer/cli 17.0.1 → 17.0.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/README.md CHANGED
@@ -23,6 +23,22 @@ export SECONDLAYER_API_URL=http://127.0.0.1:3800
23
23
  export INSTANCE_TOKEN=<from secondlayer init>
24
24
  ```
25
25
 
26
+ ### Hosted commands (`webhooks`, `subgraphs`) — credential resolution order
27
+
28
+ Against `api.secondlayer.tools`, `resolveHostedAuth()` tries these in order —
29
+ the first one set wins:
30
+
31
+ | Order | Source | Notes |
32
+ |---|---|---|
33
+ | 1 | `SECONDLAYER_API_KEY` (`sk-sl_*`) | Hosted account key |
34
+ | 2 | `INSTANCE_TOKEN` / `--api-key` | Rarely set on the merchant host |
35
+ | 3 | Saved session, `~/.secondlayer/session.json` | Written by `secondlayer login`, scoped per API URL, 0600 |
36
+ | — | none of the above | Fails: `Not logged in — run secondlayer login` |
37
+
38
+ A shell with no `SECONDLAYER_API_KEY` exported can still authenticate against
39
+ the merchant host if this machine ran `secondlayer login` at some point — that's
40
+ #3, a real (if easy to forget) credential, not a bug.
41
+
26
42
  ## Quickstart
27
43
 
28
44
  ```bash
package/dist/cli.js CHANGED
@@ -202495,7 +202495,7 @@ var {
202495
202495
  // package.json
202496
202496
  var package_default = {
202497
202497
  name: "@secondlayer/cli",
202498
- version: "17.0.1",
202498
+ version: "17.0.3",
202499
202499
  description: "Run a Stacks index on your own hardware — set it up, restore verified history, and keep it current.",
202500
202500
  repository: {
202501
202501
  type: "git",
@@ -202534,10 +202534,10 @@ var package_default = {
202534
202534
  "@inquirer/prompts": "^8.2.0",
202535
202535
  "@secondlayer/bundler": "^0.6.1",
202536
202536
  "@secondlayer/scaffold": "^1.6.1",
202537
- "@secondlayer/sdk": "^12.1.0",
202538
- "@secondlayer/shared": "^11.10.1",
202537
+ "@secondlayer/sdk": "^12.3.0",
202538
+ "@secondlayer/shared": "^11.12.4",
202539
202539
  "@secondlayer/stacks": "^6.1.0",
202540
- "@secondlayer/subgraphs": "^6.1.0",
202540
+ "@secondlayer/subgraphs": "^6.2.5",
202541
202541
  esbuild: "^0.28.2",
202542
202542
  "smol-toml": "^1.8.0",
202543
202543
  zod: "^4.3.6"
@@ -205248,12 +205248,19 @@ function buildWebhookUpdatePatch(options) {
205248
205248
  }
205249
205249
  return patch;
205250
205250
  }
205251
+ function formatWebhookTarget(sub) {
205252
+ if (sub.kind === "chain") {
205253
+ const types = sub.triggers?.map((t) => t.type);
205254
+ return types && types.length > 0 ? `chain.${types.join(",")}` : "chain";
205255
+ }
205256
+ return `${sub.subgraphName}.${sub.tableName}`;
205257
+ }
205251
205258
  function printWebhookDetail(sub) {
205252
205259
  console.log(formatKeyValue([
205253
205260
  ["ID", sub.id],
205254
205261
  ["Name", sub.name],
205255
205262
  ["Status", sub.status],
205256
- ["Target", `${sub.subgraphName}.${sub.tableName}`],
205263
+ ["Target", formatWebhookTarget(sub)],
205257
205264
  ["Format", sub.format],
205258
205265
  ["Runtime", sub.runtime ?? "none"],
205259
205266
  ["URL", sub.url],
@@ -205278,54 +205285,103 @@ Auth config:`));
205278
205285
  console.log(JSON.stringify(sub.authConfig, null, 2));
205279
205286
  }
205280
205287
  }
205281
- function printDoctorReport(report) {
205288
+ var DOCTOR_ISSUE_TITLES = {
205289
+ warning: "This webhook can't fire yet",
205290
+ paused: "This webhook is paused",
205291
+ last_error: "The last delivery failed",
205292
+ circuit: "Your receiver is failing",
205293
+ dead_letters: "Some events exhausted every retry",
205294
+ subgraph_gaps: "The linked subgraph has gaps",
205295
+ subgraph_catching_up: "The linked subgraph is still catching up",
205296
+ no_deliveries: "No deliveries yet",
205297
+ receiver_rate_limited: "Your receiver is rate-limiting us",
205298
+ receiver_down: "Your receiver looks down",
205299
+ receiver_rejects: "Your receiver is rejecting deliveries",
205300
+ receiver_slow: "Your receiver is slow",
205301
+ delivery_lag: "Deliveries are running behind"
205302
+ };
205303
+ function formatPrimaryInsight(primary) {
205304
+ const severityColor = primary.severity === "bad" ? redStatus : primary.severity === "warn" ? yellow : dim;
205305
+ const lines = [dim(`
205306
+ Insight:`)];
205307
+ lines.push(` ${severityColor(DOCTOR_ISSUE_TITLES[primary.code])} ${dim(`[${primary.severity}]`)}`);
205308
+ for (const evidence of primary.evidence ?? []) {
205309
+ lines.push(` ${dim(`${evidence.label}:`)} ${evidence.value}`);
205310
+ }
205311
+ if (primary.fix) {
205312
+ lines.push(` ${primary.fix.text}`);
205313
+ if (primary.fix.command)
205314
+ lines.push(` $ ${primary.fix.command}`);
205315
+ }
205316
+ return lines.join(`
205317
+ `);
205318
+ }
205319
+ function formatDoctorReport(report) {
205282
205320
  const sub = report.webhook;
205283
- console.log(formatKeyValue([
205284
- ["Webhook", `${sub.name} (${sub.id})`],
205285
- ["Status", sub.status],
205286
- ["Target", `${sub.subgraphName}.${sub.tableName}`],
205287
- ["Format", sub.format],
205288
- ["Runtime", sub.runtime ?? "none"],
205289
- ["URL", sub.url],
205290
- [
205291
- "Circuit",
205292
- sub.circuitOpenedAt ? `open at ${sub.circuitOpenedAt}` : `${sub.circuitFailures} failures`
205293
- ],
205294
- ["Last Error", sub.lastError ?? "none"],
205295
- ["Last Delivery", sub.lastDeliveryAt ?? "none"],
205296
- ["Last Success", sub.lastSuccessAt ?? "none"]
205297
- ]));
205298
- console.log(dim(`
205299
- Delivery summary:`));
205300
- console.log(formatKeyValue([
205301
- ["Recent Attempts", String(report.deliverySummary.total)],
205302
- ["Successful", String(report.deliverySummary.successful)],
205303
- ["Failed", String(report.deliverySummary.failed)],
205304
- [
205305
- "Last Attempt",
205306
- report.deliverySummary.last ? `${report.deliverySummary.last.statusCode ?? "error"} at ${report.deliverySummary.last.dispatchedAt}` : "none"
205307
- ],
205308
- ["Dead Letter Rows", String(report.deadCount)]
205309
- ]));
205310
- if (report.subgraph) {
205311
- console.log(dim(`
205312
- Linked subgraph:`));
205313
- console.log(formatKeyValue([
205314
- ["Name", report.subgraph.name],
205315
- ["Status", report.subgraph.status],
205316
- ["Sync", report.subgraph.syncStatus],
205321
+ const sections = [
205322
+ formatKeyValue([
205323
+ ["Webhook", `${sub.name} (${sub.id})`],
205324
+ ["Status", sub.status],
205325
+ ["Target", formatWebhookTarget(sub)],
205326
+ ["Format", sub.format],
205327
+ ["Runtime", sub.runtime ?? "none"],
205328
+ ["URL", sub.url],
205317
205329
  [
205318
- "Blocks",
205319
- `${report.subgraph.lastProcessedBlock} / ${report.subgraph.chainTip}`
205330
+ "Circuit",
205331
+ sub.circuitOpenedAt ? `open at ${sub.circuitOpenedAt}` : `${sub.circuitFailures} failures`
205320
205332
  ],
205321
- ["Integrity", report.subgraph.integrity],
205322
- ["Gaps", String(report.subgraph.gapCount)]
205323
- ]));
205333
+ ["Last Error", sub.lastError ?? "none"],
205334
+ ["Last Delivery", sub.lastDeliveryAt ?? "none"],
205335
+ ["Last Success", sub.lastSuccessAt ?? "none"]
205336
+ ]),
205337
+ [
205338
+ dim(`
205339
+ Delivery summary:`),
205340
+ formatKeyValue([
205341
+ ["Recent Attempts", String(report.deliverySummary.total)],
205342
+ ["Successful", String(report.deliverySummary.successful)],
205343
+ ["Failed", String(report.deliverySummary.failed)],
205344
+ [
205345
+ "Last Attempt",
205346
+ report.deliverySummary.last ? `${report.deliverySummary.last.statusCode ?? "error"} at ${report.deliverySummary.last.dispatchedAt}` : "none"
205347
+ ],
205348
+ ["Dead Letter Rows", String(report.deadCount)]
205349
+ ])
205350
+ ].join(`
205351
+ `)
205352
+ ];
205353
+ if (report.subgraph) {
205354
+ sections.push([
205355
+ dim(`
205356
+ Linked subgraph:`),
205357
+ formatKeyValue([
205358
+ ["Name", report.subgraph.name],
205359
+ ["Status", report.subgraph.status],
205360
+ ["Sync", report.subgraph.syncStatus],
205361
+ [
205362
+ "Blocks",
205363
+ `${report.subgraph.lastProcessedBlock} / ${report.subgraph.chainTip}`
205364
+ ],
205365
+ ["Integrity", report.subgraph.integrity],
205366
+ ["Gaps", String(report.subgraph.gapCount)]
205367
+ ])
205368
+ ].join(`
205369
+ `));
205324
205370
  }
205325
- console.log(dim(`
205326
- Next steps:`));
205327
- for (const hint of report.hints)
205328
- console.log(` - ${hint}`);
205371
+ if (report.primary)
205372
+ sections.push(formatPrimaryInsight(report.primary));
205373
+ const primaryIndex = report.primary ? report.issues.indexOf(report.primary) : -1;
205374
+ const rest = report.hints.filter((_, i) => i !== primaryIndex);
205375
+ if (rest.length > 0) {
205376
+ sections.push([dim(`
205377
+ Next steps:`), ...rest.map((hint) => ` - ${hint}`)].join(`
205378
+ `));
205379
+ }
205380
+ return sections.join(`
205381
+ `);
205382
+ }
205383
+ function printDoctorReport(report) {
205384
+ console.log(formatDoctorReport(report));
205329
205385
  }
205330
205386
  function syntheticValue(type) {
205331
205387
  switch (type) {
@@ -205475,7 +205531,7 @@ function attachWebhookSubcommands(parent) {
205475
205531
  sub.name,
205476
205532
  sub.id,
205477
205533
  sub.status === "active" ? green(sub.status) : sub.status === "paused" ? yellow(sub.status) : redStatus(sub.status),
205478
- `${sub.subgraphName}.${sub.tableName}`,
205534
+ formatWebhookTarget(sub),
205479
205535
  sub.format,
205480
205536
  formatMaybeDate(sub.lastSuccessAt)
205481
205537
  ])));
@@ -209003,5 +209059,5 @@ registerCreditsCommand(program);
209003
209059
  registerArchiveCommand(program);
209004
209060
  program.parse();
209005
209061
 
209006
- //# debugId=AE6E7533FECA57AE64756E2164756E21
209062
+ //# debugId=071DD5EE0E04E9D664756E2164756E21
209007
209063
  //# sourceMappingURL=cli.js.map