187 lines
4.4 KiB
TypeScript
187 lines
4.4 KiB
TypeScript
export interface ContextRepositoryJsonDtoProps {
|
|
id: string;
|
|
title: string;
|
|
source: 'github' | 'local';
|
|
sourceUrl: string;
|
|
branch: string | null;
|
|
isLocal: boolean;
|
|
}
|
|
|
|
export class ContextRepositoryJsonDto {
|
|
id: string;
|
|
title: string;
|
|
source: 'github' | 'local';
|
|
sourceUrl: string;
|
|
branch: string | null;
|
|
isLocal: boolean;
|
|
|
|
constructor(props: ContextRepositoryJsonDtoProps) {
|
|
this.id = props.id;
|
|
this.title = props.title;
|
|
this.source = props.source;
|
|
this.sourceUrl = props.sourceUrl;
|
|
this.branch = props.branch;
|
|
this.isLocal = props.isLocal;
|
|
}
|
|
}
|
|
|
|
export interface ContextVersionJsonDtoProps {
|
|
requested: string | null;
|
|
resolved: string | null;
|
|
id: string | null;
|
|
}
|
|
|
|
export class ContextVersionJsonDto {
|
|
requested: string | null;
|
|
resolved: string | null;
|
|
id: string | null;
|
|
|
|
constructor(props: ContextVersionJsonDtoProps) {
|
|
this.requested = props.requested;
|
|
this.resolved = props.resolved;
|
|
this.id = props.id;
|
|
}
|
|
}
|
|
|
|
export interface SnippetOriginJsonDtoProps {
|
|
repositoryId: string;
|
|
repositoryTitle: string;
|
|
source: 'github' | 'local';
|
|
sourceUrl: string;
|
|
version: string | null;
|
|
versionId: string | null;
|
|
isLocal: boolean;
|
|
}
|
|
|
|
export class SnippetOriginJsonDto {
|
|
repositoryId: string;
|
|
repositoryTitle: string;
|
|
source: 'github' | 'local';
|
|
sourceUrl: string;
|
|
version: string | null;
|
|
versionId: string | null;
|
|
isLocal: boolean;
|
|
|
|
constructor(props: SnippetOriginJsonDtoProps) {
|
|
this.repositoryId = props.repositoryId;
|
|
this.repositoryTitle = props.repositoryTitle;
|
|
this.source = props.source;
|
|
this.sourceUrl = props.sourceUrl;
|
|
this.version = props.version;
|
|
this.versionId = props.versionId;
|
|
this.isLocal = props.isLocal;
|
|
}
|
|
}
|
|
|
|
export class LibrarySearchJsonResultDto {
|
|
id: string;
|
|
title: string;
|
|
description: string | null;
|
|
branch: string | null;
|
|
lastUpdateDate: string | null;
|
|
state: 'initial' | 'finalized' | 'error';
|
|
totalTokens: number | null;
|
|
totalSnippets: number | null;
|
|
stars: number | null;
|
|
trustScore: number | null;
|
|
benchmarkScore: number | null;
|
|
versions: string[];
|
|
source: string;
|
|
|
|
constructor(props: LibrarySearchJsonResultDto) {
|
|
this.id = props.id;
|
|
this.title = props.title;
|
|
this.description = props.description;
|
|
this.branch = props.branch;
|
|
this.lastUpdateDate = props.lastUpdateDate;
|
|
this.state = props.state;
|
|
this.totalTokens = props.totalTokens;
|
|
this.totalSnippets = props.totalSnippets;
|
|
this.stars = props.stars;
|
|
this.trustScore = props.trustScore;
|
|
this.benchmarkScore = props.benchmarkScore;
|
|
this.versions = props.versions;
|
|
this.source = props.source;
|
|
}
|
|
}
|
|
|
|
export class LibrarySearchJsonResponseDto {
|
|
results: LibrarySearchJsonResultDto[];
|
|
|
|
constructor(results: LibrarySearchJsonResultDto[]) {
|
|
this.results = results;
|
|
}
|
|
}
|
|
|
|
export class CodeListItemDto {
|
|
language: string;
|
|
code: string;
|
|
|
|
constructor(props: CodeListItemDto) {
|
|
this.language = props.language;
|
|
this.code = props.code;
|
|
}
|
|
}
|
|
|
|
export class CodeSnippetJsonDto {
|
|
type: 'code' = 'code';
|
|
title: string | null;
|
|
description: string | null;
|
|
language: string | null;
|
|
codeList: CodeListItemDto[];
|
|
id: string;
|
|
tokenCount: number | null;
|
|
pageTitle: string | null;
|
|
origin: SnippetOriginJsonDto | null;
|
|
|
|
constructor(props: Omit<CodeSnippetJsonDto, 'type'>) {
|
|
this.title = props.title;
|
|
this.description = props.description;
|
|
this.language = props.language;
|
|
this.codeList = props.codeList;
|
|
this.id = props.id;
|
|
this.tokenCount = props.tokenCount;
|
|
this.pageTitle = props.pageTitle;
|
|
this.origin = props.origin;
|
|
}
|
|
}
|
|
|
|
export class InfoSnippetJsonDto {
|
|
type: 'info' = 'info';
|
|
text: string;
|
|
breadcrumb: string | null;
|
|
pageId: string;
|
|
tokenCount: number | null;
|
|
origin: SnippetOriginJsonDto | null;
|
|
|
|
constructor(props: Omit<InfoSnippetJsonDto, 'type'>) {
|
|
this.text = props.text;
|
|
this.breadcrumb = props.breadcrumb;
|
|
this.pageId = props.pageId;
|
|
this.tokenCount = props.tokenCount;
|
|
this.origin = props.origin;
|
|
}
|
|
}
|
|
|
|
export type SnippetJsonDto = CodeSnippetJsonDto | InfoSnippetJsonDto;
|
|
|
|
export class ContextJsonResponseDto {
|
|
snippets: SnippetJsonDto[];
|
|
rules: string[];
|
|
totalTokens: number;
|
|
localSource: boolean;
|
|
repository: ContextRepositoryJsonDto | null;
|
|
version: ContextVersionJsonDto | null;
|
|
resultCount: number;
|
|
|
|
constructor(props: ContextJsonResponseDto) {
|
|
this.snippets = props.snippets;
|
|
this.rules = props.rules;
|
|
this.totalTokens = props.totalTokens;
|
|
this.localSource = props.localSource;
|
|
this.repository = props.repository;
|
|
this.version = props.version;
|
|
this.resultCount = props.resultCount;
|
|
}
|
|
}
|