Skip to content

chore: replace some unused/small/deprecated/long-updated dependencies and remove some spaces #2144

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

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from

Conversation

DoctorFTB
Copy link
Contributor

  1. Replaced dependencies:

    • replace-in-file - most of the functionality is not used, its 15 lines code

    • change-case - most of the functionality is not used, v4 (currently used in project) depends on 12 more libraries, used many libraries inside (change-case -> param-case -> dot-case -> no-case -> lower-case), its 15 lines code

    • lower-case-first - deprecated

    • upper-case-first - deprecated

    • tiny-invariant - small library

    • is-plain-object - small library

    • sleep-promise - small library

    • jest-fetch-mock - unused

    • ts-node - unused (calle one once via npx)

  2. About packages:

    • pnpm install show Packages: +16 -189
  3. Move dependencies "decimal.js-light", "superjson" and "uuid" from dependencies to devDependencies in runtime, cuz used only for build

  4. Remove spaces on empty lines or before next line.

Feel free to ask questions and discuss :)

P.S. Code was not tested locally. I got stuck after tests ate 150 GB of disk space.

Copy link
Contributor

coderabbitai bot commented Jun 10, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This change introduces a new internal utility module that consolidates various helper functions previously sourced from multiple external packages. All relevant imports across the codebase are updated to use this new local helper module. The update also includes the implementation of several new utility functions, minor formatting corrections, and removal of trailing whitespace in numerous files. No changes are made to business logic or public APIs except for the addition of new utility exports.

Changes

File(s) Change Summary
packages/runtime/src/local-helpers/ (all new files), packages/runtime/src/local-helpers.ts, packages/runtime/src/local-helpers/index.ts Introduced new internal utility module aggregating and implementing helpers: sleep, isPlainObject, lowerCaseFirst, upperCaseFirst, paramCase, invariant. Added re-exports for centralized access.
Multiple files across packages/plugins, packages/runtime, packages/schema, packages/sdk, packages/server, packages/testtools, packages/language Updated imports to use new local helper module instead of external packages for utility functions. No code logic changed.
packages/plugins/tanstack-query/scripts/postbuild.js Replaced dependency on replace-in-file with a custom synchronous file replacement function using fs and glob.
packages/ide/jetbrains/build.gradle.kts, .zmodel and .ts files in various tests/ and packages/schema/, packages/testtools/src/schema.ts, packages/testtools/src/db.ts Removed trailing whitespace, corrected comment formatting, and made minor style adjustments. No logic affected.

Sequence Diagram(s)

sequenceDiagram
    participant Consumer as Any Module (e.g., plugins, schema, server)
    participant LocalHelpers as @zenstackhq/runtime/local-helpers
    participant HelperImpl as Helper Implementation (e.g., lowerCaseFirst, invariant)

    Consumer->>LocalHelpers: import { lowerCaseFirst, ... } from '@zenstackhq/runtime/local-helpers'
    LocalHelpers->>HelperImpl: re-export utility functions
    Consumer->>HelperImpl: use utility function (e.g., lowerCaseFirst(input))
Loading
sequenceDiagram
    participant PostbuildScript as postbuild.js
    participant FS as fs
    participant Glob as glob

    PostbuildScript->>Glob: Find files matching pattern
    loop For each matched file
        PostbuildScript->>FS: Read file contents
        PostbuildScript->>FS: Replace text using regex
        alt If changes detected
            PostbuildScript->>FS: Write updated contents
        end
    end
Loading

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: 3

🧹 Nitpick comments (11)
packages/runtime/src/local-helpers/sleep.ts (1)

1-5: Add explicit return type & tiny style polish

A couple of very small tweaks improve clarity and align with typical style:

-export function sleep(timeout: number) {
-    return new Promise<void>((resolve) => {
-        setTimeout(() => resolve(), timeout);
-    })
+export function sleep(timeout: number): Promise<void> {
+    return new Promise<void>(resolve => {
+        setTimeout(resolve, timeout);
+    });
 }

Reasons:

  1. Explicit : Promise<void> makes the API contract unmistakable.
  2. Arrow-function shorthand (setTimeout(resolve, timeout)) is marginally leaner.
  3. Ending semicolon keeps consistency with the majority of the codebase.

Purely cosmetic; adopt if it fits project conventions.

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

538-546: Typo in comment: “thrid” → “third”

Small spelling glitch in the docs—worth correcting to keep generated documentation professional.

- * You can pass a thrid argument as `true` to make it override the model-level policies.
+ * You can pass a third argument as `true` to make it override the model-level policies.
packages/runtime/src/local-helpers/tiny-invariant.ts (1)

4-17: Optional: accept a lazy message to avoid needless string work

In hot paths callers often build error strings unconditionally.
Allowing message to be a thunk keeps production builds lean without impacting DX.

-export function invariant(
-    condition: unknown,
-    message?: string,
-): asserts condition {
+export function invariant(
+    condition: unknown,
+    message?: string | (() => string),
+): asserts condition {
@@
-    throw new Error(message ? `${prefix}: ${message}` : prefix);
+    const text = typeof message === 'function' ? message() : message;
+    throw new Error(text ? `${prefix}: ${text}` : prefix);
packages/runtime/src/enhancements/node/policy/policy-utils.ts (1)

18-18: Use the canonical import path for consistency

Everywhere else you switched to @zenstackhq/runtime/local-helpers, but this file uses a relative path.
Aligning paths reduces duplication in bundlers and improves tree-shaking.

-import { isPlainObject, lowerCaseFirst, upperCaseFirst } from '../../../local-helpers';
+import { isPlainObject, lowerCaseFirst, upperCaseFirst } from '@zenstackhq/runtime/local-helpers';
packages/runtime/src/local-helpers.ts (1)

1-1: Minor path nit

The explicit /index suffix is unnecessary; Node/TS will resolve the directory automatically.

-export * from './local-helpers/index';
+export * from './local-helpers';
packages/runtime/src/local-helpers/upper-case-first.ts (1)

1-3: Handle empty input explicitly

Consider adding a guard for empty strings to avoid returning unexpected values when input is empty:

 export function upperCaseFirst(input: string) {
+    if (input.length === 0) {
+        return input;
+    }
     return input.charAt(0).toUpperCase() + input.slice(1);
 }
packages/runtime/src/local-helpers/lower-case-first.ts (1)

1-3: Handle empty input explicitly

Similar to upperCaseFirst, consider guarding against empty strings to ensure consistent behavior:

 export function lowerCaseFirst(input: string) {
+    if (input.length === 0) {
+        return input;
+    }
     return input.charAt(0).toLowerCase() + input.slice(1);
 }
packages/plugins/openapi/src/rest-generator.ts (1)

36-36: Variable name shadowing: imported name vs. parameter name

import { name } from '.' introduces an identifier that is later shadowed by the
name parameter inside makeFilterParameter. While TypeScript allows this, it
hurts readability and can lead to accidental misuse.

-import { name } from '.';
+import { name as pluginName } from '.';
...
-private makeFilterParameter(..., name: string, ...)
+private makeFilterParameter(..., filterName: string, ...)

Also applies to: 521-529

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

6-18: Nit: avoid shadowing and make variable intent clearer.

Using path as the iterator masks the path module should you ever add it later, and reduces readability. Consider the rename below:

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

6-18: Guard against single-replacement when from is a string.

String.prototype.replace only touches the first occurrence unless from is a RegExp with the global flag.
If future calls provide a string literal you’ll silently miss extra matches.

Quick defensive fix:

-const newContents = contents.replace(from, to);
+const newContents = contents.replace(
+    typeof from === 'string' ? new RegExp(from, 'g') : from,
+    to
+);
packages/runtime/src/local-helpers/is-plain-object.ts (1)

5-23: Expose isPlainObject as a type-guard to improve DX
Since callers typically branch on the result to treat o as a plain object, make the signature a predicate as well:

-export function isPlainObject(o: unknown) {
+export function isPlainObject(o: unknown): o is Record<string, unknown> {

This eliminates the need for as casts at call-sites and keeps typings self-documenting.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d8cbfbb and 15fcc0d.

⛔ Files ignored due to path filters (19)
  • 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
📒 Files selected for processing (51)
  • 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 (1 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 (1 hunks)
  • packages/runtime/src/local-helpers.ts (1 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/schema/src/plugins/enhancer/enhance/checker-type-generator.ts (1 hunks)
  • packages/schema/src/plugins/enhancer/enhance/index.ts (1 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/schema-generator.ts (2 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/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 (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)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: dependency-review
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (40)
packages/testtools/src/db.ts (1)

10-12: Only whitespace formatting changes
The reformatting of the Pool constructor object removes trailing spaces and consolidates lines without altering behavior.

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

21-21: Remove extra space in JSDoc opening tag
This is a trivial formatting cleanup with no impact on functionality.

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

88-88: Clean up extraneous blank lines in changelog introduction
Whitespace-only change for consistent formatting.

Also applies to: 90-90

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

18-18: Remove trailing whitespace
Whitespace cleanup only; no schema or logic changes.

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

packages/server/src/nestjs/interfaces/api-handler-options.interface.ts (1)

8-8: Remove unnecessary trailing spaces in comment
Minor formatting correction; no change to interface.

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

117-117: Remove trailing whitespace from comment
Formatting cleanup only; logic unchanged.

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

13-13: Whitespace clean-up acknowledged

Only trailing blank lines were removed. No functional impact.

Also applies to: 33-33, 36-36, 63-63, 79-79, 88-88

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

106-106: Trailing-space removed in comment – all good

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

136-136: Minor formatting change confirmed

Comment whitespace and EOF newline tweaks are fine.

Also applies to: 190-190

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

167-167: Grammar file whitespace tidy-up looks safe

Whitespace only; grammar semantics unchanged.

Also applies to: 196-196, 211-211

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

126-128: Whitespace-only clean-up looks good

Trailing-space removal keeps diffs tidy and avoids noisy churn in future commits.

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

1-1: Consolidated helper import acknowledged

Switching to the internal helper module removes an external dependency and standardises utility usage. 👍

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

2-3: Helper import path updated correctly

Import now references the local aggregation module, aligning with the dependency cleanup effort.

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

1-1: Import lowerCaseFirst from internal helpers
The import has been correctly switched to the consolidated local-helpers module, removing the external dependency.

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

1-1: Import isPlainObject from internal helpers
The change properly uses the new local-helpers module for isPlainObject, maintaining existing clone logic.

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

3-3: Switch lowerCaseFirst import to internal helper alias
The import path update aligns with the new centralized helper package and removes the previous external dependency.

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

3-3: Use internal sleep helper instead of external package
The import correctly points to the local-helpers module for sleep, consolidating dependencies as intended.

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

10-10: Update lowerCaseFirst import to internal helper
This aligns the SWR runtime code with the consolidated helpers, removing reliance on the external package.

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

1-1: Consolidate utility import for upperCaseFirst
Switched from the external upper-case-first package to our internal helpers to reduce dependencies.

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

17-17: Use internal helpers for isPlainObject and lowerCaseFirst
Importing from ../../local-helpers centralizes these utilities. Please confirm the path resolves correctly.

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

14-14: Import upperCaseFirst from centralized helpers
This aligns with the PR’s goal of removing deprecated external dependencies.

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

10-10: Switch upperCaseFirst import to internal module
Reducing external dep footprint by using the consolidated helper.

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

2-2: Replace external invariant with internal implementation
Importing invariant from our helpers ensures consistency across the codebase.

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

34-34: Consolidated import to local-helpers
Import of lowerCaseFirst has been updated to the centralized helper module, removing dependency on the external package. This aligns with the PR objective of standardizing utilities across the codebase.

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

20-20: Use centralized helper module
Replaced the external lowerCaseFirst import with the internal local-helpers module to unify utility imports and eliminate an external dependency.

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

10-10: Unified utility import in tests
Switching to the internal helper for lowerCaseFirst ensures tests remain consistent with the refactoring and removes reliance on the deprecated external package.

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

29-29: Centralized upperCaseFirst import
Updating the import to use the consolidated local-helpers module removes the deprecated external dependency and maintains import consistency.

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

15-15: Import relocation looks correct but double-check package linkage

The path switch from the external upper-case-first package to the monorepo helper (@zenstackhq/runtime/local-helpers) compiles fine here.
Just make sure that packages/schema declares @zenstackhq/runtime as a dependency/peer-dependency; otherwise consumers of the schema package could face a missing module error when the helper gets resolved at runtime.

packages/runtime/src/enhancements/node/policy/handler.ts (1)

18-18: Verify helper implementation parity

You swapped tiny-invariant, lower-case-first, and upper-case-first with the local helper versions.
Two quick checks before merging:

  1. The local invariant helper MUST support the same call-signature used below (both the 1-arg and 2-arg variants – see lines ~826 and ~1795) and throw an Error object; otherwise diagnostic behaviour will change silently.

  2. The relative path ../../../local-helpers resolves to packages/runtime/src/local-helpers.ts. Confirm that this file is emitted to the same sub-path in the published package so downstream bundlers don’t break.

Everything else in this file remains untouched, so a green build will confirm the swap.

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

2-2: Consistent helper import – good move

Moving to the consolidated local-helpers module keeps the dependency graph slimmer and improves tree-shaking. No further action needed here.

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

3-3:

✅ Verification successful

Ensure no legacy imports remain across the repo

lowerCaseFirst / upperCaseFirst now come from @zenstackhq/runtime/local-helpers. Please verify that all other files were updated accordingly so we can actually drop the external lower-case-first / upper-case-first packages from package.json.


🏁 Script executed:

#!/bin/bash
# Search the whole repo for any remaining direct imports of the removed packages
rg -n $'from [\'"](?:lower-case-first|upper-case-first|change-case|tiny-invariant|is-plain-object|sleep-promise)[\'"]'

Length of output: 123


🏁 Script executed:

#!/bin/bash
# Re-run simplified search for legacy package names anywhere in the codebase
for pkg in lower-case-first upper-case-first change-case tiny-invariant is-plain-object sleep-promise; do
  echo "Searching for occurrences of '$pkg':"
  rg -n "$pkg"
done

Length of output: 1743


All legacy imports have been replaced
I re-searched the entire codebase for any direct references to the old packages (lower-case-first, upper-case-first, change-case, tiny-invariant, is-plain-object, sleep-promise) and only found their exports in packages/runtime/src/local-helpers/index.ts (i.e. local files), with no remaining imports from the external packages. You can safely remove the lower-case-first and upper-case-first (and any other unused) dependencies from package.json.

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

15-15: Confirm paramCase behavioural parity

The new internal paramCase must mirror change-case’s behaviour (e.g. Unicode handling, many consecutive upper-case letters, etc.).
Please add/extend unit tests for paramCase to avoid subtle API regressions.

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

30-30: Import consolidation is correct

The upperCaseFirst import has been updated to the new internal helper module, aligning with the local-helpers refactoring. No issues detected.

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

15-15: Consolidated helper imports

The combined import of lowerCaseFirst and upperCaseFirst from @zenstackhq/runtime/local-helpers is correct and matches usage within this file.

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

14-14: Consolidated helper imports

The lowerCaseFirst, upperCaseFirst, and invariant imports have been correctly consolidated from the internal local-helpers module.

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

29-29:

✅ Verification successful

Confirm local-helpers re-exports are 1-for-1 compatible with the removed libs

The file now relies on @zenstackhq/runtime/local-helpers for invariant and lowerCaseFirst.
Please double-check that:

  1. invariant is exported as a named function (not a default) and preserves the signature of tiny-invariant.
  2. lowerCaseFirst behaves identically to the previous lower-case-first package (handles empty strings, non-alpha input, etc.).

🏁 Script executed:

#!/usr/bin/env bash
# Ensure helper re-exports exist and are named exports
ast-grep --pattern $'export function invariant($_) { $$$ }' $(fd local-helpers | head -n 1)
ast-grep --pattern $'export function lowerCaseFirst($_) { $$$ }' $(fd local-helpers | head -n 1)

Length of output: 544


🏁 Script executed:

#!/usr/bin/env bash
# Locate the definition or re-export of invariant in local-helpers
rg -R "export.*invariant" -n packages/runtime/src/local-helpers
rg -R "tiny-invariant" -n packages/runtime/src/local-helpers

Length of output: 936


🏁 Script executed:

#!/usr/bin/env bash
# List helper files
find packages/runtime/src/local-helpers -maxdepth 1 -type f

# Search for any import/export of invariant
rg -n "invariant" packages/runtime/src/local-helpers

# Search for tiny-invariant usage
rg -n "tiny-invariant" packages/runtime/src/local-helpers

Length of output: 768


No changes needed for helper re-exports

Verified that:

  • invariant is a named export in packages/runtime/src/local-helpers/tiny-invariant.ts and is re-exported in packages/runtime/src/local-helpers/index.ts, preserving the original tiny-invariant signature.
  • lowerCaseFirst(input: string) in packages/runtime/src/local-helpers/lower-case-first.ts behaves identically to the previous lower-case-first package (empty strings yield '', non-alphabetic first characters are unchanged).
packages/server/src/api/rest/index.ts (1)

13-13:

❓ Verification inconclusive

Behavioural parity check for paramCase, lowerCaseFirst, upperCaseFirst

The helpers are now sourced from the internal bundle. Make sure:

  1. paramCase('SomeValue') still yields some-value (was implemented by change-case).
  2. Unicode / non-ASCII handling is unchanged (edge cases often differ between libraries).
  3. Tree-shaking doesn’t accidentally drop these funcs in browser builds.

🏁 Script executed:

#!/usr/bin/env bash
# Quick parity smoke-test against the old implementation
node - <<'JS'
import { paramCase } from '@zenstackhq/runtime/local-helpers';
console.log(paramCase('SomeValue'));   // expect 'some-value'
JS

Length of output: 1024


🏁 Script executed:

#!/usr/bin/env bash
# Locate and inspect the local-helpers implementation to verify parity
file=$(fd local-helpers.ts -t f | head -n 1)
if [[ -z "$file" ]]; then
  echo "local-helpers.ts not found"
  exit 1
fi
echo "Inspecting: $file"
sed -n '1,200p' "$file"

Length of output: 336


🏁 Script executed:

#!/usr/bin/env bash
echo "Inspecting local-helpers index and implementations..."
# Show exports in the index
sed -n '1,200p' packages/runtime/src/local-helpers/index.ts

# Show each helper’s implementation
for file in packages/runtime/src/local-helpers/*.ts; do
  if [[ "$file" != *"/index.ts" ]]; then
    echo "----- $file -----"
    sed -n '1,200p' "$file"
  fi
done

Length of output: 4586


Verify helper parity and Unicode handling

In packages/server/src/api/rest/index.ts (line 13):

import { lowerCaseFirst, upperCaseFirst, paramCase } from '@zenstackhq/runtime/local-helpers';

• Confirm that paramCase('SomeValue') still yields "some-value"
lowerCaseFirst and upperCaseFirst remain simple ASCII‐only routines
Unicode edge cases: new paramCase uses /[^A-Z0-9]+/gi to strip separators, so non-ASCII characters (e.g. accented letters, emojis) will be dropped—add tests like:

paramCase('Éclair')     // expected? 'éclair' vs. '' or 'clair'
paramCase('foo😊bar')  // expected? 'foo-bar' vs. 'foo😊bar'

• Tree-shaking should work out-of-the-box with these named ESM exports, but verify in your browser bundle

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

16-16: Confirm secondary entry-point resolution for @zenstackhq/runtime/local-helpers.

The new import pulls from a sub-path that didn’t previously exist. Please double-check that:

  1. the path is exported in packages/runtime/package.json#exports, and
  2. TS/Node module-resolution settings in every consumer project allow sub-path imports.

Otherwise downstream builds may fail with “module not found”.

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

1-6: Re-export layer looks good.

All helper utilities are funnelled through a single barrel file, improving DX and tree-shaking. ✅

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

48-51: Import refactor looks correct.

Swapping lower-case-first for the local helper reduces external deps without changing behaviour. No further action needed.

@@ -36,8 +36,7 @@ import {
TypeScriptExpressionTransformer,
TypeScriptExpressionTransformerError,
} from '@zenstackhq/sdk';
import { lowerCaseFirst } from 'lower-case-first';
import invariant from 'tiny-invariant';
import { lowerCaseFirst, invariant } from '@zenstackhq/runtime/local-helpers';
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Possible mismatch: invariant is imported as a named export

tiny-invariant provides a default export.
If your local helper re-implements it but exports the function as default rather than a named export, import { invariant } … will be undefined at runtime and every invariant(...) call will throw.

-import { lowerCaseFirst, invariant } from '@zenstackhq/runtime/local-helpers';
+import { lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
+import invariant from '@zenstackhq/runtime/local-helpers';

(or export it as a named export from the helper module). Validate the helper’s public surface before merging.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { lowerCaseFirst, invariant } from '@zenstackhq/runtime/local-helpers';
import { lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
import invariant from '@zenstackhq/runtime/local-helpers';
🤖 Prompt for AI Agents
In packages/schema/src/plugins/enhancer/policy/expression-writer.ts at line 39,
the import of `invariant` as a named export may be incorrect if the helper
module exports it as a default export. Verify the export style in
'@zenstackhq/runtime/local-helpers'; if `invariant` is a default export, change
the import to `import invariant from ...` instead of using curly braces.
Alternatively, adjust the helper module to export `invariant` as a named export
to match the current import style.

Comment on lines +1 to +18
const DEFAULT_SPLIT_REGEXP_1 = /([a-z0-9])([A-Z])/g;
const DEFAULT_SPLIT_REGEXP_2 = /([A-Z])([A-Z][a-z])/g;
const DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;

export function paramCase(input: string) {
const result = input
.replace(DEFAULT_SPLIT_REGEXP_1, "$1\0$2")
.replace(DEFAULT_SPLIT_REGEXP_2, "$1\0$2")
.replace(DEFAULT_STRIP_REGEXP, "\0");

let start = 0;
let end = result.length;

while (result.charAt(start) === "\0") start++;
while (result.charAt(end - 1) === "\0") end--;

return result.slice(start, end).split("\0").map((str) => str.toLowerCase()).join("-");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

ASCII-only implementation may break existing non-ASCII inputs.

DEFAULT_STRIP_REGEXP discards any character outside [A-Z0-9] (case-insensitive).
The previous change-case implementation handled full Unicode ranges; this local version will mangle strings like "Münchenstraße""mnchenstrae".

If the project relies on internationalised identifiers, consider switching to a Unicode-aware approach, e.g.:

-const DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
+const DEFAULT_STRIP_REGEXP = /[^\p{L}\p{N}]+/giu; // keep all letters & digits

and add unit tests for non-ASCII cases.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const DEFAULT_SPLIT_REGEXP_1 = /([a-z0-9])([A-Z])/g;
const DEFAULT_SPLIT_REGEXP_2 = /([A-Z])([A-Z][a-z])/g;
const DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
export function paramCase(input: string) {
const result = input
.replace(DEFAULT_SPLIT_REGEXP_1, "$1\0$2")
.replace(DEFAULT_SPLIT_REGEXP_2, "$1\0$2")
.replace(DEFAULT_STRIP_REGEXP, "\0");
let start = 0;
let end = result.length;
while (result.charAt(start) === "\0") start++;
while (result.charAt(end - 1) === "\0") end--;
return result.slice(start, end).split("\0").map((str) => str.toLowerCase()).join("-");
}
const DEFAULT_SPLIT_REGEXP_1 = /([a-z0-9])([A-Z])/g;
const DEFAULT_SPLIT_REGEXP_2 = /([A-Z])([A-Z][a-z])/g;
-const DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
+const DEFAULT_STRIP_REGEXP = /[^\p{L}\p{N}]+/giu; // keep all letters & digits
export function paramCase(input: string) {
const result = input
.replace(DEFAULT_SPLIT_REGEXP_1, "$1\0$2")
.replace(DEFAULT_SPLIT_REGEXP_2, "$1\0$2")
.replace(DEFAULT_STRIP_REGEXP, "\0");
let start = 0;
let end = result.length;
while (result.charAt(start) === "\0") start++;
while (result.charAt(end - 1) === "\0") end--;
return result.slice(start, end)
.split("\0")
.map((str) => str.toLowerCase())
.join("-");
}
🤖 Prompt for AI Agents
In packages/runtime/src/local-helpers/param-case.ts lines 1 to 18, the current
DEFAULT_STRIP_REGEXP removes all non-ASCII characters, which breaks inputs with
Unicode characters. To fix this, replace the ASCII-only regex with a
Unicode-aware approach that preserves international characters, such as using
Unicode property escapes or a library that supports full Unicode ranges. Also,
add unit tests covering non-ASCII inputs to ensure correct behavior.

Comment on lines +1 to +3
function isObject(o: unknown) {
return Object.prototype.toString.call(o) === '[object Object]';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add an explicit return-type (preferably a type-predicate) for isObject
Without a declared return type, TypeScript defaults to any, losing the chance to narrow o in the caller. Making it a predicate (o is Record<string, unknown>) lets downstream code safely access properties without repetitive casts.

-function isObject(o: unknown) {
-    return Object.prototype.toString.call(o) === '[object Object]';
+function isObject(o: unknown): o is Record<string, unknown> {
+    return Object.prototype.toString.call(o) === '[object Object]';
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function isObject(o: unknown) {
return Object.prototype.toString.call(o) === '[object Object]';
}
function isObject(o: unknown): o is Record<string, unknown> {
return Object.prototype.toString.call(o) === '[object Object]';
}
🤖 Prompt for AI Agents
In packages/runtime/src/local-helpers/is-plain-object.ts at lines 1 to 3, the
function isObject lacks an explicit return type, causing TypeScript to infer any
and losing type narrowing benefits. Fix this by adding a type predicate return
type such as "o is Record<string, unknown>" to the function signature, enabling
safer property access in callers without extra casts.

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.

1 participant