feat(database): add TypeScript interfaces for database models and API responses
This commit is contained in:
parent
c7dc18f7b2
commit
74c3c7a805
1 changed files with 84 additions and 0 deletions
84
src/types/database.ts
Normal file
84
src/types/database.ts
Normal file
|
@ -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<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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<T> = {
|
||||||
|
success: true;
|
||||||
|
data: T;
|
||||||
|
} | {
|
||||||
|
success: false;
|
||||||
|
error: string;
|
||||||
|
};
|
Loading…
Add table
Reference in a new issue