1 import type { NodeMeta, PublicNodeMeta } from '@proton/drive-store'
2 import type { UseCaseInterface } from '../Domain/UseCase/UseCaseInterface'
3 import { Result } from '@proton/docs-shared'
4 import type { DocsApi } from '../Api/DocsApi'
5 import { Commit } from '@proton/docs-proto'
7 export class GetCommitData implements UseCaseInterface<Commit> {
8 constructor(private docsApi: DocsApi) {}
10 async execute(lookup: NodeMeta | PublicNodeMeta, commitId: string): Promise<Result<Commit>> {
11 const result = await this.docsApi.getCommitData(lookup, commitId)
13 if (result.isFailed()) {
14 return Result.fail(result.getError().message)
17 const commit = Commit.deserialize(result.getValue())
19 return Result.ok(commit)