diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6dd8a4c..171f016 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,6 +8,131 @@ versions at once, go through every "Requires project changes" section in order, version you have. A new release = a new section at the top; we remove the oldest ones only once there are more than 20. +## 1.13.0 + +Security and performance fixes from an audit, SEO/GEO and Search Console features, a seed helper, and English docs. +Every new default can be turned off or overridden — AGENT.md §7.1 lists each one with its switch. + +### Security and access +- **Staff features follow roles through one rule, `userMeetsRole(req, minimum)`** (exported). With `access` (a + `roles` field), the role decides. **Without `access`, every logged-in account passes** — see "What projects must + update". Used by Site Integrations, the settings globals, the test e-mail endpoint, stats, consent records, forms + and form submissions. +- **Plugin globals:** Site Settings, Cookie Settings and Notifications are written by editor+ only, Site + Integrations by admins only. Before, any logged-in account (a plain `user`) could rewrite the brand, homepage or + construction mode. Override: `ipalKit({ globalOverrides: { : { access, admin, hooks } } })`, where an object + merges key by key and a function `(global) => global` takes over (`applyGlobalOverrides`). +- **Forms:** forms are created, edited and deleted by editor+, and the Emails tab (recipients, BCC) is readable by + editor+ only, so a plain `user` can no longer BCC every submission to itself. Override: + `forms.formOverrides.access` / `.fields` (the protected fields reach your `fields` function, so you can change the + rule). +- **Injected `users` collection** (with `access`): create, delete and unlock are admin-only; read and update are + admin or self. Override: `access.authAccess` (your keys win). Your own auth collection still wins whole. +- **First account = admin:** the account made on Payload's "create first user" screen becomes admin; an open + sign-up on an empty collection still gets `defaultRole`. Turn off: `access.firstUserAdmin: false`. +- **2FA** targets `admin.user`. A `twoFactor.collectionSlug` that is not an auth collection, or differs from + `admin.user`, stops startup with a clear error. Override: `twoFactor.allowCollectionMismatch: true`. +- **Rate limit:** requests without a client IP share one `unknown-ip` bucket at 20× the limit (before: no limit). + `setUnknownIpFactor(n)`, `UNKNOWN_IP_FACTOR`; `setUnknownIpFactor(0)` only with a limiter in front. +- **Turnstile hostname check** (opt-in): `createSubmitAction({ turnstileHostnames })`, `verifyTurnstile({ hostnames })`. +- **`RenderRichText` neutralises unsafe link URLs** (`javascript:` and similar → `#`). Off: `safeLinks={false}` + (fully trusted content only). +- **Consent Mode `'basic'`** (opt-in): `` sends nothing to Google until analytics or + marketing consent. Default stays `'advanced'`. The rule is exported: `shouldLoadGoogle` (root and `/client`). +- **Construction mode** now also hides pages from the Markdown mirror, MCP and search + (`isPathVisible`, `isPathVisibleIn`, `pathOf`, type `PathVisibility`). Opt out per route: + `markdown: { isPathVisible: () => true }`, `mcp: { isPathVisible: () => true }`. +- Old-slug redirects skip never-published drafts (`resolveRedirect({ draft: true })` to include them). MCP rejects + non-object messages (-32600). The locale cookie honours consent saved under a bumped policy version + (`createProxy(config, { policyVersion })`). +- **`enabled: false` keeps the plugin's schema** (collections, globals, fields) and drops only endpoints, `onInit` + and admin components. Before, it dropped the collections and globals, so a Postgres `migrate:create` would drop + their tables. +- **Collection overrides for consent records and stats:** `consentLog.collectionOverrides`, + `stats.collectionOverrides` (object merges `access` / `admin` / `hooks`, function takes over; + `applyCollectionOverride`, type `CollectionOverride`). The stats view and dashboard chart follow the `stats-visits` + read access, so an override narrows the panel too. + +### Performance +- **`getSettings` / `getSiteShell` read Site Settings at `depth: 1`** (was 2, which pulled every assigned page's + blocks and media on every request). The archive page is re-fetched at page depth. Override: + `createContentHelpers({ settingsDepth: 2 })`. +- Stats and consent-log retention purges run off the request, as one `deleteMany`. +- `isPathVisible` reads construction mode once per list. Global saves can revalidate the layout: + `ipalKit({ revalidatePath })` (opt-in), `buildGlobalRevalidateHook` for your own globals; skip once with + `context: { disableRevalidate: true }`. +- Hooks run Local API calls with `req` (same transaction); cross-locale sync restores `req.locale`. +- Server entries no longer load `'use client'` modules. + +### SEO, GEO and Search Console +- **Site Settings → Search & AI tab:** search-engine verification codes (Google, Bing, Yandex → `` via + `generatePageMetadata`), AI crawler policy and rules (→ robots.txt via `getRobots`), localized `llmsIntro` (→ top + of `/llms.txt`). Empty fields change nothing. Off: top-level `searchSettings: false` (works without `seo`; + `seo.searchSettings` still works, the top-level option wins). Your own fields: `searchSettings: (fields) => fields`. + Building blocks: `verificationFrom`, `robotsOptionsFrom`, `AI_ASSISTANT_BOTS`, `AI_TRAINING_BOTS`. +- **`getRobots`** in `createContentHelpers`: `app/robots.ts` → `export { getRobots as default } from '@/lib/content'`. +- **Sitemap index** above 10 000 URLs (`/sitemap.xml?part=N`), CDN cache headers and an in-memory memo, documents + read in batches of 500. `sitemapOptions: { maxUrls, cacheControl, memoSeconds }`, `sitemapEntries`, + `createSitemapRouteHandler`, `buildSitemapIndexXml`. +- **Sitemap errors are errors:** at runtime `sitemapRoute` answers 503 with `Retry-After` and `sitemap()` throws + (before: an empty 200 / `[]`, which told Google the site had no pages). The build phase still falls back. +- Construction mode filters the sitemap and llms.txt. Off: `underConstructionSeo: false`. +- Unknown-route metadata is `noindex`. `collectSiteIndex` no longer caps at 1000 entries (MCP keeps `limit: 1000`). +- `seo.uploadsCollection` (default `'media'`) — the upload collection `meta.image` relates to. +- DNS verification is the default path for Search Console; `ipal-seo-check` reports a missing verification tag as + INFO only, and follows the sitemap index. + +### Seeding — `@intecion/ipal-kit/seed` (new entry) +- **`createSeeder(payload, options)`** → `upsertBySlug`, `upsertBy`, `fillGlobal`, `summary()`. Dry run, update vs + skip of entries edited in the panel, production guard (refuses non-local databases and `NODE_ENV=production` + unless allowed), seed context that skips revalidation and IndexNow. Reads the same env vars as the old templates + (`SEED_DRY_RUN` / `--dry-run`, `SEED_UPDATE`, `SEED_FORCE`, `IPAL_SEED_ALLOW_PROD_UPDATE`, `SEED_LOCAL_HOSTS`, + `SEED_DB_URL_ENV`, `SEED_UNTOUCHED_SECONDS`, `SEED_HASH_FIELD`). `guard: false` turns the guard off. +- Building blocks: `isLocalDatabase`, `writeLocales`, `seedHash`, `projectOnto`, `editedSinceSeed`. +- The `ipal-site` and `ipal-form` seed templates are now thin scripts over the helper. +- IndexNow skips writes with `context.ipalSkipIndexNow`. + +### Documentation and agent guide +- All docs, the agent guide (`docs/agent/AGENT.md`) and the `ipal-*` skills are in English. +- The agent guide covers every export, option, env var, route, middleware, layout component, import-map entry and + hook a project wires, with steps to verify. New: §7.1 "Newer defaults — turn off / override", a seeding guide, + Coolify deployment (env, migrations, seeding, backups), a DNS records checklist. +- `CLAUDE.md` states the plugin's two rules: the plugin helps projects and never limits them; an agent that adds + the plugin gets the complete guide. + +### Small and gap fixes +- `ipalEnvRules({ storage: true })`: `R2_PUBLIC_URL` is optional; `storage: { requirePublicUrl: true }` requires it. +- `forms.consentFieldName` now works: `submitForm` reads it from the `ipalKit` options. +- Top-level `searchSettings` option, public `shouldLoadGoogle`, collection overrides for `consent-records` and + `stats-visits` (see above). + +### What projects must update +1. **Behaviour change — projects without `access`:** every logged-in account can now use the plugin's admin and + editor features: Site Integrations, the settings globals, the test e-mail endpoint, stats, consent records, forms + and form submissions. Before, nobody could through the API. If the project lets untrusted people log in (open + sign-up, customer accounts), add `access` (roles), or narrow each feature with `globalOverrides`, + `forms.formOverrides` / `forms.formSubmissionOverrides`, `consentLog.collectionOverrides`, + `stats.collectionOverrides`. +2. **Projects with `access`:** accounts with the plain `user` role can no longer edit Site Settings, Cookie + Settings, Notifications or forms, or create and delete users. Give staff accounts `editor` or `admin`, or loosen + with `globalOverrides`, `forms.formOverrides.access`, `access.authAccess`. +3. **Postgres/SQLite: `payload migrate:create` → `migrate`** (Site Settings → Search & AI: `search_verification_*`, + `ai_crawlers_policy`, the `ai_crawlers_rules` table, localized `llms_intro`). With `enabled: false`, the + migration now keeps (or restores) the plugin's tables. MongoDB: no changes. +4. `pnpm payload generate:importmap`, `pnpm ipal:skills`. +5. Check: + - code that reads a relation of a relation from `getSettings` / `getSiteShell` → `settingsDepth: 2`; + - a hand-written `sitemap()` caller that relied on `[]` on errors (it throws now); + - `twoFactor.collectionSlug` other than `admin.user` (stops startup → `allowCollectionMismatch: true`); + - rate limits behind a proxy that hides the client IP (`setUnknownIpFactor`); + - rich text with deliberately unusual link schemes (`safeLinks`). +6. Review the new options and defaults: `consentMode` (`'basic'` for "zero tags before consent"), + `revalidatePath`, `turnstileHostnames`, the Search & AI tab (fill in verification codes or keep DNS + verification), `app/robots.ts` → `getRobots`, `createSearchRoute({ isPathVisible })`, `access.firstUserAdmin`. +7. Remove workarounds: a plugin after `ipalKit` that adds hooks or access to the plugin globals → + `globalOverrides` / `revalidatePath`; a hand-written global revalidation hook → `buildGlobalRevalidateHook`; + your own seed guard and upsert code → `@intecion/ipal-kit/seed`. + ## 1.12.3 ### New diff --git a/package.json b/package.json index 9b27703..83b661f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@intecion/ipal-kit", - "version": "1.12.3", + "version": "1.13.0", "description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.", "license": "MIT", "repository": {