@firela/api-types 0.0.0-canary.e1146c01 → 0.0.0-canary.e8d26ec2

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.
@@ -6,18 +6,12 @@ export const $CreateAccountDto = {
6
6
  path: {
7
7
  type: 'string',
8
8
  description: 'Account path (hierarchical, colon-separated)',
9
- example: 'Assets:CN:Bank:ICBC:Checking'
10
- },
11
- displayName: {
12
- type: 'string',
13
- description:
14
- 'Display name to distinguish accounts at the same path (default: "")',
15
- example: '工资卡'
9
+ example: 'Assets:CN:ICBC:Checking'
16
10
  },
17
11
  openDate: {
18
12
  format: 'date-time',
19
13
  type: 'string',
20
- description: 'Account open date',
14
+ description: 'Account open date (server defaults to today)',
21
15
  example: '2024-01-01'
22
16
  },
23
17
  currencies: {
@@ -45,26 +39,22 @@ export const $CreateAccountDto = {
45
39
  templatePath: {
46
40
  type: 'string',
47
41
  description: 'Reference to account-standards template path',
48
- example: 'Assets:CN:Bank:ICBC:Checking'
42
+ example: 'Assets:CN:Checking'
49
43
  },
50
44
  isCustom: {
51
45
  type: 'boolean',
52
46
  description: 'Whether this is a custom (user-created) account',
53
47
  default: false
54
48
  },
55
- i18nKey: {
56
- type: 'string',
57
- description: 'i18n key for display name (overrides template)',
58
- example: 'account.custom.mybank'
59
- },
60
49
  icon: {
61
50
  type: 'string',
62
51
  description: 'Icon identifier (overrides template)',
63
52
  example: 'bank-custom'
64
53
  },
65
- openMeta: {
54
+ openDirectiveMeta: {
66
55
  type: 'object',
67
- description: 'Additional metadata',
56
+ description:
57
+ 'Open directive metadata (NOT an opening-balance amount — use the opening-balance endpoint)',
68
58
  example: {
69
59
  branch: 'Downtown',
70
60
  accountNumber: '1234'
@@ -76,7 +66,7 @@ export const $CreateAccountDto = {
76
66
  example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
77
67
  }
78
68
  },
79
- required: ['path', 'openDate']
69
+ required: ['path']
80
70
  } as const;
81
71
 
82
72
  export const $AccountResponseDto = {
@@ -90,13 +80,7 @@ export const $AccountResponseDto = {
90
80
  path: {
91
81
  type: 'string',
92
82
  description: 'Account path (hierarchical, colon-separated)',
93
- example: 'Assets:CN:Bank:ICBC:Checking'
94
- },
95
- displayName: {
96
- type: 'string',
97
- description:
98
- 'Display name distinguishing multiple accounts at the same path',
99
- example: '工资卡'
83
+ example: 'Assets:CN:ICBC:Checking'
100
84
  },
101
85
  type: {
102
86
  type: 'string',
@@ -104,6 +88,47 @@ export const $AccountResponseDto = {
104
88
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
105
89
  example: 'Assets'
106
90
  },
91
+ assetSubClass: {
92
+ type: 'string',
93
+ description:
94
+ 'Account-level asset sub-class (product type, e.g. STOCK/DEPOSIT/CREDIT_CARD/PERSONAL_LOAN). Computed from the account path via the asset-classifier (ADR-0077). Null for non-asset accounts (Income/Expenses/Equity) or unmatched paths.',
95
+ enum: [
96
+ 'DEPOSIT',
97
+ 'CASH',
98
+ 'MONEY_MARKET_FUND',
99
+ 'STOCK',
100
+ 'ETF',
101
+ 'MUTUAL_FUND',
102
+ 'EQUITY_COMPENSATION',
103
+ 'GOVERNMENT_BOND',
104
+ 'CORPORATE_BOND',
105
+ 'BOND_FUND',
106
+ 'PRIMARY_RESIDENCE',
107
+ 'INVESTMENT_PROPERTY',
108
+ 'REIT',
109
+ 'GOLD',
110
+ 'SILVER',
111
+ 'PRECIOUS_METAL',
112
+ 'PRECIOUS_METAL_FUND',
113
+ 'COMMODITY',
114
+ 'COMMODITY_FUND',
115
+ 'CRYPTOCURRENCY',
116
+ 'RETIREMENT_ACCOUNT',
117
+ 'HEALTH_ACCOUNT',
118
+ 'EDUCATION_ACCOUNT',
119
+ 'INSURANCE',
120
+ 'PRIVATE_EQUITY',
121
+ 'HEDGE_FUND',
122
+ 'COLLECTIBLES',
123
+ 'MORTGAGE',
124
+ 'STUDENT_LOAN',
125
+ 'CREDIT_CARD',
126
+ 'PERSONAL_LOAN',
127
+ 'OTHER'
128
+ ],
129
+ nullable: true,
130
+ example: 'STOCK'
131
+ },
107
132
  status: {
108
133
  type: 'string',
109
134
  description: 'Account status',
@@ -145,26 +170,26 @@ export const $AccountResponseDto = {
145
170
  templatePath: {
146
171
  type: 'string',
147
172
  description: 'Template path reference',
148
- example: 'Assets:CN:Bank:ICBC:Checking'
173
+ example: 'Assets:CN:Checking'
149
174
  },
150
175
  isCustom: {
151
176
  type: 'boolean',
152
177
  description: 'Whether this is a custom (user-created) account',
153
178
  example: false
154
179
  },
155
- i18nKey: {
180
+ displayName: {
156
181
  type: 'string',
157
- description: 'i18n key for display name',
158
- example: 'account.assets.cn.bank.icbc.checking'
182
+ description: 'Localized display name (ADR-0114, read-time projection)',
183
+ example: 'Checking'
159
184
  },
160
185
  icon: {
161
186
  type: 'string',
162
187
  description: 'Icon identifier',
163
188
  example: 'bank-icbc'
164
189
  },
165
- openMeta: {
190
+ openDirectiveMeta: {
166
191
  type: 'object',
167
- description: 'Account metadata',
192
+ description: 'Open directive metadata (ADR-0115 Decision 9)',
168
193
  example: {
169
194
  branch: 'Downtown'
170
195
  }
@@ -192,7 +217,6 @@ export const $AccountResponseDto = {
192
217
  required: [
193
218
  'id',
194
219
  'path',
195
- 'displayName',
196
220
  'type',
197
221
  'status',
198
222
  'openDate',
@@ -225,11 +249,6 @@ export const $AccountListResponseDto = {
225
249
  export const $UpdateAccountDto = {
226
250
  type: 'object',
227
251
  properties: {
228
- displayName: {
229
- type: 'string',
230
- description: 'Display name to distinguish accounts at the same path',
231
- example: '招行工资卡'
232
- },
233
252
  currencies: {
234
253
  description: 'Allowed currencies (null = no restriction)',
235
254
  example: ['CNY', 'USD'],
@@ -251,19 +270,15 @@ export const $UpdateAccountDto = {
251
270
  'NONE'
252
271
  ]
253
272
  },
254
- i18nKey: {
255
- type: 'string',
256
- description: 'i18n key for display name',
257
- example: 'account.custom.mybank'
258
- },
259
273
  icon: {
260
274
  type: 'string',
261
275
  description: 'Icon identifier',
262
276
  example: 'bank-custom'
263
277
  },
264
- openMeta: {
278
+ openDirectiveMeta: {
265
279
  type: 'object',
266
- description: 'Additional metadata (merged with existing)',
280
+ description:
281
+ 'Open directive metadata (merged with existing; NOT an opening-balance amount)',
267
282
  example: {
268
283
  branch: 'Uptown'
269
284
  }
@@ -310,13 +325,47 @@ export const $ReopenAccountDto = {
310
325
  }
311
326
  } as const;
312
327
 
328
+ export const $CreateOpeningBalanceDto = {
329
+ type: 'object',
330
+ properties: {
331
+ amount: {
332
+ type: 'number',
333
+ description: 'Opening balance amount (non-negative)',
334
+ example: 1000
335
+ },
336
+ currency: {
337
+ type: 'string',
338
+ description: 'Currency code',
339
+ example: 'CNY'
340
+ },
341
+ date: {
342
+ format: 'date-time',
343
+ type: 'string',
344
+ description: 'Opening-balance date (defaults to now)',
345
+ example: '2024-01-01'
346
+ }
347
+ },
348
+ required: ['amount', 'currency']
349
+ } as const;
350
+
351
+ export const $OpeningBalanceResultDto = {
352
+ type: 'object',
353
+ properties: {
354
+ transactionId: {
355
+ type: 'string',
356
+ description: 'Created opening-balance transaction id.'
357
+ }
358
+ },
359
+ required: ['transactionId']
360
+ } as const;
361
+
313
362
  export const $AccountStandardResponseDto = {
314
363
  type: 'object',
315
364
  properties: {
316
365
  path: {
317
366
  type: 'string',
318
367
  description: 'Account path (hierarchical, colon-separated)',
319
- example: 'Assets:CN:Bank:ICBC:Checking'
368
+ example: 'Assets:CN:Checking'
320
369
  },
321
370
  type: {
322
371
  type: 'string',
@@ -324,11 +373,6 @@ export const $AccountStandardResponseDto = {
324
373
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
325
374
  example: 'Assets'
326
375
  },
327
- i18nKey: {
328
- type: 'string',
329
- description: 'i18n key for localized display name',
330
- example: 'account.assets.cn.bank.icbc.checking'
331
- },
332
376
  name: {
333
377
  type: 'string',
334
378
  description: 'Short localized display name',
@@ -353,7 +397,7 @@ export const $AccountStandardResponseDto = {
353
397
  example: 'bank-icbc'
354
398
  }
355
399
  },
356
- required: ['path', 'type', 'i18nKey', 'description', 'tags', 'icon']
400
+ required: ['path', 'type', 'description', 'tags', 'icon']
357
401
  } as const;
358
402
 
359
403
  export const $AccountStandardListResponseDto = {
@@ -383,18 +427,13 @@ export const $AccountStandardListResponseDto = {
383
427
  export const $TemplateMetadataDto = {
384
428
  type: 'object',
385
429
  properties: {
386
- extendable: {
387
- type: 'boolean',
388
- description: 'Whether this path can be extended',
389
- example: true
390
- },
391
430
  rootType: {
392
431
  type: 'string',
393
432
  description: 'Root account type',
394
433
  example: 'Assets'
395
434
  }
396
435
  },
397
- required: ['extendable', 'rootType']
436
+ required: ['rootType']
398
437
  } as const;
399
438
 
400
439
  export const $TemplateMetadataResponseDto = {
@@ -466,6 +505,66 @@ export const $RegionsMetadataResponseDto = {
466
505
  required: ['regions']
467
506
  } as const;
468
507
 
508
+ export const $CostSpecDto = {
509
+ type: 'object',
510
+ properties: {
511
+ mode: {
512
+ type: 'string',
513
+ enum: ['per-unit', 'total', 'date', 'label', 'auto'],
514
+ description: 'Cost specification mode (mirrors engine CostSpec)'
515
+ },
516
+ numberPerUnit: {
517
+ type: 'string',
518
+ description: 'Per-unit cost (required when mode is "per-unit")',
519
+ example: '240'
520
+ },
521
+ totalNumber: {
522
+ type: 'string',
523
+ description: 'Total cost for all units (required when mode is "total")',
524
+ example: '12000'
525
+ },
526
+ currency: {
527
+ type: 'string',
528
+ description: 'Cost currency (required in all modes)',
529
+ example: 'USD'
530
+ },
531
+ date: {
532
+ type: 'string',
533
+ description:
534
+ 'Lot acquisition date, ISO 8601 (required when mode is "date")',
535
+ example: '2024-01-15'
536
+ },
537
+ label: {
538
+ type: 'string',
539
+ description:
540
+ 'Lot label (required when mode is "label"; optional tag in buy modes)'
541
+ },
542
+ merge: {
543
+ type: 'boolean',
544
+ description: 'Merge lots for AVERAGE booking (mode: auto)'
545
+ }
546
+ },
547
+ required: ['mode', 'currency']
548
+ } as const;
549
+
550
+ export const $AmountDto = {
551
+ type: 'object',
552
+ properties: {
553
+ number: {
554
+ type: 'string',
555
+ description:
556
+ 'Amount as decimal string (max 15 integer + 15 decimal digits)',
557
+ example: '170.50'
558
+ },
559
+ currency: {
560
+ type: 'string',
561
+ description: 'Currency/commodity code',
562
+ example: 'USD'
563
+ }
564
+ },
565
+ required: ['number', 'currency']
566
+ } as const;
567
+
469
568
  export const $CreatePostingDto = {
470
569
  type: 'object',
471
570
  properties: {
@@ -473,7 +572,7 @@ export const $CreatePostingDto = {
473
572
  type: 'string',
474
573
  description:
475
574
  'Account name in Beancount format (must start with uppercase, colon-separated)',
476
- example: 'Assets:Bank:Checking'
575
+ example: 'Assets:Checking'
477
576
  },
478
577
  units: {
479
578
  type: 'string',
@@ -495,6 +594,33 @@ export const $CreatePostingDto = {
495
594
  example: {
496
595
  'tax-lot': 'Q1-2024'
497
596
  }
597
+ },
598
+ cost: {
599
+ description:
600
+ 'Cost basis (Beancount `{...}`). Maps to engine costSpec. Required for commodity holdings so they carry a monetary weight that can balance.',
601
+ example: {
602
+ mode: 'per-unit',
603
+ numberPerUnit: '240',
604
+ currency: 'USD'
605
+ },
606
+ allOf: [
607
+ {
608
+ $ref: '#/components/schemas/CostSpecDto'
609
+ }
610
+ ]
611
+ },
612
+ price: {
613
+ description:
614
+ 'Price annotation (Beancount `@...`). Maps to engine price. Used for valuation; cost takes priority for balance weight.',
615
+ example: {
616
+ number: '170',
617
+ currency: 'USD'
618
+ },
619
+ allOf: [
620
+ {
621
+ $ref: '#/components/schemas/AmountDto'
622
+ }
623
+ ]
498
624
  }
499
625
  },
500
626
  required: ['account']
@@ -573,13 +699,39 @@ export const $CreateTransactionDto = {
573
699
  required: ['date', 'narration', 'postings']
574
700
  } as const;
575
701
 
702
+ export const $CostDetailDto = {
703
+ type: 'object',
704
+ properties: {
705
+ number: {
706
+ type: 'string',
707
+ description: 'Per-unit cost basis (mirrors engine Cost.number)',
708
+ example: '240'
709
+ },
710
+ currency: {
711
+ type: 'string',
712
+ description: 'Cost currency',
713
+ example: 'USD'
714
+ },
715
+ date: {
716
+ type: 'string',
717
+ description: 'Lot acquisition date (ISO yyyy-mm-dd)',
718
+ example: '2024-01-15'
719
+ },
720
+ label: {
721
+ type: 'string',
722
+ description: 'Lot label',
723
+ example: 'lot-2024-01'
724
+ }
725
+ }
726
+ } as const;
727
+
576
728
  export const $PostingResponseDto = {
577
729
  type: 'object',
578
730
  properties: {
579
731
  account: {
580
732
  type: 'string',
581
733
  description: 'Account name',
582
- example: 'Assets:Bank:Checking'
734
+ example: 'Assets:Checking'
583
735
  },
584
736
  units: {
585
737
  type: 'string',
@@ -591,6 +743,15 @@ export const $PostingResponseDto = {
591
743
  type: 'string',
592
744
  description: 'Currency',
593
745
  example: 'USD'
746
+ },
747
+ cost: {
748
+ description:
749
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
750
+ allOf: [
751
+ {
752
+ $ref: '#/components/schemas/CostDetailDto'
753
+ }
754
+ ]
594
755
  }
595
756
  },
596
757
  required: ['account']
@@ -933,10 +1094,10 @@ export const $PostingDetailDto = {
933
1094
  description: 'Account ID',
934
1095
  example: 'clh1234567890abcdef'
935
1096
  },
936
- accountName: {
1097
+ account: {
937
1098
  type: 'string',
938
- description: 'Account name',
939
- example: 'Assets:Bank:Checking'
1099
+ description: 'Fully-qualified Beancount account path',
1100
+ example: 'Assets:Checking'
940
1101
  },
941
1102
  units: {
942
1103
  type: 'string',
@@ -964,6 +1125,15 @@ export const $PostingDetailDto = {
964
1125
  description: 'Cost date',
965
1126
  example: '2024-01-15'
966
1127
  },
1128
+ cost: {
1129
+ description:
1130
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
1131
+ allOf: [
1132
+ {
1133
+ $ref: '#/components/schemas/CostDetailDto'
1134
+ }
1135
+ ]
1136
+ },
967
1137
  priceAmount: {
968
1138
  type: 'string',
969
1139
  description: 'Price amount',
@@ -984,7 +1154,7 @@ export const $PostingDetailDto = {
984
1154
  description: 'Posting metadata'
985
1155
  }
986
1156
  },
987
- required: ['id', 'accountId', 'accountName']
1157
+ required: ['id', 'accountId', 'account']
988
1158
  } as const;
989
1159
 
990
1160
  export const $TransactionDetailDto = {
@@ -1116,6 +1286,77 @@ export const $TransactionDetailDto = {
1116
1286
  ]
1117
1287
  } as const;
1118
1288
 
1289
+ export const $BalanceByCurrencyDto = {
1290
+ type: 'object',
1291
+ properties: {
1292
+ currency: {
1293
+ type: 'string',
1294
+ description: 'ISO 4217 currency code',
1295
+ example: 'CNY'
1296
+ },
1297
+ balance: {
1298
+ type: 'string',
1299
+ description: 'Balance amount',
1300
+ example: '50000.00'
1301
+ }
1302
+ },
1303
+ required: ['currency', 'balance']
1304
+ } as const;
1305
+
1306
+ export const $ExchangeRateWarningDto = {
1307
+ type: 'object',
1308
+ properties: {
1309
+ type: {
1310
+ type: 'string',
1311
+ description: 'Warning type',
1312
+ example: 'MISSING_EXCHANGE_RATE'
1313
+ },
1314
+ currency: {
1315
+ type: 'string',
1316
+ description: 'Currency without exchange rate',
1317
+ example: 'EUR'
1318
+ },
1319
+ totalAmount: {
1320
+ type: 'string',
1321
+ description: 'Total amount affected',
1322
+ example: '1000.00'
1323
+ }
1324
+ },
1325
+ required: ['type', 'currency', 'totalAmount']
1326
+ } as const;
1327
+
1328
+ export const $TransactionListSummaryDto = {
1329
+ type: 'object',
1330
+ properties: {
1331
+ totalAmount: {
1332
+ type: 'string',
1333
+ description:
1334
+ 'Partial converted total in base currency (rated currencies only, raw Beancount sign). When warnings is non-empty this excludes currencies missing an FX rate; may be "0.00" if ALL non-base currencies lack a rate. Converted at the dateTo (or current) available rate.',
1335
+ example: '-6000.00'
1336
+ },
1337
+ currency: {
1338
+ type: 'string',
1339
+ description: 'Base currency (ISO 4217)',
1340
+ example: 'CNY'
1341
+ },
1342
+ balanceByCurrency: {
1343
+ description: 'Raw (unconverted) balance per currency',
1344
+ type: 'array',
1345
+ items: {
1346
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
1347
+ }
1348
+ },
1349
+ warnings: {
1350
+ description: 'Currencies missing an FX rate (omitted when empty)',
1351
+ type: 'array',
1352
+ items: {
1353
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
1354
+ }
1355
+ }
1356
+ },
1357
+ required: ['totalAmount', 'currency', 'balanceByCurrency']
1358
+ } as const;
1359
+
1119
1360
  export const $TransactionListResponseDto = {
1120
1361
  type: 'object',
1121
1362
  properties: {
@@ -1140,6 +1381,15 @@ export const $TransactionListResponseDto = {
1140
1381
  type: 'number',
1141
1382
  description: 'Number of items skipped',
1142
1383
  example: 0
1384
+ },
1385
+ summary: {
1386
+ description:
1387
+ 'Amount summary for the full filtered set (#514). Present only when the request has a single account OR category viewpoint; omitted for search-only / plain-list / dual-perspective requests.',
1388
+ allOf: [
1389
+ {
1390
+ $ref: '#/components/schemas/TransactionListSummaryDto'
1391
+ }
1392
+ ]
1143
1393
  }
1144
1394
  },
1145
1395
  required: ['data', 'total', 'limit', 'offset']
@@ -1239,7 +1489,7 @@ export const $BalanceResponseDto = {
1239
1489
  account: {
1240
1490
  type: 'string',
1241
1491
  description: 'Account name',
1242
- example: 'Assets:Bank:Checking'
1492
+ example: 'Assets:Checking'
1243
1493
  },
1244
1494
  balance: {
1245
1495
  type: 'string',
@@ -1266,7 +1516,7 @@ export const $MultiCurrencyBalanceResponseDto = {
1266
1516
  account: {
1267
1517
  type: 'string',
1268
1518
  description: 'Account name',
1269
- example: 'Assets:Bank:Checking'
1519
+ example: 'Assets:Checking'
1270
1520
  },
1271
1521
  balances: {
1272
1522
  type: 'object',
@@ -1322,7 +1572,7 @@ export const $TransactionSummaryDto = {
1322
1572
  accountName: {
1323
1573
  type: 'string',
1324
1574
  description: 'Source account name (first posting)',
1325
- example: 'Assets:Bank:Checking'
1575
+ example: 'Assets:Checking'
1326
1576
  },
1327
1577
  sourceType: {
1328
1578
  type: 'string',
@@ -1724,7 +1974,8 @@ export const $ResolveResultDto = {
1724
1974
  },
1725
1975
  resolutionId: {
1726
1976
  type: 'string',
1727
- description: 'Resolution ID for undo'
1977
+ description:
1978
+ 'Resolution ID for undo. Absent when the resolver rejected the decision (review stayed PENDING).'
1728
1979
  },
1729
1980
  canUndo: {
1730
1981
  type: 'boolean',
@@ -1742,7 +1993,7 @@ export const $ResolveResultDto = {
1742
1993
  example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1743
1994
  }
1744
1995
  },
1745
- required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
1996
+ required: ['success']
1746
1997
  } as const;
1747
1998
 
1748
1999
  export const $UndoResultDto = {
@@ -2613,41 +2864,198 @@ export const $UpdateCommodityDto = {
2613
2864
  }
2614
2865
  } as const;
2615
2866
 
2616
- export const $CreateRecurringRuleDto = {
2867
+ export const $CreateBeanPriceDto = {
2617
2868
  type: 'object',
2618
2869
  properties: {
2619
- name: {
2620
- type: 'string',
2621
- description: 'Rule name (unique per user)',
2622
- maxLength: 100
2623
- },
2624
- icon: {
2870
+ currency: {
2625
2871
  type: 'string',
2626
- description: 'Icon emoji',
2627
- maxLength: 10
2872
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2873
+ example: 'USD'
2628
2874
  },
2629
- frequency: {
2875
+ quoteCurrency: {
2630
2876
  type: 'string',
2631
- description: 'Recurring frequency',
2632
- enum: [
2633
- 'WEEKLY',
2634
- 'BIWEEKLY',
2635
- 'MONTHLY',
2636
- 'BIMONTHLY',
2637
- 'QUARTERLY',
2638
- 'YEARLY',
2639
- 'CUSTOM'
2640
- ]
2877
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
2878
+ example: 'CNY'
2641
2879
  },
2642
- expectedAmount: {
2880
+ amount: {
2643
2881
  type: 'number',
2644
- description: 'Expected amount (positive number)',
2882
+ description:
2883
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
2884
+ example: 175.5,
2645
2885
  minimum: 0
2646
2886
  },
2647
- expectedDay: {
2648
- type: 'number',
2649
- description: 'Expected day of month (1-31)',
2650
- minimum: 1,
2887
+ date: {
2888
+ type: 'string',
2889
+ description: 'Price date (ISO 8601 format)',
2890
+ example: '2024-11-05'
2891
+ },
2892
+ metadata: {
2893
+ type: 'object',
2894
+ description:
2895
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
2896
+ example: {
2897
+ source: 'MANUAL',
2898
+ note: 'Bank valuation report',
2899
+ confidence: 0.95
2900
+ }
2901
+ }
2902
+ },
2903
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
2904
+ } as const;
2905
+
2906
+ export const $PriceResponseDto = {
2907
+ type: 'object',
2908
+ properties: {
2909
+ id: {
2910
+ type: 'string',
2911
+ description: 'Unique identifier',
2912
+ example: 'uuid-123-456'
2913
+ },
2914
+ userId: {
2915
+ type: 'string',
2916
+ description: 'User ID (owner of the price)',
2917
+ example: 'user-123'
2918
+ },
2919
+ currency: {
2920
+ type: 'string',
2921
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2922
+ example: 'BTC'
2923
+ },
2924
+ quoteCurrency: {
2925
+ type: 'string',
2926
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2927
+ example: 'USD'
2928
+ },
2929
+ amount: {
2930
+ type: 'number',
2931
+ description:
2932
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2933
+ example: 50000
2934
+ },
2935
+ date: {
2936
+ type: 'string',
2937
+ description:
2938
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
2939
+ example: '2024-01-01',
2940
+ format: 'date'
2941
+ },
2942
+ meta: {
2943
+ type: 'object',
2944
+ description:
2945
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
2946
+ example: {
2947
+ source: 'MANUAL',
2948
+ note: 'User-defined price',
2949
+ confidence: 1
2950
+ }
2951
+ },
2952
+ createdAt: {
2953
+ format: 'date-time',
2954
+ type: 'string',
2955
+ description: 'Creation timestamp',
2956
+ example: '2024-11-03T10:00:00Z'
2957
+ },
2958
+ updatedAt: {
2959
+ format: 'date-time',
2960
+ type: 'string',
2961
+ description: 'Last update timestamp',
2962
+ example: '2024-11-03T10:00:00Z'
2963
+ }
2964
+ },
2965
+ required: [
2966
+ 'id',
2967
+ 'userId',
2968
+ 'currency',
2969
+ 'quoteCurrency',
2970
+ 'amount',
2971
+ 'date',
2972
+ 'meta',
2973
+ 'createdAt',
2974
+ 'updatedAt'
2975
+ ]
2976
+ } as const;
2977
+
2978
+ export const $PriceListResponseDto = {
2979
+ type: 'object',
2980
+ properties: {
2981
+ items: {
2982
+ description: 'List of prices',
2983
+ type: 'array',
2984
+ items: {
2985
+ $ref: '#/components/schemas/PriceResponseDto'
2986
+ }
2987
+ },
2988
+ total: {
2989
+ type: 'number',
2990
+ description: 'Total number of prices',
2991
+ example: 42
2992
+ }
2993
+ },
2994
+ required: ['items', 'total']
2995
+ } as const;
2996
+
2997
+ export const $UpdateBeanPriceDto = {
2998
+ type: 'object',
2999
+ properties: {
3000
+ currency: {
3001
+ type: 'string',
3002
+ description: 'Currency being priced'
3003
+ },
3004
+ quoteCurrency: {
3005
+ type: 'string',
3006
+ description: 'Quote currency (pricing currency)'
3007
+ },
3008
+ amount: {
3009
+ type: 'number',
3010
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
3011
+ minimum: 0
3012
+ },
3013
+ date: {
3014
+ type: 'string',
3015
+ description: 'Price date (ISO 8601 format)'
3016
+ },
3017
+ metadata: {
3018
+ type: 'object',
3019
+ description: 'Metadata'
3020
+ }
3021
+ }
3022
+ } as const;
3023
+
3024
+ export const $CreateRecurringRuleDto = {
3025
+ type: 'object',
3026
+ properties: {
3027
+ name: {
3028
+ type: 'string',
3029
+ description: 'Rule name (unique per user)',
3030
+ maxLength: 100
3031
+ },
3032
+ icon: {
3033
+ type: 'string',
3034
+ description: 'Icon emoji',
3035
+ maxLength: 10
3036
+ },
3037
+ frequency: {
3038
+ type: 'string',
3039
+ description: 'Recurring frequency',
3040
+ enum: [
3041
+ 'WEEKLY',
3042
+ 'BIWEEKLY',
3043
+ 'MONTHLY',
3044
+ 'BIMONTHLY',
3045
+ 'QUARTERLY',
3046
+ 'YEARLY',
3047
+ 'CUSTOM'
3048
+ ]
3049
+ },
3050
+ expectedAmount: {
3051
+ type: 'number',
3052
+ description: 'Expected amount (positive number)',
3053
+ minimum: 0
3054
+ },
3055
+ expectedDay: {
3056
+ type: 'number',
3057
+ description: 'Expected day of month (1-31)',
3058
+ minimum: 1,
2651
3059
  maximum: 31
2652
3060
  },
2653
3061
  customIntervalDays: {
@@ -3384,103 +3792,550 @@ export const $ForecastResponseDto = {
3384
3792
  ]
3385
3793
  } as const;
3386
3794
 
3387
- export const $CreateTransactionRuleDto = {
3795
+ export const $CurrencyBalanceDto = {
3388
3796
  type: 'object',
3389
3797
  properties: {
3390
- name: {
3798
+ currency: {
3391
3799
  type: 'string',
3392
- minLength: 1,
3393
- maxLength: 100
3800
+ description: 'ISO 4217 currency code',
3801
+ example: 'CNY'
3394
3802
  },
3395
- description: {
3803
+ balance: {
3396
3804
  type: 'string',
3397
- maxLength: 500
3398
- },
3399
- narrationKeywords: {
3400
- items: {
3401
- type: 'array'
3402
- },
3403
- maxItems: 50,
3404
- type: 'array'
3405
- },
3406
- payeeKeywords: {
3407
- items: {
3408
- type: 'array'
3409
- },
3410
- maxItems: 50,
3411
- type: 'array'
3412
- },
3413
- categoryKeywords: {
3414
- items: {
3415
- type: 'array'
3416
- },
3417
- maxItems: 50,
3418
- type: 'array'
3419
- },
3420
- methodKeywords: {
3421
- items: {
3422
- type: 'array'
3423
- },
3424
- maxItems: 50,
3425
- description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
3426
- type: 'array'
3427
- },
3428
- categoryAccount: {
3805
+ description: 'Balance amount',
3806
+ example: '500000.00'
3807
+ }
3808
+ },
3809
+ required: ['currency', 'balance']
3810
+ } as const;
3811
+
3812
+ export const $TimeSeriesPointDto = {
3813
+ type: 'object',
3814
+ properties: {
3815
+ date: {
3429
3816
  type: 'string',
3430
- maxLength: 200,
3431
- description:
3432
- 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
3817
+ description: 'Date in YYYY-MM-DD format',
3818
+ example: '2024-06-15'
3433
3819
  },
3434
- matchLogic: {
3820
+ value: {
3435
3821
  type: 'string',
3436
- enum: ['OR', 'AND'],
3437
- default: 'OR'
3822
+ description: 'Value at this date (in base currency)',
3823
+ example: '500000.00'
3438
3824
  },
3439
- amountMin: {
3440
- type: 'number',
3441
- minimum: 0,
3442
- description: 'Minimum transaction amount (inclusive)'
3825
+ change: {
3826
+ type: 'object',
3827
+ description: 'Change from previous point',
3828
+ example: '5000.00'
3443
3829
  },
3444
- amountMax: {
3445
- type: 'number',
3446
- minimum: 0,
3447
- description: 'Maximum transaction amount (inclusive)'
3830
+ assets: {
3831
+ type: 'string',
3832
+ description: 'Total assets at this date (in base currency)',
3833
+ example: '494338.00'
3448
3834
  },
3449
- priority: {
3450
- type: 'number',
3451
- default: 50,
3452
- minimum: 0,
3453
- maximum: 1000
3835
+ liabilities: {
3836
+ type: 'string',
3837
+ description: 'Total liabilities at this date (in base currency)',
3838
+ example: '310098.00'
3454
3839
  },
3455
- additionalTags: {
3840
+ byCurrency: {
3841
+ description: 'Multi-currency breakdown for this point',
3842
+ type: 'array',
3456
3843
  items: {
3457
- type: 'array'
3458
- },
3459
- maxItems: 20,
3460
- type: 'array'
3461
- },
3462
- additionalMetadata: {
3463
- type: 'object'
3464
- },
3465
- upsertByPayee: {
3466
- type: 'boolean',
3467
- description:
3468
- 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
3844
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3845
+ }
3469
3846
  }
3470
3847
  },
3471
- required: ['name', 'matchLogic', 'priority']
3848
+ required: ['date', 'value']
3472
3849
  } as const;
3473
3850
 
3474
- export const $AmountRangeDto = {
3851
+ export const $TrendSummaryDto = {
3475
3852
  type: 'object',
3476
3853
  properties: {
3477
- min: {
3478
- type: 'number',
3479
- description: 'Minimum amount'
3854
+ startValue: {
3855
+ type: 'string',
3856
+ description: 'Value at start of period',
3857
+ example: '450000.00'
3480
3858
  },
3481
- max: {
3482
- type: 'number',
3483
- description: 'Maximum amount'
3859
+ endValue: {
3860
+ type: 'string',
3861
+ description: 'Value at end of period',
3862
+ example: '500000.00'
3863
+ },
3864
+ totalChange: {
3865
+ type: 'string',
3866
+ description: 'Total change over period',
3867
+ example: '50000.00'
3868
+ },
3869
+ totalChangePercentage: {
3870
+ type: 'string',
3871
+ description: 'Total change percentage',
3872
+ example: '+11.11%'
3873
+ }
3874
+ },
3875
+ required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
3876
+ } as const;
3877
+
3878
+ export const $MultiCurrencyPointDto = {
3879
+ type: 'object',
3880
+ properties: {
3881
+ date: {
3882
+ type: 'string',
3883
+ description: 'Date in YYYY-MM-DD format',
3884
+ example: '2024-06-15'
3885
+ },
3886
+ byCurrency: {
3887
+ description: 'Balances by currency',
3888
+ type: 'array',
3889
+ items: {
3890
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3891
+ }
3892
+ }
3893
+ },
3894
+ required: ['date', 'byCurrency']
3895
+ } as const;
3896
+
3897
+ export const $PortfolioTrendsResponseDto = {
3898
+ type: 'object',
3899
+ properties: {
3900
+ series: {
3901
+ description: 'Time series data points',
3902
+ type: 'array',
3903
+ items: {
3904
+ $ref: '#/components/schemas/TimeSeriesPointDto'
3905
+ }
3906
+ },
3907
+ summary: {
3908
+ description: 'Period summary',
3909
+ allOf: [
3910
+ {
3911
+ $ref: '#/components/schemas/TrendSummaryDto'
3912
+ }
3913
+ ]
3914
+ },
3915
+ period: {
3916
+ type: 'string',
3917
+ description: 'Period requested',
3918
+ example: '6m'
3919
+ },
3920
+ granularity: {
3921
+ type: 'string',
3922
+ description: 'Data granularity',
3923
+ example: 'month'
3924
+ },
3925
+ currency: {
3926
+ type: 'string',
3927
+ description: 'Base currency for converted values',
3928
+ example: 'CNY'
3929
+ },
3930
+ byCurrency: {
3931
+ description:
3932
+ 'Multi-currency time series (each point has currency breakdown)',
3933
+ type: 'array',
3934
+ items: {
3935
+ $ref: '#/components/schemas/MultiCurrencyPointDto'
3936
+ }
3937
+ },
3938
+ warnings: {
3939
+ description: 'Exchange rate warnings',
3940
+ type: 'array',
3941
+ items: {
3942
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3943
+ }
3944
+ }
3945
+ },
3946
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
3947
+ } as const;
3948
+
3949
+ export const $CashFlowPointDto = {
3950
+ type: 'object',
3951
+ properties: {
3952
+ month: {
3953
+ type: 'string',
3954
+ description: 'Month key (YYYY-MM)',
3955
+ example: '2024-03'
3956
+ },
3957
+ income: {
3958
+ type: 'string',
3959
+ description: 'Income in base currency (absolute, converted)',
3960
+ example: '10000.00'
3961
+ },
3962
+ expense: {
3963
+ type: 'string',
3964
+ description: 'Expense in base currency (absolute, converted)',
3965
+ example: '5000.00'
3966
+ },
3967
+ netSavings: {
3968
+ type: 'string',
3969
+ description: 'netSavings = income − expense (savings positive)',
3970
+ example: '5000.00'
3971
+ }
3972
+ },
3973
+ required: ['month', 'income', 'expense', 'netSavings']
3974
+ } as const;
3975
+
3976
+ export const $CashFlowTrendSummaryDto = {
3977
+ type: 'object',
3978
+ properties: {
3979
+ totalIncome: {
3980
+ type: 'string',
3981
+ description: 'Total income across the period',
3982
+ example: '60000.00'
3983
+ },
3984
+ totalExpense: {
3985
+ type: 'string',
3986
+ description: 'Total expense across the period',
3987
+ example: '30000.00'
3988
+ },
3989
+ totalNetSavings: {
3990
+ type: 'string',
3991
+ description: 'income − expense across the period',
3992
+ example: '30000.00'
3993
+ },
3994
+ averageMonthlyNetSavings: {
3995
+ type: 'string',
3996
+ description:
3997
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
3998
+ example: '5000.00'
3999
+ }
4000
+ },
4001
+ required: [
4002
+ 'totalIncome',
4003
+ 'totalExpense',
4004
+ 'totalNetSavings',
4005
+ 'averageMonthlyNetSavings'
4006
+ ]
4007
+ } as const;
4008
+
4009
+ export const $CashFlowTrendsResponseDto = {
4010
+ type: 'object',
4011
+ properties: {
4012
+ series: {
4013
+ description:
4014
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
4015
+ type: 'array',
4016
+ items: {
4017
+ $ref: '#/components/schemas/CashFlowPointDto'
4018
+ }
4019
+ },
4020
+ summary: {
4021
+ description: 'Period totals',
4022
+ allOf: [
4023
+ {
4024
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
4025
+ }
4026
+ ]
4027
+ },
4028
+ period: {
4029
+ type: 'string',
4030
+ description: 'Period requested',
4031
+ example: '6m'
4032
+ },
4033
+ granularity: {
4034
+ type: 'string',
4035
+ description: 'Data granularity (v1 returns month buckets)',
4036
+ example: 'month'
4037
+ },
4038
+ currency: {
4039
+ type: 'string',
4040
+ description: 'Base currency for converted values',
4041
+ example: 'CNY'
4042
+ },
4043
+ warnings: {
4044
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
4045
+ type: 'array',
4046
+ items: {
4047
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
4048
+ }
4049
+ }
4050
+ },
4051
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
4052
+ } as const;
4053
+
4054
+ export const $GenerateSnapshotBody = {
4055
+ type: 'object',
4056
+ properties: {}
4057
+ } as const;
4058
+
4059
+ export const $GenerateSnapshotResponse = {
4060
+ type: 'object',
4061
+ properties: {}
4062
+ } as const;
4063
+
4064
+ export const $BackfillSnapshotsBody = {
4065
+ type: 'object',
4066
+ properties: {}
4067
+ } as const;
4068
+
4069
+ export const $BackfillSnapshotsResponse = {
4070
+ type: 'object',
4071
+ properties: {}
4072
+ } as const;
4073
+
4074
+ export const $DeleteOwnUserDto = {
4075
+ type: 'object',
4076
+ properties: {
4077
+ accessToken: {
4078
+ type: 'string',
4079
+ description: 'Access token for user verification',
4080
+ example: 'abc123xyz'
4081
+ }
4082
+ },
4083
+ required: ['accessToken']
4084
+ } as const;
4085
+
4086
+ export const $SignupDto = {
4087
+ type: 'object',
4088
+ properties: {
4089
+ turnstileToken: {
4090
+ type: 'string',
4091
+ description:
4092
+ 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4093
+ example: '0.abc123def456...'
4094
+ }
4095
+ }
4096
+ } as const;
4097
+
4098
+ export const $SignupResponseDto = {
4099
+ type: 'object',
4100
+ properties: {
4101
+ authToken: {
4102
+ type: 'string',
4103
+ description: 'JWT auth token',
4104
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4105
+ },
4106
+ accessToken: {
4107
+ type: 'string',
4108
+ description: 'Auto-generated access token'
4109
+ },
4110
+ role: {
4111
+ type: 'string',
4112
+ description: 'Assigned user role',
4113
+ enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
4114
+ }
4115
+ },
4116
+ required: ['authToken', 'accessToken', 'role']
4117
+ } as const;
4118
+
4119
+ export const $UpdateUserSettingDto = {
4120
+ type: 'object',
4121
+ properties: {
4122
+ secId: {
4123
+ type: 'number',
4124
+ description: 'Security ID'
4125
+ },
4126
+ annualInterestRate: {
4127
+ type: 'number',
4128
+ description: 'Annual interest rate',
4129
+ example: 0.05
4130
+ },
4131
+ currency: {
4132
+ type: 'string',
4133
+ description: 'Currency code',
4134
+ example: 'USD'
4135
+ },
4136
+ baseCurrency: {
4137
+ type: 'string',
4138
+ description: 'Base currency code',
4139
+ example: 'USD'
4140
+ },
4141
+ benchmark: {
4142
+ type: 'string',
4143
+ description: 'Benchmark symbol',
4144
+ example: 'SPY'
4145
+ },
4146
+ colorScheme: {
4147
+ type: 'string',
4148
+ description: 'Color scheme',
4149
+ enum: ['DARK', 'LIGHT']
4150
+ },
4151
+ dateRange: {
4152
+ type: 'string',
4153
+ description: 'Date range filter',
4154
+ example: '1y'
4155
+ },
4156
+ emergencyFund: {
4157
+ type: 'number',
4158
+ description: 'Emergency fund amount',
4159
+ example: 10000
4160
+ },
4161
+ 'filters.accounts': {
4162
+ description: 'Account filter IDs',
4163
+ type: 'array',
4164
+ items: {
4165
+ type: 'string'
4166
+ }
4167
+ },
4168
+ 'filters.assetClasses': {
4169
+ description: 'Asset class filters',
4170
+ type: 'array',
4171
+ items: {
4172
+ type: 'string'
4173
+ }
4174
+ },
4175
+ 'filters.dataSource': {
4176
+ type: 'string',
4177
+ description: 'Data source filter'
4178
+ },
4179
+ 'filters.symbol': {
4180
+ type: 'string',
4181
+ description: 'Symbol filter'
4182
+ },
4183
+ 'filters.tags': {
4184
+ description: 'Tag filters',
4185
+ type: 'array',
4186
+ items: {
4187
+ type: 'string'
4188
+ }
4189
+ },
4190
+ isExperimentalFeatures: {
4191
+ type: 'boolean',
4192
+ description: 'Enable experimental features'
4193
+ },
4194
+ isRestrictedView: {
4195
+ type: 'boolean',
4196
+ description: 'Enable restricted view mode'
4197
+ },
4198
+ language: {
4199
+ type: 'string',
4200
+ description: 'Language code',
4201
+ example: 'en'
4202
+ },
4203
+ locale: {
4204
+ type: 'string',
4205
+ description: 'Locale code',
4206
+ example: 'en-US'
4207
+ },
4208
+ projectedTotalAmount: {
4209
+ type: 'number',
4210
+ description: 'Projected total amount',
4211
+ example: 1000000
4212
+ },
4213
+ retirementDate: {
4214
+ type: 'string',
4215
+ description: 'Retirement date in ISO 8601 format',
4216
+ example: '2050-01-01'
4217
+ },
4218
+ savingsRate: {
4219
+ type: 'number',
4220
+ description: 'Savings rate percentage',
4221
+ example: 0.2
4222
+ },
4223
+ viewMode: {
4224
+ type: 'string',
4225
+ description: 'View mode',
4226
+ enum: ['DEFAULT', 'ZEN']
4227
+ }
4228
+ }
4229
+ } as const;
4230
+
4231
+ export const $UpdatePropertyDto = {
4232
+ type: 'object',
4233
+ properties: {
4234
+ value: {
4235
+ type: 'string',
4236
+ description: 'Property value'
4237
+ }
4238
+ },
4239
+ required: ['value']
4240
+ } as const;
4241
+
4242
+ export const $CreateTransactionRuleDto = {
4243
+ type: 'object',
4244
+ properties: {
4245
+ name: {
4246
+ type: 'string',
4247
+ minLength: 1,
4248
+ maxLength: 100
4249
+ },
4250
+ description: {
4251
+ type: 'string',
4252
+ maxLength: 500
4253
+ },
4254
+ narrationKeywords: {
4255
+ items: {
4256
+ type: 'array'
4257
+ },
4258
+ maxItems: 50,
4259
+ type: 'array'
4260
+ },
4261
+ payeeKeywords: {
4262
+ items: {
4263
+ type: 'array'
4264
+ },
4265
+ maxItems: 50,
4266
+ type: 'array'
4267
+ },
4268
+ categoryKeywords: {
4269
+ items: {
4270
+ type: 'array'
4271
+ },
4272
+ maxItems: 50,
4273
+ type: 'array'
4274
+ },
4275
+ methodKeywords: {
4276
+ items: {
4277
+ type: 'array'
4278
+ },
4279
+ maxItems: 50,
4280
+ description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
4281
+ type: 'array'
4282
+ },
4283
+ categoryAccount: {
4284
+ type: 'string',
4285
+ maxLength: 200,
4286
+ description:
4287
+ 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
4288
+ },
4289
+ matchLogic: {
4290
+ type: 'string',
4291
+ enum: ['OR', 'AND'],
4292
+ default: 'OR'
4293
+ },
4294
+ amountMin: {
4295
+ type: 'number',
4296
+ minimum: 0,
4297
+ description: 'Minimum transaction amount (inclusive)'
4298
+ },
4299
+ amountMax: {
4300
+ type: 'number',
4301
+ minimum: 0,
4302
+ description: 'Maximum transaction amount (inclusive)'
4303
+ },
4304
+ priority: {
4305
+ type: 'number',
4306
+ default: 50,
4307
+ minimum: 0,
4308
+ maximum: 1000
4309
+ },
4310
+ additionalTags: {
4311
+ items: {
4312
+ type: 'array'
4313
+ },
4314
+ maxItems: 20,
4315
+ type: 'array'
4316
+ },
4317
+ additionalMetadata: {
4318
+ type: 'object'
4319
+ },
4320
+ upsertByPayee: {
4321
+ type: 'boolean',
4322
+ description:
4323
+ 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
4324
+ }
4325
+ },
4326
+ required: ['name', 'matchLogic', 'priority']
4327
+ } as const;
4328
+
4329
+ export const $AmountRangeDto = {
4330
+ type: 'object',
4331
+ properties: {
4332
+ min: {
4333
+ type: 'number',
4334
+ description: 'Minimum amount'
4335
+ },
4336
+ max: {
4337
+ type: 'number',
4338
+ description: 'Maximum amount'
3484
4339
  }
3485
4340
  }
3486
4341
  } as const;
@@ -4033,151 +4888,393 @@ export const $TestRuleResponseDto = {
4033
4888
  required: ['ruleId', 'matches', 'confidence', 'matchDetails']
4034
4889
  } as const;
4035
4890
 
4036
- export const $DeleteOwnUserDto = {
4891
+ export const $CreateBeanEventDto = {
4037
4892
  type: 'object',
4038
4893
  properties: {
4039
- accessToken: {
4894
+ date: {
4040
4895
  type: 'string',
4041
- description: 'Access token for user verification',
4042
- example: 'abc123xyz'
4896
+ description: 'Life event date (ISO 8601)',
4897
+ example: '2024-03-15'
4898
+ },
4899
+ type: {
4900
+ type: 'string',
4901
+ description:
4902
+ 'Life event type (e.g., "employer", "location", "marital-status") — user-defined, no enum constraint at engine layer',
4903
+ example: 'employer'
4904
+ },
4905
+ description: {
4906
+ type: 'string',
4907
+ description:
4908
+ 'Life event description. Empty string is a VALID value (distinct from absence).',
4909
+ example: 'Acme Corp'
4910
+ },
4911
+ meta: {
4912
+ type: 'object',
4913
+ description:
4914
+ 'Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)',
4915
+ example: {
4916
+ note: 'Promotion'
4917
+ }
4043
4918
  }
4044
4919
  },
4045
- required: ['accessToken']
4920
+ required: ['date', 'type', 'description']
4046
4921
  } as const;
4047
4922
 
4048
- export const $SignupDto = {
4923
+ export const $EventResponseDto = {
4049
4924
  type: 'object',
4050
4925
  properties: {
4051
- turnstileToken: {
4926
+ id: {
4927
+ type: 'string',
4928
+ description: 'Unique identifier',
4929
+ example: 'uuid-123-456'
4930
+ },
4931
+ userId: {
4932
+ type: 'string',
4933
+ description: 'User ID (owner of the life event)',
4934
+ example: 'user-123'
4935
+ },
4936
+ date: {
4937
+ type: 'string',
4938
+ description: 'Life event date (ISO 8601 format)',
4939
+ example: '2024-03-15',
4940
+ format: 'date'
4941
+ },
4942
+ type: {
4052
4943
  type: 'string',
4053
4944
  description:
4054
- 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4055
- example: '0.abc123def456...'
4945
+ 'Life event type (user-defined, e.g., "employer", "location")',
4946
+ example: 'employer'
4947
+ },
4948
+ description: {
4949
+ type: 'string',
4950
+ description:
4951
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4952
+ example: 'Acme Corp'
4953
+ },
4954
+ meta: {
4955
+ type: 'object',
4956
+ description: 'Product-side metadata (free-form JSON)',
4957
+ example: {
4958
+ note: 'Promotion'
4959
+ }
4960
+ },
4961
+ createdAt: {
4962
+ format: 'date-time',
4963
+ type: 'string',
4964
+ description: 'Creation timestamp',
4965
+ example: '2024-03-15T10:00:00Z'
4966
+ },
4967
+ updatedAt: {
4968
+ format: 'date-time',
4969
+ type: 'string',
4970
+ description:
4971
+ 'Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.',
4972
+ example: '2024-03-15T10:00:00Z'
4056
4973
  }
4057
- }
4974
+ },
4975
+ required: [
4976
+ 'id',
4977
+ 'userId',
4978
+ 'date',
4979
+ 'type',
4980
+ 'description',
4981
+ 'meta',
4982
+ 'createdAt',
4983
+ 'updatedAt'
4984
+ ]
4058
4985
  } as const;
4059
4986
 
4060
- export const $UpdateUserSettingDto = {
4987
+ export const $EventListResponseDto = {
4061
4988
  type: 'object',
4062
4989
  properties: {
4063
- secId: {
4064
- type: 'number',
4065
- description: 'Security ID'
4990
+ items: {
4991
+ description: 'List of life events',
4992
+ type: 'array',
4993
+ items: {
4994
+ $ref: '#/components/schemas/EventResponseDto'
4995
+ }
4066
4996
  },
4067
- annualInterestRate: {
4997
+ total: {
4068
4998
  type: 'number',
4069
- description: 'Annual interest rate',
4070
- example: 0.05
4071
- },
4072
- currency: {
4999
+ description: 'Total number of life events matching the query',
5000
+ example: 42
5001
+ }
5002
+ },
5003
+ required: ['items', 'total']
5004
+ } as const;
5005
+
5006
+ export const $UpdateBeanEventDto = {
5007
+ type: 'object',
5008
+ properties: {
5009
+ date: {
4073
5010
  type: 'string',
4074
- description: 'Currency code',
4075
- example: 'USD'
5011
+ description: 'Life event date (ISO 8601)'
4076
5012
  },
4077
- baseCurrency: {
5013
+ type: {
4078
5014
  type: 'string',
4079
- description: 'Base currency code',
4080
- example: 'USD'
5015
+ description: 'Life event type (user-defined)'
4081
5016
  },
4082
- benchmark: {
5017
+ description: {
4083
5018
  type: 'string',
4084
- description: 'Benchmark symbol',
4085
- example: 'SPY'
5019
+ description:
5020
+ 'Life event description. Empty string is a VALID value (distinct from absence).'
4086
5021
  },
4087
- colorScheme: {
5022
+ meta: {
5023
+ type: 'object',
5024
+ description: 'Product-side metadata (free-form JSON)'
5025
+ }
5026
+ }
5027
+ } as const;
5028
+
5029
+ export const $OnboardingAccountDto = {
5030
+ type: 'object',
5031
+ properties: {
5032
+ path: {
4088
5033
  type: 'string',
4089
- description: 'Color scheme',
4090
- enum: ['DARK', 'LIGHT']
5034
+ description:
5035
+ 'Account path (Assets/Liabilities only; format validated by the account service)',
5036
+ example: 'Assets:Checking'
4091
5037
  },
4092
- dateRange: {
5038
+ currency: {
4093
5039
  type: 'string',
4094
- description: 'Date range filter',
4095
- example: '1y'
5040
+ description: 'ISO 4217 currency code (3 letters)',
5041
+ example: 'USD'
4096
5042
  },
4097
- emergencyFund: {
4098
- type: 'number',
4099
- description: 'Emergency fund amount',
4100
- example: 10000
5043
+ openingBalance: {
5044
+ type: 'string',
5045
+ description:
5046
+ 'Opening balance as a non-negative Decimal string (e.g. "1000.00")',
5047
+ example: '1000.00'
4101
5048
  },
4102
- 'filters.accounts': {
4103
- description: 'Account filter IDs',
5049
+ platformId: {
5050
+ type: 'string',
5051
+ description:
5052
+ 'Platform ID to bind the account to (references Platform.id); omit for unbound',
5053
+ example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
5054
+ }
5055
+ },
5056
+ required: ['path', 'currency']
5057
+ } as const;
5058
+
5059
+ export const $OnboardingDto = {
5060
+ type: 'object',
5061
+ properties: {
5062
+ accounts: {
5063
+ description: 'Asset/Liability accounts to register with opening balances',
4104
5064
  type: 'array',
4105
5065
  items: {
4106
- type: 'string'
5066
+ $ref: '#/components/schemas/OnboardingAccountDto'
4107
5067
  }
4108
5068
  },
4109
- 'filters.assetClasses': {
4110
- description: 'Asset class filters',
4111
- type: 'array',
4112
- items: {
4113
- type: 'string'
4114
- }
5069
+ skipAssetRegistration: {
5070
+ type: 'boolean',
5071
+ description:
5072
+ 'Skip asset registration; only bootstrap the core account set',
5073
+ default: false
5074
+ }
5075
+ }
5076
+ } as const;
5077
+
5078
+ export const $ActualBalanceDto = {
5079
+ type: 'object',
5080
+ properties: {
5081
+ amount: {
5082
+ type: 'string',
5083
+ description:
5084
+ 'Actual balance amount as a decimal string (preserves precision for tolerance inference).',
5085
+ example: '1234.56'
4115
5086
  },
4116
- 'filters.dataSource': {
5087
+ ccy: {
4117
5088
  type: 'string',
4118
- description: 'Data source filter'
5089
+ description: 'Currency code (ISO 4217 or commodity ticker).',
5090
+ example: 'CNY'
5091
+ }
5092
+ },
5093
+ required: ['amount', 'ccy']
5094
+ } as const;
5095
+
5096
+ export const $ComputeReconciliationDto = {
5097
+ type: 'object',
5098
+ properties: {
5099
+ accountId: {
5100
+ type: 'string',
5101
+ description: 'BeanAccount id to reconcile.'
5102
+ },
5103
+ asOfDate: {
5104
+ type: 'string',
5105
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5106
+ example: '2026-07-24'
5107
+ },
5108
+ actualBalance: {
5109
+ description: 'Actual balance from the external statement.',
5110
+ allOf: [
5111
+ {
5112
+ $ref: '#/components/schemas/ActualBalanceDto'
5113
+ }
5114
+ ]
5115
+ }
5116
+ },
5117
+ required: ['accountId', 'asOfDate', 'actualBalance']
5118
+ } as const;
5119
+
5120
+ export const $ReconciliationComputeResultDto = {
5121
+ type: 'object',
5122
+ properties: {
5123
+ accountId: {
5124
+ type: 'string'
5125
+ },
5126
+ asOfDate: {
5127
+ type: 'string'
5128
+ },
5129
+ bookBalance: {
5130
+ type: 'string',
5131
+ description: 'System-computed book balance (decimal string).'
5132
+ },
5133
+ actualBalance: {
5134
+ type: 'string',
5135
+ description: 'User-entered actual balance (decimal string).'
5136
+ },
5137
+ currency: {
5138
+ type: 'string'
5139
+ },
5140
+ diff: {
5141
+ type: 'string',
5142
+ description: 'Diff = book − actual (decimal string).'
5143
+ },
5144
+ tolerance: {
5145
+ type: 'string',
5146
+ description: 'Applied tolerance (decimal string).'
5147
+ },
5148
+ withinTolerance: {
5149
+ type: 'boolean',
5150
+ description: 'true when |diff| ≤ tolerance.'
5151
+ },
5152
+ suggestedAction: {
5153
+ type: 'string',
5154
+ enum: ['assert', 'pad'],
5155
+ description:
5156
+ 'Suggested next action: assert when within tolerance, pad otherwise.'
5157
+ }
5158
+ },
5159
+ required: [
5160
+ 'accountId',
5161
+ 'asOfDate',
5162
+ 'bookBalance',
5163
+ 'actualBalance',
5164
+ 'currency',
5165
+ 'diff',
5166
+ 'tolerance',
5167
+ 'withinTolerance',
5168
+ 'suggestedAction'
5169
+ ]
5170
+ } as const;
5171
+
5172
+ export const $AssertReconciliationDto = {
5173
+ type: 'object',
5174
+ properties: {
5175
+ accountId: {
5176
+ type: 'string',
5177
+ description: 'BeanAccount id to reconcile.'
4119
5178
  },
4120
- 'filters.symbol': {
5179
+ asOfDate: {
4121
5180
  type: 'string',
4122
- description: 'Symbol filter'
5181
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5182
+ example: '2026-07-24'
4123
5183
  },
4124
- 'filters.tags': {
4125
- description: 'Tag filters',
4126
- type: 'array',
4127
- items: {
4128
- type: 'string'
4129
- }
5184
+ actualBalance: {
5185
+ description: 'Actual balance from the external statement.',
5186
+ allOf: [
5187
+ {
5188
+ $ref: '#/components/schemas/ActualBalanceDto'
5189
+ }
5190
+ ]
4130
5191
  },
4131
- isExperimentalFeatures: {
4132
- type: 'boolean',
4133
- description: 'Enable experimental features'
5192
+ tolerance: {
5193
+ type: 'string',
5194
+ description:
5195
+ 'Optional explicit tolerance override. Omit to infer from amount precision (Beancount default).',
5196
+ example: '0.01'
5197
+ }
5198
+ },
5199
+ required: ['accountId', 'asOfDate', 'actualBalance']
5200
+ } as const;
5201
+
5202
+ export const $ReconciliationRecordDto = {
5203
+ type: 'object',
5204
+ properties: {
5205
+ id: {
5206
+ type: 'string'
4134
5207
  },
4135
- isRestrictedView: {
4136
- type: 'boolean',
4137
- description: 'Enable restricted view mode'
5208
+ accountId: {
5209
+ type: 'string'
4138
5210
  },
4139
- language: {
5211
+ date: {
5212
+ type: 'string'
5213
+ },
5214
+ amount: {
4140
5215
  type: 'string',
4141
- description: 'Language code',
4142
- example: 'en'
5216
+ description: 'Asserted (actual) amount.'
4143
5217
  },
4144
- locale: {
5218
+ currency: {
5219
+ type: 'string'
5220
+ },
5221
+ tolerance: {
5222
+ type: 'string'
5223
+ },
5224
+ diffAmount: {
4145
5225
  type: 'string',
4146
- description: 'Locale code',
4147
- example: 'en-US'
5226
+ description: 'book − actual.'
4148
5227
  },
4149
- projectedTotalAmount: {
4150
- type: 'number',
4151
- description: 'Projected total amount',
4152
- example: 1000000
5228
+ diffCurrency: {
5229
+ type: 'string'
4153
5230
  },
4154
- retirementDate: {
5231
+ createdAt: {
5232
+ type: 'string'
5233
+ }
5234
+ },
5235
+ required: ['id', 'accountId', 'date', 'amount', 'currency', 'createdAt']
5236
+ } as const;
5237
+
5238
+ export const $PadReconciliationDto = {
5239
+ type: 'object',
5240
+ properties: {
5241
+ accountId: {
4155
5242
  type: 'string',
4156
- description: 'Retirement date in ISO 8601 format',
4157
- example: '2050-01-01'
5243
+ description: 'BeanAccount id to reconcile.'
4158
5244
  },
4159
- savingsRate: {
4160
- type: 'number',
4161
- description: 'Savings rate percentage',
4162
- example: 0.2
5245
+ asOfDate: {
5246
+ type: 'string',
5247
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5248
+ example: '2026-07-24'
4163
5249
  },
4164
- viewMode: {
5250
+ actualBalance: {
5251
+ description: 'Actual balance from the external statement.',
5252
+ allOf: [
5253
+ {
5254
+ $ref: '#/components/schemas/ActualBalanceDto'
5255
+ }
5256
+ ]
5257
+ },
5258
+ sourceAccount: {
4165
5259
  type: 'string',
4166
- description: 'View mode',
4167
- enum: ['DEFAULT', 'ZEN']
5260
+ description:
5261
+ 'Pad source account. Defaults to Equity:Opening-Balances (official Beancount convention).',
5262
+ example: 'Equity:Opening-Balances',
5263
+ default: 'Equity:Opening-Balances'
4168
5264
  }
4169
- }
5265
+ },
5266
+ required: ['accountId', 'asOfDate', 'actualBalance']
4170
5267
  } as const;
4171
5268
 
4172
- export const $UpdatePropertyDto = {
5269
+ export const $PadResultDto = {
4173
5270
  type: 'object',
4174
5271
  properties: {
4175
- value: {
5272
+ transactionId: {
4176
5273
  type: 'string',
4177
- description: 'Property value'
5274
+ description: 'Created pad adjusting transaction id.'
4178
5275
  }
4179
5276
  },
4180
- required: ['value']
5277
+ required: ['transactionId']
4181
5278
  } as const;
4182
5279
 
4183
5280
  export const $FileImportDto = {
@@ -4346,7 +5443,7 @@ export const $IdentifyResultDto = {
4346
5443
  account: {
4347
5444
  type: 'string',
4348
5445
  description: 'Default account used by this importer',
4349
- example: 'Assets:Alipay:Balance'
5446
+ example: 'Assets:CN:Alipay:Balance'
4350
5447
  },
4351
5448
  message: {
4352
5449
  type: 'string',
@@ -4363,7 +5460,7 @@ export const $MapperDefaultsDto = {
4363
5460
  sourceAccount: {
4364
5461
  type: 'string',
4365
5462
  description: 'Source account for transactions (Beancount format)',
4366
- example: 'Assets:Alipay:Balance'
5463
+ example: 'Assets:CN:Alipay:Balance'
4367
5464
  },
4368
5465
  currency: {
4369
5466
  type: 'string',
@@ -4400,7 +5497,7 @@ export const $MapperDefaultsDto = {
4400
5497
  description:
4401
5498
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4402
5499
  example: {
4403
- HuaBei: 'Liabilities:Alipay:Huabei',
5500
+ HuaBei: 'Liabilities:CN:CreditLine',
4404
5501
  CreditCard: 'Liabilities:CreditCard'
4405
5502
  }
4406
5503
  }
@@ -4532,7 +5629,7 @@ export const $UpdateMapperDefaultsDto = {
4532
5629
  sourceAccount: {
4533
5630
  type: 'string',
4534
5631
  description: 'Source account for transactions (Beancount format)',
4535
- example: 'Assets:Alipay:Balance',
5632
+ example: 'Assets:CN:Alipay:Balance',
4536
5633
  pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4537
5634
  },
4538
5635
  currency: {
@@ -4560,7 +5657,7 @@ export const $UpdateMapperDefaultsDto = {
4560
5657
  description:
4561
5658
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4562
5659
  example: {
4563
- HuaBei: 'Liabilities:Alipay:Huabei',
5660
+ HuaBei: 'Liabilities:CN:CreditLine',
4564
5661
  CreditCard: 'Liabilities:CreditCard'
4565
5662
  }
4566
5663
  }
@@ -4595,119 +5692,13 @@ export const $UpdateImporterConfigDto = {
4595
5692
  }
4596
5693
  } as const;
4597
5694
 
4598
- export const $CreatePlatformDto = {
4599
- type: 'object',
4600
- properties: {
4601
- name: {
4602
- type: 'string',
4603
- description: 'Platform name',
4604
- example: 'Binance'
4605
- },
4606
- canonical: {
4607
- type: 'string',
4608
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4609
- example: 'binance'
4610
- },
4611
- aliases: {
4612
- description: 'Platform aliases (multi-language names for lookup)',
4613
- example: ['Binance', 'Binance Exchange', 'BNB'],
4614
- type: 'array',
4615
- items: {
4616
- type: 'string'
4617
- }
4618
- },
4619
- url: {
4620
- type: 'string',
4621
- description: 'Platform URL',
4622
- example: 'https://www.binance.com'
4623
- },
4624
- type: {
4625
- type: 'string',
4626
- description: 'Platform type',
4627
- enum: [
4628
- 'BANK',
4629
- 'BROKERAGE',
4630
- 'CRYPTO_EXCHANGE',
4631
- 'PAYMENT',
4632
- 'INVESTMENT',
4633
- 'INSURANCE',
4634
- 'OTHER'
4635
- ],
4636
- example: 'CRYPTO_EXCHANGE'
4637
- },
4638
- logoUrl: {
4639
- type: 'string',
4640
- description: 'Platform logo URL',
4641
- example: 'https://example.com/logos/binance.png'
4642
- },
4643
- isActive: {
4644
- type: 'boolean',
4645
- description: 'Whether the platform is active',
4646
- default: true
4647
- }
4648
- },
4649
- required: ['name', 'canonical', 'aliases', 'url', 'type']
4650
- } as const;
4651
-
4652
- export const $UpdatePlatformDto = {
4653
- type: 'object',
4654
- properties: {
4655
- name: {
4656
- type: 'string',
4657
- description: 'Platform name',
4658
- example: 'Binance'
4659
- },
4660
- canonical: {
4661
- type: 'string',
4662
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4663
- example: 'binance'
4664
- },
4665
- aliases: {
4666
- description: 'Platform aliases (multi-language names for lookup)',
4667
- example: ['Binance', 'Binance Exchange', 'BNB'],
4668
- type: 'array',
4669
- items: {
4670
- type: 'string'
4671
- }
4672
- },
4673
- url: {
4674
- type: 'string',
4675
- description: 'Platform URL',
4676
- example: 'https://www.binance.com'
4677
- },
4678
- type: {
4679
- type: 'string',
4680
- description: 'Platform type',
4681
- enum: [
4682
- 'BANK',
4683
- 'BROKERAGE',
4684
- 'CRYPTO_EXCHANGE',
4685
- 'PAYMENT',
4686
- 'INVESTMENT',
4687
- 'INSURANCE',
4688
- 'OTHER'
4689
- ],
4690
- example: 'CRYPTO_EXCHANGE'
4691
- },
4692
- logoUrl: {
4693
- type: 'string',
4694
- description: 'Platform logo URL',
4695
- example: 'https://example.com/logos/binance.png'
4696
- },
4697
- isActive: {
4698
- type: 'boolean',
4699
- description: 'Whether the platform is active'
4700
- }
4701
- }
4702
- } as const;
4703
-
4704
5695
  export const $ProviderSyncConfigDto = {
4705
5696
  type: 'object',
4706
5697
  properties: {
4707
5698
  sourceAccount: {
4708
5699
  type: 'string',
4709
5700
  description: 'Source account for the first posting',
4710
- example: 'Assets:Bank:Chase'
5701
+ example: 'Assets:US:Chase:Checking'
4711
5702
  },
4712
5703
  defaultCurrency: {
4713
5704
  type: 'string',
@@ -4728,6 +5719,12 @@ export const $ProviderSyncConfigDto = {
4728
5719
  type: 'boolean',
4729
5720
  description: 'Filter pending transactions',
4730
5721
  default: true
5722
+ },
5723
+ externalAccountId: {
5724
+ type: 'string',
5725
+ description:
5726
+ 'External account ID for per-batch providers (e.g. GoCardless). Overrides sourceAccount when an ExternalAccountLink mapping exists.',
5727
+ example: 'acc_gocardless_001'
4731
5728
  }
4732
5729
  },
4733
5730
  required: [
@@ -4844,7 +5841,95 @@ export const $SupportedProvidersResponseDto = {
4844
5841
  }
4845
5842
  }
4846
5843
  },
4847
- required: ['providers']
5844
+ required: ['providers']
5845
+ } as const;
5846
+
5847
+ export const $CreateExternalAccountLinkDto = {
5848
+ type: 'object',
5849
+ properties: {
5850
+ provider: {
5851
+ type: 'string',
5852
+ enum: [
5853
+ 'plaid',
5854
+ 'teller',
5855
+ 'truelayer',
5856
+ 'gocardless',
5857
+ 'simplefin',
5858
+ 'yodlee',
5859
+ 'beancount-direct',
5860
+ 'parsed-bill'
5861
+ ],
5862
+ example: 'plaid',
5863
+ description: 'Open Banking provider (whitelist)'
5864
+ },
5865
+ externalAccountId: {
5866
+ type: 'string',
5867
+ example: 'acc-plaid-001',
5868
+ description: 'External account ID from the provider'
5869
+ },
5870
+ beanAccountId: {
5871
+ type: 'string',
5872
+ example: '550e8400-e29b-41d4-a716-446655440000',
5873
+ description: 'Target BeanAccount ID (must belong to the JWT user)'
5874
+ }
5875
+ },
5876
+ required: ['provider', 'externalAccountId', 'beanAccountId']
5877
+ } as const;
5878
+
5879
+ export const $ExternalAccountLinkResponseDto = {
5880
+ type: 'object',
5881
+ properties: {
5882
+ id: {
5883
+ type: 'string'
5884
+ },
5885
+ provider: {
5886
+ type: 'string'
5887
+ },
5888
+ externalAccountId: {
5889
+ type: 'string'
5890
+ },
5891
+ beanAccountId: {
5892
+ type: 'string'
5893
+ },
5894
+ isActive: {
5895
+ type: 'boolean'
5896
+ },
5897
+ createdAt: {
5898
+ type: 'string'
5899
+ },
5900
+ updatedAt: {
5901
+ type: 'string'
5902
+ }
5903
+ },
5904
+ required: [
5905
+ 'id',
5906
+ 'provider',
5907
+ 'externalAccountId',
5908
+ 'beanAccountId',
5909
+ 'isActive',
5910
+ 'createdAt',
5911
+ 'updatedAt'
5912
+ ]
5913
+ } as const;
5914
+
5915
+ export const $ExternalAccountLinkListResponseDto = {
5916
+ type: 'object',
5917
+ properties: {
5918
+ items: {
5919
+ type: 'array',
5920
+ items: {
5921
+ $ref: '#/components/schemas/ExternalAccountLinkResponseDto'
5922
+ }
5923
+ },
5924
+ total: {
5925
+ type: 'number'
5926
+ },
5927
+ provider: {
5928
+ type: 'string',
5929
+ description: 'Filter by provider (query param)'
5930
+ }
5931
+ },
5932
+ required: ['items', 'total']
4848
5933
  } as const;
4849
5934
 
4850
5935
  export const $ParserTelemetryReportDto = {
@@ -4852,6 +5937,11 @@ export const $ParserTelemetryReportDto = {
4852
5937
  properties: {}
4853
5938
  } as const;
4854
5939
 
5940
+ export const $UncoveredFormatMissDto = {
5941
+ type: 'object',
5942
+ properties: {}
5943
+ } as const;
5944
+
4855
5945
  export const $ProcessNlpDto = {
4856
5946
  type: 'object',
4857
5947
  properties: {
@@ -5391,7 +6481,7 @@ export const $NlpSuggestedAccountDto = {
5391
6481
  account: {
5392
6482
  type: 'string',
5393
6483
  description: 'Suggested account path',
5394
- example: 'Assets:Bank:Checking'
6484
+ example: 'Assets:Checking'
5395
6485
  },
5396
6486
  confidence: {
5397
6487
  type: 'number',
@@ -5432,7 +6522,7 @@ export const $NlpDefaultAccountsDto = {
5432
6522
  asset: {
5433
6523
  type: 'string',
5434
6524
  description: 'Default asset account',
5435
- example: 'Assets:Bank:Checking'
6525
+ example: 'Assets:Checking'
5436
6526
  },
5437
6527
  expense: {
5438
6528
  type: 'string',
@@ -5472,7 +6562,8 @@ export const $NlpResponseDto = {
5472
6562
  'confirm_rule',
5473
6563
  'confirm_account',
5474
6564
  'confirm_payee',
5475
- 'cancel'
6565
+ 'cancel',
6566
+ 'aborted'
5476
6567
  ]
5477
6568
  },
5478
6569
  intent: {
@@ -5654,21 +6745,252 @@ export const $NlpResponseDto = {
5654
6745
  required: ['status', 'action']
5655
6746
  } as const;
5656
6747
 
5657
- export const $BalanceByCurrencyDto = {
6748
+ export const $PlatformListItemDto = {
5658
6749
  type: 'object',
5659
6750
  properties: {
5660
- currency: {
6751
+ id: {
5661
6752
  type: 'string',
5662
- description: 'ISO 4217 currency code',
5663
- example: 'CNY'
6753
+ description: 'Global platform ID'
5664
6754
  },
5665
- balance: {
6755
+ name: {
5666
6756
  type: 'string',
5667
- description: 'Balance amount',
5668
- example: '50000.00'
6757
+ description: 'Platform name'
6758
+ },
6759
+ url: {
6760
+ type: 'string',
6761
+ description: 'Platform URL'
6762
+ },
6763
+ type: {
6764
+ type: 'string',
6765
+ description: 'Platform type',
6766
+ enum: [
6767
+ 'BANK',
6768
+ 'BROKERAGE',
6769
+ 'CRYPTO_EXCHANGE',
6770
+ 'PAYMENT',
6771
+ 'INVESTMENT',
6772
+ 'INSURANCE',
6773
+ 'OTHER'
6774
+ ]
6775
+ },
6776
+ canonical: {
6777
+ type: 'string',
6778
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6779
+ },
6780
+ suggestedSegment: {
6781
+ type: 'string',
6782
+ description:
6783
+ 'Suggested path segment — canonical with first char uppercased (ACC_COMP_NAME_RE)'
6784
+ },
6785
+ logoUrl: {
6786
+ type: 'string',
6787
+ description: 'Logo URL',
6788
+ nullable: true
6789
+ },
6790
+ isBound: {
6791
+ type: 'boolean',
6792
+ description: 'Whether user has accounts using this platform'
5669
6793
  }
5670
6794
  },
5671
- required: ['currency', 'balance']
6795
+ required: [
6796
+ 'id',
6797
+ 'name',
6798
+ 'url',
6799
+ 'type',
6800
+ 'canonical',
6801
+ 'suggestedSegment',
6802
+ 'logoUrl',
6803
+ 'isBound'
6804
+ ]
6805
+ } as const;
6806
+
6807
+ export const $PlatformMatchResultDto = {
6808
+ type: 'object',
6809
+ properties: {
6810
+ id: {
6811
+ type: 'string',
6812
+ description: 'Global platform ID'
6813
+ },
6814
+ name: {
6815
+ type: 'string',
6816
+ description: 'Platform name (e.g., "ICBC")'
6817
+ },
6818
+ canonical: {
6819
+ type: 'string',
6820
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6821
+ },
6822
+ type: {
6823
+ type: 'string',
6824
+ description: 'Platform type',
6825
+ enum: [
6826
+ 'BANK',
6827
+ 'BROKERAGE',
6828
+ 'CRYPTO_EXCHANGE',
6829
+ 'PAYMENT',
6830
+ 'INVESTMENT',
6831
+ 'INSURANCE',
6832
+ 'OTHER'
6833
+ ]
6834
+ },
6835
+ suggestedSegment: {
6836
+ type: 'string',
6837
+ description:
6838
+ 'Suggested path segment — canonical, already in ACCOUNT_RE format'
6839
+ },
6840
+ logoUrl: {
6841
+ type: 'string',
6842
+ description: 'Logo URL',
6843
+ nullable: true
6844
+ },
6845
+ matchType: {
6846
+ type: 'string',
6847
+ description: "How this row matched: 'exact' > 'prefix' > 'substring'",
6848
+ enum: ['exact', 'prefix', 'substring']
6849
+ }
6850
+ },
6851
+ required: [
6852
+ 'id',
6853
+ 'name',
6854
+ 'canonical',
6855
+ 'type',
6856
+ 'suggestedSegment',
6857
+ 'logoUrl',
6858
+ 'matchType'
6859
+ ]
6860
+ } as const;
6861
+
6862
+ export const $PlatformMatchResponseDto = {
6863
+ type: 'object',
6864
+ properties: {
6865
+ platforms: {
6866
+ description: 'Ranked matches, best tier first (at most 10 rows)',
6867
+ type: 'array',
6868
+ items: {
6869
+ $ref: '#/components/schemas/PlatformMatchResultDto'
6870
+ }
6871
+ },
6872
+ matchType: {
6873
+ type: 'string',
6874
+ description:
6875
+ "Overall match quality — top row's tier, or 'none' when no hits",
6876
+ enum: ['none', 'exact', 'prefix', 'substring']
6877
+ },
6878
+ total: {
6879
+ type: 'number',
6880
+ description: 'Total matches before LIMIT (truncation transparency)'
6881
+ },
6882
+ hasMore: {
6883
+ type: 'boolean',
6884
+ description: 'true when total > platforms.length (more matches exist)'
6885
+ }
6886
+ },
6887
+ required: ['platforms', 'matchType', 'total', 'hasMore']
6888
+ } as const;
6889
+
6890
+ export const $CreatePlatformDto = {
6891
+ type: 'object',
6892
+ properties: {
6893
+ name: {
6894
+ type: 'string',
6895
+ description: 'Platform name',
6896
+ example: 'Binance'
6897
+ },
6898
+ canonical: {
6899
+ type: 'string',
6900
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6901
+ example: 'binance'
6902
+ },
6903
+ aliases: {
6904
+ description: 'Platform aliases (multi-language names for lookup)',
6905
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6906
+ type: 'array',
6907
+ items: {
6908
+ type: 'string'
6909
+ }
6910
+ },
6911
+ url: {
6912
+ type: 'string',
6913
+ description: 'Platform URL',
6914
+ example: 'https://www.binance.com'
6915
+ },
6916
+ type: {
6917
+ type: 'string',
6918
+ description: 'Platform type',
6919
+ enum: [
6920
+ 'BANK',
6921
+ 'BROKERAGE',
6922
+ 'CRYPTO_EXCHANGE',
6923
+ 'PAYMENT',
6924
+ 'INVESTMENT',
6925
+ 'INSURANCE',
6926
+ 'OTHER'
6927
+ ],
6928
+ example: 'CRYPTO_EXCHANGE'
6929
+ },
6930
+ logoUrl: {
6931
+ type: 'string',
6932
+ description: 'Platform logo URL',
6933
+ example: 'https://example.com/logos/binance.png'
6934
+ },
6935
+ isActive: {
6936
+ type: 'boolean',
6937
+ description: 'Whether the platform is active',
6938
+ default: true
6939
+ }
6940
+ },
6941
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
6942
+ } as const;
6943
+
6944
+ export const $UpdatePlatformDto = {
6945
+ type: 'object',
6946
+ properties: {
6947
+ name: {
6948
+ type: 'string',
6949
+ description: 'Platform name',
6950
+ example: 'Binance'
6951
+ },
6952
+ canonical: {
6953
+ type: 'string',
6954
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6955
+ example: 'binance'
6956
+ },
6957
+ aliases: {
6958
+ description: 'Platform aliases (multi-language names for lookup)',
6959
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6960
+ type: 'array',
6961
+ items: {
6962
+ type: 'string'
6963
+ }
6964
+ },
6965
+ url: {
6966
+ type: 'string',
6967
+ description: 'Platform URL',
6968
+ example: 'https://www.binance.com'
6969
+ },
6970
+ type: {
6971
+ type: 'string',
6972
+ description: 'Platform type',
6973
+ enum: [
6974
+ 'BANK',
6975
+ 'BROKERAGE',
6976
+ 'CRYPTO_EXCHANGE',
6977
+ 'PAYMENT',
6978
+ 'INVESTMENT',
6979
+ 'INSURANCE',
6980
+ 'OTHER'
6981
+ ],
6982
+ example: 'CRYPTO_EXCHANGE'
6983
+ },
6984
+ logoUrl: {
6985
+ type: 'string',
6986
+ description: 'Platform logo URL',
6987
+ example: 'https://example.com/logos/binance.png'
6988
+ },
6989
+ isActive: {
6990
+ type: 'boolean',
6991
+ description: 'Whether the platform is active'
6992
+ }
6993
+ }
5672
6994
  } as const;
5673
6995
 
5674
6996
  export const $NetWorthByCurrencyDto = {
@@ -5725,41 +7047,19 @@ export const $ConvertedNetWorthDto = {
5725
7047
  exchangeRates: {
5726
7048
  type: 'object',
5727
7049
  description: 'Exchange rates used for conversion',
5728
- example: {
5729
- USD: '7.200000',
5730
- EUR: '7.800000'
5731
- }
5732
- }
5733
- },
5734
- required: [
5735
- 'baseCurrency',
5736
- 'netWorth',
5737
- 'assets',
5738
- 'liabilities',
5739
- 'exchangeRates'
5740
- ]
5741
- } as const;
5742
-
5743
- export const $ExchangeRateWarningDto = {
5744
- type: 'object',
5745
- properties: {
5746
- type: {
5747
- type: 'string',
5748
- description: 'Warning type',
5749
- example: 'MISSING_EXCHANGE_RATE'
5750
- },
5751
- currency: {
5752
- type: 'string',
5753
- description: 'Currency without exchange rate',
5754
- example: 'EUR'
5755
- },
5756
- totalAmount: {
5757
- type: 'string',
5758
- description: 'Total amount affected',
5759
- example: '1000.00'
7050
+ example: {
7051
+ USD: '7.200000',
7052
+ EUR: '7.800000'
7053
+ }
5760
7054
  }
5761
7055
  },
5762
- required: ['type', 'currency', 'totalAmount']
7056
+ required: [
7057
+ 'baseCurrency',
7058
+ 'netWorth',
7059
+ 'assets',
7060
+ 'liabilities',
7061
+ 'exchangeRates'
7062
+ ]
5763
7063
  } as const;
5764
7064
 
5765
7065
  export const $NetWorthResponseDto = {
@@ -5847,7 +7147,7 @@ export const $AccountItemDto = {
5847
7147
  name: {
5848
7148
  type: 'string',
5849
7149
  description: 'Full account name',
5850
- example: 'Assets:Bank:CMB:Savings'
7150
+ example: 'Assets:CN:CMB:Savings'
5851
7151
  },
5852
7152
  displayName: {
5853
7153
  type: 'string',
@@ -5863,6 +7163,12 @@ export const $AccountItemDto = {
5863
7163
  type: 'string',
5864
7164
  description: 'Currency code',
5865
7165
  example: 'CNY'
7166
+ },
7167
+ convertedBalance: {
7168
+ type: 'string',
7169
+ description:
7170
+ 'FX-converted balance in base currency; omitted when not convertible',
7171
+ example: '50000.00'
5866
7172
  }
5867
7173
  },
5868
7174
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -5889,11 +7195,66 @@ export const $PlatformGroupDto = {
5889
7195
  },
5890
7196
  totalBalance: {
5891
7197
  type: 'string',
5892
- description: 'Total balance across all accounts in platform',
7198
+ description: 'FX-converted total balance in base currency',
7199
+ example: '100000.00'
7200
+ },
7201
+ balanceByCurrency: {
7202
+ description: 'Raw (unconverted) balances grouped by currency',
7203
+ type: 'array',
7204
+ items: {
7205
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7206
+ }
7207
+ },
7208
+ convertedBalance: {
7209
+ type: 'string',
7210
+ description:
7211
+ 'Converted balance in base currency (omitted when no currency is convertible)',
5893
7212
  example: '100000.00'
7213
+ },
7214
+ sharePct: {
7215
+ type: 'number',
7216
+ description:
7217
+ 'Share of the grand converted total (0-100); 0 when grand total is 0',
7218
+ example: 42.5
7219
+ }
7220
+ },
7221
+ required: [
7222
+ 'platformId',
7223
+ 'platformName',
7224
+ 'accounts',
7225
+ 'totalBalance',
7226
+ 'balanceByCurrency',
7227
+ 'sharePct'
7228
+ ]
7229
+ } as const;
7230
+
7231
+ export const $AccountExchangeRateWarningDto = {
7232
+ type: 'object',
7233
+ properties: {
7234
+ type: {
7235
+ type: 'string',
7236
+ description: 'Warning type',
7237
+ example: 'MISSING_EXCHANGE_RATE'
7238
+ },
7239
+ currency: {
7240
+ type: 'string',
7241
+ description: 'Currency without exchange rate',
7242
+ example: 'USD'
7243
+ },
7244
+ accounts: {
7245
+ description: 'Affected account paths',
7246
+ type: 'array',
7247
+ items: {
7248
+ type: 'string'
7249
+ }
7250
+ },
7251
+ totalAmount: {
7252
+ type: 'string',
7253
+ description: 'Total amount in this currency',
7254
+ example: '5000.00'
5894
7255
  }
5895
7256
  },
5896
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
7257
+ required: ['type', 'currency', 'accounts', 'totalAmount']
5897
7258
  } as const;
5898
7259
 
5899
7260
  export const $AccountsSummaryDto = {
@@ -5906,9 +7267,21 @@ export const $AccountsSummaryDto = {
5906
7267
  totalPlatforms: {
5907
7268
  type: 'number',
5908
7269
  description: 'Total number of platforms'
7270
+ },
7271
+ baseCurrency: {
7272
+ type: 'string',
7273
+ description: 'Base currency for conversion',
7274
+ example: 'CNY'
7275
+ },
7276
+ warnings: {
7277
+ description: 'Per-account exchange rate warnings',
7278
+ type: 'array',
7279
+ items: {
7280
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
7281
+ }
5909
7282
  }
5910
7283
  },
5911
- required: ['totalAccounts', 'totalPlatforms']
7284
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
5912
7285
  } as const;
5913
7286
 
5914
7287
  export const $AccountsResponseDto = {
@@ -5943,7 +7316,7 @@ export const $AccountItemWithAssetClassDto = {
5943
7316
  name: {
5944
7317
  type: 'string',
5945
7318
  description: 'Full account name',
5946
- example: 'Assets:Bank:CMB:Savings'
7319
+ example: 'Assets:CN:CMB:Savings'
5947
7320
  },
5948
7321
  displayName: {
5949
7322
  type: 'string',
@@ -5960,6 +7333,12 @@ export const $AccountItemWithAssetClassDto = {
5960
7333
  description: 'Currency code',
5961
7334
  example: 'CNY'
5962
7335
  },
7336
+ convertedBalance: {
7337
+ type: 'string',
7338
+ description:
7339
+ 'FX-converted balance in base currency; omitted when not convertible',
7340
+ example: '50000.00'
7341
+ },
5963
7342
  assetClass: {
5964
7343
  type: 'string',
5965
7344
  description: 'Asset class',
@@ -5979,6 +7358,12 @@ export const $AccountItemWithAssetClassDto = {
5979
7358
  type: 'string',
5980
7359
  description: 'Risk level',
5981
7360
  example: 'LOW'
7361
+ },
7362
+ source: {
7363
+ type: 'string',
7364
+ description:
7365
+ 'ADR-0105 classification provenance (holding level always; account level only on FALLBACK)',
7366
+ enum: ['USER_META', 'FIAT_CURRENCY', 'OPENBB_MAPPING', 'FALLBACK']
5982
7367
  }
5983
7368
  },
5984
7369
  required: ['id', 'name', 'displayName', 'balance', 'currency', 'assetClass']
@@ -6033,35 +7418,6 @@ export const $AssetClassGroupDto = {
6033
7418
  required: ['assetClass', 'accounts', 'balanceByCurrency']
6034
7419
  } as const;
6035
7420
 
6036
- export const $AccountExchangeRateWarningDto = {
6037
- type: 'object',
6038
- properties: {
6039
- type: {
6040
- type: 'string',
6041
- description: 'Warning type',
6042
- example: 'MISSING_EXCHANGE_RATE'
6043
- },
6044
- currency: {
6045
- type: 'string',
6046
- description: 'Currency without exchange rate',
6047
- example: 'USD'
6048
- },
6049
- accounts: {
6050
- description: 'Affected account paths',
6051
- type: 'array',
6052
- items: {
6053
- type: 'string'
6054
- }
6055
- },
6056
- totalAmount: {
6057
- type: 'string',
6058
- description: 'Total amount in this currency',
6059
- example: '5000.00'
6060
- }
6061
- },
6062
- required: ['type', 'currency', 'accounts', 'totalAmount']
6063
- } as const;
6064
-
6065
7421
  export const $AssetClassSummaryDto = {
6066
7422
  type: 'object',
6067
7423
  properties: {
@@ -6084,6 +7440,11 @@ export const $AssetClassSummaryDto = {
6084
7440
  items: {
6085
7441
  $ref: '#/components/schemas/AccountExchangeRateWarningDto'
6086
7442
  }
7443
+ },
7444
+ fallback: {
7445
+ type: 'object',
7446
+ description:
7447
+ 'ADR-0105 §4 fallback provenance stats (holding level only). valueRatio is the grey-area share of total converted value; count is the number of source=FALLBACK holdings.'
6087
7448
  }
6088
7449
  },
6089
7450
  required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
@@ -6106,11 +7467,107 @@ export const $AssetClassAccountsResponseDto = {
6106
7467
  $ref: '#/components/schemas/AssetClassSummaryDto'
6107
7468
  }
6108
7469
  ]
7470
+ },
7471
+ uncategorized: {
7472
+ description:
7473
+ 'ADR-0105 §6 holding-level grey-area bucket (source=FALLBACK holdings peeled out of groups). Present only for groupBy=holdingAssetClass when FALLBACK holdings exist.',
7474
+ allOf: [
7475
+ {
7476
+ $ref: '#/components/schemas/AssetClassGroupDto'
7477
+ }
7478
+ ]
6109
7479
  }
6110
7480
  },
6111
7481
  required: ['groups', 'summary']
6112
7482
  } as const;
6113
7483
 
7484
+ export const $HoldingAssetClassAccountSliceDto = {
7485
+ type: 'object',
7486
+ properties: {
7487
+ accountId: {
7488
+ type: 'string',
7489
+ description: 'Account ID'
7490
+ },
7491
+ accountPath: {
7492
+ type: 'string',
7493
+ description: 'Full account path',
7494
+ example: 'Assets:US:Fidelity:Brokerage'
7495
+ },
7496
+ accountCurrency: {
7497
+ type: 'string',
7498
+ description:
7499
+ 'Currency of the holding with the largest converted base value; undefined when no holding is convertible',
7500
+ example: 'USD'
7501
+ },
7502
+ marketValueBase: {
7503
+ type: 'string',
7504
+ description:
7505
+ "Account's market value in base currency (Σ converted holdings; grey bucket included)",
7506
+ example: '50000.00'
7507
+ },
7508
+ shareOfTotalPct: {
7509
+ type: 'number',
7510
+ description:
7511
+ 'Share of the global total (0-100). 0 when globalTotal is zero (no NaN/Infinity).',
7512
+ example: 42.5
7513
+ },
7514
+ groups: {
7515
+ description: 'Per-account asset-class breakdown',
7516
+ type: 'array',
7517
+ items: {
7518
+ $ref: '#/components/schemas/AssetClassGroupDto'
7519
+ }
7520
+ },
7521
+ uncategorized: {
7522
+ description:
7523
+ 'Per-account grey bucket (source=FALLBACK holdings, incl. broker cash)',
7524
+ allOf: [
7525
+ {
7526
+ $ref: '#/components/schemas/AssetClassGroupDto'
7527
+ }
7528
+ ]
7529
+ },
7530
+ holdings: {
7531
+ description:
7532
+ 'Every holding row for this account (account ID in each row’s `id` field)',
7533
+ type: 'array',
7534
+ items: {
7535
+ $ref: '#/components/schemas/AccountItemWithAssetClassDto'
7536
+ }
7537
+ }
7538
+ },
7539
+ required: [
7540
+ 'accountId',
7541
+ 'accountPath',
7542
+ 'marketValueBase',
7543
+ 'shareOfTotalPct',
7544
+ 'groups',
7545
+ 'holdings'
7546
+ ]
7547
+ } as const;
7548
+
7549
+ export const $HoldingAssetClassCrossAccountResponseDto = {
7550
+ type: 'object',
7551
+ properties: {
7552
+ global: {
7553
+ description: 'Merged cross-account holding aggregation',
7554
+ allOf: [
7555
+ {
7556
+ $ref: '#/components/schemas/AssetClassAccountsResponseDto'
7557
+ }
7558
+ ]
7559
+ },
7560
+ byAccount: {
7561
+ description: 'Per-account slices',
7562
+ type: 'array',
7563
+ items: {
7564
+ $ref: '#/components/schemas/HoldingAssetClassAccountSliceDto'
7565
+ }
7566
+ }
7567
+ },
7568
+ required: ['global', 'byAccount']
7569
+ } as const;
7570
+
6114
7571
  export const $CashFlowByCurrencyDto = {
6115
7572
  type: 'object',
6116
7573
  properties: {
@@ -6206,202 +7663,422 @@ export const $CashFlowResponseDto = {
6206
7663
  description: 'Base currency code',
6207
7664
  example: 'CNY'
6208
7665
  },
6209
- byCurrency: {
6210
- description: 'Cash flow grouped by original currency',
6211
- allOf: [
6212
- {
6213
- $ref: '#/components/schemas/CashFlowByCurrencyDto'
6214
- }
6215
- ]
7666
+ byCurrency: {
7667
+ description: 'Cash flow grouped by original currency',
7668
+ allOf: [
7669
+ {
7670
+ $ref: '#/components/schemas/CashFlowByCurrencyDto'
7671
+ }
7672
+ ]
7673
+ },
7674
+ converted: {
7675
+ description: 'Converted values in base currency',
7676
+ allOf: [
7677
+ {
7678
+ $ref: '#/components/schemas/ConvertedCashFlowDto'
7679
+ }
7680
+ ]
7681
+ },
7682
+ warnings: {
7683
+ description: 'Exchange rate warnings',
7684
+ type: 'array',
7685
+ items: {
7686
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7687
+ }
7688
+ }
7689
+ },
7690
+ required: [
7691
+ 'period',
7692
+ 'income',
7693
+ 'expense',
7694
+ 'netSavings',
7695
+ 'savingsRate',
7696
+ 'currency'
7697
+ ]
7698
+ } as const;
7699
+
7700
+ export const $CategoryGroupDto = {
7701
+ type: 'object',
7702
+ properties: {
7703
+ category: {
7704
+ type: 'string',
7705
+ description:
7706
+ 'Functional category (account-path Group segment); regional and universal account paths merge under it',
7707
+ example: 'Food'
7708
+ },
7709
+ totalExpense: {
7710
+ type: 'string',
7711
+ description:
7712
+ 'Converted total for this category in base currency (expense amount when flow=expense, income amount when flow=income)',
7713
+ example: '1200.00'
7714
+ },
7715
+ sharePct: {
7716
+ type: 'number',
7717
+ description: 'Share of grand total (0-100); 0 when grand total is 0',
7718
+ example: 42.5
7719
+ },
7720
+ balanceByCurrency: {
7721
+ description: 'Raw (unconverted) expense per currency',
7722
+ type: 'array',
7723
+ items: {
7724
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7725
+ }
7726
+ },
7727
+ convertedBalance: {
7728
+ type: 'string',
7729
+ description:
7730
+ 'Converted total in base currency (omitted when FX missing for all currencies in this category)',
7731
+ example: '1200.00'
7732
+ }
7733
+ },
7734
+ required: ['category', 'totalExpense', 'sharePct', 'balanceByCurrency']
7735
+ } as const;
7736
+
7737
+ export const $ExpensesByCategorySummaryDto = {
7738
+ type: 'object',
7739
+ properties: {
7740
+ totalExpense: {
7741
+ type: 'string',
7742
+ description:
7743
+ 'Total across all categories, converted (convertible categories only); expense totals when flow=expense, income totals when flow=income',
7744
+ example: '5000.00'
7745
+ },
7746
+ categoryCount: {
7747
+ type: 'number',
7748
+ description: 'Number of categories',
7749
+ example: 8
7750
+ }
7751
+ },
7752
+ required: ['totalExpense', 'categoryCount']
7753
+ } as const;
7754
+
7755
+ export const $ExpensesByCategoryResponseDto = {
7756
+ type: 'object',
7757
+ properties: {
7758
+ period: {
7759
+ type: 'string',
7760
+ description: 'Period requested',
7761
+ example: '1m'
7762
+ },
7763
+ baseCurrency: {
7764
+ type: 'string',
7765
+ description: 'Base currency for converted values',
7766
+ example: 'CNY'
7767
+ },
7768
+ groups: {
7769
+ description:
7770
+ 'Expense groups by functional category, sorted by converted total desc',
7771
+ type: 'array',
7772
+ items: {
7773
+ $ref: '#/components/schemas/CategoryGroupDto'
7774
+ }
6216
7775
  },
6217
- converted: {
6218
- description: 'Converted values in base currency',
7776
+ summary: {
7777
+ description: 'Summary statistics',
6219
7778
  allOf: [
6220
7779
  {
6221
- $ref: '#/components/schemas/ConvertedCashFlowDto'
7780
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
6222
7781
  }
6223
7782
  ]
6224
7783
  },
6225
7784
  warnings: {
6226
- description: 'Exchange rate warnings',
7785
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
6227
7786
  type: 'array',
6228
7787
  items: {
6229
7788
  $ref: '#/components/schemas/ExchangeRateWarningDto'
6230
7789
  }
6231
7790
  }
6232
7791
  },
6233
- required: [
6234
- 'period',
6235
- 'income',
6236
- 'expense',
6237
- 'netSavings',
6238
- 'savingsRate',
6239
- 'currency'
6240
- ]
7792
+ required: ['period', 'baseCurrency', 'groups', 'summary']
6241
7793
  } as const;
6242
7794
 
6243
- export const $CurrencyBalanceDto = {
7795
+ export const $MonetaryDto = {
6244
7796
  type: 'object',
6245
7797
  properties: {
6246
- currency: {
7798
+ amount: {
6247
7799
  type: 'string',
6248
- description: 'ISO 4217 currency code',
6249
- example: 'CNY'
7800
+ description: 'Amount (Decimal string)',
7801
+ example: '3000'
6250
7802
  },
6251
- balance: {
7803
+ currency: {
6252
7804
  type: 'string',
6253
- description: 'Balance amount',
6254
- example: '500000.00'
7805
+ description: 'ISO 4217 currency',
7806
+ example: 'USD'
7807
+ },
7808
+ baseCcyEquivalent: {
7809
+ type: 'object',
7810
+ description: 'Converted to user base currency (Decimal string)',
7811
+ example: '21600',
7812
+ nullable: true
6255
7813
  }
6256
7814
  },
6257
- required: ['currency', 'balance']
7815
+ required: ['amount', 'currency']
6258
7816
  } as const;
6259
7817
 
6260
- export const $TimeSeriesPointDto = {
7818
+ export const $CurrentPriceDto = {
6261
7819
  type: 'object',
6262
7820
  properties: {
6263
- date: {
7821
+ amount: {
6264
7822
  type: 'string',
6265
- description: 'Date in YYYY-MM-DD format',
6266
- example: '2024-06-15'
7823
+ description: 'Price amount (Decimal string)',
7824
+ example: '250'
6267
7825
  },
6268
- value: {
7826
+ currency: {
6269
7827
  type: 'string',
6270
- description: 'Value at this date (in base currency)',
6271
- example: '500000.00'
7828
+ description: 'Price currency (ISO 4217)',
7829
+ example: 'USD'
6272
7830
  },
6273
- change: {
6274
- type: 'object',
6275
- description: 'Change from previous point',
6276
- example: '5000.00'
7831
+ date: {
7832
+ type: 'string',
7833
+ description: 'Price date (ISO 8601)',
7834
+ example: '2024-06-01'
6277
7835
  },
6278
- byCurrency: {
6279
- description: 'Multi-currency breakdown for this point',
6280
- type: 'array',
6281
- items: {
6282
- $ref: '#/components/schemas/CurrencyBalanceDto'
6283
- }
7836
+ source: {
7837
+ type: 'string',
7838
+ description: 'Price source',
7839
+ example: 'USER_OVERRIDE',
7840
+ enum: ['USER_OVERRIDE', 'OPENBB_EQUITY', 'OPENBB_CURRENCY']
6284
7841
  }
6285
7842
  },
6286
- required: ['date', 'value']
7843
+ required: ['amount', 'currency', 'date', 'source']
6287
7844
  } as const;
6288
7845
 
6289
- export const $TrendSummaryDto = {
7846
+ export const $FxRateDto = {
6290
7847
  type: 'object',
6291
7848
  properties: {
6292
- startValue: {
7849
+ from: {
6293
7850
  type: 'string',
6294
- description: 'Value at start of period',
6295
- example: '450000.00'
7851
+ example: 'USD'
6296
7852
  },
6297
- endValue: {
7853
+ to: {
6298
7854
  type: 'string',
6299
- description: 'Value at end of period',
6300
- example: '500000.00'
7855
+ example: 'CNY'
6301
7856
  },
6302
- totalChange: {
7857
+ rate: {
6303
7858
  type: 'string',
6304
- description: 'Total change over period',
6305
- example: '50000.00'
7859
+ description: 'FX rate (Decimal string)',
7860
+ example: '7.2'
6306
7861
  },
6307
- totalChangePercentage: {
7862
+ date: {
6308
7863
  type: 'string',
6309
- description: 'Total change percentage',
6310
- example: '+11.11%'
7864
+ description: 'Rate date (ISO 8601)',
7865
+ example: '2024-01-15'
6311
7866
  }
6312
7867
  },
6313
- required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
7868
+ required: ['from', 'to', 'rate', 'date']
6314
7869
  } as const;
6315
7870
 
6316
- export const $MultiCurrencyPointDto = {
7871
+ export const $HoldingPnlRowDto = {
6317
7872
  type: 'object',
6318
7873
  properties: {
6319
- date: {
7874
+ accountId: {
6320
7875
  type: 'string',
6321
- description: 'Date in YYYY-MM-DD format',
6322
- example: '2024-06-15'
7876
+ description: 'Account UUID',
7877
+ example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
6323
7878
  },
6324
- byCurrency: {
6325
- description: 'Balances by currency',
6326
- type: 'array',
6327
- items: {
6328
- $ref: '#/components/schemas/CurrencyBalanceDto'
6329
- }
7879
+ accountPath: {
7880
+ type: 'string',
7881
+ description: 'Full account path',
7882
+ example: 'Assets:US:Broker:AAPL'
7883
+ },
7884
+ accountCcy: {
7885
+ type: 'object',
7886
+ description: 'Account settlement currency (ISO 4217), from cost currency',
7887
+ nullable: true,
7888
+ example: 'USD'
7889
+ },
7890
+ brokerType: {
7891
+ type: 'object',
7892
+ description: 'Broker type derived from Platform.type',
7893
+ nullable: true,
7894
+ example: 'broker'
7895
+ },
7896
+ symbol: {
7897
+ type: 'string',
7898
+ description: 'Commodity symbol',
7899
+ example: 'AAPL'
7900
+ },
7901
+ chartToken: {
7902
+ type: 'string',
7903
+ description: 'Chart segment token (libs/common resolver)',
7904
+ example: 'equity',
7905
+ enum: ['equity', 'fund', 'bond', 'cash', 'other']
7906
+ },
7907
+ assetClass: {
7908
+ type: 'string',
7909
+ example: 'EQUITY'
7910
+ },
7911
+ assetSubClass: {
7912
+ type: 'object',
7913
+ nullable: true,
7914
+ example: 'STOCK'
7915
+ },
7916
+ units: {
7917
+ type: 'string',
7918
+ description: 'Net held units (Decimal string)',
7919
+ example: '12'
7920
+ },
7921
+ averageCostPerUnit: {
7922
+ description:
7923
+ 'Average cost per unit; null when cost currency conflicts or no cost',
7924
+ nullable: true,
7925
+ allOf: [
7926
+ {
7927
+ $ref: '#/components/schemas/MonetaryDto'
7928
+ }
7929
+ ]
7930
+ },
7931
+ costBasis: {
7932
+ description: 'Cost basis of held units',
7933
+ nullable: true,
7934
+ allOf: [
7935
+ {
7936
+ $ref: '#/components/schemas/MonetaryDto'
7937
+ }
7938
+ ]
7939
+ },
7940
+ marketValue: {
7941
+ description: 'Market value at asOf price',
7942
+ nullable: true,
7943
+ allOf: [
7944
+ {
7945
+ $ref: '#/components/schemas/MonetaryDto'
7946
+ }
7947
+ ]
7948
+ },
7949
+ currentPrice: {
7950
+ description: 'Price used for market value',
7951
+ nullable: true,
7952
+ allOf: [
7953
+ {
7954
+ $ref: '#/components/schemas/CurrentPriceDto'
7955
+ }
7956
+ ]
7957
+ },
7958
+ unrealizedPnlBase: {
7959
+ type: 'object',
7960
+ description:
7961
+ 'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
7962
+ nullable: true,
7963
+ example: '6000'
7964
+ },
7965
+ unrealizedPnlPct: {
7966
+ type: 'object',
7967
+ description: 'Unrealized P&L % (Decimal string)',
7968
+ nullable: true,
7969
+ example: '25'
7970
+ },
7971
+ costFxRate: {
7972
+ description: 'Historical FX rate applied to cost basis',
7973
+ nullable: true,
7974
+ allOf: [
7975
+ {
7976
+ $ref: '#/components/schemas/FxRateDto'
7977
+ }
7978
+ ]
7979
+ },
7980
+ marketFxRate: {
7981
+ description: 'FX rate applied to market value',
7982
+ nullable: true,
7983
+ allOf: [
7984
+ {
7985
+ $ref: '#/components/schemas/FxRateDto'
7986
+ }
7987
+ ]
7988
+ },
7989
+ pctOfInvestedAssets: {
7990
+ type: 'object',
7991
+ description:
7992
+ 'Share of invested assets % (Decimal string); only for invested chartTokens',
7993
+ nullable: true,
7994
+ example: '40'
7995
+ },
7996
+ realizedPnl: {
7997
+ description:
7998
+ 'Cumulative realized P&L on sold lots (asOf-date cutoff); null when the method has no applicable sells, a sell lacks a price, or any required FX rate is missing (never-mix). When a sell spans multiple currencies (cross-currency sale), amount and currency reflect the base currency; baseCcyEquivalent is always the authoritative dual-FX figure',
7999
+ nullable: true,
8000
+ allOf: [
8001
+ {
8002
+ $ref: '#/components/schemas/MonetaryDto'
8003
+ }
8004
+ ]
6330
8005
  }
6331
8006
  },
6332
- required: ['date', 'byCurrency']
8007
+ required: [
8008
+ 'accountId',
8009
+ 'accountPath',
8010
+ 'symbol',
8011
+ 'chartToken',
8012
+ 'assetClass',
8013
+ 'units'
8014
+ ]
6333
8015
  } as const;
6334
8016
 
6335
- export const $PortfolioTrendsResponseDto = {
8017
+ export const $HoldingPnlWarningDto = {
6336
8018
  type: 'object',
6337
8019
  properties: {
6338
- series: {
6339
- description: 'Time series data points',
6340
- type: 'array',
6341
- items: {
6342
- $ref: '#/components/schemas/TimeSeriesPointDto'
6343
- }
6344
- },
6345
- summary: {
6346
- description: 'Period summary',
6347
- allOf: [
6348
- {
6349
- $ref: '#/components/schemas/TrendSummaryDto'
6350
- }
8020
+ type: {
8021
+ type: 'string',
8022
+ description: 'Warning type',
8023
+ example: 'MISSING_COST_FX_RATE',
8024
+ enum: [
8025
+ 'MISSING_COST_FX_RATE',
8026
+ 'MISSING_MARKET_FX_RATE',
8027
+ 'MISSING_SALE_PRICE',
8028
+ 'MISSING_REALIZED_FX_RATE',
8029
+ 'OVERSOLD_LOTS',
8030
+ 'NO_PRICE',
8031
+ 'MIXED_COST_CURRENCY'
6351
8032
  ]
6352
8033
  },
6353
- period: {
6354
- type: 'string',
6355
- description: 'Period requested',
6356
- example: '6m'
8034
+ symbol: {
8035
+ type: 'object',
8036
+ nullable: true
6357
8037
  },
6358
- granularity: {
6359
- type: 'string',
6360
- description: 'Data granularity',
6361
- example: 'month'
8038
+ accountId: {
8039
+ type: 'object',
8040
+ nullable: true
6362
8041
  },
6363
8042
  currency: {
8043
+ type: 'object',
8044
+ nullable: true
8045
+ }
8046
+ },
8047
+ required: ['type']
8048
+ } as const;
8049
+
8050
+ export const $HoldingPnlResponseDto = {
8051
+ type: 'object',
8052
+ properties: {
8053
+ asOfDate: {
8054
+ type: 'string',
8055
+ example: '2026-07-08'
8056
+ },
8057
+ baseCurrency: {
6364
8058
  type: 'string',
6365
- description: 'Base currency for converted values',
6366
8059
  example: 'CNY'
6367
8060
  },
6368
- byCurrency: {
8061
+ method: {
8062
+ type: 'string',
6369
8063
  description:
6370
- 'Multi-currency time series (each point has currency breakdown)',
8064
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
8065
+ enum: ['average', 'FIFO'],
8066
+ example: 'average'
8067
+ },
8068
+ rows: {
6371
8069
  type: 'array',
6372
8070
  items: {
6373
- $ref: '#/components/schemas/MultiCurrencyPointDto'
8071
+ $ref: '#/components/schemas/HoldingPnlRowDto'
6374
8072
  }
6375
8073
  },
6376
8074
  warnings: {
6377
- description: 'Exchange rate warnings',
6378
8075
  type: 'array',
6379
8076
  items: {
6380
- $ref: '#/components/schemas/ExchangeRateWarningDto'
8077
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
6381
8078
  }
6382
8079
  }
6383
8080
  },
6384
- required: ['series', 'summary', 'period', 'granularity', 'currency']
6385
- } as const;
6386
-
6387
- export const $GenerateSnapshotBody = {
6388
- type: 'object',
6389
- properties: {}
6390
- } as const;
6391
-
6392
- export const $GenerateSnapshotResponse = {
6393
- type: 'object',
6394
- properties: {}
6395
- } as const;
6396
-
6397
- export const $BackfillSnapshotsBody = {
6398
- type: 'object',
6399
- properties: {}
6400
- } as const;
6401
-
6402
- export const $BackfillSnapshotsResponse = {
6403
- type: 'object',
6404
- properties: {}
8081
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6405
8082
  } as const;
6406
8083
 
6407
8084
  export const $AnonymousLoginDto = {
@@ -6414,3 +8091,15 @@ export const $AnonymousLoginDto = {
6414
8091
  },
6415
8092
  required: ['accessToken']
6416
8093
  } as const;
8094
+
8095
+ export const $AnonymousLoginResponseDto = {
8096
+ type: 'object',
8097
+ properties: {
8098
+ authToken: {
8099
+ type: 'string',
8100
+ description: 'JWT auth token',
8101
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
8102
+ }
8103
+ },
8104
+ required: ['authToken']
8105
+ } as const;