ManimCat / src /studio-agent /works /memory-work-result-store.ts
Bin29's picture
Sync from main: 68df783 feat: support multimodal studio reference images
d47b053
import type { StudioWorkResult, StudioWorkResultStore } from '../domain/types'
export class InMemoryStudioWorkResultStore implements StudioWorkResultStore {
private readonly results = new Map<string, StudioWorkResult>()
async create(result: StudioWorkResult): Promise<StudioWorkResult> {
this.results.set(result.id, result)
return result
}
async getById(resultId: string): Promise<StudioWorkResult | null> {
return this.results.get(resultId) ?? null
}
async update(resultId: string, patch: Partial<StudioWorkResult>): Promise<StudioWorkResult | null> {
const current = this.results.get(resultId)
if (!current) {
return null
}
const next: StudioWorkResult = {
...current,
...patch
}
this.results.set(resultId, next)
return next
}
async listByWorkId(workId: string): Promise<StudioWorkResult[]> {
return [...this.results.values()].filter((result) => result.workId === workId)
}
}