@firela/api-types 0.0.0-canary.a85ace93 → 0.0.0-canary.a9f0aa08

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,18 +6,12 @@ export const $CreateAccountDto = {
6
6
  path: {
7
7
  type: 'string',
8
8
  description: 'Account path (hierarchical, colon-separated)',
9
- example: 'Assets:CN:Bank:ICBC:Checking'
10
- },
11
- displayName: {
12
- type: 'string',
13
- description:
14
- 'Display name to distinguish accounts at the same path (default: "")',
15
- example: '工资卡'
9
+ example: 'Assets:CN:ICBC:Checking'
16
10
  },
17
11
  openDate: {
18
12
  format: 'date-time',
19
13
  type: 'string',
20
- description: 'Account open date',
14
+ description: 'Account open date (server defaults to today)',
21
15
  example: '2024-01-01'
22
16
  },
23
17
  currencies: {
@@ -45,26 +39,22 @@ export const $CreateAccountDto = {
45
39
  templatePath: {
46
40
  type: 'string',
47
41
  description: 'Reference to account-standards template path',
48
- example: 'Assets:CN:Bank:ICBC:Checking'
42
+ example: 'Assets:CN:Checking'
49
43
  },
50
44
  isCustom: {
51
45
  type: 'boolean',
52
46
  description: 'Whether this is a custom (user-created) account',
53
47
  default: false
54
48
  },
55
- i18nKey: {
56
- type: 'string',
57
- description: 'i18n key for display name (overrides template)',
58
- example: 'account.custom.mybank'
59
- },
60
49
  icon: {
61
50
  type: 'string',
62
51
  description: 'Icon identifier (overrides template)',
63
52
  example: 'bank-custom'
64
53
  },
65
- openMeta: {
54
+ openDirectiveMeta: {
66
55
  type: 'object',
67
- description: 'Additional metadata',
56
+ description:
57
+ 'Open directive metadata (NOT an opening-balance amount — use the opening-balance endpoint)',
68
58
  example: {
69
59
  branch: 'Downtown',
70
60
  accountNumber: '1234'
@@ -76,7 +66,7 @@ export const $CreateAccountDto = {
76
66
  example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
77
67
  }
78
68
  },
79
- required: ['path', 'openDate']
69
+ required: ['path']
80
70
  } as const;
81
71
 
82
72
  export const $AccountResponseDto = {
@@ -90,13 +80,7 @@ export const $AccountResponseDto = {
90
80
  path: {
91
81
  type: 'string',
92
82
  description: 'Account path (hierarchical, colon-separated)',
93
- example: 'Assets:CN:Bank:ICBC:Checking'
94
- },
95
- displayName: {
96
- type: 'string',
97
- description:
98
- 'Display name distinguishing multiple accounts at the same path',
99
- example: '工资卡'
83
+ example: 'Assets:CN:ICBC:Checking'
100
84
  },
101
85
  type: {
102
86
  type: 'string',
@@ -104,6 +88,47 @@ export const $AccountResponseDto = {
104
88
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
105
89
  example: 'Assets'
106
90
  },
91
+ assetSubClass: {
92
+ type: 'string',
93
+ description:
94
+ 'Account-level asset sub-class (product type, e.g. STOCK/DEPOSIT/CREDIT_CARD/PERSONAL_LOAN). Computed from the account path via the asset-classifier (ADR-0077). Null for non-asset accounts (Income/Expenses/Equity) or unmatched paths.',
95
+ enum: [
96
+ 'DEPOSIT',
97
+ 'CASH',
98
+ 'MONEY_MARKET_FUND',
99
+ 'STOCK',
100
+ 'ETF',
101
+ 'MUTUAL_FUND',
102
+ 'EQUITY_COMPENSATION',
103
+ 'GOVERNMENT_BOND',
104
+ 'CORPORATE_BOND',
105
+ 'BOND_FUND',
106
+ 'PRIMARY_RESIDENCE',
107
+ 'INVESTMENT_PROPERTY',
108
+ 'REIT',
109
+ 'GOLD',
110
+ 'SILVER',
111
+ 'PRECIOUS_METAL',
112
+ 'PRECIOUS_METAL_FUND',
113
+ 'COMMODITY',
114
+ 'COMMODITY_FUND',
115
+ 'CRYPTOCURRENCY',
116
+ 'RETIREMENT_ACCOUNT',
117
+ 'HEALTH_ACCOUNT',
118
+ 'EDUCATION_ACCOUNT',
119
+ 'INSURANCE',
120
+ 'PRIVATE_EQUITY',
121
+ 'HEDGE_FUND',
122
+ 'COLLECTIBLES',
123
+ 'MORTGAGE',
124
+ 'STUDENT_LOAN',
125
+ 'CREDIT_CARD',
126
+ 'PERSONAL_LOAN',
127
+ 'OTHER'
128
+ ],
129
+ nullable: true,
130
+ example: 'STOCK'
131
+ },
107
132
  status: {
108
133
  type: 'string',
109
134
  description: 'Account status',
@@ -145,26 +170,26 @@ export const $AccountResponseDto = {
145
170
  templatePath: {
146
171
  type: 'string',
147
172
  description: 'Template path reference',
148
- example: 'Assets:CN:Bank:ICBC:Checking'
173
+ example: 'Assets:CN:Checking'
149
174
  },
150
175
  isCustom: {
151
176
  type: 'boolean',
152
177
  description: 'Whether this is a custom (user-created) account',
153
178
  example: false
154
179
  },
155
- i18nKey: {
180
+ displayName: {
156
181
  type: 'string',
157
- description: 'i18n key for display name',
158
- example: 'account.assets.cn.bank.icbc.checking'
182
+ description: 'Localized display name (ADR-0114, read-time projection)',
183
+ example: 'Checking'
159
184
  },
160
185
  icon: {
161
186
  type: 'string',
162
187
  description: 'Icon identifier',
163
188
  example: 'bank-icbc'
164
189
  },
165
- openMeta: {
190
+ openDirectiveMeta: {
166
191
  type: 'object',
167
- description: 'Account metadata',
192
+ description: 'Open directive metadata (ADR-0115 Decision 9)',
168
193
  example: {
169
194
  branch: 'Downtown'
170
195
  }
@@ -192,7 +217,6 @@ export const $AccountResponseDto = {
192
217
  required: [
193
218
  'id',
194
219
  'path',
195
- 'displayName',
196
220
  'type',
197
221
  'status',
198
222
  'openDate',
@@ -225,11 +249,6 @@ export const $AccountListResponseDto = {
225
249
  export const $UpdateAccountDto = {
226
250
  type: 'object',
227
251
  properties: {
228
- displayName: {
229
- type: 'string',
230
- description: 'Display name to distinguish accounts at the same path',
231
- example: '招行工资卡'
232
- },
233
252
  currencies: {
234
253
  description: 'Allowed currencies (null = no restriction)',
235
254
  example: ['CNY', 'USD'],
@@ -251,19 +270,15 @@ export const $UpdateAccountDto = {
251
270
  'NONE'
252
271
  ]
253
272
  },
254
- i18nKey: {
255
- type: 'string',
256
- description: 'i18n key for display name',
257
- example: 'account.custom.mybank'
258
- },
259
273
  icon: {
260
274
  type: 'string',
261
275
  description: 'Icon identifier',
262
276
  example: 'bank-custom'
263
277
  },
264
- openMeta: {
278
+ openDirectiveMeta: {
265
279
  type: 'object',
266
- description: 'Additional metadata (merged with existing)',
280
+ description:
281
+ 'Open directive metadata (merged with existing; NOT an opening-balance amount)',
267
282
  example: {
268
283
  branch: 'Uptown'
269
284
  }
@@ -310,13 +325,47 @@ export const $ReopenAccountDto = {
310
325
  }
311
326
  } as const;
312
327
 
328
+ export const $CreateOpeningBalanceDto = {
329
+ type: 'object',
330
+ properties: {
331
+ amount: {
332
+ type: 'number',
333
+ description: 'Opening balance amount (non-negative)',
334
+ example: 1000
335
+ },
336
+ currency: {
337
+ type: 'string',
338
+ description: 'Currency code',
339
+ example: 'CNY'
340
+ },
341
+ date: {
342
+ format: 'date-time',
343
+ type: 'string',
344
+ description: 'Opening-balance date (defaults to now)',
345
+ example: '2024-01-01'
346
+ }
347
+ },
348
+ required: ['amount', 'currency']
349
+ } as const;
350
+
351
+ export const $OpeningBalanceResultDto = {
352
+ type: 'object',
353
+ properties: {
354
+ transactionId: {
355
+ type: 'string',
356
+ description: 'Created opening-balance transaction id.'
357
+ }
358
+ },
359
+ required: ['transactionId']
360
+ } as const;
361
+
313
362
  export const $AccountStandardResponseDto = {
314
363
  type: 'object',
315
364
  properties: {
316
365
  path: {
317
366
  type: 'string',
318
367
  description: 'Account path (hierarchical, colon-separated)',
319
- example: 'Assets:CN:Bank:ICBC:Checking'
368
+ example: 'Assets:CN:Checking'
320
369
  },
321
370
  type: {
322
371
  type: 'string',
@@ -324,11 +373,6 @@ export const $AccountStandardResponseDto = {
324
373
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
325
374
  example: 'Assets'
326
375
  },
327
- i18nKey: {
328
- type: 'string',
329
- description: 'i18n key for localized display name',
330
- example: 'account.assets.cn.bank.icbc.checking'
331
- },
332
376
  name: {
333
377
  type: 'string',
334
378
  description: 'Short localized display name',
@@ -353,7 +397,7 @@ export const $AccountStandardResponseDto = {
353
397
  example: 'bank-icbc'
354
398
  }
355
399
  },
356
- required: ['path', 'type', 'i18nKey', 'description', 'tags', 'icon']
400
+ required: ['path', 'type', 'description', 'tags', 'icon']
357
401
  } as const;
358
402
 
359
403
  export const $AccountStandardListResponseDto = {
@@ -383,18 +427,13 @@ export const $AccountStandardListResponseDto = {
383
427
  export const $TemplateMetadataDto = {
384
428
  type: 'object',
385
429
  properties: {
386
- extendable: {
387
- type: 'boolean',
388
- description: 'Whether this path can be extended',
389
- example: true
390
- },
391
430
  rootType: {
392
431
  type: 'string',
393
432
  description: 'Root account type',
394
433
  example: 'Assets'
395
434
  }
396
435
  },
397
- required: ['extendable', 'rootType']
436
+ required: ['rootType']
398
437
  } as const;
399
438
 
400
439
  export const $TemplateMetadataResponseDto = {
@@ -466,6 +505,66 @@ export const $RegionsMetadataResponseDto = {
466
505
  required: ['regions']
467
506
  } as const;
468
507
 
508
+ export const $CostSpecDto = {
509
+ type: 'object',
510
+ properties: {
511
+ mode: {
512
+ type: 'string',
513
+ enum: ['per-unit', 'total', 'date', 'label', 'auto'],
514
+ description: 'Cost specification mode (mirrors engine CostSpec)'
515
+ },
516
+ numberPerUnit: {
517
+ type: 'string',
518
+ description: 'Per-unit cost (required when mode is "per-unit")',
519
+ example: '240'
520
+ },
521
+ totalNumber: {
522
+ type: 'string',
523
+ description: 'Total cost for all units (required when mode is "total")',
524
+ example: '12000'
525
+ },
526
+ currency: {
527
+ type: 'string',
528
+ description: 'Cost currency (required in all modes)',
529
+ example: 'USD'
530
+ },
531
+ date: {
532
+ type: 'string',
533
+ description:
534
+ 'Lot acquisition date, ISO 8601 (required when mode is "date")',
535
+ example: '2024-01-15'
536
+ },
537
+ label: {
538
+ type: 'string',
539
+ description:
540
+ 'Lot label (required when mode is "label"; optional tag in buy modes)'
541
+ },
542
+ merge: {
543
+ type: 'boolean',
544
+ description: 'Merge lots for AVERAGE booking (mode: auto)'
545
+ }
546
+ },
547
+ required: ['mode', 'currency']
548
+ } as const;
549
+
550
+ export const $AmountDto = {
551
+ type: 'object',
552
+ properties: {
553
+ number: {
554
+ type: 'string',
555
+ description:
556
+ 'Amount as decimal string (max 15 integer + 15 decimal digits)',
557
+ example: '170.50'
558
+ },
559
+ currency: {
560
+ type: 'string',
561
+ description: 'Currency/commodity code',
562
+ example: 'USD'
563
+ }
564
+ },
565
+ required: ['number', 'currency']
566
+ } as const;
567
+
469
568
  export const $CreatePostingDto = {
470
569
  type: 'object',
471
570
  properties: {
@@ -473,7 +572,7 @@ export const $CreatePostingDto = {
473
572
  type: 'string',
474
573
  description:
475
574
  'Account name in Beancount format (must start with uppercase, colon-separated)',
476
- example: 'Assets:Bank:Checking'
575
+ example: 'Assets:Checking'
477
576
  },
478
577
  units: {
479
578
  type: 'string',
@@ -495,6 +594,33 @@ export const $CreatePostingDto = {
495
594
  example: {
496
595
  'tax-lot': 'Q1-2024'
497
596
  }
597
+ },
598
+ cost: {
599
+ description:
600
+ 'Cost basis (Beancount `{...}`). Maps to engine costSpec. Required for commodity holdings so they carry a monetary weight that can balance.',
601
+ example: {
602
+ mode: 'per-unit',
603
+ numberPerUnit: '240',
604
+ currency: 'USD'
605
+ },
606
+ allOf: [
607
+ {
608
+ $ref: '#/components/schemas/CostSpecDto'
609
+ }
610
+ ]
611
+ },
612
+ price: {
613
+ description:
614
+ 'Price annotation (Beancount `@...`). Maps to engine price. Used for valuation; cost takes priority for balance weight.',
615
+ example: {
616
+ number: '170',
617
+ currency: 'USD'
618
+ },
619
+ allOf: [
620
+ {
621
+ $ref: '#/components/schemas/AmountDto'
622
+ }
623
+ ]
498
624
  }
499
625
  },
500
626
  required: ['account']
@@ -573,13 +699,39 @@ export const $CreateTransactionDto = {
573
699
  required: ['date', 'narration', 'postings']
574
700
  } as const;
575
701
 
702
+ export const $CostDetailDto = {
703
+ type: 'object',
704
+ properties: {
705
+ number: {
706
+ type: 'string',
707
+ description: 'Per-unit cost basis (mirrors engine Cost.number)',
708
+ example: '240'
709
+ },
710
+ currency: {
711
+ type: 'string',
712
+ description: 'Cost currency',
713
+ example: 'USD'
714
+ },
715
+ date: {
716
+ type: 'string',
717
+ description: 'Lot acquisition date (ISO yyyy-mm-dd)',
718
+ example: '2024-01-15'
719
+ },
720
+ label: {
721
+ type: 'string',
722
+ description: 'Lot label',
723
+ example: 'lot-2024-01'
724
+ }
725
+ }
726
+ } as const;
727
+
576
728
  export const $PostingResponseDto = {
577
729
  type: 'object',
578
730
  properties: {
579
731
  account: {
580
732
  type: 'string',
581
733
  description: 'Account name',
582
- example: 'Assets:Bank:Checking'
734
+ example: 'Assets:Checking'
583
735
  },
584
736
  units: {
585
737
  type: 'string',
@@ -591,6 +743,15 @@ export const $PostingResponseDto = {
591
743
  type: 'string',
592
744
  description: 'Currency',
593
745
  example: 'USD'
746
+ },
747
+ cost: {
748
+ description:
749
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
750
+ allOf: [
751
+ {
752
+ $ref: '#/components/schemas/CostDetailDto'
753
+ }
754
+ ]
594
755
  }
595
756
  },
596
757
  required: ['account']
@@ -936,7 +1097,7 @@ export const $PostingDetailDto = {
936
1097
  account: {
937
1098
  type: 'string',
938
1099
  description: 'Fully-qualified Beancount account path',
939
- example: 'Assets:Bank:Checking'
1100
+ example: 'Assets:Checking'
940
1101
  },
941
1102
  units: {
942
1103
  type: 'string',
@@ -964,6 +1125,15 @@ export const $PostingDetailDto = {
964
1125
  description: 'Cost date',
965
1126
  example: '2024-01-15'
966
1127
  },
1128
+ cost: {
1129
+ description:
1130
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
1131
+ allOf: [
1132
+ {
1133
+ $ref: '#/components/schemas/CostDetailDto'
1134
+ }
1135
+ ]
1136
+ },
967
1137
  priceAmount: {
968
1138
  type: 'string',
969
1139
  description: 'Price amount',
@@ -1116,6 +1286,77 @@ export const $TransactionDetailDto = {
1116
1286
  ]
1117
1287
  } as const;
1118
1288
 
1289
+ export const $BalanceByCurrencyDto = {
1290
+ type: 'object',
1291
+ properties: {
1292
+ currency: {
1293
+ type: 'string',
1294
+ description: 'ISO 4217 currency code',
1295
+ example: 'CNY'
1296
+ },
1297
+ balance: {
1298
+ type: 'string',
1299
+ description: 'Balance amount',
1300
+ example: '50000.00'
1301
+ }
1302
+ },
1303
+ required: ['currency', 'balance']
1304
+ } as const;
1305
+
1306
+ export const $ExchangeRateWarningDto = {
1307
+ type: 'object',
1308
+ properties: {
1309
+ type: {
1310
+ type: 'string',
1311
+ description: 'Warning type',
1312
+ example: 'MISSING_EXCHANGE_RATE'
1313
+ },
1314
+ currency: {
1315
+ type: 'string',
1316
+ description: 'Currency without exchange rate',
1317
+ example: 'EUR'
1318
+ },
1319
+ totalAmount: {
1320
+ type: 'string',
1321
+ description: 'Total amount affected',
1322
+ example: '1000.00'
1323
+ }
1324
+ },
1325
+ required: ['type', 'currency', 'totalAmount']
1326
+ } as const;
1327
+
1328
+ export const $TransactionListSummaryDto = {
1329
+ type: 'object',
1330
+ properties: {
1331
+ totalAmount: {
1332
+ type: 'string',
1333
+ description:
1334
+ 'Partial converted total in base currency (rated currencies only, raw Beancount sign). When warnings is non-empty this excludes currencies missing an FX rate; may be "0.00" if ALL non-base currencies lack a rate. Converted at the dateTo (or current) available rate.',
1335
+ example: '-6000.00'
1336
+ },
1337
+ currency: {
1338
+ type: 'string',
1339
+ description: 'Base currency (ISO 4217)',
1340
+ example: 'CNY'
1341
+ },
1342
+ balanceByCurrency: {
1343
+ description: 'Raw (unconverted) balance per currency',
1344
+ type: 'array',
1345
+ items: {
1346
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
1347
+ }
1348
+ },
1349
+ warnings: {
1350
+ description: 'Currencies missing an FX rate (omitted when empty)',
1351
+ type: 'array',
1352
+ items: {
1353
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
1354
+ }
1355
+ }
1356
+ },
1357
+ required: ['totalAmount', 'currency', 'balanceByCurrency']
1358
+ } as const;
1359
+
1119
1360
  export const $TransactionListResponseDto = {
1120
1361
  type: 'object',
1121
1362
  properties: {
@@ -1140,6 +1381,15 @@ export const $TransactionListResponseDto = {
1140
1381
  type: 'number',
1141
1382
  description: 'Number of items skipped',
1142
1383
  example: 0
1384
+ },
1385
+ summary: {
1386
+ description:
1387
+ 'Amount summary for the full filtered set (#514). Present only when the request has a single account OR category viewpoint; omitted for search-only / plain-list / dual-perspective requests.',
1388
+ allOf: [
1389
+ {
1390
+ $ref: '#/components/schemas/TransactionListSummaryDto'
1391
+ }
1392
+ ]
1143
1393
  }
1144
1394
  },
1145
1395
  required: ['data', 'total', 'limit', 'offset']
@@ -1239,7 +1489,7 @@ export const $BalanceResponseDto = {
1239
1489
  account: {
1240
1490
  type: 'string',
1241
1491
  description: 'Account name',
1242
- example: 'Assets:Bank:Checking'
1492
+ example: 'Assets:Checking'
1243
1493
  },
1244
1494
  balance: {
1245
1495
  type: 'string',
@@ -1266,7 +1516,7 @@ export const $MultiCurrencyBalanceResponseDto = {
1266
1516
  account: {
1267
1517
  type: 'string',
1268
1518
  description: 'Account name',
1269
- example: 'Assets:Bank:Checking'
1519
+ example: 'Assets:Checking'
1270
1520
  },
1271
1521
  balances: {
1272
1522
  type: 'object',
@@ -1322,7 +1572,7 @@ export const $TransactionSummaryDto = {
1322
1572
  accountName: {
1323
1573
  type: 'string',
1324
1574
  description: 'Source account name (first posting)',
1325
- example: 'Assets:Bank:Checking'
1575
+ example: 'Assets:Checking'
1326
1576
  },
1327
1577
  sourceType: {
1328
1578
  type: 'string',
@@ -1724,7 +1974,8 @@ export const $ResolveResultDto = {
1724
1974
  },
1725
1975
  resolutionId: {
1726
1976
  type: 'string',
1727
- description: 'Resolution ID for undo'
1977
+ description:
1978
+ 'Resolution ID for undo. Absent when the resolver rejected the decision (review stayed PENDING).'
1728
1979
  },
1729
1980
  canUndo: {
1730
1981
  type: 'boolean',
@@ -1742,7 +1993,7 @@ export const $ResolveResultDto = {
1742
1993
  example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1743
1994
  }
1744
1995
  },
1745
- required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
1996
+ required: ['success']
1746
1997
  } as const;
1747
1998
 
1748
1999
  export const $UndoResultDto = {
@@ -2613,37 +2864,194 @@ export const $UpdateCommodityDto = {
2613
2864
  }
2614
2865
  } as const;
2615
2866
 
2616
- export const $CreateRecurringRuleDto = {
2867
+ export const $CreateBeanPriceDto = {
2617
2868
  type: 'object',
2618
2869
  properties: {
2619
- name: {
2620
- type: 'string',
2621
- description: 'Rule name (unique per user)',
2622
- maxLength: 100
2623
- },
2624
- icon: {
2870
+ currency: {
2625
2871
  type: 'string',
2626
- description: 'Icon emoji',
2627
- maxLength: 10
2872
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2873
+ example: 'USD'
2628
2874
  },
2629
- frequency: {
2875
+ quoteCurrency: {
2630
2876
  type: 'string',
2631
- description: 'Recurring frequency',
2632
- enum: [
2633
- 'WEEKLY',
2634
- 'BIWEEKLY',
2635
- 'MONTHLY',
2636
- 'BIMONTHLY',
2637
- 'QUARTERLY',
2638
- 'YEARLY',
2639
- 'CUSTOM'
2640
- ]
2877
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
2878
+ example: 'CNY'
2641
2879
  },
2642
- expectedAmount: {
2880
+ amount: {
2643
2881
  type: 'number',
2644
- description: 'Expected amount (positive number)',
2645
- minimum: 0
2646
- },
2882
+ description:
2883
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
2884
+ example: 175.5,
2885
+ minimum: 0
2886
+ },
2887
+ date: {
2888
+ type: 'string',
2889
+ description: 'Price date (ISO 8601 format)',
2890
+ example: '2024-11-05'
2891
+ },
2892
+ metadata: {
2893
+ type: 'object',
2894
+ description:
2895
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
2896
+ example: {
2897
+ source: 'MANUAL',
2898
+ note: 'Bank valuation report',
2899
+ confidence: 0.95
2900
+ }
2901
+ }
2902
+ },
2903
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
2904
+ } as const;
2905
+
2906
+ export const $PriceResponseDto = {
2907
+ type: 'object',
2908
+ properties: {
2909
+ id: {
2910
+ type: 'string',
2911
+ description: 'Unique identifier',
2912
+ example: 'uuid-123-456'
2913
+ },
2914
+ userId: {
2915
+ type: 'string',
2916
+ description: 'User ID (owner of the price)',
2917
+ example: 'user-123'
2918
+ },
2919
+ currency: {
2920
+ type: 'string',
2921
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2922
+ example: 'BTC'
2923
+ },
2924
+ quoteCurrency: {
2925
+ type: 'string',
2926
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2927
+ example: 'USD'
2928
+ },
2929
+ amount: {
2930
+ type: 'number',
2931
+ description:
2932
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2933
+ example: 50000
2934
+ },
2935
+ date: {
2936
+ type: 'string',
2937
+ description:
2938
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
2939
+ example: '2024-01-01',
2940
+ format: 'date'
2941
+ },
2942
+ meta: {
2943
+ type: 'object',
2944
+ description:
2945
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
2946
+ example: {
2947
+ source: 'MANUAL',
2948
+ note: 'User-defined price',
2949
+ confidence: 1
2950
+ }
2951
+ },
2952
+ createdAt: {
2953
+ format: 'date-time',
2954
+ type: 'string',
2955
+ description: 'Creation timestamp',
2956
+ example: '2024-11-03T10:00:00Z'
2957
+ },
2958
+ updatedAt: {
2959
+ format: 'date-time',
2960
+ type: 'string',
2961
+ description: 'Last update timestamp',
2962
+ example: '2024-11-03T10:00:00Z'
2963
+ }
2964
+ },
2965
+ required: [
2966
+ 'id',
2967
+ 'userId',
2968
+ 'currency',
2969
+ 'quoteCurrency',
2970
+ 'amount',
2971
+ 'date',
2972
+ 'meta',
2973
+ 'createdAt',
2974
+ 'updatedAt'
2975
+ ]
2976
+ } as const;
2977
+
2978
+ export const $PriceListResponseDto = {
2979
+ type: 'object',
2980
+ properties: {
2981
+ items: {
2982
+ description: 'List of prices',
2983
+ type: 'array',
2984
+ items: {
2985
+ $ref: '#/components/schemas/PriceResponseDto'
2986
+ }
2987
+ },
2988
+ total: {
2989
+ type: 'number',
2990
+ description: 'Total number of prices',
2991
+ example: 42
2992
+ }
2993
+ },
2994
+ required: ['items', 'total']
2995
+ } as const;
2996
+
2997
+ export const $UpdateBeanPriceDto = {
2998
+ type: 'object',
2999
+ properties: {
3000
+ currency: {
3001
+ type: 'string',
3002
+ description: 'Currency being priced'
3003
+ },
3004
+ quoteCurrency: {
3005
+ type: 'string',
3006
+ description: 'Quote currency (pricing currency)'
3007
+ },
3008
+ amount: {
3009
+ type: 'number',
3010
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
3011
+ minimum: 0
3012
+ },
3013
+ date: {
3014
+ type: 'string',
3015
+ description: 'Price date (ISO 8601 format)'
3016
+ },
3017
+ metadata: {
3018
+ type: 'object',
3019
+ description: 'Metadata'
3020
+ }
3021
+ }
3022
+ } as const;
3023
+
3024
+ export const $CreateRecurringRuleDto = {
3025
+ type: 'object',
3026
+ properties: {
3027
+ name: {
3028
+ type: 'string',
3029
+ description: 'Rule name (unique per user)',
3030
+ maxLength: 100
3031
+ },
3032
+ icon: {
3033
+ type: 'string',
3034
+ description: 'Icon emoji',
3035
+ maxLength: 10
3036
+ },
3037
+ frequency: {
3038
+ type: 'string',
3039
+ description: 'Recurring frequency',
3040
+ enum: [
3041
+ 'WEEKLY',
3042
+ 'BIWEEKLY',
3043
+ 'MONTHLY',
3044
+ 'BIMONTHLY',
3045
+ 'QUARTERLY',
3046
+ 'YEARLY',
3047
+ 'CUSTOM'
3048
+ ]
3049
+ },
3050
+ expectedAmount: {
3051
+ type: 'number',
3052
+ description: 'Expected amount (positive number)',
3053
+ minimum: 0
3054
+ },
2647
3055
  expectedDay: {
2648
3056
  type: 'number',
2649
3057
  description: 'Expected day of month (1-31)',
@@ -3384,278 +3792,470 @@ export const $ForecastResponseDto = {
3384
3792
  ]
3385
3793
  } as const;
3386
3794
 
3387
- export const $CreateTransactionRuleDto = {
3795
+ export const $CurrencyBalanceDto = {
3388
3796
  type: 'object',
3389
3797
  properties: {
3390
- name: {
3798
+ currency: {
3391
3799
  type: 'string',
3392
- minLength: 1,
3393
- maxLength: 100
3800
+ description: 'ISO 4217 currency code',
3801
+ example: 'CNY'
3394
3802
  },
3395
- description: {
3803
+ balance: {
3396
3804
  type: 'string',
3397
- maxLength: 500
3398
- },
3399
- narrationKeywords: {
3400
- items: {
3401
- type: 'array'
3402
- },
3403
- maxItems: 50,
3404
- type: 'array'
3405
- },
3406
- payeeKeywords: {
3407
- items: {
3408
- type: 'array'
3409
- },
3410
- maxItems: 50,
3411
- type: 'array'
3805
+ description: 'Balance amount',
3806
+ example: '500000.00'
3807
+ }
3808
+ },
3809
+ required: ['currency', 'balance']
3810
+ } as const;
3811
+
3812
+ export const $TimeSeriesPointDto = {
3813
+ type: 'object',
3814
+ properties: {
3815
+ date: {
3816
+ type: 'string',
3817
+ description: 'Date in YYYY-MM-DD format',
3818
+ example: '2024-06-15'
3412
3819
  },
3413
- categoryKeywords: {
3414
- items: {
3415
- type: 'array'
3416
- },
3417
- maxItems: 50,
3418
- type: 'array'
3820
+ value: {
3821
+ type: 'string',
3822
+ description: 'Value at this date (in base currency)',
3823
+ example: '500000.00'
3419
3824
  },
3420
- methodKeywords: {
3421
- items: {
3422
- type: 'array'
3423
- },
3424
- maxItems: 50,
3425
- description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
3426
- type: 'array'
3825
+ change: {
3826
+ type: 'object',
3827
+ description: 'Change from previous point',
3828
+ example: '5000.00'
3427
3829
  },
3428
- categoryAccount: {
3830
+ assets: {
3429
3831
  type: 'string',
3430
- maxLength: 200,
3431
- description:
3432
- 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
3832
+ description: 'Total assets at this date (in base currency)',
3833
+ example: '494338.00'
3433
3834
  },
3434
- matchLogic: {
3835
+ liabilities: {
3435
3836
  type: 'string',
3436
- enum: ['OR', 'AND'],
3437
- default: 'OR'
3438
- },
3439
- amountMin: {
3440
- type: 'number',
3441
- minimum: 0,
3442
- description: 'Minimum transaction amount (inclusive)'
3443
- },
3444
- amountMax: {
3445
- type: 'number',
3446
- minimum: 0,
3447
- description: 'Maximum transaction amount (inclusive)'
3837
+ description: 'Total liabilities at this date (in base currency)',
3838
+ example: '310098.00'
3448
3839
  },
3449
- priority: {
3450
- type: 'number',
3451
- default: 50,
3452
- minimum: 0,
3453
- maximum: 1000
3454
- },
3455
- additionalTags: {
3840
+ byCurrency: {
3841
+ description: 'Multi-currency breakdown for this point',
3842
+ type: 'array',
3456
3843
  items: {
3457
- type: 'array'
3458
- },
3459
- maxItems: 20,
3460
- type: 'array'
3461
- },
3462
- additionalMetadata: {
3463
- type: 'object'
3464
- },
3465
- upsertByPayee: {
3466
- type: 'boolean',
3467
- description:
3468
- 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
3844
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3845
+ }
3469
3846
  }
3470
3847
  },
3471
- required: ['name', 'matchLogic', 'priority']
3848
+ required: ['date', 'value']
3472
3849
  } as const;
3473
3850
 
3474
- export const $AmountRangeDto = {
3851
+ export const $TrendSummaryDto = {
3475
3852
  type: 'object',
3476
3853
  properties: {
3477
- min: {
3478
- type: 'number',
3479
- description: 'Minimum amount'
3854
+ startValue: {
3855
+ type: 'string',
3856
+ description: 'Value at start of period',
3857
+ example: '450000.00'
3480
3858
  },
3481
- max: {
3482
- type: 'number',
3483
- description: 'Maximum amount'
3859
+ endValue: {
3860
+ type: 'string',
3861
+ description: 'Value at end of period',
3862
+ example: '500000.00'
3863
+ },
3864
+ totalChange: {
3865
+ type: 'string',
3866
+ description: 'Total change over period',
3867
+ example: '50000.00'
3868
+ },
3869
+ totalChangePercentage: {
3870
+ type: 'string',
3871
+ description: 'Total change percentage',
3872
+ example: '+11.11%'
3484
3873
  }
3485
- }
3874
+ },
3875
+ required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
3486
3876
  } as const;
3487
3877
 
3488
- export const $TransactionRuleResponseDto = {
3878
+ export const $MultiCurrencyPointDto = {
3489
3879
  type: 'object',
3490
3880
  properties: {
3491
- id: {
3492
- type: 'string',
3493
- description: 'Rule ID'
3494
- },
3495
- name: {
3496
- type: 'string',
3497
- description: 'Rule name'
3498
- },
3499
- description: {
3881
+ date: {
3500
3882
  type: 'string',
3501
- description: 'Rule description'
3502
- },
3503
- narrationKeywords: {
3504
- description: 'Keywords to match in transaction narration',
3505
- type: 'array',
3506
- items: {
3507
- type: 'string'
3508
- }
3509
- },
3510
- payeeKeywords: {
3511
- description: 'Keywords to match in payee name',
3512
- type: 'array',
3513
- items: {
3514
- type: 'string'
3515
- }
3883
+ description: 'Date in YYYY-MM-DD format',
3884
+ example: '2024-06-15'
3516
3885
  },
3517
- categoryKeywords: {
3518
- description: 'Keywords to match in category',
3886
+ byCurrency: {
3887
+ description: 'Balances by currency',
3519
3888
  type: 'array',
3520
3889
  items: {
3521
- type: 'string'
3890
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3522
3891
  }
3523
- },
3524
- methodKeywords: {
3525
- description: 'Keywords to match in payment method',
3892
+ }
3893
+ },
3894
+ required: ['date', 'byCurrency']
3895
+ } as const;
3896
+
3897
+ export const $PortfolioTrendsResponseDto = {
3898
+ type: 'object',
3899
+ properties: {
3900
+ series: {
3901
+ description: 'Time series data points',
3526
3902
  type: 'array',
3527
3903
  items: {
3528
- type: 'string'
3904
+ $ref: '#/components/schemas/TimeSeriesPointDto'
3529
3905
  }
3530
3906
  },
3531
- categoryAccount: {
3532
- type: 'string',
3533
- description: 'Destination account for categorization'
3534
- },
3535
- matchLogic: {
3536
- type: 'string',
3537
- description: 'Keyword matching logic',
3538
- enum: ['OR', 'AND'],
3539
- example: 'OR'
3540
- },
3541
- amountRange: {
3542
- description: 'Amount range for matching',
3907
+ summary: {
3908
+ description: 'Period summary',
3543
3909
  allOf: [
3544
3910
  {
3545
- $ref: '#/components/schemas/AmountRangeDto'
3911
+ $ref: '#/components/schemas/TrendSummaryDto'
3546
3912
  }
3547
3913
  ]
3548
3914
  },
3549
- priority: {
3550
- type: 'number',
3551
- description: 'Rule priority (0-1000, higher = first match)',
3552
- example: 50
3553
- },
3554
- enabled: {
3555
- type: 'boolean',
3556
- description: 'Whether the rule is enabled'
3557
- },
3558
- learningSource: {
3915
+ period: {
3559
3916
  type: 'string',
3560
- description: 'Learning source: NLP, REVIEW_CENTER, or null for manual',
3561
- enum: ['NLP', 'REVIEW_CENTER'],
3562
- nullable: true,
3563
- example: 'REVIEW_CENTER'
3917
+ description: 'Period requested',
3918
+ example: '6m'
3564
3919
  },
3565
- autoApplyEnabled: {
3566
- type: 'boolean',
3567
- description: 'Whether auto-apply is enabled for this rule'
3920
+ granularity: {
3921
+ type: 'string',
3922
+ description: 'Data granularity',
3923
+ example: 'month'
3568
3924
  },
3569
- confirmationCount: {
3570
- type: 'number',
3571
- description: 'Number of confirmations for NLP-learned rules',
3572
- example: 3
3925
+ currency: {
3926
+ type: 'string',
3927
+ description: 'Base currency for converted values',
3928
+ example: 'CNY'
3573
3929
  },
3574
- additionalTags: {
3575
- description: 'Additional tags',
3930
+ byCurrency: {
3931
+ description:
3932
+ 'Multi-currency time series (each point has currency breakdown)',
3576
3933
  type: 'array',
3577
3934
  items: {
3578
- type: 'string'
3935
+ $ref: '#/components/schemas/MultiCurrencyPointDto'
3579
3936
  }
3580
3937
  },
3581
- additionalMetadata: {
3582
- type: 'object',
3583
- description: 'Additional metadata',
3584
- additionalProperties: {
3585
- type: 'string'
3938
+ warnings: {
3939
+ description: 'Exchange rate warnings',
3940
+ type: 'array',
3941
+ items: {
3942
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3586
3943
  }
3944
+ }
3945
+ },
3946
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
3947
+ } as const;
3948
+
3949
+ export const $CashFlowPointDto = {
3950
+ type: 'object',
3951
+ properties: {
3952
+ month: {
3953
+ type: 'string',
3954
+ description: 'Month key (YYYY-MM)',
3955
+ example: '2024-03'
3587
3956
  },
3588
- createdAt: {
3589
- format: 'date-time',
3957
+ income: {
3590
3958
  type: 'string',
3591
- description: 'Created timestamp'
3959
+ description: 'Income in base currency (absolute, converted)',
3960
+ example: '10000.00'
3592
3961
  },
3593
- updatedAt: {
3594
- format: 'date-time',
3962
+ expense: {
3595
3963
  type: 'string',
3596
- description: 'Updated timestamp'
3964
+ description: 'Expense in base currency (absolute, converted)',
3965
+ example: '5000.00'
3966
+ },
3967
+ netSavings: {
3968
+ type: 'string',
3969
+ description: 'netSavings = income − expense (savings positive)',
3970
+ example: '5000.00'
3597
3971
  }
3598
3972
  },
3599
- required: [
3600
- 'id',
3601
- 'name',
3602
- 'narrationKeywords',
3603
- 'payeeKeywords',
3604
- 'categoryKeywords',
3605
- 'methodKeywords',
3606
- 'matchLogic',
3607
- 'priority',
3608
- 'enabled',
3609
- 'autoApplyEnabled',
3610
- 'confirmationCount',
3611
- 'additionalTags',
3612
- 'createdAt',
3613
- 'updatedAt'
3614
- ]
3973
+ required: ['month', 'income', 'expense', 'netSavings']
3615
3974
  } as const;
3616
3975
 
3617
- export const $TransactionRuleListResponseDto = {
3976
+ export const $CashFlowTrendSummaryDto = {
3618
3977
  type: 'object',
3619
3978
  properties: {
3620
- data: {
3621
- type: 'array',
3622
- items: {
3623
- $ref: '#/components/schemas/TransactionRuleResponseDto'
3624
- }
3979
+ totalIncome: {
3980
+ type: 'string',
3981
+ description: 'Total income across the period',
3982
+ example: '60000.00'
3625
3983
  },
3626
- total: {
3627
- type: 'number',
3628
- description: 'Total count of rules'
3984
+ totalExpense: {
3985
+ type: 'string',
3986
+ description: 'Total expense across the period',
3987
+ example: '30000.00'
3629
3988
  },
3630
- limit: {
3631
- type: 'number',
3632
- description: 'Results per page'
3989
+ totalNetSavings: {
3990
+ type: 'string',
3991
+ description: 'income − expense across the period',
3992
+ example: '30000.00'
3633
3993
  },
3634
- offset: {
3635
- type: 'number',
3636
- description: 'Pagination offset'
3994
+ averageMonthlyNetSavings: {
3995
+ type: 'string',
3996
+ description:
3997
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
3998
+ example: '5000.00'
3637
3999
  }
3638
4000
  },
3639
- required: ['data', 'total', 'limit', 'offset']
4001
+ required: [
4002
+ 'totalIncome',
4003
+ 'totalExpense',
4004
+ 'totalNetSavings',
4005
+ 'averageMonthlyNetSavings'
4006
+ ]
3640
4007
  } as const;
3641
4008
 
3642
- export const $ValidateRuleDto = {
4009
+ export const $CashFlowTrendsResponseDto = {
3643
4010
  type: 'object',
3644
4011
  properties: {
3645
- name: {
4012
+ series: {
4013
+ description:
4014
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
4015
+ type: 'array',
4016
+ items: {
4017
+ $ref: '#/components/schemas/CashFlowPointDto'
4018
+ }
4019
+ },
4020
+ summary: {
4021
+ description: 'Period totals',
4022
+ allOf: [
4023
+ {
4024
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
4025
+ }
4026
+ ]
4027
+ },
4028
+ period: {
3646
4029
  type: 'string',
3647
- minLength: 1,
3648
- maxLength: 100
4030
+ description: 'Period requested',
4031
+ example: '6m'
3649
4032
  },
3650
- description: {
4033
+ granularity: {
3651
4034
  type: 'string',
3652
- maxLength: 500
4035
+ description: 'Data granularity (v1 returns month buckets)',
4036
+ example: 'month'
3653
4037
  },
3654
- narrationKeywords: {
3655
- items: {
3656
- type: 'array'
3657
- },
3658
- maxItems: 50,
4038
+ currency: {
4039
+ type: 'string',
4040
+ description: 'Base currency for converted values',
4041
+ example: 'CNY'
4042
+ },
4043
+ warnings: {
4044
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
4045
+ type: 'array',
4046
+ items: {
4047
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
4048
+ }
4049
+ }
4050
+ },
4051
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
4052
+ } as const;
4053
+
4054
+ export const $GenerateSnapshotBody = {
4055
+ type: 'object',
4056
+ properties: {}
4057
+ } as const;
4058
+
4059
+ export const $GenerateSnapshotResponse = {
4060
+ type: 'object',
4061
+ properties: {}
4062
+ } as const;
4063
+
4064
+ export const $BackfillSnapshotsBody = {
4065
+ type: 'object',
4066
+ properties: {}
4067
+ } as const;
4068
+
4069
+ export const $BackfillSnapshotsResponse = {
4070
+ type: 'object',
4071
+ properties: {}
4072
+ } as const;
4073
+
4074
+ export const $DeleteOwnUserDto = {
4075
+ type: 'object',
4076
+ properties: {
4077
+ accessToken: {
4078
+ type: 'string',
4079
+ description: 'Access token for user verification',
4080
+ example: 'abc123xyz'
4081
+ }
4082
+ },
4083
+ required: ['accessToken']
4084
+ } as const;
4085
+
4086
+ export const $SignupDto = {
4087
+ type: 'object',
4088
+ properties: {
4089
+ turnstileToken: {
4090
+ type: 'string',
4091
+ description:
4092
+ 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4093
+ example: '0.abc123def456...'
4094
+ }
4095
+ }
4096
+ } as const;
4097
+
4098
+ export const $SignupResponseDto = {
4099
+ type: 'object',
4100
+ properties: {
4101
+ authToken: {
4102
+ type: 'string',
4103
+ description: 'JWT auth token',
4104
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4105
+ },
4106
+ accessToken: {
4107
+ type: 'string',
4108
+ description: 'Auto-generated access token'
4109
+ },
4110
+ role: {
4111
+ type: 'string',
4112
+ description: 'Assigned user role',
4113
+ enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
4114
+ }
4115
+ },
4116
+ required: ['authToken', 'accessToken', 'role']
4117
+ } as const;
4118
+
4119
+ export const $UpdateUserSettingDto = {
4120
+ type: 'object',
4121
+ properties: {
4122
+ secId: {
4123
+ type: 'number',
4124
+ description: 'Security ID'
4125
+ },
4126
+ annualInterestRate: {
4127
+ type: 'number',
4128
+ description: 'Annual interest rate',
4129
+ example: 0.05
4130
+ },
4131
+ currency: {
4132
+ type: 'string',
4133
+ description: 'Currency code',
4134
+ example: 'USD'
4135
+ },
4136
+ baseCurrency: {
4137
+ type: 'string',
4138
+ description: 'Base currency code',
4139
+ example: 'USD'
4140
+ },
4141
+ benchmark: {
4142
+ type: 'string',
4143
+ description: 'Benchmark symbol',
4144
+ example: 'SPY'
4145
+ },
4146
+ colorScheme: {
4147
+ type: 'string',
4148
+ description: 'Color scheme',
4149
+ enum: ['DARK', 'LIGHT']
4150
+ },
4151
+ dateRange: {
4152
+ type: 'string',
4153
+ description: 'Date range filter',
4154
+ example: '1y'
4155
+ },
4156
+ emergencyFund: {
4157
+ type: 'number',
4158
+ description: 'Emergency fund amount',
4159
+ example: 10000
4160
+ },
4161
+ 'filters.accounts': {
4162
+ description: 'Account filter IDs',
4163
+ type: 'array',
4164
+ items: {
4165
+ type: 'string'
4166
+ }
4167
+ },
4168
+ 'filters.assetClasses': {
4169
+ description: 'Asset class filters',
4170
+ type: 'array',
4171
+ items: {
4172
+ type: 'string'
4173
+ }
4174
+ },
4175
+ 'filters.dataSource': {
4176
+ type: 'string',
4177
+ description: 'Data source filter'
4178
+ },
4179
+ 'filters.symbol': {
4180
+ type: 'string',
4181
+ description: 'Symbol filter'
4182
+ },
4183
+ 'filters.tags': {
4184
+ description: 'Tag filters',
4185
+ type: 'array',
4186
+ items: {
4187
+ type: 'string'
4188
+ }
4189
+ },
4190
+ isExperimentalFeatures: {
4191
+ type: 'boolean',
4192
+ description: 'Enable experimental features'
4193
+ },
4194
+ isRestrictedView: {
4195
+ type: 'boolean',
4196
+ description: 'Enable restricted view mode'
4197
+ },
4198
+ language: {
4199
+ type: 'string',
4200
+ description: 'Language code',
4201
+ example: 'en'
4202
+ },
4203
+ locale: {
4204
+ type: 'string',
4205
+ description: 'Locale code',
4206
+ example: 'en-US'
4207
+ },
4208
+ projectedTotalAmount: {
4209
+ type: 'number',
4210
+ description: 'Projected total amount',
4211
+ example: 1000000
4212
+ },
4213
+ retirementDate: {
4214
+ type: 'string',
4215
+ description: 'Retirement date in ISO 8601 format',
4216
+ example: '2050-01-01'
4217
+ },
4218
+ savingsRate: {
4219
+ type: 'number',
4220
+ description: 'Savings rate percentage',
4221
+ example: 0.2
4222
+ },
4223
+ viewMode: {
4224
+ type: 'string',
4225
+ description: 'View mode',
4226
+ enum: ['DEFAULT', 'ZEN']
4227
+ }
4228
+ }
4229
+ } as const;
4230
+
4231
+ export const $UpdatePropertyDto = {
4232
+ type: 'object',
4233
+ properties: {
4234
+ value: {
4235
+ type: 'string',
4236
+ description: 'Property value'
4237
+ }
4238
+ },
4239
+ required: ['value']
4240
+ } as const;
4241
+
4242
+ export const $CreateTransactionRuleDto = {
4243
+ type: 'object',
4244
+ properties: {
4245
+ name: {
4246
+ type: 'string',
4247
+ minLength: 1,
4248
+ maxLength: 100
4249
+ },
4250
+ description: {
4251
+ type: 'string',
4252
+ maxLength: 500
4253
+ },
4254
+ narrationKeywords: {
4255
+ items: {
4256
+ type: 'array'
4257
+ },
4258
+ maxItems: 50,
3659
4259
  type: 'array'
3660
4260
  },
3661
4261
  payeeKeywords: {
@@ -3726,175 +4326,175 @@ export const $ValidateRuleDto = {
3726
4326
  required: ['name', 'matchLogic', 'priority']
3727
4327
  } as const;
3728
4328
 
3729
- export const $ValidateRuleResponseDto = {
4329
+ export const $AmountRangeDto = {
3730
4330
  type: 'object',
3731
4331
  properties: {
3732
- valid: {
3733
- type: 'boolean',
3734
- description: 'Whether the rule configuration is valid',
3735
- example: true
3736
- },
3737
- errors: {
3738
- description: 'List of validation errors (empty if valid)',
3739
- example: [],
3740
- items: {
3741
- type: 'array'
3742
- },
3743
- type: 'array'
4332
+ min: {
4333
+ type: 'number',
4334
+ description: 'Minimum amount'
3744
4335
  },
3745
- warnings: {
3746
- description: 'List of validation warnings (non-blocking issues)',
3747
- example: [
3748
- 'No account constraints specified - rule will match any account'
3749
- ],
3750
- items: {
3751
- type: 'array'
3752
- },
3753
- type: 'array'
4336
+ max: {
4337
+ type: 'number',
4338
+ description: 'Maximum amount'
3754
4339
  }
3755
- },
3756
- required: ['valid', 'errors', 'warnings']
4340
+ }
3757
4341
  } as const;
3758
4342
 
3759
- export const $BulkCreateRulesDto = {
4343
+ export const $TransactionRuleResponseDto = {
3760
4344
  type: 'object',
3761
4345
  properties: {
3762
- rules: {
3763
- items: {
3764
- type: 'array'
3765
- },
3766
- description: 'Array of rules to import',
3767
- type: 'array'
4346
+ id: {
4347
+ type: 'string',
4348
+ description: 'Rule ID'
3768
4349
  },
3769
- conflictStrategy: {
4350
+ name: {
3770
4351
  type: 'string',
3771
- enum: ['replace', 'skip'],
3772
- default: 'skip',
3773
- description:
3774
- 'Conflict handling strategy: skip (default) ignores duplicates, replace soft-deletes existing rule'
3775
- }
3776
- },
3777
- required: ['rules', 'conflictStrategy']
3778
- } as const;
3779
-
3780
- export const $BulkCreateRulesResponseDto = {
3781
- type: 'object',
3782
- properties: {
3783
- successCount: {
3784
- type: 'number',
3785
- description: 'Number of successfully created rules'
4352
+ description: 'Rule name'
3786
4353
  },
3787
- failureCount: {
3788
- type: 'number',
3789
- description: 'Number of failed rules'
4354
+ description: {
4355
+ type: 'string',
4356
+ description: 'Rule description'
3790
4357
  },
3791
- errors: {
4358
+ narrationKeywords: {
4359
+ description: 'Keywords to match in transaction narration',
3792
4360
  type: 'array',
3793
- description: 'Error details for failed rules',
3794
4361
  items: {
3795
- type: 'object',
3796
- properties: {
3797
- index: {
3798
- type: 'number'
3799
- },
3800
- message: {
3801
- type: 'string'
3802
- }
3803
- }
4362
+ type: 'string'
3804
4363
  }
3805
4364
  },
3806
- createdRuleIds: {
3807
- description: 'IDs of successfully created rules',
4365
+ payeeKeywords: {
4366
+ description: 'Keywords to match in payee name',
3808
4367
  type: 'array',
3809
4368
  items: {
3810
4369
  type: 'string'
3811
4370
  }
3812
- }
3813
- },
3814
- required: ['successCount', 'failureCount', 'errors', 'createdRuleIds']
3815
- } as const;
3816
-
3817
- export const $ExportRulesResponseDto = {
3818
- type: 'object',
3819
- properties: {
3820
- exportedAt: {
4371
+ },
4372
+ categoryKeywords: {
4373
+ description: 'Keywords to match in category',
4374
+ type: 'array',
4375
+ items: {
4376
+ type: 'string'
4377
+ }
4378
+ },
4379
+ methodKeywords: {
4380
+ description: 'Keywords to match in payment method',
4381
+ type: 'array',
4382
+ items: {
4383
+ type: 'string'
4384
+ }
4385
+ },
4386
+ categoryAccount: {
3821
4387
  type: 'string',
3822
- description: 'Export timestamp'
4388
+ description: 'Destination account for categorization'
3823
4389
  },
3824
- userId: {
4390
+ matchLogic: {
3825
4391
  type: 'string',
3826
- description: 'User ID'
4392
+ description: 'Keyword matching logic',
4393
+ enum: ['OR', 'AND'],
4394
+ example: 'OR'
3827
4395
  },
3828
- ruleCount: {
4396
+ amountRange: {
4397
+ description: 'Amount range for matching',
4398
+ allOf: [
4399
+ {
4400
+ $ref: '#/components/schemas/AmountRangeDto'
4401
+ }
4402
+ ]
4403
+ },
4404
+ priority: {
3829
4405
  type: 'number',
3830
- description: 'Number of exported rules'
4406
+ description: 'Rule priority (0-1000, higher = first match)',
4407
+ example: 50
3831
4408
  },
3832
- rules: {
4409
+ enabled: {
4410
+ type: 'boolean',
4411
+ description: 'Whether the rule is enabled'
4412
+ },
4413
+ learningSource: {
4414
+ type: 'string',
4415
+ description: 'Learning source: NLP, REVIEW_CENTER, or null for manual',
4416
+ enum: ['NLP', 'REVIEW_CENTER'],
4417
+ nullable: true,
4418
+ example: 'REVIEW_CENTER'
4419
+ },
4420
+ autoApplyEnabled: {
4421
+ type: 'boolean',
4422
+ description: 'Whether auto-apply is enabled for this rule'
4423
+ },
4424
+ confirmationCount: {
4425
+ type: 'number',
4426
+ description: 'Number of confirmations for NLP-learned rules',
4427
+ example: 3
4428
+ },
4429
+ additionalTags: {
4430
+ description: 'Additional tags',
3833
4431
  type: 'array',
3834
- description: 'Exported rules'
4432
+ items: {
4433
+ type: 'string'
4434
+ }
4435
+ },
4436
+ additionalMetadata: {
4437
+ type: 'object',
4438
+ description: 'Additional metadata',
4439
+ additionalProperties: {
4440
+ type: 'string'
4441
+ }
4442
+ },
4443
+ createdAt: {
4444
+ format: 'date-time',
4445
+ type: 'string',
4446
+ description: 'Created timestamp'
4447
+ },
4448
+ updatedAt: {
4449
+ format: 'date-time',
4450
+ type: 'string',
4451
+ description: 'Updated timestamp'
3835
4452
  }
3836
4453
  },
3837
- required: ['exportedAt', 'userId', 'ruleCount', 'rules']
4454
+ required: [
4455
+ 'id',
4456
+ 'name',
4457
+ 'narrationKeywords',
4458
+ 'payeeKeywords',
4459
+ 'categoryKeywords',
4460
+ 'methodKeywords',
4461
+ 'matchLogic',
4462
+ 'priority',
4463
+ 'enabled',
4464
+ 'autoApplyEnabled',
4465
+ 'confirmationCount',
4466
+ 'additionalTags',
4467
+ 'createdAt',
4468
+ 'updatedAt'
4469
+ ]
3838
4470
  } as const;
3839
4471
 
3840
- export const $RuleStatisticsResponseDto = {
4472
+ export const $TransactionRuleListResponseDto = {
3841
4473
  type: 'object',
3842
4474
  properties: {
3843
- period: {
3844
- type: 'string',
3845
- description: 'Statistics time period',
3846
- enum: ['7d', '30d', '90d']
3847
- },
3848
- totalRules: {
3849
- type: 'number',
3850
- description: 'Total number of rules'
4475
+ data: {
4476
+ type: 'array',
4477
+ items: {
4478
+ $ref: '#/components/schemas/TransactionRuleResponseDto'
4479
+ }
3851
4480
  },
3852
- rulesWithMatches: {
4481
+ total: {
3853
4482
  type: 'number',
3854
- description: 'Number of rules with at least one match'
4483
+ description: 'Total count of rules'
3855
4484
  },
3856
- totalMatches: {
4485
+ limit: {
3857
4486
  type: 'number',
3858
- description: 'Total number of matches across all rules'
4487
+ description: 'Results per page'
3859
4488
  },
3860
- averageConfidence: {
4489
+ offset: {
3861
4490
  type: 'number',
3862
- description: 'Average confidence score across all matches',
3863
- example: 0.82
3864
- },
3865
- ruleStats: {
3866
- type: 'array',
3867
- description: 'Per-rule statistics',
3868
- items: {
3869
- type: 'object',
3870
- properties: {
3871
- ruleId: {
3872
- type: 'string'
3873
- },
3874
- ruleName: {
3875
- type: 'string'
3876
- },
3877
- matchCount: {
3878
- type: 'number'
3879
- },
3880
- averageConfidence: {
3881
- type: 'number'
3882
- }
3883
- }
3884
- }
4491
+ description: 'Pagination offset'
3885
4492
  }
3886
4493
  },
3887
- required: [
3888
- 'period',
3889
- 'totalRules',
3890
- 'rulesWithMatches',
3891
- 'totalMatches',
3892
- 'averageConfidence',
3893
- 'ruleStats'
3894
- ]
4494
+ required: ['data', 'total', 'limit', 'offset']
3895
4495
  } as const;
3896
4496
 
3897
- export const $UpdateTransactionRuleDto = {
4497
+ export const $ValidateRuleDto = {
3898
4498
  type: 'object',
3899
4499
  properties: {
3900
4500
  name: {
@@ -3943,7 +4543,8 @@ export const $UpdateTransactionRuleDto = {
3943
4543
  },
3944
4544
  matchLogic: {
3945
4545
  type: 'string',
3946
- enum: ['OR', 'AND']
4546
+ enum: ['OR', 'AND'],
4547
+ default: 'OR'
3947
4548
  },
3948
4549
  amountMin: {
3949
4550
  type: 'number',
@@ -3957,13 +4558,10 @@ export const $UpdateTransactionRuleDto = {
3957
4558
  },
3958
4559
  priority: {
3959
4560
  type: 'number',
4561
+ default: 50,
3960
4562
  minimum: 0,
3961
4563
  maximum: 1000
3962
4564
  },
3963
- enabled: {
3964
- type: 'boolean',
3965
- description: 'Enable or disable the rule'
3966
- },
3967
4565
  additionalTags: {
3968
4566
  items: {
3969
4567
  type: 'array'
@@ -3973,48 +4571,305 @@ export const $UpdateTransactionRuleDto = {
3973
4571
  },
3974
4572
  additionalMetadata: {
3975
4573
  type: 'object'
3976
- }
3977
- }
3978
- } as const;
3979
-
3980
- export const $TestRuleDto = {
3981
- type: 'object',
3982
- properties: {
3983
- narration: {
3984
- type: 'string',
3985
- minLength: 1,
3986
- maxLength: 500
3987
- },
3988
- payee: {
3989
- type: 'string',
3990
- maxLength: 200
3991
- },
3992
- categoryAccount: {
3993
- type: 'string',
3994
- maxLength: 200
3995
- },
3996
- amount: {
3997
- type: 'number'
3998
4574
  },
3999
- currency: {
4000
- type: 'string',
4001
- maxLength: 10
4575
+ upsertByPayee: {
4576
+ type: 'boolean',
4577
+ description:
4578
+ 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
4002
4579
  }
4003
4580
  },
4004
- required: ['narration']
4581
+ required: ['name', 'matchLogic', 'priority']
4005
4582
  } as const;
4006
4583
 
4007
- export const $TestRuleResponseDto = {
4584
+ export const $ValidateRuleResponseDto = {
4008
4585
  type: 'object',
4009
4586
  properties: {
4010
- ruleId: {
4011
- type: 'string',
4012
- description: 'Rule ID that was tested'
4013
- },
4014
- matches: {
4587
+ valid: {
4015
4588
  type: 'boolean',
4016
- description: 'Whether the rule matched the test data'
4017
- },
4589
+ description: 'Whether the rule configuration is valid',
4590
+ example: true
4591
+ },
4592
+ errors: {
4593
+ description: 'List of validation errors (empty if valid)',
4594
+ example: [],
4595
+ items: {
4596
+ type: 'array'
4597
+ },
4598
+ type: 'array'
4599
+ },
4600
+ warnings: {
4601
+ description: 'List of validation warnings (non-blocking issues)',
4602
+ example: [
4603
+ 'No account constraints specified - rule will match any account'
4604
+ ],
4605
+ items: {
4606
+ type: 'array'
4607
+ },
4608
+ type: 'array'
4609
+ }
4610
+ },
4611
+ required: ['valid', 'errors', 'warnings']
4612
+ } as const;
4613
+
4614
+ export const $BulkCreateRulesDto = {
4615
+ type: 'object',
4616
+ properties: {
4617
+ rules: {
4618
+ items: {
4619
+ type: 'array'
4620
+ },
4621
+ description: 'Array of rules to import',
4622
+ type: 'array'
4623
+ },
4624
+ conflictStrategy: {
4625
+ type: 'string',
4626
+ enum: ['replace', 'skip'],
4627
+ default: 'skip',
4628
+ description:
4629
+ 'Conflict handling strategy: skip (default) ignores duplicates, replace soft-deletes existing rule'
4630
+ }
4631
+ },
4632
+ required: ['rules', 'conflictStrategy']
4633
+ } as const;
4634
+
4635
+ export const $BulkCreateRulesResponseDto = {
4636
+ type: 'object',
4637
+ properties: {
4638
+ successCount: {
4639
+ type: 'number',
4640
+ description: 'Number of successfully created rules'
4641
+ },
4642
+ failureCount: {
4643
+ type: 'number',
4644
+ description: 'Number of failed rules'
4645
+ },
4646
+ errors: {
4647
+ type: 'array',
4648
+ description: 'Error details for failed rules',
4649
+ items: {
4650
+ type: 'object',
4651
+ properties: {
4652
+ index: {
4653
+ type: 'number'
4654
+ },
4655
+ message: {
4656
+ type: 'string'
4657
+ }
4658
+ }
4659
+ }
4660
+ },
4661
+ createdRuleIds: {
4662
+ description: 'IDs of successfully created rules',
4663
+ type: 'array',
4664
+ items: {
4665
+ type: 'string'
4666
+ }
4667
+ }
4668
+ },
4669
+ required: ['successCount', 'failureCount', 'errors', 'createdRuleIds']
4670
+ } as const;
4671
+
4672
+ export const $ExportRulesResponseDto = {
4673
+ type: 'object',
4674
+ properties: {
4675
+ exportedAt: {
4676
+ type: 'string',
4677
+ description: 'Export timestamp'
4678
+ },
4679
+ userId: {
4680
+ type: 'string',
4681
+ description: 'User ID'
4682
+ },
4683
+ ruleCount: {
4684
+ type: 'number',
4685
+ description: 'Number of exported rules'
4686
+ },
4687
+ rules: {
4688
+ type: 'array',
4689
+ description: 'Exported rules'
4690
+ }
4691
+ },
4692
+ required: ['exportedAt', 'userId', 'ruleCount', 'rules']
4693
+ } as const;
4694
+
4695
+ export const $RuleStatisticsResponseDto = {
4696
+ type: 'object',
4697
+ properties: {
4698
+ period: {
4699
+ type: 'string',
4700
+ description: 'Statistics time period',
4701
+ enum: ['7d', '30d', '90d']
4702
+ },
4703
+ totalRules: {
4704
+ type: 'number',
4705
+ description: 'Total number of rules'
4706
+ },
4707
+ rulesWithMatches: {
4708
+ type: 'number',
4709
+ description: 'Number of rules with at least one match'
4710
+ },
4711
+ totalMatches: {
4712
+ type: 'number',
4713
+ description: 'Total number of matches across all rules'
4714
+ },
4715
+ averageConfidence: {
4716
+ type: 'number',
4717
+ description: 'Average confidence score across all matches',
4718
+ example: 0.82
4719
+ },
4720
+ ruleStats: {
4721
+ type: 'array',
4722
+ description: 'Per-rule statistics',
4723
+ items: {
4724
+ type: 'object',
4725
+ properties: {
4726
+ ruleId: {
4727
+ type: 'string'
4728
+ },
4729
+ ruleName: {
4730
+ type: 'string'
4731
+ },
4732
+ matchCount: {
4733
+ type: 'number'
4734
+ },
4735
+ averageConfidence: {
4736
+ type: 'number'
4737
+ }
4738
+ }
4739
+ }
4740
+ }
4741
+ },
4742
+ required: [
4743
+ 'period',
4744
+ 'totalRules',
4745
+ 'rulesWithMatches',
4746
+ 'totalMatches',
4747
+ 'averageConfidence',
4748
+ 'ruleStats'
4749
+ ]
4750
+ } as const;
4751
+
4752
+ export const $UpdateTransactionRuleDto = {
4753
+ type: 'object',
4754
+ properties: {
4755
+ name: {
4756
+ type: 'string',
4757
+ minLength: 1,
4758
+ maxLength: 100
4759
+ },
4760
+ description: {
4761
+ type: 'string',
4762
+ maxLength: 500
4763
+ },
4764
+ narrationKeywords: {
4765
+ items: {
4766
+ type: 'array'
4767
+ },
4768
+ maxItems: 50,
4769
+ type: 'array'
4770
+ },
4771
+ payeeKeywords: {
4772
+ items: {
4773
+ type: 'array'
4774
+ },
4775
+ maxItems: 50,
4776
+ type: 'array'
4777
+ },
4778
+ categoryKeywords: {
4779
+ items: {
4780
+ type: 'array'
4781
+ },
4782
+ maxItems: 50,
4783
+ type: 'array'
4784
+ },
4785
+ methodKeywords: {
4786
+ items: {
4787
+ type: 'array'
4788
+ },
4789
+ maxItems: 50,
4790
+ description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
4791
+ type: 'array'
4792
+ },
4793
+ categoryAccount: {
4794
+ type: 'string',
4795
+ maxLength: 200,
4796
+ description:
4797
+ 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
4798
+ },
4799
+ matchLogic: {
4800
+ type: 'string',
4801
+ enum: ['OR', 'AND']
4802
+ },
4803
+ amountMin: {
4804
+ type: 'number',
4805
+ minimum: 0,
4806
+ description: 'Minimum transaction amount (inclusive)'
4807
+ },
4808
+ amountMax: {
4809
+ type: 'number',
4810
+ minimum: 0,
4811
+ description: 'Maximum transaction amount (inclusive)'
4812
+ },
4813
+ priority: {
4814
+ type: 'number',
4815
+ minimum: 0,
4816
+ maximum: 1000
4817
+ },
4818
+ enabled: {
4819
+ type: 'boolean',
4820
+ description: 'Enable or disable the rule'
4821
+ },
4822
+ additionalTags: {
4823
+ items: {
4824
+ type: 'array'
4825
+ },
4826
+ maxItems: 20,
4827
+ type: 'array'
4828
+ },
4829
+ additionalMetadata: {
4830
+ type: 'object'
4831
+ }
4832
+ }
4833
+ } as const;
4834
+
4835
+ export const $TestRuleDto = {
4836
+ type: 'object',
4837
+ properties: {
4838
+ narration: {
4839
+ type: 'string',
4840
+ minLength: 1,
4841
+ maxLength: 500
4842
+ },
4843
+ payee: {
4844
+ type: 'string',
4845
+ maxLength: 200
4846
+ },
4847
+ categoryAccount: {
4848
+ type: 'string',
4849
+ maxLength: 200
4850
+ },
4851
+ amount: {
4852
+ type: 'number'
4853
+ },
4854
+ currency: {
4855
+ type: 'string',
4856
+ maxLength: 10
4857
+ }
4858
+ },
4859
+ required: ['narration']
4860
+ } as const;
4861
+
4862
+ export const $TestRuleResponseDto = {
4863
+ type: 'object',
4864
+ properties: {
4865
+ ruleId: {
4866
+ type: 'string',
4867
+ description: 'Rule ID that was tested'
4868
+ },
4869
+ matches: {
4870
+ type: 'boolean',
4871
+ description: 'Whether the rule matched the test data'
4872
+ },
4018
4873
  confidence: {
4019
4874
  type: 'number',
4020
4875
  description: 'Match confidence score (0-1)',
@@ -4033,151 +4888,393 @@ export const $TestRuleResponseDto = {
4033
4888
  required: ['ruleId', 'matches', 'confidence', 'matchDetails']
4034
4889
  } as const;
4035
4890
 
4036
- export const $DeleteOwnUserDto = {
4891
+ export const $CreateBeanEventDto = {
4037
4892
  type: 'object',
4038
4893
  properties: {
4039
- accessToken: {
4894
+ date: {
4040
4895
  type: 'string',
4041
- description: 'Access token for user verification',
4042
- example: 'abc123xyz'
4896
+ description: 'Life event date (ISO 8601)',
4897
+ example: '2024-03-15'
4898
+ },
4899
+ type: {
4900
+ type: 'string',
4901
+ description:
4902
+ 'Life event type (e.g., "employer", "location", "marital-status") — user-defined, no enum constraint at engine layer',
4903
+ example: 'employer'
4904
+ },
4905
+ description: {
4906
+ type: 'string',
4907
+ description:
4908
+ 'Life event description. Empty string is a VALID value (distinct from absence).',
4909
+ example: 'Acme Corp'
4910
+ },
4911
+ meta: {
4912
+ type: 'object',
4913
+ description:
4914
+ 'Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)',
4915
+ example: {
4916
+ note: 'Promotion'
4917
+ }
4043
4918
  }
4044
4919
  },
4045
- required: ['accessToken']
4920
+ required: ['date', 'type', 'description']
4046
4921
  } as const;
4047
4922
 
4048
- export const $SignupDto = {
4923
+ export const $EventResponseDto = {
4049
4924
  type: 'object',
4050
4925
  properties: {
4051
- turnstileToken: {
4926
+ id: {
4927
+ type: 'string',
4928
+ description: 'Unique identifier',
4929
+ example: 'uuid-123-456'
4930
+ },
4931
+ userId: {
4932
+ type: 'string',
4933
+ description: 'User ID (owner of the life event)',
4934
+ example: 'user-123'
4935
+ },
4936
+ date: {
4937
+ type: 'string',
4938
+ description: 'Life event date (ISO 8601 format)',
4939
+ example: '2024-03-15',
4940
+ format: 'date'
4941
+ },
4942
+ type: {
4052
4943
  type: 'string',
4053
4944
  description:
4054
- 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4055
- example: '0.abc123def456...'
4945
+ 'Life event type (user-defined, e.g., "employer", "location")',
4946
+ example: 'employer'
4947
+ },
4948
+ description: {
4949
+ type: 'string',
4950
+ description:
4951
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4952
+ example: 'Acme Corp'
4953
+ },
4954
+ meta: {
4955
+ type: 'object',
4956
+ description: 'Product-side metadata (free-form JSON)',
4957
+ example: {
4958
+ note: 'Promotion'
4959
+ }
4960
+ },
4961
+ createdAt: {
4962
+ format: 'date-time',
4963
+ type: 'string',
4964
+ description: 'Creation timestamp',
4965
+ example: '2024-03-15T10:00:00Z'
4966
+ },
4967
+ updatedAt: {
4968
+ format: 'date-time',
4969
+ type: 'string',
4970
+ description:
4971
+ 'Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.',
4972
+ example: '2024-03-15T10:00:00Z'
4056
4973
  }
4057
- }
4974
+ },
4975
+ required: [
4976
+ 'id',
4977
+ 'userId',
4978
+ 'date',
4979
+ 'type',
4980
+ 'description',
4981
+ 'meta',
4982
+ 'createdAt',
4983
+ 'updatedAt'
4984
+ ]
4058
4985
  } as const;
4059
4986
 
4060
- export const $UpdateUserSettingDto = {
4987
+ export const $EventListResponseDto = {
4061
4988
  type: 'object',
4062
4989
  properties: {
4063
- secId: {
4990
+ items: {
4991
+ description: 'List of life events',
4992
+ type: 'array',
4993
+ items: {
4994
+ $ref: '#/components/schemas/EventResponseDto'
4995
+ }
4996
+ },
4997
+ total: {
4064
4998
  type: 'number',
4065
- description: 'Security ID'
4999
+ description: 'Total number of life events matching the query',
5000
+ example: 42
5001
+ }
5002
+ },
5003
+ required: ['items', 'total']
5004
+ } as const;
5005
+
5006
+ export const $UpdateBeanEventDto = {
5007
+ type: 'object',
5008
+ properties: {
5009
+ date: {
5010
+ type: 'string',
5011
+ description: 'Life event date (ISO 8601)'
5012
+ },
5013
+ type: {
5014
+ type: 'string',
5015
+ description: 'Life event type (user-defined)'
5016
+ },
5017
+ description: {
5018
+ type: 'string',
5019
+ description:
5020
+ 'Life event description. Empty string is a VALID value (distinct from absence).'
5021
+ },
5022
+ meta: {
5023
+ type: 'object',
5024
+ description: 'Product-side metadata (free-form JSON)'
5025
+ }
5026
+ }
5027
+ } as const;
5028
+
5029
+ export const $OnboardingAccountDto = {
5030
+ type: 'object',
5031
+ properties: {
5032
+ path: {
5033
+ type: 'string',
5034
+ description:
5035
+ 'Account path (Assets/Liabilities only; format validated by the account service)',
5036
+ example: 'Assets:Checking'
5037
+ },
5038
+ currency: {
5039
+ type: 'string',
5040
+ description: 'ISO 4217 currency code (3 letters)',
5041
+ example: 'USD'
5042
+ },
5043
+ openingBalance: {
5044
+ type: 'string',
5045
+ description:
5046
+ 'Opening balance as a non-negative Decimal string (e.g. "1000.00")',
5047
+ example: '1000.00'
5048
+ },
5049
+ platformId: {
5050
+ type: 'string',
5051
+ description:
5052
+ 'Platform ID to bind the account to (references Platform.id); omit for unbound',
5053
+ example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
5054
+ }
5055
+ },
5056
+ required: ['path', 'currency']
5057
+ } as const;
5058
+
5059
+ export const $OnboardingDto = {
5060
+ type: 'object',
5061
+ properties: {
5062
+ accounts: {
5063
+ description: 'Asset/Liability accounts to register with opening balances',
5064
+ type: 'array',
5065
+ items: {
5066
+ $ref: '#/components/schemas/OnboardingAccountDto'
5067
+ }
5068
+ },
5069
+ skipAssetRegistration: {
5070
+ type: 'boolean',
5071
+ description:
5072
+ 'Skip asset registration; only bootstrap the core account set',
5073
+ default: false
5074
+ }
5075
+ }
5076
+ } as const;
5077
+
5078
+ export const $ActualBalanceDto = {
5079
+ type: 'object',
5080
+ properties: {
5081
+ amount: {
5082
+ type: 'string',
5083
+ description:
5084
+ 'Actual balance amount as a decimal string (preserves precision for tolerance inference).',
5085
+ example: '1234.56'
5086
+ },
5087
+ ccy: {
5088
+ type: 'string',
5089
+ description: 'Currency code (ISO 4217 or commodity ticker).',
5090
+ example: 'CNY'
5091
+ }
5092
+ },
5093
+ required: ['amount', 'ccy']
5094
+ } as const;
5095
+
5096
+ export const $ComputeReconciliationDto = {
5097
+ type: 'object',
5098
+ properties: {
5099
+ accountId: {
5100
+ type: 'string',
5101
+ description: 'BeanAccount id to reconcile.'
5102
+ },
5103
+ asOfDate: {
5104
+ type: 'string',
5105
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5106
+ example: '2026-07-24'
5107
+ },
5108
+ actualBalance: {
5109
+ description: 'Actual balance from the external statement.',
5110
+ allOf: [
5111
+ {
5112
+ $ref: '#/components/schemas/ActualBalanceDto'
5113
+ }
5114
+ ]
5115
+ }
5116
+ },
5117
+ required: ['accountId', 'asOfDate', 'actualBalance']
5118
+ } as const;
5119
+
5120
+ export const $ReconciliationComputeResultDto = {
5121
+ type: 'object',
5122
+ properties: {
5123
+ accountId: {
5124
+ type: 'string'
5125
+ },
5126
+ asOfDate: {
5127
+ type: 'string'
4066
5128
  },
4067
- annualInterestRate: {
4068
- type: 'number',
4069
- description: 'Annual interest rate',
4070
- example: 0.05
5129
+ bookBalance: {
5130
+ type: 'string',
5131
+ description: 'System-computed book balance (decimal string).'
4071
5132
  },
4072
- currency: {
5133
+ actualBalance: {
4073
5134
  type: 'string',
4074
- description: 'Currency code',
4075
- example: 'USD'
5135
+ description: 'User-entered actual balance (decimal string).'
4076
5136
  },
4077
- baseCurrency: {
5137
+ currency: {
5138
+ type: 'string'
5139
+ },
5140
+ diff: {
4078
5141
  type: 'string',
4079
- description: 'Base currency code',
4080
- example: 'USD'
5142
+ description: 'Diff = book − actual (decimal string).'
4081
5143
  },
4082
- benchmark: {
5144
+ tolerance: {
4083
5145
  type: 'string',
4084
- description: 'Benchmark symbol',
4085
- example: 'SPY'
5146
+ description: 'Applied tolerance (decimal string).'
4086
5147
  },
4087
- colorScheme: {
5148
+ withinTolerance: {
5149
+ type: 'boolean',
5150
+ description: 'true when |diff| ≤ tolerance.'
5151
+ },
5152
+ suggestedAction: {
4088
5153
  type: 'string',
4089
- description: 'Color scheme',
4090
- enum: ['DARK', 'LIGHT']
5154
+ enum: ['assert', 'pad'],
5155
+ description:
5156
+ 'Suggested next action: assert when within tolerance, pad otherwise.'
5157
+ }
5158
+ },
5159
+ required: [
5160
+ 'accountId',
5161
+ 'asOfDate',
5162
+ 'bookBalance',
5163
+ 'actualBalance',
5164
+ 'currency',
5165
+ 'diff',
5166
+ 'tolerance',
5167
+ 'withinTolerance',
5168
+ 'suggestedAction'
5169
+ ]
5170
+ } as const;
5171
+
5172
+ export const $AssertReconciliationDto = {
5173
+ type: 'object',
5174
+ properties: {
5175
+ accountId: {
5176
+ type: 'string',
5177
+ description: 'BeanAccount id to reconcile.'
4091
5178
  },
4092
- dateRange: {
5179
+ asOfDate: {
4093
5180
  type: 'string',
4094
- description: 'Date range filter',
4095
- example: '1y'
5181
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5182
+ example: '2026-07-24'
4096
5183
  },
4097
- emergencyFund: {
4098
- type: 'number',
4099
- description: 'Emergency fund amount',
4100
- example: 10000
5184
+ actualBalance: {
5185
+ description: 'Actual balance from the external statement.',
5186
+ allOf: [
5187
+ {
5188
+ $ref: '#/components/schemas/ActualBalanceDto'
5189
+ }
5190
+ ]
4101
5191
  },
4102
- 'filters.accounts': {
4103
- description: 'Account filter IDs',
4104
- type: 'array',
4105
- items: {
4106
- type: 'string'
4107
- }
5192
+ tolerance: {
5193
+ type: 'string',
5194
+ description:
5195
+ 'Optional explicit tolerance override. Omit to infer from amount precision (Beancount default).',
5196
+ example: '0.01'
5197
+ }
5198
+ },
5199
+ required: ['accountId', 'asOfDate', 'actualBalance']
5200
+ } as const;
5201
+
5202
+ export const $ReconciliationRecordDto = {
5203
+ type: 'object',
5204
+ properties: {
5205
+ id: {
5206
+ type: 'string'
4108
5207
  },
4109
- 'filters.assetClasses': {
4110
- description: 'Asset class filters',
4111
- type: 'array',
4112
- items: {
4113
- type: 'string'
4114
- }
5208
+ accountId: {
5209
+ type: 'string'
4115
5210
  },
4116
- 'filters.dataSource': {
4117
- type: 'string',
4118
- description: 'Data source filter'
5211
+ date: {
5212
+ type: 'string'
4119
5213
  },
4120
- 'filters.symbol': {
5214
+ amount: {
4121
5215
  type: 'string',
4122
- description: 'Symbol filter'
5216
+ description: 'Asserted (actual) amount.'
4123
5217
  },
4124
- 'filters.tags': {
4125
- description: 'Tag filters',
4126
- type: 'array',
4127
- items: {
4128
- type: 'string'
4129
- }
4130
- },
4131
- isExperimentalFeatures: {
4132
- type: 'boolean',
4133
- description: 'Enable experimental features'
5218
+ currency: {
5219
+ type: 'string'
4134
5220
  },
4135
- isRestrictedView: {
4136
- type: 'boolean',
4137
- description: 'Enable restricted view mode'
5221
+ tolerance: {
5222
+ type: 'string'
4138
5223
  },
4139
- language: {
5224
+ diffAmount: {
4140
5225
  type: 'string',
4141
- description: 'Language code',
4142
- example: 'en'
5226
+ description: 'book − actual.'
4143
5227
  },
4144
- locale: {
4145
- type: 'string',
4146
- description: 'Locale code',
4147
- example: 'en-US'
5228
+ diffCurrency: {
5229
+ type: 'string'
4148
5230
  },
4149
- projectedTotalAmount: {
4150
- type: 'number',
4151
- description: 'Projected total amount',
4152
- example: 1000000
5231
+ createdAt: {
5232
+ type: 'string'
5233
+ }
5234
+ },
5235
+ required: ['id', 'accountId', 'date', 'amount', 'currency', 'createdAt']
5236
+ } as const;
5237
+
5238
+ export const $PadReconciliationDto = {
5239
+ type: 'object',
5240
+ properties: {
5241
+ accountId: {
5242
+ type: 'string',
5243
+ description: 'BeanAccount id to reconcile.'
4153
5244
  },
4154
- retirementDate: {
5245
+ asOfDate: {
4155
5246
  type: 'string',
4156
- description: 'Retirement date in ISO 8601 format',
4157
- example: '2050-01-01'
5247
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5248
+ example: '2026-07-24'
4158
5249
  },
4159
- savingsRate: {
4160
- type: 'number',
4161
- description: 'Savings rate percentage',
4162
- example: 0.2
5250
+ actualBalance: {
5251
+ description: 'Actual balance from the external statement.',
5252
+ allOf: [
5253
+ {
5254
+ $ref: '#/components/schemas/ActualBalanceDto'
5255
+ }
5256
+ ]
4163
5257
  },
4164
- viewMode: {
5258
+ sourceAccount: {
4165
5259
  type: 'string',
4166
- description: 'View mode',
4167
- enum: ['DEFAULT', 'ZEN']
5260
+ description:
5261
+ 'Pad source account. Defaults to Equity:Opening-Balances (official Beancount convention).',
5262
+ example: 'Equity:Opening-Balances',
5263
+ default: 'Equity:Opening-Balances'
4168
5264
  }
4169
- }
5265
+ },
5266
+ required: ['accountId', 'asOfDate', 'actualBalance']
4170
5267
  } as const;
4171
5268
 
4172
- export const $UpdatePropertyDto = {
5269
+ export const $PadResultDto = {
4173
5270
  type: 'object',
4174
5271
  properties: {
4175
- value: {
5272
+ transactionId: {
4176
5273
  type: 'string',
4177
- description: 'Property value'
5274
+ description: 'Created pad adjusting transaction id.'
4178
5275
  }
4179
5276
  },
4180
- required: ['value']
5277
+ required: ['transactionId']
4181
5278
  } as const;
4182
5279
 
4183
5280
  export const $FileImportDto = {
@@ -4346,7 +5443,7 @@ export const $IdentifyResultDto = {
4346
5443
  account: {
4347
5444
  type: 'string',
4348
5445
  description: 'Default account used by this importer',
4349
- example: 'Assets:Alipay:Balance'
5446
+ example: 'Assets:CN:Alipay:Balance'
4350
5447
  },
4351
5448
  message: {
4352
5449
  type: 'string',
@@ -4363,7 +5460,7 @@ export const $MapperDefaultsDto = {
4363
5460
  sourceAccount: {
4364
5461
  type: 'string',
4365
5462
  description: 'Source account for transactions (Beancount format)',
4366
- example: 'Assets:Alipay:Balance'
5463
+ example: 'Assets:CN:Alipay:Balance'
4367
5464
  },
4368
5465
  currency: {
4369
5466
  type: 'string',
@@ -4400,7 +5497,7 @@ export const $MapperDefaultsDto = {
4400
5497
  description:
4401
5498
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4402
5499
  example: {
4403
- HuaBei: 'Liabilities:Alipay:Huabei',
5500
+ HuaBei: 'Liabilities:CN:CreditLine',
4404
5501
  CreditCard: 'Liabilities:CreditCard'
4405
5502
  }
4406
5503
  }
@@ -4532,7 +5629,7 @@ export const $UpdateMapperDefaultsDto = {
4532
5629
  sourceAccount: {
4533
5630
  type: 'string',
4534
5631
  description: 'Source account for transactions (Beancount format)',
4535
- example: 'Assets:Alipay:Balance',
5632
+ example: 'Assets:CN:Alipay:Balance',
4536
5633
  pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4537
5634
  },
4538
5635
  currency: {
@@ -4560,7 +5657,7 @@ export const $UpdateMapperDefaultsDto = {
4560
5657
  description:
4561
5658
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4562
5659
  example: {
4563
- HuaBei: 'Liabilities:Alipay:Huabei',
5660
+ HuaBei: 'Liabilities:CN:CreditLine',
4564
5661
  CreditCard: 'Liabilities:CreditCard'
4565
5662
  }
4566
5663
  }
@@ -4584,119 +5681,13 @@ export const $UpdateConfigDataDto = {
4584
5681
  export const $UpdateImporterConfigDto = {
4585
5682
  type: 'object',
4586
5683
  properties: {
4587
- data: {
4588
- description: 'Configuration data (v1 schema)',
4589
- allOf: [
4590
- {
4591
- $ref: '#/components/schemas/UpdateConfigDataDto'
4592
- }
4593
- ]
4594
- }
4595
- }
4596
- } as const;
4597
-
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'
5684
+ data: {
5685
+ description: 'Configuration data (v1 schema)',
5686
+ allOf: [
5687
+ {
5688
+ $ref: '#/components/schemas/UpdateConfigDataDto'
5689
+ }
5690
+ ]
4700
5691
  }
4701
5692
  }
4702
5693
  } as const;
@@ -4707,7 +5698,7 @@ export const $ProviderSyncConfigDto = {
4707
5698
  sourceAccount: {
4708
5699
  type: 'string',
4709
5700
  description: 'Source account for the first posting',
4710
- example: 'Assets:Bank:Chase'
5701
+ example: 'Assets:US:Chase:Checking'
4711
5702
  },
4712
5703
  defaultCurrency: {
4713
5704
  type: 'string',
@@ -4728,6 +5719,12 @@ export const $ProviderSyncConfigDto = {
4728
5719
  type: 'boolean',
4729
5720
  description: 'Filter pending transactions',
4730
5721
  default: true
5722
+ },
5723
+ externalAccountId: {
5724
+ type: 'string',
5725
+ description:
5726
+ 'External account ID for per-batch providers (e.g. GoCardless). Overrides sourceAccount when an ExternalAccountLink mapping exists.',
5727
+ example: 'acc_gocardless_001'
4731
5728
  }
4732
5729
  },
4733
5730
  required: [
@@ -4847,6 +5844,94 @@ export const $SupportedProvidersResponseDto = {
4847
5844
  required: ['providers']
4848
5845
  } as const;
4849
5846
 
5847
+ export const $CreateExternalAccountLinkDto = {
5848
+ type: 'object',
5849
+ properties: {
5850
+ provider: {
5851
+ type: 'string',
5852
+ enum: [
5853
+ 'plaid',
5854
+ 'teller',
5855
+ 'truelayer',
5856
+ 'gocardless',
5857
+ 'simplefin',
5858
+ 'yodlee',
5859
+ 'beancount-direct',
5860
+ 'parsed-bill'
5861
+ ],
5862
+ example: 'plaid',
5863
+ description: 'Open Banking provider (whitelist)'
5864
+ },
5865
+ externalAccountId: {
5866
+ type: 'string',
5867
+ example: 'acc-plaid-001',
5868
+ description: 'External account ID from the provider'
5869
+ },
5870
+ beanAccountId: {
5871
+ type: 'string',
5872
+ example: '550e8400-e29b-41d4-a716-446655440000',
5873
+ description: 'Target BeanAccount ID (must belong to the JWT user)'
5874
+ }
5875
+ },
5876
+ required: ['provider', 'externalAccountId', 'beanAccountId']
5877
+ } as const;
5878
+
5879
+ export const $ExternalAccountLinkResponseDto = {
5880
+ type: 'object',
5881
+ properties: {
5882
+ id: {
5883
+ type: 'string'
5884
+ },
5885
+ provider: {
5886
+ type: 'string'
5887
+ },
5888
+ externalAccountId: {
5889
+ type: 'string'
5890
+ },
5891
+ beanAccountId: {
5892
+ type: 'string'
5893
+ },
5894
+ isActive: {
5895
+ type: 'boolean'
5896
+ },
5897
+ createdAt: {
5898
+ type: 'string'
5899
+ },
5900
+ updatedAt: {
5901
+ type: 'string'
5902
+ }
5903
+ },
5904
+ required: [
5905
+ 'id',
5906
+ 'provider',
5907
+ 'externalAccountId',
5908
+ 'beanAccountId',
5909
+ 'isActive',
5910
+ 'createdAt',
5911
+ 'updatedAt'
5912
+ ]
5913
+ } as const;
5914
+
5915
+ export const $ExternalAccountLinkListResponseDto = {
5916
+ type: 'object',
5917
+ properties: {
5918
+ items: {
5919
+ type: 'array',
5920
+ items: {
5921
+ $ref: '#/components/schemas/ExternalAccountLinkResponseDto'
5922
+ }
5923
+ },
5924
+ total: {
5925
+ type: 'number'
5926
+ },
5927
+ provider: {
5928
+ type: 'string',
5929
+ description: 'Filter by provider (query param)'
5930
+ }
5931
+ },
5932
+ required: ['items', 'total']
5933
+ } as const;
5934
+
4850
5935
  export const $ParserTelemetryReportDto = {
4851
5936
  type: 'object',
4852
5937
  properties: {}
@@ -4881,6 +5966,18 @@ export const $ProcessNlpDto = {
4881
5966
  currency: 'CNY',
4882
5967
  payee: 'Starbucks'
4883
5968
  }
5969
+ },
5970
+ selectedRuleId: {
5971
+ type: 'string',
5972
+ description:
5973
+ '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.',
5974
+ example: 'rule_abc123'
5975
+ },
5976
+ selectedAccount: {
5977
+ type: 'string',
5978
+ description:
5979
+ '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.',
5980
+ example: 'Expenses:Food:Coffee'
4884
5981
  }
4885
5982
  },
4886
5983
  required: ['message']
@@ -5205,7 +6302,8 @@ export const $NlpAccountConfirmationDataDto = {
5205
6302
  },
5206
6303
  suggestedAccount: {
5207
6304
  type: 'string',
5208
- description: 'Suggested replacement account',
6305
+ description:
6306
+ 'Suggested replacement account (omitted when no clear candidate)',
5209
6307
  example: 'Expenses:Food:Drinks'
5210
6308
  },
5211
6309
  similarAccounts: {
@@ -5227,7 +6325,6 @@ export const $NlpAccountConfirmationDataDto = {
5227
6325
  },
5228
6326
  required: [
5229
6327
  'invalidAccount',
5230
- 'suggestedAccount',
5231
6328
  'similarAccounts',
5232
6329
  'errorMessage',
5233
6330
  'transactionContext'
@@ -5396,11 +6493,12 @@ export const $NlpSuggestedAccountDto = {
5396
6493
  account: {
5397
6494
  type: 'string',
5398
6495
  description: 'Suggested account path',
5399
- example: 'Assets:Bank:Checking'
6496
+ example: 'Assets:Checking'
5400
6497
  },
5401
6498
  confidence: {
5402
6499
  type: 'number',
5403
- description: 'Confidence score for this suggestion (0-1)',
6500
+ description:
6501
+ 'Confidence score for this suggestion (0-1). Present = predicted (confirm/confirm_rule/confirm_account); omitted = actual persisted account (created). (#586)',
5404
6502
  example: 0.9
5405
6503
  }
5406
6504
  },
@@ -5436,23 +6534,31 @@ export const $NlpDefaultAccountsDto = {
5436
6534
  properties: {
5437
6535
  asset: {
5438
6536
  type: 'string',
5439
- description: 'Default asset account',
5440
- example: 'Assets:Bank:Checking'
6537
+ description:
6538
+ 'Default OPEN asset account (MRU when multiple), or null when none/ambiguous',
6539
+ example: 'Assets:Checking',
6540
+ nullable: true
5441
6541
  },
5442
6542
  expense: {
5443
6543
  type: 'string',
5444
- description: 'Default expense account',
5445
- example: 'Expenses:Uncategorized'
6544
+ description:
6545
+ 'Default OPEN expense account (MRU when multiple), or null when none/ambiguous',
6546
+ example: 'Expenses:Food:Coffee',
6547
+ nullable: true
5446
6548
  },
5447
6549
  income: {
5448
6550
  type: 'string',
5449
- description: 'Default income account',
5450
- example: 'Income:Uncategorized'
6551
+ description:
6552
+ 'Default OPEN income account (MRU when multiple), or null when none/ambiguous',
6553
+ example: 'Income:Salary',
6554
+ nullable: true
5451
6555
  },
5452
6556
  liability: {
5453
6557
  type: 'string',
5454
- description: 'Default liability account',
5455
- example: 'Liabilities:CreditCard'
6558
+ description:
6559
+ 'Default OPEN liability account (MRU when multiple), or null when none/ambiguous',
6560
+ example: 'Liabilities:CreditCard',
6561
+ nullable: true
5456
6562
  }
5457
6563
  },
5458
6564
  required: ['asset', 'expense', 'income', 'liability']
@@ -5477,7 +6583,8 @@ export const $NlpResponseDto = {
5477
6583
  'confirm_rule',
5478
6584
  'confirm_account',
5479
6585
  'confirm_payee',
5480
- 'cancel'
6586
+ 'cancel',
6587
+ 'aborted'
5481
6588
  ]
5482
6589
  },
5483
6590
  intent: {
@@ -5639,7 +6746,7 @@ export const $NlpResponseDto = {
5639
6746
  },
5640
6747
  suggestedAccounts: {
5641
6748
  description:
5642
- 'Suggested accounts for this transaction. Contains recommended source and destination accounts based on the detected intent and rules.',
6749
+ '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.',
5643
6750
  allOf: [
5644
6751
  {
5645
6752
  $ref: '#/components/schemas/NlpSuggestedAccountsDto'
@@ -5648,7 +6755,7 @@ export const $NlpResponseDto = {
5648
6755
  },
5649
6756
  defaultAccounts: {
5650
6757
  description:
5651
- 'Default accounts for the user/region. These are fallback accounts used when no specific suggestion is available.',
6758
+ 'Default fallback accounts for the user/region (#586). v1 returns universal constants; per-user personalization is planned.',
5652
6759
  allOf: [
5653
6760
  {
5654
6761
  $ref: '#/components/schemas/NlpDefaultAccountsDto'
@@ -5656,24 +6763,255 @@ export const $NlpResponseDto = {
5656
6763
  ]
5657
6764
  }
5658
6765
  },
5659
- required: ['status', 'action']
6766
+ required: ['status', 'action']
6767
+ } as const;
6768
+
6769
+ export const $PlatformListItemDto = {
6770
+ type: 'object',
6771
+ properties: {
6772
+ id: {
6773
+ type: 'string',
6774
+ description: 'Global platform ID'
6775
+ },
6776
+ name: {
6777
+ type: 'string',
6778
+ description: 'Platform name'
6779
+ },
6780
+ url: {
6781
+ type: 'string',
6782
+ description: 'Platform URL'
6783
+ },
6784
+ type: {
6785
+ type: 'string',
6786
+ description: 'Platform type',
6787
+ enum: [
6788
+ 'BANK',
6789
+ 'BROKERAGE',
6790
+ 'CRYPTO_EXCHANGE',
6791
+ 'PAYMENT',
6792
+ 'INVESTMENT',
6793
+ 'INSURANCE',
6794
+ 'OTHER'
6795
+ ]
6796
+ },
6797
+ canonical: {
6798
+ type: 'string',
6799
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6800
+ },
6801
+ suggestedSegment: {
6802
+ type: 'string',
6803
+ description:
6804
+ 'Suggested path segment — canonical with first char uppercased (ACC_COMP_NAME_RE)'
6805
+ },
6806
+ logoUrl: {
6807
+ type: 'string',
6808
+ description: 'Logo URL',
6809
+ nullable: true
6810
+ },
6811
+ isBound: {
6812
+ type: 'boolean',
6813
+ description: 'Whether user has accounts using this platform'
6814
+ }
6815
+ },
6816
+ required: [
6817
+ 'id',
6818
+ 'name',
6819
+ 'url',
6820
+ 'type',
6821
+ 'canonical',
6822
+ 'suggestedSegment',
6823
+ 'logoUrl',
6824
+ 'isBound'
6825
+ ]
6826
+ } as const;
6827
+
6828
+ export const $PlatformMatchResultDto = {
6829
+ type: 'object',
6830
+ properties: {
6831
+ id: {
6832
+ type: 'string',
6833
+ description: 'Global platform ID'
6834
+ },
6835
+ name: {
6836
+ type: 'string',
6837
+ description: 'Platform name (e.g., "ICBC")'
6838
+ },
6839
+ canonical: {
6840
+ type: 'string',
6841
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6842
+ },
6843
+ type: {
6844
+ type: 'string',
6845
+ description: 'Platform type',
6846
+ enum: [
6847
+ 'BANK',
6848
+ 'BROKERAGE',
6849
+ 'CRYPTO_EXCHANGE',
6850
+ 'PAYMENT',
6851
+ 'INVESTMENT',
6852
+ 'INSURANCE',
6853
+ 'OTHER'
6854
+ ]
6855
+ },
6856
+ suggestedSegment: {
6857
+ type: 'string',
6858
+ description:
6859
+ 'Suggested path segment — canonical, already in ACCOUNT_RE format'
6860
+ },
6861
+ logoUrl: {
6862
+ type: 'string',
6863
+ description: 'Logo URL',
6864
+ nullable: true
6865
+ },
6866
+ matchType: {
6867
+ type: 'string',
6868
+ description: "How this row matched: 'exact' > 'prefix' > 'substring'",
6869
+ enum: ['exact', 'prefix', 'substring']
6870
+ }
6871
+ },
6872
+ required: [
6873
+ 'id',
6874
+ 'name',
6875
+ 'canonical',
6876
+ 'type',
6877
+ 'suggestedSegment',
6878
+ 'logoUrl',
6879
+ 'matchType'
6880
+ ]
6881
+ } as const;
6882
+
6883
+ export const $PlatformMatchResponseDto = {
6884
+ type: 'object',
6885
+ properties: {
6886
+ platforms: {
6887
+ description: 'Ranked matches, best tier first (at most 10 rows)',
6888
+ type: 'array',
6889
+ items: {
6890
+ $ref: '#/components/schemas/PlatformMatchResultDto'
6891
+ }
6892
+ },
6893
+ matchType: {
6894
+ type: 'string',
6895
+ description:
6896
+ "Overall match quality — top row's tier, or 'none' when no hits",
6897
+ enum: ['none', 'exact', 'prefix', 'substring']
6898
+ },
6899
+ total: {
6900
+ type: 'number',
6901
+ description: 'Total matches before LIMIT (truncation transparency)'
6902
+ },
6903
+ hasMore: {
6904
+ type: 'boolean',
6905
+ description: 'true when total > platforms.length (more matches exist)'
6906
+ }
6907
+ },
6908
+ required: ['platforms', 'matchType', 'total', 'hasMore']
6909
+ } as const;
6910
+
6911
+ export const $CreatePlatformDto = {
6912
+ type: 'object',
6913
+ properties: {
6914
+ name: {
6915
+ type: 'string',
6916
+ description: 'Platform name',
6917
+ example: 'Binance'
6918
+ },
6919
+ canonical: {
6920
+ type: 'string',
6921
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6922
+ example: 'binance'
6923
+ },
6924
+ aliases: {
6925
+ description: 'Platform aliases (multi-language names for lookup)',
6926
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6927
+ type: 'array',
6928
+ items: {
6929
+ type: 'string'
6930
+ }
6931
+ },
6932
+ url: {
6933
+ type: 'string',
6934
+ description: 'Platform URL',
6935
+ example: 'https://www.binance.com'
6936
+ },
6937
+ type: {
6938
+ type: 'string',
6939
+ description: 'Platform type',
6940
+ enum: [
6941
+ 'BANK',
6942
+ 'BROKERAGE',
6943
+ 'CRYPTO_EXCHANGE',
6944
+ 'PAYMENT',
6945
+ 'INVESTMENT',
6946
+ 'INSURANCE',
6947
+ 'OTHER'
6948
+ ],
6949
+ example: 'CRYPTO_EXCHANGE'
6950
+ },
6951
+ logoUrl: {
6952
+ type: 'string',
6953
+ description: 'Platform logo URL',
6954
+ example: 'https://example.com/logos/binance.png'
6955
+ },
6956
+ isActive: {
6957
+ type: 'boolean',
6958
+ description: 'Whether the platform is active',
6959
+ default: true
6960
+ }
6961
+ },
6962
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
5660
6963
  } as const;
5661
6964
 
5662
- export const $BalanceByCurrencyDto = {
6965
+ export const $UpdatePlatformDto = {
5663
6966
  type: 'object',
5664
6967
  properties: {
5665
- currency: {
6968
+ name: {
5666
6969
  type: 'string',
5667
- description: 'ISO 4217 currency code',
5668
- example: 'CNY'
6970
+ description: 'Platform name',
6971
+ example: 'Binance'
5669
6972
  },
5670
- balance: {
6973
+ canonical: {
5671
6974
  type: 'string',
5672
- description: 'Balance amount',
5673
- example: '50000.00'
6975
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6976
+ example: 'binance'
6977
+ },
6978
+ aliases: {
6979
+ description: 'Platform aliases (multi-language names for lookup)',
6980
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6981
+ type: 'array',
6982
+ items: {
6983
+ type: 'string'
6984
+ }
6985
+ },
6986
+ url: {
6987
+ type: 'string',
6988
+ description: 'Platform URL',
6989
+ example: 'https://www.binance.com'
6990
+ },
6991
+ type: {
6992
+ type: 'string',
6993
+ description: 'Platform type',
6994
+ enum: [
6995
+ 'BANK',
6996
+ 'BROKERAGE',
6997
+ 'CRYPTO_EXCHANGE',
6998
+ 'PAYMENT',
6999
+ 'INVESTMENT',
7000
+ 'INSURANCE',
7001
+ 'OTHER'
7002
+ ],
7003
+ example: 'CRYPTO_EXCHANGE'
7004
+ },
7005
+ logoUrl: {
7006
+ type: 'string',
7007
+ description: 'Platform logo URL',
7008
+ example: 'https://example.com/logos/binance.png'
7009
+ },
7010
+ isActive: {
7011
+ type: 'boolean',
7012
+ description: 'Whether the platform is active'
5674
7013
  }
5675
- },
5676
- required: ['currency', 'balance']
7014
+ }
5677
7015
  } as const;
5678
7016
 
5679
7017
  export const $NetWorthByCurrencyDto = {
@@ -5745,28 +7083,6 @@ export const $ConvertedNetWorthDto = {
5745
7083
  ]
5746
7084
  } as const;
5747
7085
 
5748
- export const $ExchangeRateWarningDto = {
5749
- type: 'object',
5750
- properties: {
5751
- type: {
5752
- type: 'string',
5753
- description: 'Warning type',
5754
- example: 'MISSING_EXCHANGE_RATE'
5755
- },
5756
- currency: {
5757
- type: 'string',
5758
- description: 'Currency without exchange rate',
5759
- example: 'EUR'
5760
- },
5761
- totalAmount: {
5762
- type: 'string',
5763
- description: 'Total amount affected',
5764
- example: '1000.00'
5765
- }
5766
- },
5767
- required: ['type', 'currency', 'totalAmount']
5768
- } as const;
5769
-
5770
7086
  export const $NetWorthResponseDto = {
5771
7087
  type: 'object',
5772
7088
  properties: {
@@ -5852,7 +7168,7 @@ export const $AccountItemDto = {
5852
7168
  name: {
5853
7169
  type: 'string',
5854
7170
  description: 'Full account name',
5855
- example: 'Assets:Bank:CMB:Savings'
7171
+ example: 'Assets:CN:CMB:Savings'
5856
7172
  },
5857
7173
  displayName: {
5858
7174
  type: 'string',
@@ -5868,6 +7184,12 @@ export const $AccountItemDto = {
5868
7184
  type: 'string',
5869
7185
  description: 'Currency code',
5870
7186
  example: 'CNY'
7187
+ },
7188
+ convertedBalance: {
7189
+ type: 'string',
7190
+ description:
7191
+ 'FX-converted balance in base currency; omitted when not convertible',
7192
+ example: '50000.00'
5871
7193
  }
5872
7194
  },
5873
7195
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -5894,11 +7216,66 @@ export const $PlatformGroupDto = {
5894
7216
  },
5895
7217
  totalBalance: {
5896
7218
  type: 'string',
5897
- description: 'Total balance across all accounts in platform',
7219
+ description: 'FX-converted total balance in base currency',
7220
+ example: '100000.00'
7221
+ },
7222
+ balanceByCurrency: {
7223
+ description: 'Raw (unconverted) balances grouped by currency',
7224
+ type: 'array',
7225
+ items: {
7226
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7227
+ }
7228
+ },
7229
+ convertedBalance: {
7230
+ type: 'string',
7231
+ description:
7232
+ 'Converted balance in base currency (omitted when no currency is convertible)',
5898
7233
  example: '100000.00'
7234
+ },
7235
+ sharePct: {
7236
+ type: 'number',
7237
+ description:
7238
+ 'Share of the grand converted total (0-100); 0 when grand total is 0',
7239
+ example: 42.5
7240
+ }
7241
+ },
7242
+ required: [
7243
+ 'platformId',
7244
+ 'platformName',
7245
+ 'accounts',
7246
+ 'totalBalance',
7247
+ 'balanceByCurrency',
7248
+ 'sharePct'
7249
+ ]
7250
+ } as const;
7251
+
7252
+ export const $AccountExchangeRateWarningDto = {
7253
+ type: 'object',
7254
+ properties: {
7255
+ type: {
7256
+ type: 'string',
7257
+ description: 'Warning type',
7258
+ example: 'MISSING_EXCHANGE_RATE'
7259
+ },
7260
+ currency: {
7261
+ type: 'string',
7262
+ description: 'Currency without exchange rate',
7263
+ example: 'USD'
7264
+ },
7265
+ accounts: {
7266
+ description: 'Affected account paths',
7267
+ type: 'array',
7268
+ items: {
7269
+ type: 'string'
7270
+ }
7271
+ },
7272
+ totalAmount: {
7273
+ type: 'string',
7274
+ description: 'Total amount in this currency',
7275
+ example: '5000.00'
5899
7276
  }
5900
7277
  },
5901
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
7278
+ required: ['type', 'currency', 'accounts', 'totalAmount']
5902
7279
  } as const;
5903
7280
 
5904
7281
  export const $AccountsSummaryDto = {
@@ -5911,9 +7288,21 @@ export const $AccountsSummaryDto = {
5911
7288
  totalPlatforms: {
5912
7289
  type: 'number',
5913
7290
  description: 'Total number of platforms'
7291
+ },
7292
+ baseCurrency: {
7293
+ type: 'string',
7294
+ description: 'Base currency for conversion',
7295
+ example: 'CNY'
7296
+ },
7297
+ warnings: {
7298
+ description: 'Per-account exchange rate warnings',
7299
+ type: 'array',
7300
+ items: {
7301
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
7302
+ }
5914
7303
  }
5915
7304
  },
5916
- required: ['totalAccounts', 'totalPlatforms']
7305
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
5917
7306
  } as const;
5918
7307
 
5919
7308
  export const $AccountsResponseDto = {
@@ -5948,7 +7337,7 @@ export const $AccountItemWithAssetClassDto = {
5948
7337
  name: {
5949
7338
  type: 'string',
5950
7339
  description: 'Full account name',
5951
- example: 'Assets:Bank:CMB:Savings'
7340
+ example: 'Assets:CN:CMB:Savings'
5952
7341
  },
5953
7342
  displayName: {
5954
7343
  type: 'string',
@@ -5965,6 +7354,12 @@ export const $AccountItemWithAssetClassDto = {
5965
7354
  description: 'Currency code',
5966
7355
  example: 'CNY'
5967
7356
  },
7357
+ convertedBalance: {
7358
+ type: 'string',
7359
+ description:
7360
+ 'FX-converted balance in base currency; omitted when not convertible',
7361
+ example: '50000.00'
7362
+ },
5968
7363
  assetClass: {
5969
7364
  type: 'string',
5970
7365
  description: 'Asset class',
@@ -6044,35 +7439,6 @@ export const $AssetClassGroupDto = {
6044
7439
  required: ['assetClass', 'accounts', 'balanceByCurrency']
6045
7440
  } as const;
6046
7441
 
6047
- export const $AccountExchangeRateWarningDto = {
6048
- type: 'object',
6049
- properties: {
6050
- type: {
6051
- type: 'string',
6052
- description: 'Warning type',
6053
- example: 'MISSING_EXCHANGE_RATE'
6054
- },
6055
- currency: {
6056
- type: 'string',
6057
- description: 'Currency without exchange rate',
6058
- example: 'USD'
6059
- },
6060
- accounts: {
6061
- description: 'Affected account paths',
6062
- type: 'array',
6063
- items: {
6064
- type: 'string'
6065
- }
6066
- },
6067
- totalAmount: {
6068
- type: 'string',
6069
- description: 'Total amount in this currency',
6070
- example: '5000.00'
6071
- }
6072
- },
6073
- required: ['type', 'currency', 'accounts', 'totalAmount']
6074
- } as const;
6075
-
6076
7442
  export const $AssetClassSummaryDto = {
6077
7443
  type: 'object',
6078
7444
  properties: {
@@ -6146,7 +7512,7 @@ export const $HoldingAssetClassAccountSliceDto = {
6146
7512
  accountPath: {
6147
7513
  type: 'string',
6148
7514
  description: 'Full account path',
6149
- example: 'Assets:US:Investments:Brokerage'
7515
+ example: 'Assets:US:Fidelity:Brokerage'
6150
7516
  },
6151
7517
  accountCurrency: {
6152
7518
  type: 'string',
@@ -6318,38 +7684,133 @@ export const $CashFlowResponseDto = {
6318
7684
  description: 'Base currency code',
6319
7685
  example: 'CNY'
6320
7686
  },
6321
- byCurrency: {
6322
- description: 'Cash flow grouped by original currency',
6323
- allOf: [
6324
- {
6325
- $ref: '#/components/schemas/CashFlowByCurrencyDto'
6326
- }
6327
- ]
7687
+ byCurrency: {
7688
+ description: 'Cash flow grouped by original currency',
7689
+ allOf: [
7690
+ {
7691
+ $ref: '#/components/schemas/CashFlowByCurrencyDto'
7692
+ }
7693
+ ]
7694
+ },
7695
+ converted: {
7696
+ description: 'Converted values in base currency',
7697
+ allOf: [
7698
+ {
7699
+ $ref: '#/components/schemas/ConvertedCashFlowDto'
7700
+ }
7701
+ ]
7702
+ },
7703
+ warnings: {
7704
+ description: 'Exchange rate warnings',
7705
+ type: 'array',
7706
+ items: {
7707
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7708
+ }
7709
+ }
7710
+ },
7711
+ required: [
7712
+ 'period',
7713
+ 'income',
7714
+ 'expense',
7715
+ 'netSavings',
7716
+ 'savingsRate',
7717
+ 'currency'
7718
+ ]
7719
+ } as const;
7720
+
7721
+ export const $CategoryGroupDto = {
7722
+ type: 'object',
7723
+ properties: {
7724
+ category: {
7725
+ type: 'string',
7726
+ description:
7727
+ 'Functional category (account-path Group segment); regional and universal account paths merge under it',
7728
+ example: 'Food'
7729
+ },
7730
+ totalExpense: {
7731
+ type: 'string',
7732
+ description:
7733
+ 'Converted total for this category in base currency (expense amount when flow=expense, income amount when flow=income)',
7734
+ example: '1200.00'
7735
+ },
7736
+ sharePct: {
7737
+ type: 'number',
7738
+ description: 'Share of grand total (0-100); 0 when grand total is 0',
7739
+ example: 42.5
7740
+ },
7741
+ balanceByCurrency: {
7742
+ description: 'Raw (unconverted) expense per currency',
7743
+ type: 'array',
7744
+ items: {
7745
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7746
+ }
7747
+ },
7748
+ convertedBalance: {
7749
+ type: 'string',
7750
+ description:
7751
+ 'Converted total in base currency (omitted when FX missing for all currencies in this category)',
7752
+ example: '1200.00'
7753
+ }
7754
+ },
7755
+ required: ['category', 'totalExpense', 'sharePct', 'balanceByCurrency']
7756
+ } as const;
7757
+
7758
+ export const $ExpensesByCategorySummaryDto = {
7759
+ type: 'object',
7760
+ properties: {
7761
+ totalExpense: {
7762
+ type: 'string',
7763
+ description:
7764
+ 'Total across all categories, converted (convertible categories only); expense totals when flow=expense, income totals when flow=income',
7765
+ example: '5000.00'
7766
+ },
7767
+ categoryCount: {
7768
+ type: 'number',
7769
+ description: 'Number of categories',
7770
+ example: 8
7771
+ }
7772
+ },
7773
+ required: ['totalExpense', 'categoryCount']
7774
+ } as const;
7775
+
7776
+ export const $ExpensesByCategoryResponseDto = {
7777
+ type: 'object',
7778
+ properties: {
7779
+ period: {
7780
+ type: 'string',
7781
+ description: 'Period requested',
7782
+ example: '1m'
7783
+ },
7784
+ baseCurrency: {
7785
+ type: 'string',
7786
+ description: 'Base currency for converted values',
7787
+ example: 'CNY'
7788
+ },
7789
+ groups: {
7790
+ description:
7791
+ 'Expense groups by functional category, sorted by converted total desc',
7792
+ type: 'array',
7793
+ items: {
7794
+ $ref: '#/components/schemas/CategoryGroupDto'
7795
+ }
6328
7796
  },
6329
- converted: {
6330
- description: 'Converted values in base currency',
7797
+ summary: {
7798
+ description: 'Summary statistics',
6331
7799
  allOf: [
6332
7800
  {
6333
- $ref: '#/components/schemas/ConvertedCashFlowDto'
7801
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
6334
7802
  }
6335
7803
  ]
6336
7804
  },
6337
7805
  warnings: {
6338
- description: 'Exchange rate warnings',
7806
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
6339
7807
  type: 'array',
6340
7808
  items: {
6341
7809
  $ref: '#/components/schemas/ExchangeRateWarningDto'
6342
7810
  }
6343
7811
  }
6344
7812
  },
6345
- required: [
6346
- 'period',
6347
- 'income',
6348
- 'expense',
6349
- 'netSavings',
6350
- 'savingsRate',
6351
- 'currency'
6352
- ]
7813
+ required: ['period', 'baseCurrency', 'groups', 'summary']
6353
7814
  } as const;
6354
7815
 
6355
7816
  export const $MonetaryDto = {
@@ -6566,409 +8027,243 @@ export const $HoldingPnlRowDto = {
6566
8027
  },
6567
8028
  required: [
6568
8029
  'accountId',
6569
- 'accountPath',
6570
- 'symbol',
6571
- 'chartToken',
6572
- 'assetClass',
6573
- 'units'
6574
- ]
6575
- } as const;
6576
-
6577
- export const $HoldingPnlWarningDto = {
6578
- type: 'object',
6579
- properties: {
6580
- type: {
6581
- type: 'string',
6582
- description: 'Warning type',
6583
- example: 'MISSING_COST_FX_RATE',
6584
- enum: [
6585
- 'MISSING_COST_FX_RATE',
6586
- 'MISSING_MARKET_FX_RATE',
6587
- 'MISSING_SALE_PRICE',
6588
- 'MISSING_REALIZED_FX_RATE',
6589
- 'OVERSOLD_LOTS',
6590
- 'NO_PRICE',
6591
- 'MIXED_COST_CURRENCY'
6592
- ]
6593
- },
6594
- symbol: {
6595
- type: 'object',
6596
- nullable: true
6597
- },
6598
- accountId: {
6599
- type: 'object',
6600
- nullable: true
6601
- },
6602
- currency: {
6603
- type: 'object',
6604
- nullable: true
6605
- }
6606
- },
6607
- required: ['type']
6608
- } as const;
6609
-
6610
- export const $HoldingPnlResponseDto = {
6611
- type: 'object',
6612
- properties: {
6613
- asOfDate: {
6614
- type: 'string',
6615
- example: '2026-07-08'
6616
- },
6617
- baseCurrency: {
6618
- type: 'string',
6619
- example: 'CNY'
6620
- },
6621
- method: {
6622
- type: 'string',
6623
- description:
6624
- 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
6625
- enum: ['average', 'FIFO'],
6626
- example: 'average'
6627
- },
6628
- rows: {
6629
- type: 'array',
6630
- items: {
6631
- $ref: '#/components/schemas/HoldingPnlRowDto'
6632
- }
6633
- },
6634
- warnings: {
6635
- type: 'array',
6636
- items: {
6637
- $ref: '#/components/schemas/HoldingPnlWarningDto'
6638
- }
6639
- }
6640
- },
6641
- required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6642
- } as const;
6643
-
6644
- export const $CreateBeanPriceDto = {
6645
- type: 'object',
6646
- properties: {
6647
- currency: {
6648
- type: 'string',
6649
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6650
- example: 'USD'
6651
- },
6652
- quoteCurrency: {
6653
- type: 'string',
6654
- description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
6655
- example: 'CNY'
6656
- },
6657
- amount: {
6658
- type: 'number',
6659
- description:
6660
- 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
6661
- example: 175.5,
6662
- minimum: 0
6663
- },
6664
- date: {
6665
- type: 'string',
6666
- description: 'Price date (ISO 8601 format)',
6667
- example: '2024-11-05'
6668
- },
6669
- metadata: {
6670
- type: 'object',
6671
- description:
6672
- 'Metadata (validated by Zod schema, max field lengths enforced)',
6673
- example: {
6674
- source: 'MANUAL',
6675
- note: 'Bank valuation report',
6676
- confidence: 0.95
6677
- }
6678
- }
6679
- },
6680
- required: ['currency', 'quoteCurrency', 'amount', 'date']
6681
- } as const;
6682
-
6683
- export const $PriceResponseDto = {
6684
- type: 'object',
6685
- properties: {
6686
- id: {
6687
- type: 'string',
6688
- description: 'Unique identifier',
6689
- example: 'uuid-123-456'
6690
- },
6691
- userId: {
6692
- type: 'string',
6693
- description: 'User ID (owner of the price)',
6694
- example: 'user-123'
6695
- },
6696
- currency: {
6697
- type: 'string',
6698
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6699
- example: 'BTC'
6700
- },
6701
- quoteCurrency: {
6702
- type: 'string',
6703
- description: 'Quote currency (pricing currency, e.g., USD, CNY)',
6704
- example: 'USD'
6705
- },
6706
- amount: {
6707
- type: 'number',
6708
- description:
6709
- 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
6710
- example: 50000
6711
- },
6712
- date: {
6713
- type: 'string',
6714
- description:
6715
- 'Price date (ISO 8601 format). Represents the date this price was valid.',
6716
- example: '2024-01-01',
6717
- format: 'date'
6718
- },
6719
- meta: {
6720
- type: 'object',
6721
- description:
6722
- 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
6723
- example: {
6724
- source: 'MANUAL',
6725
- note: 'User-defined price',
6726
- confidence: 1
6727
- }
6728
- },
6729
- createdAt: {
6730
- format: 'date-time',
6731
- type: 'string',
6732
- description: 'Creation timestamp',
6733
- example: '2024-11-03T10:00:00Z'
6734
- },
6735
- updatedAt: {
6736
- format: 'date-time',
6737
- type: 'string',
6738
- description: 'Last update timestamp',
6739
- example: '2024-11-03T10:00:00Z'
6740
- }
6741
- },
6742
- required: [
6743
- 'id',
6744
- 'userId',
6745
- 'currency',
6746
- 'quoteCurrency',
6747
- 'amount',
6748
- 'date',
6749
- 'meta',
6750
- 'createdAt',
6751
- 'updatedAt'
6752
- ]
6753
- } as const;
6754
-
6755
- export const $PriceListResponseDto = {
6756
- type: 'object',
6757
- properties: {
6758
- items: {
6759
- description: 'List of prices',
6760
- type: 'array',
6761
- items: {
6762
- $ref: '#/components/schemas/PriceResponseDto'
6763
- }
6764
- },
6765
- total: {
6766
- type: 'number',
6767
- description: 'Total number of prices',
6768
- example: 42
6769
- }
6770
- },
6771
- required: ['items', 'total']
6772
- } as const;
6773
-
6774
- export const $UpdateBeanPriceDto = {
6775
- type: 'object',
6776
- properties: {
6777
- currency: {
6778
- type: 'string',
6779
- description: 'Currency being priced'
6780
- },
6781
- quoteCurrency: {
6782
- type: 'string',
6783
- description: 'Quote currency (pricing currency)'
6784
- },
6785
- amount: {
6786
- type: 'number',
6787
- description: 'Price amount (MUST be >= 0 per Beancount spec)',
6788
- minimum: 0
6789
- },
6790
- date: {
6791
- type: 'string',
6792
- description: 'Price date (ISO 8601 format)'
6793
- },
6794
- metadata: {
6795
- type: 'object',
6796
- description: 'Metadata'
6797
- }
6798
- }
8030
+ 'accountPath',
8031
+ 'symbol',
8032
+ 'chartToken',
8033
+ 'assetClass',
8034
+ 'units'
8035
+ ]
6799
8036
  } as const;
6800
8037
 
6801
- export const $CurrencyBalanceDto = {
8038
+ export const $HoldingPnlWarningDto = {
6802
8039
  type: 'object',
6803
8040
  properties: {
6804
- currency: {
8041
+ type: {
6805
8042
  type: 'string',
6806
- description: 'ISO 4217 currency code',
6807
- example: 'CNY'
8043
+ description: 'Warning type',
8044
+ example: 'MISSING_COST_FX_RATE',
8045
+ enum: [
8046
+ 'MISSING_COST_FX_RATE',
8047
+ 'MISSING_MARKET_FX_RATE',
8048
+ 'MISSING_SALE_PRICE',
8049
+ 'MISSING_REALIZED_FX_RATE',
8050
+ 'OVERSOLD_LOTS',
8051
+ 'NO_PRICE',
8052
+ 'MIXED_COST_CURRENCY'
8053
+ ]
6808
8054
  },
6809
- balance: {
6810
- type: 'string',
6811
- description: 'Balance amount',
6812
- example: '500000.00'
8055
+ symbol: {
8056
+ type: 'object',
8057
+ nullable: true
8058
+ },
8059
+ accountId: {
8060
+ type: 'object',
8061
+ nullable: true
8062
+ },
8063
+ currency: {
8064
+ type: 'object',
8065
+ nullable: true
6813
8066
  }
6814
8067
  },
6815
- required: ['currency', 'balance']
8068
+ required: ['type']
6816
8069
  } as const;
6817
8070
 
6818
- export const $TimeSeriesPointDto = {
8071
+ export const $HoldingPnlResponseDto = {
6819
8072
  type: 'object',
6820
8073
  properties: {
6821
- date: {
8074
+ asOfDate: {
6822
8075
  type: 'string',
6823
- description: 'Date in YYYY-MM-DD format',
6824
- example: '2024-06-15'
8076
+ example: '2026-07-08'
6825
8077
  },
6826
- value: {
8078
+ baseCurrency: {
6827
8079
  type: 'string',
6828
- description: 'Value at this date (in base currency)',
6829
- example: '500000.00'
8080
+ example: 'CNY'
6830
8081
  },
6831
- change: {
6832
- type: 'object',
6833
- description: 'Change from previous point',
6834
- example: '5000.00'
8082
+ method: {
8083
+ type: 'string',
8084
+ description:
8085
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
8086
+ enum: ['average', 'FIFO'],
8087
+ example: 'average'
6835
8088
  },
6836
- byCurrency: {
6837
- description: 'Multi-currency breakdown for this point',
8089
+ rows: {
6838
8090
  type: 'array',
6839
8091
  items: {
6840
- $ref: '#/components/schemas/CurrencyBalanceDto'
8092
+ $ref: '#/components/schemas/HoldingPnlRowDto'
8093
+ }
8094
+ },
8095
+ warnings: {
8096
+ type: 'array',
8097
+ items: {
8098
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
6841
8099
  }
6842
8100
  }
6843
8101
  },
6844
- required: ['date', 'value']
8102
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6845
8103
  } as const;
6846
8104
 
6847
- export const $TrendSummaryDto = {
8105
+ export const $AnonymousLoginDto = {
6848
8106
  type: 'object',
6849
8107
  properties: {
6850
- startValue: {
6851
- type: 'string',
6852
- description: 'Value at start of period',
6853
- example: '450000.00'
6854
- },
6855
- endValue: {
6856
- type: 'string',
6857
- description: 'Value at end of period',
6858
- example: '500000.00'
6859
- },
6860
- totalChange: {
6861
- type: 'string',
6862
- description: 'Total change over period',
6863
- example: '50000.00'
6864
- },
6865
- totalChangePercentage: {
8108
+ accessToken: {
6866
8109
  type: 'string',
6867
- description: 'Total change percentage',
6868
- example: '+11.11%'
8110
+ description: 'Access token for anonymous login'
6869
8111
  }
6870
8112
  },
6871
- required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
8113
+ required: ['accessToken']
6872
8114
  } as const;
6873
8115
 
6874
- export const $MultiCurrencyPointDto = {
8116
+ export const $AnonymousLoginResponseDto = {
6875
8117
  type: 'object',
6876
8118
  properties: {
6877
- date: {
8119
+ authToken: {
6878
8120
  type: 'string',
6879
- description: 'Date in YYYY-MM-DD format',
6880
- example: '2024-06-15'
6881
- },
6882
- byCurrency: {
6883
- description: 'Balances by currency',
6884
- type: 'array',
6885
- items: {
6886
- $ref: '#/components/schemas/CurrencyBalanceDto'
6887
- }
8121
+ description: 'JWT auth token',
8122
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
6888
8123
  }
6889
8124
  },
6890
- required: ['date', 'byCurrency']
8125
+ required: ['authToken']
6891
8126
  } as const;
6892
8127
 
6893
- export const $PortfolioTrendsResponseDto = {
8128
+ export const $SymbolSearchResultDto = {
6894
8129
  type: 'object',
6895
8130
  properties: {
6896
- series: {
6897
- description: 'Time series data points',
6898
- type: 'array',
6899
- items: {
6900
- $ref: '#/components/schemas/TimeSeriesPointDto'
6901
- }
8131
+ symbol: {
8132
+ type: 'string',
8133
+ example: 'AAPL'
6902
8134
  },
6903
- summary: {
6904
- description: 'Period summary',
6905
- allOf: [
6906
- {
6907
- $ref: '#/components/schemas/TrendSummaryDto'
6908
- }
6909
- ]
8135
+ name: {
8136
+ type: 'object',
8137
+ example: 'Apple Inc.',
8138
+ nullable: true
6910
8139
  },
6911
- period: {
6912
- type: 'string',
6913
- description: 'Period requested',
6914
- example: '6m'
8140
+ exchange: {
8141
+ type: 'object',
8142
+ example: 'US',
8143
+ nullable: true
6915
8144
  },
6916
- granularity: {
6917
- type: 'string',
6918
- description: 'Data granularity',
6919
- example: 'month'
8145
+ assetType: {
8146
+ type: 'object',
8147
+ description: 'OpenBB asset_type (e.g. stock, etf)',
8148
+ example: 'stock',
8149
+ nullable: true
6920
8150
  },
6921
- currency: {
6922
- type: 'string',
6923
- description: 'Base currency for converted values',
6924
- example: 'CNY'
8151
+ assetClass: {
8152
+ type: 'object',
8153
+ description: 'IGN asset class (region.types.ts ASSET_CLASSES)',
8154
+ example: 'EQUITY',
8155
+ nullable: true
6925
8156
  },
6926
- byCurrency: {
6927
- description:
6928
- 'Multi-currency time series (each point has currency breakdown)',
6929
- type: 'array',
6930
- items: {
6931
- $ref: '#/components/schemas/MultiCurrencyPointDto'
6932
- }
8157
+ assetSubClass: {
8158
+ type: 'object',
8159
+ description: 'IGN asset sub-class (region.types.ts ASSET_SUB_CLASSES)',
8160
+ example: 'STOCK',
8161
+ nullable: true
6933
8162
  },
6934
- warnings: {
6935
- description: 'Exchange rate warnings',
6936
- type: 'array',
6937
- items: {
6938
- $ref: '#/components/schemas/ExchangeRateWarningDto'
6939
- }
8163
+ currency: {
8164
+ type: 'object',
8165
+ description: 'Trading currency (extra_data or inferred from exchange)',
8166
+ example: 'USD',
8167
+ nullable: true
6940
8168
  }
6941
8169
  },
6942
- required: ['series', 'summary', 'period', 'granularity', 'currency']
6943
- } as const;
6944
-
6945
- export const $GenerateSnapshotBody = {
6946
- type: 'object',
6947
- properties: {}
6948
- } as const;
6949
-
6950
- export const $GenerateSnapshotResponse = {
6951
- type: 'object',
6952
- properties: {}
6953
- } as const;
6954
-
6955
- export const $BackfillSnapshotsBody = {
6956
- type: 'object',
6957
- properties: {}
6958
- } as const;
6959
-
6960
- export const $BackfillSnapshotsResponse = {
6961
- type: 'object',
6962
- properties: {}
8170
+ required: ['symbol']
6963
8171
  } as const;
6964
8172
 
6965
- export const $AnonymousLoginDto = {
8173
+ export const $SymbolQuoteDto = {
6966
8174
  type: 'object',
6967
8175
  properties: {
6968
- accessToken: {
8176
+ symbol: {
6969
8177
  type: 'string',
6970
- description: 'Access token for anonymous login'
8178
+ example: 'AAPL'
8179
+ },
8180
+ name: {
8181
+ type: 'object',
8182
+ example: 'Apple Inc.',
8183
+ nullable: true
8184
+ },
8185
+ exchange: {
8186
+ type: 'object',
8187
+ example: 'US',
8188
+ nullable: true
8189
+ },
8190
+ assetType: {
8191
+ type: 'object',
8192
+ description: 'OpenBB asset_type',
8193
+ example: 'stock',
8194
+ nullable: true
8195
+ },
8196
+ assetClass: {
8197
+ type: 'object',
8198
+ description: 'IGN asset class',
8199
+ example: 'EQUITY',
8200
+ nullable: true
8201
+ },
8202
+ assetSubClass: {
8203
+ type: 'object',
8204
+ description: 'IGN asset sub-class',
8205
+ example: 'STOCK',
8206
+ nullable: true
8207
+ },
8208
+ currency: {
8209
+ type: 'object',
8210
+ description: 'Trading currency (extra_data or inferred from exchange)',
8211
+ example: 'USD',
8212
+ nullable: true
8213
+ },
8214
+ price: {
8215
+ type: 'object',
8216
+ description: 'Latest price (Decimal string)',
8217
+ example: '189.84',
8218
+ nullable: true
8219
+ },
8220
+ priceDate: {
8221
+ type: 'object',
8222
+ description: 'Date the price was observed (ISO yyyy-MM-dd)',
8223
+ example: '2026-08-05',
8224
+ nullable: true
8225
+ },
8226
+ changePercent: {
8227
+ type: 'object',
8228
+ description:
8229
+ '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.',
8230
+ example: 1.7,
8231
+ nullable: true
8232
+ },
8233
+ prevClose: {
8234
+ type: 'object',
8235
+ description: 'Previous close (Decimal string)',
8236
+ nullable: true
8237
+ },
8238
+ open: {
8239
+ type: 'object',
8240
+ description: 'Day open (Decimal string)',
8241
+ nullable: true
8242
+ },
8243
+ high: {
8244
+ type: 'object',
8245
+ description: 'Day high (Decimal string)',
8246
+ nullable: true
8247
+ },
8248
+ low: {
8249
+ type: 'object',
8250
+ description: 'Day low (Decimal string)',
8251
+ nullable: true
8252
+ },
8253
+ volume: {
8254
+ type: 'object',
8255
+ description: 'Day volume (Decimal string)',
8256
+ nullable: true
8257
+ },
8258
+ yearHigh: {
8259
+ type: 'object',
8260
+ description: '52-week high (Decimal string)',
8261
+ nullable: true
8262
+ },
8263
+ yearLow: {
8264
+ type: 'object',
8265
+ description: '52-week low (Decimal string)',
8266
+ nullable: true
6971
8267
  }
6972
- },
6973
- required: ['accessToken']
8268
+ }
6974
8269
  } as const;