Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Jun 20, 2025

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

📝 Walkthrough
## Walkthrough

This update introduces internal utility modules consolidating helper functions (e.g., `lowerCaseFirst`, `upperCaseFirst`, `invariant`), refactors imports across packages to use these local helpers, and adapts logic for supporting a new Prisma client generator. It also adds validation option controls, improves Prisma client type processing, updates test dependencies, and introduces new tests.

## Changes

| Files / Areas                                                                                  | Change Summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|-----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `packages/runtime/src/local-helpers/*`<br>`packages/runtime/src/local-helpers/index.ts`        | Added new local helper modules for utility functions (`lowerCaseFirst`, `upperCaseFirst`, `paramCase`, `isPlainObject`, `invariant`, `sleep`) and an aggregator index for consolidated imports.                                                                                                                                                                                                                                                                                                                                                                                                             |
| Most packages: `src/*`, `tests/*`                                                             | Refactored imports to use new local helper modules instead of external packages for utility functions (`lowerCaseFirst`, `upperCaseFirst`, `paramCase`, `isPlainObject`, `invariant`, `sleep`).                                                                                                                                                                                                                                                                                                                                                                                                             |
| `packages/runtime/src/types.ts`                                                               | Added `ValidationOptions` type and an optional `validation` property to `EnhancementOptions` for controlling input-only validation on update.                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `packages/runtime/src/enhancements/node/policy/policy-utils.ts`                               | Modified schema validation logic in `checkPolicyForUnique` to honor the new `validation.inputOnlyValidationForUpdate` option.                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `packages/schema/src/plugins/enhancer/enhance/index.ts`<br>`packages/schema/src/plugins/prisma/index.ts` | Refactored to support both legacy and new Prisma client generators using `getPrismaClientGenerator`; split client type processing logic for new/legacy generators; adjusted import paths and file handling accordingly.                                                                                                                                                                                                                                                                                                                                              |
| `packages/sdk/src/utils.ts`                                                                   | Added `getPrismaClientGenerator` utility and updated `getPreviewFeatures` to recognize both `"prisma-client-js"` and `"prisma-client"` providers.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `packages/schema/src/cli/actions/generate.ts`                                                 | Added explicit check for output path requirement when using the new Prisma client generator, throwing an error if missing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `packages/schema/src/cli/plugin-runner.ts`                                                    | Refined project emission logic to depend on output and compile options.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `packages/schema/src/language-server/zmodel-workspace-manager.ts`                             | Enhanced stdlib resolution to prefer installed zenstack package in workspace over bundled version.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `packages/plugins/tanstack-query/scripts/postbuild.js`                                        | Replaced external `replace-in-file` usage with a custom synchronous file replacement function.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `packages/plugins/tanstack-query/src/generator.ts`                                            | Adjusted logic to detect new Prisma client generator and issue warnings or generate bundled types accordingly.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `packages/schema/src/plugins/enhancer/policy/expression-writer.ts`<br>...<br>`schema-gen.ts`  | Updated imports for helper functions to use local helpers.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `tests/integration/tests/cli/generate.test.ts`                                                | Updated assertions to expect TypeScript (`.ts`) output files instead of JavaScript (`.js`) in custom output directories.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `tests/integration/tests/cli/plugins.test.ts`<br>`script/test-scaffold.ts`                    | Updated Prisma and `@prisma/client` dependency versions from `6.8.x` to `6.10.x`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `tests/integration/tests/misc/prisma-client-generator.test.ts`                                | Added new integration tests for the new Prisma client generator, including support for `auth()` in defaults and delegate models.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `tests/regression/tests/issue-2025.test.ts`                                                   | Added regression test verifying input-only validation for updates with new enhancement option.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `packages/testtools/src/schema.ts`                                                            | Deferred Prisma client loading until after compilation step in `loadSchema`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `packages/schema/src/plugins/prisma/schema-generator.ts`                                      | Broadened generator provider check to accept both `"prisma-client-js"` and `"prisma-client"`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `packages/schema/tests/schema/*`, `packages/schema/src/res/stdlib.zmodel`, etc.               | Whitespace and comment formatting cleanup in schema and grammar files.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant CLI
    participant SchemaLoader
    participant PrismaGenUtil
    participant Enhancer
    participant FileSystem

    CLI->>SchemaLoader: Load schema
    SchemaLoader->>PrismaGenUtil: getPrismaClientGenerator(model)
    PrismaGenUtil-->>SchemaLoader: { output, isNewGenerator, ... }
    SchemaLoader->>CLI: If isNewGenerator and no output, throw error

    CLI->>Enhancer: Run plugin enhancer
    Enhancer->>PrismaGenUtil: getPrismaClientGenerator(model)
    Enhancer->>FileSystem: If isNewGenerator, process model files in /models
    Enhancer->>FileSystem: Else, process index.d.ts
    FileSystem-->>Enhancer: Write transformed files
sequenceDiagram
    participant Runtime
    participant UserCode

    UserCode->>Runtime: Enhance PrismaClient({ validation: { inputOnlyValidationForUpdate } })
    UserCode->>Runtime: client.model.update(...)
    Runtime->>Runtime: If validation.inputOnlyValidationForUpdate is true, validate input only
    Runtime->>Runtime: Else, validate entire entity after update
    Runtime-->>UserCode: Return result or throw validation error
Loading

Possibly related PRs

  • zenstackhq/zenstack#2151: Implements support for the new "prisma-client" generator, including the getPrismaClientGenerator utility and logic branching for generator types—directly related to the generator and type processing refactor.
  • zenstackhq/zenstack#2152: Adds the inputOnlyValidationForUpdate enhancement option and corresponding validation logic, as well as the regression test for issue 2025—strong code-level connection.
  • zenstackhq/zenstack#2144: Replaces external utility imports with a consolidated local helper module and includes similar whitespace cleanups, indicating a direct relationship in code structure and import refactoring.


</details>

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

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


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between de7b2b8c4309657772e7f91211724b15d9d335ee and 8d118ee479da096835c5b37df14c880be65a87f5.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `packages/schema/src/cli/actions/init.ts` (1 hunks)

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (7)</summary>

* GitHub Check: OSSAR-Scan
* GitHub Check: dependency-review
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: build-test (20.x)
* GitHub Check: build-test (20.x)
* GitHub Check: OSSAR-Scan
* GitHub Check: Analyze (javascript-typescript)

</details>

<details>
<summary>🔇 Additional comments (1)</summary><blockquote>

<details>
<summary>packages/schema/src/cli/actions/init.ts (1)</summary>

`48-48`: **Verify the resource file exists at the new location.**

The filename change from `starter.zmodel` to `starter.txt` looks appropriate for a template file. However, ensure that the new resource file exists at the expected location to prevent runtime errors during project initialization.



