@reddoorla/maintenance 0.64.0 → 0.65.0

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.
Files changed (89) hide show
  1. package/dist/airtable-GGZJUGQB.js +9 -0
  2. package/dist/{announce-QEON4O7E.js → announce-GFLKAPTT.js} +4 -4
  3. package/dist/{bump-deps-2U6GIHM5.js → bump-deps-3QQHYDKJ.js} +2 -2
  4. package/dist/{chunk-BMDBOPN3.js → chunk-4A5PYCGB.js} +2 -2
  5. package/dist/{chunk-OSRFDGQM.js → chunk-4GACMVNE.js} +2 -1
  6. package/dist/{chunk-BLD6AYJO.js → chunk-7RGQ4KLE.js} +5 -2
  7. package/dist/chunk-7RGQ4KLE.js.map +1 -0
  8. package/dist/{chunk-YYUY2OVP.js → chunk-CSTLFSGM.js} +2 -2
  9. package/dist/{chunk-SAOCVNX7.js → chunk-FH7WQHD7.js} +2 -2
  10. package/dist/{chunk-KTPPKO2C.js → chunk-FX3QBSUF.js} +2 -2
  11. package/dist/{chunk-L5F664ZA.js → chunk-G2YRXV26.js} +2 -2
  12. package/dist/chunk-GASBX52O.js +12 -0
  13. package/dist/chunk-GASBX52O.js.map +1 -0
  14. package/dist/{chunk-4REUHZAW.js → chunk-LM42CATB.js} +3 -3
  15. package/dist/{chunk-NPJFHBAX.js → chunk-M5LX2VSR.js} +2 -2
  16. package/dist/{chunk-ZEX2T6JH.js → chunk-MQM5YP4J.js} +2 -2
  17. package/dist/{chunk-P7VJM46I.js → chunk-OYN6H4CX.js} +3 -3
  18. package/dist/{chunk-6ZKM7OIJ.js → chunk-PTPTVVY7.js} +6 -4
  19. package/dist/chunk-PTPTVVY7.js.map +1 -0
  20. package/dist/{chunk-J37CZORZ.js → chunk-QSL3EJGI.js} +3 -3
  21. package/dist/{chunk-SS7BKOIX.js → chunk-TC7Z5LG7.js} +237 -1
  22. package/dist/chunk-TC7Z5LG7.js.map +1 -0
  23. package/dist/{chunk-3HM4S422.js → chunk-UATHDNWP.js} +7 -14
  24. package/dist/chunk-UATHDNWP.js.map +1 -0
  25. package/dist/cli/bin.js +16 -16
  26. package/dist/cli/bin.js.map +1 -1
  27. package/dist/cli/commands/audit.js +10 -8
  28. package/dist/cli/commands/audit.js.map +1 -1
  29. package/dist/{client-GTMJTXBK.js → client-C2GOZD2D.js} +2 -2
  30. package/dist/{convert-to-pnpm-JG3767ZQ.js → convert-to-pnpm-ZO673UFB.js} +2 -2
  31. package/dist/{db-Y6BVTNH7.js → db-YBLQR2YY.js} +2 -2
  32. package/dist/{digest-ABJROO4H.js → digest-R3ROSGLP.js} +3 -3
  33. package/dist/{github-signals-XTJLKOXJ.js → github-signals-N5JGWHW2.js} +9 -9
  34. package/dist/index.d.ts +39 -3
  35. package/dist/index.js +17 -10
  36. package/dist/index.js.map +1 -1
  37. package/dist/{init-DMAIKUQE.js → init-FOHNISF2.js} +6 -4
  38. package/dist/{init-DMAIKUQE.js.map → init-FOHNISF2.js.map} +1 -1
  39. package/dist/{launch-IBP23PNY.js → launch-TM3IHSSU.js} +9 -8
  40. package/dist/{launch-IBP23PNY.js.map → launch-TM3IHSSU.js.map} +1 -1
  41. package/dist/{lighthouse-airtable-HTEW6BBT.js → lighthouse-airtable-5FHELRCA.js} +3 -3
  42. package/dist/{onboard-TTIC3YZI.js → onboard-K2EL4MSG.js} +2 -2
  43. package/dist/{orchestrate-CYYZ737H.js → orchestrate-OX3Z4DUI.js} +5 -5
  44. package/dist/{renovate-dispatch-QDDMTATD.js → renovate-dispatch-H25CQ36P.js} +3 -3
  45. package/dist/{report-QNE7HFOZ.js → report-UEYKO6WH.js} +5 -5
  46. package/dist/{self-updating-2RLUP4AA.js → self-updating-YXOGQWH5.js} +5 -4
  47. package/dist/{self-updating-2RLUP4AA.js.map → self-updating-YXOGQWH5.js.map} +1 -1
  48. package/dist/{selftest-5ELLRH6Q.js → selftest-VE7CSGWE.js} +7 -7
  49. package/dist/{svelte-codemods-BPLKSVIA.js → svelte-codemods-745QM25J.js} +2 -2
  50. package/dist/{sync-configs-VFRV3TJ4.js → sync-configs-NYC3Z625.js} +2 -2
  51. package/dist/{upgrade-WCFD2TRN.js → upgrade-UBPPJ6HN.js} +2 -2
  52. package/dist/{websites-HM2NMZMR.js → websites-CSVLSEVL.js} +2 -2
  53. package/dist/{write-audits-to-airtable-QF26PCAR.js → write-audits-to-airtable-JCV7FYAW.js} +4 -4
  54. package/package.json +1 -1
  55. package/dist/airtable-HHAWHBNM.js +0 -9
  56. package/dist/chunk-3HM4S422.js.map +0 -1
  57. package/dist/chunk-6ZKM7OIJ.js.map +0 -1
  58. package/dist/chunk-BLD6AYJO.js.map +0 -1
  59. package/dist/chunk-SS7BKOIX.js.map +0 -1
  60. /package/dist/{airtable-HHAWHBNM.js.map → airtable-GGZJUGQB.js.map} +0 -0
  61. /package/dist/{announce-QEON4O7E.js.map → announce-GFLKAPTT.js.map} +0 -0
  62. /package/dist/{bump-deps-2U6GIHM5.js.map → bump-deps-3QQHYDKJ.js.map} +0 -0
  63. /package/dist/{chunk-BMDBOPN3.js.map → chunk-4A5PYCGB.js.map} +0 -0
  64. /package/dist/{chunk-OSRFDGQM.js.map → chunk-4GACMVNE.js.map} +0 -0
  65. /package/dist/{chunk-YYUY2OVP.js.map → chunk-CSTLFSGM.js.map} +0 -0
  66. /package/dist/{chunk-SAOCVNX7.js.map → chunk-FH7WQHD7.js.map} +0 -0
  67. /package/dist/{chunk-KTPPKO2C.js.map → chunk-FX3QBSUF.js.map} +0 -0
  68. /package/dist/{chunk-L5F664ZA.js.map → chunk-G2YRXV26.js.map} +0 -0
  69. /package/dist/{chunk-4REUHZAW.js.map → chunk-LM42CATB.js.map} +0 -0
  70. /package/dist/{chunk-NPJFHBAX.js.map → chunk-M5LX2VSR.js.map} +0 -0
  71. /package/dist/{chunk-ZEX2T6JH.js.map → chunk-MQM5YP4J.js.map} +0 -0
  72. /package/dist/{chunk-P7VJM46I.js.map → chunk-OYN6H4CX.js.map} +0 -0
  73. /package/dist/{chunk-J37CZORZ.js.map → chunk-QSL3EJGI.js.map} +0 -0
  74. /package/dist/{client-GTMJTXBK.js.map → client-C2GOZD2D.js.map} +0 -0
  75. /package/dist/{convert-to-pnpm-JG3767ZQ.js.map → convert-to-pnpm-ZO673UFB.js.map} +0 -0
  76. /package/dist/{db-Y6BVTNH7.js.map → db-YBLQR2YY.js.map} +0 -0
  77. /package/dist/{digest-ABJROO4H.js.map → digest-R3ROSGLP.js.map} +0 -0
  78. /package/dist/{github-signals-XTJLKOXJ.js.map → github-signals-N5JGWHW2.js.map} +0 -0
  79. /package/dist/{lighthouse-airtable-HTEW6BBT.js.map → lighthouse-airtable-5FHELRCA.js.map} +0 -0
  80. /package/dist/{onboard-TTIC3YZI.js.map → onboard-K2EL4MSG.js.map} +0 -0
  81. /package/dist/{orchestrate-CYYZ737H.js.map → orchestrate-OX3Z4DUI.js.map} +0 -0
  82. /package/dist/{renovate-dispatch-QDDMTATD.js.map → renovate-dispatch-H25CQ36P.js.map} +0 -0
  83. /package/dist/{report-QNE7HFOZ.js.map → report-UEYKO6WH.js.map} +0 -0
  84. /package/dist/{selftest-5ELLRH6Q.js.map → selftest-VE7CSGWE.js.map} +0 -0
  85. /package/dist/{svelte-codemods-BPLKSVIA.js.map → svelte-codemods-745QM25J.js.map} +0 -0
  86. /package/dist/{sync-configs-VFRV3TJ4.js.map → sync-configs-NYC3Z625.js.map} +0 -0
  87. /package/dist/{upgrade-WCFD2TRN.js.map → upgrade-UBPPJ6HN.js.map} +0 -0
  88. /package/dist/{websites-HM2NMZMR.js.map → websites-CSVLSEVL.js.map} +0 -0
  89. /package/dist/{write-audits-to-airtable-QF26PCAR.js.map → write-audits-to-airtable-JCV7FYAW.js.map} +0 -0
