Skip to content

fix: preserve v1 Video Player settings via typeVersion 2 bump#11

Open
eitanp461 wants to merge 1 commit into
masterfrom
fix/video-player-typeversion-2
Open

fix: preserve v1 Video Player settings via typeVersion 2 bump#11
eitanp461 wants to merge 1 commit into
masterfrom
fix/video-player-typeversion-2

Conversation

@eitanp461

Copy link
Copy Markdown
Contributor

Summary

n8n Cloud verification flagged a [HIGH] breaking change: the 0.1.2 → 0.2.0 update renamed the Video Player parameters without a typeVersion bump, silently dropping saved settings on upgrade.

PR #10 (0.2.0) regrouped the Video Player's flat params (playerAutoplayMode, playerSkin, playerAdvancedOptions, …) into five collection fields (playerPlayback, playerLayout, playerAppearance, playerFeatures, playerAiOptions). A parameter name rename is frozen-by-string (see docs/backwards-compat.md) — every workflow that references the old name is orphaned.

The catch: those flat params had already shipped to public npm in 0.1.0–0.1.2 (live for two days before 0.2.0). So any workflow saved against 0.1.x with Video Player settings lost them on upgrade. The backward-compat check passed only because it was baselined against 0.0.9, which predates the Video Player entirely.

This PR applies Option 1 (the standard n8n pattern the reviewer recommended): keep the v1 schema intact behind a typeVersion bump instead of mutating it.

Changes

  • Cloudinary.node.tsversion: 1version: [1, 2] + defaultVersion: 2. Both schemas ship side by side; new nodes default to v2.
  • descriptions/widget.fields.ts — restore the v1 flat fields gated on displayOptions.show['@version']: [1]; gate the v2 collections on [{ _cnd: { gte: 2 } }] (gte so a future v3 inheriting the v2 schema keeps showing them without re-gating). The three unchanged essentials (playerTransformation, playerPoster, playerSourceTypes) keep the same name across versions, so they're declared once and shown for both.
  • operations/widget/videoPlayer.ts — dispatch on getNode().typeVersion to readPlayerParamsV1 (flat) or readPlayerParamsV2 (collections) into one shared PlayerParams; the URL/config builders are untouched. v1 yields ai: {}, so its output matches 0.1.x exactly (no AI keys, which v1 didn't have).
  • operations/testHelpers.tsmakeCtx accepts typeVersion (default 2), exposed via getNode().
  • operations/widget/widget.test.ts — explicit dispatch coverage at both ends: a v2 node reads collections / ignores stray flat params; a v1 node reads flat params / ignores stray collections, plus the no-AI-keys guarantee for v1.
  • docs/backwards-compat.md — added a worked example documenting the v1→v2 bump.
  • package.json0.2.00.2.1 (the lockfile was lagging at 0.1.2; corrected to match).

Behavior

Workflow saved on typeVersion in JSON Result after upgrade
0.1.x (flat params) 1 Reads flat params → settings preserved
0.2.x (collections) 2 Reads collections → unchanged
New node 2 (default) v2 collections

Verification

  • npm test242/242 pass (added explicit version-coverage tests)
  • npm run build, npm run lint, prepublish lint — clean
  • npm run n8n-validate — security scan passed

Note: the validator scans the published npm package, so it currently reports 0.2.0; it'll re-scan once 0.2.1 publishes.

🤖 Generated with Claude Code

0.2.0 (#10) regrouped the Video Player's flat params (playerAutoplayMode,
playerSkin, playerAdvancedOptions, …) into collection fields
(playerPlayback, playerLayout, playerAppearance, playerFeatures,
playerAiOptions). Those flat params had already shipped to npm in 0.1.0–0.1.2,
so renaming them — a frozen-by-string break — silently dropped Video Player
settings from any workflow saved against 0.1.x on upgrade to 0.2.0. The
backward-compat check missed it because it was baselined against 0.0.9, which
predates the Video Player. (Flagged by n8n Cloud verification.)

Fix per the standard n8n pattern: keep the v1 schema intact behind a
typeVersion bump instead of mutating it.

- Cloudinary.node.ts: version 1 -> [1, 2], defaultVersion 2.
- widget.fields.ts: restore the v1 flat fields gated on
  displayOptions.show['@Version']: [1]; gate the v2 collections on
  [{ _cnd: { gte: 2 } }] (gte so a future v3 inherits the schema without
  re-gating); the three unchanged essentials (playerTransformation,
  playerPoster, playerSourceTypes) stay ungated and show for both.
- videoPlayer.ts: dispatch on getNode().typeVersion to readPlayerParamsV1
  (flat) or readPlayerParamsV2 (collections) into one shared PlayerParams;
  the URL/config builders are untouched. v1 yields ai: {}, so its output
  matches 0.1.x exactly.
- testHelpers.ts: makeCtx accepts typeVersion (default 2), exposed via getNode().
- widget.test.ts: explicit dispatch coverage at both ends — v2 reads
  collections / ignores stray flat params; v1 reads flat params / ignores
  stray collections, plus the no-AI-keys guarantee.
- docs/backwards-compat.md: worked example of the bump.
- package.json: 0.2.0 -> 0.2.1 (lockfile was lagging at 0.1.2; corrected).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

2 participants