```shell
#!/bin/bash
# Description: Verify the new resource file exists and check for any remaining references to the old filename.

# Check if the new resource file exists
echo "Checking if starter.txt exists:"
fd "starter.txt" --type f

# Check if the old resource file still exists (should be removed)
echo -e "\nChecking if old starter.zmodel still exists:"
fd "starter.zmodel" --type f

# Search for any remaining references to the old filename
echo -e "\nSearching for remaining references to 'starter.zmodel':"
rg "starter\.zmodel" --type ts --type js
✨ 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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
packages/plugins/tanstack-query/scripts/postbuild.js (1)

6-18: Consider adding basic error handling for file operations.

The custom replaceSync implementation correctly maintains the same functionality as the external library and follows good practices by only writing files when content actually changes. However, it lacks error handling for file system operations.

Consider adding basic error handling:

function replaceSync({ file, from, to }) {
    const paths = glob.sync(file, { ignore: [], nodir: true });

    paths.forEach(path => {
+       try {
            const contents = fs.readFileSync(path, { encoding: 'utf-8' });
            const newContents = contents.replace(from, to);

            if (newContents !== contents) {
                fs.writeFileSync(path, newContents, { encoding: 'utf-8' });
            }
+       } catch (error) {
+           console.error(`Error processing file ${path}:`, error.message);
+           throw error;
+       }
    });
}
packages/runtime/src/local-helpers/param-case.ts (1)

1-18: LGTM! Well-implemented param-case conversion utility.

The implementation correctly handles:

  • camelCase boundaries (([a-z0-9])([A-Z]))
  • Consecutive capitals (([A-Z])([A-Z][a-z]))
  • Non-alphanumeric character replacement
  • Proper trimming and joining with hyphens

The use of null character as internal delimiter is clever and safe since it won't appear in normal strings.

Consider adding JSDoc comments to document the function's behavior and some example transformations:

+/**
+ * Converts a string to param-case (kebab-case) format.
+ * @example
+ * paramCase('camelCase') // 'camel-case'
+ * paramCase('PascalCase') // 'pascal-case'
+ * paramCase('snake_case') // 'snake-case'
+ * paramCase('UPPER_CASE') // 'upper-case'
+ */
 export function paramCase(input: string) {
packages/runtime/src/local-helpers/is-plain-object.ts (1)

1-23: LGTM! Solid implementation of plain object detection.

The implementation correctly follows standard patterns for plain object detection:

  • Reliable type checking with Object.prototype.toString.call()
  • Proper handling of constructor and prototype chain
  • Correct logic for distinguishing plain objects from class instances

Consider adding type guards to improve type safety:

 export function isPlainObject(o: unknown) {
     if (isObject(o) === false) return false;
 
     // If has modified constructor
-    const ctor = (o as { constructor: unknown }).constructor;
+    const ctor = (o as Record<string, unknown>).constructor;
     if (ctor === undefined) return true;
 
     // If has modified prototype
-    const prot = (ctor as { prototype: unknown }).prototype;
+    const prot = typeof ctor === 'function' ? ctor.prototype : undefined;
     if (isObject(prot) === false) return false;
 
     // If constructor does not have an Object-specific method
-    if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf') === false) {
+    if (prot && Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf') === false) {
         return false;
     }
packages/schema/src/language-server/zmodel-workspace-manager.ts (1)

21-56: LGTM: Dynamic stdlib resolution logic is well-implemented.

The approach to dynamically locate stdlib from installed zenstack packages provides good flexibility. The fallback mechanism ensures robustness. However, remove the unnecessary continue statement.

Apply this diff to remove the unnecessary continue statement:

            } catch (error) {
                // Package not found or other error, continue to next folder
-                continue;
            }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 19f4870 and 6e147e9.

⛔ Files ignored due to path filters (26)
  • .github/workflows/github-releases-to-discord.yml is excluded by !**/*.yml
  • package.json is excluded by !**/*.json
  • packages/ide/jetbrains/package.json is excluded by !**/*.json
  • packages/language/package.json is excluded by !**/*.json
  • packages/misc/redwood/package.json is excluded by !**/*.json
  • packages/plugins/openapi/package.json is excluded by !**/*.json
  • packages/plugins/openapi/tests/baseline/rest-3.1.0.baseline.yaml is excluded by !**/*.yaml
  • packages/plugins/swr/package.json is excluded by !**/*.json
  • packages/plugins/tanstack-query/package.json is excluded by !**/*.json
  • packages/plugins/trpc/package.json is excluded by !**/*.json
  • packages/plugins/trpc/tests/projects/nuxt-trpc-v10/package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • packages/plugins/trpc/tests/projects/nuxt-trpc-v10/package.json is excluded by !**/*.json
  • packages/plugins/trpc/tests/projects/nuxt-trpc-v11/package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • packages/plugins/trpc/tests/projects/nuxt-trpc-v11/package.json is excluded by !**/*.json
  • packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json is excluded by !**/*.json
  • packages/plugins/trpc/tests/projects/t3-trpc-v11/package.json is excluded by !**/*.json
  • packages/runtime/package.json is excluded by !**/*.json
  • packages/schema/package.json is excluded by !**/*.json
  • packages/sdk/package.json is excluded by !**/*.json
  • packages/server/package.json is excluded by !**/*.json
  • packages/testtools/package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml
  • tests/integration/package.json is excluded by !**/*.json
  • tests/integration/test-run/package.json is excluded by !**/*.json
  • tests/integration/tests/frameworks/nextjs/test-project/package.json is excluded by !**/*.json
  • tests/integration/tests/frameworks/trpc/test-project/package.json is excluded by !**/*.json
📒 Files selected for processing (61)
  • packages/ide/jetbrains/build.gradle.kts (1 hunks)
  • packages/language/src/zmodel.langium (3 hunks)
  • packages/plugins/openapi/src/rest-generator.ts (1 hunks)
  • packages/plugins/openapi/src/rpc-generator.ts (1 hunks)
  • packages/plugins/swr/src/generator.ts (1 hunks)
  • packages/plugins/swr/src/runtime/index.ts (1 hunks)
  • packages/plugins/swr/tests/react-hooks.test.tsx (1 hunks)
  • packages/plugins/tanstack-query/scripts/postbuild.js (1 hunks)
  • packages/plugins/tanstack-query/src/generator.ts (2 hunks)
  • packages/plugins/trpc/src/client-helper/index.ts (1 hunks)
  • packages/plugins/trpc/src/generator.ts (2 hunks)
  • packages/plugins/trpc/src/utils.ts (1 hunks)
  • packages/runtime/src/cross/clone.ts (1 hunks)
  • packages/runtime/src/cross/model-meta.ts (1 hunks)
  • packages/runtime/src/cross/query-analyzer.ts (1 hunks)
  • packages/runtime/src/cross/utils.ts (1 hunks)
  • packages/runtime/src/enhancements/node/delegate.ts (1 hunks)
  • packages/runtime/src/enhancements/node/policy/handler.ts (1 hunks)
  • packages/runtime/src/enhancements/node/policy/policy-utils.ts (2 hunks)
  • packages/runtime/src/local-helpers/index.ts (1 hunks)
  • packages/runtime/src/local-helpers/is-plain-object.ts (1 hunks)
  • packages/runtime/src/local-helpers/lower-case-first.ts (1 hunks)
  • packages/runtime/src/local-helpers/param-case.ts (1 hunks)
  • packages/runtime/src/local-helpers/sleep.ts (1 hunks)
  • packages/runtime/src/local-helpers/tiny-invariant.ts (1 hunks)
  • packages/runtime/src/local-helpers/upper-case-first.ts (1 hunks)
  • packages/runtime/src/types.ts (2 hunks)
  • packages/schema/src/cli/actions/generate.ts (2 hunks)
  • packages/schema/src/cli/plugin-runner.ts (2 hunks)
  • packages/schema/src/language-server/zmodel-workspace-manager.ts (2 hunks)
  • packages/schema/src/plugins/enhancer/enhance/checker-type-generator.ts (1 hunks)
  • packages/schema/src/plugins/enhancer/enhance/index.ts (9 hunks)
  • packages/schema/src/plugins/enhancer/policy/expression-writer.ts (1 hunks)
  • packages/schema/src/plugins/enhancer/policy/policy-guard-generator.ts (1 hunks)
  • packages/schema/src/plugins/prisma/index.ts (4 hunks)
  • packages/schema/src/plugins/prisma/schema-generator.ts (3 hunks)
  • packages/schema/src/plugins/zod/generator.ts (1 hunks)
  • packages/schema/src/plugins/zod/index.ts (1 hunks)
  • packages/schema/src/plugins/zod/transformer.ts (1 hunks)
  • packages/schema/src/plugins/zod/utils/schema-gen.ts (1 hunks)
  • packages/schema/src/res/stdlib.zmodel (6 hunks)
  • packages/schema/src/telemetry.ts (1 hunks)
  • packages/schema/tests/schema/all-features.zmodel (2 hunks)
  • packages/schema/tests/schema/todo.zmodel (2 hunks)
  • packages/sdk/src/dmmf-helpers/aggregate-helpers.ts (1 hunks)
  • packages/sdk/src/model-meta-generator.ts (1 hunks)
  • packages/sdk/src/utils.ts (2 hunks)
  • packages/server/src/api/rest/index.ts (1 hunks)
  • packages/server/src/api/rpc/index.ts (1 hunks)
  • packages/server/src/nestjs/interfaces/api-handler-options.interface.ts (1 hunks)
  • packages/testtools/src/db.ts (1 hunks)
  • packages/testtools/src/schema.ts (2 hunks)
  • script/test-scaffold.ts (1 hunks)
  • tests/integration/tests/cli/generate.test.ts (2 hunks)
  • tests/integration/tests/cli/plugins.test.ts (2 hunks)
  • tests/integration/tests/misc/prisma-client-generator.test.ts (1 hunks)
  • tests/integration/tests/schema/petstore.zmodel (3 hunks)
  • tests/integration/tests/schema/refactor-pg.zmodel (5 hunks)
  • tests/integration/tests/schema/todo-pg.zmodel (1 hunks)
  • tests/integration/tests/schema/todo.zmodel (1 hunks)
  • tests/regression/tests/issue-2025.test.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/schema/src/language-server/zmodel-workspace-manager.ts

[error] 44-44: Unnecessary continue statement

Unsafe fix: Delete the unnecessary continue statement

(lint/correctness/noUnnecessaryContinue)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-test (20.x)
  • GitHub Check: build-test (20.x)
  • GitHub Check: dependency-review
  • GitHub Check: build-test (20.x)
  • GitHub Check: OSSAR-Scan
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (87)
packages/server/src/nestjs/interfaces/api-handler-options.interface.ts (1)

8-8: Remove trailing spaces in comment. The formatting cleanup on the example annotation (e.g.) is consistent with project style and has no functional impact.

packages/testtools/src/db.ts (1)

10-12: Formatting cleanup only
Whitespace around the object literal keys/braces has been standardized. No behavioral changes.

packages/plugins/tanstack-query/scripts/postbuild.js (2)

3-4: LGTM: Clean import of standard Node.js modules.

The imports for fs and glob are appropriate for the custom implementation.


22-47: LGTM: Function calls correctly updated to use custom implementation.

The parameter renaming from files to file and the function name change from replace.sync to replaceSync are consistent and maintain the same functionality. All regex patterns and replacement logic are preserved.

packages/ide/jetbrains/build.gradle.kts (1)

88-88: Whitespace cleanup in changelog introduction.
Removed trailing spaces from the introduction string; no functional or behavioral changes.

script/test-scaffold.ts (1)

22-22: Updated Prisma package versions.
Bumped prisma and @prisma/client from 6.8.x to 6.10.x to align with the new Prisma client generator support. No other logic was altered.

tests/integration/tests/schema/petstore.zmodel (1)

18-18: Removed trailing whitespace.
This is a pure formatting cleanup—no changes to model definitions, fields, or authorization rules.

Also applies to: 21-21, 34-34, 52-52

tests/integration/tests/schema/todo.zmodel (1)

117-117: Removed trailing whitespace in authorization comment.
Formatting-only adjustment; logic remains unchanged.

packages/schema/tests/schema/todo.zmodel (1)

126-126: Removed trailing whitespace lines.
Whitespace cleanup without any impact on the schema or permissions.

Also applies to: 182-182

tests/integration/tests/schema/refactor-pg.zmodel (5)

13-13: Remove trailing whitespace.

Cleaned up an extraneous blank line in the User model. No functional changes.


33-33: Remove trailing whitespace.

Cleaned up an extraneous blank line in the Profile model. No functional changes.


36-36: Remove trailing whitespace.

Cleaned up an extraneous blank line before the update permission in Profile. No functional changes.


79-79: Remove trailing whitespace.

Cleaned up an extraneous blank line in the Comment model. No functional changes.


88-88: Remove trailing whitespace.

Cleaned up an extraneous blank line before the final policy in Comment. No functional changes.

tests/integration/tests/schema/todo-pg.zmodel (1)

106-106: Remove trailing space in comment.

Fixed a trailing space in the read-permission comment of the List model. No functional impact.

packages/language/src/zmodel.langium (3)

167-167: Remove trailing whitespace.

Cleaned up trailing whitespace in the DataModel rule. No grammar changes.


196-196: Remove trailing whitespace.

Cleaned up trailing whitespace in the TypeDefField rule. No grammar changes.


211-211: Remove trailing whitespace.

Cleaned up trailing whitespace in the Enum rule. No grammar changes.

packages/schema/tests/schema/all-features.zmodel (2)

136-136: Remove trailing whitespace in comment.

Fixed a trailing space in the read-permission comment of the List model. No functional changes.


190-190: Add newline at EOF.

Ensured a newline at end-of-file for POSIX compliance. No logic impact.

packages/schema/src/res/stdlib.zmodel (5)

28-28: Remove trailing whitespace.

Cleaned up trailing whitespace after the SetNull enum entry.


113-113: Remove trailing whitespace.

Cleaned up trailing whitespace in the documentation for autoincrement().


185-185: Remove trailing whitespace.

Cleaned up trailing whitespace in the currentModel doc comment.


215-215: Remove trailing whitespace.

Cleaned up trailing whitespace in the @allow field-level policy documentation.


588-588: Remove trailing whitespace.

Cleaned up trailing whitespace in the @encrypted doc comment.

packages/runtime/src/local-helpers/tiny-invariant.ts (1)

1-17: LGTM! Clean implementation of invariant utility.

The implementation correctly handles both production and development modes, uses proper TypeScript assertion syntax, and provides clear error messages. The early return for truthy conditions is efficient.

Note that this implementation assumes a Node.js environment (using process.env.NODE_ENV), which should be fine given this is part of the runtime package.

tests/integration/tests/cli/generate.test.ts (2)

71-74: LGTM! Test expectations correctly updated for TypeScript output.

The test correctly expects .ts files to exist and .js files to not exist, aligning with the new generator behavior that produces TypeScript files instead of JavaScript.


88-91: LGTM! Consistent test expectations for TypeScript output.

The test changes are consistent with the other custom output test, correctly expecting TypeScript files and ensuring JavaScript files don't exist.

packages/runtime/src/types.ts (2)

144-147: LGTM! Clean integration of validation options.

The new validation property is properly typed as optional and follows the established pattern in EnhancementOptions.


218-233: LGTM! Well-documented validation options type.

The ValidationOptions type is clearly documented with:

  • Comprehensive explanation of the behavioral difference
  • Clear default value specification
  • Good explanation of when to use the option

The property name inputOnlyValidationForUpdate is descriptive and self-explanatory.

packages/schema/src/language-server/zmodel-workspace-manager.ts (1)

4-4: LGTM: fs import addition is appropriate.

The fs import is correctly added to support the new file system operations for stdlib path resolution.

packages/runtime/src/cross/query-analyzer.ts (1)

2-2: LGTM: Import refactoring aligns with dependency consolidation effort.

The change from external package to local helpers is part of the broader refactoring to reduce external dependencies and centralize utility functions.

packages/runtime/src/cross/utils.ts (1)

1-1: LGTM: Import refactoring aligns with dependency consolidation effort.

The change from external package to local helpers is consistent with the broader refactoring to reduce external dependencies and centralize utility functions.

packages/runtime/src/cross/model-meta.ts (1)

1-1: LGTM: Import refactoring aligns with dependency consolidation effort.

The change from external package to local helpers is consistent with the systematic refactoring to reduce external dependencies and centralize utility functions.

packages/schema/src/telemetry.ts (1)

3-3: LGTM: Import refactoring aligns with dependency consolidation effort.

The change from external package to local helpers is part of the broader refactoring to reduce external dependencies and centralize utility functions.

packages/plugins/swr/src/runtime/index.ts (1)

10-10: Import utility from centralized helper module
Switching lowerCaseFirst to @zenstackhq/runtime/local-helpers aligns with the new consolidation of utility functions. Ensure that this module exports lowerCaseFirst as expected.

packages/schema/src/plugins/enhancer/enhance/checker-type-generator.ts (1)

3-3: Use centralized lowerCaseFirst import
Refactoring to import lowerCaseFirst from the local helper maintains consistency across packages. Confirm the helper barrel re-exports this function.

packages/schema/src/plugins/zod/utils/schema-gen.ts (1)

14-14: Centralize upperCaseFirst import
Adopting the local helper import for upperCaseFirst standardizes utilities. Verify it’s correctly exported from @zenstackhq/runtime/local-helpers.

packages/sdk/src/dmmf-helpers/aggregate-helpers.ts (1)

1-1: Consolidate upperCaseFirst import
Importing upperCaseFirst from the internal helper module follows the refactoring pattern. Ensure the helper module’s barrel includes this export.

packages/runtime/src/cross/clone.ts (1)

1-1: Switch isPlainObject to local helper
Replacing the external is-plain-object with the in-repo helper reduces dependencies. Confirm that ../local-helpers exposes isPlainObject and consider matching the import style used elsewhere.

packages/server/src/api/rpc/index.ts (1)

10-10: Consistent internal helper import.

The upperCaseFirst import has been correctly updated to use the unified internal helper module, matching the refactoring across the codebase.

packages/schema/src/plugins/enhancer/policy/policy-guard-generator.ts (1)

34-34: Unified utility import.

Switching lowerCaseFirst to the central @zenstackhq/runtime/local-helpers aligns with the new internal helpers consolidation without altering functionality.

packages/sdk/src/model-meta-generator.ts (1)

20-20: Updated to internal helper.

Importing lowerCaseFirst from the consolidated local-helpers module is correct and maintains existing behavior.

packages/schema/src/plugins/zod/generator.ts (1)

29-29: Standardized helper import.

The upperCaseFirst import now consistently references the internal helper library, matching the refactoring in other modules.

packages/plugins/swr/tests/react-hooks.test.tsx (1)

10-10: Consistent test utility import.

Switching the test’s lowerCaseFirst import to the internal helper path keeps the test aligned with the refactored helpers.

packages/plugins/trpc/src/utils.ts (1)

2-2: Good consolidation of utility imports.

The import consolidation from external packages to the internal helper module aligns with the broader refactoring effort and should reduce dependency overhead.

Please verify that the internal helper functions are properly implemented and compatible with the external ones:

#!/bin/bash
# Description: Verify that lowerCaseFirst and upperCaseFirst functions are available in the internal helper module

# Check if the internal helper module exists and exports the required functions
rg -A 5 "export.*lowerCaseFirst|export.*upperCaseFirst" --type ts
packages/schema/src/plugins/zod/transformer.ts (1)

15-15: Import consolidation looks good.

The change from external package to internal helper module is consistent with the broader refactoring effort. The upperCaseFirst function is used extensively throughout the file, so this consolidation should provide better control over the utility implementation.

Please verify that the upperCaseFirst function is properly exported from the internal helper module:

#!/bin/bash
# Description: Verify that upperCaseFirst function is available and properly implemented in the internal helper module

# Check the internal helper module implementation
rg -A 10 "export.*upperCaseFirst" --type ts packages/runtime/src/local-helpers

# Verify all import statements have been updated consistently across the codebase
rg "from ['\"]upper-case-first['\"]" --type ts
packages/runtime/src/enhancements/node/policy/handler.ts (1)

18-18: Import utility functions from local helpers
Centralizes external dependencies by sourcing lowerCaseFirst, upperCaseFirst, and invariant from the internal helpers module.

packages/schema/src/plugins/zod/index.ts (1)

2-2: Switch invariant import to local helpers
Aligns with the new consolidated helper module by importing invariant from @zenstackhq/runtime/local-helpers.

packages/schema/src/plugins/enhancer/policy/expression-writer.ts (1)

39-39: Use internal helper imports
Refactors imports for lowerCaseFirst and invariant to the centralized @zenstackhq/runtime/local-helpers.

tests/integration/tests/cli/plugins.test.ts (2)

78-78: Bump @prisma/client to 6.10.x
Updates the runtime dependency to match the upgraded Prisma version across the codebase.


88-88: Bump prisma dev dependency to 6.10.x
Updates the development dependency to stay in sync with the Prisma client version.

packages/runtime/src/local-helpers/sleep.ts (1)

1-5: Add sleep utility function
Introduces an async sleep helper returning a Promise<void>, enabling delay behavior.

packages/runtime/src/enhancements/node/delegate.ts (1)

17-17: Consolidated utility import
Replaced external imports of isPlainObject and lowerCaseFirst with the internal local-helpers module. This centralizes helper functions and removes a direct dependency on third-party packages.

packages/plugins/swr/src/generator.ts (1)

15-15: Unified import for case utilities
Switched to importing both upperCaseFirst and paramCase from the single @zenstackhq/runtime/local-helpers module to align with the internalization strategy.

packages/plugins/trpc/src/client-helper/index.ts (1)

3-3: Centralize casing helpers
Now pulling lowerCaseFirst and upperCaseFirst from the shared local-helpers entry point, reducing external dependencies and ensuring consistency.

packages/server/src/api/rest/index.ts (1)

13-13: Consolidate external utility imports.

The distinct imports for lowerCaseFirst, upperCaseFirst, and paramCase have been unified under the internal @zenstackhq/runtime/local-helpers module, reducing external dependencies. Ensure that this helper module re-exports all three utilities and that no leftover external imports remain.

packages/runtime/src/local-helpers/upper-case-first.ts (1)

1-3: Implement upperCaseFirst helper.

The function correctly capitalizes the first character and preserves the remainder. It also implicitly handles empty strings by returning an empty string.

packages/runtime/src/local-helpers/lower-case-first.ts (1)

1-3: Implement lowerCaseFirst helper.

The function correctly lowercases the first character and preserves the remainder, mirroring upperCaseFirst’s pattern. Empty inputs yield the original string.

packages/plugins/openapi/src/rest-generator.ts (1)

29-29: Switch to internal invariant and lowerCaseFirst imports.

Replacing external tiny-invariant and lower-case-first with the local-helpers versions aligns with the consolidation strategy. Confirm that invariant is correctly implemented and re-exported in the helper index, and that all references are updated consistently.

packages/plugins/openapi/src/rpc-generator.ts (1)

14-14: LGTM! Excellent import consolidation.

This change successfully consolidates utility function imports from multiple external packages (lower-case-first, upper-case-first, tiny-invariant) into the new centralized local helpers module. This reduces external dependencies and improves maintainability across the codebase.

packages/plugins/trpc/src/generator.ts (2)

15-15: LGTM! Import consolidation aligns with architectural improvements.

The consolidation of lowerCaseFirst and upperCaseFirst imports to the local helpers module is consistent with the broader refactoring effort to reduce external dependencies and centralize utility functions.


171-176: LGTM! Clean formatting improvements.

The whitespace cleanup in the template literal improves code formatting consistency without affecting functionality.

packages/runtime/src/local-helpers/index.ts (1)

1-6: LGTM! Excellent centralization of utility functions.

This new module provides a clean, centralized entry point for utility functions that were previously imported from various external packages. The re-export pattern enables the import consolidation effort across the codebase while reducing external dependencies and improving maintainability.

packages/testtools/src/schema.ts (1)

307-327: LGTM! Improved execution order for Prisma client initialization.

Moving the Prisma client initialization to occur after TypeScript compilation is a logical improvement that ensures all generated files and dependencies are properly set up before client instantiation. This change aligns well with the enhanced Prisma client generator support and improves the reliability of the schema loading process.

packages/schema/src/cli/plugin-runner.ts (1)

448-448: LGTM! Refined condition improves compilation logic.

The updated condition provides more precise control over when to emit versus save the project during compilation. This refinement aligns with the enhanced Prisma client generation and output path handling, ensuring correct behavior across different compilation scenarios.

packages/runtime/src/enhancements/node/policy/policy-utils.ts (2)

18-18: LGTM! Import consolidation follows project-wide refactoring.

The import change from external packages to the local helper module aligns with the broader effort to centralize utility functions across the codebase.


940-951: LGTM! Validation behavior properly controlled by new enhancement option.

The conditional validation logic correctly implements the new inputOnlyValidationForUpdate option. When enabled, schema validation is skipped during update operations, allowing for more flexible validation behavior as intended by the feature.

packages/schema/src/cli/actions/generate.ts (2)

1-1: LGTM! Import addition supports new generator validation.

The import of getPrismaClientGenerator enables the validation logic for the new Prisma client generator.


73-83: LGTM! Proper validation for new Prisma client generator usage.

The validation correctly enforces that the new "prisma-client" generator requires an explicit output path, preventing potential configuration issues. The error messages are clear and actionable.

tests/regression/tests/issue-2025.test.ts (1)

1-42: LGTM! Comprehensive regression test for validation behavior.

The test effectively verifies the new inputOnlyValidationForUpdate option:

  1. Creates a user with invalid email (bypassing validation on creation)
  2. Tests update with inputOnlyValidationForUpdate: true - should succeed
  3. Tests update with default settings - should be rejected by policy

This properly covers both code paths and confirms the expected behavior change.

packages/plugins/tanstack-query/src/generator.ts (2)

9-9: LGTM! Import consolidation aligns with project-wide refactoring.

The imports from @zenstackhq/sdk and @zenstackhq/runtime/local-helpers follow the broader effort to centralize utility functions and add new generator support.

Also applies to: 17-17


71-78: LGTM! Proper handling of portable option with new generator.

The logic correctly:

  1. Detects the new Prisma client generator using getPrismaClientGenerator
  2. Issues a helpful warning that the portable option is unsupported
  3. Falls back to generating bundled types for the legacy generator

This maintains backward compatibility while clearly communicating limitations.

packages/schema/src/plugins/prisma/index.ts (4)

5-5: LGTM! Import addition enables refactored generator handling.

The import of getPrismaClientGenerator supports the simplified generator extraction logic.


60-63: LGTM! Simplified generator extraction using utility function.

The refactored code replaces manual AST traversal with the utility function, making the code cleaner and more maintainable while providing the same functionality.


79-82: LGTM! Correct import path handling for new generator.

The logic properly appends "/client" to the import path when the new "prisma-client" generator is detected, reflecting the new import structure requirements.


92-92: LGTM! Appropriate type resolution logic for new generator.

The condition correctly skips the fallback node module resolution for the new generator, preventing unnecessary resolution attempts that would fail for the new generator structure.

packages/sdk/src/utils.ts (1)

691-714: LGTM! Well-structured utility function.

The new getPrismaClientGenerator function properly detects both legacy and new Prisma client generators and provides comprehensive information about the generator configuration.

packages/schema/src/plugins/prisma/schema-generator.ts (2)

48-50: LGTM! Import consolidation aligns with PR objectives.

The reorganization of imports to use local helper modules is consistent with the broader refactoring effort across the codebase.


236-239: LGTM! Correctly handles both Prisma client generators.

The expanded condition properly checks for both legacy ('prisma-client-js') and new ('prisma-client') generator providers using JSON-stringified values, which aligns with how these values are stored.

tests/integration/tests/misc/prisma-client-generator.test.ts (1)

1-124: LGTM! Comprehensive test coverage for the new Prisma client generator.

The test suite provides good coverage for the new Prisma client generator functionality, including:

  • Testing auth() in @default attribute behavior
  • Testing delegate models with model inheritance
  • Proper setup with inline TypeScript source files

The tests effectively validate the new generator's behavior and integration with ZenStack enhancements.

packages/schema/src/plugins/enhancer/enhance/index.ts (6)

10-10: LGTM! Import updates align with the refactoring objectives.

The changes properly integrate the new getPrismaClientGenerator utility and use local helpers consistently.

Also applies to: 29-29


58-58: LGTM! Path normalization improves clarity.

Removing the leading dot from the path makes it more standard and less ambiguous.


116-118: LGTM! Correctly handles the new generator's output structure.

The code properly appends '/client' to the import path when the new Prisma client generator is detected, aligning with its different output directory structure.


445-450: LGTM! Improved error handling and code reuse.

The refactored method properly uses the new utility function and provides a clearer error message that mentions both supported generator types.


464-518: LGTM! Well-structured handling of different generator outputs.

The implementation elegantly handles the distinct output structures:

  • Legacy generator: Single index.d.ts file
  • New generator: Individual model files under models/ directory

The code properly transforms interfaces and type aliases while maintaining backward compatibility.


953-956: LGTM! Clean encapsulation of generator type check.

The getter provides a clear and reusable way to check if the new Prisma client generator is being used.

@ymc9 ymc9 merged commit 9596d33 into main Jun 21, 2025
13 of 14 checks passed
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.

3 participants