Skip to content

Conversation

@RajPrakash681
Copy link
Contributor

Requirements

This PR has a title that briefly describes the work done including the ticket number. Ensure your PR title includes a conventional commit label (such as feat, fix, or chore, among others). See existing PR titles for inspiration.

If applicable

My work includes tests or is validated by existing tests.
I have updated the esm-framework mock to reflect any API changes I have made.

Summary

This PR fixes the extension configuration schema machinery so that extensions can properly define and use their own configuration schemas independent of module schemas.

Problems Solved:

  • defineExtensionConfigSchema() wasn't properly registering extension schemas (missing moduleLoaded flag)
  • useConfig hook was always merging module config with extension config, even when extension had its own schema

Changes:

  • Added extensionHasOwnConfigSchema() function to check if an extension has its own config schema
  • Fixed defineExtensionConfigSchema() to set the moduleLoaded flag
  • Updated useConfig hook to use extension-specific schemas exclusively when they exist
  • Updated mock files (mock.ts, mock-jest.ts) for testing compatibility

Behavior:
When an extension defines its own config schema using defineExtensionConfigSchema(), the useConfig hook now returns only the extension's config (not merged with module config). When no extension schema exists, it falls back to merging module + extension configs.

Related Issue

https://openmrs.atlassian.net/browse/O3-4562

Other

All 95 existing tests pass. Extension config tests verify the correct exclusive schema usage. No breaking changes to existing functionality.

This fixes the extension configuration schema concept so that:

1. defineExtensionConfigSchema() correctly registers a config schema
   associated with an extension by setting the moduleLoaded flag

2. When an extension has its own config schema, it is used exclusively
   instead of being merged with the module schema

Changes:
- Added extensionHasOwnConfigSchema() function to check if an extension
  has its own config schema defined
- Fixed defineExtensionConfigSchema() to set moduleLoaded flag
- Updated useConfig hook to use extension-specific schemas exclusively
  when they exist, falling back to merged configs otherwise
- Updated mock files for testing compatibility

Testing:
All 95 existing tests pass. Extension config schemas now work as designed.
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