@secondlayer/sdk 14.5.1 → 15.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.
@@ -1,11 +1,10 @@
1
- import { SubgraphDetail } from "@secondlayer/shared/schemas/subgraphs";
2
1
  import { DeadRow, DeliveryRow, WebhookDetail, WebhookSummary } from "@secondlayer/shared/schemas/webhooks";
3
2
  /**
4
3
  * Webhook diagnosis, shared by `secondlayer webhooks doctor` and the
5
4
  * dashboard's webhook detail page. Moved out of the CLI (unchanged behavior)
6
5
  * so the web can build the same judgment without printing CLI-command text.
7
6
  *
8
- * Plan 068 adds five deterministic, numbers-only detectors on top of the
7
+ * Five deterministic, numbers-only detectors sit on top of the
9
8
  * existing flag checks: no model, no history beyond the deliveries window
10
9
  * already fetched. Thresholds are named constants below, conservative on
11
10
  * purpose — a wrong insight costs more trust than a missed one.
@@ -23,7 +22,7 @@ interface DoctorFix {
23
22
  /** Anchor into the docs' webhooks troubleshooting section. */
24
23
  docsPath?: string;
25
24
  }
26
- type DoctorIssueCode = "warning" | "paused" | "last_error" | "circuit" | "dead_letters" | "subgraph_gaps" | "subgraph_catching_up" | "no_deliveries" | "receiver_rate_limited" | "receiver_down" | "receiver_rejects" | "receiver_slow" | "delivery_lag";
25
+ type DoctorIssueCode = "warning" | "paused" | "last_error" | "circuit" | "dead_letters" | "no_deliveries" | "receiver_rate_limited" | "receiver_down" | "receiver_rejects" | "receiver_slow" | "delivery_lag";
27
26
  interface DoctorIssue {
28
27
  code: DoctorIssueCode;
29
28
  detail?: string;
@@ -43,15 +42,6 @@ interface DoctorReport {
43
42
  last: DeliveryRow | null;
44
43
  };
45
44
  deadCount: number;
46
- subgraph: {
47
- name: string;
48
- status: string;
49
- syncStatus: string;
50
- lastProcessedBlock: number;
51
- chainTip: number;
52
- gapCount: number;
53
- integrity: string;
54
- } | null;
55
45
  /** CLI-facing next steps, one per issue, in the same order as `issues`. */
56
46
  hints: string[];
57
47
  issues: DoctorIssue[];
@@ -65,7 +55,6 @@ declare function buildDoctorReport(input: {
65
55
  webhook: WebhookDetail;
66
56
  deliveries: DeliveryRow[];
67
57
  dead: DeadRow[];
68
- subgraph?: SubgraphDetail | null;
69
58
  }): DoctorReport;
70
59
  /**
71
60
  * The list page's own reduced detector: computed from `WebhookSummary` alone
@@ -206,9 +206,7 @@ var CODE_PRIORITY = [
206
206
  "receiver_rate_limited",
207
207
  "receiver_slow",
208
208
  "delivery_lag",
209
- "no_deliveries",
210
- "subgraph_gaps",
211
- "subgraph_catching_up"
209
+ "no_deliveries"
212
210
  ];
213
211
  function pickPrimary(issues) {
214
212
  if (issues.length === 0)
@@ -228,15 +226,6 @@ function hintFor(issue) {
228
226
  function buildDoctorReport(input) {
229
227
  const successful = input.deliveries.filter(isSuccessDelivery).length;
230
228
  const failed = input.deliveries.length - successful;
231
- const subgraph = input.subgraph ? {
232
- name: input.subgraph.name,
233
- status: input.subgraph.status,
234
- syncStatus: input.subgraph.sync.status,
235
- lastProcessedBlock: input.subgraph.sync.lastProcessedBlock,
236
- chainTip: input.subgraph.sync.chainTip,
237
- gapCount: input.subgraph.sync.gaps.count,
238
- integrity: input.subgraph.sync.integrity
239
- } : null;
240
229
  const hints = [];
241
230
  const issues = [];
242
231
  if (input.webhook.warning) {
@@ -267,14 +256,6 @@ function buildDoctorReport(input) {
267
256
  hints.push(`Dead-letter rows exist; inspect with secondlayer webhooks dead ${input.webhook.id} and requeue selected rows.`);
268
257
  issues.push({ code: "dead_letters", severity: "bad" });
269
258
  }
270
- if (subgraph?.gapCount && subgraph.gapCount > 0) {
271
- hints.push(`Linked subgraph has gaps; run secondlayer subgraphs gaps ${input.webhook.subgraphName}.`);
272
- issues.push({ code: "subgraph_gaps", severity: "calm" });
273
- }
274
- if (subgraph?.syncStatus === "catching_up") {
275
- hints.push("Linked subgraph is still catching up; new matching rows may arrive later.");
276
- issues.push({ code: "subgraph_catching_up", severity: "calm" });
277
- }
278
259
  for (const detector of [
279
260
  detectReceiverRateLimited,
280
261
  detectReceiverDown,
@@ -293,7 +274,7 @@ function buildDoctorReport(input) {
293
274
  hints.push(hintFor(lagIssue));
294
275
  }
295
276
  if (input.deliveries.length === 0) {
296
- hints.push("No deliveries yet; confirm the table is receiving inserted rows that match the filter.");
277
+ hints.push("No deliveries yet; confirm a chain event matching one of the triggers has happened since the webhook was created.");
297
278
  issues.push({ code: "no_deliveries", severity: "calm" });
298
279
  }
299
280
  if (hints.length === 0) {
@@ -308,7 +289,6 @@ function buildDoctorReport(input) {
308
289
  last: input.deliveries[0] ?? null
309
290
  },
310
291
  deadCount: input.dead.length,
311
- subgraph,
312
292
  hints,
313
293
  issues,
314
294
  primary: pickPrimary(issues)
@@ -346,5 +326,5 @@ export {
346
326
  isSuccessDelivery
347
327
  };
348
328
 
349
- //# debugId=EF7130FCE4633E3E64756E2164756E21
329
+ //# debugId=58B01F30F18A50B264756E2164756E21
350
330
  //# sourceMappingURL=doctor.js.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["src/webhooks/doctor.ts"],
4
4
  "sourcesContent": [
5
- "import type { SubgraphDetail } from \"@secondlayer/shared/schemas/subgraphs\";\nimport type {\n\tDeadRow,\n\tDeliveryRow,\n\tWebhookDetail,\n\tWebhookSummary,\n} from \"@secondlayer/shared/schemas/webhooks\";\n\n/**\n * Webhook diagnosis, shared by `secondlayer webhooks doctor` and the\n * dashboard's webhook detail page. Moved out of the CLI (unchanged behavior)\n * so the web can build the same judgment without printing CLI-command text.\n *\n * Plan 068 adds five deterministic, numbers-only detectors on top of the\n * existing flag checks: no model, no history beyond the deliveries window\n * already fetched. Thresholds are named constants below, conservative on\n * purpose — a wrong insight costs more trust than a missed one.\n */\n\nexport function isSuccessDelivery(row: DeliveryRow): boolean {\n\treturn (\n\t\trow.statusCode !== null && row.statusCode >= 200 && row.statusCode < 300\n\t);\n}\n\nexport type DoctorSeverity = \"bad\" | \"warn\" | \"calm\";\n\nexport interface DoctorEvidence {\n\tlabel: string;\n\tvalue: string;\n}\n\nexport interface DoctorFix {\n\ttext: string;\n\t/** A `secondlayer webhooks ...` command the reader can copy. */\n\tcommand?: string;\n\t/** Anchor into the docs' webhooks troubleshooting section. */\n\tdocsPath?: string;\n}\n\nexport type DoctorIssueCode =\n\t| \"warning\"\n\t| \"paused\"\n\t| \"last_error\"\n\t| \"circuit\"\n\t| \"dead_letters\"\n\t| \"subgraph_gaps\"\n\t| \"subgraph_catching_up\"\n\t| \"no_deliveries\"\n\t| \"receiver_rate_limited\"\n\t| \"receiver_down\"\n\t| \"receiver_rejects\"\n\t| \"receiver_slow\"\n\t| \"delivery_lag\";\n\nexport interface DoctorIssue {\n\tcode: DoctorIssueCode;\n\tdetail?: string;\n\tseverity: DoctorSeverity;\n\t/** 2-4 numbers-only facts backing the issue. Only the five new detectors\n\t * and the list-summary circuit issue carry this — the older flag checks\n\t * keep their plain `detail` string. */\n\tevidence?: DoctorEvidence[];\n\tfix?: DoctorFix;\n}\n\nexport interface DoctorReport {\n\twebhook: WebhookDetail;\n\tdeliverySummary: {\n\t\ttotal: number;\n\t\tsuccessful: number;\n\t\tfailed: number;\n\t\tlast: DeliveryRow | null;\n\t};\n\tdeadCount: number;\n\tsubgraph: {\n\t\tname: string;\n\t\tstatus: string;\n\t\tsyncStatus: string;\n\t\tlastProcessedBlock: number;\n\t\tchainTip: number;\n\t\tgapCount: number;\n\t\tintegrity: string;\n\t} | null;\n\t/** CLI-facing next steps, one per issue, in the same order as `issues`. */\n\thints: string[];\n\tissues: DoctorIssue[];\n\t/** The single most severe issue (bad > warn > calm, then rule priority),\n\t * or `null` when there are none. The UI leads with this and collapses\n\t * the rest underneath. */\n\tprimary: DoctorIssue | null;\n}\n\n// ── Detector thresholds ─────────────────────────────────────────────\n// Named constants, not config (plan 068). Tune from real data at the 054\n// spike — until then these stay conservative.\n\nconst RATE_LIMITED_MIN_ATTEMPTS = 10;\nconst RATE_LIMITED_MIN_RATIO = 0.5;\n// Exported: the status pill's \"auto-failing\" rule (plan 070) reuses this\n// instead of duplicating the number.\nexport const DOWN_MIN_CONSECUTIVE = 5;\nconst REJECTS_MIN_CONSECUTIVE = 5;\nconst SLOW_WINDOW = 20;\nconst SLOW_MIN_SAMPLES = 5;\nconst SLOW_TIMEOUT_RATIO = 0.5;\nconst LAG_WINDOW = 20;\nconst LAG_MIN_SAMPLES = 5;\nconst LAG_THRESHOLD_MS = 60_000;\nconst ERROR_SNIPPET_MAX = 200;\n\nfunction median(values: number[]): number {\n\tif (values.length === 0) return 0;\n\tconst sorted = [...values].sort((a, b) => a - b);\n\treturn sorted[Math.floor(sorted.length / 2)] ?? 0;\n}\n\nfunction percentile(values: number[], p: number): number {\n\tif (values.length === 0) return 0;\n\tconst sorted = [...values].sort((a, b) => a - b);\n\tconst idx = Math.min(sorted.length - 1, Math.floor(p * sorted.length));\n\treturn sorted[idx] ?? 0;\n}\n\nfunction formatMs(ms: number): string {\n\treturn ms >= 1000 ? `${(ms / 1000).toFixed(1)}s` : `${Math.round(ms)}ms`;\n}\n\n/** \"2026-04-23 00:00 UTC\" — date, hour:minute, and an explicit zone so an\n * evidence value never reads as local time. */\nfunction formatShortDate(iso: string): string {\n\treturn `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;\n}\n\n/** The longest run from the start of `rows` (newest-first) matching\n * `predicate` — the current losing (or rejecting) streak. */\nfunction consecutiveFromStart(\n\trows: DeliveryRow[],\n\tpredicate: (row: DeliveryRow) => boolean,\n): DeliveryRow[] {\n\tconst out: DeliveryRow[] = [];\n\tfor (const row of rows) {\n\t\tif (!predicate(row)) break;\n\t\tout.push(row);\n\t}\n\treturn out;\n}\n\nfunction summarizeStatusBreakdown(rows: DeliveryRow[]): string {\n\tconst counts = new Map<string, number>();\n\tfor (const row of rows) {\n\t\tconst key =\n\t\t\trow.statusCode === null ? \"timeout/no response\" : String(row.statusCode);\n\t\tcounts.set(key, (counts.get(key) ?? 0) + 1);\n\t}\n\treturn [...counts.entries()].map(([key, n]) => `${n}× ${key}`).join(\", \");\n}\n\nconst RETRY_AFTER_RE = /retry-after:?\\s*(\\d+)/i;\n\n/** The most recent 429's `Retry-After`, if the receiver's error text carried\n * one — we never invent a value the rows didn't report. */\nfunction extractRetryAfterSeconds(rows: DeliveryRow[]): string | null {\n\tfor (const row of rows) {\n\t\tif (row.statusCode !== 429 || !row.errorMessage) continue;\n\t\tconst match = row.errorMessage.match(RETRY_AFTER_RE);\n\t\tif (match?.[1]) return match[1];\n\t}\n\treturn null;\n}\n\n/** ≥10 attempts in the window, ≥50% of them 429 — the receiver is\n * rate-limiting us, not failing. */\nfunction detectReceiverRateLimited(\n\twebhook: WebhookDetail,\n\tdeliveries: DeliveryRow[],\n): DoctorIssue | null {\n\tif (deliveries.length < RATE_LIMITED_MIN_ATTEMPTS) return null;\n\tconst count429 = deliveries.filter((d) => d.statusCode === 429).length;\n\tif (count429 / deliveries.length < RATE_LIMITED_MIN_RATIO) return null;\n\n\tconst oldest = deliveries[deliveries.length - 1];\n\tconst newest = deliveries[0];\n\tconst evidence: DoctorEvidence[] = [\n\t\t{\n\t\t\tlabel: \"429 responses\",\n\t\t\tvalue: `${count429} of ${deliveries.length} attempts`,\n\t\t},\n\t\t{\n\t\t\tlabel: \"window\",\n\t\t\tvalue:\n\t\t\t\toldest && newest\n\t\t\t\t\t? `${formatShortDate(oldest.dispatchedAt)} → ${formatShortDate(newest.dispatchedAt)}`\n\t\t\t\t\t: \"unknown\",\n\t\t},\n\t];\n\tconst retryAfter = extractRetryAfterSeconds(deliveries);\n\tif (retryAfter) {\n\t\tevidence.push({ label: \"latest Retry-After\", value: `${retryAfter}s` });\n\t}\n\n\tconst suggestedConcurrency = Math.max(1, Math.floor(webhook.concurrency / 2));\n\treturn {\n\t\tcode: \"receiver_rate_limited\",\n\t\tseverity: \"warn\",\n\t\tevidence,\n\t\tfix: {\n\t\t\ttext: \"Lower concurrency, or honor the Retry-After header on your receiver.\",\n\t\t\tcommand: `secondlayer webhooks update ${webhook.id} --concurrency ${suggestedConcurrency}`,\n\t\t\tdocsPath: \"/docs/webhooks#receiver-rate-limited\",\n\t\t},\n\t};\n}\n\n/** ≥5 most recent attempts are 5xx or got no response at all (timeout /\n * connection failure) — the receiver looks down, not just slow. */\nfunction detectReceiverDown(\n\twebhook: WebhookDetail,\n\tdeliveries: DeliveryRow[],\n): DoctorIssue | null {\n\tconst streak = consecutiveFromStart(\n\t\tdeliveries,\n\t\t(d) => d.statusCode === null || d.statusCode >= 500,\n\t);\n\tif (streak.length < DOWN_MIN_CONSECUTIVE) return null;\n\n\treturn {\n\t\tcode: \"receiver_down\",\n\t\tseverity: \"bad\",\n\t\tevidence: [\n\t\t\t{ label: \"consecutive failures\", value: String(streak.length) },\n\t\t\t{ label: \"breakdown\", value: summarizeStatusBreakdown(streak) },\n\t\t\t{\n\t\t\t\tlabel: \"last success\",\n\t\t\t\tvalue: webhook.lastSuccessAt\n\t\t\t\t\t? formatShortDate(webhook.lastSuccessAt)\n\t\t\t\t\t: \"never\",\n\t\t\t},\n\t\t],\n\t\tfix: {\n\t\t\ttext: \"Check your receiver's health and logs, then send a test event.\",\n\t\t\tcommand: `secondlayer webhooks test ${webhook.id}`,\n\t\t\tdocsPath: \"/docs/webhooks#receiver-down\",\n\t\t},\n\t};\n}\n\n/** ≥5 most recent attempts are 4xx other than 429 — the receiver is\n * reachable but actively rejecting us (auth, signature, bad request). */\nfunction detectReceiverRejects(\n\twebhook: WebhookDetail,\n\tdeliveries: DeliveryRow[],\n): DoctorIssue | null {\n\tconst streak = consecutiveFromStart(\n\t\tdeliveries,\n\t\t(d) =>\n\t\t\td.statusCode !== null &&\n\t\t\td.statusCode >= 400 &&\n\t\t\td.statusCode < 500 &&\n\t\t\td.statusCode !== 429,\n\t);\n\tif (streak.length < REJECTS_MIN_CONSECUTIVE) return null;\n\n\tconst evidence: DoctorEvidence[] = [\n\t\t{ label: \"consecutive rejects\", value: String(streak.length) },\n\t\t{ label: \"breakdown\", value: summarizeStatusBreakdown(streak) },\n\t];\n\tconst withText = streak.find((d) => d.errorMessage || d.responseBody);\n\tconst snippet = withText\n\t\t? (withText.errorMessage ?? withText.responseBody ?? \"\").slice(\n\t\t\t\t0,\n\t\t\t\tERROR_SNIPPET_MAX,\n\t\t\t)\n\t\t: null;\n\tif (snippet) evidence.push({ label: \"first error\", value: snippet });\n\n\treturn {\n\t\tcode: \"receiver_rejects\",\n\t\tseverity: \"bad\",\n\t\tevidence,\n\t\tfix: {\n\t\t\ttext: \"Check your receiver's auth config or signature verification.\",\n\t\t\tcommand: `secondlayer webhooks test ${webhook.id}`,\n\t\t\tdocsPath: \"/docs/webhooks#receiver-rejects\",\n\t\t},\n\t};\n}\n\n/** Median response time of the newest 20 attempts is at least half the\n * webhook's timeout — deliveries are slow, not failing. */\nfunction detectReceiverSlow(\n\twebhook: WebhookDetail,\n\tdeliveries: DeliveryRow[],\n): DoctorIssue | null {\n\tconst durations = deliveries\n\t\t.slice(0, SLOW_WINDOW)\n\t\t.map((d) => d.durationMs)\n\t\t.filter((d): d is number => d !== null);\n\tif (durations.length < SLOW_MIN_SAMPLES) return null;\n\n\tconst med = median(durations);\n\tif (med < webhook.timeoutMs * SLOW_TIMEOUT_RATIO) return null;\n\n\treturn {\n\t\tcode: \"receiver_slow\",\n\t\tseverity: \"warn\",\n\t\tevidence: [\n\t\t\t{ label: \"median response time\", value: formatMs(med) },\n\t\t\t{\n\t\t\t\tlabel: \"p95 response time\",\n\t\t\t\tvalue: formatMs(percentile(durations, 0.95)),\n\t\t\t},\n\t\t\t{ label: \"timeout\", value: formatMs(webhook.timeoutMs) },\n\t\t],\n\t\tfix: {\n\t\t\ttext: \"Speed up your receiver, or raise the timeout (up to 30s hosted).\",\n\t\t\tcommand: `secondlayer webhooks update ${webhook.id} --timeout-ms 30000`,\n\t\t\tdocsPath: \"/docs/webhooks#receiver-slow\",\n\t\t},\n\t};\n}\n\n/** Median (dispatch time − block time) of the newest 20 attempts with a\n * known block time exceeds a minute — we're behind on delivery. This is\n * our-side latency, not something the receiver can fix, so it carries no\n * actionable command. */\nfunction detectDeliveryLag(deliveries: DeliveryRow[]): DoctorIssue | null {\n\tconst window = deliveries\n\t\t.slice(0, LAG_WINDOW)\n\t\t.filter(\n\t\t\t(d): d is DeliveryRow & { blockTime: string } => d.blockTime !== null,\n\t\t);\n\tif (window.length < LAG_MIN_SAMPLES) return null;\n\n\tconst lags = window.map(\n\t\t(d) => new Date(d.dispatchedAt).getTime() - new Date(d.blockTime).getTime(),\n\t);\n\tconst med = median(lags);\n\tif (med <= LAG_THRESHOLD_MS) return null;\n\n\tconst blockTimes = window.map((d) => d.blockTime).sort();\n\tconst oldest = blockTimes[0];\n\tconst newest = blockTimes[blockTimes.length - 1];\n\n\treturn {\n\t\tcode: \"delivery_lag\",\n\t\tseverity: \"warn\",\n\t\tevidence: [\n\t\t\t{ label: \"median lag\", value: formatMs(med) },\n\t\t\t{\n\t\t\t\tlabel: \"block time range\",\n\t\t\t\tvalue:\n\t\t\t\t\toldest && newest\n\t\t\t\t\t\t? `${formatShortDate(oldest)} → ${formatShortDate(newest)}`\n\t\t\t\t\t\t: \"unknown\",\n\t\t\t},\n\t\t],\n\t\tfix: {\n\t\t\ttext: \"We're behind on delivery; no action needed on your end.\",\n\t\t},\n\t};\n}\n\nconst SEVERITY_RANK: Record<DoctorSeverity, number> = {\n\tbad: 0,\n\twarn: 1,\n\tcalm: 2,\n};\n\n/** Tie-break within a severity tier when more than one issue fires at\n * once — most specific / most actionable first. */\nconst CODE_PRIORITY: DoctorIssueCode[] = [\n\t\"circuit\",\n\t\"receiver_down\",\n\t\"receiver_rejects\",\n\t\"dead_letters\",\n\t\"paused\",\n\t\"last_error\",\n\t\"warning\",\n\t\"receiver_rate_limited\",\n\t\"receiver_slow\",\n\t\"delivery_lag\",\n\t\"no_deliveries\",\n\t\"subgraph_gaps\",\n\t\"subgraph_catching_up\",\n];\n\nfunction pickPrimary(issues: DoctorIssue[]): DoctorIssue | null {\n\tif (issues.length === 0) return null;\n\treturn (\n\t\t[...issues].sort((a, b) => {\n\t\t\tconst sevDiff = SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity];\n\t\t\tif (sevDiff !== 0) return sevDiff;\n\t\t\treturn CODE_PRIORITY.indexOf(a.code) - CODE_PRIORITY.indexOf(b.code);\n\t\t})[0] ?? null\n\t);\n}\n\nfunction hintFor(issue: DoctorIssue): string {\n\tif (!issue.fix) return issue.detail ?? issue.code;\n\treturn issue.fix.command\n\t\t? `${issue.fix.text} ${issue.fix.command}`\n\t\t: issue.fix.text;\n}\n\nexport function buildDoctorReport(input: {\n\twebhook: WebhookDetail;\n\tdeliveries: DeliveryRow[];\n\tdead: DeadRow[];\n\tsubgraph?: SubgraphDetail | null;\n}): DoctorReport {\n\tconst successful = input.deliveries.filter(isSuccessDelivery).length;\n\tconst failed = input.deliveries.length - successful;\n\tconst subgraph = input.subgraph\n\t\t? {\n\t\t\t\tname: input.subgraph.name,\n\t\t\t\tstatus: input.subgraph.status,\n\t\t\t\tsyncStatus: input.subgraph.sync.status,\n\t\t\t\tlastProcessedBlock: input.subgraph.sync.lastProcessedBlock,\n\t\t\t\tchainTip: input.subgraph.sync.chainTip,\n\t\t\t\tgapCount: input.subgraph.sync.gaps.count,\n\t\t\t\tintegrity: input.subgraph.sync.integrity,\n\t\t\t}\n\t\t: null;\n\n\tconst hints: string[] = [];\n\tconst issues: DoctorIssue[] = [];\n\tif (input.webhook.warning) {\n\t\thints.push(input.webhook.warning);\n\t\tissues.push({\n\t\t\tcode: \"warning\",\n\t\t\tdetail: input.webhook.warning,\n\t\t\tseverity: \"warn\",\n\t\t});\n\t}\n\tif (input.webhook.status === \"paused\") {\n\t\thints.push(\n\t\t\t`Resume when the receiver is healthy: secondlayer webhooks resume ${input.webhook.id}`,\n\t\t);\n\t\tissues.push({ code: \"paused\", severity: \"warn\" });\n\t}\n\tif (input.webhook.lastError) {\n\t\thints.push(\n\t\t\t\"Run secondlayer webhooks test to reproduce the receiver request.\",\n\t\t);\n\t\tissues.push({\n\t\t\tcode: \"last_error\",\n\t\t\tdetail: input.webhook.lastError,\n\t\t\tseverity: \"warn\",\n\t\t});\n\t}\n\tif (input.webhook.circuitOpenedAt || input.webhook.circuitFailures > 0) {\n\t\thints.push(\n\t\t\t\"Circuit breaker has failures; inspect receiver logs and delivery status codes.\",\n\t\t);\n\t\tissues.push({ code: \"circuit\", severity: \"bad\" });\n\t}\n\tif (input.dead.length > 0) {\n\t\thints.push(\n\t\t\t`Dead-letter rows exist; inspect with secondlayer webhooks dead ${input.webhook.id} and requeue selected rows.`,\n\t\t);\n\t\tissues.push({ code: \"dead_letters\", severity: \"bad\" });\n\t}\n\tif (subgraph?.gapCount && subgraph.gapCount > 0) {\n\t\thints.push(\n\t\t\t`Linked subgraph has gaps; run secondlayer subgraphs gaps ${input.webhook.subgraphName}.`,\n\t\t);\n\t\tissues.push({ code: \"subgraph_gaps\", severity: \"calm\" });\n\t}\n\tif (subgraph?.syncStatus === \"catching_up\") {\n\t\thints.push(\n\t\t\t\"Linked subgraph is still catching up; new matching rows may arrive later.\",\n\t\t);\n\t\tissues.push({ code: \"subgraph_catching_up\", severity: \"calm\" });\n\t}\n\n\tfor (const detector of [\n\t\tdetectReceiverRateLimited,\n\t\tdetectReceiverDown,\n\t\tdetectReceiverRejects,\n\t\tdetectReceiverSlow,\n\t]) {\n\t\tconst issue = detector(input.webhook, input.deliveries);\n\t\tif (issue) {\n\t\t\tissues.push(issue);\n\t\t\thints.push(hintFor(issue));\n\t\t}\n\t}\n\tconst lagIssue = detectDeliveryLag(input.deliveries);\n\tif (lagIssue) {\n\t\tissues.push(lagIssue);\n\t\thints.push(hintFor(lagIssue));\n\t}\n\n\tif (input.deliveries.length === 0) {\n\t\thints.push(\n\t\t\t\"No deliveries yet; confirm the table is receiving inserted rows that match the filter.\",\n\t\t);\n\t\tissues.push({ code: \"no_deliveries\", severity: \"calm\" });\n\t}\n\tif (hints.length === 0) {\n\t\thints.push(\"No immediate action needed.\");\n\t}\n\n\treturn {\n\t\twebhook: input.webhook,\n\t\tdeliverySummary: {\n\t\t\ttotal: input.deliveries.length,\n\t\t\tsuccessful,\n\t\t\tfailed,\n\t\t\tlast: input.deliveries[0] ?? null,\n\t\t},\n\t\tdeadCount: input.dead.length,\n\t\tsubgraph,\n\t\thints,\n\t\tissues,\n\t\tprimary: pickPrimary(issues),\n\t};\n}\n\n/**\n * The list page's own reduced detector: computed from `WebhookSummary` alone\n * (no deliveries, no dead-letter rows — the list endpoint returns neither,\n * and fetching per-row detail or deliveries here would fan out one request\n * per row). Only `status` and `circuitOpenedAt` distinguish a real problem\n * from a manual pause at this level; deliveries-based rules (rate limits,\n * downtime, rejects, slowness, lag) only ever show on the detail page.\n */\nexport function buildListIssue(\n\twebhook: Pick<WebhookSummary, \"status\" | \"circuitOpenedAt\" | \"lastSuccessAt\">,\n): DoctorIssue | null {\n\tif (webhook.status !== \"paused\") return null;\n\tif (webhook.circuitOpenedAt) {\n\t\treturn {\n\t\t\tcode: \"circuit\",\n\t\t\tseverity: \"bad\",\n\t\t\tevidence: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"circuit opened\",\n\t\t\t\t\tvalue: formatShortDate(webhook.circuitOpenedAt),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"last success\",\n\t\t\t\t\tvalue: webhook.lastSuccessAt\n\t\t\t\t\t\t? formatShortDate(webhook.lastSuccessAt)\n\t\t\t\t\t\t: \"never\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tfix: {\n\t\t\t\ttext: \"Check your receiver's health and logs, then send a test event.\",\n\t\t\t\tdocsPath: \"/docs/webhooks#receiver-down\",\n\t\t\t},\n\t\t};\n\t}\n\treturn { code: \"paused\", severity: \"warn\" };\n}\n"
5
+ "import type {\n\tDeadRow,\n\tDeliveryRow,\n\tWebhookDetail,\n\tWebhookSummary,\n} from \"@secondlayer/shared/schemas/webhooks\";\n\n/**\n * Webhook diagnosis, shared by `secondlayer webhooks doctor` and the\n * dashboard's webhook detail page. Moved out of the CLI (unchanged behavior)\n * so the web can build the same judgment without printing CLI-command text.\n *\n * Five deterministic, numbers-only detectors sit on top of the\n * existing flag checks: no model, no history beyond the deliveries window\n * already fetched. Thresholds are named constants below, conservative on\n * purpose — a wrong insight costs more trust than a missed one.\n */\n\nexport function isSuccessDelivery(row: DeliveryRow): boolean {\n\treturn (\n\t\trow.statusCode !== null && row.statusCode >= 200 && row.statusCode < 300\n\t);\n}\n\nexport type DoctorSeverity = \"bad\" | \"warn\" | \"calm\";\n\nexport interface DoctorEvidence {\n\tlabel: string;\n\tvalue: string;\n}\n\nexport interface DoctorFix {\n\ttext: string;\n\t/** A `secondlayer webhooks ...` command the reader can copy. */\n\tcommand?: string;\n\t/** Anchor into the docs' webhooks troubleshooting section. */\n\tdocsPath?: string;\n}\n\nexport type DoctorIssueCode =\n\t| \"warning\"\n\t| \"paused\"\n\t| \"last_error\"\n\t| \"circuit\"\n\t| \"dead_letters\"\n\t| \"no_deliveries\"\n\t| \"receiver_rate_limited\"\n\t| \"receiver_down\"\n\t| \"receiver_rejects\"\n\t| \"receiver_slow\"\n\t| \"delivery_lag\";\n\nexport interface DoctorIssue {\n\tcode: DoctorIssueCode;\n\tdetail?: string;\n\tseverity: DoctorSeverity;\n\t/** 2-4 numbers-only facts backing the issue. Only the five new detectors\n\t * and the list-summary circuit issue carry this — the older flag checks\n\t * keep their plain `detail` string. */\n\tevidence?: DoctorEvidence[];\n\tfix?: DoctorFix;\n}\n\nexport interface DoctorReport {\n\twebhook: WebhookDetail;\n\tdeliverySummary: {\n\t\ttotal: number;\n\t\tsuccessful: number;\n\t\tfailed: number;\n\t\tlast: DeliveryRow | null;\n\t};\n\tdeadCount: number;\n\t/** CLI-facing next steps, one per issue, in the same order as `issues`. */\n\thints: string[];\n\tissues: DoctorIssue[];\n\t/** The single most severe issue (bad > warn > calm, then rule priority),\n\t * or `null` when there are none. The UI leads with this and collapses\n\t * the rest underneath. */\n\tprimary: DoctorIssue | null;\n}\n\n// ── Detector thresholds ─────────────────────────────────────────────\n// Named constants, not config. Tune from real data; until then these stay\n// conservative.\n\nconst RATE_LIMITED_MIN_ATTEMPTS = 10;\nconst RATE_LIMITED_MIN_RATIO = 0.5;\n// Exported: the status pill's \"auto-failing\" rule reuses this\n// instead of duplicating the number.\nexport const DOWN_MIN_CONSECUTIVE = 5;\nconst REJECTS_MIN_CONSECUTIVE = 5;\nconst SLOW_WINDOW = 20;\nconst SLOW_MIN_SAMPLES = 5;\nconst SLOW_TIMEOUT_RATIO = 0.5;\nconst LAG_WINDOW = 20;\nconst LAG_MIN_SAMPLES = 5;\nconst LAG_THRESHOLD_MS = 60_000;\nconst ERROR_SNIPPET_MAX = 200;\n\nfunction median(values: number[]): number {\n\tif (values.length === 0) return 0;\n\tconst sorted = [...values].sort((a, b) => a - b);\n\treturn sorted[Math.floor(sorted.length / 2)] ?? 0;\n}\n\nfunction percentile(values: number[], p: number): number {\n\tif (values.length === 0) return 0;\n\tconst sorted = [...values].sort((a, b) => a - b);\n\tconst idx = Math.min(sorted.length - 1, Math.floor(p * sorted.length));\n\treturn sorted[idx] ?? 0;\n}\n\nfunction formatMs(ms: number): string {\n\treturn ms >= 1000 ? `${(ms / 1000).toFixed(1)}s` : `${Math.round(ms)}ms`;\n}\n\n/** \"2026-04-23 00:00 UTC\" — date, hour:minute, and an explicit zone so an\n * evidence value never reads as local time. */\nfunction formatShortDate(iso: string): string {\n\treturn `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;\n}\n\n/** The longest run from the start of `rows` (newest-first) matching\n * `predicate` — the current losing (or rejecting) streak. */\nfunction consecutiveFromStart(\n\trows: DeliveryRow[],\n\tpredicate: (row: DeliveryRow) => boolean,\n): DeliveryRow[] {\n\tconst out: DeliveryRow[] = [];\n\tfor (const row of rows) {\n\t\tif (!predicate(row)) break;\n\t\tout.push(row);\n\t}\n\treturn out;\n}\n\nfunction summarizeStatusBreakdown(rows: DeliveryRow[]): string {\n\tconst counts = new Map<string, number>();\n\tfor (const row of rows) {\n\t\tconst key =\n\t\t\trow.statusCode === null ? \"timeout/no response\" : String(row.statusCode);\n\t\tcounts.set(key, (counts.get(key) ?? 0) + 1);\n\t}\n\treturn [...counts.entries()].map(([key, n]) => `${n}× ${key}`).join(\", \");\n}\n\nconst RETRY_AFTER_RE = /retry-after:?\\s*(\\d+)/i;\n\n/** The most recent 429's `Retry-After`, if the receiver's error text carried\n * one — we never invent a value the rows didn't report. */\nfunction extractRetryAfterSeconds(rows: DeliveryRow[]): string | null {\n\tfor (const row of rows) {\n\t\tif (row.statusCode !== 429 || !row.errorMessage) continue;\n\t\tconst match = row.errorMessage.match(RETRY_AFTER_RE);\n\t\tif (match?.[1]) return match[1];\n\t}\n\treturn null;\n}\n\n/** ≥10 attempts in the window, ≥50% of them 429 — the receiver is\n * rate-limiting us, not failing. */\nfunction detectReceiverRateLimited(\n\twebhook: WebhookDetail,\n\tdeliveries: DeliveryRow[],\n): DoctorIssue | null {\n\tif (deliveries.length < RATE_LIMITED_MIN_ATTEMPTS) return null;\n\tconst count429 = deliveries.filter((d) => d.statusCode === 429).length;\n\tif (count429 / deliveries.length < RATE_LIMITED_MIN_RATIO) return null;\n\n\tconst oldest = deliveries[deliveries.length - 1];\n\tconst newest = deliveries[0];\n\tconst evidence: DoctorEvidence[] = [\n\t\t{\n\t\t\tlabel: \"429 responses\",\n\t\t\tvalue: `${count429} of ${deliveries.length} attempts`,\n\t\t},\n\t\t{\n\t\t\tlabel: \"window\",\n\t\t\tvalue:\n\t\t\t\toldest && newest\n\t\t\t\t\t? `${formatShortDate(oldest.dispatchedAt)} → ${formatShortDate(newest.dispatchedAt)}`\n\t\t\t\t\t: \"unknown\",\n\t\t},\n\t];\n\tconst retryAfter = extractRetryAfterSeconds(deliveries);\n\tif (retryAfter) {\n\t\tevidence.push({ label: \"latest Retry-After\", value: `${retryAfter}s` });\n\t}\n\n\tconst suggestedConcurrency = Math.max(1, Math.floor(webhook.concurrency / 2));\n\treturn {\n\t\tcode: \"receiver_rate_limited\",\n\t\tseverity: \"warn\",\n\t\tevidence,\n\t\tfix: {\n\t\t\ttext: \"Lower concurrency, or honor the Retry-After header on your receiver.\",\n\t\t\tcommand: `secondlayer webhooks update ${webhook.id} --concurrency ${suggestedConcurrency}`,\n\t\t\tdocsPath: \"/docs/webhooks#receiver-rate-limited\",\n\t\t},\n\t};\n}\n\n/** ≥5 most recent attempts are 5xx or got no response at all (timeout /\n * connection failure) — the receiver looks down, not just slow. */\nfunction detectReceiverDown(\n\twebhook: WebhookDetail,\n\tdeliveries: DeliveryRow[],\n): DoctorIssue | null {\n\tconst streak = consecutiveFromStart(\n\t\tdeliveries,\n\t\t(d) => d.statusCode === null || d.statusCode >= 500,\n\t);\n\tif (streak.length < DOWN_MIN_CONSECUTIVE) return null;\n\n\treturn {\n\t\tcode: \"receiver_down\",\n\t\tseverity: \"bad\",\n\t\tevidence: [\n\t\t\t{ label: \"consecutive failures\", value: String(streak.length) },\n\t\t\t{ label: \"breakdown\", value: summarizeStatusBreakdown(streak) },\n\t\t\t{\n\t\t\t\tlabel: \"last success\",\n\t\t\t\tvalue: webhook.lastSuccessAt\n\t\t\t\t\t? formatShortDate(webhook.lastSuccessAt)\n\t\t\t\t\t: \"never\",\n\t\t\t},\n\t\t],\n\t\tfix: {\n\t\t\ttext: \"Check your receiver's health and logs, then send a test event.\",\n\t\t\tcommand: `secondlayer webhooks test ${webhook.id}`,\n\t\t\tdocsPath: \"/docs/webhooks#receiver-down\",\n\t\t},\n\t};\n}\n\n/** ≥5 most recent attempts are 4xx other than 429 — the receiver is\n * reachable but actively rejecting us (auth, signature, bad request). */\nfunction detectReceiverRejects(\n\twebhook: WebhookDetail,\n\tdeliveries: DeliveryRow[],\n): DoctorIssue | null {\n\tconst streak = consecutiveFromStart(\n\t\tdeliveries,\n\t\t(d) =>\n\t\t\td.statusCode !== null &&\n\t\t\td.statusCode >= 400 &&\n\t\t\td.statusCode < 500 &&\n\t\t\td.statusCode !== 429,\n\t);\n\tif (streak.length < REJECTS_MIN_CONSECUTIVE) return null;\n\n\tconst evidence: DoctorEvidence[] = [\n\t\t{ label: \"consecutive rejects\", value: String(streak.length) },\n\t\t{ label: \"breakdown\", value: summarizeStatusBreakdown(streak) },\n\t];\n\tconst withText = streak.find((d) => d.errorMessage || d.responseBody);\n\tconst snippet = withText\n\t\t? (withText.errorMessage ?? withText.responseBody ?? \"\").slice(\n\t\t\t\t0,\n\t\t\t\tERROR_SNIPPET_MAX,\n\t\t\t)\n\t\t: null;\n\tif (snippet) evidence.push({ label: \"first error\", value: snippet });\n\n\treturn {\n\t\tcode: \"receiver_rejects\",\n\t\tseverity: \"bad\",\n\t\tevidence,\n\t\tfix: {\n\t\t\ttext: \"Check your receiver's auth config or signature verification.\",\n\t\t\tcommand: `secondlayer webhooks test ${webhook.id}`,\n\t\t\tdocsPath: \"/docs/webhooks#receiver-rejects\",\n\t\t},\n\t};\n}\n\n/** Median response time of the newest 20 attempts is at least half the\n * webhook's timeout — deliveries are slow, not failing. */\nfunction detectReceiverSlow(\n\twebhook: WebhookDetail,\n\tdeliveries: DeliveryRow[],\n): DoctorIssue | null {\n\tconst durations = deliveries\n\t\t.slice(0, SLOW_WINDOW)\n\t\t.map((d) => d.durationMs)\n\t\t.filter((d): d is number => d !== null);\n\tif (durations.length < SLOW_MIN_SAMPLES) return null;\n\n\tconst med = median(durations);\n\tif (med < webhook.timeoutMs * SLOW_TIMEOUT_RATIO) return null;\n\n\treturn {\n\t\tcode: \"receiver_slow\",\n\t\tseverity: \"warn\",\n\t\tevidence: [\n\t\t\t{ label: \"median response time\", value: formatMs(med) },\n\t\t\t{\n\t\t\t\tlabel: \"p95 response time\",\n\t\t\t\tvalue: formatMs(percentile(durations, 0.95)),\n\t\t\t},\n\t\t\t{ label: \"timeout\", value: formatMs(webhook.timeoutMs) },\n\t\t],\n\t\tfix: {\n\t\t\ttext: \"Speed up your receiver, or raise the timeout (up to 30s hosted).\",\n\t\t\tcommand: `secondlayer webhooks update ${webhook.id} --timeout-ms 30000`,\n\t\t\tdocsPath: \"/docs/webhooks#receiver-slow\",\n\t\t},\n\t};\n}\n\n/** Median (dispatch time − block time) of the newest 20 attempts with a\n * known block time exceeds a minute — we're behind on delivery. This is\n * our-side latency, not something the receiver can fix, so it carries no\n * actionable command. */\nfunction detectDeliveryLag(deliveries: DeliveryRow[]): DoctorIssue | null {\n\tconst window = deliveries\n\t\t.slice(0, LAG_WINDOW)\n\t\t.filter(\n\t\t\t(d): d is DeliveryRow & { blockTime: string } => d.blockTime !== null,\n\t\t);\n\tif (window.length < LAG_MIN_SAMPLES) return null;\n\n\tconst lags = window.map(\n\t\t(d) => new Date(d.dispatchedAt).getTime() - new Date(d.blockTime).getTime(),\n\t);\n\tconst med = median(lags);\n\tif (med <= LAG_THRESHOLD_MS) return null;\n\n\tconst blockTimes = window.map((d) => d.blockTime).sort();\n\tconst oldest = blockTimes[0];\n\tconst newest = blockTimes[blockTimes.length - 1];\n\n\treturn {\n\t\tcode: \"delivery_lag\",\n\t\tseverity: \"warn\",\n\t\tevidence: [\n\t\t\t{ label: \"median lag\", value: formatMs(med) },\n\t\t\t{\n\t\t\t\tlabel: \"block time range\",\n\t\t\t\tvalue:\n\t\t\t\t\toldest && newest\n\t\t\t\t\t\t? `${formatShortDate(oldest)} → ${formatShortDate(newest)}`\n\t\t\t\t\t\t: \"unknown\",\n\t\t\t},\n\t\t],\n\t\tfix: {\n\t\t\ttext: \"We're behind on delivery; no action needed on your end.\",\n\t\t},\n\t};\n}\n\nconst SEVERITY_RANK: Record<DoctorSeverity, number> = {\n\tbad: 0,\n\twarn: 1,\n\tcalm: 2,\n};\n\n/** Tie-break within a severity tier when more than one issue fires at\n * once — most specific / most actionable first. */\nconst CODE_PRIORITY: DoctorIssueCode[] = [\n\t\"circuit\",\n\t\"receiver_down\",\n\t\"receiver_rejects\",\n\t\"dead_letters\",\n\t\"paused\",\n\t\"last_error\",\n\t\"warning\",\n\t\"receiver_rate_limited\",\n\t\"receiver_slow\",\n\t\"delivery_lag\",\n\t\"no_deliveries\",\n];\n\nfunction pickPrimary(issues: DoctorIssue[]): DoctorIssue | null {\n\tif (issues.length === 0) return null;\n\treturn (\n\t\t[...issues].sort((a, b) => {\n\t\t\tconst sevDiff = SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity];\n\t\t\tif (sevDiff !== 0) return sevDiff;\n\t\t\treturn CODE_PRIORITY.indexOf(a.code) - CODE_PRIORITY.indexOf(b.code);\n\t\t})[0] ?? null\n\t);\n}\n\nfunction hintFor(issue: DoctorIssue): string {\n\tif (!issue.fix) return issue.detail ?? issue.code;\n\treturn issue.fix.command\n\t\t? `${issue.fix.text} ${issue.fix.command}`\n\t\t: issue.fix.text;\n}\n\nexport function buildDoctorReport(input: {\n\twebhook: WebhookDetail;\n\tdeliveries: DeliveryRow[];\n\tdead: DeadRow[];\n}): DoctorReport {\n\tconst successful = input.deliveries.filter(isSuccessDelivery).length;\n\tconst failed = input.deliveries.length - successful;\n\n\tconst hints: string[] = [];\n\tconst issues: DoctorIssue[] = [];\n\tif (input.webhook.warning) {\n\t\thints.push(input.webhook.warning);\n\t\tissues.push({\n\t\t\tcode: \"warning\",\n\t\t\tdetail: input.webhook.warning,\n\t\t\tseverity: \"warn\",\n\t\t});\n\t}\n\tif (input.webhook.status === \"paused\") {\n\t\thints.push(\n\t\t\t`Resume when the receiver is healthy: secondlayer webhooks resume ${input.webhook.id}`,\n\t\t);\n\t\tissues.push({ code: \"paused\", severity: \"warn\" });\n\t}\n\tif (input.webhook.lastError) {\n\t\thints.push(\n\t\t\t\"Run secondlayer webhooks test to reproduce the receiver request.\",\n\t\t);\n\t\tissues.push({\n\t\t\tcode: \"last_error\",\n\t\t\tdetail: input.webhook.lastError,\n\t\t\tseverity: \"warn\",\n\t\t});\n\t}\n\tif (input.webhook.circuitOpenedAt || input.webhook.circuitFailures > 0) {\n\t\thints.push(\n\t\t\t\"Circuit breaker has failures; inspect receiver logs and delivery status codes.\",\n\t\t);\n\t\tissues.push({ code: \"circuit\", severity: \"bad\" });\n\t}\n\tif (input.dead.length > 0) {\n\t\thints.push(\n\t\t\t`Dead-letter rows exist; inspect with secondlayer webhooks dead ${input.webhook.id} and requeue selected rows.`,\n\t\t);\n\t\tissues.push({ code: \"dead_letters\", severity: \"bad\" });\n\t}\n\n\tfor (const detector of [\n\t\tdetectReceiverRateLimited,\n\t\tdetectReceiverDown,\n\t\tdetectReceiverRejects,\n\t\tdetectReceiverSlow,\n\t]) {\n\t\tconst issue = detector(input.webhook, input.deliveries);\n\t\tif (issue) {\n\t\t\tissues.push(issue);\n\t\t\thints.push(hintFor(issue));\n\t\t}\n\t}\n\tconst lagIssue = detectDeliveryLag(input.deliveries);\n\tif (lagIssue) {\n\t\tissues.push(lagIssue);\n\t\thints.push(hintFor(lagIssue));\n\t}\n\n\tif (input.deliveries.length === 0) {\n\t\thints.push(\n\t\t\t\"No deliveries yet; confirm a chain event matching one of the triggers has happened since the webhook was created.\",\n\t\t);\n\t\tissues.push({ code: \"no_deliveries\", severity: \"calm\" });\n\t}\n\tif (hints.length === 0) {\n\t\thints.push(\"No immediate action needed.\");\n\t}\n\n\treturn {\n\t\twebhook: input.webhook,\n\t\tdeliverySummary: {\n\t\t\ttotal: input.deliveries.length,\n\t\t\tsuccessful,\n\t\t\tfailed,\n\t\t\tlast: input.deliveries[0] ?? null,\n\t\t},\n\t\tdeadCount: input.dead.length,\n\t\thints,\n\t\tissues,\n\t\tprimary: pickPrimary(issues),\n\t};\n}\n\n/**\n * The list page's own reduced detector: computed from `WebhookSummary` alone\n * (no deliveries, no dead-letter rows — the list endpoint returns neither,\n * and fetching per-row detail or deliveries here would fan out one request\n * per row). Only `status` and `circuitOpenedAt` distinguish a real problem\n * from a manual pause at this level; deliveries-based rules (rate limits,\n * downtime, rejects, slowness, lag) only ever show on the detail page.\n */\nexport function buildListIssue(\n\twebhook: Pick<WebhookSummary, \"status\" | \"circuitOpenedAt\" | \"lastSuccessAt\">,\n): DoctorIssue | null {\n\tif (webhook.status !== \"paused\") return null;\n\tif (webhook.circuitOpenedAt) {\n\t\treturn {\n\t\t\tcode: \"circuit\",\n\t\t\tseverity: \"bad\",\n\t\t\tevidence: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"circuit opened\",\n\t\t\t\t\tvalue: formatShortDate(webhook.circuitOpenedAt),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"last success\",\n\t\t\t\t\tvalue: webhook.lastSuccessAt\n\t\t\t\t\t\t? formatShortDate(webhook.lastSuccessAt)\n\t\t\t\t\t\t: \"never\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tfix: {\n\t\t\t\ttext: \"Check your receiver's health and logs, then send a test event.\",\n\t\t\t\tdocsPath: \"/docs/webhooks#receiver-down\",\n\t\t\t},\n\t\t};\n\t}\n\treturn { code: \"paused\", severity: \"warn\" };\n}\n"
6
6
  ],
7
- "mappings": ";AAmBO,SAAS,iBAAiB,CAAC,KAA2B;AAAA,EAC5D,OACC,IAAI,eAAe,QAAQ,IAAI,cAAc,OAAO,IAAI,aAAa;AAAA;AA4EvE,IAAM,4BAA4B;AAClC,IAAM,yBAAyB;AAGxB,IAAM,uBAAuB;AACpC,IAAM,0BAA0B;AAChC,IAAM,cAAc;AACpB,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;AAC3B,IAAM,aAAa;AACnB,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AACzB,IAAM,oBAAoB;AAE1B,SAAS,MAAM,CAAC,QAA0B;AAAA,EACzC,IAAI,OAAO,WAAW;AAAA,IAAG,OAAO;AAAA,EAChC,MAAM,SAAS,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AAAA,EAC/C,OAAO,OAAO,KAAK,MAAM,OAAO,SAAS,CAAC,MAAM;AAAA;AAGjD,SAAS,UAAU,CAAC,QAAkB,GAAmB;AAAA,EACxD,IAAI,OAAO,WAAW;AAAA,IAAG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,GAAG;AAAA,IAClC,MAAM,KACL,mHACD;AAAA,IACA,OAAO,KAAK,EAAE,MAAM,iBAAiB,UAAU,OAAO,CAAC;AAAA,EACxD;AAAA,EACA,IAAI,MAAM,WAAW,GAAG;AAAA,IACvB,MAAM,KAAK,6BAA6B;AAAA,EACzC;AAAA,EAEA,OAAO;AAAA,IACN,SAAS,MAAM;AAAA,IACf,iBAAiB;AAAA,MAChB,OAAO,MAAM,WAAW;AAAA,MACxB;AAAA,MACA;AAAA,MACA,MAAM,MAAM,WAAW,MAAM;AAAA,IAC9B;AAAA,IACA,WAAW,MAAM,KAAK;AAAA,IACtB;AAAA,IACA;AAAA,IACA,SAAS,YAAY,MAAM;AAAA,EAC5B;AAAA;AAWM,SAAS,cAAc,CAC7B,SACqB;AAAA,EACrB,IAAI,QAAQ,WAAW;AAAA,IAAU,OAAO;AAAA,EACxC,IAAI,QAAQ,iBAAiB;AAAA,IAC5B,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,UAAU;AAAA,QACT;AAAA,UACC,OAAO;AAAA,UACP,OAAO,gBAAgB,QAAQ,eAAe;AAAA,QAC/C;AAAA,QACA;AAAA,UACC,OAAO;AAAA,UACP,OAAO,QAAQ,gBACZ,gBAAgB,QAAQ,aAAa,IACrC;AAAA,QACJ;AAAA,MACD;AAAA,MACA,KAAK;AAAA,QACJ,MAAM;AAAA,QACN,UAAU;AAAA,MACX;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO,EAAE,MAAM,UAAU,UAAU,OAAO;AAAA;",
8
+ "debugId": "58B01F30F18A50B264756E2164756E21",
9
9
  "names": []
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secondlayer/sdk",
3
- "version": "14.5.1",
3
+ "version": "15.0.1",
4
4
  "description": "Decoded Stacks data in your own database — stream rows into your schema, or query the tables you defined.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -68,12 +68,12 @@
68
68
  "prepublishOnly": "bun run build"
69
69
  },
70
70
  "dependencies": {
71
- "@secondlayer/shared": "^11.24.1",
72
- "@secondlayer/stacks": "^6.2.0",
73
- "@secondlayer/subgraphs": "^6.5.0"
71
+ "@secondlayer/shared": "^12.1.1",
72
+ "@secondlayer/stacks": "^6.2.1",
73
+ "@secondlayer/subgraphs": "^7.0.2"
74
74
  },
75
75
  "devDependencies": {
76
- "@openpkg-ts/cli": "^0.11.3",
76
+ "@openpkg-ts/cli": "^0.13.2",
77
77
  "@types/bun": "latest",
78
78
  "@types/pg": "^8.15.0",
79
79
  "bunup": "0.16.32",