Files
outline/server/routes/api/batch/schema.ts
T
Tom Moor eceba73a14 chore: Upgrade koa-helmet to v9 and koa-body to v8 (#14046)
* chore: Upgrade koa-helmet to v9 and koa-body to v8

* fix: Keep decimal parsing for pagination limit and offset
2026-10-16 02:11:11 +00:00

28 lines
757 B
TypeScript

import { z } from "zod";
import { BatchMaxRequests } from "@shared/constants";
import { BaseSchema } from "../schema";
export const BatchSchema = BaseSchema.extend({
body: z.object({
requests: z
.array(
z.object({
/** The RPC method to invoke, e.g. "documents.update". */
method: z.string(),
/** The request body passed to the method. */
body: z.record(z.string(), z.json()).optional(),
})
)
.min(1)
.max(BatchMaxRequests, {
message: `A batch may contain at most ${BatchMaxRequests} requests`,
}),
}),
});
export type BatchReq = z.infer<typeof BatchSchema>;
export type BatchRequestBody = NonNullable<
BatchReq["body"]["requests"][number]["body"]
>;