From 74c3c7a805ff3baa6dca1b0950fb08a3cf85aac7 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 18 Jun 2025 14:24:07 +0300 Subject: [PATCH] feat(database): add TypeScript interfaces for database models and API responses --- src/types/database.ts | 84 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/types/database.ts diff --git a/src/types/database.ts b/src/types/database.ts new file mode 100644 index 0000000..76e23d9 --- /dev/null +++ b/src/types/database.ts @@ -0,0 +1,84 @@ +// Core Item type matching our Rust Item struct +export interface Item { + id: string; + name: string; + description: string; + wikidataId?: string; + customProperties: Record; +} + +// Database models (matching Prisma schema) +export interface DbUrl { + id: number; + url: string; + createdAt: Date; +} + +export interface DbProperty { + id: number; + name: string; + globalUsageCount: number; +} + +export interface DbItem { + id: string; + urlId: number; + wikidataId?: string; + itemOrder: number; + globalItemId: string; +} + +export interface DbItemProperty { + globalItemId: string; + propertyId: number; + value: string; +} + +export interface DbSelectedProperty { + urlId: number; + propertyId: number; +} + +export interface DbDeletedProperty { + urlId: number; + globalItemId: string; + propertyId: number; +} + +// API Response types +export interface ItemsResponse { + items: Item[]; + selectedProperties: string[]; +} + +export interface PropertyResponse { + id: number; + name: string; + globalUsageCount: number; +} + +// Wikidata types (for future integration) +export interface WikidataSuggestion { + id: string; + label: string; + description?: string; +} + +export interface WikidataProperty { + id: string; + label: string; + value: string; +} + +// Core properties that are always present +export const CORE_PROPERTIES = ['name', 'description'] as const; +export type CoreProperty = typeof CORE_PROPERTIES[number]; + +// Database operation results +export type DatabaseResult = { + success: true; + data: T; +} | { + success: false; + error: string; +}; \ No newline at end of file