Seeder: whole localized arrays keep every language (1.15.4)
createSeeder / writeLocales: a value written per locale as a whole —
fields: { pl: [...], en: [...], de: [...] }, a page layout, a global array —
returned the picked locale without walking into it, so each locale write made new
shared rows and only the last language survived (vanstevpl-web, 1.15.3).
- localize() localizes the picked value again with the stored rows, so row ids
are shared across locales (arrays, blocks, nested arrays in blocks, groups)
- writeLocales passes the target's fields: a field that is itself localized
(localized: true layout) never reuses another locale's row ids
- real-Payload regression test (pl, en, de): form with blocks and nested select
options, shared and localized page layouts, global array via fillGlobal; a later
PL save validates
- CHANGELOG Unreleased, seeding.md, api.md; reference skills refreshed
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4d1de4c66a
commit
00e814e3ca
@@ -8,6 +8,16 @@ 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.
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixed
|
||||
- **Seeding whole localized arrays** (`createSeeder`, `writeLocales`): a value written per language as a whole —
|
||||
`fields: { pl: [...], en: [...], de: [...] }`, a page `layout`, a global array — now keeps the stored row ids in every
|
||||
language. Before, each locale write made new shared rows and only the last language survived (form fields, nested
|
||||
select options, layouts, global arrays); an editor's later save could then fail validation. Fields that are
|
||||
themselves `localized: true` (a localized layout) keep rows per language, as before. Seed scripts need no change;
|
||||
re-run a seed that was hit (locally first, or with `SEED_ONLY` on a live site).
|
||||
|
||||
## 1.15.3
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -564,7 +564,7 @@ Server only (`pnpm payload run`); never import it from client code, the Payload
|
||||
| `summary()` | (method) | Prints and returns `{ created, skipped, updated, skippedEdited, errors }`; exit 1 when `errors`. |
|
||||
| `guardSeedExit({ label?, log?, process? })`, `activeSeedExitGuard()` | `@intecion/ipal-kit/seed` | Call first in a seed script: a run that ends before Payload initializes or before `summary()` (Node exiting through an empty event loop under `payload run`) prints `[seed] ended before …` and exits 1 instead of a silent 0. `createSeeder` / `summary()` report to it; `dispose()` stops it. |
|
||||
| `isLocalDatabase(url, { localHosts? })` | `@intecion/ipal-kit/seed` | `true` for SQLite files, Unix sockets, localhost / 127.0.0.1 / ::1 (+ `SEED_LOCAL_HOSTS`). |
|
||||
| `writeLocales(payload, target, data, { context?, draft? })` | `@intecion/ipal-kit/seed` | Writes seed values (`{ pl, en }` per field) to `{ collection, id }` or `{ global }`: default locale first, then every other locale with `fallbackLocale: false` onto the same row ids. |
|
||||
| `writeLocales(payload, target, data, { context?, draft? })` | `@intecion/ipal-kit/seed` | Writes seed values (`{ pl, en }` per field, or a whole array per locale) to `{ collection, id }` or `{ global }`: default locale first, then every other locale with `fallbackLocale: false` onto the same row ids (shared rows of non-localized arrays and blocks; a `localized: true` field keeps rows per locale). |
|
||||
| `seedHash(value)` | `@intecion/ipal-kit/seed` | Stable hash for the hidden `seedHash` field (key order, row ids, nulls ignored). |
|
||||
| `projectOnto(seed, current)` | `@intecion/ipal-kit/seed` | Current values at the keys the seed writes — hash them to compare with the stored hash. |
|
||||
| `editedSinceSeed({ doc, currentHash?, hashField?, untouchedSeconds? })` | `@intecion/ipal-kit/seed` | `null` = untouched; otherwise the reason (stored hash differs / `updatedAt` too late after `createdAt`). |
|
||||
|
||||
@@ -197,6 +197,10 @@ process.exit(seed.summary().errors ? 1 : 0)
|
||||
**Seed values.** Write each value once, every language side by side. An object whose keys are all
|
||||
locale codes is one value per locale (`{ pl: 'Kontakt', en: 'Contact' }`); anything else is the same
|
||||
in every locale. A locale missing from such an object is left untouched in that locale.
|
||||
This works at any level: a text (`label: { pl, en }`) or a whole array, layout or group (`fields: { pl: [...], en: [...] }`).
|
||||
Rows of a field that is not localized are shared by every language — the helper reuses their ids, so give each
|
||||
language the same rows in the same order (its texts differ; non-localized values such as an option's `value` come
|
||||
from the last language written). A field with `localized: true` keeps its own rows per language.
|
||||
`{ $page: 'kontakt' }` becomes the ID of the page whose default-locale slug is `kontakt`;
|
||||
`{ $form: 'Contact form' }` becomes the ID of the form with that title (seed the form first). A missing form
|
||||
is an error for that record, never an empty relation. Ready pages made of library blocks:
|
||||
|
||||
Reference in New Issue
Block a user