1.18.0 (owner's decisions Q3, Q4, Q5): writes that keep others' saves, access answers announced, drafts out of related documents

- Q3: the integration status (emailStatus, turnstileStatus) is written alone through the
  database adapter (writeGlobalFields, exported): a visitor's form submit no longer puts back an
  admin's SMTP or Turnstile change saved at the same moment. addToCookieList reads the list again
  right before writing and works the change out again when an editor's save changed it (up to 5
  times). Both races reproduced exactly in test/statusWrites.test.ts, on the three adapters.
- Q4: cookieScanner.access and the doctor's access go through accessAllowed: any truthy answer
  still allows, an answer that is not a boolean is reported once per option; strict (only true)
  is announced for 1.19.0.
- Q5: related documents that are drafts are left out of what the public helpers answer
  (resolveRoute, getSettings, getArchiveEntries, the 404 page, llms-full; Markdown and MCP through
  resolveRoute): null alone, removed from a list, value null in a polymorphic one. A preview keeps
  them; draftRelations: 'keep' keeps the old behaviour. withoutDraftRelations,
  applyDraftRelations exported.
- Docs: content.md, frontend.md, integrations.md, cookie-scanner.md, security.md, AGENT.md;
  iapl-nav and iapl-doctor skills.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 11:15:13 +01:00
co-authored by Claude Opus 5.5
parent fc70a34f3e
commit 21ef0fdeb0
29 changed files with 555 additions and 48 deletions
+33
View File
@@ -0,0 +1,33 @@
/**
* The answer of a project's access callback (`cookieScanner.access`, the doctor's `access`), read the same way
* everywhere (owner's decision Q4, 1.18.0).
*
* Today any truthy answer lets the request in, as before: `({ req }) => req.user` returns an account object, and
* a function that returns `'no'` or `{}` lets the request in too. From the next minor version only `true` will
* allow. Until then the first answer that is not a boolean is reported once per option in the server log, so a
* project sees it before the change. (A callback needs a request to be asked, so this cannot be checked at start:
* the warning comes with the first call.)
*/
const warned = new Set<string>()
export type AccessAnswerOptions = {
/** Where to report (default `console.warn`). */
warn?: (message: string) => void
}
/** True when the request may pass; warns once per `option` when the answer is not a boolean. */
export function accessAllowed(option: string, answer: unknown, { warn = (m) => console.warn(m) }: AccessAnswerOptions = {}): boolean {
if (typeof answer !== 'boolean' && !warned.has(option)) {
warned.add(option)
const kind = answer === null ? 'null' : Array.isArray(answer) ? 'an array' : typeof answer === 'object' ? 'an object' : `a ${typeof answer}`
warn(
`[iapl] ${option} returned ${kind}, not true or false. It is still read as ${answer ? 'allowed' : 'refused'}; from the next minor version only \`true\` allows. Return a boolean, e.g. \`({ req }) => Boolean(req.user)\` (docs/security.md "Access callbacks").`,
)
}
return Boolean(answer)
}
/** For tests: forget which options were reported. */
export function resetAccessWarnings(): void {
warned.clear()
}