-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat(cms): Be able to query organization by national id #17122
Conversation
WalkthroughThe changes in this pull request involve significant refactoring of the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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
Documentation and Community
|
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: 0
🧹 Outside diff range and nitpick comments (2)
libs/cms/src/lib/cms.contentful.service.ts (2)
Line range hint
351-375
: Consider adding input validation for fieldName parameter.The utility method effectively centralizes organization querying logic. However, consider validating the fieldName parameter against a list of allowed fields to prevent potential runtime errors from invalid field names.
+ const ALLOWED_ORGANIZATION_FIELDS = ['slug', 'title', 'referenceIdentifier', 'kennitala'] as const; + type OrganizationField = typeof ALLOWED_ORGANIZATION_FIELDS[number]; private async getOrganizationBy( - fieldName: string, + fieldName: OrganizationField, fieldValue: string, lang: string, requireFieldValue = false, ): Promise<Organization | null> { + if (!ALLOWED_ORGANIZATION_FIELDS.includes(fieldName)) { + throw new Error(`Invalid field name: ${fieldName}`); + }
398-403
: Consider adding national ID format validation.While the implementation is correct, consider adding validation for the national ID format to ensure data integrity.
async getOrganizationByNationalId( nationalId: string, lang: string, ): Promise<Organization | null> { + // Icelandic national ID format: DDMMYY-XXXX + const nationalIdRegex = /^\d{6}-?\d{4}$/; + if (!nationalIdRegex.test(nationalId)) { + throw new Error('Invalid national ID format. Expected format: DDMMYY-XXXX'); + } return this.getOrganizationBy('kennitala', nationalId, lang, true) }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
libs/cms/src/lib/cms.contentful.service.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/cms/src/lib/cms.contentful.service.ts (1)
Pattern libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
🔇 Additional comments (3)
libs/cms/src/lib/cms.contentful.service.ts (3)
377-382
: LGTM! Clean refactor maintaining backward compatibility.
The refactored method effectively uses the new utility while maintaining its original contract and behavior.
384-389
: LGTM! Effective use of Contentful's match operator.
The refactored method correctly uses the match operator for title search while maintaining its original behavior.
391-396
: LGTM! Clean refactor using the utility method.
The refactored method effectively uses the new utility while maintaining its original behavior.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17122 +/- ##
=======================================
Coverage 35.72% 35.72%
=======================================
Files 6920 6920
Lines 147485 147480 -5
Branches 41988 41987 -1
=======================================
Hits 52686 52686
+ Misses 94799 94794 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportAll test runs ✅ 10 Total Test Services: 0 Failed, 9 Passed Test ServicesThis report shows up to 10 services
|
What
Why
To be able to query organizations by national id
Checklist:
Summary by CodeRabbit