@@ -0,0 +1,9 @@
1
+ import {
2
+ fromAirtableBase
3
+ } from "./chunk-MQM5YP4J.js";
4
+ import "./chunk-U5SZ4FOP.js";
5
+ import "./chunk-7RGQ4KLE.js";
6
+ export {
7
+ fromAirtableBase
8
+ };
9
+ //# sourceMappingURL=airtable-GGZJUGQB.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  scoresFromRow
3
- } from "./chunk-P7VJM46I.js";
3
+ } from "./chunk-OYN6H4CX.js";
4
4
  import {
5
5
  fetchGaUsers,
6
6
  fetchSearch
7
- } from "./chunk-NPJFHBAX.js";
7
+ } from "./chunk-M5LX2VSR.js";
8
8
  import {
9
9
  queueDraft
10
10
  } from "./chunk-6LIWDIXU.js";
@@ -26,7 +26,7 @@ import "./chunk-U5SZ4FOP.js";
26
26
  import {
27
27
  listWebsites,
28
28
  siteSlug
29
- } from "./chunk-BLD6AYJO.js";
29
+ } from "./chunk-7RGQ4KLE.js";
30
30
  import {
31
31
  openBase,
32
32
  readAirtableConfig
@@ -170,4 +170,4 @@ export {
170
170
  formatAnnounceResult,
171
171
  runAnnounceCommand
172
172
  };
173
- //# sourceMappingURL=announce-QEON4O7E.js.map
173
+ //# sourceMappingURL=announce-GFLKAPTT.js.map
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-4NAOR44V.js";
6
6
  import {
7
7
  resolveSites
8
- } from "./chunk-SAOCVNX7.js";
8
+ } from "./chunk-FH7WQHD7.js";
9
9
  import {
10
10
  bumpDeps
11
11
  } from "./chunk-D3DQFC32.js";
@@ -54,4 +54,4 @@ async function runBumpDepsCommand(site, opts) {
54
54
  export {
55
55
  runBumpDepsCommand
56
56
  };
57
- //# sourceMappingURL=bump-deps-2U6GIHM5.js.map
57
+ //# sourceMappingURL=bump-deps-3QQHYDKJ.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  siteSlug
3
- } from "./chunk-BLD6AYJO.js";
3
+ } from "./chunk-7RGQ4KLE.js";
4
4
 
5
5
  // src/alerts/digest-collectors.ts
