fix: Document import schema
This commit is contained in:
@@ -1074,12 +1074,14 @@ router.post(
|
||||
auth(),
|
||||
validate(T.DocumentsImportSchema),
|
||||
async (ctx: APIContext<T.DocumentsImportReq>) => {
|
||||
const { publish, collectionId, parentDocumentId } = ctx.input;
|
||||
|
||||
if (!ctx.is("multipart/form-data")) {
|
||||
throw InvalidRequestError("Request type must be multipart/form-data");
|
||||
}
|
||||
|
||||
// String as this is always multipart/form-data
|
||||
const publish = ctx.input.publish === "true";
|
||||
const { collectionId, parentDocumentId } = ctx.input;
|
||||
|
||||
const file = ctx.request.files
|
||||
? Object.values(ctx.request.files)[0]
|
||||
: undefined;
|
||||
|
||||
@@ -231,8 +231,8 @@ export const DocumentsUnpublishSchema = BaseIdSchema.extend({});
|
||||
export type DocumentsUnpublishReq = z.infer<typeof DocumentsUnpublishSchema>;
|
||||
|
||||
export const DocumentsImportSchema = z.object({
|
||||
/** Whether to publish the imported docs */
|
||||
publish: z.boolean().optional(),
|
||||
/** Whether to publish the imported docs. String due to multi-part form upload */
|
||||
publish: z.string().optional(),
|
||||
|
||||
/** Import docs to this collection */
|
||||
collectionId: z.string().uuid(),
|
||||
|
||||
Reference in New Issue
Block a user