From 5ddc36555d540c6eecd4b24a6f68c613c5405ae0 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Fri, 21 Jun 2024 20:34:31 -0400 Subject: [PATCH] fix: Remove breaking requirement to not pass collectionId with parentDocumentId. This was regressed as part of 95b94532695ab41f0e12ff24d0445ca82d28d4ba and unfortunately is a breaking change for API consumers --- server/routes/api/documents/documents.test.ts | 20 ------------------- server/routes/api/documents/schema.ts | 3 --- 2 files changed, 23 deletions(-) diff --git a/server/routes/api/documents/documents.test.ts b/server/routes/api/documents/documents.test.ts index 793dc6b1b..d7be7b323 100644 --- a/server/routes/api/documents/documents.test.ts +++ b/server/routes/api/documents/documents.test.ts @@ -2868,26 +2868,6 @@ describe("#documents.create", () => { ); }); - it("should not allow creating a nested doc with a collection", async () => { - const team = await buildTeam(); - const user = await buildUser({ teamId: team.id }); - const res = await server.post("/api/documents.create", { - body: { - token: user.getJwtToken(), - collectionId: "d7a4eb73-fac1-4028-af45-d7e34d54db8e", - parentDocumentId: "d7a4eb73-fac1-4028-af45-d7e34d54db8e", - title: "nested doc", - text: "nested doc without collection", - }, - }); - const body = await res.json(); - - expect(res.status).toEqual(400); - expect(body.message).toBe( - "collectionId is inferred when creating a nested document" - ); - }); - it("should not allow very long titles", async () => { const team = await buildTeam(); const user = await buildUser({ teamId: team.id }); diff --git a/server/routes/api/documents/schema.ts b/server/routes/api/documents/schema.ts index 61771022d..8d40117d5 100644 --- a/server/routes/api/documents/schema.ts +++ b/server/routes/api/documents/schema.ts @@ -348,9 +348,6 @@ export const DocumentsCreateSchema = BaseSchema.extend({ template: z.boolean().optional(), }), }) - .refine((req) => !req.body.parentDocumentId || !req.body.collectionId, { - message: "collectionId is inferred when creating a nested document", - }) .refine((req) => !(req.body.template && !req.body.collectionId), { message: "collectionId is required to create a template document", })