-
-
Notifications
You must be signed in to change notification settings - Fork 31
blog: zenstack next chapter part 2 #441
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request makes two main updates. First, it modifies a reference in the existing blog post ( Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant ORM as ZenStack V3 ORM
participant Kysely as Kysely Query Builder
Developer->>+ORM: Initiate CRUD or procedure call
ORM->>+Kysely: Build query with computed fields
Kysely-->>-ORM: Return computed results
ORM-->>-Developer: Return complete response
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (4)
blog/next-chapter-2/index.md (4)
51-53
: Refine Computed Fields DescriptionIn the sentence describing computed fields—specifically, "like adding a
postCount
field to return the number of posts a user has"—consider inserting an article for improved clarity. For example:- ...like adding a `postCount` field to return the number of posts a user has + ...like adding a `postCount` field to return the number of posts that a user has🧰 Tools
🪛 LanguageTool
[uncategorized] ~53-~53: You might be missing the article “a” here.
Context: ...mbiningfirstName
andlastName
into full name, but you can't do anything that ne...(AI_EN_LECTOR_MISSING_DETERMINER_A)
84-92
: Clear Example Using Computed Fields in QueriesThe sample demonstrating filter and sorting on the computed field is both clear and practical.
Additionally, consider rephrasing "returned in the result" to "included in the result" for smoother reading:- ...the `postCount` field will be returned in the result + ...the `postCount` field will be included in the result🧰 Tools
🪛 LanguageTool
[grammar] ~84-~84: The usual collocation for “returned” is “to”, not “in”.
Context: ...rmodel, the
postCount` field will be returned in the result. You can also use it to filt...(RETURN_IN_THE)
125-140
: Well-Documented Procedure ImplementationThe example showing the procedure implementation inside the ZenStackClient configuration is practical. It also illustrates real-world actions like sending a welcome email. Consider adding error handling for production readiness.
180-187
: Conclusion Section – Enhance Tone with Stronger AdjectiveThe conclusion effectively outlines future directions for ZenStack v3. To further strengthen your wording, consider replacing "deep customizations" with a term like "profound customizations":
- deep customizations + profound customizations🧰 Tools
🪛 LanguageTool
[style] ~186-~186: Consider an alternative adjective to strengthen your wording.
Context: ...ew plugin system will allow you to make deep customizations to ZenStack in a clean a...(DEEP_PROFOUND)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
blog/next-chapter-2/cover.png
is excluded by!**/*.png
,!**/*.png
📒 Files selected for processing (2)
blog/next-chapter-1/index.md
(1 hunks)blog/next-chapter-2/index.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
blog/next-chapter-2/index.md
[uncategorized] ~53-~53: You might be missing the article “a” here.
Context: ...mbining firstName
and lastName
into full name, but you can't do anything that ne...
(AI_EN_LECTOR_MISSING_DETERMINER_A)
[grammar] ~84-~84: The usual collocation for “returned” is “to”, not “in”.
Context: ...rmodel, the
postCount` field will be returned in the result. You can also use it to filt...
(RETURN_IN_THE)
[style] ~186-~186: Consider an alternative adjective to strengthen your wording.
Context: ...ew plugin system will allow you to make deep customizations to ZenStack in a clean a...
(DEEP_PROFOUND)
🔇 Additional comments (11)
blog/next-chapter-1/index.md (1)
126-127
: Updated Hyperlink for Seamless NavigationThe list item now includes a hyperlink to the next chapter (
../next-chapter-2/index.md
), which greatly improves navigability between related posts. Please verify that the relative path is correct for your deployment.blog/next-chapter-2/index.md (10)
1-8
: Frontmatter Metadata is Clear and ConsistentThe metadata block (title, description, tags, authors, image, date) is well defined and aligns with the post’s subject on ZenStack V3. Ensure that the publication date and other metadata continue to match your timeline.
14-15
: Clear Reference to the Previous PostThe introductory sentence correctly links to the previous post (
../next-chapter-1/index.md
), helping readers navigate through the series with ease.
22-31
: Effective Code Snippet for CRUD and Query Builder DemonstrationThe embedded TypeScript example neatly illustrates both the CRUD API usage and the Kysely query builder approach. The clarity of these examples will help readers grasp the underlying concepts.
32-35
: Seamless Blending of Query ApproachesThe explanation following the code snippet effectively highlights how the query builder can complement standard CRUD operations. No changes are required here.
51-57
: Well-Outlined Computed Fields FeatureThe "Computed Fields" section clearly describes the limitations of previous versions and introduces the new
@computed
attribute for ZenStack v3. The accompanying schema snippet is informative.🧰 Tools
🪛 LanguageTool
[uncategorized] ~53-~53: You might be missing the article “a” here.
Context: ...mbiningfirstName
andlastName
into full name, but you can't do anything that ne...(AI_EN_LECTOR_MISSING_DETERMINER_A)
57-82
: Solid Implementation of Computed Fields CallbackThe provided ZenStackClient initialization with the
computed
callback is well constructed and leverages Kysely’s capabilities effectively. This example should help users understand how to implement dynamic computed fields.
105-109
: Comprehensive Introduction to Custom ProceduresThe introduction to the "Custom Procedures" section is clear and sets the stage for the detailed examples that follow. The rationale for encapsulating business logic is well stated.
110-124
: Clear Schema Example for Procedure DeclarationThe Prisma schema snippet that declares a procedure (e.g.,
proc signUp
) is concise and clearly demonstrates how procedures are defined within ZenStack v3.
142-146
: Illustrative Procedure InvocationThe snippet demonstrating how to call the custom procedure is succinct and clearly shows the integration of type-safe procedure calls.
147-178
: Effective Frontend Integration ExampleThe example integrating TanStack query hooks with the custom procedures showcases a smooth frontend implementation. The snippet is clear and should be very useful for developers.
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
blog/next-chapter-2/index.md (2)
53-53
: Minor grammar issue in explanation.There's a missing article before "full name" in this sentence.
- It's good for simple computations like combining `firstName` and `lastName` into full name, but you can't do anything that needs database-side computation + It's good for simple computations like combining `firstName` and `lastName` into a full name, but you can't do anything that needs database-side computation🧰 Tools
🪛 LanguageTool
[uncategorized] ~53-~53: Possible missing article found.
Context: ...mbiningfirstName
andlastName
into full name, but you can't do anything that ne...(AI_HYDRA_LEO_MISSING_A)
84-84
: Consider revising phrasing for clarity.The phrase "returned in the result" could be improved for better readability.
- Then, when you query the `User` model, the `postCount` field will be returned in the result. + Then, when you query the `User` model, the `postCount` field will be included in the result.🧰 Tools
🪛 LanguageTool
[grammar] ~84-~84: The usual collocation for “returned” is “to”, not “in”.
Context: ...rmodel, the
postCount` field will be returned in the result. You can also use it to filt...(RETURN_IN_THE)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
blog/next-chapter-2/index.md
(1 hunks)src/lib/prism-zmodel.js
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
blog/next-chapter-2/index.md
[uncategorized] ~53-~53: Possible missing article found.
Context: ...mbining firstName
and lastName
into full name, but you can't do anything that ne...
(AI_HYDRA_LEO_MISSING_A)
[grammar] ~84-~84: The usual collocation for “returned” is “to”, not “in”.
Context: ...rmodel, the
postCount` field will be returned in the result. You can also use it to filt...
(RETURN_IN_THE)
[style] ~186-~186: Consider an alternative adjective to strengthen your wording.
Context: ...ew plugin system will allow you to make deep customizations to ZenStack in a clean a...
(DEEP_PROFOUND)
🔇 Additional comments (7)
src/lib/prism-zmodel.js (1)
2-2
: Correctly added newproc
keyword to syntax highlighting.The addition of the
proc
keyword to the ZModel syntax highlighter aligns perfectly with the introduction of the new procedure construct feature in ZenStack V3 detailed in the blog post. This ensures proper syntax highlighting for code examples using the new feature.blog/next-chapter-2/index.md (6)
1-8
: LGTM: Blog post frontmatter looks good.The metadata is complete with all necessary fields including title, description, tags, author, image, and date. The future date (2025-04-10) is appropriate for content that describes upcoming features.
14-14
: Excellent cross-referencing to previous content.Good job linking to the previous post to provide context and continuity in the blog series about ZenStack V3.
20-50
: Well-structured explanation of dual API approach.The explanation of how ZenStack V3 provides both high-level CRUD and low-level query builder APIs is clear and comprehensive. The code examples effectively demonstrate the different approaches and how they can be combined.
51-104
: Comprehensive explanation of computed fields feature.The explanation of the new computed fields feature is thorough and includes all key aspects:
- Problem statement and motivation
- Syntax for defining computed fields in ZModel
- Implementation details using Kysely's expression builder
- Usage examples showing filtering and sorting
- Integration with access policies
- Benefits for tooling ecosystem
This provides readers with a clear understanding of both the what and the how of this powerful new feature.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~53-~53: Possible missing article found.
Context: ...mbiningfirstName
andlastName
into full name, but you can't do anything that ne...(AI_HYDRA_LEO_MISSING_A)
[grammar] ~84-~84: The usual collocation for “returned” is “to”, not “in”.
Context: ...rmodel, the
postCount` field will be returned in the result. You can also use it to filt...(RETURN_IN_THE)
105-181
: Well-documented custom procedures feature.The explanation of the new
proc
construct is clear and comprehensive, covering:
- Introduction and motivation
- Syntax for defining procedures in ZModel
- Implementation approach
- Usage examples including frontend integration
- Integration with access policies
- Benefits for the ecosystem
The code examples effectively demonstrate how to define, implement, and use procedures, making this complex feature accessible to readers.
182-186
: Strong conclusion with forward-looking element.The conclusion effectively summarizes the key points about ZenStack V3's extensibility improvements and sets up anticipation for the next post about the plugin system. This maintains reader engagement with the series.
🧰 Tools
🪛 LanguageTool
[style] ~186-~186: Consider an alternative adjective to strengthen your wording.
Context: ...ew plugin system will allow you to make deep customizations to ZenStack in a clean a...(DEEP_PROFOUND)
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.
Actionable comments posted: 0
🧹 Nitpick comments (4)
blog/next-chapter-2/index.md (4)
84-84
: Grammatical Refinement SuggestionThe sentence on line 84 could be phrased more naturally. Consider changing:
-Then, when you query the `User` model, the `postCount` field will be returned in the result. +Then, when you query the `User` model, the `postCount` field will be included in the result.This small change improves the flow of the sentence.
🧰 Tools
🪛 LanguageTool
[grammar] ~84-~84: The usual collocation for “returned” is “to”, not “in”.
Context: ...rmodel, the
postCount` field will be returned in the result. You can also use it to filt...(RETURN_IN_THE)
126-139
: Procedure Implementation: Verify External Function AvailabilityThe TS code snippet implementing the custom procedure is clear; however, note that the function
sendWelcomeEmail
is used without an import or definition. Ensure that this function is defined or imported in the actual codebase to avoid runtime issues.
158-178
: Front-End Integration Example is EffectiveThe React snippet using TanStack query hooks offers a clear example of integrating the custom procedures into a frontend component.
Optional Suggestion: In typical React form handling, it is common to callevent.preventDefault()
within the submission handler to avoid unintended page reloads. If this example is intended for a real-world scenario, consider updatinghandleSubmit
as follows:-const handleSubmit = async (data) => { - await signUp(data); -}; +const handleSubmit = async (event) => { + event.preventDefault(); // Prevent default form submission behavior + // Extract form data as needed (e.g., using FormData or a state management hook) + const data = /* your form data extraction logic */; + await signUp(data); +};This change would make the snippet more robust for production use.
182-186
: Conclusion Section: Consider a Stronger DescriptorThe conclusion is well written. However, on line 186, the phrase “deep customizations” might be enhanced with a stronger adjective for greater impact. For instance, consider “profound customizations” or “comprehensive customizations” to better convey the capability.
🧰 Tools
🪛 LanguageTool
[style] ~186-~186: Consider an alternative adjective to strengthen your wording.
Context: ...ew plugin system will allow you to make deep customizations to ZenStack in a clean a...(DEEP_PROFOUND)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
blog/next-chapter-1/cover.png
is excluded by!**/*.png
,!**/*.png
📒 Files selected for processing (1)
blog/next-chapter-2/index.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
blog/next-chapter-2/index.md
[grammar] ~84-~84: The usual collocation for “returned” is “to”, not “in”.
Context: ...rmodel, the
postCount` field will be returned in the result. You can also use it to filt...
(RETURN_IN_THE)
[style] ~186-~186: Consider an alternative adjective to strengthen your wording.
Context: ...ew plugin system will allow you to make deep customizations to ZenStack in a clean a...
(DEEP_PROFOUND)
🔇 Additional comments (11)
blog/next-chapter-2/index.md (11)
1-8
: Front Matter Metadata is Clear and Well-FormattedThe metadata block clearly defines the title, description, tags, authors, image path, and date. Everything appears to be in order and consistent with standard front matter for a blog post.
10-17
: Introduction Section is ClearThe introductory section, including the main heading, cover image, and link to the previous post, establishes context effectively. The relative paths (e.g., for the cover image and the previous post) are correctly applied.
18-31
: CRUD and Query Builder Code Example is Well-DemonstratedThe code snippet detailing both the CRUD API and the Kysely-backed query builder API is clear and concise. It effectively contrasts the two approaches.
33-35
: Explanation of API Inference is InformativeThe text that explains how both APIs are automatically inferred from the ZModel schema is clear and adds value to the reader’s understanding.
36-45
: Mixed Query Example is Clear and PracticalThe example combining the CRUD API with a query builder expression demonstrates practical usage. The code is legible and follows a logical structure.
51-64
: Computed Fields Section is Well-PresentedThe “Computed Fields” section—including both the descriptive text and the
zmodel
snippet defining a computed field—is well structured.
67-82
: Implementation of Computed Fields is ClearThe provided TS configuration for the
ZenStackClient
with a custom computed field is correctly implemented and clearly shows how to integrate Kysely’s expression builder.
94-101
: Access Policy Snippet is ConsistentThe access policy example using a ZModel snippet to deny deletion based on
postCount
is concise and clearly illustrates the concept.
107-123
: Custom Procedures Declaration is ClearThe ZModel snippet defining the
proc signUp
procedure along with theSignUpInput
type is straightforward and well documented.
142-146
: Procedure Call Example is ClearThe example showing how to call the custom procedure with
client.$procs.signUp
is practical and well demonstrated.
148-156
: Endpoint Exposure Example is Well-DocumentedThe snippet demonstrating how the custom procedure can be exposed as an HTTP endpoint is clear and provides a useful reference for developers integrating with the API.
Summary by CodeRabbit
proc
, for improved functionality.