mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-24 23:32:19 +10:00
fix(api): cap bulk application operation id arrays
This commit is contained in:
@@ -83,3 +83,24 @@ describe("applicationDto zero-argument inputs", () => {
|
|||||||
expect(applicationDto.tags.input.parse(undefined)).toEqual({});
|
expect(applicationDto.tags.input.parse(undefined)).toEqual({});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Bulk operations cap `ids` at 200 to bound memory/DB work from a single call.
|
||||||
|
describe("applicationDto bulk id caps", () => {
|
||||||
|
const idsOfLength = (n: number) => Array.from({ length: n }, (_, i) => String(i));
|
||||||
|
|
||||||
|
it("rejects a bulkDelete ids array over the cap", () => {
|
||||||
|
expect(applicationDto.bulkDelete.input.safeParse({ ids: idsOfLength(201) }).success).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("accepts a bulkDelete ids array at the cap", () => {
|
||||||
|
expect(applicationDto.bulkDelete.input.safeParse({ ids: idsOfLength(200) }).success).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("rejects a bulkUpdate ids array over the cap", () => {
|
||||||
|
expect(applicationDto.bulkUpdate.input.safeParse({ ids: idsOfLength(201) }).success).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("accepts a bulkUpdate ids array at the cap", () => {
|
||||||
|
expect(applicationDto.bulkUpdate.input.safeParse({ ids: idsOfLength(200) }).success).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ export const applicationDto = {
|
|||||||
// Table bulk actions: move stage, archive/unarchive, add tags across a selection.
|
// Table bulk actions: move stage, archive/unarchive, add tags across a selection.
|
||||||
bulkUpdate: {
|
bulkUpdate: {
|
||||||
input: z.object({
|
input: z.object({
|
||||||
ids: z.array(z.string()).min(1),
|
ids: z.array(z.string()).min(1).max(200, "Too many items in a single bulk operation"),
|
||||||
status: applicationStatusSchema.optional(),
|
status: applicationStatusSchema.optional(),
|
||||||
archived: z.boolean().optional(),
|
archived: z.boolean().optional(),
|
||||||
addTags: z.array(z.string()).optional(),
|
addTags: z.array(z.string()).optional(),
|
||||||
@@ -171,7 +171,7 @@ export const applicationDto = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
bulkDelete: {
|
bulkDelete: {
|
||||||
input: z.object({ ids: z.array(z.string()).min(1) }),
|
input: z.object({ ids: z.array(z.string()).min(1).max(200, "Too many items in a single bulk operation") }),
|
||||||
output: z.object({ deleted: z.number() }),
|
output: z.object({ deleted: z.number() }),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user