dataconnect: internal refactor to use higher-level types to work with proto struct paths #7613
+590
−223
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.
This PR implements an internal refactoring within the
firebase-dataconnectmodule, moving from a string-based representation of proto struct paths to a more structured and type-safeDataConnectPath(a list ofDataConnectPathSegmentobjects). This change improves the robustness and maintainability of path handling throughout the module, particularly in areas related to serialization, deserialization, and error reporting. The refactor introduces a set of utility functions for path manipulation, ensuring consistent and correct path construction and representation.Highlights
String?to a more robust and type-safeDataConnectPath(an alias forList<DataConnectPathSegment>).DataConnectPathto facilitate common operations like converting paths to strings (toPathString,appendPathStringTo) and safely adding new segments (addField,addListIndex,withAddedPathSegment).ProtoStructDecoder,ProtoStructEncoder, andProtoUtilclasses have been updated to leverage the newDataConnectPathtype and its associated utility functions, improving consistency and error reporting.ErrorInfoImpl.toString()method now uses the new path string conversion utilities, ensuring consistent and accurate path representation in error messages.Changelog
DataConnectPathtype alias and extension functions for path string conversion and segment addition.ErrorInfoImpl.toString()to use the newappendPathStringTofunction for path formatting.decodefunctions and decoder classes to acceptDataConnectPathinstead ofString?for path parameters, integrating new path manipulation functions.DataConnectPathfor path parameters and leverage new path extension functions.ProtoValueEncoderandProtoValueDecoderinstantiation to useemptyList()for initial paths.DataConnectPathSegmentextension functions, coveringtoPathString,appendPathStringTo,addField,addListIndex,withAddedField,withAddedListIndex, andwithAddedPathSegment.Arb.dataConnect.errorPath()toArb.dataConnect.dataConnectPath().errorPathArbwithdataConnectPathArband simplifiedtoString()tests to use the newtoPathStringfunction.MyArbutility object.errorPathwithdataConnectPathand introducedDataConnectPathArbfor more controlled generation ofDataConnectPathinstances in property-based tests.