feat(domain): add seed dataset and domain barrel
Add SCHEMA_VERSION and createSeedDataset to initialize first-run state with three budget envelopes (Video Games, Food, Events and Social), newId() for generating unique identifiers, and complete the domain export barrel with all pure domain modules. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
564a5f4079
commit
438d53d016
3 files changed
+96
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import type { Dataset, MonthId, Post } from "./types.ts";
|
||||
|
||||
export const SCHEMA_VERSION = 1;
|
||||
|
||||
const SEED_POST_NAMES = ["Video Games", "Food", "Events and Social"] as const;
|
||||
|
||||
export function newId(): string {
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* The first-run dataset. Takes the start month as an argument because the
|
||||
* domain layer must not read the ambient clock.
|
||||
*/
|
||||
export function createSeedDataset(startMonth: MonthId): Dataset {
|
||||
const posts: Post[] = SEED_POST_NAMES.map((name, order) => ({
|
||||
id: newId(),
|
||||
name,
|
||||
order,
|
||||
archived: false,
|
||||
currency: "DKK",
|
||||
standingRule: { kind: "fixed", amount: { amount: 0, currency: "DKK" } },
|
||||
}));
|
||||
|
||||
return {
|
||||
settings: {
|
||||
baseCurrency: "DKK",
|
||||
foldStartMonth: startMonth,
|
||||
schemaVersion: SCHEMA_VERSION,
|
||||
},
|
||||
fxRates: [],
|
||||
posts,
|
||||
months: [
|
||||
{ id: startMonth, income: { amount: 0, currency: "DKK" }, ruleOverrides: {} },
|
||||
],
|
||||
purchases: [],
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user