@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.
Files changed (72) hide show
  1. package/dist/browser/docs/index.js +93 -0
  2. package/dist/browser/docs/wealth-snapshot.docblock.js +93 -0
  3. package/dist/browser/entities/index.js +191 -0
  4. package/dist/browser/events.js +111 -0
  5. package/dist/browser/example.js +42 -0
  6. package/dist/browser/handlers/index.js +5 -0
  7. package/dist/browser/index.js +885 -0
  8. package/dist/browser/operations/index.js +238 -0
  9. package/dist/browser/presentations/index.js +11 -0
  10. package/dist/browser/presentations.js +124 -0
  11. package/dist/browser/wealth-snapshot.capability.js +40 -0
  12. package/dist/browser/wealth-snapshot.feature.js +72 -0
  13. package/dist/docs/index.d.ts +2 -1
  14. package/dist/docs/index.d.ts.map +1 -0
  15. package/dist/docs/index.js +94 -1
  16. package/dist/docs/wealth-snapshot.docblock.d.ts +2 -1
  17. package/dist/docs/wealth-snapshot.docblock.d.ts.map +1 -0
  18. package/dist/docs/wealth-snapshot.docblock.js +45 -55
  19. package/dist/entities/index.d.ts +120 -125
  20. package/dist/entities/index.d.ts.map +1 -1
  21. package/dist/entities/index.js +181 -219
  22. package/dist/events.d.ts +167 -173
  23. package/dist/events.d.ts.map +1 -1
  24. package/dist/events.js +103 -172
  25. package/dist/example.d.ts +2 -6
  26. package/dist/example.d.ts.map +1 -1
  27. package/dist/example.js +41 -54
  28. package/dist/handlers/index.d.ts +1 -4
  29. package/dist/handlers/index.d.ts.map +1 -1
  30. package/dist/handlers/index.js +5 -8
  31. package/dist/index.d.ts +12 -16
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +882 -23
  34. package/dist/node/docs/index.js +93 -0
  35. package/dist/node/docs/wealth-snapshot.docblock.js +93 -0
  36. package/dist/node/entities/index.js +191 -0
  37. package/dist/node/events.js +111 -0
  38. package/dist/node/example.js +42 -0
  39. package/dist/node/handlers/index.js +5 -0
  40. package/dist/node/index.js +885 -0
  41. package/dist/node/operations/index.js +238 -0
  42. package/dist/node/presentations/index.js +11 -0
  43. package/dist/node/presentations.js +124 -0
  44. package/dist/node/wealth-snapshot.capability.js +40 -0
  45. package/dist/node/wealth-snapshot.feature.js +72 -0
  46. package/dist/operations/index.d.ts +392 -398
  47. package/dist/operations/index.d.ts.map +1 -1
  48. package/dist/operations/index.js +237 -425
  49. package/dist/presentations/index.d.ts +1 -4
  50. package/dist/presentations/index.d.ts.map +1 -1
  51. package/dist/presentations/index.js +11 -11
  52. package/dist/presentations.d.ts +5 -10
  53. package/dist/presentations.d.ts.map +1 -1
  54. package/dist/presentations.js +120 -127
  55. package/dist/wealth-snapshot.capability.d.ts +3 -8
  56. package/dist/wealth-snapshot.capability.d.ts.map +1 -1
  57. package/dist/wealth-snapshot.capability.js +41 -46
  58. package/dist/wealth-snapshot.feature.d.ts +1 -6
  59. package/dist/wealth-snapshot.feature.d.ts.map +1 -1
  60. package/dist/wealth-snapshot.feature.js +71 -139
  61. package/package.json +144 -37
  62. package/dist/docs/wealth-snapshot.docblock.js.map +0 -1
  63. package/dist/entities/index.js.map +0 -1
  64. package/dist/events.js.map +0 -1
  65. package/dist/example.js.map +0 -1
  66. package/dist/handlers/index.js.map +0 -1
  67. package/dist/index.js.map +0 -1
  68. package/dist/operations/index.js.map +0 -1
  69. package/dist/presentations/index.js.map +0 -1
  70. package/dist/presentations.js.map +0 -1
  71. package/dist/wealth-snapshot.capability.js.map +0 -1
  72. package/dist/wealth-snapshot.feature.js.map +0 -1
