@reddoorla/maintenance 0.88.3 → 0.89.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 (108) hide show
  1. package/dist/{announce-GKD5YJNB.js → announce-OJFAS5JT.js} +6 -6
  2. package/dist/{chunk-7UAYMAKR.js → chunk-3VQWSE3F.js} +4 -4
  3. package/dist/{chunk-XKDCR4UE.js → chunk-5PWB3JHJ.js} +2 -3
  4. package/dist/chunk-5PWB3JHJ.js.map +1 -0
  5. package/dist/{chunk-XSOINOPY.js → chunk-62NYED6E.js} +3 -3
  6. package/dist/{chunk-B23FFWU4.js → chunk-AEXJDCJN.js} +96 -19
  7. package/dist/{chunk-B23FFWU4.js.map → chunk-AEXJDCJN.js.map} +1 -1
  8. package/dist/{chunk-7FFUBF4I.js → chunk-AX22DH6S.js} +2 -2
  9. package/dist/{chunk-CEW5PEHZ.js → chunk-DXKF552B.js} +260 -5
  10. package/dist/chunk-DXKF552B.js.map +1 -0
  11. package/dist/{chunk-6I6L3CMX.js → chunk-KGUKL3CV.js} +2 -2
  12. package/dist/{chunk-ULHPALI5.js → chunk-NDCOOI3V.js} +2 -2
  13. package/dist/{chunk-GQDDWYU2.js → chunk-QBAAZY7W.js} +1 -1
  14. package/dist/{chunk-GQDDWYU2.js.map → chunk-QBAAZY7W.js.map} +1 -1
  15. package/dist/{chunk-6UCVWYDA.js → chunk-QLIUDTY6.js} +4 -4
  16. package/dist/{chunk-XP5WM2LV.js → chunk-SKI23ZZH.js} +4 -4
  17. package/dist/chunk-SVAAONYB.js +21 -0
  18. package/dist/chunk-SVAAONYB.js.map +1 -0
  19. package/dist/{chunk-DGZWFI2G.js → chunk-VBEKL445.js} +17 -8
  20. package/dist/chunk-VBEKL445.js.map +1 -0
  21. package/dist/{chunk-WPL5GERE.js → chunk-ZOCJBJQV.js} +2 -2
  22. package/dist/{chunk-J3WEZGIN.js → chunk-ZRI5VRPG.js} +4 -4
  23. package/dist/cli/bin.js +22 -16
  24. package/dist/cli/bin.js.map +1 -1
  25. package/dist/cli/commands/audit.js +5 -5
  26. package/dist/{db-DXUUAMXT.js → db-DAJX7NNW.js} +50 -9
  27. package/dist/db-DAJX7NNW.js.map +1 -0
  28. package/dist/{digest-NBLECFM7.js → digest-T6TAZNLF.js} +11 -11
  29. package/dist/{digest-collectors-NM7WUWQP.js → digest-collectors-NI2M3UTC.js} +6 -6
  30. package/dist/{dump-EPL7AZFR.js → dump-QK7LNOGC.js} +14 -1
  31. package/dist/{dump-EPL7AZFR.js.map → dump-QK7LNOGC.js.map} +1 -1
  32. package/dist/{email-FMMEUPX6.js → email-LJQT5J7F.js} +6 -7
  33. package/dist/{email-FMMEUPX6.js.map → email-LJQT5J7F.js.map} +1 -1
  34. package/dist/{ensure-site-FU6527OU.js → ensure-site-NSNY2QHN.js} +2 -2
  35. package/dist/{fleet-state-R5LU7IC3.js → fleet-state-3LQUQHYD.js} +2 -2
  36. package/dist/{forms-notify-target-SGDGXXK5.js → forms-notify-target-LYSKME5L.js} +2 -2
  37. package/dist/freeze-A6MUCZU4.js +9 -0
  38. package/dist/{github-signals-DB25UWY4.js → github-signals-4YML6NY5.js} +4 -4
  39. package/dist/{health-mirror-GCDN7BJL.js → health-mirror-7LKC7Q5Z.js} +5 -5
  40. package/dist/index.d.ts +16 -4
  41. package/dist/index.js +22 -22
  42. package/dist/{init-32AWPS7A.js → init-NHKADHB6.js} +6 -6
  43. package/dist/{launch-52WUE4TZ.js → launch-VQJ4Z35C.js} +6 -6
  44. package/dist/{orchestrate-JNKCWU5K.js → orchestrate-6HROYTM6.js} +4 -4
  45. package/dist/{parity-NBYZUBFU.js → parity-623WNFZG.js} +3 -3
  46. package/dist/{pipeline-YIBIQ7XK.js → pipeline-MQJD4CKN.js} +6 -2
  47. package/dist/{preflight-IMTYDDD4.js → preflight-LIN5NCYU.js} +5 -5
  48. package/dist/{prismic-ci-MY2U6NN7.js → prismic-ci-PZ5LCPWT.js} +4 -4
  49. package/dist/{prismic-models-IJWZW2EO.js → prismic-models-6OYYZUR5.js} +3 -3
  50. package/dist/prospect/types.d.ts +8 -0
  51. package/dist/{prospect-audit-WJQI7V5V.js → prospect-audit-DBBXL7EG.js} +8 -6
  52. package/dist/prospect-audit-DBBXL7EG.js.map +1 -0
  53. package/dist/recipes/sync-configs.js +2 -2
  54. package/dist/{render-CVKE7IWC.js → render-P3SBUFVB.js} +3 -3
  55. package/dist/{render-from-row-DOYJDO2L.js → render-from-row-P5CWM3MQ.js} +3 -3
  56. package/dist/{report-2LM2SX67.js → report-2N4PXO3L.js} +30 -14
  57. package/dist/report-2N4PXO3L.js.map +1 -0
  58. package/dist/{report-mirror-AAK3MXHY.js → report-mirror-3ENU6OOK.js} +5 -5
  59. package/dist/{selftest-DIZ5JD2X.js → selftest-CUX2FIQD.js} +6 -6
  60. package/dist/{site-mirror-Q763PLGG.js → site-mirror-RQTEAID5.js} +5 -5
  61. package/dist/{sync-GBFV45WX.js → sync-ESP5ZQUU.js} +3 -3
  62. package/dist/{sync-configs-34JIA6KZ.js → sync-configs-LVBITPLU.js} +3 -3
  63. package/dist/usage-UHKU76VK.js +147 -0
  64. package/dist/usage-UHKU76VK.js.map +1 -0
  65. package/dist/{write-audits-to-airtable-OPBJXGS4.js → write-audits-to-airtable-K352LZQY.js} +3 -3
  66. package/dist/write-audits-to-airtable-K352LZQY.js.map +1 -0
  67. package/package.json +1 -1
  68. package/dist/chunk-CEW5PEHZ.js.map +0 -1
  69. package/dist/chunk-DGZWFI2G.js.map +0 -1
  70. package/dist/chunk-RUPPWAD6.js +0 -7
  71. package/dist/chunk-RUPPWAD6.js.map +0 -1
  72. package/dist/chunk-XKDCR4UE.js.map +0 -1
  73. package/dist/db-DXUUAMXT.js.map +0 -1
  74. package/dist/prospect-audit-WJQI7V5V.js.map +0 -1
  75. package/dist/report-2LM2SX67.js.map +0 -1
  76. /package/dist/{announce-GKD5YJNB.js.map → announce-OJFAS5JT.js.map} +0 -0
  77. /package/dist/{chunk-7UAYMAKR.js.map → chunk-3VQWSE3F.js.map} +0 -0
  78. /package/dist/{chunk-XSOINOPY.js.map → chunk-62NYED6E.js.map} +0 -0
  79. /package/dist/{chunk-7FFUBF4I.js.map → chunk-AX22DH6S.js.map} +0 -0
  80. /package/dist/{chunk-6I6L3CMX.js.map → chunk-KGUKL3CV.js.map} +0 -0
  81. /package/dist/{chunk-ULHPALI5.js.map → chunk-NDCOOI3V.js.map} +0 -0
  82. /package/dist/{chunk-6UCVWYDA.js.map → chunk-QLIUDTY6.js.map} +0 -0
  83. /package/dist/{chunk-XP5WM2LV.js.map → chunk-SKI23ZZH.js.map} +0 -0
  84. /package/dist/{chunk-WPL5GERE.js.map → chunk-ZOCJBJQV.js.map} +0 -0
  85. /package/dist/{chunk-J3WEZGIN.js.map → chunk-ZRI5VRPG.js.map} +0 -0
  86. /package/dist/{digest-NBLECFM7.js.map → digest-T6TAZNLF.js.map} +0 -0
  87. /package/dist/{digest-collectors-NM7WUWQP.js.map → digest-collectors-NI2M3UTC.js.map} +0 -0
  88. /package/dist/{ensure-site-FU6527OU.js.map → ensure-site-NSNY2QHN.js.map} +0 -0
  89. /package/dist/{fleet-state-R5LU7IC3.js.map → fleet-state-3LQUQHYD.js.map} +0 -0
  90. /package/dist/{forms-notify-target-SGDGXXK5.js.map → forms-notify-target-LYSKME5L.js.map} +0 -0
  91. /package/dist/{orchestrate-JNKCWU5K.js.map → freeze-A6MUCZU4.js.map} +0 -0
  92. /package/dist/{github-signals-DB25UWY4.js.map → github-signals-4YML6NY5.js.map} +0 -0
  93. /package/dist/{health-mirror-GCDN7BJL.js.map → health-mirror-7LKC7Q5Z.js.map} +0 -0
  94. /package/dist/{init-32AWPS7A.js.map → init-NHKADHB6.js.map} +0 -0
  95. /package/dist/{launch-52WUE4TZ.js.map → launch-VQJ4Z35C.js.map} +0 -0
  96. /package/dist/{parity-NBYZUBFU.js.map → orchestrate-6HROYTM6.js.map} +0 -0
  97. /package/dist/{pipeline-YIBIQ7XK.js.map → parity-623WNFZG.js.map} +0 -0
  98. /package/dist/{render-CVKE7IWC.js.map → pipeline-MQJD4CKN.js.map} +0 -0
  99. /package/dist/{preflight-IMTYDDD4.js.map → preflight-LIN5NCYU.js.map} +0 -0
  100. /package/dist/{prismic-ci-MY2U6NN7.js.map → prismic-ci-PZ5LCPWT.js.map} +0 -0
  101. /package/dist/{prismic-models-IJWZW2EO.js.map → prismic-models-6OYYZUR5.js.map} +0 -0
  102. /package/dist/{render-from-row-DOYJDO2L.js.map → render-P3SBUFVB.js.map} +0 -0
  103. /package/dist/{write-audits-to-airtable-OPBJXGS4.js.map → render-from-row-P5CWM3MQ.js.map} +0 -0
  104. /package/dist/{report-mirror-AAK3MXHY.js.map → report-mirror-3ENU6OOK.js.map} +0 -0
  105. /package/dist/{selftest-DIZ5JD2X.js.map → selftest-CUX2FIQD.js.map} +0 -0
  106. /package/dist/{site-mirror-Q763PLGG.js.map → site-mirror-RQTEAID5.js.map} +0 -0
  107. /package/dist/{sync-GBFV45WX.js.map → sync-ESP5ZQUU.js.map} +0 -0
  108. /package/dist/{sync-configs-34JIA6KZ.js.map → sync-configs-LVBITPLU.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/db/dump.ts"],"sourcesContent":["/**\n * Phase 1.5 of #539: a platform-auth-free SQL dump of the whole database.\n *\n * `turso db dump` needs a PLATFORM login (browser OAuth) — a nightly workflow\n * has only the DATABASE-level url+token it already holds for every other job.\n * So the dump speaks plain SQL through the same client: schema straight from\n * `sqlite_master`, then every row as an INSERT. The output loads into stock\n * `sqlite3` (libSQL IS SQLite), which is exactly how the rehearsed restore\n * proves it — and how a real disaster would replay it into a fresh database.\n *\n * Determinism: tables and rows are emitted in stable order (name, then rowid)\n * so two dumps of an unchanged database are byte-identical — a diffable backup.\n */\n\n/** Minimal execute surface: the @libsql/client `execute` we need. Injectable so\n * tests run against :memory: without the real network client. */\nexport type SqlExecutor = {\n execute: (sql: string) => Promise<{\n columns: string[];\n rows: Array<Record<string, unknown>>;\n }>;\n};\n\nconst IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nfunction quoteIdent(name: string): string {\n return IDENT.test(name) ? name : `\"${name.replaceAll('\"', '\"\"')}\"`;\n}\n\nexport function sqlLiteral(v: unknown): string {\n if (v === null || v === undefined) return \"NULL\";\n if (typeof v === \"number\") return Number.isFinite(v) ? String(v) : \"NULL\";\n if (typeof v === \"bigint\") return v.toString();\n if (v instanceof Uint8Array || v instanceof ArrayBuffer) {\n const bytes = v instanceof ArrayBuffer ? new Uint8Array(v) : v;\n let hex = \"\";\n for (const b of bytes) hex += b.toString(16).padStart(2, \"0\");\n return `X'${hex}'`;\n }\n const str = String(v);\n // A NUL cannot ride a single-quoted SQL literal. This used to strip them,\n // justified as \"they cannot legitimately appear in this schema's TEXT\n // columns\" — but `submissions` free text is attacker-supplied and SQLite\n // stores NUL inside TEXT quite happily, so the backup would have silently\n // differed from the origin with no signal. Emit the whole value as a hex blob\n // cast back to text instead: lossless, and it round-trips through the\n // rehearsal like any other literal.\n if (str.includes(\"\\u0000\")) {\n const bytes = new TextEncoder().encode(str);\n let hex = \"\";\n for (const b of bytes) hex += b.toString(16).padStart(2, \"0\");\n return `CAST(X'${hex}' AS TEXT)`;\n }\n // Strings: standard SQL escaping — double the single quotes.\n return `'${str.replaceAll(\"'\", \"''\")}'`;\n}\n\n/**\n * Dump schema + data as executable SQL. Skips SQLite's internal tables\n * (`sqlite_*`); includes indexes. Wrapped in a transaction so a partial load\n * fails atomically instead of leaving a half-restored scratch that could be\n * mistaken for a good one.\n */\nexport async function dumpDatabase(db: SqlExecutor, generatedAt: string): Promise<string> {\n // Read the ORIGIN's own numbers BEFORE serialising anything. This is the\n // whole point: it is the only measurement that does not come from the dump,\n // so it is the only one that can notice the dump is short.\n const manifest: DumpManifest = {\n tables: await tableCounts(db),\n blobBytes: await headerImageBytes(db),\n generatedAt,\n };\n const out: string[] = [\n // First line, so a truncated dump still carries what it CLAIMED to hold.\n `${MANIFEST_PREFIX}${JSON.stringify(manifest)}`,\n \"PRAGMA foreign_keys=OFF;\",\n \"BEGIN TRANSACTION;\",\n ];\n\n const schema = await db.execute(\n \"SELECT name, type, sql FROM sqlite_master \" +\n \"WHERE sql IS NOT NULL AND name NOT LIKE 'sqlite_%' \" +\n \"ORDER BY CASE type WHEN 'table' THEN 0 ELSE 1 END, name\",\n );\n\n const tables: string[] = [];\n for (const row of schema.rows) {\n out.push(`${String(row.sql).trim().replace(/;?$/, \"\")};`);\n if (row.type === \"table\") tables.push(String(row.name));\n }\n\n for (const table of tables) {\n const data = await db.execute(`SELECT * FROM ${quoteIdent(table)} ORDER BY rowid`);\n if (data.rows.length === 0) continue;\n const cols = data.columns.map(quoteIdent).join(\", \");\n for (const row of data.rows) {\n const values = data.columns.map((c) => sqlLiteral(row[c])).join(\", \");\n out.push(`INSERT INTO ${quoteIdent(table)} (${cols}) VALUES (${values});`);\n }\n }\n\n out.push(\"COMMIT;\");\n return out.join(\"\\n\") + \"\\n\";\n}\n\n/** Marker for the origin manifest line, first line of every dump. */\nexport const MANIFEST_PREFIX = \"-- REDDOOR_DUMP_MANIFEST \";\n\n/** What the ORIGIN database held at dump time.\n *\n * This exists because the restore rehearsal used to compare the dump against\n * ITSELF: expected counts were parsed out of the dump text, and actual counts\n * came from loading that same text. Both sides moved together, so a dump that\n * collected 5 of 44 sites verified clean. A manifest read from the LIVE\n * database before any rows are serialised is the only thing that can catch\n * under-dumping.\n *\n * `blobBytes` is the cheap content check. Row counts alone pass a dump in\n * which every `header_image` came back NULL — and those bytes exist in no\n * other store once Airtable is frozen. */\nexport type DumpManifest = {\n tables: Record<string, number>;\n blobBytes: number;\n generatedAt: string;\n};\n\n/** Total stored header-image bytes, the one content signal cheap enough to\n * check on every nightly run. */\nexport async function headerImageBytes(db: SqlExecutor): Promise<number> {\n const r = await db.execute(\n \"SELECT COALESCE(SUM(LENGTH(header_image)), 0) AS n FROM sites WHERE header_image IS NOT NULL\",\n );\n return Number(r.rows[0]?.n ?? 0);\n}\n\n/** Parse the manifest line from a dump, or null when the dump predates it. */\nexport function parseDumpManifest(sql: string): DumpManifest | null {\n const line = sql.split(\"\\n\").find((l) => l.startsWith(MANIFEST_PREFIX));\n if (!line) return null;\n try {\n return JSON.parse(line.slice(MANIFEST_PREFIX.length)) as DumpManifest;\n } catch {\n return null;\n }\n}\n\n/** Per-table row counts — the cheap integrity check the restore rehearsal\n * compares across original vs restored. */\nexport async function tableCounts(db: SqlExecutor): Promise<Record<string, number>> {\n const schema = await db.execute(\n \"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name\",\n );\n const counts: Record<string, number> = {};\n for (const row of schema.rows) {\n const name = String(row.name);\n const r = await db.execute(`SELECT COUNT(*) AS c FROM ${quoteIdent(name)}`);\n counts[name] = Number(r.rows[0]?.c ?? 0);\n }\n return counts;\n}\n"],"mappings":";AAuBA,IAAM,QAAQ;AAEd,SAAS,WAAW,MAAsB;AACxC,SAAO,MAAM,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,WAAW,KAAK,IAAI,CAAC;AACjE;AAEO,SAAS,WAAW,GAAoB;AAC7C,MAAI,MAAM,QAAQ,MAAM,OAAW,QAAO;AAC1C,MAAI,OAAO,MAAM,SAAU,QAAO,OAAO,SAAS,CAAC,IAAI,OAAO,CAAC,IAAI;AACnE,MAAI,OAAO,MAAM,SAAU,QAAO,EAAE,SAAS;AAC7C,MAAI,aAAa,cAAc,aAAa,aAAa;AACvD,UAAM,QAAQ,aAAa,cAAc,IAAI,WAAW,CAAC,IAAI;AAC7D,QAAI,MAAM;AACV,eAAW,KAAK,MAAO,QAAO,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAC5D,WAAO,KAAK,GAAG;AAAA,EACjB;AACA,QAAM,MAAM,OAAO,CAAC;AAQpB,MAAI,IAAI,SAAS,IAAQ,GAAG;AAC1B,UAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,G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O,IAAM,kBAAkB;AAsB/B,eAAsB,iBAAiB,IAAkC;AACvE,QAAM,IAAI,MAAM,GAAG;AAAA,IACjB;AAAA,EACF;AACA,SAAO,OAAO,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;AACjC;AAGO,SAAS,kBAAkB,KAAkC;AAClE,QAAM,OAAO,IAAI,MAAM,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,eAAe,CAAC;AACtE,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI;AACF,WAAO,KAAK,MAAM,KAAK,MAAM,gBAAgB,MAAM,CAAC;AAAA,EACtD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIA,eAAsB,YAAY,IAAkD;AAClF,QAAM,SAAS,MAAM,GAAG;AAAA,IACtB;AAAA,EACF;AACA,QAAM,SAAiC,CAAC;AACxC,aAAW,OAAO,OAAO,MAAM;AAC7B,UAAM,OAAO,OAAO,IAAI,IAAI;AAC5B,UAAM,IAAI,MAAM,GAAG,QAAQ,6BAA6B,WAAW,IAAI,CAAC,EAAE;AAC1E,WAAO,IAAI,IAAI,OAAO,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;AAAA,EACzC;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/db/dump.ts"],"sourcesContent":["/**\n * Phase 1.5 of #539: a platform-auth-free SQL dump of the whole database.\n *\n * `turso db dump` needs a PLATFORM login (browser OAuth) — a nightly workflow\n * has only the DATABASE-level url+token it already holds for every other job.\n * So the dump speaks plain SQL through the same client: schema straight from\n * `sqlite_master`, then every row as an INSERT. The output loads into stock\n * `sqlite3` (libSQL IS SQLite), which is exactly how the rehearsed restore\n * proves it — and how a real disaster would replay it into a fresh database.\n *\n * Determinism: tables and rows are emitted in stable order (name, then rowid)\n * so two dumps of an unchanged database are byte-identical — a diffable backup.\n */\n\n/** Minimal execute surface: the @libsql/client `execute` we need. Injectable so\n * tests run against :memory: without the real network client. */\nexport type SqlExecutor = {\n execute: (sql: string) => Promise<{\n columns: string[];\n rows: Array<Record<string, unknown>>;\n }>;\n};\n\nconst IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nfunction quoteIdent(name: string): string {\n return IDENT.test(name) ? name : `\"${name.replaceAll('\"', '\"\"')}\"`;\n}\n\nexport function sqlLiteral(v: unknown): string {\n if (v === null || v === undefined) return \"NULL\";\n if (typeof v === \"number\") return Number.isFinite(v) ? String(v) : \"NULL\";\n if (typeof v === \"bigint\") return v.toString();\n if (v instanceof Uint8Array || v instanceof ArrayBuffer) {\n const bytes = v instanceof ArrayBuffer ? new Uint8Array(v) : v;\n let hex = \"\";\n for (const b of bytes) hex += b.toString(16).padStart(2, \"0\");\n return `X'${hex}'`;\n }\n const str = String(v);\n // A NUL cannot ride a single-quoted SQL literal. This used to strip them,\n // justified as \"they cannot legitimately appear in this schema's TEXT\n // columns\" — but `submissions` free text is attacker-supplied and SQLite\n // stores NUL inside TEXT quite happily, so the backup would have silently\n // differed from the origin with no signal. Emit the whole value as a hex blob\n // cast back to text instead: lossless, and it round-trips through the\n // rehearsal like any other literal.\n if (str.includes(\"\\u0000\")) {\n const bytes = new TextEncoder().encode(str);\n let hex = \"\";\n for (const b of bytes) hex += b.toString(16).padStart(2, \"0\");\n return `CAST(X'${hex}' AS TEXT)`;\n }\n // Strings: standard SQL escaping — double the single quotes.\n return `'${str.replaceAll(\"'\", \"''\")}'`;\n}\n\n/**\n * Dump schema + data as executable SQL. Skips SQLite's internal tables\n * (`sqlite_*`); includes indexes. Wrapped in a transaction so a partial load\n * fails atomically instead of leaving a half-restored scratch that could be\n * mistaken for a good one.\n */\nexport async function dumpDatabase(db: SqlExecutor, generatedAt: string): Promise<string> {\n // Read the ORIGIN's own numbers BEFORE serialising anything. This is the\n // whole point: it is the only measurement that does not come from the dump,\n // so it is the only one that can notice the dump is short.\n const manifest: DumpManifest = {\n tables: await tableCounts(db),\n blobBytes: await headerImageBytes(db),\n generatedAt,\n };\n const out: string[] = [\n // First line, so a truncated dump still carries what it CLAIMED to hold.\n `${MANIFEST_PREFIX}${JSON.stringify(manifest)}`,\n \"PRAGMA foreign_keys=OFF;\",\n \"BEGIN TRANSACTION;\",\n ];\n\n const schema = await db.execute(\n \"SELECT name, type, sql FROM sqlite_master \" +\n \"WHERE sql IS NOT NULL AND name NOT LIKE 'sqlite_%' \" +\n \"ORDER BY CASE type WHEN 'table' THEN 0 ELSE 1 END, name\",\n );\n\n const tables: string[] = [];\n for (const row of schema.rows) {\n out.push(`${String(row.sql).trim().replace(/;?$/, \"\")};`);\n if (row.type === \"table\") tables.push(String(row.name));\n }\n\n for (const table of tables) {\n const data = await db.execute(`SELECT * FROM ${quoteIdent(table)} ORDER BY rowid`);\n if (data.rows.length === 0) continue;\n const cols = data.columns.map(quoteIdent).join(\", \");\n for (const row of data.rows) {\n const values = data.columns.map((c) => sqlLiteral(row[c])).join(\", \");\n out.push(`INSERT INTO ${quoteIdent(table)} (${cols}) VALUES (${values});`);\n }\n }\n\n out.push(\"COMMIT;\");\n return out.join(\"\\n\") + \"\\n\";\n}\n\n/** Marker for the origin manifest line, first line of every dump. */\nexport const MANIFEST_PREFIX = \"-- REDDOOR_DUMP_MANIFEST \";\n\n/** What the ORIGIN database held at dump time.\n *\n * This exists because the restore rehearsal used to compare the dump against\n * ITSELF: expected counts were parsed out of the dump text, and actual counts\n * came from loading that same text. Both sides moved together, so a dump that\n * collected 5 of 44 sites verified clean. A manifest read from the LIVE\n * database before any rows are serialised is the only thing that can catch\n * under-dumping.\n *\n * `blobBytes` is the cheap content check. Row counts alone pass a dump in\n * which every `header_image` came back NULL — and those bytes exist in no\n * other store once Airtable is frozen. */\nexport type DumpManifest = {\n tables: Record<string, number>;\n blobBytes: number;\n generatedAt: string;\n};\n\n/** Total stored header-image bytes, the one content signal cheap enough to\n * check on every nightly run. */\nexport async function headerImageBytes(db: SqlExecutor): Promise<number> {\n const r = await db.execute(\n \"SELECT COALESCE(SUM(LENGTH(header_image)), 0) AS n FROM sites WHERE header_image IS NOT NULL\",\n );\n return Number(r.rows[0]?.n ?? 0);\n}\n\n/** Parse the manifest line from a dump, or null when the dump predates it. */\nexport function parseDumpManifest(sql: string): DumpManifest | null {\n const line = sql.split(\"\\n\").find((l) => l.startsWith(MANIFEST_PREFIX));\n if (!line) return null;\n try {\n return JSON.parse(line.slice(MANIFEST_PREFIX.length)) as DumpManifest;\n } catch {\n return null;\n }\n}\n\n/** Per-table row counts — the cheap integrity check the restore rehearsal\n * compares across original vs restored. */\nexport async function tableCounts(db: SqlExecutor): Promise<Record<string, number>> {\n const schema = await db.execute(\n \"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name\",\n );\n const counts: Record<string, number> = {};\n for (const row of schema.rows) {\n const name = String(row.name);\n const r = await db.execute(`SELECT COUNT(*) AS c FROM ${quoteIdent(name)}`);\n counts[name] = Number(r.rows[0]?.c ?? 0);\n }\n return counts;\n}\n\n/** Hosts that serve libSQL without authentication: `turso dev`, a local file,\n * and the in-process scratch engine the nightly rehearsal loads into. */\n// `[::1]` keeps its brackets: WHATWG URL reports an IPv6 hostname bracketed,\n// so the bare form alone would classify a local IPv6 target as hosted.\nconst LOCAL_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\", \"::1\"]);\n\n/** Does this restore target need an auth token?\n *\n * `db restore` used to build its client from a url alone, which works against\n * every target the tests and rehearsals had ever used — `:memory:` and a local\n * `turso dev` — and 401s against every target a real recovery would have.\n * Classifying the url lets the command refuse with a named reason before the\n * network instead of surfacing an opaque SERVER_ERROR.\n *\n * Fails CLOSED: a url we cannot parse is treated as needing a token, because\n * the alternative is silently skipping auth and getting the 401 anyway. */\nexport function requiresAuthToken(url: string): boolean {\n if (url === \":memory:\") return false;\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return true;\n }\n if (parsed.protocol === \"file:\") return false;\n return !LOCAL_HOSTS.has(parsed.hostname);\n}\n"],"mappings":";AAuBA,IAAM,QAAQ;AAEd,S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IAAI,MAAM,GAAG,QAAQ,6BAA6B,WAAW,IAAI,CAAC,EAAE;AAC1E,WAAO,IAAI,IAAI,OAAO,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;AAAA,EACzC;AACA,SAAO;AACT;AAMA,IAAM,cAAc,oBAAI,IAAI,CAAC,aAAa,aAAa,SAAS,KAAK,CAAC;AAY/D,SAAS,kBAAkB,KAAsB;AACtD,MAAI,QAAQ,WAAY,QAAO;AAC/B,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,GAAG;AAAA,EACtB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,OAAO,aAAa,QAAS,QAAO;AACxC,SAAO,CAAC,YAAY,IAAI,OAAO,QAAQ;AACzC;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  renderProspectReport
