-
-
Couldn't load subscription status.
- Fork 126
merge dev to main (v2.16.0) #2156
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
Co-authored-by: Yiming <yiming@whimslab.io>
… and remove some spaces (#2144) Co-authored-by: Yiming Cao <yiming@whimslab.io>
📝 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 filessequenceDiagram
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
Possibly related PRs
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
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: 1
🧹 Nitpick comments (4)
packages/plugins/tanstack-query/scripts/postbuild.js (1)
6-18: Consider adding basic error handling for file operations.The custom
replaceSyncimplementation 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
⛔ Files ignored due to path filters (26)
.github/workflows/github-releases-to-discord.ymlis excluded by!**/*.ymlpackage.jsonis excluded by!**/*.jsonpackages/ide/jetbrains/package.jsonis excluded by!**/*.jsonpackages/language/package.jsonis excluded by!**/*.jsonpackages/misc/redwood/package.jsonis excluded by!**/*.jsonpackages/plugins/openapi/package.jsonis excluded by!**/*.jsonpackages/plugins/openapi/tests/baseline/rest-3.1.0.baseline.yamlis excluded by!**/*.yamlpackages/plugins/swr/package.jsonis excluded by!**/*.jsonpackages/plugins/tanstack-query/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/tests/projects/nuxt-trpc-v10/package-lock.jsonis excluded by!**/package-lock.json,!**/*.jsonpackages/plugins/trpc/tests/projects/nuxt-trpc-v10/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/tests/projects/nuxt-trpc-v11/package-lock.jsonis excluded by!**/package-lock.json,!**/*.jsonpackages/plugins/trpc/tests/projects/nuxt-trpc-v11/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/tests/projects/t3-trpc-v10/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/tests/projects/t3-trpc-v11/package.jsonis excluded by!**/*.jsonpackages/runtime/package.jsonis excluded by!**/*.jsonpackages/schema/package.jsonis excluded by!**/*.jsonpackages/sdk/package.jsonis excluded by!**/*.jsonpackages/server/package.jsonis excluded by!**/*.jsonpackages/testtools/package.jsonis excluded by!**/*.jsonpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!**/*.yamltests/integration/package.jsonis excluded by!**/*.jsontests/integration/test-run/package.jsonis excluded by!**/*.jsontests/integration/tests/frameworks/nextjs/test-project/package.jsonis excluded by!**/*.jsontests/integration/tests/frameworks/trpc/test-project/package.jsonis 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
fsandglobare appropriate for the custom implementation.
22-47: LGTM: Function calls correctly updated to use custom implementation.The parameter renaming from
filestofileand the function name change fromreplace.synctoreplaceSyncare 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.
Bumpedprismaand@prisma/clientfrom6.8.xto6.10.xto 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
Usermodel. No functional changes.
33-33: Remove trailing whitespace.Cleaned up an extraneous blank line in the
Profilemodel. 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
Commentmodel. 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
Listmodel. No functional impact.packages/language/src/zmodel.langium (3)
167-167: Remove trailing whitespace.Cleaned up trailing whitespace in the
DataModelrule. No grammar changes.
196-196: Remove trailing whitespace.Cleaned up trailing whitespace in the
TypeDefFieldrule. No grammar changes.
211-211: Remove trailing whitespace.Cleaned up trailing whitespace in the
Enumrule. 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
Listmodel. 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
SetNullenum 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
currentModeldoc comment.
215-215: Remove trailing whitespace.Cleaned up trailing whitespace in the
@allowfield-level policy documentation.
588-588: Remove trailing whitespace.Cleaned up trailing whitespace in the
@encrypteddoc 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
.tsfiles to exist and.jsfiles 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
validationproperty is properly typed as optional and follows the established pattern inEnhancementOptions.
218-233: LGTM! Well-documented validation options type.The
ValidationOptionstype 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
inputOnlyValidationForUpdateis 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
SwitchinglowerCaseFirstto@zenstackhq/runtime/local-helpersaligns with the new consolidation of utility functions. Ensure that this module exportslowerCaseFirstas expected.packages/schema/src/plugins/enhancer/enhance/checker-type-generator.ts (1)
3-3: Use centralizedlowerCaseFirstimport
Refactoring to importlowerCaseFirstfrom 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: CentralizeupperCaseFirstimport
Adopting the local helper import forupperCaseFirststandardizes utilities. Verify it’s correctly exported from@zenstackhq/runtime/local-helpers.packages/sdk/src/dmmf-helpers/aggregate-helpers.ts (1)
1-1: ConsolidateupperCaseFirstimport
ImportingupperCaseFirstfrom 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: SwitchisPlainObjectto local helper
Replacing the externalis-plain-objectwith the in-repo helper reduces dependencies. Confirm that../local-helpersexposesisPlainObjectand consider matching the import style used elsewhere.packages/server/src/api/rpc/index.ts (1)
10-10: Consistent internal helper import.The
upperCaseFirstimport 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
lowerCaseFirstto the central@zenstackhq/runtime/local-helpersaligns with the new internal helpers consolidation without altering functionality.packages/sdk/src/model-meta-generator.ts (1)
20-20: Updated to internal helper.Importing
lowerCaseFirstfrom 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
upperCaseFirstimport 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
lowerCaseFirstimport 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 tspackages/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
upperCaseFirstfunction is used extensively throughout the file, so this consolidation should provide better control over the utility implementation.Please verify that the
upperCaseFirstfunction 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 tspackages/runtime/src/enhancements/node/policy/handler.ts (1)
18-18: Import utility functions from local helpers
Centralizes external dependencies by sourcinglowerCaseFirst,upperCaseFirst, andinvariantfrom 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 importinginvariantfrom@zenstackhq/runtime/local-helpers.packages/schema/src/plugins/enhancer/policy/expression-writer.ts (1)
39-39: Use internal helper imports
Refactors imports forlowerCaseFirstandinvariantto 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 asyncsleephelper returning aPromise<void>, enabling delay behavior.packages/runtime/src/enhancements/node/delegate.ts (1)
17-17: Consolidated utility import
Replaced external imports ofisPlainObjectandlowerCaseFirstwith the internallocal-helpersmodule. 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 bothupperCaseFirstandparamCasefrom the single@zenstackhq/runtime/local-helpersmodule to align with the internalization strategy.packages/plugins/trpc/src/client-helper/index.ts (1)
3-3: Centralize casing helpers
Now pullinglowerCaseFirstandupperCaseFirstfrom the sharedlocal-helpersentry 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-helpersmodule, 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: ImplementupperCaseFirsthelper.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: ImplementlowerCaseFirsthelper.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 internalinvariantandlowerCaseFirstimports.Replacing external
tiny-invariantandlower-case-firstwith the local-helpers versions aligns with the consolidation strategy. Confirm thatinvariantis 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
lowerCaseFirstandupperCaseFirstimports 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
inputOnlyValidationForUpdateoption. 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
getPrismaClientGeneratorenables 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
inputOnlyValidationForUpdateoption:
- Creates a user with invalid email (bypassing validation on creation)
- Tests update with
inputOnlyValidationForUpdate: true- should succeed- 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/sdkand@zenstackhq/runtime/local-helpersfollow 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:
- Detects the new Prisma client generator using
getPrismaClientGenerator- Issues a helpful warning that the portable option is unsupported
- 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
getPrismaClientGeneratorsupports 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
getPrismaClientGeneratorfunction 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@defaultattribute 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
getPrismaClientGeneratorutility 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.tsfile- New generator: Individual model files under
models/directoryThe 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.
No description provided.