Skip to content

Match utility dependencies exactly in the registry - #259

Merged
sneridagh merged 1 commit into
mainfrom
fix/registry-utilities-exact-match
Oct 9, 2026
Merged

sneridagh merged 1 commit into
mainfrom
fix/registry-utilities-exact-match

Conversation

@sneridagh

Copy link
Copy Markdown
Member

getUtilities matched utility keys by prefix, with no separator between the dependencies and the utility name. A lookup for { widget: 'url' } also returned utilities registered for { widget: 'url_list' }, or for any value starting with url. getUtility and getUtilities also didn't sort dependency keys (unlike registerUtility), so multi-key lookups only matched when callers passed the keys in sorted order.

The dependency part of the key is now built by one helper, utilityDepsPrefix. It sorts the keys and ends with a separator: |widget:url|url instead of |widget:urlurl. Utilities registered without dependencies keep their plain name as the key. Nothing outside the registry reads the keys directly.

Behavior to note:

  • getUtilities without dependencies still returns every utility of the type. The app relies on this for clientEndpoints, rootLoaderData, rootContentSubRequest and the somersault migrations, and a test now covers it.
  • With dependencies, a lookup matches only that exact set. A subset lookup no longer returns utilities registered with extra dependencies. No current caller passes dependencies to getUtilities.

Tests: added cases for prefix-sharing values, unsorted keys in getUtilities and getUtility, a dependency/name split collision, and the no-dependency case. Registry (132), cmsui (205) and aurora app vitest (48) pass. Registry build and check:ts are clean.

getUtilities matched keys by prefix with no separator between the
dependencies and the name, so a lookup for { widget: 'url' } also
returned utilities registered for { widget: 'url_list' }. getUtility
and getUtilities also did not sort dependency keys, so multi-key
lookups only worked when callers passed them in sorted order.

Build the dependency part of the key in one helper that sorts the keys
and ends with a separator.
@sneridagh
sneridagh merged commit 8072d94 into main Oct 9, 2026
40 checks passed
@sneridagh
sneridagh deleted the fix/registry-utilities-exact-match branch October 9, 2026 16:32
sneridagh added a commit that referenced this pull request Oct 10, 2026
* origin/main:
  Validate schema-driven forms (#256)
  Move the recurrence modal off TanStack Form (#254)
  Move the forms onto the helpers form store (#253)
  Add a Jotai-native form layer to helpers (#252)
  Render every schema form through one field renderer (#251)
  Document and type the form widget contract (#97)
  Match utility dependencies exactly in the registry (#259)

# Conflicts:
#	packages/cmsui/config/widgets.ts
sneridagh added a commit that referenced this pull request Oct 10, 2026
…widget-context

* origin/feat/widget-adapters:
  Restore files the pre-commit hook reformatted
  Validate schema-driven forms (#256)
  Move the recurrence modal off TanStack Form (#254)
  Move the forms onto the helpers form store (#253)
  Add a Jotai-native form layer to helpers (#252)
  Render every schema form through one field renderer (#251)
  Document and type the form widget contract (#97)
  Match utility dependencies exactly in the registry (#259)
sneridagh added a commit that referenced this pull request Oct 10, 2026
…yped-widget-registry

* origin/feat/widget-context:
  Restore files the pre-commit hook reformatted
  Validate schema-driven forms (#256)
  Move the recurrence modal off TanStack Form (#254)
  Move the forms onto the helpers form store (#253)
  Add a Jotai-native form layer to helpers (#252)
  Render every schema form through one field renderer (#251)
  Document and type the form widget contract (#97)
  Match utility dependencies exactly in the registry (#259)
sneridagh added a commit that referenced this pull request Oct 10, 2026
… feat/missing-widgets

* origin/feat/typed-widget-registry:
  Restore files the pre-commit hook reformatted
  Validate schema-driven forms (#256)
  Move the recurrence modal off TanStack Form (#254)
  Move the forms onto the helpers form store (#253)
  Add a Jotai-native form layer to helpers (#252)
  Render every schema form through one field renderer (#251)
  Document and type the form widget contract (#97)
  Match utility dependencies exactly in the registry (#259)
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