3
- } from "./chunk-XKDCR4UE.js";
4
- import "./chunk-CEW5PEHZ.js";
3
+ } from "./chunk-5PWB3JHJ.js";
4
+ import "./chunk-DXKF552B.js";
5
5
  import {
6
6
  escapeHtml,
7
7
  safeUrl
@@ -68,17 +68,16 @@ function notMeasuredLines(result) {
68
68
  lines.push({ label: "Answers", reason: "the model found no buyer questions to check" });
69
69
  }
70
70
  if (!result.probes.ok) {
71
- lines.push({ label: "AI Visibility", reason: result.probes.error });
71
+ lines.push({ label: "AI engine answers", reason: result.probes.error });
72
72
  } else if (result.scores.aiVisibility === null) {
73
- lines.push({ label: "AI Visibility", reason: "no category (buyer-question) query ran" });
73
+ lines.push({ label: "AI engine answers", reason: "no category (buyer-question) query ran" });
74
74
  }
75
75
  return lines;
76
76
  }
77
77
  var SCORE_FIELDS = [
78
78
  { key: "findability", label: "Findability" },
79
79
  { key: "readability", label: "Readability" },
80
- { key: "answers", label: "Answers" },
81
- { key: "aiVisibility", label: "AI Visibility" }
80
+ { key: "answers", label: "Answers" }
82
81
  ];