@@ -0,0 +1,885 @@
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);
94
+ // src/entities/index.ts
95
+ import {
96
+ defineEntity,
97
+ defineEntityEnum,
98
+ field,
99
+ index
100
+ } from "@contractspec/lib.schema";
101
+ var schema = "lssm_wealth_snapshot";
102
+ var AccountTypeEnum = defineEntityEnum({
103
+ name: "AccountType",
104
+ schema,
105
+ values: ["CHECKING", "SAVINGS", "INVESTMENT", "CREDIT_CARD", "LOAN"],
106
+ description: "Account categories for holdings and debts."
107
+ });
108
+ var AssetCategoryEnum = defineEntityEnum({
109
+ name: "AssetCategory",
110
+ schema,
111
+ values: ["CASH", "EQUITY", "REAL_ESTATE", "CRYPTO", "OTHER"],
112
+ description: "Asset categories."
113
+ });
114
+ var LiabilityCategoryEnum = defineEntityEnum({
115
+ name: "LiabilityCategory",
116
+ schema,
117
+ values: ["CREDIT_CARD", "LOAN", "MORTGAGE", "TAX", "OTHER"],
118
+ description: "Liability categories."
119
+ });
120
+ var GoalStatusEnum = defineEntityEnum({
121
+ name: "GoalStatus",
122
+ schema,
123
+ values: ["ACTIVE", "ON_TRACK", "AT_RISK", "OFF_TRACK", "COMPLETED"],
124
+ description: "Goal health/status."
125
+ });
126
+ var AccountEntity = defineEntity({
127
+ name: "Account",
128
+ description: "Financial account representing holdings or debts.",
129
+ schema,
130
+ map: "account",
131
+ fields: {
132
+ id: field.id({ description: "Account ID" }),
133
+ name: field.string({ description: "Account name" }),
134
+ type: field.enum("AccountType", { description: "Account type" }),
135
+ currency: field.string({ description: "Currency code", default: '"USD"' }),
136
+ balance: field.decimal({ description: "Current balance" }),
137
+ institution: field.string({ description: "Institution", isOptional: true }),
138
+ orgId: field.string({ description: "Org/household id" }),
139
+ ownerId: field.string({ description: "Owner user id", isOptional: true }),
140
+ createdAt: field.createdAt(),
141
+ updatedAt: field.updatedAt()
142
+ },
143
+ enums: [AccountTypeEnum],
144
+ indexes: [index.on(["orgId"]), index.on(["type"]), index.on(["ownerId"])]
145
+ });
146
+ var AssetEntity = defineEntity({
147
+ name: "Asset",
148
+ description: "Individual asset position.",
149
+ schema,
150
+ map: "asset",
151
+ fields: {
152
+ id: field.id({ description: "Asset ID" }),
153
+ accountId: field.foreignKey({
154
+ description: "Holding account",
155
+ isOptional: true
156
+ }),
157
+ name: field.string({ description: "Asset name" }),
158
+ category: field.enum("AssetCategory", { description: "Asset category" }),
159
+ value: field.decimal({ description: "Current value" }),
160
+ currency: field.string({ description: "Currency", default: '"USD"' }),
161
+ orgId: field.string({ description: "Org/household id" }),
162
+ metadata: field.json({ description: "Metadata", isOptional: true }),
163
+ updatedAt: field.updatedAt(),
164
+ createdAt: field.createdAt(),
165
+ account: field.belongsTo("Account", ["accountId"], ["id"], {
166
+ onDelete: "SetNull"
167
+ })
168
+ },
169
+ enums: [AssetCategoryEnum],
170
+ indexes: [index.on(["orgId"]), index.on(["category"])]
171
+ });
172
+ var LiabilityEntity = defineEntity({
173
+ name: "Liability",
174
+ description: "Debt or obligation.",
175
+ schema,
176
+ map: "liability",
177
+ fields: {
178
+ id: field.id({ description: "Liability ID" }),
179
+ accountId: field.foreignKey({
180
+ description: "Liability account",
181
+ isOptional: true
182
+ }),
183
+ name: field.string({ description: "Liability name" }),
184
+ category: field.enum("LiabilityCategory", {
185
+ description: "Liability category"
186
+ }),
187
+ balance: field.decimal({ description: "Outstanding balance" }),
188
+ currency: field.string({ description: "Currency", default: '"USD"' }),
189
+ interestRate: field.decimal({
190
+ description: "Interest rate (e.g., 0.05 for 5%)",
191
+ isOptional: true
192
+ }),
193
+ orgId: field.string({ description: "Org/household id" }),
194
+ metadata: field.json({ description: "Metadata", isOptional: true }),
195
+ updatedAt: field.updatedAt(),
196
+ createdAt: field.createdAt(),
197
+ account: field.belongsTo("Account", ["accountId"], ["id"], {
198
+ onDelete: "SetNull"
199
+ })
200
+ },
201
+ enums: [LiabilityCategoryEnum],
202
+ indexes: [index.on(["orgId"]), index.on(["category"])]
203
+ });
204
+ var GoalEntity = defineEntity({
205
+ name: "Goal",
206
+ description: "Financial goal with target amount/date.",
207
+ schema,
208
+ map: "goal",
209
+ fields: {
210
+ id: field.id({ description: "Goal ID" }),
211
+ name: field.string({ description: "Goal name" }),
212
+ targetAmount: field.decimal({ description: "Target amount" }),
213
+ currentAmount: field.decimal({
214
+ description: "Current progress amount",
215
+ default: 0
216
+ }),
217
+ currency: field.string({ description: "Currency", default: '"USD"' }),
218
+ targetDate: field.dateTime({
219
+ description: "Target completion date",
220
+ isOptional: true
221
+ }),
222
+ status: field.enum("GoalStatus", {
223
+ description: "Goal status",
224
+ default: "ACTIVE"
225
+ }),
226
+ orgId: field.string({ description: "Org/household id" }),
227
+ ownerId: field.string({ description: "Owner user id", isOptional: true }),
228
+ createdAt: field.createdAt(),
229
+ updatedAt: field.updatedAt()
230
+ },
231
+ enums: [GoalStatusEnum],
232
+ indexes: [
233
+ index.on(["orgId"]),
234
+ index.on(["status"]),
235
+ index.on(["targetDate"])
236
+ ]
237
+ });
238
+ var NetWorthSnapshotEntity = defineEntity({
239
+ name: "NetWorthSnapshot",
240
+ description: "Aggregated net worth snapshot for a date.",
241
+ schema,
242
+ map: "networth_snapshot",
243
+ fields: {
244
+ id: field.id({ description: "Snapshot ID" }),
245
+ asOf: field.dateTime({ description: "Snapshot date" }),
246
+ totalAssets: field.decimal({ description: "Total assets" }),
247
+ totalLiabilities: field.decimal({ description: "Total liabilities" }),
248
+ netWorth: field.decimal({ description: "Net worth" }),
249
+ currency: field.string({ description: "Currency", default: '"USD"' }),
250
+ orgId: field.string({ description: "Org/household id" }),
251
+ createdAt: field.createdAt()
252
+ },
253
+ indexes: [index.unique(["orgId", "asOf"], { name: "networth_unique" })]
254
+ });
255
+ var wealthSnapshotEntities = [
256
+ AccountEntity,
257
+ AssetEntity,
258
+ LiabilityEntity,
259
+ GoalEntity,
260
+ NetWorthSnapshotEntity
261
+ ];
262
+ var wealthSnapshotSchemaContribution = {
263
+ moduleId: "@contractspec/example.wealth-snapshot",
264
+ entities: wealthSnapshotEntities,
265
+ enums: [
266
+ AccountTypeEnum,
267
+ AssetCategoryEnum,
268
+ LiabilityCategoryEnum,
269
+ GoalStatusEnum
270
+ ]
271
+ };
272
+
273
+ // src/events.ts
274
+ import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
275
+ import { defineEvent, StabilityEnum } from "@contractspec/lib.contracts";
276
+ var AssetEventPayload = defineSchemaModel({
277
+ name: "AssetEventPayload",
278
+ description: "Payload for asset events",
279
+ fields: {
280
+ assetId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
281
+ category: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
282
+ value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
283
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
284
+ orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
285
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
286
+ }
287
+ });
288
+ var LiabilityEventPayload = defineSchemaModel({
289
+ name: "LiabilityEventPayload",
290
+ description: "Payload for liability events",
291
+ fields: {
292
+ liabilityId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
293
+ category: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
294
+ balance: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
295
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
296
+ orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
297
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
298
+ }
299
+ });
300
+ var GoalEventPayload = defineSchemaModel({
301
+ name: "GoalEventPayload",
302
+ description: "Payload for goal events",
303
+ fields: {
304
+ goalId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
305
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
306
+ currentAmount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
307
+ targetAmount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
308
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
309
+ orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
310
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
311
+ }
312
+ });
313
+ var AssetAddedEvent = defineEvent({
314
+ meta: {
315
+ key: "wealth.asset.added",
316
+ version: "1.0.0",
317
+ description: "An asset was added or updated.",
318
+ stability: StabilityEnum.Experimental,
319
+ owners: [],
320
+ tags: []
321
+ },
322
+ payload: AssetEventPayload
323
+ });
324
+ var LiabilityAddedEvent = defineEvent({
325
+ meta: {
326
+ key: "wealth.liability.added",
327
+ version: "1.0.0",
328
+ description: "A liability was added or updated.",
329
+ stability: StabilityEnum.Experimental,
330
+ owners: [],
331
+ tags: []
332
+ },
333
+ payload: LiabilityEventPayload
334
+ });
335
+ var GoalUpdatedEvent = defineEvent({
336
+ meta: {
337
+ key: "wealth.goal.updated",
338
+ version: "1.0.0",
339
+ description: "A goal was updated.",
340
+ stability: StabilityEnum.Experimental,
341
+ owners: [],
342
+ tags: []
343
+ },
344
+ payload: GoalEventPayload
345
+ });
346
+ var NetWorthSnapshotCreatedEvent = defineEvent({
347
+ meta: {
348
+ key: "wealth.networth.snapshot_created",
349
+ version: "1.0.0",
350
+ description: "A net worth snapshot was generated.",
351
+ stability: StabilityEnum.Experimental,
352
+ owners: [],
353
+ tags: []
354
+ },
355
+ payload: defineSchemaModel({
356
+ name: "NetWorthSnapshotEventPayload",
357
+ description: "Net worth snapshot payload",
358
+ fields: {
359
+ netWorth: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
360
+ totalAssets: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
361
+ totalLiabilities: {
362
+ type: ScalarTypeEnum.Float_unsecure(),
363
+ isOptional: false
364
+ },
365
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
366
+ orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
367
+ asOf: { type: ScalarTypeEnum.DateTime(), isOptional: false }
368
+ }
369
+ })
370
+ });
371
+ var WealthSnapshotEvents = {
372
+ AssetAddedEvent,
373
+ LiabilityAddedEvent,
374
+ GoalUpdatedEvent,
375
+ NetWorthSnapshotCreatedEvent
376
+ };
377
+
378
+ // src/example.ts
379
+ import { defineExample } from "@contractspec/lib.contracts";
380
+ var example = defineExample({
381
+ meta: {
382
+ key: "wealth-snapshot",
383
+ version: "1.0.0",
384
+ title: "Wealth Snapshot",
385
+ description: "Simple wealth overview with accounts, assets, liabilities, goals, and net-worth snapshots.",
386
+ kind: "template",
387
+ visibility: "public",
388
+ stability: "experimental",
389
+ owners: ["@platform.core"],
390
+ tags: ["finance", "net-worth", "goals"]
391
+ },
392
+ docs: {
393
+ rootDocId: "docs.examples.wealth-snapshot",
394
+ goalDocId: "docs.examples.wealth-snapshot.goal",
395
+ usageDocId: "docs.examples.wealth-snapshot.usage",
396
+ constraintsDocId: "docs.examples.wealth-snapshot.constraints"
397
+ },
398
+ entrypoints: {
399
+ packageName: "@contractspec/example.wealth-snapshot",
400
+ feature: "./feature",
401
+ contracts: "./contracts",
402
+ presentations: "./presentations",
403
+ handlers: "./handlers",
404
+ docs: "./docs"
405
+ },
406
+ surfaces: {
407
+ templates: true,
408
+ sandbox: {
409
+ enabled: true,
410
+ modes: ["playground", "specs", "builder", "markdown", "evolution"]
411
+ },
412
+ studio: { enabled: true, installable: true },
413
+ mcp: { enabled: true }
414
+ }
415
+ });
416
+ var example_default = example;
417
+
418
+ // src/handlers/index.ts
419
+ function registerWealthSnapshotHandlers() {}
420
+
421
+ // src/operations/index.ts
422
+ import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
423
+ import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
424
+ var OWNERS = ["examples.wealth-snapshot"];
425
+ var AccountModel = defineSchemaModel2({
426
+ name: "Account",
427
+ description: "Account model",
428
+ fields: {
429
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
430
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
431
+ type: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
432
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
433
+ balance: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false }
434
+ }
435
+ });
436
+ var AssetModel = defineSchemaModel2({
437
+ name: "Asset",
438
+ description: "Asset model",
439
+ fields: {
440
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
441
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
442
+ category: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
443
+ value: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
444
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
445
+ }
446
+ });
447
+ var LiabilityModel = defineSchemaModel2({
448
+ name: "Liability",
449
+ description: "Liability model",
450
+ fields: {
451
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
452
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
453
+ category: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
454
+ balance: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
455
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
456
+ }
457
+ });
458
+ var GoalModel = defineSchemaModel2({
459
+ name: "Goal",
460
+ description: "Goal model",
461
+ fields: {
462
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
463
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
464
+ targetAmount: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
465
+ currentAmount: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
466
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
467
+ status: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
468
+ }
469
+ });
470
+ var NetWorthSnapshotModel = defineSchemaModel2({
471
+ name: "NetWorthSnapshot",
472
+ description: "Net worth snapshot model",
473
+ fields: {
474
+ asOf: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
475
+ totalAssets: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
476
+ totalLiabilities: {
477
+ type: ScalarTypeEnum2.Float_unsecure(),
478
+ isOptional: false
479
+ },
480
+ netWorth: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
481
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
482
+ }
483
+ });
484
+ var CreateAccountInput = defineSchemaModel2({
485
+ name: "CreateAccountInput",
486
+ description: "Create account input",
487
+ fields: {
488
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
489
+ type: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
490
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
491
+ balance: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: true },
492
+ orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
493
+ }
494
+ });
495
+ var AddAssetInput = defineSchemaModel2({
496
+ name: "AddAssetInput",
497
+ description: "Add asset input",
498
+ fields: {
499
+ accountId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
500
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
501
+ category: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
502
+ value: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
503
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
504
+ orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
505
+ }
506
+ });
507
+ var AddLiabilityInput = defineSchemaModel2({
508
+ name: "AddLiabilityInput",
509
+ description: "Add liability input",
510
+ fields: {
511
+ accountId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
512
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
513
+ category: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
514
+ balance: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
515
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
516
+ orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
517
+ }
518
+ });
519
+ var UpdateGoalInput = defineSchemaModel2({
520
+ name: "UpdateGoalInput",
521
+ description: "Update goal progress",
522
+ fields: {
523
+ goalId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
524
+ currentAmount: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
525
+ status: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
526
+ }
527
+ });
528
+ var CreateGoalInput = defineSchemaModel2({
529
+ name: "CreateGoalInput",
530
+ description: "Create goal input",
531
+ fields: {
532
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
533
+ targetAmount: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
534
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
535
+ targetDate: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
536
+ orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
537
+ }
538
+ });
539
+ var NetWorthQueryInput = defineSchemaModel2({
540
+ name: "NetWorthQueryInput",
541
+ description: "Filter for net worth snapshots",
542
+ fields: {
543
+ orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
544
+ from: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
545
+ to: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
546
+ }
547
+ });
548
+ var CreateAccountContract = defineCommand({
549
+ meta: {
550
+ key: "wealth.account.create",
551
+ version: "1.0.0",
552
+ stability: "stable",
553
+ owners: [...OWNERS],
554
+ tags: ["wealth", "account", "create"],
555
+ description: "Create a financial account.",
556
+ goal: "Track account balances.",
557
+ context: "Onboarding/import."
558
+ },
559
+ io: { input: CreateAccountInput, output: AccountModel },
560
+ policy: { auth: "user" }
561
+ });
562
+ var AddAssetContract = defineCommand({
563
+ meta: {
564
+ key: "wealth.asset.add",
565
+ version: "1.0.0",
566
+ stability: "stable",
567
+ owners: [...OWNERS],
568
+ tags: ["wealth", "asset", "add"],
569
+ description: "Add an asset position.",
570
+ goal: "Track holdings.",
571
+ context: "Asset onboarding/update."
572
+ },
573
+ io: { input: AddAssetInput, output: AssetModel },
574
+ policy: { auth: "user" }
575
+ });
576
+ var AddLiabilityContract = defineCommand({
577
+ meta: {
578
+ key: "wealth.liability.add",
579
+ version: "1.0.0",
580
+ stability: "stable",
581
+ owners: [...OWNERS],
582
+ tags: ["wealth", "liability", "add"],
583
+ description: "Add a liability.",
584
+ goal: "Track debts.",
585
+ context: "Debt onboarding/update."
586
+ },
587
+ io: { input: AddLiabilityInput, output: LiabilityModel },
588
+ policy: { auth: "user" }
589
+ });
590
+ var CreateGoalContract = defineCommand({
591
+ meta: {
592
+ key: "wealth.goal.create",
593
+ version: "1.0.0",
594
+ stability: "stable",
595
+ owners: [...OWNERS],
596
+ tags: ["wealth", "goal", "create"],
597
+ description: "Create a financial goal.",
598
+ goal: "Track progress toward goals.",
599
+ context: "Planning."
600
+ },
601
+ io: { input: CreateGoalInput, output: GoalModel },
602
+ policy: { auth: "user" }
603
+ });
604
+ var UpdateGoalContract = defineCommand({
605
+ meta: {
606
+ key: "wealth.goal.update",
607
+ version: "1.0.0",
608
+ stability: "stable",
609
+ owners: [...OWNERS],
610
+ tags: ["wealth", "goal", "update"],
611
+ description: "Update goal progress.",
612
+ goal: "Keep progress current.",
613
+ context: "Periodic update."
614
+ },
615
+ io: { input: UpdateGoalInput, output: GoalModel },
616
+ policy: { auth: "user" }
617
+ });
618
+ var GetNetWorthContract = defineQuery({
619
+ meta: {
620
+ key: "wealth.networth.get",
621
+ version: "1.0.0",
622
+ stability: "stable",
623
+ owners: [...OWNERS],
624
+ tags: ["wealth", "networth"],
625
+ description: "Get net worth snapshots for a period.",
626
+ goal: "Render charts and indicators.",
627
+ context: "Dashboard."
628
+ },
629
+ io: {
630
+ input: NetWorthQueryInput,
631
+ output: defineSchemaModel2({
632
+ name: "NetWorthQueryOutput",
633
+ description: "Snapshots + latest indicators",
634
+ fields: {
635
+ snapshots: {
636
+ type: NetWorthSnapshotModel,
637
+ isArray: true,
638
+ isOptional: false
639
+ },
640
+ latest: { type: NetWorthSnapshotModel, isOptional: true }
641
+ }
642
+ })
643
+ },
644
+ policy: { auth: "user" }
645
+ });
646
+
647
+ // src/presentations.ts
648
+ import { definePresentation, StabilityEnum as StabilityEnum2 } from "@contractspec/lib.contracts";
649
+ var WealthDashboardPresentation = definePresentation({
650
+ meta: {
651
+ key: "wealth-snapshot.dashboard",
652
+ version: "1.0.0",
653
+ title: "Wealth Dashboard",
654
+ description: "Wealth snapshot dashboard with net worth overview",
655
+ domain: "finance",
656
+ owners: ["@wealth-snapshot"],
657
+ tags: ["finance", "wealth", "dashboard"],
658
+ stability: StabilityEnum2.Experimental,
659
+ goal: "Overview of wealth",
660
+ context: "Dashboard"
661
+ },
662
+ source: {
663
+ type: "component",
664
+ framework: "react",
665
+ componentKey: "WealthDashboard"
666
+ },
667
+ targets: ["react", "markdown"],
668
+ policy: {
669
+ flags: ["wealth.dashboard.enabled"]
670
+ }
671
+ });
672
+ var AccountsListPresentation = definePresentation({
673
+ meta: {
674
+ key: "wealth-snapshot.accounts.list",
675
+ version: "1.0.0",
676
+ title: "Accounts List",
677
+ description: "List of financial accounts",
678
+ domain: "finance",
679
+ owners: ["@wealth-snapshot"],
680
+ tags: ["finance", "accounts", "list"],
681
+ stability: StabilityEnum2.Experimental,
682
+ goal: "List accounts",
683
+ context: "Overview"
684
+ },
685
+ source: {
686
+ type: "component",
687
+ framework: "react",
688
+ componentKey: "AccountsList"
689
+ },
690
+ targets: ["react", "markdown"],
691
+ policy: {
692
+ flags: ["wealth.accounts.enabled"]
693
+ }
694
+ });
695
+ var AssetsListPresentation = definePresentation({
696
+ meta: {
697
+ key: "wealth-snapshot.assets.list",
698
+ version: "1.0.0",
699
+ title: "Assets List",
700
+ description: "List of assets with valuations",
701
+ domain: "finance",
702
+ owners: ["@wealth-snapshot"],
703
+ tags: ["finance", "assets", "list"],
704
+ stability: StabilityEnum2.Experimental,
705
+ goal: "List assets",
706
+ context: "Overview"
707
+ },
708
+ source: {
709
+ type: "component",
710
+ framework: "react",
711
+ componentKey: "AssetsList"
712
+ },
713
+ targets: ["react", "markdown"],
714
+ policy: {
715
+ flags: ["wealth.assets.enabled"]
716
+ }
717
+ });
718
+ var LiabilitiesListPresentation = definePresentation({
719
+ meta: {
720
+ key: "wealth-snapshot.liabilities.list",
721
+ version: "1.0.0",
722
+ title: "Liabilities List",
723
+ description: "List of liabilities and debts",
724
+ domain: "finance",
725
+ owners: ["@wealth-snapshot"],
726
+ tags: ["finance", "liabilities", "list"],
727
+ stability: StabilityEnum2.Experimental,
728
+ goal: "List liabilities",
729
+ context: "Overview"
730
+ },
731
+ source: {
732
+ type: "component",
733
+ framework: "react",
734
+ componentKey: "LiabilitiesList"
735
+ },
736
+ targets: ["react", "markdown"],
737
+ policy: {
738
+ flags: ["wealth.liabilities.enabled"]
739
+ }
740
+ });
741
+ var GoalsListPresentation = definePresentation({
742
+ meta: {
743
+ key: "wealth-snapshot.goals.list",
744
+ version: "1.0.0",
745
+ title: "Goals List",
746
+ description: "List of financial goals with progress",
747
+ domain: "finance",
748
+ owners: ["@wealth-snapshot"],
749
+ tags: ["finance", "goals", "list"],
750
+ stability: StabilityEnum2.Experimental,
751
+ goal: "List goals",
752
+ context: "Overview"
753
+ },
754
+ source: {
755
+ type: "component",
756
+ framework: "react",
757
+ componentKey: "GoalsList"
758
+ },
759
+ targets: ["react", "markdown"],
760
+ policy: {
761
+ flags: ["wealth.goals.enabled"]
762
+ }
763
+ });
764
+
765
+ // src/wealth-snapshot.feature.ts
766
+ import { defineFeature } from "@contractspec/lib.contracts";
767
+ var WealthSnapshotFeature = defineFeature({
768
+ meta: {
769
+ key: "wealth-snapshot",
770
+ version: "1.0.0",
771
+ title: "Wealth Snapshot",
772
+ description: "Mini-app for accounts, assets, liabilities, goals, and net worth.",
773
+ domain: "finance",
774
+ owners: ["@wealth-snapshot"],
775
+ tags: ["finance", "net-worth", "goals"],
776
+ stability: "experimental"
777
+ },
778
+ operations: [
779
+ { key: "wealth.account.create", version: "1.0.0" },
780
+ { key: "wealth.asset.add", version: "1.0.0" },
781
+ { key: "wealth.liability.add", version: "1.0.0" },
782
+ { key: "wealth.goal.create", version: "1.0.0" },
783
+ { key: "wealth.goal.update", version: "1.0.0" },
784
+ { key: "wealth.networth.get", version: "1.0.0" }
785
+ ],
786
+ events: [
787
+ { key: "wealth.asset.added", version: "1.0.0" },
788
+ { key: "wealth.liability.added", version: "1.0.0" },
789
+ { key: "wealth.goal.updated", version: "1.0.0" },
790
+ { key: "wealth.networth.snapshot_created", version: "1.0.0" }
791
+ ],
792
+ presentations: [
793
+ { key: "wealth-snapshot.dashboard", version: "1.0.0" },
794
+ { key: "wealth-snapshot.accounts.list", version: "1.0.0" },
795
+ { key: "wealth-snapshot.assets.list", version: "1.0.0" },
796
+ { key: "wealth-snapshot.liabilities.list", version: "1.0.0" },
797
+ { key: "wealth-snapshot.goals.list", version: "1.0.0" }
798
+ ],
799
+ presentationsTargets: [
800
+ {
801
+ key: "wealth-snapshot.dashboard",
802
+ version: "1.0.0",
803
+ targets: ["react", "markdown"]
804
+ },
805
+ {
806
+ key: "wealth-snapshot.assets.list",
807
+ version: "1.0.0",
808
+ targets: ["react", "markdown"]
809
+ },
810
+ {
811
+ key: "wealth-snapshot.liabilities.list",
812
+ version: "1.0.0",
813
+ targets: ["react", "markdown"]
814
+ },
815
+ {
816
+ key: "wealth-snapshot.goals.list",
817
+ version: "1.0.0",
818
+ targets: ["react", "markdown"]
819
+ }
820
+ ],
821
+ capabilities: {
822
+ requires: [
823
+ { key: "identity", version: "1.0.0" },
824
+ { key: "audit-trail", version: "1.0.0" },
825
+ { key: "notifications", version: "1.0.0" }
826
+ ],
827
+ provides: [
828
+ { key: "accounts", version: "1.0.0" },
829
+ { key: "net-worth", version: "1.0.0" },
830
+ { key: "goals", version: "1.0.0" }
831
+ ]
832
+ }
833
+ });
834
+ // src/index.ts
835
+ import { identityRbacSchemaContribution } from "@contractspec/lib.identity-rbac";
836
+ import { auditTrailSchemaContribution } from "@contractspec/module.audit-trail";
837
+ import { notificationsSchemaContribution } from "@contractspec/module.notifications";
838
+ var schemaComposition = {
839
+ modules: [
840
+ identityRbacSchemaContribution,
841
+ auditTrailSchemaContribution,
842
+ notificationsSchemaContribution,
843
+ wealthSnapshotSchemaContribution
844
+ ],
845
+ provider: "postgresql",
846
+ outputPath: "./prisma/schema/generated.prisma"
847
+ };
848
+ export {
849
+ wealthSnapshotSchemaContribution,
850
+ wealthSnapshotEntities,
851
+ schemaComposition,
852
+ registerWealthSnapshotHandlers,
853
+ example_default as example,
854
+ WealthSnapshotFeature,
855
+ WealthSnapshotEvents,
856
+ WealthDashboardPresentation,
857
+ UpdateGoalContract,
858
+ NetWorthSnapshotModel,
859
+ NetWorthSnapshotEntity,
860
+ NetWorthSnapshotCreatedEvent,
861
+ LiabilityModel,
862
+ LiabilityEntity,
863
+ LiabilityCategoryEnum,
864
+ LiabilityAddedEvent,
865
+ LiabilitiesListPresentation,
866
+ GoalsListPresentation,
867
+ GoalUpdatedEvent,
868
+ GoalStatusEnum,
869
+ GoalModel,
870
+ GoalEntity,
871
+ GetNetWorthContract,
872
+ CreateGoalContract,
873
+ CreateAccountContract,
874
+ AssetsListPresentation,
875
+ AssetModel,
876
+ AssetEntity,
877
+ AssetCategoryEnum,
878
+ AssetAddedEvent,
879
+ AddLiabilityContract,
880
+ AddAssetContract,
881
+ AccountsListPresentation,
882
+ AccountTypeEnum,
883
+ AccountModel,
884
+ AccountEntity
885
+ };