-
Notifications
You must be signed in to change notification settings - Fork 1
Refined DataModel #1405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refined DataModel #1405
Conversation
🦋 Changeset detectedLatest commit: d729e96 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello @vadimpiven, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refines the data model definition within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refines the DataModel API by introducing a DataModelBuilder for more explicit data versioning, removing the simpler DataModel.create method. The changes are consistently applied across the codebase, including updates to example blocks and documentation. Additionally, the project's formatting tooling seems to have been switched from Prettier to Zed with ESLint, with corresponding formatting updates in several files. My review includes a suggestion to improve the developer experience for simple data models and a code simplification for better readability.
I am having trouble creating individual review comments. Click here to see my feedback.
etc/blocks/sum-numbers-v3/model/src/index.ts (72-74)
The condition to check if sources has elements can be simplified using optional chaining and checking for a truthy length. This makes the code more concise and easier to read.
.enriches((args) => (args.sources?.length ? [args.sources[0]] : []))sdk/model/src/block_migrations.ts (399-422)
While the new DataModelBuilder provides a more explicit and powerful way to define data models with versioning, removing DataModel.create makes the common case of a simple, single-version data model more verbose. Previously, it was a single line:
DataModel.create<BlockData>(() => ({...}))
Now it requires multiple lines of boilerplate:
const Version = defineDataVersions({ V1: DATA_MODEL_DEFAULT_VERSION });
type VersionedData = { [Version.V1]: BlockData };
const dataModel = new DataModelBuilder<VersionedData>()
.from(Version.V1)
.init(() => ({...}));To improve developer experience for this common scenario, consider providing a simplified helper. One option is to add a static method to DataModelBuilder for this purpose, which would encapsulate the builder logic for a single-version model. For example:
export class DataModelBuilder<VersionedData extends DataVersionMap> {
/**
* Creates a simple DataModel with a single default version.
*/
static simple<T>(initialData: () => T): DataModel<T> {
const Version = defineDataVersions({ V1: DATA_MODEL_DEFAULT_VERSION });
type VersionedData = { [Version.V1]: T };
return new DataModelBuilder<VersionedData>()
.from(Version.V1)
.init(initialData);
}
// ... existing from() method
}This would allow developers to create simple data models with a concise API: DataModelBuilder.simple<BlockData>(() => ({...})).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1405 +/- ##
=======================================
Coverage 53.10% 53.10%
=======================================
Files 239 239
Lines 13369 13368 -1
Branches 2736 2736
=======================================
Hits 7099 7099
+ Misses 5368 5366 -2
- Partials 902 903 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.