@reddoorla/maintenance 0.85.2 → 0.86.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 (245) hide show
  1. package/README.md +8 -0
  2. package/dist/airtable-G7WBQQMI.js +9 -0
  3. package/dist/{announce-GIAYN67S.js → announce-MXTUQ6C7.js} +26 -19
  4. package/dist/announce-MXTUQ6C7.js.map +1 -0
  5. package/dist/{bump-deps-SWJB6H5V.js → bump-deps-EC74CPLS.js} +9 -9
  6. package/dist/chunk-2EVEFOZY.js +129 -0
  7. package/dist/chunk-2EVEFOZY.js.map +1 -0
  8. package/dist/{chunk-COZPL62X.js → chunk-2NDRHXMR.js} +25 -17
  9. package/dist/chunk-2NDRHXMR.js.map +1 -0
  10. package/dist/{chunk-SDUJIANJ.js → chunk-2NJQLSEU.js} +3 -3
  11. package/dist/chunk-2NQUCS7O.js +243 -0
  12. package/dist/chunk-2NQUCS7O.js.map +1 -0
  13. package/dist/{chunk-DTTIFYAM.js → chunk-2ZPT7GLV.js} +42 -403
  14. package/dist/chunk-2ZPT7GLV.js.map +1 -0
  15. package/dist/{chunk-ZTPPCHDB.js → chunk-3G25KIWW.js} +4 -4
  16. package/dist/chunk-3SF7D4DY.js +359 -0
  17. package/dist/chunk-3SF7D4DY.js.map +1 -0
  18. package/dist/{chunk-Q276MZ7E.js → chunk-3VQWSE3F.js} +4 -4
  19. package/dist/{chunk-37S6L6G4.js → chunk-5UINJNAJ.js} +72 -2
  20. package/dist/chunk-5UINJNAJ.js.map +1 -0
  21. package/dist/{chunk-THEFTZ7F.js → chunk-62CMMGEO.js} +5 -5
  22. package/dist/{chunk-FDIFTIXC.js → chunk-6TWWY7ZU.js} +2 -2
  23. package/dist/{chunk-UYCAF77E.js → chunk-7RJ2HMMJ.js} +3 -3
  24. package/dist/chunk-ACBRLLFT.js +198 -0
  25. package/dist/chunk-ACBRLLFT.js.map +1 -0
  26. package/dist/chunk-BNM5POSJ.js +284 -0
  27. package/dist/chunk-BNM5POSJ.js.map +1 -0
  28. package/dist/{chunk-R6FPFMOS.js → chunk-BQRFQSGY.js} +3 -3
  29. package/dist/{chunk-MGR2H7F4.js → chunk-BYK66EWO.js} +19 -12
  30. package/dist/chunk-BYK66EWO.js.map +1 -0
  31. package/dist/{chunk-6QRLRT3P.js → chunk-CQR4LIM7.js} +12 -265
  32. package/dist/chunk-CQR4LIM7.js.map +1 -0
  33. package/dist/{chunk-SEEA6RXF.js → chunk-DJZWYIPP.js} +2 -2
  34. package/dist/chunk-DJZWYIPP.js.map +1 -0
  35. package/dist/chunk-EVBCK2KC.js +68 -0
  36. package/dist/chunk-EVBCK2KC.js.map +1 -0
  37. package/dist/{chunk-TP5M2NQB.js → chunk-F5KM4LEQ.js} +3 -3
  38. package/dist/{chunk-62VF32IC.js → chunk-ILUNZHYV.js} +2 -2
  39. package/dist/chunk-ITIOFN7A.js +396 -0
  40. package/dist/chunk-ITIOFN7A.js.map +1 -0
  41. package/dist/{chunk-LS6QPANO.js → chunk-IYSEC543.js} +2 -2
  42. package/dist/{chunk-DC5H7KEQ.js → chunk-JHGHLKFS.js} +2 -2
  43. package/dist/{chunk-PBWDDDQH.js → chunk-KTH5ZODA.js} +2 -2
  44. package/dist/{chunk-4DHQCN5H.js → chunk-LBYOLBW7.js} +17 -2
  45. package/dist/chunk-LBYOLBW7.js.map +1 -0
  46. package/dist/{chunk-577HCGZO.js → chunk-LDWZSLSU.js} +38 -23
  47. package/dist/chunk-LDWZSLSU.js.map +1 -0
  48. package/dist/{chunk-LTB6KVJW.js → chunk-N45M3FDK.js} +13 -11
  49. package/dist/{chunk-LTB6KVJW.js.map → chunk-N45M3FDK.js.map} +1 -1
  50. package/dist/chunk-NYUYNYQL.js +48 -0
  51. package/dist/chunk-NYUYNYQL.js.map +1 -0
  52. package/dist/{chunk-7J53SUT6.js → chunk-P2FE5AI6.js} +4 -4
  53. package/dist/{chunk-3YXDSCM6.js → chunk-PPE5KZJK.js} +29 -11
  54. package/dist/chunk-PPE5KZJK.js.map +1 -0
  55. package/dist/chunk-PTDMVGKL.js +31 -0
  56. package/dist/chunk-PTDMVGKL.js.map +1 -0
  57. package/dist/{chunk-D4FVAIEJ.js → chunk-PZR4EBPY.js} +5 -2
  58. package/dist/chunk-PZR4EBPY.js.map +1 -0
  59. package/dist/{chunk-NWB4O5EY.js → chunk-SLUQ7R6I.js} +3 -3
  60. package/dist/chunk-SLUQ7R6I.js.map +1 -0
  61. package/dist/{chunk-GZNBCHAZ.js → chunk-TERE5SDF.js} +4 -4
  62. package/dist/{chunk-ZMIPG6TR.js → chunk-TVL5MVUF.js} +4 -4
  63. package/dist/chunk-UDRHAQT7.js +172 -0
  64. package/dist/chunk-UDRHAQT7.js.map +1 -0
  65. package/dist/chunk-VAD43MOR.js +72 -0
  66. package/dist/chunk-VAD43MOR.js.map +1 -0
  67. package/dist/chunk-VSBFM7DS.js +229 -0
  68. package/dist/chunk-VSBFM7DS.js.map +1 -0
  69. package/dist/chunk-W7Z3BGCI.js +274 -0
  70. package/dist/chunk-W7Z3BGCI.js.map +1 -0
  71. package/dist/chunk-X3B723J4.js +1209 -0
  72. package/dist/chunk-X3B723J4.js.map +1 -0
  73. package/dist/{chunk-VRWUL4TR.js → chunk-XHHMM5HX.js} +2 -2
  74. package/dist/{chunk-RJB3QUSP.js → chunk-XIDUYLSR.js} +3 -3
  75. package/dist/{chunk-QG6OSL4M.js → chunk-XUGSZP7Z.js} +2 -2
  76. package/dist/{chunk-S56JQJ4F.js → chunk-Y53WOQIJ.js} +3 -3
  77. package/dist/{chunk-ICXV25N7.js → chunk-Z3KYFUN6.js} +3 -3
  78. package/dist/{chunk-MPBXOJ3N.js → chunk-Z7AXYKQB.js} +33 -2
  79. package/dist/chunk-Z7AXYKQB.js.map +1 -0
  80. package/dist/{chunk-WYYQK4D3.js → chunk-ZKXSX4LO.js} +11 -11
  81. package/dist/cli/bin.js +46 -28
  82. package/dist/cli/bin.js.map +1 -1
  83. package/dist/cli/commands/audit.d.ts +30 -1
  84. package/dist/cli/commands/audit.js +62 -30
  85. package/dist/cli/commands/audit.js.map +1 -1
  86. package/dist/client-AUE3XUPO.js +11 -0
  87. package/dist/{convert-to-pnpm-AT52NWZB.js → convert-to-pnpm-6L6P74WR.js} +9 -9
  88. package/dist/db-B35OGV3G.js +217 -0
  89. package/dist/db-B35OGV3G.js.map +1 -0
  90. package/dist/{digest-UVHYZUYE.js → digest-BL6UJYKH.js} +23 -20
  91. package/dist/{digest-UVHYZUYE.js.map → digest-BL6UJYKH.js.map} +1 -1
  92. package/dist/dump-P6EBSIOH.js +68 -0
  93. package/dist/dump-P6EBSIOH.js.map +1 -0
  94. package/dist/email-VTTTKKL5.js +195 -0
  95. package/dist/email-VTTTKKL5.js.map +1 -0
  96. package/dist/{ensure-site-S25MDDHW.js → ensure-site-DFTB7MN3.js} +8 -7
  97. package/dist/ensure-site-DFTB7MN3.js.map +1 -0
  98. package/dist/fleet-events-cF2Om88w.d.ts +24 -0
  99. package/dist/{forms-notify-target-TWN4EH6K.js → forms-notify-target-75U6OU7L.js} +38 -132
  100. package/dist/forms-notify-target-75U6OU7L.js.map +1 -0
  101. package/dist/{github-signals-G4ILZAJ6.js → github-signals-IJUPGCUX.js} +40 -19
  102. package/dist/github-signals-IJUPGCUX.js.map +1 -0
  103. package/dist/{header-image-T7XD37JL.js → header-image-AWLLQA4L.js} +34 -11
  104. package/dist/header-image-AWLLQA4L.js.map +1 -0
  105. package/dist/header-images-335L2AKB.js +68 -0
  106. package/dist/header-images-335L2AKB.js.map +1 -0
  107. package/dist/{health-endpoint-242WG2OJ.js → health-endpoint-WJC2UMYS.js} +9 -9
  108. package/dist/health-mirror-4B2L7T2Y.js +75 -0
  109. package/dist/health-mirror-4B2L7T2Y.js.map +1 -0
  110. package/dist/import-airtable-HE43FB4H.js +35 -0
  111. package/dist/index.d.ts +175 -21
  112. package/dist/index.js +115 -73
  113. package/dist/index.js.map +1 -1
  114. package/dist/{init-JN26NTWF.js → init-NJEOEO7I.js} +20 -17
  115. package/dist/{init-JN26NTWF.js.map → init-NJEOEO7I.js.map} +1 -1
  116. package/dist/{launch-JA7Z4CIM.js → launch-XNAX427U.js} +31 -25
  117. package/dist/{launch-JA7Z4CIM.js.map → launch-XNAX427U.js.map} +1 -1
  118. package/dist/lighthouse-VHI77PFB.js +11 -0
  119. package/dist/{lighthouse-airtable-BIPM26SZ.js → lighthouse-airtable-LBVIYYP5.js} +3 -3
  120. package/dist/mailchimp-XYCTEEJY.js +72 -0
  121. package/dist/mailchimp-XYCTEEJY.js.map +1 -0
  122. package/dist/migrate-GQH237A6.js +7 -0
  123. package/dist/notify-C645PGD5.js +22 -0
  124. package/dist/{onboard-53CITIM7.js → onboard-GK4PHPNI.js} +9 -9
  125. package/dist/orchestrate-77UO4BYJ.js +30 -0
  126. package/dist/orchestrate-77UO4BYJ.js.map +1 -0
  127. package/dist/parity-MWS24A3H.js +12 -0
  128. package/dist/parity-MWS24A3H.js.map +1 -0
  129. package/dist/pipeline-S6CVHDGB.js +12 -0
  130. package/dist/pipeline-S6CVHDGB.js.map +1 -0
  131. package/dist/{preflight-3XPDUHFJ.js → preflight-6WBNU2GZ.js} +16 -13
  132. package/dist/{preflight-3XPDUHFJ.js.map → preflight-6WBNU2GZ.js.map} +1 -1
  133. package/dist/{prismic-ci-UTQ6LRR3.js → prismic-ci-3RHOZUUT.js} +15 -15
  134. package/dist/{prismic-models-PVES6R5V.js → prismic-models-QBGUT2Q3.js} +10 -10
  135. package/dist/prospect-audit-IUNCJ2LV.js +174 -0
  136. package/dist/prospect-audit-IUNCJ2LV.js.map +1 -0
  137. package/dist/prospect-audits-3PMIO73D.js +19 -0
  138. package/dist/prospect-audits-3PMIO73D.js.map +1 -0
  139. package/dist/{protection-audit-64PLLBLI.js → protection-audit-SJO53MEQ.js} +3 -3
  140. package/dist/recipes/sync-configs.js +3 -3
  141. package/dist/render-AQAVQDPZ.js +10 -0
  142. package/dist/render-AQAVQDPZ.js.map +1 -0
  143. package/dist/{renovate-dispatch-ICJGSFCE.js → renovate-dispatch-QJY75ODR.js} +8 -8
  144. package/dist/replay-C2LXMJZP.js +66 -0
  145. package/dist/replay-C2LXMJZP.js.map +1 -0
  146. package/dist/{report-6CKSWJNG.js → report-4EVNDHOZ.js} +55 -29
  147. package/dist/report-4EVNDHOZ.js.map +1 -0
  148. package/dist/reports/header-image/assets/headline-announcement.png +0 -0
  149. package/dist/reports/header-image/assets/headline-launch.png +0 -0
  150. package/dist/reports/header-image/assets/headline-maintenance.png +0 -0
  151. package/dist/reports/header-image/assets/headline-testing.png +0 -0
  152. package/dist/reports/header-image/assets/plate-clean.png +0 -0
  153. package/dist/{self-updating-PPQVV6UA.js → self-updating-6DWI2Z56.js} +9 -9
  154. package/dist/{selftest-CQ6NOX52.js → selftest-RC36MTKP.js} +25 -20
  155. package/dist/selftest-RC36MTKP.js.map +1 -0
  156. package/dist/smoke-B2GQOSIZ.js +20 -0
  157. package/dist/smoke-B2GQOSIZ.js.map +1 -0
  158. package/dist/{smoke-suite-TMCSOYRK.js → smoke-suite-VYY2LXM2.js} +9 -9
  159. package/dist/{submissions-GJ6ITBRH.js → submissions-Q7DRFOCD.js} +3 -3
  160. package/dist/{svelte-codemods-ZOBDHIES.js → svelte-codemods-25J2FO22.js} +9 -9
  161. package/dist/sync-34HNZZ56.js +44 -0
  162. package/dist/sync-34HNZZ56.js.map +1 -0
  163. package/dist/{sync-configs-CJXUX6MD.js → sync-configs-3SE6PSCO.js} +9 -9
  164. package/dist/{upgrade-WLX27UPC.js → upgrade-WBRQ62FX.js} +9 -9
  165. package/dist/{webflow-624FEBFD.js → webflow-IRKOIT7S.js} +4 -4
  166. package/dist/webhook-VOGOW3W6.js +38 -0
  167. package/dist/webhook-VOGOW3W6.js.map +1 -0
  168. package/dist/{websites-SADZR4XQ.js → websites-SXWTP72S.js} +6 -2
  169. package/dist/websites-SXWTP72S.js.map +1 -0
  170. package/dist/{write-audits-to-airtable-7PH75YWY.js → write-audits-to-airtable-MBEILLPU.js} +4 -4
  171. package/dist/write-audits-to-airtable-MBEILLPU.js.map +1 -0
  172. package/package.json +5 -2
  173. package/dist/airtable-HRKSA7V4.js +0 -9
  174. package/dist/announce-GIAYN67S.js.map +0 -1
  175. package/dist/chunk-37S6L6G4.js.map +0 -1
  176. package/dist/chunk-3YXDSCM6.js.map +0 -1
  177. package/dist/chunk-4DHQCN5H.js.map +0 -1
  178. package/dist/chunk-4SOCPK7A.js +0 -108
  179. package/dist/chunk-4SOCPK7A.js.map +0 -1
  180. package/dist/chunk-577HCGZO.js.map +0 -1
  181. package/dist/chunk-6QRLRT3P.js.map +0 -1
  182. package/dist/chunk-COZPL62X.js.map +0 -1
  183. package/dist/chunk-D4FVAIEJ.js.map +0 -1
  184. package/dist/chunk-DTTIFYAM.js.map +0 -1
  185. package/dist/chunk-MGR2H7F4.js.map +0 -1
  186. package/dist/chunk-MPBXOJ3N.js.map +0 -1
  187. package/dist/chunk-NWB4O5EY.js.map +0 -1
  188. package/dist/chunk-SEEA6RXF.js.map +0 -1
  189. package/dist/chunk-U5SZ4FOP.js +0 -26
  190. package/dist/chunk-U5SZ4FOP.js.map +0 -1
  191. package/dist/client-X5WUJWDE.js +0 -11
  192. package/dist/db-JSIZYT23.js +0 -23
  193. package/dist/db-JSIZYT23.js.map +0 -1
  194. package/dist/ensure-site-S25MDDHW.js.map +0 -1
  195. package/dist/forms-notify-target-TWN4EH6K.js.map +0 -1
  196. package/dist/github-signals-G4ILZAJ6.js.map +0 -1
  197. package/dist/header-image-T7XD37JL.js.map +0 -1
  198. package/dist/migrate-LJUFGXQZ.js +0 -7
  199. package/dist/orchestrate-KDNXZQX7.js +0 -27
  200. package/dist/report-6CKSWJNG.js.map +0 -1
  201. package/dist/reports/header-image/assets/plate.png +0 -0
  202. package/dist/selftest-CQ6NOX52.js.map +0 -1
  203. /package/dist/{airtable-HRKSA7V4.js.map → airtable-G7WBQQMI.js.map} +0 -0
  204. /package/dist/{bump-deps-SWJB6H5V.js.map → bump-deps-EC74CPLS.js.map} +0 -0
  205. /package/dist/{chunk-SDUJIANJ.js.map → chunk-2NJQLSEU.js.map} +0 -0
  206. /package/dist/{chunk-ZTPPCHDB.js.map → chunk-3G25KIWW.js.map} +0 -0
  207. /package/dist/{chunk-Q276MZ7E.js.map → chunk-3VQWSE3F.js.map} +0 -0
  208. /package/dist/{chunk-THEFTZ7F.js.map → chunk-62CMMGEO.js.map} +0 -0
  209. /package/dist/{chunk-FDIFTIXC.js.map → chunk-6TWWY7ZU.js.map} +0 -0
  210. /package/dist/{chunk-UYCAF77E.js.map → chunk-7RJ2HMMJ.js.map} +0 -0
  211. /package/dist/{chunk-R6FPFMOS.js.map → chunk-BQRFQSGY.js.map} +0 -0
  212. /package/dist/{chunk-TP5M2NQB.js.map → chunk-F5KM4LEQ.js.map} +0 -0
  213. /package/dist/{chunk-62VF32IC.js.map → chunk-ILUNZHYV.js.map} +0 -0
  214. /package/dist/{chunk-LS6QPANO.js.map → chunk-IYSEC543.js.map} +0 -0
  215. /package/dist/{chunk-DC5H7KEQ.js.map → chunk-JHGHLKFS.js.map} +0 -0
  216. /package/dist/{chunk-PBWDDDQH.js.map → chunk-KTH5ZODA.js.map} +0 -0
  217. /package/dist/{chunk-7J53SUT6.js.map → chunk-P2FE5AI6.js.map} +0 -0
  218. /package/dist/{chunk-GZNBCHAZ.js.map → chunk-TERE5SDF.js.map} +0 -0
  219. /package/dist/{chunk-ZMIPG6TR.js.map → chunk-TVL5MVUF.js.map} +0 -0
  220. /package/dist/{chunk-VRWUL4TR.js.map → chunk-XHHMM5HX.js.map} +0 -0
  221. /package/dist/{chunk-RJB3QUSP.js.map → chunk-XIDUYLSR.js.map} +0 -0
  222. /package/dist/{chunk-QG6OSL4M.js.map → chunk-XUGSZP7Z.js.map} +0 -0
  223. /package/dist/{chunk-S56JQJ4F.js.map → chunk-Y53WOQIJ.js.map} +0 -0
  224. /package/dist/{chunk-ICXV25N7.js.map → chunk-Z3KYFUN6.js.map} +0 -0
  225. /package/dist/{chunk-WYYQK4D3.js.map → chunk-ZKXSX4LO.js.map} +0 -0
  226. /package/dist/{client-X5WUJWDE.js.map → client-AUE3XUPO.js.map} +0 -0
  227. /package/dist/{convert-to-pnpm-AT52NWZB.js.map → convert-to-pnpm-6L6P74WR.js.map} +0 -0
  228. /package/dist/{health-endpoint-242WG2OJ.js.map → health-endpoint-WJC2UMYS.js.map} +0 -0
  229. /package/dist/{lighthouse-airtable-BIPM26SZ.js.map → import-airtable-HE43FB4H.js.map} +0 -0
  230. /package/dist/{migrate-LJUFGXQZ.js.map → lighthouse-VHI77PFB.js.map} +0 -0
  231. /package/dist/{orchestrate-KDNXZQX7.js.map → lighthouse-airtable-LBVIYYP5.js.map} +0 -0
  232. /package/dist/{websites-SADZR4XQ.js.map → migrate-GQH237A6.js.map} +0 -0
  233. /package/dist/{write-audits-to-airtable-7PH75YWY.js.map → notify-C645PGD5.js.map} +0 -0
  234. /package/dist/{onboard-53CITIM7.js.map → onboard-GK4PHPNI.js.map} +0 -0
  235. /package/dist/{prismic-ci-UTQ6LRR3.js.map → prismic-ci-3RHOZUUT.js.map} +0 -0
  236. /package/dist/{prismic-models-PVES6R5V.js.map → prismic-models-QBGUT2Q3.js.map} +0 -0
  237. /package/dist/{protection-audit-64PLLBLI.js.map → protection-audit-SJO53MEQ.js.map} +0 -0
  238. /package/dist/{renovate-dispatch-ICJGSFCE.js.map → renovate-dispatch-QJY75ODR.js.map} +0 -0
  239. /package/dist/{self-updating-PPQVV6UA.js.map → self-updating-6DWI2Z56.js.map} +0 -0
  240. /package/dist/{smoke-suite-TMCSOYRK.js.map → smoke-suite-VYY2LXM2.js.map} +0 -0
  241. /package/dist/{submissions-GJ6ITBRH.js.map → submissions-Q7DRFOCD.js.map} +0 -0
  242. /package/dist/{svelte-codemods-ZOBDHIES.js.map → svelte-codemods-25J2FO22.js.map} +0 -0
  243. /package/dist/{sync-configs-CJXUX6MD.js.map → sync-configs-3SE6PSCO.js.map} +0 -0
  244. /package/dist/{upgrade-WLX27UPC.js.map → upgrade-WBRQ62FX.js.map} +0 -0
  245. /package/dist/{webflow-624FEBFD.js.map → webflow-IRKOIT7S.js.map} +0 -0
