Skip to content

feat(render-method-2024)!: align RenderTemplate2024 with downstream renderer#19

Merged
ashleythedeveloper merged 1 commit into
nextfrom
feat/render-template-2024-spec-alignment
May 1, 2026
Merged

feat(render-method-2024)!: align RenderTemplate2024 with downstream renderer#19
ashleythedeveloper merged 1 commit into
nextfrom
feat/render-template-2024-spec-alignment

Conversation

@ashleythedeveloper
Copy link
Copy Markdown
Contributor

This PR aligns the RenderTemplate2024 interface and provider with the shape already produced and consumed by the downstream vckit renderer (packages/renderer/src/providers/render-template-2024.ts), so render methods built via constructRenderMethod round-trip cleanly through the renderer with no missing fields.

The renderer reads name, mediaType, and digestMultibase, and a type array containing "RenderTemplate2024". The previous interface only modelled mediaQuery, template, and url, and emitted unset optional fields as empty strings, neither of which match what the renderer expects.

Closes #18

Breaking changes

  • RenderTemplate2024.type is now string[] rather than the literal RenderMethodType.RenderTemplate2024. Direct consumers of the type (anyone reading renderMethod.type === 'RenderTemplate2024') must update to renderMethod.type.includes('RenderTemplate2024').
  • RenderMethod2024.construct no longer emits unset optional fields. Code that relies on mediaQuery: '' or url: '' always being present must check for the property before reading it.

Additions

  • New optional fields on RenderTemplate2024: name, mediaType, digestMultibase. All are accepted via the extra argument of constructRenderMethod and only emitted when supplied as non-empty strings.
  • extractRenderTemplate resolves the discriminator from either string or string[] type values, throwing UnsupportedRenderMethodError (with diagnostic detail for empty or unsupported arrays) when no supported entry is present.

Out of scope (potential follow-ups)

  • Tightening type to a tuple form ([RenderMethodType.RenderTemplate2024, ...string[]]) to encode the "must contain" invariant in the type system.
  • Splitting RenderTemplate2024 into Input vs Emitted variants to express the producer/consumer asymmetry.
  • Validating the discriminator inside constructRenderMethod (currently only the extract path validates).

Test plan

  • type is emitted as an array containing "RenderTemplate2024"
  • name, mediaType, and digestMultibase are accepted via extra and round-tripped onto the constructed render method
  • Optional fields supplied as undefined, missing, empty string, or non-string values are omitted from the constructed render method (no empty-string emission)
  • template is omitted when empty (URL-only construction)
  • extractRenderTemplate resolves the render method type from a string[] discriminator, including arrays with additional entries
  • extractRenderTemplate passes through a non-array type unchanged for WebRenderingTemplate2022
  • extractRenderTemplate throws UnsupportedRenderMethodError with the joined unsupported entries, and with <empty> when the array is empty
  • yarn build, yarn test, yarn lint, and yarn format all pass

Update the `RenderTemplate2024` interface and provider so that constructed
render methods conform to the W3C-CCG vc-render-method specification.

Breaking changes:
- `RenderTemplate2024.type` is now `string[]` (must contain
  `"RenderTemplate2024"`) rather than a single literal.
- `RenderMethod2024.construct` no longer emits unset optional fields as
  empty strings; only fields with non-empty string values are included
  in the result.

Additions:
- New optional fields on `RenderTemplate2024`: `name`, `mediaType`,
  `digestMultibase`. All accepted via the `extra` argument.
- `extractRenderTemplate` now resolves the render method type from
  either a string or string[] discriminator and throws
  `UnsupportedRenderMethodError` (with diagnostic detail for empty or
  unsupported arrays) when no supported entry is present.

Closes #18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Code Coverage Report

Lines Statements Branches Functions
Coverage: 100%
100% (145/145) 97.22% (35/36) 100% (26/26)
Tests Skipped Failures Errors Time
73 0 💤 0 ❌ 0 🔥 1.954s ⏱️

@ashleythedeveloper ashleythedeveloper merged commit d042ef9 into next May 1, 2026
4 checks passed
@ashleythedeveloper ashleythedeveloper deleted the feat/render-template-2024-spec-alignment branch May 1, 2026 03:16
ashleythedeveloper added a commit that referenced this pull request May 1, 2026
* chore: fix extractRenderTemplate example format (#3)

* feat: normalise template whitespace (#4)

* feat: enhance removeLineBreaks to handle \r and consecutive line breaks (#5)

* ci: update changelog config (#7)

* ci: update changelog config (#9)

* ci: fix changelog manifest version bump (#11)

* ci: remove node workspace plugin (#15)

* chore: add repository information

* feat(render-method-2024)!: align RenderTemplate2024 with downstream renderer (#19)

* chore: re-trigger release-please

* chore: bump version to 2.0.0 and update changelog (#22)
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.

Update RenderTemplate2024 shape to match downstream renderer

1 participant