6
6
  function dashboardUrl(baseUrl, siteName) {
@@ -208,4 +208,4 @@ export {
208
208
  readDigestState,
209
209
  writeDigestState
210
210
  };
211
- //# sourceMappingURL=chunk-BMDBOPN3.js.map
211
+ //# sourceMappingURL=chunk-4A5PYCGB.js.map
@@ -236,6 +236,7 @@ function makeGitHub(deps) {
236
236
  }
237
237
 
238
238
  export {
239
+ assertUrlSegment,
239
240
  makeGitHub
240
241
  };
241
- //# sourceMappingURL=chunk-OSRFDGQM.js.map
242
+ //# sourceMappingURL=chunk-4GACMVNE.js.map
@@ -62,6 +62,7 @@ function mapRow(rec) {
62
62
  gitRepo: f["Git repo"] ?? null,
63
63
  reportRecipientsTo: f["Report recipients (To)"] ?? null,
64
64
  reportRecipientsCc: f["Report recipients (CC)"] ?? null,
65
+ acceptedWatchConditions: Array.isArray(f["Accepted Watch Conditions"]) ? f["Accepted Watch Conditions"] : [],
65
66
  headerImage: header,
66
67
  pScore: f["pScore"] ?? null,
67
68
  rScore: f["rScore"] ?? null,
@@ -163,12 +164,14 @@ function normalizeSecurityAdvisory(raw) {
163
164
  if (severity !== "low" && severity !== "moderate" && severity !== "high" && severity !== "critical")
164
165
  return null;
165
166
  const cves = Array.isArray(e["cves"]) ? e["cves"].filter((c) => typeof c === "string") : [];
167
+ const scope = e["scope"] === "runtime" || e["scope"] === "development" ? e["scope"] : void 0;
166
168
  return {
167
169
  module,
168
170
  severity,
169
171
  title: typeof e["title"] === "string" ? e["title"] : "",
170
172
  cves,
171
- url: typeof e["url"] === "string" ? e["url"] : null
173
+ url: typeof e["url"] === "string" ? e["url"] : null,
174
+ ...scope ? { scope } : {}
172
175
  };
173
176
  }
174
177
  function parseSecurityAdvisories(raw) {
@@ -297,4 +300,4 @@ export {
297
300
  updateGitHubSignals,
298
301
  updateLaunched
299
302
  };
300
- //# sourceMappingURL=chunk-BLD6AYJO.js.map
303
+ //# sourceMappingURL=chunk-7RGQ4KLE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/reports/airtable/websites.ts"],"sourcesContent":["import type { FieldSet } from \"airtable\";\nimport type { AirtableBase } from \"./client.js\";\nimport type { LighthouseScores, LighthouseScoreWriteback } from \"../types.js\";\n\nexport const WEBSITES_TABLE = \"Websites\";\n\nexport type Frequency = \"None\" | \"Monthly\" | \"Quarterly\" | \"Yearly\";\n\nexport type Status =\n | \"in development\"\n | \"launch period\"\n | \"maintenance\"\n | \"hosting\"\n | \"probably not our problem\"\n | \"deprecated\";\n\n/**\n * Per-site notification routing. When present on a `maintenance` site, the form\n * notification is addressed by the value of a submission field (`field`, read from\n * `extraFields`) — e.g. route a contact form's `interest` to a different recipient\n * per option, always CC-ing a shared address. Absent (`null`) → the site keeps the\n * default single-POC behavior. Recipients live HERE (server-side Airtable config),\n * never supplied by the submitting site, so the ingest can't be turned into an open\n * relay.\n */\nexport type NotifyRouting = {\n /** The `extraFields` key whose value selects a route, e.g. \"interest\". */\n field: string;\n /** Field-value → recipient address(es). */\n routes: Record<string, string | string[]>;\n /** Recipient(s) when the value matches no route. */\n default?: string | string[];\n /** Address(es) CC'd on every routed (maintenance) send. */\n cc?: string[];\n};\n\nexport type WebsiteRow = {\n id: string;\n name: string;\n url: string;\n status: Status | null;\n pointOfContact: string | null;\n maintenanceFreq: Frequency;\n testingFreq: Frequency;\n /** Last manually-recorded maintenance day (used as fallback when no Reports row exists). */\n maintenanceDay: string | null;\n testingDay: string | null;\n ga4PropertyId: string | null;\n /** Operator-supplied query for the Google search-presence check (e.g. the business name).\n * Null = no query set → the check is skipped for this site. */\n searchQuery: string | null;\n /** Explicit Search Console property for this site (`sc-domain:...` or `https://.../`).\n * Null = auto-resolve from the SA's visible properties by host. */\n searchConsoleProperty: string | null;\n /** ISO timestamp of the last draft run where THIS site's GA/Search enrichment\n * ERRORED (vs a legitimate \"not configured\" skip). Set by drafting on a soft-fail,\n * cleared (null) on a clean enrichment, so the per-site analytics-failure signal\n * self-heals. Null when the operator-added `Analytics soft-fail at` column is absent. */\n analyticsSoftFailAt: string | null;\n /** GitHub repo identity as `owner/repo`. Null = no git wiring → self-update ops skip\n * (or, for local runs, fall back to the checkout's origin remote). */\n gitRepo: string | null;\n reportRecipientsTo: string | null;\n reportRecipientsCc: string | null;\n acceptedWatchConditions: string[];\n /** First attachment in the Header image field (Airtable's signed URL — fetch before expiry). */\n headerImage: { url: string; filename: string; type: string } | null;\n /** Lighthouse \"current state\" snapshot, kept fresh by `audit lighthouse --write-airtable`. */\n pScore: number | null;\n rScore: number | null;\n bpScore: number | null;\n seoScore: number | null;\n /** ISO timestamp set by `audit lighthouse --write-airtable` when scores were last refreshed. */\n lastLighthouseAuditAt: string | null;\n /** Last-known counts from non-lighthouse audits, written by\n * `audit --write-airtable`. `null` = never audited (or this audit\n * type was skipped on the last run). 0 = audited, clean. */\n a11yViolations: number | null;\n /** Declared-range drift vs the Reddoor baseline (what package.json asks for). */\n depsDrifted: number | null;\n depsMajorBehind: number | null;\n /** Real installed-version drift: deps behind the registry's latest, from the\n * committed lockfile (`pnpm outdated`). Null = not determined this run. */\n depsOutdated: number | null;\n securityVulnsCritical: number | null;\n securityVulnsHigh: number | null;\n securityVulnsModerate: number | null;\n securityVulnsLow: number | null;\n /** Count of consecutive nightly Renovate auto-fix dispatches for the CURRENT\n * critical/high vuln episode that have NOT yet cleared it. Owned by\n * `renovate-dispatch`: +1 per real dispatch, reset to 0 when vulns clear.\n * Null = field absent / never dispatched → reads as 0. At/above\n * AUTO_FIX_EXHAUSTED_CYCLES the vuln renders as \"auto-fix failed\". */\n securityAutoFixAttempts: number | null;\n /** ISO timestamp the security audit last ran — gates freshness of the Security Updates auto-tick\n * (clean counts only auto-tick when recent). */\n lastSecurityAuditAt: string | null;\n /** The known advisories behind the counts (severity-sorted, capped), so the dashboard can show\n * WHICH packages are vulnerable, not just the totals. null = never audited / unparseable;\n * empty array = audited clean. Written alongside the counts by the security audit. */\n securityAdvisories: SecurityAdvisory[] | null;\n /** Domain/DNS/SSL probe (the `domain` audit). `certDaysRemaining` is days until the TLS cert\n * expires (null = unresolved or no usable cert); `domainCheckedAt` is when it last ran. */\n certDaysRemaining: number | null;\n domainCheckedAt: string | null;\n /** Netlify site id — the IDENTITY the `netlify-deploy` audit needs to query the\n * Netlify API. Read-only input (operator-set in Airtable); null = not on Netlify\n * (or not wired) → that audit skips. Never derived from the URL. */\n netlifyId: string | null;\n /** Latest PRODUCTION deploy health (the `netlify-deploy` audit). `deployStatus` is\n * Netlify's deploy state lower-cased (`ready`/`error`/`building`/…), null = none / not\n * checked; `lastDeployAt` is when it deployed; `deployLogUrl` links to the deploy/log. */\n deployStatus: string | null;\n lastDeployAt: string | null;\n deployLogUrl: string | null;\n /** Deployed-URL browser probe (the `browser` audit): cross-engine render OK, mobile render OK,\n * internal-links OK + broken count, and when it last ran (one timestamp gates all three). */\n crossbrowserOk: boolean | null;\n mobileOk: boolean | null;\n linksOk: boolean | null;\n brokenLinks: number | null;\n browserCheckedAt: string | null;\n /** Per-site copy overrides (M6a). Blank → null → the DEFAULT_COPY value. */\n copyIntro: string | null;\n copyContact: string | null;\n copyFooter: string | null;\n /** Go-live timestamp, stamped when a Launch report sends (M6b). Null = not yet launched. */\n launchedAt: string | null;\n /** Optional per-site webhook (e.g. Zapier Catch Hook). When set, the ingest\n * POSTs newsletter-formType submissions here (best-effort). Blank → null. */\n newsletterWebhook: string | null;\n /** Per-site Mailchimp (newsletter). Both must be set for the direct add;\n * blank → skipped. The API key is `key-dc` format; dc is derived from it. */\n mailchimpApiKey: string | null;\n mailchimpAudienceId: string | null;\n /** GitHub-signals sweep (slice 2a), written nightly by `github-signals --fleet`. */\n renovateFailingCis: number | null;\n defaultBranchCi: string | null; // \"passing\" | \"failing\" | \"pending\" | \"none\"\n lastCommitAt: string | null;\n githubSignalsAt: string | null;\n notifyRouting: NotifyRouting | null;\n};\n\nexport function siteSlug(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-|-$/g, \"\");\n}\n\n/** Blank-trim-to-null: a non-string or whitespace-only value becomes null,\n * otherwise the trimmed string. */\nfunction trimToNull(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const trimmed = raw.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\n/**\n * Parse the Websites `Notify Routing` JSON into a NotifyRouting, defensively: a\n * non-string, blank, malformed-JSON, or wrong-shape value yields null (the site\n * then keeps default single-POC routing) — never throws. Mirrors the pipeline's\n * \"a bad Airtable string degrades quietly\" rule.\n */\nexport function parseNotifyRouting(raw: unknown): NotifyRouting | null {\n if (typeof raw !== \"string\") return null;\n const trimmed = raw.trim();\n if (!trimmed) return null;\n let parsed: unknown;\n try {\n parsed = JSON.parse(trimmed);\n } catch {\n return null;\n }\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) return null;\n const o = parsed as Record<string, unknown>;\n if (typeof o.field !== \"string\" || !o.field.trim()) return null;\n if (!o.routes || typeof o.routes !== \"object\" || Array.isArray(o.routes)) return null;\n const routing: NotifyRouting = {\n field: o.field,\n routes: o.routes as Record<string, string | string[]>,\n };\n if (o.default !== undefined) routing.default = o.default as string | string[];\n if (Array.isArray(o.cc)) routing.cc = o.cc.filter((x): x is string => typeof x === \"string\");\n return routing;\n}\n\n/**\n * Active sites: actively-maintained or pre-launch. Single source of truth for\n * \"is this a live site\" — the operator cockpit shows these, and the fleet\n * audit/report path runs against these. A `null` status (not-yet-active) is\n * deliberately excluded.\n */\nexport const ACTIVE_STATUSES: ReadonlySet<Status> = new Set<Status>([\n \"maintenance\",\n \"launch period\",\n]);\n\nexport function isDashboardVisible(site: WebsiteRow): boolean {\n return site.status !== null && ACTIVE_STATUSES.has(site.status);\n}\n\nconst FREQUENCIES: readonly Frequency[] = [\"None\", \"Monthly\", \"Quarterly\", \"Yearly\"];\n\n/** Coerce an Airtable single-select value to a known Frequency. An unrecognized value — a\n * renamed / typo'd / whitespace option — falls back to \"None\" (its section is simply omitted)\n * rather than flowing a bogus string downstream, which the announcement would otherwise render\n * as \"We do this undefined.\" into a client email. */\nfunction toFrequency(raw: unknown): Frequency {\n return typeof raw === \"string\" && (FREQUENCIES as readonly string[]).includes(raw)\n ? (raw as Frequency)\n : \"None\";\n}\n\n// NOTE: every `f[\"...\"]` key below is a load-bearing magic string that must match\n// the live Airtable \"Websites\" column name EXACTLY — including the legacy\n// misspelling `\"maintenence freq\"`, the mixed-case `\"GA4 property ID\"`, and the\n// lowercase `\"url\"` / `\"point of contact\"`. A column rename in Airtable silently\n// returns undefined here (→ null), which degrades quietly (GA skipped, recipients\n// empty) with no error. If you rename a column, change it here too.\nexport function mapRow(rec: { id: string; fields: Record<string, unknown> }): WebsiteRow {\n const f = rec.fields;\n const attachments =\n (f[\"Header image\"] as Array<{ url: string; filename: string; type: string }> | undefined) ?? [];\n const header = attachments[0] ?? null;\n return {\n id: rec.id,\n name: String(f[\"Name\"] ?? \"\"),\n url: String(f[\"url\"] ?? \"\"),\n status: (f[\"Status\"] as Status | undefined) ?? null,\n pointOfContact: (f[\"point of contact\"] as string | undefined) ?? null,\n maintenanceFreq: toFrequency(f[\"maintenence freq\"]),\n testingFreq: toFrequency(f[\"testing freq\"]),\n maintenanceDay: (f[\"maintenance day\"] as string | undefined) ?? null,\n testingDay: (f[\"testing day\"] as string | undefined) ?? null,\n ga4PropertyId: (f[\"GA4 property ID\"] as string | undefined) ?? null,\n searchQuery: (f[\"Search query\"] as string | undefined) ?? null,\n searchConsoleProperty: (f[\"Search Console property\"] as string | undefined) ?? null,\n analyticsSoftFailAt: (f[\"Analytics soft-fail at\"] as string | undefined) ?? null,\n gitRepo: (f[\"Git repo\"] as string | undefined) ?? null,\n reportRecipientsTo: (f[\"Report recipients (To)\"] as string | undefined) ?? null,\n reportRecipientsCc: (f[\"Report recipients (CC)\"] as string | undefined) ?? null,\n acceptedWatchConditions: Array.isArray(f[\"Accepted Watch Conditions\"])\n ? (f[\"Accepted Watch Conditions\"] as string[])\n : [],\n headerImage: header,\n pScore: (f[\"pScore\"] as number | undefined) ?? null,\n rScore: (f[\"rScore\"] as number | undefined) ?? null,\n bpScore: (f[\"bpScore\"] as number | undefined) ?? null,\n seoScore: (f[\"seoScore\"] as number | undefined) ?? null,\n lastLighthouseAuditAt: (f[\"Last lighthouse audit at\"] as string | undefined) ?? null,\n a11yViolations: (f[\"A11y Violations\"] as number | undefined) ?? null,\n depsDrifted: (f[\"Deps Drifted\"] as number | undefined) ?? null,\n depsMajorBehind: (f[\"Deps Major Behind\"] as number | undefined) ?? null,\n depsOutdated: (f[\"Deps Outdated\"] as number | undefined) ?? null,\n securityVulnsCritical: (f[\"Security Vulns Critical\"] as number | undefined) ?? null,\n securityVulnsHigh: (f[\"Security Vulns High\"] as number | undefined) ?? null,\n securityVulnsModerate: (f[\"Security Vulns Moderate\"] as number | undefined) ?? null,\n securityVulnsLow: (f[\"Security Vulns Low\"] as number | undefined) ?? null,\n securityAutoFixAttempts: (f[\"Security Auto-Fix Attempts\"] as number | undefined) ?? null,\n lastSecurityAuditAt: (f[\"Last security audit at\"] as string | undefined) ?? null,\n securityAdvisories: parseSecurityAdvisories(f[\"Security advisories\"]),\n certDaysRemaining: (f[\"Cert days remaining\"] as number | undefined) ?? null,\n domainCheckedAt: (f[\"Domain checked at\"] as string | undefined) ?? null,\n netlifyId: trimToNull(f[\"Netlify ID\"]),\n deployStatus: (f[\"Deploy status\"] as string | undefined) ?? null,\n lastDeployAt: (f[\"Last deploy at\"] as string | undefined) ?? null,\n deployLogUrl: (f[\"Deploy log URL\"] as string | undefined) ?? null,\n crossbrowserOk:\n typeof f[\"Crossbrowser OK\"] === \"boolean\" ? (f[\"Crossbrowser OK\"] as boolean) : null,\n mobileOk: typeof f[\"Mobile OK\"] === \"boolean\" ? (f[\"Mobile OK\"] as boolean) : null,\n linksOk: typeof f[\"Links OK\"] === \"boolean\" ? (f[\"Links OK\"] as boolean) : null,\n brokenLinks: typeof f[\"Broken links\"] === \"number\" ? (f[\"Broken links\"] as number) : null,\n browserCheckedAt: (f[\"Browser checked at\"] as string | undefined) ?? null,\n copyIntro: trimToNull(f[\"Copy — Intro\"]),\n copyContact: trimToNull(f[\"Copy — Contact\"]),\n copyFooter: trimToNull(f[\"Copy — Footer\"]),\n launchedAt: (f[\"Launched at\"] as string | undefined) ?? null,\n newsletterWebhook: trimToNull(f[\"Newsletter Webhook\"]),\n notifyRouting: parseNotifyRouting(f[\"Notify Routing\"]),\n mailchimpApiKey: trimToNull(f[\"Mailchimp API Key\"]),\n mailchimpAudienceId: trimToNull(f[\"Mailchimp Audience ID\"]),\n renovateFailingCis: (f[\"Renovate Failing CIs\"] as number | undefined) ?? null,\n defaultBranchCi: (f[\"Default Branch CI\"] as string | undefined) ?? null,\n lastCommitAt: (f[\"Last Commit At\"] as string | undefined) ?? null,\n githubSignalsAt: (f[\"GitHub Signals At\"] as string | undefined) ?? null,\n };\n}\n\nexport async function listWebsites(base: AirtableBase): Promise<WebsiteRow[]> {\n const out: WebsiteRow[] = [];\n await base(WEBSITES_TABLE)\n .select({ pageSize: 100 })\n .eachPage((records, fetchNextPage) => {\n for (const rec of records) out.push(mapRow({ id: rec.id, fields: rec.fields }));\n fetchNextPage();\n });\n return out;\n}\n\nexport async function getWebsiteBySlug(\n base: AirtableBase,\n slug: string,\n): Promise<WebsiteRow | null> {\n // Slugs are siteSlug() output: [a-z0-9] segments joined by single hyphens.\n // Reject anything else — it can't match a real row, and it keeps URL-supplied\n // input out of the filter formula below (formula-injection guard).\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug)) return null;\n\n // Narrow the fetch to the slug-matching row server-side instead of paging the\n // whole table per request (MEDIUM-H). The formula replicates siteSlug() on\n // {Name} — lowercase → non-alnum runs to \"-\" → strip leading/trailing \"-\" —\n // verified against the live base. maxRecords caps it (slug collisions keep the\n // prior first-match-wins behavior).\n const formula = `REGEX_REPLACE(REGEX_REPLACE(LOWER({Name}),\"[^a-z0-9]+\",\"-\"),\"^-|-$\",\"\")=${JSON.stringify(\n slug,\n )}`;\n const rows: WebsiteRow[] = [];\n await base(WEBSITES_TABLE)\n .select({ filterByFormula: formula, maxRecords: 1 })\n .eachPage((records, fetchNextPage) => {\n for (const rec of records) rows.push(mapRow({ id: rec.id, fields: rec.fields }));\n fetchNextPage();\n });\n // Confirm the match in JS too: keeps the function correct if the formula and\n // siteSlug() ever drift, and under test fakes that don't evaluate the formula.\n return rows.find((w) => siteSlug(w.name) === slug) ?? null;\n}\n\n// ── audit-field builders ─────────────────────────────────────────────────────\n// One source of truth for the column-name → value mappings of each audit type.\n// The per-audit `updateXxxCounts` writers delegate to these (for their other\n// callers), and `updateAuditFields` merges whichever are present into ONE write —\n// so the field-name magic strings live in exactly one place.\n\nexport type A11yCounts = { violations: number };\nexport type DepsCounts = { drifted: number; majorBehind: number; outdated: number | null };\nexport type SecurityCounts = { critical: number; high: number; moderate: number; low: number };\nexport type Severity = \"low\" | \"moderate\" | \"high\" | \"critical\";\n/** One known vulnerability behind the security counts, as persisted/rendered. */\nexport type SecurityAdvisory = {\n module: string;\n severity: Severity;\n title: string;\n cves: string[];\n url: string | null;\n /** GitHub Dependabot dependency scope (\"runtime\" | \"development\"), when known. Lets the\n * dashboard flag build-time-only (\"development\") vulns. Omitted for advisories from the\n * lockfile `pnpm audit` fallback, which carries no per-package graph scope. */\n scope?: \"runtime\" | \"development\";\n};\nexport type DomainResult = { certDaysRemaining: number | null; checkedAt: string };\nexport type NetlifyDeployResult = {\n /** Netlify deploy state lower-cased (`ready`/`error`/`building`/…), null = none. */\n state: string | null;\n /** When the latest production deploy was published/created (ISO), null = unknown. */\n deployedAt: string | null;\n /** Link to the deploy / its build log, null = unknown. */\n logUrl: string | null;\n /** When the audit last ran. */\n checkedAt: string;\n};\nexport type BrowserAuditFields = {\n desktopOk: boolean;\n mobileOk: boolean;\n linksOk: boolean;\n brokenLinks: number;\n checkedAt: string;\n};\n\nfunction scoreFields(scores: LighthouseScoreWriteback): FieldSet {\n // A null score CLEARS the cell (→ dashboard \"—\"), distinguishing a metric that\n // errored this run (e.g. NO_LCP → null performance) from a real low score. This\n // intentionally overwrites a prior value: a run that couldn't measure the metric\n // shouldn't keep showing a stale number. Writing null to clear mirrors\n // updateAnalyticsHealth; the `as FieldSet` cast is needed because airtable's\n // FieldSet type omits null.\n const fields: Record<string, number | string | null> = {\n pScore: scores.performance,\n rScore: scores.accessibility,\n bpScore: scores.bestPractices,\n seoScore: scores.seo,\n \"Last lighthouse audit at\": new Date().toISOString(),\n };\n return fields as FieldSet;\n}\n\nfunction a11yFields(counts: A11yCounts): FieldSet {\n return { \"A11y Violations\": counts.violations };\n}\n\nfunction depsFields(counts: DepsCounts): FieldSet {\n const fields: FieldSet = {\n \"Deps Drifted\": counts.drifted,\n \"Deps Major Behind\": counts.majorBehind,\n };\n // Only write the outdated count when it was determined — a null (no/stale\n // lockfile this run) must not clobber a previously-good value.\n if (counts.outdated !== null) {\n fields[\"Deps Outdated\"] = counts.outdated;\n }\n return fields;\n}\n\n/** Critical first → low last; the persist cap and the dashboard list both lean on this. */\nexport const SEVERITY_RANK: Record<Severity, number> = {\n critical: 0,\n high: 1,\n moderate: 2,\n low: 3,\n};\n/** Cap persisted advisories so the JSON field can't blow up on a badly-neglected site. */\nconst MAX_PERSISTED_ADVISORIES = 25;\n\n/** Coerce one untrusted value into a SecurityAdvisory, or null if it isn't shaped like one.\n * Shared by the read path (`parseSecurityAdvisories`) and the write path so both validate\n * identically. A missing module or unrecognized severity drops the entry entirely. */\nexport function normalizeSecurityAdvisory(raw: unknown): SecurityAdvisory | null {\n if (!raw || typeof raw !== \"object\") return null;\n const e = raw as Record<string, unknown>;\n const module = typeof e[\"module\"] === \"string\" ? (e[\"module\"] as string) : null;\n const severity = e[\"severity\"];\n if (module === null) return null;\n if (\n severity !== \"low\" &&\n severity !== \"moderate\" &&\n severity !== \"high\" &&\n severity !== \"critical\"\n )\n return null;\n const cves = Array.isArray(e[\"cves\"])\n ? (e[\"cves\"] as unknown[]).filter((c): c is string => typeof c === \"string\")\n : [];\n const scope =\n e[\"scope\"] === \"runtime\" || e[\"scope\"] === \"development\"\n ? (e[\"scope\"] as \"runtime\" | \"development\")\n : undefined;\n return {\n module,\n severity,\n title: typeof e[\"title\"] === \"string\" ? (e[\"title\"] as string) : \"\",\n cves,\n url: typeof e[\"url\"] === \"string\" ? (e[\"url\"] as string) : null,\n ...(scope ? { scope } : {}),\n };\n}\n\n/** Parse the `Security advisories` JSON cell. null when absent/blank/unparseable/not-an-array\n * (treated as \"never audited\"); a valid array (possibly empty = audited clean) otherwise. */\nexport function parseSecurityAdvisories(raw: unknown): SecurityAdvisory[] | null {\n if (typeof raw !== \"string\" || raw.trim() === \"\") return null;\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return null;\n }\n if (!Array.isArray(parsed)) return null;\n return parsed.map(normalizeSecurityAdvisory).filter((a): a is SecurityAdvisory => a !== null);\n}\n\nfunction securityAdvisoryFields(advisories: SecurityAdvisory[]): FieldSet {\n const capped = [...advisories]\n .sort((a, b) => SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity])\n .slice(0, MAX_PERSISTED_ADVISORIES);\n // Always write — an empty array (\"[]\") clears a stale list when a once-vulnerable site goes clean.\n return { \"Security advisories\": JSON.stringify(capped) };\n}\n\nfunction securityFields(counts: SecurityCounts): FieldSet {\n return {\n \"Security Vulns Critical\": counts.critical,\n \"Security Vulns High\": counts.high,\n \"Security Vulns Moderate\": counts.moderate,\n \"Security Vulns Low\": counts.low,\n // Stamp freshness alongside the counts so the Security Updates auto-tick can require a recent\n // audit (a clean count from months ago must not silently keep ticking the box).\n \"Last security audit at\": new Date().toISOString(),\n };\n}\n\nfunction domainFields(result: DomainResult): FieldSet {\n const fields: FieldSet = { \"Domain checked at\": result.checkedAt };\n // Write the cert days UNCONDITIONALLY: a null (unresolved / no usable cert) must CLEAR any\n // previously-good value. Leaving a stale number in place — next to a freshly-stamped \"Domain\n // checked at\" — false-passes the Domain/DNS/SSL auto-tick (domainEvidence reads the stale\n // non-null value as a current pass) for a site that's actually down. null clears the cell in\n // Airtable; FieldSet's type doesn't model null, hence the cast through a widened record.\n (fields as Record<string, number | null>)[\"Cert days remaining\"] = result.certDaysRemaining;\n return fields;\n}\n\nfunction netlifyDeployFields(result: NetlifyDeployResult): FieldSet {\n // Write all three deploy fields UNCONDITIONALLY (null clears the cell): a null state /\n // deployedAt / logUrl this run means \"couldn't read it\" and must not leave a STALE value\n // sitting next to a fresh \"Deploy checked at\" — the dashboard would otherwise render a green\n // \"ready\" badge for a site whose latest deploy actually errored. FieldSet's type doesn't model\n // null, hence the cast through a widened record (same approach as domainFields).\n const fields: Record<string, string | null> = {\n \"Deploy status\": result.state,\n \"Last deploy at\": result.deployedAt,\n \"Deploy log URL\": result.logUrl,\n \"Deploy checked at\": result.checkedAt,\n };\n return fields as FieldSet;\n}\n\nfunction browserFields(r: BrowserAuditFields): FieldSet {\n return {\n \"Crossbrowser OK\": r.desktopOk,\n \"Mobile OK\": r.mobileOk,\n \"Links OK\": r.linksOk,\n \"Broken links\": r.brokenLinks,\n \"Browser checked at\": r.checkedAt,\n };\n}\n\n/**\n * Write the four Lighthouse scores + a refreshed-at timestamp onto a Websites row.\n * Called by `audit lighthouse --write-airtable` after a successful audit run, so\n * the operator never has to paste numbers manually before drafting a report.\n */\nexport async function updateScores(\n base: AirtableBase,\n recordId: string,\n scores: LighthouseScores,\n): Promise<void> {\n await base(WEBSITES_TABLE).update([{ id: recordId, fields: scoreFields(scores) }]);\n}\n\n/**\n * Record (or clear) the per-site GA/Search enrichment health on the `Analytics\n * soft-fail at` column. `at` is an ISO timestamp when the site's last draft had a\n * GA/Search soft-failure, or `null` to clear it after a clean enrichment. The\n * caller (drafting) swallows errors: this column is operator-added, so until it\n * exists Airtable throws UNKNOWN_FIELD_NAME — which must not break a draft.\n */\nexport async function updateAnalyticsHealth(\n base: AirtableBase,\n recordId: string,\n at: string | null,\n): Promise<void> {\n const fields: Record<string, string | null> = { \"Analytics soft-fail at\": at };\n await base(WEBSITES_TABLE).update([{ id: recordId, fields: fields as FieldSet }]);\n}\n\n/** Persist a11y violation count. */\nexport async function updateA11yCounts(\n base: AirtableBase,\n recordId: string,\n counts: A11yCounts,\n): Promise<void> {\n await base(WEBSITES_TABLE).update([{ id: recordId, fields: a11yFields(counts) }]);\n}\n\n/** Persist deps drift counts (declared-range drift + real outdated installs). */\nexport async function updateDepsCounts(\n base: AirtableBase,\n recordId: string,\n counts: DepsCounts,\n): Promise<void> {\n await base(WEBSITES_TABLE).update([{ id: recordId, fields: depsFields(counts) }]);\n}\n\n/** Persist security vulnerability counts by severity. */\nexport async function updateSecurityCounts(\n base: AirtableBase,\n recordId: string,\n counts: SecurityCounts,\n): Promise<void> {\n await base(WEBSITES_TABLE).update([{ id: recordId, fields: securityFields(counts) }]);\n}\n\n/** Persist a site's auto-fix attempt counter. Its own one-field writer so the\n * nightly Renovate dispatch can update it without touching the audit's counts. */\nexport async function updateAutoFixAttempts(\n base: AirtableBase,\n recordId: string,\n attempts: number,\n): Promise<void> {\n await base(WEBSITES_TABLE).update([\n { id: recordId, fields: { \"Security Auto-Fix Attempts\": attempts } },\n ]);\n}\n\n/** Generic single-field writer for the dashboard site-details editor. The caller\n * (setSiteDetail) restricts `column` to the EDITABLE_SITE_FIELDS allowlist, so this\n * never writes an arbitrary column from request input. */\nexport async function updateSiteField(\n base: AirtableBase,\n recordId: string,\n column: string,\n value: string,\n): Promise<void> {\n await base(WEBSITES_TABLE).update([{ id: recordId, fields: { [column]: value } }]);\n}\n\n/**\n * Persist all of a single audit run's results to one Websites row in ONE atomic\n * `update()` — instead of up to four sequential updates on the same id (which left\n * a row half-written on a mid-sequence failure and quadrupled the request volume).\n * Pass only the audit slices that produced real values; each present slice is merged\n * via the SAME field mappings the per-audit writers use. Omit a slice (or pass\n * undefined) to leave those columns untouched. Returns the merged FieldSet so the\n * caller can enumerate what was written.\n */\nexport async function updateAuditFields(\n base: AirtableBase,\n recordId: string,\n audits: {\n scores?: LighthouseScoreWriteback;\n a11y?: A11yCounts;\n deps?: DepsCounts;\n security?: SecurityCounts;\n securityAdvisories?: SecurityAdvisory[];\n domain?: DomainResult;\n browser?: BrowserAuditFields;\n netlifyDeploy?: NetlifyDeployResult;\n },\n): Promise<FieldSet> {\n const fields: FieldSet = {};\n if (audits.scores) Object.assign(fields, scoreFields(audits.scores));\n if (audits.a11y) Object.assign(fields, a11yFields(audits.a11y));\n if (audits.deps) Object.assign(fields, depsFields(audits.deps));\n if (audits.security) Object.assign(fields, securityFields(audits.security));\n // Separate slice (not folded into `security`) so the advisory list and the counts can be\n // written independently, but in practice the security audit supplies both together.\n if (audits.securityAdvisories)\n Object.assign(fields, securityAdvisoryFields(audits.securityAdvisories));\n if (audits.domain) Object.assign(fields, domainFields(audits.domain));\n if (audits.browser) Object.assign(fields, browserFields(audits.browser));\n if (audits.netlifyDeploy) Object.assign(fields, netlifyDeployFields(audits.netlifyDeploy));\n await base(WEBSITES_TABLE).update([{ id: recordId, fields }]);\n return fields;\n}\n\n/** Persist the GitHub-signals sweep onto a Websites row (slice 2a). A null\n * `lastCommitAt` is OMITTED so a not-determined-this-run value never clobbers a\n * previously-good timestamp (mirrors updateDepsCounts' outdated handling). */\nexport async function updateGitHubSignals(\n base: AirtableBase,\n recordId: string,\n signals: {\n renovateFailingCis: number;\n ciState: string;\n lastCommitAt: string | null;\n sweptAt: string;\n },\n): Promise<void> {\n const fields: FieldSet = {\n \"Renovate Failing CIs\": signals.renovateFailingCis,\n \"Default Branch CI\": signals.ciState,\n \"GitHub Signals At\": signals.sweptAt,\n };\n if (signals.lastCommitAt !== null) {\n fields[\"Last Commit At\"] = signals.lastCommitAt;\n }\n await base(WEBSITES_TABLE).update([{ id: recordId, fields }]);\n}\n\n/** Mark a site launched: flip Status → maintenance + stamp Launched at (M6b).\n * The first code that writes Status. Called after a Launch report sends. */\nexport async function updateLaunched(\n base: AirtableBase,\n recordId: string,\n at: string,\n): Promise<void> {\n const fields: FieldSet = { Status: \"maintenance\", \"Launched at\": at };\n await base(WEBSITES_TABLE).update([{ id: recordId, fields }]);\n}\n"],"mappings":";AAIO,IAAM,iBAAiB;AA2IvB,SAAS,SAAS,MAAsB;AAC7C,SAAO,KACJ,YAAY,EACZ,QAAQ,eAAe,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G1E,MAAI,OAAO;AACT,WAAO,OAAO,QAAQ,uBAAuB,OAAO,kBAAkB,CAAC;AACzE,MAAI,OAAO,OAAQ,QAAO,OAAO,QAAQ,aAAa,OAAO,MAAM,CAAC;AACpE,MAAI,OAAO,QAAS,QAAO,OAAO,QAAQ,cAAc,OAAO,OAAO,CAAC;AACvE,MAAI,OAAO,cAAe,QAAO,OAAO,QAAQ,oBAAoB,OAAO,aAAa,CAAC;AACzF,QAAM,KAAK,cAAc,EAAE,OAAO,CAAC,EAAE,IAAI,UAAU,OAAO,CAAC,CAAC;AAC5D,SAAO;AACT;AAKA,eAAsB,oBACpB,MACA,UACA,SAMe;AACf,QAAM,SAAmB;AAAA,IACvB,wBAAwB,QAAQ;AAAA,IAChC,qBAAqB,QAAQ;AAAA,IAC7B,qBAAqB,QAAQ;AAAA,EAC/B;AACA,MAAI,QAAQ,iBAAiB,MAAM;AACjC,WAAO,gBAAgB,IAAI,QAAQ;AAAA,EACrC;AACA,QAAM,KAAK,cAAc,EAAE,OAAO,CAAC,EAAE,IAAI,UAAU,OAAO,CAAC,CAAC;AAC9D;AAIA,eAAsB,eACpB,MACA,UACA,IACe;AACf,QAAM,SAAmB,EAAE,QAAQ,eAAe,eAAe,GAAG;AACpE,QAAM,KAAK,cAAc,EAAE,OAAO,CAAC,EAAE,IAAI,UAAU,OAAO,CAAC,CAAC;AAC9D;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  siteSlug
3
- } from "./chunk-BLD6AYJO.js";
3
+ } from "./chunk-7RGQ4KLE.js";
4
4
 
5
5
  // src/audits/lighthouse-airtable.ts
6
6
  import { readFile } from "fs/promises";
@@ -48,4 +48,4 @@ export {
48
48
  lighthouseScoresFromResult,
49
49
  resolveSlugFromCwd
50
50
  };
51
- //# sourceMappingURL=chunk-YYUY2OVP.js.map
51
+ //# sourceMappingURL=chunk-CSTLFSGM.js.map
@@ -30,7 +30,7 @@ async function resolveSites(input) {
30
30
  }
31
31
  if (input.fleet === "airtable") {
32
32
  const { openBase, readAirtableConfig } = await import("./client-EPVO3FEH.js");
33
- const { fromAirtableBase } = await import("./airtable-HHAWHBNM.js");
33
+ const { fromAirtableBase } = await import("./airtable-GGZJUGQB.js");
34
34
  const base = openBase(readAirtableConfig());
35
35
  const provider = fromAirtableBase(base, input.workdir ? { workdir: input.workdir } : {});
36
36
  return provider();
@@ -61,4 +61,4 @@ async function resolveSites(input) {
61
61
  export {
62
62
  resolveSites
63
63
  };
64
- //# sourceMappingURL=chunk-SAOCVNX7.js.map
64
+ //# sourceMappingURL=chunk-FH7WQHD7.js.map
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-XKOZUVK2.js";
16
16
  import {
17
17
  runAudits
18
- } from "./chunk-SS7BKOIX.js";
18
+ } from "./chunk-TC7Z5LG7.js";
19
19
  import {
20
20
  siteLabel
21
21
  } from "./chunk-XXTZBPUY.js";
@@ -135,4 +135,4 @@ export {
135
135
  DEFAULT_INIT_STEPS,
136
136
  init
137
137
  };
138
- //# sourceMappingURL=chunk-KTPPKO2C.js.map
138
+ //# sourceMappingURL=chunk-FX3QBSUF.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  openDb,
3
3
  readDbConfig
4
- } from "./chunk-6ZKM7OIJ.js";
4
+ } from "./chunk-PTPTVVY7.js";
5
5
 
6
6
  // src/db/fleet-events.ts
7
7
  async function recordFleetEvent(db, e) {
@@ -42,4 +42,4 @@ async function recordFleetEventsBestEffort(events, now, open = () => openDb(read
42
42
  export {
43
43
  recordFleetEventsBestEffort
44
44
  };
45
- //# sourceMappingURL=chunk-L5F664ZA.js.map
45
+ //# sourceMappingURL=chunk-G2YRXV26.js.map
@@ -0,0 +1,12 @@
1
+ // src/github/config.ts
2
+ function readGitHubConfig() {
3
+ const token = process.env.GITHUB_TOKEN?.trim();
4
+ if (!token) return null;
5
+ const renovateToken = process.env.RENOVATE_TOKEN?.trim() || token;
6
+ return { token, renovateToken };
7
+ }
8
+
9
+ export {
10
+ readGitHubConfig
11
+ };
12
+ //# sourceMappingURL=chunk-GASBX52O.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/github/config.ts"],"sourcesContent":["export type GitHubConfig = {\n /** Broad PAT used by the tool's own `gh` calls (PRs, branch protection, secrets). */\n token: string;\n /** Narrow PAT stored per-repo as the RENOVATE_TOKEN secret. Falls back to `token`. */\n renovateToken: string;\n};\n\n/**\n * Read GitHub config from the environment (credentials.env is loaded into process.env by the CLI).\n * Returns null when GITHUB_TOKEN is unset — the signal that git/GitHub features aren't configured.\n * RENOVATE_TOKEN falls back to GITHUB_TOKEN when unset (a narrower token is recommended but optional).\n */\nexport function readGitHubConfig(): GitHubConfig | null {\n const token = process.env.GITHUB_TOKEN?.trim();\n if (!token) return null;\n const renovateToken = process.env.RENOVATE_TOKEN?.trim() || token;\n return { token, renovateToken };\n}\n"],"mappings":";AAYO,SAAS,mBAAwC;AACtD,QAAM,QAAQ,QAAQ,IAAI,cAAc,KAAK;AAC7C,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,gBAAgB,QAAQ,IAAI,gBAAgB,KAAK,KAAK;AAC5D,SAAO,EAAE,OAAO,cAAc;AAChC;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  hasRealScores,
3
3
  lighthouseScoresFromResult
4
- } from "./chunk-YYUY2OVP.js";
4
+ } from "./chunk-CSTLFSGM.js";
5
5
  import {
6
6
  detectAuditEvents
7
7
  } from "./chunk-5L3FPQIJ.js";
@@ -9,7 +9,7 @@ import {
9
9
  normalizeSecurityAdvisory,
10
10
  siteSlug,
11
11
  updateAuditFields
12
- } from "./chunk-BLD6AYJO.js";
12
+ } from "./chunk-7RGQ4KLE.js";
13
13
 
14
14
  // src/audits/a11y-airtable.ts
15
15
  function hasA11yCounts(result) {
@@ -236,4 +236,4 @@ export {
236
236
  formatFleetWriteSummary,
237
237
  writeFleetAuditsToAirtable
238
238
  };
239
- //# sourceMappingURL=chunk-4REUHZAW.js.map
239
+ //# sourceMappingURL=chunk-LM42CATB.js.map
@@ -17,7 +17,7 @@ import {
17
17
  import {
18
18
  siteSlug,
19
19
  updateAnalyticsHealth
20
- } from "./chunk-BLD6AYJO.js";
20
+ } from "./chunk-7RGQ4KLE.js";
21
21
  import {
22
22
  defaultCredentialsPath
23
23
  } from "./chunk-6VAL7XJT.js";
@@ -441,4 +441,4 @@ export {
441
441
  fetchGaUsers,
442
442
  fetchSearch
443
443
  };
444
- //# sourceMappingURL=chunk-NPJFHBAX.js.map
444
+ //# sourceMappingURL=chunk-M5LX2VSR.js.map
@@ -5,7 +5,7 @@ import {
5
5
  ACTIVE_STATUSES,
6
6
  listWebsites,
7
7
  siteSlug
8
- } from "./chunk-BLD6AYJO.js";
8
+ } from "./chunk-7RGQ4KLE.js";
9
9
 
