-
Notifications
You must be signed in to change notification settings - Fork 192
fix(api): resolve camelCased classname #1122
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
fix(api): resolve camelCased classname #1122
Conversation
WalkthroughThe internal logic of the Changes
Sequence Diagram(s)sequenceDiagram
participant Repository as BaseRepository
participant EventBus
Repository->>Repository: getEventName(entity)
Repository->>Repository: camelCase(entity.className)
Repository->>EventBus: emit(eventName, payload)
Assessment against linked issues
Suggested reviewers
Poem
✨ 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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
api/src/utils/generics/base-repository.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Frontend Tests
- GitHub Check: API-Tests
- GitHub Check: Analyze (actions)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
api/src/utils/generics/base-repository.ts (1)
40-40: Import ofcamelCasehelper is correct
The import path matches the existing helper location and aligns with surrounding imports.
| const entity = camelCase(this.cls.name); | ||
| return `hook:${entity}:${suffix}` as `hook:${IHookEntities}:${TNormalizedEvents}`; |
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.
💡 Verification agent
🧩 Analysis chain
Ensure compatibility with existing event listeners
Switching from .toLocaleLowerCase() to camelCase(this.cls.name) will change the emitted event names and may break consumers relying on the old lowercase format. Verify all event listener registrations (hard-coded strings or decorator usages), add unit tests for getEventName to cover various class names, and document this change (including a note in the changelog or upgrade guide).
🏁 Script executed:
#!/usr/bin/env bash
# Search for hard-coded hook event strings
rg -n "hook:" -n
# Search for decorator-based event listeners
rg -n "@OnEvent" -n
# Locate any calls to getEventName
rg -n "getEventName" -n
# Check for any remaining uses of toLocaleLowerCase in event naming
rg -n "toLocaleLowerCase" -nLength of output: 14559
🏁 Script executed:
#!/usr/bin/env bash
# Display the getEventName method definition and surrounding lines for context
sed -n '120,160p' api/src/utils/generics/base-repository.tsLength of output: 1833
Event name generation (camelCase) is already compatible—update docs & add tests
A scan of all @OnEvent('hook:…') decorators and emit('hook:…') calls shows consumers use camel-cased entity names (e.g. nlpEntity, chatbot), so switching to camelCase(this.cls.name) is backward-compatible. To complete this change, please:
- JSDoc update
Inapi/src/utils/generics/base-repository.ts(around thegetEventNamemethod), change the doc comment to state that<entity>is derived viacamelCase(this.cls.name), not full lower-casing. - Unit tests
Add tests forgetEventNamecovering both single-word and multi-word class names (e.g.User,UserProfile,NlpValue). - Changelog/upgrade guide
Document this convention change in your CHANGELOG or upgrade guide, noting that event names are now camelCase.
🤖 Prompt for AI Agents
In api/src/utils/generics/base-repository.ts around lines 132 to 133, update the
JSDoc for the getEventName method to specify that the entity part of the event
name is generated using camelCase(this.cls.name) instead of toLocaleLowerCase.
Add unit tests for getEventName to cover various class names including
single-word and multi-word examples like User, UserProfile, and NlpValue.
Finally, document this change in the project's CHANGELOG or upgrade guide,
noting that event names now use camelCase to ensure clarity and maintain
compatibility.
Motivation
The main motivation of this PR is to make camelCased the classname.
Fixes #1121 (HOTFIX)
Type of change:
Checklist:
Summary by CodeRabbit