-
Notifications
You must be signed in to change notification settings - Fork 3
WIP: feat(GH-133): Add custom fields support for resources #136
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: main
Are you sure you want to change the base?
Conversation
- Add customFields JSON column to Resource entity - Update CreateResourceDto and UpdateResourceDto to support custom fields - Update ResourcesService to handle custom fields in create/update operations - Add database migration for customFields column - Fix all test mocks to include customFields property - Support key-value pairs for integration with external MRP systems Resolves #133
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.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Missing Migration Error Context ▹ view | 🧠 Incorrect |
Files scanned
| File Path | Reviewed |
|---|---|
| apps/api/src/database/migrations/1749397000000-add-resource-custom-fields.ts | ✅ |
| apps/api/src/database/migrations/index.ts | ✅ |
| apps/api/src/resources/dtos/createResource.dto.ts | ✅ |
| apps/api/src/resources/dtos/updateResource.dto.ts | ✅ |
| libs/database-entities/src/lib/entities/resource.entity.ts | ✅ |
| apps/api/src/resources/resources.service.ts | ✅ |
| libs/react-query-client/src/lib/requests/schemas.gen.ts | ✅ |
| libs/react-query-client/src/lib/requests/types.gen.ts | ✅ |
| libs/api-client/src/generated/Api.ts | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
apps/api/src/database/migrations/1749397000000-add-resource-custom-fields.ts
Show resolved
Hide resolved
|
🐳 Docker images built and pushed: GitHub Container Registry: Image Digest: |
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.
Bug: Custom Fields Validation Mismatch
The customFields property in CreateResourceDto and UpdateResourceDto is typed as Record<string, string> but only validated with @IsObject(). This allows non-string values (e.g., numbers, booleans, nested objects) to pass validation, violating the type contract and causing runtime issues when string values are expected. This inconsistency is further compounded by broader client-side type definitions (e.g., object or { [key: string]: unknown }). The validation should either enforce string values or the type should be Record<string, any> to align with the intended data.
apps/api/src/resources/dtos/createResource.dto.ts#L80-L83
apps/api/src/resources/dtos/updateResource.dto.ts#L91-L94
Was this report helpful? Give feedback by reacting with 👍 or 👎
|
🐳 Docker images built and pushed: GitHub Container Registry: Image Digest: |
Summary
This PR implements additional custom fields for resource management as key-value pairs to allow user-definable fields like
externalIDfor MRP system integration.Changes Made
Backend Changes
customFieldsJSON column to store key-value pairsCreateResourceDtoandUpdateResourceDtoto include optionalcustomFieldspropertyResourcesServiceto handle custom fields in create and update operations1749397000000-add-resource-custom-fields.tsto add the new columncustomFieldspropertyAPI Changes
Example Usage
Creating a resource with custom fields:
{ "name": "3D Printer", "description": "High-precision 3D printer", "customFields": { "externalID": "MRP-001", "category": "printer", "location": "room-a", "vendor": "Prusa" } }Updating custom fields:
{ "customFields": { "externalID": "MRP-002", "maintenanceDate": "2025-01-15" } }Benefits
externalIDfieldTesting
Related Issues
Resolves #133
Migration Notes
The database migration adds a nullable JSON column
customFieldsto theresourcetable. No data migration is required as existing resources will havecustomFieldsset tonull.Description by Korbit AI
What change is being made?
Add support for custom fields in the
resourceentity by modifying the database schema, DTOs, service, and API client to handle custom field data as key-value pairs in JSON format.Why are these changes being made?
These changes introduce the ability to store additional, user-defined data on resources through custom fields, improving flexibility and extensibility of resource data handling. This approach allows for scalable data customization without altering the fundamental database schema for each new data requirement, while ensuring consistent validation and integration across all relevant application layers.