10
10
  // src/inventory/airtable.ts
11
11
  function fromAirtableBase(base, opts = {}) {
@@ -47,4 +47,4 @@ function fromAirtableBase(base, opts = {}) {
47
47
  export {
48
48
  fromAirtableBase
49
49
  };
50
- //# sourceMappingURL=chunk-ZEX2T6JH.js.map
50
+ //# sourceMappingURL=chunk-MQM5YP4J.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  fetchGaUsers,
3
3
  fetchSearch
4
- } from "./chunk-NPJFHBAX.js";
4
+ } from "./chunk-M5LX2VSR.js";
5
5
  import {
6
6
  announcementSiteExtras,
7
7
  resolveCopy
8
8
  } from "./chunk-U3MF6RCS.js";
9
9
  import {
10
10
  siteSlug
11
- } from "./chunk-BLD6AYJO.js";
11
+ } from "./chunk-7RGQ4KLE.js";
12
12
 
13
13
  // src/reports/report-data.ts
14
14
  var PREVIEW_WINDOW_DAYS = 30;
@@ -60,4 +60,4 @@ export {
60
60
  scoresFromRow,
61
61
  buildReportDataForSite
62
62
  };
63
- //# sourceMappingURL=chunk-P7VJM46I.js.map
63
+ //# sourceMappingURL=chunk-OYN6H4CX.js.map
@@ -6,9 +6,6 @@ import {
6
6
  } from "./chunk-6VAL7XJT.js";