@@ -0,0 +1,396 @@
1
+ import {
2
+ MAINTENANCE_CHECKLIST,
3
+ TESTING_CHECKLIST
4
+ } from "./chunk-VAD43MOR.js";
5
+ import {
6
+ siteSlug
7
+ } from "./chunk-LDWZSLSU.js";
8
+
9
+ // src/db/import-airtable.ts
10
+ var EXCLUDED_WEBSITE_FIELDS = /* @__PURE__ */ new Set([
11
+ // Dropped under D4's rule (empty everywhere + unreferenced), verified 2026-08-23.
12
+ "site host username",
13
+ "site host password",
14
+ "launch day",
15
+ "contract link",
16
+ // Plaintext credentials — operator ruling 2026-08-23: these live on ONLY in
17
+ // the frozen Airtable base. A new store does not inherit plaintext creds.
18
+ "DNS username",
19
+ "DNS password",
20
+ "cms username",
21
+ "cms password",
22
+ // Link columns: Turso joins by rec id (D1); the links carry no extra data.
23
+ "Reports",
24
+ "Submissions",
25
+ "Spam Screenouts",
26
+ // Regenerated into sites.header_image as a BLOB by the header-image CLI (D5);
27
+ // the Airtable attachment (an expiring signed URL) is never migrated.
28
+ "Header image"
29
+ ]);
30
+ var s = (v) => {
31
+ if (v === void 0 || v === null) return null;
32
+ if (typeof v === "string") return v.trim() === "" ? null : v;
33
+ return String(v);
34
+ };
35
+ var n = (v) => typeof v === "number" ? v : null;
36
+ var b01 = (v) => v === true ? 1 : 0;
37
+ var b01n = (v) => typeof v === "boolean" ? v ? 1 : 0 : null;
38
+ var json = (v) => v === void 0 ? null : JSON.stringify(v);
39
+ var SITE_FIELDS = {
40
+ Name: "name",
41
+ url: "url",
42
+ Status: "status",
43
+ "point of contact": "point_of_contact",
44
+ "maintenence freq": "maintenance_freq",
45
+ // Airtable's misspelling dies at this boundary
46
+ "testing freq": "testing_freq",
47
+ "maintenance day": "maintenance_day",
48
+ "testing day": "testing_day",
49
+ "GA4 property ID": "ga4_property_id",
50
+ "Search query": "search_query",
51
+ "Search Console property": "search_console_property",
52
+ "Git repo": "git_repo",
53
+ "Netlify ID": "netlify_id",
54
+ "Report recipients (To)": "report_recipients_to",
55
+ "Report recipients (CC)": "report_recipients_cc",
56
+ "Copy \u2014 Intro": "copy_intro",
57
+ "Copy \u2014 Contact": "copy_contact",
58
+ "Copy \u2014 Footer": "copy_footer",
59
+ "Newsletter Webhook": "newsletter_webhook",
60
+ "Mailchimp API Key": "mailchimp_api_key",
61
+ "Mailchimp Audience ID": "mailchimp_audience_id",
62
+ "Notify Routing": "notify_routing",
63
+ "Prismic Ack Until": "prismic_ack_until",
64
+ "Launched at": "launched_at"
65
+ };
66
+ var HEALTH_FIELDS = {
67
+ pScore: "p_score",
68
+ rScore: "r_score",
69
+ bpScore: "bp_score",
70
+ seoScore: "seo_score",
71
+ "Last lighthouse audit at": "lighthouse_at",
72
+ "A11y Violations": "a11y_violations",
73
+ "Deps Drifted": "deps_drifted",
74
+ "Deps Major Behind": "deps_major_behind",
75
+ "Deps Outdated": "deps_outdated",
76
+ "Deps Major Outdated": "deps_major_outdated",
77
+ "Security Vulns Critical": "vulns_critical",
78
+ "Security Vulns High": "vulns_high",
79
+ "Security Vulns Moderate": "vulns_moderate",
80
+ "Security Vulns Low": "vulns_low",
81
+ "Last security audit at": "security_audit_at",
82
+ "Security advisories": "security_advisories",
83
+ "Security Auto-Fix Attempts": "auto_fix_attempts",
84
+ "Analytics soft-fail at": "analytics_soft_fail_at",
85
+ "Cert days remaining": "cert_days_remaining",
86
+ "Domain checked at": "domain_checked_at",
87
+ "Deploy status": "deploy_status",
88
+ "Last deploy at": "last_deploy_at",
89
+ "Deploy log URL": "deploy_log_url",
90
+ "Deploy checked at": "deploy_checked_at",
91
+ "Function health": "function_health",
92
+ "CMS Reachable": "cms_reachable",
93
+ "Turnstile widget": "turnstile_widget",
94
+ "Function health checked at": "function_health_checked_at",
95
+ "Broken links": "broken_links",
96
+ "Browser checked at": "browser_checked_at",
97
+ "Uptime Reachable": "uptime_reachable",
98
+ "Titles & Meta OK": "titles_meta_ok",
99
+ "Smoke OK": "smoke_ok",
100
+ "Last Smoke At": "last_smoke_at",
101
+ "Form E2E OK": "form_e2e_ok",
102
+ "Form E2E checked at": "form_e2e_checked_at",
103
+ "Renovate Failing CIs": "renovate_failing_cis",
104
+ "Default Branch CI": "default_branch_ci",
105
+ "Last Commit At": "last_commit_at",
106
+ "GitHub Signals At": "github_signals_at",
107
+ "Prismic Models": "prismic_models",
108
+ "Prismic Models Checked At": "prismic_models_checked_at",
109
+ "Prismic Models Drift": "prismic_models_drift"
110
+ };
111
+ var HEALTH_NUMERIC = /* @__PURE__ */ new Set([
112
+ "p_score",
113
+ "r_score",
114
+ "bp_score",
115
+ "seo_score",
116
+ "a11y_violations",
117
+ "deps_drifted",
118
+ "deps_major_behind",
119
+ "deps_outdated",
120
+ "deps_major_outdated",
121
+ "vulns_critical",
122
+ "vulns_high",
123
+ "vulns_moderate",
124
+ "vulns_low",
125
+ "auto_fix_attempts",
126
+ "cert_days_remaining",
127
+ "broken_links",
128
+ "renovate_failing_cis"
129
+ ]);
130
+ var HEALTH_BOOLEAN = {
131
+ "Crossbrowser OK": "crossbrowser_ok",
132
+ "Mobile OK": "mobile_ok",
133
+ "Links OK": "links_ok"
134
+ };
135
+ var SCHEDULE_FIELDS = {
136
+ "Next maintenance at": "next_maintenance_at",
137
+ "Next testing at": "next_testing_at"
138
+ };
139
+ function healthColumnFor(field) {
140
+ const direct = HEALTH_FIELDS[field];
141
+ if (direct) return { col: direct, coerce: HEALTH_NUMERIC.has(direct) ? n : s };
142
+ const bool = HEALTH_BOOLEAN[field];
143
+ if (bool) return { col: bool, coerce: b01n };
144
+ return null;
145
+ }
146
+ function scheduleColumnFor(field) {
147
+ const col = SCHEDULE_FIELDS[field];
148
+ return col ? { col, coerce: s } : null;
149
+ }
150
+ function mapWebsiteRecord(rec, computedAt) {
151
+ const f = rec.fields;
152
+ const name = s(f["Name"]);
153
+ if (!name) throw new Error(`Websites ${rec.id}: blank Name \u2014 cannot derive a slug`);
154
+ const slug = siteSlug(name);
155
+ if (!slug) throw new Error(`Websites ${rec.id}: Name "${name}" yields an empty slug`);
156
+ const awcRaw = f["Accepted Watch Conditions"];
157
+ const awc = Array.isArray(awcRaw) ? awcRaw.filter((x) => typeof x === "string").map((x) => x.trim()).filter(Boolean) : typeof awcRaw === "string" ? awcRaw.split(/[\n,]/).map((x) => x.trim()).filter(Boolean) : [];
158
+ const site = {
159
+ id: rec.id,
160
+ slug,
161
+ name,
162
+ url: null,
163
+ status: null,
164
+ point_of_contact: null,
165
+ maintenance_freq: null,
166
+ testing_freq: null,
167
+ maintenance_day: null,
168
+ testing_day: null,
169
+ ga4_property_id: null,
170
+ search_query: null,
171
+ search_console_property: null,
172
+ git_repo: null,
173
+ netlify_id: null,
174
+ report_recipients_to: null,
175
+ report_recipients_cc: null,
176
+ copy_intro: null,
177
+ copy_contact: null,
178
+ copy_footer: null,
179
+ newsletter_webhook: null,
180
+ mailchimp_api_key: null,
181
+ mailchimp_audience_id: null,
182
+ notify_routing: null,
183
+ require_turnstile: b01(f["Require Turnstile"]),
184
+ accepted_watch_conditions: awc.length > 0 ? JSON.stringify(awc) : null,
185
+ prismic_ack_until: null,
186
+ launched_at: null,
187
+ legacy: null
188
+ };
189
+ for (const [field, col] of Object.entries(SITE_FIELDS)) {
190
+ if (col === "name") continue;
191
+ site[col] = s(f[field]);
192
+ }
193
+ const health = { site_id: rec.id };
194
+ for (const field of [...Object.keys(HEALTH_FIELDS), ...Object.keys(HEALTH_BOOLEAN)]) {
195
+ const m = healthColumnFor(field);
196
+ if (m) health[m.col] = m.coerce(f[field]);
197
+ }
198
+ const schedule = {
199
+ site_id: rec.id,
200
+ next_maintenance_at: s(f["Next maintenance at"]),
201
+ next_testing_at: s(f["Next testing at"]),
202
+ computed_at: computedAt
203
+ };
204
+ const claimed = /* @__PURE__ */ new Set([
205
+ "Name",
206
+ "Require Turnstile",
207
+ "Accepted Watch Conditions",
208
+ ...Object.keys(SITE_FIELDS),
209
+ ...Object.keys(HEALTH_FIELDS),
210
+ ...Object.keys(HEALTH_BOOLEAN),
211
+ ...Object.keys(SCHEDULE_FIELDS)
212
+ ]);
213
+ const legacy = {};
214
+ for (const [field, value] of Object.entries(f)) {
215
+ if (claimed.has(field) || EXCLUDED_WEBSITE_FIELDS.has(field)) continue;
216
+ legacy[field] = value;
217
+ }
218
+ site.legacy = Object.keys(legacy).length > 0 ? JSON.stringify(legacy) : null;
219
+ return { site, health, schedule };
220
+ }
221
+ var CHECKLIST_BY_FIELD = [
222
+ ...MAINTENANCE_CHECKLIST,
223
+ ...TESTING_CHECKLIST
224
+ ].map((i) => ({ field: i.field, key: i.key }));
225
+ function mapReportRecord(rec, renderedHtml) {
226
+ const f = rec.fields;
227
+ const linkSites = f["Site"] ?? [];
228
+ const checklist = {};
229
+ for (const { field, key } of CHECKLIST_BY_FIELD) checklist[key] = Boolean(f[field]);
230
+ return {
231
+ id: rec.id,
232
+ site_id: linkSites[0] ?? null,
233
+ report_id: s(f["Report ID"]),
234
+ report_type: s(f["Report type"]),
235
+ period: s(f["Period"]),
236
+ period_start: s(f["Period start"]),
237
+ period_end: s(f["Period end"]),
238
+ completed_on: s(f["Completed on"]),
239
+ lighthouse_performance: n(f["Lighthouse \u2014 Performance"]),
240
+ lighthouse_accessibility: n(f["Lighthouse \u2014 Accessibility"]),
241
+ lighthouse_best_practices: n(f["Lighthouse \u2014 Best Practices"]),
242
+ lighthouse_seo: n(f["Lighthouse \u2014 SEO"]),
243
+ ga_users_current: n(f["GA users (period)"]),
244
+ ga_users_previous: n(f["GA users (prev period)"]),
245
+ search_found_page1: b01n(f["Search found page 1"]),
246
+ search_position: n(f["Search position"]),
247
+ last_tested_date: s(f["Last tested date"]),
248
+ commentary: s(f["Commentary"]),
249
+ subject_override: s(f["Subject override"]),
250
+ draft_ready: b01(f["Draft ready"]),
251
+ approved_to_send: b01(f["Approved to send"]),
252
+ approved_at: s(f["Approved At"]),
253
+ approved_by: s(f["Approved By"]),
254
+ send_override: b01(f["Send override"]),
255
+ override_reason: s(f["Override reason"]),
256
+ override_by: s(f["Override by"]),
257
+ override_at: s(f["Override at"]),
258
+ sent_at: s(f["Sent at"]),
259
+ delivery_status: s(f["Delivery status"]) ?? "pending",
260
+ resend_message_id: s(f["Resend message ID"]),
261
+ checklist: JSON.stringify(checklist),
262
+ // The Airtable cell is a long-text field, so the API hands us a STRING of
263
+ // JSON — store it verbatim. json() here would double-encode it, and
264
+ // parseAutoEvidence on the read side would then parse to a string and
265
+ // yield null (evidence silently lost). The non-string branch only exists
266
+ // for defensive completeness.
267
+ checklist_auto_evidence: typeof f["Checklist auto-evidence"] === "string" ? s(f["Checklist auto-evidence"]) : json(f["Checklist auto-evidence"] ?? void 0),
268
+ rendered_html: renderedHtml
269
+ };
270
+ }
271
+ function renderedHtmlUrl(rec) {
272
+ const atts = rec.fields["Rendered HTML"];
273
+ const url = atts?.[0]?.url;
274
+ return typeof url === "string" && url.length > 0 ? url : null;
275
+ }
276
+ var REAP_FLOOR = 5;
277
+ var REAP_FRACTION = 0.1;
278
+ function reapAllowance(stored) {
279
+ return Math.max(REAP_FLOOR, Math.ceil(stored * REAP_FRACTION));
280
+ }
281
+ function formatReapSummary(reaped) {
282
+ const lines = [];
283
+ for (const id of reaped.sites) {
284
+ lines.push(`\u2702 reaped sites ${id} (+ its health/schedule rows) \u2014 no longer in Airtable`);
285
+ }
286
+ for (const id of reaped.reports) {
287
+ lines.push(`\u2702 reaped reports ${id} \u2014 no longer in Airtable`);
288
+ }
289
+ for (const reason of reaped.refusals) lines.push(`\u26A0 ${reason}`);
290
+ lines.push(
291
+ `FLEET_REAP sites=${reaped.sites.length} reports=${reaped.reports.length} refused=${reaped.refusals.length}`
292
+ );
293
+ return lines;
294
+ }
295
+ function reapRefusal(table, incoming, stored, toReap) {
296
+ if (incoming === 0 && stored > 0) {
297
+ return `${table}: REFUSED to reap \u2014 Airtable returned 0 rows while ${stored} are stored; that is a failed read, not an empty fleet. Nothing deleted.`;
298
+ }
299
+ const allowed = reapAllowance(stored);
300
+ if (toReap > allowed) {
301
+ return `${table}: REFUSED to reap \u2014 ${toReap} rows are missing from Airtable, over the ${allowed}-row allowance for ${stored} stored. Nothing deleted; re-run, and if the deletions are real, remove them in smaller batches.`;
302
+ }
303
+ return null;
304
+ }
305
+ async function importFleetState(db, io, opts = {}) {
306
+ const computedAt = io.now().toISOString();
307
+ const websites = await io.listWebsiteRecords();
308
+ const mapped = websites.map((r) => mapWebsiteRecord(r, computedAt));
309
+ const slugOwner = /* @__PURE__ */ new Map();
310
+ for (const m of mapped) {
311
+ const prior = slugOwner.get(m.site.slug);
312
+ if (prior)
313
+ throw new Error(`slug collision: ${prior} and ${m.site.id} both map to '${m.site.slug}'`);
314
+ slugOwner.set(m.site.slug, m.site.id);
315
+ }
316
+ for (const { site, health, schedule } of mapped) {
317
+ await db.insertInto("sites").values(site).onConflict((oc) => oc.column("id").doUpdateSet(site)).execute();
318
+ await db.insertInto("site_health").values(health).onConflict((oc) => oc.column("site_id").doUpdateSet(health)).execute();
319
+ await db.insertInto("site_schedule").values(schedule).onConflict((oc) => oc.column("site_id").doUpdateSet(schedule)).execute();
320
+ }
321
+ const reports = await io.listReportRecords();
322
+ const alreadyStored = opts.reportHtml === "when-missing" ? new Set(
323
+ (await db.selectFrom("reports").select("id").where("rendered_html", "is not", null).execute()).map((r) => r.id)
324
+ ) : null;
325
+ const misses = [];
326
+ let fetched = 0;
327
+ let skipped = 0;
328
+ for (const rec of reports) {
329
+ const url = renderedHtmlUrl(rec);
330
+ const skip = url !== null && alreadyStored !== null && alreadyStored.has(rec.id);
331
+ if (skip) skipped++;
332
+ const html = url && !skip ? await io.fetchAttachment(url) : null;
333
+ if (url && !skip && html === null) misses.push(rec.id);
334
+ if (html !== null) fetched++;
335
+ const row = mapReportRecord(rec, html);
336
+ const { rendered_html: _rh, ...rowSansHtml } = row;
337
+ void _rh;
338
+ await db.insertInto("reports").values(row).onConflict((oc) => oc.column("id").doUpdateSet(html !== null ? row : rowSansHtml)).execute();
339
+ }
340
+ const reaped = { sites: [], reports: [], refusals: [] };
341
+ const liveSiteIds = new Set(mapped.map((m) => m.site.id));
342
+ const storedSites = (await db.selectFrom("sites").select("id").execute()).map(
343
+ (r) => String(r.id)
344
+ );
345
+ const staleSites = storedSites.filter((id) => !liveSiteIds.has(id)).sort();
346
+ const siteRefusal = reapRefusal("sites", websites.length, storedSites.length, staleSites.length);
347
+ if (siteRefusal) reaped.refusals.push(siteRefusal);
348
+ else if (staleSites.length > 0) {
349
+ await db.deleteFrom("site_health").where("site_id", "in", staleSites).execute();
350
+ await db.deleteFrom("site_schedule").where("site_id", "in", staleSites).execute();
351
+ await db.deleteFrom("sites").where("id", "in", staleSites).execute();
352
+ reaped.sites = staleSites;
353
+ }
354
+ const liveReportIds = new Set(reports.map((r) => r.id));
355
+ const storedReports = (await db.selectFrom("reports").select("id").execute()).map(
356
+ (r) => String(r.id)
357
+ );
358
+ const staleReports = storedReports.filter((id) => !liveReportIds.has(id)).sort();
359
+ const reportRefusal = reapRefusal(
360
+ "reports",
361
+ reports.length,
362
+ storedReports.length,
363
+ staleReports.length
364
+ );
365
+ if (reportRefusal) reaped.refusals.push(reportRefusal);
366
+ else if (staleReports.length > 0) {
367
+ await db.deleteFrom("reports").where("id", "in", staleReports).execute();
368
+ reaped.reports = staleReports;
369
+ }
370
+ return {
371
+ sites: mapped.length,
372
+ reports: reports.length,
373
+ renderedHtmlMisses: misses,
374
+ renderedHtmlFetched: fetched,
375
+ renderedHtmlSkipped: skipped,
376
+ reaped
377
+ };
378
+ }
379
+
380
+ export {
381
+ EXCLUDED_WEBSITE_FIELDS,
382
+ SITE_FIELDS,
383
+ HEALTH_FIELDS,
384
+ HEALTH_BOOLEAN,
385
+ SCHEDULE_FIELDS,
386
+ healthColumnFor,
387
+ scheduleColumnFor,
388
+ mapWebsiteRecord,
389
+ mapReportRecord,
390
+ renderedHtmlUrl,
391
+ reapAllowance,
392
+ formatReapSummary,
393
+ reapRefusal,
394
+ importFleetState
395
+ };
396
+ //# sourceMappingURL=chunk-ITIOFN7A.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/db/import-airtable.ts"],"sourcesContent":["import type { Db } from \"./client.js\";\nimport type { SitesTable, SiteHealthTable, SiteScheduleTable, ReportsTable } from \"./schema.js\";\nimport { siteSlug } from \"../reports/airtable/websites.js\";\nimport { MAINTENANCE_CHECKLIST, TESTING_CHECKLIST } from \"../reports/checklist.js\";\n\n/** One raw Airtable record: id + the fields object exactly as the API returns it\n * (empty cells are ABSENT, not null — the API omits them). */\nexport type RawRecord = { id: string; fields: Record<string, unknown> };\n\n/**\n * Phase 1.3 of #539: map raw Airtable records into the 0007 fleet-state tables,\n * and upsert them idempotently.\n *\n * The mapping here is the SINGLE source of truth for Airtable-column →\n * Turso-column: the parity harness (`db parity`) imports these same functions,\n * so \"what the importer writes\" and \"what parity expects\" cannot drift apart.\n *\n * Values are stored RAW (the cell as Airtable returns it, stringified where the\n * column is TEXT). Coercion — `toFrequency`, `toVerdict`, recipient splitting —\n * stays in the READ layer, exactly as `mapRow` does it today, so the store\n * never bakes in a lossy interpretation. The two exceptions are shapes, not\n * meanings: `Accepted Watch Conditions` normalizes to a JSON array (mapRow\n * accepts array or delimited string; the new store keeps one shape), and the\n * report checklist re-keys from Airtable column names to the stable keys in\n * src/reports/checklist.ts.\n */\n\n/** Websites columns that must NEVER reach Turso, and why. Everything else that\n * is populated but unmapped lands in `sites.legacy` (JSON, keyed by original\n * column name) so no data is silently dropped. */\nexport const EXCLUDED_WEBSITE_FIELDS: ReadonlySet<string> = new Set([\n // Dropped under D4's rule (empty everywhere + unreferenced), verified 2026-08-23.\n \"site host username\",\n \"site host password\",\n \"launch day\",\n \"contract link\",\n // Plaintext credentials — operator ruling 2026-08-23: these live on ONLY in\n // the frozen Airtable base. A new store does not inherit plaintext creds.\n \"DNS username\",\n \"DNS password\",\n \"cms username\",\n \"cms password\",\n // Link columns: Turso joins by rec id (D1); the links carry no extra data.\n \"Reports\",\n \"Submissions\",\n \"Spam Screenouts\",\n // Regenerated into sites.header_image as a BLOB by the header-image CLI (D5);\n // the Airtable attachment (an expiring signed URL) is never migrated.\n \"Header image\",\n]);\n\nconst s = (v: unknown): string | null => {\n if (v === undefined || v === null) return null;\n if (typeof v === \"string\") return v.trim() === \"\" ? null : v;\n return String(v);\n};\nconst n = (v: unknown): number | null => (typeof v === \"number\" ? v : null);\nconst b01 = (v: unknown): number => (v === true ? 1 : 0);\nconst b01n = (v: unknown): number | null => (typeof v === \"boolean\" ? (v ? 1 : 0) : null);\nconst json = (v: unknown): string | null => (v === undefined ? null : JSON.stringify(v));\n\n/** Direct field→column map for `sites` (operator-owned config). Exported for\n * the site-details write-through (fleet-state.mirrorSiteField), so the editor\n * and the importer share ONE Airtable-column → sites-column truth. */\nexport const SITE_FIELDS: Record<string, keyof SitesTable> = {\n Name: \"name\",\n url: \"url\",\n Status: \"status\",\n \"point of contact\": \"point_of_contact\",\n \"maintenence freq\": \"maintenance_freq\", // Airtable's misspelling dies at this boundary\n \"testing freq\": \"testing_freq\",\n \"maintenance day\": \"maintenance_day\",\n \"testing day\": \"testing_day\",\n \"GA4 property ID\": \"ga4_property_id\",\n \"Search query\": \"search_query\",\n \"Search Console property\": \"search_console_property\",\n \"Git repo\": \"git_repo\",\n \"Netlify ID\": \"netlify_id\",\n \"Report recipients (To)\": \"report_recipients_to\",\n \"Report recipients (CC)\": \"report_recipients_cc\",\n \"Copy — Intro\": \"copy_intro\",\n \"Copy — Contact\": \"copy_contact\",\n \"Copy — Footer\": \"copy_footer\",\n \"Newsletter Webhook\": \"newsletter_webhook\",\n \"Mailchimp API Key\": \"mailchimp_api_key\",\n \"Mailchimp Audience ID\": \"mailchimp_audience_id\",\n \"Notify Routing\": \"notify_routing\",\n \"Prismic Ack Until\": \"prismic_ack_until\",\n \"Launched at\": \"launched_at\",\n};\n\n/** Direct field→column map for `site_health` (nightly-cron-owned). Exported for\n * the Phase 3 writer mirrors (fleet-state.mirrorHealthFields) and their\n * lockstep tests, so the nightly writers and the importer share ONE\n * Airtable-column → site_health-column truth. */\nexport const HEALTH_FIELDS: Record<string, keyof SiteHealthTable> = {\n pScore: \"p_score\",\n rScore: \"r_score\",\n bpScore: \"bp_score\",\n seoScore: \"seo_score\",\n \"Last lighthouse audit at\": \"lighthouse_at\",\n \"A11y Violations\": \"a11y_violations\",\n \"Deps Drifted\": \"deps_drifted\",\n \"Deps Major Behind\": \"deps_major_behind\",\n \"Deps Outdated\": \"deps_outdated\",\n \"Deps Major Outdated\": \"deps_major_outdated\",\n \"Security Vulns Critical\": \"vulns_critical\",\n \"Security Vulns High\": \"vulns_high\",\n \"Security Vulns Moderate\": \"vulns_moderate\",\n \"Security Vulns Low\": \"vulns_low\",\n \"Last security audit at\": \"security_audit_at\",\n \"Security advisories\": \"security_advisories\",\n \"Security Auto-Fix Attempts\": \"auto_fix_attempts\",\n \"Analytics soft-fail at\": \"analytics_soft_fail_at\",\n \"Cert days remaining\": \"cert_days_remaining\",\n \"Domain checked at\": \"domain_checked_at\",\n \"Deploy status\": \"deploy_status\",\n \"Last deploy at\": \"last_deploy_at\",\n \"Deploy log URL\": \"deploy_log_url\",\n \"Deploy checked at\": \"deploy_checked_at\",\n \"Function health\": \"function_health\",\n \"CMS Reachable\": \"cms_reachable\",\n \"Turnstile widget\": \"turnstile_widget\",\n \"Function health checked at\": \"function_health_checked_at\",\n \"Broken links\": \"broken_links\",\n \"Browser checked at\": \"browser_checked_at\",\n \"Uptime Reachable\": \"uptime_reachable\",\n \"Titles & Meta OK\": \"titles_meta_ok\",\n \"Smoke OK\": \"smoke_ok\",\n \"Last Smoke At\": \"last_smoke_at\",\n \"Form E2E OK\": \"form_e2e_ok\",\n \"Form E2E checked at\": \"form_e2e_checked_at\",\n \"Renovate Failing CIs\": \"renovate_failing_cis\",\n \"Default Branch CI\": \"default_branch_ci\",\n \"Last Commit At\": \"last_commit_at\",\n \"GitHub Signals At\": \"github_signals_at\",\n \"Prismic Models\": \"prismic_models\",\n \"Prismic Models Checked At\": \"prismic_models_checked_at\",\n \"Prismic Models Drift\": \"prismic_models_drift\",\n};\n\n/** Numeric health columns (everything else in HEALTH_FIELDS stores as text). */\nconst HEALTH_NUMERIC: ReadonlySet<keyof SiteHealthTable> = new Set([\n \"p_score\",\n \"r_score\",\n \"bp_score\",\n \"seo_score\",\n \"a11y_violations\",\n \"deps_drifted\",\n \"deps_major_behind\",\n \"deps_outdated\",\n \"deps_major_outdated\",\n \"vulns_critical\",\n \"vulns_high\",\n \"vulns_moderate\",\n \"vulns_low\",\n \"auto_fix_attempts\",\n \"cert_days_remaining\",\n \"broken_links\",\n \"renovate_failing_cis\",\n]);\n\n/** Boolean-checkbox health columns (Airtable true/absent → 1/0/null). */\nexport const HEALTH_BOOLEAN: Record<string, keyof SiteHealthTable> = {\n \"Crossbrowser OK\": \"crossbrowser_ok\",\n \"Mobile OK\": \"mobile_ok\",\n \"Links OK\": \"links_ok\",\n};\n\n/** Fields consumed by the schedule table. */\nexport const SCHEDULE_FIELDS: Record<string, keyof SiteScheduleTable> = {\n \"Next maintenance at\": \"next_maintenance_at\",\n \"Next testing at\": \"next_testing_at\",\n};\n\n/** Resolve one Airtable health field to its site_health column AND the exact\n * coercion the importer applies to it. The ONE shared path between\n * mapWebsiteRecord (full-row import) and fleet-state.mirrorHealthFields\n * (partial write-through): a coercion that exists twice will eventually\n * disagree, and the hourly import silently papers over the loser. Returns\n * null for a field no health column claims. */\nexport function healthColumnFor(\n field: string,\n): { col: keyof SiteHealthTable; coerce: (v: unknown) => string | number | null } | null {\n const direct = HEALTH_FIELDS[field];\n if (direct) return { col: direct, coerce: HEALTH_NUMERIC.has(direct) ? n : s };\n const bool = HEALTH_BOOLEAN[field];\n if (bool) return { col: bool, coerce: b01n };\n return null;\n}\n\n/** The schedule twin of {@link healthColumnFor} (both columns store as text). */\nexport function scheduleColumnFor(\n field: string,\n): { col: keyof SiteScheduleTable; coerce: (v: unknown) => string | null } | null {\n const col = SCHEDULE_FIELDS[field];\n return col ? { col, coerce: s } : null;\n}\n\nexport type MappedWebsite = {\n site: Omit<\n SitesTable,\n \"header_image\" | \"header_image_filename\" | \"header_image_type\" | \"header_image_generated_at\"\n >;\n health: SiteHealthTable;\n schedule: SiteScheduleTable;\n};\n\n/** Map one raw Websites record into its three-table shape. Pure. */\nexport function mapWebsiteRecord(rec: RawRecord, computedAt: string): MappedWebsite {\n const f = rec.fields;\n const name = s(f[\"Name\"]);\n if (!name) throw new Error(`Websites ${rec.id}: blank Name — cannot derive a slug`);\n const slug = siteSlug(name);\n if (!slug) throw new Error(`Websites ${rec.id}: Name \"${name}\" yields an empty slug`);\n\n // Accepted Watch Conditions: array or delimited string in Airtable → one\n // canonical JSON array here (same trimming mapRow applies at read time).\n const awcRaw = f[\"Accepted Watch Conditions\"];\n const awc = Array.isArray(awcRaw)\n ? awcRaw\n .filter((x): x is string => typeof x === \"string\")\n .map((x) => x.trim())\n .filter(Boolean)\n : typeof awcRaw === \"string\"\n ? awcRaw\n .split(/[\\n,]/)\n .map((x) => x.trim())\n .filter(Boolean)\n : [];\n\n const site: MappedWebsite[\"site\"] = {\n id: rec.id,\n slug,\n name,\n url: null,\n status: null,\n point_of_contact: null,\n maintenance_freq: null,\n testing_freq: null,\n maintenance_day: null,\n testing_day: null,\n ga4_property_id: null,\n search_query: null,\n search_console_property: null,\n git_repo: null,\n netlify_id: null,\n report_recipients_to: null,\n report_recipients_cc: null,\n copy_intro: null,\n copy_contact: null,\n copy_footer: null,\n newsletter_webhook: null,\n mailchimp_api_key: null,\n mailchimp_audience_id: null,\n notify_routing: null,\n require_turnstile: b01(f[\"Require Turnstile\"]),\n accepted_watch_conditions: awc.length > 0 ? JSON.stringify(awc) : null,\n prismic_ack_until: null,\n launched_at: null,\n legacy: null,\n };\n for (const [field, col] of Object.entries(SITE_FIELDS)) {\n if (col === \"name\") continue; // handled above (validated)\n (site as unknown as Record<string, unknown>)[col] = s(f[field]);\n }\n\n const health = { site_id: rec.id } as SiteHealthTable;\n // Through healthColumnFor — the SAME resolution+coercion the Phase 3 writer\n // mirrors use, so import and write-through cannot drift apart.\n for (const field of [...Object.keys(HEALTH_FIELDS), ...Object.keys(HEALTH_BOOLEAN)]) {\n const m = healthColumnFor(field);\n if (m) (health as unknown as Record<string, unknown>)[m.col] = m.coerce(f[field]);\n }\n\n const schedule: SiteScheduleTable = {\n site_id: rec.id,\n next_maintenance_at: s(f[\"Next maintenance at\"]),\n next_testing_at: s(f[\"Next testing at\"]),\n computed_at: computedAt,\n };\n\n // Everything populated that no table claims and no exclusion bans → legacy.\n const claimed = new Set<string>([\n \"Name\",\n \"Require Turnstile\",\n \"Accepted Watch Conditions\",\n ...Object.keys(SITE_FIELDS),\n ...Object.keys(HEALTH_FIELDS),\n ...Object.keys(HEALTH_BOOLEAN),\n ...Object.keys(SCHEDULE_FIELDS),\n ]);\n const legacy: Record<string, unknown> = {};\n for (const [field, value] of Object.entries(f)) {\n if (claimed.has(field) || EXCLUDED_WEBSITE_FIELDS.has(field)) continue;\n legacy[field] = value;\n }\n site.legacy = Object.keys(legacy).length > 0 ? JSON.stringify(legacy) : null;\n\n return { site, health, schedule };\n}\n\n/** Stable-key checklist mapping (Airtable column name → key). */\nconst CHECKLIST_BY_FIELD: ReadonlyArray<{ field: string; key: string }> = [\n ...MAINTENANCE_CHECKLIST,\n ...TESTING_CHECKLIST,\n].map((i) => ({ field: i.field, key: i.key }));\n\n/** Map one raw Reports record. `renderedHtml` is fetched by the caller (the\n * attachment URL is an expiring signed URL — see the design's Attachments\n * section); pass null when the record has no attachment or the fetch failed. */\nexport function mapReportRecord(rec: RawRecord, renderedHtml: string | null): ReportsTable {\n const f = rec.fields;\n const linkSites = (f[\"Site\"] as string[] | undefined) ?? [];\n const checklist: Record<string, boolean> = {};\n for (const { field, key } of CHECKLIST_BY_FIELD) checklist[key] = Boolean(f[field]);\n\n return {\n id: rec.id,\n site_id: linkSites[0] ?? null,\n report_id: s(f[\"Report ID\"]),\n report_type: s(f[\"Report type\"]),\n period: s(f[\"Period\"]),\n period_start: s(f[\"Period start\"]),\n period_end: s(f[\"Period end\"]),\n completed_on: s(f[\"Completed on\"]),\n lighthouse_performance: n(f[\"Lighthouse — Performance\"]),\n lighthouse_accessibility: n(f[\"Lighthouse — Accessibility\"]),\n lighthouse_best_practices: n(f[\"Lighthouse — Best Practices\"]),\n lighthouse_seo: n(f[\"Lighthouse — SEO\"]),\n ga_users_current: n(f[\"GA users (period)\"]),\n ga_users_previous: n(f[\"GA users (prev period)\"]),\n search_found_page1: b01n(f[\"Search found page 1\"]),\n search_position: n(f[\"Search position\"]),\n last_tested_date: s(f[\"Last tested date\"]),\n commentary: s(f[\"Commentary\"]),\n subject_override: s(f[\"Subject override\"]),\n draft_ready: b01(f[\"Draft ready\"]),\n approved_to_send: b01(f[\"Approved to send\"]),\n approved_at: s(f[\"Approved At\"]),\n approved_by: s(f[\"Approved By\"]),\n send_override: b01(f[\"Send override\"]),\n override_reason: s(f[\"Override reason\"]),\n override_by: s(f[\"Override by\"]),\n override_at: s(f[\"Override at\"]),\n sent_at: s(f[\"Sent at\"]),\n delivery_status: s(f[\"Delivery status\"]) ?? \"pending\",\n resend_message_id: s(f[\"Resend message ID\"]),\n checklist: JSON.stringify(checklist),\n // The Airtable cell is a long-text field, so the API hands us a STRING of\n // JSON — store it verbatim. json() here would double-encode it, and\n // parseAutoEvidence on the read side would then parse to a string and\n // yield null (evidence silently lost). The non-string branch only exists\n // for defensive completeness.\n checklist_auto_evidence:\n typeof f[\"Checklist auto-evidence\"] === \"string\"\n ? s(f[\"Checklist auto-evidence\"])\n : json(f[\"Checklist auto-evidence\"] ?? undefined),\n rendered_html: renderedHtml,\n };\n}\n\n/** First Rendered HTML attachment's signed URL, or null. Exposed so the CLI can\n * fetch it and tests can assert which URL would be fetched. */\nexport function renderedHtmlUrl(rec: RawRecord): string | null {\n const atts = rec.fields[\"Rendered HTML\"] as Array<{ url?: string }> | undefined;\n const url = atts?.[0]?.url;\n return typeof url === \"string\" && url.length > 0 ? url : null;\n}\n\n/** What the import removed because Airtable no longer has the record — and what\n * it declined to remove. `refusals` is non-empty only when the incoming read\n * looked untrustworthy; in that case NOTHING was deleted for that table. */\nexport type ReapSummary = {\n sites: string[];\n reports: string[];\n refusals: string[];\n};\n\n/** Reaping is the only destructive thing the importer does, and it acts on the\n * absence of evidence — so it is only ever as trustworthy as the read that\n * motivated it. A short read (a truncated page, a partial outage) is\n * indistinguishable from mass deletion by looking at the rows alone, so the\n * allowance is deliberately shaped like an operator tidying up rather than\n * like a bad page: at most 10% of what is stored, with a floor of 5 so a small\n * table stays workable. Over that, refuse the whole table and let parity red\n * the run — a wedged-red sync is recoverable, an emptied Turso is not. */\nconst REAP_FLOOR = 5;\nconst REAP_FRACTION = 0.1;\n\nexport function reapAllowance(stored: number): number {\n return Math.max(REAP_FLOOR, Math.ceil(stored * REAP_FRACTION));\n}\n\n/** Human lines plus the FLEET_REAP machine line, emitted on EVERY pass (nothing\n * reaped included) — an absent line must read as \"the reap never ran\", never as\n * \"it ran clean\", the same contract FLEET_PARITY and FLEET_SYNC hold. Shared by\n * `db sync` and the one-shot `db import-airtable`: both can delete, so a second\n * hand-rolled copy is how one of them ends up doing it quietly. */\nexport function formatReapSummary(reaped: ReapSummary): string[] {\n const lines: string[] = [];\n for (const id of reaped.sites) {\n lines.push(`✂ reaped sites ${id} (+ its health/schedule rows) — no longer in Airtable`);\n }\n for (const id of reaped.reports) {\n lines.push(`✂ reaped reports ${id} — no longer in Airtable`);\n }\n for (const reason of reaped.refusals) lines.push(`⚠ ${reason}`);\n lines.push(\n `FLEET_REAP sites=${reaped.sites.length} reports=${reaped.reports.length} ` +\n `refused=${reaped.refusals.length}`,\n );\n return lines;\n}\n\n/** Null when the reap may proceed, else the human reason it was refused. */\nexport function reapRefusal(\n table: string,\n incoming: number,\n stored: number,\n toReap: number,\n): string | null {\n if (incoming === 0 && stored > 0) {\n return `${table}: REFUSED to reap — Airtable returned 0 rows while ${stored} are stored; that is a failed read, not an empty fleet. Nothing deleted.`;\n }\n const allowed = reapAllowance(stored);\n if (toReap > allowed) {\n return `${table}: REFUSED to reap — ${toReap} rows are missing from Airtable, over the ${allowed}-row allowance for ${stored} stored. Nothing deleted; re-run, and if the deletions are real, remove them in smaller batches.`;\n }\n return null;\n}\n\nexport type ImportSummary = {\n sites: number;\n reports: number;\n /** Rows removed (or refused) because their Airtable record is gone. */\n reaped: ReapSummary;\n /** Reports whose Rendered HTML attachment could not be fetched (URL expired /\n * network) — imported with rendered_html null, named so the run is honest. */\n renderedHtmlMisses: string[];\n /** Attachment fetches attempted and succeeded this run. */\n renderedHtmlFetched: number;\n /** Fetches skipped because the stored row already carries rendered_html\n * (only in reportHtml: \"when-missing\" mode — the hourly sync's mode). */\n renderedHtmlSkipped: number;\n};\n\nexport type ImportOptions = {\n /** \"always\" (default): fetch every report's Rendered HTML attachment — the\n * one-shot full import's mode. \"when-missing\": fetch only for reports whose\n * stored row has no rendered_html yet — the hourly sync's mode, so 24 runs a\n * day don't re-download every attachment every hour. Safe for Phase 2:\n * nothing reads reports.rendered_html from Turso until the Phase 4 report\n * review lands; revisit the staleness story there (a re-rendered report's\n * stored HTML goes stale under \"when-missing\"). Parity is unaffected —\n * rendered_html is a parity SKIP_COLUMN. */\n reportHtml?: \"always\" | \"when-missing\";\n};\n\nexport type ImportIo = {\n listWebsiteRecords: () => Promise<RawRecord[]>;\n listReportRecords: () => Promise<RawRecord[]>;\n /** Fetch an attachment body; null on failure (the miss is reported, not fatal). */\n fetchAttachment: (url: string) => Promise<string | null>;\n now: () => Date;\n};\n\n/**\n * Import both tables, idempotently: upsert by rec id, so a re-run converges\n * instead of duplicating. On conflict the sites upsert deliberately does NOT\n * touch the header_image* columns — Airtable stopped being their source (D5),\n * so a re-import must never wipe a regenerated image. rendered_html is only\n * overwritten when the fetch succeeded, for the same reason: a re-run with an\n * expired signed URL must not erase a body captured while it was valid.\n */\nexport async function importFleetState(\n db: Db,\n io: ImportIo,\n opts: ImportOptions = {},\n): Promise<ImportSummary> {\n const computedAt = io.now().toISOString();\n const websites = await io.listWebsiteRecords();\n\n const mapped = websites.map((r) => mapWebsiteRecord(r, computedAt));\n const slugOwner = new Map<string, string>();\n for (const m of mapped) {\n const prior = slugOwner.get(m.site.slug);\n if (prior)\n throw new Error(`slug collision: ${prior} and ${m.site.id} both map to '${m.site.slug}'`);\n slugOwner.set(m.site.slug, m.site.id);\n }\n\n for (const { site, health, schedule } of mapped) {\n await db\n .insertInto(\"sites\")\n .values(site)\n .onConflict((oc) => oc.column(\"id\").doUpdateSet(site))\n .execute();\n await db\n .insertInto(\"site_health\")\n .values(health)\n .onConflict((oc) => oc.column(\"site_id\").doUpdateSet(health))\n .execute();\n await db\n .insertInto(\"site_schedule\")\n .values(schedule)\n .onConflict((oc) => oc.column(\"site_id\").doUpdateSet(schedule))\n .execute();\n }\n\n const reports = await io.listReportRecords();\n // \"when-missing\": one pre-read of which report rows already hold a body, so\n // the loop can skip their attachment fetches. A skipped fetch keeps the\n // stored body (the upsert falls into the rowSansHtml branch) and is counted,\n // not treated as a miss.\n const alreadyStored =\n opts.reportHtml === \"when-missing\"\n ? new Set(\n (\n await db\n .selectFrom(\"reports\")\n .select(\"id\")\n .where(\"rendered_html\", \"is not\", null)\n .execute()\n ).map((r) => r.id),\n )\n : null;\n const misses: string[] = [];\n let fetched = 0;\n let skipped = 0;\n for (const rec of reports) {\n const url = renderedHtmlUrl(rec);\n const skip = url !== null && alreadyStored !== null && alreadyStored.has(rec.id);\n if (skip) skipped++;\n const html = url && !skip ? await io.fetchAttachment(url) : null;\n if (url && !skip && html === null) misses.push(rec.id);\n if (html !== null) fetched++;\n const row = mapReportRecord(rec, html);\n const { rendered_html: _rh, ...rowSansHtml } = row;\n void _rh;\n await db\n .insertInto(\"reports\")\n .values(row)\n .onConflict((oc) => oc.column(\"id\").doUpdateSet(html !== null ? row : rowSansHtml))\n .execute();\n }\n\n const reaped: ReapSummary = { sites: [], reports: [], refusals: [] };\n\n // Sites first. No foreign keys are declared, so the health and schedule rows\n // must be removed explicitly — parity only reverse-checks `sites`, so an\n // orphan left here would linger forever, unnoticed and still readable.\n const liveSiteIds = new Set(mapped.map((m) => m.site.id));\n const storedSites = (await db.selectFrom(\"sites\").select(\"id\").execute()).map((r) =>\n String(r.id),\n );\n const staleSites = storedSites.filter((id) => !liveSiteIds.has(id)).sort();\n const siteRefusal = reapRefusal(\"sites\", websites.length, storedSites.length, staleSites.length);\n if (siteRefusal) reaped.refusals.push(siteRefusal);\n else if (staleSites.length > 0) {\n await db.deleteFrom(\"site_health\").where(\"site_id\", \"in\", staleSites).execute();\n await db.deleteFrom(\"site_schedule\").where(\"site_id\", \"in\", staleSites).execute();\n await db.deleteFrom(\"sites\").where(\"id\", \"in\", staleSites).execute();\n reaped.sites = staleSites;\n }\n\n const liveReportIds = new Set(reports.map((r) => r.id));\n const storedReports = (await db.selectFrom(\"reports\").select(\"id\").execute()).map((r) =>\n String(r.id),\n );\n const staleReports = storedReports.filter((id) => !liveReportIds.has(id)).sort();\n const reportRefusal = reapRefusal(\n \"reports\",\n reports.length,\n storedReports.length,\n staleReports.length,\n );\n if (reportRefusal) reaped.refusals.push(reportRefusal);\n else if (staleReports.length > 0) {\n await db.deleteFrom(\"reports\").where(\"id\", \"in\", staleReports).execute();\n reaped.reports = staleReports;\n }\n\n return {\n sites: mapped.length,\n reports: reports.length,\n renderedHtmlMisses: misses,\n renderedHtmlFetched: fetched,\n renderedHtmlSkipped: skipped,\n reaped,\n };\n}\n"],"mappings":";;;;;;;;;AA8BO,IAAM,0BAA+C,oBAAI,IAAI;AAAA;AAAA,EAElE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AACF,CAA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ZQUCW.js";
4
4
  import {
5
5
  withRecipe
6
- } from "./chunk-ZTPPCHDB.js";
6
+ } from "./chunk-3G25KIWW.js";
7
7
 
