Skip to content
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(framework): add class-validator support #6945

Open
wants to merge 87 commits into
base: next
Choose a base branch
from

Conversation

paulwer
Copy link
Contributor

@paulwer paulwer commented Nov 11, 2024

What changed? Why was the change needed?

  • Add Class Validator support for @novu/framework
  • Add type error messages when providing invalid schemas
  • Add Stringify<T> generic helper for helpful type error messages
  • Hard-code checkIsErrorResponse into @novu/framework to resolve ESM import issues from @novu/shared

Screenhots

Class validator peer dependency import failure message

 ⨯ Error: Tried to use a class-validator schema in @novu/framework without class-validator-jsonschema installed. Please install it by running `npm install class-validator-jsonschema`.
    at se (/Users/rifont/git/framework-next-turbo/.next/server/app/api/novu/route.js:411:77618)
    at async si.canHandle (/Users/rifont/git/framework-next-turbo/.next/server/app/api/novu/route.js:411:79403)
    at async sp (/Users/rifont/git/framework-next-turbo/.next/server/app/api/novu/route.js:411:81104)
    at async Object.discover (/Users/rifont/git/framework-next-turbo/.next/server/app/api/novu/route.js:505:10531)
    at async sl.addWorkflows (/Users/rifont/git/framework-next-turbo/.next/server/app/api/novu/route.js:501:8314)
    at async (/Users/rifont/git/framework-next-turbo/.next/server/app/api/novu/route.js:505:3508)
    at async te.do (/Users/rifont/git/framework-next-turbo/node_modules/.pnpm/[email protected][email protected][email protected]__utrvdij6okqvk6cvj3mqcl5cuy/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:17826)
    at async te.handle (/Users/rifont/git/framework-next-turbo/node_modules/.pnpm/[email protected][email protected][email protected]__utrvdij6okqvk6cvj3mqcl5cuy/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:22492)
    at async doRender (/Users/rifont/git/framework-next-turbo/node_modules/.pnpm/[email protected][email protected][email protected]__utrvdij6okqvk6cvj3mqcl5cuy/node_modules/next/dist/server/base-server.js:1455:42) {
  statusCode: 500,
  code: 'MissingDependencyError',
  data: [Array]
}

New type error messages shown when attempting to consume data for invalid schemas
image

Demonstrating a more advanced variant of the error message
image

Expand for optional sections ### Related enterprise PR

Special notes for your reviewer

closes #6682

reference #6840

paulwer and others added 30 commits November 4, 2024 14:17
…validator-support' into feat-package-class-validator-support
Copy link
Collaborator

@rifont rifont left a comment

Choose a reason for hiding this comment

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

Awesome work @paulwer , thank you for your contribution!

@paulwer
Copy link
Contributor Author

paulwer commented Jan 14, 2025

any updates?

@SokratisVidros
Copy link
Contributor

@paulwer can you please fix the rebase conflicts to continue with the final review?

@paulwer
Copy link
Contributor Author

paulwer commented Jan 30, 2025

@SokratisVidros @rifont i have pulled the next branch into this PR and fixed the conflicts.
tbh @rifont has added multiple stuff, which i cannot validate, so maybe a final review by him again is necessary.

@paulwer
Copy link
Contributor Author

paulwer commented Feb 3, 2025

@SokratisVidros @rifont I've reworked the documentation section to fit to this PR.
If you have any questions/additions/feedback, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 Feature: @novu/framework Integration with class-validator
4 participants