- docs, AGENT.md, the 16 skills, PROGRAMISTA and README use the preferred names (scripted, same list of forms); past CHANGELOG entries and the proposals in docs/dev are not rewritten - AGENT.md: 'Names: IAPL and ipal-kit' — old name, new name, state in 1.x; what is not renamed; storageNames - iapl-upgrade '→ 1.17.0', PROGRAMISTA §6 item 72, CHANGELOG 1.17.0 (draft): nothing required - env.md, doctor.md (legacy-names, storage-names), stats.md, security.md, project-starter.md, iapl-reference, iapl-setup - skill scripts read ipal-audit-skip and IPAL_IP_HEADER too; audit rule ids stay what they were - reference site: iapl(), iapl-doctor.json, iapl-* skills, storageNames: 'iapl'; INDEX.md regenerated Co-Authored-By: Claude Fable 5.2 <[email protected]>
85 lines
4.9 KiB
Markdown
85 lines
4.9 KiB
Markdown
# integrations — the Site integrations global and integration status in the admin panel
|
|
|
|
External service keys edited in the admin panel, plus a notice for the editor when one of them
|
|
stops working — no crons, no polling: the server records the status when it actually uses an integration.
|
|
|
|
Related: [email.md](./email.md) (SMTP/Graph), [turnstile.md](./turnstile.md),
|
|
[analytics.md](./analytics.md), [seo.md](./seo.md) (IndexNow), [deployment.md](./deployment.md).
|
|
|
|
## The `site-integrations` global (panel: Settings → Site integrations)
|
|
|
|
Currently always added by the plugin. Tabs (unnamed — flat data, e.g. `ga4MeasurementId`):
|
|
|
|
| Tab | Fields |
|
|
|---|---|
|
|
| Analytics | `ga4MeasurementId`, `gtmContainerId`, `metaPixelId`, `clarityProjectId`, `linkedInPartnerId`, `tiktokPixelId` |
|
|
| Spam protection | `turnstileSiteKey`, `turnstileSecretKey`, hidden `turnstileStatus` + banner |
|
|
| E-mail sending | `emailTransport` (`smtp` / `graph`), `smtpHost`, `smtpPort`, `smtpUser`, `smtpPassword`, `smtpFromAddress`, `smtpFromName`, test button, hidden `emailStatus` + banner |
|
|
| IndexNow | `indexNowKey` (generated on first save) |
|
|
| More | fields from the `integrationsFields` option — only when given |
|
|
|
|
Access: read and write only for the `admin` role (secrets) — anonymous users and editors get nothing
|
|
over REST/GraphQL. On the server, read through the Local API:
|
|
|
|
```ts
|
|
import { getSiteIntegrations } from '@intecion/ipal-kit'
|
|
const integrations = await getSiteIntegrations<SiteIntegration>(payload) // overrideAccess — do not send the whole thing to the browser
|
|
```
|
|
|
|
The "Send test" button (E-mail sending tab) calls `POST /api/ipal/test-email` (endpoint currently always added).
|
|
|
|
## Integration status — dashboard alert and tab banner
|
|
|
|
- **Write:** `mailAdapter()` on every send (`emailStatus`) and Turnstile verification on a
|
|
form (`turnstileStatus`) call `recordIntegrationStatus`. It writes only when the state changes,
|
|
or at most every 10 min while an error lasts; it never throws.
|
|
- **Changing keys in the admin panel** (Turnstile, `emailTransport` / `smtp*`) clears that integration's old status.
|
|
- **`IntegrationAlerts`** (`@intecion/ipal-kit/admin`) — the plugin always wires it into
|
|
`admin.components.beforeDashboard`: a list of integrations in the `degraded` state + Turnstile key
|
|
problems + an "Open Site integrations" link (from `adminRoute`). When everything works it renders nothing.
|
|
- **`IntegrationStatusBanner`** (`/admin`) — a banner on the tab: red on error (message,
|
|
code, since when), a green line after a fix, nothing before first use.
|
|
|
|
## Building blocks for your own integrations
|
|
|
|
The same mechanism for project integrations (fields via `integrationsFields`):
|
|
|
|
```ts
|
|
import { buildIntegrationStatusBanner, buildIntegrationStatusField, recordIntegrationStatus } from '@intecion/ipal-kit'
|
|
|
|
iapl({
|
|
integrationsFields: [
|
|
// UI field `crmStatusBanner`; label as a string or { en, pl }; optional third argument
|
|
// { failing, hint } = keys of your own texts in i18n.translations.<lang>.ipal
|
|
buildIntegrationStatusBanner('crmStatus', { en: 'CRM', pl: 'CRM' }),
|
|
{ name: 'crmApiKey', type: 'text' },
|
|
buildIntegrationStatusField('crmStatus'), // hidden group: state, code, message, since, checkedAt
|
|
],
|
|
})
|
|
|
|
// after calling the CRM (previous = the current crmStatus from getSiteIntegrations)
|
|
await recordIntegrationStatus(payload, 'crmStatus', previous, { state: 'degraded', code: 'http-500', message: 'CRM is down' })
|
|
await recordIntegrationStatus(payload, 'crmStatus', previous, { state: 'ok' })
|
|
```
|
|
|
|
After adding the banner: `pnpm payload generate:importmap`; Postgres: `migrate:create`.
|
|
|
|
Types: `IntegrationState` (`'ok' | 'degraded'`), `IntegrationStatus`, `IntegrationLabel`
|
|
(`string | { en, pl }`), `IntegrationBannerTexts` (`{ failing, hint }` — text keys). Without
|
|
texts the banner says "{label} is not working."; the plugin's own banners use
|
|
`statusEmailFailing` / `statusEmailHint` and `statusTurnstileFailing` / `statusTurnstileHint`
|
|
(override per language in `i18n.translations.<lang>.ipal`, see i18n.md "Admin panel languages and texts").
|
|
The dashboard `IntegrationAlerts` checks only `emailStatus` and `turnstileStatus` by default
|
|
(prop `checks`, labels as strings or `{ en, pl }`) — to show your own integration, wire a second
|
|
`IntegrationAlerts` with `checks: { crmStatus: 'CRM' }` into `beforeDashboard`.
|
|
|
|
## Turn off / override
|
|
|
|
- The `site-integrations` global, the `/api/ipal/test-email` endpoint and `IntegrationAlerts` on the dashboard
|
|
are **currently always added** — there is no option to turn them off. Workaround: a project plugin
|
|
wired after `iapl()` that removes / replaces the entry in `config.globals`, `config.endpoints` or
|
|
`admin.components.beforeDashboard`.
|
|
- Extension: `integrationsFields` (the *More* tab). Access, hooks, labels and tabs: override with
|
|
`iapl({ globalOverrides: { 'site-integrations': … } })` (an object merges `access` / `admin` / `hooks`,
|
|
a function gets the whole global — hooks.md).
|