feat(utils): export DependsOnEvaluator on the public barrel#69
Open
abhijitnairDhwani wants to merge 1 commit into
Open
feat(utils): export DependsOnEvaluator on the public barrel#69abhijitnairDhwani wants to merge 1 commit into
abhijitnairDhwani wants to merge 1 commit into
Conversation
`DependsOnEvaluator` is canonical infrastructure for evaluating Frappe's
`depends_on` / `mandatory_depends_on` expressions — the SDK uses it 9
times internally (form_builder.dart × 7, link_option_service.dart × 2)
and the class docstring already calls out the public-API intent
("expressions evaluated here come from server-side DocType meta
configured by Frappe admins").
Consumers that own their own form layer (rather than rendering through
`FrappeFormBuilder`) need the same evaluator to apply depends_on
semantics on the UI side — re-implementing the parser locally would
duplicate ~150 LOC and create a drift vector the moment the SDK adds
new expression forms.
One-line addition to the `Utils` section of the barrel. No code in
`src/utils/depends_on_evaluator.dart` changes; only its visibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
One-line addition to the SDK barrel:
No code in
src/utils/depends_on_evaluator.dartchanges; only its visibility.Why this is needed
DependsOnEvaluatorevaluates Frappe'sdepends_on/mandatory_depends_onexpressions. The class is already mature canonical infrastructure for the SDK itself — referenced 9 times internally:src/ui/widgets/form_builder.dart× 7 (visibility, mandatoriness, read-only, tab/section evaluation)src/services/link_option_service.dart× 2 (extractEvalDocField)The class docstring already calls out the public-API intent:
The class lives in
src/utils/only because it was never explicitly exported. Consumers reaching into the SDK to use it need// ignore: implementation_imports.Who needs this
Apps that own their own form layer rather than rendering through
FrappeFormBuilderneed the same evaluator on the UI side. Concretely: any consumer that:OfflineRepository,SyncService,UnifiedResolver) for offline-first save / pull / push;… needs
depends_on/mandatory_depends_onsemantics on the UI side to match the SDK's data-layer expectations.Re-implementing the evaluator locally would mean duplicating ~150 LOC of expression parsing (the
eval:prefix strip, AND/OR splits outside brackets, six comparison operators,.includes([...])patterns, nested-paren handling). Every time the SDK extends the supported expression syntax, the consumer's duplicate would silently drift.Exporting the symbol from the SDK's public barrel keeps semantics aligned with the upstream evaluator, with no code drift surface.
Why not introduce a new abstract interface
The existing class is the contract. There's nothing implementation-specific about evaluating a string against a
Map<String, dynamic>— that's exactly what the SDK does internally too. A new interface would just shadow the existing class without adding value.Tests
No new tests; the change is visibility-only. The existing evaluator tests in
test/utils/depends_on_evaluator_test.dart(if any) and the 7+2 internal call sites continue to work unchanged.