@reddoorla/maintenance 0.85.2 → 0.87.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.
- package/README.md +8 -0
- package/dist/airtable-ZBUPQJSC.js +9 -0
- package/dist/{announce-GIAYN67S.js → announce-I2Z4JN3I.js} +58 -30
- package/dist/announce-I2Z4JN3I.js.map +1 -0
- package/dist/attachments-NLZIJ5NU.js +9 -0
- package/dist/{bump-deps-SWJB6H5V.js → bump-deps-CGVELRLK.js} +9 -9
- package/dist/{chunk-SDUJIANJ.js → chunk-2NJQLSEU.js} +3 -3
- package/dist/chunk-2NQUCS7O.js +243 -0
- package/dist/chunk-2NQUCS7O.js.map +1 -0
- package/dist/{chunk-ZTPPCHDB.js → chunk-3G25KIWW.js} +4 -4
- package/dist/{chunk-DTTIFYAM.js → chunk-3JQ2FO3D.js} +44 -405
- package/dist/chunk-3JQ2FO3D.js.map +1 -0
- package/dist/chunk-3SF7D4DY.js +359 -0
- package/dist/chunk-3SF7D4DY.js.map +1 -0
- package/dist/{chunk-37S6L6G4.js → chunk-5UINJNAJ.js} +72 -2
- package/dist/chunk-5UINJNAJ.js.map +1 -0
- package/dist/{chunk-THEFTZ7F.js → chunk-62CMMGEO.js} +5 -5
- package/dist/{chunk-FDIFTIXC.js → chunk-6TWWY7ZU.js} +2 -2
- package/dist/{chunk-PBWDDDQH.js → chunk-7BZUOZPU.js} +2 -2
- package/dist/{chunk-577HCGZO.js → chunk-7NYN2P6I.js} +44 -26
- package/dist/chunk-7NYN2P6I.js.map +1 -0
- package/dist/{chunk-UYCAF77E.js → chunk-7RJ2HMMJ.js} +3 -3
- package/dist/{chunk-Q276MZ7E.js → chunk-7UAYMAKR.js} +2 -2
- package/dist/{chunk-MGR2H7F4.js → chunk-BBUSGEES.js} +58 -45
- package/dist/chunk-BBUSGEES.js.map +1 -0
- package/dist/chunk-BNM5POSJ.js +284 -0
- package/dist/chunk-BNM5POSJ.js.map +1 -0
- package/dist/{chunk-R6FPFMOS.js → chunk-BQRFQSGY.js} +3 -3
- package/dist/{chunk-NWB4O5EY.js → chunk-C6CLRKPV.js} +5 -5
- package/dist/chunk-C6CLRKPV.js.map +1 -0
- package/dist/{chunk-7J53SUT6.js → chunk-CROKUHJB.js} +4 -4
- package/dist/chunk-DEWJMMG3.js +274 -0
- package/dist/chunk-DEWJMMG3.js.map +1 -0
- package/dist/{chunk-SEEA6RXF.js → chunk-DJZWYIPP.js} +2 -2
- package/dist/chunk-DJZWYIPP.js.map +1 -0
- package/dist/chunk-EVBCK2KC.js +68 -0
- package/dist/chunk-EVBCK2KC.js.map +1 -0
- package/dist/chunk-F3JWOPTG.js +202 -0
- package/dist/chunk-F3JWOPTG.js.map +1 -0
- package/dist/{chunk-GZNBCHAZ.js → chunk-HEWSRXYV.js} +4 -4
- package/dist/chunk-HHMMUR4P.js +335 -0
- package/dist/chunk-HHMMUR4P.js.map +1 -0
- package/dist/chunk-HSI6Q7MI.js +1238 -0
- package/dist/chunk-HSI6Q7MI.js.map +1 -0
- package/dist/{chunk-MPBXOJ3N.js → chunk-IY6256GK.js} +33 -2
- package/dist/chunk-IY6256GK.js.map +1 -0
- package/dist/{chunk-LS6QPANO.js → chunk-IYSEC543.js} +2 -2
- package/dist/{chunk-DC5H7KEQ.js → chunk-JHGHLKFS.js} +2 -2
- package/dist/{chunk-4DHQCN5H.js → chunk-LBYOLBW7.js} +17 -2
- package/dist/chunk-LBYOLBW7.js.map +1 -0
- package/dist/{chunk-6QRLRT3P.js → chunk-MT2JINSS.js} +16 -265
- package/dist/chunk-MT2JINSS.js.map +1 -0
- package/dist/{chunk-TP5M2NQB.js → chunk-NCMZMLY7.js} +3 -3
- package/dist/{chunk-COZPL62X.js → chunk-NDWYJLRF.js} +24 -139
- package/dist/chunk-NDWYJLRF.js.map +1 -0
- package/dist/{chunk-3YXDSCM6.js → chunk-NXNPDCF3.js} +29 -11
- package/dist/chunk-NXNPDCF3.js.map +1 -0
- package/dist/chunk-NYUYNYQL.js +48 -0
- package/dist/chunk-NYUYNYQL.js.map +1 -0
- package/dist/chunk-P6AORG32.js +415 -0
- package/dist/chunk-P6AORG32.js.map +1 -0
- package/dist/chunk-PTDMVGKL.js +31 -0
- package/dist/chunk-PTDMVGKL.js.map +1 -0
- package/dist/{chunk-D4FVAIEJ.js → chunk-PZR4EBPY.js} +5 -2
- package/dist/chunk-PZR4EBPY.js.map +1 -0
- package/dist/{chunk-LTB6KVJW.js → chunk-SDDPUAWH.js} +13 -11
- package/dist/{chunk-LTB6KVJW.js.map → chunk-SDDPUAWH.js.map} +1 -1
- package/dist/{chunk-WYYQK4D3.js → chunk-TD2NNXLZ.js} +13 -13
- package/dist/{chunk-ZMIPG6TR.js → chunk-TVL5MVUF.js} +4 -4
- package/dist/chunk-UDRHAQT7.js +172 -0
- package/dist/chunk-UDRHAQT7.js.map +1 -0
- package/dist/chunk-VAD43MOR.js +72 -0
- package/dist/chunk-VAD43MOR.js.map +1 -0
- package/dist/chunk-VSBFM7DS.js +229 -0
- package/dist/chunk-VSBFM7DS.js.map +1 -0
- package/dist/{chunk-VRWUL4TR.js → chunk-XHHMM5HX.js} +2 -2
- package/dist/{chunk-RJB3QUSP.js → chunk-XIDUYLSR.js} +3 -3
- package/dist/{chunk-QG6OSL4M.js → chunk-XUGSZP7Z.js} +2 -2
- package/dist/{chunk-S56JQJ4F.js → chunk-Y53WOQIJ.js} +3 -3
- package/dist/{chunk-62VF32IC.js → chunk-YFAXOD7Z.js} +10 -6
- package/dist/chunk-YFAXOD7Z.js.map +1 -0
- package/dist/{chunk-ICXV25N7.js → chunk-Z3KYFUN6.js} +3 -3
- package/dist/chunk-ZBDZTJUO.js +129 -0
- package/dist/chunk-ZBDZTJUO.js.map +1 -0
- package/dist/chunk-ZGBEIWSC.js +146 -0
- package/dist/chunk-ZGBEIWSC.js.map +1 -0
- package/dist/cli/bin.js +51 -28
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/commands/audit.d.ts +30 -1
- package/dist/cli/commands/audit.js +69 -33
- package/dist/cli/commands/audit.js.map +1 -1
- package/dist/client-AUE3XUPO.js +11 -0
- package/dist/{convert-to-pnpm-AT52NWZB.js → convert-to-pnpm-QFJOEP5V.js} +9 -9
- package/dist/db-UXNIZ2RG.js +217 -0
- package/dist/db-UXNIZ2RG.js.map +1 -0
- package/dist/{digest-UVHYZUYE.js → digest-FW6QMZZJ.js} +26 -22
- package/dist/{digest-UVHYZUYE.js.map → digest-FW6QMZZJ.js.map} +1 -1
- package/dist/dump-P6EBSIOH.js +68 -0
- package/dist/dump-P6EBSIOH.js.map +1 -0
- package/dist/email-KJXASVH5.js +195 -0
- package/dist/email-KJXASVH5.js.map +1 -0
- package/dist/{ensure-site-S25MDDHW.js → ensure-site-4DCEBAPM.js} +25 -16
- package/dist/ensure-site-4DCEBAPM.js.map +1 -0
- package/dist/fleet-events-cF2Om88w.d.ts +24 -0
- package/dist/fleet-state-7TJ2GYT2.js +39 -0
- package/dist/{forms-notify-target-TWN4EH6K.js → forms-notify-target-2EAWCWBW.js} +42 -133
- package/dist/forms-notify-target-2EAWCWBW.js.map +1 -0
- package/dist/{github-signals-G4ILZAJ6.js → github-signals-E2WPYTBK.js} +42 -21
- package/dist/github-signals-E2WPYTBK.js.map +1 -0
- package/dist/{header-image-T7XD37JL.js → header-image-6IC53W27.js} +36 -13
- package/dist/header-image-6IC53W27.js.map +1 -0
- package/dist/header-images-SQBCE5OD.js +88 -0
- package/dist/header-images-SQBCE5OD.js.map +1 -0
- package/dist/{health-endpoint-242WG2OJ.js → health-endpoint-RFXL2F4A.js} +9 -9
- package/dist/health-mirror-L5JBEJVA.js +41 -0
- package/dist/health-mirror-L5JBEJVA.js.map +1 -0
- package/dist/import-airtable-OHVY344G.js +37 -0
- package/dist/index.d.ts +324 -21
- package/dist/index.js +215 -76
- package/dist/index.js.map +1 -1
- package/dist/{init-JN26NTWF.js → init-XRAQZYID.js} +21 -18
- package/dist/{init-JN26NTWF.js.map → init-XRAQZYID.js.map} +1 -1
- package/dist/{launch-JA7Z4CIM.js → launch-IX4Y5JJC.js} +65 -30
- package/dist/launch-IX4Y5JJC.js.map +1 -0
- package/dist/lighthouse-VHI77PFB.js +11 -0
- package/dist/{lighthouse-airtable-BIPM26SZ.js → lighthouse-airtable-3GUWHETW.js} +3 -3
- package/dist/mailchimp-XYCTEEJY.js +72 -0
- package/dist/mailchimp-XYCTEEJY.js.map +1 -0
- package/dist/migrate-GQH237A6.js +7 -0
- package/dist/migrate-GQH237A6.js.map +1 -0
- package/dist/notify-C645PGD5.js +22 -0
- package/dist/notify-C645PGD5.js.map +1 -0
- package/dist/{onboard-53CITIM7.js → onboard-O4IAHJMO.js} +9 -9
- package/dist/orchestrate-YLWQ6KK2.js +31 -0
- package/dist/orchestrate-YLWQ6KK2.js.map +1 -0
- package/dist/parity-56KA2DGR.js +12 -0
- package/dist/parity-56KA2DGR.js.map +1 -0
- package/dist/pipeline-3AANZFCR.js +12 -0
- package/dist/pipeline-3AANZFCR.js.map +1 -0
- package/dist/{preflight-3XPDUHFJ.js → preflight-TNORKGCX.js} +17 -13
- package/dist/{preflight-3XPDUHFJ.js.map → preflight-TNORKGCX.js.map} +1 -1
- package/dist/{prismic-ci-UTQ6LRR3.js → prismic-ci-G2AK53VL.js} +12 -12
- package/dist/{prismic-models-PVES6R5V.js → prismic-models-O6Z3OK3A.js} +18 -13
- package/dist/prismic-models-O6Z3OK3A.js.map +1 -0
- package/dist/prospect/types.d.ts +267 -0
- package/dist/prospect/types.js +1 -0
- package/dist/prospect/types.js.map +1 -0
- package/dist/prospect-audit-KSXUNQ5J.js +174 -0
- package/dist/prospect-audit-KSXUNQ5J.js.map +1 -0
- package/dist/prospect-audits-3PMIO73D.js +19 -0
- package/dist/prospect-audits-3PMIO73D.js.map +1 -0
- package/dist/{protection-audit-64PLLBLI.js → protection-audit-SJO53MEQ.js} +3 -3
- package/dist/recipes/sync-configs.js +3 -3
- package/dist/render-IFOGFB5T.js +10 -0
- package/dist/render-IFOGFB5T.js.map +1 -0
- package/dist/render-from-row-BWSOIYDS.js +17 -0
- package/dist/render-from-row-BWSOIYDS.js.map +1 -0
- package/dist/{renovate-dispatch-ICJGSFCE.js → renovate-dispatch-6GQWTRKX.js} +12 -12
- package/dist/{renovate-dispatch-ICJGSFCE.js.map → renovate-dispatch-6GQWTRKX.js.map} +1 -1
- package/dist/replay-C2LXMJZP.js +66 -0
- package/dist/replay-C2LXMJZP.js.map +1 -0
- package/dist/{report-6CKSWJNG.js → report-R3E3Y7HR.js} +100 -32
- package/dist/report-R3E3Y7HR.js.map +1 -0
- package/dist/report-mirror-4MNORYQ4.js +49 -0
- package/dist/report-mirror-4MNORYQ4.js.map +1 -0
- package/dist/reports/header-image/assets/headline-announcement.png +0 -0
- package/dist/reports/header-image/assets/headline-launch.png +0 -0
- package/dist/reports/header-image/assets/headline-maintenance.png +0 -0
- package/dist/reports/header-image/assets/headline-testing.png +0 -0
- package/dist/reports/header-image/assets/plate-clean.png +0 -0
- package/dist/rerender-3FM6DNRH.js +32 -0
- package/dist/rerender-3FM6DNRH.js.map +1 -0
- package/dist/{self-updating-PPQVV6UA.js → self-updating-UCIWESAX.js} +9 -9
- package/dist/{selftest-CQ6NOX52.js → selftest-VGHWPN72.js} +31 -24
- package/dist/selftest-VGHWPN72.js.map +1 -0
- package/dist/site-mirror-NIREX5ME.js +52 -0
- package/dist/site-mirror-NIREX5ME.js.map +1 -0
- package/dist/smoke-B2GQOSIZ.js +20 -0
- package/dist/smoke-B2GQOSIZ.js.map +1 -0
- package/dist/{smoke-suite-TMCSOYRK.js → smoke-suite-U3UKD3NS.js} +9 -9
- package/dist/{submissions-GJ6ITBRH.js → submissions-IQEJX6FK.js} +3 -3
- package/dist/{svelte-codemods-ZOBDHIES.js → svelte-codemods-GOKXTBHW.js} +9 -9
- package/dist/sync-CTUVXMCK.js +44 -0
- package/dist/sync-CTUVXMCK.js.map +1 -0
- package/dist/{sync-configs-CJXUX6MD.js → sync-configs-SPTLFJCC.js} +9 -9
- package/dist/{upgrade-WLX27UPC.js → upgrade-W6ZR3FJH.js} +9 -9
- package/dist/webhook-VOGOW3W6.js +38 -0
- package/dist/webhook-VOGOW3W6.js.map +1 -0
- package/dist/{websites-SADZR4XQ.js → websites-D6WYFAES.js} +6 -2
- package/dist/websites-D6WYFAES.js.map +1 -0
- package/dist/{write-audits-to-airtable-7PH75YWY.js → write-audits-to-airtable-CMKHGJNQ.js} +4 -4
- package/dist/write-audits-to-airtable-CMKHGJNQ.js.map +1 -0
- package/package.json +9 -2
- package/dist/airtable-HRKSA7V4.js +0 -9
- package/dist/announce-GIAYN67S.js.map +0 -1
- package/dist/chunk-37S6L6G4.js.map +0 -1
- package/dist/chunk-3YXDSCM6.js.map +0 -1
- package/dist/chunk-4DHQCN5H.js.map +0 -1
- package/dist/chunk-4SOCPK7A.js +0 -108
- package/dist/chunk-4SOCPK7A.js.map +0 -1
- package/dist/chunk-577HCGZO.js.map +0 -1
- package/dist/chunk-62VF32IC.js.map +0 -1
- package/dist/chunk-6QRLRT3P.js.map +0 -1
- package/dist/chunk-COZPL62X.js.map +0 -1
- package/dist/chunk-D4FVAIEJ.js.map +0 -1
- package/dist/chunk-DTTIFYAM.js.map +0 -1
- package/dist/chunk-MGR2H7F4.js.map +0 -1
- package/dist/chunk-MPBXOJ3N.js.map +0 -1
- package/dist/chunk-NWB4O5EY.js.map +0 -1
- package/dist/chunk-SEEA6RXF.js.map +0 -1
- package/dist/chunk-U5SZ4FOP.js +0 -26
- package/dist/chunk-U5SZ4FOP.js.map +0 -1
- package/dist/client-X5WUJWDE.js +0 -11
- package/dist/db-JSIZYT23.js +0 -23
- package/dist/db-JSIZYT23.js.map +0 -1
- package/dist/ensure-site-S25MDDHW.js.map +0 -1
- package/dist/forms-notify-target-TWN4EH6K.js.map +0 -1
- package/dist/github-signals-G4ILZAJ6.js.map +0 -1
- package/dist/header-image-T7XD37JL.js.map +0 -1
- package/dist/launch-JA7Z4CIM.js.map +0 -1
- package/dist/migrate-LJUFGXQZ.js +0 -7
- package/dist/orchestrate-KDNXZQX7.js +0 -27
- package/dist/prismic-models-PVES6R5V.js.map +0 -1
- package/dist/report-6CKSWJNG.js.map +0 -1
- package/dist/reports/header-image/assets/plate.png +0 -0
- package/dist/selftest-CQ6NOX52.js.map +0 -1
- /package/dist/{airtable-HRKSA7V4.js.map → airtable-ZBUPQJSC.js.map} +0 -0
- /package/dist/{client-X5WUJWDE.js.map → attachments-NLZIJ5NU.js.map} +0 -0
- /package/dist/{bump-deps-SWJB6H5V.js.map → bump-deps-CGVELRLK.js.map} +0 -0
- /package/dist/{chunk-SDUJIANJ.js.map → chunk-2NJQLSEU.js.map} +0 -0
- /package/dist/{chunk-ZTPPCHDB.js.map → chunk-3G25KIWW.js.map} +0 -0
- /package/dist/{chunk-THEFTZ7F.js.map → chunk-62CMMGEO.js.map} +0 -0
- /package/dist/{chunk-FDIFTIXC.js.map → chunk-6TWWY7ZU.js.map} +0 -0
- /package/dist/{chunk-PBWDDDQH.js.map → chunk-7BZUOZPU.js.map} +0 -0
- /package/dist/{chunk-UYCAF77E.js.map → chunk-7RJ2HMMJ.js.map} +0 -0
- /package/dist/{chunk-Q276MZ7E.js.map → chunk-7UAYMAKR.js.map} +0 -0
- /package/dist/{chunk-R6FPFMOS.js.map → chunk-BQRFQSGY.js.map} +0 -0
- /package/dist/{chunk-7J53SUT6.js.map → chunk-CROKUHJB.js.map} +0 -0
- /package/dist/{chunk-GZNBCHAZ.js.map → chunk-HEWSRXYV.js.map} +0 -0
- /package/dist/{chunk-LS6QPANO.js.map → chunk-IYSEC543.js.map} +0 -0
- /package/dist/{chunk-DC5H7KEQ.js.map → chunk-JHGHLKFS.js.map} +0 -0
- /package/dist/{chunk-TP5M2NQB.js.map → chunk-NCMZMLY7.js.map} +0 -0
- /package/dist/{chunk-WYYQK4D3.js.map → chunk-TD2NNXLZ.js.map} +0 -0
- /package/dist/{chunk-ZMIPG6TR.js.map → chunk-TVL5MVUF.js.map} +0 -0
- /package/dist/{chunk-VRWUL4TR.js.map → chunk-XHHMM5HX.js.map} +0 -0
- /package/dist/{chunk-RJB3QUSP.js.map → chunk-XIDUYLSR.js.map} +0 -0
- /package/dist/{chunk-QG6OSL4M.js.map → chunk-XUGSZP7Z.js.map} +0 -0
- /package/dist/{chunk-S56JQJ4F.js.map → chunk-Y53WOQIJ.js.map} +0 -0
- /package/dist/{chunk-ICXV25N7.js.map → chunk-Z3KYFUN6.js.map} +0 -0
- /package/dist/{lighthouse-airtable-BIPM26SZ.js.map → client-AUE3XUPO.js.map} +0 -0
- /package/dist/{convert-to-pnpm-AT52NWZB.js.map → convert-to-pnpm-QFJOEP5V.js.map} +0 -0
- /package/dist/{migrate-LJUFGXQZ.js.map → fleet-state-7TJ2GYT2.js.map} +0 -0
- /package/dist/{health-endpoint-242WG2OJ.js.map → health-endpoint-RFXL2F4A.js.map} +0 -0
- /package/dist/{orchestrate-KDNXZQX7.js.map → import-airtable-OHVY344G.js.map} +0 -0
- /package/dist/{websites-SADZR4XQ.js.map → lighthouse-VHI77PFB.js.map} +0 -0
- /package/dist/{write-audits-to-airtable-7PH75YWY.js.map → lighthouse-airtable-3GUWHETW.js.map} +0 -0
- /package/dist/{onboard-53CITIM7.js.map → onboard-O4IAHJMO.js.map} +0 -0
- /package/dist/{prismic-ci-UTQ6LRR3.js.map → prismic-ci-G2AK53VL.js.map} +0 -0
- /package/dist/{protection-audit-64PLLBLI.js.map → protection-audit-SJO53MEQ.js.map} +0 -0
- /package/dist/{self-updating-PPQVV6UA.js.map → self-updating-UCIWESAX.js.map} +0 -0
- /package/dist/{smoke-suite-TMCSOYRK.js.map → smoke-suite-U3UKD3NS.js.map} +0 -0
- /package/dist/{submissions-GJ6ITBRH.js.map → submissions-IQEJX6FK.js.map} +0 -0
- /package/dist/{svelte-codemods-ZOBDHIES.js.map → svelte-codemods-GOKXTBHW.js.map} +0 -0
- /package/dist/{sync-configs-CJXUX6MD.js.map → sync-configs-SPTLFJCC.js.map} +0 -0
- /package/dist/{upgrade-WLX27UPC.js.map → upgrade-W6ZR3FJH.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/recipes/forms-notify-target.ts","../src/cli/commands/forms-notify-target.ts"],"sourcesContent":["import { openBase, readAirtableConfig } from \"../reports/airtable/client.js\";\nimport type { AirtableBase } from \"../reports/airtable/client.js\";\nimport type { SiteMirror } from \"../db/site-mirror.js\";\nimport {\n listWebsites,\n siteSlug,\n updateSiteField,\n type Status,\n type WebsiteRow,\n} from \"../reports/airtable/websites.js\";\nimport { canonicalizeStatus, toAirtableStatus } from \"../reports/airtable/site-status.js\";\nimport { describeNotifyTarget, type NotifyTarget } from \"../forms/notify.js\";\n\n/** The Airtable column the pre-launch guard actually lives in. */\nexport const STATUS_COLUMN = \"Status\";\n\n/** The two ends of the verify flip. Deliberately the ONLY transition this\n * performs: a site in any other status is already guarded (or is deliberately\n * something else, like \"hosted-only\"), and silently rewriting that would be the\n * same class of unseen change as the incident. */\nexport const LIVE_STATUS: Status = \"maintained\";\nexport const VERIFY_STATUS: Status = \"launching\";\n\nexport type FormsNotifyTargetDeps = {\n base?: AirtableBase;\n /** Site slug or the Airtable Websites NAME (both accepted). */\n site: string;\n /** `on` routes notifications to the operator; `off` restores. Omit to read. */\n set?: \"on\" | \"off\";\n /** Status to restore with `--set off`. Required, never inferred. */\n restore?: string;\n /** #539 Phase 5: Turso write-through for the Status cell this flips. Injected\n * at the CLI root, never defaulted — the unit suite calls this with a fake\n * base and must not open a real libSQL handle. */\n siteMirror?: SiteMirror;\n};\n\nexport type FormsNotifyTargetResult = {\n site: string;\n status: Status | null;\n target: NotifyTarget;\n /** Present only when a flip was attempted. `confirmed` is the whole point:\n * it comes from RE-READING the row, not from the write call returning. */\n flip?: { from: Status | null; to: Status; confirmed: boolean };\n};\n\n/**\n * The exact Airtable cell to write for an operator-supplied `--restore` value:\n * the operator's own string, verbatim.\n *\n * This is the ONE non-revertible surface in the #539 Phase 4 stage-1 rename —\n * every other change is code, and `git revert` undoes code. It cannot undo a\n * rewritten Airtable cell. So the rule here is stricter than everywhere else:\n * substitute only when the substitution is provably lossless, i.e. when\n * canonicalizing and mapping back ROUND-TRIPS to the operator's own string.\n *\n * That condition is, today, never false in a way that changes the answer — which\n * is the point. `toAirtableStatus(canonicalizeStatus(raw))` either equals `raw`\n * (so writing it is writing `raw`) or it does not (so we must write `raw`). The\n * function therefore reduces to \"write raw\", and it is written this way so the\n * reduction is visible rather than assumed. The case that made it matter:\n * `--restore legacy` canonicalizes to `archived`, which maps back to\n * \"deprecated\" — a different, real, operator-visible Airtable option that nobody\n * asked for. `hosting` → `hosted-only` → \"hosting\" round-trips and is safe.\n *\n * Airtable, not this module, is the authority on which option strings the\n * \"Status\" single-select accepts. Writing verbatim delegates to it: a typo is\n * rejected loudly at the API, exactly as it was before the rename.\n */\nexport function restoreCell(raw: string): string {\n const canonical = canonicalizeStatus(raw);\n if (canonical === null) return raw;\n const roundTripped = toAirtableStatus(canonical);\n return roundTripped === raw ? roundTripped : raw;\n}\n\nfunction findSite(rows: WebsiteRow[], site: string): WebsiteRow | undefined {\n const wanted = site.trim().toLowerCase();\n return rows.find(\n (r) => siteSlug(r.name) === siteSlug(site) || r.name.trim().toLowerCase() === wanted,\n );\n}\n\n/**\n * Answer \"who would a form submission on this site email?\" — and optionally\n * flip the pre-launch guard, confirming the flip by reading it back.\n *\n * The guard is a single Airtable `Status` cell. Nothing between \"I intended to\n * flip it\" and \"the client received a test lead\" reported the current state, so\n * on 2026-08-03 a flip that never landed sent a real client a test submission.\n * The fix is not a better intention, it is feedback: this reads the row back\n * after every write and refuses to call the flip confirmed on anything less.\n */\nexport async function formsNotifyTarget(\n deps: FormsNotifyTargetDeps,\n): Promise<FormsNotifyTargetResult> {\n const base = deps.base ?? openBase(readAirtableConfig());\n const rows = await listWebsites(base);\n const row = findSite(rows, deps.site);\n if (!row) {\n // The Websites NAME is not the repo slug (\"Sonder\", not \"gallerysonder\"),\n // and that mismatch has cost time before — so name the near misses rather\n // than making the operator go read Airtable to find the spelling.\n const needle = siteSlug(deps.site);\n const near = rows\n .map((r) => r.name)\n .filter((n) => siteSlug(n).includes(needle) || needle.includes(siteSlug(n)));\n throw Object.assign(\n new Error(\n `No Websites row matches '${deps.site}'. The Websites NAME is not always the repo ` +\n `slug (Sonder, not gallerysonder).` +\n (near.length > 0 ? ` Did you mean: ${near.join(\", \")}?` : \"\"),\n ),\n { exitCode: 2 },\n );\n }\n\n if (!deps.set) {\n return { site: row.name, status: row.status, target: describeNotifyTarget(row) };\n }\n\n // `--restore` is operator free text. It is canonicalized for what this command\n // REPORTS (`flip.to`, and the predicates downstream), but NEVER for what it\n // WRITES — see `restoreCell` below.\n const restoreRaw = deps.restore?.trim();\n const to = deps.set === \"on\" ? VERIFY_STATUS : (canonicalizeStatus(restoreRaw) ?? undefined);\n if (deps.set === \"off\" && !to) {\n throw Object.assign(\n new Error(\n `--set off needs --restore <status>: the status to return to is never inferred. ` +\n `Guessing \"${LIVE_STATUS}\" for a site that was \"hosted-only\" or \"archived\" would start ` +\n `sending real client notifications — the inverse of the failure this command exists ` +\n `to prevent.`,\n ),\n { exitCode: 2 },\n );\n }\n // Only ever flip a LIVE site into verify mode. A site already outside\n // \"maintained\" is guarded already, and rewriting its status would destroy a\n // real value nobody asked us to touch.\n if (deps.set === \"on\" && row.status !== LIVE_STATUS) {\n throw Object.assign(\n new Error(\n `${row.name} is \"${row.status ?? \"blank\"}\", not \"${LIVE_STATUS}\" — notifications ` +\n `already go to the operator only, so there is nothing to flip. Leaving the status ` +\n `untouched.`,\n ),\n { exitCode: 2 },\n );\n }\n\n // `--set on` writes a status this MODULE owns (VERIFY_STATUS), so mapping it to\n // the current Airtable vocabulary is correct. `--set off` writes the operator's\n // own string — see restoreCell.\n const cell = deps.set === \"on\" ? toAirtableStatus(VERIFY_STATUS) : restoreCell(restoreRaw!);\n await updateSiteField(base, row.id, STATUS_COLUMN, cell);\n // Mirror the same cell. The console reads Status from Turso, so without this a\n // site flipped into verify mode still reads as live for up to an hour — on the\n // one surface an operator would check to confirm the flip.\n await deps.siteMirror?.site(row.id, { [STATUS_COLUMN]: cell });\n\n // Read it back. The write returning is NOT evidence the field changed.\n const after = findSite(await listWebsites(base), deps.site);\n if (!after) {\n throw Object.assign(new Error(`${row.name} vanished from Websites during the flip.`), {\n exitCode: 1,\n });\n }\n return {\n site: after.name,\n status: after.status,\n target: describeNotifyTarget(after),\n // `confirmed` compares the RAW cell against the exact string written, not\n // canonical-to-canonical. Canonical equality is too weak to be a read-back\n // guard here: `legacy` and `deprecated` are the same canonical status, so a\n // cell holding either would confirm a flip to the other. Comparing raw is the\n // only comparison that can actually catch \"the cell is not what I sent\". The\n // canonical check rides along so a reader that stopped canonicalizing is\n // caught too.\n flip: {\n from: row.status,\n to: to!,\n confirmed: after.statusRaw === cell && after.status === to,\n },\n };\n}\n","import {\n formsNotifyTarget,\n LIVE_STATUS,\n VERIFY_STATUS,\n type FormsNotifyTargetResult,\n} from \"../../recipes/forms-notify-target.js\";\n\nexport type FormsNotifyTargetCommandOptions = {\n set?: string;\n restore?: string;\n cwd?: string;\n};\n\nconst AUDIENCE_LABEL = {\n client: \"THE CLIENT\",\n operator: \"OPERATOR ONLY\",\n nobody: \"NOBODY\",\n} as const;\n\n/** The line that decides whether it is safe to test-submit. Deliberately the\n * loudest thing on screen: the incident happened because the answer was\n * invisible, not because it was subtle. */\nexport function formatNotifyTarget(r: FormsNotifyTargetResult): string {\n const lines: string[] = [];\n if (r.flip) {\n const arrow = `${r.flip.from ?? \"blank\"} → ${r.flip.to}`;\n lines.push(\n r.flip.confirmed\n ? `${r.site} Status: ${arrow} ✓ confirmed by read-back`\n : `${r.site} Status: ${arrow} ✗ NOT CONFIRMED — the row still reads \"${r.status ?? \"blank\"}\". Nothing was verified; do not test-submit.`,\n );\n } else {\n lines.push(`${r.site} Status: ${r.status ?? \"blank\"}`);\n }\n\n lines.push(`A submission right now would notify: ${AUDIENCE_LABEL[r.target.audience]}`);\n if (r.target.to.length > 0) lines.push(` to: ${r.target.to.join(\", \")}`);\n if (r.target.cc.length > 0) lines.push(` cc: ${r.target.cc.join(\", \")}`);\n lines.push(` ${r.target.reason}`);\n\n if (r.target.audience === \"client\") {\n lines.push(\n \"\",\n `⚠️ A test submission WILL email the client, and email cannot be recalled.`,\n ` Route it to yourself first: reddoor forms-notify-target ${r.site} --set on`,\n );\n }\n if (r.flip?.confirmed && r.flip.to === VERIFY_STATUS) {\n lines.push(\n \"\",\n `Safe to test. When you are done, restore it:`,\n ` reddoor forms-notify-target ${r.site} --set off --restore ${r.flip.from ?? LIVE_STATUS}`,\n );\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * `forms-notify-target <site>` — show who a form submission would email, and\n * optionally flip the pre-launch guard with a read-back confirmation.\n *\n * Read-only by default: answering the question must never be riskier than not\n * asking it.\n */\nexport async function runFormsNotifyTargetCommand(\n site: string | undefined,\n opts: FormsNotifyTargetCommandOptions,\n): Promise<{ output: string; code: number }> {\n if (!site?.trim()) {\n return { output: \"forms-notify-target requires <site> (slug or Airtable name)\", code: 2 };\n }\n const set = opts.set?.trim().toLowerCase();\n if (set !== undefined && set !== \"on\" && set !== \"off\") {\n return { output: `--set must be 'on' or 'off' (got '${opts.set}')`, code: 2 };\n }\n try {\n // #539 Phase 5: the flip writes Status on the Websites row; mirror it so the\n // console (which reads Turso) shows the new routing immediately.\n const { makeSiteMirror } = await import(\"../../db/site-mirror.js\");\n const result = await formsNotifyTarget({\n siteMirror: await makeSiteMirror(),\n site: site.trim(),\n ...(set ? { set: set as \"on\" | \"off\" } : {}),\n ...(opts.restore ? { restore: opts.restore } : {}),\n });\n // An unconfirmed flip must not exit 0: a script (or a person skimming) that\n // reads exit status would otherwise take \"I flipped it\" on faith, which is\n // exactly the assumption that sent a client a test lead.\n return {\n output: formatNotifyTarget(result),\n code: result.flip && !result.flip.confirmed ? 1 : 0,\n };\n } catch (err) {\n const e = err as { message?: string; exitCode?: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AAQ,QAAQ,QAAQ,OAAO;AACtD,WAAO,EAAE,QAAQ,qCAAqC,KAAK,GAAG,MAAM,MAAM,EAAE;AAAA,EAC9E;AACA,MAAI;AAGF,UAAM,EAAE,eAAe,IAAI,MAAM,OAAO,2BAAyB;AACjE,UAAM,SAAS,MAAM,kBAAkB;AAAA,MACrC,YAAY,MAAM,eAAe;AAAA,MACjC,MAAM,KAAK,KAAK;AAAA,MAChB,GAAI,MAAM,EAAE,IAAyB,IAAI,CAAC;AAAA,MAC1C,GAAI,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,IAClD,CAAC;AAID,WAAO;AAAA,MACL,QAAQ,mBAAmB,MAAM;AAAA,MACjC,MAAM,OAAO,QAAQ,CAAC,OAAO,KAAK,YAAY,IAAI;AAAA,IACpD;AAAA,EACF,SAAS,KAAK;AACZ,UAAM,IAAI;AACV,WAAO,EAAE,QAAQ,EAAE,WAAW,OAAO,GAAG,GAAG,MAAM,EAAE,YAAY,EAAE;AAAA,EACnE;AACF;","names":[]}
|
|
@@ -3,30 +3,30 @@ import {
|
|
|
3
3
|
} from "./chunk-PZQ3WED2.js";
|
|
4
4
|
import {
|
|
5
5
|
formatFleetWriteSummary
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-NXNPDCF3.js";
|
|
7
|
+
import "./chunk-7BZUOZPU.js";
|
|
8
8
|
import {
|
|
9
9
|
detectSignalEvents,
|
|
10
10
|
fleetSweptEvent
|
|
11
11
|
} from "./chunk-5L3FPQIJ.js";
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
recordFleetEventsBestEffort
|
|
17
|
-
} from "./chunk-QG6OSL4M.js";
|
|
18
|
-
import "./chunk-DC5H7KEQ.js";
|
|
19
|
-
import "./chunk-4SOCPK7A.js";
|
|
20
|
-
import "./chunk-4DHQCN5H.js";
|
|
13
|
+
openBase,
|
|
14
|
+
readAirtableConfig
|
|
15
|
+
} from "./chunk-HN6I2XWI.js";
|
|
21
16
|
import {
|
|
22
17
|
listWebsites,
|
|
23
18
|
siteSlug,
|
|
24
19
|
updateGitHubSignals
|
|
25
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-7NYN2P6I.js";
|
|
26
21
|
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
makeGitHub
|
|
23
|
+
} from "./chunk-XHHMM5HX.js";
|
|
24
|
+
import {
|
|
25
|
+
recordFleetEventsBestEffort
|
|
26
|
+
} from "./chunk-XUGSZP7Z.js";
|
|
27
|
+
import "./chunk-JHGHLKFS.js";
|
|
28
|
+
import "./chunk-3SF7D4DY.js";
|
|
29
|
+
import "./chunk-LBYOLBW7.js";
|
|
30
30
|
import "./chunk-6VAL7XJT.js";
|
|
31
31
|
|
|
32
32
|
// src/audits/github-signals.ts
|
|
@@ -59,7 +59,7 @@ async function collectGitHubSignals(sites, deps, onSkip = () => {
|
|
|
59
59
|
function githubSignalsExitCode(written, failed) {
|
|
60
60
|
return failed > written ? 1 : 0;
|
|
61
61
|
}
|
|
62
|
-
async function runGitHubSignalsCommand(opts) {
|
|
62
|
+
async function runGitHubSignalsCommand(opts, deps = {}) {
|
|
63
63
|
if (!opts.fleet || !opts.writeAirtable) {
|
|
64
64
|
return { output: "github-signals currently supports only --fleet --write-airtable", code: 2 };
|
|
65
65
|
}
|
|
@@ -70,9 +70,9 @@ async function runGitHubSignalsCommand(opts) {
|
|
|
70
70
|
code: 0
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
const base = openBase(readAirtableConfig());
|
|
73
|
+
const base = deps.openBase ? deps.openBase() : openBase(readAirtableConfig());
|
|
74
74
|
const websites = await listWebsites(base);
|
|
75
|
-
const gh = makeGitHub({ token });
|
|
75
|
+
const gh = deps.makeGh ? deps.makeGh(token) : makeGitHub({ token });
|
|
76
76
|
const sites = websites.map((w) => ({
|
|
77
77
|
path: "",
|
|
78
78
|
name: w.name,
|
|
@@ -89,7 +89,16 @@ async function runGitHubSignalsCommand(opts) {
|
|
|
89
89
|
({ repo }) => skipped.push(repo)
|
|
90
90
|
);
|
|
91
91
|
const sweptAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
92
|
-
const
|
|
92
|
+
const makeMirror = deps.makeMirror ?? (async () => {
|
|
93
|
+
const { makeHealthMirrorBestEffort } = await import("./health-mirror-L5JBEJVA.js");
|
|
94
|
+
return makeHealthMirrorBestEffort();
|
|
95
|
+
});
|
|
96
|
+
const mirror = await makeMirror();
|
|
97
|
+
const result = {
|
|
98
|
+
written: [],
|
|
99
|
+
failed: [],
|
|
100
|
+
...mirror ? { mirrored: 0, mirrorFailed: 0, mirrorMissed: 0 } : {}
|
|
101
|
+
};
|
|
93
102
|
const byRepo = new Map(websites.filter((w) => w.gitRepo).map((w) => [w.gitRepo, w]));
|
|
94
103
|
const events = [];
|
|
95
104
|
const sweptMs = Date.parse(sweptAt);
|
|
@@ -101,12 +110,24 @@ async function runGitHubSignalsCommand(opts) {
|
|
|
101
110
|
continue;
|
|
102
111
|
}
|
|
103
112
|
try {
|
|
104
|
-
await updateGitHubSignals(base, target.id, {
|
|
113
|
+
const ghFields = await updateGitHubSignals(base, target.id, {
|
|
105
114
|
renovateFailingCis: row.renovateFailingCis,
|
|
106
115
|
ciState: row.ciState,
|
|
107
116
|
lastCommitAt: row.lastCommitAt,
|
|
108
117
|
sweptAt
|
|
109
118
|
});
|
|
119
|
+
if (mirror) {
|
|
120
|
+
try {
|
|
121
|
+
if (await mirror(target.id, ghFields)) {
|
|
122
|
+
result.mirrored = (result.mirrored ?? 0) + 1;
|
|
123
|
+
} else {
|
|
124
|
+
result.mirrorMissed = (result.mirrorMissed ?? 0) + 1;
|
|
125
|
+
}
|
|
126
|
+
} catch (e) {
|
|
127
|
+
result.mirrorFailed = (result.mirrorFailed ?? 0) + 1;
|
|
128
|
+
console.error(`[health-mirror] ${target.name}: ${e.message}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
110
131
|
result.written.push({
|
|
111
132
|
siteName: target.name,
|
|
112
133
|
writes: [{ audit: "github-signals", counts: row }]
|
|
@@ -124,7 +145,7 @@ async function runGitHubSignalsCommand(opts) {
|
|
|
124
145
|
}
|
|
125
146
|
for (const repo of skipped) result.failed.push({ slug: repo, error: "probe failed (skipped)" });
|
|
126
147
|
events.push(fleetSweptEvent("github-signals", result.written.length, sweptAt));
|
|
127
|
-
await recordFleetEventsBestEffort(events, /* @__PURE__ */ new Date());
|
|
148
|
+
await (deps.recordEvents ?? recordFleetEventsBestEffort)(events, /* @__PURE__ */ new Date());
|
|
128
149
|
return {
|
|
129
150
|
output: formatFleetWriteSummary(result),
|
|
130
151
|
code: githubSignalsExitCode(result.written.length, result.failed.length)
|
|
@@ -134,4 +155,4 @@ export {
|
|
|
134
155
|
githubSignalsExitCode,
|
|
135
156
|
runGitHubSignalsCommand
|
|
136
157
|
};
|
|
137
|
-
//# sourceMappingURL=github-signals-
|
|
158
|
+
//# sourceMappingURL=github-signals-E2WPYTBK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/audits/github-signals.ts","../src/cli/commands/github-signals.ts"],"sourcesContent":["import type { Site } from \"../types.js\";\nimport type { CiState, PullRequestSummary } from \"../github/gh.js\";\nimport { isFailingRenovatePR } from \"../alerts/renovate.js\";\n\n/** One swept row, ready for the Airtable writer (slug-keyed by `site`). */\nexport type GitHubSignalsRow = {\n site: string; // the site name/slug the writer matches on\n repo: string; // owner/repo\n renovateFailingCis: number;\n ciState: CiState;\n lastCommitAt: string | null;\n};\n\n/** Injected GitHub reads (so the sweep is pure + testable). */\nexport type GitHubSignalsDeps = {\n openPullRequests: (repo: string) => Promise<PullRequestSummary[]>;\n defaultBranchStatus: (repo: string) => Promise<{ ciState: CiState; lastCommitAt: string | null }>;\n};\n\n/** Per repo-backed site: count its failing Renovate PRs + read its default-branch\n * status. Sites without `gitRepo` are skipped (not errors). A repo whose probe\n * throws is reported via `onSkip` and produces no row — one GitHub hiccup never\n * sinks the sweep. PURE over `deps`. */\nexport async function collectGitHubSignals(\n sites: Site[],\n deps: GitHubSignalsDeps,\n onSkip: (s: { repo: string }) => void = () => {},\n): Promise<GitHubSignalsRow[]> {\n const rows: GitHubSignalsRow[] = [];\n for (const s of sites) {\n const repo = s.gitRepo;\n if (!repo) continue;\n const name = s.name;\n if (!name) continue;\n try {\n const prs = await deps.openPullRequests(repo);\n const status = await deps.defaultBranchStatus(repo);\n rows.push({\n site: name,\n repo,\n renovateFailingCis: prs.filter(isFailingRenovatePR).length,\n ciState: status.ciState,\n lastCommitAt: status.lastCommitAt,\n });\n } catch {\n onSkip({ repo });\n }\n }\n return rows;\n}\n","import { openBase, readAirtableConfig, type AirtableBase } from \"../../reports/airtable/client.js\";\nimport { listWebsites, siteSlug, updateGitHubSignals } from \"../../reports/airtable/websites.js\";\nimport type { Site } from \"../../types.js\";\nimport { collectGitHubSignals } from \"../../audits/github-signals.js\";\nimport { makeGitHub, type GitHub } from \"../../github/gh.js\";\nimport {\n formatFleetWriteSummary,\n type FleetWriteResult,\n} from \"../../audits/write-audits-to-airtable.js\";\nimport { detectSignalEvents, fleetSweptEvent } from \"../../audits/fleet-event-detectors.js\";\nimport { recordFleetEventsBestEffort } from \"../../audits/fleet-events-writer.js\";\nimport type { FleetEvent } from \"../../db/fleet-events.js\";\nimport type { HealthMirror } from \"../../audits/health-mirror.js\";\n\n/** The slice of the GitHub client this sweep actually probes. */\ntype GhProbes = Pick<\n GitHub,\n \"openPullRequests\" | \"defaultBranchStatus\" | \"mergedRenovatePullRequests\"\n>;\n\n/** Injectable wiring for {@link runGitHubSignalsCommand}. Every default is the\n * real fleet path; tests override to reach the per-row write+mirror loop —\n * the hand-rolled `makeHealthMirrorBestEffort()` call made that loop\n * untestable (no test could prove a mirror throw stays out of `failed`, that\n * the counters increment the right way round, or that the mirror sees the\n * same payload Airtable got). Same seam shape as\n * `writeFleetAuditsToAirtable`'s `mirror` argument. */\nexport type GitHubSignalsDeps = {\n /** Airtable base (default: real creds via readAirtableConfig). */\n openBase: () => AirtableBase;\n /** GitHub probe client for the fleet token (default: makeGitHub). */\n makeGh: (token: string) => GhProbes;\n /** Turso mirror factory (default: makeHealthMirrorBestEffort — null without\n * libSQL creds, leaving the Airtable sweep byte-for-byte unchanged). */\n makeMirror: () => Promise<HealthMirror | null>;\n /** Fleet-activity recorder (default: recordFleetEventsBestEffort). */\n recordEvents: (events: FleetEvent[], now: Date) => Promise<void>;\n};\n\n/** Exit code for a fleet github-signals run. Exit 1 when failures are the\n * MAJORITY of the fleet (`failed > written`), not only on a total wipeout —\n * a run where 11/12 repos failed but 1 wrote should still signal an outage.\n * All-success or a minority of flakes (e.g. 1/12 failed) stays exit 0. The\n * no-token clean-skip returns 0 separately (before any probe runs). */\nexport function githubSignalsExitCode(written: number, failed: number): number {\n return failed > written ? 1 : 0;\n}\n\n/** `github-signals --fleet --write-airtable`: sweep every repo-backed site for its\n * Renovate-failing count + default-branch CI state + last-commit date, write each\n * row serially (Airtable ~5 req/sec), and emit FLEET_WRITE_SUMMARY for CI. A\n * missing fleet token is a clean skip (local runs), not a failure. */\nexport async function runGitHubSignalsCommand(\n opts: {\n fleet?: boolean | undefined;\n writeAirtable?: boolean | undefined;\n },\n deps: Partial<GitHubSignalsDeps> = {},\n): Promise<{ output: string; code: number }> {\n if (!opts.fleet || !opts.writeAirtable) {\n return { output: \"github-signals currently supports only --fleet --write-airtable\", code: 2 };\n }\n const token = process.env.RENOVATE_TOKEN?.trim() || process.env.GH_TOKEN?.trim();\n if (!token) {\n return {\n output: \"github-signals skipped: no RENOVATE_TOKEN/GH_TOKEN (fleet read) configured.\",\n code: 0,\n };\n }\n const base = deps.openBase ? deps.openBase() : openBase(readAirtableConfig());\n const websites = await listWebsites(base);\n const gh: GhProbes = deps.makeGh ? deps.makeGh(token) : makeGitHub({ token });\n const sites: Site[] = websites.map((w) => ({\n path: \"\",\n name: w.name,\n meta: {},\n ...(w.gitRepo ? { gitRepo: w.gitRepo } : {}),\n }));\n\n const skipped: string[] = [];\n const rows = await collectGitHubSignals(\n sites,\n {\n openPullRequests: (r) => gh.openPullRequests(r),\n defaultBranchStatus: (r) => gh.defaultBranchStatus(r),\n },\n ({ repo }) => skipped.push(repo),\n );\n\n const sweptAt = new Date().toISOString();\n // Phase 3 dual-write (#539): mirror each row's written FieldSet into\n // site_health. Null when libSQL creds are absent — the Airtable sweep\n // proceeds exactly as before. (Dynamic import so the no-mirror path never\n // loads the db client.)\n const makeMirror =\n deps.makeMirror ??\n (async () => {\n const { makeHealthMirrorBestEffort } = await import(\"../../audits/health-mirror.js\");\n return makeHealthMirrorBestEffort();\n });\n const mirror = await makeMirror();\n const result: FleetWriteResult = {\n written: [],\n failed: [],\n ...(mirror ? { mirrored: 0, mirrorFailed: 0, mirrorMissed: 0 } : {}),\n };\n const byRepo = new Map(websites.filter((w) => w.gitRepo).map((w) => [w.gitRepo, w]));\n const events: FleetEvent[] = [];\n const sweptMs = Date.parse(sweptAt);\n const since24h = new Date(sweptMs - 24 * 60 * 60 * 1000).toISOString();\n // Serial: Airtable's ~5 req/sec limit (matches writeFleetAuditsToAirtable).\n for (const row of rows) {\n const target = byRepo.get(row.repo);\n if (!target) {\n result.failed.push({ slug: siteSlug(row.site), error: \"no Websites row matched\" });\n continue;\n }\n try {\n const ghFields = await updateGitHubSignals(base, target.id, {\n renovateFailingCis: row.renovateFailingCis,\n ciState: row.ciState,\n lastCommitAt: row.lastCommitAt,\n sweptAt,\n });\n if (mirror) {\n // Count, never throw: a Turso blip must not move an Airtable-written\n // row into `failed` (that would red the sweep via githubSignalsExitCode\n // on a fleet-wide mirror outage). A 0-row match (site not yet imported)\n // is a miss, not a mirror — see FleetWriteResult.mirrorMissed.\n try {\n if (await mirror(target.id, ghFields)) {\n result.mirrored = (result.mirrored ?? 0) + 1;\n } else {\n result.mirrorMissed = (result.mirrorMissed ?? 0) + 1;\n }\n } catch (e) {\n result.mirrorFailed = (result.mirrorFailed ?? 0) + 1;\n console.error(`[health-mirror] ${target.name}: ${(e as Error).message}`);\n }\n }\n result.written.push({\n siteName: target.name,\n writes: [{ audit: \"github-signals\", counts: row }],\n });\n // Fleet-activity events for this repo: merged Renovate PRs since the last sweep\n // (watermark = the row's prior GitHub Signals At, else a 24h fallback) + a\n // CI-recovered transition. A PR-fetch hiccup drops only this repo's PR events.\n const since = target.githubSignalsAt ?? since24h;\n let merged: Awaited<ReturnType<typeof gh.mergedRenovatePullRequests>> = [];\n try {\n merged = await gh.mergedRenovatePullRequests(row.repo, since);\n } catch {\n // PR list unavailable this run — skip pr_automerged for this repo, keep ci_recovered\n }\n events.push(...detectSignalEvents(target, row, merged, sweptAt));\n } catch (e) {\n result.failed.push({ slug: siteSlug(row.site), error: (e as Error).message });\n }\n }\n for (const repo of skipped) result.failed.push({ slug: repo, error: \"probe failed (skipped)\" });\n\n events.push(fleetSweptEvent(\"github-signals\", result.written.length, sweptAt));\n await (deps.recordEvents ?? recordFleetEventsBestEffort)(events, new Date());\n\n // Exit non-zero when failures are the MAJORITY of the fleet, not only on a\n // total wipeout. A run where 11/12 repos failed but 1 wrote used to return 0,\n // masking a large outage. The nightly cron step is `continue-on-error`, so a\n // non-zero here is an operator-visibility signal, not a red build.\n return {\n output: formatFleetWriteSummary(result),\n code: githubSignalsExitCode(result.written.length, result.failed.length),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,qBACpB,OACA,MACA,SAAwC,MAAM;AAAC,GAClB;AAC7B,QAAM,OAA2B,CAAC;AAClC,aAAW,KAAK,OAAO;AACrB,UAAM,OAAO,EAAE;AACf,QAAI,CAAC,KAAM;AACX,UAAM,OAAO,EAAE;AACf,QAAI,CAAC,KAAM;AACX,QAAI;AACF,YAAM,MAAM,MAAM,KAAK,iBAAiB,IAAI;AAC5C,YAAM,SAAS,MAAM,KAAK,oBAAoB,IAAI;AAClD,WAAK,KAAK;AAAA,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AACnD,kBAAQ,MAAM,mBAAmB,OAAO,IAAI,KAAM,EAAY,OAAO,EAAE;AAAA,QACzE;AAAA,MACF;AACA,aAAO,QAAQ,KAAK;AAAA,QAClB,UAAU,OAAO;AAAA,QACjB,QAAQ,CAAC,EAAE,OAAO,kBAAkB,QAAQ,IAAI,CAAC;AAAA,MACnD,CAAC;AAID,YAAM,QAAQ,OAAO,mBAAmB;AACxC,UAAI,SAAoE,CAAC;AACzE,UAAI;AACF,iBAAS,MAAM,GAAG,2BAA2B,IAAI,MAAM,KAAK;AAAA,MAC9D,QAAQ;AAAA,MAER;AACA,aAAO,KAAK,GAAG,mBAAmB,QAAQ,KAAK,QAAQ,OAAO,CAAC;AAAA,IACjE,SAAS,GAAG;AACV,aAAO,OAAO,KAAK,EAAE,MAAM,SAAS,IAAI,IAAI,GAAG,OAAQ,EAAY,QAAQ,CAAC;AAAA,IAC9E;AAAA,EACF;AACA,aAAW,QAAQ,QAAS,QAAO,OAAO,KAAK,EAAE,MAAM,MAAM,OAAO,yBAAyB,CAAC;AAE9F,SAAO,KAAK,gBAAgB,kBAAkB,OAAO,QAAQ,QAAQ,OAAO,CAAC;AAC7E,SAAO,KAAK,gBAAgB,6BAA6B,QAAQ,oBAAI,KAAK,CAAC;AAM3E,SAAO;AAAA,IACL,QAAQ,wBAAwB,MAAM;AAAA,IACtC,MAAM,sBAAsB,OAAO,QAAQ,QAAQ,OAAO,OAAO,MAAM;AAAA,EACzE;AACF;","names":[]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
generateHeaderImage
|
|
3
|
-
} from "./chunk-37S6L6G4.js";
|
|
4
1
|
import {
|
|
5
2
|
uploadAttachment
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
ACTIVE_STATUSES,
|
|
9
|
-
listWebsites,
|
|
10
|
-
siteSlug
|
|
11
|
-
} from "./chunk-577HCGZO.js";
|
|
3
|
+
} from "./chunk-IY6256GK.js";
|
|
12
4
|
import {
|
|
13
5
|
openBase,
|
|
14
6
|
readAirtableConfig
|
|
15
7
|
} from "./chunk-HN6I2XWI.js";
|
|
8
|
+
import {
|
|
9
|
+
generateHeaderImage
|
|
10
|
+
} from "./chunk-5UINJNAJ.js";
|
|
11
|
+
import {
|
|
12
|
+
ACTIVE_STATUSES,
|
|
13
|
+
listWebsites,
|
|
14
|
+
siteSlug
|
|
15
|
+
} from "./chunk-7NYN2P6I.js";
|
|
16
16
|
import "./chunk-6VAL7XJT.js";
|
|
17
17
|
|
|
18
18
|
// src/cli/commands/header-image.ts
|
|
@@ -57,9 +57,25 @@ async function generateForTargets(targets, opts, generate = generateHeaderImage)
|
|
|
57
57
|
...settleMs === void 0 ? {} : { settleMs }
|
|
58
58
|
});
|
|
59
59
|
if (opts.writeAirtable) {
|
|
60
|
-
await uploadAttachment(row.id, "Header image", gen.bytes, gen.filename, gen.contentType
|
|
60
|
+
await uploadAttachment(row.id, "Header image", gen.bytes, gen.filename, gen.contentType, {
|
|
61
|
+
replaceIn: "Websites"
|
|
62
|
+
});
|
|
63
|
+
let stored = "";
|
|
64
|
+
if (opts.storeDb) {
|
|
65
|
+
try {
|
|
66
|
+
await opts.storeDb(row.id, {
|
|
67
|
+
bytes: gen.bytes,
|
|
68
|
+
filename: gen.filename,
|
|
69
|
+
contentType: gen.contentType,
|
|
70
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
71
|
+
});
|
|
72
|
+
stored = " + turso";
|
|
73
|
+
} catch (err) {
|
|
74
|
+
stored = ` (\u26A0 turso store FAILED: ${err instanceof Error ? err.message : String(err)})`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
61
77
|
lines.push(
|
|
62
|
-
`\u2714 ${row.name} \u2014 uploaded ${gen.filename} (${(gen.bytes.byteLength / 1024 / 1024).toFixed(2)} MB)`
|
|
78
|
+
`\u2714 ${row.name} \u2014 uploaded ${gen.filename} (${(gen.bytes.byteLength / 1024 / 1024).toFixed(2)} MB)${stored}`
|
|
63
79
|
);
|
|
64
80
|
} else {
|
|
65
81
|
const path = resolve(outDir, gen.filename);
|
|
@@ -84,7 +100,14 @@ async function runHeaderImageCommand(site, opts) {
|
|
|
84
100
|
code: 1
|
|
85
101
|
};
|
|
86
102
|
}
|
|
87
|
-
|
|
103
|
+
let withStore = opts;
|
|
104
|
+
if (opts.writeAirtable && !opts.storeDb && process.env.TURSO_DATABASE_URL) {
|
|
105
|
+
const { openDb, readDbConfig } = await import("./client-AUE3XUPO.js");
|
|
106
|
+
const { storeHeaderImage } = await import("./header-images-SQBCE5OD.js");
|
|
107
|
+
const db = await openDb(readDbConfig());
|
|
108
|
+
withStore = { ...opts, storeDb: (id, img) => storeHeaderImage(db, id, img) };
|
|
109
|
+
}
|
|
110
|
+
return generateForTargets(targets, withStore);
|
|
88
111
|
}
|
|
89
112
|
export {
|
|
90
113
|
generateForTargets,
|
|
@@ -92,4 +115,4 @@ export {
|
|
|
92
115
|
resolveTargets,
|
|
93
116
|
runHeaderImageCommand
|
|
94
117
|
};
|
|
95
|
-
//# sourceMappingURL=header-image-
|
|
118
|
+
//# sourceMappingURL=header-image-6IC53W27.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/header-image.ts"],"sourcesContent":["import { mkdir, writeFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { openBase, readAirtableConfig } from \"../../reports/airtable/client.js\";\nimport { listWebsites, siteSlug, ACTIVE_STATUSES } from \"../../reports/airtable/websites.js\";\nimport type { WebsiteRow } from \"../../reports/airtable/websites.js\";\nimport { uploadAttachment } from \"../../reports/airtable/attachments.js\";\nimport { generateHeaderImage } from \"../../reports/header-image/index.js\";\nimport type { StoredHeaderImage } from \"../../db/header-images.js\";\n\nexport type HeaderImageOptions = {\n all?: boolean;\n force?: boolean;\n writeAirtable?: boolean;\n outDir?: string;\n settleMs?: string;\n /** Injected Turso store for the dual-write (#539, design D5): while Airtable\n * is still written (until the Phase 5 freeze), every upload ALSO lands the\n * bytes in sites.header_image* so the Turso read layer serves a real image.\n * Absent → Airtable-only (a local run without Turso env still works). */\n storeDb?: (siteId: string, img: StoredHeaderImage) => Promise<void>;\n};\n\n/** Which rows this invocation should act on. Pure, so it is unit-tested. */\nexport function resolveTargets(\n rows: readonly WebsiteRow[],\n // `| undefined` spelled out because `exactOptionalPropertyTypes` otherwise\n // rejects the caller passing through possibly-undefined CLI flags.\n opts: { site?: string | undefined; all?: boolean | undefined; force?: boolean | undefined },\n): WebsiteRow[] {\n if (opts.site) {\n const want = siteSlug(opts.site);\n return rows.filter((r) => siteSlug(r.name) === want);\n }\n if (!opts.all) return [];\n return rows.filter((r) => {\n if (!r.url) return false;\n if (r.status === null || !ACTIVE_STATUSES.has(r.status)) return false;\n return opts.force ? true : !r.headerImage;\n });\n}\n\n/** Parse the `--settle-ms <ms>` flag. Unset → undefined (the generator's own\n * default settle). `Number(\"abc\")` is NaN, which would sail through as a NaN\n * timeout and silently skip the settle entirely, so anything non-finite or\n * negative is rejected up front rather than producing a subtly-wrong capture. */\nexport function parseSettleMs(value: string | undefined): number | undefined {\n if (value === undefined) return undefined;\n const n = Number(value);\n if (!Number.isFinite(n) || n < 0) {\n throw Object.assign(\n new Error(`--settle-ms must be a non-negative number of milliseconds, got \"${value}\"`),\n { exitCode: 2 },\n );\n }\n return n;\n}\n\n/** Injected in tests so the file-writing branch can be exercised without\n * driving a real browser (mirrors `GenerateInput.shooter`). */\ntype Generate = typeof generateHeaderImage;\n\n/**\n * Generate a header image per target row and either upload it to Airtable or\n * write it locally for review. Split out of {@link runHeaderImageCommand} so\n * the local-output path is testable without an Airtable base.\n */\nexport async function generateForTargets(\n targets: readonly WebsiteRow[],\n opts: HeaderImageOptions,\n generate: Generate = generateHeaderImage,\n): Promise<{ output: string; code: number }> {\n const outDir = resolve(opts.outDir ?? \"reports\");\n const settleMs = parseSettleMs(opts.settleMs);\n // `reports/` does not exist on a fresh checkout, so the writeFile() below\n // would throw ENOENT for the first operator to run the default (local) path.\n // Create it once, before the loop, rather than per site.\n if (!opts.writeAirtable) await mkdir(outDir, { recursive: true });\n\n const lines: string[] = [];\n let failed = 0;\n\n for (const row of targets) {\n try {\n const gen = await generate({\n url: row.url,\n slug: siteSlug(row.name),\n // `exactOptionalPropertyTypes` rejects an explicit `settleMs: undefined`\n // against `settleMs?: number`, so omit the key entirely when unset.\n ...(settleMs === undefined ? {} : { settleMs }),\n });\n if (opts.writeAirtable) {\n // replaceIn: the field must hold exactly the current header — see\n // uploadAttachment, where appending left readers on a stale [0].\n await uploadAttachment(row.id, \"Header image\", gen.bytes, gen.filename, gen.contentType, {\n replaceIn: \"Websites\",\n });\n let stored = \"\";\n if (opts.storeDb) {\n // Dual-write. A Turso failure must not void the Airtable upload —\n // but it must be VISIBLE, never a silent divergence.\n try {\n await opts.storeDb(row.id, {\n bytes: gen.bytes,\n filename: gen.filename,\n contentType: gen.contentType,\n generatedAt: new Date().toISOString(),\n });\n stored = \" + turso\";\n } catch (err) {\n stored = ` (⚠ turso store FAILED: ${err instanceof Error ? err.message : String(err)})`;\n }\n }\n lines.push(\n `✔ ${row.name} — uploaded ${gen.filename} (${(gen.bytes.byteLength / 1024 / 1024).toFixed(2)} MB)${stored}`,\n );\n } else {\n const path = resolve(outDir, gen.filename);\n await writeFile(path, gen.bytes);\n lines.push(`✔ ${row.name} — wrote ${path} (review, then re-run with --write-airtable)`);\n }\n } catch (err) {\n failed++;\n lines.push(`✖ ${row.name} — ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n\n lines.push(`${targets.length - failed}/${targets.length} generated.`);\n return { output: lines.join(\"\\n\"), code: failed > 0 ? 1 : 0 };\n}\n\n/**\n * `header-image [site]` — capture a site's live homepage and composite its\n * report header image. Defaults to writing the JPEG locally so the operator can\n * eyeball it; `--write-airtable` uploads it to the Websites row's Header image\n * field. `--all` backfills every live site that has no header image yet.\n */\nexport async function runHeaderImageCommand(\n site: string | undefined,\n opts: HeaderImageOptions,\n): Promise<{ output: string; code: number }> {\n const base = openBase(readAirtableConfig());\n const rows = await listWebsites(base);\n const targets = resolveTargets(rows, { site, all: opts.all, force: opts.force });\n if (targets.length === 0) {\n return {\n output: site ? `No site matched \"${site}\".` : \"No sites need a header image.\",\n code: 1,\n };\n }\n // Wire the Turso dual-write when the env is present; a local run without it\n // still works Airtable-only (the store is per-site error-isolated above).\n let withStore = opts;\n if (opts.writeAirtable && !opts.storeDb && process.env.TURSO_DATABASE_URL) {\n const { openDb, readDbConfig } = await import(\"../../db/client.js\");\n const { storeHeaderImage } = await import(\"../../db/header-images.js\");\n const db = await openDb(readDbConfig());\n withStore = { ...opts, storeDb: (id, img) => storeHeaderImage(db, id, img) };\n }\n return generateForTargets(targets, withStore);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,iBAAiB;AACjC,SAAS,eAAe;AAsBjB,SAAS,eACd,MAGA,MACc;AACd,MAAI,KAAK,MAAM;AACb,UAAM,OAAO,SAAS,KAAK,IAAI;AAC/B,WAAO,KAAK,OAAO,CAAC,MAAM,SAAS,EAAE,IAAI,MAAM,IAAI;AAAA,EACrD;AACA,MAAI,CAAC,KAAK,IAAK,QAAO,CAAC;AACvB,SAAO,KAAK,OAAO,CAAC,MAAM;AACxB,QAAI,CAAC,EAAE,IAAK,QAAO;AACnB,QAAI,EAAE,WAAW,QAAQ,CAAC,gBAAgB,IAAI,EAAE,MAAM,EAAG,QAAO;AAChE,WAAO,KAAK,QAAQ,OAAO,CAAC,EAAE;AAAA,EAChC,CAAC;AACH;AAMO,SAAS,cAAc,OAA+C;AAC3E,MAAI,UAAU,OAAW,QAAO;AAChC,QAAM,IAAI,OAAO,KAAK;AACtB,MAAI,CAAC,OAAO,SAAS,CAAC,KAAK,IAAI,GAAG;AAChC,UAAM,OAAO;AAAA,MACX,IAAI,MAAM,mEAAmE,KAAK,GAAG;AAAA,MACrF,EAAE,UAAU,EAAE;AAAA,IAChB;AAAA,EACF;AACA,SAAO;AACT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A8C;AAAA,MACxF;AAAA,IACF,SAAS,KAAK;AACZ;AACA,YAAM,KAAK,UAAK,IAAI,IAAI,WAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,EAAE;AAAA,IAClF;AAAA,EACF;AAEA,QAAM,KAAK,GAAG,QAAQ,SAAS,MAAM,IAAI,QAAQ,MAAM,aAAa;AACpE,SAAO,EAAE,QAAQ,MAAM,KAAK,IAAI,GAAG,MAAM,SAAS,IAAI,IAAI,EAAE;AAC9D;AAQA,eAAsB,sBACpB,MACA,MAC2C;AAC3C,QAAM,OAAO,SAAS,mBAAmB,CAAC;AAC1C,QAAM,OAAO,MAAM,aAAa,IAAI;AACpC,QAAM,UAAU,eAAe,MAAM,EAAE,MAAM,KAAK,KAAK,KAAK,OAAO,KAAK,MAAM,CAAC;AAC/E,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO;AAAA,MACL,QAAQ,OAAO,oBAAoB,IAAI,OAAO;AAAA,MAC9C,MAAM;AAAA,IACR;AAAA,EACF;AAGA,MAAI,YAAY;AAChB,MAAI,KAAK,iBAAiB,CAAC,KAAK,WAAW,QAAQ,IAAI,oBAAoB;AACzE,UAAM,EAAE,QAAQ,aAAa,IAAI,MAAM,OAAO,sBAAoB;AAClE,UAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,6BAA2B;AACrE,UAAM,KAAK,MAAM,OAAO,aAAa,CAAC;AACtC,gBAAY,EAAE,GAAG,MAAM,SAAS,CAAC,IAAI,QAAQ,iBAAiB,IAAI,IAAI,GAAG,EAAE;AAAA,EAC7E;AACA,SAAO,mBAAmB,SAAS,SAAS;AAC9C;","names":[]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/db/header-images.ts
|
|
2
|
+
async function storeHeaderImage(db, siteId, image) {
|
|
3
|
+
await db.updateTable("sites").set({
|
|
4
|
+
header_image: image.bytes,
|
|
5
|
+
header_image_filename: image.filename,
|
|
6
|
+
header_image_type: image.contentType,
|
|
7
|
+
header_image_generated_at: image.generatedAt
|
|
8
|
+
}).where("id", "=", siteId).execute();
|
|
9
|
+
}
|
|
10
|
+
async function loadHeaderImage(db, siteId) {
|
|
11
|
+
const row = await db.selectFrom("sites").select([
|
|
12
|
+
"header_image",
|
|
13
|
+
"header_image_filename",
|
|
14
|
+
"header_image_type",
|
|
15
|
+
"header_image_generated_at"
|
|
16
|
+
]).where("id", "=", siteId).executeTakeFirst();
|
|
17
|
+
if (!row) return null;
|
|
18
|
+
const raw = row.header_image;
|
|
19
|
+
if (raw === null || raw === void 0) return null;
|
|
20
|
+
const bytes = new Uint8Array(raw);
|
|
21
|
+
if (bytes.length === 0) return null;
|
|
22
|
+
return {
|
|
23
|
+
bytes,
|
|
24
|
+
filename: row.header_image_filename ?? "header-image",
|
|
25
|
+
contentType: row.header_image_type ?? "application/octet-stream",
|
|
26
|
+
generatedAt: row.header_image_generated_at ?? null
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function headerImageAttachment(rec) {
|
|
30
|
+
const atts = rec.fields["Header image"];
|
|
31
|
+
const a = atts?.at(-1);
|
|
32
|
+
return a && typeof a.url === "string" && a.url.length > 0 ? {
|
|
33
|
+
url: a.url,
|
|
34
|
+
filename: typeof a.filename === "string" ? a.filename : "header-image",
|
|
35
|
+
type: typeof a.type === "string" ? a.type : "application/octet-stream"
|
|
36
|
+
} : null;
|
|
37
|
+
}
|
|
38
|
+
async function backfillHeaderImages(db, io) {
|
|
39
|
+
const records = await io.listWebsiteRecords();
|
|
40
|
+
const populated = new Set(
|
|
41
|
+
(await db.selectFrom("sites").select("id").where("header_image", "is not", null).execute()).map(
|
|
42
|
+
(r) => r.id
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
const result = { stored: 0, skipped: 0, absent: 0, failed: [] };
|
|
46
|
+
for (const rec of records) {
|
|
47
|
+
const att = headerImageAttachment(rec);
|
|
48
|
+
if (!att) {
|
|
49
|
+
result.absent++;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (populated.has(rec.id)) {
|
|
53
|
+
result.skipped++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const bytes = await io.fetchBytes(att.url);
|
|
57
|
+
if (bytes === null) {
|
|
58
|
+
result.failed.push(rec.id);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
await storeHeaderImage(db, rec.id, {
|
|
62
|
+
bytes,
|
|
63
|
+
filename: att.filename,
|
|
64
|
+
contentType: att.type,
|
|
65
|
+
generatedAt: null
|
|
66
|
+
});
|
|
67
|
+
result.stored++;
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
function formatBackfillResult(r) {
|
|
72
|
+
const lines = [];
|
|
73
|
+
if (r.failed.length > 0) {
|
|
74
|
+
lines.push(`\u26A0 ${r.failed.length} attachment fetch(es) failed: ${r.failed.join(", ")}`);
|
|
75
|
+
}
|
|
76
|
+
lines.push(
|
|
77
|
+
`HEADER_IMAGE_BACKFILL stored=${r.stored} skipped=${r.skipped} absent=${r.absent} failed=${r.failed.length}`
|
|
78
|
+
);
|
|
79
|
+
return lines.join("\n");
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
backfillHeaderImages,
|
|
83
|
+
formatBackfillResult,
|
|
84
|
+
headerImageAttachment,
|
|
85
|
+
loadHeaderImage,
|
|
86
|
+
storeHeaderImage
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=header-images-SQBCE5OD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/db/header-images.ts"],"sourcesContent":["/** Header images move to Turso (#539, design D5 completed).\n *\n * Since Phase 1 the schema has reserved `sites.header_image*` as the image's\n * home — the importer deliberately never touches those columns — but nothing\n * wrote them, so the read layer's `headerImage` was null fleet-wide and both\n * cockpit preflight and approve-report stayed pinned to the Airtable reader.\n * Two writers and one reader close that:\n *\n * - `storeHeaderImage` — the shared write, used by the header-image CLI's\n * dual-write (Airtable upload + Turso store, until Phase 5 freezes Airtable)\n * and by the backfill.\n * - `loadHeaderImage` — the reader. Until it existed the bytes went in and could\n * not come out, so every consumer still fetched Airtable's signed URL.\n * - `backfillHeaderImages` — one-shot: copy every site's CURRENT Airtable\n * attachment into Turso. Idempotent — a site whose BLOB is already\n * populated is skipped, so re-runs never clobber a freshly generated image\n * with a stale Airtable copy. Emits its machine line on EVERY run.\n */\nimport type { Db } from \"./client.js\";\nimport type { RawRecord } from \"./import-airtable.js\";\n\nexport type StoredHeaderImage = {\n bytes: Uint8Array;\n filename: string;\n contentType: string;\n /** The generator's stamp; null for a backfilled copy (a backfill is not a\n * generation — the column keeps meaning \"when the generator made it\"). */\n generatedAt: string | null;\n};\n\nexport async function storeHeaderImage(\n db: Db,\n siteId: string,\n image: StoredHeaderImage,\n): Promise<void> {\n await db\n .updateTable(\"sites\")\n .set({\n header_image: image.bytes,\n header_image_filename: image.filename,\n header_image_type: image.contentType,\n header_image_generated_at: image.generatedAt,\n })\n .where(\"id\", \"=\", siteId)\n .execute();\n}\n\n/**\n * Read one site's stored header image back.\n *\n * A SEPARATE query from the site read, deliberately. `getSiteBySlug` excludes\n * the BLOB on purpose — it is 0.6–0.8 MB per site in production, so a selectAll\n * would haul megabytes into every dashboard GET and every form ingest — which\n * means reading the bytes has to be an explicit, per-site act rather than a\n * field that arrives for free.\n *\n * Null when the site has no image, when the id is unknown, and when the\n * metadata is present but the BLOB is not: handing a consumer an empty buffer\n * with a filename would render a report with a broken header instead of failing\n * loudly with \"no header image\".\n */\nexport async function loadHeaderImage(db: Db, siteId: string): Promise<StoredHeaderImage | null> {\n const row = await db\n .selectFrom(\"sites\")\n .select([\n \"header_image\",\n \"header_image_filename\",\n \"header_image_type\",\n \"header_image_generated_at\",\n ])\n .where(\"id\", \"=\", siteId)\n .executeTakeFirst();\n if (!row) return null;\n // Normalize BEFORE measuring. libSQL can hand the BLOB back as an ArrayBuffer\n // rather than a Uint8Array, and an ArrayBuffer has `byteLength`, not `length` —\n // so a naive `bytes.length === 0` compares `undefined` to 0, passes, and lets a\n // zero-length image through as if it were real. Mutation-testing the null check\n // is what exposed that; the guard did not do what its own name said.\n const raw = row.header_image;\n if (raw === null || raw === undefined) return null;\n // `raw` is a Uint8Array on some drivers and an ArrayBuffer on others; the\n // Uint8Array constructor accepts either, but the two do not share a TS type.\n const bytes = new Uint8Array(raw as unknown as ArrayBufferLike);\n if (bytes.length === 0) return null;\n\n return {\n bytes,\n filename: row.header_image_filename ?? \"header-image\",\n contentType: row.header_image_type ?? \"application/octet-stream\",\n generatedAt: row.header_image_generated_at ?? null,\n };\n}\n\ntype Attachment = { url: string; filename: string; type: string };\n\n/** NEWEST \"Header image\" attachment of a raw Websites record, or null.\n *\n * The tail, not the head: Airtable's uploadAttachment APPENDS, so a field that ever\n * held more than one file served its OLDEST image from `[0]` forever — see the note\n * in `reports/airtable/websites.ts` and #574/#577. Kept in step with that reader so\n * the Turso mirror and the send path can never disagree about which file is current. */\nexport function headerImageAttachment(rec: RawRecord): Attachment | null {\n const atts = rec.fields[\"Header image\"] as Array<Partial<Attachment>> | undefined;\n const a = atts?.at(-1);\n return a && typeof a.url === \"string\" && a.url.length > 0\n ? {\n url: a.url,\n filename: typeof a.filename === \"string\" ? a.filename : \"header-image\",\n type: typeof a.type === \"string\" ? a.type : \"application/octet-stream\",\n }\n : null;\n}\n\nexport type BackfillIo = {\n listWebsiteRecords: () => Promise<RawRecord[]>;\n /** Fetch attachment bytes; null on failure (named in the summary, not fatal). */\n fetchBytes: (url: string) => Promise<Uint8Array | null>;\n};\n\nexport type BackfillResult = {\n stored: number;\n /** Sites whose BLOB was already populated — never overwritten. */\n skipped: number;\n /** Sites with no Airtable attachment at all. */\n absent: number;\n /** Record ids whose attachment fetch failed — named, never silent. */\n failed: string[];\n};\n\nexport async function backfillHeaderImages(db: Db, io: BackfillIo): Promise<BackfillResult> {\n const records = await io.listWebsiteRecords();\n const populated = new Set(\n (await db.selectFrom(\"sites\").select(\"id\").where(\"header_image\", \"is not\", null).execute()).map(\n (r) => r.id,\n ),\n );\n const result: BackfillResult = { stored: 0, skipped: 0, absent: 0, failed: [] };\n for (const rec of records) {\n const att = headerImageAttachment(rec);\n if (!att) {\n result.absent++;\n continue;\n }\n if (populated.has(rec.id)) {\n result.skipped++;\n continue;\n }\n const bytes = await io.fetchBytes(att.url);\n if (bytes === null) {\n result.failed.push(rec.id);\n continue;\n }\n await storeHeaderImage(db, rec.id, {\n bytes,\n filename: att.filename,\n contentType: att.type,\n generatedAt: null,\n });\n result.stored++;\n }\n return result;\n}\n\n/** Human lines + the machine line, emitted on every run (count=0 included). */\nexport function formatBackfillResult(r: BackfillResult): string {\n const lines: string[] = [];\n if (r.failed.length > 0) {\n lines.push(`⚠ ${r.failed.length} attachment fetch(es) failed: ${r.failed.join(\", \")}`);\n }\n lines.push(\n `HEADER_IMAGE_BACKFILL stored=${r.stored} skipped=${r.skipped} absent=${r.absent} failed=${r.failed.length}`,\n );\n return lines.join(\"\\n\");\n}\n"],"mappings":";AA8BA,eAAsB,iBACpB,IACA,QACA,OACe;AACf,QAAM,GACH,YAAY,OAAO,EACnB,IAAI;AAAA,IACH,cAAc,MAAM;AAAA,IACpB,uBAAuB,MAAM;AAAA,IAC7B,mBAAmB,MAAM;AAAA,IACzB,2BAA2B,MAAM;AAAA,EACnC,CAAC,EACA,MAAM,MAAM,KAAK,MAAM,EACvB,QAAQ;AACb;AAgBA,eAAsB,gBAAgB,IAAQ,QAAmD;AAC/F,QAAM,MAAM,MAAM,GACf,WAAW,OAAO,EAClB,OAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC,EACA,MAAM,MAAM,KAAK,MAAM,EACvB,iBAAiB;AACpB,MAAI,CAAC,IAAK,QAAO;AAMjB,QAAM,MAAM,IAAI;AAChB,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAG9C,QAAM,QAAQ,IAAI,WAAW,GAAiC;AAC9D,MAAI,MA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AAa;AAAA,IACf,CAAC;AACD,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAGO,SAAS,qBAAqB,GAA2B;AAC9D,QAAM,QAAkB,CAAC;AACzB,MAAI,EAAE,OAAO,SAAS,GAAG;AACvB,UAAM,KAAK,UAAK,EAAE,OAAO,MAAM,iCAAiC,EAAE,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,EACvF;AACA,QAAM;AAAA,IACJ,gCAAgC,EAAE,MAAM,YAAY,EAAE,OAAO,WAAW,EAAE,MAAM,WAAW,EAAE,OAAO,MAAM;AAAA,EAC5G;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
|
|
@@ -5,20 +5,20 @@ import {
|
|
|
5
5
|
appendSkipNotice,
|
|
6
6
|
fleetWorkdir,
|
|
7
7
|
prepareFleetSites
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TVL5MVUF.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveSites
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-CROKUHJB.js";
|
|
12
12
|
import {
|
|
13
13
|
healthEndpoint
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BQRFQSGY.js";
|
|
15
15
|
import "./chunk-R53VL3RI.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-XXTZBPUY.js";
|
|
16
|
+
import "./chunk-3G25KIWW.js";
|
|
17
|
+
import "./chunk-6TWWY7ZU.js";
|
|
18
|
+
import "./chunk-EVBCK2KC.js";
|
|
20
19
|
import "./chunk-XTK5VIQB.js";
|
|
21
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-LBYOLBW7.js";
|
|
21
|
+
import "./chunk-XXTZBPUY.js";
|
|
22
22
|
|
|
23
23
|
// src/cli/commands/health-endpoint.ts
|
|
24
24
|
import { resolve } from "path";
|
|
@@ -51,4 +51,4 @@ async function runHealthEndpointCommand(site, opts) {
|
|
|
51
51
|
export {
|
|
52
52
|
runHealthEndpointCommand
|
|
53
53
|
};
|
|
54
|
-
//# sourceMappingURL=health-endpoint-
|
|
54
|
+
//# sourceMappingURL=health-endpoint-RFXL2F4A.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mirrorHealthFields,
|
|
3
|
+
mirrorScheduleFields
|
|
4
|
+
} from "./chunk-HHMMUR4P.js";
|
|
5
|
+
import "./chunk-P6AORG32.js";
|
|
6
|
+
import "./chunk-F3JWOPTG.js";
|
|
7
|
+
import "./chunk-VAD43MOR.js";
|
|
8
|
+
import "./chunk-7NYN2P6I.js";
|
|
9
|
+
import {
|
|
10
|
+
openDb,
|
|
11
|
+
readDbConfig
|
|
12
|
+
} from "./chunk-JHGHLKFS.js";
|
|
13
|
+
import "./chunk-3SF7D4DY.js";
|
|
14
|
+
import "./chunk-6VAL7XJT.js";
|
|
15
|
+
|
|
16
|
+
// src/audits/health-mirror.ts
|
|
17
|
+
async function makeHealthMirrorBestEffort(open = () => openDb(readDbConfig())) {
|
|
18
|
+
let db;
|
|
19
|
+
try {
|
|
20
|
+
db = await open();
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.error(`[health-mirror] mirroring disabled: no libSQL (${String(e)})`);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return (siteId, fields) => mirrorHealthFields(db, siteId, fields);
|
|
26
|
+
}
|
|
27
|
+
async function makeScheduleMirrorBestEffort(open = () => openDb(readDbConfig())) {
|
|
28
|
+
let db;
|
|
29
|
+
try {
|
|
30
|
+
db = await open();
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.error(`[schedule-mirror] mirroring disabled: no libSQL (${String(e)})`);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return (siteId, fields, computedAt) => mirrorScheduleFields(db, siteId, fields, computedAt);
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
makeHealthMirrorBestEffort,
|
|
39
|
+
makeScheduleMirrorBestEffort
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=health-mirror-L5JBEJVA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/audits/health-mirror.ts"],"sourcesContent":["import { openDb, readDbConfig, type Db } from \"../db/client.js\";\nimport { mirrorHealthFields, mirrorScheduleFields } from \"../db/fleet-state.js\";\n\n/** One site's just-written Airtable FieldSet, mirrored into site_health.\n * Resolves true when a site_health row matched; false when the UPDATE touched\n * 0 rows (site created in Airtable after the last hourly import) — callers\n * count that as mirror_missed, never as mirrored. */\nexport type HealthMirror = (siteId: string, fields: Record<string, unknown>) => Promise<boolean>;\n\n/** The site_schedule twin, for the nightly next-due write-back. Same\n * matched-row contract as {@link HealthMirror}: false = 0-row UPDATE →\n * mirror_missed. */\nexport type ScheduleMirror = (\n siteId: string,\n fields: Record<string, unknown>,\n computedAt: string,\n) => Promise<boolean>;\n\n/** Build the Turso write-through for the nightly writers (#539 Phase 3\n * dual-write), or null when libSQL creds are absent — mirroring NOT attempted\n * is a different outcome than mirroring failed, and the caller's summary line\n * reports mirror counts only when a mirror existed. Same contract as\n * recordFleetEventsBestEffort: the mirror must never fail the sweep that\n * produced the data (per-site failures are the caller's to count; Airtable\n * stays authoritative and the hourly sync converges whatever the mirror\n * missed). `open` is injectable for tests. */\nexport async function makeHealthMirrorBestEffort(\n open: () => Promise<Db> = () => openDb(readDbConfig()),\n): Promise<HealthMirror | null> {\n let db: Db;\n try {\n db = await open();\n } catch (e) {\n console.error(`[health-mirror] mirroring disabled: no libSQL (${String(e)})`);\n return null;\n }\n return (siteId, fields) => mirrorHealthFields(db, siteId, fields);\n}\n\n/** {@link makeHealthMirrorBestEffort}'s schedule twin — same null-without-creds\n * contract, for `writeNextDueDates`' site_schedule write-through. */\nexport async function makeScheduleMirrorBestEffort(\n open: () => Promise<Db> = () => openDb(readDbConfig()),\n): Promise<ScheduleMirror | null> {\n let db: Db;\n try {\n db = await open();\n } catch (e) {\n console.error(`[schedule-mirror] mirroring disabled: no libSQL (${String(e)})`);\n return null;\n }\n return (siteId, fields, computedAt) => mirrorScheduleFields(db, siteId, fields, computedAt);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,eAAsB,2BACpB,OAA0B,MAAM,OAAO,aAAa,CAAC,GACvB;AAC9B,MAAI;AACJ,MAAI;AACF,SAAK,MAAM,KAAK;AAAA,EAClB,SAAS,GAAG;AACV,YAAQ,MAAM,kDAAkD,OAAO,CAAC,CAAC,GAAG;AAC5E,WAAO;AAAA,EACT;AACA,SAAO,CAAC,QAAQ,WAAW,mBAAmB,IAAI,QAAQ,MAAM;AAClE;AAIA,eAAsB,6BACpB,OAA0B,MAAM,OAAO,aAAa,CAAC,GACrB;AAChC,MAAI;AACJ,MAAI;AACF,SAAK,MAAM,KAAK;AAAA,EAClB,SAAS,GAAG;AACV,YAAQ,MAAM,oDAAoD,OAAO,CAAC,CAAC,GAAG;AAC9E,WAAO;AAAA,EACT;AACA,SAAO,CAAC,QAAQ,QAAQ,eAAe,qBAAqB,IAAI,QAAQ,QAAQ,UAAU;AAC5F;","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EXCLUDED_WEBSITE_FIELDS,
|
|
3
|
+
HEALTH_BOOLEAN,
|
|
4
|
+
HEALTH_FIELDS,
|
|
5
|
+
SCHEDULE_FIELDS,
|
|
6
|
+
SITE_FIELDS,
|
|
7
|
+
formatReapSummary,
|
|
8
|
+
healthColumnFor,
|
|
9
|
+
importFleetState,
|
|
10
|
+
mapReportRecord,
|
|
11
|
+
mapWebsiteRecord,
|
|
12
|
+
reapAllowance,
|
|
13
|
+
reapRefusal,
|
|
14
|
+
renderedHtmlUrl,
|
|
15
|
+
scheduleColumnFor,
|
|
16
|
+
siteValueFor
|
|
17
|
+
} from "./chunk-P6AORG32.js";
|
|
18
|
+
import "./chunk-VAD43MOR.js";
|
|
19
|
+
import "./chunk-7NYN2P6I.js";
|
|
20
|
+
export {
|
|
21
|
+
EXCLUDED_WEBSITE_FIELDS,
|
|
22
|
+
HEALTH_BOOLEAN,
|
|
23
|
+
HEALTH_FIELDS,
|
|
24
|
+
SCHEDULE_FIELDS,
|
|
25
|
+
SITE_FIELDS,
|
|
26
|
+
formatReapSummary,
|
|
27
|
+
healthColumnFor,
|
|
28
|
+
importFleetState,
|
|
29
|
+
mapReportRecord,
|
|
30
|
+
mapWebsiteRecord,
|
|
31
|
+
reapAllowance,
|
|
32
|
+
reapRefusal,
|
|
33
|
+
renderedHtmlUrl,
|
|
34
|
+
scheduleColumnFor,
|
|
35
|
+
siteValueFor
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=import-airtable-OHVY344G.js.map
|