8
8
  // src/recipes/svelte-codemods.ts
9
9
  import { writeFile } from "fs/promises";
@@ -32,4 +32,4 @@ async function svelteCodemods(site) {
32
32
  export {
33
33
  svelteCodemods
34
34
  };
35
- //# sourceMappingURL=chunk-LS6QPANO.js.map
35
+ //# sourceMappingURL=chunk-IYSEC543.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runMigrations
3
- } from "./chunk-4SOCPK7A.js";
3
+ } from "./chunk-3SF7D4DY.js";
4
4
  import {
5
5
  defaultCredentialsPath
6
6
  } from "./chunk-6VAL7XJT.js";
@@ -48,4 +48,4 @@ export {
48
48
  readDbConfig,
49
49
  openDb
50
50
  };
51
- //# sourceMappingURL=chunk-DC5H7KEQ.js.map
51
+ //# sourceMappingURL=chunk-JHGHLKFS.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  siteSlug
3
- } from "./chunk-577HCGZO.js";
3
+ } from "./chunk-LDWZSLSU.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-PBWDDDQH.js.map
51
+ //# sourceMappingURL=chunk-KTH5ZODA.js.map
@@ -1,6 +1,20 @@
1
1
  // src/audits/util/spawn.ts
2
2
  import { spawn } from "child_process";
