Skip to content

#211-new into main 🧊 add flatten type#266

Open
debabin wants to merge 1 commit into
mainfrom
#211-new
Open

#211-new into main 🧊 add flatten type#266
debabin wants to merge 1 commit into
mainfrom
#211-new

Conversation

@debabin

@debabin debabin commented Mar 29, 2026

Copy link
Copy Markdown
Member

No description provided.

@coderabbitai

coderabbitai Bot commented Mar 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 07c16e1e-e357-4173-b6dc-a6ebe100962e

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch #211-new

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Mar 29, 2026

Copy link
Copy Markdown

Greptile Summary

This PR improves type safety across the database routing and ORM layers by introducing the shared PlainObject type alias (Record<string, any>) in place of any and Record<string, unknown>, and tightens a few related logic details along the way.

Key changes:

  • Replaces flatten<any, any> with flatten<PlainObject, PlainObject> in sort.ts and createOrm.ts across both the server and playground packages.
  • Fixes a subtle sort bug: the old falsy check !flattenedA[key] would skip sorting for valid values like 0, false, or null; replaced with an explicit === undefined guard.
  • Adds an Array.isArray(a) guard to the some filter operator in the playground's filter.ts, returning false instead of throwing TypeError when the field value is not an array.
  • Upgrades operator parameter types in the playground's filter.ts from any to unknown, using Number()/String() wrappers for safer coercion.
  • Reformats inline test object literals to multi-line style in createShallowDatabaseRoutes.test.ts (no logic change).
  • One minor inconsistency: searchInNestedObjects in packages/server/src/core/database/createDatabaseRoutes/helpers/search/search.ts still uses any for its obj parameter despite PlainObject being imported in the same file, while the playground counterpart was correctly updated.

Confidence Score: 5/5

Safe to merge — changes are type-level improvements with one small logic fix; no regressions introduced.

All functional changes are improvements (falsy → undefined check, Array.isArray guard) that fix edge-case bugs rather than introducing new ones. The PlainObject type is simply Record<string, any>, so replacing any with it is a refactor with no runtime impact. The only remaining item is a one-line P2 style inconsistency in the server's searchInNestedObjects parameter type.

Minor attention needed in packages/server/src/core/database/createDatabaseRoutes/helpers/search/search.tssearchInNestedObjects should use PlainObject for obj to match the playground version.

Important Files Changed

Filename Overview
packages/server/src/core/database/createDatabaseRoutes/helpers/search/search.ts Adds PlainObject import and applies it to the search function's array parameter, but searchInNestedObjects still uses any for obj — inconsistent with the playground counterpart.
packages/server/src/core/database/createDatabaseRoutes/helpers/sort/sort.ts Replaces any with PlainObject and refactors null check from falsy !value to explicit === undefined, fixing edge cases where 0, false, or null field values would be incorrectly skipped during sorting.
packages/server/src/core/database/createOrm/createOrm.ts Replaces any with PlainObject in flatten generics and resource callback types, harmonising with the shared type system.
packages/playground/src/core/createOrm/createOrm.ts Mirror of server createOrm.ts — replaces any with PlainObject and Record<string, unknown> consistently.
packages/playground/src/core/createDatabaseRoutes/helpers/functions/filter/filter.ts Upgrades operator types from any to unknown, adds Array.isArray guard to some operator, and uses Number()/String() wrappers instead of unary + and raw .includes/.startsWith/.endsWith.
packages/playground/src/core/createDatabaseRoutes/helpers/functions/sort/sort.ts Playground mirror of server sort.ts — same PlainObject adoption and undefined-check fix.
packages/playground/src/core/createDatabaseRoutes/helpers/functions/search/search.ts Playground mirror of server search.ts — correctly applies PlainObject to both searchInNestedObjects and search parameters.
packages/server/src/core/database/createDatabaseRoutes/helpers/createShallowDatabaseRoutes/createShallowDatabaseRoutes.test.ts Formatting-only refactor — inline object literals expanded to multi-line style for readability. No logic changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Incoming Query / Filters] --> B[filter.ts\noperators now use unknown + Array.isArray guard]
    A --> C[sort.ts\nflatten uses PlainObject\nundefined check replaces falsy check]
    A --> D[search.ts\narray param typed as PlainObject]
    B --> E[createShallowDatabaseRoutes]
    C --> E
    D --> E
    E --> F[createOrm.ts\nfilter / find / exists\nflatten uses PlainObject]
    F --> G[Storage read / write]
Loading

Reviews (1): Last reviewed commit: "#211-new 🧊 add flatten type" | Re-trigger Greptile


import type { PlainObject } from '@/utils/types';

export const searchInNestedObjects = (obj: any, searchText: string) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 PlainObject import not applied to searchInNestedObjects

PlainObject was imported in this file and applied to the search function's array parameter, but searchInNestedObjects still uses any for its obj parameter. The playground counterpart (packages/playground/src/core/createDatabaseRoutes/helpers/functions/search/search.ts) correctly updated this parameter to PlainObject. For consistency, the same change should be applied here.

Suggested change
export const searchInNestedObjects = (obj: any, searchText: string) => {
export const searchInNestedObjects = (obj: PlainObject, searchText: string) => {

@debabin debabin changed the title #211-new 🧊 add flatten type #211-new into main 🧊 add flatten type Apr 5, 2026
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