7
7
 
8
8
  // src/db/client.ts
9
- import { createClient } from "@libsql/client";
10
- import { Kysely } from "kysely";
11
- import { LibsqlDialect } from "@libsql/kysely-libsql";
12
9
  function missing(name) {
13
10
  return Object.assign(
14
11
  new Error(
@@ -36,6 +33,11 @@ function ensureMigrated(url, client) {
36
33
  return p;
37
34
  }
38
35
  async function openDb(cfg) {
36
+ const [{ createClient }, { Kysely }, { LibsqlDialect }] = await Promise.all([
37
+ import("@libsql/client"),
38
+ import("kysely"),
39
+ import("@libsql/kysely-libsql")
40
+ ]);
39
41
  const clientConfig = cfg.authToken ? { url: cfg.url, authToken: cfg.authToken } : { url: cfg.url };
40
42
  const client = createClient(clientConfig);
41
43
  await ensureMigrated(cfg.url, client);
@@ -46,4 +48,4 @@ export {
46
48
  readDbConfig,
47
49
  openDb
48
50
  };
49
- //# sourceMappingURL=chunk-6ZKM7OIJ.js.map
51
+ //# sourceMappingURL=chunk-PTPTVVY7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/db/client.ts"],"sourcesContent":["import type { Client, Config as LibsqlConfig } from \"@libsql/client\";\nimport type { Kysely as KyselyType } from \"kysely\";\nimport { defaultCredentialsPath } from \"../util/credentials.js\";\nimport type { Database } from \"./schema.js\";\nimport { runMigrations } from \"./migrate.js\";\n\nexport type DbConfig = { url: string; authToken?: string };\nexport type Db = KyselyType<Database>;\n\nfunction missing(name: string): Error {\n return Object.assign(\n new Error(\n `${name} not set. Export it in your shell or put it in ${defaultCredentialsPath()} as ${name}=...`,\n ),\n { exitCode: 2 },\n );\n}\n\n/** Read TURSO_DATABASE_URL (+ optional TURSO_AUTH_TOKEN) from the environment,\n * mirroring readAirtableConfig. The token is optional so a local `file:`/`:memory:`\n * url works with no token. */\nexport function readDbConfig(): DbConfig {\n const url = process.env.TURSO_DATABASE_URL;\n if (!url) throw missing(\"TURSO_DATABASE_URL\");\n const authToken = process.env.TURSO_AUTH_TOKEN;\n return authToken ? { url, authToken } : { url };\n}\n\n// Migrations are idempotent but cost two Turso round-trips (CREATE TABLE IF NOT EXISTS +\n// SELECT applied ids). Running them on EVERY openDb — i.e. every warm Netlify invocation —\n// is pure latency on the form-ingest hot path and every dashboard GET. Cache the run per\n// database URL so a warm process migrates once. \":memory:\" is deliberately EXCLUDED: each\n// in-memory client is a brand-new, separate database, so a cached \"already migrated\" would\n// hand the next openDb an empty db (file:/libsql:/https: all persist → safe to cache).\nconst migrationsByUrl = new Map<string, Promise<void>>();\n\nfunction ensureMigrated(url: string, client: Client): Promise<void> {\n if (url === \":memory:\") return runMigrations(client).then(() => undefined);\n const cached = migrationsByUrl.get(url);\n if (cached) return cached;\n const p = runMigrations(client)\n .then(() => undefined)\n .catch((err: unknown) => {\n // Don't poison the process: a transient first-call failure (a Turso blip) must not\n // leave a rejected promise cached for every future openDb. Evict so the next retries.\n migrationsByUrl.delete(url);\n throw err;\n });\n migrationsByUrl.set(url, p);\n return p;\n}\n\n/** Open a libSQL-backed Kysely. Builds ONE client, ensures migrations are applied on it\n * (once per process per persistent url — see ensureMigrated), then wraps that exact client\n * in the Kysely dialect — the shared client is required so an in-memory db (per-client) is\n * the same database the queries see. The same code serves Turso (libsql:// url + token), a\n * self-hosted sqld, a local file: url, and :memory: for tests — host portability is a\n * connection-string swap. */\nexport async function openDb(cfg: DbConfig): Promise<Db> {\n // Lazy-load the libSQL/kysely stack: these live in devDependencies (consuming fleet\n // sites do not install them), and tsup externalizes them, so a TOP-LEVEL import here\n // would make every entry that transitively reaches this module — notably the `audit`\n // CLI entry via fleet-events-writer — eager-require packages the consumer lacks\n // (crashing `reddoor-maint audit` on fleet sites). Importing them only inside openDb\n // keeps the module graph dependency-free until an actual DB connection is opened.\n const [{ createClient }, { Kysely }, { LibsqlDialect }] = await Promise.all([\n import(\"@libsql/client\"),\n import(\"kysely\"),\n import(\"@libsql/kysely-libsql\"),\n ]);\n const clientConfig: LibsqlConfig = cfg.authToken\n ? { url: cfg.url, authToken: cfg.authToken }\n : { url: cfg.url };\n const client: Client = createClient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K,MAAM;AACpC,SAAO,IAAI,OAAiB,EAAE,SAAS,IAAI,cAAc,EAAE,OAAO,CAAC,EAAE,CAAC;AACxE;","names":[]}
@@ -19,12 +19,12 @@ import {
19
19
  } from "./chunk-OCS7SZUZ.js";
20
20
  import {
21
21
  recordFleetEventsBestEffort
22
- } from "./chunk-L5F664ZA.js";
22
+ } from "./chunk-G2YRXV26.js";
23
23
  import {
24
24
  listWebsites,
25
25
  siteSlug,
26
26
  updateLaunched
27
- } from "./chunk-BLD6AYJO.js";
27
+ } from "./chunk-7RGQ4KLE.js";
28
28
  import {
29
29
  openBase,
30
30
  readAirtableConfig
@@ -303,4 +303,4 @@ export {
303
303
  parseAddresses,
304
304
  isProbablyEmail
305
305
  };
306
- //# sourceMappingURL=chunk-J37CZORZ.js.map
306
+ //# sourceMappingURL=chunk-QSL3EJGI.js.map