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
@@ -0,0 +1,57 @@
/**
* 积分历史记录模型 - 对应后端 CreditsHistoryData schema
* 原始 Dart: CreditsHistoryData (lib/data/models/user/user.dart)
*
* 注:原始 Dart 中 `records` 为 `List<Map<String, dynamic>>`
* 迁移为 `Record<string, unknown>[]`。
*/
export class CreditsHistoryData {
readonly records: Record<string, unknown>[];
readonly total: number;
readonly limit: number;
readonly offset: number;
constructor(params: {
records: Record<string, unknown>[];
total: number;
limit: number;
offset: number;
}) {
this.records = params.records;
this.total = params.total;
this.limit = params.limit;
this.offset = params.offset;
Object.freeze(this);
}
toJson(): Record<string, unknown> {
return {
records: this.records,
total: this.total,
limit: this.limit,
offset: this.offset,
};
}
static fromJson(json: Record<string, unknown>): CreditsHistoryData {
const requireNumber = (key: string): number => {
const v = json[key];
if (typeof v !== "number") {
throw new Error(
`CreditsHistoryData.${key} is required and must be a number`
);
}
return v;
};
const rawRecords = json.records;
const records: Record<string, unknown>[] = Array.isArray(rawRecords)
? (rawRecords as Record<string, unknown>[])
: [];
return new CreditsHistoryData({
records,
total: requireNumber("total"),
limit: requireNumber("limit"),
offset: requireNumber("offset"),
});
}
}