-
-
Notifications
You must be signed in to change notification settings - Fork 562
feat(core): add management APIs for custom profile fields #7446
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
base: master
Are you sure you want to change the base?
Conversation
COMPARE TO
|
Name | Diff |
---|---|
packages/core/src/libraries/custom-profile-fields.ts | 📈 +3.65 KB |
packages/core/src/middleware/koa-slonik-error-handler.ts | 📈 +220 Bytes |
packages/core/src/queries/custom-profile-fields.ts | 📈 +2.34 KB |
packages/core/src/routes/custom-profile-fields.openapi.json | 📈 +4.62 KB |
packages/core/src/routes/custom-profile-fields.ts | 📈 +3.15 KB |
packages/core/src/routes/init.ts | 📈 +173 Bytes |
packages/core/src/routes/swagger/utils/documents.ts | 📈 +26 Bytes |
packages/core/src/routes/swagger/utils/general.ts | 📈 +109 Bytes |
packages/core/src/routes/swagger/utils/operation-id.ts | 📈 +80 Bytes |
packages/core/src/tenants/Libraries.ts | 📈 +164 Bytes |
packages/core/src/tenants/Queries.ts | 📈 +159 Bytes |
packages/schemas/alterations/next-1749724664-drop-sie-order-constraint-from-custom-profile-fields.ts | 📈 +533 Bytes |
packages/schemas/tables/custom_profile_fields.sql | 📈 +81 Bytes |
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.
Pull Request Overview
This PR introduces management APIs for custom profile fields, including database queries, libraries, route handlers, and Swagger/OpenAPI integration.
- Added custom profile fields queries and integrated them into the tenant
Queries
class. - Implemented business logic in a new library and exposed CRUD + ordering operations via Koa routes.
- Updated Swagger utilities and added a standalone OpenAPI spec for the new endpoints.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
packages/core/src/tenants/Queries.ts | Imported and exposed customProfileFields queries |
packages/core/src/tenants/Libraries.ts | Imported and exposed customProfileFields library |
packages/core/src/routes/swagger/utils/operation-id.ts | Registered a dev feature operation ID for post /custom-profile-fields |
packages/core/src/routes/swagger/utils/general.ts | Added custom-profile-fields tag when dev features are enabled |
packages/core/src/routes/swagger/utils/documents.ts | Included “Custom profile fields” in additional Swagger tags |
packages/core/src/routes/init.ts | Mounted customProfileFieldsRoutes under the dev features flag |
packages/core/src/routes/custom-profile-fields.ts | Defined GET/POST/PATCH/DELETE/PUT routes for custom profile fields |
packages/core/src/routes/custom-profile-fields.openapi.json | Added OpenAPI definitions for the new endpoints |
packages/core/src/queries/custom-profile-fields.ts | Implemented SQL queries for custom profile fields management |
packages/core/src/libraries/custom-profile-fields.ts | Created library functions with validation and ordering logic |
Comments suppressed due to low confidence (6)
packages/core/src/tenants/Libraries.ts:24
- This import uses a relative path while other libraries in this module use the '#src/libraries/...' alias. Consider using a consistent import alias for clarity and maintainability.
import { createCustomProfileFieldsLibrary } from '../libraries/custom-profile-fields.js';
packages/core/src/routes/custom-profile-fields.openapi.json:40
- The GET
/api/custom-profile-fields/{id}
spec only lists a 200 response but the implementation may return 400 or 404. Please update the OpenAPI responses to match possible status codes (400, 404).
"get": {
packages/core/src/routes/custom-profile-fields.openapi.json:50
- The PATCH spec only documents a 200 response. The route guard allows 400 and 404—please include those in the OpenAPI response definitions for accuracy.
"patch": {
packages/core/src/routes/custom-profile-fields.openapi.json:69
- The DELETE spec only documents a 204 response. The implementation may return 400 or 404—add those responses in the spec to stay in sync.
"delete": {
packages/core/src/routes/custom-profile-fields.ts:13
- These new routes lack accompanying unit or integration tests. Please add tests for each endpoint, including error conditions, to meet coverage requirements.
export default function customProfileFieldsRoutes<T extends ManagementApiRouter>(
packages/core/src/routes/swagger/utils/operation-id.ts:31
- Only the POST operation for custom-profile-fields is registered in devFeatureCustomRoutes. You may need to register the other CRUD routes (GET, PATCH, DELETE, PUT) to ensure consistent operation IDs in development mode.
'post /custom-profile-fields': 'CreateCustomProfileField',
|
||
// eslint-disable-next-line complexity | ||
const validateCustomProfileField = (data: CreateCustomProfileFieldData) => { | ||
switch (data.type) { |
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.
Can we define multiple classes or objects with key guard mapping to avoid complicated switching logic?
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.
Can you be more specific? I'm afraid creating classes will complicate the situation even more
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.
or maybe just an object? using data.type
as key
); | ||
|
||
router.patch( | ||
'/custom-profile-fields/:id', |
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.
nit: if the name or type is unique, it feels like using the field name or type is more handy than the ID.
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.
I still feel using name
instead of id
is anti-pattern, since the name
is user specified value and could be anything we allow to input into the DB. For example it might be CJK characters or other unicode values. Currently I don't check the input values of the name
, or perhaps I should have?
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.
discussed offline
61ee680
to
2b6f4da
Compare
53ab629
to
a584e27
Compare
2b6f4da
to
7a453ea
Compare
b0acf71
to
b07ec4d
Compare
b07ec4d
to
8a2a35e
Compare
Summary
Add management APIs for custom profile fields.
Testing
Locally tested. Unit tests and API tests will be added in the follow-up PR.
Checklist
- [ ].changeset
- [ ] unit tests- [ ] integration tests- [ ] necessary TSDoc comments