3
3
  import { StringDecoder } from "string_decoder";
4
+ var SpawnTimeoutError = class extends Error {
5
+ timeoutMs;
6
+ command;
7
+ constructor(command, timeoutMs) {
8
+ super(`spawn timeout after ${timeoutMs}ms: ${command}`);
9
+ this.name = "SpawnTimeoutError";
10
+ this.command = command;
11
+ this.timeoutMs = timeoutMs;
12
+ }
13
+ };
14
+ function isSpawnTimeout(err) {
15
+ if (err instanceof SpawnTimeoutError) return true;
16
+ return err instanceof Error && /^spawn timeout after \d+ms:/.test(err.message);
17
+ }
4
18
  var TRUNCATION_MARKER = "\n\u2026[output truncated]";
5
19
  function makeSpawn(internals = {}) {
6
20
  const spawnImpl = internals.spawnImpl ?? spawn;
@@ -56,7 +70,7 @@ function makeSpawn(internals = {}) {
56
70
  killGroup("SIGTERM");
57
71
  killTimer = setTimeout(() => killGroup("SIGKILL"), killGraceMs);
58
72
  killTimer.unref();
59
- reject(new Error(`spawn timeout after ${opts.timeoutMs}ms: ${cmd}`));
73
+ reject(new SpawnTimeoutError(cmd, opts.timeoutMs));
60
74
  }, opts.timeoutMs) : void 0;