83
82
  function scoresTableHtml(scores) {
84
83
  const cells = SCORE_FIELDS.map(({ key, label }) => {
@@ -202,4 +201,4 @@ export {
202
201
  parseProspectAuditRecipients,
203
202
  sendAuditEmail
204
203
  };
205
- //# sourceMappingURL=email-FMMEUPX6.js.map
204
+ //# sourceMappingURL=email-LJQT5J7F.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/prospect/email.ts"],"sourcesContent":["import { escapeHtml, safeUrl } from \"../util/html.js\";\nimport { hostnameOf } from \"../util/url.js\";\nimport { renderProspectReport } from \"./render.js\";\nimport { defaultResendClient, type ResendClient } from \"../reports/send/resend.js\";\nimport type { AnalyzeResult, Fix, ProspectAuditResult, StageResult } from \"./types.js\";\n\n/**\n * Mirrors `reports/send/orchestrate.ts`'s `FROM_ADDRESS` (its line 18) — copied,\n * not imported, exactly like `digest.ts` and `recipes/selftest-email.ts` already\n * do. orchestrate.ts's own `FROM_ADDRESS` isn't exported, and importing it would\n * drag its whole Airtable/MJML dependency chain into this module's graph, which\n * stays lazy-loaded on purpose (see bin.ts's central-dep-blocker comment — this\n * module reaches `resend`, a devDependency, and must only ever be reached via a\n * dynamic `import()` from the CLI).\n */\nconst FROM_ADDRESS = \"Reddoor Reports <reports@reddoorla.com>\";\n\nconst IMPACT_ORDER: Record<Fix[\"impact\"], number> = { high: 0, medium: 1, low: 2 };\n\n/** \"top few fixes\" per the design — enough to be useful on an internal sheet\n * without turning it into the full client report. */\nconst TOP_FIX_COUNT = 3;\n\nexport type AuditEmailContent = {\n subject: string;\n html: string;\n /** The FULL client-facing report (render.ts's `renderProspectReport`, pure\n * and deterministic like this function), so `sendAuditEmail` can attach it\n * without a second render call on the default path. */\n attachmentHtml: string;\n};\n\n/** The searchable business name when the pipeline resolved one, else the\n * hostname — mirrors render.ts's identical fallback (types.ts's businessName\n * doc: \"Null when no name was ever resolved... itself a finding, not an\n * error\"). Used for both the subject line and the sheet's own heading. */\nfunction resolveName(result: ProspectAuditResult): string {\n return result.businessName && result.businessName.trim()\n ? result.businessName\n : hostnameOf(result.url);\n}\n\n/**\n * Mail subject headers are plain text, never HTML-rendered by a client — no\n * `escapeHtml` needed there (that would wrongly show literal \"&lt;\" etc. in\n * the subject line). A raw newline/control character IS worth collapsing:\n * a business name that embeds one (scraped page title, model output) would\n * otherwise visibly break the subject, and a stray CR/LF in a header value\n * is the classic email-header-injection vector — defense-in-depth even\n * though the Resend API's JSON transport already neutralizes it here.\n */\nfunction subjectSafe(s: string): string {\n return s.replace(/\\s+/g, \" \").trim();\n}\n\n/** Local copy of render.ts's date formatter — small enough that importing it\n * (render.ts doesn't export it) isn't worth the coupling. */\nfunction formatIsoDate(iso: string): string {\n const d = new Date(iso);\n if (Number.isNaN(d.getTime())) return iso;\n return d.toLocaleDateString(\"en-US\", {\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n timeZone: \"UTC\",\n });\n}\n\ntype NotMeasuredLine = { label: string; reason: string };\n\n/**\n * Everything on the sheet that reads \"not measured\", and why — in plain\n * words. Unlike render.ts's client-facing report (which collapses every\n * stage failure to STAGE_FAILED_MESSAGE so a stranger never sees operator\n * vocabulary), this email goes to Tucker/Tim/Erik: the real diagnostic\n * (a fetch error, an LLM timeout) is more useful to them than a sanitized\n * phrase, so stage `error` strings are surfaced verbatim (still escaped —\n * they can embed arbitrary text from a fetch response).\n *\n * The four-Scores branches mirror checks.ts's `computeScores` exactly: which\n * stage feeds which score, and the cases where that stage's OWN data still\n * nulls the score even though the stage itself succeeded (crawlerAccessMeasured\n * false, avgMissing null, empty buyerQuestions, a null visibilityScore). If\n * computeScores' conditions change, this needs the matching update.\n */\nfunction notMeasuredLines(result: ProspectAuditResult): NotMeasuredLine[] {\n const lines: NotMeasuredLine[] = [];\n\n if (!result.checks.ok) {\n lines.push({\n label: \"Findability\",\n reason: `the checks stage failed — ${result.checks.error}`,\n });\n lines.push({\n label: \"Readability\",\n reason: `the checks stage failed — ${result.checks.error}`,\n });\n } else {\n const c = result.checks.data;\n if (result.scores.findability === null) {\n lines.push({\n label: \"Findability\",\n reason: !c.crawlerAccessMeasured\n ? \"robots.txt could not be fetched, so crawler access wasn't measured\"\n : \"every crawled page failed to produce readable content\",\n });\n }\n if (result.scores.readability === null) {\n lines.push({\n label: \"Readability\",\n reason: \"no page produced a comparable raw/rendered pair to measure JavaScript dependence\",\n });\n }\n }\n\n if (!result.lighthouse.ok) {\n lines.push({ label: \"Lighthouse\", reason: result.lighthouse.error });\n }\n\n if (!result.analyze.ok) {\n lines.push({ label: \"Answers\", reason: result.analyze.error });\n } else if (result.scores.answers === null) {\n lines.push({ label: \"Answers\", reason: \"the model found no buyer questions to check\" });\n }\n\n if (!result.probes.ok) {\n lines.push({ label: \"AI Visibility\", reason: result.probes.error });\n } else if (result.scores.aiVisibility === null) {\n lines.push({ label: \"AI Visibility\", reason: \"no category (buyer-question) query ran\" });\n }\n\n return lines;\n}\n\nconst SCORE_FIELDS: { key: keyof ProspectAuditResult[\"scores\"]; label: string }[] = [\n { key: \"findability\", label: \"Findability\" },\n { key: \"readability\", label: \"Readability\" },\n { key: \"answers\", label: \"Answers\" },\n { key: \"aiVisibility\", label: \"AI Visibility\" },\n];\n\nfunction scoresTableHtml(scores: ProspectAuditResult[\"scores\"]): string {\n const cells = SCORE_FIELDS.map(({ key, label }) => {\n const value = scores[key];\n const display = value === null ? \"Not measured\" : String(value);\n const valueStyle =\n value === null ? \"color:#8a857e;font-size:14px;\" : \"color:#d71920;font-size:28px;\";\n return `<td style=\"padding:12px 16px;border:1px solid #e6e1da;text-align:center;\">\n <div style=\"font-weight:600;${valueStyle}\">${escapeHtml(display)}</div>\n <div style=\"font-size:12px;letter-spacing:.04em;text-transform:uppercase;color:#57544f;margin-top:4px;\">${escapeHtml(label)}</div>\n </td>`;\n }).join(\"\");\n return `<table role=\"presentation\" style=\"border-collapse:collapse;margin:16px 0;\"><tr>${cells}</tr></table>`;\n}\n\nfunction notMeasuredHtml(lines: NotMeasuredLine[]): string {\n if (lines.length === 0) return \"\";\n const items = lines\n .map((l) => `<li><strong>${escapeHtml(l.label)}</strong> — ${escapeHtml(l.reason)}</li>`)\n .join(\"\");\n return `<h2 style=\"font-size:16px;margin:24px 0 8px;\">Not measured</h2><ul style=\"margin:0;padding-left:20px;\">${items}</ul>`;\n}\n\n/** analyze.error and fix titles/why are untrusted (LLM output, or text lifted\n * from the prospect's own site) — every interpolation below is escaped. */\nfunction fixesHtml(analyze: StageResult<AnalyzeResult>): string {\n if (!analyze.ok) {\n return `<p style=\"color:#8a857e;margin:8px 0 0;\">Fixes not available — ${escapeHtml(analyze.error)}</p>`;\n }\n const top = [...analyze.data.fixes]\n .sort((a, b) => IMPACT_ORDER[a.impact] - IMPACT_ORDER[b.impact])\n .slice(0, TOP_FIX_COUNT);\n if (top.length === 0) {\n return `<p style=\"margin:8px 0 0;\">Nothing urgent — the essentials are already in place.</p>`;\n }\n const items = top\n .map(\n (f) =>\n `<li><strong>${escapeHtml(f.title)}</strong> — ${escapeHtml(f.why)} <span style=\"color:#8a857e;\">(${escapeHtml(f.impact)} impact, ${escapeHtml(f.effort)} effort)</span></li>`,\n )\n .join(\"\");\n return `<ol style=\"margin:8px 0 0;padding-left:20px;\">${items}</ol>`;\n}\n\nfunction linkHtml(link: string | null): string {\n if (!link) {\n return `<p style=\"margin:24px 0 0;color:#8a857e;\">No shareable link — the audit could not be saved to the database. The full report is attached to this email instead.</p>`;\n }\n const safe = safeUrl(link);\n return `<p style=\"margin:24px 0 0;\"><strong>Full report:</strong> <a href=\"${escapeHtml(safe)}\">${escapeHtml(link)}</a></p>`;\n}\n\n/** This sheet is for us, and it says so. It carries the real reasons a stage did\n * not run — useful internally, wrong in front of a prospect — so it has to be\n * obvious that the shareable artefact is the attachment and the link, not this\n * body. Without the label, the natural thing to do with a useful email is\n * forward it. */\nconst INTERNAL_NOTE = `<p style=\"margin:24px 0 0;padding:12px 14px;background:#f4f2ef;border-left:3px solid #d71920;color:#57544f;font-size:14px;\">\n Internal sheet — it names the reasons a section could not be measured. The\n version to send a prospect is the linked report, also attached to this email.\n</p>`;\n\n/**\n * Build the internal sheet — a SHORT summary for Tucker/Tim/Erik, distinct\n * from the client-facing report render.ts builds. Pure: no IO, so it's safe\n * to call from a test with no network. `attachmentHtml` is the full report\n * (render.ts's `renderProspectReport`, itself pure), included here so\n * `sendAuditEmail`'s default path doesn't need a second render call.\n *\n * Every value that can trace back to the prospect's site or the model —\n * the business name, fixes, stage error text, the narrative-adjacent bits —\n * is escaped with `escapeHtml`/`safeUrl`, the same honesty-and-safety rule\n * render.ts follows for the client-facing report.\n */\nexport function buildAuditEmail(\n result: ProspectAuditResult,\n opts: { link: string | null },\n): AuditEmailContent {\n const name = resolveName(result);\n const subject = `Prospect audit — ${subjectSafe(name)}`;\n\n const html = `<!doctype html>\n<html lang=\"en\">\n<head><meta charset=\"utf-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /></head>\n<body style=\"margin:0;padding:24px;background:#faf8f5;color:#1a1a1a;font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif;\">\n <h1 style=\"font-size:22px;margin:0 0 4px;\">Prospect audit — ${escapeHtml(name)}</h1>\n <p style=\"margin:0 0 16px;color:#57544f;\">\n <a href=\"${escapeHtml(safeUrl(result.url))}\">${escapeHtml(result.url)}</a> · audited ${escapeHtml(formatIsoDate(result.generatedAt))}\n </p>\n ${scoresTableHtml(result.scores)}\n ${notMeasuredHtml(notMeasuredLines(result))}\n <h2 style=\"font-size:16px;margin:24px 0 8px;\">Top fixes</h2>\n ${fixesHtml(result.analyze)}\n ${linkHtml(opts.link)}\n ${INTERNAL_NOTE}\n</body>\n</html>`;\n\n return { subject, html, attachmentHtml: renderProspectReport(result) };\n}\n\n/**\n * Parse `PROSPECT_AUDIT_RECIPIENTS` (comma-separated) into a clean address\n * list: trimmed, empties dropped, case-insensitively deduped — mirrors\n * `reports/send/orchestrate.ts`'s `parseAddresses` for the same reasons (an\n * operator-typed env var, same typo surface). No address is ever hardcoded\n * anywhere in this module; an unset or empty var yields `[]`, which\n * `sendAuditEmail` treats as \"skip, and say why\" rather than an error.\n */\nexport function parseProspectAuditRecipients(raw: string | undefined | null): string[] {\n if (!raw) return [];\n const seen = new Set<string>();\n const list: string[] = [];\n for (const part of raw.split(\",\")) {\n const trimmed = part.trim().toLowerCase();\n if (!trimmed) continue;\n if (seen.has(trimmed)) continue;\n seen.add(trimmed);\n list.push(trimmed);\n }\n return list;\n}\n\n/** Filesystem-safe attachment-filename fragment. Tiny local copy of the CLI's\n * private `slugify` (prospect-audit.ts) — not worth exporting/sharing one\n * three-line predicate across a module boundary. */\nfunction slugify(s: string): string {\n const slug = s\n .toLowerCase()\n .replace(/[^a-z0-9.-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n return slug || \"prospect\";\n}\n\nexport type SendAuditEmailOptions = {\n link: string | null;\n recipients: string[];\n /**\n * The persisted `prospect_audits` row id (from `createProspectAudit`), when\n * persistence succeeded. Mirrors orchestrate.ts's\n * `idempotencyKey: \\`report:${report.id}\\`` pattern, so re-sending for the\n * SAME already-persisted audit dedupes at Resend instead of double-mailing.\n * Null when persistence failed — the sheet can still be sent (it's built to\n * survive independently of Turso), but then there is no stable row id, so\n * the key falls back to `url`+`generatedAt`: that still protects a\n * same-process double-call, though — unlike a DB id — it can't survive an\n * entire pipeline rerun, which mints genuinely new content anyway.\n */\n auditId?: string | null;\n /**\n * The print-designed PDF leave-behind, when one was rendered.\n *\n * Optional on purpose: rendering it needs a live page and a headless browser,\n * and neither is worth losing a delivered report over. Absent, the email goes\n * exactly as it did before — the HTML sheet and the link — and the caller has\n * already recorded a warning saying why.\n */\n pdf?: Buffer | null;\n /** Defaults to `defaultResendClient()`. */\n client?: ResendClient;\n /** Test seam for the ATTACHMENT content only (production omits it and gets\n * the real `renderProspectReport` output `buildAuditEmail` already\n * computed) — lets a test of this function's sending mechanics (recipients,\n * idempotency key, attachment shape) skip re-deriving the full report. */\n renderReport?: (result: ProspectAuditResult) => string;\n};\n\nexport type SendAuditEmailResult =\n { sent: true; messageId: string; recipients: string[] } | { sent: false; reason: string };\n\n/**\n * Send the audit sheet with the full rendered report attached as an `.html`\n * file (base64), so the sheet survives independently of the link and of\n * Turso. Empty `recipients` is a legitimate, non-exceptional outcome (no\n * `PROSPECT_AUDIT_RECIPIENTS` configured) — returns `{sent:false}` rather\n * than throwing, so a caller can report it as a warning; a genuine send\n * failure (a throwing `client.send`) still propagates as a real exception.\n */\nexport async function sendAuditEmail(\n result: ProspectAuditResult,\n opts: SendAuditEmailOptions,\n): Promise<SendAuditEmailResult> {\n if (opts.recipients.length === 0) {\n return {\n sent: false,\n reason: \"no recipients configured (PROSPECT_AUDIT_RECIPIENTS is unset or empty)\",\n };\n }\n\n const built = buildAuditEmail(result, { link: opts.link });\n const attachmentHtml = opts.renderReport ? opts.renderReport(result) : built.attachmentHtml;\n const client = opts.client ?? defaultResendClient();\n const idempotencyKey = `prospect-audit:${opts.auditId ?? `${result.url}#${result.generatedAt}`}`;\n const filename = `prospect-audit-${slugify(hostnameOf(result.url))}.html`;\n\n const { messageId } = await client.send({\n from: FROM_ADDRESS,\n to: opts.recipients,\n subject: built.subject,\n html: built.html,\n attachments: [\n {\n filename,\n content: Buffer.from(attachmentHtml, \"utf-8\").toString(\"base64\"),\n contentType: \"text/html\",\n },\n // The PDF goes second so the HTML sheet stays the first attachment it has\n // always been, and appears only when one was actually rendered — an empty\n // or broken attachment is worse than none.\n ...(opts.pdf\n ? [\n {\n filename: filename.replace(/\\.html$/, \".pdf\"),\n content: opts.pdf.toString(\"base64\"),\n contentType: \"application/pdf\",\n },\n ]\n : []),\n ],\n idempotencyKey,\n });\n\n return { sent: true, messageId, recipients: opts.recipients };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAM,eAAe;AAErB,IAAM,eAA8C,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,EAAE;AAIjF,IAAM,gBAAgB;AAetB,SAAS,YAAY,QAAqC;AACxD,SAAO,OAAO,gBAAgB,OAAO,aAAa,KAAK,IACnD,OAAO,eACP,WAAW,OAAO,GA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,WAAW,MAAM;AAAA,UAC5C,SAAS,KAAK,IAAI,SAAS,QAAQ;AAAA,UACnC,aAAa;AAAA,QACf;AAAA,MACF,IACA,CAAC;AAAA,IACP;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO,EAAE,MAAM,MAAM,WAAW,YAAY,KAAK,WAAW;AAC9D;","names":[]}
1
+ {"version":3,"sources":["../src/prospect/email.ts"],"sourcesContent":["import { escapeHtml, safeUrl } from \"../util/html.js\";\nimport { hostnameOf } from \"../util/url.js\";\nimport { renderProspectReport } from \"./render.js\";\nimport { defaultResendClient, type ResendClient } from \"../reports/send/resend.js\";\nimport type { AnalyzeResult, Fix, ProspectAuditResult, StageResult } from \"./types.js\";\n\n/**\n * Mirrors `reports/send/orchestrate.ts`'s `FROM_ADDRESS` (its line 18) — copied,\n * not imported, exactly like `digest.ts` and `recipes/selftest-email.ts` already\n * do. orchestrate.ts's own `FROM_ADDRESS` isn't exported, and importing it would\n * drag its whole Airtable/MJML dependency chain into this module's graph, which\n * stays lazy-loaded on purpose (see bin.ts's central-dep-blocker comment — this\n * module reaches `resend`, a devDependency, and must only ever be reached via a\n * dynamic `import()` from the CLI).\n */\nconst FROM_ADDRESS = \"Reddoor Reports <reports@reddoorla.com>\";\n\nconst IMPACT_ORDER: Record<Fix[\"impact\"], number> = { high: 0, medium: 1, low: 2 };\n\n/** \"top few fixes\" per the design — enough to be useful on an internal sheet\n * without turning it into the full client report. */\nconst TOP_FIX_COUNT = 3;\n\nexport type AuditEmailContent = {\n subject: string;\n html: string;\n /** The FULL client-facing report (render.ts's `renderProspectReport`, pure\n * and deterministic like this function), so `sendAuditEmail` can attach it\n * without a second render call on the default path. */\n attachmentHtml: string;\n};\n\n/** The searchable business name when the pipeline resolved one, else the\n * hostname — mirrors render.ts's identical fallback (types.ts's businessName\n * doc: \"Null when no name was ever resolved... itself a finding, not an\n * error\"). Used for both the subject line and the sheet's own heading. */\nfunction resolveName(result: ProspectAuditResult): string {\n return result.businessName && result.businessName.trim()\n ? result.businessName\n : hostnameOf(result.url);\n}\n\n/**\n * Mail subject headers are plain text, never HTML-rendered by a client — no\n * `escapeHtml` needed there (that would wrongly show literal \"&lt;\" etc. in\n * the subject line). A raw newline/control character IS worth collapsing:\n * a business name that embeds one (scraped page title, model output) would\n * otherwise visibly break the subject, and a stray CR/LF in a header value\n * is the classic email-header-injection vector — defense-in-depth even\n * though the Resend API's JSON transport already neutralizes it here.\n */\nfunction subjectSafe(s: string): string {\n return s.replace(/\\s+/g, \" \").trim();\n}\n\n/** Local copy of render.ts's date formatter — small enough that importing it\n * (render.ts doesn't export it) isn't worth the coupling. */\nfunction formatIsoDate(iso: string): string {\n const d = new Date(iso);\n if (Number.isNaN(d.getTime())) return iso;\n return d.toLocaleDateString(\"en-US\", {\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n timeZone: \"UTC\",\n });\n}\n\ntype NotMeasuredLine = { label: string; reason: string };\n\n/**\n * Everything on the sheet that reads \"not measured\", and why — in plain\n * words. Unlike render.ts's client-facing report (which collapses every\n * stage failure to STAGE_FAILED_MESSAGE so a stranger never sees operator\n * vocabulary), this email goes to Tucker/Tim/Erik: the real diagnostic\n * (a fetch error, an LLM timeout) is more useful to them than a sanitized\n * phrase, so stage `error` strings are surfaced verbatim (still escaped —\n * they can embed arbitrary text from a fetch response).\n *\n * The four-Scores branches mirror checks.ts's `computeScores` exactly: which\n * stage feeds which score, and the cases where that stage's OWN data still\n * nulls the score even though the stage itself succeeded (crawlerAccessMeasured\n * false, avgMissing null, empty buyerQuestions, a null visibilityScore). If\n * computeScores' conditions change, this needs the matching update.\n */\nfunction notMeasuredLines(result: ProspectAuditResult): NotMeasuredLine[] {\n const lines: NotMeasuredLine[] = [];\n\n if (!result.checks.ok) {\n lines.push({\n label: \"Findability\",\n reason: `the checks stage failed — ${result.checks.error}`,\n });\n lines.push({\n label: \"Readability\",\n reason: `the checks stage failed — ${result.checks.error}`,\n });\n } else {\n const c = result.checks.data;\n if (result.scores.findability === null) {\n lines.push({\n label: \"Findability\",\n reason: !c.crawlerAccessMeasured\n ? \"robots.txt could not be fetched, so crawler access wasn't measured\"\n : \"every crawled page failed to produce readable content\",\n });\n }\n if (result.scores.readability === null) {\n lines.push({\n label: \"Readability\",\n reason: \"no page produced a comparable raw/rendered pair to measure JavaScript dependence\",\n });\n }\n }\n\n if (!result.lighthouse.ok) {\n lines.push({ label: \"Lighthouse\", reason: result.lighthouse.error });\n }\n\n if (!result.analyze.ok) {\n lines.push({ label: \"Answers\", reason: result.analyze.error });\n } else if (result.scores.answers === null) {\n lines.push({ label: \"Answers\", reason: \"the model found no buyer questions to check\" });\n }\n\n // Named for what the stage measures (the receipts section), not for the\n // removed score label — the email no longer presents an AI Visibility score.\n if (!result.probes.ok) {\n lines.push({ label: \"AI engine answers\", reason: result.probes.error });\n } else if (result.scores.aiVisibility === null) {\n lines.push({ label: \"AI engine answers\", reason: \"no category (buyer-question) query ran\" });\n }\n\n return lines;\n}\n\n/** The three SITE scores. aiVisibility is deliberately absent — the report\n * reorganised around what the client controls, and a visibility number in a\n * score row reads as ours to move. It stays computed and stored; the report\n * page presents the receipts. */\nconst SCORE_FIELDS: { key: keyof ProspectAuditResult[\"scores\"]; label: string }[] = [\n { key: \"findability\", label: \"Findability\" },\n { key: \"readability\", label: \"Readability\" },\n { key: \"answers\", label: \"Answers\" },\n];\n\nfunction scoresTableHtml(scores: ProspectAuditResult[\"scores\"]): string {\n const cells = SCORE_FIELDS.map(({ key, label }) => {\n const value = scores[key];\n const display = value === null ? \"Not measured\" : String(value);\n const valueStyle =\n value === null ? \"color:#8a857e;font-size:14px;\" : \"color:#d71920;font-size:28px;\";\n return `<td style=\"padding:12px 16px;border:1px solid #e6e1da;text-align:center;\">\n <div style=\"font-weight:600;${valueStyle}\">${escapeHtml(display)}</div>\n <div style=\"font-size:12px;letter-spacing:.04em;text-transform:uppercase;color:#57544f;margin-top:4px;\">${escapeHtml(label)}</div>\n </td>`;\n }).join(\"\");\n return `<table role=\"presentation\" style=\"border-collapse:collapse;margin:16px 0;\"><tr>${cells}</tr></table>`;\n}\n\nfunction notMeasuredHtml(lines: NotMeasuredLine[]): string {\n if (lines.length === 0) return \"\";\n const items = lines\n .map((l) => `<li><strong>${escapeHtml(l.label)}</strong> — ${escapeHtml(l.reason)}</li>`)\n .join(\"\");\n return `<h2 style=\"font-size:16px;margin:24px 0 8px;\">Not measured</h2><ul style=\"margin:0;padding-left:20px;\">${items}</ul>`;\n}\n\n/** analyze.error and fix titles/why are untrusted (LLM output, or text lifted\n * from the prospect's own site) — every interpolation below is escaped. */\nfunction fixesHtml(analyze: StageResult<AnalyzeResult>): string {\n if (!analyze.ok) {\n return `<p style=\"color:#8a857e;margin:8px 0 0;\">Fixes not available — ${escapeHtml(analyze.error)}</p>`;\n }\n const top = [...analyze.data.fixes]\n .sort((a, b) => IMPACT_ORDER[a.impact] - IMPACT_ORDER[b.impact])\n .slice(0, TOP_FIX_COUNT);\n if (top.length === 0) {\n return `<p style=\"margin:8px 0 0;\">Nothing urgent — the essentials are already in place.</p>`;\n }\n const items = top\n .map(\n (f) =>\n `<li><strong>${escapeHtml(f.title)}</strong> — ${escapeHtml(f.why)} <span style=\"color:#8a857e;\">(${escapeHtml(f.impact)} impact, ${escapeHtml(f.effort)} effort)</span></li>`,\n )\n .join(\"\");\n return `<ol style=\"margin:8px 0 0;padding-left:20px;\">${items}</ol>`;\n}\n\nfunction linkHtml(link: string | null): string {\n if (!link) {\n return `<p style=\"margin:24px 0 0;color:#8a857e;\">No shareable link — the audit could not be saved to the database. The full report is attached to this email instead.</p>`;\n }\n const safe = safeUrl(link);\n return `<p style=\"margin:24px 0 0;\"><strong>Full report:</strong> <a href=\"${escapeHtml(safe)}\">${escapeHtml(link)}</a></p>`;\n}\n\n/** This sheet is for us, and it says so. It carries the real reasons a stage did\n * not run — useful internally, wrong in front of a prospect — so it has to be\n * obvious that the shareable artefact is the attachment and the link, not this\n * body. Without the label, the natural thing to do with a useful email is\n * forward it. */\nconst INTERNAL_NOTE = `<p style=\"margin:24px 0 0;padding:12px 14px;background:#f4f2ef;border-left:3px solid #d71920;color:#57544f;font-size:14px;\">\n Internal sheet — it names the reasons a section could not be measured. The\n version to send a prospect is the linked report, also attached to this email.\n</p>`;\n\n/**\n * Build the internal sheet — a SHORT summary for Tucker/Tim/Erik, distinct\n * from the client-facing report render.ts builds. Pure: no IO, so it's safe\n * to call from a test with no network. `attachmentHtml` is the full report\n * (render.ts's `renderProspectReport`, itself pure), included here so\n * `sendAuditEmail`'s default path doesn't need a second render call.\n *\n * Every value that can trace back to the prospect's site or the model —\n * the business name, fixes, stage error text, the narrative-adjacent bits —\n * is escaped with `escapeHtml`/`safeUrl`, the same honesty-and-safety rule\n * render.ts follows for the client-facing report.\n */\nexport function buildAuditEmail(\n result: ProspectAuditResult,\n opts: { link: string | null },\n): AuditEmailContent {\n const name = resolveName(result);\n const subject = `Prospect audit — ${subjectSafe(name)}`;\n\n const html = `<!doctype html>\n<html lang=\"en\">\n<head><meta charset=\"utf-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /></head>\n<body style=\"margin:0;padding:24px;background:#faf8f5;color:#1a1a1a;font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif;\">\n <h1 style=\"font-size:22px;margin:0 0 4px;\">Prospect audit — ${escapeHtml(name)}</h1>\n <p style=\"margin:0 0 16px;color:#57544f;\">\n <a href=\"${escapeHtml(safeUrl(result.url))}\">${escapeHtml(result.url)}</a> · audited ${escapeHtml(formatIsoDate(result.generatedAt))}\n </p>\n ${scoresTableHtml(result.scores)}\n ${notMeasuredHtml(notMeasuredLines(result))}\n <h2 style=\"font-size:16px;margin:24px 0 8px;\">Top fixes</h2>\n ${fixesHtml(result.analyze)}\n ${linkHtml(opts.link)}\n ${INTERNAL_NOTE}\n</body>\n</html>`;\n\n return { subject, html, attachmentHtml: renderProspectReport(result) };\n}\n\n/**\n * Parse `PROSPECT_AUDIT_RECIPIENTS` (comma-separated) into a clean address\n * list: trimmed, empties dropped, case-insensitively deduped — mirrors\n * `reports/send/orchestrate.ts`'s `parseAddresses` for the same reasons (an\n * operator-typed env var, same typo surface). No address is ever hardcoded\n * anywhere in this module; an unset or empty var yields `[]`, which\n * `sendAuditEmail` treats as \"skip, and say why\" rather than an error.\n */\nexport function parseProspectAuditRecipients(raw: string | undefined | null): string[] {\n if (!raw) return [];\n const seen = new Set<string>();\n const list: string[] = [];\n for (const part of raw.split(\",\")) {\n const trimmed = part.trim().toLowerCase();\n if (!trimmed) continue;\n if (seen.has(trimmed)) continue;\n seen.add(trimmed);\n list.push(trimmed);\n }\n return list;\n}\n\n/** Filesystem-safe attachment-filename fragment. Tiny local copy of the CLI's\n * private `slugify` (prospect-audit.ts) — not worth exporting/sharing one\n * three-line predicate across a module boundary. */\nfunction slugify(s: string): string {\n const slug = s\n .toLowerCase()\n .replace(/[^a-z0-9.-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n return slug || \"prospect\";\n}\n\nexport type SendAuditEmailOptions = {\n link: string | null;\n recipients: string[];\n /**\n * The persisted `prospect_audits` row id (from `createProspectAudit`), when\n * persistence succeeded. Mirrors orchestrate.ts's\n * `idempotencyKey: \\`report:${report.id}\\`` pattern, so re-sending for the\n * SAME already-persisted audit dedupes at Resend instead of double-mailing.\n * Null when persistence failed — the sheet can still be sent (it's built to\n * survive independently of Turso), but then there is no stable row id, so\n * the key falls back to `url`+`generatedAt`: that still protects a\n * same-process double-call, though — unlike a DB id — it can't survive an\n * entire pipeline rerun, which mints genuinely new content anyway.\n */\n auditId?: string | null;\n /**\n * The print-designed PDF leave-behind, when one was rendered.\n *\n * Optional on purpose: rendering it needs a live page and a headless browser,\n * and neither is worth losing a delivered report over. Absent, the email goes\n * exactly as it did before — the HTML sheet and the link — and the caller has\n * already recorded a warning saying why.\n */\n pdf?: Buffer | null;\n /** Defaults to `defaultResendClient()`. */\n client?: ResendClient;\n /** Test seam for the ATTACHMENT content only (production omits it and gets\n * the real `renderProspectReport` output `buildAuditEmail` already\n * computed) — lets a test of this function's sending mechanics (recipients,\n * idempotency key, attachment shape) skip re-deriving the full report. */\n renderReport?: (result: ProspectAuditResult) => string;\n};\n\nexport type SendAuditEmailResult =\n { sent: true; messageId: string; recipients: string[] } | { sent: false; reason: string };\n\n/**\n * Send the audit sheet with the full rendered report attached as an `.html`\n * file (base64), so the sheet survives independently of the link and of\n * Turso. Empty `recipients` is a legitimate, non-exceptional outcome (no\n * `PROSPECT_AUDIT_RECIPIENTS` configured) — returns `{sent:false}` rather\n * than throwing, so a caller can report it as a warning; a genuine send\n * failure (a throwing `client.send`) still propagates as a real exception.\n */\nexport async function sendAuditEmail(\n result: ProspectAuditResult,\n opts: SendAuditEmailOptions,\n): Promise<SendAuditEmailResult> {\n if (opts.recipients.length === 0) {\n return {\n sent: false,\n reason: \"no recipients configured (PROSPECT_AUDIT_RECIPIENTS is unset or empty)\",\n };\n }\n\n const built = buildAuditEmail(result, { link: opts.link });\n const attachmentHtml = opts.renderReport ? opts.renderReport(result) : built.attachmentHtml;\n const client = opts.client ?? defaultResendClient();\n const idempotencyKey = `prospect-audit:${opts.auditId ?? `${result.url}#${result.generatedAt}`}`;\n const filename = `prospect-audit-${slugify(hostnameOf(result.url))}.html`;\n\n const { messageId } = await client.send({\n from: FROM_ADDRESS,\n to: opts.recipients,\n subject: built.subject,\n html: built.html,\n attachments: [\n {\n filename,\n content: Buffer.from(attachmentHtml, \"utf-8\").toString(\"base64\"),\n contentType: \"text/html\",\n },\n // The PDF goes second so the HTML sheet stays the first attachment it has\n // always been, and appears only when one was actually rendered — an empty\n // or broken attachment is worse than none.\n ...(opts.pdf\n ? [\n {\n filename: filename.replace(/\\.html$/, \".pdf\"),\n content: opts.pdf.toString(\"base64\"),\n contentType: \"application/pdf\",\n },\n ]\n : []),\n ],\n idempotencyKey,\n });\n\n return { sent: true, messageId, recipients: opts.recipients };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA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AK,gBAAgB,OAAO,EAAE,SAAS,QAAQ;AAAA,QAC/D,aAAa;AAAA,MACf;AAAA;AAAA;AAAA;AAAA,MAIA,GAAI,KAAK,MACL;AAAA,QACE;AAAA,UACE,UAAU,SAAS,QAAQ,WAAW,MAAM;AAAA,UAC5C,SAAS,KAAK,IAAI,SAAS,QAAQ;AAAA,UACnC,aAAa;AAAA,QACf;AAAA,MACF,IACA,CAAC;AAAA,IACP;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO,EAAE,MAAM,MAAM,WAAW,YAAY,KAAK,WAAW;AAC9D;","names":[]}
@@ -66,7 +66,7 @@ async function runEnsureSiteCommand(slug, opts) {
66
66
  if (!slug) return { output: "Provide a <slug> (e.g. `ensure-site roalson`).", code: 2 };
67
67
  try {
68
68
  const base = openBase(readAirtableConfig());
69
- const { makeSiteMirror } = await import("./site-mirror-Q763PLGG.js");
69
+ const { makeSiteMirror } = await import("./site-mirror-RQTEAID5.js");
70
70
  const result = await ensureSite(
71
71
  base,
72
72
  {
@@ -93,4 +93,4 @@ async function runEnsureSiteCommand(slug, opts) {
93
93
  export {
94
94
  runEnsureSiteCommand
95
95
  };
96
- //# sourceMappingURL=ensure-site-FU6527OU.js.map
96
+ //# sourceMappingURL=ensure-site-NSNY2QHN.js.map
@@ -15,7 +15,7 @@ import {
15
15
  mirrorSiteFields,
16
16
  mirrorSiteInsert,
17
17
  storeRenderedHtml
18
- } from "./chunk-GQDDWYU2.js";
18
+ } from "./chunk-QBAAZY7W.js";
19
19
  import "./chunk-P6AORG32.js";
20
20
  import "./chunk-F3JWOPTG.js";
21
21
  import "./chunk-VAD43MOR.js";
@@ -38,4 +38,4 @@ export {
38
38
  mirrorSiteInsert,
39
39
  storeRenderedHtml
40
40
  };
41
- //# sourceMappingURL=fleet-state-R5LU7IC3.js.map
41
+ //# sourceMappingURL=fleet-state-3LQUQHYD.js.map
@@ -143,7 +143,7 @@ async function runFormsNotifyTargetCommand(site, opts) {
143
143
  return { output: `--set must be 'on' or 'off' (got '${opts.set}')`, code: 2 };
144
144
  }
145
145
  try {
146
- const { makeSiteMirror } = await import("./site-mirror-Q763PLGG.js");
146
+ const { makeSiteMirror } = await import("./site-mirror-RQTEAID5.js");
147
147
  const result = await formsNotifyTarget({
148
148
  siteMirror: await makeSiteMirror(),
149
149
  site: site.trim(),
@@ -163,4 +163,4 @@ export {
163
163
  formatNotifyTarget,
164
164
  runFormsNotifyTargetCommand
165
165
  };
166
- //# sourceMappingURL=forms-notify-target-SGDGXXK5.js.map
166
+ //# sourceMappingURL=forms-notify-target-LYSKME5L.js.map
@@ -0,0 +1,9 @@
1
+ import {
2
+ TURSO_IS_AUTHORITATIVE,
3
+ mirrorWrite
4
+ } from "./chunk-SVAAONYB.js";
5
+ export {
6
+ TURSO_IS_AUTHORITATIVE,
7
+ mirrorWrite
8
+ };
9
+ //# sourceMappingURL=freeze-A6MUCZU4.js.map
@@ -3,9 +3,9 @@ import {
3
3
  } from "./chunk-PZQ3WED2.js";
4
4
  import {
5
5
  formatFleetWriteSummary
6
- } from "./chunk-6UCVWYDA.js";
7
- import "./chunk-RUPPWAD6.js";
6
+ } from "./chunk-QLIUDTY6.js";
8
7
  import "./chunk-7BZUOZPU.js";
8
+ import "./chunk-SVAAONYB.js";
9
9
  import {
10
10
  detectSignalEvents,
11
11
  fleetSweptEvent
@@ -91,7 +91,7 @@ async function runGitHubSignalsCommand(opts, deps = {}) {
91
91
  );
92
92
  const sweptAt = (/* @__PURE__ */ new Date()).toISOString();
93
93
  const makeMirror = deps.makeMirror ?? (async () => {
94
- const { makeHealthMirrorBestEffort } = await import("./health-mirror-GCDN7BJL.js");
94
+ const { makeHealthMirrorBestEffort } = await import("./health-mirror-7LKC7Q5Z.js");
95
95
  return makeHealthMirrorBestEffort();
96
96
  });
97
97
  const mirror = await makeMirror();
@@ -156,4 +156,4 @@ export {
156
156
  githubSignalsExitCode,
157
157
  runGitHubSignalsCommand
158
158
  };
159
- //# sourceMappingURL=github-signals-DB25UWY4.js.map
159
+ //# sourceMappingURL=github-signals-4YML6NY5.js.map
@@ -1,10 +1,10 @@
1
- import {
2
- TURSO_IS_AUTHORITATIVE
3
- } from "./chunk-RUPPWAD6.js";
4
1
  import {
5
2
  mirrorHealthFields,
6
3
  mirrorScheduleFields
7
- } from "./chunk-GQDDWYU2.js";
4
+ } from "./chunk-QBAAZY7W.js";
5
+ import {
6
+ TURSO_IS_AUTHORITATIVE
7
+ } from "./chunk-SVAAONYB.js";
8
8
  import "./chunk-P6AORG32.js";
9
9
  import "./chunk-F3JWOPTG.js";
10
10
  import "./chunk-VAD43MOR.js";
@@ -43,4 +43,4 @@ export {
43
43
  makeHealthMirrorBestEffort,
44
44
  makeScheduleMirrorBestEffort
45
45
  };
46
- //# sourceMappingURL=health-mirror-GCDN7BJL.js.map
46
+ //# sourceMappingURL=health-mirror-7LKC7Q5Z.js.map
package/dist/index.d.ts CHANGED
@@ -129,6 +129,13 @@ type FormSubmitOutcome = {
129
129
  * `elapsedMs` — is what the budget check must compare against. Undefined
130
130
  * when no POST was observed. */
131
131
  postElapsedMs?: number;
132
+ /** The probe's filled values were wiped by a client re-render (2026-08-31:
133
+ * a hydration mismatch on reddoor's /contact recreated the form subtree,
134
+ * discarding the fills AND the injected hidden fields, so the click hit an
135
+ * empty form and native `required` validation blocked the submit) and were
136
+ * re-filled once before the click. On a pass this is production proof the
137
+ * wipe happens; on a failure it says one refill wasn't enough. */
138
+ refilled?: boolean;
132
139
  } | {
133
140
  testModeUndeclared: true;
134
141
  };
@@ -1006,10 +1013,8 @@ interface ReportsTable {
1006
1013
  *
1007
1014
  * `rendered_html` stays deliberately OUT even though the drafting path now
1008
1015
  * writes it: bodies go through `storeRenderedHtml`, so a request handler
1009
- * holding a patch cannot accidentally write megabytes of HTML. `sent_at` and
1010
- * `resend_message_id` stay out because nothing but the send batch writes them
1011
- * and the hourly sync converges those. */
1012
- type ReportMirrorPatch = Partial<Pick<ReportsTable, "approved_to_send" | "approved_at" | "approved_by" | "send_override" | "override_reason" | "override_by" | "override_at" | "delivery_status" | "commentary" | "draft_ready" | "lighthouse_performance" | "lighthouse_accessibility" | "lighthouse_best_practices" | "lighthouse_seo" | "ga_users_current" | "ga_users_previous" | "search_found_page1" | "search_position" | "completed_on">>;
1016
+ * holding a patch cannot accidentally write megabytes of HTML. */
1017
+ type ReportMirrorPatch = Partial<Pick<ReportsTable, "approved_to_send" | "approved_at" | "approved_by" | "send_override" | "override_reason" | "override_by" | "override_at" | "delivery_status" | "commentary" | "draft_ready" | "lighthouse_performance" | "lighthouse_accessibility" | "lighthouse_best_practices" | "lighthouse_seo" | "ga_users_current" | "ga_users_previous" | "search_found_page1" | "search_position" | "completed_on" | "sent_at" | "resend_message_id">>;
1013
1018
 
1014
1019
  /** #539 Phase 5: the Turso write-through for the Reports write surface.
1015
1020
  *
@@ -1255,6 +1260,13 @@ type OrchestrateOptions = {
1255
1260
  * updates. Injected rather than defaulted — this function is called directly
1256
1261
  * by tests, and a default would open a real libSQL handle inside the suite. */
1257
1262
  siteMirror?: SiteMirror;
1263
+ /** #643 (the freeze): Turso write-through for the `Sent at` / `Resend message
1264
+ * ID` stamp. stampSent is what removes a row from listSendableReports, so
1265
+ * once it lands there is no replay left to converge a lost mirror — and the
1266
+ * console's already-sent guards (approve, the commentary lock, re-render)
1267
+ * read `sent_at` from Turso. Injected like siteMirror; the CLI wires it
1268
+ * through `mirrorWrite` so the freeze switch owns the error semantics. */
1269
+ reportSentMirror?: (reportId: string, sentAt: Date, messageId: string | null) => Promise<void>;
1258
1270
  };
1259
1271
  declare function sendApprovedReports(options?: OrchestrateOptions): Promise<{
1260
1272
  output: string;
package/dist/index.js CHANGED
@@ -1,18 +1,23 @@
1
1
  import "./chunk-2SLED3NB.js";
2
2
  import {
3
3
  draftReportForSite
4
- } from "./chunk-J3WEZGIN.js";
4
+ } from "./chunk-ZRI5VRPG.js";
5
+ import "./chunk-YFAXOD7Z.js";
6
+ import {
7
+ upgradeSvelte4to5
8
+ } from "./chunk-Z3KYFUN6.js";
5
9
  import {
6
10
  DEFAULT_INIT_STEPS,
7
11
  a11yFixturesPage,
8
12
  init
9
- } from "./chunk-XSOINOPY.js";
13
+ } from "./chunk-62NYED6E.js";
10
14
  import {
11
15
  convertToPnpm
12
16
  } from "./chunk-XIDUYLSR.js";
13
17
  import {
14
18
  svelteCodemods
15
19
  } from "./chunk-IYSEC543.js";
20
+ import "./chunk-J7SZQUCW.js";
16
21
  import "./chunk-BQRFQSGY.js";
17
22
  import "./chunk-Y53WOQIJ.js";
18
23
  import {
@@ -20,19 +25,14 @@ import {
20
25
  selfCaretRange,
21
26
  selfPackageVersion
22
27
  } from "./chunk-7RJ2HMMJ.js";
23
- import "./chunk-YFAXOD7Z.js";
24
28
  import {
25
29
  bumpDeps
26
30
  } from "./chunk-2NJQLSEU.js";
27
31
  import "./chunk-R53VL3RI.js";
28
- import {
29
- upgradeSvelte4to5
30
- } from "./chunk-Z3KYFUN6.js";
31
- import "./chunk-J7SZQUCW.js";
32
- import "./chunk-WPL5GERE.js";
32
+ import "./chunk-ZOCJBJQV.js";
33
33
  import {
34
34
  approveBlockers
35
- } from "./chunk-6I6L3CMX.js";
35
+ } from "./chunk-KGUKL3CV.js";
36
36
  import {
37
37
  findDueReports
38
38
  } from "./chunk-PZR4EBPY.js";
@@ -40,12 +40,12 @@ import {
40
40
  parseAddresses,
41
41
  sendApprovedReports,
42
42
  withGlobalCc
43
- } from "./chunk-DGZWFI2G.js";
44
- import "./chunk-BRYXFH77.js";
45
- import "./chunk-NYUYNYQL.js";
43
+ } from "./chunk-VBEKL445.js";
46
44
  import {
47
45
  isPendingApproval
48
46
  } from "./chunk-F3JWOPTG.js";
47
+ import "./chunk-BRYXFH77.js";
48
+ import "./chunk-NYUYNYQL.js";
49
49
  import {
50
50
  checklistFor,
51
51
  gatingFields,
@@ -56,14 +56,8 @@ import {
56
56
  } from "./chunk-PR343K7F.js";
57
57
  import "./chunk-IY6256GK.js";
58
58
  import "./chunk-HN6I2XWI.js";
59
- import "./chunk-XP5WM2LV.js";
59
+ import "./chunk-SKI23ZZH.js";
60
60
  import "./chunk-GECESMVS.js";
61
- import {
62
- domainFromUrl,
63
- generateHeaderImage,
64
- loadHeadline,
65
- loadPlate
66
- } from "./chunk-5UINJNAJ.js";
67
61
  import {
68
62
  BLURRED_CID,
69
63
  CHECK_CID,
@@ -71,6 +65,12 @@ import {
71
65
  renderReportHtml,
72
66
  rendersCommentary
73
67
  } from "./chunk-KJGKZLCT.js";
68
+ import {
69
+ domainFromUrl,
70
+ generateHeaderImage,
71
+ loadHeadline,
72
+ loadPlate
73
+ } from "./chunk-5UINJNAJ.js";
74
74
  import {
75
75
  escapeHtml,
76
76
  safeUrl
@@ -84,9 +84,9 @@ import {
84
84
  import "./chunk-WEKL2HYJ.js";
85
85
  import {
86
86
  syncConfigs
87
- } from "./chunk-7UAYMAKR.js";
88
- import "./chunk-73UFRZKY.js";
87
+ } from "./chunk-3VQWSE3F.js";
89
88
  import "./chunk-3G25KIWW.js";
89
+ import "./chunk-73UFRZKY.js";
90
90
  import "./chunk-OTGB6YQO.js";
91
91
  import {
92
92
  ALL_AUDIT_NAMES,
@@ -96,7 +96,7 @@ import {
96
96
  runAudits,
97
97
  runAuditsAcross,
98
98
  securityAudit
99
- } from "./chunk-B23FFWU4.js";
99
+ } from "./chunk-AEXJDCJN.js";
100
100
  import "./chunk-LKGVSM2O.js";
101
101
  import "./chunk-GASBX52O.js";
102
102
  import "./chunk-XHHMM5HX.js";
@@ -8,19 +8,19 @@ import {
8
8
  } from "./chunk-Q47DU255.js";
9
9
  import {
10
10
  init
11
- } from "./chunk-XSOINOPY.js";
11
+ } from "./chunk-62NYED6E.js";
12
12
  import "./chunk-XIDUYLSR.js";
13
13
  import "./chunk-IYSEC543.js";
14
+ import "./chunk-J7SZQUCW.js";
14
15
  import "./chunk-BQRFQSGY.js";
15
16
  import "./chunk-Y53WOQIJ.js";
16
17
  import "./chunk-7RJ2HMMJ.js";
17
18
  import "./chunk-R53VL3RI.js";
18
- import "./chunk-J7SZQUCW.js";
19
- import "./chunk-7UAYMAKR.js";
20
- import "./chunk-73UFRZKY.js";
19
+ import "./chunk-3VQWSE3F.js";
21
20
  import "./chunk-3G25KIWW.js";
21
+ import "./chunk-73UFRZKY.js";
22
22
  import "./chunk-OTGB6YQO.js";
23
- import "./chunk-B23FFWU4.js";
23
+ import "./chunk-AEXJDCJN.js";
24
24
  import "./chunk-LKGVSM2O.js";
25
25
  import "./chunk-GASBX52O.js";
26
26
  import "./chunk-XHHMM5HX.js";
@@ -110,4 +110,4 @@ async function runInitCommand(site, opts) {
110
110
  export {
111
111
  runInitCommand
112
112
  };
113
- //# sourceMappingURL=init-32AWPS7A.js.map
113
+ //# sourceMappingURL=init-NHKADHB6.js.map
@@ -4,12 +4,12 @@ import {
4
4
  import "./chunk-MNDIED4M.js";
5
5
  import {
6
6
  writeAuditsToAirtable
7
- } from "./chunk-6UCVWYDA.js";
8
- import "./chunk-RUPPWAD6.js";
7
+ } from "./chunk-QLIUDTY6.js";
9
8
  import {
10
9
  hasRealScores,
11
10
  lighthouseScoresFromResult
12
11
  } from "./chunk-7BZUOZPU.js";
12
+ import "./chunk-SVAAONYB.js";
13
13
  import {
14
14
  resolveSites
15
15
  } from "./chunk-Q47DU255.js";
@@ -42,7 +42,7 @@ import {
42
42
  import "./chunk-73UFRZKY.js";
43
43
  import {
44
44
  runAudits
45
- } from "./chunk-B23FFWU4.js";
45
+ } from "./chunk-AEXJDCJN.js";
46
46
  import "./chunk-LKGVSM2O.js";
47
47
  import "./chunk-GASBX52O.js";
48
48
  import "./chunk-XHHMM5HX.js";
@@ -241,8 +241,8 @@ async function runLaunchCommand(site, opts) {
241
241
  if (!target) {
242
242
  return { output: `No site resolved for "${site}".`, code: 1 };
243
243
  }
244
- const { makeReportMirror } = await import("./report-mirror-AAK3MXHY.js");
245
- const { makeSiteMirror } = await import("./site-mirror-Q763PLGG.js");
244
+ const { makeReportMirror } = await import("./report-mirror-3ENU6OOK.js");
245
+ const { makeSiteMirror } = await import("./site-mirror-RQTEAID5.js");
246
246
  const result = await launch(target, {
247
247
  reportMirror: await makeReportMirror(),
248
248
  siteMirror: await makeSiteMirror()
@@ -252,4 +252,4 @@ async function runLaunchCommand(site, opts) {
252
252
  export {
253
253
  runLaunchCommand
254
254
  };
255
- //# sourceMappingURL=launch-52WUE4TZ.js.map
255
+ //# sourceMappingURL=launch-VQJ4Z35C.js.map
@@ -4,15 +4,15 @@ import {
4
4
  parseAddresses,
5
5
  sendApprovedReports,
6
6
  withGlobalCc
7
- } from "./chunk-DGZWFI2G.js";
7
+ } from "./chunk-VBEKL445.js";
8
8
  import "./chunk-F3JWOPTG.js";
9
9
  import "./chunk-VAD43MOR.js";
10
10
  import "./chunk-IY6256GK.js";
11
11
  import "./chunk-HN6I2XWI.js";
12
- import "./chunk-XP5WM2LV.js";
12
+ import "./chunk-SKI23ZZH.js";
13
13
  import "./chunk-GECESMVS.js";
14
- import "./chunk-5UINJNAJ.js";
15
14
  import "./chunk-KJGKZLCT.js";
15
+ import "./chunk-5UINJNAJ.js";
16
16
  import "./chunk-BGTYPVLT.js";
17
17
  import "./chunk-7NYN2P6I.js";
18
18
  import "./chunk-WEKL2HYJ.js";
@@ -28,4 +28,4 @@ export {
28
28
  sendApprovedReports,
29
29
  withGlobalCc
30
30
  };
31
- //# sourceMappingURL=orchestrate-JNKCWU5K.js.map
31
+ //# sourceMappingURL=orchestrate-6HROYTM6.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  checkFleetParity,
3
3
  formatParityResult
4
- } from "./chunk-7FFUBF4I.js";
5
- import "./chunk-GQDDWYU2.js";
4
+ } from "./chunk-AX22DH6S.js";
5
+ import "./chunk-QBAAZY7W.js";
6
6
  import "./chunk-P6AORG32.js";
7
7
  import "./chunk-F3JWOPTG.js";
8
8
  import "./chunk-VAD43MOR.js";
@@ -11,4 +11,4 @@ export {
11
11
  checkFleetParity,
12
12
  formatParityResult
13
13
  };
14
- //# sourceMappingURL=parity-NBYZUBFU.js.map
14
+ //# sourceMappingURL=parity-623WNFZG.js.map
@@ -1,12 +1,16 @@
1
1
  import {
2
2
  ANALYZE_SKIPPED,
3
3
  PROBES_SKIPPED,
4
+ envAnalyzeDeps,
5
+ envEngines,
4
6
  runProspectAudit
5
- } from "./chunk-CEW5PEHZ.js";
7
+ } from "./chunk-DXKF552B.js";
6
8
  import "./chunk-RARREDQE.js";
7
9
  export {
8
10
  ANALYZE_SKIPPED,
9
11
  PROBES_SKIPPED,
12
+ envAnalyzeDeps,
13
+ envEngines,
10
14
  runProspectAudit
11
15
  };
12
- //# sourceMappingURL=pipeline-YIBIQ7XK.js.map
16
+ //# sourceMappingURL=pipeline-MQJD4CKN.js.map
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  preflight
3
- } from "./chunk-6I6L3CMX.js";
3
+ } from "./chunk-KGUKL3CV.js";
4
4
  import "./chunk-PZR4EBPY.js";
5
- import "./chunk-DGZWFI2G.js";
5
+ import "./chunk-VBEKL445.js";
6
6
  import "./chunk-F3JWOPTG.js";
7
7
  import "./chunk-VAD43MOR.js";
8
8
  import "./chunk-IY6256GK.js";
9
9
  import "./chunk-HN6I2XWI.js";
10
- import "./chunk-XP5WM2LV.js";
10
+ import "./chunk-SKI23ZZH.js";
11
11
  import "./chunk-GECESMVS.js";
12
- import "./chunk-5UINJNAJ.js";
13
12
  import "./chunk-KJGKZLCT.js";
13
+ import "./chunk-5UINJNAJ.js";
14
14
  import "./chunk-BGTYPVLT.js";
15
15
  import "./chunk-7NYN2P6I.js";
16
16
  import "./chunk-WEKL2HYJ.js";
@@ -67,4 +67,4 @@ async function runPreflightCommand(site, opts) {
67
67
  export {
68
68
  runPreflightCommand
69
69
  };
70
- //# sourceMappingURL=preflight-IMTYDDD4.js.map
70
+ //# sourceMappingURL=preflight-LIN5NCYU.js.map
@@ -1,10 +1,10 @@
1
+ import {
2
+ runRecipeOverSites
3
+ } from "./chunk-VPJ7N6P7.js";
1
4
  import {
2
5
  noWorkingTreeFailure,
3
6
  readPrismicConfig
4
7
  } from "./chunk-VNB5XBQ4.js";
5
- import {
6
- runRecipeOverSites
7
- } from "./chunk-VPJ7N6P7.js";
8
8
  import {
9
9
  appendSkipNotice,
10
10
  fleetWorkdir,
@@ -444,4 +444,4 @@ export {
444
444
  formatPrismicCiResults,
445
445
  runPrismicCiCommand
446
446
  };
447
- //# sourceMappingURL=prismic-ci-MY2U6NN7.js.map
447
+ //# sourceMappingURL=prismic-ci-PZ5LCPWT.js.map