Files
trueref-legacy/src/lib/types.ts
Giancarmine Salucci 7630740403 feat(TRUEREF-0022): complete iteration 0 — worker-thread indexing, parallel jobs, SSE progress
- Move IndexingPipeline.run() into Worker Threads via WorkerPool
- Add dedicated embedding worker thread with single model instance
- Add stage/stageDetail columns to indexing_jobs schema
- Create ProgressBroadcaster for SSE channel management
- Add SSE endpoints: GET /api/v1/jobs/:id/stream, GET /api/v1/jobs/stream
- Replace UI polling with EventSource on repo detail and admin pages
- Add concurrency settings UI and API endpoint
- Build worker entries separately via esbuild
2026-03-30 17:08:23 +02:00

99 lines
2.7 KiB
TypeScript

/**
* Shared domain types for TrueRef.
* These re-export and extend the Drizzle-inferred schema types with
* application-level conveniences.
*/
export type {
Repository,
NewRepository,
RepositoryVersion,
NewRepositoryVersion,
Document,
NewDocument,
Snippet,
NewSnippet,
SnippetEmbedding,
NewSnippetEmbedding,
IndexingJob,
NewIndexingJob,
RepositoryConfig,
NewRepositoryConfig,
Settings,
NewSettings
} from './server/db/schema';
// ---------------------------------------------------------------------------
// Application-level union types (narrower than raw DB enums)
// ---------------------------------------------------------------------------
export type RepositorySource = 'github' | 'local';
export type RepositoryState = 'pending' | 'indexing' | 'indexed' | 'error';
export type SnippetType = 'code' | 'info';
export type JobStatus = 'queued' | 'running' | 'done' | 'failed';
export type IndexingStage = 'queued' | 'differential' | 'crawling' | 'cloning' | 'parsing' | 'storing' | 'embedding' | 'done' | 'failed';
export type VersionState = 'pending' | 'indexing' | 'indexed' | 'error';
export type EmbeddingProviderKind = 'local-transformers' | 'openai-compatible';
// ---------------------------------------------------------------------------
// API / service layer types
// ---------------------------------------------------------------------------
/** Payload accepted by the repository management service when adding a repo. */
export interface AddRepositoryInput {
id: string;
title: string;
description?: string;
source: RepositorySource;
sourceUrl: string;
branch?: string;
githubToken?: string;
}
/** Lightweight repository summary returned in list endpoints. */
export interface RepositorySummary {
id: string;
title: string;
description: string | null;
source: RepositorySource;
state: RepositoryState;
totalSnippets: number;
totalTokens: number;
trustScore: number;
stars: number | null;
lastIndexedAt: Date | null;
}
/** Snippet returned from search results. */
export interface SearchResultSnippet {
id: string;
repositoryId: string;
documentId: string;
type: SnippetType;
title: string | null;
content: string;
language: string | null;
breadcrumb: string | null;
tokenCount: number;
score?: number;
}
/** Search request parameters. */
export interface SearchQuery {
query: string;
libraryId?: string;
type?: SnippetType;
limit?: number;
}
/** Parsed trueref.json / context7.json configuration. */
export interface TrueRefConfig {
projectTitle?: string;
description?: string;
folders?: string[];
excludeFolders?: string[];
excludeFiles?: string[];
rules?: string[];
previousVersions?: Array<{ tag: string; title: string; commitHash?: string }>;
}