Meta interface#826
Merged
Merged
Conversation
Prior to the Meta ($) type, the Data class was difficult to maintain. Everytime a new feature was added every reference needed to change. We now contain all the Data generics in an interface. BREAKING CHANGE: Data generics have changed.
Prior to the Meta ($) type, the Data class was difficult to maintain. Everytime a new feature was added every reference needed to change. We now contain all the Data generics in an interface. BREAKING CHANGE: Data generics have changed.
Prior to the Meta ($) type, the Data class was difficult to maintain. Everytime a new feature was added every reference needed to change. We now contain all the Data generics in an interface. BREAKING CHANGE: Data generics have changed.
Prior to the Meta ($) type, the Data class was difficult to maintain. Everytime a new feature was added every reference needed to change. We now contain all the Data generics in an interface. BREAKING CHANGE: Data generics have changed.
Keep things simple and use a full meta interface
96a51d8 to
2d5e5cf
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a Meta interface to consolidate type parameters, reducing code duplication and improving maintainability. Instead of passing four separate parser type parameters (PayloadParsers, TargetingParsers, QueryParsers, FallThroughTargetingParsers) throughout the codebase, a single Meta interface encapsulates all four.
Key changes:
- Introduced
DT.Metainterface with four parser type properties - Refactored generic type parameters across the codebase to use
$ extends DT.Meta - Simplified type definitions by accessing parser types through the Meta interface (e.g.,
$['PayloadParsers'])
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/api/src/types/Data.ts | Added Meta and EmptyMeta interfaces; refactored type helper functions to use the new Meta pattern |
| packages/api/src/types/Payload.ts | Updated Payload and Payloads types to use Meta interface |
| packages/api/src/types/FallThroughTargeting.ts | Updated Rules type to use Meta interface |
| packages/api/src/parsers/DataItemRule.ts | Refactored all parser and rule types to use Meta interface instead of separate type parameters |
| packages/api/src/parsers/DataItemRules.ts | Updated parser function and types to use Meta interface |
| packages/api/src/parsers/DataItem.ts | Updated DataItem parser and types to use Meta interface |
| packages/api/src/parsers/DataItemVariablesParser.ts | Refactored to use Meta interface for targeting parsers |
| packages/api/src/parsers/DataItems.ts | Updated to use Meta interface and added ObjValues helper type |
| packages/api/src/parsers/TargetingPredicates.ts | Updated to use Meta interface with Pick for required parser types |
| packages/api/src/Data.ts | Refactored Data class to use Meta interface throughout |
| packages/api/src/PromisedData.ts | Updated PromisedData class to use Meta interface and implement new IData interface |
| packages/api/src/IData.ts | Added new interface defining the Data API contract using Meta interface |
| packages/client/src/index.ts | Simplified Client class to use Meta interface; streamlined ClientWithData type |
| packages/server/src/middleware/castQueryProp.ts | Added generic type parameters and exported ParsedQs type |
| packages/server/src/middleware/castQueryArrayProps.ts | Updated to use DT.Any and simplified type parameters |
| packages/api/src/types.ts | Added ObjValues utility type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
Author
|
🎉 This PR is included in version @targetd/api-v8.0.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
Extending maintainability by passing around a
Metainterface instead of declaring each set of parsers separately.