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:
co-authored by
Claude Fable 5.2
parent
414a4702df
commit
0a4f001797
+21
-21
@@ -4,7 +4,7 @@ import { describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import type { I18nConfig } from '../src/modules/i18n/types.js'
|
||||
|
||||
import { ipalKit } from '../src/plugin.js'
|
||||
import { iapl } from '../src/plugin.js'
|
||||
import { withTotpParts } from './helpers.js'
|
||||
|
||||
const i18n: I18nConfig = {
|
||||
@@ -21,9 +21,9 @@ const base = (): Config =>
|
||||
secret: 'test',
|
||||
}) as unknown as Config
|
||||
|
||||
describe('ipalKit — config transform', () => {
|
||||
describe('iapl — config transform', () => {
|
||||
test('adds globals, endpoint, localization and roles', async () => {
|
||||
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: false })(base())
|
||||
const config = await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: false })(base())
|
||||
|
||||
expect(config.globals?.map((g) => g.slug)).toEqual(
|
||||
expect.arrayContaining(['site-settings', 'site-integrations']),
|
||||
@@ -36,18 +36,18 @@ describe('ipalKit — config transform', () => {
|
||||
})
|
||||
|
||||
test('enforces 2FA unless explicitly disabled', async () => {
|
||||
await expect(ipalKit({ i18n } as never)(base())).rejects.toThrow(/twoFactor\.issuer is required/)
|
||||
await expect(ipalKit({ i18n, twoFactor: { issuer: 'Acme' } } as never)(base())).rejects.toThrow(
|
||||
await expect(iapl({ i18n } as never)(base())).rejects.toThrow(/twoFactor\.issuer is required/)
|
||||
await expect(iapl({ i18n, twoFactor: { issuer: 'Acme' } } as never)(base())).rejects.toThrow(
|
||||
/no 2FA plugin was injected/,
|
||||
)
|
||||
|
||||
const totp = vi.fn((o: { collection: string }) => (c: Config) => withTotpParts(c, o.collection))
|
||||
await ipalKit({ i18n, twoFactor: { issuer: 'Acme', plugin: totp as never } })(base())
|
||||
await iapl({ i18n, twoFactor: { issuer: 'Acme', plugin: totp as never } })(base())
|
||||
expect(totp).toHaveBeenCalledWith(expect.objectContaining({ forceSetup: true, totp: { issuer: 'Acme' } }))
|
||||
})
|
||||
|
||||
test('enabled: false keeps the schema (collections, globals) but adds no endpoints, onInit or admin components', async () => {
|
||||
const config = await ipalKit({ access: { authCollection: 'users' }, consentLog: true, enabled: false, i18n, stats: true, twoFactor: false })(base())
|
||||
const config = await iapl({ access: { authCollection: 'users' }, consentLog: true, enabled: false, i18n, stats: true, twoFactor: false })(base())
|
||||
expect(config.globals?.map((g) => g.slug)).toEqual(expect.arrayContaining(['site-settings', 'site-integrations', 'cookie-settings', 'notifications']))
|
||||
expect(config.collections?.map((c) => c.slug)).toEqual(expect.arrayContaining(['users', 'consent-records', 'stats-visits']))
|
||||
expect(config.endpoints ?? []).toEqual([])
|
||||
@@ -56,18 +56,18 @@ describe('ipalKit — config transform', () => {
|
||||
})
|
||||
|
||||
test('forms.consentFieldName reaches submitForm through config.custom.ipal', async () => {
|
||||
const config = await ipalKit({ forms: { consentFieldName: 'zgoda' }, i18n, twoFactor: false })(base())
|
||||
const config = await iapl({ forms: { consentFieldName: 'zgoda' }, i18n, twoFactor: false })(base())
|
||||
expect((config.custom as { ipal?: { consentFieldName?: string } }).ipal?.consentFieldName).toBe('zgoda')
|
||||
})
|
||||
|
||||
test('invalid i18n fails fast', () => {
|
||||
expect(() => ipalKit({ i18n: { defaultLocale: 'de', locales: i18n.locales }, twoFactor: false })).toThrow()
|
||||
expect(() => iapl({ i18n: { defaultLocale: 'de', locales: i18n.locales }, twoFactor: false })).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ipalKit — auth collection', () => {
|
||||
describe('iapl — auth collection', () => {
|
||||
test('injects a users auth collection when the project has none, with roles', async () => {
|
||||
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: false })({
|
||||
const config = await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: false })({
|
||||
collections: [],
|
||||
secret: 'x',
|
||||
} as unknown as Config)
|
||||
@@ -78,7 +78,7 @@ describe('ipalKit — auth collection', () => {
|
||||
|
||||
test("keeps the project's own users collection", async () => {
|
||||
const own = { slug: 'users', auth: true, fields: [{ name: 'fullName', type: 'text' }] }
|
||||
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: false })({
|
||||
const config = await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: false })({
|
||||
collections: [own],
|
||||
secret: 'x',
|
||||
} as unknown as Config)
|
||||
@@ -108,17 +108,17 @@ describe('options that keep features reachable and overridable', () => {
|
||||
}) as unknown as Config
|
||||
|
||||
test('seo.uploadsCollection: the meta image relates to the given upload collection (default media)', async () => {
|
||||
const custom = await ipalKit({ i18n, seo: { collections: ['pages'], uploadsCollection: 'images' }, twoFactor: false })(withPages())
|
||||
const custom = await iapl({ i18n, seo: { collections: ['pages'], uploadsCollection: 'images' }, twoFactor: false })(withPages())
|
||||
const meta = findField(custom.collections!.find((c) => c.slug === 'pages')!.fields, 'meta')!
|
||||
expect(findField(meta.fields as unknown[], 'image')?.relationTo).toBe('images')
|
||||
|
||||
const plain = await ipalKit({ i18n, seo: { collections: ['pages'] }, twoFactor: false })(withPages())
|
||||
const plain = await iapl({ i18n, seo: { collections: ['pages'] }, twoFactor: false })(withPages())
|
||||
const metaDefault = findField(plain.collections!.find((c) => c.slug === 'pages')!.fields, 'meta')!
|
||||
expect(findField(metaDefault.fields as unknown[], 'image')?.relationTo).toBe('media')
|
||||
})
|
||||
|
||||
test('without `access` (no roles field) admin and editor features stay reachable for logged-in users', async () => {
|
||||
const config = await ipalKit({ consentLog: true, forms: {}, i18n, stats: true, twoFactor: false })(base())
|
||||
const config = await iapl({ consentLog: true, forms: {}, i18n, stats: true, twoFactor: false })(base())
|
||||
const users = config.collections!.find((c) => c.slug === 'users')!
|
||||
// `admin.user` is what Payload's sanitize fills in: the panel's login collection = the staff collection.
|
||||
const req = (user: unknown) => ({ payload: { collections: { users: { config: users } }, config: { admin: { user: 'users' } } }, user }) as never
|
||||
@@ -135,7 +135,7 @@ describe('options that keep features reachable and overridable', () => {
|
||||
})
|
||||
|
||||
test('with `access` the roles still decide', async () => {
|
||||
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, stats: true, twoFactor: false })(base())
|
||||
const config = await iapl({ access: { authCollection: 'users' }, i18n, stats: true, twoFactor: false })(base())
|
||||
const users = config.collections!.find((c) => c.slug === 'users')!
|
||||
const req = (user: unknown) => ({ payload: { collections: { users: { config: users } }, config: { admin: { user: 'users' } } }, user }) as never
|
||||
const read = config.globals!.find((g) => g.slug === 'site-integrations')!.access!.read as (a: { req: unknown }) => unknown
|
||||
@@ -154,12 +154,12 @@ describe('gap fixes: searchSettings, collection overrides', () => {
|
||||
}
|
||||
|
||||
test('searchSettings: false removes the Search engines tab without `seo`', async () => {
|
||||
expect(tabsOf(await ipalKit({ i18n, twoFactor: false })(base()))).toContain('Search engines')
|
||||
expect(tabsOf(await ipalKit({ i18n, searchSettings: false, twoFactor: false })(base()))).not.toContain('Search engines')
|
||||
expect(tabsOf(await iapl({ i18n, twoFactor: false })(base()))).toContain('Search engines')
|
||||
expect(tabsOf(await iapl({ i18n, searchSettings: false, twoFactor: false })(base()))).not.toContain('Search engines')
|
||||
})
|
||||
|
||||
test('searchSettings: a function shapes the fields; the top-level option wins over seo.searchSettings', async () => {
|
||||
const config = await ipalKit({
|
||||
const config = await iapl({
|
||||
i18n,
|
||||
searchSettings: (fields) => fields.filter((f) => 'name' in f && f.name === 'llmsIntro'),
|
||||
seo: { collections: [], searchSettings: false },
|
||||
@@ -171,12 +171,12 @@ describe('gap fixes: searchSettings, collection overrides', () => {
|
||||
)!
|
||||
expect(tab.fields.map((f) => f.name)).toEqual(['llmsIntro'])
|
||||
// the older seo.searchSettings still works alone
|
||||
expect(tabsOf(await ipalKit({ i18n, seo: { collections: [], searchSettings: false }, twoFactor: false })(base()))).not.toContain('Search engines')
|
||||
expect(tabsOf(await iapl({ i18n, seo: { collections: [], searchSettings: false }, twoFactor: false })(base()))).not.toContain('Search engines')
|
||||
})
|
||||
|
||||
test('consentLog / stats collectionOverrides: an object merges access, a function takes over', async () => {
|
||||
const dpoOnly = ({ req }: { req: { user?: { email?: string } } }) => req.user?.email === '[email protected]'
|
||||
const config = await ipalKit({
|
||||
const config = await iapl({
|
||||
consentLog: { collectionOverrides: { access: { read: dpoOnly as never }, admin: { group: 'Privacy' } } },
|
||||
i18n,
|
||||
stats: { collectionOverrides: (c) => ({ ...c, labels: { plural: 'Visits', singular: 'Visit' } }) },
|
||||
|
||||
Reference in New Issue
Block a user