feat(SOSO-435): UnknownFieldPolicy strategy for DynamicTable#13
Merged
feat(SOSO-435): UnknownFieldPolicy strategy for DynamicTable#13
Conversation
Introduce injectable UnknownFieldPolicyInterface to handle fields in row objects that are not defined in the table schema. DynamicTable now applies the policy before validation in add(), update(), and delete() operations. - Add UnknownFieldPolicyInterface in src/types/policies.ts - Add 3 built-in policies in src/utils/policies/: - StripUnknownFieldPolicy (default): silently removes unknown fields - IgnoreUnknownFieldPolicy: passes rows through unchanged - ErrorUnknownFieldPolicy: throws ValidationError for unknown fields - Extend DynamicTable constructor with optional 3rd param (default: Strip) - Extend DynamicTableFactory constructor to pass policy through - Add 18 unit tests for policy implementations - Add 16 integration tests for DynamicTable with all policies + custom DI - All 306 tests pass (272 existing + 34 new)
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.
Summary
UnknownFieldPolicyInterface(Strategy Pattern) to handle fields in row objects that are not defined in the table schemaadd(),update(), anddelete()operationsStripUnknownFieldPolicy(silently removes unknown fields — safer default)Changes
New Files (6)
src/types/policies.tsUnknownFieldPolicyInterfacedefinitionsrc/utils/policies/StripUnknownFieldPolicy.tssrc/utils/policies/IgnoreUnknownFieldPolicy.tssrc/utils/policies/ErrorUnknownFieldPolicy.tsValidationErrorsrc/utils/policies/index.tsModified Files (4)
src/client/DynamicTable.tsadd(),update(),delete()src/client/DynamicTableFactory.tssrc/types/index.tssrc/utils/index.tsNew Tests (2 files, 34 tests)
tests/utils/policies/UnknownFieldPolicies.test.tstests/client/DynamicTable.unknownFields.test.tsTest Results
Design Decisions
'ignore' | 'warn' | 'strip' | 'error'stringsSelectorBuilderInterface— interface intypes/, impl inutils/, optional constructor param with?? new Default()console.warn/console.log, communicates only via return values and exceptionsdelete()covered — unknown fields in delete key objects are also processedRelated
docs/SOSO-435/INTEGRATION_CONCEPT.md