@secondlayer/cli 17.0.0 → 17.0.2

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.0",
202498
+ version: "17.0.2",
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.0.0",
202538
- "@secondlayer/shared": "^11.10.1",
202537
+ "@secondlayer/sdk": "^12.1.0",
202538
+ "@secondlayer/shared": "^11.12.3",
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"
@@ -204801,6 +204801,7 @@ init_api_client();
204801
204801
  init_filter_params();
204802
204802
  init_output();
204803
204803
  init_resolve_auth();
204804
+ import { buildDoctorReport, isSuccessDelivery } from "@secondlayer/sdk";
204804
204805
  import { sign } from "@secondlayer/shared/crypto/standard-webhooks";
204805
204806
 
204806
204807
  // src/lib/webhook-validation.ts
@@ -205179,9 +205180,6 @@ function truncate(value, max = 48) {
205179
205180
  function formatMaybeDate(value) {
205180
205181
  return value ? value.replace("T", " ").slice(0, 19) : dim("-");
205181
205182
  }
205182
- function isSuccessDelivery(row) {
205183
- return row.statusCode !== null && row.statusCode >= 200 && row.statusCode < 300;
205184
- }
205185
205183
  function printJson(value) {
205186
205184
  console.log(JSON.stringify(value, null, 2));
205187
205185
  }
@@ -205250,12 +205248,19 @@ function buildWebhookUpdatePatch(options) {
205250
205248
  }
205251
205249
  return patch;
205252
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
+ }
205253
205258
  function printWebhookDetail(sub) {
205254
205259
  console.log(formatKeyValue([
205255
205260
  ["ID", sub.id],
205256
205261
  ["Name", sub.name],
205257
205262
  ["Status", sub.status],
205258
- ["Target", `${sub.subgraphName}.${sub.tableName}`],
205263
+ ["Target", formatWebhookTarget(sub)],
205259
205264
  ["Format", sub.format],
205260
205265
  ["Runtime", sub.runtime ?? "none"],
205261
205266
  ["URL", sub.url],
@@ -205280,65 +205285,12 @@ Auth config:`));
205280
205285
  console.log(JSON.stringify(sub.authConfig, null, 2));
205281
205286
  }
205282
205287
  }
205283
- function buildDoctorReport(input) {
205284
- const successful = input.deliveries.filter(isSuccessDelivery).length;
205285
- const failed = input.deliveries.length - successful;
205286
- const subgraph = input.subgraph ? {
205287
- name: input.subgraph.name,
205288
- status: input.subgraph.status,
205289
- syncStatus: input.subgraph.sync.status,
205290
- lastProcessedBlock: input.subgraph.sync.lastProcessedBlock,
205291
- chainTip: input.subgraph.sync.chainTip,
205292
- gapCount: input.subgraph.sync.gaps.count,
205293
- integrity: input.subgraph.sync.integrity
205294
- } : null;
205295
- const hints = [];
205296
- if (input.webhook.warning) {
205297
- hints.push(input.webhook.warning);
205298
- }
205299
- if (input.webhook.status === "paused") {
205300
- hints.push(`Resume when the receiver is healthy: secondlayer webhooks resume ${input.webhook.id}`);
205301
- }
205302
- if (input.webhook.lastError) {
205303
- hints.push("Run secondlayer webhooks test to reproduce the receiver request.");
205304
- }
205305
- if (input.webhook.circuitOpenedAt || input.webhook.circuitFailures > 0) {
205306
- hints.push("Circuit breaker has failures; inspect receiver logs and delivery status codes.");
205307
- }
205308
- if (input.dead.length > 0) {
205309
- hints.push(`Dead-letter rows exist; inspect with secondlayer webhooks dead ${input.webhook.id} and requeue selected rows.`);
205310
- }
205311
- if (subgraph?.gapCount && subgraph.gapCount > 0) {
205312
- hints.push(`Linked subgraph has gaps; run secondlayer subgraphs gaps ${input.webhook.subgraphName}.`);
205313
- }
205314
- if (subgraph?.syncStatus === "catching_up") {
205315
- hints.push("Linked subgraph is still catching up; new matching rows may arrive later.");
205316
- }
205317
- if (input.deliveries.length === 0) {
205318
- hints.push("No deliveries yet; confirm the table is receiving inserted rows that match the filter.");
205319
- }
205320
- if (hints.length === 0) {
205321
- hints.push("No immediate action needed.");
205322
- }
205323
- return {
205324
- webhook: input.webhook,
205325
- deliverySummary: {
205326
- total: input.deliveries.length,
205327
- successful,
205328
- failed,
205329
- last: input.deliveries[0] ?? null
205330
- },
205331
- deadCount: input.dead.length,
205332
- subgraph,
205333
- hints
205334
- };
205335
- }
205336
205288
  function printDoctorReport(report) {
205337
205289
  const sub = report.webhook;
205338
205290
  console.log(formatKeyValue([
205339
205291
  ["Webhook", `${sub.name} (${sub.id})`],
205340
205292
  ["Status", sub.status],
205341
- ["Target", `${sub.subgraphName}.${sub.tableName}`],
205293
+ ["Target", formatWebhookTarget(sub)],
205342
205294
  ["Format", sub.format],
205343
205295
  ["Runtime", sub.runtime ?? "none"],
205344
205296
  ["URL", sub.url],
@@ -205530,7 +205482,7 @@ function attachWebhookSubcommands(parent) {
205530
205482
  sub.name,
205531
205483
  sub.id,
205532
205484
  sub.status === "active" ? green(sub.status) : sub.status === "paused" ? yellow(sub.status) : redStatus(sub.status),
205533
- `${sub.subgraphName}.${sub.tableName}`,
205485
+ formatWebhookTarget(sub),
205534
205486
  sub.format,
205535
205487
  formatMaybeDate(sub.lastSuccessAt)
205536
205488
  ])));
@@ -209058,5 +209010,5 @@ registerCreditsCommand(program);
209058
209010
  registerArchiveCommand(program);
209059
209011
  program.parse();
209060
209012
 
209061
- //# debugId=51F0AC96395CA7BC64756E2164756E21
209013
+ //# debugId=3879CF2E258096FC64756E2164756E21
209062
209014
  //# sourceMappingURL=cli.js.map