-
-
Notifications
You must be signed in to change notification settings - Fork 134
refactor: migrate DTOs from class-validator to Zod #2542
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
Merged
Merged
Conversation
This file contains hidden or 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
…p models - Replaced class-validator DTOs with Zod schemas for CreateDraft, UpdateDraft, and related models in the Draft module. - Removed unused draft.dto.ts and meta-preset.dto.ts files, consolidating validation logic into draft.schema.ts and meta-preset.schema.ts. - Updated service and controller files to reference the new Zod-based DTOs. - Cleaned up model definitions by removing unnecessary decorators and imports. Signed-off-by: Innei <tukon479@gmail.com>
- Upgraded zod from version 3.25.76 to 4.3.5 across various modules and schemas. - Removed deprecated class-validator dependencies and validation pipes, consolidating validation logic using Zod. - Updated schemas to utilize z.enum for enum types instead of z.nativeEnum for better compatibility with Zod v4. - Cleaned up imports and adjusted related service and controller files to align with the new validation approach. Signed-off-by: Innei <tukon479@gmail.com>
…PagerDto - Enhanced the PostController to support category-based filtering in post queries. - Updated PostPagerDto to include categoryIds, allowing for flexible filtering of posts by categories. - Refactored the selection logic in the aggregation pipeline for improved readability and performance. Signed-off-by: Innei <tukon479@gmail.com>
- Added `publishedVersion` property to `DraftModel` to track the version of the draft when it was published. - Updated `DraftService` to include `markAsPublished` method for marking drafts as published and synchronizing their version. - Modified `NoteService`, `PageService`, and `PostService` to handle draft publication during note, page, and post creation and updates, respectively. - Introduced `draftId` field in schemas for Note, Page, and Post to associate drafts with published content. Signed-off-by: Innei <tukon479@gmail.com>
SafeDep Report SummaryPackage Details
This report is generated by SafeDep Github App |
…ion logic - Added missing imports in comment.schema.ts, configs.schema.ts, markdown.schema.ts, and webhook.schema.ts for consistency. - Refactored BaseCrudFactory in crud-factor.transformer.ts to simplify DTO class definitions, removing PartialType and clarifying validation handling. - Updated test files to replace ExtendedValidationPipe with extendedZodValidationPipeInstance for improved validation consistency. - Adjusted e2e tests for OptionController to reflect changes in the API endpoint and response structure. Signed-off-by: Innei <tukon479@gmail.com>
…or request context management - Removed cls-hooked from package.json and pnpm-lock.yaml to simplify dependency management. - Refactored RequestContext to utilize AsyncLocalStorage for storing request context, enhancing performance and reducing complexity. - Updated RequestContextMiddleware to use the new AsyncLocalStorage implementation. - Added Redis server installation step in CI workflow and improved Redis mock setup to locate the system binary. Signed-off-by: Innei <tukon479@gmail.com>
- Introduced e2e tests in request.context.e2e-spec.ts to verify that the RequestContext maintains consistency throughout a request lifecycle and does not leak context across concurrent requests. - Added unit tests in request.context.spec.ts to ensure proper context management during asynchronous operations and isolation of concurrent request contexts. Signed-off-by: Innei <tukon479@gmail.com>
…hod call Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Innei <tukon479@gmail.com>
- Removed lodash imports across various modules and replaced them with equivalent functions from es-toolkit/compat. - Added es-toolkit as a dependency in package.json and pnpm-lock.yaml. - Updated related configuration files to reflect the removal of lodash. Signed-off-by: Innei <tukon479@gmail.com>
…ation - Modified the `type` property in SnippetModel to include an enum validation for SnippetType, ensuring that only valid types can be assigned. - Removed outdated snapshot tests for NoteController to streamline test suite and reduce clutter. Signed-off-by: Innei <tukon479@gmail.com>
…Model type validation - Refactored various controller tests to utilize a dynamic API route prefix for improved maintainability. - Updated the `type` property in SnippetModel to ensure enum validation is based on `Object.values(SnippetType)` for better type safety. Signed-off-by: Innei <tukon479@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Summary
common/zod/) with primitives, custom validators, and validation pipeChanges
class-validatordecorators with Zod schemas across all modules*.schema.tsfiles for Zod schemas (replacing*.dto.ts)shared/schema/ZodValidationPipe178 files changed