Skip to content

refactor: stop filtering deprecated content in the deserializer - #201

Merged
tvdeyen merged 1 commit into
mainfrom
remove-essences
Aug 21, 2026
Merged

refactor: stop filtering deprecated content in the deserializer#201
tvdeyen merged 1 commit into
mainfrom
remove-essences

Conversation

@tvdeyen

@tvdeyen tvdeyen commented Aug 20, 2026

Copy link
Copy Markdown
Member

deserializePage/deserializePages stripped elements whose deprecated flag was set. But deprecated is an admin-only hint — it marks element/ingredient definitions that were removed from config so the CMS can warn editors. It should never remove content from a serialized page delivered to a frontend; doing so is destructive and opinionated.

It also turns out the filtering was already incomplete: filterDeprecatedElements handled elements and the pre-6.0 essences, but never the ingredients that replaced essences in Alchemy 6.0 — even though ingredients carry the same deprecated flag. So ingredient deprecation has been silently unfiltered in production for years with no ill effect, which is good evidence the filtering isn't needed.

This removes filterDeprecatedElements entirely. deserializePage/deserializePages remain as thin, API-compatible wrappers around deserialize and no longer mutate the output; the specs now assert that deprecated elements and nested elements are preserved.

Stacked on #200 (merged); base is main.

Base automatically changed from fix-deserializer-rangeerror to main August 20, 2026 17:49
@tvdeyen
tvdeyen force-pushed the remove-essences branch 2 times, most recently from a58159b to 47aa5be Compare August 20, 2026 18:03
@tvdeyen tvdeyen changed the title refactor: drop deprecated-essence handling from the element deserializer refactor: stop filtering deprecated content in the deserializer Aug 20, 2026
@tvdeyen

tvdeyen commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

superseds #107

Deprecation on elements and ingredients is an admin-only hint; the
deserializer must not drop that content from a serialized page. The old
filterDeprecatedElements also only ever handled elements and the pre-6.0
"essences" — never the ingredients that replaced them — so it had
silently done nothing for ingredient deprecation for years anyway.

Remove the filtering entirely. deserializePage/deserializePages stay as
thin, API-compatible wrappers around deserialize and no longer mutate the
output; both are marked @deprecated and warn once (console.warn) in
favour of calling deserialize directly.
@tvdeyen
tvdeyen merged commit 40b9145 into main Aug 21, 2026
15 checks passed
@tvdeyen
tvdeyen deleted the remove-essences branch August 21, 2026 06:17
tvdeyen added a commit that referenced this pull request Aug 31, 2026
…ion (#202)

Migrates the deserializer to TypeScript and ships type declarations so
consumers get types and editor support (including the `@deprecated`
hints on `deserializePage`/`deserializePages` added in #201).

**Source** — `deserialize`, `alchemyApiDeserializer` and the barrel
become `.ts`. Behaviour is unchanged; the existing specs (migrated to
`.ts`) still pass, and the folded numeric-id/absent-to-many case keeps
the coverage the old `deserialize.spec.js` had.

**Distribution pipeline** — `build` now runs `vite build` for the JS
bundles plus `tsc --emitDeclarationOnly` for the `.d.ts`. A
`tsconfig.json` (strict, `lib: ["ES2022","DOM"]` for `structuredClone`)
drives declaration emit and a new `typecheck` script. `package.json`
gains a `types` field and an `exports` map exposing types for both the
root entry and the `./deserialize` subpath.

**Public type surface** — the JSON:API document shapes are kept
**internal** (not exported). `deserialize` is `<T = unknown>(document:
unknown): T`, so those shapes aren't part of the contract; exporting
them would only add generically-named types (`JsonApiResource`,
`JsonApiDocument`, …) that could collide with a consumer's own
definitions. The emitted `deserialize.d.ts` therefore exposes only
`deserialize`.

Based on `main` (after #200 and #201).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant