aps-agent/server/app/projects.ts

29 lines
776 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 项目存储(A1 阶段内存实现)。
*
* 开发期内置一个默认项目,避免本地启动后无项目可用;
* A3.7 落库后换成持久层,默认项目由种子脚本负责。
*/
import type { ProjectSummary } from '@aps/contracts';
export class ProjectStore {
private readonly projects = new Map<string, ProjectSummary>();
constructor() {
const defaultProject: ProjectSummary = {
projectId: 'p-default',
name: '默认项目',
status: 'active',
writable: true,
};
this.projects.set(defaultProject.projectId, defaultProject);
}
list(): ProjectSummary[] {
return [...this.projects.values()];
}
get(projectId: string): ProjectSummary | undefined {
return this.projects.get(projectId);
}
}