Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Jun 15, 2025

Summary by CodeRabbit

  • New Features

    • Added a LICENSE file with the MIT License.
    • Expanded public API with new error exports and client options.
    • Introduced automated schema generation and a comprehensive test schema for improved type safety and validation.
    • Added extensive TypeScript typing and runtime validation tests for the client API.
  • Bug Fixes

    • Improved error handling for policy enforcement during create and update operations, ensuring errors are only thrown when relevant.
  • Documentation

    • Updated new features documentation to clarify feature descriptions.
  • Chores

    • Updated dependency management and test scripts for better development workflow.
    • Removed an unused, empty test suite.
  • Refactor

    • Enhanced and refactored client CRUD type definitions for improved flexibility and type safety.
    • Consolidated and optimized import statements for clarity.

@ymc9 ymc9 merged commit 9bf9479 into dev Jun 15, 2025
5 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Jun 15, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces a new MIT license file, refines documentation, and reorganizes dependencies in the CLI package. Major enhancements were made to the runtime's CRUD type system, improving type safety and flexibility for model operations. The test suite was expanded with new schema definitions and comprehensive type validation scripts, while some redundant or skipped tests were removed.

Changes

File(s) Change Summary
LICENSE Added MIT license file.
NEW-FEATURES.md Updated feature list wording from "Custom policy functions" to "Computed fields".
packages/cli/package.json Moved @zenstackhq/runtime from dependencies to devDependencies.
packages/runtime/package.json Simplified build script, expanded test scripts, added tsx as dev dependency.
packages/runtime/src/client/crud-types.ts Enhanced CRUD type definitions, added/updated generics, improved type safety for select, create, and connectOrCreate operations.
packages/runtime/src/client/crud/operations/create.ts
packages/runtime/src/client/crud/operations/update.ts
Modified error throwing logic to only trigger on falsy results when a policy is enabled.
packages/runtime/src/client/index.ts Reordered and expanded exports; added exports for errors and ClientOptions type.
packages/runtime/src/plugins/policy/index.ts Added export for errors module.
packages/runtime/test/client-api/many-to-many.test.ts Removed unused, empty, skipped test suite.
packages/runtime/test/test-schema.ts Consolidated import statements for clarity.
packages/runtime/test/utils.ts Changed import path for ClientOptions type.
packages/runtime/test/typing/generate.ts Added script to generate TypeScript schema from .zmodel file.
packages/runtime/test/typing/schema.ts Added auto-generated TypeScript schema definition and type alias.
packages/runtime/test/typing/typing-test.zmodel Added new Prisma-style schema with six models and SQLite datasource.
packages/runtime/test/typing/verify-typing.ts Added comprehensive TypeScript typing and runtime validation tests for ZenStackClient API.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Script as generate.ts
    participant SDK as TsSchemaGenerator
    participant FS as File System

    Dev->>Script: Run generate.ts
    Script->>FS: Read typing-test.zmodel
    Script->>SDK: Generate schema.ts from zmodel
    SDK-->>Script: schema.ts generated
    Script->>FS: Read schema.ts
    Script->>FS: Replace '@zenstackhq/runtime' with '../../dist'
    Script->>FS: Write updated schema.ts
    Script-->>Dev: Log output path
Loading
sequenceDiagram
    participant Test as verify-typing.ts
    participant Client as ZenStackClient
    participant DB as Database

    Test->>Client: Perform CRUD operations (find, create, update, delete)
    Client->>DB: Execute queries
    DB-->>Client: Return results
    Client-->>Test: Return typed results
    Test->>Test: Validate types, expect errors where appropriate
    Test-->>Console: Log outputs for verification
Loading

Poem

🐇
A license shines, MIT and bright,
Types enhanced for CRUD delight.
Tests now blossom, schemas grow,
Typings checked from head to toe.
With scripts to build and code to run,
This rabbit’s work is never done—
But oh, what fun!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0fac4f and 0365726.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • LICENSE (1 hunks)
  • NEW-FEATURES.md (1 hunks)
  • packages/cli/package.json (1 hunks)
  • packages/runtime/package.json (2 hunks)
  • packages/runtime/src/client/crud-types.ts (8 hunks)
  • packages/runtime/src/client/crud/operations/create.ts (1 hunks)
  • packages/runtime/src/client/crud/operations/update.ts (1 hunks)
  • packages/runtime/src/client/index.ts (1 hunks)
  • packages/runtime/src/plugins/policy/index.ts (1 hunks)
  • packages/runtime/test/client-api/many-to-many.test.ts (0 hunks)
  • packages/runtime/test/test-schema.ts (1 hunks)
  • packages/runtime/test/typing/generate.ts (1 hunks)
  • packages/runtime/test/typing/schema.ts (1 hunks)
  • packages/runtime/test/typing/typing-test.zmodel (1 hunks)
  • packages/runtime/test/typing/verify-typing.ts (1 hunks)
  • packages/runtime/test/utils.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants