From 3d5106bc4a0c083cd76237c2062ecbbe8f73a435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Smoli=C5=84ski?= Date: Wed, 25 Nov 2026 17:47:11 +0100 Subject: [PATCH] IAPL rename: readEnv exported, the MCP server name left as it was, legacy:site needs a database MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - readEnv / legacyEnvName exported from the root and /env (a project's own code reads IAPL_* with the IPAL_* fallback); the name constants hold the IAPL_ spelling — changelog and env.md say so - createMcpRoute: the default serverName stays 'ipal-site' (clients see it); the scripted step had changed it - legacy:site: the builds read the database; the script and PROGRAMISTA say which Co-Authored-By: Claude Fable 5.2 --- docs/CHANGELOG.md | 3 +++ docs/agent/skills/iapl-reference/resources/api.md | 1 + docs/dev/PROGRAMISTA.md | 2 +- docs/env.md | 6 ++++++ docs/mcp.md | 2 +- reference/.agents/skills/iapl-reference/resources/api.md | 1 + scripts/legacy-site-check.mjs | 3 ++- src/exports/env.ts | 2 +- src/index.ts | 2 +- src/modules/env/index.ts | 1 + src/modules/mcp/createMcpRoute.ts | 4 ++-- 11 files changed, 20 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6f86e4b..2275a60 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -32,6 +32,9 @@ once there are more than 20. - **Not renamed:** the package and its import paths, import-map paths, routes `/api/ipal/*`, CSS tokens `--ipal-*`, `data-ipal` hooks, `config.custom.ipal`, `req.context` flags, the `ipal` translation namespace, the header `X-Ipal-Cookie-Crawler`. They change, with a migration path, in 2.0. +- The exported name constants `SITE_NOINDEX_ENV`, `COOKIE_SCAN_URL_ENV` and `COOKIE_SCAN_TOKEN_ENV` hold the `IAPL_` + spelling. The plugin reads both spellings itself; code of your own that does `process.env[SITE_NOINDEX_ENV]` should + call `readEnv(SITE_NOINDEX_ENV)` (new, from `/env` or the root) or `isSiteNoindex()`. - Docs, the agent guide and the skills use the new names; `AGENT.md` has one table of old and new names ("Names: IAPL and ipal-kit"). - Audit findings whose titles named a command (`iapl-tokens --check`, "forms in iapl", `IAPL_IP_HEADER in .env.example`) diff --git a/docs/agent/skills/iapl-reference/resources/api.md b/docs/agent/skills/iapl-reference/resources/api.md index 3137f81..1d9bf2a 100644 --- a/docs/agent/skills/iapl-reference/resources/api.md +++ b/docs/agent/skills/iapl-reference/resources/api.md @@ -305,6 +305,7 @@ Opt-in with `iapl({ cookieScanner: true })`; the plugin wires the collection, en | Export | Import from | What it does / when | |---|---|---| | `assertEnv(rules, { env?, label? })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | validates `process.env` against the rules at startup; collects every missing item and throws one error | +| `readEnv(name, env?)`, `legacyEnvName(name)` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | Value of a plugin variable: `IAPL_` first, the spelling before 1.17.0 (`IPAL_`) when it is missing or empty. `legacyEnvName('IAPL_NOINDEX')` → `'IPAL_NOINDEX'`. For your own code that reads `IAPL_*`. | | `iaplEnvRules({ storage?, emailGraph?, ipHeader?, turnstile?, serverUrlVar?, secretVar?, secretMinLength?, databaseVar?, databaseName? })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | ready rule set (`DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL` + `R2_*`/`GRAPH_*`/Turnstile/`IAPL_IP_HEADER` depending on the features used) for `assertEnv`; `R2_PUBLIC_URL` optional unless `storage: { requirePublicUrl: true }`; `secretMinLength` (default 32, `0` = off) is the minimum `PAYLOAD_SECRET` length in production; `databaseName: true \| { domain?, warn? }` only warns when the `DATABASE_URI` database is not `_prod` / `_dev` | | `databaseNamesFor(domainOrUrl)` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | the two database names for a site: `intecion.com` → `{ prod: 'intecioncom_prod', dev: 'intecioncom_dev' }` (`www.` dropped, dots removed) | | `databaseNameFromUri(uri)` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | the database name (URI path) of a Mongo / Postgres `DATABASE_URI`; null for SQLite files or no name | diff --git a/docs/dev/PROGRAMISTA.md b/docs/dev/PROGRAMISTA.md index 045cc0e..dd97c85 100644 --- a/docs/dev/PROGRAMISTA.md +++ b/docs/dev/PROGRAMISTA.md @@ -780,7 +780,7 @@ done until the reference site uses it. Before `npm version`: and installed against this build without one edit: the old commands run, the doctor reports no error, the committed import map and `tokens.css` are still current, `tsc` passes, and it builds with webpack and with Turbopack. This is the proof that an existing site upgrades with no change (`scripts/legacy-site-check.mjs`; - no database needed). With it: `test/legacyNames.test.ts` (every old name) and `test/legacyNameForms.test.ts` + `DATABASE_URI` = a reachable local MongoDB, an empty one is enough). With it: `test/legacyNames.test.ts` (every old name) and `test/legacyNameForms.test.ts` (no new name is born with the old spelling). - [ ] **`pnpm e2e:built` green — required, no release without it.** It builds the reference site with webpack AND with Turbopack (with the late-staff fixture, `E2E_LATE_STAFF=1`) and runs, on each built site: the account rules of diff --git a/docs/env.md b/docs/env.md index 4235a83..b2c01db 100644 --- a/docs/env.md +++ b/docs/env.md @@ -97,6 +97,12 @@ whose messages name the `IAPL_` spelling). Set one of the two; `iapl-doctor` (`l set with different values. For your own rules: `{ name: 'NEW_NAME', aliases: ['OLD_NAME'] }` reads the old name the same way. `ipalEnvRules` is the old name of `iaplEnvRules` and still exported. +Reading one of the plugin's variables in your own code: `readEnv('IAPL_NOINDEX')` (from `@intecion/ipal-kit/env` or the +root) returns the `IAPL_` value, else the `IPAL_` one; `legacyEnvName('IAPL_NOINDEX')` is `'IPAL_NOINDEX'`. The exported +name constants (`SITE_NOINDEX_ENV`, `COOKIE_SCAN_URL_ENV`, `COOKIE_SCAN_TOKEN_ENV`) hold the `IAPL_` spelling since +1.17.0, so `process.env[SITE_NOINDEX_ENV]` alone no longer sees a variable set under the old name — use `readEnv` +(or `isSiteNoindex()`). + The plugin also reads (outside the preset — add your own rules if you want to validate them): `INDEXNOW_KEY` (seo.md), `IAPL_NOINDEX` (`1`/`true`/`yes` — staging, seo.md), `IAPL_DOCTOR_TOKEN` (≥ 32 characters — turns `GET /api/ipal/doctor` on, doctor.md). Full table: diff --git a/docs/mcp.md b/docs/mcp.md index 4b8bc09..f7b3614 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -79,7 +79,7 @@ runs `initialize` → `tools/list` → and can then call `get_site_info`, | `content` | — | archive collections (`list_pages`, `get_page` for entries) | | `summaryField` | — | field with a richer AI description (`buildSummaryField`), preferred in results | | `isPathVisible` | — (from `createContentHelpers`: set) | `(path, locale) => boolean` — hides pages hidden by under-construction mode | -| `serverName` | `'iapl-site'` | name in `initialize` (and fallback site name) | +| `serverName` | `'ipal-site'` | name in `initialize` (and fallback site name) | | `serverVersion` | `'1.0.0'` | version in `initialize` | | `rateLimit` | `{ max: 60, windowMs: 60_000 }` | per-IP limit; `false` = off | | `clientIp` | — | `{ header?, trustedProxies? }` — where to read the IP from (see [forms.md](./forms.md#client-ip-and-rate-limit)) | diff --git a/reference/.agents/skills/iapl-reference/resources/api.md b/reference/.agents/skills/iapl-reference/resources/api.md index 3137f81..1d9bf2a 100644 --- a/reference/.agents/skills/iapl-reference/resources/api.md +++ b/reference/.agents/skills/iapl-reference/resources/api.md @@ -305,6 +305,7 @@ Opt-in with `iapl({ cookieScanner: true })`; the plugin wires the collection, en | Export | Import from | What it does / when | |---|---|---| | `assertEnv(rules, { env?, label? })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | validates `process.env` against the rules at startup; collects every missing item and throws one error | +| `readEnv(name, env?)`, `legacyEnvName(name)` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | Value of a plugin variable: `IAPL_` first, the spelling before 1.17.0 (`IPAL_`) when it is missing or empty. `legacyEnvName('IAPL_NOINDEX')` → `'IPAL_NOINDEX'`. For your own code that reads `IAPL_*`. | | `iaplEnvRules({ storage?, emailGraph?, ipHeader?, turnstile?, serverUrlVar?, secretVar?, secretMinLength?, databaseVar?, databaseName? })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | ready rule set (`DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL` + `R2_*`/`GRAPH_*`/Turnstile/`IAPL_IP_HEADER` depending on the features used) for `assertEnv`; `R2_PUBLIC_URL` optional unless `storage: { requirePublicUrl: true }`; `secretMinLength` (default 32, `0` = off) is the minimum `PAYLOAD_SECRET` length in production; `databaseName: true \| { domain?, warn? }` only warns when the `DATABASE_URI` database is not `_prod` / `_dev` | | `databaseNamesFor(domainOrUrl)` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | the two database names for a site: `intecion.com` → `{ prod: 'intecioncom_prod', dev: 'intecioncom_dev' }` (`www.` dropped, dots removed) | | `databaseNameFromUri(uri)` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | the database name (URI path) of a Mongo / Postgres `DATABASE_URI`; null for SQLite files or no name | diff --git a/scripts/legacy-site-check.mjs b/scripts/legacy-site-check.mjs index afdceaa..ae97922 100644 --- a/scripts/legacy-site-check.mjs +++ b/scripts/legacy-site-check.mjs @@ -11,7 +11,8 @@ * 4. a production build with webpack and one with Turbopack. * * Needs: the plugin built (`pnpm build`; --skip-plugin-build when dist is current), the tag in the local repository. - * The builds need no database (pages that read it are built on demand), but DATABASE_URI must be set to something. + * The builds read the database (static params), so DATABASE_URI must point at a reachable local MongoDB — an empty + * one is enough (default mongodb://127.0.0.1:27017/example-studiopl_dev, the reference site's local database). * Options: --tag=v1.16.7 · --only=webpack|turbopack · --skip-build (steps 1–3 only) · --keep (leave the folder). * The folder (.legacy-site-, git-ignored) is removed at the end unless --keep. */ diff --git a/src/exports/env.ts b/src/exports/env.ts index f817f90..2860bb7 100644 --- a/src/exports/env.ts +++ b/src/exports/env.ts @@ -13,5 +13,5 @@ * if (process.env.NEXT_RUNTIME === 'nodejs') assertEnv(iaplEnvRules({ storage: true })) * } */ -export { assertEnv, checkDatabaseName, databaseNameFromUri, databaseNamesFor, iaplEnvRules, ipalEnvRules } from '../modules/env/index.js' +export { assertEnv, checkDatabaseName, databaseNameFromUri, databaseNamesFor, iaplEnvRules, ipalEnvRules, legacyEnvName, readEnv } from '../modules/env/index.js' export type { AssertEnvOptions, EnvKind, EnvRule, IaplEnvFeatures, IpalEnvFeatures } from '../modules/env/index.js' diff --git a/src/index.ts b/src/index.ts index b20c25f..cf9ac4c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -216,7 +216,7 @@ export type { MailAdapterArgs } from './modules/email/mailAdapter.js' export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js' export type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js' // Boot-time environment validation (fail fast on misconfigured deploys). -export { assertEnv, checkDatabaseName, databaseNameFromUri, databaseNamesFor, iaplEnvRules, ipalEnvRules } from './modules/env/index.js' +export { assertEnv, checkDatabaseName, databaseNameFromUri, databaseNamesFor, iaplEnvRules, ipalEnvRules, legacyEnvName, readEnv } from './modules/env/index.js' export type { AssertEnvOptions, EnvKind, EnvRule, IaplEnvFeatures, IpalEnvFeatures } from './modules/env/index.js' export type { FormAttachmentsOption, FormFileScanInput, FormFileScanResult, FormSubmitEndpointOptions } from './modules/forms/attachments/config.js' export { buildFileBlock, fileBlock } from './modules/forms/attachments/fileBlock.js' diff --git a/src/modules/env/index.ts b/src/modules/env/index.ts index c62188a..b391123 100644 --- a/src/modules/env/index.ts +++ b/src/modules/env/index.ts @@ -1,3 +1,4 @@ +export { legacyEnvName, readEnv } from '../shared/envName.js' export { assertEnv } from './assertEnv.js' export type { AssertEnvOptions, EnvKind, EnvRule } from './assertEnv.js' export { checkDatabaseName, databaseNameFromUri, databaseNamesFor } from './databaseName.js' diff --git a/src/modules/mcp/createMcpRoute.ts b/src/modules/mcp/createMcpRoute.ts index 61fe01e..db67797 100644 --- a/src/modules/mcp/createMcpRoute.ts +++ b/src/modules/mcp/createMcpRoute.ts @@ -71,7 +71,7 @@ export type CreateMcpRouteArgs = { * `false` = off (a limiter in front, e.g. Cloudflare WAF rate limiting). */ rateLimit?: { max?: number; windowMs?: number } | false - /** Server name advertised in `initialize`. Default 'iapl-site'. */ + /** Server name advertised in `initialize`. Default 'ipal-site'. */ serverName?: string /** Server version advertised in `initialize`. Default '1.0.0'. */ serverVersion?: string @@ -104,7 +104,7 @@ export function createMcpRoute(args: CreateMcpRouteArgs) { getCachedPayload, isPathVisible, maxBatch = 10, - serverName = 'iapl-site', + serverName = 'ipal-site', serverVersion = '1.0.0', settingsSlug = 'site-settings', summaryField,