-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathshapeshift.ts
More file actions
43 lines (38 loc) · 1.25 KB
/
Copy pathshapeshift.ts
File metadata and controls
43 lines (38 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { z } from "zod";
import { bookIDSchema } from "./book.js";
export const CreateJobValidator = z.object({
body: z.object({
highPriority: z.boolean().optional(),
url: z.url(),
}),
});
export const GetJobsValidator = z.object({
query: z.object({
limit: z.coerce.number().int().nonnegative().default(100),
offset: z.coerce.number().int().nonnegative().default(0),
sort: z.enum(['asc', 'desc']).default('desc'),
status: z
.preprocess(
(val) => (typeof val === 'string' ? val.split(',') : val),
z.array(z.enum(['created', 'inprogress', 'failed', 'finished'])),
)
.optional(),
}),
});
/**
* Book-scoped routes are addressed by bookID and authorized against the Project
* that owns the book, so the path param is all they take.
*/
export const BookScopedValidator = z.object({
params: z.object({
bookID: bookIDSchema,
}),
});
export const WebhookValidator = z.object({
body: z.object({
bookID: bookIDSchema,
contentPageCount: z.number().int().nonnegative().optional(),
timestamp: z.number().int().nonnegative(), // Unix timestamp in milliseconds
customCoverOrg: z.string().trim().min(1).max(255).optional(), // Only set if the book has a custom cover by the producing org
}),
});