File size: 1,654 Bytes
e1cc3bc | 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 44 45 46 47 48 49 50 51 52 | /**
* PDF Server Types - Simplified for didactic purposes
*/
import { z } from "zod";
// ============================================================================
// Core Types
// ============================================================================
export const PdfMetadataSchema = z.object({
title: z.string().optional(),
author: z.string().optional(),
pageCount: z.number(),
fileSizeBytes: z.number(),
});
export type PdfMetadata = z.infer<typeof PdfMetadataSchema>;
export const PdfEntrySchema = z.object({
url: z.string(), // Also serves as unique ID
metadata: PdfMetadataSchema,
});
export type PdfEntry = z.infer<typeof PdfEntrySchema>;
export const PdfIndexSchema = z.object({
entries: z.array(PdfEntrySchema),
});
export type PdfIndex = z.infer<typeof PdfIndexSchema>;
// ============================================================================
// Chunked Binary Loading
// ============================================================================
/** Max bytes per response chunk */
export const MAX_CHUNK_BYTES = 500 * 1024; // 500KB
export const PdfBytesChunkSchema = z.object({
url: z.string(),
bytes: z.string(), // base64
offset: z.number(),
byteCount: z.number(),
totalBytes: z.number(),
hasMore: z.boolean(),
});
export type PdfBytesChunk = z.infer<typeof PdfBytesChunkSchema>;
export const ReadPdfBytesInputSchema = z.object({
url: z.string().describe("PDF URL"),
offset: z.number().min(0).default(0).describe("Byte offset"),
byteCount: z.number().default(MAX_CHUNK_BYTES).describe("Bytes to read"),
});
export type ReadPdfBytesInput = z.infer<typeof ReadPdfBytesInputSchema>;
|