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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,18 +6,12 @@ export const $CreateAccountDto = {
6
6
  path: {
7
7
  type: 'string',
8
8
  description: 'Account path (hierarchical, colon-separated)',
9
- example: 'Assets:CN:Bank:ICBC:Checking'
10
- },
11
- displayName: {
12
- type: 'string',
13
- description:
14
- 'Display name to distinguish accounts at the same path (default: "")',
15
- example: '工资卡'
9
+ example: 'Assets:CN:ICBC:Checking'
16
10
  },
17
11
  openDate: {
18
12
  format: 'date-time',
19
13
  type: 'string',
20
- description: 'Account open date',
14
+ description: 'Account open date (server defaults to today)',
21
15
  example: '2024-01-01'
22
16
  },
23
17
  currencies: {
@@ -45,26 +39,22 @@ export const $CreateAccountDto = {
45
39
  templatePath: {
46
40
  type: 'string',
47
41
  description: 'Reference to account-standards template path',
48
- example: 'Assets:CN:Bank:ICBC:Checking'
42
+ example: 'Assets:CN:Checking'
49
43
  },
50
44
  isCustom: {
51
45
  type: 'boolean',
52
46
  description: 'Whether this is a custom (user-created) account',
53
47
  default: false
54
48
  },
55
- i18nKey: {
56
- type: 'string',
57
- description: 'i18n key for display name (overrides template)',
58
- example: 'account.custom.mybank'
59
- },
60
49
  icon: {
61
50
  type: 'string',
62
51
  description: 'Icon identifier (overrides template)',
63
52
  example: 'bank-custom'
64
53
  },
65
- openMeta: {
54
+ openDirectiveMeta: {
66
55
  type: 'object',
67
- description: 'Additional metadata',
56
+ description:
57
+ 'Open directive metadata (NOT an opening-balance amount — use the opening-balance endpoint)',
68
58
  example: {
69
59
  branch: 'Downtown',
70
60
  accountNumber: '1234'
@@ -76,7 +66,7 @@ export const $CreateAccountDto = {
76
66
  example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
77
67
  }
78
68
  },
79
- required: ['path', 'openDate']
69
+ required: ['path']
80
70
  } as const;
81
71
 
82
72
  export const $AccountResponseDto = {
@@ -90,13 +80,7 @@ export const $AccountResponseDto = {
90
80
  path: {
91
81
  type: 'string',
92
82
  description: 'Account path (hierarchical, colon-separated)',
93
- example: 'Assets:CN:Bank:ICBC:Checking'
94
- },
95
- displayName: {
96
- type: 'string',
97
- description:
98
- 'Display name distinguishing multiple accounts at the same path',
99
- example: '工资卡'
83
+ example: 'Assets:CN:ICBC:Checking'
100
84
  },
101
85
  type: {
102
86
  type: 'string',
@@ -104,6 +88,47 @@ export const $AccountResponseDto = {
104
88
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
105
89
  example: 'Assets'
106
90
  },
91
+ assetSubClass: {
92
+ type: 'string',
93
+ description:
94
+ 'Account-level asset sub-class (product type, e.g. STOCK/DEPOSIT/CREDIT_CARD/PERSONAL_LOAN). Computed from the account path via the asset-classifier (ADR-0077). Null for non-asset accounts (Income/Expenses/Equity) or unmatched paths.',
95
+ enum: [
96
+ 'DEPOSIT',
97
+ 'CASH',
98
+ 'MONEY_MARKET_FUND',
99
+ 'STOCK',
100
+ 'ETF',
101
+ 'MUTUAL_FUND',
102
+ 'EQUITY_COMPENSATION',
103
+ 'GOVERNMENT_BOND',
104
+ 'CORPORATE_BOND',
105
+ 'BOND_FUND',
106
+ 'PRIMARY_RESIDENCE',
107
+ 'INVESTMENT_PROPERTY',
108
+ 'REIT',
109
+ 'GOLD',
110
+ 'SILVER',
111
+ 'PRECIOUS_METAL',
112
+ 'PRECIOUS_METAL_FUND',
113
+ 'COMMODITY',
114
+ 'COMMODITY_FUND',
115
+ 'CRYPTOCURRENCY',
116
+ 'RETIREMENT_ACCOUNT',
117
+ 'HEALTH_ACCOUNT',
118
+ 'EDUCATION_ACCOUNT',
119
+ 'INSURANCE',
120
+ 'PRIVATE_EQUITY',
121
+ 'HEDGE_FUND',
122
+ 'COLLECTIBLES',
123
+ 'MORTGAGE',
124
+ 'STUDENT_LOAN',
125
+ 'CREDIT_CARD',
126
+ 'PERSONAL_LOAN',
127
+ 'OTHER'
128
+ ],
129
+ nullable: true,
130
+ example: 'STOCK'
131
+ },
107
132
  status: {
108
133
  type: 'string',
109
134
  description: 'Account status',
@@ -145,26 +170,26 @@ export const $AccountResponseDto = {
145
170
  templatePath: {
146
171
  type: 'string',
147
172
  description: 'Template path reference',
148
- example: 'Assets:CN:Bank:ICBC:Checking'
173
+ example: 'Assets:CN:Checking'
149
174
  },
150
175
  isCustom: {
151
176
  type: 'boolean',
152
177
  description: 'Whether this is a custom (user-created) account',
153
178
  example: false
154
179
  },
155
- i18nKey: {
180
+ displayName: {
156
181
  type: 'string',
157
- description: 'i18n key for display name',
158
- example: 'account.assets.cn.bank.icbc.checking'
182
+ description: 'Localized display name (ADR-0114, read-time projection)',
183
+ example: 'Checking'
159
184
  },
160
185
  icon: {
161
186
  type: 'string',
162
187
  description: 'Icon identifier',
163
188
  example: 'bank-icbc'
164
189
  },
165
- openMeta: {
190
+ openDirectiveMeta: {
166
191
  type: 'object',
167
- description: 'Account metadata',
192
+ description: 'Open directive metadata (ADR-0115 Decision 9)',
168
193
  example: {
169
194
  branch: 'Downtown'
170
195
  }
@@ -192,7 +217,6 @@ export const $AccountResponseDto = {
192
217
  required: [
193
218
  'id',
194
219
  'path',
195
- 'displayName',
196
220
  'type',
197
221
  'status',
198
222
  'openDate',
@@ -225,11 +249,6 @@ export const $AccountListResponseDto = {
225
249
  export const $UpdateAccountDto = {
226
250
  type: 'object',
227
251
  properties: {
228
- displayName: {
229
- type: 'string',
230
- description: 'Display name to distinguish accounts at the same path',
231
- example: '招行工资卡'
232
- },
233
252
  currencies: {
234
253
  description: 'Allowed currencies (null = no restriction)',
235
254
  example: ['CNY', 'USD'],
@@ -251,19 +270,15 @@ export const $UpdateAccountDto = {
251
270
  'NONE'
252
271
  ]
253
272
  },
254
- i18nKey: {
255
- type: 'string',
256
- description: 'i18n key for display name',
257
- example: 'account.custom.mybank'
258
- },
259
273
  icon: {
260
274
  type: 'string',
261
275
  description: 'Icon identifier',
262
276
  example: 'bank-custom'
263
277
  },
264
- openMeta: {
278
+ openDirectiveMeta: {
265
279
  type: 'object',
266
- description: 'Additional metadata (merged with existing)',
280
+ description:
281
+ 'Open directive metadata (merged with existing; NOT an opening-balance amount)',
267
282
  example: {
268
283
  branch: 'Uptown'
269
284
  }
@@ -310,13 +325,47 @@ export const $ReopenAccountDto = {
310
325
  }
311
326
  } as const;
312
327
 
328
+ export const $CreateOpeningBalanceDto = {
329
+ type: 'object',
330
+ properties: {
331
+ amount: {
332
+ type: 'number',
333
+ description: 'Opening balance amount (non-negative)',
334
+ example: 1000
335
+ },
336
+ currency: {
337
+ type: 'string',
338
+ description: 'Currency code',
339
+ example: 'CNY'
340
+ },
341
+ date: {
342
+ format: 'date-time',
343
+ type: 'string',
344
+ description: 'Opening-balance date (defaults to now)',
345
+ example: '2024-01-01'
346
+ }
347
+ },
348
+ required: ['amount', 'currency']
349
+ } as const;
350
+
351
+ export const $OpeningBalanceResultDto = {
352
+ type: 'object',
353
+ properties: {
354
+ transactionId: {
355
+ type: 'string',
356
+ description: 'Created opening-balance transaction id.'
357
+ }
358
+ },
359
+ required: ['transactionId']
360
+ } as const;
361
+
313
362
  export const $AccountStandardResponseDto = {
314
363
  type: 'object',
315
364
  properties: {
316
365
  path: {
317
366
  type: 'string',
318
367
  description: 'Account path (hierarchical, colon-separated)',
319
- example: 'Assets:CN:Bank:ICBC:Checking'
368
+ example: 'Assets:CN:Checking'
320
369
  },
321
370
  type: {
322
371
  type: 'string',
@@ -324,14 +373,14 @@ export const $AccountStandardResponseDto = {
324
373
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
325
374
  example: 'Assets'
326
375
  },
327
- i18nKey: {
376
+ name: {
328
377
  type: 'string',
329
- description: 'i18n key for localized display name',
330
- example: 'account.assets.cn.bank.icbc.checking'
378
+ description: 'Short localized display name',
379
+ example: 'Housing Fund'
331
380
  },
332
381
  description: {
333
382
  type: 'string',
334
- description: 'Account description',
383
+ description: 'Account description (stable semantics only)',
335
384
  example: 'ICBC checking account for daily transactions'
336
385
  },
337
386
  tags: {
@@ -348,7 +397,7 @@ export const $AccountStandardResponseDto = {
348
397
  example: 'bank-icbc'
349
398
  }
350
399
  },
351
- required: ['path', 'type']
400
+ required: ['path', 'type', 'description', 'tags', 'icon']
352
401
  } as const;
353
402
 
354
403
  export const $AccountStandardListResponseDto = {
@@ -378,18 +427,13 @@ export const $AccountStandardListResponseDto = {
378
427
  export const $TemplateMetadataDto = {
379
428
  type: 'object',
380
429
  properties: {
381
- extendable: {
382
- type: 'boolean',
383
- description: 'Whether this path can be extended',
384
- example: true
385
- },
386
430
  rootType: {
387
431
  type: 'string',
388
432
  description: 'Root account type',
389
433
  example: 'Assets'
390
434
  }
391
435
  },
392
- required: ['extendable', 'rootType']
436
+ required: ['rootType']
393
437
  } as const;
394
438
 
395
439
  export const $TemplateMetadataResponseDto = {
@@ -432,11 +476,10 @@ export const $RegionInfoDto = {
432
476
  example: 'Germany'
433
477
  },
434
478
  parent: {
435
- type: 'string',
436
- example: 'eu-core'
479
+ type: 'string'
437
480
  },
438
481
  chain: {
439
- example: ['eu-core', 'de'],
482
+ example: ['de'],
440
483
  type: 'array',
441
484
  items: {
442
485
  type: 'string'
@@ -462,6 +505,66 @@ export const $RegionsMetadataResponseDto = {
462
505
  required: ['regions']
463
506
  } as const;
464
507
 
508
+ export const $CostSpecDto = {
509
+ type: 'object',
510
+ properties: {
511
+ mode: {
512
+ type: 'string',
513
+ enum: ['per-unit', 'total', 'date', 'label', 'auto'],
514
+ description: 'Cost specification mode (mirrors engine CostSpec)'
515
+ },
516
+ numberPerUnit: {
517
+ type: 'string',
518
+ description: 'Per-unit cost (required when mode is "per-unit")',
519
+ example: '240'
520
+ },
521
+ totalNumber: {
522
+ type: 'string',
523
+ description: 'Total cost for all units (required when mode is "total")',
524
+ example: '12000'
525
+ },
526
+ currency: {
527
+ type: 'string',
528
+ description: 'Cost currency (required in all modes)',
529
+ example: 'USD'
530
+ },
531
+ date: {
532
+ type: 'string',
533
+ description:
534
+ 'Lot acquisition date, ISO 8601 (required when mode is "date")',
535
+ example: '2024-01-15'
536
+ },
537
+ label: {
538
+ type: 'string',
539
+ description:
540
+ 'Lot label (required when mode is "label"; optional tag in buy modes)'
541
+ },
542
+ merge: {
543
+ type: 'boolean',
544
+ description: 'Merge lots for AVERAGE booking (mode: auto)'
545
+ }
546
+ },
547
+ required: ['mode', 'currency']
548
+ } as const;
549
+
550
+ export const $AmountDto = {
551
+ type: 'object',
552
+ properties: {
553
+ number: {
554
+ type: 'string',
555
+ description:
556
+ 'Amount as decimal string (max 15 integer + 15 decimal digits)',
557
+ example: '170.50'
558
+ },
559
+ currency: {
560
+ type: 'string',
561
+ description: 'Currency/commodity code',
562
+ example: 'USD'
563
+ }
564
+ },
565
+ required: ['number', 'currency']
566
+ } as const;
567
+
465
568
  export const $CreatePostingDto = {
466
569
  type: 'object',
467
570
  properties: {
@@ -469,7 +572,7 @@ export const $CreatePostingDto = {
469
572
  type: 'string',
470
573
  description:
471
574
  'Account name in Beancount format (must start with uppercase, colon-separated)',
472
- example: 'Assets:Bank:Checking'
575
+ example: 'Assets:Checking'
473
576
  },
474
577
  units: {
475
578
  type: 'string',
@@ -491,6 +594,33 @@ export const $CreatePostingDto = {
491
594
  example: {
492
595
  'tax-lot': 'Q1-2024'
493
596
  }
597
+ },
598
+ cost: {
599
+ description:
600
+ 'Cost basis (Beancount `{...}`). Maps to engine costSpec. Required for commodity holdings so they carry a monetary weight that can balance.',
601
+ example: {
602
+ mode: 'per-unit',
603
+ numberPerUnit: '240',
604
+ currency: 'USD'
605
+ },
606
+ allOf: [
607
+ {
608
+ $ref: '#/components/schemas/CostSpecDto'
609
+ }
610
+ ]
611
+ },
612
+ price: {
613
+ description:
614
+ 'Price annotation (Beancount `@...`). Maps to engine price. Used for valuation; cost takes priority for balance weight.',
615
+ example: {
616
+ number: '170',
617
+ currency: 'USD'
618
+ },
619
+ allOf: [
620
+ {
621
+ $ref: '#/components/schemas/AmountDto'
622
+ }
623
+ ]
494
624
  }
495
625
  },
496
626
  required: ['account']
@@ -569,23 +699,59 @@ export const $CreateTransactionDto = {
569
699
  required: ['date', 'narration', 'postings']
570
700
  } as const;
571
701
 
702
+ export const $CostDetailDto = {
703
+ type: 'object',
704
+ properties: {
705
+ number: {
706
+ type: 'string',
707
+ description: 'Per-unit cost basis (mirrors engine Cost.number)',
708
+ example: '240'
709
+ },
710
+ currency: {
711
+ type: 'string',
712
+ description: 'Cost currency',
713
+ example: 'USD'
714
+ },
715
+ date: {
716
+ type: 'string',
717
+ description: 'Lot acquisition date (ISO yyyy-mm-dd)',
718
+ example: '2024-01-15'
719
+ },
720
+ label: {
721
+ type: 'string',
722
+ description: 'Lot label',
723
+ example: 'lot-2024-01'
724
+ }
725
+ }
726
+ } as const;
727
+
572
728
  export const $PostingResponseDto = {
573
729
  type: 'object',
574
730
  properties: {
575
731
  account: {
576
732
  type: 'string',
577
733
  description: 'Account name',
578
- example: 'Assets:Bank:Checking'
734
+ example: 'Assets:Checking'
579
735
  },
580
736
  units: {
581
737
  type: 'string',
582
- description: 'Amount (may be null if interpolated)',
738
+ description:
739
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
583
740
  example: '100.50'
584
741
  },
585
742
  currency: {
586
743
  type: 'string',
587
744
  description: 'Currency',
588
745
  example: 'USD'
746
+ },
747
+ cost: {
748
+ description:
749
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
750
+ allOf: [
751
+ {
752
+ $ref: '#/components/schemas/CostDetailDto'
753
+ }
754
+ ]
589
755
  }
590
756
  },
591
757
  required: ['account']
@@ -805,6 +971,11 @@ export const $BatchTransactionErrorDto = {
805
971
  type: 'string',
806
972
  description: 'Error message describing the failure',
807
973
  example: 'Transaction does not balance'
974
+ },
975
+ errorCode: {
976
+ type: 'string',
977
+ description: 'Structured error code for programmatic handling',
978
+ example: 'INSUFFICIENT_QUANTITY'
808
979
  }
809
980
  },
810
981
  required: ['index', 'error']
@@ -831,6 +1002,85 @@ export const $BatchTransactionResponseDto = {
831
1002
  required: ['succeeded', 'failed']
832
1003
  } as const;
833
1004
 
1005
+ export const $CorrectTransactionDto = {
1006
+ type: 'object',
1007
+ properties: {
1008
+ date: {
1009
+ type: 'string',
1010
+ description: 'Transaction date (ISO 8601 format)',
1011
+ example: '2024-11-28'
1012
+ },
1013
+ flag: {
1014
+ type: 'string',
1015
+ description: 'Transaction flag: * (cleared), ! (pending)',
1016
+ enum: ['*', '!'],
1017
+ example: '*'
1018
+ },
1019
+ payee: {
1020
+ type: 'string',
1021
+ description: 'Payee name',
1022
+ example: 'Whole Foods Market'
1023
+ },
1024
+ narration: {
1025
+ type: 'string',
1026
+ description: 'Transaction narration/description',
1027
+ example: 'Grocery shopping'
1028
+ },
1029
+ tags: {
1030
+ description: 'Transaction tags (without # prefix)',
1031
+ example: ['vacation', 'personal'],
1032
+ type: 'array',
1033
+ items: {
1034
+ type: 'string'
1035
+ }
1036
+ },
1037
+ links: {
1038
+ description: 'Transaction links (without ^ prefix)',
1039
+ example: ['invoice-123'],
1040
+ type: 'array',
1041
+ items: {
1042
+ type: 'string'
1043
+ }
1044
+ },
1045
+ postings: {
1046
+ description:
1047
+ 'Transaction postings (minimum 1, typically 2 for double-entry)',
1048
+ type: 'array',
1049
+ items: {
1050
+ $ref: '#/components/schemas/CreatePostingDto'
1051
+ }
1052
+ },
1053
+ meta: {
1054
+ type: 'object',
1055
+ description: 'Transaction-level metadata',
1056
+ example: {
1057
+ invoice: '12345'
1058
+ }
1059
+ },
1060
+ idempotencyKey: {
1061
+ type: 'string',
1062
+ description:
1063
+ 'Unique key for idempotent transaction creation. If provided, duplicate requests with the same key will return the existing transaction.',
1064
+ example: 'import-2024-01-15-batch-001',
1065
+ maxLength: 128
1066
+ },
1067
+ autoCreateAccounts: {
1068
+ type: 'boolean',
1069
+ description:
1070
+ '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.',
1071
+ default: true,
1072
+ example: true
1073
+ },
1074
+ correctionReason: {
1075
+ type: 'string',
1076
+ description: 'Reason for correcting/superseding the original transaction',
1077
+ example: 'Wrong amount — corrected from receipt',
1078
+ maxLength: 500
1079
+ }
1080
+ },
1081
+ required: ['date', 'narration', 'postings']
1082
+ } as const;
1083
+
834
1084
  export const $PostingDetailDto = {
835
1085
  type: 'object',
836
1086
  properties: {
@@ -844,14 +1094,15 @@ export const $PostingDetailDto = {
844
1094
  description: 'Account ID',
845
1095
  example: 'clh1234567890abcdef'
846
1096
  },
847
- accountName: {
1097
+ account: {
848
1098
  type: 'string',
849
- description: 'Account name',
850
- example: 'Assets:Bank:Checking'
1099
+ description: 'Fully-qualified Beancount account path',
1100
+ example: 'Assets:Checking'
851
1101
  },
852
1102
  units: {
853
1103
  type: 'string',
854
- description: 'Amount (may be null if interpolated)',
1104
+ description:
1105
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
855
1106
  example: '100.50'
856
1107
  },
857
1108
  currency: {
@@ -874,6 +1125,15 @@ export const $PostingDetailDto = {
874
1125
  description: 'Cost date',
875
1126
  example: '2024-01-15'
876
1127
  },
1128
+ cost: {
1129
+ description:
1130
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
1131
+ allOf: [
1132
+ {
1133
+ $ref: '#/components/schemas/CostDetailDto'
1134
+ }
1135
+ ]
1136
+ },
877
1137
  priceAmount: {
878
1138
  type: 'string',
879
1139
  description: 'Price amount',
@@ -894,7 +1154,7 @@ export const $PostingDetailDto = {
894
1154
  description: 'Posting metadata'
895
1155
  }
896
1156
  },
897
- required: ['id', 'accountId', 'accountName']
1157
+ required: ['id', 'accountId', 'account']
898
1158
  } as const;
899
1159
 
900
1160
  export const $TransactionDetailDto = {
@@ -966,8 +1226,8 @@ export const $TransactionDetailDto = {
966
1226
  },
967
1227
  sourceType: {
968
1228
  type: 'string',
969
- description: 'Source type (how the transaction was created)',
970
- enum: ['NLP', 'CSV', 'OCR', 'API']
1229
+ description:
1230
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
971
1231
  },
972
1232
  sourcePlatform: {
973
1233
  type: 'string',
@@ -1000,6 +1260,18 @@ export const $TransactionDetailDto = {
1000
1260
  type: 'string',
1001
1261
  description: 'Correction reason (if voided or superseded)',
1002
1262
  example: 'Duplicate entry'
1263
+ },
1264
+ supersededBy: {
1265
+ type: 'string',
1266
+ description:
1267
+ 'ID of the transaction that supersedes this one (set when status=SUPERSEDED)',
1268
+ example: 'clh1234567890abcdef'
1269
+ },
1270
+ originalTxn: {
1271
+ type: 'string',
1272
+ description:
1273
+ 'ID of the transaction this one corrected/replaced (back-link on the replacement)',
1274
+ example: 'clh1234567890abcdef'
1003
1275
  }
1004
1276
  },
1005
1277
  required: [
@@ -1014,18 +1286,89 @@ export const $TransactionDetailDto = {
1014
1286
  ]
1015
1287
  } as const;
1016
1288
 
1017
- export const $TransactionListResponseDto = {
1289
+ export const $BalanceByCurrencyDto = {
1018
1290
  type: 'object',
1019
1291
  properties: {
1020
- data: {
1021
- description: 'List of transactions',
1022
- type: 'array',
1023
- items: {
1024
- $ref: '#/components/schemas/TransactionDetailDto'
1025
- }
1292
+ currency: {
1293
+ type: 'string',
1294
+ description: 'ISO 4217 currency code',
1295
+ example: 'CNY'
1026
1296
  },
1027
- total: {
1028
- type: 'number',
1297
+ balance: {
1298
+ type: 'string',
1299
+ description: 'Balance amount',
1300
+ example: '50000.00'
1301
+ }
1302
+ },
1303
+ required: ['currency', 'balance']
1304
+ } as const;
1305
+
1306
+ export const $ExchangeRateWarningDto = {
1307
+ type: 'object',
1308
+ properties: {
1309
+ type: {
1310
+ type: 'string',
1311
+ description: 'Warning type',
1312
+ example: 'MISSING_EXCHANGE_RATE'
1313
+ },
1314
+ currency: {
1315
+ type: 'string',
1316
+ description: 'Currency without exchange rate',
1317
+ example: 'EUR'
1318
+ },
1319
+ totalAmount: {
1320
+ type: 'string',
1321
+ description: 'Total amount affected',
1322
+ example: '1000.00'
1323
+ }
1324
+ },
1325
+ required: ['type', 'currency', 'totalAmount']
1326
+ } as const;
1327
+
1328
+ export const $TransactionListSummaryDto = {
1329
+ type: 'object',
1330
+ properties: {
1331
+ totalAmount: {
1332
+ type: 'string',
1333
+ description:
1334
+ 'Partial converted total in base currency (rated currencies only, raw Beancount sign). When warnings is non-empty this excludes currencies missing an FX rate; may be "0.00" if ALL non-base currencies lack a rate. Converted at the dateTo (or current) available rate.',
1335
+ example: '-6000.00'
1336
+ },
1337
+ currency: {
1338
+ type: 'string',
1339
+ description: 'Base currency (ISO 4217)',
1340
+ example: 'CNY'
1341
+ },
1342
+ balanceByCurrency: {
1343
+ description: 'Raw (unconverted) balance per currency',
1344
+ type: 'array',
1345
+ items: {
1346
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
1347
+ }
1348
+ },
1349
+ warnings: {
1350
+ description: 'Currencies missing an FX rate (omitted when empty)',
1351
+ type: 'array',
1352
+ items: {
1353
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
1354
+ }
1355
+ }
1356
+ },
1357
+ required: ['totalAmount', 'currency', 'balanceByCurrency']
1358
+ } as const;
1359
+
1360
+ export const $TransactionListResponseDto = {
1361
+ type: 'object',
1362
+ properties: {
1363
+ data: {
1364
+ description: 'List of transactions',
1365
+ type: 'array',
1366
+ items: {
1367
+ $ref: '#/components/schemas/TransactionDetailDto'
1368
+ }
1369
+ },
1370
+ total: {
1371
+ type: 'number',
1029
1372
  description: 'Total count of matching transactions',
1030
1373
  example: 100
1031
1374
  },
@@ -1038,11 +1381,51 @@ export const $TransactionListResponseDto = {
1038
1381
  type: 'number',
1039
1382
  description: 'Number of items skipped',
1040
1383
  example: 0
1384
+ },
1385
+ summary: {
1386
+ description:
1387
+ 'Amount summary for the full filtered set (#514). Present only when the request has a single account OR category viewpoint; omitted for search-only / plain-list / dual-perspective requests.',
1388
+ allOf: [
1389
+ {
1390
+ $ref: '#/components/schemas/TransactionListSummaryDto'
1391
+ }
1392
+ ]
1041
1393
  }
1042
1394
  },
1043
1395
  required: ['data', 'total', 'limit', 'offset']
1044
1396
  } as const;
1045
1397
 
1398
+ export const $TagSuggestionDto = {
1399
+ type: 'object',
1400
+ properties: {
1401
+ tag: {
1402
+ type: 'string',
1403
+ description: 'Tag name',
1404
+ example: 'Monthly'
1405
+ },
1406
+ count: {
1407
+ type: 'number',
1408
+ description: 'Usage count across ACTIVE transactions',
1409
+ example: 12
1410
+ }
1411
+ },
1412
+ required: ['tag', 'count']
1413
+ } as const;
1414
+
1415
+ export const $TagSuggestionsResponseDto = {
1416
+ type: 'object',
1417
+ properties: {
1418
+ data: {
1419
+ description: 'Tag suggestions sorted as requested',
1420
+ type: 'array',
1421
+ items: {
1422
+ $ref: '#/components/schemas/TagSuggestionDto'
1423
+ }
1424
+ }
1425
+ },
1426
+ required: ['data']
1427
+ } as const;
1428
+
1046
1429
  export const $UpdateTransactionDto = {
1047
1430
  type: 'object',
1048
1431
  properties: {
@@ -1106,7 +1489,7 @@ export const $BalanceResponseDto = {
1106
1489
  account: {
1107
1490
  type: 'string',
1108
1491
  description: 'Account name',
1109
- example: 'Assets:Bank:Checking'
1492
+ example: 'Assets:Checking'
1110
1493
  },
1111
1494
  balance: {
1112
1495
  type: 'string',
@@ -1133,7 +1516,7 @@ export const $MultiCurrencyBalanceResponseDto = {
1133
1516
  account: {
1134
1517
  type: 'string',
1135
1518
  description: 'Account name',
1136
- example: 'Assets:Bank:Checking'
1519
+ example: 'Assets:Checking'
1137
1520
  },
1138
1521
  balances: {
1139
1522
  type: 'object',
@@ -1189,12 +1572,12 @@ export const $TransactionSummaryDto = {
1189
1572
  accountName: {
1190
1573
  type: 'string',
1191
1574
  description: 'Source account name (first posting)',
1192
- example: 'Assets:Bank:Checking'
1575
+ example: 'Assets:Checking'
1193
1576
  },
1194
1577
  sourceType: {
1195
1578
  type: 'string',
1196
- description: 'Source type (NLP, CSV, OCR, API)',
1197
- enum: ['NLP', 'CSV', 'OCR', 'API']
1579
+ description:
1580
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1198
1581
  },
1199
1582
  sourcePlatform: {
1200
1583
  type: 'string',
@@ -1234,8 +1617,10 @@ export const $ReviewSummaryDto = {
1234
1617
  },
1235
1618
  confidenceLevel: {
1236
1619
  type: 'string',
1237
- description: 'Confidence level derived from score',
1238
- enum: ['HIGH', 'MEDIUM', 'LOW']
1620
+ description:
1621
+ 'Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.',
1622
+ enum: ['HIGH', 'MEDIUM', 'LOW'],
1623
+ nullable: true
1239
1624
  },
1240
1625
  summaryKey: {
1241
1626
  type: 'string',
@@ -1259,7 +1644,8 @@ export const $ReviewSummaryDto = {
1259
1644
  },
1260
1645
  sourceType: {
1261
1646
  type: 'string',
1262
- description: 'Source type (NLP, CSV, OCR, API)'
1647
+ description:
1648
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1263
1649
  },
1264
1650
  sourcePlatform: {
1265
1651
  type: 'string',
@@ -1369,7 +1755,20 @@ export const $DecisionOptionDto = {
1369
1755
  properties: {
1370
1756
  value: {
1371
1757
  type: 'string',
1372
- description: 'The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)'
1758
+ description: 'The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)',
1759
+ enum: [
1760
+ 'UPGRADE_REPLACE',
1761
+ 'LINK_KEEP_BOTH',
1762
+ 'IGNORE_NEW',
1763
+ 'CONFIRM_DIFFERENT',
1764
+ 'ACCEPT',
1765
+ 'REJECT',
1766
+ 'ACCEPT_AND_LEARN',
1767
+ 'CHOOSE_OTHER',
1768
+ 'CANCEL',
1769
+ 'FIX',
1770
+ 'IGNORE'
1771
+ ]
1373
1772
  },
1374
1773
  labelKey: {
1375
1774
  type: 'string',
@@ -1417,8 +1816,10 @@ export const $ReviewDetailDto = {
1417
1816
  },
1418
1817
  confidenceLevel: {
1419
1818
  type: 'string',
1420
- description: 'Confidence level derived from score',
1421
- enum: ['HIGH', 'MEDIUM', 'LOW']
1819
+ description:
1820
+ 'Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.',
1821
+ enum: ['HIGH', 'MEDIUM', 'LOW'],
1822
+ nullable: true
1422
1823
  },
1423
1824
  summaryKey: {
1424
1825
  type: 'string',
@@ -1442,7 +1843,8 @@ export const $ReviewDetailDto = {
1442
1843
  },
1443
1844
  sourceType: {
1444
1845
  type: 'string',
1445
- description: 'Source type (NLP, CSV, OCR, API)'
1846
+ description:
1847
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1446
1848
  },
1447
1849
  sourcePlatform: {
1448
1850
  type: 'string',
@@ -1522,7 +1924,20 @@ export const $ResolveReviewDto = {
1522
1924
  action: {
1523
1925
  type: 'string',
1524
1926
  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',
1927
+ 'Decision action. Valid actions vary by review type — see DecisionOptionDto.value returned by the review detail endpoint.',
1928
+ enum: [
1929
+ 'UPGRADE_REPLACE',
1930
+ 'LINK_KEEP_BOTH',
1931
+ 'IGNORE_NEW',
1932
+ 'CONFIRM_DIFFERENT',
1933
+ 'ACCEPT',
1934
+ 'REJECT',
1935
+ 'ACCEPT_AND_LEARN',
1936
+ 'CHOOSE_OTHER',
1937
+ 'CANCEL',
1938
+ 'FIX',
1939
+ 'IGNORE'
1940
+ ],
1526
1941
  example: 'ACCEPT'
1527
1942
  },
1528
1943
  data: {
@@ -1559,7 +1974,8 @@ export const $ResolveResultDto = {
1559
1974
  },
1560
1975
  resolutionId: {
1561
1976
  type: 'string',
1562
- description: 'Resolution ID for undo'
1977
+ description:
1978
+ 'Resolution ID for undo. Absent when the resolver rejected the decision (review stayed PENDING).'
1563
1979
  },
1564
1980
  canUndo: {
1565
1981
  type: 'boolean',
@@ -1577,7 +1993,7 @@ export const $ResolveResultDto = {
1577
1993
  example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1578
1994
  }
1579
1995
  },
1580
- required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
1996
+ required: ['success']
1581
1997
  } as const;
1582
1998
 
1583
1999
  export const $UndoResultDto = {
@@ -1613,6 +2029,19 @@ export const $BatchResolveDto = {
1613
2029
  action: {
1614
2030
  type: 'string',
1615
2031
  description: 'Decision action to apply to all items',
2032
+ enum: [
2033
+ 'UPGRADE_REPLACE',
2034
+ 'LINK_KEEP_BOTH',
2035
+ 'IGNORE_NEW',
2036
+ 'CONFIRM_DIFFERENT',
2037
+ 'ACCEPT',
2038
+ 'REJECT',
2039
+ 'ACCEPT_AND_LEARN',
2040
+ 'CHOOSE_OTHER',
2041
+ 'CANCEL',
2042
+ 'FIX',
2043
+ 'IGNORE'
2044
+ ],
1616
2045
  example: 'ACCEPT'
1617
2046
  },
1618
2047
  data: {
@@ -2435,6 +2864,163 @@ export const $UpdateCommodityDto = {
2435
2864
  }
2436
2865
  } as const;
2437
2866
 
2867
+ export const $CreateBeanPriceDto = {
2868
+ type: 'object',
2869
+ properties: {
2870
+ currency: {
2871
+ type: 'string',
2872
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2873
+ example: 'USD'
2874
+ },
2875
+ quoteCurrency: {
2876
+ type: 'string',
2877
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
2878
+ example: 'CNY'
2879
+ },
2880
+ amount: {
2881
+ type: 'number',
2882
+ description:
2883
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
2884
+ example: 175.5,
2885
+ minimum: 0
2886
+ },
2887
+ date: {
2888
+ type: 'string',
2889
+ description: 'Price date (ISO 8601 format)',
2890
+ example: '2024-11-05'
2891
+ },
2892
+ metadata: {
2893
+ type: 'object',
2894
+ description:
2895
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
2896
+ example: {
2897
+ source: 'MANUAL',
2898
+ note: 'Bank valuation report',
2899
+ confidence: 0.95
2900
+ }
2901
+ }
2902
+ },
2903
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
2904
+ } as const;
2905
+
2906
+ export const $PriceResponseDto = {
2907
+ type: 'object',
2908
+ properties: {
2909
+ id: {
2910
+ type: 'string',
2911
+ description: 'Unique identifier',
2912
+ example: 'uuid-123-456'
2913
+ },
2914
+ userId: {
2915
+ type: 'string',
2916
+ description: 'User ID (owner of the price)',
2917
+ example: 'user-123'
2918
+ },
2919
+ currency: {
2920
+ type: 'string',
2921
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2922
+ example: 'BTC'
2923
+ },
2924
+ quoteCurrency: {
2925
+ type: 'string',
2926
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2927
+ example: 'USD'
2928
+ },
2929
+ amount: {
2930
+ type: 'number',
2931
+ description:
2932
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2933
+ example: 50000
2934
+ },
2935
+ date: {
2936
+ type: 'string',
2937
+ description:
2938
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
2939
+ example: '2024-01-01',
2940
+ format: 'date'
2941
+ },
2942
+ meta: {
2943
+ type: 'object',
2944
+ description:
2945
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
2946
+ example: {
2947
+ source: 'MANUAL',
2948
+ note: 'User-defined price',
2949
+ confidence: 1
2950
+ }
2951
+ },
2952
+ createdAt: {
2953
+ format: 'date-time',
2954
+ type: 'string',
2955
+ description: 'Creation timestamp',
2956
+ example: '2024-11-03T10:00:00Z'
2957
+ },
2958
+ updatedAt: {
2959
+ format: 'date-time',
2960
+ type: 'string',
2961
+ description: 'Last update timestamp',
2962
+ example: '2024-11-03T10:00:00Z'
2963
+ }
2964
+ },
2965
+ required: [
2966
+ 'id',
2967
+ 'userId',
2968
+ 'currency',
2969
+ 'quoteCurrency',
2970
+ 'amount',
2971
+ 'date',
2972
+ 'meta',
2973
+ 'createdAt',
2974
+ 'updatedAt'
2975
+ ]
2976
+ } as const;
2977
+
2978
+ export const $PriceListResponseDto = {
2979
+ type: 'object',
2980
+ properties: {
2981
+ items: {
2982
+ description: 'List of prices',
2983
+ type: 'array',
2984
+ items: {
2985
+ $ref: '#/components/schemas/PriceResponseDto'
2986
+ }
2987
+ },
2988
+ total: {
2989
+ type: 'number',
2990
+ description: 'Total number of prices',
2991
+ example: 42
2992
+ }
2993
+ },
2994
+ required: ['items', 'total']
2995
+ } as const;
2996
+
2997
+ export const $UpdateBeanPriceDto = {
2998
+ type: 'object',
2999
+ properties: {
3000
+ currency: {
3001
+ type: 'string',
3002
+ description: 'Currency being priced'
3003
+ },
3004
+ quoteCurrency: {
3005
+ type: 'string',
3006
+ description: 'Quote currency (pricing currency)'
3007
+ },
3008
+ amount: {
3009
+ type: 'number',
3010
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
3011
+ minimum: 0
3012
+ },
3013
+ date: {
3014
+ type: 'string',
3015
+ description: 'Price date (ISO 8601 format)'
3016
+ },
3017
+ metadata: {
3018
+ type: 'object',
3019
+ description: 'Metadata'
3020
+ }
3021
+ }
3022
+ } as const;
3023
+
2438
3024
  export const $CreateRecurringRuleDto = {
2439
3025
  type: 'object',
2440
3026
  properties: {
@@ -3206,23 +3792,470 @@ export const $ForecastResponseDto = {
3206
3792
  ]
3207
3793
  } as const;
3208
3794
 
3209
- export const $CreateTransactionRuleDto = {
3795
+ export const $CurrencyBalanceDto = {
3210
3796
  type: 'object',
3211
3797
  properties: {
3212
- name: {
3798
+ currency: {
3213
3799
  type: 'string',
3214
- minLength: 1,
3215
- maxLength: 100
3800
+ description: 'ISO 4217 currency code',
3801
+ example: 'CNY'
3216
3802
  },
3217
- description: {
3803
+ balance: {
3218
3804
  type: 'string',
3219
- maxLength: 500
3805
+ description: 'Balance amount',
3806
+ example: '500000.00'
3807
+ }
3808
+ },
3809
+ required: ['currency', 'balance']
3810
+ } as const;
3811
+
3812
+ export const $TimeSeriesPointDto = {
3813
+ type: 'object',
3814
+ properties: {
3815
+ date: {
3816
+ type: 'string',
3817
+ description: 'Date in YYYY-MM-DD format',
3818
+ example: '2024-06-15'
3220
3819
  },
3221
- narrationKeywords: {
3222
- items: {
3223
- type: 'array'
3224
- },
3225
- maxItems: 50,
3820
+ value: {
3821
+ type: 'string',
3822
+ description: 'Value at this date (in base currency)',
3823
+ example: '500000.00'
3824
+ },
3825
+ change: {
3826
+ type: 'object',
3827
+ description: 'Change from previous point',
3828
+ example: '5000.00'
3829
+ },
3830
+ assets: {
3831
+ type: 'string',
3832
+ description: 'Total assets at this date (in base currency)',
3833
+ example: '494338.00'
3834
+ },
3835
+ liabilities: {
3836
+ type: 'string',
3837
+ description: 'Total liabilities at this date (in base currency)',
3838
+ example: '310098.00'
3839
+ },
3840
+ byCurrency: {
3841
+ description: 'Multi-currency breakdown for this point',
3842
+ type: 'array',
3843
+ items: {
3844
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3845
+ }
3846
+ }
3847
+ },
3848
+ required: ['date', 'value']
3849
+ } as const;
3850
+
3851
+ export const $TrendSummaryDto = {
3852
+ type: 'object',
3853
+ properties: {
3854
+ startValue: {
3855
+ type: 'string',
3856
+ description: 'Value at start of period',
3857
+ example: '450000.00'
3858
+ },
3859
+ endValue: {
3860
+ type: 'string',
3861
+ description: 'Value at end of period',
3862
+ example: '500000.00'
3863
+ },
3864
+ totalChange: {
3865
+ type: 'string',
3866
+ description: 'Total change over period',
3867
+ example: '50000.00'
3868
+ },
3869
+ totalChangePercentage: {
3870
+ type: 'string',
3871
+ description: 'Total change percentage',
3872
+ example: '+11.11%'
3873
+ }
3874
+ },
3875
+ required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
3876
+ } as const;
3877
+
3878
+ export const $MultiCurrencyPointDto = {
3879
+ type: 'object',
3880
+ properties: {
3881
+ date: {
3882
+ type: 'string',
3883
+ description: 'Date in YYYY-MM-DD format',
3884
+ example: '2024-06-15'
3885
+ },
3886
+ byCurrency: {
3887
+ description: 'Balances by currency',
3888
+ type: 'array',
3889
+ items: {
3890
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3891
+ }
3892
+ }
3893
+ },
3894
+ required: ['date', 'byCurrency']
3895
+ } as const;
3896
+
3897
+ export const $PortfolioTrendsResponseDto = {
3898
+ type: 'object',
3899
+ properties: {
3900
+ series: {
3901
+ description: 'Time series data points',
3902
+ type: 'array',
3903
+ items: {
3904
+ $ref: '#/components/schemas/TimeSeriesPointDto'
3905
+ }
3906
+ },
3907
+ summary: {
3908
+ description: 'Period summary',
3909
+ allOf: [
3910
+ {
3911
+ $ref: '#/components/schemas/TrendSummaryDto'
3912
+ }
3913
+ ]
3914
+ },
3915
+ period: {
3916
+ type: 'string',
3917
+ description: 'Period requested',
3918
+ example: '6m'
3919
+ },
3920
+ granularity: {
3921
+ type: 'string',
3922
+ description: 'Data granularity',
3923
+ example: 'month'
3924
+ },
3925
+ currency: {
3926
+ type: 'string',
3927
+ description: 'Base currency for converted values',
3928
+ example: 'CNY'
3929
+ },
3930
+ byCurrency: {
3931
+ description:
3932
+ 'Multi-currency time series (each point has currency breakdown)',
3933
+ type: 'array',
3934
+ items: {
3935
+ $ref: '#/components/schemas/MultiCurrencyPointDto'
3936
+ }
3937
+ },
3938
+ warnings: {
3939
+ description: 'Exchange rate warnings',
3940
+ type: 'array',
3941
+ items: {
3942
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3943
+ }
3944
+ }
3945
+ },
3946
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
3947
+ } as const;
3948
+
3949
+ export const $CashFlowPointDto = {
3950
+ type: 'object',
3951
+ properties: {
3952
+ month: {
3953
+ type: 'string',
3954
+ description: 'Month key (YYYY-MM)',
3955
+ example: '2024-03'
3956
+ },
3957
+ income: {
3958
+ type: 'string',
3959
+ description: 'Income in base currency (absolute, converted)',
3960
+ example: '10000.00'
3961
+ },
3962
+ expense: {
3963
+ type: 'string',
3964
+ description: 'Expense in base currency (absolute, converted)',
3965
+ example: '5000.00'
3966
+ },
3967
+ netSavings: {
3968
+ type: 'string',
3969
+ description: 'netSavings = income − expense (savings positive)',
3970
+ example: '5000.00'
3971
+ }
3972
+ },
3973
+ required: ['month', 'income', 'expense', 'netSavings']
3974
+ } as const;
3975
+
3976
+ export const $CashFlowTrendSummaryDto = {
3977
+ type: 'object',
3978
+ properties: {
3979
+ totalIncome: {
3980
+ type: 'string',
3981
+ description: 'Total income across the period',
3982
+ example: '60000.00'
3983
+ },
3984
+ totalExpense: {
3985
+ type: 'string',
3986
+ description: 'Total expense across the period',
3987
+ example: '30000.00'
3988
+ },
3989
+ totalNetSavings: {
3990
+ type: 'string',
3991
+ description: 'income − expense across the period',
3992
+ example: '30000.00'
3993
+ },
3994
+ averageMonthlyNetSavings: {
3995
+ type: 'string',
3996
+ description:
3997
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
3998
+ example: '5000.00'
3999
+ }
4000
+ },
4001
+ required: [
4002
+ 'totalIncome',
4003
+ 'totalExpense',
4004
+ 'totalNetSavings',
4005
+ 'averageMonthlyNetSavings'
4006
+ ]
4007
+ } as const;
4008
+
4009
+ export const $CashFlowTrendsResponseDto = {
4010
+ type: 'object',
4011
+ properties: {
4012
+ series: {
4013
+ description:
4014
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
4015
+ type: 'array',
4016
+ items: {
4017
+ $ref: '#/components/schemas/CashFlowPointDto'
4018
+ }
4019
+ },
4020
+ summary: {
4021
+ description: 'Period totals',
4022
+ allOf: [
4023
+ {
4024
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
4025
+ }
4026
+ ]
4027
+ },
4028
+ period: {
4029
+ type: 'string',
4030
+ description: 'Period requested',
4031
+ example: '6m'
4032
+ },
4033
+ granularity: {
4034
+ type: 'string',
4035
+ description: 'Data granularity (v1 returns month buckets)',
4036
+ example: 'month'
4037
+ },
4038
+ currency: {
4039
+ type: 'string',
4040
+ description: 'Base currency for converted values',
4041
+ example: 'CNY'
4042
+ },
4043
+ warnings: {
4044
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
4045
+ type: 'array',
4046
+ items: {
4047
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
4048
+ }
4049
+ }
4050
+ },
4051
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
4052
+ } as const;
4053
+
4054
+ export const $GenerateSnapshotBody = {
4055
+ type: 'object',
4056
+ properties: {}
4057
+ } as const;
4058
+
4059
+ export const $GenerateSnapshotResponse = {
4060
+ type: 'object',
4061
+ properties: {}
4062
+ } as const;
4063
+
4064
+ export const $BackfillSnapshotsBody = {
4065
+ type: 'object',
4066
+ properties: {}
4067
+ } as const;
4068
+
4069
+ export const $BackfillSnapshotsResponse = {
4070
+ type: 'object',
4071
+ properties: {}
4072
+ } as const;
4073
+
4074
+ export const $DeleteOwnUserDto = {
4075
+ type: 'object',
4076
+ properties: {
4077
+ accessToken: {
4078
+ type: 'string',
4079
+ description: 'Access token for user verification',
4080
+ example: 'abc123xyz'
4081
+ }
4082
+ },
4083
+ required: ['accessToken']
4084
+ } as const;
4085
+
4086
+ export const $SignupDto = {
4087
+ type: 'object',
4088
+ properties: {
4089
+ turnstileToken: {
4090
+ type: 'string',
4091
+ description:
4092
+ 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4093
+ example: '0.abc123def456...'
4094
+ }
4095
+ }
4096
+ } as const;
4097
+
4098
+ export const $SignupResponseDto = {
4099
+ type: 'object',
4100
+ properties: {
4101
+ authToken: {
4102
+ type: 'string',
4103
+ description: 'JWT auth token',
4104
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4105
+ },
4106
+ accessToken: {
4107
+ type: 'string',
4108
+ description: 'Auto-generated access token'
4109
+ },
4110
+ role: {
4111
+ type: 'string',
4112
+ description: 'Assigned user role',
4113
+ enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
4114
+ }
4115
+ },
4116
+ required: ['authToken', 'accessToken', 'role']
4117
+ } as const;
4118
+
4119
+ export const $UpdateUserSettingDto = {
4120
+ type: 'object',
4121
+ properties: {
4122
+ secId: {
4123
+ type: 'number',
4124
+ description: 'Security ID'
4125
+ },
4126
+ annualInterestRate: {
4127
+ type: 'number',
4128
+ description: 'Annual interest rate',
4129
+ example: 0.05
4130
+ },
4131
+ currency: {
4132
+ type: 'string',
4133
+ description: 'Currency code',
4134
+ example: 'USD'
4135
+ },
4136
+ baseCurrency: {
4137
+ type: 'string',
4138
+ description: 'Base currency code',
4139
+ example: 'USD'
4140
+ },
4141
+ benchmark: {
4142
+ type: 'string',
4143
+ description: 'Benchmark symbol',
4144
+ example: 'SPY'
4145
+ },
4146
+ colorScheme: {
4147
+ type: 'string',
4148
+ description: 'Color scheme',
4149
+ enum: ['DARK', 'LIGHT']
4150
+ },
4151
+ dateRange: {
4152
+ type: 'string',
4153
+ description: 'Date range filter',
4154
+ example: '1y'
4155
+ },
4156
+ emergencyFund: {
4157
+ type: 'number',
4158
+ description: 'Emergency fund amount',
4159
+ example: 10000
4160
+ },
4161
+ 'filters.accounts': {
4162
+ description: 'Account filter IDs',
4163
+ type: 'array',
4164
+ items: {
4165
+ type: 'string'
4166
+ }
4167
+ },
4168
+ 'filters.assetClasses': {
4169
+ description: 'Asset class filters',
4170
+ type: 'array',
4171
+ items: {
4172
+ type: 'string'
4173
+ }
4174
+ },
4175
+ 'filters.dataSource': {
4176
+ type: 'string',
4177
+ description: 'Data source filter'
4178
+ },
4179
+ 'filters.symbol': {
4180
+ type: 'string',
4181
+ description: 'Symbol filter'
4182
+ },
4183
+ 'filters.tags': {
4184
+ description: 'Tag filters',
4185
+ type: 'array',
4186
+ items: {
4187
+ type: 'string'
4188
+ }
4189
+ },
4190
+ isExperimentalFeatures: {
4191
+ type: 'boolean',
4192
+ description: 'Enable experimental features'
4193
+ },
4194
+ isRestrictedView: {
4195
+ type: 'boolean',
4196
+ description: 'Enable restricted view mode'
4197
+ },
4198
+ language: {
4199
+ type: 'string',
4200
+ description: 'Language code',
4201
+ example: 'en'
4202
+ },
4203
+ locale: {
4204
+ type: 'string',
4205
+ description: 'Locale code',
4206
+ example: 'en-US'
4207
+ },
4208
+ projectedTotalAmount: {
4209
+ type: 'number',
4210
+ description: 'Projected total amount',
4211
+ example: 1000000
4212
+ },
4213
+ retirementDate: {
4214
+ type: 'string',
4215
+ description: 'Retirement date in ISO 8601 format',
4216
+ example: '2050-01-01'
4217
+ },
4218
+ savingsRate: {
4219
+ type: 'number',
4220
+ description: 'Savings rate percentage',
4221
+ example: 0.2
4222
+ },
4223
+ viewMode: {
4224
+ type: 'string',
4225
+ description: 'View mode',
4226
+ enum: ['DEFAULT', 'ZEN']
4227
+ }
4228
+ }
4229
+ } as const;
4230
+
4231
+ export const $UpdatePropertyDto = {
4232
+ type: 'object',
4233
+ properties: {
4234
+ value: {
4235
+ type: 'string',
4236
+ description: 'Property value'
4237
+ }
4238
+ },
4239
+ required: ['value']
4240
+ } as const;
4241
+
4242
+ export const $CreateTransactionRuleDto = {
4243
+ type: 'object',
4244
+ properties: {
4245
+ name: {
4246
+ type: 'string',
4247
+ minLength: 1,
4248
+ maxLength: 100
4249
+ },
4250
+ description: {
4251
+ type: 'string',
4252
+ maxLength: 500
4253
+ },
4254
+ narrationKeywords: {
4255
+ items: {
4256
+ type: 'array'
4257
+ },
4258
+ maxItems: 50,
3226
4259
  type: 'array'
3227
4260
  },
3228
4261
  payeeKeywords: {
@@ -3855,151 +4888,393 @@ export const $TestRuleResponseDto = {
3855
4888
  required: ['ruleId', 'matches', 'confidence', 'matchDetails']
3856
4889
  } as const;
3857
4890
 
3858
- export const $DeleteOwnUserDto = {
4891
+ export const $CreateBeanEventDto = {
3859
4892
  type: 'object',
3860
4893
  properties: {
3861
- accessToken: {
4894
+ date: {
3862
4895
  type: 'string',
3863
- description: 'Access token for user verification',
3864
- example: 'abc123xyz'
4896
+ description: 'Life event date (ISO 8601)',
4897
+ example: '2024-03-15'
4898
+ },
4899
+ type: {
4900
+ type: 'string',
4901
+ description:
4902
+ 'Life event type (e.g., "employer", "location", "marital-status") — user-defined, no enum constraint at engine layer',
4903
+ example: 'employer'
4904
+ },
4905
+ description: {
4906
+ type: 'string',
4907
+ description:
4908
+ 'Life event description. Empty string is a VALID value (distinct from absence).',
4909
+ example: 'Acme Corp'
4910
+ },
4911
+ meta: {
4912
+ type: 'object',
4913
+ description:
4914
+ 'Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)',
4915
+ example: {
4916
+ note: 'Promotion'
4917
+ }
3865
4918
  }
3866
4919
  },
3867
- required: ['accessToken']
4920
+ required: ['date', 'type', 'description']
3868
4921
  } as const;
3869
4922
 
3870
- export const $SignupDto = {
4923
+ export const $EventResponseDto = {
3871
4924
  type: 'object',
3872
4925
  properties: {
3873
- turnstileToken: {
4926
+ id: {
4927
+ type: 'string',
4928
+ description: 'Unique identifier',
4929
+ example: 'uuid-123-456'
4930
+ },
4931
+ userId: {
4932
+ type: 'string',
4933
+ description: 'User ID (owner of the life event)',
4934
+ example: 'user-123'
4935
+ },
4936
+ date: {
4937
+ type: 'string',
4938
+ description: 'Life event date (ISO 8601 format)',
4939
+ example: '2024-03-15',
4940
+ format: 'date'
4941
+ },
4942
+ type: {
3874
4943
  type: 'string',
3875
4944
  description:
3876
- 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
3877
- example: '0.abc123def456...'
4945
+ 'Life event type (user-defined, e.g., "employer", "location")',
4946
+ example: 'employer'
4947
+ },
4948
+ description: {
4949
+ type: 'string',
4950
+ description:
4951
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4952
+ example: 'Acme Corp'
4953
+ },
4954
+ meta: {
4955
+ type: 'object',
4956
+ description: 'Product-side metadata (free-form JSON)',
4957
+ example: {
4958
+ note: 'Promotion'
4959
+ }
4960
+ },
4961
+ createdAt: {
4962
+ format: 'date-time',
4963
+ type: 'string',
4964
+ description: 'Creation timestamp',
4965
+ example: '2024-03-15T10:00:00Z'
4966
+ },
4967
+ updatedAt: {
4968
+ format: 'date-time',
4969
+ type: 'string',
4970
+ description:
4971
+ 'Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.',
4972
+ example: '2024-03-15T10:00:00Z'
4973
+ }
4974
+ },
4975
+ required: [
4976
+ 'id',
4977
+ 'userId',
4978
+ 'date',
4979
+ 'type',
4980
+ 'description',
4981
+ 'meta',
4982
+ 'createdAt',
4983
+ 'updatedAt'
4984
+ ]
4985
+ } as const;
4986
+
4987
+ export const $EventListResponseDto = {
4988
+ type: 'object',
4989
+ properties: {
4990
+ items: {
4991
+ description: 'List of life events',
4992
+ type: 'array',
4993
+ items: {
4994
+ $ref: '#/components/schemas/EventResponseDto'
4995
+ }
4996
+ },
4997
+ total: {
4998
+ type: 'number',
4999
+ description: 'Total number of life events matching the query',
5000
+ example: 42
5001
+ }
5002
+ },
5003
+ required: ['items', 'total']
5004
+ } as const;
5005
+
5006
+ export const $UpdateBeanEventDto = {
5007
+ type: 'object',
5008
+ properties: {
5009
+ date: {
5010
+ type: 'string',
5011
+ description: 'Life event date (ISO 8601)'
5012
+ },
5013
+ type: {
5014
+ type: 'string',
5015
+ description: 'Life event type (user-defined)'
5016
+ },
5017
+ description: {
5018
+ type: 'string',
5019
+ description:
5020
+ 'Life event description. Empty string is a VALID value (distinct from absence).'
5021
+ },
5022
+ meta: {
5023
+ type: 'object',
5024
+ description: 'Product-side metadata (free-form JSON)'
5025
+ }
5026
+ }
5027
+ } as const;
5028
+
5029
+ export const $OnboardingAccountDto = {
5030
+ type: 'object',
5031
+ properties: {
5032
+ path: {
5033
+ type: 'string',
5034
+ description:
5035
+ 'Account path (Assets/Liabilities only; format validated by the account service)',
5036
+ example: 'Assets:Checking'
5037
+ },
5038
+ currency: {
5039
+ type: 'string',
5040
+ description: 'ISO 4217 currency code (3 letters)',
5041
+ example: 'USD'
5042
+ },
5043
+ openingBalance: {
5044
+ type: 'string',
5045
+ description:
5046
+ 'Opening balance as a non-negative Decimal string (e.g. "1000.00")',
5047
+ example: '1000.00'
5048
+ },
5049
+ platformId: {
5050
+ type: 'string',
5051
+ description:
5052
+ 'Platform ID to bind the account to (references Platform.id); omit for unbound',
5053
+ example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
5054
+ }
5055
+ },
5056
+ required: ['path', 'currency']
5057
+ } as const;
5058
+
5059
+ export const $OnboardingDto = {
5060
+ type: 'object',
5061
+ properties: {
5062
+ accounts: {
5063
+ description: 'Asset/Liability accounts to register with opening balances',
5064
+ type: 'array',
5065
+ items: {
5066
+ $ref: '#/components/schemas/OnboardingAccountDto'
5067
+ }
5068
+ },
5069
+ skipAssetRegistration: {
5070
+ type: 'boolean',
5071
+ description:
5072
+ 'Skip asset registration; only bootstrap the core account set',
5073
+ default: false
5074
+ }
5075
+ }
5076
+ } as const;
5077
+
5078
+ export const $ActualBalanceDto = {
5079
+ type: 'object',
5080
+ properties: {
5081
+ amount: {
5082
+ type: 'string',
5083
+ description:
5084
+ 'Actual balance amount as a decimal string (preserves precision for tolerance inference).',
5085
+ example: '1234.56'
5086
+ },
5087
+ ccy: {
5088
+ type: 'string',
5089
+ description: 'Currency code (ISO 4217 or commodity ticker).',
5090
+ example: 'CNY'
5091
+ }
5092
+ },
5093
+ required: ['amount', 'ccy']
5094
+ } as const;
5095
+
5096
+ export const $ComputeReconciliationDto = {
5097
+ type: 'object',
5098
+ properties: {
5099
+ accountId: {
5100
+ type: 'string',
5101
+ description: 'BeanAccount id to reconcile.'
5102
+ },
5103
+ asOfDate: {
5104
+ type: 'string',
5105
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5106
+ example: '2026-07-24'
5107
+ },
5108
+ actualBalance: {
5109
+ description: 'Actual balance from the external statement.',
5110
+ allOf: [
5111
+ {
5112
+ $ref: '#/components/schemas/ActualBalanceDto'
5113
+ }
5114
+ ]
3878
5115
  }
3879
- }
5116
+ },
5117
+ required: ['accountId', 'asOfDate', 'actualBalance']
3880
5118
  } as const;
3881
5119
 
3882
- export const $UpdateUserSettingDto = {
5120
+ export const $ReconciliationComputeResultDto = {
3883
5121
  type: 'object',
3884
5122
  properties: {
3885
- secId: {
3886
- type: 'number',
3887
- description: 'Security ID'
5123
+ accountId: {
5124
+ type: 'string'
3888
5125
  },
3889
- annualInterestRate: {
3890
- type: 'number',
3891
- description: 'Annual interest rate',
3892
- example: 0.05
5126
+ asOfDate: {
5127
+ type: 'string'
3893
5128
  },
3894
- currency: {
5129
+ bookBalance: {
3895
5130
  type: 'string',
3896
- description: 'Currency code',
3897
- example: 'USD'
5131
+ description: 'System-computed book balance (decimal string).'
3898
5132
  },
3899
- baseCurrency: {
5133
+ actualBalance: {
3900
5134
  type: 'string',
3901
- description: 'Base currency code',
3902
- example: 'USD'
5135
+ description: 'User-entered actual balance (decimal string).'
3903
5136
  },
3904
- benchmark: {
3905
- type: 'string',
3906
- description: 'Benchmark symbol',
3907
- example: 'SPY'
5137
+ currency: {
5138
+ type: 'string'
3908
5139
  },
3909
- colorScheme: {
5140
+ diff: {
3910
5141
  type: 'string',
3911
- description: 'Color scheme',
3912
- enum: ['DARK', 'LIGHT']
5142
+ description: 'Diff = book − actual (decimal string).'
3913
5143
  },
3914
- dateRange: {
5144
+ tolerance: {
3915
5145
  type: 'string',
3916
- description: 'Date range filter',
3917
- example: '1y'
3918
- },
3919
- emergencyFund: {
3920
- type: 'number',
3921
- description: 'Emergency fund amount',
3922
- example: 10000
5146
+ description: 'Applied tolerance (decimal string).'
3923
5147
  },
3924
- 'filters.accounts': {
3925
- description: 'Account filter IDs',
3926
- type: 'array',
3927
- items: {
3928
- type: 'string'
3929
- }
3930
- },
3931
- 'filters.assetClasses': {
3932
- description: 'Asset class filters',
3933
- type: 'array',
3934
- items: {
3935
- type: 'string'
3936
- }
5148
+ withinTolerance: {
5149
+ type: 'boolean',
5150
+ description: 'true when |diff| ≤ tolerance.'
3937
5151
  },
3938
- 'filters.dataSource': {
5152
+ suggestedAction: {
3939
5153
  type: 'string',
3940
- description: 'Data source filter'
5154
+ enum: ['assert', 'pad'],
5155
+ description:
5156
+ 'Suggested next action: assert when within tolerance, pad otherwise.'
5157
+ }
5158
+ },
5159
+ required: [
5160
+ 'accountId',
5161
+ 'asOfDate',
5162
+ 'bookBalance',
5163
+ 'actualBalance',
5164
+ 'currency',
5165
+ 'diff',
5166
+ 'tolerance',
5167
+ 'withinTolerance',
5168
+ 'suggestedAction'
5169
+ ]
5170
+ } as const;
5171
+
5172
+ export const $AssertReconciliationDto = {
5173
+ type: 'object',
5174
+ properties: {
5175
+ accountId: {
5176
+ type: 'string',
5177
+ description: 'BeanAccount id to reconcile.'
3941
5178
  },
3942
- 'filters.symbol': {
5179
+ asOfDate: {
3943
5180
  type: 'string',
3944
- description: 'Symbol filter'
5181
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5182
+ example: '2026-07-24'
3945
5183
  },
3946
- 'filters.tags': {
3947
- description: 'Tag filters',
3948
- type: 'array',
3949
- items: {
3950
- type: 'string'
3951
- }
5184
+ actualBalance: {
5185
+ description: 'Actual balance from the external statement.',
5186
+ allOf: [
5187
+ {
5188
+ $ref: '#/components/schemas/ActualBalanceDto'
5189
+ }
5190
+ ]
3952
5191
  },
3953
- isExperimentalFeatures: {
3954
- type: 'boolean',
3955
- description: 'Enable experimental features'
5192
+ tolerance: {
5193
+ type: 'string',
5194
+ description:
5195
+ 'Optional explicit tolerance override. Omit to infer from amount precision (Beancount default).',
5196
+ example: '0.01'
5197
+ }
5198
+ },
5199
+ required: ['accountId', 'asOfDate', 'actualBalance']
5200
+ } as const;
5201
+
5202
+ export const $ReconciliationRecordDto = {
5203
+ type: 'object',
5204
+ properties: {
5205
+ id: {
5206
+ type: 'string'
3956
5207
  },
3957
- isRestrictedView: {
3958
- type: 'boolean',
3959
- description: 'Enable restricted view mode'
5208
+ accountId: {
5209
+ type: 'string'
3960
5210
  },
3961
- language: {
5211
+ date: {
5212
+ type: 'string'
5213
+ },
5214
+ amount: {
3962
5215
  type: 'string',
3963
- description: 'Language code',
3964
- example: 'en'
5216
+ description: 'Asserted (actual) amount.'
3965
5217
  },
3966
- locale: {
5218
+ currency: {
5219
+ type: 'string'
5220
+ },
5221
+ tolerance: {
5222
+ type: 'string'
5223
+ },
5224
+ diffAmount: {
3967
5225
  type: 'string',
3968
- description: 'Locale code',
3969
- example: 'en-US'
5226
+ description: 'book − actual.'
3970
5227
  },
3971
- projectedTotalAmount: {
3972
- type: 'number',
3973
- description: 'Projected total amount',
3974
- example: 1000000
5228
+ diffCurrency: {
5229
+ type: 'string'
3975
5230
  },
3976
- retirementDate: {
5231
+ createdAt: {
5232
+ type: 'string'
5233
+ }
5234
+ },
5235
+ required: ['id', 'accountId', 'date', 'amount', 'currency', 'createdAt']
5236
+ } as const;
5237
+
5238
+ export const $PadReconciliationDto = {
5239
+ type: 'object',
5240
+ properties: {
5241
+ accountId: {
3977
5242
  type: 'string',
3978
- description: 'Retirement date in ISO 8601 format',
3979
- example: '2050-01-01'
5243
+ description: 'BeanAccount id to reconcile.'
3980
5244
  },
3981
- savingsRate: {
3982
- type: 'number',
3983
- description: 'Savings rate percentage',
3984
- example: 0.2
5245
+ asOfDate: {
5246
+ type: 'string',
5247
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5248
+ example: '2026-07-24'
3985
5249
  },
3986
- viewMode: {
5250
+ actualBalance: {
5251
+ description: 'Actual balance from the external statement.',
5252
+ allOf: [
5253
+ {
5254
+ $ref: '#/components/schemas/ActualBalanceDto'
5255
+ }
5256
+ ]
5257
+ },
5258
+ sourceAccount: {
3987
5259
  type: 'string',
3988
- description: 'View mode',
3989
- enum: ['DEFAULT', 'ZEN']
5260
+ description:
5261
+ 'Pad source account. Defaults to Equity:Opening-Balances (official Beancount convention).',
5262
+ example: 'Equity:Opening-Balances',
5263
+ default: 'Equity:Opening-Balances'
3990
5264
  }
3991
- }
5265
+ },
5266
+ required: ['accountId', 'asOfDate', 'actualBalance']
3992
5267
  } as const;
3993
5268
 
3994
- export const $UpdatePropertyDto = {
5269
+ export const $PadResultDto = {
3995
5270
  type: 'object',
3996
5271
  properties: {
3997
- value: {
5272
+ transactionId: {
3998
5273
  type: 'string',
3999
- description: 'Property value'
5274
+ description: 'Created pad adjusting transaction id.'
4000
5275
  }
4001
5276
  },
4002
- required: ['value']
5277
+ required: ['transactionId']
4003
5278
  } as const;
4004
5279
 
4005
5280
  export const $FileImportDto = {
@@ -4168,7 +5443,7 @@ export const $IdentifyResultDto = {
4168
5443
  account: {
4169
5444
  type: 'string',
4170
5445
  description: 'Default account used by this importer',
4171
- example: 'Assets:Alipay:Balance'
5446
+ example: 'Assets:CN:Alipay:Balance'
4172
5447
  },
4173
5448
  message: {
4174
5449
  type: 'string',
@@ -4185,7 +5460,7 @@ export const $MapperDefaultsDto = {
4185
5460
  sourceAccount: {
4186
5461
  type: 'string',
4187
5462
  description: 'Source account for transactions (Beancount format)',
4188
- example: 'Assets:Alipay:Balance'
5463
+ example: 'Assets:CN:Alipay:Balance'
4189
5464
  },
4190
5465
  currency: {
4191
5466
  type: 'string',
@@ -4222,7 +5497,7 @@ export const $MapperDefaultsDto = {
4222
5497
  description:
4223
5498
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4224
5499
  example: {
4225
- HuaBei: 'Liabilities:Alipay:Huabei',
5500
+ HuaBei: 'Liabilities:CN:CreditLine',
4226
5501
  CreditCard: 'Liabilities:CreditCard'
4227
5502
  }
4228
5503
  }
@@ -4354,7 +5629,7 @@ export const $UpdateMapperDefaultsDto = {
4354
5629
  sourceAccount: {
4355
5630
  type: 'string',
4356
5631
  description: 'Source account for transactions (Beancount format)',
4357
- example: 'Assets:Alipay:Balance',
5632
+ example: 'Assets:CN:Alipay:Balance',
4358
5633
  pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4359
5634
  },
4360
5635
  currency: {
@@ -4382,7 +5657,7 @@ export const $UpdateMapperDefaultsDto = {
4382
5657
  description:
4383
5658
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4384
5659
  example: {
4385
- HuaBei: 'Liabilities:Alipay:Huabei',
5660
+ HuaBei: 'Liabilities:CN:CreditLine',
4386
5661
  CreditCard: 'Liabilities:CreditCard'
4387
5662
  }
4388
5663
  }
@@ -4409,116 +5684,10 @@ export const $UpdateImporterConfigDto = {
4409
5684
  data: {
4410
5685
  description: 'Configuration data (v1 schema)',
4411
5686
  allOf: [
4412
- {
4413
- $ref: '#/components/schemas/UpdateConfigDataDto'
4414
- }
4415
- ]
4416
- }
4417
- }
4418
- } as const;
4419
-
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'
5687
+ {
5688
+ $ref: '#/components/schemas/UpdateConfigDataDto'
5689
+ }
5690
+ ]
4522
5691
  }
4523
5692
  }
4524
5693
  } as const;
@@ -4529,7 +5698,7 @@ export const $ProviderSyncConfigDto = {
4529
5698
  sourceAccount: {
4530
5699
  type: 'string',
4531
5700
  description: 'Source account for the first posting',
4532
- example: 'Assets:Bank:Chase'
5701
+ example: 'Assets:US:Chase:Checking'
4533
5702
  },
4534
5703
  defaultCurrency: {
4535
5704
  type: 'string',
@@ -4550,6 +5719,12 @@ export const $ProviderSyncConfigDto = {
4550
5719
  type: 'boolean',
4551
5720
  description: 'Filter pending transactions',
4552
5721
  default: true
5722
+ },
5723
+ externalAccountId: {
5724
+ type: 'string',
5725
+ description:
5726
+ 'External account ID for per-batch providers (e.g. GoCardless). Overrides sourceAccount when an ExternalAccountLink mapping exists.',
5727
+ example: 'acc_gocardless_001'
4553
5728
  }
4554
5729
  },
4555
5730
  required: [
@@ -4669,11 +5844,104 @@ export const $SupportedProvidersResponseDto = {
4669
5844
  required: ['providers']
4670
5845
  } as const;
4671
5846
 
5847
+ export const $CreateExternalAccountLinkDto = {
5848
+ type: 'object',
5849
+ properties: {
5850
+ provider: {
5851
+ type: 'string',
5852
+ enum: [
5853
+ 'plaid',
5854
+ 'teller',
5855
+ 'truelayer',
5856
+ 'gocardless',
5857
+ 'simplefin',
5858
+ 'yodlee',
5859
+ 'beancount-direct',
5860
+ 'parsed-bill'
5861
+ ],
5862
+ example: 'plaid',
5863
+ description: 'Open Banking provider (whitelist)'
5864
+ },
5865
+ externalAccountId: {
5866
+ type: 'string',
5867
+ example: 'acc-plaid-001',
5868
+ description: 'External account ID from the provider'
5869
+ },
5870
+ beanAccountId: {
5871
+ type: 'string',
5872
+ example: '550e8400-e29b-41d4-a716-446655440000',
5873
+ description: 'Target BeanAccount ID (must belong to the JWT user)'
5874
+ }
5875
+ },
5876
+ required: ['provider', 'externalAccountId', 'beanAccountId']
5877
+ } as const;
5878
+
5879
+ export const $ExternalAccountLinkResponseDto = {
5880
+ type: 'object',
5881
+ properties: {
5882
+ id: {
5883
+ type: 'string'
5884
+ },
5885
+ provider: {
5886
+ type: 'string'
5887
+ },
5888
+ externalAccountId: {
5889
+ type: 'string'
5890
+ },
5891
+ beanAccountId: {
5892
+ type: 'string'
5893
+ },
5894
+ isActive: {
5895
+ type: 'boolean'
5896
+ },
5897
+ createdAt: {
5898
+ type: 'string'
5899
+ },
5900
+ updatedAt: {
5901
+ type: 'string'
5902
+ }
5903
+ },
5904
+ required: [
5905
+ 'id',
5906
+ 'provider',
5907
+ 'externalAccountId',
5908
+ 'beanAccountId',
5909
+ 'isActive',
5910
+ 'createdAt',
5911
+ 'updatedAt'
5912
+ ]
5913
+ } as const;
5914
+
5915
+ export const $ExternalAccountLinkListResponseDto = {
5916
+ type: 'object',
5917
+ properties: {
5918
+ items: {
5919
+ type: 'array',
5920
+ items: {
5921
+ $ref: '#/components/schemas/ExternalAccountLinkResponseDto'
5922
+ }
5923
+ },
5924
+ total: {
5925
+ type: 'number'
5926
+ },
5927
+ provider: {
5928
+ type: 'string',
5929
+ description: 'Filter by provider (query param)'
5930
+ }
5931
+ },
5932
+ required: ['items', 'total']
5933
+ } as const;
5934
+
4672
5935
  export const $ParserTelemetryReportDto = {
4673
5936
  type: 'object',
4674
5937
  properties: {}
4675
5938
  } as const;
4676
5939
 
5940
+ export const $UncoveredFormatMissDto = {
5941
+ type: 'object',
5942
+ properties: {}
5943
+ } as const;
5944
+
4677
5945
  export const $ProcessNlpDto = {
4678
5946
  type: 'object',
4679
5947
  properties: {
@@ -4688,6 +5956,28 @@ export const $ProcessNlpDto = {
4688
5956
  description:
4689
5957
  'Session ID for multi-turn conversation (auto-generated if not provided)',
4690
5958
  example: 'session_abc123'
5959
+ },
5960
+ parsedData: {
5961
+ type: 'object',
5962
+ description:
5963
+ 'Parsed data from previous NLP response for session recovery. Send back the parsedData received in confirm_payee/confirm responses.',
5964
+ example: {
5965
+ amount: 35,
5966
+ currency: 'CNY',
5967
+ payee: 'Starbucks'
5968
+ }
5969
+ },
5970
+ selectedRuleId: {
5971
+ type: 'string',
5972
+ description:
5973
+ 'confirm_rule echo-back: rule id selected from the prior confirm_rule response (matchedRule.id or alternatives[i].ruleId). Applied directly when the session is confirming_rule — no NL re-parse.',
5974
+ example: 'rule_abc123'
5975
+ },
5976
+ selectedAccount: {
5977
+ type: 'string',
5978
+ description:
5979
+ 'confirm_account echo-back: account path selected from the prior confirm_account response (suggestedAccount, similarAccounts[i], or a typed path). Applied directly when the session is confirming_account — no NL re-parse.',
5980
+ example: 'Expenses:Food:Coffee'
4691
5981
  }
4692
5982
  },
4693
5983
  required: ['message']
@@ -5012,7 +6302,8 @@ export const $NlpAccountConfirmationDataDto = {
5012
6302
  },
5013
6303
  suggestedAccount: {
5014
6304
  type: 'string',
5015
- description: 'Suggested replacement account',
6305
+ description:
6306
+ 'Suggested replacement account (omitted when no clear candidate)',
5016
6307
  example: 'Expenses:Food:Drinks'
5017
6308
  },
5018
6309
  similarAccounts: {
@@ -5034,7 +6325,6 @@ export const $NlpAccountConfirmationDataDto = {
5034
6325
  },
5035
6326
  required: [
5036
6327
  'invalidAccount',
5037
- 'suggestedAccount',
5038
6328
  'similarAccounts',
5039
6329
  'errorMessage',
5040
6330
  'transactionContext'
@@ -5203,11 +6493,12 @@ export const $NlpSuggestedAccountDto = {
5203
6493
  account: {
5204
6494
  type: 'string',
5205
6495
  description: 'Suggested account path',
5206
- example: 'Assets:Bank:Checking'
6496
+ example: 'Assets:Checking'
5207
6497
  },
5208
6498
  confidence: {
5209
6499
  type: 'number',
5210
- description: 'Confidence score for this suggestion (0-1)',
6500
+ description:
6501
+ 'Confidence score for this suggestion (0-1). Present = predicted (confirm/confirm_rule/confirm_account); omitted = actual persisted account (created). (#586)',
5211
6502
  example: 0.9
5212
6503
  }
5213
6504
  },
@@ -5243,23 +6534,31 @@ export const $NlpDefaultAccountsDto = {
5243
6534
  properties: {
5244
6535
  asset: {
5245
6536
  type: 'string',
5246
- description: 'Default asset account',
5247
- example: 'Assets:Bank:Checking'
6537
+ description:
6538
+ 'Default OPEN asset account (MRU when multiple), or null when none/ambiguous',
6539
+ example: 'Assets:Checking',
6540
+ nullable: true
5248
6541
  },
5249
6542
  expense: {
5250
6543
  type: 'string',
5251
- description: 'Default expense account',
5252
- example: 'Expenses:Uncategorized'
6544
+ description:
6545
+ 'Default OPEN expense account (MRU when multiple), or null when none/ambiguous',
6546
+ example: 'Expenses:Food:Coffee',
6547
+ nullable: true
5253
6548
  },
5254
6549
  income: {
5255
6550
  type: 'string',
5256
- description: 'Default income account',
5257
- example: 'Income:Uncategorized'
6551
+ description:
6552
+ 'Default OPEN income account (MRU when multiple), or null when none/ambiguous',
6553
+ example: 'Income:Salary',
6554
+ nullable: true
5258
6555
  },
5259
6556
  liability: {
5260
6557
  type: 'string',
5261
- description: 'Default liability account',
5262
- example: 'Liabilities:CreditCard'
6558
+ description:
6559
+ 'Default OPEN liability account (MRU when multiple), or null when none/ambiguous',
6560
+ example: 'Liabilities:CreditCard',
6561
+ nullable: true
5263
6562
  }
5264
6563
  },
5265
6564
  required: ['asset', 'expense', 'income', 'liability']
@@ -5284,7 +6583,8 @@ export const $NlpResponseDto = {
5284
6583
  'confirm_rule',
5285
6584
  'confirm_account',
5286
6585
  'confirm_payee',
5287
- 'cancel'
6586
+ 'cancel',
6587
+ 'aborted'
5288
6588
  ]
5289
6589
  },
5290
6590
  intent: {
@@ -5444,43 +6744,274 @@ export const $NlpResponseDto = {
5444
6744
  }
5445
6745
  ]
5446
6746
  },
5447
- suggestedAccounts: {
5448
- description:
5449
- 'Suggested accounts for this transaction. Contains recommended source and destination accounts based on the detected intent and rules.',
5450
- allOf: [
5451
- {
5452
- $ref: '#/components/schemas/NlpSuggestedAccountsDto'
5453
- }
5454
- ]
6747
+ suggestedAccounts: {
6748
+ description:
6749
+ 'Suggested accounts for this transaction (#586). confirm/confirm_rule/confirm_account: predicted (source/destination carry confidence); created: actual persisted accounts (confidence omitted). confirm_account destination is the suggested replacement, never the invalid account.',
6750
+ allOf: [
6751
+ {
6752
+ $ref: '#/components/schemas/NlpSuggestedAccountsDto'
6753
+ }
6754
+ ]
6755
+ },
6756
+ defaultAccounts: {
6757
+ description:
6758
+ 'Default fallback accounts for the user/region (#586). v1 returns universal constants; per-user personalization is planned.',
6759
+ allOf: [
6760
+ {
6761
+ $ref: '#/components/schemas/NlpDefaultAccountsDto'
6762
+ }
6763
+ ]
6764
+ }
6765
+ },
6766
+ required: ['status', 'action']
6767
+ } as const;
6768
+
6769
+ export const $PlatformListItemDto = {
6770
+ type: 'object',
6771
+ properties: {
6772
+ id: {
6773
+ type: 'string',
6774
+ description: 'Global platform ID'
6775
+ },
6776
+ name: {
6777
+ type: 'string',
6778
+ description: 'Platform name'
6779
+ },
6780
+ url: {
6781
+ type: 'string',
6782
+ description: 'Platform URL'
6783
+ },
6784
+ type: {
6785
+ type: 'string',
6786
+ description: 'Platform type',
6787
+ enum: [
6788
+ 'BANK',
6789
+ 'BROKERAGE',
6790
+ 'CRYPTO_EXCHANGE',
6791
+ 'PAYMENT',
6792
+ 'INVESTMENT',
6793
+ 'INSURANCE',
6794
+ 'OTHER'
6795
+ ]
6796
+ },
6797
+ canonical: {
6798
+ type: 'string',
6799
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6800
+ },
6801
+ suggestedSegment: {
6802
+ type: 'string',
6803
+ description:
6804
+ 'Suggested path segment — canonical with first char uppercased (ACC_COMP_NAME_RE)'
6805
+ },
6806
+ logoUrl: {
6807
+ type: 'string',
6808
+ description: 'Logo URL',
6809
+ nullable: true
6810
+ },
6811
+ isBound: {
6812
+ type: 'boolean',
6813
+ description: 'Whether user has accounts using this platform'
6814
+ }
6815
+ },
6816
+ required: [
6817
+ 'id',
6818
+ 'name',
6819
+ 'url',
6820
+ 'type',
6821
+ 'canonical',
6822
+ 'suggestedSegment',
6823
+ 'logoUrl',
6824
+ 'isBound'
6825
+ ]
6826
+ } as const;
6827
+
6828
+ export const $PlatformMatchResultDto = {
6829
+ type: 'object',
6830
+ properties: {
6831
+ id: {
6832
+ type: 'string',
6833
+ description: 'Global platform ID'
6834
+ },
6835
+ name: {
6836
+ type: 'string',
6837
+ description: 'Platform name (e.g., "ICBC")'
6838
+ },
6839
+ canonical: {
6840
+ type: 'string',
6841
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6842
+ },
6843
+ type: {
6844
+ type: 'string',
6845
+ description: 'Platform type',
6846
+ enum: [
6847
+ 'BANK',
6848
+ 'BROKERAGE',
6849
+ 'CRYPTO_EXCHANGE',
6850
+ 'PAYMENT',
6851
+ 'INVESTMENT',
6852
+ 'INSURANCE',
6853
+ 'OTHER'
6854
+ ]
6855
+ },
6856
+ suggestedSegment: {
6857
+ type: 'string',
6858
+ description:
6859
+ 'Suggested path segment — canonical, already in ACCOUNT_RE format'
6860
+ },
6861
+ logoUrl: {
6862
+ type: 'string',
6863
+ description: 'Logo URL',
6864
+ nullable: true
6865
+ },
6866
+ matchType: {
6867
+ type: 'string',
6868
+ description: "How this row matched: 'exact' > 'prefix' > 'substring'",
6869
+ enum: ['exact', 'prefix', 'substring']
6870
+ }
6871
+ },
6872
+ required: [
6873
+ 'id',
6874
+ 'name',
6875
+ 'canonical',
6876
+ 'type',
6877
+ 'suggestedSegment',
6878
+ 'logoUrl',
6879
+ 'matchType'
6880
+ ]
6881
+ } as const;
6882
+
6883
+ export const $PlatformMatchResponseDto = {
6884
+ type: 'object',
6885
+ properties: {
6886
+ platforms: {
6887
+ description: 'Ranked matches, best tier first (at most 10 rows)',
6888
+ type: 'array',
6889
+ items: {
6890
+ $ref: '#/components/schemas/PlatformMatchResultDto'
6891
+ }
6892
+ },
6893
+ matchType: {
6894
+ type: 'string',
6895
+ description:
6896
+ "Overall match quality — top row's tier, or 'none' when no hits",
6897
+ enum: ['none', 'exact', 'prefix', 'substring']
6898
+ },
6899
+ total: {
6900
+ type: 'number',
6901
+ description: 'Total matches before LIMIT (truncation transparency)'
6902
+ },
6903
+ hasMore: {
6904
+ type: 'boolean',
6905
+ description: 'true when total > platforms.length (more matches exist)'
6906
+ }
6907
+ },
6908
+ required: ['platforms', 'matchType', 'total', 'hasMore']
6909
+ } as const;
6910
+
6911
+ export const $CreatePlatformDto = {
6912
+ type: 'object',
6913
+ properties: {
6914
+ name: {
6915
+ type: 'string',
6916
+ description: 'Platform name',
6917
+ example: 'Binance'
6918
+ },
6919
+ canonical: {
6920
+ type: 'string',
6921
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6922
+ example: 'binance'
6923
+ },
6924
+ aliases: {
6925
+ description: 'Platform aliases (multi-language names for lookup)',
6926
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6927
+ type: 'array',
6928
+ items: {
6929
+ type: 'string'
6930
+ }
6931
+ },
6932
+ url: {
6933
+ type: 'string',
6934
+ description: 'Platform URL',
6935
+ example: 'https://www.binance.com'
6936
+ },
6937
+ type: {
6938
+ type: 'string',
6939
+ description: 'Platform type',
6940
+ enum: [
6941
+ 'BANK',
6942
+ 'BROKERAGE',
6943
+ 'CRYPTO_EXCHANGE',
6944
+ 'PAYMENT',
6945
+ 'INVESTMENT',
6946
+ 'INSURANCE',
6947
+ 'OTHER'
6948
+ ],
6949
+ example: 'CRYPTO_EXCHANGE'
6950
+ },
6951
+ logoUrl: {
6952
+ type: 'string',
6953
+ description: 'Platform logo URL',
6954
+ example: 'https://example.com/logos/binance.png'
5455
6955
  },
5456
- defaultAccounts: {
5457
- description:
5458
- 'Default accounts for the user/region. These are fallback accounts used when no specific suggestion is available.',
5459
- allOf: [
5460
- {
5461
- $ref: '#/components/schemas/NlpDefaultAccountsDto'
5462
- }
5463
- ]
6956
+ isActive: {
6957
+ type: 'boolean',
6958
+ description: 'Whether the platform is active',
6959
+ default: true
5464
6960
  }
5465
6961
  },
5466
- required: ['status', 'action']
6962
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
5467
6963
  } as const;
5468
6964
 
5469
- export const $BalanceByCurrencyDto = {
6965
+ export const $UpdatePlatformDto = {
5470
6966
  type: 'object',
5471
6967
  properties: {
5472
- currency: {
6968
+ name: {
5473
6969
  type: 'string',
5474
- description: 'ISO 4217 currency code',
5475
- example: 'CNY'
6970
+ description: 'Platform name',
6971
+ example: 'Binance'
5476
6972
  },
5477
- balance: {
6973
+ canonical: {
5478
6974
  type: 'string',
5479
- description: 'Balance amount',
5480
- example: '50000.00'
6975
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6976
+ example: 'binance'
6977
+ },
6978
+ aliases: {
6979
+ description: 'Platform aliases (multi-language names for lookup)',
6980
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6981
+ type: 'array',
6982
+ items: {
6983
+ type: 'string'
6984
+ }
6985
+ },
6986
+ url: {
6987
+ type: 'string',
6988
+ description: 'Platform URL',
6989
+ example: 'https://www.binance.com'
6990
+ },
6991
+ type: {
6992
+ type: 'string',
6993
+ description: 'Platform type',
6994
+ enum: [
6995
+ 'BANK',
6996
+ 'BROKERAGE',
6997
+ 'CRYPTO_EXCHANGE',
6998
+ 'PAYMENT',
6999
+ 'INVESTMENT',
7000
+ 'INSURANCE',
7001
+ 'OTHER'
7002
+ ],
7003
+ example: 'CRYPTO_EXCHANGE'
7004
+ },
7005
+ logoUrl: {
7006
+ type: 'string',
7007
+ description: 'Platform logo URL',
7008
+ example: 'https://example.com/logos/binance.png'
7009
+ },
7010
+ isActive: {
7011
+ type: 'boolean',
7012
+ description: 'Whether the platform is active'
5481
7013
  }
5482
- },
5483
- required: ['currency', 'balance']
7014
+ }
5484
7015
  } as const;
5485
7016
 
5486
7017
  export const $NetWorthByCurrencyDto = {
@@ -5552,28 +7083,6 @@ export const $ConvertedNetWorthDto = {
5552
7083
  ]
5553
7084
  } as const;
5554
7085
 
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'
5572
- }
5573
- },
5574
- required: ['type', 'currency', 'totalAmount']
5575
- } as const;
5576
-
5577
7086
  export const $NetWorthResponseDto = {
5578
7087
  type: 'object',
5579
7088
  properties: {
@@ -5659,7 +7168,7 @@ export const $AccountItemDto = {
5659
7168
  name: {
5660
7169
  type: 'string',
5661
7170
  description: 'Full account name',
5662
- example: 'Assets:Bank:CMB:Savings'
7171
+ example: 'Assets:CN:CMB:Savings'
5663
7172
  },
5664
7173
  displayName: {
5665
7174
  type: 'string',
@@ -5675,6 +7184,12 @@ export const $AccountItemDto = {
5675
7184
  type: 'string',
5676
7185
  description: 'Currency code',
5677
7186
  example: 'CNY'
7187
+ },
7188
+ convertedBalance: {
7189
+ type: 'string',
7190
+ description:
7191
+ 'FX-converted balance in base currency; omitted when not convertible',
7192
+ example: '50000.00'
5678
7193
  }
5679
7194
  },
5680
7195
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -5701,11 +7216,66 @@ export const $PlatformGroupDto = {
5701
7216
  },
5702
7217
  totalBalance: {
5703
7218
  type: 'string',
5704
- description: 'Total balance across all accounts in platform',
7219
+ description: 'FX-converted total balance in base currency',
7220
+ example: '100000.00'
7221
+ },
7222
+ balanceByCurrency: {
7223
+ description: 'Raw (unconverted) balances grouped by currency',
7224
+ type: 'array',
7225
+ items: {
7226
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7227
+ }
7228
+ },
7229
+ convertedBalance: {
7230
+ type: 'string',
7231
+ description:
7232
+ 'Converted balance in base currency (omitted when no currency is convertible)',
5705
7233
  example: '100000.00'
7234
+ },
7235
+ sharePct: {
7236
+ type: 'number',
7237
+ description:
7238
+ 'Share of the grand converted total (0-100); 0 when grand total is 0',
7239
+ example: 42.5
7240
+ }
7241
+ },
7242
+ required: [
7243
+ 'platformId',
7244
+ 'platformName',
7245
+ 'accounts',
7246
+ 'totalBalance',
7247
+ 'balanceByCurrency',
7248
+ 'sharePct'
7249
+ ]
7250
+ } as const;
7251
+
7252
+ export const $AccountExchangeRateWarningDto = {
7253
+ type: 'object',
7254
+ properties: {
7255
+ type: {
7256
+ type: 'string',
7257
+ description: 'Warning type',
7258
+ example: 'MISSING_EXCHANGE_RATE'
7259
+ },
7260
+ currency: {
7261
+ type: 'string',
7262
+ description: 'Currency without exchange rate',
7263
+ example: 'USD'
7264
+ },
7265
+ accounts: {
7266
+ description: 'Affected account paths',
7267
+ type: 'array',
7268
+ items: {
7269
+ type: 'string'
7270
+ }
7271
+ },
7272
+ totalAmount: {
7273
+ type: 'string',
7274
+ description: 'Total amount in this currency',
7275
+ example: '5000.00'
5706
7276
  }
5707
7277
  },
5708
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
7278
+ required: ['type', 'currency', 'accounts', 'totalAmount']
5709
7279
  } as const;
5710
7280
 
5711
7281
  export const $AccountsSummaryDto = {
@@ -5718,9 +7288,21 @@ export const $AccountsSummaryDto = {
5718
7288
  totalPlatforms: {
5719
7289
  type: 'number',
5720
7290
  description: 'Total number of platforms'
7291
+ },
7292
+ baseCurrency: {
7293
+ type: 'string',
7294
+ description: 'Base currency for conversion',
7295
+ example: 'CNY'
7296
+ },
7297
+ warnings: {
7298
+ description: 'Per-account exchange rate warnings',
7299
+ type: 'array',
7300
+ items: {
7301
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
7302
+ }
5721
7303
  }
5722
7304
  },
5723
- required: ['totalAccounts', 'totalPlatforms']
7305
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
5724
7306
  } as const;
5725
7307
 
5726
7308
  export const $AccountsResponseDto = {
@@ -5755,7 +7337,7 @@ export const $AccountItemWithAssetClassDto = {
5755
7337
  name: {
5756
7338
  type: 'string',
5757
7339
  description: 'Full account name',
5758
- example: 'Assets:Bank:CMB:Savings'
7340
+ example: 'Assets:CN:CMB:Savings'
5759
7341
  },
5760
7342
  displayName: {
5761
7343
  type: 'string',
@@ -5772,6 +7354,12 @@ export const $AccountItemWithAssetClassDto = {
5772
7354
  description: 'Currency code',
5773
7355
  example: 'CNY'
5774
7356
  },
7357
+ convertedBalance: {
7358
+ type: 'string',
7359
+ description:
7360
+ 'FX-converted balance in base currency; omitted when not convertible',
7361
+ example: '50000.00'
7362
+ },
5775
7363
  assetClass: {
5776
7364
  type: 'string',
5777
7365
  description: 'Asset class',
@@ -5791,6 +7379,12 @@ export const $AccountItemWithAssetClassDto = {
5791
7379
  type: 'string',
5792
7380
  description: 'Risk level',
5793
7381
  example: 'LOW'
7382
+ },
7383
+ source: {
7384
+ type: 'string',
7385
+ description:
7386
+ 'ADR-0105 classification provenance (holding level always; account level only on FALLBACK)',
7387
+ enum: ['USER_META', 'FIAT_CURRENCY', 'OPENBB_MAPPING', 'FALLBACK']
5794
7388
  }
5795
7389
  },
5796
7390
  required: ['id', 'name', 'displayName', 'balance', 'currency', 'assetClass']
@@ -5845,82 +7439,154 @@ export const $AssetClassGroupDto = {
5845
7439
  required: ['assetClass', 'accounts', 'balanceByCurrency']
5846
7440
  } as const;
5847
7441
 
5848
- export const $AccountExchangeRateWarningDto = {
7442
+ export const $AssetClassSummaryDto = {
5849
7443
  type: 'object',
5850
7444
  properties: {
5851
- type: {
5852
- type: 'string',
5853
- description: 'Warning type',
5854
- example: 'MISSING_EXCHANGE_RATE'
7445
+ totalAccounts: {
7446
+ type: 'number',
7447
+ description: 'Total number of accounts'
5855
7448
  },
5856
- currency: {
7449
+ totalAssetClasses: {
7450
+ type: 'number',
7451
+ description: 'Total number of asset classes'
7452
+ },
7453
+ baseCurrency: {
5857
7454
  type: 'string',
5858
- description: 'Currency without exchange rate',
5859
- example: 'USD'
7455
+ description: 'Base currency for conversion',
7456
+ example: 'CNY'
5860
7457
  },
5861
- accounts: {
5862
- description: 'Affected account paths',
7458
+ warnings: {
7459
+ description: 'Exchange rate warnings',
5863
7460
  type: 'array',
5864
7461
  items: {
5865
- type: 'string'
7462
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
5866
7463
  }
5867
7464
  },
5868
- totalAmount: {
5869
- type: 'string',
5870
- description: 'Total amount in this currency',
5871
- example: '5000.00'
7465
+ fallback: {
7466
+ type: 'object',
7467
+ description:
7468
+ '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.'
5872
7469
  }
5873
7470
  },
5874
- required: ['type', 'currency', 'accounts', 'totalAmount']
7471
+ required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
5875
7472
  } as const;
5876
7473
 
5877
- export const $AssetClassSummaryDto = {
7474
+ export const $AssetClassAccountsResponseDto = {
5878
7475
  type: 'object',
5879
7476
  properties: {
5880
- totalAccounts: {
5881
- type: 'number',
5882
- description: 'Total number of accounts'
7477
+ groups: {
7478
+ description: 'Account groups by asset class',
7479
+ type: 'array',
7480
+ items: {
7481
+ $ref: '#/components/schemas/AssetClassGroupDto'
7482
+ }
7483
+ },
7484
+ summary: {
7485
+ description: 'Summary statistics',
7486
+ allOf: [
7487
+ {
7488
+ $ref: '#/components/schemas/AssetClassSummaryDto'
7489
+ }
7490
+ ]
7491
+ },
7492
+ uncategorized: {
7493
+ description:
7494
+ 'ADR-0105 §6 holding-level grey-area bucket (source=FALLBACK holdings peeled out of groups). Present only for groupBy=holdingAssetClass when FALLBACK holdings exist.',
7495
+ allOf: [
7496
+ {
7497
+ $ref: '#/components/schemas/AssetClassGroupDto'
7498
+ }
7499
+ ]
7500
+ }
7501
+ },
7502
+ required: ['groups', 'summary']
7503
+ } as const;
7504
+
7505
+ export const $HoldingAssetClassAccountSliceDto = {
7506
+ type: 'object',
7507
+ properties: {
7508
+ accountId: {
7509
+ type: 'string',
7510
+ description: 'Account ID'
7511
+ },
7512
+ accountPath: {
7513
+ type: 'string',
7514
+ description: 'Full account path',
7515
+ example: 'Assets:US:Fidelity:Brokerage'
7516
+ },
7517
+ accountCurrency: {
7518
+ type: 'string',
7519
+ description:
7520
+ 'Currency of the holding with the largest converted base value; undefined when no holding is convertible',
7521
+ example: 'USD'
7522
+ },
7523
+ marketValueBase: {
7524
+ type: 'string',
7525
+ description:
7526
+ "Account's market value in base currency (Σ converted holdings; grey bucket included)",
7527
+ example: '50000.00'
5883
7528
  },
5884
- totalAssetClasses: {
7529
+ shareOfTotalPct: {
5885
7530
  type: 'number',
5886
- description: 'Total number of asset classes'
7531
+ description:
7532
+ 'Share of the global total (0-100). 0 when globalTotal is zero (no NaN/Infinity).',
7533
+ example: 42.5
5887
7534
  },
5888
- baseCurrency: {
5889
- type: 'string',
5890
- description: 'Base currency for conversion',
5891
- example: 'CNY'
7535
+ groups: {
7536
+ description: 'Per-account asset-class breakdown',
7537
+ type: 'array',
7538
+ items: {
7539
+ $ref: '#/components/schemas/AssetClassGroupDto'
7540
+ }
5892
7541
  },
5893
- warnings: {
5894
- description: 'Exchange rate warnings',
7542
+ uncategorized: {
7543
+ description:
7544
+ 'Per-account grey bucket (source=FALLBACK holdings, incl. broker cash)',
7545
+ allOf: [
7546
+ {
7547
+ $ref: '#/components/schemas/AssetClassGroupDto'
7548
+ }
7549
+ ]
7550
+ },
7551
+ holdings: {
7552
+ description:
7553
+ 'Every holding row for this account (account ID in each row’s `id` field)',
5895
7554
  type: 'array',
5896
7555
  items: {
5897
- $ref: '#/components/schemas/AccountExchangeRateWarningDto'
7556
+ $ref: '#/components/schemas/AccountItemWithAssetClassDto'
5898
7557
  }
5899
7558
  }
5900
7559
  },
5901
- required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
7560
+ required: [
7561
+ 'accountId',
7562
+ 'accountPath',
7563
+ 'marketValueBase',
7564
+ 'shareOfTotalPct',
7565
+ 'groups',
7566
+ 'holdings'
7567
+ ]
5902
7568
  } as const;
5903
7569
 
5904
- export const $AssetClassAccountsResponseDto = {
7570
+ export const $HoldingAssetClassCrossAccountResponseDto = {
5905
7571
  type: 'object',
5906
7572
  properties: {
5907
- groups: {
5908
- description: 'Account groups by asset class',
5909
- type: 'array',
5910
- items: {
5911
- $ref: '#/components/schemas/AssetClassGroupDto'
5912
- }
5913
- },
5914
- summary: {
5915
- description: 'Summary statistics',
7573
+ global: {
7574
+ description: 'Merged cross-account holding aggregation',
5916
7575
  allOf: [
5917
7576
  {
5918
- $ref: '#/components/schemas/AssetClassSummaryDto'
7577
+ $ref: '#/components/schemas/AssetClassAccountsResponseDto'
5919
7578
  }
5920
7579
  ]
7580
+ },
7581
+ byAccount: {
7582
+ description: 'Per-account slices',
7583
+ type: 'array',
7584
+ items: {
7585
+ $ref: '#/components/schemas/HoldingAssetClassAccountSliceDto'
7586
+ }
5921
7587
  }
5922
7588
  },
5923
- required: ['groups', 'summary']
7589
+ required: ['global', 'byAccount']
5924
7590
  } as const;
5925
7591
 
5926
7592
  export const $CashFlowByCurrencyDto = {
@@ -6022,207 +7688,582 @@ export const $CashFlowResponseDto = {
6022
7688
  description: 'Cash flow grouped by original currency',
6023
7689
  allOf: [
6024
7690
  {
6025
- $ref: '#/components/schemas/CashFlowByCurrencyDto'
7691
+ $ref: '#/components/schemas/CashFlowByCurrencyDto'
7692
+ }
7693
+ ]
7694
+ },
7695
+ converted: {
7696
+ description: 'Converted values in base currency',
7697
+ allOf: [
7698
+ {
7699
+ $ref: '#/components/schemas/ConvertedCashFlowDto'
7700
+ }
7701
+ ]
7702
+ },
7703
+ warnings: {
7704
+ description: 'Exchange rate warnings',
7705
+ type: 'array',
7706
+ items: {
7707
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7708
+ }
7709
+ }
7710
+ },
7711
+ required: [
7712
+ 'period',
7713
+ 'income',
7714
+ 'expense',
7715
+ 'netSavings',
7716
+ 'savingsRate',
7717
+ 'currency'
7718
+ ]
7719
+ } as const;
7720
+
7721
+ export const $CategoryGroupDto = {
7722
+ type: 'object',
7723
+ properties: {
7724
+ category: {
7725
+ type: 'string',
7726
+ description:
7727
+ 'Functional category (account-path Group segment); regional and universal account paths merge under it',
7728
+ example: 'Food'
7729
+ },
7730
+ totalExpense: {
7731
+ type: 'string',
7732
+ description:
7733
+ 'Converted total for this category in base currency (expense amount when flow=expense, income amount when flow=income)',
7734
+ example: '1200.00'
7735
+ },
7736
+ sharePct: {
7737
+ type: 'number',
7738
+ description: 'Share of grand total (0-100); 0 when grand total is 0',
7739
+ example: 42.5
7740
+ },
7741
+ balanceByCurrency: {
7742
+ description: 'Raw (unconverted) expense per currency',
7743
+ type: 'array',
7744
+ items: {
7745
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7746
+ }
7747
+ },
7748
+ convertedBalance: {
7749
+ type: 'string',
7750
+ description:
7751
+ 'Converted total in base currency (omitted when FX missing for all currencies in this category)',
7752
+ example: '1200.00'
7753
+ }
7754
+ },
7755
+ required: ['category', 'totalExpense', 'sharePct', 'balanceByCurrency']
7756
+ } as const;
7757
+
7758
+ export const $ExpensesByCategorySummaryDto = {
7759
+ type: 'object',
7760
+ properties: {
7761
+ totalExpense: {
7762
+ type: 'string',
7763
+ description:
7764
+ 'Total across all categories, converted (convertible categories only); expense totals when flow=expense, income totals when flow=income',
7765
+ example: '5000.00'
7766
+ },
7767
+ categoryCount: {
7768
+ type: 'number',
7769
+ description: 'Number of categories',
7770
+ example: 8
7771
+ }
7772
+ },
7773
+ required: ['totalExpense', 'categoryCount']
7774
+ } as const;
7775
+
7776
+ export const $ExpensesByCategoryResponseDto = {
7777
+ type: 'object',
7778
+ properties: {
7779
+ period: {
7780
+ type: 'string',
7781
+ description: 'Period requested',
7782
+ example: '1m'
7783
+ },
7784
+ baseCurrency: {
7785
+ type: 'string',
7786
+ description: 'Base currency for converted values',
7787
+ example: 'CNY'
7788
+ },
7789
+ groups: {
7790
+ description:
7791
+ 'Expense groups by functional category, sorted by converted total desc',
7792
+ type: 'array',
7793
+ items: {
7794
+ $ref: '#/components/schemas/CategoryGroupDto'
7795
+ }
7796
+ },
7797
+ summary: {
7798
+ description: 'Summary statistics',
7799
+ allOf: [
7800
+ {
7801
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
7802
+ }
7803
+ ]
7804
+ },
7805
+ warnings: {
7806
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
7807
+ type: 'array',
7808
+ items: {
7809
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7810
+ }
7811
+ }
7812
+ },
7813
+ required: ['period', 'baseCurrency', 'groups', 'summary']
7814
+ } as const;
7815
+
7816
+ export const $MonetaryDto = {
7817
+ type: 'object',
7818
+ properties: {
7819
+ amount: {
7820
+ type: 'string',
7821
+ description: 'Amount (Decimal string)',
7822
+ example: '3000'
7823
+ },
7824
+ currency: {
7825
+ type: 'string',
7826
+ description: 'ISO 4217 currency',
7827
+ example: 'USD'
7828
+ },
7829
+ baseCcyEquivalent: {
7830
+ type: 'object',
7831
+ description: 'Converted to user base currency (Decimal string)',
7832
+ example: '21600',
7833
+ nullable: true
7834
+ }
7835
+ },
7836
+ required: ['amount', 'currency']
7837
+ } as const;
7838
+
7839
+ export const $CurrentPriceDto = {
7840
+ type: 'object',
7841
+ properties: {
7842
+ amount: {
7843
+ type: 'string',
7844
+ description: 'Price amount (Decimal string)',
7845
+ example: '250'
7846
+ },
7847
+ currency: {
7848
+ type: 'string',
7849
+ description: 'Price currency (ISO 4217)',
7850
+ example: 'USD'
7851
+ },
7852
+ date: {
7853
+ type: 'string',
7854
+ description: 'Price date (ISO 8601)',
7855
+ example: '2024-06-01'
7856
+ },
7857
+ source: {
7858
+ type: 'string',
7859
+ description: 'Price source',
7860
+ example: 'USER_OVERRIDE',
7861
+ enum: ['USER_OVERRIDE', 'OPENBB_EQUITY', 'OPENBB_CURRENCY']
7862
+ }
7863
+ },
7864
+ required: ['amount', 'currency', 'date', 'source']
7865
+ } as const;
7866
+
7867
+ export const $FxRateDto = {
7868
+ type: 'object',
7869
+ properties: {
7870
+ from: {
7871
+ type: 'string',
7872
+ example: 'USD'
7873
+ },
7874
+ to: {
7875
+ type: 'string',
7876
+ example: 'CNY'
7877
+ },
7878
+ rate: {
7879
+ type: 'string',
7880
+ description: 'FX rate (Decimal string)',
7881
+ example: '7.2'
7882
+ },
7883
+ date: {
7884
+ type: 'string',
7885
+ description: 'Rate date (ISO 8601)',
7886
+ example: '2024-01-15'
7887
+ }
7888
+ },
7889
+ required: ['from', 'to', 'rate', 'date']
7890
+ } as const;
7891
+
7892
+ export const $HoldingPnlRowDto = {
7893
+ type: 'object',
7894
+ properties: {
7895
+ accountId: {
7896
+ type: 'string',
7897
+ description: 'Account UUID',
7898
+ example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
7899
+ },
7900
+ accountPath: {
7901
+ type: 'string',
7902
+ description: 'Full account path',
7903
+ example: 'Assets:US:Broker:AAPL'
7904
+ },
7905
+ accountCcy: {
7906
+ type: 'object',
7907
+ description: 'Account settlement currency (ISO 4217), from cost currency',
7908
+ nullable: true,
7909
+ example: 'USD'
7910
+ },
7911
+ brokerType: {
7912
+ type: 'object',
7913
+ description: 'Broker type derived from Platform.type',
7914
+ nullable: true,
7915
+ example: 'broker'
7916
+ },
7917
+ symbol: {
7918
+ type: 'string',
7919
+ description: 'Commodity symbol',
7920
+ example: 'AAPL'
7921
+ },
7922
+ chartToken: {
7923
+ type: 'string',
7924
+ description: 'Chart segment token (libs/common resolver)',
7925
+ example: 'equity',
7926
+ enum: ['equity', 'fund', 'bond', 'cash', 'other']
7927
+ },
7928
+ assetClass: {
7929
+ type: 'string',
7930
+ example: 'EQUITY'
7931
+ },
7932
+ assetSubClass: {
7933
+ type: 'object',
7934
+ nullable: true,
7935
+ example: 'STOCK'
7936
+ },
7937
+ units: {
7938
+ type: 'string',
7939
+ description: 'Net held units (Decimal string)',
7940
+ example: '12'
7941
+ },
7942
+ averageCostPerUnit: {
7943
+ description:
7944
+ 'Average cost per unit; null when cost currency conflicts or no cost',
7945
+ nullable: true,
7946
+ allOf: [
7947
+ {
7948
+ $ref: '#/components/schemas/MonetaryDto'
7949
+ }
7950
+ ]
7951
+ },
7952
+ costBasis: {
7953
+ description: 'Cost basis of held units',
7954
+ nullable: true,
7955
+ allOf: [
7956
+ {
7957
+ $ref: '#/components/schemas/MonetaryDto'
7958
+ }
7959
+ ]
7960
+ },
7961
+ marketValue: {
7962
+ description: 'Market value at asOf price',
7963
+ nullable: true,
7964
+ allOf: [
7965
+ {
7966
+ $ref: '#/components/schemas/MonetaryDto'
7967
+ }
7968
+ ]
7969
+ },
7970
+ currentPrice: {
7971
+ description: 'Price used for market value',
7972
+ nullable: true,
7973
+ allOf: [
7974
+ {
7975
+ $ref: '#/components/schemas/CurrentPriceDto'
7976
+ }
7977
+ ]
7978
+ },
7979
+ unrealizedPnlBase: {
7980
+ type: 'object',
7981
+ description:
7982
+ 'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
7983
+ nullable: true,
7984
+ example: '6000'
7985
+ },
7986
+ unrealizedPnlPct: {
7987
+ type: 'object',
7988
+ description: 'Unrealized P&L % (Decimal string)',
7989
+ nullable: true,
7990
+ example: '25'
7991
+ },
7992
+ costFxRate: {
7993
+ description: 'Historical FX rate applied to cost basis',
7994
+ nullable: true,
7995
+ allOf: [
7996
+ {
7997
+ $ref: '#/components/schemas/FxRateDto'
6026
7998
  }
6027
7999
  ]
6028
8000
  },
6029
- converted: {
6030
- description: 'Converted values in base currency',
8001
+ marketFxRate: {
8002
+ description: 'FX rate applied to market value',
8003
+ nullable: true,
6031
8004
  allOf: [
6032
8005
  {
6033
- $ref: '#/components/schemas/ConvertedCashFlowDto'
8006
+ $ref: '#/components/schemas/FxRateDto'
6034
8007
  }
6035
8008
  ]
6036
8009
  },
6037
- warnings: {
6038
- description: 'Exchange rate warnings',
6039
- type: 'array',
6040
- items: {
6041
- $ref: '#/components/schemas/ExchangeRateWarningDto'
6042
- }
8010
+ pctOfInvestedAssets: {
8011
+ type: 'object',
8012
+ description:
8013
+ 'Share of invested assets % (Decimal string); only for invested chartTokens',
8014
+ nullable: true,
8015
+ example: '40'
8016
+ },
8017
+ realizedPnl: {
8018
+ description:
8019
+ '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',
8020
+ nullable: true,
8021
+ allOf: [
8022
+ {
8023
+ $ref: '#/components/schemas/MonetaryDto'
8024
+ }
8025
+ ]
6043
8026
  }
6044
8027
  },
6045
8028
  required: [
6046
- 'period',
6047
- 'income',
6048
- 'expense',
6049
- 'netSavings',
6050
- 'savingsRate',
6051
- 'currency'
8029
+ 'accountId',
8030
+ 'accountPath',
8031
+ 'symbol',
8032
+ 'chartToken',
8033
+ 'assetClass',
8034
+ 'units'
6052
8035
  ]
6053
8036
  } as const;
6054
8037
 
6055
- export const $CurrencyBalanceDto = {
8038
+ export const $HoldingPnlWarningDto = {
6056
8039
  type: 'object',
6057
8040
  properties: {
6058
- currency: {
8041
+ type: {
6059
8042
  type: 'string',
6060
- description: 'ISO 4217 currency code',
6061
- example: 'CNY'
8043
+ description: 'Warning type',
8044
+ example: 'MISSING_COST_FX_RATE',
8045
+ enum: [
8046
+ 'MISSING_COST_FX_RATE',
8047
+ 'MISSING_MARKET_FX_RATE',
8048
+ 'MISSING_SALE_PRICE',
8049
+ 'MISSING_REALIZED_FX_RATE',
8050
+ 'OVERSOLD_LOTS',
8051
+ 'NO_PRICE',
8052
+ 'MIXED_COST_CURRENCY'
8053
+ ]
6062
8054
  },
6063
- balance: {
6064
- type: 'string',
6065
- description: 'Balance amount',
6066
- example: '500000.00'
8055
+ symbol: {
8056
+ type: 'object',
8057
+ nullable: true
8058
+ },
8059
+ accountId: {
8060
+ type: 'object',
8061
+ nullable: true
8062
+ },
8063
+ currency: {
8064
+ type: 'object',
8065
+ nullable: true
6067
8066
  }
6068
8067
  },
6069
- required: ['currency', 'balance']
8068
+ required: ['type']
6070
8069
  } as const;
6071
8070
 
6072
- export const $TimeSeriesPointDto = {
8071
+ export const $HoldingPnlResponseDto = {
6073
8072
  type: 'object',
6074
8073
  properties: {
6075
- date: {
8074
+ asOfDate: {
6076
8075
  type: 'string',
6077
- description: 'Date in YYYY-MM-DD format',
6078
- example: '2024-06-15'
8076
+ example: '2026-07-08'
6079
8077
  },
6080
- value: {
8078
+ baseCurrency: {
6081
8079
  type: 'string',
6082
- description: 'Value at this date (in base currency)',
6083
- example: '500000.00'
8080
+ example: 'CNY'
6084
8081
  },
6085
- change: {
6086
- type: 'object',
6087
- description: 'Change from previous point',
6088
- example: '5000.00'
8082
+ method: {
8083
+ type: 'string',
8084
+ description:
8085
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
8086
+ enum: ['average', 'FIFO'],
8087
+ example: 'average'
6089
8088
  },
6090
- byCurrency: {
6091
- description: 'Multi-currency breakdown for this point',
8089
+ rows: {
6092
8090
  type: 'array',
6093
8091
  items: {
6094
- $ref: '#/components/schemas/CurrencyBalanceDto'
8092
+ $ref: '#/components/schemas/HoldingPnlRowDto'
8093
+ }
8094
+ },
8095
+ warnings: {
8096
+ type: 'array',
8097
+ items: {
8098
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
6095
8099
  }
6096
8100
  }
6097
8101
  },
6098
- required: ['date', 'value']
8102
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6099
8103
  } as const;
6100
8104
 
6101
- export const $TrendSummaryDto = {
8105
+ export const $AnonymousLoginDto = {
6102
8106
  type: 'object',
6103
8107
  properties: {
6104
- startValue: {
6105
- type: 'string',
6106
- description: 'Value at start of period',
6107
- example: '450000.00'
6108
- },
6109
- endValue: {
6110
- type: 'string',
6111
- description: 'Value at end of period',
6112
- example: '500000.00'
6113
- },
6114
- totalChange: {
6115
- type: 'string',
6116
- description: 'Total change over period',
6117
- example: '50000.00'
6118
- },
6119
- totalChangePercentage: {
8108
+ accessToken: {
6120
8109
  type: 'string',
6121
- description: 'Total change percentage',
6122
- example: '+11.11%'
8110
+ description: 'Access token for anonymous login'
6123
8111
  }
6124
8112
  },
6125
- required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
8113
+ required: ['accessToken']
6126
8114
  } as const;
6127
8115
 
6128
- export const $MultiCurrencyPointDto = {
8116
+ export const $AnonymousLoginResponseDto = {
6129
8117
  type: 'object',
6130
8118
  properties: {
6131
- date: {
8119
+ authToken: {
6132
8120
  type: 'string',
6133
- description: 'Date in YYYY-MM-DD format',
6134
- example: '2024-06-15'
6135
- },
6136
- byCurrency: {
6137
- description: 'Balances by currency',
6138
- type: 'array',
6139
- items: {
6140
- $ref: '#/components/schemas/CurrencyBalanceDto'
6141
- }
8121
+ description: 'JWT auth token',
8122
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
6142
8123
  }
6143
8124
  },
6144
- required: ['date', 'byCurrency']
8125
+ required: ['authToken']
6145
8126
  } as const;
6146
8127
 
6147
- export const $PortfolioTrendsResponseDto = {
8128
+ export const $SymbolSearchResultDto = {
6148
8129
  type: 'object',
6149
8130
  properties: {
6150
- series: {
6151
- description: 'Time series data points',
6152
- type: 'array',
6153
- items: {
6154
- $ref: '#/components/schemas/TimeSeriesPointDto'
6155
- }
8131
+ symbol: {
8132
+ type: 'string',
8133
+ example: 'AAPL'
6156
8134
  },
6157
- summary: {
6158
- description: 'Period summary',
6159
- allOf: [
6160
- {
6161
- $ref: '#/components/schemas/TrendSummaryDto'
6162
- }
6163
- ]
8135
+ name: {
8136
+ type: 'object',
8137
+ example: 'Apple Inc.',
8138
+ nullable: true
6164
8139
  },
6165
- period: {
6166
- type: 'string',
6167
- description: 'Period requested',
6168
- example: '6m'
8140
+ exchange: {
8141
+ type: 'object',
8142
+ example: 'US',
8143
+ nullable: true
6169
8144
  },
6170
- granularity: {
6171
- type: 'string',
6172
- description: 'Data granularity',
6173
- example: 'month'
8145
+ assetType: {
8146
+ type: 'object',
8147
+ description: 'OpenBB asset_type (e.g. stock, etf)',
8148
+ example: 'stock',
8149
+ nullable: true
6174
8150
  },
6175
- currency: {
6176
- type: 'string',
6177
- description: 'Base currency for converted values',
6178
- example: 'CNY'
8151
+ assetClass: {
8152
+ type: 'object',
8153
+ description: 'IGN asset class (region.types.ts ASSET_CLASSES)',
8154
+ example: 'EQUITY',
8155
+ nullable: true
6179
8156
  },
6180
- byCurrency: {
6181
- description:
6182
- 'Multi-currency time series (each point has currency breakdown)',
6183
- type: 'array',
6184
- items: {
6185
- $ref: '#/components/schemas/MultiCurrencyPointDto'
6186
- }
8157
+ assetSubClass: {
8158
+ type: 'object',
8159
+ description: 'IGN asset sub-class (region.types.ts ASSET_SUB_CLASSES)',
8160
+ example: 'STOCK',
8161
+ nullable: true
6187
8162
  },
6188
- warnings: {
6189
- description: 'Exchange rate warnings',
6190
- type: 'array',
6191
- items: {
6192
- $ref: '#/components/schemas/ExchangeRateWarningDto'
6193
- }
8163
+ currency: {
8164
+ type: 'object',
8165
+ description: 'Trading currency (extra_data or inferred from exchange)',
8166
+ example: 'USD',
8167
+ nullable: true
6194
8168
  }
6195
8169
  },
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: {}
8170
+ required: ['symbol']
6217
8171
  } as const;
6218
8172
 
6219
- export const $AnonymousLoginDto = {
8173
+ export const $SymbolQuoteDto = {
6220
8174
  type: 'object',
6221
8175
  properties: {
6222
- accessToken: {
8176
+ symbol: {
6223
8177
  type: 'string',
6224
- description: 'Access token for anonymous login'
8178
+ example: 'AAPL'
8179
+ },
8180
+ name: {
8181
+ type: 'object',
8182
+ example: 'Apple Inc.',
8183
+ nullable: true
8184
+ },
8185
+ exchange: {
8186
+ type: 'object',
8187
+ example: 'US',
8188
+ nullable: true
8189
+ },
8190
+ assetType: {
8191
+ type: 'object',
8192
+ description: 'OpenBB asset_type',
8193
+ example: 'stock',
8194
+ nullable: true
8195
+ },
8196
+ assetClass: {
8197
+ type: 'object',
8198
+ description: 'IGN asset class',
8199
+ example: 'EQUITY',
8200
+ nullable: true
8201
+ },
8202
+ assetSubClass: {
8203
+ type: 'object',
8204
+ description: 'IGN asset sub-class',
8205
+ example: 'STOCK',
8206
+ nullable: true
8207
+ },
8208
+ currency: {
8209
+ type: 'object',
8210
+ description: 'Trading currency (extra_data or inferred from exchange)',
8211
+ example: 'USD',
8212
+ nullable: true
8213
+ },
8214
+ price: {
8215
+ type: 'object',
8216
+ description: 'Latest price (Decimal string)',
8217
+ example: '189.84',
8218
+ nullable: true
8219
+ },
8220
+ priceDate: {
8221
+ type: 'object',
8222
+ description: 'Date the price was observed (ISO yyyy-MM-dd)',
8223
+ example: '2026-08-05',
8224
+ nullable: true
8225
+ },
8226
+ changePercent: {
8227
+ type: 'object',
8228
+ description:
8229
+ 'Change vs previous close, in percentage points (1.7 == 1.7%). openbb stores change_percent as a normalized decimal; this exposes percentage points for frontend convenience.',
8230
+ example: 1.7,
8231
+ nullable: true
8232
+ },
8233
+ prevClose: {
8234
+ type: 'object',
8235
+ description: 'Previous close (Decimal string)',
8236
+ nullable: true
8237
+ },
8238
+ open: {
8239
+ type: 'object',
8240
+ description: 'Day open (Decimal string)',
8241
+ nullable: true
8242
+ },
8243
+ high: {
8244
+ type: 'object',
8245
+ description: 'Day high (Decimal string)',
8246
+ nullable: true
8247
+ },
8248
+ low: {
8249
+ type: 'object',
8250
+ description: 'Day low (Decimal string)',
8251
+ nullable: true
8252
+ },
8253
+ volume: {
8254
+ type: 'object',
8255
+ description: 'Day volume (Decimal string)',
8256
+ nullable: true
8257
+ },
8258
+ yearHigh: {
8259
+ type: 'object',
8260
+ description: '52-week high (Decimal string)',
8261
+ nullable: true
8262
+ },
8263
+ yearLow: {
8264
+ type: 'object',
8265
+ description: '52-week low (Decimal string)',
8266
+ nullable: true
6225
8267
  }
6226
- },
6227
- required: ['accessToken']
8268
+ }
6228
8269
  } as const;