test: define schema contract for topic fact graph
This commit is contained in:
34
src/core/schema.ts
Normal file
34
src/core/schema.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
export const TOPICS_TABLE = 'topics';
|
||||
export const FACTS_TABLE = 'facts';
|
||||
export const FACT_TOPICS_TABLE = 'fact_topics';
|
||||
|
||||
export const TOPIC_COLUMNS = [
|
||||
'id',
|
||||
'name',
|
||||
'normalized_name',
|
||||
'category',
|
||||
'granularity',
|
||||
'description',
|
||||
'metadata',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
] as const;
|
||||
|
||||
export const FACT_COLUMNS = [
|
||||
'id',
|
||||
'statement',
|
||||
'summary',
|
||||
'source',
|
||||
'confidence',
|
||||
'metadata',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
] as const;
|
||||
|
||||
export const FACT_TOPIC_COLUMNS = [
|
||||
'fact_id',
|
||||
'topic_id',
|
||||
'role',
|
||||
'position',
|
||||
'created_at',
|
||||
] as const;
|
||||
22
src/types/api.ts
Normal file
22
src/types/api.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { JsonValue, TopicCategory, TopicGranularity } from './domain';
|
||||
|
||||
export interface UpsertTopicInput {
|
||||
name: string;
|
||||
category?: TopicCategory;
|
||||
granularity?: TopicGranularity;
|
||||
description?: string | null;
|
||||
metadata?: JsonValue | null;
|
||||
}
|
||||
|
||||
export interface TopicLinkInput extends UpsertTopicInput {
|
||||
role?: string | null;
|
||||
}
|
||||
|
||||
export interface AddFactInput {
|
||||
statement: string;
|
||||
summary?: string | null;
|
||||
source?: string | null;
|
||||
confidence?: number | null;
|
||||
metadata?: JsonValue | null;
|
||||
topics: TopicLinkInput[];
|
||||
}
|
||||
7
src/types/database.ts
Normal file
7
src/types/database.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { FactRecord, FactTopicRecord, TopicRecord } from './domain';
|
||||
|
||||
export interface IdentityDatabaseSchema {
|
||||
topics: TopicRecord;
|
||||
facts: FactRecord;
|
||||
fact_topics: FactTopicRecord;
|
||||
}
|
||||
37
src/types/domain.ts
Normal file
37
src/types/domain.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
export type TopicCategory = 'entity' | 'concept' | 'temporal' | 'custom';
|
||||
|
||||
export type TopicGranularity = 'abstract' | 'concrete' | 'mixed';
|
||||
|
||||
export type JsonPrimitive = string | number | boolean | null;
|
||||
export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };
|
||||
|
||||
export interface TopicRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
normalized_name: string;
|
||||
category: TopicCategory;
|
||||
granularity: TopicGranularity;
|
||||
description: string | null;
|
||||
metadata: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface FactRecord {
|
||||
id: string;
|
||||
statement: string;
|
||||
summary: string | null;
|
||||
source: string | null;
|
||||
confidence: number | null;
|
||||
metadata: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface FactTopicRecord {
|
||||
fact_id: string;
|
||||
topic_id: string;
|
||||
role: string | null;
|
||||
position: number;
|
||||
created_at: string;
|
||||
}
|
||||
Reference in New Issue
Block a user