Stable admin import map without R2 env, read-only media, Cookie Settings save-button migration

buildR2Storage registered nothing without R2_* env, so `pnpm dev` / generate:importmap in dev
wrote an importMap.js without S3ClientUploadHandler — committed, the production admin (R2 on)
rendered a blank page with no console error (hit vanstev.pl). The injected s3Storage is now
always registered (enabled: false without R2 → local disk); storage-s3 still adds its client
handler, so the import map is identical in every environment. ipal-audit flags an import map
without the handler.

R2_PUBLIC_URL alone (absolute, outside production) = read-only media: URLs from the media
domain, upload/delete refused with 403 — local dev against a production database without
bucket keys. ipalEnvRules allows it in development.

Cookie Settings (MongoDB): the 1.11.1 rename buttons.save → savePreferences lost the texts on
the first save; onInit copies the old value (all locales) when the new field is missing.
getConsentTexts read the old field as a string, Mongo returns the raw { pl, en } map.

Also: context.ipalSkipAutoFill (SKIP_AUTO_FILL) — save without meta / aiSummary auto-fill;
createPageRoute redirects the homepage under its own slug (homeAlias, default 'redirect');
ipal-audit: multi-line tsconfig exclude, numeronyms (a11y) not "numbered fields",
`${prefix}/${slug}` links and slugs typed into links detected, clearer panel-language message.
Docs: fallback-on-save in i18n.md, `pnpm up --latest` and the stale-token 401 in PROGRAMISTA §1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-21 16:45:03 +02:00
co-authored by Claude Opus 5.5
parent 2c3195c4e1
commit e1431a7c49
25 changed files with 511 additions and 23 deletions
@@ -0,0 +1,39 @@
import type { BasePayload } from 'payload'
type MongoGlobals = {
collection?: {
updateOne: (
filter: Record<string, unknown>,
update: Record<string, unknown>[],
) => Promise<{ modifiedCount?: number }>
}
}
/**
* 1.11.1 renamed Cookie Settings `buttons.save` → `buttons.savePreferences` (Mongoose
* reserves `save`). MongoDB keeps the old key, but the first save of the global — panel
* or script — rewrites the document without it, and the button text silently falls back
* to "Save preferences" in every language. Runs once per start: copies the old value
* (all locales at once) into the new field when the new one is still missing.
* SQL adapters: the column rename happens in the migration (`migrate:create` → rename).
*/
export async function migrateCookieSettingsSaveButton(payload: BasePayload): Promise<void> {
if (payload.db.name !== 'mongoose') {return}
const globals = (payload.db as unknown as { globals?: MongoGlobals }).globals
if (!globals?.collection) {return}
try {
const result = await globals.collection.updateOne(
{
'buttons.save': { $exists: true },
'buttons.savePreferences': { $exists: false },
globalType: 'cookie-settings',
},
[{ $set: { 'buttons.savePreferences': '$buttons.save' } }],
)
if (result.modifiedCount) {
payload.logger.info('[ipal] Cookie Settings: buttons.save copied to buttons.savePreferences (1.11.1 rename).')
}
} catch (error) {
payload.logger.error({ err: error, msg: '[ipal] Cookie Settings: could not migrate buttons.save → buttons.savePreferences' })
}
}