feat(openfeature): JavaScript openfeature provider new spec - #1129
feat(openfeature): JavaScript openfeature provider new spec#1129ayushjain17 wants to merge 1 commit into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates the JavaScript OpenFeature provider to a new “spec”-aligned architecture (local vs remote resolution, data sources, refresh strategies), while extending the native Rust core and FFI surface area to support shared parse/filter logic and cache filtering/variant selection across languages.
Changes:
- Introduces new JS provider architecture:
LocalResolutionProvider(native-cache backed) andSuperpositionAPIProvider(remote-only), plus HTTP/File data sources and typed options/auth/refresh strategies. - Consolidates Rust parse/filter logic (
parse_config_file_with_filters) and adds new C-ABI cache operations to mirror UniFFI behaviors (filter config/experiments, applicable variants). - Adds JS provider unit tests (type-coercion contract, on-demand TTL behavior, file if-modified behavior) and updates harness/config to exercise new providers.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| makefile | Runs new JS provider unit tests before the integration harness. |
| crates/superposition_core/src/lib.rs | Re-exports new parse/filter and cache-related legacy FFI functions. |
| crates/superposition_core/src/format.rs | Adds shared parse_config_file_with_filters helper. |
| crates/superposition_core/src/ffi.rs | Removes legacy UniFFI parse APIs; routes parse+filter through shared helper; factors cache logic into shared inner methods. |
| crates/superposition_core/src/ffi_legacy.rs | Adds new C-ABI cache filter/variant APIs and a unified parse+filter entrypoint. |
| crates/superposition_core/src/experiment.rs | Makes ExperimentConfig serializable for JSON return paths. |
| clients/python/bindings/superposition_bindings/superposition_client.py | Removes checksums and wrappers for removed UniFFI parse functions. |
| clients/javascript/provider-sdk-tests/unit/test-type-contract.mjs | Adds type-coercion contract unit test. |
| clients/javascript/provider-sdk-tests/unit/test-ondemand-ttl.mjs | Adds on-demand TTL “checked-at clock” unit test. |
| clients/javascript/provider-sdk-tests/unit/test-file-if-modified.mjs | Adds FileDataSource if_modified_since unit test. |
| clients/javascript/provider-sdk-tests/index.js | Updates integration harness to run scenarios against multiple providers/data sources/strategies. |
| clients/javascript/provider-sdk-tests/config.toml | Adds file-backed config used by new integration flows. |
| clients/javascript/open-feature-provider/types.ts | Re-exports canonical native binding types from superposition-bindings. |
| clients/javascript/open-feature-provider/tsconfig.json | Updates TS lib and bindings path mapping. |
| clients/javascript/open-feature-provider/superposition-provider.ts | Aligns legacy provider option types to canonical Config type. |
| clients/javascript/open-feature-provider/remote-provider.ts | Adds SuperpositionAPIProvider implementation. |
| clients/javascript/open-feature-provider/options.ts | Adds auth/options/refresh-strategy model and SDK auth wiring. |
| clients/javascript/open-feature-provider/local-provider.ts | Adds LocalResolutionProvider implementation with caching + refresh strategies. |
| clients/javascript/open-feature-provider/interfaces.ts | Adds shared resolution/type-contract base (AllFeatureProvider) and experiment meta interface. |
| clients/javascript/open-feature-provider/index.ts | Updates exports to include new architecture components. |
| clients/javascript/open-feature-provider/http-data-source.ts | Adds HTTP data source with 304 handling. |
| clients/javascript/open-feature-provider/file-data-source.ts | Adds file data source with if_modified_since + watch support. |
| clients/javascript/open-feature-provider/errors.ts | Adds typed provider/data source error model. |
| clients/javascript/open-feature-provider/data-source.ts | Adds data-source abstraction and FetchResponse sum type. |
| clients/javascript/open-feature-provider/conversions.ts | Adds conversion helpers from SDK responses to native-cache shapes. |
| clients/javascript/open-feature-provider/configuration-client.ts | Reuses conversion helper and switches defaults/current config typing to canonical Config. |
| clients/javascript/bindings/tsconfig.json | Adds esnext.disposable lib for Symbol.dispose typing. |
| clients/javascript/bindings/test-toml.ts | Updates tests to use unified parse+filter API. |
| clients/javascript/bindings/test-json.ts | Updates tests to use unified parse+filter API. |
| clients/javascript/bindings/native-resolver.ts | Adds cache wrapper class + new FFI function bindings (parse+filter, cache filtering, variants). |
| clients/java/bindings/.../superposition_client.kt | Removes bindings for removed UniFFI parse functions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let file_content = match c_str_to_string(file_content) { | ||
| Ok(s) => s, | ||
| Err(e) => { | ||
| copy_string(ebuf, format!("Invalid UTF-8 in toml_content: {}", e)); | ||
| copy_string(ebuf, format!("Invalid UTF-8 in file_content: {}", e)); | ||
| return ptr::null_mut(); |
| let format = match c_str_to_string(format) { | ||
| Ok(s) => s, | ||
| Err(e) => { | ||
| copy_string(ebuf, e.to_string()); | ||
| copy_string(ebuf, format!("Invalid UTF-8 in format: {}", e)); | ||
| return ptr::null_mut(); |
| * Mirrors Rust/Python/Java `FileDataSource`. Honours `if_modified_since` via the file's last-modified | ||
| * time (a 304-equivalent), and supports watching the file for changes via `fs.watch`. Filtering is | ||
| * not applied here (the file is parsed whole); the local provider filters during evaluation. | ||
| */ |
| this.status = ProviderStatus.NOT_READY; | ||
| this.globalContext = context ?? {}; | ||
|
|
||
| this.ffiCache = this.resolver.createProviderCache(); | ||
| cacheRegistry.register(this, this.ffiCache, this); |
cc67322 to
0b28d71
Compare
Change log
Javascript provider in the new spec