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:
co-authored by
Claude Opus 5.5
parent
d628839235
commit
f0127ac1b8
@@ -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'
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -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
|
||||
/**
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 } : {}),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user