@reddoorla/maintenance 0.91.0 → 0.92.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/dist/{bump-deps-KGH5UYSF.js → bump-deps-GI7PHMOC.js} +6 -6
- package/dist/{chunk-A6T2R63Z.js → chunk-3HS6LPFX.js} +2 -2
- package/dist/{chunk-UXJZU23T.js → chunk-4NUKMPOO.js} +9 -9
- package/dist/{chunk-BQRFQSGY.js → chunk-4R3YAQNV.js} +2 -2
- package/dist/{chunk-JRHIFA5R.js → chunk-5XMKJX74.js} +10 -4
- package/dist/chunk-5XMKJX74.js.map +1 -0
- package/dist/{chunk-XIDUYLSR.js → chunk-7CJ3DVZW.js} +2 -2
- package/dist/{chunk-Z3KYFUN6.js → chunk-B6NUZ2ZX.js} +2 -2
- package/dist/{chunk-WVVT6SJK.js → chunk-BJQCIJOY.js} +169 -17
- package/dist/chunk-BJQCIJOY.js.map +1 -0
- package/dist/{chunk-Y53WOQIJ.js → chunk-CVJF2IC5.js} +2 -2
- package/dist/{chunk-QD427NIO.js → chunk-JB4Q3C3M.js} +7 -7
- package/dist/{chunk-IYSEC543.js → chunk-LS6QPANO.js} +2 -2
- package/dist/{chunk-SJOXWJ5Y.js → chunk-M2XF6JAI.js} +80 -9
- package/dist/chunk-M2XF6JAI.js.map +1 -0
- package/dist/{chunk-7RJ2HMMJ.js → chunk-NTLSMJHW.js} +2 -2
- package/dist/chunk-PJ23RDHT.js +48 -0
- package/dist/chunk-PJ23RDHT.js.map +1 -0
- package/dist/{chunk-2NJQLSEU.js → chunk-PPIZHDJL.js} +2 -2
- package/dist/{chunk-RQLXEMEE.js → chunk-T7ZUUOZ2.js} +2 -2
- package/dist/chunk-T7ZUUOZ2.js.map +1 -0
- package/dist/{chunk-TVL5MVUF.js → chunk-TCF6S7AD.js} +4 -4
- package/dist/{chunk-GSWTT2J6.js → chunk-WHWVYL7B.js} +4 -4
- package/dist/{chunk-3G25KIWW.js → chunk-ZTPPCHDB.js} +4 -4
- package/dist/cli/bin.js +17 -17
- package/dist/cli/commands/audit.js +10 -10
- package/dist/{convert-to-pnpm-NWB5FCQ2.js → convert-to-pnpm-ONFP3JKF.js} +6 -6
- package/dist/{db-IMMQSRAB.js → db-DJVW6ZSE.js} +3 -3
- package/dist/digest-EOA4JLTV.js +1 -1
- package/dist/digest-collectors-ZA3BTS3R.js +1 -1
- package/dist/{email-PLPDJUDH.js → email-I4BCETI4.js} +16 -65
- package/dist/email-I4BCETI4.js.map +1 -0
- package/dist/forms/index.d.ts +5 -1
- package/dist/forms/index.js +1 -1
- package/dist/forms/index.js.map +1 -1
- package/dist/forms/prismic.d.ts +69 -0
- package/dist/forms/prismic.js +75 -0
- package/dist/forms/prismic.js.map +1 -0
- package/dist/{forms-notify-target-YCZUAHTY.js → forms-notify-target-MNNOGSJ7.js} +4 -3
- package/dist/{forms-notify-target-YCZUAHTY.js.map → forms-notify-target-MNNOGSJ7.js.map} +1 -1
- package/dist/{health-endpoint-UVX6R5N5.js → health-endpoint-DHKJUPRM.js} +6 -6
- package/dist/index.js +30 -23
- package/dist/index.js.map +1 -1
- package/dist/{init-NXZ4NXTL.js → init-ZRKWYCKA.js} +15 -15
- package/dist/{launch-WPEQ3TY2.js → launch-6X5OXPF2.js} +11 -11
- package/dist/{notify-4HP4GZ2H.js → notify-FYSOWKMJ.js} +4 -3
- package/dist/{onboard-BKCYBAVW.js → onboard-6NHGCKGB.js} +6 -6
- package/dist/orchestrate-KMQIUP3H.js +1 -1
- package/dist/{pipeline-HQJYZ443.js → pipeline-AQBFG5WM.js} +5 -3
- package/dist/preflight-VPHQYWTY.js +1 -1
- package/dist/{prismic-ci-6YGRIOHT.js → prismic-ci-A2HI7NNJ.js} +8 -8
- package/dist/{prismic-models-FPDSUXDO.js → prismic-models-QTKIMFBC.js} +4 -4
- package/dist/prospect/types.d.ts +17 -0
- package/dist/prospect/types.js +1 -1
- package/dist/{prospect-audit-TFIXSTE5.js → prospect-audit-RKUVSTLN.js} +4 -4
- package/dist/recipes/sync-configs.js +3 -3
- package/dist/{chunk-H6BLTEFN.js → render-7G43BSK5.js} +3 -3
- package/dist/{chunk-H6BLTEFN.js.map → render-7G43BSK5.js.map} +1 -1
- package/dist/{replay-4S6ENYCH.js → replay-HV7MGKBU.js} +3 -2
- package/dist/{replay-4S6ENYCH.js.map → replay-HV7MGKBU.js.map} +1 -1
- package/dist/{self-updating-VQIW24RZ.js → self-updating-D5XOWS7V.js} +5 -5
- package/dist/selftest-IFGSJP4X.js +1 -1
- package/dist/{smoke-suite-4JFZZYVW.js → smoke-suite-GXC5JZPH.js} +6 -6
- package/dist/{svelte-codemods-QAPDZC6F.js → svelte-codemods-A3EARSRP.js} +6 -6
- package/dist/{sync-configs-PVRLZRKL.js → sync-configs-KSESOHFF.js} +6 -6
- package/dist/{upgrade-IR2OO3KP.js → upgrade-ZLNVEIEA.js} +6 -6
- package/dist/{webflow-624FEBFD.js → webflow-IRKOIT7S.js} +4 -4
- package/package.json +5 -1
- package/dist/chunk-JRHIFA5R.js.map +0 -1
- package/dist/chunk-RQLXEMEE.js.map +0 -1
- package/dist/chunk-SJOXWJ5Y.js.map +0 -1
- package/dist/chunk-WVVT6SJK.js.map +0 -1
- package/dist/email-PLPDJUDH.js.map +0 -1
- package/dist/render-3GYW2J34.js +0 -11
- package/dist/render-3GYW2J34.js.map +0 -1
- /package/dist/{bump-deps-KGH5UYSF.js.map → bump-deps-GI7PHMOC.js.map} +0 -0
- /package/dist/{chunk-A6T2R63Z.js.map → chunk-3HS6LPFX.js.map} +0 -0
- /package/dist/{chunk-UXJZU23T.js.map → chunk-4NUKMPOO.js.map} +0 -0
- /package/dist/{chunk-BQRFQSGY.js.map → chunk-4R3YAQNV.js.map} +0 -0
- /package/dist/{chunk-XIDUYLSR.js.map → chunk-7CJ3DVZW.js.map} +0 -0
- /package/dist/{chunk-Z3KYFUN6.js.map → chunk-B6NUZ2ZX.js.map} +0 -0
- /package/dist/{chunk-Y53WOQIJ.js.map → chunk-CVJF2IC5.js.map} +0 -0
- /package/dist/{chunk-QD427NIO.js.map → chunk-JB4Q3C3M.js.map} +0 -0
- /package/dist/{chunk-IYSEC543.js.map → chunk-LS6QPANO.js.map} +0 -0
- /package/dist/{chunk-7RJ2HMMJ.js.map → chunk-NTLSMJHW.js.map} +0 -0
- /package/dist/{chunk-2NJQLSEU.js.map → chunk-PPIZHDJL.js.map} +0 -0
- /package/dist/{chunk-TVL5MVUF.js.map → chunk-TCF6S7AD.js.map} +0 -0
- /package/dist/{chunk-GSWTT2J6.js.map → chunk-WHWVYL7B.js.map} +0 -0
- /package/dist/{chunk-3G25KIWW.js.map → chunk-ZTPPCHDB.js.map} +0 -0
- /package/dist/{convert-to-pnpm-NWB5FCQ2.js.map → convert-to-pnpm-ONFP3JKF.js.map} +0 -0
- /package/dist/{db-IMMQSRAB.js.map → db-DJVW6ZSE.js.map} +0 -0
- /package/dist/{health-endpoint-UVX6R5N5.js.map → health-endpoint-DHKJUPRM.js.map} +0 -0
- /package/dist/{init-NXZ4NXTL.js.map → init-ZRKWYCKA.js.map} +0 -0
- /package/dist/{launch-WPEQ3TY2.js.map → launch-6X5OXPF2.js.map} +0 -0
- /package/dist/{notify-4HP4GZ2H.js.map → notify-FYSOWKMJ.js.map} +0 -0
- /package/dist/{onboard-BKCYBAVW.js.map → onboard-6NHGCKGB.js.map} +0 -0
- /package/dist/{pipeline-HQJYZ443.js.map → pipeline-AQBFG5WM.js.map} +0 -0
- /package/dist/{prismic-ci-6YGRIOHT.js.map → prismic-ci-A2HI7NNJ.js.map} +0 -0
- /package/dist/{prismic-models-FPDSUXDO.js.map → prismic-models-QTKIMFBC.js.map} +0 -0
- /package/dist/{prospect-audit-TFIXSTE5.js.map → prospect-audit-RKUVSTLN.js.map} +0 -0
- /package/dist/{self-updating-VQIW24RZ.js.map → self-updating-D5XOWS7V.js.map} +0 -0
- /package/dist/{smoke-suite-4JFZZYVW.js.map → smoke-suite-GXC5JZPH.js.map} +0 -0
- /package/dist/{svelte-codemods-QAPDZC6F.js.map → svelte-codemods-A3EARSRP.js.map} +0 -0
- /package/dist/{sync-configs-PVRLZRKL.js.map → sync-configs-KSESOHFF.js.map} +0 -0
- /package/dist/{upgrade-IR2OO3KP.js.map → upgrade-ZLNVEIEA.js.map} +0 -0
- /package/dist/{webflow-624FEBFD.js.map → webflow-IRKOIT7S.js.map} +0 -0
|
@@ -5,19 +5,19 @@ import {
|
|
|
5
5
|
appendSkipNotice,
|
|
6
6
|
fleetWorkdir,
|
|
7
7
|
prepareFleetSites
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TCF6S7AD.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveSites
|
|
11
11
|
} from "./chunk-Q47DU255.js";
|
|
12
12
|
import {
|
|
13
13
|
bumpDeps
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-PPIZHDJL.js";
|
|
15
|
+
import "./chunk-ZTPPCHDB.js";
|
|
16
16
|
import "./chunk-Z3JXLULD.js";
|
|
17
|
-
import "./chunk-RARREDQE.js";
|
|
18
|
-
import "./chunk-XTK5VIQB.js";
|
|
19
17
|
import "./chunk-LBYOLBW7.js";
|
|
18
|
+
import "./chunk-RARREDQE.js";
|
|
20
19
|
import "./chunk-XXTZBPUY.js";
|
|
20
|
+
import "./chunk-XTK5VIQB.js";
|
|
21
21
|
|
|
22
22
|
// src/cli/commands/bump-deps.ts
|
|
23
23
|
import { resolve } from "path";
|
|
@@ -57,4 +57,4 @@ async function runBumpDepsCommand(site, opts) {
|
|
|
57
57
|
export {
|
|
58
58
|
runBumpDepsCommand
|
|
59
59
|
};
|
|
60
|
-
//# sourceMappingURL=bump-deps-
|
|
60
|
+
//# sourceMappingURL=bump-deps-GI7PHMOC.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withRecipe
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZTPPCHDB.js";
|
|
4
4
|
import {
|
|
5
5
|
ALL_TEMPLATES,
|
|
6
6
|
RENOVATE_ACTION_CONFIG,
|
|
@@ -229,4 +229,4 @@ export {
|
|
|
229
229
|
planTemplateDiffs,
|
|
230
230
|
syncConfigs
|
|
231
231
|
};
|
|
232
|
-
//# sourceMappingURL=chunk-
|
|
232
|
+
//# sourceMappingURL=chunk-3HS6LPFX.js.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
convertToPnpm
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7CJ3DVZW.js";
|
|
4
4
|
import {
|
|
5
5
|
svelteCodemods
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LS6QPANO.js";
|
|
7
7
|
import {
|
|
8
8
|
healthEndpoint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4R3YAQNV.js";
|
|
10
10
|
import {
|
|
11
11
|
smokeSuite
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CVJF2IC5.js";
|
|
13
13
|
import {
|
|
14
14
|
onboard
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NTLSMJHW.js";
|
|
16
16
|
import {
|
|
17
17
|
syncConfigs
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-3HS6LPFX.js";
|
|
19
19
|
import {
|
|
20
20
|
withRecipe
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-ZTPPCHDB.js";
|
|
22
22
|
import {
|
|
23
23
|
runAudits
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-JB4Q3C3M.js";
|
|
25
25
|
import {
|
|
26
26
|
siteLabel
|
|
27
27
|
} from "./chunk-XXTZBPUY.js";
|
|
@@ -143,4 +143,4 @@ export {
|
|
|
143
143
|
DEFAULT_INIT_STEPS,
|
|
144
144
|
init
|
|
145
145
|
};
|
|
146
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-4NUKMPOO.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-R53VL3RI.js";
|
|
5
5
|
import {
|
|
6
6
|
withRecipe
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZTPPCHDB.js";
|
|
8
8
|
import {
|
|
9
9
|
defaultSpawn
|
|
10
10
|
} from "./chunk-LBYOLBW7.js";
|
|
@@ -142,4 +142,4 @@ async function healthEndpoint(site, deps = { spawn: defaultSpawn }) {
|
|
|
142
142
|
export {
|
|
143
143
|
healthEndpoint
|
|
144
144
|
};
|
|
145
|
-
//# sourceMappingURL=chunk-
|
|
145
|
+
//# sourceMappingURL=chunk-4R3YAQNV.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SPAM_THRESHOLD
|
|
3
3
|
} from "./chunk-NO74DXDP.js";
|
|
4
|
+
import {
|
|
5
|
+
parseReplyCopy
|
|
6
|
+
} from "./chunk-PJ23RDHT.js";
|
|
4
7
|
import {
|
|
5
8
|
SUBMISSION_FORM_TYPES
|
|
6
9
|
} from "./chunk-2OP4JKIQ.js";
|
|
@@ -17,7 +20,8 @@ var KNOWN_KEYS = /* @__PURE__ */ new Set([
|
|
|
17
20
|
"sourceUrl",
|
|
18
21
|
"utm",
|
|
19
22
|
"extra",
|
|
20
|
-
"_meta"
|
|
23
|
+
"_meta",
|
|
24
|
+
"_reply"
|
|
21
25
|
]);
|
|
22
26
|
var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
23
27
|
var EMAIL_RE = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
|
|
@@ -47,12 +51,14 @@ function normalizeSubmission(payload) {
|
|
|
47
51
|
const extra = p.extra;
|
|
48
52
|
if (typeof extra === "object" && extra !== null) {
|
|
49
53
|
for (const [k, v] of Object.entries(extra)) {
|
|
50
|
-
if (!DANGEROUS_KEYS.has(k)) extraFields[k] = v;
|
|
54
|
+
if (!DANGEROUS_KEYS.has(k) && !k.startsWith("_")) extraFields[k] = v;
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
for (const [k, v] of Object.entries(p)) {
|
|
54
|
-
if (!KNOWN_KEYS.has(k) && !DANGEROUS_KEYS.has(k)) extraFields[k] = v;
|
|
58
|
+
if (!KNOWN_KEYS.has(k) && !DANGEROUS_KEYS.has(k) && !k.startsWith("_")) extraFields[k] = v;
|
|
55
59
|
}
|
|
60
|
+
const reply = parseReplyCopy(p._reply);
|
|
61
|
+
if (reply) extraFields._reply = reply;
|
|
56
62
|
const value = {
|
|
57
63
|
formType,
|
|
58
64
|
name,
|
|
@@ -281,4 +287,4 @@ export {
|
|
|
281
287
|
ingestSubmission,
|
|
282
288
|
hostsMatch
|
|
283
289
|
};
|
|
284
|
-
//# sourceMappingURL=chunk-
|
|
290
|
+
//# sourceMappingURL=chunk-5XMKJX74.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/forms/payload.ts","../src/forms/ingest.ts"],"sourcesContent":["import { SUBMISSION_FORM_TYPES, type FormType } from \"./types.js\";\nimport type { SubmissionMeta } from \"./meta.js\";\nimport { parseReplyCopy, type ReplyCopy } from \"./reply-copy.js\";\n\n/** The JSON wire format a fleet site forwards to the ingest endpoint.\n *\n * Underscore-prefixed keys are RESERVED for transport concerns and are never\n * lead data: `_meta` (below) and `_screenOut` (the bot screen-out beacon —\n * a `{ _screenOut: \"honeypot\" | \"too-fast\" }` body is a counter ping, not a\n * submission; see ingest.ts `parseScreenOut`). Site field names must not\n * start with `_`. */\nexport type SubmissionPayload = {\n formType?: string;\n name?: string;\n firstName?: string;\n lastName?: string;\n email?: string;\n phone?: string;\n message?: string;\n sourceUrl?: string;\n utm?: string;\n /** Any additional, site-specific fields. */\n extra?: Record<string, unknown>;\n /** Reserved transport envelope (token/IP/UA); stripped by normalizeSubmission, never persisted. */\n _meta?: SubmissionMeta;\n /** Reserved: confirmation-email copy the SITE resolved from its own CMS.\n * Validated by parseReplyCopy, then stored under the same key in extraFields\n * so a replayed submission sends the same email it would have sent live. */\n _reply?: ReplyCopy;\n};\n\nexport type NormalizedSubmission = {\n formType: FormType;\n name: string;\n email: string;\n phone?: string;\n message?: string;\n sourceUrl?: string;\n utm?: string;\n extraFields: Record<string, unknown>;\n};\n\nexport type NormalizeResult =\n { ok: true; value: NormalizedSubmission } | { ok: false; errors: string[] };\n\nconst KNOWN_KEYS = new Set([\n \"formType\",\n \"name\",\n \"firstName\",\n \"lastName\",\n \"email\",\n \"phone\",\n \"message\",\n \"sourceUrl\",\n \"utm\",\n \"extra\",\n \"_meta\",\n \"_reply\",\n]);\n\n// Keys that, copied as own-properties into the captured object, could surprise a\n// downstream consumer (template/DB layer). This is an untrusted boundary, so the\n// extraFields merge drops them rather than trusting the caller.\nconst DANGEROUS_KEYS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\nconst EMAIL_RE = /^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/;\n\nfunction str(v: unknown): string {\n return typeof v === \"string\" ? v.trim() : \"\";\n}\n\n/**\n * Resolve the submission's formType. An ABSENT/blank value defaults to \"contact\"\n * (the long-standing minimal-form contract). A PRESENT but unrecognized value\n * (e.g. a typo'd \"news\") returns null → the caller rejects it, rather than\n * silently storing it as contact — which would, for a newsletter signup, drop the\n * Mailchimp fan-out. Mirrors createIngestEndpoint's reject-invalid behavior.\n */\nfunction resolveFormType(raw: unknown): FormType | null {\n const s = str(raw);\n if (s === \"\") return \"contact\";\n return (SUBMISSION_FORM_TYPES as readonly string[]).includes(s) ? (s as FormType) : null;\n}\n\n/**\n * Defensively normalize an untrusted ingest payload into typed fields. Folds\n * name/first+last, lowercases email, and dumps every unclaimed key into\n * extraFields so no site-specific data is lost. Rejects only when there's\n * nothing to act on (no email AND no message) or a present email is malformed.\n */\nexport function normalizeSubmission(payload: unknown): NormalizeResult {\n if (typeof payload !== \"object\" || payload === null) {\n return { ok: false, errors: [\"payload must be a JSON object\"] };\n }\n const p = payload as Record<string, unknown>;\n const name = str(p.name) || [str(p.firstName), str(p.lastName)].filter(Boolean).join(\" \");\n const email = str(p.email).toLowerCase();\n const message = str(p.message);\n\n const formType = resolveFormType(p.formType);\n const errors: string[] = [];\n if (!email && !message) errors.push(\"at least one of email or message is required\");\n if (email && !EMAIL_RE.test(email)) errors.push(\"email is not a valid address\");\n if (formType === null) errors.push(\"formType is not a recognized form type\");\n // The `|| formType === null` is redundant for control flow (the push above\n // already made errors non-empty) but narrows formType to FormType past this line.\n if (errors.length > 0 || formType === null) return { ok: false, errors };\n\n const extraFields: Record<string, unknown> = {};\n const extra = p.extra;\n if (typeof extra === \"object\" && extra !== null) {\n for (const [k, v] of Object.entries(extra)) {\n if (!DANGEROUS_KEYS.has(k) && !k.startsWith(\"_\")) extraFields[k] = v;\n }\n }\n for (const [k, v] of Object.entries(p)) {\n if (!KNOWN_KEYS.has(k) && !DANGEROUS_KEYS.has(k) && !k.startsWith(\"_\")) extraFields[k] = v;\n }\n // The ONE underscore key a caller may set. Both loops above dropped the rest,\n // including any `_reply` smuggled in through `extra` — this is the only way a\n // value reaches that key, and it is validated on the way through. Without it,\n // a bot could POST its own copy and dictate the text of an email we send from\n // a domain with real sending reputation.\n const reply = parseReplyCopy(p._reply);\n if (reply) extraFields._reply = reply;\n\n const value: NormalizedSubmission = {\n formType,\n name,\n email,\n extraFields,\n };\n const phone = str(p.phone);\n if (phone) value.phone = phone;\n if (message) value.message = message;\n const sourceUrl = str(p.sourceUrl);\n if (sourceUrl) value.sourceUrl = sourceUrl;\n const utm = str(p.utm);\n if (utm) value.utm = utm;\n return { ok: true, value };\n}\n","import type { WebsiteRow } from \"../reports/airtable/websites.js\";\nimport type {\n SubmissionRow,\n SubmissionInput,\n NotifyStatus,\n SubmissionStatus,\n} from \"../reports/submission-row.js\";\nimport { normalizeSubmission, type NormalizedSubmission } from \"./payload.js\";\nimport type { TurnstileOutcome, TurnstileVerification } from \"./turnstile.js\";\nimport { SPAM_THRESHOLD, type SpamVerdict } from \"./spam-classifier.js\";\n\n/** How far back the duplicate-spray AND repeat-sender lookups scan. Sprays arrive in\n * bursts but bots also re-run for weeks; 30 days catches repeats without an unbounded\n * table scan. */\nconst DUPLICATE_WINDOW_MS = 30 * 24 * 60 * 60 * 1000;\n\nexport type IngestDeps = {\n getWebsiteBySlug: (slug: string) => Promise<WebsiteRow | null>;\n createSubmission: (input: SubmissionInput) => Promise<SubmissionRow>;\n /** Optional last-resort capture for a lead whose site lookup THREW (a store\n * outage, not an unknown slug). When present, the lead is persisted here and\n * the visitor still gets \"accepted\"; `db replay-deadletters` re-runs it once\n * the lookup recovers. Absent → the error propagates exactly as before, so\n * callers that never wired it are byte-for-byte unchanged. */\n deadLetter?: (input: {\n siteSlug: string;\n payload: unknown;\n turnstile: TurnstileVerification;\n error: string;\n receivedAt: Date;\n }) => Promise<{ id: string }>;\n notify: (\n site: WebsiteRow,\n submission: SubmissionRow,\n ) => Promise<{ status: NotifyStatus; messageId: string | null }>;\n stampNotified: (id: string, status: NotifyStatus, messageId: string | null) => Promise<void>;\n now: () => Date;\n /** Optional spam classifier. When present, its verdict drives the stored\n * status/score/reason; absent → every submission scores 0 (fail-open, clean).\n * Injected so the classifier stays a pure, transport-agnostic leaf. */\n classifySpam?: (n: NormalizedSubmission, turnstile: TurnstileOutcome) => SpamVerdict;\n /** Optional: fleet-wide duplicate/near-duplicate body lookup since `since`. Drives\n * the duplicate-spray signal — the same pitch blasted to many sites shows up as\n * identical (`exact`) or template-substituted (`similar`, token-set Jaccard) bodies.\n * Statuses let the retro re-bucket pick still-'new' prior copies; siteId+email let\n * the caller exempt a genuine same-sender resubmission on the same site. Absent →\n * the check is skipped (fail-open clean). */\n findRecentDuplicates?: (\n message: string,\n since: Date,\n ) => Promise<{\n exact: Array<{ id: string; status: string; siteId: string; email: string }>;\n similar: Array<{ id: string; status: string; siteId: string; email: string }>;\n }>;\n /** Optional: recent non-newsletter submissions from the same email since `since`.\n * Drives the cross-site repeat-sender signal — the fleet's sites are unrelated\n * businesses, so one address contacting 2+ of them within the window is a\n * solicitation tell. Absent → the check is skipped (fail-open clean). */\n listRecentSubmissionsForEmail?: (\n email: string,\n since: Date,\n ) => Promise<Array<{ id: string; siteId: string; status: string }>>;\n /** Optional: retroactively re-bucket prior still-'new' rows once a later copy\n * identifies a spray (the first copy is delivered by design). Implementations\n * must only touch status='new' rows. Best-effort — failures are swallowed. */\n retroBucket?: (ids: string[], reason: string) => Promise<void>;\n /** Optional: POST a newsletter submission to the site's configured webhook\n * (best-effort). Omitted in tests/handlers that don't need it. */\n forwardNewsletter?: (\n webhookUrl: string,\n submission: SubmissionRow,\n site: WebsiteRow,\n ) => Promise<{ ok: boolean; status: number }>;\n /** Optional: add a newsletter submitter to the site's Mailchimp audience\n * (best-effort). Omitted where unused. `tagged:false` reports a member who was\n * upserted but could NOT be tagged — recorded separately, see FANOUT below. */\n addToMailchimp?: (\n site: WebsiteRow,\n submission: SubmissionRow,\n ) => Promise<{ ok: boolean; status: number; tagged?: boolean }>;\n /** Optional: persist the newsletter fan-out outcome on the row (see FANOUT below).\n * Best-effort — failures are swallowed. Absent → the fan-out still runs, just\n * unrecorded (older callers and most tests). */\n stampFanout?: (id: string, fanoutStatus: string) => Promise<void>;\n /** Optional: run the best-effort tail (notify → stamp → fan-out) AFTER the\n * response instead of before it. Production passes Netlify's\n * `context.waitUntil`, which keeps the invocation alive until the promise\n * settles. Absent → the tail runs inline, exactly as it always did; this is a\n * latency change, never a behavioural one.\n *\n * Why it matters: the submitting site waits on this response under an abort\n * budget (forms/client.ts `INGEST_TIMEOUT_MS`). Once the row is written the\n * lead is captured, so every further second spent on email/webhook providers\n * is time in which a captured lead can still be reported to the visitor as a\n * failed submission — which is exactly what happened to 1836dig on\n * 2026-08-03. */\n defer?: (work: Promise<unknown>) => void;\n};\n\nexport type IngestResult =\n | { status: \"accepted\"; submissionId: string; notifyStatus: NotifyStatus | \"deferred\" }\n | { status: \"rejected\"; reason: \"invalid-payload\"; errors: string[] }\n | { status: \"unknown-site\"; slug: string };\n\nexport type ScreenOutDeps = {\n getWebsiteBySlug: (slug: string) => Promise<WebsiteRow | null>;\n recordScreenOut: (siteId: string, reason: \"honeypot\" | \"too-fast\") => Promise<void>;\n};\n\nexport type ScreenOutResult =\n { status: \"recorded\"; slug: string } | { status: \"unknown-site\"; slug: string };\n\n/** Extract the screen-out reason from a beacon body, or null if it isn't one.\n * The beacon key is the reserved `_screenOut` (underscore-namespaced like `_meta`,\n * see payload.ts). The bare `screenOut` key is the DEPRECATED pre-namespacing wire\n * shape — sites run older package versions for a while, so the central receiver\n * keeps accepting it. `_screenOut` wins when both are present. */\nexport function parseScreenOut(payload: unknown): \"honeypot\" | \"too-fast\" | null {\n if (!payload || typeof payload !== \"object\") return null;\n const body = payload as Record<string, unknown>;\n const v = \"_screenOut\" in body ? body[\"_screenOut\"] : body[\"screenOut\"];\n return v === \"honeypot\" || v === \"too-fast\" ? v : null;\n}\n\n/** Resolve the site and record a caught screen-out. Best-effort: a record failure is\n * the caller's to swallow — a missed count must never error a screened bot. */\nexport async function ingestScreenOut(\n deps: ScreenOutDeps,\n slug: string,\n reason: \"honeypot\" | \"too-fast\",\n): Promise<ScreenOutResult> {\n const site = await deps.getWebsiteBySlug(slug);\n if (!site) return { status: \"unknown-site\", slug };\n await deps.recordScreenOut(site.id, reason);\n return { status: \"recorded\", slug };\n}\n\n/**\n * Normalize → resolve site → persist → notify → stamp. The order is load-bearing:\n * the row is written BEFORE notify, and notify/stamp failures are swallowed (logged)\n * so a Resend or Airtable-write-back hiccup can never turn an accepted lead into a 502.\n */\nexport async function ingestSubmission(\n deps: IngestDeps,\n slug: string,\n rawPayload: unknown,\n turnstileInput: TurnstileOutcome | TurnstileVerification = \"unverifiable\",\n): Promise<IngestResult> {\n // Accept either the full verification (the production handler) or a bare outcome\n // string (older callers and virtually every test) — a string simply has no solved-\n // hostname to check. Normalized once so the body has a single shape to reason about.\n const verification: TurnstileVerification =\n typeof turnstileInput === \"string\"\n ? { outcome: turnstileInput, hostname: null }\n : turnstileInput;\n const turnstile = verification.outcome;\n const normalized = normalizeSubmission(rawPayload);\n if (!normalized.ok) {\n return { status: \"rejected\", reason: \"invalid-payload\", errors: normalized.errors };\n }\n // Persist before enrich (#539 Phase 0). The lookup THROWING is a store outage,\n // not an answer — and until 2026-08-23 it was the one await that could cost a\n // lead: the row write comes later, so a thrown lookup 502'd the visitor with\n // nothing recorded anywhere (the 2026-08-17 Airtable quota outage did exactly\n // that, while the submissions store itself was healthy the whole time). With\n // `deadLetter` wired, the lead lands there and the visitor gets an honest\n // \"accepted\"; `db replay-deadletters` runs it through this same function once\n // the lookup recovers, producing a normal row with real classification+notify.\n //\n // Three deliberate boundaries:\n // - A lookup that RESOLVES to null is still `unknown-site` — the store answered,\n // and a junk slug is a rejection, not a lead to save.\n // - A testMode probe rethrows: it persists nothing by design, so there is\n // nothing to save, and swallowing the outage would green the form-e2e audit\n // precisely when central ingest is degraded.\n // - `deadLetter` itself throwing propagates: both stores are down, and the 502\n // is honest — there is nowhere left to put the lead.\n let site: WebsiteRow | null;\n try {\n site = await deps.getWebsiteBySlug(slug);\n } catch (err) {\n if (!deps.deadLetter || isTestMode(rawPayload)) throw err;\n const dl = await deps.deadLetter({\n siteSlug: slug,\n payload: rawPayload,\n turnstile: verification,\n error: String(err),\n receivedAt: deps.now(),\n });\n console.error(\n `[ingest] site lookup failed for '${slug}' — lead dead-lettered as ${dl.id}: ${String(err)}`,\n );\n return { status: \"accepted\", submissionId: dl.id, notifyStatus: \"skipped\" };\n }\n if (!site) return { status: \"unknown-site\", slug };\n\n // Synthetic end-to-end probe (the `form-e2e` fleet audit). A central-only marker\n // on the payload routes the submission away from EVERY real sink: no row is\n // persisted, no spam classification, no operator/autoresponder email, no\n // newsletter fan-out — and Turnstile enforcement is bypassed (the short-circuit\n // sits before that check). The marker therefore grants a bot NO benefit: it\n // reaches no inbox/DB/webhook, so skipping Turnstile costs nothing. This\n // suppression MUST be central — the submitting site alone cannot stop the real\n // inbox firing. Validity + site resolution are still enforced above (a junk body\n // is rejected, an unknown slug is unknown-site), so the marker can't smuggle\n // anything through. Return accepted+skipped so the probe asserts success.\n if (isTestMode(rawPayload)) {\n return { status: \"accepted\", submissionId: \"test-mode\", notifyStatus: \"skipped\" };\n }\n\n const n = normalized.value;\n\n // A site still under construction is where the operator tests their OWN forms:\n // one address, several unrelated sites, minutes apart. That is byte-for-byte the\n // cross-site repeat-sender signature below, so a site in development reliably\n // auto-spams its own builder's test submissions — the row lands `spam_auto`,\n // notify is skipped and the cockpit hides it, which reads exactly like \"the form\n // is broken\" (it did, on 2026-08-17). Spam handling on a site with no real\n // visitors protects nothing, so skip ALL of it: content scoring, the Turnstile\n // escalation, the repeat-sender scan and the duplicate/spray scan — including\n // their retroactive re-bucketing of OTHER sites' rows, which a test submission\n // has no business triggering. Re-enabled the moment the site leaves development.\n const spamHandlingEnabled = site.status !== \"building\";\n\n // Fold the content signals + the Turnstile verdict into ONE spam decision.\n // Absent classifier → treat as clean (fail-open). A throwing classifier is\n // swallowed the same way — a bug in the heuristic must never turn an\n // otherwise-good lead into a 500; it just scores clean. On a `requireTurnstile`\n // site, both an ACTUAL \"fail\" (forged token) AND an \"absent\" token escalate to\n // auto-spam regardless of score — a real browser that renders the widget ALWAYS\n // sends a token, so a completely missing one is the direct-POST-bot signature. A\n // present-but-\"unverifiable\" token (expired/duplicate — a real browser DID render\n // the widget) stays neutral, as does anything on a site that hasn't opted in.\n let verdict: SpamVerdict = { score: 0, reasons: [] };\n if (spamHandlingEnabled && deps.classifySpam) {\n try {\n verdict = deps.classifySpam(n, turnstile);\n } catch (err) {\n console.error(`[ingest] classifySpam threw: ${String(err)}`);\n }\n }\n const reasons = [...verdict.reasons];\n let status: SubmissionStatus = verdict.score >= SPAM_THRESHOLD ? \"spam_auto\" : \"new\";\n if (\n spamHandlingEnabled &&\n site.requireTurnstile &&\n (turnstile === \"fail\" || turnstile === \"absent\")\n ) {\n status = \"spam_auto\";\n const reason = turnstile === \"fail\" ? \"turnstile-required-failed\" : \"turnstile-required-absent\";\n if (!reasons.includes(reason)) reasons.push(reason);\n } else if (\n spamHandlingEnabled &&\n site.requireTurnstile &&\n turnstile === \"pass\" &&\n verification.hostname !== null &&\n !turnstileHostnameAcceptable(verification.hostname, site.url)\n ) {\n // Defense-in-depth vs token farming: the token PASSED, but Cloudflare says it was\n // solved on a host unrelated to this site. Cloudflare domain-binds sitekeys, so\n // this only trips on a loose widget allowlist — still, a passing token from a\n // foreign host accompanying a gated site's submission is not a real visitor. A\n // null hostname (older responses) or an unparseable site.url skips the check\n // entirely (fail-open); subdomains of the site's host (www., previews) match.\n status = \"spam_auto\";\n if (!reasons.includes(\"turnstile-required-hostname\"))\n reasons.push(\"turnstile-required-hostname\");\n }\n\n // Cross-site repeat-sender signal: the fleet's sites are UNRELATED businesses\n // (art gallery, realtor, home builder…), so the same email writing to 2+ different\n // sites within the window is a solicitation tell no single-message scan can see.\n // Same-site repeats alone must NOT trigger — those are genuine follow-ups. The\n // operator explicitly accepts overblocking here (spam_auto is recoverable). Prior\n // still-'new' rows on OTHER sites are retro-bucketed too: the first copy of a\n // spray is delivered by design, so the copy that identifies it also cleans the\n // queue. The scan runs EVEN WHEN the incoming copy is already spam_auto — after the\n // classifier began catching whole spray families, an already-bucketed copy was\n // skipping this scan and the retro cleanup never fired for exactly the sprays it\n // was built for; escalation/reason still only applies when not already spam.\n // Best-effort — a lookup failure never blocks a lead.\n if (spamHandlingEnabled && n.formType !== \"newsletter\" && deps.listRecentSubmissionsForEmail) {\n try {\n const since = new Date(deps.now().getTime() - DUPLICATE_WINDOW_MS);\n const prior = await deps.listRecentSubmissionsForEmail(n.email, since);\n const otherSites = prior.filter((p) => p.siteId !== site.id);\n if (otherSites.length > 0) {\n if (status !== \"spam_auto\") {\n status = \"spam_auto\";\n if (!reasons.includes(\"repeat-sender\")) reasons.push(\"repeat-sender\");\n }\n const retroIds = otherSites.filter((p) => p.status === \"new\").map((p) => p.id);\n if (deps.retroBucket && retroIds.length > 0) {\n try {\n await deps.retroBucket(retroIds, \"retro:repeat-sender\");\n } catch (err) {\n console.error(`[ingest] retroBucket (repeat-sender) threw: ${String(err)}`);\n }\n }\n }\n } catch (err) {\n console.error(`[ingest] listRecentSubmissionsForEmail threw: ${String(err)}`);\n }\n }\n\n // Duplicate/spray signal: the same pitch blasted across the fleet (or repeated) is\n // a bot tell a lone content scan can't see. An identical body ('exact') OR a\n // template-substituted near-copy ('similar' — the live dog-harness spray differed\n // only in greeting; SEO sprays swap the target domain per site) → auto-spam\n // (recoverable). Prior still-'new' copies are retro-bucketed for the same reason\n // as above, and the scan runs even when the incoming copy is already spam_auto\n // (see the repeat-sender note). GENUINE-RESUBMIT EXEMPTION: a match from the SAME\n // sender on the SAME site is a real visitor double-submitting or resending after\n // silence, not spray evidence — without this exemption the resend was silently\n // bucketed AND retro-flipped the delivered original, vanishing an active lead\n // with no signal. Only cross-site or different-sender copies count. Guarded:\n // non-newsletter forms with a real body; the db helper ignores short bodies /\n // small token sets. Best-effort — a lookup failure never blocks a lead.\n if (\n spamHandlingEnabled &&\n n.formType !== \"newsletter\" &&\n n.message !== undefined &&\n deps.findRecentDuplicates\n ) {\n try {\n const since = new Date(deps.now().getTime() - DUPLICATE_WINDOW_MS);\n const dupes = await deps.findRecentDuplicates(n.message, since);\n const senderEmail = n.email.trim().toLowerCase();\n const isOwnResend = (m: { siteId: string; email: string }) =>\n m.siteId === site.id && m.email.trim().toLowerCase() === senderEmail;\n const exact = dupes.exact.filter((m) => !isOwnResend(m));\n const similar = dupes.similar.filter((m) => !isOwnResend(m));\n const reason =\n exact.length > 0 ? \"duplicate-body\" : similar.length > 0 ? \"similar-body\" : null;\n if (reason !== null) {\n if (status !== \"spam_auto\") {\n status = \"spam_auto\";\n if (!reasons.includes(reason)) reasons.push(reason);\n }\n const retroIds = [...exact, ...similar].filter((m) => m.status === \"new\").map((m) => m.id);\n if (deps.retroBucket && retroIds.length > 0) {\n try {\n await deps.retroBucket(retroIds, \"retro:duplicate-body\");\n } catch (err) {\n console.error(`[ingest] retroBucket (duplicate-body) threw: ${String(err)}`);\n }\n }\n }\n } catch (err) {\n console.error(`[ingest] findRecentDuplicates threw: ${String(err)}`);\n }\n }\n const spamReason = reasons.length > 0 ? reasons.join(\",\") : null;\n\n const row = await deps.createSubmission({\n siteId: site.id,\n formType: n.formType,\n name: n.name,\n email: n.email,\n extraFields: n.extraFields,\n status,\n spamScore: verdict.score,\n spamReason,\n // Optional fields spread only when present — exactOptionalPropertyTypes\n // forbids assigning `undefined` to an optional `phone?: string` etc.\n ...(n.phone !== undefined ? { phone: n.phone } : {}),\n ...(n.message !== undefined ? { message: n.message } : {}),\n ...(n.sourceUrl !== undefined ? { sourceUrl: n.sourceUrl } : {}),\n ...(n.utm !== undefined ? { utm: n.utm } : {}),\n submittedAt: deps.now(),\n });\n\n // Auto-spam (and operator-marked spam) is captured but silent: no operator\n // email, no autoresponder, no newsletter fan-out. Skip notify entirely and\n // record the honest \"skipped\" stamp. notify.ts also nulls both builders for\n // these statuses (defense in depth), but short-circuiting here means the\n // injected notify dep is never even invoked for a spam row.\n const isSpam = row.status === \"spam_auto\" || row.status === \"spam\";\n\n // ── best-effort tail ───────────────────────────────────────────────────────\n // notify → stamp → newsletter fan-out. NOTHING below can cost the lead: the\n // row is already durable, and every step here is swallowed+logged rather than\n // allowed to turn an accepted lead into a 502. That is precisely why it does\n // not belong on the visitor's critical path — the submitting site waits on\n // this response under an abort budget (forms/client.ts INGEST_TIMEOUT_MS), so\n // Resend latency used to be able to make a captured lead read as a failed\n // submission in the visitor's browser (1836dig, 2026-08-03).\n //\n // `deps.defer` (Netlify's `context.waitUntil` in production) runs the tail\n // AFTER the response goes out. Absent — every test, and any runtime without\n // post-response execution — it runs inline exactly as before, so this is a\n // latency change and never a behavioural one.\n const runTail = async (): Promise<NotifyStatus> => {\n let notify: { status: NotifyStatus; messageId: string | null };\n if (isSpam) {\n notify = { status: \"skipped\", messageId: null };\n } else {\n try {\n notify = await deps.notify(site, row);\n } catch (err) {\n console.error(`[ingest] notify threw: ${String(err)}`);\n notify = { status: \"failed\", messageId: null };\n }\n }\n try {\n await deps.stampNotified(row.id, notify.status, notify.messageId);\n } catch (err) {\n console.error(`[ingest] stampNotified failed: ${String(err)}`);\n }\n\n await runFanout();\n return notify.status;\n };\n\n // Newsletter fan-out: each configured destination fires best-effort and is\n // swallowed+logged — the lead is already persisted; never turn it into a 502.\n // Guarded on the row status so a spam signup is never forwarded to a site\n // webhook or added to a Mailchimp audience.\n //\n // FANOUT provenance (2026-07-31): the outcome is ALSO recorded on the row, one\n // `<destination>:<outcome>` token per attempt, comma-joined in attempt order —\n // `webhook:ok,mailchimp:401`. Outcome is `ok`, the HTTP status of a non-2xx\n // (`0` for a network error / misconfiguration, see mailchimp.ts), or `threw`.\n // `mailchimp-tags:failed` is appended when the member was upserted but the tag\n // write did not land. Until this existed the results were console.error-only, so\n // an expired Mailchimp key stopped signups reaching the audience while the row\n // still read `notify=sent` — healthy-looking, with the failure visible nowhere the\n // operator ever looks. Nothing attempted → nothing stamped (null stays \"no\n // destination configured\", NOT \"we tried and lost the answer\"). The stamp is\n // best-effort like everything else here: a provenance write must never cost a lead.\n // A const arrow, not a hoisted declaration: `site` is narrowed non-null above,\n // and that narrowing only survives into a closure created after it. Declared\n // below runTail (which calls it) but before either call site, so there is no TDZ.\n const runFanout = async (): Promise<void> => {\n const fanout: string[] = [];\n if (n.formType === \"newsletter\" && !isSpam) {\n if (site.newsletterWebhook && deps.forwardNewsletter) {\n try {\n const fwd = await deps.forwardNewsletter(site.newsletterWebhook, row, site);\n if (!fwd.ok)\n console.error(`[ingest] newsletter webhook → ${fwd.status} for ${site.name}`);\n fanout.push(fwd.ok ? \"webhook:ok\" : `webhook:${fwd.status}`);\n } catch (err) {\n console.error(`[ingest] newsletter webhook threw: ${String(err)}`);\n fanout.push(\"webhook:threw\");\n }\n }\n if (site.mailchimpApiKey && site.mailchimpAudienceId && deps.addToMailchimp) {\n try {\n const mc = await deps.addToMailchimp(site, row);\n if (!mc.ok) console.error(`[ingest] mailchimp add → ${mc.status} for ${site.name}`);\n fanout.push(mc.ok ? \"mailchimp:ok\" : `mailchimp:${mc.status}`);\n // Only meaningful alongside a successful add — a failed add was never tagged\n // either, and one token per real problem keeps the row readable.\n if (mc.ok && mc.tagged === false) {\n console.error(`[ingest] mailchimp tags not applied for ${site.name}`);\n fanout.push(\"mailchimp-tags:failed\");\n }\n } catch (err) {\n console.error(`[ingest] mailchimp add threw: ${String(err)}`);\n fanout.push(\"mailchimp:threw\");\n }\n }\n }\n if (fanout.length > 0 && deps.stampFanout) {\n try {\n await deps.stampFanout(row.id, fanout.join(\",\"));\n } catch (err) {\n console.error(`[ingest] stampFanout failed: ${String(err)}`);\n }\n }\n };\n\n if (deps.defer) {\n // A rejection escaping here would land as an unhandled rejection in the\n // platform's post-response context, where nothing is left to catch it — so\n // the boundary is made unrejectable. Everything inside is already swallowed;\n // this guards the shape, not a known throw.\n deps.defer(\n runTail().catch((err) => {\n console.error(`[ingest] deferred tail threw: ${String(err)}`);\n }),\n );\n // The lead is durable and the response can go out now. The real notify\n // outcome lands on the ROW via stampNotified moments later — this field is\n // only ever read by callers wanting the in-request outcome, which by\n // definition does not exist once the tail is deferred.\n return { status: \"accepted\", submissionId: row.id, notifyStatus: \"deferred\" };\n }\n return { status: \"accepted\", submissionId: row.id, notifyStatus: await runTail() };\n}\n\n/** True when `a` and `b` are the same host or one is a subdomain of the other\n * (case-insensitive): `www.reddoorla.com` vs `reddoorla.com` matches both ways.\n * Exported for tests. PURE. */\nexport function hostsMatch(a: string, b: string): boolean {\n const ha = a.trim().toLowerCase();\n const hb = b.trim().toLowerCase();\n if (ha.length === 0 || hb.length === 0) return false;\n return ha === hb || ha.endsWith(`.${hb}`) || hb.endsWith(`.${ha}`);\n}\n\n/** Whether a passing token's solved-hostname is acceptable for the site at `siteUrl`.\n * An unparseable/hostless `siteUrl` returns TRUE — the check self-disables rather\n * than punishing a possibly-real visitor for an operator data problem (fail-open,\n * same philosophy as verifyTurnstile). PURE. */\nexport function turnstileHostnameAcceptable(tokenHostname: string, siteUrl: string): boolean {\n let siteHost: string;\n try {\n siteHost = new URL(siteUrl).hostname;\n } catch {\n return true;\n }\n if (!siteHost) return true;\n return hostsMatch(tokenHostname, siteHost);\n}\n\n/** True when an untrusted ingest payload carries the synthetic-probe marker\n * (top-level `testMode: true`). Read from the RAW payload so the branch never\n * depends on normalization internals; any non-`true` value is ignored (a real\n * visitor's form never sets it — the starter only forwards it when the submitted\n * form field `testMode` equals \"true\"). */\nexport function isTestMode(rawPayload: unknown): boolean {\n if (!rawPayload || typeof rawPayload !== \"object\") return false;\n return (rawPayload as Record<string, unknown>).testMode === true;\n}\n"],"mappings":";;;;;;;;;;;AA6CA,IAAM,aAAa,oBAAI,IAAI;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAKD,IAAM,iBAAiB,oBAAI,IAAI,CAAC,aAAa,eAAe,WAAW,CAAC;AAExE,IAAM,WAAW;AAEjB,SAAS,IAAI,GAAoB;AAC/B,SAAO,OAAO,MAAM,WAAW,EAAE,KAAK,IAAI;AAC5C;AASA,SAAS,gBAAgB,KAA+B;AACtD,QAAM,IAAI,IAAI,GAAG;AACjB,MAAI,MAAM,GAAI,QAAO;AACrB,SAAQ,sBAA4C,SAAS,CAAC,IAAK,IAAiB;AACtF;AAQO,SAAS,oBAAoB,SAAmC;AACrE,MAAI,OAAO,YAAY,YAAY,YAAY,MAAM;AACnD,WAAO,EAAE,IAAI,OAAO,QAAQ,CAAC,+BAA+B,EAAE;AAAA,EAChE;AACA,QAAM,IAAI;AACV,QAAM,OAAO,IAAI,EAAE,IAAI,KAAK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) {
|
|
|
96
96
|
export {
|
|
97
97
|
convertToPnpm
|
|
98
98
|
};
|
|
99
|
-
//# sourceMappingURL=chunk-
|
|
99
|
+
//# sourceMappingURL=chunk-7CJ3DVZW.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-J7SZQUCW.js";
|
|
4
4
|
import {
|
|
5
5
|
withRecipe
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZTPPCHDB.js";
|
|
7
7
|
import {
|
|
8
8
|
bumpDep,
|
|
9
9
|
readPackageJson,
|
|
@@ -243,4 +243,4 @@ async function upgradeSvelte4to5(site, opts = {}) {
|
|
|
243
243
|
export {
|
|
244
244
|
upgradeSvelte4to5
|
|
245
245
|
};
|
|
246
|
-
//# sourceMappingURL=chunk-
|
|
246
|
+
//# sourceMappingURL=chunk-B6NUZ2ZX.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
checkGoal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-T7ZUUOZ2.js";
|
|
4
4
|
import {
|
|
5
5
|
isPrivateOrLoopbackHost
|
|
6
6
|
} from "./chunk-RARREDQE.js";
|
|
@@ -1273,6 +1273,10 @@ Return:
|
|
|
1273
1273
|
at it with a pronoun has no antecedent and the engine will answer that it does not know who is meant.
|
|
1274
1274
|
These are searches, not conversational questions, and they are not the buyerQuestions above.
|
|
1275
1275
|
- fixes: prioritized, concrete, specific to this site. No generic SEO advice.
|
|
1276
|
+
Each "why" describes what a buyer or a crawler can or cannot read on the site TODAY. Never predict
|
|
1277
|
+
what an answer engine will cite, repeat, rank or recommend: the report states elsewhere, with
|
|
1278
|
+
evidence, that nothing on the site reliably moves that, and a fix that promises it contradicts the
|
|
1279
|
+
report. "A buyer cannot find a price" is a reason; "an engine will have nothing to cite" is not.
|
|
1276
1280
|
Set addresses to the key of the measured requirement a fix would satisfy \u2014 one of the keys listed
|
|
1277
1281
|
under "What we have already measured", exactly as written \u2014 or null when it answers to none of them.
|
|
1278
1282
|
Null is the normal case: a heavy image, a broken link or a stale copyright year maps to no
|
|
@@ -1462,7 +1466,12 @@ async function analyzeSite(url, crawl, checks, deps = defaultAnalyzeDeps(), goal
|
|
|
1462
1466
|
...parsed,
|
|
1463
1467
|
questionSetId: set.id,
|
|
1464
1468
|
buyerQuestions: conformToSet(parsed.buyerQuestions, set),
|
|
1465
|
-
fixes
|
|
1469
|
+
// Stamped here, at the one place model fixes enter the system, so the
|
|
1470
|
+
// renderer can label them as judgement and never as a finding.
|
|
1471
|
+
fixes: reconcileFixes(parsed.fixes, goalFit).map((f) => ({
|
|
1472
|
+
...f,
|
|
1473
|
+
origin: "recommendation"
|
|
1474
|
+
}))
|
|
1466
1475
|
};
|
|
1467
1476
|
return verifyEvidence(conformed, crawl);
|
|
1468
1477
|
}
|
|
@@ -2050,6 +2059,7 @@ async function classifyDomains(prospectUrl, prospectPhones, domains, deps) {
|
|
|
2050
2059
|
var MAX_PAGES2 = 14;
|
|
2051
2060
|
var MAX_TOTAL_CHARS = 12e4;
|
|
2052
2061
|
var MAX_ASSERTIONS = 12;
|
|
2062
|
+
var NO_CONFLATION = { detected: false, otherNames: [], engineQuote: null };
|
|
2053
2063
|
var AccuracySchema = z2.object({
|
|
2054
2064
|
assertions: z2.array(
|
|
2055
2065
|
z2.object({
|
|
@@ -2065,7 +2075,15 @@ var AccuracySchema = z2.object({
|
|
|
2065
2075
|
*/
|
|
2066
2076
|
searchTerms: z2.array(z2.string()).min(1).max(6)
|
|
2067
2077
|
})
|
|
2068
|
-
).max(MAX_ASSERTIONS)
|
|
2078
|
+
).max(MAX_ASSERTIONS),
|
|
2079
|
+
/** Does the answer describe MORE THAN ONE business under this name, or a
|
|
2080
|
+
* different business first? Defaulted, so a model that omits it reads as
|
|
2081
|
+
* "not detected" rather than failing the whole stage. */
|
|
2082
|
+
conflation: z2.object({
|
|
2083
|
+
detected: z2.boolean(),
|
|
2084
|
+
otherNames: z2.array(z2.string()).max(6),
|
|
2085
|
+
engineQuote: z2.string().nullable()
|
|
2086
|
+
}).default({ detected: false, otherNames: [], engineQuote: null })
|
|
2069
2087
|
});
|
|
2070
2088
|
function makeFenceTag2() {
|
|
2071
2089
|
return `data_${randomBytes2(6).toString("hex")}`;
|
|
@@ -2103,6 +2121,12 @@ For each assertion return:
|
|
|
2103
2121
|
- searchTerms: 1-6 distinctive words or short phrases you would search the site for to find this fact \u2014
|
|
2104
2122
|
proper nouns, numbers, street names. These are used to re-check "absent" verdicts across pages you were
|
|
2105
2123
|
not shown, so choose terms that would actually appear if the fact were stated somewhere else on the site.
|
|
2124
|
+
|
|
2125
|
+
Separately, return "conflation": does the answer describe MORE THAN ONE business under this name, or
|
|
2126
|
+
describe a different business first? If so, detected is true, otherNames lists the OTHER businesses
|
|
2127
|
+
named (never this one), and engineQuote is the exact sentence that says the name belongs to several
|
|
2128
|
+
businesses \u2014 copied verbatim, it is checked against the answer character by character. Otherwise
|
|
2129
|
+
detected is false with an empty otherNames and a null engineQuote.
|
|
2106
2130
|
Avoid generic words ("dental", "services") that appear on every page.
|
|
2107
2131
|
|
|
2108
2132
|
Be conservative about "confirmed": if the site only gestures at the fact, that is "absent". Being wrong in
|
|
@@ -2268,28 +2292,40 @@ function quoteSupportsClaim(claim, quote) {
|
|
|
2268
2292
|
for (const w of words(claim)) if (inQuote.has(w)) shared += 1;
|
|
2269
2293
|
return shared >= 2;
|
|
2270
2294
|
}
|
|
2271
|
-
function verifyQuotes(raw, answerText, siteText, answerOf, prospectDomain) {
|
|
2295
|
+
function verifyQuotes(raw, answerText, siteText, answerOf, prospectDomain, searchTermsByClaim = /* @__PURE__ */ new Map()) {
|
|
2272
2296
|
const answers = normalize(answerText);
|
|
2273
2297
|
const site = normalize(siteText);
|
|
2298
|
+
const flat = siteText.replace(/\s+/g, " ");
|
|
2274
2299
|
const out = [];
|
|
2275
2300
|
for (const a of raw) {
|
|
2276
2301
|
if (!answers.includes(normalize(a.engineQuote))) continue;
|
|
2302
|
+
let verdict = a.verdict;
|
|
2303
|
+
let siteQuote = a.siteQuote;
|
|
2304
|
+
if (a.verdict === "contradicted") {
|
|
2305
|
+
for (const term of distinctive(searchTermsByClaim.get(a.claim) ?? [])) {
|
|
2306
|
+
if (findTerm(site, term) !== "exact") continue;
|
|
2307
|
+
const at = site.indexOf(normalize(term));
|
|
2308
|
+
verdict = "confirmed";
|
|
2309
|
+
siteQuote = flat.slice(Math.max(0, at - 80), at + term.length + 80).trim();
|
|
2310
|
+
break;
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2277
2313
|
const from = answerOf.get(normalize(a.engineQuote));
|
|
2278
2314
|
const sourceDomains = [
|
|
2279
2315
|
...new Set((from?.citedDomains ?? []).map(domainOf).filter((d) => d !== prospectDomain))
|
|
2280
2316
|
];
|
|
2281
|
-
const quoteReal =
|
|
2282
|
-
const needsQuote =
|
|
2283
|
-
const quoteSupports = quoteReal &&
|
|
2317
|
+
const quoteReal = siteQuote !== null && site.includes(normalize(siteQuote));
|
|
2318
|
+
const needsQuote = verdict === "confirmed" || verdict === "contradicted";
|
|
2319
|
+
const quoteSupports = quoteReal && siteQuote !== null && quoteSupportsClaim(a.claim, siteQuote);
|
|
2284
2320
|
const unsupported = needsQuote && (!quoteReal || !quoteSupports);
|
|
2285
2321
|
out.push({
|
|
2286
2322
|
claim: a.claim,
|
|
2287
|
-
verdict: unsupported ? "unverified" :
|
|
2323
|
+
verdict: unsupported ? "unverified" : verdict,
|
|
2288
2324
|
engineQuote: a.engineQuote,
|
|
2289
2325
|
// Kept when it is real, even where it does not carry the claim: the
|
|
2290
2326
|
// reader can see what we looked at and judge it themselves, which is a
|
|
2291
2327
|
// better position than being told we found nothing.
|
|
2292
|
-
siteQuote: quoteReal ?
|
|
2328
|
+
siteQuote: quoteReal ? siteQuote : null,
|
|
2293
2329
|
nearbyMention: null,
|
|
2294
2330
|
unverifiedReason: !unsupported ? null : !quoteReal ? "We could not find the passage this was based on, so we have not stated it either way." : "The passage we found is about the same subject but does not actually say this, so we have not stated it either way.",
|
|
2295
2331
|
sourceDomains,
|
|
@@ -2332,11 +2368,13 @@ async function checkAccuracy(url, crawl, answers, prospectPhones, deps) {
|
|
|
2332
2368
|
siteFullyRead: false,
|
|
2333
2369
|
pagesRead: 0,
|
|
2334
2370
|
pagesTotal: crawl.pages.length,
|
|
2335
|
-
answersRead: 0
|
|
2371
|
+
answersRead: 0,
|
|
2372
|
+
conflation: NO_CONFLATION
|
|
2336
2373
|
};
|
|
2337
2374
|
}
|
|
2338
2375
|
const input = buildAccuracyInput(crawl, branded);
|
|
2339
2376
|
const parsed = AccuracySchema.parse(await deps.run(input));
|
|
2377
|
+
const termsByClaim = new Map(parsed.assertions.map((a) => [a.claim, a.searchTerms]));
|
|
2340
2378
|
const answerOf = /* @__PURE__ */ new Map();
|
|
2341
2379
|
for (const a of branded) {
|
|
2342
2380
|
const text = normalize(a.fullAnswer ?? "");
|
|
@@ -2346,14 +2384,17 @@ async function checkAccuracy(url, crawl, answers, prospectPhones, deps) {
|
|
|
2346
2384
|
}
|
|
2347
2385
|
}
|
|
2348
2386
|
const siteText = fullSiteText(crawl);
|
|
2387
|
+
const answerText = branded.map((a) => a.fullAnswer ?? "").join("\n");
|
|
2349
2388
|
const verified = verifyQuotes(
|
|
2350
2389
|
parsed.assertions,
|
|
2351
|
-
|
|
2390
|
+
answerText,
|
|
2352
2391
|
siteText,
|
|
2353
2392
|
answerOf,
|
|
2354
|
-
domainOf(url)
|
|
2393
|
+
domainOf(url),
|
|
2394
|
+
termsByClaim
|
|
2355
2395
|
);
|
|
2356
|
-
const
|
|
2396
|
+
const c = parsed.conflation;
|
|
2397
|
+
const conflation = c.detected && c.engineQuote !== null && normalize(answerText).includes(normalize(c.engineQuote)) ? { detected: true, otherNames: c.otherNames, engineQuote: c.engineQuote } : NO_CONFLATION;
|
|
2357
2398
|
const sources = await classifyDomains(
|
|
2358
2399
|
url,
|
|
2359
2400
|
prospectPhones,
|
|
@@ -2366,7 +2407,8 @@ async function checkAccuracy(url, crawl, answers, prospectPhones, deps) {
|
|
|
2366
2407
|
siteFullyRead: input.fullyRead,
|
|
2367
2408
|
pagesRead: input.pagesRead,
|
|
2368
2409
|
pagesTotal: crawl.pages.length,
|
|
2369
|
-
answersRead: branded.length
|
|
2410
|
+
answersRead: branded.length,
|
|
2411
|
+
conflation
|
|
2370
2412
|
};
|
|
2371
2413
|
}
|
|
2372
2414
|
|
|
@@ -3155,6 +3197,99 @@ async function checkBasics(crawl, deps) {
|
|
|
3155
3197
|
};
|
|
3156
3198
|
}
|
|
3157
3199
|
|
|
3200
|
+
// src/prospect/measured-fixes.ts
|
|
3201
|
+
var plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
3202
|
+
function measuredFixes(input) {
|
|
3203
|
+
const out = [];
|
|
3204
|
+
const c = input.checks;
|
|
3205
|
+
if (c && c.crawlerAccessMeasured && c.crawlerAccess.blockedAi.length > 0) {
|
|
3206
|
+
const names = c.crawlerAccess.blockedAi.join(", ");
|
|
3207
|
+
out.push({
|
|
3208
|
+
title: `Let ${names} read your site`,
|
|
3209
|
+
why: `Your robots.txt turns away ${names}. A crawler that is refused cannot read a page, so nothing else in this report can help for it until this changes.`,
|
|
3210
|
+
impact: "high",
|
|
3211
|
+
effort: "low",
|
|
3212
|
+
tier: "crawl",
|
|
3213
|
+
addresses: null,
|
|
3214
|
+
origin: "measured"
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
for (const r of input.goalFit?.requirements ?? []) {
|
|
3218
|
+
if (r.status !== "missing") continue;
|
|
3219
|
+
out.push({
|
|
3220
|
+
title: r.label.charAt(0).toUpperCase() + r.label.slice(1),
|
|
3221
|
+
why: r.why,
|
|
3222
|
+
impact: "high",
|
|
3223
|
+
effort: r.scope === "quick" ? "low" : r.scope === "content" ? "medium" : "high",
|
|
3224
|
+
tier: r.scope === "quick" ? "technical" : "content",
|
|
3225
|
+
addresses: r.key,
|
|
3226
|
+
origin: "measured"
|
|
3227
|
+
});
|
|
3228
|
+
}
|
|
3229
|
+
const phoneJudgedByGoal = (input.goalFit?.requirements ?? []).some(
|
|
3230
|
+
(r) => r.key === "tappable-phone"
|
|
3231
|
+
);
|
|
3232
|
+
const plain = phoneJudgedByGoal ? 0 : (input.phones ?? []).filter((p) => p.linked === false).length;
|
|
3233
|
+
if (plain > 0) {
|
|
3234
|
+
out.push({
|
|
3235
|
+
title: "Make your phone number tappable",
|
|
3236
|
+
why: `${plural(plain, "number is", "numbers are")} written as plain text. On a phone that is something a visitor has to memorise and retype; as a link it is one tap, and it is the moment they were most likely to call.`,
|
|
3237
|
+
impact: "medium",
|
|
3238
|
+
effort: "low",
|
|
3239
|
+
tier: "technical",
|
|
3240
|
+
addresses: null,
|
|
3241
|
+
origin: "measured"
|
|
3242
|
+
});
|
|
3243
|
+
}
|
|
3244
|
+
if (input.brokenLinks !== null && input.brokenLinks > 0) {
|
|
3245
|
+
out.push({
|
|
3246
|
+
title: `Repair ${plural(input.brokenLinks, "broken link", "broken links")}`,
|
|
3247
|
+
why: "A visitor who follows one lands on an error page, and a crawler that follows one stops there.",
|
|
3248
|
+
impact: "medium",
|
|
3249
|
+
effort: "low",
|
|
3250
|
+
tier: "technical",
|
|
3251
|
+
addresses: null,
|
|
3252
|
+
origin: "measured"
|
|
3253
|
+
});
|
|
3254
|
+
}
|
|
3255
|
+
if (input.brokenImages !== null && input.brokenImages > 0) {
|
|
3256
|
+
out.push({
|
|
3257
|
+
title: `Replace ${plural(input.brokenImages, "broken image", "broken images")}`,
|
|
3258
|
+
why: "It shows as an empty box or a missing-image icon on the page a visitor is reading.",
|
|
3259
|
+
impact: "low",
|
|
3260
|
+
effort: "low",
|
|
3261
|
+
tier: "technical",
|
|
3262
|
+
addresses: null,
|
|
3263
|
+
origin: "measured"
|
|
3264
|
+
});
|
|
3265
|
+
}
|
|
3266
|
+
if (c) {
|
|
3267
|
+
if (c.headings.pagesWithoutH1 > 0) {
|
|
3268
|
+
out.push({
|
|
3269
|
+
title: `Give ${plural(c.headings.pagesWithoutH1, "page", "pages")} a top heading`,
|
|
3270
|
+
why: `${c.headings.pagesWithoutH1} of ${c.meta.pageCount} pages have no top-level heading, so a reader or a crawler arriving on them is not told what the page is about.`,
|
|
3271
|
+
impact: "medium",
|
|
3272
|
+
effort: "low",
|
|
3273
|
+
tier: "technical",
|
|
3274
|
+
addresses: null,
|
|
3275
|
+
origin: "measured"
|
|
3276
|
+
});
|
|
3277
|
+
}
|
|
3278
|
+
if (c.meta.missingCanonical > 0) {
|
|
3279
|
+
out.push({
|
|
3280
|
+
title: "Tell search engines which address is the real one for each page",
|
|
3281
|
+
why: `${c.meta.missingCanonical} of ${c.meta.pageCount} pages do not declare a canonical address. When the same page is reachable at more than one address, a search engine has to guess which one to keep.`,
|
|
3282
|
+
impact: "medium",
|
|
3283
|
+
effort: "low",
|
|
3284
|
+
tier: "technical",
|
|
3285
|
+
addresses: null,
|
|
3286
|
+
origin: "measured"
|
|
3287
|
+
});
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
return out;
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3158
3293
|
// src/prospect/pipeline.ts
|
|
3159
3294
|
function envAnalyzeDeps(factories = {
|
|
3160
3295
|
api: defaultAnalyzeDeps,
|
|
@@ -3215,6 +3350,10 @@ async function stage(name, deps, fn) {
|
|
|
3215
3350
|
return { ok: false, error };
|
|
3216
3351
|
}
|
|
3217
3352
|
}
|
|
3353
|
+
function mergeFixes(measured, model) {
|
|
3354
|
+
const covered = new Set(measured.map((f) => f.addresses).filter((k) => !!k));
|
|
3355
|
+
return [...measured, ...model.filter((f) => !(f.addresses && covered.has(f.addresses)))];
|
|
3356
|
+
}
|
|
3218
3357
|
async function runProspectAudit(url, opts, deps = {}) {
|
|
3219
3358
|
const llmAuth = llmAuthMode();
|
|
3220
3359
|
const crawlDeps = deps.crawl ?? defaultCrawlDeps();
|
|
@@ -3320,9 +3459,21 @@ async function runProspectAudit(url, opts, deps = {}) {
|
|
|
3320
3459
|
checks.ok ? checks.data : null
|
|
3321
3460
|
)
|
|
3322
3461
|
};
|
|
3323
|
-
const reconciled = analyze.ok
|
|
3462
|
+
const reconciled = analyze.ok ? {
|
|
3324
3463
|
ok: true,
|
|
3325
|
-
data: {
|
|
3464
|
+
data: {
|
|
3465
|
+
...analyze.data,
|
|
3466
|
+
fixes: mergeFixes(
|
|
3467
|
+
measuredFixes({
|
|
3468
|
+
goalFit: goalFit.ok ? goalFit.data : null,
|
|
3469
|
+
checks: checks.ok ? checks.data : null,
|
|
3470
|
+
phones: checks.ok ? checks.data.consistency?.phones ?? null : null,
|
|
3471
|
+
brokenLinks: assets.ok ? assets.data.brokenLinks.length : null,
|
|
3472
|
+
brokenImages: assets.ok ? assets.data.brokenImages.length : null
|
|
3473
|
+
}),
|
|
3474
|
+
goalFit.ok ? reconcileFixes(analyze.data.fixes, goalFit.data) : analyze.data.fixes
|
|
3475
|
+
)
|
|
3476
|
+
}
|
|
3326
3477
|
} : analyze;
|
|
3327
3478
|
const brandedAnswers = probes.ok ? probes.data.answers.filter((a) => a.kind === "branded") : [];
|
|
3328
3479
|
const accuracy = brandedAnswers.length === 0 ? { ok: false, error: ACCURACY_SKIPPED } : await stage("accuracy", deps, async () => {
|
|
@@ -3377,6 +3528,7 @@ export {
|
|
|
3377
3528
|
GOAL_UNRESOLVED,
|
|
3378
3529
|
ASSET_ACCEPT,
|
|
3379
3530
|
defaultAssetProbe,
|
|
3531
|
+
mergeFixes,
|
|
3380
3532
|
runProspectAudit
|
|
3381
3533
|
};
|
|
3382
|
-
//# sourceMappingURL=chunk-
|
|
3534
|
+
//# sourceMappingURL=chunk-BJQCIJOY.js.map
|