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

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,49 @@ 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
+ 'ACCOUNTS_PAYABLE',
128
+ 'TAX_PAYABLE',
129
+ 'OTHER'
130
+ ],
131
+ nullable: true,
132
+ example: 'STOCK'
133
+ },
107
134
  status: {
108
135
  type: 'string',
109
136
  description: 'Account status',
@@ -145,26 +172,26 @@ export const $AccountResponseDto = {
145
172
  templatePath: {
146
173
  type: 'string',
147
174
  description: 'Template path reference',
148
- example: 'Assets:CN:Bank:ICBC:Checking'
175
+ example: 'Assets:CN:Checking'
149
176
  },
150
177
  isCustom: {
151
178
  type: 'boolean',
152
179
  description: 'Whether this is a custom (user-created) account',
153
180
  example: false
154
181
  },
155
- i18nKey: {
182
+ displayName: {
156
183
  type: 'string',
157
- description: 'i18n key for display name',
158
- example: 'account.assets.cn.bank.icbc.checking'
184
+ description: 'Localized display name (ADR-0114, read-time projection)',
185
+ example: 'Checking'
159
186
  },
160
187
  icon: {
161
188
  type: 'string',
162
189
  description: 'Icon identifier',
163
190
  example: 'bank-icbc'
164
191
  },
165
- openMeta: {
192
+ openDirectiveMeta: {
166
193
  type: 'object',
167
- description: 'Account metadata',
194
+ description: 'Open directive metadata (ADR-0115 Decision 9)',
168
195
  example: {
169
196
  branch: 'Downtown'
170
197
  }
@@ -192,7 +219,6 @@ export const $AccountResponseDto = {
192
219
  required: [
193
220
  'id',
194
221
  'path',
195
- 'displayName',
196
222
  'type',
197
223
  'status',
198
224
  'openDate',
@@ -225,11 +251,6 @@ export const $AccountListResponseDto = {
225
251
  export const $UpdateAccountDto = {
226
252
  type: 'object',
227
253
  properties: {
228
- displayName: {
229
- type: 'string',
230
- description: 'Display name to distinguish accounts at the same path',
231
- example: '招行工资卡'
232
- },
233
254
  currencies: {
234
255
  description: 'Allowed currencies (null = no restriction)',
235
256
  example: ['CNY', 'USD'],
@@ -251,19 +272,15 @@ export const $UpdateAccountDto = {
251
272
  'NONE'
252
273
  ]
253
274
  },
254
- i18nKey: {
255
- type: 'string',
256
- description: 'i18n key for display name',
257
- example: 'account.custom.mybank'
258
- },
259
275
  icon: {
260
276
  type: 'string',
261
277
  description: 'Icon identifier',
262
278
  example: 'bank-custom'
263
279
  },
264
- openMeta: {
280
+ openDirectiveMeta: {
265
281
  type: 'object',
266
- description: 'Additional metadata (merged with existing)',
282
+ description:
283
+ 'Open directive metadata (merged with existing; NOT an opening-balance amount)',
267
284
  example: {
268
285
  branch: 'Uptown'
269
286
  }
@@ -310,13 +327,47 @@ export const $ReopenAccountDto = {
310
327
  }
311
328
  } as const;
312
329
 
330
+ export const $CreateOpeningBalanceDto = {
331
+ type: 'object',
332
+ properties: {
333
+ amount: {
334
+ type: 'number',
335
+ description: 'Opening balance amount (non-negative)',
336
+ example: 1000
337
+ },
338
+ currency: {
339
+ type: 'string',
340
+ description: 'Currency code',
341
+ example: 'CNY'
342
+ },
343
+ date: {
344
+ format: 'date-time',
345
+ type: 'string',
346
+ description: 'Opening-balance date (defaults to now)',
347
+ example: '2024-01-01'
348
+ }
349
+ },
350
+ required: ['amount', 'currency']
351
+ } as const;
352
+
353
+ export const $OpeningBalanceResultDto = {
354
+ type: 'object',
355
+ properties: {
356
+ transactionId: {
357
+ type: 'string',
358
+ description: 'Created opening-balance transaction id.'
359
+ }
360
+ },
361
+ required: ['transactionId']
362
+ } as const;
363
+
313
364
  export const $AccountStandardResponseDto = {
314
365
  type: 'object',
315
366
  properties: {
316
367
  path: {
317
368
  type: 'string',
318
369
  description: 'Account path (hierarchical, colon-separated)',
319
- example: 'Assets:CN:Bank:ICBC:Checking'
370
+ example: 'Assets:CN:Checking'
320
371
  },
321
372
  type: {
322
373
  type: 'string',
@@ -324,11 +375,6 @@ export const $AccountStandardResponseDto = {
324
375
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
325
376
  example: 'Assets'
326
377
  },
327
- i18nKey: {
328
- type: 'string',
329
- description: 'i18n key for localized display name',
330
- example: 'account.assets.cn.bank.icbc.checking'
331
- },
332
378
  name: {
333
379
  type: 'string',
334
380
  description: 'Short localized display name',
@@ -351,9 +397,47 @@ export const $AccountStandardResponseDto = {
351
397
  type: 'string',
352
398
  description: 'Icon identifier for UI display',
353
399
  example: 'bank-icbc'
400
+ },
401
+ productCategory: {
402
+ type: 'string',
403
+ description:
404
+ 'Onboarding product category (coarse grouping derived from assetSubClass)',
405
+ enum: [
406
+ 'cash',
407
+ 'investment',
408
+ 'credit_card',
409
+ 'loan',
410
+ 'payable_tax',
411
+ 'other'
412
+ ],
413
+ example: 'investment'
414
+ },
415
+ assetClass: {
416
+ type: 'string',
417
+ description:
418
+ 'Asset class (LIQUIDITY/EQUITY/.../LIABILITY), derived at read time from classification rules',
419
+ enum: [
420
+ 'LIQUIDITY',
421
+ 'EQUITY',
422
+ 'FIXED_INCOME',
423
+ 'PRECIOUS_METALS',
424
+ 'COMMODITY',
425
+ 'INSURANCE',
426
+ 'ALTERNATIVE_INVESTMENT',
427
+ 'PERSONAL_ASSETS',
428
+ 'LIABILITY',
429
+ 'REAL_ESTATE',
430
+ 'INDEX'
431
+ ]
432
+ },
433
+ assetSubClass: {
434
+ type: 'string',
435
+ description:
436
+ 'Asset sub-class (product type, derived at read time from classification rules)',
437
+ example: 'STOCK'
354
438
  }
355
439
  },
356
- required: ['path', 'type', 'i18nKey', 'description', 'tags', 'icon']
440
+ required: ['path', 'type', 'description', 'tags', 'icon', 'productCategory']
357
441
  } as const;
358
442
 
359
443
  export const $AccountStandardListResponseDto = {
@@ -383,18 +467,13 @@ export const $AccountStandardListResponseDto = {
383
467
  export const $TemplateMetadataDto = {
384
468
  type: 'object',
385
469
  properties: {
386
- extendable: {
387
- type: 'boolean',
388
- description: 'Whether this path can be extended',
389
- example: true
390
- },
391
470
  rootType: {
392
471
  type: 'string',
393
472
  description: 'Root account type',
394
473
  example: 'Assets'
395
474
  }
396
475
  },
397
- required: ['extendable', 'rootType']
476
+ required: ['rootType']
398
477
  } as const;
399
478
 
400
479
  export const $TemplateMetadataResponseDto = {
@@ -466,6 +545,66 @@ export const $RegionsMetadataResponseDto = {
466
545
  required: ['regions']
467
546
  } as const;
468
547
 
548
+ export const $CostSpecDto = {
549
+ type: 'object',
550
+ properties: {
551
+ mode: {
552
+ type: 'string',
553
+ enum: ['per-unit', 'total', 'date', 'label', 'auto'],
554
+ description: 'Cost specification mode (mirrors engine CostSpec)'
555
+ },
556
+ numberPerUnit: {
557
+ type: 'string',
558
+ description: 'Per-unit cost (required when mode is "per-unit")',
559
+ example: '240'
560
+ },
561
+ totalNumber: {
562
+ type: 'string',
563
+ description: 'Total cost for all units (required when mode is "total")',
564
+ example: '12000'
565
+ },
566
+ currency: {
567
+ type: 'string',
568
+ description: 'Cost currency (required in all modes)',
569
+ example: 'USD'
570
+ },
571
+ date: {
572
+ type: 'string',
573
+ description:
574
+ 'Lot acquisition date, ISO 8601 (required when mode is "date")',
575
+ example: '2024-01-15'
576
+ },
577
+ label: {
578
+ type: 'string',
579
+ description:
580
+ 'Lot label (required when mode is "label"; optional tag in buy modes)'
581
+ },
582
+ merge: {
583
+ type: 'boolean',
584
+ description: 'Merge lots for AVERAGE booking (mode: auto)'
585
+ }
586
+ },
587
+ required: ['mode', 'currency']
588
+ } as const;
589
+
590
+ export const $AmountDto = {
591
+ type: 'object',
592
+ properties: {
593
+ number: {
594
+ type: 'string',
595
+ description:
596
+ 'Amount as decimal string (max 15 integer + 15 decimal digits)',
597
+ example: '170.50'
598
+ },
599
+ currency: {
600
+ type: 'string',
601
+ description: 'Currency/commodity code',
602
+ example: 'USD'
603
+ }
604
+ },
605
+ required: ['number', 'currency']
606
+ } as const;
607
+
469
608
  export const $CreatePostingDto = {
470
609
  type: 'object',
471
610
  properties: {
@@ -473,7 +612,7 @@ export const $CreatePostingDto = {
473
612
  type: 'string',
474
613
  description:
475
614
  'Account name in Beancount format (must start with uppercase, colon-separated)',
476
- example: 'Assets:Bank:Checking'
615
+ example: 'Assets:Checking'
477
616
  },
478
617
  units: {
479
618
  type: 'string',
@@ -495,6 +634,33 @@ export const $CreatePostingDto = {
495
634
  example: {
496
635
  'tax-lot': 'Q1-2024'
497
636
  }
637
+ },
638
+ cost: {
639
+ description:
640
+ 'Cost basis (Beancount `{...}`). Maps to engine costSpec. Required for commodity holdings so they carry a monetary weight that can balance.',
641
+ example: {
642
+ mode: 'per-unit',
643
+ numberPerUnit: '240',
644
+ currency: 'USD'
645
+ },
646
+ allOf: [
647
+ {
648
+ $ref: '#/components/schemas/CostSpecDto'
649
+ }
650
+ ]
651
+ },
652
+ price: {
653
+ description:
654
+ 'Price annotation (Beancount `@...`). Maps to engine price. Used for valuation; cost takes priority for balance weight.',
655
+ example: {
656
+ number: '170',
657
+ currency: 'USD'
658
+ },
659
+ allOf: [
660
+ {
661
+ $ref: '#/components/schemas/AmountDto'
662
+ }
663
+ ]
498
664
  }
499
665
  },
500
666
  required: ['account']
@@ -573,13 +739,39 @@ export const $CreateTransactionDto = {
573
739
  required: ['date', 'narration', 'postings']
574
740
  } as const;
575
741
 
742
+ export const $CostDetailDto = {
743
+ type: 'object',
744
+ properties: {
745
+ number: {
746
+ type: 'string',
747
+ description: 'Per-unit cost basis (mirrors engine Cost.number)',
748
+ example: '240'
749
+ },
750
+ currency: {
751
+ type: 'string',
752
+ description: 'Cost currency',
753
+ example: 'USD'
754
+ },
755
+ date: {
756
+ type: 'string',
757
+ description: 'Lot acquisition date (ISO yyyy-mm-dd)',
758
+ example: '2024-01-15'
759
+ },
760
+ label: {
761
+ type: 'string',
762
+ description: 'Lot label',
763
+ example: 'lot-2024-01'
764
+ }
765
+ }
766
+ } as const;
767
+
576
768
  export const $PostingResponseDto = {
577
769
  type: 'object',
578
770
  properties: {
579
771
  account: {
580
772
  type: 'string',
581
773
  description: 'Account name',
582
- example: 'Assets:Bank:Checking'
774
+ example: 'Assets:Checking'
583
775
  },
584
776
  units: {
585
777
  type: 'string',
@@ -591,6 +783,15 @@ export const $PostingResponseDto = {
591
783
  type: 'string',
592
784
  description: 'Currency',
593
785
  example: 'USD'
786
+ },
787
+ cost: {
788
+ description:
789
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
790
+ allOf: [
791
+ {
792
+ $ref: '#/components/schemas/CostDetailDto'
793
+ }
794
+ ]
594
795
  }
595
796
  },
596
797
  required: ['account']
@@ -933,10 +1134,10 @@ export const $PostingDetailDto = {
933
1134
  description: 'Account ID',
934
1135
  example: 'clh1234567890abcdef'
935
1136
  },
936
- accountName: {
1137
+ account: {
937
1138
  type: 'string',
938
- description: 'Account name',
939
- example: 'Assets:Bank:Checking'
1139
+ description: 'Fully-qualified Beancount account path',
1140
+ example: 'Assets:Checking'
940
1141
  },
941
1142
  units: {
942
1143
  type: 'string',
@@ -964,6 +1165,15 @@ export const $PostingDetailDto = {
964
1165
  description: 'Cost date',
965
1166
  example: '2024-01-15'
966
1167
  },
1168
+ cost: {
1169
+ description:
1170
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
1171
+ allOf: [
1172
+ {
1173
+ $ref: '#/components/schemas/CostDetailDto'
1174
+ }
1175
+ ]
1176
+ },
967
1177
  priceAmount: {
968
1178
  type: 'string',
969
1179
  description: 'Price amount',
@@ -984,7 +1194,7 @@ export const $PostingDetailDto = {
984
1194
  description: 'Posting metadata'
985
1195
  }
986
1196
  },
987
- required: ['id', 'accountId', 'accountName']
1197
+ required: ['id', 'accountId', 'account']
988
1198
  } as const;
989
1199
 
990
1200
  export const $TransactionDetailDto = {
@@ -1116,6 +1326,77 @@ export const $TransactionDetailDto = {
1116
1326
  ]
1117
1327
  } as const;
1118
1328
 
1329
+ export const $BalanceByCurrencyDto = {
1330
+ type: 'object',
1331
+ properties: {
1332
+ currency: {
1333
+ type: 'string',
1334
+ description: 'ISO 4217 currency code',
1335
+ example: 'CNY'
1336
+ },
1337
+ balance: {
1338
+ type: 'string',
1339
+ description: 'Balance amount',
1340
+ example: '50000.00'
1341
+ }
1342
+ },
1343
+ required: ['currency', 'balance']
1344
+ } as const;
1345
+
1346
+ export const $ExchangeRateWarningDto = {
1347
+ type: 'object',
1348
+ properties: {
1349
+ type: {
1350
+ type: 'string',
1351
+ description: 'Warning type',
1352
+ example: 'MISSING_EXCHANGE_RATE'
1353
+ },
1354
+ currency: {
1355
+ type: 'string',
1356
+ description: 'Currency without exchange rate',
1357
+ example: 'EUR'
1358
+ },
1359
+ totalAmount: {
1360
+ type: 'string',
1361
+ description: 'Total amount affected',
1362
+ example: '1000.00'
1363
+ }
1364
+ },
1365
+ required: ['type', 'currency', 'totalAmount']
1366
+ } as const;
1367
+
1368
+ export const $TransactionListSummaryDto = {
1369
+ type: 'object',
1370
+ properties: {
1371
+ totalAmount: {
1372
+ type: 'string',
1373
+ description:
1374
+ '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.',
1375
+ example: '-6000.00'
1376
+ },
1377
+ currency: {
1378
+ type: 'string',
1379
+ description: 'Base currency (ISO 4217)',
1380
+ example: 'CNY'
1381
+ },
1382
+ balanceByCurrency: {
1383
+ description: 'Raw (unconverted) balance per currency',
1384
+ type: 'array',
1385
+ items: {
1386
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
1387
+ }
1388
+ },
1389
+ warnings: {
1390
+ description: 'Currencies missing an FX rate (omitted when empty)',
1391
+ type: 'array',
1392
+ items: {
1393
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
1394
+ }
1395
+ }
1396
+ },
1397
+ required: ['totalAmount', 'currency', 'balanceByCurrency']
1398
+ } as const;
1399
+
1119
1400
  export const $TransactionListResponseDto = {
1120
1401
  type: 'object',
1121
1402
  properties: {
@@ -1140,6 +1421,15 @@ export const $TransactionListResponseDto = {
1140
1421
  type: 'number',
1141
1422
  description: 'Number of items skipped',
1142
1423
  example: 0
1424
+ },
1425
+ summary: {
1426
+ description:
1427
+ '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.',
1428
+ allOf: [
1429
+ {
1430
+ $ref: '#/components/schemas/TransactionListSummaryDto'
1431
+ }
1432
+ ]
1143
1433
  }
1144
1434
  },
1145
1435
  required: ['data', 'total', 'limit', 'offset']
@@ -1239,7 +1529,7 @@ export const $BalanceResponseDto = {
1239
1529
  account: {
1240
1530
  type: 'string',
1241
1531
  description: 'Account name',
1242
- example: 'Assets:Bank:Checking'
1532
+ example: 'Assets:Checking'
1243
1533
  },
1244
1534
  balance: {
1245
1535
  type: 'string',
@@ -1266,7 +1556,7 @@ export const $MultiCurrencyBalanceResponseDto = {
1266
1556
  account: {
1267
1557
  type: 'string',
1268
1558
  description: 'Account name',
1269
- example: 'Assets:Bank:Checking'
1559
+ example: 'Assets:Checking'
1270
1560
  },
1271
1561
  balances: {
1272
1562
  type: 'object',
@@ -1322,7 +1612,7 @@ export const $TransactionSummaryDto = {
1322
1612
  accountName: {
1323
1613
  type: 'string',
1324
1614
  description: 'Source account name (first posting)',
1325
- example: 'Assets:Bank:Checking'
1615
+ example: 'Assets:Checking'
1326
1616
  },
1327
1617
  sourceType: {
1328
1618
  type: 'string',
@@ -1724,7 +2014,8 @@ export const $ResolveResultDto = {
1724
2014
  },
1725
2015
  resolutionId: {
1726
2016
  type: 'string',
1727
- description: 'Resolution ID for undo'
2017
+ description:
2018
+ 'Resolution ID for undo. Absent when the resolver rejected the decision (review stayed PENDING).'
1728
2019
  },
1729
2020
  canUndo: {
1730
2021
  type: 'boolean',
@@ -1742,7 +2033,7 @@ export const $ResolveResultDto = {
1742
2033
  example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1743
2034
  }
1744
2035
  },
1745
- required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
2036
+ required: ['success']
1746
2037
  } as const;
1747
2038
 
1748
2039
  export const $UndoResultDto = {
@@ -2613,12 +2904,169 @@ export const $UpdateCommodityDto = {
2613
2904
  }
2614
2905
  } as const;
2615
2906
 
2616
- export const $CreateRecurringRuleDto = {
2907
+ export const $CreateBeanPriceDto = {
2617
2908
  type: 'object',
2618
2909
  properties: {
2619
- name: {
2910
+ currency: {
2620
2911
  type: 'string',
2621
- description: 'Rule name (unique per user)',
2912
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2913
+ example: 'USD'
2914
+ },
2915
+ quoteCurrency: {
2916
+ type: 'string',
2917
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
2918
+ example: 'CNY'
2919
+ },
2920
+ amount: {
2921
+ type: 'number',
2922
+ description:
2923
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
2924
+ example: 175.5,
2925
+ minimum: 0
2926
+ },
2927
+ date: {
2928
+ type: 'string',
2929
+ description: 'Price date (ISO 8601 format)',
2930
+ example: '2024-11-05'
2931
+ },
2932
+ metadata: {
2933
+ type: 'object',
2934
+ description:
2935
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
2936
+ example: {
2937
+ source: 'MANUAL',
2938
+ note: 'Bank valuation report',
2939
+ confidence: 0.95
2940
+ }
2941
+ }
2942
+ },
2943
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
2944
+ } as const;
2945
+
2946
+ export const $PriceResponseDto = {
2947
+ type: 'object',
2948
+ properties: {
2949
+ id: {
2950
+ type: 'string',
2951
+ description: 'Unique identifier',
2952
+ example: 'uuid-123-456'
2953
+ },
2954
+ userId: {
2955
+ type: 'string',
2956
+ description: 'User ID (owner of the price)',
2957
+ example: 'user-123'
2958
+ },
2959
+ currency: {
2960
+ type: 'string',
2961
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2962
+ example: 'BTC'
2963
+ },
2964
+ quoteCurrency: {
2965
+ type: 'string',
2966
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2967
+ example: 'USD'
2968
+ },
2969
+ amount: {
2970
+ type: 'number',
2971
+ description:
2972
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2973
+ example: 50000
2974
+ },
2975
+ date: {
2976
+ type: 'string',
2977
+ description:
2978
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
2979
+ example: '2024-01-01',
2980
+ format: 'date'
2981
+ },
2982
+ meta: {
2983
+ type: 'object',
2984
+ description:
2985
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
2986
+ example: {
2987
+ source: 'MANUAL',
2988
+ note: 'User-defined price',
2989
+ confidence: 1
2990
+ }
2991
+ },
2992
+ createdAt: {
2993
+ format: 'date-time',
2994
+ type: 'string',
2995
+ description: 'Creation timestamp',
2996
+ example: '2024-11-03T10:00:00Z'
2997
+ },
2998
+ updatedAt: {
2999
+ format: 'date-time',
3000
+ type: 'string',
3001
+ description: 'Last update timestamp',
3002
+ example: '2024-11-03T10:00:00Z'
3003
+ }
3004
+ },
3005
+ required: [
3006
+ 'id',
3007
+ 'userId',
3008
+ 'currency',
3009
+ 'quoteCurrency',
3010
+ 'amount',
3011
+ 'date',
3012
+ 'meta',
3013
+ 'createdAt',
3014
+ 'updatedAt'
3015
+ ]
3016
+ } as const;
3017
+
3018
+ export const $PriceListResponseDto = {
3019
+ type: 'object',
3020
+ properties: {
3021
+ items: {
3022
+ description: 'List of prices',
3023
+ type: 'array',
3024
+ items: {
3025
+ $ref: '#/components/schemas/PriceResponseDto'
3026
+ }
3027
+ },
3028
+ total: {
3029
+ type: 'number',
3030
+ description: 'Total number of prices',
3031
+ example: 42
3032
+ }
3033
+ },
3034
+ required: ['items', 'total']
3035
+ } as const;
3036
+
3037
+ export const $UpdateBeanPriceDto = {
3038
+ type: 'object',
3039
+ properties: {
3040
+ currency: {
3041
+ type: 'string',
3042
+ description: 'Currency being priced'
3043
+ },
3044
+ quoteCurrency: {
3045
+ type: 'string',
3046
+ description: 'Quote currency (pricing currency)'
3047
+ },
3048
+ amount: {
3049
+ type: 'number',
3050
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
3051
+ minimum: 0
3052
+ },
3053
+ date: {
3054
+ type: 'string',
3055
+ description: 'Price date (ISO 8601 format)'
3056
+ },
3057
+ metadata: {
3058
+ type: 'object',
3059
+ description: 'Metadata'
3060
+ }
3061
+ }
3062
+ } as const;
3063
+
3064
+ export const $CreateRecurringRuleDto = {
3065
+ type: 'object',
3066
+ properties: {
3067
+ name: {
3068
+ type: 'string',
3069
+ description: 'Rule name (unique per user)',
2622
3070
  maxLength: 100
2623
3071
  },
2624
3072
  icon: {
@@ -3384,121 +3832,568 @@ export const $ForecastResponseDto = {
3384
3832
  ]
3385
3833
  } as const;
3386
3834
 
3387
- export const $CreateTransactionRuleDto = {
3835
+ export const $CurrencyBalanceDto = {
3388
3836
  type: 'object',
3389
3837
  properties: {
3390
- name: {
3838
+ currency: {
3391
3839
  type: 'string',
3392
- minLength: 1,
3393
- maxLength: 100
3840
+ description: 'ISO 4217 currency code',
3841
+ example: 'CNY'
3394
3842
  },
3395
- description: {
3843
+ balance: {
3396
3844
  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: {
3845
+ description: 'Balance amount',
3846
+ example: '500000.00'
3847
+ }
3848
+ },
3849
+ required: ['currency', 'balance']
3850
+ } as const;
3851
+
3852
+ export const $TimeSeriesPointDto = {
3853
+ type: 'object',
3854
+ properties: {
3855
+ date: {
3429
3856
  type: 'string',
3430
- maxLength: 200,
3431
- description:
3432
- 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
3857
+ description: 'Date in YYYY-MM-DD format',
3858
+ example: '2024-06-15'
3433
3859
  },
3434
- matchLogic: {
3860
+ value: {
3435
3861
  type: 'string',
3436
- enum: ['OR', 'AND'],
3437
- default: 'OR'
3862
+ description: 'Value at this date (in base currency)',
3863
+ example: '500000.00'
3438
3864
  },
3439
- amountMin: {
3440
- type: 'number',
3441
- minimum: 0,
3442
- description: 'Minimum transaction amount (inclusive)'
3865
+ change: {
3866
+ type: 'object',
3867
+ description: 'Change from previous point',
3868
+ example: '5000.00'
3443
3869
  },
3444
- amountMax: {
3445
- type: 'number',
3446
- minimum: 0,
3447
- description: 'Maximum transaction amount (inclusive)'
3870
+ assets: {
3871
+ type: 'string',
3872
+ description: 'Total assets at this date (in base currency)',
3873
+ example: '494338.00'
3448
3874
  },
3449
- priority: {
3450
- type: 'number',
3451
- default: 50,
3452
- minimum: 0,
3453
- maximum: 1000
3875
+ liabilities: {
3876
+ type: 'string',
3877
+ description: 'Total liabilities at this date (in base currency)',
3878
+ example: '310098.00'
3454
3879
  },
3455
- additionalTags: {
3880
+ byCurrency: {
3881
+ description: 'Multi-currency breakdown for this point',
3882
+ type: 'array',
3456
3883
  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'
3884
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3885
+ }
3469
3886
  }
3470
3887
  },
3471
- required: ['name', 'matchLogic', 'priority']
3472
- } as const;
3473
-
3474
- export const $AmountRangeDto = {
3475
- type: 'object',
3476
- properties: {
3477
- min: {
3478
- type: 'number',
3479
- description: 'Minimum amount'
3480
- },
3481
- max: {
3482
- type: 'number',
3483
- description: 'Maximum amount'
3484
- }
3485
- }
3888
+ required: ['date', 'value']
3486
3889
  } as const;
3487
3890
 
3488
- export const $TransactionRuleResponseDto = {
3891
+ export const $TrendSummaryDto = {
3489
3892
  type: 'object',
3490
3893
  properties: {
3491
- id: {
3894
+ startValue: {
3492
3895
  type: 'string',
3493
- description: 'Rule ID'
3896
+ description: 'Value at start of period',
3897
+ example: '450000.00'
3494
3898
  },
3495
- name: {
3899
+ endValue: {
3496
3900
  type: 'string',
3497
- description: 'Rule name'
3901
+ description: 'Value at end of period',
3902
+ example: '500000.00'
3498
3903
  },
3499
- description: {
3904
+ totalChange: {
3500
3905
  type: 'string',
3501
- description: 'Rule description'
3906
+ description: 'Total change over period',
3907
+ example: '50000.00'
3908
+ },
3909
+ totalChangePercentage: {
3910
+ type: 'string',
3911
+ description: 'Total change percentage',
3912
+ example: '+11.11%'
3913
+ }
3914
+ },
3915
+ required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
3916
+ } as const;
3917
+
3918
+ export const $MultiCurrencyPointDto = {
3919
+ type: 'object',
3920
+ properties: {
3921
+ date: {
3922
+ type: 'string',
3923
+ description: 'Date in YYYY-MM-DD format',
3924
+ example: '2024-06-15'
3925
+ },
3926
+ byCurrency: {
3927
+ description: 'Balances by currency',
3928
+ type: 'array',
3929
+ items: {
3930
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3931
+ }
3932
+ }
3933
+ },
3934
+ required: ['date', 'byCurrency']
3935
+ } as const;
3936
+
3937
+ export const $PortfolioTrendsResponseDto = {
3938
+ type: 'object',
3939
+ properties: {
3940
+ series: {
3941
+ description: 'Time series data points',
3942
+ type: 'array',
3943
+ items: {
3944
+ $ref: '#/components/schemas/TimeSeriesPointDto'
3945
+ }
3946
+ },
3947
+ summary: {
3948
+ description: 'Period summary',
3949
+ allOf: [
3950
+ {
3951
+ $ref: '#/components/schemas/TrendSummaryDto'
3952
+ }
3953
+ ]
3954
+ },
3955
+ period: {
3956
+ type: 'string',
3957
+ description: 'Period requested',
3958
+ example: '6m'
3959
+ },
3960
+ granularity: {
3961
+ type: 'string',
3962
+ description: 'Data granularity',
3963
+ example: 'month'
3964
+ },
3965
+ currency: {
3966
+ type: 'string',
3967
+ description: 'Base currency for converted values',
3968
+ example: 'CNY'
3969
+ },
3970
+ byCurrency: {
3971
+ description:
3972
+ 'Multi-currency time series (each point has currency breakdown)',
3973
+ type: 'array',
3974
+ items: {
3975
+ $ref: '#/components/schemas/MultiCurrencyPointDto'
3976
+ }
3977
+ },
3978
+ warnings: {
3979
+ description: 'Exchange rate warnings',
3980
+ type: 'array',
3981
+ items: {
3982
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3983
+ }
3984
+ }
3985
+ },
3986
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
3987
+ } as const;
3988
+
3989
+ export const $CashFlowPointDto = {
3990
+ type: 'object',
3991
+ properties: {
3992
+ month: {
3993
+ type: 'string',
3994
+ description: 'Month key (YYYY-MM)',
3995
+ example: '2024-03'
3996
+ },
3997
+ income: {
3998
+ type: 'string',
3999
+ description: 'Income in base currency (absolute, converted)',
4000
+ example: '10000.00'
4001
+ },
4002
+ expense: {
4003
+ type: 'string',
4004
+ description: 'Expense in base currency (absolute, converted)',
4005
+ example: '5000.00'
4006
+ },
4007
+ netSavings: {
4008
+ type: 'string',
4009
+ description: 'netSavings = income − expense (savings positive)',
4010
+ example: '5000.00'
4011
+ }
4012
+ },
4013
+ required: ['month', 'income', 'expense', 'netSavings']
4014
+ } as const;
4015
+
4016
+ export const $CashFlowTrendSummaryDto = {
4017
+ type: 'object',
4018
+ properties: {
4019
+ totalIncome: {
4020
+ type: 'string',
4021
+ description: 'Total income across the period',
4022
+ example: '60000.00'
4023
+ },
4024
+ totalExpense: {
4025
+ type: 'string',
4026
+ description: 'Total expense across the period',
4027
+ example: '30000.00'
4028
+ },
4029
+ totalNetSavings: {
4030
+ type: 'string',
4031
+ description: 'income − expense across the period',
4032
+ example: '30000.00'
4033
+ },
4034
+ averageMonthlyNetSavings: {
4035
+ type: 'string',
4036
+ description:
4037
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
4038
+ example: '5000.00'
4039
+ }
4040
+ },
4041
+ required: [
4042
+ 'totalIncome',
4043
+ 'totalExpense',
4044
+ 'totalNetSavings',
4045
+ 'averageMonthlyNetSavings'
4046
+ ]
4047
+ } as const;
4048
+
4049
+ export const $CashFlowTrendsResponseDto = {
4050
+ type: 'object',
4051
+ properties: {
4052
+ series: {
4053
+ description:
4054
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
4055
+ type: 'array',
4056
+ items: {
4057
+ $ref: '#/components/schemas/CashFlowPointDto'
4058
+ }
4059
+ },
4060
+ summary: {
4061
+ description: 'Period totals',
4062
+ allOf: [
4063
+ {
4064
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
4065
+ }
4066
+ ]
4067
+ },
4068
+ period: {
4069
+ type: 'string',
4070
+ description: 'Period requested',
4071
+ example: '6m'
4072
+ },
4073
+ granularity: {
4074
+ type: 'string',
4075
+ description: 'Data granularity (v1 returns month buckets)',
4076
+ example: 'month'
4077
+ },
4078
+ currency: {
4079
+ type: 'string',
4080
+ description: 'Base currency for converted values',
4081
+ example: 'CNY'
4082
+ },
4083
+ warnings: {
4084
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
4085
+ type: 'array',
4086
+ items: {
4087
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
4088
+ }
4089
+ }
4090
+ },
4091
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
4092
+ } as const;
4093
+
4094
+ export const $GenerateSnapshotBody = {
4095
+ type: 'object',
4096
+ properties: {}
4097
+ } as const;
4098
+
4099
+ export const $GenerateSnapshotResponse = {
4100
+ type: 'object',
4101
+ properties: {}
4102
+ } as const;
4103
+
4104
+ export const $BackfillSnapshotsBody = {
4105
+ type: 'object',
4106
+ properties: {}
4107
+ } as const;
4108
+
4109
+ export const $BackfillSnapshotsResponse = {
4110
+ type: 'object',
4111
+ properties: {}
4112
+ } as const;
4113
+
4114
+ export const $DeleteOwnUserDto = {
4115
+ type: 'object',
4116
+ properties: {
4117
+ accessToken: {
4118
+ type: 'string',
4119
+ description: 'Access token for user verification',
4120
+ example: 'abc123xyz'
4121
+ }
4122
+ },
4123
+ required: ['accessToken']
4124
+ } as const;
4125
+
4126
+ export const $SignupDto = {
4127
+ type: 'object',
4128
+ properties: {
4129
+ turnstileToken: {
4130
+ type: 'string',
4131
+ description:
4132
+ 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4133
+ example: '0.abc123def456...'
4134
+ }
4135
+ }
4136
+ } as const;
4137
+
4138
+ export const $SignupResponseDto = {
4139
+ type: 'object',
4140
+ properties: {
4141
+ authToken: {
4142
+ type: 'string',
4143
+ description: 'JWT auth token',
4144
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4145
+ },
4146
+ accessToken: {
4147
+ type: 'string',
4148
+ description: 'Auto-generated access token'
4149
+ },
4150
+ role: {
4151
+ type: 'string',
4152
+ description: 'Assigned user role',
4153
+ enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
4154
+ }
4155
+ },
4156
+ required: ['authToken', 'accessToken', 'role']
4157
+ } as const;
4158
+
4159
+ export const $UpdateUserSettingDto = {
4160
+ type: 'object',
4161
+ properties: {
4162
+ secId: {
4163
+ type: 'number',
4164
+ description: 'Security ID'
4165
+ },
4166
+ annualInterestRate: {
4167
+ type: 'number',
4168
+ description: 'Annual interest rate',
4169
+ example: 0.05
4170
+ },
4171
+ currency: {
4172
+ type: 'string',
4173
+ description: 'Currency code',
4174
+ example: 'USD'
4175
+ },
4176
+ baseCurrency: {
4177
+ type: 'string',
4178
+ description: 'Base currency code',
4179
+ example: 'USD'
4180
+ },
4181
+ benchmark: {
4182
+ type: 'string',
4183
+ description: 'Benchmark symbol',
4184
+ example: 'SPY'
4185
+ },
4186
+ colorScheme: {
4187
+ type: 'string',
4188
+ description: 'Color scheme',
4189
+ enum: ['DARK', 'LIGHT']
4190
+ },
4191
+ dateRange: {
4192
+ type: 'string',
4193
+ description: 'Date range filter',
4194
+ example: '1y'
4195
+ },
4196
+ emergencyFund: {
4197
+ type: 'number',
4198
+ description: 'Emergency fund amount',
4199
+ example: 10000
4200
+ },
4201
+ 'filters.accounts': {
4202
+ description: 'Account filter IDs',
4203
+ type: 'array',
4204
+ items: {
4205
+ type: 'string'
4206
+ }
4207
+ },
4208
+ 'filters.assetClasses': {
4209
+ description: 'Asset class filters',
4210
+ type: 'array',
4211
+ items: {
4212
+ type: 'string'
4213
+ }
4214
+ },
4215
+ 'filters.dataSource': {
4216
+ type: 'string',
4217
+ description: 'Data source filter'
4218
+ },
4219
+ 'filters.symbol': {
4220
+ type: 'string',
4221
+ description: 'Symbol filter'
4222
+ },
4223
+ 'filters.tags': {
4224
+ description: 'Tag filters',
4225
+ type: 'array',
4226
+ items: {
4227
+ type: 'string'
4228
+ }
4229
+ },
4230
+ isExperimentalFeatures: {
4231
+ type: 'boolean',
4232
+ description: 'Enable experimental features'
4233
+ },
4234
+ isRestrictedView: {
4235
+ type: 'boolean',
4236
+ description: 'Enable restricted view mode'
4237
+ },
4238
+ language: {
4239
+ type: 'string',
4240
+ description: 'Language code',
4241
+ example: 'en'
4242
+ },
4243
+ locale: {
4244
+ type: 'string',
4245
+ description: 'Locale code',
4246
+ example: 'en-US'
4247
+ },
4248
+ projectedTotalAmount: {
4249
+ type: 'number',
4250
+ description: 'Projected total amount',
4251
+ example: 1000000
4252
+ },
4253
+ retirementDate: {
4254
+ type: 'string',
4255
+ description: 'Retirement date in ISO 8601 format',
4256
+ example: '2050-01-01'
4257
+ },
4258
+ savingsRate: {
4259
+ type: 'number',
4260
+ description: 'Savings rate percentage',
4261
+ example: 0.2
4262
+ },
4263
+ viewMode: {
4264
+ type: 'string',
4265
+ description: 'View mode',
4266
+ enum: ['DEFAULT', 'ZEN']
4267
+ }
4268
+ }
4269
+ } as const;
4270
+
4271
+ export const $UpdatePropertyDto = {
4272
+ type: 'object',
4273
+ properties: {
4274
+ value: {
4275
+ type: 'string',
4276
+ description: 'Property value'
4277
+ }
4278
+ },
4279
+ required: ['value']
4280
+ } as const;
4281
+
4282
+ export const $CreateTransactionRuleDto = {
4283
+ type: 'object',
4284
+ properties: {
4285
+ name: {
4286
+ type: 'string',
4287
+ minLength: 1,
4288
+ maxLength: 100
4289
+ },
4290
+ description: {
4291
+ type: 'string',
4292
+ maxLength: 500
4293
+ },
4294
+ narrationKeywords: {
4295
+ items: {
4296
+ type: 'array'
4297
+ },
4298
+ maxItems: 50,
4299
+ type: 'array'
4300
+ },
4301
+ payeeKeywords: {
4302
+ items: {
4303
+ type: 'array'
4304
+ },
4305
+ maxItems: 50,
4306
+ type: 'array'
4307
+ },
4308
+ categoryKeywords: {
4309
+ items: {
4310
+ type: 'array'
4311
+ },
4312
+ maxItems: 50,
4313
+ type: 'array'
4314
+ },
4315
+ methodKeywords: {
4316
+ items: {
4317
+ type: 'array'
4318
+ },
4319
+ maxItems: 50,
4320
+ description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
4321
+ type: 'array'
4322
+ },
4323
+ categoryAccount: {
4324
+ type: 'string',
4325
+ maxLength: 200,
4326
+ description:
4327
+ 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
4328
+ },
4329
+ matchLogic: {
4330
+ type: 'string',
4331
+ enum: ['OR', 'AND'],
4332
+ default: 'OR'
4333
+ },
4334
+ amountMin: {
4335
+ type: 'number',
4336
+ minimum: 0,
4337
+ description: 'Minimum transaction amount (inclusive)'
4338
+ },
4339
+ amountMax: {
4340
+ type: 'number',
4341
+ minimum: 0,
4342
+ description: 'Maximum transaction amount (inclusive)'
4343
+ },
4344
+ priority: {
4345
+ type: 'number',
4346
+ default: 50,
4347
+ minimum: 0,
4348
+ maximum: 1000
4349
+ },
4350
+ additionalTags: {
4351
+ items: {
4352
+ type: 'array'
4353
+ },
4354
+ maxItems: 20,
4355
+ type: 'array'
4356
+ },
4357
+ additionalMetadata: {
4358
+ type: 'object'
4359
+ },
4360
+ upsertByPayee: {
4361
+ type: 'boolean',
4362
+ description:
4363
+ 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
4364
+ }
4365
+ },
4366
+ required: ['name', 'matchLogic', 'priority']
4367
+ } as const;
4368
+
4369
+ export const $AmountRangeDto = {
4370
+ type: 'object',
4371
+ properties: {
4372
+ min: {
4373
+ type: 'number',
4374
+ description: 'Minimum amount'
4375
+ },
4376
+ max: {
4377
+ type: 'number',
4378
+ description: 'Maximum amount'
4379
+ }
4380
+ }
4381
+ } as const;
4382
+
4383
+ export const $TransactionRuleResponseDto = {
4384
+ type: 'object',
4385
+ properties: {
4386
+ id: {
4387
+ type: 'string',
4388
+ description: 'Rule ID'
4389
+ },
4390
+ name: {
4391
+ type: 'string',
4392
+ description: 'Rule name'
4393
+ },
4394
+ description: {
4395
+ type: 'string',
4396
+ description: 'Rule description'
3502
4397
  },
3503
4398
  narrationKeywords: {
3504
4399
  description: 'Keywords to match in transaction narration',
@@ -4033,151 +4928,393 @@ export const $TestRuleResponseDto = {
4033
4928
  required: ['ruleId', 'matches', 'confidence', 'matchDetails']
4034
4929
  } as const;
4035
4930
 
4036
- export const $DeleteOwnUserDto = {
4931
+ export const $CreateBeanEventDto = {
4037
4932
  type: 'object',
4038
4933
  properties: {
4039
- accessToken: {
4934
+ date: {
4040
4935
  type: 'string',
4041
- description: 'Access token for user verification',
4042
- example: 'abc123xyz'
4936
+ description: 'Life event date (ISO 8601)',
4937
+ example: '2024-03-15'
4938
+ },
4939
+ type: {
4940
+ type: 'string',
4941
+ description:
4942
+ 'Life event type (e.g., "employer", "location", "marital-status") — user-defined, no enum constraint at engine layer',
4943
+ example: 'employer'
4944
+ },
4945
+ description: {
4946
+ type: 'string',
4947
+ description:
4948
+ 'Life event description. Empty string is a VALID value (distinct from absence).',
4949
+ example: 'Acme Corp'
4950
+ },
4951
+ meta: {
4952
+ type: 'object',
4953
+ description:
4954
+ 'Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)',
4955
+ example: {
4956
+ note: 'Promotion'
4957
+ }
4043
4958
  }
4044
4959
  },
4045
- required: ['accessToken']
4960
+ required: ['date', 'type', 'description']
4046
4961
  } as const;
4047
4962
 
4048
- export const $SignupDto = {
4963
+ export const $EventResponseDto = {
4049
4964
  type: 'object',
4050
4965
  properties: {
4051
- turnstileToken: {
4966
+ id: {
4967
+ type: 'string',
4968
+ description: 'Unique identifier',
4969
+ example: 'uuid-123-456'
4970
+ },
4971
+ userId: {
4972
+ type: 'string',
4973
+ description: 'User ID (owner of the life event)',
4974
+ example: 'user-123'
4975
+ },
4976
+ date: {
4977
+ type: 'string',
4978
+ description: 'Life event date (ISO 8601 format)',
4979
+ example: '2024-03-15',
4980
+ format: 'date'
4981
+ },
4982
+ type: {
4052
4983
  type: 'string',
4053
4984
  description:
4054
- 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4055
- example: '0.abc123def456...'
4985
+ 'Life event type (user-defined, e.g., "employer", "location")',
4986
+ example: 'employer'
4987
+ },
4988
+ description: {
4989
+ type: 'string',
4990
+ description:
4991
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4992
+ example: 'Acme Corp'
4993
+ },
4994
+ meta: {
4995
+ type: 'object',
4996
+ description: 'Product-side metadata (free-form JSON)',
4997
+ example: {
4998
+ note: 'Promotion'
4999
+ }
5000
+ },
5001
+ createdAt: {
5002
+ format: 'date-time',
5003
+ type: 'string',
5004
+ description: 'Creation timestamp',
5005
+ example: '2024-03-15T10:00:00Z'
5006
+ },
5007
+ updatedAt: {
5008
+ format: 'date-time',
5009
+ type: 'string',
5010
+ description:
5011
+ 'Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.',
5012
+ example: '2024-03-15T10:00:00Z'
4056
5013
  }
4057
- }
5014
+ },
5015
+ required: [
5016
+ 'id',
5017
+ 'userId',
5018
+ 'date',
5019
+ 'type',
5020
+ 'description',
5021
+ 'meta',
5022
+ 'createdAt',
5023
+ 'updatedAt'
5024
+ ]
4058
5025
  } as const;
4059
5026
 
4060
- export const $UpdateUserSettingDto = {
5027
+ export const $EventListResponseDto = {
4061
5028
  type: 'object',
4062
5029
  properties: {
4063
- secId: {
4064
- type: 'number',
4065
- description: 'Security ID'
5030
+ items: {
5031
+ description: 'List of life events',
5032
+ type: 'array',
5033
+ items: {
5034
+ $ref: '#/components/schemas/EventResponseDto'
5035
+ }
4066
5036
  },
4067
- annualInterestRate: {
5037
+ total: {
4068
5038
  type: 'number',
4069
- description: 'Annual interest rate',
4070
- example: 0.05
5039
+ description: 'Total number of life events matching the query',
5040
+ example: 42
5041
+ }
5042
+ },
5043
+ required: ['items', 'total']
5044
+ } as const;
5045
+
5046
+ export const $UpdateBeanEventDto = {
5047
+ type: 'object',
5048
+ properties: {
5049
+ date: {
5050
+ type: 'string',
5051
+ description: 'Life event date (ISO 8601)'
5052
+ },
5053
+ type: {
5054
+ type: 'string',
5055
+ description: 'Life event type (user-defined)'
5056
+ },
5057
+ description: {
5058
+ type: 'string',
5059
+ description:
5060
+ 'Life event description. Empty string is a VALID value (distinct from absence).'
5061
+ },
5062
+ meta: {
5063
+ type: 'object',
5064
+ description: 'Product-side metadata (free-form JSON)'
5065
+ }
5066
+ }
5067
+ } as const;
5068
+
5069
+ export const $OnboardingAccountDto = {
5070
+ type: 'object',
5071
+ properties: {
5072
+ path: {
5073
+ type: 'string',
5074
+ description:
5075
+ 'Account path (Assets/Liabilities only; format validated by the account service)',
5076
+ example: 'Assets:Checking'
4071
5077
  },
4072
5078
  currency: {
4073
5079
  type: 'string',
4074
- description: 'Currency code',
5080
+ description: 'ISO 4217 currency code (3 letters)',
4075
5081
  example: 'USD'
4076
5082
  },
4077
- baseCurrency: {
5083
+ openingBalance: {
4078
5084
  type: 'string',
4079
- description: 'Base currency code',
4080
- example: 'USD'
5085
+ description:
5086
+ 'Opening balance as a non-negative Decimal string (e.g. "1000.00")',
5087
+ example: '1000.00'
4081
5088
  },
4082
- benchmark: {
5089
+ platformId: {
4083
5090
  type: 'string',
4084
- description: 'Benchmark symbol',
4085
- example: 'SPY'
5091
+ description:
5092
+ 'Platform ID to bind the account to (references Platform.id); omit for unbound',
5093
+ example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
5094
+ }
5095
+ },
5096
+ required: ['path', 'currency']
5097
+ } as const;
5098
+
5099
+ export const $OnboardingDto = {
5100
+ type: 'object',
5101
+ properties: {
5102
+ accounts: {
5103
+ description: 'Asset/Liability accounts to register with opening balances',
5104
+ type: 'array',
5105
+ items: {
5106
+ $ref: '#/components/schemas/OnboardingAccountDto'
5107
+ }
5108
+ },
5109
+ skipAssetRegistration: {
5110
+ type: 'boolean',
5111
+ description:
5112
+ 'Skip asset registration; only bootstrap the core account set',
5113
+ default: false
5114
+ }
5115
+ }
5116
+ } as const;
5117
+
5118
+ export const $ActualBalanceDto = {
5119
+ type: 'object',
5120
+ properties: {
5121
+ amount: {
5122
+ type: 'string',
5123
+ description:
5124
+ 'Actual balance amount as a decimal string (preserves precision for tolerance inference).',
5125
+ example: '1234.56'
5126
+ },
5127
+ ccy: {
5128
+ type: 'string',
5129
+ description: 'Currency code (ISO 4217 or commodity ticker).',
5130
+ example: 'CNY'
5131
+ }
5132
+ },
5133
+ required: ['amount', 'ccy']
5134
+ } as const;
5135
+
5136
+ export const $ComputeReconciliationDto = {
5137
+ type: 'object',
5138
+ properties: {
5139
+ accountId: {
5140
+ type: 'string',
5141
+ description: 'BeanAccount id to reconcile.'
5142
+ },
5143
+ asOfDate: {
5144
+ type: 'string',
5145
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5146
+ example: '2026-07-24'
5147
+ },
5148
+ actualBalance: {
5149
+ description: 'Actual balance from the external statement.',
5150
+ allOf: [
5151
+ {
5152
+ $ref: '#/components/schemas/ActualBalanceDto'
5153
+ }
5154
+ ]
5155
+ }
5156
+ },
5157
+ required: ['accountId', 'asOfDate', 'actualBalance']
5158
+ } as const;
5159
+
5160
+ export const $ReconciliationComputeResultDto = {
5161
+ type: 'object',
5162
+ properties: {
5163
+ accountId: {
5164
+ type: 'string'
5165
+ },
5166
+ asOfDate: {
5167
+ type: 'string'
5168
+ },
5169
+ bookBalance: {
5170
+ type: 'string',
5171
+ description: 'System-computed book balance (decimal string).'
5172
+ },
5173
+ actualBalance: {
5174
+ type: 'string',
5175
+ description: 'User-entered actual balance (decimal string).'
5176
+ },
5177
+ currency: {
5178
+ type: 'string'
5179
+ },
5180
+ diff: {
5181
+ type: 'string',
5182
+ description: 'Diff = book − actual (decimal string).'
5183
+ },
5184
+ tolerance: {
5185
+ type: 'string',
5186
+ description: 'Applied tolerance (decimal string).'
5187
+ },
5188
+ withinTolerance: {
5189
+ type: 'boolean',
5190
+ description: 'true when |diff| ≤ tolerance.'
4086
5191
  },
4087
- colorScheme: {
5192
+ suggestedAction: {
4088
5193
  type: 'string',
4089
- description: 'Color scheme',
4090
- enum: ['DARK', 'LIGHT']
5194
+ enum: ['assert', 'pad'],
5195
+ description:
5196
+ 'Suggested next action: assert when within tolerance, pad otherwise.'
5197
+ }
5198
+ },
5199
+ required: [
5200
+ 'accountId',
5201
+ 'asOfDate',
5202
+ 'bookBalance',
5203
+ 'actualBalance',
5204
+ 'currency',
5205
+ 'diff',
5206
+ 'tolerance',
5207
+ 'withinTolerance',
5208
+ 'suggestedAction'
5209
+ ]
5210
+ } as const;
5211
+
5212
+ export const $AssertReconciliationDto = {
5213
+ type: 'object',
5214
+ properties: {
5215
+ accountId: {
5216
+ type: 'string',
5217
+ description: 'BeanAccount id to reconcile.'
4091
5218
  },
4092
- dateRange: {
5219
+ asOfDate: {
4093
5220
  type: 'string',
4094
- description: 'Date range filter',
4095
- example: '1y'
5221
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5222
+ example: '2026-07-24'
4096
5223
  },
4097
- emergencyFund: {
4098
- type: 'number',
4099
- description: 'Emergency fund amount',
4100
- example: 10000
5224
+ actualBalance: {
5225
+ description: 'Actual balance from the external statement.',
5226
+ allOf: [
5227
+ {
5228
+ $ref: '#/components/schemas/ActualBalanceDto'
5229
+ }
5230
+ ]
4101
5231
  },
4102
- 'filters.accounts': {
4103
- description: 'Account filter IDs',
4104
- type: 'array',
4105
- items: {
4106
- type: 'string'
4107
- }
5232
+ tolerance: {
5233
+ type: 'string',
5234
+ description:
5235
+ 'Optional explicit tolerance override. Omit to infer from amount precision (Beancount default).',
5236
+ example: '0.01'
5237
+ }
5238
+ },
5239
+ required: ['accountId', 'asOfDate', 'actualBalance']
5240
+ } as const;
5241
+
5242
+ export const $ReconciliationRecordDto = {
5243
+ type: 'object',
5244
+ properties: {
5245
+ id: {
5246
+ type: 'string'
4108
5247
  },
4109
- 'filters.assetClasses': {
4110
- description: 'Asset class filters',
4111
- type: 'array',
4112
- items: {
4113
- type: 'string'
4114
- }
5248
+ accountId: {
5249
+ type: 'string'
4115
5250
  },
4116
- 'filters.dataSource': {
4117
- type: 'string',
4118
- description: 'Data source filter'
5251
+ date: {
5252
+ type: 'string'
4119
5253
  },
4120
- 'filters.symbol': {
5254
+ amount: {
4121
5255
  type: 'string',
4122
- description: 'Symbol filter'
4123
- },
4124
- 'filters.tags': {
4125
- description: 'Tag filters',
4126
- type: 'array',
4127
- items: {
4128
- type: 'string'
4129
- }
5256
+ description: 'Asserted (actual) amount.'
4130
5257
  },
4131
- isExperimentalFeatures: {
4132
- type: 'boolean',
4133
- description: 'Enable experimental features'
5258
+ currency: {
5259
+ type: 'string'
4134
5260
  },
4135
- isRestrictedView: {
4136
- type: 'boolean',
4137
- description: 'Enable restricted view mode'
5261
+ tolerance: {
5262
+ type: 'string'
4138
5263
  },
4139
- language: {
5264
+ diffAmount: {
4140
5265
  type: 'string',
4141
- description: 'Language code',
4142
- example: 'en'
5266
+ description: 'book − actual.'
4143
5267
  },
4144
- locale: {
4145
- type: 'string',
4146
- description: 'Locale code',
4147
- example: 'en-US'
5268
+ diffCurrency: {
5269
+ type: 'string'
4148
5270
  },
4149
- projectedTotalAmount: {
4150
- type: 'number',
4151
- description: 'Projected total amount',
4152
- example: 1000000
5271
+ createdAt: {
5272
+ type: 'string'
5273
+ }
5274
+ },
5275
+ required: ['id', 'accountId', 'date', 'amount', 'currency', 'createdAt']
5276
+ } as const;
5277
+
5278
+ export const $PadReconciliationDto = {
5279
+ type: 'object',
5280
+ properties: {
5281
+ accountId: {
5282
+ type: 'string',
5283
+ description: 'BeanAccount id to reconcile.'
4153
5284
  },
4154
- retirementDate: {
5285
+ asOfDate: {
4155
5286
  type: 'string',
4156
- description: 'Retirement date in ISO 8601 format',
4157
- example: '2050-01-01'
5287
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5288
+ example: '2026-07-24'
4158
5289
  },
4159
- savingsRate: {
4160
- type: 'number',
4161
- description: 'Savings rate percentage',
4162
- example: 0.2
5290
+ actualBalance: {
5291
+ description: 'Actual balance from the external statement.',
5292
+ allOf: [
5293
+ {
5294
+ $ref: '#/components/schemas/ActualBalanceDto'
5295
+ }
5296
+ ]
4163
5297
  },
4164
- viewMode: {
5298
+ sourceAccount: {
4165
5299
  type: 'string',
4166
- description: 'View mode',
4167
- enum: ['DEFAULT', 'ZEN']
5300
+ description:
5301
+ 'Pad source account. Defaults to Equity:Opening-Balances (official Beancount convention).',
5302
+ example: 'Equity:Opening-Balances',
5303
+ default: 'Equity:Opening-Balances'
4168
5304
  }
4169
- }
5305
+ },
5306
+ required: ['accountId', 'asOfDate', 'actualBalance']
4170
5307
  } as const;
4171
5308
 
4172
- export const $UpdatePropertyDto = {
5309
+ export const $PadResultDto = {
4173
5310
  type: 'object',
4174
5311
  properties: {
4175
- value: {
5312
+ transactionId: {
4176
5313
  type: 'string',
4177
- description: 'Property value'
5314
+ description: 'Created pad adjusting transaction id.'
4178
5315
  }
4179
5316
  },
4180
- required: ['value']
5317
+ required: ['transactionId']
4181
5318
  } as const;
4182
5319
 
4183
5320
  export const $FileImportDto = {
@@ -4346,7 +5483,7 @@ export const $IdentifyResultDto = {
4346
5483
  account: {
4347
5484
  type: 'string',
4348
5485
  description: 'Default account used by this importer',
4349
- example: 'Assets:Alipay:Balance'
5486
+ example: 'Assets:CN:Alipay:Balance'
4350
5487
  },
4351
5488
  message: {
4352
5489
  type: 'string',
@@ -4363,7 +5500,7 @@ export const $MapperDefaultsDto = {
4363
5500
  sourceAccount: {
4364
5501
  type: 'string',
4365
5502
  description: 'Source account for transactions (Beancount format)',
4366
- example: 'Assets:Alipay:Balance'
5503
+ example: 'Assets:CN:Alipay:Balance'
4367
5504
  },
4368
5505
  currency: {
4369
5506
  type: 'string',
@@ -4400,7 +5537,7 @@ export const $MapperDefaultsDto = {
4400
5537
  description:
4401
5538
  '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
5539
  example: {
4403
- HuaBei: 'Liabilities:Alipay:Huabei',
5540
+ HuaBei: 'Liabilities:CN:CreditLine',
4404
5541
  CreditCard: 'Liabilities:CreditCard'
4405
5542
  }
4406
5543
  }
@@ -4532,7 +5669,7 @@ export const $UpdateMapperDefaultsDto = {
4532
5669
  sourceAccount: {
4533
5670
  type: 'string',
4534
5671
  description: 'Source account for transactions (Beancount format)',
4535
- example: 'Assets:Alipay:Balance',
5672
+ example: 'Assets:CN:Alipay:Balance',
4536
5673
  pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4537
5674
  },
4538
5675
  currency: {
@@ -4560,7 +5697,7 @@ export const $UpdateMapperDefaultsDto = {
4560
5697
  description:
4561
5698
  '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
5699
  example: {
4563
- HuaBei: 'Liabilities:Alipay:Huabei',
5700
+ HuaBei: 'Liabilities:CN:CreditLine',
4564
5701
  CreditCard: 'Liabilities:CreditCard'
4565
5702
  }
4566
5703
  }
@@ -4595,119 +5732,13 @@ export const $UpdateImporterConfigDto = {
4595
5732
  }
4596
5733
  } as const;
4597
5734
 
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
5735
  export const $ProviderSyncConfigDto = {
4705
5736
  type: 'object',
4706
5737
  properties: {
4707
5738
  sourceAccount: {
4708
5739
  type: 'string',
4709
5740
  description: 'Source account for the first posting',
4710
- example: 'Assets:Bank:Chase'
5741
+ example: 'Assets:US:Chase:Checking'
4711
5742
  },
4712
5743
  defaultCurrency: {
4713
5744
  type: 'string',
@@ -4716,26 +5747,29 @@ export const $ProviderSyncConfigDto = {
4716
5747
  },
4717
5748
  defaultExpenseAccount: {
4718
5749
  type: 'string',
4719
- description: 'Default expense account for the second posting',
5750
+ description:
5751
+ 'Default expense account for the second posting. Omit when no real default exists; the pipeline routes to Review via the Uncategorized sentinel (#618).',
4720
5752
  example: 'Expenses:Unknown'
4721
5753
  },
4722
5754
  defaultIncomeAccount: {
4723
5755
  type: 'string',
4724
- description: 'Default income account for the second posting',
5756
+ description:
5757
+ 'Default income account for the second posting. Omit when no real default exists; the pipeline routes to Review via the Uncategorized sentinel (#618).',
4725
5758
  example: 'Income:Unknown'
4726
5759
  },
4727
5760
  filterPending: {
4728
5761
  type: 'boolean',
4729
5762
  description: 'Filter pending transactions',
4730
5763
  default: true
5764
+ },
5765
+ externalAccountId: {
5766
+ type: 'string',
5767
+ description:
5768
+ 'External account ID for per-batch providers (e.g. GoCardless). Overrides sourceAccount when an ExternalAccountLink mapping exists.',
5769
+ example: 'acc_gocardless_001'
4731
5770
  }
4732
5771
  },
4733
- required: [
4734
- 'sourceAccount',
4735
- 'defaultCurrency',
4736
- 'defaultExpenseAccount',
4737
- 'defaultIncomeAccount'
4738
- ]
5772
+ required: ['sourceAccount', 'defaultCurrency']
4739
5773
  } as const;
4740
5774
 
4741
5775
  export const $ProviderSyncDto = {
@@ -4823,12 +5857,36 @@ export const $ProviderSyncResponseDto = {
4823
5857
  required: ['imported', 'skipped', 'pendingReview', 'failed']
4824
5858
  } as const;
4825
5859
 
4826
- export const $SupportedProvidersResponseDto = {
5860
+ export const $SupportedProvidersResponseDto = {
5861
+ type: 'object',
5862
+ properties: {
5863
+ providers: {
5864
+ description: 'List of supported provider names',
5865
+ example: [
5866
+ 'plaid',
5867
+ 'teller',
5868
+ 'truelayer',
5869
+ 'gocardless',
5870
+ 'simplefin',
5871
+ 'yodlee',
5872
+ 'beancount-direct',
5873
+ 'parsed-bill'
5874
+ ],
5875
+ type: 'array',
5876
+ items: {
5877
+ type: 'string'
5878
+ }
5879
+ }
5880
+ },
5881
+ required: ['providers']
5882
+ } as const;
5883
+
5884
+ export const $CreateExternalAccountLinkDto = {
4827
5885
  type: 'object',
4828
5886
  properties: {
4829
- providers: {
4830
- description: 'List of supported provider names',
4831
- example: [
5887
+ provider: {
5888
+ type: 'string',
5889
+ enum: [
4832
5890
  'plaid',
4833
5891
  'teller',
4834
5892
  'truelayer',
@@ -4838,13 +5896,77 @@ export const $SupportedProvidersResponseDto = {
4838
5896
  'beancount-direct',
4839
5897
  'parsed-bill'
4840
5898
  ],
5899
+ example: 'plaid',
5900
+ description: 'Open Banking provider (whitelist)'
5901
+ },
5902
+ externalAccountId: {
5903
+ type: 'string',
5904
+ example: 'acc-plaid-001',
5905
+ description: 'External account ID from the provider'
5906
+ },
5907
+ beanAccountId: {
5908
+ type: 'string',
5909
+ example: '550e8400-e29b-41d4-a716-446655440000',
5910
+ description: 'Target BeanAccount ID (must belong to the JWT user)'
5911
+ }
5912
+ },
5913
+ required: ['provider', 'externalAccountId', 'beanAccountId']
5914
+ } as const;
5915
+
5916
+ export const $ExternalAccountLinkResponseDto = {
5917
+ type: 'object',
5918
+ properties: {
5919
+ id: {
5920
+ type: 'string'
5921
+ },
5922
+ provider: {
5923
+ type: 'string'
5924
+ },
5925
+ externalAccountId: {
5926
+ type: 'string'
5927
+ },
5928
+ beanAccountId: {
5929
+ type: 'string'
5930
+ },
5931
+ isActive: {
5932
+ type: 'boolean'
5933
+ },
5934
+ createdAt: {
5935
+ type: 'string'
5936
+ },
5937
+ updatedAt: {
5938
+ type: 'string'
5939
+ }
5940
+ },
5941
+ required: [
5942
+ 'id',
5943
+ 'provider',
5944
+ 'externalAccountId',
5945
+ 'beanAccountId',
5946
+ 'isActive',
5947
+ 'createdAt',
5948
+ 'updatedAt'
5949
+ ]
5950
+ } as const;
5951
+
5952
+ export const $ExternalAccountLinkListResponseDto = {
5953
+ type: 'object',
5954
+ properties: {
5955
+ items: {
4841
5956
  type: 'array',
4842
5957
  items: {
4843
- type: 'string'
5958
+ $ref: '#/components/schemas/ExternalAccountLinkResponseDto'
4844
5959
  }
5960
+ },
5961
+ total: {
5962
+ type: 'number'
5963
+ },
5964
+ provider: {
5965
+ type: 'string',
5966
+ description: 'Filter by provider (query param)'
4845
5967
  }
4846
5968
  },
4847
- required: ['providers']
5969
+ required: ['items', 'total']
4848
5970
  } as const;
4849
5971
 
4850
5972
  export const $ParserTelemetryReportDto = {
@@ -4852,6 +5974,11 @@ export const $ParserTelemetryReportDto = {
4852
5974
  properties: {}
4853
5975
  } as const;
4854
5976
 
5977
+ export const $UncoveredFormatMissDto = {
5978
+ type: 'object',
5979
+ properties: {}
5980
+ } as const;
5981
+
4855
5982
  export const $ProcessNlpDto = {
4856
5983
  type: 'object',
4857
5984
  properties: {
@@ -4876,6 +6003,18 @@ export const $ProcessNlpDto = {
4876
6003
  currency: 'CNY',
4877
6004
  payee: 'Starbucks'
4878
6005
  }
6006
+ },
6007
+ selectedRuleId: {
6008
+ type: 'string',
6009
+ description:
6010
+ 'confirm_rule echo-back: rule id selected from the prior confirm_rule response (matchedRule.id or alternatives[i].ruleId). Applied directly when the session is confirming_rule — no NL re-parse.',
6011
+ example: 'rule_abc123'
6012
+ },
6013
+ selectedAccount: {
6014
+ type: 'string',
6015
+ description:
6016
+ 'confirm_account echo-back: account path selected from the prior confirm_account response (suggestedAccount, similarAccounts[i], or a typed path). Applied directly when the session is confirming_account — no NL re-parse.',
6017
+ example: 'Expenses:Food:Coffee'
4879
6018
  }
4880
6019
  },
4881
6020
  required: ['message']
@@ -5200,7 +6339,8 @@ export const $NlpAccountConfirmationDataDto = {
5200
6339
  },
5201
6340
  suggestedAccount: {
5202
6341
  type: 'string',
5203
- description: 'Suggested replacement account',
6342
+ description:
6343
+ 'Suggested replacement account (omitted when no clear candidate)',
5204
6344
  example: 'Expenses:Food:Drinks'
5205
6345
  },
5206
6346
  similarAccounts: {
@@ -5222,7 +6362,6 @@ export const $NlpAccountConfirmationDataDto = {
5222
6362
  },
5223
6363
  required: [
5224
6364
  'invalidAccount',
5225
- 'suggestedAccount',
5226
6365
  'similarAccounts',
5227
6366
  'errorMessage',
5228
6367
  'transactionContext'
@@ -5391,11 +6530,12 @@ export const $NlpSuggestedAccountDto = {
5391
6530
  account: {
5392
6531
  type: 'string',
5393
6532
  description: 'Suggested account path',
5394
- example: 'Assets:Bank:Checking'
6533
+ example: 'Assets:Checking'
5395
6534
  },
5396
6535
  confidence: {
5397
6536
  type: 'number',
5398
- description: 'Confidence score for this suggestion (0-1)',
6537
+ description:
6538
+ 'Confidence score for this suggestion (0-1). Present = predicted (confirm/confirm_rule/confirm_account); omitted = actual persisted account (created). (#586)',
5399
6539
  example: 0.9
5400
6540
  }
5401
6541
  },
@@ -5431,23 +6571,31 @@ export const $NlpDefaultAccountsDto = {
5431
6571
  properties: {
5432
6572
  asset: {
5433
6573
  type: 'string',
5434
- description: 'Default asset account',
5435
- example: 'Assets:Bank:Checking'
6574
+ description:
6575
+ 'Default OPEN asset account (MRU when multiple), or null when none/ambiguous',
6576
+ example: 'Assets:Checking',
6577
+ nullable: true
5436
6578
  },
5437
6579
  expense: {
5438
6580
  type: 'string',
5439
- description: 'Default expense account',
5440
- example: 'Expenses:Uncategorized'
6581
+ description:
6582
+ 'Default OPEN expense account (MRU when multiple), or null when none/ambiguous',
6583
+ example: 'Expenses:Food:Coffee',
6584
+ nullable: true
5441
6585
  },
5442
6586
  income: {
5443
6587
  type: 'string',
5444
- description: 'Default income account',
5445
- example: 'Income:Uncategorized'
6588
+ description:
6589
+ 'Default OPEN income account (MRU when multiple), or null when none/ambiguous',
6590
+ example: 'Income:Salary',
6591
+ nullable: true
5446
6592
  },
5447
6593
  liability: {
5448
6594
  type: 'string',
5449
- description: 'Default liability account',
5450
- example: 'Liabilities:CreditCard'
6595
+ description:
6596
+ 'Default OPEN liability account (MRU when multiple), or null when none/ambiguous',
6597
+ example: 'Liabilities:CreditCard',
6598
+ nullable: true
5451
6599
  }
5452
6600
  },
5453
6601
  required: ['asset', 'expense', 'income', 'liability']
@@ -5472,7 +6620,8 @@ export const $NlpResponseDto = {
5472
6620
  'confirm_rule',
5473
6621
  'confirm_account',
5474
6622
  'confirm_payee',
5475
- 'cancel'
6623
+ 'cancel',
6624
+ 'aborted'
5476
6625
  ]
5477
6626
  },
5478
6627
  intent: {
@@ -5632,43 +6781,304 @@ export const $NlpResponseDto = {
5632
6781
  }
5633
6782
  ]
5634
6783
  },
5635
- suggestedAccounts: {
5636
- description:
5637
- 'Suggested accounts for this transaction. Contains recommended source and destination accounts based on the detected intent and rules.',
5638
- allOf: [
5639
- {
5640
- $ref: '#/components/schemas/NlpSuggestedAccountsDto'
5641
- }
5642
- ]
6784
+ suggestedAccounts: {
6785
+ description:
6786
+ 'Suggested accounts for this transaction (#586). confirm/confirm_rule/confirm_account: predicted (source/destination carry confidence); created: actual persisted accounts (confidence omitted). confirm_account destination is the suggested replacement, never the invalid account.',
6787
+ allOf: [
6788
+ {
6789
+ $ref: '#/components/schemas/NlpSuggestedAccountsDto'
6790
+ }
6791
+ ]
6792
+ },
6793
+ defaultAccounts: {
6794
+ description:
6795
+ 'Default fallback accounts for the user/region (#586). v1 returns universal constants; per-user personalization is planned.',
6796
+ allOf: [
6797
+ {
6798
+ $ref: '#/components/schemas/NlpDefaultAccountsDto'
6799
+ }
6800
+ ]
6801
+ }
6802
+ },
6803
+ required: ['status', 'action']
6804
+ } as const;
6805
+
6806
+ export const $PlatformListItemDto = {
6807
+ type: 'object',
6808
+ properties: {
6809
+ id: {
6810
+ type: 'string',
6811
+ description: 'Global platform ID'
6812
+ },
6813
+ name: {
6814
+ type: 'string',
6815
+ description: 'Platform name'
6816
+ },
6817
+ url: {
6818
+ type: 'string',
6819
+ description: 'Platform URL'
6820
+ },
6821
+ type: {
6822
+ type: 'string',
6823
+ description: 'Platform type',
6824
+ enum: [
6825
+ 'BANK',
6826
+ 'BROKERAGE',
6827
+ 'CRYPTO_EXCHANGE',
6828
+ 'PAYMENT',
6829
+ 'INVESTMENT',
6830
+ 'INSURANCE',
6831
+ 'OTHER'
6832
+ ]
6833
+ },
6834
+ canonical: {
6835
+ type: 'string',
6836
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6837
+ },
6838
+ suggestedSegment: {
6839
+ type: 'string',
6840
+ description:
6841
+ 'Suggested path segment — PascalCase of canonical, hyphens removed (e.g. "ApplePay")'
6842
+ },
6843
+ logoUrl: {
6844
+ type: 'string',
6845
+ description: 'Logo URL',
6846
+ nullable: true
6847
+ },
6848
+ countryCode: {
6849
+ type: 'string',
6850
+ description: 'ISO 3166-1 alpha-2 (UPPERCASE); null = global platform',
6851
+ example: 'CN',
6852
+ nullable: true
6853
+ },
6854
+ category: {
6855
+ type: 'string',
6856
+ description:
6857
+ 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank). null = no region-aware suggestion; fall back to type.',
6858
+ nullable: true,
6859
+ example: 'DigitalWallet'
6860
+ },
6861
+ isBound: {
6862
+ type: 'boolean',
6863
+ description: 'Whether user has accounts using this platform'
6864
+ }
6865
+ },
6866
+ required: [
6867
+ 'id',
6868
+ 'name',
6869
+ 'url',
6870
+ 'type',
6871
+ 'canonical',
6872
+ 'suggestedSegment',
6873
+ 'logoUrl',
6874
+ 'countryCode',
6875
+ 'category',
6876
+ 'isBound'
6877
+ ]
6878
+ } as const;
6879
+
6880
+ export const $PlatformMatchResultDto = {
6881
+ type: 'object',
6882
+ properties: {
6883
+ id: {
6884
+ type: 'string',
6885
+ description: 'Global platform ID'
6886
+ },
6887
+ name: {
6888
+ type: 'string',
6889
+ description: 'Platform name (e.g., "ICBC")'
6890
+ },
6891
+ canonical: {
6892
+ type: 'string',
6893
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6894
+ },
6895
+ type: {
6896
+ type: 'string',
6897
+ description: 'Platform type',
6898
+ enum: [
6899
+ 'BANK',
6900
+ 'BROKERAGE',
6901
+ 'CRYPTO_EXCHANGE',
6902
+ 'PAYMENT',
6903
+ 'INVESTMENT',
6904
+ 'INSURANCE',
6905
+ 'OTHER'
6906
+ ]
6907
+ },
6908
+ suggestedSegment: {
6909
+ type: 'string',
6910
+ description:
6911
+ 'Suggested path segment — PascalCase of canonical, hyphens removed (e.g. "ApplePay")'
6912
+ },
6913
+ logoUrl: {
6914
+ type: 'string',
6915
+ description: 'Logo URL',
6916
+ nullable: true
6917
+ },
6918
+ countryCode: {
6919
+ type: 'string',
6920
+ description: 'ISO 3166-1 alpha-2 (UPPERCASE); null = global platform',
6921
+ example: 'CN',
6922
+ nullable: true
6923
+ },
6924
+ category: {
6925
+ type: 'string',
6926
+ description:
6927
+ 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank). null = no region-aware suggestion; fall back to type.',
6928
+ nullable: true,
6929
+ example: 'DigitalWallet'
6930
+ },
6931
+ matchType: {
6932
+ type: 'string',
6933
+ description: "How this row matched: 'exact' > 'prefix' > 'substring'",
6934
+ enum: ['exact', 'prefix', 'substring']
6935
+ }
6936
+ },
6937
+ required: [
6938
+ 'id',
6939
+ 'name',
6940
+ 'canonical',
6941
+ 'type',
6942
+ 'suggestedSegment',
6943
+ 'logoUrl',
6944
+ 'countryCode',
6945
+ 'category',
6946
+ 'matchType'
6947
+ ]
6948
+ } as const;
6949
+
6950
+ export const $PlatformMatchResponseDto = {
6951
+ type: 'object',
6952
+ properties: {
6953
+ platforms: {
6954
+ description: 'Ranked matches, best tier first (at most 10 rows)',
6955
+ type: 'array',
6956
+ items: {
6957
+ $ref: '#/components/schemas/PlatformMatchResultDto'
6958
+ }
6959
+ },
6960
+ matchType: {
6961
+ type: 'string',
6962
+ description:
6963
+ "Overall match quality — top row's tier, or 'none' when no hits",
6964
+ enum: ['none', 'exact', 'prefix', 'substring']
6965
+ },
6966
+ total: {
6967
+ type: 'number',
6968
+ description: 'Total matches before LIMIT (truncation transparency)'
6969
+ },
6970
+ hasMore: {
6971
+ type: 'boolean',
6972
+ description: 'true when total > platforms.length (more matches exist)'
6973
+ }
6974
+ },
6975
+ required: ['platforms', 'matchType', 'total', 'hasMore']
6976
+ } as const;
6977
+
6978
+ export const $CreatePlatformDto = {
6979
+ type: 'object',
6980
+ properties: {
6981
+ name: {
6982
+ type: 'string',
6983
+ description: 'Platform name',
6984
+ example: 'Binance'
6985
+ },
6986
+ canonical: {
6987
+ type: 'string',
6988
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6989
+ example: 'binance'
6990
+ },
6991
+ aliases: {
6992
+ description: 'Platform aliases (multi-language names for lookup)',
6993
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6994
+ type: 'array',
6995
+ items: {
6996
+ type: 'string'
6997
+ }
6998
+ },
6999
+ url: {
7000
+ type: 'string',
7001
+ description: 'Platform URL',
7002
+ example: 'https://www.binance.com'
7003
+ },
7004
+ type: {
7005
+ type: 'string',
7006
+ description: 'Platform type',
7007
+ enum: [
7008
+ 'BANK',
7009
+ 'BROKERAGE',
7010
+ 'CRYPTO_EXCHANGE',
7011
+ 'PAYMENT',
7012
+ 'INVESTMENT',
7013
+ 'INSURANCE',
7014
+ 'OTHER'
7015
+ ],
7016
+ example: 'CRYPTO_EXCHANGE'
7017
+ },
7018
+ logoUrl: {
7019
+ type: 'string',
7020
+ description: 'Platform logo URL',
7021
+ example: 'https://example.com/logos/binance.png'
5643
7022
  },
5644
- defaultAccounts: {
5645
- description:
5646
- 'Default accounts for the user/region. These are fallback accounts used when no specific suggestion is available.',
5647
- allOf: [
5648
- {
5649
- $ref: '#/components/schemas/NlpDefaultAccountsDto'
5650
- }
5651
- ]
7023
+ isActive: {
7024
+ type: 'boolean',
7025
+ description: 'Whether the platform is active',
7026
+ default: true
5652
7027
  }
5653
7028
  },
5654
- required: ['status', 'action']
7029
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
5655
7030
  } as const;
5656
7031
 
5657
- export const $BalanceByCurrencyDto = {
7032
+ export const $UpdatePlatformDto = {
5658
7033
  type: 'object',
5659
7034
  properties: {
5660
- currency: {
7035
+ name: {
5661
7036
  type: 'string',
5662
- description: 'ISO 4217 currency code',
5663
- example: 'CNY'
7037
+ description: 'Platform name',
7038
+ example: 'Binance'
5664
7039
  },
5665
- balance: {
7040
+ canonical: {
5666
7041
  type: 'string',
5667
- description: 'Balance amount',
5668
- example: '50000.00'
7042
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
7043
+ example: 'binance'
7044
+ },
7045
+ aliases: {
7046
+ description: 'Platform aliases (multi-language names for lookup)',
7047
+ example: ['Binance', 'Binance Exchange', 'BNB'],
7048
+ type: 'array',
7049
+ items: {
7050
+ type: 'string'
7051
+ }
7052
+ },
7053
+ url: {
7054
+ type: 'string',
7055
+ description: 'Platform URL',
7056
+ example: 'https://www.binance.com'
7057
+ },
7058
+ type: {
7059
+ type: 'string',
7060
+ description: 'Platform type',
7061
+ enum: [
7062
+ 'BANK',
7063
+ 'BROKERAGE',
7064
+ 'CRYPTO_EXCHANGE',
7065
+ 'PAYMENT',
7066
+ 'INVESTMENT',
7067
+ 'INSURANCE',
7068
+ 'OTHER'
7069
+ ],
7070
+ example: 'CRYPTO_EXCHANGE'
7071
+ },
7072
+ logoUrl: {
7073
+ type: 'string',
7074
+ description: 'Platform logo URL',
7075
+ example: 'https://example.com/logos/binance.png'
7076
+ },
7077
+ isActive: {
7078
+ type: 'boolean',
7079
+ description: 'Whether the platform is active'
5669
7080
  }
5670
- },
5671
- required: ['currency', 'balance']
7081
+ }
5672
7082
  } as const;
5673
7083
 
5674
7084
  export const $NetWorthByCurrencyDto = {
@@ -5740,28 +7150,6 @@ export const $ConvertedNetWorthDto = {
5740
7150
  ]
5741
7151
  } as const;
5742
7152
 
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'
5760
- }
5761
- },
5762
- required: ['type', 'currency', 'totalAmount']
5763
- } as const;
5764
-
5765
7153
  export const $NetWorthResponseDto = {
5766
7154
  type: 'object',
5767
7155
  properties: {
@@ -5847,7 +7235,7 @@ export const $AccountItemDto = {
5847
7235
  name: {
5848
7236
  type: 'string',
5849
7237
  description: 'Full account name',
5850
- example: 'Assets:Bank:CMB:Savings'
7238
+ example: 'Assets:CN:CMB:Savings'
5851
7239
  },
5852
7240
  displayName: {
5853
7241
  type: 'string',
@@ -5863,6 +7251,12 @@ export const $AccountItemDto = {
5863
7251
  type: 'string',
5864
7252
  description: 'Currency code',
5865
7253
  example: 'CNY'
7254
+ },
7255
+ convertedBalance: {
7256
+ type: 'string',
7257
+ description:
7258
+ 'FX-converted balance in base currency; omitted when not convertible',
7259
+ example: '50000.00'
5866
7260
  }
5867
7261
  },
5868
7262
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -5889,11 +7283,66 @@ export const $PlatformGroupDto = {
5889
7283
  },
5890
7284
  totalBalance: {
5891
7285
  type: 'string',
5892
- description: 'Total balance across all accounts in platform',
7286
+ description: 'FX-converted total balance in base currency',
7287
+ example: '100000.00'
7288
+ },
7289
+ balanceByCurrency: {
7290
+ description: 'Raw (unconverted) balances grouped by currency',
7291
+ type: 'array',
7292
+ items: {
7293
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7294
+ }
7295
+ },
7296
+ convertedBalance: {
7297
+ type: 'string',
7298
+ description:
7299
+ 'Converted balance in base currency (omitted when no currency is convertible)',
5893
7300
  example: '100000.00'
7301
+ },
7302
+ sharePct: {
7303
+ type: 'number',
7304
+ description:
7305
+ 'Share of the grand converted total (0-100); 0 when grand total is 0',
7306
+ example: 42.5
7307
+ }
7308
+ },
7309
+ required: [
7310
+ 'platformId',
7311
+ 'platformName',
7312
+ 'accounts',
7313
+ 'totalBalance',
7314
+ 'balanceByCurrency',
7315
+ 'sharePct'
7316
+ ]
7317
+ } as const;
7318
+
7319
+ export const $AccountExchangeRateWarningDto = {
7320
+ type: 'object',
7321
+ properties: {
7322
+ type: {
7323
+ type: 'string',
7324
+ description: 'Warning type',
7325
+ example: 'MISSING_EXCHANGE_RATE'
7326
+ },
7327
+ currency: {
7328
+ type: 'string',
7329
+ description: 'Currency without exchange rate',
7330
+ example: 'USD'
7331
+ },
7332
+ accounts: {
7333
+ description: 'Affected account paths',
7334
+ type: 'array',
7335
+ items: {
7336
+ type: 'string'
7337
+ }
7338
+ },
7339
+ totalAmount: {
7340
+ type: 'string',
7341
+ description: 'Total amount in this currency',
7342
+ example: '5000.00'
5894
7343
  }
5895
7344
  },
5896
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
7345
+ required: ['type', 'currency', 'accounts', 'totalAmount']
5897
7346
  } as const;
5898
7347
 
5899
7348
  export const $AccountsSummaryDto = {
@@ -5906,9 +7355,21 @@ export const $AccountsSummaryDto = {
5906
7355
  totalPlatforms: {
5907
7356
  type: 'number',
5908
7357
  description: 'Total number of platforms'
7358
+ },
7359
+ baseCurrency: {
7360
+ type: 'string',
7361
+ description: 'Base currency for conversion',
7362
+ example: 'CNY'
7363
+ },
7364
+ warnings: {
7365
+ description: 'Per-account exchange rate warnings',
7366
+ type: 'array',
7367
+ items: {
7368
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
7369
+ }
5909
7370
  }
5910
7371
  },
5911
- required: ['totalAccounts', 'totalPlatforms']
7372
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
5912
7373
  } as const;
5913
7374
 
5914
7375
  export const $AccountsResponseDto = {
@@ -5943,7 +7404,7 @@ export const $AccountItemWithAssetClassDto = {
5943
7404
  name: {
5944
7405
  type: 'string',
5945
7406
  description: 'Full account name',
5946
- example: 'Assets:Bank:CMB:Savings'
7407
+ example: 'Assets:CN:CMB:Savings'
5947
7408
  },
5948
7409
  displayName: {
5949
7410
  type: 'string',
@@ -5960,6 +7421,12 @@ export const $AccountItemWithAssetClassDto = {
5960
7421
  description: 'Currency code',
5961
7422
  example: 'CNY'
5962
7423
  },
7424
+ convertedBalance: {
7425
+ type: 'string',
7426
+ description:
7427
+ 'FX-converted balance in base currency; omitted when not convertible',
7428
+ example: '50000.00'
7429
+ },
5963
7430
  assetClass: {
5964
7431
  type: 'string',
5965
7432
  description: 'Asset class',
@@ -5979,6 +7446,12 @@ export const $AccountItemWithAssetClassDto = {
5979
7446
  type: 'string',
5980
7447
  description: 'Risk level',
5981
7448
  example: 'LOW'
7449
+ },
7450
+ source: {
7451
+ type: 'string',
7452
+ description:
7453
+ 'ADR-0105 classification provenance (holding level always; account level only on FALLBACK)',
7454
+ enum: ['USER_META', 'FIAT_CURRENCY', 'OPENBB_MAPPING', 'FALLBACK']
5982
7455
  }
5983
7456
  },
5984
7457
  required: ['id', 'name', 'displayName', 'balance', 'currency', 'assetClass']
@@ -6033,82 +7506,154 @@ export const $AssetClassGroupDto = {
6033
7506
  required: ['assetClass', 'accounts', 'balanceByCurrency']
6034
7507
  } as const;
6035
7508
 
6036
- export const $AccountExchangeRateWarningDto = {
7509
+ export const $AssetClassSummaryDto = {
6037
7510
  type: 'object',
6038
7511
  properties: {
6039
- type: {
6040
- type: 'string',
6041
- description: 'Warning type',
6042
- example: 'MISSING_EXCHANGE_RATE'
7512
+ totalAccounts: {
7513
+ type: 'number',
7514
+ description: 'Total number of accounts'
6043
7515
  },
6044
- currency: {
7516
+ totalAssetClasses: {
7517
+ type: 'number',
7518
+ description: 'Total number of asset classes'
7519
+ },
7520
+ baseCurrency: {
6045
7521
  type: 'string',
6046
- description: 'Currency without exchange rate',
6047
- example: 'USD'
7522
+ description: 'Base currency for conversion',
7523
+ example: 'CNY'
6048
7524
  },
6049
- accounts: {
6050
- description: 'Affected account paths',
7525
+ warnings: {
7526
+ description: 'Exchange rate warnings',
6051
7527
  type: 'array',
6052
7528
  items: {
6053
- type: 'string'
7529
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
6054
7530
  }
6055
7531
  },
6056
- totalAmount: {
6057
- type: 'string',
6058
- description: 'Total amount in this currency',
6059
- example: '5000.00'
7532
+ fallback: {
7533
+ type: 'object',
7534
+ description:
7535
+ '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.'
6060
7536
  }
6061
7537
  },
6062
- required: ['type', 'currency', 'accounts', 'totalAmount']
7538
+ required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
6063
7539
  } as const;
6064
7540
 
6065
- export const $AssetClassSummaryDto = {
7541
+ export const $AssetClassAccountsResponseDto = {
6066
7542
  type: 'object',
6067
7543
  properties: {
6068
- totalAccounts: {
6069
- type: 'number',
6070
- description: 'Total number of accounts'
7544
+ groups: {
7545
+ description: 'Account groups by asset class',
7546
+ type: 'array',
7547
+ items: {
7548
+ $ref: '#/components/schemas/AssetClassGroupDto'
7549
+ }
7550
+ },
7551
+ summary: {
7552
+ description: 'Summary statistics',
7553
+ allOf: [
7554
+ {
7555
+ $ref: '#/components/schemas/AssetClassSummaryDto'
7556
+ }
7557
+ ]
7558
+ },
7559
+ uncategorized: {
7560
+ description:
7561
+ 'ADR-0105 §6 holding-level grey-area bucket (source=FALLBACK holdings peeled out of groups). Present only for groupBy=holdingAssetClass when FALLBACK holdings exist.',
7562
+ allOf: [
7563
+ {
7564
+ $ref: '#/components/schemas/AssetClassGroupDto'
7565
+ }
7566
+ ]
7567
+ }
7568
+ },
7569
+ required: ['groups', 'summary']
7570
+ } as const;
7571
+
7572
+ export const $HoldingAssetClassAccountSliceDto = {
7573
+ type: 'object',
7574
+ properties: {
7575
+ accountId: {
7576
+ type: 'string',
7577
+ description: 'Account ID'
7578
+ },
7579
+ accountPath: {
7580
+ type: 'string',
7581
+ description: 'Full account path',
7582
+ example: 'Assets:US:Fidelity:Brokerage'
7583
+ },
7584
+ accountCurrency: {
7585
+ type: 'string',
7586
+ description:
7587
+ 'Currency of the holding with the largest converted base value; undefined when no holding is convertible',
7588
+ example: 'USD'
7589
+ },
7590
+ marketValueBase: {
7591
+ type: 'string',
7592
+ description:
7593
+ "Account's market value in base currency (Σ converted holdings; grey bucket included)",
7594
+ example: '50000.00'
6071
7595
  },
6072
- totalAssetClasses: {
7596
+ shareOfTotalPct: {
6073
7597
  type: 'number',
6074
- description: 'Total number of asset classes'
7598
+ description:
7599
+ 'Share of the global total (0-100). 0 when globalTotal is zero (no NaN/Infinity).',
7600
+ example: 42.5
6075
7601
  },
6076
- baseCurrency: {
6077
- type: 'string',
6078
- description: 'Base currency for conversion',
6079
- example: 'CNY'
7602
+ groups: {
7603
+ description: 'Per-account asset-class breakdown',
7604
+ type: 'array',
7605
+ items: {
7606
+ $ref: '#/components/schemas/AssetClassGroupDto'
7607
+ }
6080
7608
  },
6081
- warnings: {
6082
- description: 'Exchange rate warnings',
7609
+ uncategorized: {
7610
+ description:
7611
+ 'Per-account grey bucket (source=FALLBACK holdings, incl. broker cash)',
7612
+ allOf: [
7613
+ {
7614
+ $ref: '#/components/schemas/AssetClassGroupDto'
7615
+ }
7616
+ ]
7617
+ },
7618
+ holdings: {
7619
+ description:
7620
+ 'Every holding row for this account (account ID in each row’s `id` field)',
6083
7621
  type: 'array',
6084
7622
  items: {
6085
- $ref: '#/components/schemas/AccountExchangeRateWarningDto'
7623
+ $ref: '#/components/schemas/AccountItemWithAssetClassDto'
6086
7624
  }
6087
7625
  }
6088
7626
  },
6089
- required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
7627
+ required: [
7628
+ 'accountId',
7629
+ 'accountPath',
7630
+ 'marketValueBase',
7631
+ 'shareOfTotalPct',
7632
+ 'groups',
7633
+ 'holdings'
7634
+ ]
6090
7635
  } as const;
6091
7636
 
6092
- export const $AssetClassAccountsResponseDto = {
7637
+ export const $HoldingAssetClassCrossAccountResponseDto = {
6093
7638
  type: 'object',
6094
7639
  properties: {
6095
- groups: {
6096
- description: 'Account groups by asset class',
6097
- type: 'array',
6098
- items: {
6099
- $ref: '#/components/schemas/AssetClassGroupDto'
6100
- }
6101
- },
6102
- summary: {
6103
- description: 'Summary statistics',
7640
+ global: {
7641
+ description: 'Merged cross-account holding aggregation',
6104
7642
  allOf: [
6105
7643
  {
6106
- $ref: '#/components/schemas/AssetClassSummaryDto'
7644
+ $ref: '#/components/schemas/AssetClassAccountsResponseDto'
6107
7645
  }
6108
7646
  ]
7647
+ },
7648
+ byAccount: {
7649
+ description: 'Per-account slices',
7650
+ type: 'array',
7651
+ items: {
7652
+ $ref: '#/components/schemas/HoldingAssetClassAccountSliceDto'
7653
+ }
6109
7654
  }
6110
7655
  },
6111
- required: ['groups', 'summary']
7656
+ required: ['global', 'byAccount']
6112
7657
  } as const;
6113
7658
 
6114
7659
  export const $CashFlowByCurrencyDto = {
@@ -6210,207 +7755,582 @@ export const $CashFlowResponseDto = {
6210
7755
  description: 'Cash flow grouped by original currency',
6211
7756
  allOf: [
6212
7757
  {
6213
- $ref: '#/components/schemas/CashFlowByCurrencyDto'
7758
+ $ref: '#/components/schemas/CashFlowByCurrencyDto'
7759
+ }
7760
+ ]
7761
+ },
7762
+ converted: {
7763
+ description: 'Converted values in base currency',
7764
+ allOf: [
7765
+ {
7766
+ $ref: '#/components/schemas/ConvertedCashFlowDto'
7767
+ }
7768
+ ]
7769
+ },
7770
+ warnings: {
7771
+ description: 'Exchange rate warnings',
7772
+ type: 'array',
7773
+ items: {
7774
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7775
+ }
7776
+ }
7777
+ },
7778
+ required: [
7779
+ 'period',
7780
+ 'income',
7781
+ 'expense',
7782
+ 'netSavings',
7783
+ 'savingsRate',
7784
+ 'currency'
7785
+ ]
7786
+ } as const;
7787
+
7788
+ export const $CategoryGroupDto = {
7789
+ type: 'object',
7790
+ properties: {
7791
+ category: {
7792
+ type: 'string',
7793
+ description:
7794
+ 'Functional category (account-path Group segment); regional and universal account paths merge under it',
7795
+ example: 'Food'
7796
+ },
7797
+ totalExpense: {
7798
+ type: 'string',
7799
+ description:
7800
+ 'Converted total for this category in base currency (expense amount when flow=expense, income amount when flow=income)',
7801
+ example: '1200.00'
7802
+ },
7803
+ sharePct: {
7804
+ type: 'number',
7805
+ description: 'Share of grand total (0-100); 0 when grand total is 0',
7806
+ example: 42.5
7807
+ },
7808
+ balanceByCurrency: {
7809
+ description: 'Raw (unconverted) expense per currency',
7810
+ type: 'array',
7811
+ items: {
7812
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7813
+ }
7814
+ },
7815
+ convertedBalance: {
7816
+ type: 'string',
7817
+ description:
7818
+ 'Converted total in base currency (omitted when FX missing for all currencies in this category)',
7819
+ example: '1200.00'
7820
+ }
7821
+ },
7822
+ required: ['category', 'totalExpense', 'sharePct', 'balanceByCurrency']
7823
+ } as const;
7824
+
7825
+ export const $ExpensesByCategorySummaryDto = {
7826
+ type: 'object',
7827
+ properties: {
7828
+ totalExpense: {
7829
+ type: 'string',
7830
+ description:
7831
+ 'Total across all categories, converted (convertible categories only); expense totals when flow=expense, income totals when flow=income',
7832
+ example: '5000.00'
7833
+ },
7834
+ categoryCount: {
7835
+ type: 'number',
7836
+ description: 'Number of categories',
7837
+ example: 8
7838
+ }
7839
+ },
7840
+ required: ['totalExpense', 'categoryCount']
7841
+ } as const;
7842
+
7843
+ export const $ExpensesByCategoryResponseDto = {
7844
+ type: 'object',
7845
+ properties: {
7846
+ period: {
7847
+ type: 'string',
7848
+ description: 'Period requested',
7849
+ example: '1m'
7850
+ },
7851
+ baseCurrency: {
7852
+ type: 'string',
7853
+ description: 'Base currency for converted values',
7854
+ example: 'CNY'
7855
+ },
7856
+ groups: {
7857
+ description:
7858
+ 'Expense groups by functional category, sorted by converted total desc',
7859
+ type: 'array',
7860
+ items: {
7861
+ $ref: '#/components/schemas/CategoryGroupDto'
7862
+ }
7863
+ },
7864
+ summary: {
7865
+ description: 'Summary statistics',
7866
+ allOf: [
7867
+ {
7868
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
7869
+ }
7870
+ ]
7871
+ },
7872
+ warnings: {
7873
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
7874
+ type: 'array',
7875
+ items: {
7876
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7877
+ }
7878
+ }
7879
+ },
7880
+ required: ['period', 'baseCurrency', 'groups', 'summary']
7881
+ } as const;
7882
+
7883
+ export const $MonetaryDto = {
7884
+ type: 'object',
7885
+ properties: {
7886
+ amount: {
7887
+ type: 'string',
7888
+ description: 'Amount (Decimal string)',
7889
+ example: '3000'
7890
+ },
7891
+ currency: {
7892
+ type: 'string',
7893
+ description: 'ISO 4217 currency',
7894
+ example: 'USD'
7895
+ },
7896
+ baseCcyEquivalent: {
7897
+ type: 'object',
7898
+ description: 'Converted to user base currency (Decimal string)',
7899
+ example: '21600',
7900
+ nullable: true
7901
+ }
7902
+ },
7903
+ required: ['amount', 'currency']
7904
+ } as const;
7905
+
7906
+ export const $CurrentPriceDto = {
7907
+ type: 'object',
7908
+ properties: {
7909
+ amount: {
7910
+ type: 'string',
7911
+ description: 'Price amount (Decimal string)',
7912
+ example: '250'
7913
+ },
7914
+ currency: {
7915
+ type: 'string',
7916
+ description: 'Price currency (ISO 4217)',
7917
+ example: 'USD'
7918
+ },
7919
+ date: {
7920
+ type: 'string',
7921
+ description: 'Price date (ISO 8601)',
7922
+ example: '2024-06-01'
7923
+ },
7924
+ source: {
7925
+ type: 'string',
7926
+ description: 'Price source',
7927
+ example: 'USER_OVERRIDE',
7928
+ enum: ['USER_OVERRIDE', 'OPENBB_EQUITY', 'OPENBB_CURRENCY']
7929
+ }
7930
+ },
7931
+ required: ['amount', 'currency', 'date', 'source']
7932
+ } as const;
7933
+
7934
+ export const $FxRateDto = {
7935
+ type: 'object',
7936
+ properties: {
7937
+ from: {
7938
+ type: 'string',
7939
+ example: 'USD'
7940
+ },
7941
+ to: {
7942
+ type: 'string',
7943
+ example: 'CNY'
7944
+ },
7945
+ rate: {
7946
+ type: 'string',
7947
+ description: 'FX rate (Decimal string)',
7948
+ example: '7.2'
7949
+ },
7950
+ date: {
7951
+ type: 'string',
7952
+ description: 'Rate date (ISO 8601)',
7953
+ example: '2024-01-15'
7954
+ }
7955
+ },
7956
+ required: ['from', 'to', 'rate', 'date']
7957
+ } as const;
7958
+
7959
+ export const $HoldingPnlRowDto = {
7960
+ type: 'object',
7961
+ properties: {
7962
+ accountId: {
7963
+ type: 'string',
7964
+ description: 'Account UUID',
7965
+ example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
7966
+ },
7967
+ accountPath: {
7968
+ type: 'string',
7969
+ description: 'Full account path',
7970
+ example: 'Assets:US:Broker:AAPL'
7971
+ },
7972
+ accountCcy: {
7973
+ type: 'object',
7974
+ description: 'Account settlement currency (ISO 4217), from cost currency',
7975
+ nullable: true,
7976
+ example: 'USD'
7977
+ },
7978
+ brokerType: {
7979
+ type: 'object',
7980
+ description: 'Broker type derived from Platform.type',
7981
+ nullable: true,
7982
+ example: 'broker'
7983
+ },
7984
+ symbol: {
7985
+ type: 'string',
7986
+ description: 'Commodity symbol',
7987
+ example: 'AAPL'
7988
+ },
7989
+ chartToken: {
7990
+ type: 'string',
7991
+ description: 'Chart segment token (libs/common resolver)',
7992
+ example: 'equity',
7993
+ enum: ['equity', 'fund', 'bond', 'cash', 'other']
7994
+ },
7995
+ assetClass: {
7996
+ type: 'string',
7997
+ example: 'EQUITY'
7998
+ },
7999
+ assetSubClass: {
8000
+ type: 'object',
8001
+ nullable: true,
8002
+ example: 'STOCK'
8003
+ },
8004
+ units: {
8005
+ type: 'string',
8006
+ description: 'Net held units (Decimal string)',
8007
+ example: '12'
8008
+ },
8009
+ averageCostPerUnit: {
8010
+ description:
8011
+ 'Average cost per unit; null when cost currency conflicts or no cost',
8012
+ nullable: true,
8013
+ allOf: [
8014
+ {
8015
+ $ref: '#/components/schemas/MonetaryDto'
8016
+ }
8017
+ ]
8018
+ },
8019
+ costBasis: {
8020
+ description: 'Cost basis of held units',
8021
+ nullable: true,
8022
+ allOf: [
8023
+ {
8024
+ $ref: '#/components/schemas/MonetaryDto'
8025
+ }
8026
+ ]
8027
+ },
8028
+ marketValue: {
8029
+ description: 'Market value at asOf price',
8030
+ nullable: true,
8031
+ allOf: [
8032
+ {
8033
+ $ref: '#/components/schemas/MonetaryDto'
8034
+ }
8035
+ ]
8036
+ },
8037
+ currentPrice: {
8038
+ description: 'Price used for market value',
8039
+ nullable: true,
8040
+ allOf: [
8041
+ {
8042
+ $ref: '#/components/schemas/CurrentPriceDto'
8043
+ }
8044
+ ]
8045
+ },
8046
+ unrealizedPnlBase: {
8047
+ type: 'object',
8048
+ description:
8049
+ 'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
8050
+ nullable: true,
8051
+ example: '6000'
8052
+ },
8053
+ unrealizedPnlPct: {
8054
+ type: 'object',
8055
+ description: 'Unrealized P&L % (Decimal string)',
8056
+ nullable: true,
8057
+ example: '25'
8058
+ },
8059
+ costFxRate: {
8060
+ description: 'Historical FX rate applied to cost basis',
8061
+ nullable: true,
8062
+ allOf: [
8063
+ {
8064
+ $ref: '#/components/schemas/FxRateDto'
6214
8065
  }
6215
8066
  ]
6216
8067
  },
6217
- converted: {
6218
- description: 'Converted values in base currency',
8068
+ marketFxRate: {
8069
+ description: 'FX rate applied to market value',
8070
+ nullable: true,
6219
8071
  allOf: [
6220
8072
  {
6221
- $ref: '#/components/schemas/ConvertedCashFlowDto'
8073
+ $ref: '#/components/schemas/FxRateDto'
6222
8074
  }
6223
8075
  ]
6224
8076
  },
6225
- warnings: {
6226
- description: 'Exchange rate warnings',
6227
- type: 'array',
6228
- items: {
6229
- $ref: '#/components/schemas/ExchangeRateWarningDto'
6230
- }
8077
+ pctOfInvestedAssets: {
8078
+ type: 'object',
8079
+ description:
8080
+ 'Share of invested assets % (Decimal string); only for invested chartTokens',
8081
+ nullable: true,
8082
+ example: '40'
8083
+ },
8084
+ realizedPnl: {
8085
+ description:
8086
+ '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',
8087
+ nullable: true,
8088
+ allOf: [
8089
+ {
8090
+ $ref: '#/components/schemas/MonetaryDto'
8091
+ }
8092
+ ]
6231
8093
  }
6232
8094
  },
6233
8095
  required: [
6234
- 'period',
6235
- 'income',
6236
- 'expense',
6237
- 'netSavings',
6238
- 'savingsRate',
6239
- 'currency'
8096
+ 'accountId',
8097
+ 'accountPath',
8098
+ 'symbol',
8099
+ 'chartToken',
8100
+ 'assetClass',
8101
+ 'units'
6240
8102
  ]
6241
8103
  } as const;
6242
8104
 
6243
- export const $CurrencyBalanceDto = {
8105
+ export const $HoldingPnlWarningDto = {
6244
8106
  type: 'object',
6245
8107
  properties: {
6246
- currency: {
8108
+ type: {
6247
8109
  type: 'string',
6248
- description: 'ISO 4217 currency code',
6249
- example: 'CNY'
8110
+ description: 'Warning type',
8111
+ example: 'MISSING_COST_FX_RATE',
8112
+ enum: [
8113
+ 'MISSING_COST_FX_RATE',
8114
+ 'MISSING_MARKET_FX_RATE',
8115
+ 'MISSING_SALE_PRICE',
8116
+ 'MISSING_REALIZED_FX_RATE',
8117
+ 'OVERSOLD_LOTS',
8118
+ 'NO_PRICE',
8119
+ 'MIXED_COST_CURRENCY'
8120
+ ]
6250
8121
  },
6251
- balance: {
6252
- type: 'string',
6253
- description: 'Balance amount',
6254
- example: '500000.00'
8122
+ symbol: {
8123
+ type: 'object',
8124
+ nullable: true
8125
+ },
8126
+ accountId: {
8127
+ type: 'object',
8128
+ nullable: true
8129
+ },
8130
+ currency: {
8131
+ type: 'object',
8132
+ nullable: true
6255
8133
  }
6256
8134
  },
6257
- required: ['currency', 'balance']
8135
+ required: ['type']
6258
8136
  } as const;
6259
8137
 
6260
- export const $TimeSeriesPointDto = {
8138
+ export const $HoldingPnlResponseDto = {
6261
8139
  type: 'object',
6262
8140
  properties: {
6263
- date: {
8141
+ asOfDate: {
6264
8142
  type: 'string',
6265
- description: 'Date in YYYY-MM-DD format',
6266
- example: '2024-06-15'
8143
+ example: '2026-07-08'
6267
8144
  },
6268
- value: {
8145
+ baseCurrency: {
6269
8146
  type: 'string',
6270
- description: 'Value at this date (in base currency)',
6271
- example: '500000.00'
8147
+ example: 'CNY'
6272
8148
  },
6273
- change: {
6274
- type: 'object',
6275
- description: 'Change from previous point',
6276
- example: '5000.00'
8149
+ method: {
8150
+ type: 'string',
8151
+ description:
8152
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
8153
+ enum: ['average', 'FIFO'],
8154
+ example: 'average'
6277
8155
  },
6278
- byCurrency: {
6279
- description: 'Multi-currency breakdown for this point',
8156
+ rows: {
6280
8157
  type: 'array',
6281
8158
  items: {
6282
- $ref: '#/components/schemas/CurrencyBalanceDto'
8159
+ $ref: '#/components/schemas/HoldingPnlRowDto'
8160
+ }
8161
+ },
8162
+ warnings: {
8163
+ type: 'array',
8164
+ items: {
8165
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
6283
8166
  }
6284
8167
  }
6285
8168
  },
6286
- required: ['date', 'value']
8169
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6287
8170
  } as const;
6288
8171
 
6289
- export const $TrendSummaryDto = {
8172
+ export const $AnonymousLoginDto = {
6290
8173
  type: 'object',
6291
8174
  properties: {
6292
- startValue: {
6293
- type: 'string',
6294
- description: 'Value at start of period',
6295
- example: '450000.00'
6296
- },
6297
- endValue: {
6298
- type: 'string',
6299
- description: 'Value at end of period',
6300
- example: '500000.00'
6301
- },
6302
- totalChange: {
6303
- type: 'string',
6304
- description: 'Total change over period',
6305
- example: '50000.00'
6306
- },
6307
- totalChangePercentage: {
8175
+ accessToken: {
6308
8176
  type: 'string',
6309
- description: 'Total change percentage',
6310
- example: '+11.11%'
8177
+ description: 'Access token for anonymous login'
6311
8178
  }
6312
8179
  },
6313
- required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
8180
+ required: ['accessToken']
6314
8181
  } as const;
6315
8182
 
6316
- export const $MultiCurrencyPointDto = {
8183
+ export const $AnonymousLoginResponseDto = {
6317
8184
  type: 'object',
6318
8185
  properties: {
6319
- date: {
8186
+ authToken: {
6320
8187
  type: 'string',
6321
- description: 'Date in YYYY-MM-DD format',
6322
- example: '2024-06-15'
6323
- },
6324
- byCurrency: {
6325
- description: 'Balances by currency',
6326
- type: 'array',
6327
- items: {
6328
- $ref: '#/components/schemas/CurrencyBalanceDto'
6329
- }
8188
+ description: 'JWT auth token',
8189
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
6330
8190
  }
6331
8191
  },
6332
- required: ['date', 'byCurrency']
8192
+ required: ['authToken']
6333
8193
  } as const;
6334
8194
 
6335
- export const $PortfolioTrendsResponseDto = {
8195
+ export const $SymbolSearchResultDto = {
6336
8196
  type: 'object',
6337
8197
  properties: {
6338
- series: {
6339
- description: 'Time series data points',
6340
- type: 'array',
6341
- items: {
6342
- $ref: '#/components/schemas/TimeSeriesPointDto'
6343
- }
8198
+ symbol: {
8199
+ type: 'string',
8200
+ example: 'AAPL'
6344
8201
  },
6345
- summary: {
6346
- description: 'Period summary',
6347
- allOf: [
6348
- {
6349
- $ref: '#/components/schemas/TrendSummaryDto'
6350
- }
6351
- ]
8202
+ name: {
8203
+ type: 'object',
8204
+ example: 'Apple Inc.',
8205
+ nullable: true
6352
8206
  },
6353
- period: {
6354
- type: 'string',
6355
- description: 'Period requested',
6356
- example: '6m'
8207
+ exchange: {
8208
+ type: 'object',
8209
+ example: 'US',
8210
+ nullable: true
6357
8211
  },
6358
- granularity: {
6359
- type: 'string',
6360
- description: 'Data granularity',
6361
- example: 'month'
8212
+ assetType: {
8213
+ type: 'object',
8214
+ description: 'OpenBB asset_type (e.g. stock, etf)',
8215
+ example: 'stock',
8216
+ nullable: true
6362
8217
  },
6363
- currency: {
6364
- type: 'string',
6365
- description: 'Base currency for converted values',
6366
- example: 'CNY'
8218
+ assetClass: {
8219
+ type: 'object',
8220
+ description: 'IGN asset class (region.types.ts ASSET_CLASSES)',
8221
+ example: 'EQUITY',
8222
+ nullable: true
6367
8223
  },
6368
- byCurrency: {
6369
- description:
6370
- 'Multi-currency time series (each point has currency breakdown)',
6371
- type: 'array',
6372
- items: {
6373
- $ref: '#/components/schemas/MultiCurrencyPointDto'
6374
- }
8224
+ assetSubClass: {
8225
+ type: 'object',
8226
+ description: 'IGN asset sub-class (region.types.ts ASSET_SUB_CLASSES)',
8227
+ example: 'STOCK',
8228
+ nullable: true
6375
8229
  },
6376
- warnings: {
6377
- description: 'Exchange rate warnings',
6378
- type: 'array',
6379
- items: {
6380
- $ref: '#/components/schemas/ExchangeRateWarningDto'
6381
- }
8230
+ currency: {
8231
+ type: 'object',
8232
+ description: 'Trading currency (extra_data or inferred from exchange)',
8233
+ example: 'USD',
8234
+ nullable: true
6382
8235
  }
6383
8236
  },
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: {}
8237
+ required: ['symbol']
6405
8238
  } as const;
6406
8239
 
6407
- export const $AnonymousLoginDto = {
8240
+ export const $SymbolQuoteDto = {
6408
8241
  type: 'object',
6409
8242
  properties: {
6410
- accessToken: {
8243
+ symbol: {
6411
8244
  type: 'string',
6412
- description: 'Access token for anonymous login'
8245
+ example: 'AAPL'
8246
+ },
8247
+ name: {
8248
+ type: 'object',
8249
+ example: 'Apple Inc.',
8250
+ nullable: true
8251
+ },
8252
+ exchange: {
8253
+ type: 'object',
8254
+ example: 'US',
8255
+ nullable: true
8256
+ },
8257
+ assetType: {
8258
+ type: 'object',
8259
+ description: 'OpenBB asset_type',
8260
+ example: 'stock',
8261
+ nullable: true
8262
+ },
8263
+ assetClass: {
8264
+ type: 'object',
8265
+ description: 'IGN asset class',
8266
+ example: 'EQUITY',
8267
+ nullable: true
8268
+ },
8269
+ assetSubClass: {
8270
+ type: 'object',
8271
+ description: 'IGN asset sub-class',
8272
+ example: 'STOCK',
8273
+ nullable: true
8274
+ },
8275
+ currency: {
8276
+ type: 'object',
8277
+ description: 'Trading currency (extra_data or inferred from exchange)',
8278
+ example: 'USD',
8279
+ nullable: true
8280
+ },
8281
+ price: {
8282
+ type: 'object',
8283
+ description: 'Latest price (Decimal string)',
8284
+ example: '189.84',
8285
+ nullable: true
8286
+ },
8287
+ priceDate: {
8288
+ type: 'object',
8289
+ description: 'Date the price was observed (ISO yyyy-MM-dd)',
8290
+ example: '2026-08-05',
8291
+ nullable: true
8292
+ },
8293
+ changePercent: {
8294
+ type: 'object',
8295
+ description:
8296
+ 'Change vs previous close, in percentage points (1.7 == 1.7%). openbb stores change_percent as a normalized decimal; this exposes percentage points for frontend convenience.',
8297
+ example: 1.7,
8298
+ nullable: true
8299
+ },
8300
+ prevClose: {
8301
+ type: 'object',
8302
+ description: 'Previous close (Decimal string)',
8303
+ nullable: true
8304
+ },
8305
+ open: {
8306
+ type: 'object',
8307
+ description: 'Day open (Decimal string)',
8308
+ nullable: true
8309
+ },
8310
+ high: {
8311
+ type: 'object',
8312
+ description: 'Day high (Decimal string)',
8313
+ nullable: true
8314
+ },
8315
+ low: {
8316
+ type: 'object',
8317
+ description: 'Day low (Decimal string)',
8318
+ nullable: true
8319
+ },
8320
+ volume: {
8321
+ type: 'object',
8322
+ description: 'Day volume (Decimal string)',
8323
+ nullable: true
8324
+ },
8325
+ yearHigh: {
8326
+ type: 'object',
8327
+ description: '52-week high (Decimal string)',
8328
+ nullable: true
8329
+ },
8330
+ yearLow: {
8331
+ type: 'object',
8332
+ description: '52-week low (Decimal string)',
8333
+ nullable: true
6413
8334
  }
6414
- },
6415
- required: ['accessToken']
8335
+ }
6416
8336
  } as const;