@contractspec/example.wealth-snapshot 1.57.0 → 1.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/docs/index.js +93 -0
- package/dist/browser/docs/wealth-snapshot.docblock.js +93 -0
- package/dist/browser/entities/index.js +191 -0
- package/dist/browser/events.js +111 -0
- package/dist/browser/example.js +42 -0
- package/dist/browser/handlers/index.js +5 -0
- package/dist/browser/index.js +885 -0
- package/dist/browser/operations/index.js +238 -0
- package/dist/browser/presentations/index.js +11 -0
- package/dist/browser/presentations.js +124 -0
- package/dist/browser/wealth-snapshot.capability.js +40 -0
- package/dist/browser/wealth-snapshot.feature.js +72 -0
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +94 -1
- package/dist/docs/wealth-snapshot.docblock.d.ts +2 -1
- package/dist/docs/wealth-snapshot.docblock.d.ts.map +1 -0
- package/dist/docs/wealth-snapshot.docblock.js +45 -55
- package/dist/entities/index.d.ts +120 -125
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +181 -219
- package/dist/events.d.ts +167 -173
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +103 -172
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +41 -54
- package/dist/handlers/index.d.ts +1 -4
- package/dist/handlers/index.d.ts.map +1 -1
- package/dist/handlers/index.js +5 -8
- package/dist/index.d.ts +12 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +882 -23
- package/dist/node/docs/index.js +93 -0
- package/dist/node/docs/wealth-snapshot.docblock.js +93 -0
- package/dist/node/entities/index.js +191 -0
- package/dist/node/events.js +111 -0
- package/dist/node/example.js +42 -0
- package/dist/node/handlers/index.js +5 -0
- package/dist/node/index.js +885 -0
- package/dist/node/operations/index.js +238 -0
- package/dist/node/presentations/index.js +11 -0
- package/dist/node/presentations.js +124 -0
- package/dist/node/wealth-snapshot.capability.js +40 -0
- package/dist/node/wealth-snapshot.feature.js +72 -0
- package/dist/operations/index.d.ts +392 -398
- package/dist/operations/index.d.ts.map +1 -1
- package/dist/operations/index.js +237 -425
- package/dist/presentations/index.d.ts +1 -4
- package/dist/presentations/index.d.ts.map +1 -1
- package/dist/presentations/index.js +11 -11
- package/dist/presentations.d.ts +5 -10
- package/dist/presentations.d.ts.map +1 -1
- package/dist/presentations.js +120 -127
- package/dist/wealth-snapshot.capability.d.ts +3 -8
- package/dist/wealth-snapshot.capability.d.ts.map +1 -1
- package/dist/wealth-snapshot.capability.js +41 -46
- package/dist/wealth-snapshot.feature.d.ts +1 -6
- package/dist/wealth-snapshot.feature.d.ts.map +1 -1
- package/dist/wealth-snapshot.feature.js +71 -139
- package/package.json +144 -37
- package/dist/docs/wealth-snapshot.docblock.js.map +0 -1
- package/dist/entities/index.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/handlers/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/operations/index.js.map +0 -1
- package/dist/presentations/index.js.map +0 -1
- package/dist/presentations.js.map +0 -1
- package/dist/wealth-snapshot.capability.js.map +0 -1
- package/dist/wealth-snapshot.feature.js.map +0 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/docs/wealth-snapshot.docblock.ts
|
|
2
|
+
import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
|
|
3
|
+
var wealthSnapshotDocBlocks = [
|
|
4
|
+
{
|
|
5
|
+
id: "docs.examples.wealth-snapshot",
|
|
6
|
+
title: "Wealth Snapshot",
|
|
7
|
+
summary: "Simple wealth overview with accounts, assets, liabilities, goals, and net-worth snapshots.",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/examples/wealth-snapshot",
|
|
11
|
+
tags: ["finance", "net-worth", "goals"],
|
|
12
|
+
body: `## Features
|
|
13
|
+
|
|
14
|
+
- Accounts with balances/currencies.
|
|
15
|
+
- Assets & liabilities categorized for net worth.
|
|
16
|
+
- Goals with target amounts/dates and status.
|
|
17
|
+
- Net worth snapshots for charting; events emitted for analytics.
|
|
18
|
+
|
|
19
|
+
## Modules reused
|
|
20
|
+
- Identity/RBAC for scoping to household/org
|
|
21
|
+
- Notifications for threshold crossings/goal reminders
|
|
22
|
+
- Audit trail for financial changes
|
|
23
|
+
|
|
24
|
+
## Presentations
|
|
25
|
+
- Dashboard, accounts list, assets list, liabilities list, goals list (React + Markdown targets).
|
|
26
|
+
`
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "docs.examples.wealth-snapshot.goal",
|
|
30
|
+
title: "Wealth Snapshot — Goal",
|
|
31
|
+
summary: "Why this personal/household finance template exists.",
|
|
32
|
+
kind: "goal",
|
|
33
|
+
visibility: "public",
|
|
34
|
+
route: "/docs/examples/wealth-snapshot/goal",
|
|
35
|
+
tags: ["finance", "goal"],
|
|
36
|
+
body: `## Why it matters
|
|
37
|
+
- Provides a regenerable net-worth and goals view without bespoke finance code.
|
|
38
|
+
- Keeps accounts/assets/liabilities/goals consistent across surfaces with PII care.
|
|
39
|
+
|
|
40
|
+
## Business/Product goal
|
|
41
|
+
- Deliver clear net-worth visibility, goal tracking, and alerting for thresholds.
|
|
42
|
+
- Support safe regeneration while keeping currency/units explicit.
|
|
43
|
+
|
|
44
|
+
## Success criteria
|
|
45
|
+
- Spec changes to assets/liabilities/goals regenerate UI/API/events cleanly.
|
|
46
|
+
- PII and sensitive values are marked and redacted where needed.`
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "docs.examples.wealth-snapshot.usage",
|
|
50
|
+
title: "Wealth Snapshot — Usage",
|
|
51
|
+
summary: "How to seed, extend, and regenerate wealth tracking safely.",
|
|
52
|
+
kind: "usage",
|
|
53
|
+
visibility: "public",
|
|
54
|
+
route: "/docs/examples/wealth-snapshot/usage",
|
|
55
|
+
tags: ["finance", "usage"],
|
|
56
|
+
body: `## Setup
|
|
57
|
+
1) Seed (if provided) or add accounts/assets/liabilities/goals via UI.
|
|
58
|
+
2) Configure Notifications for goal reminders/threshold alerts; Audit for changes.
|
|
59
|
+
|
|
60
|
+
## Extend & regenerate
|
|
61
|
+
1) Adjust schemas for asset classes, liability terms, goal metrics; keep currency/units explicit.
|
|
62
|
+
2) Regenerate to update dashboards and events; mark PII paths (account numbers, holder names).
|
|
63
|
+
3) Use Feature Flags to trial new indicators or alerting rules.
|
|
64
|
+
|
|
65
|
+
## Guardrails
|
|
66
|
+
- Emit events for asset/liability/goal changes; log in Audit Trail.
|
|
67
|
+
- Redact sensitive identifiers in presentations.
|
|
68
|
+
- Keep calculations (net worth) transparent and driven by spec fields.`
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "docs.examples.wealth-snapshot.constraints",
|
|
72
|
+
title: "Wealth Snapshot — Constraints & Safety",
|
|
73
|
+
summary: "Internal guardrails for finance data, PII, and regeneration semantics.",
|
|
74
|
+
kind: "reference",
|
|
75
|
+
visibility: "internal",
|
|
76
|
+
route: "/docs/examples/wealth-snapshot/constraints",
|
|
77
|
+
tags: ["finance", "constraints", "internal"],
|
|
78
|
+
body: `## Constraints
|
|
79
|
+
- Net worth and goal calculations must stay spec-driven; avoid hidden math.
|
|
80
|
+
- Events to emit: asset.created/updated, liability.created/updated, goal.created/updated, snapshot.recorded.
|
|
81
|
+
- Regeneration should not alter currency/unit semantics without explicit spec change.
|
|
82
|
+
|
|
83
|
+
## PII & Sensitivity
|
|
84
|
+
- Mark account identifiers, holder names, and addresses as PII; redact in presentations.
|
|
85
|
+
- Avoid exposing raw balances in MCP/web without policy checks; prefer summaries.
|
|
86
|
+
|
|
87
|
+
## Verification
|
|
88
|
+
- Add fixtures for currency/unit changes and snapshot calculations.
|
|
89
|
+
- Ensure Audit Trail covers all financial mutations; Notifications optional for goals/thresholds.
|
|
90
|
+
- Use Feature Flags for new indicators/alert rules; default safe/off.`
|
|
91
|
+
}
|
|
92
|
+
];
|
|
93
|
+
registerDocBlocks(wealthSnapshotDocBlocks);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/docs/wealth-snapshot.docblock.ts
|
|
2
|
+
import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
|
|
3
|
+
var wealthSnapshotDocBlocks = [
|
|
4
|
+
{
|
|
5
|
+
id: "docs.examples.wealth-snapshot",
|
|
6
|
+
title: "Wealth Snapshot",
|
|
7
|
+
summary: "Simple wealth overview with accounts, assets, liabilities, goals, and net-worth snapshots.",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/examples/wealth-snapshot",
|
|
11
|
+
tags: ["finance", "net-worth", "goals"],
|
|
12
|
+
body: `## Features
|
|
13
|
+
|
|
14
|
+
- Accounts with balances/currencies.
|
|
15
|
+
- Assets & liabilities categorized for net worth.
|
|
16
|
+
- Goals with target amounts/dates and status.
|
|
17
|
+
- Net worth snapshots for charting; events emitted for analytics.
|
|
18
|
+
|
|
19
|
+
## Modules reused
|
|
20
|
+
- Identity/RBAC for scoping to household/org
|
|
21
|
+
- Notifications for threshold crossings/goal reminders
|
|
22
|
+
- Audit trail for financial changes
|
|
23
|
+
|
|
24
|
+
## Presentations
|
|
25
|
+
- Dashboard, accounts list, assets list, liabilities list, goals list (React + Markdown targets).
|
|
26
|
+
`
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "docs.examples.wealth-snapshot.goal",
|
|
30
|
+
title: "Wealth Snapshot — Goal",
|
|
31
|
+
summary: "Why this personal/household finance template exists.",
|
|
32
|
+
kind: "goal",
|
|
33
|
+
visibility: "public",
|
|
34
|
+
route: "/docs/examples/wealth-snapshot/goal",
|
|
35
|
+
tags: ["finance", "goal"],
|
|
36
|
+
body: `## Why it matters
|
|
37
|
+
- Provides a regenerable net-worth and goals view without bespoke finance code.
|
|
38
|
+
- Keeps accounts/assets/liabilities/goals consistent across surfaces with PII care.
|
|
39
|
+
|
|
40
|
+
## Business/Product goal
|
|
41
|
+
- Deliver clear net-worth visibility, goal tracking, and alerting for thresholds.
|
|
42
|
+
- Support safe regeneration while keeping currency/units explicit.
|
|
43
|
+
|
|
44
|
+
## Success criteria
|
|
45
|
+
- Spec changes to assets/liabilities/goals regenerate UI/API/events cleanly.
|
|
46
|
+
- PII and sensitive values are marked and redacted where needed.`
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "docs.examples.wealth-snapshot.usage",
|
|
50
|
+
title: "Wealth Snapshot — Usage",
|
|
51
|
+
summary: "How to seed, extend, and regenerate wealth tracking safely.",
|
|
52
|
+
kind: "usage",
|
|
53
|
+
visibility: "public",
|
|
54
|
+
route: "/docs/examples/wealth-snapshot/usage",
|
|
55
|
+
tags: ["finance", "usage"],
|
|
56
|
+
body: `## Setup
|
|
57
|
+
1) Seed (if provided) or add accounts/assets/liabilities/goals via UI.
|
|
58
|
+
2) Configure Notifications for goal reminders/threshold alerts; Audit for changes.
|
|
59
|
+
|
|
60
|
+
## Extend & regenerate
|
|
61
|
+
1) Adjust schemas for asset classes, liability terms, goal metrics; keep currency/units explicit.
|
|
62
|
+
2) Regenerate to update dashboards and events; mark PII paths (account numbers, holder names).
|
|
63
|
+
3) Use Feature Flags to trial new indicators or alerting rules.
|
|
64
|
+
|
|
65
|
+
## Guardrails
|
|
66
|
+
- Emit events for asset/liability/goal changes; log in Audit Trail.
|
|
67
|
+
- Redact sensitive identifiers in presentations.
|
|
68
|
+
- Keep calculations (net worth) transparent and driven by spec fields.`
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "docs.examples.wealth-snapshot.constraints",
|
|
72
|
+
title: "Wealth Snapshot — Constraints & Safety",
|
|
73
|
+
summary: "Internal guardrails for finance data, PII, and regeneration semantics.",
|
|
74
|
+
kind: "reference",
|
|
75
|
+
visibility: "internal",
|
|
76
|
+
route: "/docs/examples/wealth-snapshot/constraints",
|
|
77
|
+
tags: ["finance", "constraints", "internal"],
|
|
78
|
+
body: `## Constraints
|
|
79
|
+
- Net worth and goal calculations must stay spec-driven; avoid hidden math.
|
|
80
|
+
- Events to emit: asset.created/updated, liability.created/updated, goal.created/updated, snapshot.recorded.
|
|
81
|
+
- Regeneration should not alter currency/unit semantics without explicit spec change.
|
|
82
|
+
|
|
83
|
+
## PII & Sensitivity
|
|
84
|
+
- Mark account identifiers, holder names, and addresses as PII; redact in presentations.
|
|
85
|
+
- Avoid exposing raw balances in MCP/web without policy checks; prefer summaries.
|
|
86
|
+
|
|
87
|
+
## Verification
|
|
88
|
+
- Add fixtures for currency/unit changes and snapshot calculations.
|
|
89
|
+
- Ensure Audit Trail covers all financial mutations; Notifications optional for goals/thresholds.
|
|
90
|
+
- Use Feature Flags for new indicators/alert rules; default safe/off.`
|
|
91
|
+
}
|
|
92
|
+
];
|
|
93
|
+
registerDocBlocks(wealthSnapshotDocBlocks);
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// src/entities/index.ts
|
|
2
|
+
import {
|
|
3
|
+
defineEntity,
|
|
4
|
+
defineEntityEnum,
|
|
5
|
+
field,
|
|
6
|
+
index
|
|
7
|
+
} from "@contractspec/lib.schema";
|
|
8
|
+
var schema = "lssm_wealth_snapshot";
|
|
9
|
+
var AccountTypeEnum = defineEntityEnum({
|
|
10
|
+
name: "AccountType",
|
|
11
|
+
schema,
|
|
12
|
+
values: ["CHECKING", "SAVINGS", "INVESTMENT", "CREDIT_CARD", "LOAN"],
|
|
13
|
+
description: "Account categories for holdings and debts."
|
|
14
|
+
});
|
|
15
|
+
var AssetCategoryEnum = defineEntityEnum({
|
|
16
|
+
name: "AssetCategory",
|
|
17
|
+
schema,
|
|
18
|
+
values: ["CASH", "EQUITY", "REAL_ESTATE", "CRYPTO", "OTHER"],
|
|
19
|
+
description: "Asset categories."
|
|
20
|
+
});
|
|
21
|
+
var LiabilityCategoryEnum = defineEntityEnum({
|
|
22
|
+
name: "LiabilityCategory",
|
|
23
|
+
schema,
|
|
24
|
+
values: ["CREDIT_CARD", "LOAN", "MORTGAGE", "TAX", "OTHER"],
|
|
25
|
+
description: "Liability categories."
|
|
26
|
+
});
|
|
27
|
+
var GoalStatusEnum = defineEntityEnum({
|
|
28
|
+
name: "GoalStatus",
|
|
29
|
+
schema,
|
|
30
|
+
values: ["ACTIVE", "ON_TRACK", "AT_RISK", "OFF_TRACK", "COMPLETED"],
|
|
31
|
+
description: "Goal health/status."
|
|
32
|
+
});
|
|
33
|
+
var AccountEntity = defineEntity({
|
|
34
|
+
name: "Account",
|
|
35
|
+
description: "Financial account representing holdings or debts.",
|
|
36
|
+
schema,
|
|
37
|
+
map: "account",
|
|
38
|
+
fields: {
|
|
39
|
+
id: field.id({ description: "Account ID" }),
|
|
40
|
+
name: field.string({ description: "Account name" }),
|
|
41
|
+
type: field.enum("AccountType", { description: "Account type" }),
|
|
42
|
+
currency: field.string({ description: "Currency code", default: '"USD"' }),
|
|
43
|
+
balance: field.decimal({ description: "Current balance" }),
|
|
44
|
+
institution: field.string({ description: "Institution", isOptional: true }),
|
|
45
|
+
orgId: field.string({ description: "Org/household id" }),
|
|
46
|
+
ownerId: field.string({ description: "Owner user id", isOptional: true }),
|
|
47
|
+
createdAt: field.createdAt(),
|
|
48
|
+
updatedAt: field.updatedAt()
|
|
49
|
+
},
|
|
50
|
+
enums: [AccountTypeEnum],
|
|
51
|
+
indexes: [index.on(["orgId"]), index.on(["type"]), index.on(["ownerId"])]
|
|
52
|
+
});
|
|
53
|
+
var AssetEntity = defineEntity({
|
|
54
|
+
name: "Asset",
|
|
55
|
+
description: "Individual asset position.",
|
|
56
|
+
schema,
|
|
57
|
+
map: "asset",
|
|
58
|
+
fields: {
|
|
59
|
+
id: field.id({ description: "Asset ID" }),
|
|
60
|
+
accountId: field.foreignKey({
|
|
61
|
+
description: "Holding account",
|
|
62
|
+
isOptional: true
|
|
63
|
+
}),
|
|
64
|
+
name: field.string({ description: "Asset name" }),
|
|
65
|
+
category: field.enum("AssetCategory", { description: "Asset category" }),
|
|
66
|
+
value: field.decimal({ description: "Current value" }),
|
|
67
|
+
currency: field.string({ description: "Currency", default: '"USD"' }),
|
|
68
|
+
orgId: field.string({ description: "Org/household id" }),
|
|
69
|
+
metadata: field.json({ description: "Metadata", isOptional: true }),
|
|
70
|
+
updatedAt: field.updatedAt(),
|
|
71
|
+
createdAt: field.createdAt(),
|
|
72
|
+
account: field.belongsTo("Account", ["accountId"], ["id"], {
|
|
73
|
+
onDelete: "SetNull"
|
|
74
|
+
})
|
|
75
|
+
},
|
|
76
|
+
enums: [AssetCategoryEnum],
|
|
77
|
+
indexes: [index.on(["orgId"]), index.on(["category"])]
|
|
78
|
+
});
|
|
79
|
+
var LiabilityEntity = defineEntity({
|
|
80
|
+
name: "Liability",
|
|
81
|
+
description: "Debt or obligation.",
|
|
82
|
+
schema,
|
|
83
|
+
map: "liability",
|
|
84
|
+
fields: {
|
|
85
|
+
id: field.id({ description: "Liability ID" }),
|
|
86
|
+
accountId: field.foreignKey({
|
|
87
|
+
description: "Liability account",
|
|
88
|
+
isOptional: true
|
|
89
|
+
}),
|
|
90
|
+
name: field.string({ description: "Liability name" }),
|
|
91
|
+
category: field.enum("LiabilityCategory", {
|
|
92
|
+
description: "Liability category"
|
|
93
|
+
}),
|
|
94
|
+
balance: field.decimal({ description: "Outstanding balance" }),
|
|
95
|
+
currency: field.string({ description: "Currency", default: '"USD"' }),
|
|
96
|
+
interestRate: field.decimal({
|
|
97
|
+
description: "Interest rate (e.g., 0.05 for 5%)",
|
|
98
|
+
isOptional: true
|
|
99
|
+
}),
|
|
100
|
+
orgId: field.string({ description: "Org/household id" }),
|
|
101
|
+
metadata: field.json({ description: "Metadata", isOptional: true }),
|
|
102
|
+
updatedAt: field.updatedAt(),
|
|
103
|
+
createdAt: field.createdAt(),
|
|
104
|
+
account: field.belongsTo("Account", ["accountId"], ["id"], {
|
|
105
|
+
onDelete: "SetNull"
|
|
106
|
+
})
|
|
107
|
+
},
|
|
108
|
+
enums: [LiabilityCategoryEnum],
|
|
109
|
+
indexes: [index.on(["orgId"]), index.on(["category"])]
|
|
110
|
+
});
|
|
111
|
+
var GoalEntity = defineEntity({
|
|
112
|
+
name: "Goal",
|
|
113
|
+
description: "Financial goal with target amount/date.",
|
|
114
|
+
schema,
|
|
115
|
+
map: "goal",
|
|
116
|
+
fields: {
|
|
117
|
+
id: field.id({ description: "Goal ID" }),
|
|
118
|
+
name: field.string({ description: "Goal name" }),
|
|
119
|
+
targetAmount: field.decimal({ description: "Target amount" }),
|
|
120
|
+
currentAmount: field.decimal({
|
|
121
|
+
description: "Current progress amount",
|
|
122
|
+
default: 0
|
|
123
|
+
}),
|
|
124
|
+
currency: field.string({ description: "Currency", default: '"USD"' }),
|
|
125
|
+
targetDate: field.dateTime({
|
|
126
|
+
description: "Target completion date",
|
|
127
|
+
isOptional: true
|
|
128
|
+
}),
|
|
129
|
+
status: field.enum("GoalStatus", {
|
|
130
|
+
description: "Goal status",
|
|
131
|
+
default: "ACTIVE"
|
|
132
|
+
}),
|
|
133
|
+
orgId: field.string({ description: "Org/household id" }),
|
|
134
|
+
ownerId: field.string({ description: "Owner user id", isOptional: true }),
|
|
135
|
+
createdAt: field.createdAt(),
|
|
136
|
+
updatedAt: field.updatedAt()
|
|
137
|
+
},
|
|
138
|
+
enums: [GoalStatusEnum],
|
|
139
|
+
indexes: [
|
|
140
|
+
index.on(["orgId"]),
|
|
141
|
+
index.on(["status"]),
|
|
142
|
+
index.on(["targetDate"])
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
var NetWorthSnapshotEntity = defineEntity({
|
|
146
|
+
name: "NetWorthSnapshot",
|
|
147
|
+
description: "Aggregated net worth snapshot for a date.",
|
|
148
|
+
schema,
|
|
149
|
+
map: "networth_snapshot",
|
|
150
|
+
fields: {
|
|
151
|
+
id: field.id({ description: "Snapshot ID" }),
|
|
152
|
+
asOf: field.dateTime({ description: "Snapshot date" }),
|
|
153
|
+
totalAssets: field.decimal({ description: "Total assets" }),
|
|
154
|
+
totalLiabilities: field.decimal({ description: "Total liabilities" }),
|
|
155
|
+
netWorth: field.decimal({ description: "Net worth" }),
|
|
156
|
+
currency: field.string({ description: "Currency", default: '"USD"' }),
|
|
157
|
+
orgId: field.string({ description: "Org/household id" }),
|
|
158
|
+
createdAt: field.createdAt()
|
|
159
|
+
},
|
|
160
|
+
indexes: [index.unique(["orgId", "asOf"], { name: "networth_unique" })]
|
|
161
|
+
});
|
|
162
|
+
var wealthSnapshotEntities = [
|
|
163
|
+
AccountEntity,
|
|
164
|
+
AssetEntity,
|
|
165
|
+
LiabilityEntity,
|
|
166
|
+
GoalEntity,
|
|
167
|
+
NetWorthSnapshotEntity
|
|
168
|
+
];
|
|
169
|
+
var wealthSnapshotSchemaContribution = {
|
|
170
|
+
moduleId: "@contractspec/example.wealth-snapshot",
|
|
171
|
+
entities: wealthSnapshotEntities,
|
|
172
|
+
enums: [
|
|
173
|
+
AccountTypeEnum,
|
|
174
|
+
AssetCategoryEnum,
|
|
175
|
+
LiabilityCategoryEnum,
|
|
176
|
+
GoalStatusEnum
|
|
177
|
+
]
|
|
178
|
+
};
|
|
179
|
+
export {
|
|
180
|
+
wealthSnapshotSchemaContribution,
|
|
181
|
+
wealthSnapshotEntities,
|
|
182
|
+
NetWorthSnapshotEntity,
|
|
183
|
+
LiabilityEntity,
|
|
184
|
+
LiabilityCategoryEnum,
|
|
185
|
+
GoalStatusEnum,
|
|
186
|
+
GoalEntity,
|
|
187
|
+
AssetEntity,
|
|
188
|
+
AssetCategoryEnum,
|
|
189
|
+
AccountTypeEnum,
|
|
190
|
+
AccountEntity
|
|
191
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/events.ts
|
|
2
|
+
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
3
|
+
import { defineEvent, StabilityEnum } from "@contractspec/lib.contracts";
|
|
4
|
+
var AssetEventPayload = defineSchemaModel({
|
|
5
|
+
name: "AssetEventPayload",
|
|
6
|
+
description: "Payload for asset events",
|
|
7
|
+
fields: {
|
|
8
|
+
assetId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
+
category: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
+
value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
11
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
+
orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
13
|
+
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
var LiabilityEventPayload = defineSchemaModel({
|
|
17
|
+
name: "LiabilityEventPayload",
|
|
18
|
+
description: "Payload for liability events",
|
|
19
|
+
fields: {
|
|
20
|
+
liabilityId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
21
|
+
category: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
balance: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
23
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
24
|
+
orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
25
|
+
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var GoalEventPayload = defineSchemaModel({
|
|
29
|
+
name: "GoalEventPayload",
|
|
30
|
+
description: "Payload for goal events",
|
|
31
|
+
fields: {
|
|
32
|
+
goalId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
33
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
34
|
+
currentAmount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
35
|
+
targetAmount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
36
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
37
|
+
orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
38
|
+
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var AssetAddedEvent = defineEvent({
|
|
42
|
+
meta: {
|
|
43
|
+
key: "wealth.asset.added",
|
|
44
|
+
version: "1.0.0",
|
|
45
|
+
description: "An asset was added or updated.",
|
|
46
|
+
stability: StabilityEnum.Experimental,
|
|
47
|
+
owners: [],
|
|
48
|
+
tags: []
|
|
49
|
+
},
|
|
50
|
+
payload: AssetEventPayload
|
|
51
|
+
});
|
|
52
|
+
var LiabilityAddedEvent = defineEvent({
|
|
53
|
+
meta: {
|
|
54
|
+
key: "wealth.liability.added",
|
|
55
|
+
version: "1.0.0",
|
|
56
|
+
description: "A liability was added or updated.",
|
|
57
|
+
stability: StabilityEnum.Experimental,
|
|
58
|
+
owners: [],
|
|
59
|
+
tags: []
|
|
60
|
+
},
|
|
61
|
+
payload: LiabilityEventPayload
|
|
62
|
+
});
|
|
63
|
+
var GoalUpdatedEvent = defineEvent({
|
|
64
|
+
meta: {
|
|
65
|
+
key: "wealth.goal.updated",
|
|
66
|
+
version: "1.0.0",
|
|
67
|
+
description: "A goal was updated.",
|
|
68
|
+
stability: StabilityEnum.Experimental,
|
|
69
|
+
owners: [],
|
|
70
|
+
tags: []
|
|
71
|
+
},
|
|
72
|
+
payload: GoalEventPayload
|
|
73
|
+
});
|
|
74
|
+
var NetWorthSnapshotCreatedEvent = defineEvent({
|
|
75
|
+
meta: {
|
|
76
|
+
key: "wealth.networth.snapshot_created",
|
|
77
|
+
version: "1.0.0",
|
|
78
|
+
description: "A net worth snapshot was generated.",
|
|
79
|
+
stability: StabilityEnum.Experimental,
|
|
80
|
+
owners: [],
|
|
81
|
+
tags: []
|
|
82
|
+
},
|
|
83
|
+
payload: defineSchemaModel({
|
|
84
|
+
name: "NetWorthSnapshotEventPayload",
|
|
85
|
+
description: "Net worth snapshot payload",
|
|
86
|
+
fields: {
|
|
87
|
+
netWorth: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
88
|
+
totalAssets: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
89
|
+
totalLiabilities: {
|
|
90
|
+
type: ScalarTypeEnum.Float_unsecure(),
|
|
91
|
+
isOptional: false
|
|
92
|
+
},
|
|
93
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
94
|
+
orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
95
|
+
asOf: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
var WealthSnapshotEvents = {
|
|
100
|
+
AssetAddedEvent,
|
|
101
|
+
LiabilityAddedEvent,
|
|
102
|
+
GoalUpdatedEvent,
|
|
103
|
+
NetWorthSnapshotCreatedEvent
|
|
104
|
+
};
|
|
105
|
+
export {
|
|
106
|
+
WealthSnapshotEvents,
|
|
107
|
+
NetWorthSnapshotCreatedEvent,
|
|
108
|
+
LiabilityAddedEvent,
|
|
109
|
+
GoalUpdatedEvent,
|
|
110
|
+
AssetAddedEvent
|
|
111
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/example.ts
|
|
2
|
+
import { defineExample } from "@contractspec/lib.contracts";
|
|
3
|
+
var example = defineExample({
|
|
4
|
+
meta: {
|
|
5
|
+
key: "wealth-snapshot",
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
title: "Wealth Snapshot",
|
|
8
|
+
description: "Simple wealth overview with accounts, assets, liabilities, goals, and net-worth snapshots.",
|
|
9
|
+
kind: "template",
|
|
10
|
+
visibility: "public",
|
|
11
|
+
stability: "experimental",
|
|
12
|
+
owners: ["@platform.core"],
|
|
13
|
+
tags: ["finance", "net-worth", "goals"]
|
|
14
|
+
},
|
|
15
|
+
docs: {
|
|
16
|
+
rootDocId: "docs.examples.wealth-snapshot",
|
|
17
|
+
goalDocId: "docs.examples.wealth-snapshot.goal",
|
|
18
|
+
usageDocId: "docs.examples.wealth-snapshot.usage",
|
|
19
|
+
constraintsDocId: "docs.examples.wealth-snapshot.constraints"
|
|
20
|
+
},
|
|
21
|
+
entrypoints: {
|
|
22
|
+
packageName: "@contractspec/example.wealth-snapshot",
|
|
23
|
+
feature: "./feature",
|
|
24
|
+
contracts: "./contracts",
|
|
25
|
+
presentations: "./presentations",
|
|
26
|
+
handlers: "./handlers",
|
|
27
|
+
docs: "./docs"
|
|
28
|
+
},
|
|
29
|
+
surfaces: {
|
|
30
|
+
templates: true,
|
|
31
|
+
sandbox: {
|
|
32
|
+
enabled: true,
|
|
33
|
+
modes: ["playground", "specs", "builder", "markdown", "evolution"]
|
|
34
|
+
},
|
|
35
|
+
studio: { enabled: true, installable: true },
|
|
36
|
+
mcp: { enabled: true }
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
var example_default = example;
|
|
40
|
+
export {
|
|
41
|
+
example_default as default
|
|
42
|
+
};
|