IAPL rename, scripted: preferred names in src, bin, scripts, services, tests; bin files and skill folders moved

Replaced by an explicit list of forms only (ten exported names, runtime env names, project file
names and marks, commands, skill names, the log prefix, the brand in prose). Package name, import
paths, routes, CSS tokens, data attributes, custom keys, context flags, the cookie and kv keys are
not touched. package.json keeps the five old bin names beside the five new ones.
The old names stop working in this commit and come back as aliases in the next; docs follow.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 17:24:21 +01:00
co-authored by Claude Fable 5.2
parent 414a4702df
commit 0a4f001797
262 changed files with 955 additions and 950 deletions
+42 -42
View File
@@ -4,7 +4,7 @@ import { deepMergeSimple } from 'payload/shared'
import type { AccountsOptions, Role } from './modules/access/types.js'
import type { ResolvedAdminMeta } from './modules/branding/adminMeta.js'
import type { IpalOptions, TotpPluginFactory } from './types.js'
import type { IaplOptions, TotpPluginFactory } from './types.js'
import { buildCookieSettings } from './globals/CookieSettings/index.js'
import { migrateCookieSettingsSaveButton } from './globals/CookieSettings/migrateSaveButton.js'
@@ -62,21 +62,21 @@ import { migrateTitleSeparator } from './modules/seo/titleSeparator.js'
import { applyCollectionOverride } from './modules/shared/collectionOverride.js'
import { buildStatsCollection, buildStatsEndpoint } from './modules/stats/index.js'
/** The admin provider @clocklimited/payload-2fa registers; ipal-kit swaps it (twoFactor.provider). */
/** The admin provider @clocklimited/payload-2fa registers; IAPL swaps it (twoFactor.provider). */
const TOTP_PACKAGE_PROVIDER = '@clocklimited/payload-2fa/rsc#TOTPProvider'
/** ipal-kit's own redirect provider (twoFactor.provider default). */
/** IAPL's own redirect provider (twoFactor.provider default). */
const TOTP_REDIRECT_PROVIDER = '@intecion/ipal-kit/admin#TotpRedirectProvider'
/**
* IPAL (Intecion Payload Advanced Library) plugin for Payload CMS 3.
* IAPL (Intecion Advanced Payload Library) plugin for Payload CMS 3.
*
* @example
* ```ts
* import { ipalKit } from 'ipal-kit'
* import { iapl } from 'IAPL'
*
* export default buildConfig({
* plugins: [
* ipalKit({
* iapl({
* i18n: {
* locales: [
* { code: 'pl', label: 'Polski' },
@@ -90,7 +90,7 @@ const TOTP_REDIRECT_PROVIDER = '@intecion/ipal-kit/admin#TotpRedirectProvider'
* })
* ```
*/
export const ipalKit = (options: IpalOptions): Plugin => {
export const iapl = (options: IaplOptions): Plugin => {
// Validate eagerly — fail fast before Payload boots
validateI18nConfig(options.i18n)
@@ -159,7 +159,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
: {}),
admin: { useAsTitle: 'email' },
auth: true,
// these rules are the plugin's, written for this slug (marked as such when ipalKit finishes) — not the ones
// these rules are the plugin's, written for this slug (marked as such when iapl finishes) — not the ones
// the project passed in access.authAccess
...(hasRoles
? { custom: { ipalAccountRules: { slug: authSlug, applied: ['create', 'delete', 'read', 'unlock', 'update'].filter((k) => !(k in (options.access?.authAccess ?? {}))), ownRoles: false } } }
@@ -178,11 +178,11 @@ export const ipalKit = (options: IpalOptions): Plugin => {
// --- enforced 2FA (TOTP) via @clocklimited/payload-2fa ---
// Enforced by default (forceSetup) unless twoFactor is explicitly false. The
// package is an optional PEER the project injects — ipal-kit doesn't bundle
// package is an optional PEER the project injects — IAPL doesn't bundle
// or import it, so projects that opt out (twoFactor: false) needn't install it.
// Wrapping access control (not just admin UI) means TOTP gates data access —
// no API bypass.
// ipal-kit's own second-factor check (secondFactor.ts) covers what the 2FA
// IAPL's own second-factor check (secondFactor.ts) covers what the 2FA
// package cannot: everything added to the config after the package ran.
let secondFactorGuard = false
/** The 2FA collection, when 2FA is on. */
@@ -193,12 +193,12 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const staffToken = {}
/**
* A config has gone live on this instance (start, or a dev hot reload): guard what plugins
* listed after ipalKit added, and file its staff collections under the instance.
* listed after iapl added, and file its staff collections under the instance.
*/
const adoptConfig = (payload: BasePayload) => {
const token = (payload.config.custom as { ipal?: { staffToken?: object } } | undefined)?.ipal?.staffToken
registerStaffCollections(payload, staffCollectionSlugs(payload), token)
// Auth collections a plugin listed after ipalKit added: the account rules for them too — BEFORE the
// Auth collections a plugin listed after iapl added: the account rules for them too — BEFORE the
// 2FA guard below wraps their access (it needs the rule inside its wrapper).
if (accounts) {
const rule = resolvePasswordRule(accounts.password)
@@ -213,12 +213,12 @@ export const ipalKit = (options: IpalOptions): Plugin => {
for (const late of lateAccounts) {
const parts = [late.applied.length ? `access rules for ${late.applied.join(', ')}` : '', late.password ? 'the password rule' : '', late.firstUser ? 'the first-user endpoint' : ''].filter(Boolean)
const kept = late.kept.length ? ` Its own rules for ${late.kept.join(', ')} are kept as written.` : ''
payload.logger.info(`[ipal] "${late.slug}" ${late.known ? 'became a staff collection after ipalKit ran' : 'was added after ipalKit'}: put on it — ${parts.join('; ')}.${kept}`)
payload.logger.info(`[iapl] "${late.slug}" ${late.known ? 'became a staff collection after iapl ran' : 'was added after iapl'}: put on it — ${parts.join('; ')}.${kept}`)
}
}
if (!secondFactorGuard) {return}
const late = ensurePayloadGuarded(payload)
if (late?.length) {payload.logger.info(`[ipal] 2FA also enforced on entities added after ipalKit: ${late.join(', ')}.`)}
if (late?.length) {payload.logger.info(`[iapl] 2FA also enforced on entities added after iapl: ${late.join(', ')}.`)}
}
/** 2FA collection when "setup required" is on — its existing accounts get their setup window in onInit. */
let setupRequiredFor: null | string = null
@@ -246,7 +246,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const tf = options.twoFactor
if (!tf?.issuer) {
throw new Error(
'[ipal] twoFactor.issuer is required (name shown in the authenticator ' +
'[iapl] twoFactor.issuer is required (name shown in the authenticator ' +
'app). Pass twoFactor: { issuer: "Your Site" }, or twoFactor: false to ' +
'opt out (discouraged).',
)
@@ -258,7 +258,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
if (typeof totp !== 'function') {
throw new Error(
'[ipal] 2FA is enforced but no 2FA plugin was injected. Add ' +
'[iapl] 2FA is enforced but no 2FA plugin was injected. Add ' +
'`import { payloadTotp } from "@clocklimited/payload-2fa"` and pass ' +
'`twoFactor: { issuer, plugin: payloadTotp }`. Or set twoFactor: false ' +
'to opt out (discouraged).',
@@ -276,13 +276,13 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const target = tf.collectionSlug ?? adminSlug
if (!authSlugs.includes(target)) {
throw new Error(
`[ipal] twoFactor: "${target}" is not an auth collection, so 2FA would protect nothing. ` +
`[iapl] twoFactor: "${target}" is not an auth collection, so 2FA would protect nothing. ` +
`Auth collections: ${authSlugs.join(', ') || 'none'}. Fix twoFactor.collectionSlug.`,
)
}
if (target !== adminSlug && !tf.allowCollectionMismatch) {
throw new Error(
`[ipal] twoFactor wraps "${target}" but the admin panel logs in with "${adminSlug}" ` +
`[iapl] twoFactor wraps "${target}" but the admin panel logs in with "${adminSlug}" ` +
'(admin.user) — those accounts would skip 2FA. Point twoFactor.collectionSlug at ' +
`"${adminSlug}", or pass twoFactor.allowCollectionMismatch: true if that is deliberate.`,
)
@@ -297,7 +297,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const entityEndpointsBefore = new Map<string, Set<unknown>>(
[...(config.collections ?? []), ...(config.globals ?? [])].map((e) => [e.slug, new Set<unknown>(Array.isArray(e.endpoints) ? e.endpoints : [])]),
)
// custom.ipal.secondFactor (ipal-kit's per-entity opt-out) → the package's own key
// custom.ipal.secondFactor (IAPL's per-entity opt-out) → the package's own key
config = passOptOutsToPackage(config)
config = await totp({
collection: target,
@@ -335,13 +335,13 @@ export const ipalKit = (options: IpalOptions): Plugin => {
// field joins it below, when the mode is on. Validates requireSetup at start either way.
if (tf.requireSetup !== false) {resolveRequireSetup(tf.requireSetup)}
// The views the 2FA package registered, by object: it REPLACES a view the project (or an
// earlier run of the package, or of ipalKit) already had under its keys, so a key that
// earlier run of the package, or of iapl) already had under its keys, so a key that
// existed before is no sign that the view is the project's own. Taken here, before the
// texts step below re-creates those objects.
const viewsFromPackage = changedViewKeys(viewsBefore, { ...config.admin?.components?.views })
// The package wraps only what is in the config right now. ipal-kit's own
// globals and collections come later, so they get ipal-kit's guard at the
// The package wraps only what is in the config right now. IAPL's own
// globals and collections come later, so they get IAPL's guard at the
// end of this function (and other plugins' in onInit). The guard reads the
// package's `totp` strategy and `hasTotp` field: when those are not there,
// this is a version it was not written for — refuse to start rather than
@@ -350,8 +350,8 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const missing = missingTotpParts(config, target)
if (missing.length) {
throw new Error(
`[ipal] twoFactor: the injected 2FA plugin did not add ${missing.join(', ')} to "${target}". ` +
'ipal-kit enforces the second factor on its own globals and collections through them, so it ' +
`[iapl] twoFactor: the injected 2FA plugin did not add ${missing.join(', ')} to "${target}". ` +
'IAPL enforces the second factor on its own globals and collections through them, so it ' +
'cannot do that with this version of @clocklimited/payload-2fa. Use a supported version, or pass ' +
'twoFactor.guard: false to rely on the package alone (docs/security.md — not recommended).',
)
@@ -388,7 +388,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
// An admin resets an account's TOTP (lost phone) / reopens its setup window.
config.endpoints = [...(config.endpoints ?? []), buildTwoFactorResetEndpoint(target, { access: tf.resetAccess })]
// Called by Payload on every request before any access function: guards whatever
// the live config has that was added after ipalKit (start, dev hot reload).
// the live config has that was added after iapl (start, dev hot reload).
const sweep = buildGuardStrategy(adoptConfig)
config.collections = (config.collections ?? []).map((c) =>
c.slug === target && typeof c.auth === 'object'
@@ -402,7 +402,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
c.slug === target ? { ...c, fields: [...c.fields, ...buildSetupFields({ statusField })] } : c,
)
// The package's texts are long and informal: ipal-kit's (admin-ux.md) go over
// The package's texts are long and informal: IAPL's (admin-ux.md) go over
// them, the project's own i18n.translations over both. The 2FA screens get a
// tab title instead of "Payload" (view meta is a plain string: the site's language).
if (tf.texts !== false) {
@@ -432,7 +432,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
// The package's TOTPProvider reads the path from an `x-pathname` header
// no proxy sets on /admin, so it redirected the setup screen to itself
// (`setup-totp?back=null`). Swap in ipal-kit's client-side provider, or
// (`setup-totp?back=null`). Swap in IAPL's client-side provider, or
// the project's (`provider`); `provider: false` keeps the package's.
if (tf.provider !== false) {
const custom = tf.provider
@@ -458,7 +458,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
// The package's setup and verify screens send the browser to the `back` query
// value after a valid code, unchecked: a crafted link runs script in the panel
// or leaves the site (safeBack.ts). ipal-kit's view goes in front of them and
// or leaves the site (safeBack.ts). IAPL's view goes in front of them and
// hands the package's view a checked value. `safeBack: false` leaves them as
// the package registered them; a function replaces the rule.
if (tf.safeBack !== false) {
@@ -489,7 +489,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
components: {
...config.admin?.components,
providers: providers.map((p) =>
p && typeof p === 'object' && p.path === TOTP_REDIRECT_PROVIDER // ipal-kit's own provider only
p && typeof p === 'object' && p.path === TOTP_REDIRECT_PROVIDER // IAPL's own provider only
? { ...p, clientProps: { ...p.clientProps, staleImportMap: true } }
: p,
),
@@ -614,7 +614,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
if (panelRole && options.access.firstUserAdmin === false && ROLE_HIERARCHY.indexOf(firstRole) < ROLE_HIERARCHY.indexOf(panelRole)) {
if (accounts?.panelRole !== undefined) {
throw new Error(
`[ipal] access.firstUserAdmin: false with accounts.panelRole: '${panelRole}' leaves a fresh site with nobody who can open the panel: ` +
`[iapl] access.firstUserAdmin: false with accounts.panelRole: '${panelRole}' leaves a fresh site with nobody who can open the panel: ` +
`the first account gets the role '${firstRole}', which is below the panel role. Set access.defaultRole to '${panelRole}' or higher, ` +
"or accounts: { panelRole: false }, or drop access.firstUserAdmin: false (docs/access.md \"Account rules\").",
)
@@ -648,7 +648,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
// --- seo: apply @payloadcms/plugin-seo directly ---
// NOTE: apply the plugin function to the config immediately rather than
// pushing it onto config.plugins. Payload has already iterated the plugins
// array by the time IPAL runs, so nested plugins added to that list are
// array by the time IAPL runs, so nested plugins added to that list are
// never executed. Calling the plugin as (config) => config applies its
// transform now.
if (options.seo) {
@@ -742,7 +742,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
config.endpoints = [...(config.endpoints ?? []), testEmailEndpoint]
// --- ipal-doctor status (404 until IPAL_DOCTOR_TOKEN is set; docs/doctor.md) ---
// --- iapl-doctor status (404 until IAPL_DOCTOR_TOKEN is set; docs/doctor.md) ---
if (options.doctor !== false) {
config.endpoints = [...(config.endpoints ?? []), buildDoctorEndpoint(options.doctor ?? {})]
}
@@ -911,7 +911,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const unknownStaff = unknownStaffCollections(payload.config as never, [...new Set([options.access?.authCollection, ...(options.access?.staffCollections ?? [])].filter((s): s is string => Boolean(s)))])
if (unknownStaff.length) {
throw new Error(
`[ipal] access names ${unknownStaff.map((s) => `"${s}"`).join(', ')} as a staff collection, but this config has no auth collection with that slug ` +
`[iapl] access names ${unknownStaff.map((s) => `"${s}"`).join(', ')} as a staff collection, but this config has no auth collection with that slug ` +
`(auth collections: ${payload.config.collections.filter((c) => c.auth).map((c) => c.slug).join(', ') || 'none'}). ` +
'Fix the slug in access.authCollection / access.staffCollections, or add the collection (docs/access.md "Who is staff").',
)
@@ -921,7 +921,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
watchPayloadConfig(payload, adoptConfig)
if (staleImportMap) {
payload.logger.error(
`[ipal] The admin import map may be out of date: ${staleImportMap}. If the 2FA setup and verify screens are ` +
`[iapl] The admin import map may be out of date: ${staleImportMap}. If the 2FA setup and verify screens are ` +
'EMPTY (no code form), nobody can sign in to the panel: run `pnpm payload generate:importmap`, commit ' +
'importMap.js, rebuild and redeploy. If the screens work, the file on disk is not the map the build used — ' +
'set twoFactor.importMapCheck: false (docs/security.md "A stale import map").',
@@ -932,14 +932,14 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const uncovered = staffCollectionSlugs(payload).filter((slug) => slug !== twoFactorCollection)
if (uncovered.length) {
payload.logger.warn(
`[ipal] 2FA covers "${twoFactorCollection}" only. Staff accounts of ${uncovered.map((s) => `"${s}"`).join(', ')} ` +
`[iapl] 2FA covers "${twoFactorCollection}" only. Staff accounts of ${uncovered.map((s) => `"${s}"`).join(', ')} ` +
'pass the staff checks with a password alone (docs/access.md "Who is staff").',
)
}
}
if (panelRoleSkipped) {
payload.logger.warn(
`[ipal] The panel role (accounts.panelRole, 'editor' by default) is NOT applied: ${panelRoleSkipped}, so nobody could open the panel on a fresh site. ` +
`[iapl] The panel role (accounts.panelRole, 'editor' by default) is NOT applied: ${panelRoleSkipped}, so nobody could open the panel on a fresh site. ` +
'Every account of the login collection can open the panel. To keep the lowest role out, set access.defaultRole to \'editor\' or drop access.firstUserAdmin: false (docs/access.md "Account rules").',
)
}
@@ -948,13 +948,13 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const { stuck, unchecked } = await staffCollectionsNobodyManages(payload as never, staffCollectionSlugs(payload), options.access?.authCollection)
if (stuck.length) {
payload.logger.warn(
`[ipal] No staff account holds the role "admin", so NOBODY can create, delete or unlock accounts in ${stuck.map((s) => `"${s}"`).join(', ')} ` +
`[iapl] No staff account holds the role "admin", so NOBODY can create, delete or unlock accounts in ${stuck.map((s) => `"${s}"`).join(', ')} ` +
"(only an admin does there: the collection's roles can hold \"editor\" or \"admin\"). Give one account the role with a script " +
'(payload.update, Local API), or write the collection\'s own access.create / update / delete rules (docs/access.md "Account rules").',
)
} else if (unchecked.length) {
payload.logger.warn(
`[ipal] Could not check whether an account of ${unchecked.map((s) => `"${s}"`).join(', ')} holds the role "admin" (no other staff account does). ` +
`[iapl] Could not check whether an account of ${unchecked.map((s) => `"${s}"`).join(', ')} holds the role "admin" (no other staff account does). ` +
'If none does, nobody can create, delete or unlock accounts in the staff collections that are managed by admins only (docs/access.md "Account rules").',
)
}
@@ -965,12 +965,12 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const { all, below } = await countBelowPanelRole(payload, panelRoleFor.slug, panelRoleFor.role)
if (all && below === all) {
payload.logger.error(
`[ipal] No account of "${panelRoleFor.slug}" has the role "${panelRoleFor.role}" or higher, so NOBODY can open the admin panel ` +
`[iapl] No account of "${panelRoleFor.slug}" has the role "${panelRoleFor.role}" or higher, so NOBODY can open the admin panel ` +
'(accounts.panelRole). Give an account the role with a script (payload.update, Local API), or set accounts: { panelRole: false } and redeploy (docs/access.md "Account rules").',
)
} else if (below) {
payload.logger.warn(
`[ipal] ${below} account(s) of "${panelRoleFor.slug}" are below the role "${panelRoleFor.role}" and cannot open the admin panel ` +
`[iapl] ${below} account(s) of "${panelRoleFor.slug}" are below the role "${panelRoleFor.role}" and cannot open the admin panel ` +
'(accounts.panelRole). Give them a higher role, or set accounts: { panelRole: \'user\' } (docs/access.md "Account rules").',
)
}
@@ -983,7 +983,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const started = await backfillSetupFrom(payload, setupRequiredFor)
if (started) {
payload.logger.warn(
`[ipal] 2FA: ${started} existing account(s) without two-step verification. ` +
`[iapl] 2FA: ${started} existing account(s) without two-step verification. ` +
(setupWindowHours ? `They have ${setupWindowHours} h from now to set it up; after that an administrator must reopen setup.` : 'They cannot use the panel until they set it up.'),
)
}
@@ -991,7 +991,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
await migrateCookieSettingsSaveButton(payload)
await migrateTitleSeparator(payload, settingsSlug)
if (adminMeta) {await syncAdminMeta(payload, adminMeta, { nameField: brandFields.nameField, settingsSlug })}
payload.logger.info('[ipal] Plugin initialized.')
payload.logger.info('[iapl] Plugin initialized.')
}
// Every auth collection of this config has been seen: what appears later is a late one (adoptConfig).