Commit 8d87b53
refactor: migrate DTOs from class-validator to Zod (#2542)
* feat: init zod
* refactor(draft, meta-preset): migrate DTOs to Zod schemas and clean up 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 <[email protected]>
* chore: update zod dependency and refactor validation logic
- 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 <[email protected]>
* feat(post): add category filtering to post pagination and update PostPagerDto
- 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 <[email protected]>
* feat(draft): enhance draft management with published version tracking
- 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 <[email protected]>
* chore: update schemas to include missing imports and refactor validation 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 <[email protected]>
* chore: remove cls-hooked dependency and implement AsyncLocalStorage for 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 <[email protected]>
* test: add end-to-end and unit tests for RequestContext management
- 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 <[email protected]>
* Potential fix for code scanning alert no. 66: Unvalidated dynamic method call
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Innei <[email protected]>
* chore: replace lodash with es-toolkit and update dependencies
- 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 <[email protected]>
* fix(snippet): update SnippetModel type property to include enum validation
- 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 <[email protected]>
* refactor: update API routes to use dynamic prefix and enhance SnippetModel 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 <[email protected]>
---------
Signed-off-by: Innei <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>1 parent d03a881 commit 8d87b53
File tree
211 files changed
+6091
-6630
lines changed- .github/workflows
- apps/core
- external
- src
- common
- contexts
- decorators
- exceptions
- guards
- interceptors
- middlewares
- pipes
- zod
- decorators
- dto
- migration/helper
- modules
- ack
- activity
- dtos
- aggregate
- ai
- ai-summary
- ai-writer
- analyze
- auth
- backup
- category
- comment
- configs
- draft
- file
- health
- sub-controller
- init
- link
- markdown
- meta-preset
- note
- models
- option
- controllers
- dtoes
- pageproxy
- page
- post
- project
- recently
- render
- say
- search
- serverless
- snippet
- subscribe
- topic
- update
- user
- webhook
- processors
- gateway
- web
- dtos
- helper
- transformers
- utils
- test
- helper
- src
- common/contexts
- modules
- configs
- link
- note
- __snapshots__
- options
- post
- snippet
- user
- transformers
- __snapshots__
- packages
- api-client
- __tests__/helpers
- compiled
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
211 files changed
+6091
-6630
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
| 112 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 88 | | |
93 | 89 | | |
94 | 90 | | |
95 | 91 | | |
96 | 92 | | |
| 93 | + | |
97 | 94 | | |
98 | 95 | | |
99 | 96 | | |
| |||
103 | 100 | | |
104 | 101 | | |
105 | 102 | | |
106 | | - | |
107 | 103 | | |
108 | 104 | | |
109 | 105 | | |
| |||
114 | 110 | | |
115 | 111 | | |
116 | 112 | | |
| 113 | + | |
117 | 114 | | |
118 | 115 | | |
119 | 116 | | |
| |||
131 | 128 | | |
132 | 129 | | |
133 | 130 | | |
| 131 | + | |
134 | 132 | | |
135 | 133 | | |
136 | 134 | | |
| |||
139 | 137 | | |
140 | 138 | | |
141 | 139 | | |
142 | | - | |
143 | 140 | | |
144 | 141 | | |
145 | 142 | | |
146 | | - | |
147 | 143 | | |
148 | 144 | | |
149 | 145 | | |
| |||
165 | 161 | | |
166 | 162 | | |
167 | 163 | | |
168 | | - | |
| 164 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
| |||
129 | 128 | | |
130 | 129 | | |
131 | 130 | | |
132 | | - | |
133 | 131 | | |
134 | 132 | | |
135 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | | - | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
Lines changed: 28 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
0 commit comments