36 lines
997 B
TypeScript
36 lines
997 B
TypeScript
import {
|
|
RepositoryVersion,
|
|
RepositoryVersionDto,
|
|
RepositoryVersionEntity
|
|
} from '$lib/server/models/repository-version.js';
|
|
|
|
export class RepositoryVersionMapper {
|
|
static fromEntity(entity: RepositoryVersionEntity): RepositoryVersion {
|
|
return new RepositoryVersion({
|
|
id: entity.id,
|
|
repositoryId: entity.repository_id,
|
|
tag: entity.tag,
|
|
title: entity.title,
|
|
commitHash: entity.commit_hash,
|
|
state: entity.state,
|
|
totalSnippets: entity.total_snippets ?? 0,
|
|
indexedAt: entity.indexed_at != null ? new Date(entity.indexed_at * 1000) : null,
|
|
createdAt: new Date(entity.created_at * 1000)
|
|
});
|
|
}
|
|
|
|
static toDto(domain: RepositoryVersion): RepositoryVersionDto {
|
|
return new RepositoryVersionDto({
|
|
id: domain.id,
|
|
repositoryId: domain.repositoryId,
|
|
tag: domain.tag,
|
|
title: domain.title,
|
|
commitHash: domain.commitHash,
|
|
state: domain.state,
|
|
totalSnippets: domain.totalSnippets,
|
|
indexedAt: domain.indexedAt,
|
|
createdAt: domain.createdAt
|
|
});
|
|
}
|
|
}
|