- Add upsertGlobalItemSchema and bulkUpsertGlobalItemsSchema to schemas.ts - Add UpsertGlobalItemInput and BulkUpsertGlobalItemsInput types to types.ts - Implement upsertGlobalItem with onConflictDoUpdate and tag sync - Implement bulkUpsertGlobalItems processing array in single transaction - Fix migration 0003 to only add new columns + unique constraint - All 21 tests pass including 8 new upsert operation tests
70 lines
2.4 KiB
TypeScript
70 lines
2.4 KiB
TypeScript
import type { z } from "zod";
|
|
import type {
|
|
categories,
|
|
globalItems,
|
|
globalItemTags,
|
|
items,
|
|
setupItems,
|
|
setups,
|
|
tags,
|
|
threadCandidates,
|
|
threads,
|
|
} from "../db/schema.ts";
|
|
import type {
|
|
bulkUpsertGlobalItemsSchema,
|
|
createCandidateSchema,
|
|
createCategorySchema,
|
|
createItemSchema,
|
|
createSetupSchema,
|
|
createThreadSchema,
|
|
reorderCandidatesSchema,
|
|
resolveThreadSchema,
|
|
searchGlobalItemsSchema,
|
|
syncSetupItemsSchema,
|
|
updateCandidateSchema,
|
|
updateCategorySchema,
|
|
updateClassificationSchema,
|
|
updateItemSchema,
|
|
updateProfileSchema,
|
|
updateSetupSchema,
|
|
updateThreadSchema,
|
|
upsertGlobalItemSchema,
|
|
} from "./schemas.ts";
|
|
|
|
// Types inferred from Zod schemas
|
|
export type CreateItem = z.infer<typeof createItemSchema>;
|
|
export type UpdateItem = z.infer<typeof updateItemSchema>;
|
|
export type CreateCategory = z.infer<typeof createCategorySchema>;
|
|
export type UpdateCategory = z.infer<typeof updateCategorySchema>;
|
|
export type CreateThread = z.infer<typeof createThreadSchema>;
|
|
export type UpdateThread = z.infer<typeof updateThreadSchema>;
|
|
export type CreateCandidate = z.infer<typeof createCandidateSchema>;
|
|
export type UpdateCandidate = z.infer<typeof updateCandidateSchema>;
|
|
export type ResolveThread = z.infer<typeof resolveThreadSchema>;
|
|
export type ReorderCandidates = z.infer<typeof reorderCandidatesSchema>;
|
|
|
|
// Setup types
|
|
export type CreateSetup = z.infer<typeof createSetupSchema>;
|
|
export type UpdateSetup = z.infer<typeof updateSetupSchema>;
|
|
export type SyncSetupItems = z.infer<typeof syncSetupItemsSchema>;
|
|
export type UpdateClassification = z.infer<typeof updateClassificationSchema>;
|
|
|
|
// Global item types
|
|
export type SearchGlobalItems = z.infer<typeof searchGlobalItemsSchema>;
|
|
export type UpdateProfile = z.infer<typeof updateProfileSchema>;
|
|
export type UpsertGlobalItemInput = z.infer<typeof upsertGlobalItemSchema>;
|
|
export type BulkUpsertGlobalItemsInput = z.infer<
|
|
typeof bulkUpsertGlobalItemsSchema
|
|
>;
|
|
|
|
// Types inferred from Drizzle schema
|
|
export type Item = typeof items.$inferSelect;
|
|
export type Category = typeof categories.$inferSelect;
|
|
export type Thread = typeof threads.$inferSelect;
|
|
export type ThreadCandidate = typeof threadCandidates.$inferSelect;
|
|
export type Setup = typeof setups.$inferSelect;
|
|
export type SetupItem = typeof setupItems.$inferSelect;
|
|
export type GlobalItem = typeof globalItems.$inferSelect;
|
|
export type Tag = typeof tags.$inferSelect;
|
|
export type GlobalItemTag = typeof globalItemTags.$inferSelect;
|