-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Add endpoint PATCH `/projects/:projectId/folders/:folderI…
…d` (no-changelog) (#13454)
- Loading branch information
1 parent
b50658c
commit f7f5f5e
Showing
10 changed files
with
217 additions
and
5 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
packages/@n8n/api-types/src/dto/folders/__tests__/update-folder.request.dto.test.ts
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { UpdateFolderDto } from '../update-folder.dto'; | ||
|
||
describe('UpdateFolderDto', () => { | ||
describe('Valid requests', () => { | ||
test.each([ | ||
{ | ||
name: 'name without parentId', | ||
request: { | ||
name: 'test', | ||
}, | ||
}, | ||
])('should validate $name', ({ request }) => { | ||
const result = UpdateFolderDto.safeParse(request); | ||
expect(result.success).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('Invalid requests', () => { | ||
test.each([ | ||
{ | ||
name: 'missing name', | ||
request: {}, | ||
expectedErrorPath: ['name'], | ||
}, | ||
{ | ||
name: 'empty name', | ||
request: { | ||
name: '', | ||
}, | ||
expectedErrorPath: ['name'], | ||
}, | ||
])('should fail validation for $name', ({ request, expectedErrorPath }) => { | ||
const result = UpdateFolderDto.safeParse(request); | ||
|
||
expect(result.success).toBe(false); | ||
|
||
if (expectedErrorPath) { | ||
expect(result.error?.issues[0].path).toEqual(expectedErrorPath); | ||
} | ||
}); | ||
}); | ||
}); |
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,7 +1,9 @@ | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
import { folderNameSchema } from '../../schemas/folder.schema'; | ||
|
||
export class CreateFolderDto extends Z.class({ | ||
name: z.string().trim().min(1).max(128), | ||
name: folderNameSchema, | ||
parentFolderId: z.string().optional(), | ||
}) {} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Z } from 'zod-class'; | ||
|
||
import { folderNameSchema } from '../../schemas/folder.schema'; | ||
|
||
export class UpdateFolderDto extends Z.class({ | ||
name: folderNameSchema, | ||
}) {} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { z } from 'zod'; | ||
|
||
export const folderNameSchema = z.string().trim().min(1).max(128); |
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