-
-
Notifications
You must be signed in to change notification settings - Fork 12
merge dev to main (v3.0.0-alpha.13) #119
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
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6ad973d
chore: add CLAUDE.md (#100)
ymc9 8df3f88
feat: cli validate command (#103)
ymc9 a27a132
Add claude GitHub actions (#104)
ymc9 a61eb0c
fix: add a few missing zmodel validation checks (#101)
ymc9 d94fdf3
chore: update test schema generation (#105)
ymc9 39cf629
feat: implementing mixin (#106)
ymc9 55d4e77
feat: strongly typed JSON fields (#107)
ymc9 ca2a428
test: more cases for mixins (#108)
ymc9 c80e724
chore: change zod to peer dependency (#109)
ymc9 cbf1ce3
feat: implement delegate models (create + read) (#110)
ymc9 04959ad
fix(delegate): relation selection (#111)
ymc9 c7f02ea
fix(delegate): filter fixes (#112)
ymc9 05b0c51
feat: implement update/upsert for delegate models (#113)
ymc9 cefe223
feat: implement delegate delete (#114)
ymc9 36e1b77
feat: count and aggregate for delegate models (#115)
ymc9 3f1af06
chore: reorg test schemas (#116)
ymc9 b9bee5d
feat: delegate client typing (#117)
ymc9 33ac58e
chore: bump version 3.0.0-alpha.13 (#118)
github-actions[bot] a0c79b0
chore: addressing PR comments (#120)
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,78 @@ | ||
| name: Claude Code Review | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
| # Optional: Only run on specific file changes | ||
| # paths: | ||
| # - "src/**/*.ts" | ||
| # - "src/**/*.tsx" | ||
| # - "src/**/*.js" | ||
| # - "src/**/*.jsx" | ||
|
|
||
| jobs: | ||
| claude-review: | ||
| # Optional: Filter by PR author | ||
| # if: | | ||
| # github.event.pull_request.user.login == 'external-contributor' || | ||
| # github.event.pull_request.user.login == 'new-developer' || | ||
| # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' | ||
|
|
||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| issues: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run Claude Code Review | ||
| id: claude-review | ||
| uses: anthropics/claude-code-action@beta | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
|
|
||
| # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4) | ||
| # model: "claude-opus-4-20250514" | ||
|
|
||
| # Direct prompt for automated review (no @claude mention needed) | ||
| direct_prompt: | | ||
| Please review this pull request and provide feedback on: | ||
| - Code quality and best practices | ||
| - Potential bugs or issues | ||
| - Performance considerations | ||
| - Security concerns | ||
| - Test coverage | ||
|
|
||
| Be constructive and helpful in your feedback. | ||
|
|
||
| # Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR | ||
| # use_sticky_comment: true | ||
|
|
||
| # Optional: Customize review based on file types | ||
| # direct_prompt: | | ||
| # Review this PR focusing on: | ||
| # - For TypeScript files: Type safety and proper interface usage | ||
| # - For API endpoints: Security, input validation, and error handling | ||
| # - For React components: Performance, accessibility, and best practices | ||
| # - For tests: Coverage, edge cases, and test quality | ||
|
|
||
| # Optional: Different prompts for different authors | ||
| # direct_prompt: | | ||
| # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' && | ||
| # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' || | ||
| # 'Please provide a thorough code review focusing on our coding standards and best practices.' }} | ||
|
|
||
| # Optional: Add specific tools for running tests or linting | ||
| # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)" | ||
|
|
||
| # Optional: Skip review for certain conditions | ||
| # if: | | ||
| # !contains(github.event.pull_request.title, '[skip-review]') && | ||
| # !contains(github.event.pull_request.title, '[WIP]') | ||
|
|
||
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,64 @@ | ||
| name: Claude Code | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issues: | ||
| types: [opened, assigned] | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| jobs: | ||
| claude: | ||
| if: | | ||
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | ||
| (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| issues: read | ||
| id-token: write | ||
| actions: read # Required for Claude to read CI results on PRs | ||
ymc9 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run Claude Code | ||
| id: claude | ||
| uses: anthropics/claude-code-action@beta | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
|
|
||
| # This is an optional setting that allows Claude to read CI results on PRs | ||
| additional_permissions: | | ||
| actions: read | ||
|
|
||
| # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4) | ||
| # model: "claude-opus-4-20250514" | ||
|
|
||
| # Optional: Customize the trigger phrase (default: @claude) | ||
| # trigger_phrase: "/claude" | ||
|
|
||
| # Optional: Trigger when specific user is assigned to an issue | ||
| # assignee_trigger: "claude-bot" | ||
|
|
||
| # Optional: Allow Claude to run specific commands | ||
| # allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)" | ||
|
|
||
| # Optional: Add custom instructions for Claude to customize its behavior for your project | ||
| # custom_instructions: | | ||
| # Follow our coding standards | ||
| # Ensure all new code has tests | ||
| # Use TypeScript for new files | ||
|
|
||
| # Optional: Custom environment variables for Claude | ||
| # claude_env: | | ||
| # NODE_ENV: test | ||
|
|
||
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 |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| packages/language/src/generated/** | ||
| **/schema.ts | ||
| **/test/**/schema.ts | ||
| **/test/**/models.ts | ||
| **/test/**/input.ts | ||
| samples/**/schema.ts | ||
| samples/**/models.ts | ||
| samples/**/input.ts |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "zenstack-v3", | ||
| "version": "3.0.0-alpha.12", | ||
| "version": "3.0.0-alpha.13", | ||
| "description": "ZenStack", | ||
| "packageManager": "[email protected]", | ||
| "scripts": { | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import colors from 'colors'; | ||
| import { getSchemaFile, loadSchemaDocument } from './action-utils'; | ||
|
|
||
| type Options = { | ||
| schema?: string; | ||
| }; | ||
|
|
||
| /** | ||
| * CLI action for validating schema without generation | ||
| */ | ||
| export async function run(options: Options) { | ||
| const schemaFile = getSchemaFile(options.schema); | ||
|
|
||
| try { | ||
| await loadSchemaDocument(schemaFile); | ||
| console.log(colors.green('✓ Schema validation completed successfully.')); | ||
| } catch (error) { | ||
| console.error(colors.red('✗ Schema validation failed.')); | ||
| // Re-throw to maintain CLI exit code behavior | ||
| throw error; | ||
| } | ||
| } |
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.