@firela/api-types 0.0.0-canary.ba0a88d9 → 0.0.0-canary.ce345b8f

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',
@@ -145,26 +129,26 @@ export const $AccountResponseDto = {
145
129
  templatePath: {
146
130
  type: 'string',
147
131
  description: 'Template path reference',
148
- example: 'Assets:CN:Bank:ICBC:Checking'
132
+ example: 'Assets:CN:Checking'
149
133
  },
150
134
  isCustom: {
151
135
  type: 'boolean',
152
136
  description: 'Whether this is a custom (user-created) account',
153
137
  example: false
154
138
  },
155
- i18nKey: {
139
+ displayName: {
156
140
  type: 'string',
157
- description: 'i18n key for display name',
158
- example: 'account.assets.cn.bank.icbc.checking'
141
+ description: 'Localized display name (ADR-0114, read-time projection)',
142
+ example: 'Checking'
159
143
  },
160
144
  icon: {
161
145
  type: 'string',
162
146
  description: 'Icon identifier',
163
147
  example: 'bank-icbc'
164
148
  },
165
- openMeta: {
149
+ openDirectiveMeta: {
166
150
  type: 'object',
167
- description: 'Account metadata',
151
+ description: 'Open directive metadata (ADR-0115 Decision 9)',
168
152
  example: {
169
153
  branch: 'Downtown'
170
154
  }
@@ -192,7 +176,6 @@ export const $AccountResponseDto = {
192
176
  required: [
193
177
  'id',
194
178
  'path',
195
- 'displayName',
196
179
  'type',
197
180
  'status',
198
181
  'openDate',
@@ -225,11 +208,6 @@ export const $AccountListResponseDto = {
225
208
  export const $UpdateAccountDto = {
226
209
  type: 'object',
227
210
  properties: {
228
- displayName: {
229
- type: 'string',
230
- description: 'Display name to distinguish accounts at the same path',
231
- example: '招行工资卡'
232
- },
233
211
  currencies: {
234
212
  description: 'Allowed currencies (null = no restriction)',
235
213
  example: ['CNY', 'USD'],
@@ -251,19 +229,15 @@ export const $UpdateAccountDto = {
251
229
  'NONE'
252
230
  ]
253
231
  },
254
- i18nKey: {
255
- type: 'string',
256
- description: 'i18n key for display name',
257
- example: 'account.custom.mybank'
258
- },
259
232
  icon: {
260
233
  type: 'string',
261
234
  description: 'Icon identifier',
262
235
  example: 'bank-custom'
263
236
  },
264
- openMeta: {
237
+ openDirectiveMeta: {
265
238
  type: 'object',
266
- description: 'Additional metadata (merged with existing)',
239
+ description:
240
+ 'Open directive metadata (merged with existing; NOT an opening-balance amount)',
267
241
  example: {
268
242
  branch: 'Uptown'
269
243
  }
@@ -310,13 +284,47 @@ export const $ReopenAccountDto = {
310
284
  }
311
285
  } as const;
312
286
 
287
+ export const $CreateOpeningBalanceDto = {
288
+ type: 'object',
289
+ properties: {
290
+ amount: {
291
+ type: 'number',
292
+ description: 'Opening balance amount (non-negative)',
293
+ example: 1000
294
+ },
295
+ currency: {
296
+ type: 'string',
297
+ description: 'Currency code',
298
+ example: 'CNY'
299
+ },
300
+ date: {
301
+ format: 'date-time',
302
+ type: 'string',
303
+ description: 'Opening-balance date (defaults to now)',
304
+ example: '2024-01-01'
305
+ }
306
+ },
307
+ required: ['amount', 'currency']
308
+ } as const;
309
+
310
+ export const $OpeningBalanceResultDto = {
311
+ type: 'object',
312
+ properties: {
313
+ transactionId: {
314
+ type: 'string',
315
+ description: 'Created opening-balance transaction id.'
316
+ }
317
+ },
318
+ required: ['transactionId']
319
+ } as const;
320
+
313
321
  export const $AccountStandardResponseDto = {
314
322
  type: 'object',
315
323
  properties: {
316
324
  path: {
317
325
  type: 'string',
318
326
  description: 'Account path (hierarchical, colon-separated)',
319
- example: 'Assets:CN:Bank:ICBC:Checking'
327
+ example: 'Assets:CN:Checking'
320
328
  },
321
329
  type: {
322
330
  type: 'string',
@@ -324,14 +332,14 @@ export const $AccountStandardResponseDto = {
324
332
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
325
333
  example: 'Assets'
326
334
  },
327
- i18nKey: {
335
+ name: {
328
336
  type: 'string',
329
- description: 'i18n key for localized display name',
330
- example: 'account.assets.cn.bank.icbc.checking'
337
+ description: 'Short localized display name',
338
+ example: 'Housing Fund'
331
339
  },
332
340
  description: {
333
341
  type: 'string',
334
- description: 'Account description',
342
+ description: 'Account description (stable semantics only)',
335
343
  example: 'ICBC checking account for daily transactions'
336
344
  },
337
345
  tags: {
@@ -348,7 +356,7 @@ export const $AccountStandardResponseDto = {
348
356
  example: 'bank-icbc'
349
357
  }
350
358
  },
351
- required: ['path', 'type']
359
+ required: ['path', 'type', 'description', 'tags', 'icon']
352
360
  } as const;
353
361
 
354
362
  export const $AccountStandardListResponseDto = {
@@ -378,18 +386,13 @@ export const $AccountStandardListResponseDto = {
378
386
  export const $TemplateMetadataDto = {
379
387
  type: 'object',
380
388
  properties: {
381
- extendable: {
382
- type: 'boolean',
383
- description: 'Whether this path can be extended',
384
- example: true
385
- },
386
389
  rootType: {
387
390
  type: 'string',
388
391
  description: 'Root account type',
389
392
  example: 'Assets'
390
393
  }
391
394
  },
392
- required: ['extendable', 'rootType']
395
+ required: ['rootType']
393
396
  } as const;
394
397
 
395
398
  export const $TemplateMetadataResponseDto = {
@@ -432,11 +435,10 @@ export const $RegionInfoDto = {
432
435
  example: 'Germany'
433
436
  },
434
437
  parent: {
435
- type: 'string',
436
- example: 'eu-core'
438
+ type: 'string'
437
439
  },
438
440
  chain: {
439
- example: ['eu-core', 'de'],
441
+ example: ['de'],
440
442
  type: 'array',
441
443
  items: {
442
444
  type: 'string'
@@ -462,6 +464,66 @@ export const $RegionsMetadataResponseDto = {
462
464
  required: ['regions']
463
465
  } as const;
464
466
 
467
+ export const $CostSpecDto = {
468
+ type: 'object',
469
+ properties: {
470
+ mode: {
471
+ type: 'string',
472
+ enum: ['per-unit', 'total', 'date', 'label', 'auto'],
473
+ description: 'Cost specification mode (mirrors engine CostSpec)'
474
+ },
475
+ numberPerUnit: {
476
+ type: 'string',
477
+ description: 'Per-unit cost (required when mode is "per-unit")',
478
+ example: '240'
479
+ },
480
+ totalNumber: {
481
+ type: 'string',
482
+ description: 'Total cost for all units (required when mode is "total")',
483
+ example: '12000'
484
+ },
485
+ currency: {
486
+ type: 'string',
487
+ description: 'Cost currency (required in all modes)',
488
+ example: 'USD'
489
+ },
490
+ date: {
491
+ type: 'string',
492
+ description:
493
+ 'Lot acquisition date, ISO 8601 (required when mode is "date")',
494
+ example: '2024-01-15'
495
+ },
496
+ label: {
497
+ type: 'string',
498
+ description:
499
+ 'Lot label (required when mode is "label"; optional tag in buy modes)'
500
+ },
501
+ merge: {
502
+ type: 'boolean',
503
+ description: 'Merge lots for AVERAGE booking (mode: auto)'
504
+ }
505
+ },
506
+ required: ['mode', 'currency']
507
+ } as const;
508
+
509
+ export const $AmountDto = {
510
+ type: 'object',
511
+ properties: {
512
+ number: {
513
+ type: 'string',
514
+ description:
515
+ 'Amount as decimal string (max 15 integer + 15 decimal digits)',
516
+ example: '170.50'
517
+ },
518
+ currency: {
519
+ type: 'string',
520
+ description: 'Currency/commodity code',
521
+ example: 'USD'
522
+ }
523
+ },
524
+ required: ['number', 'currency']
525
+ } as const;
526
+
465
527
  export const $CreatePostingDto = {
466
528
  type: 'object',
467
529
  properties: {
@@ -469,7 +531,7 @@ export const $CreatePostingDto = {
469
531
  type: 'string',
470
532
  description:
471
533
  'Account name in Beancount format (must start with uppercase, colon-separated)',
472
- example: 'Assets:Bank:Checking'
534
+ example: 'Assets:Checking'
473
535
  },
474
536
  units: {
475
537
  type: 'string',
@@ -491,6 +553,33 @@ export const $CreatePostingDto = {
491
553
  example: {
492
554
  'tax-lot': 'Q1-2024'
493
555
  }
556
+ },
557
+ cost: {
558
+ description:
559
+ 'Cost basis (Beancount `{...}`). Maps to engine costSpec. Required for commodity holdings so they carry a monetary weight that can balance.',
560
+ example: {
561
+ mode: 'per-unit',
562
+ numberPerUnit: '240',
563
+ currency: 'USD'
564
+ },
565
+ allOf: [
566
+ {
567
+ $ref: '#/components/schemas/CostSpecDto'
568
+ }
569
+ ]
570
+ },
571
+ price: {
572
+ description:
573
+ 'Price annotation (Beancount `@...`). Maps to engine price. Used for valuation; cost takes priority for balance weight.',
574
+ example: {
575
+ number: '170',
576
+ currency: 'USD'
577
+ },
578
+ allOf: [
579
+ {
580
+ $ref: '#/components/schemas/AmountDto'
581
+ }
582
+ ]
494
583
  }
495
584
  },
496
585
  required: ['account']
@@ -569,23 +658,59 @@ export const $CreateTransactionDto = {
569
658
  required: ['date', 'narration', 'postings']
570
659
  } as const;
571
660
 
661
+ export const $CostDetailDto = {
662
+ type: 'object',
663
+ properties: {
664
+ number: {
665
+ type: 'string',
666
+ description: 'Per-unit cost basis (mirrors engine Cost.number)',
667
+ example: '240'
668
+ },
669
+ currency: {
670
+ type: 'string',
671
+ description: 'Cost currency',
672
+ example: 'USD'
673
+ },
674
+ date: {
675
+ type: 'string',
676
+ description: 'Lot acquisition date (ISO yyyy-mm-dd)',
677
+ example: '2024-01-15'
678
+ },
679
+ label: {
680
+ type: 'string',
681
+ description: 'Lot label',
682
+ example: 'lot-2024-01'
683
+ }
684
+ }
685
+ } as const;
686
+
572
687
  export const $PostingResponseDto = {
573
688
  type: 'object',
574
689
  properties: {
575
690
  account: {
576
691
  type: 'string',
577
692
  description: 'Account name',
578
- example: 'Assets:Bank:Checking'
693
+ example: 'Assets:Checking'
579
694
  },
580
695
  units: {
581
696
  type: 'string',
582
- description: 'Amount (may be null if interpolated)',
697
+ description:
698
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
583
699
  example: '100.50'
584
700
  },
585
701
  currency: {
586
702
  type: 'string',
587
703
  description: 'Currency',
588
704
  example: 'USD'
705
+ },
706
+ cost: {
707
+ description:
708
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
709
+ allOf: [
710
+ {
711
+ $ref: '#/components/schemas/CostDetailDto'
712
+ }
713
+ ]
589
714
  }
590
715
  },
591
716
  required: ['account']
@@ -805,6 +930,11 @@ export const $BatchTransactionErrorDto = {
805
930
  type: 'string',
806
931
  description: 'Error message describing the failure',
807
932
  example: 'Transaction does not balance'
933
+ },
934
+ errorCode: {
935
+ type: 'string',
936
+ description: 'Structured error code for programmatic handling',
937
+ example: 'INSUFFICIENT_QUANTITY'
808
938
  }
809
939
  },
810
940
  required: ['index', 'error']
@@ -831,6 +961,85 @@ export const $BatchTransactionResponseDto = {
831
961
  required: ['succeeded', 'failed']
832
962
  } as const;
833
963
 
964
+ export const $CorrectTransactionDto = {
965
+ type: 'object',
966
+ properties: {
967
+ date: {
968
+ type: 'string',
969
+ description: 'Transaction date (ISO 8601 format)',
970
+ example: '2024-11-28'
971
+ },
972
+ flag: {
973
+ type: 'string',
974
+ description: 'Transaction flag: * (cleared), ! (pending)',
975
+ enum: ['*', '!'],
976
+ example: '*'
977
+ },
978
+ payee: {
979
+ type: 'string',
980
+ description: 'Payee name',
981
+ example: 'Whole Foods Market'
982
+ },
983
+ narration: {
984
+ type: 'string',
985
+ description: 'Transaction narration/description',
986
+ example: 'Grocery shopping'
987
+ },
988
+ tags: {
989
+ description: 'Transaction tags (without # prefix)',
990
+ example: ['vacation', 'personal'],
991
+ type: 'array',
992
+ items: {
993
+ type: 'string'
994
+ }
995
+ },
996
+ links: {
997
+ description: 'Transaction links (without ^ prefix)',
998
+ example: ['invoice-123'],
999
+ type: 'array',
1000
+ items: {
1001
+ type: 'string'
1002
+ }
1003
+ },
1004
+ postings: {
1005
+ description:
1006
+ 'Transaction postings (minimum 1, typically 2 for double-entry)',
1007
+ type: 'array',
1008
+ items: {
1009
+ $ref: '#/components/schemas/CreatePostingDto'
1010
+ }
1011
+ },
1012
+ meta: {
1013
+ type: 'object',
1014
+ description: 'Transaction-level metadata',
1015
+ example: {
1016
+ invoice: '12345'
1017
+ }
1018
+ },
1019
+ idempotencyKey: {
1020
+ type: 'string',
1021
+ description:
1022
+ 'Unique key for idempotent transaction creation. If provided, duplicate requests with the same key will return the existing transaction.',
1023
+ example: 'import-2024-01-15-batch-001',
1024
+ maxLength: 128
1025
+ },
1026
+ autoCreateAccounts: {
1027
+ type: 'boolean',
1028
+ description:
1029
+ 'Auto-create accounts if not found. When true, missing accounts will be automatically created. When false (default for API), missing accounts will cause a validation error. Set to true for quick entry scenarios where you want to create accounts on-the-fly.',
1030
+ default: true,
1031
+ example: true
1032
+ },
1033
+ correctionReason: {
1034
+ type: 'string',
1035
+ description: 'Reason for correcting/superseding the original transaction',
1036
+ example: 'Wrong amount — corrected from receipt',
1037
+ maxLength: 500
1038
+ }
1039
+ },
1040
+ required: ['date', 'narration', 'postings']
1041
+ } as const;
1042
+
834
1043
  export const $PostingDetailDto = {
835
1044
  type: 'object',
836
1045
  properties: {
@@ -844,14 +1053,15 @@ export const $PostingDetailDto = {
844
1053
  description: 'Account ID',
845
1054
  example: 'clh1234567890abcdef'
846
1055
  },
847
- accountName: {
1056
+ account: {
848
1057
  type: 'string',
849
- description: 'Account name',
850
- example: 'Assets:Bank:Checking'
1058
+ description: 'Fully-qualified Beancount account path',
1059
+ example: 'Assets:Checking'
851
1060
  },
852
1061
  units: {
853
1062
  type: 'string',
854
- description: 'Amount (may be null if interpolated)',
1063
+ description:
1064
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
855
1065
  example: '100.50'
856
1066
  },
857
1067
  currency: {
@@ -874,6 +1084,15 @@ export const $PostingDetailDto = {
874
1084
  description: 'Cost date',
875
1085
  example: '2024-01-15'
876
1086
  },
1087
+ cost: {
1088
+ description:
1089
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
1090
+ allOf: [
1091
+ {
1092
+ $ref: '#/components/schemas/CostDetailDto'
1093
+ }
1094
+ ]
1095
+ },
877
1096
  priceAmount: {
878
1097
  type: 'string',
879
1098
  description: 'Price amount',
@@ -894,7 +1113,7 @@ export const $PostingDetailDto = {
894
1113
  description: 'Posting metadata'
895
1114
  }
896
1115
  },
897
- required: ['id', 'accountId', 'accountName']
1116
+ required: ['id', 'accountId', 'account']
898
1117
  } as const;
899
1118
 
900
1119
  export const $TransactionDetailDto = {
@@ -966,8 +1185,8 @@ export const $TransactionDetailDto = {
966
1185
  },
967
1186
  sourceType: {
968
1187
  type: 'string',
969
- description: 'Source type (how the transaction was created)',
970
- enum: ['NLP', 'CSV', 'OCR', 'API']
1188
+ description:
1189
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
971
1190
  },
972
1191
  sourcePlatform: {
973
1192
  type: 'string',
@@ -1000,6 +1219,18 @@ export const $TransactionDetailDto = {
1000
1219
  type: 'string',
1001
1220
  description: 'Correction reason (if voided or superseded)',
1002
1221
  example: 'Duplicate entry'
1222
+ },
1223
+ supersededBy: {
1224
+ type: 'string',
1225
+ description:
1226
+ 'ID of the transaction that supersedes this one (set when status=SUPERSEDED)',
1227
+ example: 'clh1234567890abcdef'
1228
+ },
1229
+ originalTxn: {
1230
+ type: 'string',
1231
+ description:
1232
+ 'ID of the transaction this one corrected/replaced (back-link on the replacement)',
1233
+ example: 'clh1234567890abcdef'
1003
1234
  }
1004
1235
  },
1005
1236
  required: [
@@ -1014,35 +1245,146 @@ export const $TransactionDetailDto = {
1014
1245
  ]
1015
1246
  } as const;
1016
1247
 
1017
- export const $TransactionListResponseDto = {
1248
+ export const $BalanceByCurrencyDto = {
1018
1249
  type: 'object',
1019
1250
  properties: {
1020
- data: {
1021
- description: 'List of transactions',
1022
- type: 'array',
1023
- items: {
1024
- $ref: '#/components/schemas/TransactionDetailDto'
1025
- }
1026
- },
1027
- total: {
1028
- type: 'number',
1029
- description: 'Total count of matching transactions',
1030
- example: 100
1031
- },
1032
- limit: {
1033
- type: 'number',
1034
- description: 'Number of items per page',
1035
- example: 20
1251
+ currency: {
1252
+ type: 'string',
1253
+ description: 'ISO 4217 currency code',
1254
+ example: 'CNY'
1036
1255
  },
1037
- offset: {
1038
- type: 'number',
1256
+ balance: {
1257
+ type: 'string',
1258
+ description: 'Balance amount',
1259
+ example: '50000.00'
1260
+ }
1261
+ },
1262
+ required: ['currency', 'balance']
1263
+ } as const;
1264
+
1265
+ export const $ExchangeRateWarningDto = {
1266
+ type: 'object',
1267
+ properties: {
1268
+ type: {
1269
+ type: 'string',
1270
+ description: 'Warning type',
1271
+ example: 'MISSING_EXCHANGE_RATE'
1272
+ },
1273
+ currency: {
1274
+ type: 'string',
1275
+ description: 'Currency without exchange rate',
1276
+ example: 'EUR'
1277
+ },
1278
+ totalAmount: {
1279
+ type: 'string',
1280
+ description: 'Total amount affected',
1281
+ example: '1000.00'
1282
+ }
1283
+ },
1284
+ required: ['type', 'currency', 'totalAmount']
1285
+ } as const;
1286
+
1287
+ export const $TransactionListSummaryDto = {
1288
+ type: 'object',
1289
+ properties: {
1290
+ totalAmount: {
1291
+ type: 'string',
1292
+ description:
1293
+ '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.',
1294
+ example: '-6000.00'
1295
+ },
1296
+ currency: {
1297
+ type: 'string',
1298
+ description: 'Base currency (ISO 4217)',
1299
+ example: 'CNY'
1300
+ },
1301
+ balanceByCurrency: {
1302
+ description: 'Raw (unconverted) balance per currency',
1303
+ type: 'array',
1304
+ items: {
1305
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
1306
+ }
1307
+ },
1308
+ warnings: {
1309
+ description: 'Currencies missing an FX rate (omitted when empty)',
1310
+ type: 'array',
1311
+ items: {
1312
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
1313
+ }
1314
+ }
1315
+ },
1316
+ required: ['totalAmount', 'currency', 'balanceByCurrency']
1317
+ } as const;
1318
+
1319
+ export const $TransactionListResponseDto = {
1320
+ type: 'object',
1321
+ properties: {
1322
+ data: {
1323
+ description: 'List of transactions',
1324
+ type: 'array',
1325
+ items: {
1326
+ $ref: '#/components/schemas/TransactionDetailDto'
1327
+ }
1328
+ },
1329
+ total: {
1330
+ type: 'number',
1331
+ description: 'Total count of matching transactions',
1332
+ example: 100
1333
+ },
1334
+ limit: {
1335
+ type: 'number',
1336
+ description: 'Number of items per page',
1337
+ example: 20
1338
+ },
1339
+ offset: {
1340
+ type: 'number',
1039
1341
  description: 'Number of items skipped',
1040
1342
  example: 0
1343
+ },
1344
+ summary: {
1345
+ description:
1346
+ '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.',
1347
+ allOf: [
1348
+ {
1349
+ $ref: '#/components/schemas/TransactionListSummaryDto'
1350
+ }
1351
+ ]
1041
1352
  }
1042
1353
  },
1043
1354
  required: ['data', 'total', 'limit', 'offset']
1044
1355
  } as const;
1045
1356
 
1357
+ export const $TagSuggestionDto = {
1358
+ type: 'object',
1359
+ properties: {
1360
+ tag: {
1361
+ type: 'string',
1362
+ description: 'Tag name',
1363
+ example: 'Monthly'
1364
+ },
1365
+ count: {
1366
+ type: 'number',
1367
+ description: 'Usage count across ACTIVE transactions',
1368
+ example: 12
1369
+ }
1370
+ },
1371
+ required: ['tag', 'count']
1372
+ } as const;
1373
+
1374
+ export const $TagSuggestionsResponseDto = {
1375
+ type: 'object',
1376
+ properties: {
1377
+ data: {
1378
+ description: 'Tag suggestions sorted as requested',
1379
+ type: 'array',
1380
+ items: {
1381
+ $ref: '#/components/schemas/TagSuggestionDto'
1382
+ }
1383
+ }
1384
+ },
1385
+ required: ['data']
1386
+ } as const;
1387
+
1046
1388
  export const $UpdateTransactionDto = {
1047
1389
  type: 'object',
1048
1390
  properties: {
@@ -1106,7 +1448,7 @@ export const $BalanceResponseDto = {
1106
1448
  account: {
1107
1449
  type: 'string',
1108
1450
  description: 'Account name',
1109
- example: 'Assets:Bank:Checking'
1451
+ example: 'Assets:Checking'
1110
1452
  },
1111
1453
  balance: {
1112
1454
  type: 'string',
@@ -1133,7 +1475,7 @@ export const $MultiCurrencyBalanceResponseDto = {
1133
1475
  account: {
1134
1476
  type: 'string',
1135
1477
  description: 'Account name',
1136
- example: 'Assets:Bank:Checking'
1478
+ example: 'Assets:Checking'
1137
1479
  },
1138
1480
  balances: {
1139
1481
  type: 'object',
@@ -1189,12 +1531,12 @@ export const $TransactionSummaryDto = {
1189
1531
  accountName: {
1190
1532
  type: 'string',
1191
1533
  description: 'Source account name (first posting)',
1192
- example: 'Assets:Bank:Checking'
1534
+ example: 'Assets:Checking'
1193
1535
  },
1194
1536
  sourceType: {
1195
1537
  type: 'string',
1196
- description: 'Source type (NLP, CSV, OCR, API)',
1197
- enum: ['NLP', 'CSV', 'OCR', 'API']
1538
+ description:
1539
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1198
1540
  },
1199
1541
  sourcePlatform: {
1200
1542
  type: 'string',
@@ -1234,8 +1576,10 @@ export const $ReviewSummaryDto = {
1234
1576
  },
1235
1577
  confidenceLevel: {
1236
1578
  type: 'string',
1237
- description: 'Confidence level derived from score',
1238
- enum: ['HIGH', 'MEDIUM', 'LOW']
1579
+ description:
1580
+ 'Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.',
1581
+ enum: ['HIGH', 'MEDIUM', 'LOW'],
1582
+ nullable: true
1239
1583
  },
1240
1584
  summaryKey: {
1241
1585
  type: 'string',
@@ -1259,7 +1603,8 @@ export const $ReviewSummaryDto = {
1259
1603
  },
1260
1604
  sourceType: {
1261
1605
  type: 'string',
1262
- description: 'Source type (NLP, CSV, OCR, API)'
1606
+ description:
1607
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1263
1608
  },
1264
1609
  sourcePlatform: {
1265
1610
  type: 'string',
@@ -1369,7 +1714,20 @@ export const $DecisionOptionDto = {
1369
1714
  properties: {
1370
1715
  value: {
1371
1716
  type: 'string',
1372
- description: 'The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)'
1717
+ description: 'The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)',
1718
+ enum: [
1719
+ 'UPGRADE_REPLACE',
1720
+ 'LINK_KEEP_BOTH',
1721
+ 'IGNORE_NEW',
1722
+ 'CONFIRM_DIFFERENT',
1723
+ 'ACCEPT',
1724
+ 'REJECT',
1725
+ 'ACCEPT_AND_LEARN',
1726
+ 'CHOOSE_OTHER',
1727
+ 'CANCEL',
1728
+ 'FIX',
1729
+ 'IGNORE'
1730
+ ]
1373
1731
  },
1374
1732
  labelKey: {
1375
1733
  type: 'string',
@@ -1417,8 +1775,10 @@ export const $ReviewDetailDto = {
1417
1775
  },
1418
1776
  confidenceLevel: {
1419
1777
  type: 'string',
1420
- description: 'Confidence level derived from score',
1421
- enum: ['HIGH', 'MEDIUM', 'LOW']
1778
+ description:
1779
+ 'Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.',
1780
+ enum: ['HIGH', 'MEDIUM', 'LOW'],
1781
+ nullable: true
1422
1782
  },
1423
1783
  summaryKey: {
1424
1784
  type: 'string',
@@ -1442,7 +1802,8 @@ export const $ReviewDetailDto = {
1442
1802
  },
1443
1803
  sourceType: {
1444
1804
  type: 'string',
1445
- description: 'Source type (NLP, CSV, OCR, API)'
1805
+ description:
1806
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1446
1807
  },
1447
1808
  sourcePlatform: {
1448
1809
  type: 'string',
@@ -1522,7 +1883,20 @@ export const $ResolveReviewDto = {
1522
1883
  action: {
1523
1884
  type: 'string',
1524
1885
  description:
1525
- 'Decision action. Available actions vary by review type: DUPLICATE: UPGRADE_REPLACE, KEEP_EXISTING, KEEP_BOTH | PAYEE_MATCH: ACCEPT, REJECT, ACCEPT_AND_LEARN | ACCOUNT_VALIDATION: FIX, REJECT | RULE_MATCH: ACCEPT, REJECT, ACCEPT_AND_LEARN',
1886
+ 'Decision action. Valid actions vary by review type — see DecisionOptionDto.value returned by the review detail endpoint.',
1887
+ enum: [
1888
+ 'UPGRADE_REPLACE',
1889
+ 'LINK_KEEP_BOTH',
1890
+ 'IGNORE_NEW',
1891
+ 'CONFIRM_DIFFERENT',
1892
+ 'ACCEPT',
1893
+ 'REJECT',
1894
+ 'ACCEPT_AND_LEARN',
1895
+ 'CHOOSE_OTHER',
1896
+ 'CANCEL',
1897
+ 'FIX',
1898
+ 'IGNORE'
1899
+ ],
1526
1900
  example: 'ACCEPT'
1527
1901
  },
1528
1902
  data: {
@@ -1559,7 +1933,8 @@ export const $ResolveResultDto = {
1559
1933
  },
1560
1934
  resolutionId: {
1561
1935
  type: 'string',
1562
- description: 'Resolution ID for undo'
1936
+ description:
1937
+ 'Resolution ID for undo. Absent when the resolver rejected the decision (review stayed PENDING).'
1563
1938
  },
1564
1939
  canUndo: {
1565
1940
  type: 'boolean',
@@ -1577,7 +1952,7 @@ export const $ResolveResultDto = {
1577
1952
  example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1578
1953
  }
1579
1954
  },
1580
- required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
1955
+ required: ['success']
1581
1956
  } as const;
1582
1957
 
1583
1958
  export const $UndoResultDto = {
@@ -1613,6 +1988,19 @@ export const $BatchResolveDto = {
1613
1988
  action: {
1614
1989
  type: 'string',
1615
1990
  description: 'Decision action to apply to all items',
1991
+ enum: [
1992
+ 'UPGRADE_REPLACE',
1993
+ 'LINK_KEEP_BOTH',
1994
+ 'IGNORE_NEW',
1995
+ 'CONFIRM_DIFFERENT',
1996
+ 'ACCEPT',
1997
+ 'REJECT',
1998
+ 'ACCEPT_AND_LEARN',
1999
+ 'CHOOSE_OTHER',
2000
+ 'CANCEL',
2001
+ 'FIX',
2002
+ 'IGNORE'
2003
+ ],
1616
2004
  example: 'ACCEPT'
1617
2005
  },
1618
2006
  data: {
@@ -2435,6 +2823,163 @@ export const $UpdateCommodityDto = {
2435
2823
  }
2436
2824
  } as const;
2437
2825
 
2826
+ export const $CreateBeanPriceDto = {
2827
+ type: 'object',
2828
+ properties: {
2829
+ currency: {
2830
+ type: 'string',
2831
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2832
+ example: 'USD'
2833
+ },
2834
+ quoteCurrency: {
2835
+ type: 'string',
2836
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
2837
+ example: 'CNY'
2838
+ },
2839
+ amount: {
2840
+ type: 'number',
2841
+ description:
2842
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
2843
+ example: 175.5,
2844
+ minimum: 0
2845
+ },
2846
+ date: {
2847
+ type: 'string',
2848
+ description: 'Price date (ISO 8601 format)',
2849
+ example: '2024-11-05'
2850
+ },
2851
+ metadata: {
2852
+ type: 'object',
2853
+ description:
2854
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
2855
+ example: {
2856
+ source: 'MANUAL',
2857
+ note: 'Bank valuation report',
2858
+ confidence: 0.95
2859
+ }
2860
+ }
2861
+ },
2862
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
2863
+ } as const;
2864
+
2865
+ export const $PriceResponseDto = {
2866
+ type: 'object',
2867
+ properties: {
2868
+ id: {
2869
+ type: 'string',
2870
+ description: 'Unique identifier',
2871
+ example: 'uuid-123-456'
2872
+ },
2873
+ userId: {
2874
+ type: 'string',
2875
+ description: 'User ID (owner of the price)',
2876
+ example: 'user-123'
2877
+ },
2878
+ currency: {
2879
+ type: 'string',
2880
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2881
+ example: 'BTC'
2882
+ },
2883
+ quoteCurrency: {
2884
+ type: 'string',
2885
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2886
+ example: 'USD'
2887
+ },
2888
+ amount: {
2889
+ type: 'number',
2890
+ description:
2891
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2892
+ example: 50000
2893
+ },
2894
+ date: {
2895
+ type: 'string',
2896
+ description:
2897
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
2898
+ example: '2024-01-01',
2899
+ format: 'date'
2900
+ },
2901
+ meta: {
2902
+ type: 'object',
2903
+ description:
2904
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
2905
+ example: {
2906
+ source: 'MANUAL',
2907
+ note: 'User-defined price',
2908
+ confidence: 1
2909
+ }
2910
+ },
2911
+ createdAt: {
2912
+ format: 'date-time',
2913
+ type: 'string',
2914
+ description: 'Creation timestamp',
2915
+ example: '2024-11-03T10:00:00Z'
2916
+ },
2917
+ updatedAt: {
2918
+ format: 'date-time',
2919
+ type: 'string',
2920
+ description: 'Last update timestamp',
2921
+ example: '2024-11-03T10:00:00Z'
2922
+ }
2923
+ },
2924
+ required: [
2925
+ 'id',
2926
+ 'userId',
2927
+ 'currency',
2928
+ 'quoteCurrency',
2929
+ 'amount',
2930
+ 'date',
2931
+ 'meta',
2932
+ 'createdAt',
2933
+ 'updatedAt'
2934
+ ]
2935
+ } as const;
2936
+
2937
+ export const $PriceListResponseDto = {
2938
+ type: 'object',
2939
+ properties: {
2940
+ items: {
2941
+ description: 'List of prices',
2942
+ type: 'array',
2943
+ items: {
2944
+ $ref: '#/components/schemas/PriceResponseDto'
2945
+ }
2946
+ },
2947
+ total: {
2948
+ type: 'number',
2949
+ description: 'Total number of prices',
2950
+ example: 42
2951
+ }
2952
+ },
2953
+ required: ['items', 'total']
2954
+ } as const;
2955
+
2956
+ export const $UpdateBeanPriceDto = {
2957
+ type: 'object',
2958
+ properties: {
2959
+ currency: {
2960
+ type: 'string',
2961
+ description: 'Currency being priced'
2962
+ },
2963
+ quoteCurrency: {
2964
+ type: 'string',
2965
+ description: 'Quote currency (pricing currency)'
2966
+ },
2967
+ amount: {
2968
+ type: 'number',
2969
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
2970
+ minimum: 0
2971
+ },
2972
+ date: {
2973
+ type: 'string',
2974
+ description: 'Price date (ISO 8601 format)'
2975
+ },
2976
+ metadata: {
2977
+ type: 'object',
2978
+ description: 'Metadata'
2979
+ }
2980
+ }
2981
+ } as const;
2982
+
2438
2983
  export const $CreateRecurringRuleDto = {
2439
2984
  type: 'object',
2440
2985
  properties: {
@@ -3206,26 +3751,473 @@ export const $ForecastResponseDto = {
3206
3751
  ]
3207
3752
  } as const;
3208
3753
 
3209
- export const $CreateTransactionRuleDto = {
3754
+ export const $CurrencyBalanceDto = {
3210
3755
  type: 'object',
3211
3756
  properties: {
3212
- name: {
3757
+ currency: {
3213
3758
  type: 'string',
3214
- minLength: 1,
3215
- maxLength: 100
3759
+ description: 'ISO 4217 currency code',
3760
+ example: 'CNY'
3216
3761
  },
3217
- description: {
3762
+ balance: {
3218
3763
  type: 'string',
3219
- maxLength: 500
3220
- },
3221
- narrationKeywords: {
3222
- items: {
3223
- type: 'array'
3224
- },
3225
- maxItems: 50,
3226
- type: 'array'
3227
- },
3228
- payeeKeywords: {
3764
+ description: 'Balance amount',
3765
+ example: '500000.00'
3766
+ }
3767
+ },
3768
+ required: ['currency', 'balance']
3769
+ } as const;
3770
+
3771
+ export const $TimeSeriesPointDto = {
3772
+ type: 'object',
3773
+ properties: {
3774
+ date: {
3775
+ type: 'string',
3776
+ description: 'Date in YYYY-MM-DD format',
3777
+ example: '2024-06-15'
3778
+ },
3779
+ value: {
3780
+ type: 'string',
3781
+ description: 'Value at this date (in base currency)',
3782
+ example: '500000.00'
3783
+ },
3784
+ change: {
3785
+ type: 'object',
3786
+ description: 'Change from previous point',
3787
+ example: '5000.00'
3788
+ },
3789
+ assets: {
3790
+ type: 'string',
3791
+ description: 'Total assets at this date (in base currency)',
3792
+ example: '494338.00'
3793
+ },
3794
+ liabilities: {
3795
+ type: 'string',
3796
+ description: 'Total liabilities at this date (in base currency)',
3797
+ example: '310098.00'
3798
+ },
3799
+ byCurrency: {
3800
+ description: 'Multi-currency breakdown for this point',
3801
+ type: 'array',
3802
+ items: {
3803
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3804
+ }
3805
+ }
3806
+ },
3807
+ required: ['date', 'value']
3808
+ } as const;
3809
+
3810
+ export const $TrendSummaryDto = {
3811
+ type: 'object',
3812
+ properties: {
3813
+ startValue: {
3814
+ type: 'string',
3815
+ description: 'Value at start of period',
3816
+ example: '450000.00'
3817
+ },
3818
+ endValue: {
3819
+ type: 'string',
3820
+ description: 'Value at end of period',
3821
+ example: '500000.00'
3822
+ },
3823
+ totalChange: {
3824
+ type: 'string',
3825
+ description: 'Total change over period',
3826
+ example: '50000.00'
3827
+ },
3828
+ totalChangePercentage: {
3829
+ type: 'string',
3830
+ description: 'Total change percentage',
3831
+ example: '+11.11%'
3832
+ }
3833
+ },
3834
+ required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
3835
+ } as const;
3836
+
3837
+ export const $MultiCurrencyPointDto = {
3838
+ type: 'object',
3839
+ properties: {
3840
+ date: {
3841
+ type: 'string',
3842
+ description: 'Date in YYYY-MM-DD format',
3843
+ example: '2024-06-15'
3844
+ },
3845
+ byCurrency: {
3846
+ description: 'Balances by currency',
3847
+ type: 'array',
3848
+ items: {
3849
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3850
+ }
3851
+ }
3852
+ },
3853
+ required: ['date', 'byCurrency']
3854
+ } as const;
3855
+
3856
+ export const $PortfolioTrendsResponseDto = {
3857
+ type: 'object',
3858
+ properties: {
3859
+ series: {
3860
+ description: 'Time series data points',
3861
+ type: 'array',
3862
+ items: {
3863
+ $ref: '#/components/schemas/TimeSeriesPointDto'
3864
+ }
3865
+ },
3866
+ summary: {
3867
+ description: 'Period summary',
3868
+ allOf: [
3869
+ {
3870
+ $ref: '#/components/schemas/TrendSummaryDto'
3871
+ }
3872
+ ]
3873
+ },
3874
+ period: {
3875
+ type: 'string',
3876
+ description: 'Period requested',
3877
+ example: '6m'
3878
+ },
3879
+ granularity: {
3880
+ type: 'string',
3881
+ description: 'Data granularity',
3882
+ example: 'month'
3883
+ },
3884
+ currency: {
3885
+ type: 'string',
3886
+ description: 'Base currency for converted values',
3887
+ example: 'CNY'
3888
+ },
3889
+ byCurrency: {
3890
+ description:
3891
+ 'Multi-currency time series (each point has currency breakdown)',
3892
+ type: 'array',
3893
+ items: {
3894
+ $ref: '#/components/schemas/MultiCurrencyPointDto'
3895
+ }
3896
+ },
3897
+ warnings: {
3898
+ description: 'Exchange rate warnings',
3899
+ type: 'array',
3900
+ items: {
3901
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3902
+ }
3903
+ }
3904
+ },
3905
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
3906
+ } as const;
3907
+
3908
+ export const $CashFlowPointDto = {
3909
+ type: 'object',
3910
+ properties: {
3911
+ month: {
3912
+ type: 'string',
3913
+ description: 'Month key (YYYY-MM)',
3914
+ example: '2024-03'
3915
+ },
3916
+ income: {
3917
+ type: 'string',
3918
+ description: 'Income in base currency (absolute, converted)',
3919
+ example: '10000.00'
3920
+ },
3921
+ expense: {
3922
+ type: 'string',
3923
+ description: 'Expense in base currency (absolute, converted)',
3924
+ example: '5000.00'
3925
+ },
3926
+ netSavings: {
3927
+ type: 'string',
3928
+ description: 'netSavings = income − expense (savings positive)',
3929
+ example: '5000.00'
3930
+ }
3931
+ },
3932
+ required: ['month', 'income', 'expense', 'netSavings']
3933
+ } as const;
3934
+
3935
+ export const $CashFlowTrendSummaryDto = {
3936
+ type: 'object',
3937
+ properties: {
3938
+ totalIncome: {
3939
+ type: 'string',
3940
+ description: 'Total income across the period',
3941
+ example: '60000.00'
3942
+ },
3943
+ totalExpense: {
3944
+ type: 'string',
3945
+ description: 'Total expense across the period',
3946
+ example: '30000.00'
3947
+ },
3948
+ totalNetSavings: {
3949
+ type: 'string',
3950
+ description: 'income − expense across the period',
3951
+ example: '30000.00'
3952
+ },
3953
+ averageMonthlyNetSavings: {
3954
+ type: 'string',
3955
+ description:
3956
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
3957
+ example: '5000.00'
3958
+ }
3959
+ },
3960
+ required: [
3961
+ 'totalIncome',
3962
+ 'totalExpense',
3963
+ 'totalNetSavings',
3964
+ 'averageMonthlyNetSavings'
3965
+ ]
3966
+ } as const;
3967
+
3968
+ export const $CashFlowTrendsResponseDto = {
3969
+ type: 'object',
3970
+ properties: {
3971
+ series: {
3972
+ description:
3973
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
3974
+ type: 'array',
3975
+ items: {
3976
+ $ref: '#/components/schemas/CashFlowPointDto'
3977
+ }
3978
+ },
3979
+ summary: {
3980
+ description: 'Period totals',
3981
+ allOf: [
3982
+ {
3983
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
3984
+ }
3985
+ ]
3986
+ },
3987
+ period: {
3988
+ type: 'string',
3989
+ description: 'Period requested',
3990
+ example: '6m'
3991
+ },
3992
+ granularity: {
3993
+ type: 'string',
3994
+ description: 'Data granularity (v1 returns month buckets)',
3995
+ example: 'month'
3996
+ },
3997
+ currency: {
3998
+ type: 'string',
3999
+ description: 'Base currency for converted values',
4000
+ example: 'CNY'
4001
+ },
4002
+ warnings: {
4003
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
4004
+ type: 'array',
4005
+ items: {
4006
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
4007
+ }
4008
+ }
4009
+ },
4010
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
4011
+ } as const;
4012
+
4013
+ export const $GenerateSnapshotBody = {
4014
+ type: 'object',
4015
+ properties: {}
4016
+ } as const;
4017
+
4018
+ export const $GenerateSnapshotResponse = {
4019
+ type: 'object',
4020
+ properties: {}
4021
+ } as const;
4022
+
4023
+ export const $BackfillSnapshotsBody = {
4024
+ type: 'object',
4025
+ properties: {}
4026
+ } as const;
4027
+
4028
+ export const $BackfillSnapshotsResponse = {
4029
+ type: 'object',
4030
+ properties: {}
4031
+ } as const;
4032
+
4033
+ export const $DeleteOwnUserDto = {
4034
+ type: 'object',
4035
+ properties: {
4036
+ accessToken: {
4037
+ type: 'string',
4038
+ description: 'Access token for user verification',
4039
+ example: 'abc123xyz'
4040
+ }
4041
+ },
4042
+ required: ['accessToken']
4043
+ } as const;
4044
+
4045
+ export const $SignupDto = {
4046
+ type: 'object',
4047
+ properties: {
4048
+ turnstileToken: {
4049
+ type: 'string',
4050
+ description:
4051
+ 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4052
+ example: '0.abc123def456...'
4053
+ }
4054
+ }
4055
+ } as const;
4056
+
4057
+ export const $SignupResponseDto = {
4058
+ type: 'object',
4059
+ properties: {
4060
+ authToken: {
4061
+ type: 'string',
4062
+ description: 'JWT auth token',
4063
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4064
+ },
4065
+ accessToken: {
4066
+ type: 'string',
4067
+ description: 'Auto-generated access token'
4068
+ },
4069
+ role: {
4070
+ type: 'string',
4071
+ description: 'Assigned user role',
4072
+ enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
4073
+ }
4074
+ },
4075
+ required: ['authToken', 'accessToken', 'role']
4076
+ } as const;
4077
+
4078
+ export const $UpdateUserSettingDto = {
4079
+ type: 'object',
4080
+ properties: {
4081
+ secId: {
4082
+ type: 'number',
4083
+ description: 'Security ID'
4084
+ },
4085
+ annualInterestRate: {
4086
+ type: 'number',
4087
+ description: 'Annual interest rate',
4088
+ example: 0.05
4089
+ },
4090
+ currency: {
4091
+ type: 'string',
4092
+ description: 'Currency code',
4093
+ example: 'USD'
4094
+ },
4095
+ baseCurrency: {
4096
+ type: 'string',
4097
+ description: 'Base currency code',
4098
+ example: 'USD'
4099
+ },
4100
+ benchmark: {
4101
+ type: 'string',
4102
+ description: 'Benchmark symbol',
4103
+ example: 'SPY'
4104
+ },
4105
+ colorScheme: {
4106
+ type: 'string',
4107
+ description: 'Color scheme',
4108
+ enum: ['DARK', 'LIGHT']
4109
+ },
4110
+ dateRange: {
4111
+ type: 'string',
4112
+ description: 'Date range filter',
4113
+ example: '1y'
4114
+ },
4115
+ emergencyFund: {
4116
+ type: 'number',
4117
+ description: 'Emergency fund amount',
4118
+ example: 10000
4119
+ },
4120
+ 'filters.accounts': {
4121
+ description: 'Account filter IDs',
4122
+ type: 'array',
4123
+ items: {
4124
+ type: 'string'
4125
+ }
4126
+ },
4127
+ 'filters.assetClasses': {
4128
+ description: 'Asset class filters',
4129
+ type: 'array',
4130
+ items: {
4131
+ type: 'string'
4132
+ }
4133
+ },
4134
+ 'filters.dataSource': {
4135
+ type: 'string',
4136
+ description: 'Data source filter'
4137
+ },
4138
+ 'filters.symbol': {
4139
+ type: 'string',
4140
+ description: 'Symbol filter'
4141
+ },
4142
+ 'filters.tags': {
4143
+ description: 'Tag filters',
4144
+ type: 'array',
4145
+ items: {
4146
+ type: 'string'
4147
+ }
4148
+ },
4149
+ isExperimentalFeatures: {
4150
+ type: 'boolean',
4151
+ description: 'Enable experimental features'
4152
+ },
4153
+ isRestrictedView: {
4154
+ type: 'boolean',
4155
+ description: 'Enable restricted view mode'
4156
+ },
4157
+ language: {
4158
+ type: 'string',
4159
+ description: 'Language code',
4160
+ example: 'en'
4161
+ },
4162
+ locale: {
4163
+ type: 'string',
4164
+ description: 'Locale code',
4165
+ example: 'en-US'
4166
+ },
4167
+ projectedTotalAmount: {
4168
+ type: 'number',
4169
+ description: 'Projected total amount',
4170
+ example: 1000000
4171
+ },
4172
+ retirementDate: {
4173
+ type: 'string',
4174
+ description: 'Retirement date in ISO 8601 format',
4175
+ example: '2050-01-01'
4176
+ },
4177
+ savingsRate: {
4178
+ type: 'number',
4179
+ description: 'Savings rate percentage',
4180
+ example: 0.2
4181
+ },
4182
+ viewMode: {
4183
+ type: 'string',
4184
+ description: 'View mode',
4185
+ enum: ['DEFAULT', 'ZEN']
4186
+ }
4187
+ }
4188
+ } as const;
4189
+
4190
+ export const $UpdatePropertyDto = {
4191
+ type: 'object',
4192
+ properties: {
4193
+ value: {
4194
+ type: 'string',
4195
+ description: 'Property value'
4196
+ }
4197
+ },
4198
+ required: ['value']
4199
+ } as const;
4200
+
4201
+ export const $CreateTransactionRuleDto = {
4202
+ type: 'object',
4203
+ properties: {
4204
+ name: {
4205
+ type: 'string',
4206
+ minLength: 1,
4207
+ maxLength: 100
4208
+ },
4209
+ description: {
4210
+ type: 'string',
4211
+ maxLength: 500
4212
+ },
4213
+ narrationKeywords: {
4214
+ items: {
4215
+ type: 'array'
4216
+ },
4217
+ maxItems: 50,
4218
+ type: 'array'
4219
+ },
4220
+ payeeKeywords: {
3229
4221
  items: {
3230
4222
  type: 'array'
3231
4223
  },
@@ -3855,151 +4847,393 @@ export const $TestRuleResponseDto = {
3855
4847
  required: ['ruleId', 'matches', 'confidence', 'matchDetails']
3856
4848
  } as const;
3857
4849
 
3858
- export const $DeleteOwnUserDto = {
4850
+ export const $CreateBeanEventDto = {
3859
4851
  type: 'object',
3860
4852
  properties: {
3861
- accessToken: {
4853
+ date: {
3862
4854
  type: 'string',
3863
- description: 'Access token for user verification',
3864
- example: 'abc123xyz'
4855
+ description: 'Life event date (ISO 8601)',
4856
+ example: '2024-03-15'
4857
+ },
4858
+ type: {
4859
+ type: 'string',
4860
+ description:
4861
+ 'Life event type (e.g., "employer", "location", "marital-status") — user-defined, no enum constraint at engine layer',
4862
+ example: 'employer'
4863
+ },
4864
+ description: {
4865
+ type: 'string',
4866
+ description:
4867
+ 'Life event description. Empty string is a VALID value (distinct from absence).',
4868
+ example: 'Acme Corp'
4869
+ },
4870
+ meta: {
4871
+ type: 'object',
4872
+ description:
4873
+ 'Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)',
4874
+ example: {
4875
+ note: 'Promotion'
4876
+ }
3865
4877
  }
3866
4878
  },
3867
- required: ['accessToken']
4879
+ required: ['date', 'type', 'description']
3868
4880
  } as const;
3869
4881
 
3870
- export const $SignupDto = {
4882
+ export const $EventResponseDto = {
3871
4883
  type: 'object',
3872
4884
  properties: {
3873
- turnstileToken: {
4885
+ id: {
4886
+ type: 'string',
4887
+ description: 'Unique identifier',
4888
+ example: 'uuid-123-456'
4889
+ },
4890
+ userId: {
4891
+ type: 'string',
4892
+ description: 'User ID (owner of the life event)',
4893
+ example: 'user-123'
4894
+ },
4895
+ date: {
4896
+ type: 'string',
4897
+ description: 'Life event date (ISO 8601 format)',
4898
+ example: '2024-03-15',
4899
+ format: 'date'
4900
+ },
4901
+ type: {
3874
4902
  type: 'string',
3875
4903
  description:
3876
- 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
3877
- example: '0.abc123def456...'
4904
+ 'Life event type (user-defined, e.g., "employer", "location")',
4905
+ example: 'employer'
4906
+ },
4907
+ description: {
4908
+ type: 'string',
4909
+ description:
4910
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4911
+ example: 'Acme Corp'
4912
+ },
4913
+ meta: {
4914
+ type: 'object',
4915
+ description: 'Product-side metadata (free-form JSON)',
4916
+ example: {
4917
+ note: 'Promotion'
4918
+ }
4919
+ },
4920
+ createdAt: {
4921
+ format: 'date-time',
4922
+ type: 'string',
4923
+ description: 'Creation timestamp',
4924
+ example: '2024-03-15T10:00:00Z'
4925
+ },
4926
+ updatedAt: {
4927
+ format: 'date-time',
4928
+ type: 'string',
4929
+ description:
4930
+ 'Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.',
4931
+ example: '2024-03-15T10:00:00Z'
3878
4932
  }
3879
- }
4933
+ },
4934
+ required: [
4935
+ 'id',
4936
+ 'userId',
4937
+ 'date',
4938
+ 'type',
4939
+ 'description',
4940
+ 'meta',
4941
+ 'createdAt',
4942
+ 'updatedAt'
4943
+ ]
3880
4944
  } as const;
3881
4945
 
3882
- export const $UpdateUserSettingDto = {
4946
+ export const $EventListResponseDto = {
3883
4947
  type: 'object',
3884
4948
  properties: {
3885
- secId: {
3886
- type: 'number',
3887
- description: 'Security ID'
4949
+ items: {
4950
+ description: 'List of life events',
4951
+ type: 'array',
4952
+ items: {
4953
+ $ref: '#/components/schemas/EventResponseDto'
4954
+ }
3888
4955
  },
3889
- annualInterestRate: {
4956
+ total: {
3890
4957
  type: 'number',
3891
- description: 'Annual interest rate',
3892
- example: 0.05
3893
- },
3894
- currency: {
4958
+ description: 'Total number of life events matching the query',
4959
+ example: 42
4960
+ }
4961
+ },
4962
+ required: ['items', 'total']
4963
+ } as const;
4964
+
4965
+ export const $UpdateBeanEventDto = {
4966
+ type: 'object',
4967
+ properties: {
4968
+ date: {
3895
4969
  type: 'string',
3896
- description: 'Currency code',
3897
- example: 'USD'
4970
+ description: 'Life event date (ISO 8601)'
3898
4971
  },
3899
- baseCurrency: {
4972
+ type: {
3900
4973
  type: 'string',
3901
- description: 'Base currency code',
3902
- example: 'USD'
4974
+ description: 'Life event type (user-defined)'
3903
4975
  },
3904
- benchmark: {
4976
+ description: {
3905
4977
  type: 'string',
3906
- description: 'Benchmark symbol',
3907
- example: 'SPY'
4978
+ description:
4979
+ 'Life event description. Empty string is a VALID value (distinct from absence).'
3908
4980
  },
3909
- colorScheme: {
4981
+ meta: {
4982
+ type: 'object',
4983
+ description: 'Product-side metadata (free-form JSON)'
4984
+ }
4985
+ }
4986
+ } as const;
4987
+
4988
+ export const $OnboardingAccountDto = {
4989
+ type: 'object',
4990
+ properties: {
4991
+ path: {
3910
4992
  type: 'string',
3911
- description: 'Color scheme',
3912
- enum: ['DARK', 'LIGHT']
4993
+ description:
4994
+ 'Account path (Assets/Liabilities only; format validated by the account service)',
4995
+ example: 'Assets:Checking'
3913
4996
  },
3914
- dateRange: {
4997
+ currency: {
3915
4998
  type: 'string',
3916
- description: 'Date range filter',
3917
- example: '1y'
4999
+ description: 'ISO 4217 currency code (3 letters)',
5000
+ example: 'USD'
3918
5001
  },
3919
- emergencyFund: {
3920
- type: 'number',
3921
- description: 'Emergency fund amount',
3922
- example: 10000
5002
+ openingBalance: {
5003
+ type: 'string',
5004
+ description:
5005
+ 'Opening balance as a non-negative Decimal string (e.g. "1000.00")',
5006
+ example: '1000.00'
3923
5007
  },
3924
- 'filters.accounts': {
3925
- description: 'Account filter IDs',
5008
+ platformId: {
5009
+ type: 'string',
5010
+ description:
5011
+ 'Platform ID to bind the account to (references Platform.id); omit for unbound',
5012
+ example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
5013
+ }
5014
+ },
5015
+ required: ['path', 'currency']
5016
+ } as const;
5017
+
5018
+ export const $OnboardingDto = {
5019
+ type: 'object',
5020
+ properties: {
5021
+ accounts: {
5022
+ description: 'Asset/Liability accounts to register with opening balances',
3926
5023
  type: 'array',
3927
5024
  items: {
3928
- type: 'string'
5025
+ $ref: '#/components/schemas/OnboardingAccountDto'
3929
5026
  }
3930
5027
  },
3931
- 'filters.assetClasses': {
3932
- description: 'Asset class filters',
3933
- type: 'array',
3934
- items: {
3935
- type: 'string'
3936
- }
5028
+ skipAssetRegistration: {
5029
+ type: 'boolean',
5030
+ description:
5031
+ 'Skip asset registration; only bootstrap the core account set',
5032
+ default: false
5033
+ }
5034
+ }
5035
+ } as const;
5036
+
5037
+ export const $ActualBalanceDto = {
5038
+ type: 'object',
5039
+ properties: {
5040
+ amount: {
5041
+ type: 'string',
5042
+ description:
5043
+ 'Actual balance amount as a decimal string (preserves precision for tolerance inference).',
5044
+ example: '1234.56'
3937
5045
  },
3938
- 'filters.dataSource': {
5046
+ ccy: {
5047
+ type: 'string',
5048
+ description: 'Currency code (ISO 4217 or commodity ticker).',
5049
+ example: 'CNY'
5050
+ }
5051
+ },
5052
+ required: ['amount', 'ccy']
5053
+ } as const;
5054
+
5055
+ export const $ComputeReconciliationDto = {
5056
+ type: 'object',
5057
+ properties: {
5058
+ accountId: {
5059
+ type: 'string',
5060
+ description: 'BeanAccount id to reconcile.'
5061
+ },
5062
+ asOfDate: {
5063
+ type: 'string',
5064
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5065
+ example: '2026-07-24'
5066
+ },
5067
+ actualBalance: {
5068
+ description: 'Actual balance from the external statement.',
5069
+ allOf: [
5070
+ {
5071
+ $ref: '#/components/schemas/ActualBalanceDto'
5072
+ }
5073
+ ]
5074
+ }
5075
+ },
5076
+ required: ['accountId', 'asOfDate', 'actualBalance']
5077
+ } as const;
5078
+
5079
+ export const $ReconciliationComputeResultDto = {
5080
+ type: 'object',
5081
+ properties: {
5082
+ accountId: {
5083
+ type: 'string'
5084
+ },
5085
+ asOfDate: {
5086
+ type: 'string'
5087
+ },
5088
+ bookBalance: {
5089
+ type: 'string',
5090
+ description: 'System-computed book balance (decimal string).'
5091
+ },
5092
+ actualBalance: {
5093
+ type: 'string',
5094
+ description: 'User-entered actual balance (decimal string).'
5095
+ },
5096
+ currency: {
5097
+ type: 'string'
5098
+ },
5099
+ diff: {
5100
+ type: 'string',
5101
+ description: 'Diff = book − actual (decimal string).'
5102
+ },
5103
+ tolerance: {
5104
+ type: 'string',
5105
+ description: 'Applied tolerance (decimal string).'
5106
+ },
5107
+ withinTolerance: {
5108
+ type: 'boolean',
5109
+ description: 'true when |diff| ≤ tolerance.'
5110
+ },
5111
+ suggestedAction: {
5112
+ type: 'string',
5113
+ enum: ['assert', 'pad'],
5114
+ description:
5115
+ 'Suggested next action: assert when within tolerance, pad otherwise.'
5116
+ }
5117
+ },
5118
+ required: [
5119
+ 'accountId',
5120
+ 'asOfDate',
5121
+ 'bookBalance',
5122
+ 'actualBalance',
5123
+ 'currency',
5124
+ 'diff',
5125
+ 'tolerance',
5126
+ 'withinTolerance',
5127
+ 'suggestedAction'
5128
+ ]
5129
+ } as const;
5130
+
5131
+ export const $AssertReconciliationDto = {
5132
+ type: 'object',
5133
+ properties: {
5134
+ accountId: {
3939
5135
  type: 'string',
3940
- description: 'Data source filter'
5136
+ description: 'BeanAccount id to reconcile.'
3941
5137
  },
3942
- 'filters.symbol': {
5138
+ asOfDate: {
3943
5139
  type: 'string',
3944
- description: 'Symbol filter'
5140
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5141
+ example: '2026-07-24'
3945
5142
  },
3946
- 'filters.tags': {
3947
- description: 'Tag filters',
3948
- type: 'array',
3949
- items: {
3950
- type: 'string'
3951
- }
5143
+ actualBalance: {
5144
+ description: 'Actual balance from the external statement.',
5145
+ allOf: [
5146
+ {
5147
+ $ref: '#/components/schemas/ActualBalanceDto'
5148
+ }
5149
+ ]
3952
5150
  },
3953
- isExperimentalFeatures: {
3954
- type: 'boolean',
3955
- description: 'Enable experimental features'
5151
+ tolerance: {
5152
+ type: 'string',
5153
+ description:
5154
+ 'Optional explicit tolerance override. Omit to infer from amount precision (Beancount default).',
5155
+ example: '0.01'
5156
+ }
5157
+ },
5158
+ required: ['accountId', 'asOfDate', 'actualBalance']
5159
+ } as const;
5160
+
5161
+ export const $ReconciliationRecordDto = {
5162
+ type: 'object',
5163
+ properties: {
5164
+ id: {
5165
+ type: 'string'
3956
5166
  },
3957
- isRestrictedView: {
3958
- type: 'boolean',
3959
- description: 'Enable restricted view mode'
5167
+ accountId: {
5168
+ type: 'string'
3960
5169
  },
3961
- language: {
5170
+ date: {
5171
+ type: 'string'
5172
+ },
5173
+ amount: {
3962
5174
  type: 'string',
3963
- description: 'Language code',
3964
- example: 'en'
5175
+ description: 'Asserted (actual) amount.'
3965
5176
  },
3966
- locale: {
5177
+ currency: {
5178
+ type: 'string'
5179
+ },
5180
+ tolerance: {
5181
+ type: 'string'
5182
+ },
5183
+ diffAmount: {
3967
5184
  type: 'string',
3968
- description: 'Locale code',
3969
- example: 'en-US'
5185
+ description: 'book − actual.'
3970
5186
  },
3971
- projectedTotalAmount: {
3972
- type: 'number',
3973
- description: 'Projected total amount',
3974
- example: 1000000
5187
+ diffCurrency: {
5188
+ type: 'string'
3975
5189
  },
3976
- retirementDate: {
5190
+ createdAt: {
5191
+ type: 'string'
5192
+ }
5193
+ },
5194
+ required: ['id', 'accountId', 'date', 'amount', 'currency', 'createdAt']
5195
+ } as const;
5196
+
5197
+ export const $PadReconciliationDto = {
5198
+ type: 'object',
5199
+ properties: {
5200
+ accountId: {
3977
5201
  type: 'string',
3978
- description: 'Retirement date in ISO 8601 format',
3979
- example: '2050-01-01'
5202
+ description: 'BeanAccount id to reconcile.'
3980
5203
  },
3981
- savingsRate: {
3982
- type: 'number',
3983
- description: 'Savings rate percentage',
3984
- example: 0.2
5204
+ asOfDate: {
5205
+ type: 'string',
5206
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5207
+ example: '2026-07-24'
3985
5208
  },
3986
- viewMode: {
5209
+ actualBalance: {
5210
+ description: 'Actual balance from the external statement.',
5211
+ allOf: [
5212
+ {
5213
+ $ref: '#/components/schemas/ActualBalanceDto'
5214
+ }
5215
+ ]
5216
+ },
5217
+ sourceAccount: {
3987
5218
  type: 'string',
3988
- description: 'View mode',
3989
- enum: ['DEFAULT', 'ZEN']
5219
+ description:
5220
+ 'Pad source account. Defaults to Equity:Opening-Balances (official Beancount convention).',
5221
+ example: 'Equity:Opening-Balances',
5222
+ default: 'Equity:Opening-Balances'
3990
5223
  }
3991
- }
5224
+ },
5225
+ required: ['accountId', 'asOfDate', 'actualBalance']
3992
5226
  } as const;
3993
5227
 
3994
- export const $UpdatePropertyDto = {
5228
+ export const $PadResultDto = {
3995
5229
  type: 'object',
3996
5230
  properties: {
3997
- value: {
5231
+ transactionId: {
3998
5232
  type: 'string',
3999
- description: 'Property value'
5233
+ description: 'Created pad adjusting transaction id.'
4000
5234
  }
4001
5235
  },
4002
- required: ['value']
5236
+ required: ['transactionId']
4003
5237
  } as const;
4004
5238
 
4005
5239
  export const $FileImportDto = {
@@ -4168,7 +5402,7 @@ export const $IdentifyResultDto = {
4168
5402
  account: {
4169
5403
  type: 'string',
4170
5404
  description: 'Default account used by this importer',
4171
- example: 'Assets:Alipay:Balance'
5405
+ example: 'Assets:CN:Alipay:Balance'
4172
5406
  },
4173
5407
  message: {
4174
5408
  type: 'string',
@@ -4185,7 +5419,7 @@ export const $MapperDefaultsDto = {
4185
5419
  sourceAccount: {
4186
5420
  type: 'string',
4187
5421
  description: 'Source account for transactions (Beancount format)',
4188
- example: 'Assets:Alipay:Balance'
5422
+ example: 'Assets:CN:Alipay:Balance'
4189
5423
  },
4190
5424
  currency: {
4191
5425
  type: 'string',
@@ -4222,7 +5456,7 @@ export const $MapperDefaultsDto = {
4222
5456
  description:
4223
5457
  '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).',
4224
5458
  example: {
4225
- HuaBei: 'Liabilities:Alipay:Huabei',
5459
+ HuaBei: 'Liabilities:CN:CreditLine',
4226
5460
  CreditCard: 'Liabilities:CreditCard'
4227
5461
  }
4228
5462
  }
@@ -4354,7 +5588,7 @@ export const $UpdateMapperDefaultsDto = {
4354
5588
  sourceAccount: {
4355
5589
  type: 'string',
4356
5590
  description: 'Source account for transactions (Beancount format)',
4357
- example: 'Assets:Alipay:Balance',
5591
+ example: 'Assets:CN:Alipay:Balance',
4358
5592
  pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4359
5593
  },
4360
5594
  currency: {
@@ -4382,7 +5616,7 @@ export const $UpdateMapperDefaultsDto = {
4382
5616
  description:
4383
5617
  '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).',
4384
5618
  example: {
4385
- HuaBei: 'Liabilities:Alipay:Huabei',
5619
+ HuaBei: 'Liabilities:CN:CreditLine',
4386
5620
  CreditCard: 'Liabilities:CreditCard'
4387
5621
  }
4388
5622
  }
@@ -4417,119 +5651,13 @@ export const $UpdateImporterConfigDto = {
4417
5651
  }
4418
5652
  } as const;
4419
5653
 
4420
- export const $CreatePlatformDto = {
4421
- type: 'object',
4422
- properties: {
4423
- name: {
4424
- type: 'string',
4425
- description: 'Platform name',
4426
- example: 'Binance'
4427
- },
4428
- canonical: {
4429
- type: 'string',
4430
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4431
- example: 'binance'
4432
- },
4433
- aliases: {
4434
- description: 'Platform aliases (multi-language names for lookup)',
4435
- example: ['Binance', 'Binance Exchange', 'BNB'],
4436
- type: 'array',
4437
- items: {
4438
- type: 'string'
4439
- }
4440
- },
4441
- url: {
4442
- type: 'string',
4443
- description: 'Platform URL',
4444
- example: 'https://www.binance.com'
4445
- },
4446
- type: {
4447
- type: 'string',
4448
- description: 'Platform type',
4449
- enum: [
4450
- 'BANK',
4451
- 'BROKERAGE',
4452
- 'CRYPTO_EXCHANGE',
4453
- 'PAYMENT',
4454
- 'INVESTMENT',
4455
- 'INSURANCE',
4456
- 'OTHER'
4457
- ],
4458
- example: 'CRYPTO_EXCHANGE'
4459
- },
4460
- logoUrl: {
4461
- type: 'string',
4462
- description: 'Platform logo URL',
4463
- example: 'https://example.com/logos/binance.png'
4464
- },
4465
- isActive: {
4466
- type: 'boolean',
4467
- description: 'Whether the platform is active',
4468
- default: true
4469
- }
4470
- },
4471
- required: ['name', 'canonical', 'aliases', 'url', 'type']
4472
- } as const;
4473
-
4474
- export const $UpdatePlatformDto = {
4475
- type: 'object',
4476
- properties: {
4477
- name: {
4478
- type: 'string',
4479
- description: 'Platform name',
4480
- example: 'Binance'
4481
- },
4482
- canonical: {
4483
- type: 'string',
4484
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4485
- example: 'binance'
4486
- },
4487
- aliases: {
4488
- description: 'Platform aliases (multi-language names for lookup)',
4489
- example: ['Binance', 'Binance Exchange', 'BNB'],
4490
- type: 'array',
4491
- items: {
4492
- type: 'string'
4493
- }
4494
- },
4495
- url: {
4496
- type: 'string',
4497
- description: 'Platform URL',
4498
- example: 'https://www.binance.com'
4499
- },
4500
- type: {
4501
- type: 'string',
4502
- description: 'Platform type',
4503
- enum: [
4504
- 'BANK',
4505
- 'BROKERAGE',
4506
- 'CRYPTO_EXCHANGE',
4507
- 'PAYMENT',
4508
- 'INVESTMENT',
4509
- 'INSURANCE',
4510
- 'OTHER'
4511
- ],
4512
- example: 'CRYPTO_EXCHANGE'
4513
- },
4514
- logoUrl: {
4515
- type: 'string',
4516
- description: 'Platform logo URL',
4517
- example: 'https://example.com/logos/binance.png'
4518
- },
4519
- isActive: {
4520
- type: 'boolean',
4521
- description: 'Whether the platform is active'
4522
- }
4523
- }
4524
- } as const;
4525
-
4526
5654
  export const $ProviderSyncConfigDto = {
4527
5655
  type: 'object',
4528
5656
  properties: {
4529
5657
  sourceAccount: {
4530
5658
  type: 'string',
4531
5659
  description: 'Source account for the first posting',
4532
- example: 'Assets:Bank:Chase'
5660
+ example: 'Assets:US:Chase:Checking'
4533
5661
  },
4534
5662
  defaultCurrency: {
4535
5663
  type: 'string',
@@ -4550,6 +5678,12 @@ export const $ProviderSyncConfigDto = {
4550
5678
  type: 'boolean',
4551
5679
  description: 'Filter pending transactions',
4552
5680
  default: true
5681
+ },
5682
+ externalAccountId: {
5683
+ type: 'string',
5684
+ description:
5685
+ 'External account ID for per-batch providers (e.g. GoCardless). Overrides sourceAccount when an ExternalAccountLink mapping exists.',
5686
+ example: 'acc_gocardless_001'
4553
5687
  }
4554
5688
  },
4555
5689
  required: [
@@ -4666,7 +5800,95 @@ export const $SupportedProvidersResponseDto = {
4666
5800
  }
4667
5801
  }
4668
5802
  },
4669
- required: ['providers']
5803
+ required: ['providers']
5804
+ } as const;
5805
+
5806
+ export const $CreateExternalAccountLinkDto = {
5807
+ type: 'object',
5808
+ properties: {
5809
+ provider: {
5810
+ type: 'string',
5811
+ enum: [
5812
+ 'plaid',
5813
+ 'teller',
5814
+ 'truelayer',
5815
+ 'gocardless',
5816
+ 'simplefin',
5817
+ 'yodlee',
5818
+ 'beancount-direct',
5819
+ 'parsed-bill'
5820
+ ],
5821
+ example: 'plaid',
5822
+ description: 'Open Banking provider (whitelist)'
5823
+ },
5824
+ externalAccountId: {
5825
+ type: 'string',
5826
+ example: 'acc-plaid-001',
5827
+ description: 'External account ID from the provider'
5828
+ },
5829
+ beanAccountId: {
5830
+ type: 'string',
5831
+ example: '550e8400-e29b-41d4-a716-446655440000',
5832
+ description: 'Target BeanAccount ID (must belong to the JWT user)'
5833
+ }
5834
+ },
5835
+ required: ['provider', 'externalAccountId', 'beanAccountId']
5836
+ } as const;
5837
+
5838
+ export const $ExternalAccountLinkResponseDto = {
5839
+ type: 'object',
5840
+ properties: {
5841
+ id: {
5842
+ type: 'string'
5843
+ },
5844
+ provider: {
5845
+ type: 'string'
5846
+ },
5847
+ externalAccountId: {
5848
+ type: 'string'
5849
+ },
5850
+ beanAccountId: {
5851
+ type: 'string'
5852
+ },
5853
+ isActive: {
5854
+ type: 'boolean'
5855
+ },
5856
+ createdAt: {
5857
+ type: 'string'
5858
+ },
5859
+ updatedAt: {
5860
+ type: 'string'
5861
+ }
5862
+ },
5863
+ required: [
5864
+ 'id',
5865
+ 'provider',
5866
+ 'externalAccountId',
5867
+ 'beanAccountId',
5868
+ 'isActive',
5869
+ 'createdAt',
5870
+ 'updatedAt'
5871
+ ]
5872
+ } as const;
5873
+
5874
+ export const $ExternalAccountLinkListResponseDto = {
5875
+ type: 'object',
5876
+ properties: {
5877
+ items: {
5878
+ type: 'array',
5879
+ items: {
5880
+ $ref: '#/components/schemas/ExternalAccountLinkResponseDto'
5881
+ }
5882
+ },
5883
+ total: {
5884
+ type: 'number'
5885
+ },
5886
+ provider: {
5887
+ type: 'string',
5888
+ description: 'Filter by provider (query param)'
5889
+ }
5890
+ },
5891
+ required: ['items', 'total']
4670
5892
  } as const;
4671
5893
 
4672
5894
  export const $ParserTelemetryReportDto = {
@@ -4674,6 +5896,11 @@ export const $ParserTelemetryReportDto = {
4674
5896
  properties: {}
4675
5897
  } as const;
4676
5898
 
5899
+ export const $UncoveredFormatMissDto = {
5900
+ type: 'object',
5901
+ properties: {}
5902
+ } as const;
5903
+
4677
5904
  export const $ProcessNlpDto = {
4678
5905
  type: 'object',
4679
5906
  properties: {
@@ -4688,6 +5915,16 @@ export const $ProcessNlpDto = {
4688
5915
  description:
4689
5916
  'Session ID for multi-turn conversation (auto-generated if not provided)',
4690
5917
  example: 'session_abc123'
5918
+ },
5919
+ parsedData: {
5920
+ type: 'object',
5921
+ description:
5922
+ 'Parsed data from previous NLP response for session recovery. Send back the parsedData received in confirm_payee/confirm responses.',
5923
+ example: {
5924
+ amount: 35,
5925
+ currency: 'CNY',
5926
+ payee: 'Starbucks'
5927
+ }
4691
5928
  }
4692
5929
  },
4693
5930
  required: ['message']
@@ -5203,7 +6440,7 @@ export const $NlpSuggestedAccountDto = {
5203
6440
  account: {
5204
6441
  type: 'string',
5205
6442
  description: 'Suggested account path',
5206
- example: 'Assets:Bank:Checking'
6443
+ example: 'Assets:Checking'
5207
6444
  },
5208
6445
  confidence: {
5209
6446
  type: 'number',
@@ -5244,7 +6481,7 @@ export const $NlpDefaultAccountsDto = {
5244
6481
  asset: {
5245
6482
  type: 'string',
5246
6483
  description: 'Default asset account',
5247
- example: 'Assets:Bank:Checking'
6484
+ example: 'Assets:Checking'
5248
6485
  },
5249
6486
  expense: {
5250
6487
  type: 'string',
@@ -5466,21 +6703,252 @@ export const $NlpResponseDto = {
5466
6703
  required: ['status', 'action']
5467
6704
  } as const;
5468
6705
 
5469
- export const $BalanceByCurrencyDto = {
6706
+ export const $PlatformListItemDto = {
5470
6707
  type: 'object',
5471
6708
  properties: {
5472
- currency: {
6709
+ id: {
5473
6710
  type: 'string',
5474
- description: 'ISO 4217 currency code',
5475
- example: 'CNY'
6711
+ description: 'Global platform ID'
5476
6712
  },
5477
- balance: {
6713
+ name: {
5478
6714
  type: 'string',
5479
- description: 'Balance amount',
5480
- example: '50000.00'
6715
+ description: 'Platform name'
6716
+ },
6717
+ url: {
6718
+ type: 'string',
6719
+ description: 'Platform URL'
6720
+ },
6721
+ type: {
6722
+ type: 'string',
6723
+ description: 'Platform type',
6724
+ enum: [
6725
+ 'BANK',
6726
+ 'BROKERAGE',
6727
+ 'CRYPTO_EXCHANGE',
6728
+ 'PAYMENT',
6729
+ 'INVESTMENT',
6730
+ 'INSURANCE',
6731
+ 'OTHER'
6732
+ ]
6733
+ },
6734
+ canonical: {
6735
+ type: 'string',
6736
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6737
+ },
6738
+ suggestedSegment: {
6739
+ type: 'string',
6740
+ description:
6741
+ 'Suggested path segment — canonical with first char uppercased (ACC_COMP_NAME_RE)'
6742
+ },
6743
+ logoUrl: {
6744
+ type: 'string',
6745
+ description: 'Logo URL',
6746
+ nullable: true
6747
+ },
6748
+ isBound: {
6749
+ type: 'boolean',
6750
+ description: 'Whether user has accounts using this platform'
5481
6751
  }
5482
6752
  },
5483
- required: ['currency', 'balance']
6753
+ required: [
6754
+ 'id',
6755
+ 'name',
6756
+ 'url',
6757
+ 'type',
6758
+ 'canonical',
6759
+ 'suggestedSegment',
6760
+ 'logoUrl',
6761
+ 'isBound'
6762
+ ]
6763
+ } as const;
6764
+
6765
+ export const $PlatformMatchResultDto = {
6766
+ type: 'object',
6767
+ properties: {
6768
+ id: {
6769
+ type: 'string',
6770
+ description: 'Global platform ID'
6771
+ },
6772
+ name: {
6773
+ type: 'string',
6774
+ description: 'Platform name (e.g., "ICBC")'
6775
+ },
6776
+ canonical: {
6777
+ type: 'string',
6778
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6779
+ },
6780
+ type: {
6781
+ type: 'string',
6782
+ description: 'Platform type',
6783
+ enum: [
6784
+ 'BANK',
6785
+ 'BROKERAGE',
6786
+ 'CRYPTO_EXCHANGE',
6787
+ 'PAYMENT',
6788
+ 'INVESTMENT',
6789
+ 'INSURANCE',
6790
+ 'OTHER'
6791
+ ]
6792
+ },
6793
+ suggestedSegment: {
6794
+ type: 'string',
6795
+ description:
6796
+ 'Suggested path segment — canonical, already in ACCOUNT_RE format'
6797
+ },
6798
+ logoUrl: {
6799
+ type: 'string',
6800
+ description: 'Logo URL',
6801
+ nullable: true
6802
+ },
6803
+ matchType: {
6804
+ type: 'string',
6805
+ description: "How this row matched: 'exact' > 'prefix' > 'substring'",
6806
+ enum: ['exact', 'prefix', 'substring']
6807
+ }
6808
+ },
6809
+ required: [
6810
+ 'id',
6811
+ 'name',
6812
+ 'canonical',
6813
+ 'type',
6814
+ 'suggestedSegment',
6815
+ 'logoUrl',
6816
+ 'matchType'
6817
+ ]
6818
+ } as const;
6819
+
6820
+ export const $PlatformMatchResponseDto = {
6821
+ type: 'object',
6822
+ properties: {
6823
+ platforms: {
6824
+ description: 'Ranked matches, best tier first (at most 10 rows)',
6825
+ type: 'array',
6826
+ items: {
6827
+ $ref: '#/components/schemas/PlatformMatchResultDto'
6828
+ }
6829
+ },
6830
+ matchType: {
6831
+ type: 'string',
6832
+ description:
6833
+ "Overall match quality — top row's tier, or 'none' when no hits",
6834
+ enum: ['none', 'exact', 'prefix', 'substring']
6835
+ },
6836
+ total: {
6837
+ type: 'number',
6838
+ description: 'Total matches before LIMIT (truncation transparency)'
6839
+ },
6840
+ hasMore: {
6841
+ type: 'boolean',
6842
+ description: 'true when total > platforms.length (more matches exist)'
6843
+ }
6844
+ },
6845
+ required: ['platforms', 'matchType', 'total', 'hasMore']
6846
+ } as const;
6847
+
6848
+ export const $CreatePlatformDto = {
6849
+ type: 'object',
6850
+ properties: {
6851
+ name: {
6852
+ type: 'string',
6853
+ description: 'Platform name',
6854
+ example: 'Binance'
6855
+ },
6856
+ canonical: {
6857
+ type: 'string',
6858
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6859
+ example: 'binance'
6860
+ },
6861
+ aliases: {
6862
+ description: 'Platform aliases (multi-language names for lookup)',
6863
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6864
+ type: 'array',
6865
+ items: {
6866
+ type: 'string'
6867
+ }
6868
+ },
6869
+ url: {
6870
+ type: 'string',
6871
+ description: 'Platform URL',
6872
+ example: 'https://www.binance.com'
6873
+ },
6874
+ type: {
6875
+ type: 'string',
6876
+ description: 'Platform type',
6877
+ enum: [
6878
+ 'BANK',
6879
+ 'BROKERAGE',
6880
+ 'CRYPTO_EXCHANGE',
6881
+ 'PAYMENT',
6882
+ 'INVESTMENT',
6883
+ 'INSURANCE',
6884
+ 'OTHER'
6885
+ ],
6886
+ example: 'CRYPTO_EXCHANGE'
6887
+ },
6888
+ logoUrl: {
6889
+ type: 'string',
6890
+ description: 'Platform logo URL',
6891
+ example: 'https://example.com/logos/binance.png'
6892
+ },
6893
+ isActive: {
6894
+ type: 'boolean',
6895
+ description: 'Whether the platform is active',
6896
+ default: true
6897
+ }
6898
+ },
6899
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
6900
+ } as const;
6901
+
6902
+ export const $UpdatePlatformDto = {
6903
+ type: 'object',
6904
+ properties: {
6905
+ name: {
6906
+ type: 'string',
6907
+ description: 'Platform name',
6908
+ example: 'Binance'
6909
+ },
6910
+ canonical: {
6911
+ type: 'string',
6912
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6913
+ example: 'binance'
6914
+ },
6915
+ aliases: {
6916
+ description: 'Platform aliases (multi-language names for lookup)',
6917
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6918
+ type: 'array',
6919
+ items: {
6920
+ type: 'string'
6921
+ }
6922
+ },
6923
+ url: {
6924
+ type: 'string',
6925
+ description: 'Platform URL',
6926
+ example: 'https://www.binance.com'
6927
+ },
6928
+ type: {
6929
+ type: 'string',
6930
+ description: 'Platform type',
6931
+ enum: [
6932
+ 'BANK',
6933
+ 'BROKERAGE',
6934
+ 'CRYPTO_EXCHANGE',
6935
+ 'PAYMENT',
6936
+ 'INVESTMENT',
6937
+ 'INSURANCE',
6938
+ 'OTHER'
6939
+ ],
6940
+ example: 'CRYPTO_EXCHANGE'
6941
+ },
6942
+ logoUrl: {
6943
+ type: 'string',
6944
+ description: 'Platform logo URL',
6945
+ example: 'https://example.com/logos/binance.png'
6946
+ },
6947
+ isActive: {
6948
+ type: 'boolean',
6949
+ description: 'Whether the platform is active'
6950
+ }
6951
+ }
5484
6952
  } as const;
5485
6953
 
5486
6954
  export const $NetWorthByCurrencyDto = {
@@ -5537,41 +7005,19 @@ export const $ConvertedNetWorthDto = {
5537
7005
  exchangeRates: {
5538
7006
  type: 'object',
5539
7007
  description: 'Exchange rates used for conversion',
5540
- example: {
5541
- USD: '7.200000',
5542
- EUR: '7.800000'
5543
- }
5544
- }
5545
- },
5546
- required: [
5547
- 'baseCurrency',
5548
- 'netWorth',
5549
- 'assets',
5550
- 'liabilities',
5551
- 'exchangeRates'
5552
- ]
5553
- } as const;
5554
-
5555
- export const $ExchangeRateWarningDto = {
5556
- type: 'object',
5557
- properties: {
5558
- type: {
5559
- type: 'string',
5560
- description: 'Warning type',
5561
- example: 'MISSING_EXCHANGE_RATE'
5562
- },
5563
- currency: {
5564
- type: 'string',
5565
- description: 'Currency without exchange rate',
5566
- example: 'EUR'
5567
- },
5568
- totalAmount: {
5569
- type: 'string',
5570
- description: 'Total amount affected',
5571
- example: '1000.00'
7008
+ example: {
7009
+ USD: '7.200000',
7010
+ EUR: '7.800000'
7011
+ }
5572
7012
  }
5573
7013
  },
5574
- required: ['type', 'currency', 'totalAmount']
7014
+ required: [
7015
+ 'baseCurrency',
7016
+ 'netWorth',
7017
+ 'assets',
7018
+ 'liabilities',
7019
+ 'exchangeRates'
7020
+ ]
5575
7021
  } as const;
5576
7022
 
5577
7023
  export const $NetWorthResponseDto = {
@@ -5659,7 +7105,7 @@ export const $AccountItemDto = {
5659
7105
  name: {
5660
7106
  type: 'string',
5661
7107
  description: 'Full account name',
5662
- example: 'Assets:Bank:CMB:Savings'
7108
+ example: 'Assets:CN:CMB:Savings'
5663
7109
  },
5664
7110
  displayName: {
5665
7111
  type: 'string',
@@ -5675,6 +7121,12 @@ export const $AccountItemDto = {
5675
7121
  type: 'string',
5676
7122
  description: 'Currency code',
5677
7123
  example: 'CNY'
7124
+ },
7125
+ convertedBalance: {
7126
+ type: 'string',
7127
+ description:
7128
+ 'FX-converted balance in base currency; omitted when not convertible',
7129
+ example: '50000.00'
5678
7130
  }
5679
7131
  },
5680
7132
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -5701,11 +7153,66 @@ export const $PlatformGroupDto = {
5701
7153
  },
5702
7154
  totalBalance: {
5703
7155
  type: 'string',
5704
- description: 'Total balance across all accounts in platform',
7156
+ description: 'FX-converted total balance in base currency',
7157
+ example: '100000.00'
7158
+ },
7159
+ balanceByCurrency: {
7160
+ description: 'Raw (unconverted) balances grouped by currency',
7161
+ type: 'array',
7162
+ items: {
7163
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7164
+ }
7165
+ },
7166
+ convertedBalance: {
7167
+ type: 'string',
7168
+ description:
7169
+ 'Converted balance in base currency (omitted when no currency is convertible)',
5705
7170
  example: '100000.00'
7171
+ },
7172
+ sharePct: {
7173
+ type: 'number',
7174
+ description:
7175
+ 'Share of the grand converted total (0-100); 0 when grand total is 0',
7176
+ example: 42.5
7177
+ }
7178
+ },
7179
+ required: [
7180
+ 'platformId',
7181
+ 'platformName',
7182
+ 'accounts',
7183
+ 'totalBalance',
7184
+ 'balanceByCurrency',
7185
+ 'sharePct'
7186
+ ]
7187
+ } as const;
7188
+
7189
+ export const $AccountExchangeRateWarningDto = {
7190
+ type: 'object',
7191
+ properties: {
7192
+ type: {
7193
+ type: 'string',
7194
+ description: 'Warning type',
7195
+ example: 'MISSING_EXCHANGE_RATE'
7196
+ },
7197
+ currency: {
7198
+ type: 'string',
7199
+ description: 'Currency without exchange rate',
7200
+ example: 'USD'
7201
+ },
7202
+ accounts: {
7203
+ description: 'Affected account paths',
7204
+ type: 'array',
7205
+ items: {
7206
+ type: 'string'
7207
+ }
7208
+ },
7209
+ totalAmount: {
7210
+ type: 'string',
7211
+ description: 'Total amount in this currency',
7212
+ example: '5000.00'
5706
7213
  }
5707
7214
  },
5708
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
7215
+ required: ['type', 'currency', 'accounts', 'totalAmount']
5709
7216
  } as const;
5710
7217
 
5711
7218
  export const $AccountsSummaryDto = {
@@ -5718,9 +7225,21 @@ export const $AccountsSummaryDto = {
5718
7225
  totalPlatforms: {
5719
7226
  type: 'number',
5720
7227
  description: 'Total number of platforms'
7228
+ },
7229
+ baseCurrency: {
7230
+ type: 'string',
7231
+ description: 'Base currency for conversion',
7232
+ example: 'CNY'
7233
+ },
7234
+ warnings: {
7235
+ description: 'Per-account exchange rate warnings',
7236
+ type: 'array',
7237
+ items: {
7238
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
7239
+ }
5721
7240
  }
5722
7241
  },
5723
- required: ['totalAccounts', 'totalPlatforms']
7242
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
5724
7243
  } as const;
5725
7244
 
5726
7245
  export const $AccountsResponseDto = {
@@ -5755,7 +7274,7 @@ export const $AccountItemWithAssetClassDto = {
5755
7274
  name: {
5756
7275
  type: 'string',
5757
7276
  description: 'Full account name',
5758
- example: 'Assets:Bank:CMB:Savings'
7277
+ example: 'Assets:CN:CMB:Savings'
5759
7278
  },
5760
7279
  displayName: {
5761
7280
  type: 'string',
@@ -5772,6 +7291,12 @@ export const $AccountItemWithAssetClassDto = {
5772
7291
  description: 'Currency code',
5773
7292
  example: 'CNY'
5774
7293
  },
7294
+ convertedBalance: {
7295
+ type: 'string',
7296
+ description:
7297
+ 'FX-converted balance in base currency; omitted when not convertible',
7298
+ example: '50000.00'
7299
+ },
5775
7300
  assetClass: {
5776
7301
  type: 'string',
5777
7302
  description: 'Asset class',
@@ -5791,6 +7316,12 @@ export const $AccountItemWithAssetClassDto = {
5791
7316
  type: 'string',
5792
7317
  description: 'Risk level',
5793
7318
  example: 'LOW'
7319
+ },
7320
+ source: {
7321
+ type: 'string',
7322
+ description:
7323
+ 'ADR-0105 classification provenance (holding level always; account level only on FALLBACK)',
7324
+ enum: ['USER_META', 'FIAT_CURRENCY', 'OPENBB_MAPPING', 'FALLBACK']
5794
7325
  }
5795
7326
  },
5796
7327
  required: ['id', 'name', 'displayName', 'balance', 'currency', 'assetClass']
@@ -5845,35 +7376,6 @@ export const $AssetClassGroupDto = {
5845
7376
  required: ['assetClass', 'accounts', 'balanceByCurrency']
5846
7377
  } as const;
5847
7378
 
5848
- export const $AccountExchangeRateWarningDto = {
5849
- type: 'object',
5850
- properties: {
5851
- type: {
5852
- type: 'string',
5853
- description: 'Warning type',
5854
- example: 'MISSING_EXCHANGE_RATE'
5855
- },
5856
- currency: {
5857
- type: 'string',
5858
- description: 'Currency without exchange rate',
5859
- example: 'USD'
5860
- },
5861
- accounts: {
5862
- description: 'Affected account paths',
5863
- type: 'array',
5864
- items: {
5865
- type: 'string'
5866
- }
5867
- },
5868
- totalAmount: {
5869
- type: 'string',
5870
- description: 'Total amount in this currency',
5871
- example: '5000.00'
5872
- }
5873
- },
5874
- required: ['type', 'currency', 'accounts', 'totalAmount']
5875
- } as const;
5876
-
5877
7379
  export const $AssetClassSummaryDto = {
5878
7380
  type: 'object',
5879
7381
  properties: {
@@ -5896,6 +7398,11 @@ export const $AssetClassSummaryDto = {
5896
7398
  items: {
5897
7399
  $ref: '#/components/schemas/AccountExchangeRateWarningDto'
5898
7400
  }
7401
+ },
7402
+ fallback: {
7403
+ type: 'object',
7404
+ description:
7405
+ 'ADR-0105 §4 fallback provenance stats (holding level only). valueRatio is the grey-area share of total converted value; count is the number of source=FALLBACK holdings.'
5899
7406
  }
5900
7407
  },
5901
7408
  required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
@@ -5918,11 +7425,107 @@ export const $AssetClassAccountsResponseDto = {
5918
7425
  $ref: '#/components/schemas/AssetClassSummaryDto'
5919
7426
  }
5920
7427
  ]
7428
+ },
7429
+ uncategorized: {
7430
+ description:
7431
+ 'ADR-0105 §6 holding-level grey-area bucket (source=FALLBACK holdings peeled out of groups). Present only for groupBy=holdingAssetClass when FALLBACK holdings exist.',
7432
+ allOf: [
7433
+ {
7434
+ $ref: '#/components/schemas/AssetClassGroupDto'
7435
+ }
7436
+ ]
5921
7437
  }
5922
7438
  },
5923
7439
  required: ['groups', 'summary']
5924
7440
  } as const;
5925
7441
 
7442
+ export const $HoldingAssetClassAccountSliceDto = {
7443
+ type: 'object',
7444
+ properties: {
7445
+ accountId: {
7446
+ type: 'string',
7447
+ description: 'Account ID'
7448
+ },
7449
+ accountPath: {
7450
+ type: 'string',
7451
+ description: 'Full account path',
7452
+ example: 'Assets:US:Fidelity:Brokerage'
7453
+ },
7454
+ accountCurrency: {
7455
+ type: 'string',
7456
+ description:
7457
+ 'Currency of the holding with the largest converted base value; undefined when no holding is convertible',
7458
+ example: 'USD'
7459
+ },
7460
+ marketValueBase: {
7461
+ type: 'string',
7462
+ description:
7463
+ "Account's market value in base currency (Σ converted holdings; grey bucket included)",
7464
+ example: '50000.00'
7465
+ },
7466
+ shareOfTotalPct: {
7467
+ type: 'number',
7468
+ description:
7469
+ 'Share of the global total (0-100). 0 when globalTotal is zero (no NaN/Infinity).',
7470
+ example: 42.5
7471
+ },
7472
+ groups: {
7473
+ description: 'Per-account asset-class breakdown',
7474
+ type: 'array',
7475
+ items: {
7476
+ $ref: '#/components/schemas/AssetClassGroupDto'
7477
+ }
7478
+ },
7479
+ uncategorized: {
7480
+ description:
7481
+ 'Per-account grey bucket (source=FALLBACK holdings, incl. broker cash)',
7482
+ allOf: [
7483
+ {
7484
+ $ref: '#/components/schemas/AssetClassGroupDto'
7485
+ }
7486
+ ]
7487
+ },
7488
+ holdings: {
7489
+ description:
7490
+ 'Every holding row for this account (account ID in each row’s `id` field)',
7491
+ type: 'array',
7492
+ items: {
7493
+ $ref: '#/components/schemas/AccountItemWithAssetClassDto'
7494
+ }
7495
+ }
7496
+ },
7497
+ required: [
7498
+ 'accountId',
7499
+ 'accountPath',
7500
+ 'marketValueBase',
7501
+ 'shareOfTotalPct',
7502
+ 'groups',
7503
+ 'holdings'
7504
+ ]
7505
+ } as const;
7506
+
7507
+ export const $HoldingAssetClassCrossAccountResponseDto = {
7508
+ type: 'object',
7509
+ properties: {
7510
+ global: {
7511
+ description: 'Merged cross-account holding aggregation',
7512
+ allOf: [
7513
+ {
7514
+ $ref: '#/components/schemas/AssetClassAccountsResponseDto'
7515
+ }
7516
+ ]
7517
+ },
7518
+ byAccount: {
7519
+ description: 'Per-account slices',
7520
+ type: 'array',
7521
+ items: {
7522
+ $ref: '#/components/schemas/HoldingAssetClassAccountSliceDto'
7523
+ }
7524
+ }
7525
+ },
7526
+ required: ['global', 'byAccount']
7527
+ } as const;
7528
+
5926
7529
  export const $CashFlowByCurrencyDto = {
5927
7530
  type: 'object',
5928
7531
  properties: {
@@ -6018,202 +7621,422 @@ export const $CashFlowResponseDto = {
6018
7621
  description: 'Base currency code',
6019
7622
  example: 'CNY'
6020
7623
  },
6021
- byCurrency: {
6022
- description: 'Cash flow grouped by original currency',
6023
- allOf: [
6024
- {
6025
- $ref: '#/components/schemas/CashFlowByCurrencyDto'
6026
- }
6027
- ]
7624
+ byCurrency: {
7625
+ description: 'Cash flow grouped by original currency',
7626
+ allOf: [
7627
+ {
7628
+ $ref: '#/components/schemas/CashFlowByCurrencyDto'
7629
+ }
7630
+ ]
7631
+ },
7632
+ converted: {
7633
+ description: 'Converted values in base currency',
7634
+ allOf: [
7635
+ {
7636
+ $ref: '#/components/schemas/ConvertedCashFlowDto'
7637
+ }
7638
+ ]
7639
+ },
7640
+ warnings: {
7641
+ description: 'Exchange rate warnings',
7642
+ type: 'array',
7643
+ items: {
7644
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7645
+ }
7646
+ }
7647
+ },
7648
+ required: [
7649
+ 'period',
7650
+ 'income',
7651
+ 'expense',
7652
+ 'netSavings',
7653
+ 'savingsRate',
7654
+ 'currency'
7655
+ ]
7656
+ } as const;
7657
+
7658
+ export const $CategoryGroupDto = {
7659
+ type: 'object',
7660
+ properties: {
7661
+ category: {
7662
+ type: 'string',
7663
+ description:
7664
+ 'Functional category (account-path Group segment); regional and universal account paths merge under it',
7665
+ example: 'Food'
7666
+ },
7667
+ totalExpense: {
7668
+ type: 'string',
7669
+ description:
7670
+ 'Converted total for this category in base currency (expense amount when flow=expense, income amount when flow=income)',
7671
+ example: '1200.00'
7672
+ },
7673
+ sharePct: {
7674
+ type: 'number',
7675
+ description: 'Share of grand total (0-100); 0 when grand total is 0',
7676
+ example: 42.5
7677
+ },
7678
+ balanceByCurrency: {
7679
+ description: 'Raw (unconverted) expense per currency',
7680
+ type: 'array',
7681
+ items: {
7682
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7683
+ }
7684
+ },
7685
+ convertedBalance: {
7686
+ type: 'string',
7687
+ description:
7688
+ 'Converted total in base currency (omitted when FX missing for all currencies in this category)',
7689
+ example: '1200.00'
7690
+ }
7691
+ },
7692
+ required: ['category', 'totalExpense', 'sharePct', 'balanceByCurrency']
7693
+ } as const;
7694
+
7695
+ export const $ExpensesByCategorySummaryDto = {
7696
+ type: 'object',
7697
+ properties: {
7698
+ totalExpense: {
7699
+ type: 'string',
7700
+ description:
7701
+ 'Total across all categories, converted (convertible categories only); expense totals when flow=expense, income totals when flow=income',
7702
+ example: '5000.00'
7703
+ },
7704
+ categoryCount: {
7705
+ type: 'number',
7706
+ description: 'Number of categories',
7707
+ example: 8
7708
+ }
7709
+ },
7710
+ required: ['totalExpense', 'categoryCount']
7711
+ } as const;
7712
+
7713
+ export const $ExpensesByCategoryResponseDto = {
7714
+ type: 'object',
7715
+ properties: {
7716
+ period: {
7717
+ type: 'string',
7718
+ description: 'Period requested',
7719
+ example: '1m'
7720
+ },
7721
+ baseCurrency: {
7722
+ type: 'string',
7723
+ description: 'Base currency for converted values',
7724
+ example: 'CNY'
7725
+ },
7726
+ groups: {
7727
+ description:
7728
+ 'Expense groups by functional category, sorted by converted total desc',
7729
+ type: 'array',
7730
+ items: {
7731
+ $ref: '#/components/schemas/CategoryGroupDto'
7732
+ }
6028
7733
  },
6029
- converted: {
6030
- description: 'Converted values in base currency',
7734
+ summary: {
7735
+ description: 'Summary statistics',
6031
7736
  allOf: [
6032
7737
  {
6033
- $ref: '#/components/schemas/ConvertedCashFlowDto'
7738
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
6034
7739
  }
6035
7740
  ]
6036
7741
  },
6037
7742
  warnings: {
6038
- description: 'Exchange rate warnings',
7743
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
6039
7744
  type: 'array',
6040
7745
  items: {
6041
7746
  $ref: '#/components/schemas/ExchangeRateWarningDto'
6042
7747
  }
6043
7748
  }
6044
7749
  },
6045
- required: [
6046
- 'period',
6047
- 'income',
6048
- 'expense',
6049
- 'netSavings',
6050
- 'savingsRate',
6051
- 'currency'
6052
- ]
7750
+ required: ['period', 'baseCurrency', 'groups', 'summary']
6053
7751
  } as const;
6054
7752
 
6055
- export const $CurrencyBalanceDto = {
7753
+ export const $MonetaryDto = {
6056
7754
  type: 'object',
6057
7755
  properties: {
6058
- currency: {
7756
+ amount: {
6059
7757
  type: 'string',
6060
- description: 'ISO 4217 currency code',
6061
- example: 'CNY'
7758
+ description: 'Amount (Decimal string)',
7759
+ example: '3000'
6062
7760
  },
6063
- balance: {
7761
+ currency: {
6064
7762
  type: 'string',
6065
- description: 'Balance amount',
6066
- example: '500000.00'
7763
+ description: 'ISO 4217 currency',
7764
+ example: 'USD'
7765
+ },
7766
+ baseCcyEquivalent: {
7767
+ type: 'object',
7768
+ description: 'Converted to user base currency (Decimal string)',
7769
+ example: '21600',
7770
+ nullable: true
6067
7771
  }
6068
7772
  },
6069
- required: ['currency', 'balance']
7773
+ required: ['amount', 'currency']
6070
7774
  } as const;
6071
7775
 
6072
- export const $TimeSeriesPointDto = {
7776
+ export const $CurrentPriceDto = {
6073
7777
  type: 'object',
6074
7778
  properties: {
6075
- date: {
7779
+ amount: {
6076
7780
  type: 'string',
6077
- description: 'Date in YYYY-MM-DD format',
6078
- example: '2024-06-15'
7781
+ description: 'Price amount (Decimal string)',
7782
+ example: '250'
6079
7783
  },
6080
- value: {
7784
+ currency: {
6081
7785
  type: 'string',
6082
- description: 'Value at this date (in base currency)',
6083
- example: '500000.00'
7786
+ description: 'Price currency (ISO 4217)',
7787
+ example: 'USD'
6084
7788
  },
6085
- change: {
6086
- type: 'object',
6087
- description: 'Change from previous point',
6088
- example: '5000.00'
7789
+ date: {
7790
+ type: 'string',
7791
+ description: 'Price date (ISO 8601)',
7792
+ example: '2024-06-01'
6089
7793
  },
6090
- byCurrency: {
6091
- description: 'Multi-currency breakdown for this point',
6092
- type: 'array',
6093
- items: {
6094
- $ref: '#/components/schemas/CurrencyBalanceDto'
6095
- }
7794
+ source: {
7795
+ type: 'string',
7796
+ description: 'Price source',
7797
+ example: 'USER_OVERRIDE',
7798
+ enum: ['USER_OVERRIDE', 'OPENBB_EQUITY', 'OPENBB_CURRENCY']
6096
7799
  }
6097
7800
  },
6098
- required: ['date', 'value']
7801
+ required: ['amount', 'currency', 'date', 'source']
6099
7802
  } as const;
6100
7803
 
6101
- export const $TrendSummaryDto = {
7804
+ export const $FxRateDto = {
6102
7805
  type: 'object',
6103
7806
  properties: {
6104
- startValue: {
7807
+ from: {
6105
7808
  type: 'string',
6106
- description: 'Value at start of period',
6107
- example: '450000.00'
7809
+ example: 'USD'
6108
7810
  },
6109
- endValue: {
7811
+ to: {
6110
7812
  type: 'string',
6111
- description: 'Value at end of period',
6112
- example: '500000.00'
7813
+ example: 'CNY'
6113
7814
  },
6114
- totalChange: {
7815
+ rate: {
6115
7816
  type: 'string',
6116
- description: 'Total change over period',
6117
- example: '50000.00'
7817
+ description: 'FX rate (Decimal string)',
7818
+ example: '7.2'
6118
7819
  },
6119
- totalChangePercentage: {
7820
+ date: {
6120
7821
  type: 'string',
6121
- description: 'Total change percentage',
6122
- example: '+11.11%'
7822
+ description: 'Rate date (ISO 8601)',
7823
+ example: '2024-01-15'
6123
7824
  }
6124
7825
  },
6125
- required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
7826
+ required: ['from', 'to', 'rate', 'date']
6126
7827
  } as const;
6127
7828
 
6128
- export const $MultiCurrencyPointDto = {
7829
+ export const $HoldingPnlRowDto = {
6129
7830
  type: 'object',
6130
7831
  properties: {
6131
- date: {
7832
+ accountId: {
6132
7833
  type: 'string',
6133
- description: 'Date in YYYY-MM-DD format',
6134
- example: '2024-06-15'
7834
+ description: 'Account UUID',
7835
+ example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
6135
7836
  },
6136
- byCurrency: {
6137
- description: 'Balances by currency',
6138
- type: 'array',
6139
- items: {
6140
- $ref: '#/components/schemas/CurrencyBalanceDto'
6141
- }
7837
+ accountPath: {
7838
+ type: 'string',
7839
+ description: 'Full account path',
7840
+ example: 'Assets:US:Broker:AAPL'
7841
+ },
7842
+ accountCcy: {
7843
+ type: 'object',
7844
+ description: 'Account settlement currency (ISO 4217), from cost currency',
7845
+ nullable: true,
7846
+ example: 'USD'
7847
+ },
7848
+ brokerType: {
7849
+ type: 'object',
7850
+ description: 'Broker type derived from Platform.type',
7851
+ nullable: true,
7852
+ example: 'broker'
7853
+ },
7854
+ symbol: {
7855
+ type: 'string',
7856
+ description: 'Commodity symbol',
7857
+ example: 'AAPL'
7858
+ },
7859
+ chartToken: {
7860
+ type: 'string',
7861
+ description: 'Chart segment token (libs/common resolver)',
7862
+ example: 'equity',
7863
+ enum: ['equity', 'fund', 'bond', 'cash', 'other']
7864
+ },
7865
+ assetClass: {
7866
+ type: 'string',
7867
+ example: 'EQUITY'
7868
+ },
7869
+ assetSubClass: {
7870
+ type: 'object',
7871
+ nullable: true,
7872
+ example: 'STOCK'
7873
+ },
7874
+ units: {
7875
+ type: 'string',
7876
+ description: 'Net held units (Decimal string)',
7877
+ example: '12'
7878
+ },
7879
+ averageCostPerUnit: {
7880
+ description:
7881
+ 'Average cost per unit; null when cost currency conflicts or no cost',
7882
+ nullable: true,
7883
+ allOf: [
7884
+ {
7885
+ $ref: '#/components/schemas/MonetaryDto'
7886
+ }
7887
+ ]
7888
+ },
7889
+ costBasis: {
7890
+ description: 'Cost basis of held units',
7891
+ nullable: true,
7892
+ allOf: [
7893
+ {
7894
+ $ref: '#/components/schemas/MonetaryDto'
7895
+ }
7896
+ ]
7897
+ },
7898
+ marketValue: {
7899
+ description: 'Market value at asOf price',
7900
+ nullable: true,
7901
+ allOf: [
7902
+ {
7903
+ $ref: '#/components/schemas/MonetaryDto'
7904
+ }
7905
+ ]
7906
+ },
7907
+ currentPrice: {
7908
+ description: 'Price used for market value',
7909
+ nullable: true,
7910
+ allOf: [
7911
+ {
7912
+ $ref: '#/components/schemas/CurrentPriceDto'
7913
+ }
7914
+ ]
7915
+ },
7916
+ unrealizedPnlBase: {
7917
+ type: 'object',
7918
+ description:
7919
+ 'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
7920
+ nullable: true,
7921
+ example: '6000'
7922
+ },
7923
+ unrealizedPnlPct: {
7924
+ type: 'object',
7925
+ description: 'Unrealized P&L % (Decimal string)',
7926
+ nullable: true,
7927
+ example: '25'
7928
+ },
7929
+ costFxRate: {
7930
+ description: 'Historical FX rate applied to cost basis',
7931
+ nullable: true,
7932
+ allOf: [
7933
+ {
7934
+ $ref: '#/components/schemas/FxRateDto'
7935
+ }
7936
+ ]
7937
+ },
7938
+ marketFxRate: {
7939
+ description: 'FX rate applied to market value',
7940
+ nullable: true,
7941
+ allOf: [
7942
+ {
7943
+ $ref: '#/components/schemas/FxRateDto'
7944
+ }
7945
+ ]
7946
+ },
7947
+ pctOfInvestedAssets: {
7948
+ type: 'object',
7949
+ description:
7950
+ 'Share of invested assets % (Decimal string); only for invested chartTokens',
7951
+ nullable: true,
7952
+ example: '40'
7953
+ },
7954
+ realizedPnl: {
7955
+ description:
7956
+ 'Cumulative realized P&L on sold lots (asOf-date cutoff); null when the method has no applicable sells, a sell lacks a price, or any required FX rate is missing (never-mix). When a sell spans multiple currencies (cross-currency sale), amount and currency reflect the base currency; baseCcyEquivalent is always the authoritative dual-FX figure',
7957
+ nullable: true,
7958
+ allOf: [
7959
+ {
7960
+ $ref: '#/components/schemas/MonetaryDto'
7961
+ }
7962
+ ]
6142
7963
  }
6143
7964
  },
6144
- required: ['date', 'byCurrency']
7965
+ required: [
7966
+ 'accountId',
7967
+ 'accountPath',
7968
+ 'symbol',
7969
+ 'chartToken',
7970
+ 'assetClass',
7971
+ 'units'
7972
+ ]
6145
7973
  } as const;
6146
7974
 
6147
- export const $PortfolioTrendsResponseDto = {
7975
+ export const $HoldingPnlWarningDto = {
6148
7976
  type: 'object',
6149
7977
  properties: {
6150
- series: {
6151
- description: 'Time series data points',
6152
- type: 'array',
6153
- items: {
6154
- $ref: '#/components/schemas/TimeSeriesPointDto'
6155
- }
6156
- },
6157
- summary: {
6158
- description: 'Period summary',
6159
- allOf: [
6160
- {
6161
- $ref: '#/components/schemas/TrendSummaryDto'
6162
- }
7978
+ type: {
7979
+ type: 'string',
7980
+ description: 'Warning type',
7981
+ example: 'MISSING_COST_FX_RATE',
7982
+ enum: [
7983
+ 'MISSING_COST_FX_RATE',
7984
+ 'MISSING_MARKET_FX_RATE',
7985
+ 'MISSING_SALE_PRICE',
7986
+ 'MISSING_REALIZED_FX_RATE',
7987
+ 'OVERSOLD_LOTS',
7988
+ 'NO_PRICE',
7989
+ 'MIXED_COST_CURRENCY'
6163
7990
  ]
6164
7991
  },
6165
- period: {
6166
- type: 'string',
6167
- description: 'Period requested',
6168
- example: '6m'
7992
+ symbol: {
7993
+ type: 'object',
7994
+ nullable: true
6169
7995
  },
6170
- granularity: {
6171
- type: 'string',
6172
- description: 'Data granularity',
6173
- example: 'month'
7996
+ accountId: {
7997
+ type: 'object',
7998
+ nullable: true
6174
7999
  },
6175
8000
  currency: {
8001
+ type: 'object',
8002
+ nullable: true
8003
+ }
8004
+ },
8005
+ required: ['type']
8006
+ } as const;
8007
+
8008
+ export const $HoldingPnlResponseDto = {
8009
+ type: 'object',
8010
+ properties: {
8011
+ asOfDate: {
8012
+ type: 'string',
8013
+ example: '2026-07-08'
8014
+ },
8015
+ baseCurrency: {
6176
8016
  type: 'string',
6177
- description: 'Base currency for converted values',
6178
8017
  example: 'CNY'
6179
8018
  },
6180
- byCurrency: {
8019
+ method: {
8020
+ type: 'string',
6181
8021
  description:
6182
- 'Multi-currency time series (each point has currency breakdown)',
8022
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
8023
+ enum: ['average', 'FIFO'],
8024
+ example: 'average'
8025
+ },
8026
+ rows: {
6183
8027
  type: 'array',
6184
8028
  items: {
6185
- $ref: '#/components/schemas/MultiCurrencyPointDto'
8029
+ $ref: '#/components/schemas/HoldingPnlRowDto'
6186
8030
  }
6187
8031
  },
6188
8032
  warnings: {
6189
- description: 'Exchange rate warnings',
6190
8033
  type: 'array',
6191
8034
  items: {
6192
- $ref: '#/components/schemas/ExchangeRateWarningDto'
8035
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
6193
8036
  }
6194
8037
  }
6195
8038
  },
6196
- required: ['series', 'summary', 'period', 'granularity', 'currency']
6197
- } as const;
6198
-
6199
- export const $GenerateSnapshotBody = {
6200
- type: 'object',
6201
- properties: {}
6202
- } as const;
6203
-
6204
- export const $GenerateSnapshotResponse = {
6205
- type: 'object',
6206
- properties: {}
6207
- } as const;
6208
-
6209
- export const $BackfillSnapshotsBody = {
6210
- type: 'object',
6211
- properties: {}
6212
- } as const;
6213
-
6214
- export const $BackfillSnapshotsResponse = {
6215
- type: 'object',
6216
- properties: {}
8039
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6217
8040
  } as const;
6218
8041
 
6219
8042
  export const $AnonymousLoginDto = {
@@ -6226,3 +8049,15 @@ export const $AnonymousLoginDto = {
6226
8049
  },
6227
8050
  required: ['accessToken']
6228
8051
  } as const;
8052
+
8053
+ export const $AnonymousLoginResponseDto = {
8054
+ type: 'object',
8055
+ properties: {
8056
+ authToken: {
8057
+ type: 'string',
8058
+ description: 'JWT auth token',
8059
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
8060
+ }
8061
+ },
8062
+ required: ['authToken']
8063
+ } as const;