1.18.0 performance items: tests, the reference budget gate tightened (JS 195 kB, 404 without its exception, TTL check), docs (performance.md, AGENT.md, iapl-performance, module pages, api.md), changelog: what changes for an existing site

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 15:54:15 +01:00
co-authored by Claude Opus 5.5
parent d628839235
commit f0127ac1b8
35 changed files with 1154 additions and 288 deletions
+1 -1
View File
@@ -22,8 +22,8 @@ export { CookieScanButton } from '../modules/consent/scanner/CookieScanButton.js
export { CookieSiteCheckTab } from '../modules/consent/scanner/CookieSiteCheckTab.js'
export { CookieCrawlAlert } from '../modules/consent/scanner/crawl/CookieCrawlAlert.js'
export { IntegrationAlerts } from '../modules/integrations/IntegrationAlerts.js'
export { UNUSED_MEDIA_LINK_LIMIT, UnusedMediaNotice } from '../modules/media/UnusedMediaNotice.js'
export { IntegrationStatusBanner } from '../modules/integrations/IntegrationStatusBanner.js'
export { UNUSED_MEDIA_LINK_LIMIT, UnusedMediaNotice } from '../modules/media/UnusedMediaNotice.js'
export { SafeTotpView } from '../modules/security/totp/SafeTotpView.js'
export type { SafeTotpViewProps } from '../modules/security/totp/SafeTotpView.js'
export { TotpRedirectProvider } from '../modules/security/totp/TotpRedirectProvider.js'
+3 -3
View File
@@ -41,9 +41,6 @@ export type { ConstructionNoticeClassNames } from '../modules/construction/Const
export { CONSTRUCTION_CLOSE_LABEL, CONSTRUCTION_CLOSE_LABEL_PL, constructionCloseLabel } from '../modules/construction/texts.js'
export type { ConstructionMode } from '../modules/construction/types.js'
export { formatFileSize } from '../modules/forms/attachments/fileTypes.js'
// `BuilderForm` is the lazy wrapper since 1.18.0 (same props, the server renders the whole form): the form's code
// loads only on a page that shows one. The eager component: `@intecion/ipal-kit/client/eager`.
export { LazyBuilderForm as BuilderForm } from '../modules/forms/LazyBuilderForm.js'
export type { BuilderFieldRenderArgs, BuilderFormClassNames, BuilderFormProps } from '../modules/forms/BuilderForm.js'
export { autoCompleteFor, fileFieldError, fileFieldRules, initialBuilderValues, inputFields, splitSteps, stepOfField, validateBuilderFields, visibleFields } from '../modules/forms/builderLogic.js'
export type { BuilderFile } from '../modules/forms/builderLogic.js'
@@ -60,6 +57,9 @@ export type {
export { formAnalyticsOnSuccess } from '../modules/forms/formAnalytics.js'
export type { FormAnalyticsConfig } from '../modules/forms/formAnalytics.js'
export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from '../modules/forms/honeypot.js'
// `BuilderForm` is the lazy wrapper since 1.18.0 (same props, the server renders the whole form): the form's code
// loads only on a page that shows one. The eager component: `@intecion/ipal-kit/client/eager`.
export { LazyBuilderForm as BuilderForm } from '../modules/forms/LazyBuilderForm.js'
export { useBuilderForm } from '../modules/forms/useBuilderForm.js'
export type { BuilderFormApi, UseBuilderFormOptions } from '../modules/forms/useBuilderForm.js'
export { useContactForm } from '../modules/forms/useContactForm.js'
+2 -2
View File
@@ -8,8 +8,8 @@
export { DOCTOR_USAGE, expandSites, parseDoctorArgs, runDoctorCli } from '../modules/doctor/cli.js'
export { formatDriftTable, formatReport } from '../modules/doctor/format.js'
// What grows (docs/performance.md → "What grows"): the deep collector, the rules and their thresholds
export { collectGrowth } from '../modules/doctor/growth.js'
export type { GrowthStatus } from '../modules/doctor/growth.js'
export { collectGrowth, findUnusedMedia } from '../modules/doctor/growth.js'
export type { GrowthStatus, UnusedMedia } from '../modules/doctor/growth.js'
export { bareHost, createDoctorContext, loadDoctorConfig, parseEnvFile, readAuditSkips } from '../modules/doctor/project.js'
export type { DoctorContext } from '../modules/doctor/project.js'
export { planSkills } from '../modules/doctor/rules/agents.js'
+5
View File
@@ -618,6 +618,10 @@ export { assertDevelopmentHosts, DEFAULT_DEVELOPMENT_HOSTS, isDevelopmentHost, m
export { clientIp, ipRateKey, releaseRateLimit, setIpv6Grouping, setRateLimitStore, setUnknownIpFactor, UNKNOWN_IP_FACTOR } from './modules/shared/rateLimit.js'
export type { Ipv6Grouping } from './modules/shared/rateLimit.js'
export type { ClientIpOptions, RateLimitStore } from './modules/shared/rateLimit.js'
// What grows (docs/performance.md §6): MongoDB TTL indexes of the plugin's logs, the version limit of its own entities
export { isMongo, syncTtlIndex, TTL_FIELD, TTL_INDEX, ttlField } from './modules/shared/ttl.js'
export type { TtlSyncResult } from './modules/shared/ttl.js'
export { PLUGIN_VERSION_LIMIT, withVersionLimit } from './modules/shared/versionLimit.js'
export { buildSlugField, toSlug } from './modules/slug/index.js'
export { STATS_SLUG } from './modules/stats/index.js'
export type { StatsOptions, StatsPage, StatsVisit } from './modules/stats/index.js'
@@ -633,6 +637,7 @@ export type { Theme, ThemeConfig, ThemeSetting } from './modules/theme/index.js'
export { defineTokens, IAPL_BREAKPOINTS, IAPL_TOKENS, iaplVar, IPAL_BREAKPOINTS, IPAL_TOKENS, ipalVar } from './modules/tokens/index.js'
export type { IaplTokenName, IpalTokenName, TokensInput } from './modules/tokens/index.js'
export { getTurnstileConfig, TURNSTILE_SECRET_ENV, turnstileSecretFromEnv } from './modules/turnstile/config.js'
export type { TurnstileConfig } from './modules/turnstile/config.js'
export { iapl, ipalKit } from './plugin.js'
export type { IaplOptions, IpalOptions, MailOptions, ThemeOptions } from './types.js'
+1 -1
View File
@@ -1,12 +1,12 @@
import type { CollectionConfig, Endpoint, PayloadRequest } from 'payload'
import { TTL_FIELD } from '../shared/ttl.js'
import type { CollectionOverride } from '../shared/collectionOverride.js'
import { userMeetsRole } from '../access/predicates.js'
import { createDailyPurge } from '../shared/purge.js'
import { clientIp, consumeRateLimit } from '../shared/rateLimit.js'
import { readCappedBody as readCapped } from '../shared/readCappedBody.js'
import { TTL_FIELD } from '../shared/ttl.js'
import { CONSENT_CATEGORIES } from './categories.js'
import { CONSENT_CATEGORY_LABELS } from './categoryLabels.js'
import { CONSENT_VERSION } from './storage.js'
+2 -2
View File
@@ -132,7 +132,7 @@ export async function findUnusedMedia(payload: BasePayload, { limit = ORPHAN_SCA
for (const u of uploads) {
const res = await payload.find({ collection: u.slug as never, depth: 0, limit, overrideAccess: true, pagination: false, select: { filename: true } as never })
for (const d of res.docs as Array<{ filename?: null | string; id: number | string }>) {
files.set(String(d.id), { filename: d.filename ?? null, id: d.id, slug: u.slug })
files.set(String(d.id), { id: d.id, slug: u.slug, filename: d.filename ?? null })
if (d.filename) {byName.set(d.filename.toLowerCase(), String(d.id))}
}
}
@@ -179,6 +179,6 @@ export async function findUnusedMedia(payload: BasePayload, { limit = ORPHAN_SCA
}
}
const byCollection: UnusedMedia['byCollection'] = Object.fromEntries(uploads.map((u) => [u.slug, []]))
for (const [key, f] of files) {if (!seen.has(key)) {byCollection[f.slug].push({ filename: f.filename, id: f.id })}}
for (const [key, f] of files) {if (!seen.has(key)) {byCollection[f.slug].push({ id: f.id, filename: f.filename })}}
return { byCollection, checked, complete, total: files.size }
}
+2 -2
View File
@@ -24,13 +24,13 @@ export type RenderFormProps = {
/** The project's `sendForm` server action (createSubmitAction). */
action: SendFormAction
classNames?: BuilderFormClassNames
/** Rich text styling for message blocks and the confirmation (same as RenderRichText). */
converters?: JSXConvertersFunction
/**
* The client form component. Default: the lazy one (1.18.0) — its code loads only on pages with a form, the HTML
* is complete either way. `Form={BuilderForm}` from `@intecion/ipal-kit/client/eager` = in every page's bundle.
*/
Form?: ComponentType<BuilderFormProps>
/** Rich text styling for message blocks and the confirmation (same as RenderRichText). */
converters?: JSXConvertersFunction
/** The `form` relationship of the block, populated (page query depth ≥ 1). An id or null renders nothing. */
form: BuilderFormDoc | null | number | string | undefined
/**
+3 -3
View File
@@ -51,13 +51,13 @@ export async function syncTtlIndex(
return 'dropped'
}
// records from before 1.18.0 (or written by another path): the TTL counts from their own date
await coll.updateMany({ [TTL_FIELD]: { $exists: false }, [from]: { $type: 'date' } }, [{ $set: { [TTL_FIELD]: `$${from}` } }])
await coll.updateMany({ [from]: { $type: 'date' }, [TTL_FIELD]: { $exists: false } }, [{ $set: { [TTL_FIELD]: `$${from}` } }])
const seconds = Math.round(days * 86_400)
if (!existing) {
await coll.createIndex({ [TTL_FIELD]: 1 }, { expireAfterSeconds: seconds, name: TTL_INDEX })
await coll.createIndex({ [TTL_FIELD]: 1 }, { name: TTL_INDEX, expireAfterSeconds: seconds })
return 'created'
}
if (existing.expireAfterSeconds === seconds) {return 'none'}
await db.connection!.db!.command({ collMod: coll.collectionName, index: { expireAfterSeconds: seconds, name: TTL_INDEX } })
await db.connection!.db!.command({ collMod: coll.collectionName, index: { name: TTL_INDEX, expireAfterSeconds: seconds } })
return 'updated'
}
+1 -1
View File
@@ -14,6 +14,6 @@ export function withVersionLimit<T extends Versioned>(entity: T, kind: 'collecti
if (!v) {return entity}
const key = kind === 'global' ? 'max' : 'maxPerDoc'
if (v === true) {return { ...entity, versions: { [key]: limit } }}
if (typeof v === 'object' && typeof (v as Record<string, unknown>)[key] !== 'number') {return { ...entity, versions: { ...(v as object), [key]: limit } }}
if (typeof v === 'object' && typeof (v as Record<string, unknown>)[key] !== 'number') {return { ...entity, versions: { ...(v), [key]: limit } }}
return entity
}
+3 -3
View File
@@ -1,6 +1,5 @@
import type { Endpoint, PayloadRequest } from 'payload'
import { TTL_FIELD } from '../shared/ttl.js'
import type { StatsOptions, StatsPage, StatsVisit } from './collection.js'
import { gpcFromHeaders, resolveConsent } from '../consent/gpc.js'
@@ -8,6 +7,7 @@ import { CONSENT_COOKIE, CONSENT_VERSION, readConsentRecord } from '../consent/s
import { createDailyPurge } from '../shared/purge.js'
import { clientIp, consumeRateLimit } from '../shared/rateLimit.js'
import { readCappedBody } from '../shared/readCappedBody.js'
import { TTL_FIELD } from '../shared/ttl.js'
import { STATS_SLUG } from './collection.js'
import { dayOf, deviceFromUa, isBot, referrerHost, sanitizePath, VISITOR_ID_PATTERN } from './parse.js'
import { visitKey } from './visitKey.js'
@@ -120,9 +120,9 @@ export function buildStatsEndpoint({ retentionDays = 90, timeZone = 'Europe/Wars
data: {
exit: path,
lastAt: now.toISOString(),
[TTL_FIELD]: now.toISOString(), // MongoDB TTL (shared/ttl.ts)
pageCount: pages.length,
pages,
[TTL_FIELD]: now.toISOString(), // MongoDB TTL (shared/ttl.ts)
...(visitorId && !visit.visitorId ? { visitorId } : {}),
} as never,
depth: 0,
@@ -138,11 +138,11 @@ export function buildStatsEndpoint({ retentionDays = 90, timeZone = 'Europe/Wars
entry: path,
exit: path,
lastAt: now.toISOString(),
[TTL_FIELD]: now.toISOString(), // MongoDB TTL (shared/ttl.ts)
pageCount: 1,
pages: [{ p: path, t: now.toISOString() }],
referrer: referrerHost(body.r, host),
startedAt: now.toISOString(),
[TTL_FIELD]: now.toISOString(), // MongoDB TTL (shared/ttl.ts)
visitKey: key,
...(typeof body.l === 'string' && /^[a-z]{2}(?:-[A-Za-z]{2})?$/.test(body.l) ? { locale: body.l } : {}),
...(country && /^[A-Z]{2}$/.test(country) && country !== 'XX' ? { country } : {}),
+2 -2
View File
@@ -1,8 +1,8 @@
'use client'
import { TURNSTILE_HEIGHT } from './turnstileHeight.js'
import { useEffect, useRef } from 'react'
import { useTheme } from '../theme/useTheme.js'
import { TURNSTILE_HEIGHT } from './turnstileHeight.js'
declare global {
interface Window {
@@ -66,7 +66,7 @@ export type TurnstileTheme = 'auto' | 'dark' | 'light' | 'page'
* The script is injected directly (no next/script dependency) so the widget
* stays framework-agnostic.
*/
export function Turnstile({ onToken, resetSignal = 0, siteKey, theme = 'page', reserveHeight = TURNSTILE_HEIGHT }: TurnstileProps) {
export function Turnstile({ onToken, reserveHeight = TURNSTILE_HEIGHT, resetSignal = 0, siteKey, theme = 'page' }: TurnstileProps) {
const ref = useRef<HTMLDivElement>(null)
const widgetId = useRef<null | string>(null)
const pageTheme = useTheme().theme
+3 -3
View File
@@ -77,9 +77,9 @@ import { migrateTitleSeparator } from './modules/seo/titleSeparator.js'
import { applyCollectionOverride } from './modules/shared/collectionOverride.js'
import { assertDevelopmentHosts } from './modules/shared/developmentHosts.js'
import { withRetention } from './modules/shared/retention.js'
import { assertPluginSwitches } from './modules/shared/switches.js'
import { isMongo, syncTtlIndex, ttlField } from './modules/shared/ttl.js'
import { withVersionLimit } from './modules/shared/versionLimit.js'
import { assertPluginSwitches } from './modules/shared/switches.js'
import { buildStatsCollection, buildStatsEndpoint } from './modules/stats/index.js'
import { visitorCookieFor } from './modules/stats/visitorCookie.js'
@@ -884,7 +884,7 @@ export const iapl = (options: IaplOptions): Plugin => {
// MongoDB: the hidden date the TTL index counts from (shared/ttl.ts); SQL keeps its schema as it was
if (isMongo(config)) {consentCollection.fields = [...consentCollection.fields, ttlField()]}
config.collections = [...(config.collections ?? []), applyCollectionOverride(consentCollection, logOptions.collectionOverrides)]
ttlSyncs.push({ days: logOptions.retentionDays ?? 1095, enabled: logOptions.ttlIndex !== false, from: 'createdAt', slug: CONSENT_LOG_SLUG })
ttlSyncs.push({ slug: CONSENT_LOG_SLUG, days: logOptions.retentionDays ?? 1095, enabled: logOptions.ttlIndex !== false, from: 'createdAt' })
config.endpoints = [...(config.endpoints ?? []), buildConsentLogEndpoint(logOptions)]
config = withRetention(config, 'consent-records', logOptions.retentionDays ?? 1095)
}
@@ -969,7 +969,7 @@ export const iapl = (options: IaplOptions): Plugin => {
const statsCollection = buildStatsCollection()
if (isMongo(config)) {statsCollection.fields = [...statsCollection.fields, ttlField()]}
config.collections = [...(config.collections ?? []), applyCollectionOverride(statsCollection, statsOptions.collectionOverrides)]
ttlSyncs.push({ days: statsOptions.retentionDays ?? 90, enabled: statsOptions.ttlIndex !== false, from: 'lastAt', slug: 'stats-visits' })
ttlSyncs.push({ slug: 'stats-visits', days: statsOptions.retentionDays ?? 90, enabled: statsOptions.ttlIndex !== false, from: 'lastAt' })
config.endpoints = [...(config.endpoints ?? []), buildStatsEndpoint(statsOptions)]
config = withRetention(config, 'stats-visits', statsOptions.retentionDays ?? 90)
config.admin = {
+10 -10
View File
@@ -154,14 +154,6 @@ export type IaplOptions = {
* factor: whoever the dashboard is drawn for sees the full text.
*/
dashboardAlerts?: { cookies?: 'all' | 'editor'; integrations?: 'admin' | 'all' | 'editor' }
/**
* Unused media in the panel (1.18.0; docs/media.md): above the list of every upload collection (or the ones
* named), how many files no page, entry or setting uses, with a link to Payload's list filtered to them — the
* editor checks and deletes them by hand (nothing is deleted by itself). Off by default: it adds an entry to the
* admin import map (`pnpm generate:importmap`). `true` or `{ collections: ['media'] }`.
*/
unusedMedia?: boolean | { collections?: string[] }
/**
* Host patterns of the project's development, preview and staging addresses (`*` = any characters).
* Default: `DEFAULT_DEVELOPMENT_HOSTS` — `['*.dev.netscale.pl']`, Intecion's own development domain,
@@ -191,6 +183,7 @@ export type IaplOptions = {
* onInit work or admin components.
*/
enabled?: boolean
/**
* Text written in one language fills the same field in every language that is
* still empty; a language with its own text is never overwritten. Default on
@@ -200,7 +193,6 @@ export type IaplOptions = {
* Building blocks: buildFillEmptyLocalesGlobalHook / …CollectionHook.
*/
fillEmptyLocales?: { 'cookie-review'?: string[]; 'cookie-settings'?: string[] } | boolean
forms?: FormsOption
/**
@@ -283,6 +275,7 @@ export type IaplOptions = {
* over `seo.searchSettings`.
*/
searchSettings?: ((defaults: Field[]) => Field[]) | false
/**
* SEO — adds meta fields to chosen collections (via @payloadcms/plugin-seo)
* and enables locale-aware metadata helpers.
@@ -304,7 +297,6 @@ export type IaplOptions = {
* follows the new server. docs/security.md "Stored secrets".
*/
secrets?: { reenterOnChange?: false; writeOnly?: false }
seo?: SeoOption
/** Additional fields injected into SiteSettings global */
@@ -477,6 +469,14 @@ export type IaplOptions = {
}
| false
/**
* Unused media in the panel (1.18.0; docs/media.md): above the list of every upload collection (or the ones
* named), how many files no page, entry or setting uses, with a link to Payload's list filtered to them — the
* editor checks and deletes them by hand (nothing is deleted by itself). Off by default: it adds an entry to the
* admin import map (`pnpm generate:importmap`). `true` or `{ collections: ['media'] }`.
*/
unusedMedia?: { collections?: string[] } | boolean
/**
* White-label the admin panel: show the CLIENT's brand (logo + name) in the
* admin — login screen and nav — pulled from SiteSettings, set by the editor