Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ecab39783 | ||
|
|
c407ed33fc | ||
|
|
71f7108cb8 |
@@ -8,8 +8,27 @@ versions at once, go through every "Requires project changes" section in order,
|
||||
version you have. A new release = a new section at the top; we remove the oldest ones only
|
||||
once there are more than 20.
|
||||
|
||||
## 1.14.6
|
||||
|
||||
The release of everything listed under 1.14.5. **1.14.5 was tagged but never published** (its pre-publish test run
|
||||
failed on the bug below): projects upgrade from 1.14.4 straight to 1.14.6 and follow the **1.14.5 "What projects
|
||||
must update" steps**.
|
||||
|
||||
### Fixed
|
||||
- **The admin link-preview hook no longer throws without a Payload instance.** The Site settings `afterChange` hook
|
||||
added in 1.14.5 (`adminMeta`) called `syncAdminMeta(req.payload, …)`; with no `payload` on the request (tests,
|
||||
scripts calling hooks by hand) it threw, and its own error handler threw again. `syncAdminMeta` now returns when
|
||||
there is no Payload instance and logs only through `payload?.logger`, and the hook skips it without `req.payload`.
|
||||
The `fillEmptyLocales` hooks got the same guard. In a running site `req.payload` is always set.
|
||||
|
||||
### What projects must update
|
||||
- From 1.14.4: the 1.14.5 steps below (storage-type and title-separator migrations, theme key, cookie list, admin
|
||||
link preview, dependency overrides, agent skills). Nothing more for 1.14.6.
|
||||
|
||||
## 1.14.5
|
||||
|
||||
> Tagged but never published — use 1.14.6, which contains everything below.
|
||||
|
||||
The theme choice moves to the standard `theme` key, the cookie scanner declares the plugin's own browser-storage
|
||||
key, and the cookie list tells cookies from browser storage. A pasted `/admin` link now shows the site's own name,
|
||||
description and preview image instead of Payload's, and search engines are told not to index the panel.
|
||||
|
||||
@@ -160,7 +160,7 @@ Cookies in every language; the dashboard shows the reminder while cookies wait.
|
||||
**Check:** one **Cookies** entry in the admin navigation; its tabs list the review entries and the site check;
|
||||
type a cookie purpose in one language and save → the other languages show it, and a language with its own text keeps it.
|
||||
|
||||
**→ 1.14.5 (PROGRAMISTA §6, item 54; CHANGELOG 1.14.5 "What projects must update" — do all 7, in order):**
|
||||
**→ 1.14.6 (1.14.5 was never published; PROGRAMISTA §6, item 54; CHANGELOG 1.14.5 "What projects must update" — do all 7, in order):**
|
||||
1. **Cookie storage type (Postgres/SQLite):** `pnpm payload migrate:create cookie-storage-type` → `migrate` (only adds
|
||||
`cookie_settings_cookies.storage`, default `cookie`, and `cookie_settings_locales.detail_labels_storage`). Existing
|
||||
rows become *Cookie*: set the type of local/session-storage rows by hand. MongoDB: nothing.
|
||||
|
||||
@@ -651,7 +651,7 @@ Do one item at a time, build, check. Order by importance:
|
||||
| 51 | **1.14.2** — a new admin stuck on `/admin/setup-totp?back=null` (the page keeps redirecting to itself), or an own `x-pathname` rule on `/admin` added as a workaround | `pnpm payload generate:importmap` (`TotpRedirectProvider`), commit `importMap.js`, redeploy; delete the workaround; own redirect rules → `twoFactor.provider` | security.md → "The redirect to the 2FA screens", CHANGELOG |
|
||||
| 52 | **1.14.3** — editors open every Cookie review entry one by one to accept it | with `cookieScanner`: `pnpm payload generate:importmap` (`CookieApprovalView`, `CookieCrawlAlert`), Postgres/SQLite `migrate:create` (`change`, `needs_description`); editors use Approve cookies (`/admin/cookie-approval`, linked from Privacy → Cookie review); old flow: `cookieScanner: { approval: false }` | cookie-scanner.md, CHANGELOG 1.14.3 |
|
||||
| 53 | **1.14.4** — cookie texts retyped in every language; three cookie entries in the admin navigation | `pnpm payload generate:importmap` (`CookieReviewTab`, `CookieSiteCheckTab`); empty languages fill themselves (`fillEmptyLocales: false` to keep them empty); with `cookieScanner` one **Cookies** entry with tabs (`cookieScanner: { adminLayout: 'separate' }` for the old entries); Cookie banner is now called Cookies — update editor instructions; no migration | consent.md, cookie-scanner.md, hooks.md, CHANGELOG 1.14.4 |
|
||||
| 54 | **1.14.5** — `/api/graphql` answers 500; graphql-scalars high advisory; theme stored as `ipal-theme`; hand-written `admin.meta` for the panel preview | Postgres: `migrate:create` for the title separator **plus `${sql.raw(titleSeparatorSql())}` after the first `SET DATA TYPE text;`**, and the cookie storage type; `graphql-scalars` override (Node 22 recommended); `THEME_STORAGE_KEY` instead of `'ipal-theme'`; `titleSeparatorChar()` for a raw `settings.titleSeparator`; remove hand-written panel `admin.meta`; `pnpm ipal:skills` (`--external` optional) | CHANGELOG 1.14.5, seo.md, theme.md, white-label.md, consent.md |
|
||||
| 54 | **1.14.6** (1.14.5 never published) — `/api/graphql` answers 500; graphql-scalars high advisory; theme stored as `ipal-theme`; hand-written `admin.meta` for the panel preview | Postgres: `migrate:create` for the title separator **plus `${sql.raw(titleSeparatorSql())}` after the first `SET DATA TYPE text;`**, and the cookie storage type; `graphql-scalars` override (Node 22 recommended); `THEME_STORAGE_KEY` instead of `'ipal-theme'`; `titleSeparatorChar()` for a raw `settings.titleSeparator`; remove hand-written panel `admin.meta`; `pnpm ipal:skills` (`--external` optional) | CHANGELOG 1.14.6 + 1.14.5, seo.md, theme.md, white-label.md, consent.md |
|
||||
|
||||
After updating the package: `pnpm ipal:skills` (new skill versions), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep for the new symbol in
|
||||
`node_modules/@intecion/ipal-kit/dist`.
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ valid one. Up to 1.14.4 the character itself was stored, which made `/api/graphq
|
||||
still understood. For a custom title builder, `titleSeparatorChar(settings.titleSeparator)` returns the character
|
||||
(`TITLE_SEPARATORS` is the map; any other value is used literally, so a project can add its own options with
|
||||
GraphQL-safe values). For the Postgres upgrade, the migration needs `titleSeparatorSql()`: see the CHANGELOG
|
||||
(1.14.5 → What projects must update).
|
||||
(1.14.5 → What projects must update; released as 1.14.6).
|
||||
|
||||
### Where the "Title" comes from (source priority)
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@intecion/ipal-kit",
|
||||
"version": "1.14.5",
|
||||
"version": "1.14.6",
|
||||
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
@@ -171,6 +171,8 @@ export async function syncAdminMeta(
|
||||
resolved: ResolvedAdminMeta,
|
||||
{ nameField = 'siteName', settingsSlug = 'site-settings' }: { nameField?: string; settingsSlug?: string } = {},
|
||||
): Promise<void> {
|
||||
// A hook called without a Payload instance (tests, scripts) has nothing to read or write.
|
||||
if (!payload) {return}
|
||||
try {
|
||||
const locale = payload.config.localization ? payload.config.localization.defaultLocale : undefined
|
||||
const settings = (await payload.findGlobal({ slug: settingsSlug as never, depth: 0, ...(locale ? { locale: locale as never } : {}) })) as Record<string, unknown>
|
||||
@@ -185,6 +187,6 @@ export async function syncAdminMeta(
|
||||
if (!resolved.own.description && resolved.options.description !== false && description) {meta.description = description}
|
||||
if (!resolved.own.titleSuffix && resolved.options.titleSuffix !== false && titleSuffix) {meta.titleSuffix = titleSuffix}
|
||||
} catch (error) {
|
||||
payload.logger.warn({ err: error, msg: '[ipal] admin meta: could not read Site settings; Payload defaults stay.' })
|
||||
payload?.logger?.warn({ err: error, msg: '[ipal] admin meta: could not read Site settings; Payload defaults stay.' })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ async function keepingLocale(req: PayloadRequest, fn: () => Promise<unknown>) {
|
||||
try {
|
||||
await fn()
|
||||
} catch (err) {
|
||||
req.payload.logger.error(`[ipal] filling empty locales failed: ${err instanceof Error ? err.message : String(err)}`)
|
||||
req.payload?.logger?.error(`[ipal] filling empty locales failed: ${err instanceof Error ? err.message : String(err)}`)
|
||||
} finally {
|
||||
req.locale = locale
|
||||
req.fallbackLocale = fallbackLocale
|
||||
@@ -96,6 +96,9 @@ async function keepingLocale(req: PayloadRequest, fn: () => Promise<unknown>) {
|
||||
const skip = (context: Record<string, unknown> | undefined, locale: unknown) =>
|
||||
Boolean(context?.ipalFillLocales || context?.ipalCookieScan) || typeof locale !== 'string' || locale === 'all' || locale === '*'
|
||||
|
||||
/** No Payload instance on the request (tests, scripts): nothing to read or write. */
|
||||
const noPayload = (req: PayloadRequest | undefined) => !req?.payload
|
||||
|
||||
/**
|
||||
* afterChange hook for a global: text saved in one language fills that field in
|
||||
* every language where it is empty.
|
||||
@@ -104,7 +107,7 @@ const skip = (context: Record<string, unknown> | undefined, locale: unknown) =>
|
||||
*/
|
||||
export function buildFillEmptyLocalesGlobalHook({ fields, global }: { fields: string[]; global: string }): GlobalAfterChangeHook {
|
||||
return async ({ context, doc, req }) => {
|
||||
if (skip(context, req.locale)) {return doc}
|
||||
if (noPayload(req) || skip(context, req.locale)) {return doc}
|
||||
await keepingLocale(req, () =>
|
||||
fillEmptyLocales({ fields, payload: req.payload, req, source: doc as Record<string, unknown>, sourceLocale: req.locale as string, target: { global } }),
|
||||
)
|
||||
@@ -115,7 +118,7 @@ export function buildFillEmptyLocalesGlobalHook({ fields, global }: { fields: st
|
||||
/** The same for a collection: the saved document's text fills its empty languages. */
|
||||
export function buildFillEmptyLocalesCollectionHook({ collection, fields }: { collection: string; fields: string[] }): CollectionAfterChangeHook {
|
||||
return async ({ context, doc, req }) => {
|
||||
if (skip(context, req.locale) || doc?.id == null) {return doc}
|
||||
if (noPayload(req) || skip(context, req.locale) || doc?.id == null) {return doc}
|
||||
await keepingLocale(req, () =>
|
||||
fillEmptyLocales({ fields, payload: req.payload, req, source: doc as Record<string, unknown>, sourceLocale: req.locale as string, target: { id: doc.id, collection } }),
|
||||
)
|
||||
|
||||
+1
-1
@@ -401,7 +401,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
afterChange: [
|
||||
...(g.hooks?.afterChange ?? []),
|
||||
async ({ doc, req }) => {
|
||||
await syncAdminMeta(req.payload, resolved, { nameField: brandFields.nameField, settingsSlug })
|
||||
if (req?.payload) {await syncAdminMeta(req.payload, resolved, { nameField: brandFields.nameField, settingsSlug })}
|
||||
return doc
|
||||
},
|
||||
],
|
||||
|
||||
@@ -88,6 +88,11 @@ describe('admin meta defaults', () => {
|
||||
await expect(syncAdminMeta(payload, resolved)).resolves.toBeUndefined()
|
||||
expect(warn).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('sync without a Payload instance resolves (no logger to call)', async () => {
|
||||
const { resolved } = buildAdminMeta({ agency: DEFAULT_AGENCY })
|
||||
await expect(syncAdminMeta(undefined as unknown as Payload, resolved)).resolves.toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('plugin wiring', () => {
|
||||
@@ -102,6 +107,15 @@ describe('plugin wiring', () => {
|
||||
expect(credit.serverProps).toMatchObject({ agency: 'Intecion.com', url: 'https://intecion.com', variant: 'login' })
|
||||
})
|
||||
|
||||
test('every plugin global afterChange hook resolves with req: {} (no Payload instance)', async () => {
|
||||
const config = await ipalKit({ cookieScanner: { crawl: true }, i18n, twoFactor: false, whiteLabel: true } as never)(base())
|
||||
const calls = (config.globals ?? []).flatMap((g) =>
|
||||
(g.hooks?.afterChange ?? []).map((h) => h({ context: {}, doc: {}, global: g, previousDoc: {}, req: {} } as never)),
|
||||
)
|
||||
expect(calls.length).toBeGreaterThan(0)
|
||||
await expect(Promise.all(calls)).resolves.toBeDefined()
|
||||
})
|
||||
|
||||
test('adminMeta: false and agency: false switch the pieces off', async () => {
|
||||
const config = await ipalKit({ adminMeta: false, agency: false, i18n, twoFactor: false, whiteLabel: true } as never)(base())
|
||||
expect(config.admin?.meta?.robots).toBeUndefined()
|
||||
|
||||
Reference in New Issue
Block a user