Files
ipal-kit/docs/integrations.md
T
Radosław SmolińskiandClaude Opus 5.5 2d9f3e15d4 Docs in English (part 1), seeding guide, Coolify deployment
- Translate to English every doc the code branches did not touch: AGENT.md,
  developer guide, vibe, CHANGELOG, docs index, module pages, all skills
  except ipal-seo-check (14 pages follow after the security/SEO merge).
  Placeholder marker is now [TO FILL: …]; skill resources renamed to
  section-code.md / nav-code.md. AGENT.md and the ipal-skills pointer
  block say the docs are in English.
- docs/seeding.md: create-only, natural keys, never delete, no users or
  secrets, empty-field globals, fallbackLocale: false, dry run, backup and
  restore, production update guard, seeds vs migrations, Coolify Terminal.
  Seed templates gain --dry-run, the SEED_UPDATE production guard
  (IPAL_SEED_ALLOW_PROD_UPDATE), skip of edited records and a summary.
  "Seeding on production" rule block in AGENT.md.
- Coolify is the single deployment path (deployment, env, developer guide,
  ipal-setup): build vs runtime env, migrations on container start
  (prodMigrations), health check and rolling updates, rollback, backups and
  restore, DNS/Let's Encrypt/CAA. R2: custom domain needs a Cloudflare zone;
  default is media served by the app (R2_PUBLIC_URL empty).
- docsConsistency: no Polish prose outside code/quoted data (pending pages
  listed); IPAL_* names may also be read by shipped skill templates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 17:39:03 +02:00

78 lines
4.2 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` |
| Turnstile | `turnstileSiteKey`, `turnstileSecretKey`, hidden `turnstileStatus` + banner |
| SMTP | `emailTransport` (`smtp` / `graph`), `smtpHost`, `smtpPort`, `smtpUser`, `smtpPassword`, `smtpFromAddress`, `smtpFromName`, test button, hidden `emailStatus` + banner |
| IndexNow | `indexNowKey` (generated on first save) |
| Custom | 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 (SMTP) 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'
ipalKit({
integrationsFields: [
buildIntegrationStatusBanner('crmStatus', 'CRM'), // UI field `crmStatusBanner`
{ 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`. The dashboard
`IntegrationAlerts` checks only `emailStatus` and `turnstileStatus` by default (prop `checks`) —
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 `ipalKit()` that removes / replaces the entry in `config.globals`, `config.endpoints` or
`admin.components.beforeDashboard`.
- Extension: `integrationsFields` (Custom tab). The plugin's tabs, access and labels cannot
currently be overridden with an option.