Skip to content

fix(js): align block-inserter schema with native-inserter producer#501

Open
jkmassel wants to merge 2 commits into
trunkfrom
jkmassel/native-inserter-schema-fixes
Open

fix(js): align block-inserter schema with native-inserter producer#501
jkmassel wants to merge 2 commits into
trunkfrom
jkmassel/native-inserter-schema-fixes

Conversation

@jkmassel
Copy link
Copy Markdown
Contributor

Summary

Two small JS fixes that surfaced from CI on #461 / #481 / downstream stacked PRs.

  1. Schema misses iconForegroundfeat(android): render branded block icons with contrast-aware tinting #468 added iconForeground to the block payload, but the schema (added in refactor(js): harden native inserter pattern payload shape #467) declares additionalProperties: false on BlockType with no iconForeground entry. Trunk doesn't emit the field yet so trunk CI is fine, but any branch that carries both pieces (e.g. feat(android): add native block inserter #461) fails AJV validation. Adds an entry mirroring icon: nullable string.

  2. AJV version drift in error readingpackage.json declares ajv ^8.18.0 but the resolved version in node_modules is 6.12.6 (pulled in transitively and hoisted). AJV 6 surfaces the failing field path as dataPath; AJV 7+ uses instancePath. The shape-test helper only read instancePath, so error messages came back as /: should be array instead of .patterns[0].blockTypes: should be array, and the regex matchers in two rejection tests failed to find the field name. Read both, fall back across versions.

Landing this on trunk first lets #461 merge as a clean mechanical replay of already-approved squash commits.

Test plan

  • npx vitest run src/utils/blocks.test.js — 17/17 pass
  • make lint-js-fix — clean

jkmassel added 2 commits May 11, 2026 15:37
#468 added `iconForeground: getBlockIconForeground(item)` to the block
payload, but the schema (added in #467, in trunk) still has
`additionalProperties: false` on `BlockType` with no `iconForeground`
entry. Trunk doesn't emit the field so trunk CI is fine; this branch
carries both pieces and AJV rejects the payload.

Mirrors the existing `icon` entry: nullable string.
Resolved AJV in node_modules is 6.12.6 (despite package.json declaring
^8.18.0 — pulled in transitively). AJV 6 surfaces the failing field as
`dataPath`; AJV 7+ uses `instancePath`. The helper only read
`instancePath`, so error messages came back as `/: should be array`
instead of `.patterns[0].blockTypes: should be array`, and the regex
matchers in the rejection tests failed to find the field name.

Read both, fall back across versions.
@github-actions github-actions Bot added the [Type] Bug An existing feature does not function as intended label May 11, 2026
@jkmassel jkmassel requested a review from oguzkocer May 11, 2026 21:49
@wpmobilebot
Copy link
Copy Markdown

XCFramework Build

This PR's XCFramework is available for testing. Add the following to your Package.swift:

.package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/501")

Built from de8a1f6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants