Gap fixes: top-level searchSettings, public shouldLoadGoogle, consent/stats collection overrides

- ipalKit({ searchSettings }): switches off / reshapes Site Settings → Search & AI
  without `seo`; read as options.searchSettings ?? options.seo?.searchSettings.
- shouldLoadGoogle moved to a pure module (analytics/shouldLoadGoogle.ts) and
  exported from @intecion/ipal-kit and /client.
- consentLog.collectionOverrides and stats.collectionOverrides (object merges
  access/admin/hooks key by key, function takes over), via the new exported
  applyCollectionOverride / CollectionOverride. The stats view and dashboard
  chart now follow the stats-visits read access, so overrides narrow them too.

All additive; defaults unchanged. Docs: AGENT.md, ipal-reference, consent,
stats, seo, analytics, ipal-setup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-22 18:54:08 +02:00
co-authored by Claude Opus 5.5
parent 4911da7112
commit 5a07c42f76
22 changed files with 235 additions and 54 deletions
+13 -2
View File
@@ -354,10 +354,11 @@ independent consent state).
| Item | Value |
|---|---|
| Option | `consentLog?: boolean \| { retentionDays?: number }` (type `ConsentLogOptions`) |
| Option | `consentLog?: boolean \| { retentionDays?: number; collectionOverrides?: CollectionOverride }` (type `ConsentLogOptions`) |
| `retentionDays` | default `1095` (3 years) |
| `collectionOverrides` | changes `consent-records`: an object merges `access` / `admin` / `hooks` key by key (your keys win), other keys replace; a function `(collection) => collection` takes over (keep the slug — the endpoint writes to it) |
| Collection | `consent-records` (`CONSENT_LOG_SLUG`), group *Settings*; fields `consentId` (index), `version`, `choices.{necessary,functional,analytics,marketing}`, `createdAt` |
| Collection access | `read` / `delete` — admin; `create` / `update` — nobody through the API (written only by the endpoint, `overrideAccess`) |
| Collection access | `read` / `delete` — admin (without `access`, i.e. no roles: any logged-in account — narrow it with `collectionOverrides`); `create` / `update` — nobody through the API (written only by the endpoint, `overrideAccess`) |
| Endpoint | `POST /api/ipal/consent`, public (no login) |
| Body | `{ id: string (hex 16–64), version: int ≥ 1, state: { necessary, functional, analytics, marketing: boolean } }` |
| Responses | `201 { ok: true }`, `400` (bad JSON/validation), `429` (limit 20 requests/min per IP, scope `consent`), `500` |
@@ -367,6 +368,16 @@ The provider sends a record after every decision (`fetch` with `keepalive`, erro
the banner never waits). By hand: `buildConsentLogCollection()` / `buildConsentLogEndpoint(opts)`
from `@intecion/ipal-kit`.
Narrow who reads the records (e.g. a project without roles, only the data protection officer):
```ts
ipalKit({
consentLog: {
collectionOverrides: { access: { read: ({ req }) => req.user?.email === '[email protected]' } },
},
})
```
## Turn off, override, extend
- **Turn off:** do not mount `CookieBanner` / `CookieButton` (or `SiteProviders banner={false}