Skip to content

feat: add goal meta support with size validation#132

Open
devbeoservice wants to merge 3 commits intocjs8487:mainfrom
devbeoservice:feature/goal-meta
Open

feat: add goal meta support with size validation#132
devbeoservice wants to merge 3 commits intocjs8487:mainfrom
devbeoservice:feature/goal-meta

Conversation

@devbeoservice
Copy link
Contributor

  • Add meta Json? field to Goal model in Prisma schema
  • Create migration with 4096 character constraint using JSONB
  • Add GoalValidation utility for application-level validation
  • Integrate meta validation into Goals API endpoint
  • Update Goal.json schema to include meta field
  • Support auto-tracking keys and flexible metadata storage

- Add meta Json? field to Goal model in Prisma schema
- Create migration with 4096 character constraint using JSONB
- Add GoalValidation utility for application-level validation
- Integrate meta validation into Goals API endpoint
- Update Goal.json schema to include meta field
- Support auto-tracking keys and flexible metadata storage
Copy link
Owner

@cjs8487 cjs8487 left a comment

Choose a reason for hiding this comment

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

Overall this looks pretty good. Ideally we would get this into the editor as well but it’s not a huge deal right now, especially while we try and work out the exact details of the client side json editor. One request outside of the direct comments - you need to run the generate script in the schema package to generate the .d.ts files used by the client and server

* Gets the maximum allowed size for goal meta data
* @returns Maximum size in characters
*/
export function getGoalMetaMaxSize(): number {
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a practical use case for this function? Do we anticipate a need to modify the constant in some way to necessitate wrapping it like this? If not, I’d probably lean towards just exporting the constant directly, if we even need to export the value at all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've thought about a config table inside the database before, then we could've reused that in some init script to set this constant and thats why I had it seperate, since I didn't opt for that it's probably best to remove the constant and hardcode the number.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added jsdocs because its security related code, added 20 max goals with max 5 nested. earlier it would have full ignored this because its not checking against json schema in the api. is this on purpose?

Also kept the constants because it would otherwise look like magic numbers for some.

Copy link
Owner

Choose a reason for hiding this comment

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

I’m fine with keeping the constant, but I still don’t think the function is necessary. If you’re going to export a function that just returns a constant, why not just return the constant directly? I can’t see a use case where we would want to do an operation on the constant before returning it, which is the only case where I could see the function being sensible

@cjs8487
Copy link
Owner

cjs8487 commented Oct 3, 2025

I'm inclined to think that we should put merging this on hold until we merge the json editor in. The editor is pretty close at this point I think, and it'd be a pretty big win to be able to edit these out of the box without risking it getting split across multiple releases

@cjs8487 cjs8487 added enhancement New feature or request waiting for release PR is ready to be merged but is not slated to be included in the current release labels Oct 3, 2025
@cjs8487 cjs8487 removed the waiting for release PR is ready to be merged but is not slated to be included in the current release label Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants