update imports/exports

This commit is contained in:
Amruth Pillai
2026-02-08 00:28:28 +01:00
parent cc01fb9418
commit 5bdc6de862
6 changed files with 30 additions and 24 deletions
+2 -8
View File
@@ -2,6 +2,7 @@ import { createSelectSchema } from "drizzle-zod";
import z from "zod";
import { schema } from "@/integrations/drizzle";
import { resumeDataSchema } from "@/schema/resume/data";
import { jsonPatchOperationSchema } from "@/utils/resume/patch";
const resumeSchema = createSelectSchema(schema.resume, {
id: z.string().describe("The ID of the resume."),
@@ -81,14 +82,7 @@ export const resumeDto = {
input: z.object({
id: z.string().describe("The ID of the resume to patch."),
operations: z
.array(
z.object({
op: z.enum(["add", "remove", "replace", "move", "copy", "test"]),
path: z.string(),
value: z.any().optional(),
from: z.string().optional(),
}),
)
.array(jsonPatchOperationSchema)
.min(1)
.describe("An array of JSON Patch (RFC 6902) operations to apply to the resume data."),
}),
+1 -2
View File
@@ -1,4 +1,3 @@
import type { Operation } from "fast-json-patch";
import z from "zod";
import { sampleResumeData } from "@/schema/resume/sample";
import { generateRandomName, slugify } from "@/utils/string";
@@ -215,7 +214,7 @@ export const resumeRouter = {
return await resumeService.patch({
id: input.id,
userId: context.user.id,
operations: input.operations as Operation[],
operations: input.operations,
});
}),
+8 -8
View File
@@ -15,9 +15,9 @@ import { defaultResumeData, resumeDataSchema } from "@/schema/resume/data";
export const aiProviderSchema = z.enum(["ollama", "openai", "gemini", "anthropic", "vercel-ai-gateway"]);
export type AIProvider = z.infer<typeof aiProviderSchema>;
type AIProvider = z.infer<typeof aiProviderSchema>;
export type GetModelInput = {
type GetModelInput = {
provider: AIProvider;
model: string;
apiKey: string;
@@ -49,9 +49,9 @@ export const fileInputSchema = z.object({
data: z.string(), // base64 encoded
});
export type TestConnectionInput = z.infer<typeof aiCredentialsSchema>;
type TestConnectionInput = z.infer<typeof aiCredentialsSchema>;
export async function testConnection(input: TestConnectionInput): Promise<boolean> {
async function testConnection(input: TestConnectionInput): Promise<boolean> {
const RESPONSE_OK = "1";
const result = await generateText({
@@ -63,11 +63,11 @@ export async function testConnection(input: TestConnectionInput): Promise<boolea
return result.output === RESPONSE_OK;
}
export type ParsePdfInput = z.infer<typeof aiCredentialsSchema> & {
type ParsePdfInput = z.infer<typeof aiCredentialsSchema> & {
file: z.infer<typeof fileInputSchema>;
};
export async function parsePdf(input: ParsePdfInput): Promise<ResumeData> {
async function parsePdf(input: ParsePdfInput): Promise<ResumeData> {
const model = getModel(input);
const result = await generateText({
@@ -101,12 +101,12 @@ export async function parsePdf(input: ParsePdfInput): Promise<ResumeData> {
});
}
export type ParseDocxInput = z.infer<typeof aiCredentialsSchema> & {
type ParseDocxInput = z.infer<typeof aiCredentialsSchema> & {
file: z.infer<typeof fileInputSchema>;
mediaType: "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
};
export async function parseDocx(input: ParseDocxInput): Promise<ResumeData> {
async function parseDocx(input: ParseDocxInput): Promise<ResumeData> {
const model = getModel(input);
const result = await generateText({
+3 -3
View File
@@ -82,7 +82,7 @@ export function isImageFile(mimeType: string): boolean {
return IMAGE_MIME_TYPES.includes(mimeType);
}
export interface ProcessedImage {
interface ProcessedImage {
data: Uint8Array;
contentType: string;
}
@@ -316,7 +316,7 @@ export function getStorageService(): StorageService {
// High-level upload types
type UploadType = "picture" | "screenshot" | "pdf";
export interface UploadFileInput {
interface UploadFileInput {
userId: string;
data: Uint8Array;
contentType: string;
@@ -324,7 +324,7 @@ export interface UploadFileInput {
resumeId?: string;
}
export interface UploadFileResult {
interface UploadFileResult {
url: string;
key: string;
}
+2 -2
View File
@@ -8,7 +8,7 @@ import { getSectionTitle as getDefaultSectionTitle } from "./section";
// ============================================================================
/** Target section that an item can be moved to */
export type MoveTargetSection = {
type MoveTargetSection = {
sectionId: string;
sectionTitle: string;
/** Whether this is a standard section (true) or custom section (false) */
@@ -16,7 +16,7 @@ export type MoveTargetSection = {
};
/** Page with its compatible sections for the move menu */
export type MoveTargetPage = {
type MoveTargetPage = {
pageIndex: number;
sections: MoveTargetSection[];
};
+14 -1
View File
@@ -1,8 +1,21 @@
import type { JsonPatchError, Operation } from "fast-json-patch";
import jsonpatch from "fast-json-patch";
import z from "zod";
import { type ResumeData, resumeDataSchema } from "@/schema/resume/data";
export type { Operation };
/**
* A Zod schema that models JSON Patch (RFC 6902) operations as a discriminated union on `op`.
* This ensures required fields (`value` for add/replace/test, `from` for move/copy) are
* validated at the request boundary rather than failing later at the `fast-json-patch` layer.
*/
export const jsonPatchOperationSchema = z.discriminatedUnion("op", [
z.object({ op: z.literal("add"), path: z.string(), value: z.any() }),
z.object({ op: z.literal("remove"), path: z.string() }),
z.object({ op: z.literal("replace"), path: z.string(), value: z.any() }),
z.object({ op: z.literal("move"), path: z.string(), from: z.string() }),
z.object({ op: z.literal("copy"), path: z.string(), from: z.string() }),
z.object({ op: z.literal("test"), path: z.string(), value: z.any() }),
]);
/**
* A structured error thrown when a JSON Patch operation fails.