equinor / equinor/fusion-framework

Refactor(module-content): Rewrite ContextConfigBuilder to Extend BaseConfigBuilder

Open
#3,168 0 comments 0 reactions 0 assignees View on GitHub
✨ improvement
Dominant language
TypeScript
Stars
10
Forks
10
Avg merge
19h 40m
Merged PRs (30d)
150

Description

#### Background

Currently, [`ContextConfigBuilder`](https://github.com/equinor/fusion-framework/blob/main/packages/modules/context/src/ContextConfigBuilder.ts) does not extend the shared [`BaseConfigBuilder`](https://github.com/equinor/fusion-framework/blob/main/packages/modules/module/src/BaseConfigBuilder.ts) class. This leads to duplicated configuration logic, inconsistent API, and missed opportunities to leverage the advanced features and patterns provided by `BaseConfigBuilder`.

#### Proposal

Refactor `ContextConfigBuilder` so that it extends `BaseConfigBuilder`. This will:

- Unify configuration logic across modules.
- Enable dot-path config registration, async config resolution, and post-processing.
- Reduce code duplication and improve maintainability.

#### Acceptance Criteria

- `ContextConfigBuilder` extends `BaseConfigBuilder`.
- All setter methods (`setContextType`, `setContextFilter`, etc.) use the `_set` method from `BaseConfigBuilder` to register config values or callbacks.
- The direct `config` property is removed in favor of the base class’s internal config handling.
- The builder supports both direct values and async/callback-based config registration.
- The public API for consumers remains as close as possible to the current one.
- All usages and tests are updated to use the new builder.

#### Benefits

- Consistent configuration API across all module builders.
- Easier to maintain and extend configuration logic.
- Leverages advanced features of `BaseConfigBuilder` (dot-path, async, post-processing).

---

**References:**
- [`BaseConfigBuilder.ts`](https://github.com/equinor/fusion-framework/blob/main/packages/modules/module/src/BaseConfigBuilder.ts)
- [`ContextConfigBuilder.ts`](https://github.com/equinor/fusion-framework/blob/main/packages/modules/context/src/ContextConfigBuilder.ts)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.