61
75
  const clearTimers = () => {
62
76
  if (timer) clearTimeout(timer);
@@ -79,7 +93,8 @@ function makeSpawn(internals = {}) {
79
93
  var defaultSpawn = makeSpawn();
80
94
 
81
95
  export {
96
+ isSpawnTimeout,
82
97
  makeSpawn,
83
98
  defaultSpawn
84
99
  };
85
- //# sourceMappingURL=chunk-4DHQCN5H.js.map
100
+ //# sourceMappingURL=chunk-LBYOLBW7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/audits/util/spawn.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport { StringDecoder } from \"node:string_decoder\";\n\nexport type SpawnResult = { code: number; stdout: string; stderr: string };\n\n/** Rejection raised when `timeoutMs` elapses before the child exits.\n *\n * Typed rather than a bare `Error` because callers need to tell \"the command ran\n * and reported a verdict\" apart from \"we ran out of time and never learned one\" —\n * those mean opposite things to an audit. Conflating them is how a smoke timeout\n * spent four nights reported as a generic `unexpected error` while Airtable kept\n * serving the stale prior verdict.\n *\n * The message is unchanged from the historical string so anything already reading\n * it keeps working; prefer {@link isSpawnTimeout} over matching the text. */\nexport class SpawnTimeoutError extends Error {\n readonly timeoutMs: number;\n readonly command: string;\n constructor(command: string, timeoutMs: number) {\n super(`spawn timeout after ${timeoutMs}ms: ${command}`);\n this.name = \"SpawnTimeoutError\";\n this.command = command;\n this.timeoutMs = timeoutMs;\n }\n}\n\n/** True when a rejection is a spawn timeout.\n *\n * Accepts the legacy message shape as well as the class, so an injected test\n * double or a subprocess wrapper that re-wraps the error still reads as a\n * timeout rather than silently degrading to \"unexpected error\". */\nexport function isSpawnTimeout(err: unknown): boolean {\n if (err instanceof SpawnTimeoutError) return true;\n return err instanceof Error && /^spawn timeout after \\d+ms:/.test(err.message);\n}\n\nexport type SpawnOptions = {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n timeoutMs?: number;\n /** When true, the child inherits stdout/stderr so the user sees live\n * progress (useful for long-running `pnpm up` / `npm install`). The\n * returned `stdout` and `stderr` will be empty strings in that case. */\n streaming?: boolean;\n};\n\nexport type SpawnFn = (\n cmd: string,\n args: readonly string[],\n opts?: SpawnOptions,\n) => Promise<SpawnResult>;\n\ntype KillFn = (pid: number, signal: NodeJS.Signals | number) => void;\n\n/** Construction-time knobs, separated from per-call {@link SpawnOptions} mainly\n * so tests can inject deterministic `spawnImpl`/`killImpl` and a tiny grace. */\nexport type SpawnInternals = {\n spawnImpl?: typeof spawn;\n killImpl?: KillFn;\n /** Delay after SIGTERM before escalating to SIGKILL on a timeout (default 5s). */\n killGraceMs?: number;\n /** Cap on captured stdout/stderr length so a runaway child can't OOM the CLI. */\n maxOutputBytes?: number;\n};\n\nconst TRUNCATION_MARKER = \"\\n…[output truncated]\";\n\nexport function makeSpawn(internals: SpawnInternals = {}): SpawnFn {\n const spawnImpl = internals.spawnImpl ?? spawn;\n const killImpl: KillFn = internals.killImpl ?? ((pid, sig) => process.kill(pid, sig));\n const killGraceMs = internals.killGraceMs ?? 5000;\n const maxOutputBytes = internals.maxOutputBytes ?? 10 * 1024 * 1024;\n\n return (cmd, args, opts = {}) =>\n new Promise((resolve, reject) => {\n const streaming = opts.streaming === true;\n const child = spawnImpl(cmd, [...args], {\n cwd: opts.cwd,\n env: opts.env ?? process.env,\n stdio: streaming ? [\"ignore\", \"inherit\", \"inherit\"] : [\"ignore\", \"pipe\", \"pipe\"],\n // Detach ONLY when a timeout can fire: the child then leads its own\n // process group, so the timeout can kill the WHOLE tree (vite, and\n // Chromium under lhci/playwright) via process.kill(-pid), not just the\n // npx/pnpm wrapper. Without it, killing the wrapper orphaned the\n // grandchildren — a zombie vite squatting its port, Chrome left running.\n // We do NOT detach timeout-less streaming calls (pnpm install/up):\n // detaching gains nothing there (no timeout → no group-kill) and would\n // break terminal Ctrl-C, which only reaches the foreground group — i.e.\n // it would re-orphan the very children this guards. We never unref() the\n // child since we still await it.\n detached: opts.timeoutMs !== undefined,\n });\n\n // Cap appended output so an unbounded stream can't exhaust memory.\n const cap = (acc: string, chunk: string): string => {\n if (acc.length >= maxOutputBytes) return acc;\n const next = acc + chunk;\n return next.length > maxOutputBytes\n ? next.slice(0, maxOutputBytes) + TRUNCATION_MARKER\n : next;\n };\n\n let stdout = \"\";\n let stderr = \"\";\n // Decode each stream through a StringDecoder so a multibyte UTF-8 char\n // split across two `data` chunks isn't corrupted: the decoder holds the\n // partial trailing bytes until the rest arrives, instead of the old\n // `String(chunk)` which decoded each chunk in isolation (and replaced the\n // split char with U+FFFD). Flushed via `.end()` on close.\n const outDecoder = new StringDecoder(\"utf-8\");\n const errDecoder = new StringDecoder(\"utf-8\");\n if (!streaming) {\n child.stdout?.on(\n \"data\",\n (chunk: Buffer) => (stdout = cap(stdout, outDecoder.write(chunk))),\n );\n child.stderr?.on(\n \"data\",\n (chunk: Buffer) => (stderr = cap(stderr, errDecoder.write(chunk))),\n );\n }\n\n /** Signal the child's whole process group; ignore if it's already gone.\n * POSIX-only: a negative pid signals the group (the project targets\n * macOS/Linux; this is only reached when detached, i.e. on a timeout). */\n const killGroup = (sig: NodeJS.Signals): void => {\n if (child.pid === undefined) return;\n try {\n killImpl(-child.pid, sig);\n } catch {\n // ESRCH: the group already exited between the timeout and the kill.\n }\n };\n\n let killTimer: ReturnType<typeof setTimeout> | undefined;\n const timer = opts.timeoutMs\n ? setTimeout(() => {\n killGroup(\"SIGTERM\");\n // Escalate if SIGTERM is ignored (a wedged Chrome can swallow it).\n killTimer = setTimeout(() => killGroup(\"SIGKILL\"), killGraceMs);\n // Best-effort cleanup AFTER we've already rejected — it must never\n // hold the CLI open past its real work.\n killTimer.unref();\n reject(new SpawnTimeoutError(cmd, opts.timeoutMs as number));\n }, opts.timeoutMs)\n : undefined;\n\n const clearTimers = (): void => {\n if (timer) clearTimeout(timer);\n if (killTimer) clearTimeout(killTimer);\n };\n\n child.on(\"error\", (err) => {\n clearTimers();\n reject(err);\n });\n child.on(\"close\", (code) => {\n clearTimers();\n if (!streaming) {\n // Flush any bytes the decoder buffered mid-character (e.g. a truncated\n // final UTF-8 sequence). `.end()` returns \"\" when nothing is pending.\n stdout = cap(stdout, outDecoder.end());\n stderr = cap(stderr, errDecoder.end());\n }\n resolve({ code: code ?? -1, stdout, stderr });\n });\n });\n}\n\nexport const defaultSpawn: SpawnFn = makeSpawn();\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,qBAAqB;AAcvB,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAClC;AAAA,EACA;AAAA,EACT,YAAY,SAAiB,WAAmB;AAC9C,UAAM,uBAAuB,SAAS,OAAO,OAAO,EAAE;AACtD,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,SAAK,YAAY;AAAA,EACnB;AACF;AAOO,SAAS,eAAe,KAAuB;AACpD,MAAI,eAAe,kBAAmB,QAAO;AAC7C,SAAO,eAAe,SAAS,8BAA8B,KAAK,IAAI,OAAO;AAC/E;AA+BA,IAAM,oBAAoB;AAEnB,SAAS,UAAU,YAA4B,CAAC,GAAY;AACjE,QAAM,YAAY,UAAU,aAAa;AACzC,QAAM,WAAmB,UAAU,aAAa,CAAC,KAAK,QAAQ,QAAQ,KAAK,KAAK,GAAG;AACnF,QAAM,cAAc,UAAU,eAAe;AAC7C,QAAM,iBAAiB,UAAU,kBAAkB,KAAK,OAAO;AAE/D,SAAO,CAAC,KAAK,MAAM,OAAO,CAAC,MACzB,IAAI,QAAQ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