Merge main (security-perf + SEO) into docs; finish English docs and agent guide
- Resolve conflicts in analytics, consent, content, i18n, mcp and stats, keeping the docs fixes and the new code behaviour, verified against src - Translate the remaining 14 module pages, ipal-seo-check skill and script - Integrate the security-perf and SEO agent-guide text: getRobots, isPathVisible, Search & AI (DNS verification first, meta fields optional), sitemap index/cache/503, consentMode basic/advanced, policyVersion, globalOverrides, revalidatePath / buildGlobalRevalidateHook, authAccess, firstUserAdmin, allowCollectionMismatch, unknown-IP rate limit; stale claims fixed across AGENT.md, skills, frontend, developer guide, vibe - docsConsistency: pending list removed (all docs English); relative links now also check #anchors Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+48
-43
@@ -1,42 +1,42 @@
|
||||
# notifications
|
||||
|
||||
Teksty powiadomień (wyniki akcji) konfigurowane w panelu, per język, z
|
||||
fallbackiem. Na dziś obsługuje komunikaty wyników formularza (`submitForm`),
|
||||
z miejscem na przyszłe konteksty. Global **Notifications**, budowany zawsze.
|
||||
Notification texts (action results) configured in the admin panel, per language, with a
|
||||
fallback. Today it covers form result messages (`submitForm`),
|
||||
with room for future contexts. The **Notifications** global is always built.
|
||||
|
||||
## Zasada
|
||||
## Principle
|
||||
|
||||
Plugin daje KOD wyniku (`submitForm` zwraca `reason`), nie tekst. Ten moduł
|
||||
mapuje kod → tekst z panelu (localized), z fallbackiem angielskim per pole.
|
||||
Front dostaje gotowy string i styluje go jak chce (toast, inline, banner).
|
||||
Dzięki temu żaden komunikat nie jest zaszyty w kodzie — wszystko przez panel.
|
||||
The plugin returns a result CODE (`submitForm` returns `reason`), not text. This module
|
||||
maps code → text from the panel (localized), with an English fallback per field.
|
||||
The frontend gets a ready string and styles it as it likes (toast, inline, banner).
|
||||
This way no message is hardcoded — everything goes through the panel.
|
||||
|
||||
## Config
|
||||
|
||||
Brak opcji — global **Notifications** (slug `notifications`, grupa panelu *Settings*) jest zawsze budowany. Edytor zarządza
|
||||
tekstami w panelu (karta Notifications), grupowane per kontekst. Grupa `form`:
|
||||
No options — the **Notifications** global (slug `notifications`, panel group *Settings*) is always built. The editor manages
|
||||
the texts in the panel (Notifications tab), grouped per context. Group `form`:
|
||||
`success`, `error`, `rateLimited`, `turnstile`, `validation`, `consent`,
|
||||
`notFound` oraz przyciski formularzy krokowych: `next` („Dalej”), `back` („Wstecz”),
|
||||
`stepOf` („Krok {current} z {total}”). Każde pole puste → fallback (`NOTIFICATION_FALLBACK`, EN,
|
||||
eksportowany z `@intecion/ipal-kit`).
|
||||
Dla formularzy: `getFormTexts(locale)` z `lib/content` = grupa `form` w danym języku.
|
||||
`notFound` and the multi-step form buttons: `next` ("Next"), `back` ("Back"),
|
||||
`stepOf` ("Step {current} of {total}"). Every empty field → fallback (`NOTIFICATION_FALLBACK`, EN,
|
||||
exported from `@intecion/ipal-kit`).
|
||||
For forms: `getFormTexts(locale)` from `lib/content` = the `form` group in the given language.
|
||||
|
||||
## Helper — getNotificationTexts
|
||||
|
||||
Pobiera teksty z globala per język, fallback per pole. Analog `getConsentTexts`:
|
||||
Reads the texts from the global per language, with a fallback per field. The counterpart of `getConsentTexts`:
|
||||
|
||||
```ts
|
||||
import { getNotificationTexts } from '@intecion/ipal-kit'
|
||||
|
||||
const notifications = await getNotificationTexts({ payload, locale }) // w lib/content: getFormTexts(locale) = .form
|
||||
const notifications = await getNotificationTexts({ payload, locale }) // in lib/content: getFormTexts(locale) = .form
|
||||
// notifications.form.error, notifications.form.success, ...
|
||||
```
|
||||
|
||||
## Mapowanie wyniku — resolveFormMessage
|
||||
## Mapping the result — resolveFormMessage
|
||||
|
||||
Most między `submitForm` a UI: bierze wynik i teksty, zwraca jeden komunikat.
|
||||
Interpoluje `{field}` w walidacji. NIGDY nie pokazuje surowego wyjątku
|
||||
(`error` → generyczny tekst, nie treść błędu backendu).
|
||||
The bridge between `submitForm` and the UI: takes the result and the texts, returns one message.
|
||||
Interpolates `{field}` in the validation text. NEVER shows a raw exception
|
||||
(`error` → a generic text, not the backend error message).
|
||||
|
||||
```ts
|
||||
import { resolveFormMessage } from '@intecion/ipal-kit'
|
||||
@@ -47,38 +47,43 @@ if (!result.success) {
|
||||
}
|
||||
```
|
||||
|
||||
To zastępuje sztywne `Błąd: ${result.reason}` — teraz przyjazny tekst z panelu,
|
||||
per język.
|
||||
This replaces a hardcoded `Error: ${result.reason}` — now a friendly text from the panel,
|
||||
per language.
|
||||
|
||||
## Interpolacja {field}
|
||||
## {field} interpolation
|
||||
|
||||
Tekst `validation` może zawierać `{field}` — podstawia się **nazwa techniczna** pola z
|
||||
błędem (`name`, nie etykieta), tylko pierwsze wystąpienie `{field}`; brak nazwy → pusty string:
|
||||
The `validation` text may contain `{field}` — it is replaced with the **technical name** of the field with
|
||||
the error (`name`, not the label), only the first `{field}` occurrence; no name → empty string:
|
||||
|
||||
```
|
||||
Panel: "Sprawdź pole {field} i spróbuj ponownie."
|
||||
Wynik: "Sprawdź pole email i spróbuj ponownie."
|
||||
Result: "Sprawdź pole email i spróbuj ponownie."
|
||||
```
|
||||
|
||||
## Rozszerzanie o nowe konteksty
|
||||
## Adding new contexts
|
||||
|
||||
Grupa `form` to pierwszy kontekst. Kolejne (`newsletter`, `system`) dodaje się
|
||||
tak samo — nowa grupa w `globals/Notifications/fields.ts` + pole w typach +
|
||||
fallback. `getNotificationTexts` resolwuje, co istnieje.
|
||||
The `form` group is the first context. Further ones (`newsletter`, `system`) are added
|
||||
the same way — a new group in `globals/Notifications/fields.ts` + a field in the types +
|
||||
a fallback. `getNotificationTexts` resolves whatever exists.
|
||||
|
||||
## Dostęp
|
||||
## Access
|
||||
|
||||
Global ma `read: () => true` — teksty są publiczne (pokazywane użytkownikom
|
||||
końcowym), więc front czyta je bez sesji. Inaczej niż SiteIntegrations
|
||||
(`read: isAdmin` — tam sekrety).
|
||||
The global has `read: () => true` — the texts are public (shown to end
|
||||
users), so the frontend reads them without a session. Write: `editor+` (`adminOrEditor`). Unlike SiteIntegrations
|
||||
(`read: isAdmin` — secrets live there).
|
||||
|
||||
## Wyłączenie, nadpisanie, rozszerzenie
|
||||
## Turn off, override, extend
|
||||
|
||||
- **Wyłączenie:** brak — global `notifications` jest obecnie zawsze dodawany (także bez opcji `forms`).
|
||||
- **Nadpisanie tekstów:** w panelu, per język; puste pole → `NOTIFICATION_FALLBACK` (EN).
|
||||
Fallbacków nie da się podmienić opcją pluginu — własne domyślne teksty nakładasz w projekcie
|
||||
na wynik `getNotificationTexts` (np. `texts.form.error ||= '…'`).
|
||||
- **Nadpisanie mapowania:** `resolveFormMessage` jest opcjonalny — możesz mapować `result.reason`
|
||||
własnym switchem.
|
||||
- **Rozszerzenie:** pola globala są obecnie stałe (brak opcji dodania grup / pól przez `ipalKit`);
|
||||
nowy kontekst wymaga zmiany w pluginie (`globals/Notifications/fields.ts`, typy, fallback).
|
||||
- **Turn off:** none — the `notifications` global is currently always added (also without the `forms` option).
|
||||
- **Override texts:** in the panel, per language; empty field → `NOTIFICATION_FALLBACK` (EN).
|
||||
The fallbacks cannot be swapped with a plugin option — apply your own default texts in the project
|
||||
on the result of `getNotificationTexts` (e.g. `texts.form.error ||= '…'`).
|
||||
- **Override access / hooks / admin:** `ipalKit({ globalOverrides: { notifications: … } })` — an object merges
|
||||
`access`, `admin` and `hooks` key by key over the plugin's (e.g. let any logged-in user edit:
|
||||
`{ notifications: { access: { update: authenticated } } }`), a function gets the global and returns the one to use.
|
||||
- **Override mapping:** `resolveFormMessage` is optional — you can map `result.reason`
|
||||
with your own switch.
|
||||
- **Extend:** the global's fields are fixed in the plugin (no `ipalKit` option to add groups / fields);
|
||||
for a project-only extra, a `globalOverrides.notifications` function can append fields, but
|
||||
`getNotificationTexts` will not read them — a new shared context needs a change in the plugin
|
||||
(`globals/Notifications/fields.ts`, types, fallback).
|
||||
|
||||
Reference in New Issue
Block a user