feat: setup barrelsby for automatic barrel file generation

Add barrelsby as a dev dependency with a `generate-barrels` npm script and a `barrelesby.json` config targeting `./src`. This automates creation of barrel/index files to simplify imports across the project.
This commit is contained in:
2026-06-08 13:07:37 +08:00
parent 14d6e7c41e
commit c22b90c7f4
41 changed files with 2165 additions and 1 deletions
+59
View File
@@ -0,0 +1,59 @@
/**
* 最近记忆模型
* 原始 Dart: RecentMemory (lib/data/models/user/recent_memory.dart)
*
* 注:原始 Dart 中 `createdAt` 为 `String?`,按"全部非空"约定兜底为空串。
*/
export class RecentMemory {
readonly type: string;
readonly content: string;
readonly importance: number;
readonly createdAt: string;
constructor(params: {
type: string;
content: string;
importance: number;
createdAt?: string;
}) {
this.type = params.type;
this.content = params.content;
this.importance = params.importance;
this.createdAt = params.createdAt ?? "";
Object.freeze(this);
}
toJson(): Record<string, unknown> {
return {
type: this.type,
content: this.content,
importance: this.importance,
createdAt: this.createdAt,
};
}
static fromJson(json: Record<string, unknown>): RecentMemory {
const requireString = (key: string): string => {
const v = json[key];
if (typeof v !== "string") {
throw new Error(
`RecentMemory.${key} is required and must be a string`
);
}
return v;
};
const importance = json.importance;
if (typeof importance !== "number") {
throw new Error(
"RecentMemory.importance is required and must be a number"
);
}
return new RecentMemory({
type: requireString("type"),
content: requireString("content"),
importance,
createdAt:
typeof json.createdAt === "string" ? json.createdAt : undefined,
});
}
}