-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
paulwer
wants to merge
85
commits into
novuhq:next
Choose a base branch
from
paulwer:feat-package-class-validator-support
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 81 commits
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
369ffaf
feat: add class-validator support
paulwer 19c03c2
Merge branch 'next' into feat-package-class-validator-support
paulwer a16f147
Merge branch 'next' into feat-package-class-validator-support
paulwer 1016672
Merge branch 'next' into feat-package-class-validator-support
rifont c2c0512
Update packages/framework/src/validators/class-validator.validator.ts
paulwer f343a9d
fixes
paulwer b91fe48
Merge branch 'next' into feat-package-class-validator-support
paulwer 8662b2b
workaround for classValidator defaultStorage
paulwer df9128e
Update packages/framework/src/validators/class-validator.validator.ts
paulwer 86bd4f9
fixes
paulwer 5d2b8e9
Merge remote-tracking branch 'refs/remotes/origin/feat-package-class-…
paulwer 2b8f000
Merge branch 'next' into feat-package-class-validator-support
paulwer f74470a
refactor(types): replace any with unknown in T_Controls
rifont e7f3ef8
Update packages/framework/src/validators/class-validator.validator.ts
rifont c5daec5
refactor(validator): simplify metadata storage import
rifont 255115c
docs(validator): update TODO comment with @see link
rifont 68e5c9c
test(validation): update tests for validation changes
rifont ecec05d
refactor(types): update class type inference logic
rifont 836bde3
test: remove JSON stringify from test assertion
rifont f3decf0
docs(schema.types): update ClassType type description
rifont ed7c857
refactor(class-validator): improve type checking logic
rifont 322d118
test(validator): extract class-validator fixtures
rifont 7fb6368
Merge branch 'next' into feat-package-class-validator-support
rifont b432668
refactor: Remove IsOptional from name property
rifont 11210c4
Merge branch 'feat-package-class-validator-support' of https://github…
rifont 76de6fa
refactor(schema): remove zod dependency from schemas
rifont 3eb118a
docs(import.types): clarify dependency import comment
rifont 8049177
refactor(validators): update type imports and schema names
rifont 0d0b31b
refactor(types): update import to use 'type' keyword
rifont 15b9ab4
docs(zod): add comment for ZodSchema type
rifont ff1577e
fix(framework): Add dependency check import utilities
rifont dac4ef8
refactor(zod): simplify import and type usage
rifont 34f9add
Merge branch 'import-utils-refactor-schemas' into feat-package-class-…
rifont d5c304b
Update packages/framework/src/types/schema.types/zod.schema.types.ts
rifont 1281a14
Update packages/framework/src/client.test.ts
rifont d29556d
Update packages/framework/package.json
rifont 0ab32ec
Update packages/framework/src/validators/class-validator.validator.ts
rifont 5d76360
refactor(json-schema): update JSONSchema imports
rifont 0c8857d
docs(json-schema-dto): update comment for clarity
rifont dbf050e
Merge branch 'import-utils-refactor-schemas' into feat-package-class-…
rifont 37bc8bc
Update packages/framework/src/validators/validator.test.ts
rifont 2b9c81f
refactor(json-schema-dto): simplify JSON schema types
rifont 522d59a
refactor(api): replace json-schema with JSONSchemaDto
rifont 8c24423
refactor(schema): update JSONSchema to JSONSchemaDefinition
rifont d35de47
Update apps/dashboard/package.json
rifont 4aaa275
refactor: replace JsonSchema with JSONSchemaDto
rifont 6d56c0a
Merge branch 'import-utils-refactor-schemas' of ssh://github.com/novu…
rifont 2e5c3b5
refactor(json-schema-dto): use readonly types for safety
rifont 6847ef5
Merge branch 'next' into import-utils-refactor-schemas
rifont 7c2736e
refactor(api): remove json-schema-to-ts dependency
rifont e353b7e
Merge branch 'jsonschema-dto-everywhere' into import-utils-refactor-s…
rifont 0fb4a20
refactor(types): refactor JSON schema type definitions
rifont ed7ab69
Merge branch 'jsonschema-dto-everywhere' into import-utils-refactor-s…
rifont c1bf7ff
chore: add 'combinators' to cspell.json dictionary
rifont fd340d9
Merge branch 'next' into jsonschema-dto-everywhere
rifont d28d16b
Merge branch 'jsonschema-dto-everywhere' into import-utils-refactor-s…
rifont b918978
Merge branch 'import-utils-refactor-schemas' into feat-package-class-…
rifont e663960
Merge branch 'next' into import-utils-refactor-schemas
rifont 7e31412
Merge branch 'import-utils-refactor-schemas' of ssh://github.com/novu…
rifont 4140bda
Merge branch 'import-utils-refactor-schemas' into feat-package-class-…
rifont d54f009
Merge branch 'next' into feat-package-class-validator-support
rifont d7ed75f
Update packages/framework/src/resources/workflow/discover-custom-step…
rifont 229b530
Update packages/framework/src/types/schema.types/base.schema.types.ts
rifont 41d8ff3
feat: add enum tests
paulwer f146791
feat: support nested array structures
paulwer deb1a7c
Merge branch 'feat-package-class-validator-support' of https://github…
paulwer c39591f
fixes
paulwer db76adb
chore: cleanup namings for fixtures & add tests for simple UnionTypes
paulwer 42f85a6
Merge branch 'next' into feat-package-class-validator-support
paulwer d9c952c
fixes
paulwer 771a6c5
Merge branch 'next' into feat-package-class-validator-support
paulwer 8705bd8
Merge branch 'next' into feat-package-class-validator-support
scopsy bb0e949
feat: cspell
scopsy 1c7dc73
test: Add tests for enhanced type inference system
rifont 2c1a969
Merge branch 'feat-package-class-validator-support' of https://github…
rifont 52886b1
refactor(workflow): improve data type coercion
rifont bb552b8
refactor(utils): relocate checkIsResponseError function
rifont 52e7084
refactor(types): update test and stringify logic
rifont d14be75
build: exclude shared from circular check
rifont 44a390f
Merge branch 'next' into feat-package-class-validator-support
rifont 53dad23
refactor(schema): update SchemaError message wording
rifont 905f6a5
docs: Fix typos in schema inference comments
rifont 49cc45d
style(validator): fix import extensions warnings
rifont 7beb058
Merge branch 'next' into feat-package-class-validator-support
rifont 48a81af
Merge branch 'next' into feat-package-class-validator-support
rifont File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import type { InferJsonSchema, JsonSchemaMinimal } from './json.schema.types'; | ||
import type { InferZodSchema, ZodSchemaMinimal } from './zod.schema.types'; | ||
import type { InferClassValidatorSchema, ClassValidatorSchema } from './class.schema.types'; | ||
import type { Stringify } from '../util.types'; | ||
|
||
/** | ||
* A schema used to validate a JSON object. | ||
*/ | ||
export type Schema = JsonSchemaMinimal | ZodSchemaMinimal; | ||
export type Schema = JsonSchemaMinimal | ZodSchemaMinimal | ClassValidatorSchema; | ||
|
||
/** | ||
* Main utility type for schema inference | ||
|
@@ -14,7 +16,32 @@ | |
*/ | ||
type InferSchema<T extends Schema, Options extends { validated: boolean }> = | ||
| InferJsonSchema<T, Options> | ||
| InferZodSchema<T, Options>; | ||
| InferClassValidatorSchema<T, Options> | ||
| InferZodSchema<T, Options> | ||
| never extends infer U | ||
? /* | ||
* Use a distributive conditional type to detect if all inferred types are `never`. | ||
* When all inferred types are `never`, return an unknown record. | ||
* | ||
* Each schema inferrence must return `never` type when: | ||
* - The schema is generic (i.e. not a concrete schema type) | ||
* - The schema is not supported (i.e. tried to specify `string` as the schema type) | ||
* - The schema is undefined | ||
* | ||
* @see - https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types | ||
*/ | ||
[U] extends [never] | ||
? // When all inferred types are `never`, return an unknown record. | ||
Record<string, unknown> | ||
: // The type inferrence did not return `never`. Ensure the inferred type is a record type, as only objects are supported. | ||
U extends Record<string, unknown> | ||
? // Got a record type, return it. | ||
U | ||
: // The schema describes a non-record type, return an error message. | ||
{ | ||
SchemaError: `Schema must describe an object data structure. Received data type: '${Stringify<U>}'`; | ||
} | ||
: never; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
/** | ||
* Infer the type of a Schema for unvalidated data. | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@SokratisVidros is seems that Framework is still detecting circular dependency issues from Framework, even though no issues are traced back to Framework (see logs below in collapsible). Note, shared does not report these issues using
madge
on it's owncheck:circulars
script.Furthermore it appears the PR removing shared circulars had a run pulled from local cache on CI, so this removal was never tested. I am reverting for now as it's a false-positive.
Details