-
-
Notifications
You must be signed in to change notification settings - Fork 12
fix: add a few missing zmodel validation checks #101
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
51b3656
chore: add CLAUDE.md
ymc9 aa1b5bf
fix: add a few missing zmodel validation checks
ymc9 b5def9f
update
ymc9 bff4ce6
Merge remote-tracking branch 'origin/dev' into chore/claude-md
ymc9 4efba44
update
ymc9 08a065a
Merge remote-tracking branch 'origin/dev' into chore/claude-md
ymc9 fcb5be1
update
ymc9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Development Commands | ||
|
|
||
| ### Build System | ||
| - `pnpm build` - Build all packages using Turbo | ||
| - `pnpm watch` - Watch mode for all packages | ||
| - `pnpm lint` - Run ESLint across all packages | ||
| - `pnpm test` - Run tests for all packages | ||
|
|
||
| ### Package Management | ||
| - Uses `pnpm` with workspaces | ||
| - Package manager is pinned to `[email protected]` | ||
| - Packages are located in `packages/`, `samples/`, and `tests/` | ||
|
|
||
| ### Testing | ||
| - Runtime package tests: `pnpm test` (includes vitest, typing generation, and typecheck) | ||
| - CLI tests: `pnpm test` | ||
| - E2E tests are in `tests/e2e/` directory | ||
|
|
||
| ### ZenStack CLI Commands | ||
| - `npx zenstack init` - Initialize ZenStack in a project | ||
| - `npx zenstack generate` - Compile ZModel schema to TypeScript | ||
| - `npx zenstack db push` - Sync schema to database (uses Prisma) | ||
| - `npx zenstack migrate dev` - Create and apply migrations | ||
| - `npx zenstack migrate deploy` - Deploy migrations to production | ||
|
|
||
| ## Architecture Overview | ||
|
|
||
| ### Core Components | ||
| - **@zenstackhq/runtime** - Main database client and ORM engine built on Kysely | ||
| - **@zenstackhq/cli** - Command line interface and project management | ||
| - **@zenstackhq/language** - ZModel language specification and parser (uses Langium) | ||
| - **@zenstackhq/sdk** - Code generation utilities and schema processing | ||
|
|
||
| ### Key Architecture Patterns | ||
| - **Monorepo Structure**: Uses pnpm workspaces with Turbo for build orchestration | ||
| - **Language-First Design**: ZModel DSL compiles to TypeScript, not runtime code generation | ||
| - **Kysely-Based ORM**: V3 uses Kysely as query builder instead of Prisma runtime dependency | ||
| - **Plugin Architecture**: Runtime plugins for query interception and entity mutation hooks | ||
|
|
||
| ### ZModel to TypeScript Flow | ||
| 1. ZModel schema (`schema.zmodel`) defines database structure and policies | ||
| 2. `zenstack generate` compiles ZModel to TypeScript schema (`schema.ts`) | ||
| 3. Schema is used to instantiate `ZenStackClient` with type-safe CRUD operations | ||
| 4. Client provides both high-level ORM API and low-level Kysely query builder | ||
|
|
||
| ### Package Dependencies | ||
| - **Runtime**: Depends on Kysely, Zod, and various utility libraries | ||
| - **CLI**: Depends on language package, Commander.js, and Prisma (for migrations) | ||
| - **Language**: Uses Langium for grammar parsing and AST generation | ||
| - **Database Support**: SQLite (better-sqlite3) and PostgreSQL (pg) only | ||
|
|
||
| ### Testing Strategy | ||
| - Runtime package has comprehensive client API tests and policy tests | ||
| - CLI has action-specific tests for commands | ||
| - E2E tests validate real-world schema compatibility (cal.com, formbricks, trigger.dev) | ||
| - Type coverage tests ensure TypeScript inference works correctly | ||
|
|
||
| ## Key Differences from Prisma | ||
| - No runtime dependency on @prisma/client | ||
| - Pure TypeScript implementation without Rust/WASM | ||
| - Built-in access control and validation (coming soon) | ||
| - Kysely query builder as escape hatch instead of raw SQL | ||
| - Schema-first approach with ZModel DSL extension of Prisma schema language | ||
|
|
||
| ## Development Notes | ||
| - Always run `zenstack generate` after modifying ZModel schemas | ||
| - Database migrations still use Prisma CLI under the hood | ||
| - Plugin system allows interception at ORM, Kysely, and entity mutation levels | ||
| - Computed fields are evaluated at database level for performance |
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.