Skip to content

feat(datasource mongoose): handle nested enums#1765

Merged
arnaud-moncel merged 4 commits into
mainfrom
feat/nested-enum
Jul 22, 2026
Merged

feat(datasource mongoose): handle nested enums#1765
arnaud-moncel merged 4 commits into
mainfrom
feat/nested-enum

Conversation

@arnaud-moncel

@arnaud-moncel arnaud-moncel commented Jul 21, 2026

Copy link
Copy Markdown
Member

Definition of Done

General

  • Write an explicit title for the Pull Request, following Conventional Commits specification
  • Test manually the implemented changes
  • Validate the code quality (indentation, syntax, style, simplicity, readability)

Security

  • Consider the security impact of the changes made

Note

Add nested enum support to the Mongoose datasource and related utilities

  • Introduces NestedEnumColumnType ({ type: 'Enum', enumValues: string[] }) in schema.ts and a TypeGetter.isEnumField helper to detect inline enum sub-fields within composite column types.
  • Updates the Mongoose fields generator to emit NestedEnumColumnType for string-enum sub-documents instead of treating them as plain strings.
  • Propagates enum awareness through the schema generator, binary decorator, typing generator, and plugin-flattener so nested enums are preserved (not transformed) and correctly typed throughout the stack.
  • Behavioral Change: composite fields that previously had enum sub-fields serialized as plain strings will now appear as Enum type with an enumValues list in the Forest schema and generated TypeScript typings.

Changes since #1765 opened

  • Modified SchemaGeneratorFields.convertColumnType method to sort enum values for nested enum sub-fields within composite column types [5ef4283]

Macroscope summarized 4732be8.

@qltysh

qltysh Bot commented Jul 21, 2026

Copy link
Copy Markdown

5 new issues

Tool Category Rule Count
qlty Structure Function with many returns (count = 4): convertValueHelper 3
qlty Structure High total complexity (count = 55) 1
qlty Structure Function with high complexity (count = 13): convertValueHelper 1

Comment thread packages/datasource-toolkit/src/validation/type-getter.ts Outdated
@qltysh

qltysh Bot commented Jul 21, 2026

Copy link
Copy Markdown

Qlty


Coverage Impact

⬆️ Merging this pull request will increase total coverage on main by 0.02%.

Modified Files with Diff Coverage (7)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
packages/datasource-mongoose/src/utils/schema/fields.ts100.0%
Coverage rating: A Coverage rating: A
packages/agent/src/utils/forest-schema/generator-fields.ts100.0%
Coverage rating: A Coverage rating: A
packages/plugin-flattener/src/flatten-column/helpers.ts100.0%
Coverage rating: A Coverage rating: A
packages/plugin-flattener/src/flatten-column/customization.ts100.0%
Coverage rating: A Coverage rating: A
...ages/datasource-customizer/src/decorators/binary/collection.ts100.0%
Coverage rating: B Coverage rating: B
packages/datasource-customizer/src/typing-generator.ts100.0%
Coverage rating: A Coverage rating: A
packages/datasource-toolkit/src/validation/type-getter.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@christophebrun-forest christophebrun-forest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One suggestion regarding the sorting of Enum values. It's done elsewhere (See line 71)

Comment thread packages/agent/src/utils/forest-schema/generator-fields.ts Outdated

@christophebrun-forest christophebrun-forest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@arnaud-moncel
arnaud-moncel merged commit 7114afd into main Jul 22, 2026
32 checks passed
@arnaud-moncel
arnaud-moncel deleted the feat/nested-enum branch July 22, 2026 15:20
forest-bot added a commit that referenced this pull request Jul 22, 2026
forest-bot added a commit that referenced this pull request Jul 22, 2026
# @forestadmin/datasource-customizer [1.70.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/datasource-customizer@1.69.3...@forestadmin/datasource-customizer@1.70.0) (2026-07-22)

### Features

* **datasource mongoose:** handle nested enums ([#1765](#1765)) ([7114afd](7114afd))

### Dependencies

* **@forestadmin/datasource-toolkit:** upgraded to 1.54.0
forest-bot added a commit that referenced this pull request Jul 22, 2026
# @forestadmin/datasource-mongoose [1.14.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/datasource-mongoose@1.13.4...@forestadmin/datasource-mongoose@1.14.0) (2026-07-22)

### Features

* **datasource mongoose:** handle nested enums ([#1765](#1765)) ([7114afd](7114afd))

### Dependencies

* **@forestadmin/datasource-toolkit:** upgraded to 1.54.0
forest-bot added a commit that referenced this pull request Jul 22, 2026
# @forestadmin/forestadmin-client [1.41.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/forestadmin-client@1.40.5...@forestadmin/forestadmin-client@1.41.0) (2026-07-22)

### Features

* **datasource mongoose:** handle nested enums ([#1765](#1765)) ([7114afd](7114afd))

### Dependencies

* **@forestadmin/ai-proxy:** upgraded to 1.12.1
* **@forestadmin/datasource-toolkit:** upgraded to 1.54.0
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.

2 participants