@firela/api-types 0.0.0-canary.209966 → 0.0.0-canary.2b7765ff

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.
@@ -8,6 +8,12 @@ export const $CreateAccountDto = {
8
8
  description: 'Account path (hierarchical, colon-separated)',
9
9
  example: 'Assets:CN:Bank:ICBC:Checking'
10
10
  },
11
+ displayName: {
12
+ type: 'string',
13
+ description:
14
+ 'Display name to distinguish accounts at the same path (default: "")',
15
+ example: '工资卡'
16
+ },
11
17
  openDate: {
12
18
  format: 'date-time',
13
19
  type: 'string',
@@ -86,6 +92,12 @@ export const $AccountResponseDto = {
86
92
  description: 'Account path (hierarchical, colon-separated)',
87
93
  example: 'Assets:CN:Bank:ICBC:Checking'
88
94
  },
95
+ displayName: {
96
+ type: 'string',
97
+ description:
98
+ 'Display name distinguishing multiple accounts at the same path',
99
+ example: '工资卡'
100
+ },
89
101
  type: {
90
102
  type: 'string',
91
103
  description: 'Account type (root segment)',
@@ -180,6 +192,7 @@ export const $AccountResponseDto = {
180
192
  required: [
181
193
  'id',
182
194
  'path',
195
+ 'displayName',
183
196
  'type',
184
197
  'status',
185
198
  'openDate',
@@ -212,6 +225,11 @@ export const $AccountListResponseDto = {
212
225
  export const $UpdateAccountDto = {
213
226
  type: 'object',
214
227
  properties: {
228
+ displayName: {
229
+ type: 'string',
230
+ description: 'Display name to distinguish accounts at the same path',
231
+ example: '招行工资卡'
232
+ },
215
233
  currencies: {
216
234
  description: 'Allowed currencies (null = no restriction)',
217
235
  example: ['CNY', 'USD'],
@@ -251,7 +269,7 @@ export const $UpdateAccountDto = {
251
269
  }
252
270
  },
253
271
  platformId: {
254
- type: 'object',
272
+ type: 'string',
255
273
  description:
256
274
  'Platform ID (references Platform.id), null to clear association',
257
275
  example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2',
@@ -292,6 +310,222 @@ export const $ReopenAccountDto = {
292
310
  }
293
311
  } as const;
294
312
 
313
+ export const $AccountStandardResponseDto = {
314
+ type: 'object',
315
+ properties: {
316
+ path: {
317
+ type: 'string',
318
+ description: 'Account path (hierarchical, colon-separated)',
319
+ example: 'Assets:CN:Bank:ICBC:Checking'
320
+ },
321
+ type: {
322
+ type: 'string',
323
+ description: 'Account type in Beancount hierarchy',
324
+ enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
325
+ example: 'Assets'
326
+ },
327
+ i18nKey: {
328
+ type: 'string',
329
+ description: 'i18n key for localized display name',
330
+ example: 'account.assets.cn.bank.icbc.checking'
331
+ },
332
+ name: {
333
+ type: 'string',
334
+ description: 'Short localized display name',
335
+ example: 'Housing Fund'
336
+ },
337
+ description: {
338
+ type: 'string',
339
+ description: 'Account description (stable semantics only)',
340
+ example: 'ICBC checking account for daily transactions'
341
+ },
342
+ tags: {
343
+ description: 'Account tags for categorization',
344
+ example: ['bank', 'checking', 'primary'],
345
+ type: 'array',
346
+ items: {
347
+ type: 'string'
348
+ }
349
+ },
350
+ icon: {
351
+ type: 'string',
352
+ description: 'Icon identifier for UI display',
353
+ example: 'bank-icbc'
354
+ }
355
+ },
356
+ required: ['path', 'type', 'i18nKey', 'description', 'tags', 'icon']
357
+ } as const;
358
+
359
+ export const $AccountStandardListResponseDto = {
360
+ type: 'object',
361
+ properties: {
362
+ items: {
363
+ description: 'Array of account templates',
364
+ type: 'array',
365
+ items: {
366
+ $ref: '#/components/schemas/AccountStandardResponseDto'
367
+ }
368
+ },
369
+ total: {
370
+ type: 'number',
371
+ description: 'Total number of account templates',
372
+ example: 150
373
+ },
374
+ region: {
375
+ type: 'string',
376
+ description: 'Region code',
377
+ example: 'CN'
378
+ }
379
+ },
380
+ required: ['items', 'total', 'region']
381
+ } as const;
382
+
383
+ export const $TemplateMetadataDto = {
384
+ type: 'object',
385
+ properties: {
386
+ extendable: {
387
+ type: 'boolean',
388
+ description: 'Whether this path can be extended',
389
+ example: true
390
+ },
391
+ rootType: {
392
+ type: 'string',
393
+ description: 'Root account type',
394
+ example: 'Assets'
395
+ }
396
+ },
397
+ required: ['extendable', 'rootType']
398
+ } as const;
399
+
400
+ export const $TemplateMetadataResponseDto = {
401
+ type: 'object',
402
+ properties: {
403
+ metadata: {
404
+ $ref: '#/components/schemas/TemplateMetadataDto'
405
+ }
406
+ }
407
+ } as const;
408
+
409
+ export const $RegionConfigDto = {
410
+ type: 'object',
411
+ properties: {
412
+ currency: {
413
+ type: 'string',
414
+ example: 'EUR'
415
+ },
416
+ dateFormat: {
417
+ type: 'string',
418
+ example: 'DD.MM.YYYY'
419
+ },
420
+ locale: {
421
+ type: 'string',
422
+ example: 'de-DE'
423
+ }
424
+ },
425
+ required: ['currency', 'dateFormat', 'locale']
426
+ } as const;
427
+
428
+ export const $RegionInfoDto = {
429
+ type: 'object',
430
+ properties: {
431
+ code: {
432
+ type: 'string',
433
+ example: 'de'
434
+ },
435
+ displayName: {
436
+ type: 'string',
437
+ example: 'Germany'
438
+ },
439
+ parent: {
440
+ type: 'string'
441
+ },
442
+ chain: {
443
+ example: ['de'],
444
+ type: 'array',
445
+ items: {
446
+ type: 'string'
447
+ }
448
+ },
449
+ config: {
450
+ $ref: '#/components/schemas/RegionConfigDto'
451
+ }
452
+ },
453
+ required: ['code', 'displayName', 'chain', 'config']
454
+ } as const;
455
+
456
+ export const $RegionsMetadataResponseDto = {
457
+ type: 'object',
458
+ properties: {
459
+ regions: {
460
+ type: 'array',
461
+ items: {
462
+ $ref: '#/components/schemas/RegionInfoDto'
463
+ }
464
+ }
465
+ },
466
+ required: ['regions']
467
+ } as const;
468
+
469
+ export const $CostSpecDto = {
470
+ type: 'object',
471
+ properties: {
472
+ mode: {
473
+ type: 'string',
474
+ enum: ['per-unit', 'total', 'date', 'label', 'auto'],
475
+ description: 'Cost specification mode (mirrors engine CostSpec)'
476
+ },
477
+ numberPerUnit: {
478
+ type: 'string',
479
+ description: 'Per-unit cost (required when mode is "per-unit")',
480
+ example: '240'
481
+ },
482
+ totalNumber: {
483
+ type: 'string',
484
+ description: 'Total cost for all units (required when mode is "total")',
485
+ example: '12000'
486
+ },
487
+ currency: {
488
+ type: 'string',
489
+ description: 'Cost currency (required in all modes)',
490
+ example: 'USD'
491
+ },
492
+ date: {
493
+ type: 'string',
494
+ description:
495
+ 'Lot acquisition date, ISO 8601 (required when mode is "date")',
496
+ example: '2024-01-15'
497
+ },
498
+ label: {
499
+ type: 'string',
500
+ description:
501
+ 'Lot label (required when mode is "label"; optional tag in buy modes)'
502
+ },
503
+ merge: {
504
+ type: 'boolean',
505
+ description: 'Merge lots for AVERAGE booking (mode: auto)'
506
+ }
507
+ },
508
+ required: ['mode', 'currency']
509
+ } as const;
510
+
511
+ export const $AmountDto = {
512
+ type: 'object',
513
+ properties: {
514
+ number: {
515
+ type: 'string',
516
+ description:
517
+ 'Amount as decimal string (max 15 integer + 15 decimal digits)',
518
+ example: '170.50'
519
+ },
520
+ currency: {
521
+ type: 'string',
522
+ description: 'Currency/commodity code',
523
+ example: 'USD'
524
+ }
525
+ },
526
+ required: ['number', 'currency']
527
+ } as const;
528
+
295
529
  export const $CreatePostingDto = {
296
530
  type: 'object',
297
531
  properties: {
@@ -321,6 +555,33 @@ export const $CreatePostingDto = {
321
555
  example: {
322
556
  'tax-lot': 'Q1-2024'
323
557
  }
558
+ },
559
+ cost: {
560
+ description:
561
+ 'Cost basis (Beancount `{...}`). Maps to engine costSpec. Required for commodity holdings so they carry a monetary weight that can balance.',
562
+ example: {
563
+ mode: 'per-unit',
564
+ numberPerUnit: '240',
565
+ currency: 'USD'
566
+ },
567
+ allOf: [
568
+ {
569
+ $ref: '#/components/schemas/CostSpecDto'
570
+ }
571
+ ]
572
+ },
573
+ price: {
574
+ description:
575
+ 'Price annotation (Beancount `@...`). Maps to engine price. Used for valuation; cost takes priority for balance weight.',
576
+ example: {
577
+ number: '170',
578
+ currency: 'USD'
579
+ },
580
+ allOf: [
581
+ {
582
+ $ref: '#/components/schemas/AmountDto'
583
+ }
584
+ ]
324
585
  }
325
586
  },
326
587
  required: ['account']
@@ -409,7 +670,8 @@ export const $PostingResponseDto = {
409
670
  },
410
671
  units: {
411
672
  type: 'string',
412
- description: 'Amount (may be null if interpolated)',
673
+ description:
674
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
413
675
  example: '100.50'
414
676
  },
415
677
  currency: {
@@ -607,38 +869,177 @@ export const $ApiProblemResponseDto = {
607
869
  required: ['type', 'title', 'status', 'detail']
608
870
  } as const;
609
871
 
610
- export const $PostingDetailDto = {
872
+ export const $BatchCreateTransactionDto = {
611
873
  type: 'object',
612
874
  properties: {
613
- id: {
614
- type: 'string',
615
- description: 'Posting ID',
616
- example: 'clh1234567890abcdef'
875
+ transactions: {
876
+ description: 'Array of transactions to create',
877
+ minItems: 1,
878
+ maxItems: 100,
879
+ type: 'array',
880
+ items: {
881
+ $ref: '#/components/schemas/CreateTransactionDto'
882
+ }
883
+ }
884
+ },
885
+ required: ['transactions']
886
+ } as const;
887
+
888
+ export const $BatchTransactionErrorDto = {
889
+ type: 'object',
890
+ properties: {
891
+ index: {
892
+ type: 'number',
893
+ description: 'Index of failed transaction in the input array',
894
+ example: 0
617
895
  },
618
- accountId: {
896
+ error: {
619
897
  type: 'string',
620
- description: 'Account ID',
621
- example: 'clh1234567890abcdef'
898
+ description: 'Error message describing the failure',
899
+ example: 'Transaction does not balance'
622
900
  },
623
- accountName: {
901
+ errorCode: {
624
902
  type: 'string',
625
- description: 'Account name',
626
- example: 'Assets:Bank:Checking'
903
+ description: 'Structured error code for programmatic handling',
904
+ example: 'INSUFFICIENT_QUANTITY'
905
+ }
906
+ },
907
+ required: ['index', 'error']
908
+ } as const;
909
+
910
+ export const $BatchTransactionResponseDto = {
911
+ type: 'object',
912
+ properties: {
913
+ succeeded: {
914
+ description: 'Successfully created transactions',
915
+ type: 'array',
916
+ items: {
917
+ $ref: '#/components/schemas/TransactionResponseDto'
918
+ }
627
919
  },
628
- units: {
920
+ failed: {
921
+ description: 'Failed transactions with error details',
922
+ type: 'array',
923
+ items: {
924
+ $ref: '#/components/schemas/BatchTransactionErrorDto'
925
+ }
926
+ }
927
+ },
928
+ required: ['succeeded', 'failed']
929
+ } as const;
930
+
931
+ export const $CorrectTransactionDto = {
932
+ type: 'object',
933
+ properties: {
934
+ date: {
629
935
  type: 'string',
630
- description: 'Amount (may be null if interpolated)',
631
- example: '100.50'
936
+ description: 'Transaction date (ISO 8601 format)',
937
+ example: '2024-11-28'
632
938
  },
633
- currency: {
939
+ flag: {
634
940
  type: 'string',
635
- description: 'Currency',
636
- example: 'USD'
941
+ description: 'Transaction flag: * (cleared), ! (pending)',
942
+ enum: ['*', '!'],
943
+ example: '*'
637
944
  },
638
- costAmount: {
945
+ payee: {
639
946
  type: 'string',
640
- description: 'Cost amount',
641
- example: '98.00'
947
+ description: 'Payee name',
948
+ example: 'Whole Foods Market'
949
+ },
950
+ narration: {
951
+ type: 'string',
952
+ description: 'Transaction narration/description',
953
+ example: 'Grocery shopping'
954
+ },
955
+ tags: {
956
+ description: 'Transaction tags (without # prefix)',
957
+ example: ['vacation', 'personal'],
958
+ type: 'array',
959
+ items: {
960
+ type: 'string'
961
+ }
962
+ },
963
+ links: {
964
+ description: 'Transaction links (without ^ prefix)',
965
+ example: ['invoice-123'],
966
+ type: 'array',
967
+ items: {
968
+ type: 'string'
969
+ }
970
+ },
971
+ postings: {
972
+ description:
973
+ 'Transaction postings (minimum 1, typically 2 for double-entry)',
974
+ type: 'array',
975
+ items: {
976
+ $ref: '#/components/schemas/CreatePostingDto'
977
+ }
978
+ },
979
+ meta: {
980
+ type: 'object',
981
+ description: 'Transaction-level metadata',
982
+ example: {
983
+ invoice: '12345'
984
+ }
985
+ },
986
+ idempotencyKey: {
987
+ type: 'string',
988
+ description:
989
+ 'Unique key for idempotent transaction creation. If provided, duplicate requests with the same key will return the existing transaction.',
990
+ example: 'import-2024-01-15-batch-001',
991
+ maxLength: 128
992
+ },
993
+ autoCreateAccounts: {
994
+ type: 'boolean',
995
+ description:
996
+ '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.',
997
+ default: true,
998
+ example: true
999
+ },
1000
+ correctionReason: {
1001
+ type: 'string',
1002
+ description: 'Reason for correcting/superseding the original transaction',
1003
+ example: 'Wrong amount — corrected from receipt',
1004
+ maxLength: 500
1005
+ }
1006
+ },
1007
+ required: ['date', 'narration', 'postings']
1008
+ } as const;
1009
+
1010
+ export const $PostingDetailDto = {
1011
+ type: 'object',
1012
+ properties: {
1013
+ id: {
1014
+ type: 'string',
1015
+ description: 'Posting ID',
1016
+ example: 'clh1234567890abcdef'
1017
+ },
1018
+ accountId: {
1019
+ type: 'string',
1020
+ description: 'Account ID',
1021
+ example: 'clh1234567890abcdef'
1022
+ },
1023
+ account: {
1024
+ type: 'string',
1025
+ description: 'Fully-qualified Beancount account path',
1026
+ example: 'Assets:Bank:Checking'
1027
+ },
1028
+ units: {
1029
+ type: 'string',
1030
+ description:
1031
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
1032
+ example: '100.50'
1033
+ },
1034
+ currency: {
1035
+ type: 'string',
1036
+ description: 'Currency',
1037
+ example: 'USD'
1038
+ },
1039
+ costAmount: {
1040
+ type: 'string',
1041
+ description: 'Cost amount',
1042
+ example: '98.00'
642
1043
  },
643
1044
  costCurrency: {
644
1045
  type: 'string',
@@ -670,7 +1071,7 @@ export const $PostingDetailDto = {
670
1071
  description: 'Posting metadata'
671
1072
  }
672
1073
  },
673
- required: ['id', 'accountId', 'accountName']
1074
+ required: ['id', 'accountId', 'account']
674
1075
  } as const;
675
1076
 
676
1077
  export const $TransactionDetailDto = {
@@ -742,8 +1143,8 @@ export const $TransactionDetailDto = {
742
1143
  },
743
1144
  sourceType: {
744
1145
  type: 'string',
745
- description: 'Source type (how the transaction was created)',
746
- enum: ['NLP', 'CSV', 'OCR', 'API']
1146
+ description:
1147
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
747
1148
  },
748
1149
  sourcePlatform: {
749
1150
  type: 'string',
@@ -776,6 +1177,18 @@ export const $TransactionDetailDto = {
776
1177
  type: 'string',
777
1178
  description: 'Correction reason (if voided or superseded)',
778
1179
  example: 'Duplicate entry'
1180
+ },
1181
+ supersededBy: {
1182
+ type: 'string',
1183
+ description:
1184
+ 'ID of the transaction that supersedes this one (set when status=SUPERSEDED)',
1185
+ example: 'clh1234567890abcdef'
1186
+ },
1187
+ originalTxn: {
1188
+ type: 'string',
1189
+ description:
1190
+ 'ID of the transaction this one corrected/replaced (back-link on the replacement)',
1191
+ example: 'clh1234567890abcdef'
779
1192
  }
780
1193
  },
781
1194
  required: [
@@ -819,6 +1232,37 @@ export const $TransactionListResponseDto = {
819
1232
  required: ['data', 'total', 'limit', 'offset']
820
1233
  } as const;
821
1234
 
1235
+ export const $TagSuggestionDto = {
1236
+ type: 'object',
1237
+ properties: {
1238
+ tag: {
1239
+ type: 'string',
1240
+ description: 'Tag name',
1241
+ example: 'Monthly'
1242
+ },
1243
+ count: {
1244
+ type: 'number',
1245
+ description: 'Usage count across ACTIVE transactions',
1246
+ example: 12
1247
+ }
1248
+ },
1249
+ required: ['tag', 'count']
1250
+ } as const;
1251
+
1252
+ export const $TagSuggestionsResponseDto = {
1253
+ type: 'object',
1254
+ properties: {
1255
+ data: {
1256
+ description: 'Tag suggestions sorted as requested',
1257
+ type: 'array',
1258
+ items: {
1259
+ $ref: '#/components/schemas/TagSuggestionDto'
1260
+ }
1261
+ }
1262
+ },
1263
+ required: ['data']
1264
+ } as const;
1265
+
822
1266
  export const $UpdateTransactionDto = {
823
1267
  type: 'object',
824
1268
  properties: {
@@ -876,71 +1320,6 @@ export const $UpdateTransactionDto = {
876
1320
  }
877
1321
  } as const;
878
1322
 
879
- export const $AccountStandardResponseDto = {
880
- type: 'object',
881
- properties: {
882
- path: {
883
- type: 'string',
884
- description: 'Account path (hierarchical, colon-separated)',
885
- example: 'Assets:CN:Bank:ICBC:Checking'
886
- },
887
- type: {
888
- type: 'string',
889
- description: 'Account type in Beancount hierarchy',
890
- enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
891
- example: 'Assets'
892
- },
893
- i18nKey: {
894
- type: 'string',
895
- description: 'i18n key for localized display name',
896
- example: 'account.assets.cn.bank.icbc.checking'
897
- },
898
- description: {
899
- type: 'string',
900
- description: 'Account description',
901
- example: 'ICBC checking account for daily transactions'
902
- },
903
- tags: {
904
- description: 'Account tags for categorization',
905
- example: ['bank', 'checking', 'primary'],
906
- type: 'array',
907
- items: {
908
- type: 'string'
909
- }
910
- },
911
- icon: {
912
- type: 'string',
913
- description: 'Icon identifier for UI display',
914
- example: 'bank-icbc'
915
- }
916
- },
917
- required: ['path', 'type']
918
- } as const;
919
-
920
- export const $AccountStandardListResponseDto = {
921
- type: 'object',
922
- properties: {
923
- items: {
924
- description: 'Array of account templates',
925
- type: 'array',
926
- items: {
927
- $ref: '#/components/schemas/AccountStandardResponseDto'
928
- }
929
- },
930
- total: {
931
- type: 'number',
932
- description: 'Total number of account templates',
933
- example: 150
934
- },
935
- region: {
936
- type: 'string',
937
- description: 'Region code',
938
- example: 'CN'
939
- }
940
- },
941
- required: ['items', 'total', 'region']
942
- } as const;
943
-
944
1323
  export const $BalanceResponseDto = {
945
1324
  type: 'object',
946
1325
  properties: {
@@ -1034,8 +1413,8 @@ export const $TransactionSummaryDto = {
1034
1413
  },
1035
1414
  sourceType: {
1036
1415
  type: 'string',
1037
- description: 'Source type (NLP, CSV, OCR, API)',
1038
- enum: ['NLP', 'CSV', 'OCR', 'API']
1416
+ description:
1417
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1039
1418
  },
1040
1419
  sourcePlatform: {
1041
1420
  type: 'string',
@@ -1075,12 +1454,23 @@ export const $ReviewSummaryDto = {
1075
1454
  },
1076
1455
  confidenceLevel: {
1077
1456
  type: 'string',
1078
- description: 'Confidence level derived from score',
1079
- enum: ['HIGH', 'MEDIUM', 'LOW']
1457
+ description:
1458
+ 'Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.',
1459
+ enum: ['HIGH', 'MEDIUM', 'LOW'],
1460
+ nullable: true
1080
1461
  },
1081
- summary: {
1462
+ summaryKey: {
1082
1463
  type: 'string',
1083
- description: 'Human-readable summary of the review item'
1464
+ description:
1465
+ 'i18n message key for summary (e.g., review.summary.duplicate). Translate on frontend with summaryParams.'
1466
+ },
1467
+ summaryParams: {
1468
+ type: 'object',
1469
+ description:
1470
+ 'Parameters for summary message interpolation (e.g., { date: "2024-01-15", amount: "50" })',
1471
+ additionalProperties: {
1472
+ type: 'string'
1473
+ }
1084
1474
  },
1085
1475
  matchReasons: {
1086
1476
  description: 'Human-readable reasons for branching',
@@ -1091,7 +1481,8 @@ export const $ReviewSummaryDto = {
1091
1481
  },
1092
1482
  sourceType: {
1093
1483
  type: 'string',
1094
- description: 'Source type (NLP, CSV, OCR, API)'
1484
+ description:
1485
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1095
1486
  },
1096
1487
  sourcePlatform: {
1097
1488
  type: 'string',
@@ -1140,7 +1531,7 @@ export const $ReviewSummaryDto = {
1140
1531
  'status',
1141
1532
  'confidence',
1142
1533
  'confidenceLevel',
1143
- 'summary',
1534
+ 'summaryKey',
1144
1535
  'matchReasons',
1145
1536
  'sourceType',
1146
1537
  'createdAt'
@@ -1201,7 +1592,20 @@ export const $DecisionOptionDto = {
1201
1592
  properties: {
1202
1593
  value: {
1203
1594
  type: 'string',
1204
- description: 'The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)'
1595
+ description: 'The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)',
1596
+ enum: [
1597
+ 'UPGRADE_REPLACE',
1598
+ 'LINK_KEEP_BOTH',
1599
+ 'IGNORE_NEW',
1600
+ 'CONFIRM_DIFFERENT',
1601
+ 'ACCEPT',
1602
+ 'REJECT',
1603
+ 'ACCEPT_AND_LEARN',
1604
+ 'CHOOSE_OTHER',
1605
+ 'CANCEL',
1606
+ 'FIX',
1607
+ 'IGNORE'
1608
+ ]
1205
1609
  },
1206
1610
  labelKey: {
1207
1611
  type: 'string',
@@ -1249,12 +1653,23 @@ export const $ReviewDetailDto = {
1249
1653
  },
1250
1654
  confidenceLevel: {
1251
1655
  type: 'string',
1252
- description: 'Confidence level derived from score',
1253
- enum: ['HIGH', 'MEDIUM', 'LOW']
1656
+ description:
1657
+ 'Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.',
1658
+ enum: ['HIGH', 'MEDIUM', 'LOW'],
1659
+ nullable: true
1254
1660
  },
1255
- summary: {
1661
+ summaryKey: {
1256
1662
  type: 'string',
1257
- description: 'Human-readable summary of the review item'
1663
+ description:
1664
+ 'i18n message key for summary (e.g., review.summary.duplicate). Translate on frontend with summaryParams.'
1665
+ },
1666
+ summaryParams: {
1667
+ type: 'object',
1668
+ description:
1669
+ 'Parameters for summary message interpolation (e.g., { date: "2024-01-15", amount: "50" })',
1670
+ additionalProperties: {
1671
+ type: 'string'
1672
+ }
1258
1673
  },
1259
1674
  matchReasons: {
1260
1675
  description: 'Human-readable reasons for branching',
@@ -1265,7 +1680,8 @@ export const $ReviewDetailDto = {
1265
1680
  },
1266
1681
  sourceType: {
1267
1682
  type: 'string',
1268
- description: 'Source type (NLP, CSV, OCR, API)'
1683
+ description:
1684
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1269
1685
  },
1270
1686
  sourcePlatform: {
1271
1687
  type: 'string',
@@ -1330,7 +1746,7 @@ export const $ReviewDetailDto = {
1330
1746
  'status',
1331
1747
  'confidence',
1332
1748
  'confidenceLevel',
1333
- 'summary',
1749
+ 'summaryKey',
1334
1750
  'matchReasons',
1335
1751
  'sourceType',
1336
1752
  'createdAt',
@@ -1339,53 +1755,255 @@ export const $ReviewDetailDto = {
1339
1755
  ]
1340
1756
  } as const;
1341
1757
 
1342
- export const $PayeeResponseDto = {
1758
+ export const $ResolveReviewDto = {
1343
1759
  type: 'object',
1344
1760
  properties: {
1345
- id: {
1761
+ action: {
1346
1762
  type: 'string',
1347
- description: 'Unique identifier (UUID)',
1348
- example: 'uuid-123-456'
1763
+ description:
1764
+ 'Decision action. Valid actions vary by review type — see DecisionOptionDto.value returned by the review detail endpoint.',
1765
+ enum: [
1766
+ 'UPGRADE_REPLACE',
1767
+ 'LINK_KEEP_BOTH',
1768
+ 'IGNORE_NEW',
1769
+ 'CONFIRM_DIFFERENT',
1770
+ 'ACCEPT',
1771
+ 'REJECT',
1772
+ 'ACCEPT_AND_LEARN',
1773
+ 'CHOOSE_OTHER',
1774
+ 'CANCEL',
1775
+ 'FIX',
1776
+ 'IGNORE'
1777
+ ],
1778
+ example: 'ACCEPT'
1349
1779
  },
1350
- userId: {
1351
- type: 'string',
1352
- description: 'User ID (owner of this payee mapping)',
1353
- example: 'user-123'
1780
+ data: {
1781
+ type: 'object',
1782
+ description:
1783
+ 'Additional data for the decision (e.g., selected account ID)',
1784
+ example: {
1785
+ accountId: 'acc-123'
1786
+ }
1787
+ }
1788
+ },
1789
+ required: ['action']
1790
+ } as const;
1791
+
1792
+ export const $ResolveResultDto = {
1793
+ type: 'object',
1794
+ properties: {
1795
+ success: {
1796
+ type: 'boolean',
1797
+ description: 'Whether resolution was successful'
1354
1798
  },
1355
- payee: {
1799
+ messageKey: {
1356
1800
  type: 'string',
1357
- description: "User's original payee name (e.g., 'Starbucks', 'McDonald')",
1358
- example: 'Starbucks'
1359
- },
1360
- payeeProfileId: {
1361
- type: 'object',
1362
1801
  description:
1363
- 'Reference to global PayeeProfile (merchant info, i18n keys, categories)',
1364
- example: 'uuid-789',
1365
- nullable: true
1802
+ 'i18n message key for result message (e.g., review.payee.result.mapped)'
1366
1803
  },
1367
- customCategory: {
1804
+ messageParams: {
1368
1805
  type: 'object',
1369
1806
  description:
1370
- "User's custom category (overrides PayeeProfile category if set)",
1371
- example: 'Dining:Coffee',
1372
- nullable: true
1373
- },
1374
- customTags: {
1375
- description: "User's custom tags (e.g., ['favorite', 'work_meal'])",
1376
- example: ['favorite', 'work_meal'],
1377
- type: 'array',
1378
- items: {
1807
+ 'Parameters for message interpolation (e.g., { name: "PayeeName" })',
1808
+ additionalProperties: {
1379
1809
  type: 'string'
1380
1810
  }
1381
1811
  },
1382
- useCount: {
1383
- type: 'number',
1384
- description:
1385
- 'Usage count (number of times this payee was used in transactions)',
1386
- example: 42
1812
+ resolutionId: {
1813
+ type: 'string',
1814
+ description: 'Resolution ID for undo'
1387
1815
  },
1388
- lastUsedAt: {
1816
+ canUndo: {
1817
+ type: 'boolean',
1818
+ description: 'Whether this decision can be undone'
1819
+ },
1820
+ undoDeadline: {
1821
+ format: 'date-time',
1822
+ type: 'string',
1823
+ description: 'Deadline for undo (24h from resolution)'
1824
+ },
1825
+ learnedRuleId: {
1826
+ type: 'string',
1827
+ description:
1828
+ 'Rule ID if learning was triggered (ACCEPT_AND_LEARN actions). Use this to deep-link to the rule management page.',
1829
+ example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1830
+ }
1831
+ },
1832
+ required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
1833
+ } as const;
1834
+
1835
+ export const $UndoResultDto = {
1836
+ type: 'object',
1837
+ properties: {
1838
+ success: {
1839
+ type: 'boolean',
1840
+ description: 'Whether undo was successful'
1841
+ },
1842
+ message: {
1843
+ type: 'string',
1844
+ description: 'Message'
1845
+ },
1846
+ reviewId: {
1847
+ type: 'string',
1848
+ description: 'Review item ID that was restored'
1849
+ }
1850
+ },
1851
+ required: ['success', 'reviewId']
1852
+ } as const;
1853
+
1854
+ export const $BatchResolveDto = {
1855
+ type: 'object',
1856
+ properties: {
1857
+ reviewIds: {
1858
+ description: 'Review item IDs to resolve',
1859
+ example: ['review-1', 'review-2', 'review-3'],
1860
+ type: 'array',
1861
+ items: {
1862
+ type: 'string'
1863
+ }
1864
+ },
1865
+ action: {
1866
+ type: 'string',
1867
+ description: 'Decision action to apply to all items',
1868
+ enum: [
1869
+ 'UPGRADE_REPLACE',
1870
+ 'LINK_KEEP_BOTH',
1871
+ 'IGNORE_NEW',
1872
+ 'CONFIRM_DIFFERENT',
1873
+ 'ACCEPT',
1874
+ 'REJECT',
1875
+ 'ACCEPT_AND_LEARN',
1876
+ 'CHOOSE_OTHER',
1877
+ 'CANCEL',
1878
+ 'FIX',
1879
+ 'IGNORE'
1880
+ ],
1881
+ example: 'ACCEPT'
1882
+ },
1883
+ data: {
1884
+ type: 'object',
1885
+ description: 'Additional data for the decision'
1886
+ }
1887
+ },
1888
+ required: ['reviewIds', 'action']
1889
+ } as const;
1890
+
1891
+ export const $BatchResolveResultDto = {
1892
+ type: 'object',
1893
+ properties: {
1894
+ successCount: {
1895
+ type: 'number',
1896
+ description: 'Number of successfully resolved items'
1897
+ },
1898
+ failedCount: {
1899
+ type: 'number',
1900
+ description: 'Number of failed items'
1901
+ },
1902
+ results: {
1903
+ description: 'Details for each item',
1904
+ type: 'array',
1905
+ items: {
1906
+ type: 'string'
1907
+ }
1908
+ }
1909
+ },
1910
+ required: ['successCount', 'failedCount', 'results']
1911
+ } as const;
1912
+
1913
+ export const $CreatePayeeDto = {
1914
+ type: 'object',
1915
+ properties: {
1916
+ payee: {
1917
+ type: 'string',
1918
+ description:
1919
+ "User's original payee name (e.g., 'Starbucks', 'McDonald'). This is the raw payee string as entered by the user.",
1920
+ example: 'Starbucks',
1921
+ maxLength: 200
1922
+ },
1923
+ payeeProfileId: {
1924
+ type: 'string',
1925
+ description:
1926
+ 'Optional reference to global PayeeProfile for standardized data (merchant info, i18n keys, categories)',
1927
+ example: 'uuid-123',
1928
+ format: 'uuid'
1929
+ },
1930
+ customCategory: {
1931
+ type: 'string',
1932
+ description:
1933
+ "User's custom category for this payee (overrides PayeeProfile category)",
1934
+ example: 'Dining:Coffee',
1935
+ maxLength: 100
1936
+ },
1937
+ customTags: {
1938
+ description:
1939
+ "User's custom tags for this payee (e.g., ['favorite', 'work_meal'])",
1940
+ example: ['favorite', 'work_meal'],
1941
+ type: 'array',
1942
+ items: {
1943
+ type: 'string'
1944
+ }
1945
+ },
1946
+ meta: {
1947
+ type: 'object',
1948
+ description:
1949
+ 'Metadata for extended information (location, notes, contact info, etc.)',
1950
+ example: {
1951
+ location: 'Zhongguancun',
1952
+ note: 'Near subway station',
1953
+ favorite: true
1954
+ }
1955
+ }
1956
+ },
1957
+ required: ['payee']
1958
+ } as const;
1959
+
1960
+ export const $PayeeResponseDto = {
1961
+ type: 'object',
1962
+ properties: {
1963
+ id: {
1964
+ type: 'string',
1965
+ description: 'Unique identifier (UUID)',
1966
+ example: 'uuid-123-456'
1967
+ },
1968
+ userId: {
1969
+ type: 'string',
1970
+ description: 'User ID (owner of this payee mapping)',
1971
+ example: 'user-123'
1972
+ },
1973
+ payee: {
1974
+ type: 'string',
1975
+ description: "User's original payee name (e.g., 'Starbucks', 'McDonald')",
1976
+ example: 'Starbucks'
1977
+ },
1978
+ payeeProfileId: {
1979
+ type: 'string',
1980
+ description:
1981
+ 'Reference to global PayeeProfile (merchant info, i18n keys, categories)',
1982
+ example: 'uuid-789',
1983
+ nullable: true
1984
+ },
1985
+ customCategory: {
1986
+ type: 'string',
1987
+ description:
1988
+ "User's custom category (overrides PayeeProfile category if set)",
1989
+ example: 'Dining:Coffee',
1990
+ nullable: true
1991
+ },
1992
+ customTags: {
1993
+ description: "User's custom tags (e.g., ['favorite', 'work_meal'])",
1994
+ example: ['favorite', 'work_meal'],
1995
+ type: 'array',
1996
+ items: {
1997
+ type: 'string'
1998
+ }
1999
+ },
2000
+ useCount: {
2001
+ type: 'number',
2002
+ description:
2003
+ 'Usage count (number of times this payee was used in transactions)',
2004
+ example: 42
2005
+ },
2006
+ lastUsedAt: {
1389
2007
  format: 'date-time',
1390
2008
  type: 'string',
1391
2009
  description: 'Last used timestamp',
@@ -1489,21 +2107,64 @@ export const $PayeeStatsResponseDto = {
1489
2107
  required: ['payee', 'transactionCount', 'lastUsedAt']
1490
2108
  } as const;
1491
2109
 
1492
- export const $PayeeProfileResponseDto = {
2110
+ export const $UpdatePayeeDto = {
1493
2111
  type: 'object',
1494
2112
  properties: {
1495
- id: {
2113
+ payeeProfileId: {
1496
2114
  type: 'string',
1497
- description: 'Unique identifier (UUID)',
1498
- example: '550e8400-e29b-41d4-a716-446655440000'
2115
+ description:
2116
+ 'Optional reference to global PayeeProfile for standardized data (merchant info, i18n keys, categories)',
2117
+ example: 'uuid-123',
2118
+ format: 'uuid'
2119
+ },
2120
+ customCategory: {
2121
+ type: 'string',
2122
+ description:
2123
+ "User's custom category for this payee (overrides PayeeProfile category)",
2124
+ example: 'Dining:Coffee',
2125
+ maxLength: 100
2126
+ },
2127
+ customTags: {
2128
+ description:
2129
+ "User's custom tags for this payee (e.g., ['favorite', 'work_meal'])",
2130
+ example: ['favorite', 'work_meal'],
2131
+ type: 'array',
2132
+ items: {
2133
+ type: 'string'
2134
+ }
2135
+ },
2136
+ meta: {
2137
+ type: 'object',
2138
+ description:
2139
+ 'Metadata for extended information (location, notes, contact info, etc.). Will merge with existing metadata.',
2140
+ example: {
2141
+ location: 'Zhongguancun',
2142
+ note: 'Updated note',
2143
+ favorite: true
2144
+ }
1499
2145
  },
2146
+ isActive: {
2147
+ type: 'boolean',
2148
+ description:
2149
+ 'Enable or disable this payee. Disabled payees will not appear in autocomplete suggestions.',
2150
+ example: true
2151
+ }
2152
+ }
2153
+ } as const;
2154
+
2155
+ export const $CreatePayeeProfileDto = {
2156
+ type: 'object',
2157
+ properties: {
1500
2158
  canonical: {
1501
2159
  type: 'string',
1502
- description: 'Canonical payee name (unique, case-insensitive)',
1503
- example: 'Starbucks'
2160
+ description:
2161
+ 'Canonical payee name (unique, case-insensitive). This is the primary identifier for the payee.',
2162
+ example: 'Starbucks',
2163
+ maxLength: 200
1504
2164
  },
1505
2165
  aliases: {
1506
- description: 'Multi-language aliases',
2166
+ description:
2167
+ 'Multi-language aliases for the payee. Used for matching user input in different languages.',
1507
2168
  example: ['Starbucks Coffee', 'SBUX'],
1508
2169
  type: 'array',
1509
2170
  items: {
@@ -1511,14 +2172,15 @@ export const $PayeeProfileResponseDto = {
1511
2172
  }
1512
2173
  },
1513
2174
  i18nKey: {
1514
- type: 'object',
1515
- description: 'Translation key for i18n',
2175
+ type: 'string',
2176
+ description:
2177
+ 'Translation key for i18n integration (XLIFF translation system)',
1516
2178
  example: 'payee.starbucks',
1517
- nullable: true
2179
+ maxLength: 100
1518
2180
  },
1519
2181
  category: {
1520
2182
  type: 'string',
1521
- description: 'Payee category',
2183
+ description: 'Payee category classification',
1522
2184
  enum: [
1523
2185
  'RESTAURANT',
1524
2186
  'CAFE',
@@ -1547,13 +2209,14 @@ export const $PayeeProfileResponseDto = {
1547
2209
  example: 'CAFE'
1548
2210
  },
1549
2211
  subCategory: {
1550
- type: 'object',
1551
- description: 'Sub-category',
2212
+ type: 'string',
2213
+ description: 'Sub-category for more specific classification',
1552
2214
  example: 'coffee_chain',
1553
- nullable: true
2215
+ maxLength: 100
1554
2216
  },
1555
2217
  countries: {
1556
- description: 'Country codes where payee operates',
2218
+ description:
2219
+ 'Country/region codes where the payee operates (ISO 3166-1 alpha-2)',
1557
2220
  example: ['CN', 'US', 'JP'],
1558
2221
  type: 'array',
1559
2222
  items: {
@@ -1561,70 +2224,191 @@ export const $PayeeProfileResponseDto = {
1561
2224
  }
1562
2225
  },
1563
2226
  primaryCountry: {
1564
- type: 'object',
1565
- description: 'Primary operating country',
2227
+ type: 'string',
2228
+ description: 'Primary operating country (ISO 3166-1 alpha-2)',
1566
2229
  example: 'US',
1567
- nullable: true
2230
+ maxLength: 2
1568
2231
  },
1569
2232
  keywords: {
1570
- description: 'Search keywords',
1571
- example: ['coffee', 'cafe'],
2233
+ description: 'Search keywords for fuzzy matching',
2234
+ example: ['coffee', 'cafe', 'drinks'],
1572
2235
  type: 'array',
1573
2236
  items: {
1574
2237
  type: 'string'
1575
2238
  }
1576
2239
  },
1577
2240
  logoUrl: {
1578
- type: 'object',
1579
- description: 'Logo URL',
1580
- example: 'https://example.com/logo.png',
1581
- nullable: true
2241
+ type: 'string',
2242
+ description: 'Payee logo URL',
2243
+ example: 'https://example.com/logo.png'
1582
2244
  },
1583
2245
  website: {
1584
- type: 'object',
1585
- description: 'Official website',
1586
- example: 'https://www.starbucks.com',
1587
- nullable: true
2246
+ type: 'string',
2247
+ description: 'Official website URL',
2248
+ example: 'https://www.starbucks.com'
1588
2249
  },
1589
2250
  description: {
1590
- type: 'object',
1591
- description: 'Description',
1592
- example: 'Global coffeehouse chain',
1593
- nullable: true
2251
+ type: 'string',
2252
+ description: 'Payee description',
2253
+ example: 'Global coffeehouse chain headquartered in Seattle',
2254
+ maxLength: 1000
1594
2255
  },
1595
2256
  meta: {
1596
2257
  type: 'object',
1597
- description: 'Extended metadata'
2258
+ description:
2259
+ 'Extended metadata (business hours, contact info, additional details)',
2260
+ example: {
2261
+ businessHours: '07:00-22:00',
2262
+ phone: '+1-800-782-7282'
2263
+ }
1598
2264
  },
1599
2265
  dataSource: {
1600
2266
  type: 'string',
1601
- description: 'Data source',
2267
+ description: 'Data source for this profile',
1602
2268
  enum: ['MANUAL', 'IMPORT', 'API', 'CROWDSOURCED'],
1603
- example: 'MANUAL'
1604
- },
1605
- verifiedAt: {
1606
- type: 'object',
1607
- description: 'Verification timestamp (null if not verified)',
1608
- example: '2025-01-01T00:00:00.000Z',
1609
- nullable: true
1610
- },
1611
- isActive: {
1612
- type: 'boolean',
1613
- description: 'Whether the profile is active',
1614
- example: true
1615
- },
1616
- createdAt: {
1617
- format: 'date-time',
2269
+ default: 'MANUAL'
2270
+ }
2271
+ },
2272
+ required: ['canonical', 'category']
2273
+ } as const;
2274
+
2275
+ export const $PayeeProfileResponseDto = {
2276
+ type: 'object',
2277
+ properties: {
2278
+ id: {
1618
2279
  type: 'string',
1619
- description: 'Creation timestamp',
1620
- example: '2025-01-01T00:00:00.000Z'
2280
+ description: 'Unique identifier (UUID)',
2281
+ example: '550e8400-e29b-41d4-a716-446655440000'
1621
2282
  },
1622
- updatedAt: {
1623
- format: 'date-time',
2283
+ canonical: {
1624
2284
  type: 'string',
1625
- description: 'Last update timestamp',
1626
- example: '2025-01-01T00:00:00.000Z'
1627
- }
2285
+ description: 'Canonical payee name (unique, case-insensitive)',
2286
+ example: 'Starbucks'
2287
+ },
2288
+ aliases: {
2289
+ description: 'Multi-language aliases',
2290
+ example: ['Starbucks Coffee', 'SBUX'],
2291
+ type: 'array',
2292
+ items: {
2293
+ type: 'string'
2294
+ }
2295
+ },
2296
+ i18nKey: {
2297
+ type: 'string',
2298
+ description: 'Translation key for i18n',
2299
+ example: 'payee.starbucks',
2300
+ nullable: true
2301
+ },
2302
+ category: {
2303
+ type: 'string',
2304
+ description: 'Payee category',
2305
+ enum: [
2306
+ 'RESTAURANT',
2307
+ 'CAFE',
2308
+ 'FAST_FOOD',
2309
+ 'BAR',
2310
+ 'SUPERMARKET',
2311
+ 'CONVENIENCE_STORE',
2312
+ 'SHOPPING_MALL',
2313
+ 'ONLINE_SHOPPING',
2314
+ 'TAXI',
2315
+ 'RIDE_SHARING',
2316
+ 'PUBLIC_TRANSPORT',
2317
+ 'PARKING',
2318
+ 'GAS_STATION',
2319
+ 'UTILITIES',
2320
+ 'TELECOM',
2321
+ 'STREAMING',
2322
+ 'HEALTHCARE',
2323
+ 'EDUCATION',
2324
+ 'ENTERTAINMENT',
2325
+ 'SPORTS',
2326
+ 'TRAVEL',
2327
+ 'HOTEL',
2328
+ 'OTHER'
2329
+ ],
2330
+ example: 'CAFE'
2331
+ },
2332
+ subCategory: {
2333
+ type: 'string',
2334
+ description: 'Sub-category',
2335
+ example: 'coffee_chain',
2336
+ nullable: true
2337
+ },
2338
+ countries: {
2339
+ description: 'Country codes where payee operates',
2340
+ example: ['CN', 'US', 'JP'],
2341
+ type: 'array',
2342
+ items: {
2343
+ type: 'string'
2344
+ }
2345
+ },
2346
+ primaryCountry: {
2347
+ type: 'string',
2348
+ description: 'Primary operating country',
2349
+ example: 'US',
2350
+ nullable: true
2351
+ },
2352
+ keywords: {
2353
+ description: 'Search keywords',
2354
+ example: ['coffee', 'cafe'],
2355
+ type: 'array',
2356
+ items: {
2357
+ type: 'string'
2358
+ }
2359
+ },
2360
+ logoUrl: {
2361
+ type: 'string',
2362
+ description: 'Logo URL',
2363
+ example: 'https://example.com/logo.png',
2364
+ nullable: true
2365
+ },
2366
+ website: {
2367
+ type: 'string',
2368
+ description: 'Official website',
2369
+ example: 'https://www.starbucks.com',
2370
+ nullable: true
2371
+ },
2372
+ description: {
2373
+ type: 'string',
2374
+ description: 'Description',
2375
+ example: 'Global coffeehouse chain',
2376
+ nullable: true
2377
+ },
2378
+ meta: {
2379
+ type: 'object',
2380
+ description: 'Extended metadata'
2381
+ },
2382
+ dataSource: {
2383
+ type: 'string',
2384
+ description: 'Data source',
2385
+ enum: ['MANUAL', 'IMPORT', 'API', 'CROWDSOURCED'],
2386
+ example: 'MANUAL'
2387
+ },
2388
+ verifiedAt: {
2389
+ type: 'string',
2390
+ description: 'Verification timestamp (null if not verified)',
2391
+ example: '2025-01-01T00:00:00.000Z',
2392
+ format: 'date-time',
2393
+ nullable: true
2394
+ },
2395
+ isActive: {
2396
+ type: 'boolean',
2397
+ description: 'Whether the profile is active',
2398
+ example: true
2399
+ },
2400
+ createdAt: {
2401
+ format: 'date-time',
2402
+ type: 'string',
2403
+ description: 'Creation timestamp',
2404
+ example: '2025-01-01T00:00:00.000Z'
2405
+ },
2406
+ updatedAt: {
2407
+ format: 'date-time',
2408
+ type: 'string',
2409
+ description: 'Last update timestamp',
2410
+ example: '2025-01-01T00:00:00.000Z'
2411
+ }
1628
2412
  },
1629
2413
  required: [
1630
2414
  'id',
@@ -1660,6 +2444,164 @@ export const $PayeeProfileListResponseDto = {
1660
2444
  required: ['items', 'total']
1661
2445
  } as const;
1662
2446
 
2447
+ export const $UpdatePayeeProfileDto = {
2448
+ type: 'object',
2449
+ properties: {
2450
+ aliases: {
2451
+ description:
2452
+ 'Multi-language aliases for the payee. Used for matching user input in different languages.',
2453
+ example: ['Starbucks Coffee', 'SBUX'],
2454
+ type: 'array',
2455
+ items: {
2456
+ type: 'string'
2457
+ }
2458
+ },
2459
+ i18nKey: {
2460
+ type: 'string',
2461
+ description:
2462
+ 'Translation key for i18n integration (XLIFF translation system)',
2463
+ example: 'payee.starbucks',
2464
+ maxLength: 100
2465
+ },
2466
+ category: {
2467
+ type: 'string',
2468
+ description: 'Payee category classification',
2469
+ enum: [
2470
+ 'RESTAURANT',
2471
+ 'CAFE',
2472
+ 'FAST_FOOD',
2473
+ 'BAR',
2474
+ 'SUPERMARKET',
2475
+ 'CONVENIENCE_STORE',
2476
+ 'SHOPPING_MALL',
2477
+ 'ONLINE_SHOPPING',
2478
+ 'TAXI',
2479
+ 'RIDE_SHARING',
2480
+ 'PUBLIC_TRANSPORT',
2481
+ 'PARKING',
2482
+ 'GAS_STATION',
2483
+ 'UTILITIES',
2484
+ 'TELECOM',
2485
+ 'STREAMING',
2486
+ 'HEALTHCARE',
2487
+ 'EDUCATION',
2488
+ 'ENTERTAINMENT',
2489
+ 'SPORTS',
2490
+ 'TRAVEL',
2491
+ 'HOTEL',
2492
+ 'OTHER'
2493
+ ],
2494
+ example: 'CAFE'
2495
+ },
2496
+ subCategory: {
2497
+ type: 'string',
2498
+ description: 'Sub-category for more specific classification',
2499
+ example: 'coffee_chain',
2500
+ maxLength: 100
2501
+ },
2502
+ countries: {
2503
+ description:
2504
+ 'Country/region codes where the payee operates (ISO 3166-1 alpha-2)',
2505
+ example: ['CN', 'US', 'JP'],
2506
+ type: 'array',
2507
+ items: {
2508
+ type: 'string'
2509
+ }
2510
+ },
2511
+ primaryCountry: {
2512
+ type: 'string',
2513
+ description: 'Primary operating country (ISO 3166-1 alpha-2)',
2514
+ example: 'US',
2515
+ maxLength: 2
2516
+ },
2517
+ keywords: {
2518
+ description: 'Search keywords for fuzzy matching',
2519
+ example: ['coffee', 'cafe', 'drinks'],
2520
+ type: 'array',
2521
+ items: {
2522
+ type: 'string'
2523
+ }
2524
+ },
2525
+ logoUrl: {
2526
+ type: 'string',
2527
+ description: 'Payee logo URL',
2528
+ example: 'https://example.com/logo.png'
2529
+ },
2530
+ website: {
2531
+ type: 'string',
2532
+ description: 'Official website URL',
2533
+ example: 'https://www.starbucks.com'
2534
+ },
2535
+ description: {
2536
+ type: 'string',
2537
+ description: 'Payee description',
2538
+ example: 'Global coffeehouse chain headquartered in Seattle',
2539
+ maxLength: 1000
2540
+ },
2541
+ meta: {
2542
+ type: 'object',
2543
+ description:
2544
+ 'Extended metadata (business hours, contact info, additional details)',
2545
+ example: {
2546
+ businessHours: '07:00-22:00',
2547
+ phone: '+1-800-782-7282'
2548
+ }
2549
+ },
2550
+ dataSource: {
2551
+ type: 'string',
2552
+ description: 'Data source for this profile',
2553
+ enum: ['MANUAL', 'IMPORT', 'API', 'CROWDSOURCED'],
2554
+ default: 'MANUAL'
2555
+ },
2556
+ isActive: {
2557
+ type: 'boolean',
2558
+ description: 'Whether the payee profile is active (soft delete)',
2559
+ example: true
2560
+ },
2561
+ verifiedAt: {
2562
+ type: 'string',
2563
+ description:
2564
+ 'Verification timestamp. Set to current time to verify, or null to unverify.',
2565
+ example: '2025-01-01T00:00:00.000Z',
2566
+ format: 'date-time',
2567
+ nullable: true
2568
+ }
2569
+ }
2570
+ } as const;
2571
+
2572
+ export const $CreateCommodityDto = {
2573
+ type: 'object',
2574
+ properties: {
2575
+ symbol: {
2576
+ type: 'string',
2577
+ description:
2578
+ 'Commodity symbol (e.g., AAPL, USD, BTC) - corresponds to Beancount currency field',
2579
+ example: 'AAPL',
2580
+ maxLength: 50
2581
+ },
2582
+ date: {
2583
+ type: 'string',
2584
+ description:
2585
+ 'Commodity definition date (ISO 8601, required per Beancount spec). Represents when this commodity was first defined in the accounting system.',
2586
+ example: '2024-01-01',
2587
+ format: 'date'
2588
+ },
2589
+ metadata: {
2590
+ type: 'object',
2591
+ description:
2592
+ 'Metadata (corresponds to Beancount meta field). Can contain name, assetClass, precision, note, tags, etc.',
2593
+ example: {
2594
+ name: 'Apple Inc.',
2595
+ assetClass: 'stock',
2596
+ precision: 2,
2597
+ note: 'Long-term investment',
2598
+ tags: ['tech', 'dividend']
2599
+ }
2600
+ }
2601
+ },
2602
+ required: ['symbol', 'date']
2603
+ } as const;
2604
+
1663
2605
  export const $CommodityResponseDto = {
1664
2606
  type: 'object',
1665
2607
  properties: {
@@ -1669,7 +2611,7 @@ export const $CommodityResponseDto = {
1669
2611
  example: 'uuid-123-456'
1670
2612
  },
1671
2613
  userId: {
1672
- type: 'object',
2614
+ type: 'string',
1673
2615
  description: 'User ID (owner of the commodity)',
1674
2616
  example: 'user-123',
1675
2617
  nullable: true
@@ -1698,13 +2640,6 @@ export const $CommodityResponseDto = {
1698
2640
  source: 'AUTO_CREATED'
1699
2641
  }
1700
2642
  },
1701
- symbolProfileId: {
1702
- type: 'object',
1703
- description:
1704
- 'Reference to SymbolProfile (market data integration, SaaS feature)',
1705
- example: 'uuid-789',
1706
- nullable: true
1707
- },
1708
2643
  createdAt: {
1709
2644
  format: 'date-time',
1710
2645
  type: 'string',
@@ -1740,6 +2675,130 @@ export const $CommodityListResponseDto = {
1740
2675
  required: ['items', 'total']
1741
2676
  } as const;
1742
2677
 
2678
+ export const $UpdateCommodityDto = {
2679
+ type: 'object',
2680
+ properties: {
2681
+ date: {
2682
+ type: 'string',
2683
+ description:
2684
+ 'Commodity definition date (ISO 8601). Represents when this commodity was first defined in the accounting system.',
2685
+ example: '2024-01-01',
2686
+ format: 'date'
2687
+ },
2688
+ metadata: {
2689
+ type: 'object',
2690
+ description:
2691
+ 'Metadata (corresponds to Beancount meta field). Will merge with existing metadata. Can contain name, assetClass, precision, note, tags, etc.',
2692
+ example: {
2693
+ name: 'Updated Apple Inc.',
2694
+ assetClass: 'equity',
2695
+ precision: 4,
2696
+ note: 'Updated investment strategy',
2697
+ lastReviewed: '2024-11-03'
2698
+ }
2699
+ }
2700
+ }
2701
+ } as const;
2702
+
2703
+ export const $CreateRecurringRuleDto = {
2704
+ type: 'object',
2705
+ properties: {
2706
+ name: {
2707
+ type: 'string',
2708
+ description: 'Rule name (unique per user)',
2709
+ maxLength: 100
2710
+ },
2711
+ icon: {
2712
+ type: 'string',
2713
+ description: 'Icon emoji',
2714
+ maxLength: 10
2715
+ },
2716
+ frequency: {
2717
+ type: 'string',
2718
+ description: 'Recurring frequency',
2719
+ enum: [
2720
+ 'WEEKLY',
2721
+ 'BIWEEKLY',
2722
+ 'MONTHLY',
2723
+ 'BIMONTHLY',
2724
+ 'QUARTERLY',
2725
+ 'YEARLY',
2726
+ 'CUSTOM'
2727
+ ]
2728
+ },
2729
+ expectedAmount: {
2730
+ type: 'number',
2731
+ description: 'Expected amount (positive number)',
2732
+ minimum: 0
2733
+ },
2734
+ expectedDay: {
2735
+ type: 'number',
2736
+ description: 'Expected day of month (1-31)',
2737
+ minimum: 1,
2738
+ maximum: 31
2739
+ },
2740
+ customIntervalDays: {
2741
+ type: 'number',
2742
+ description: 'Custom interval in days (required for CUSTOM frequency)',
2743
+ minimum: 1
2744
+ },
2745
+ currency: {
2746
+ type: 'string',
2747
+ description: 'Currency code',
2748
+ default: 'CNY',
2749
+ maxLength: 10
2750
+ },
2751
+ matchPayeePattern: {
2752
+ type: 'string',
2753
+ description: 'Payee matching pattern (supports wildcards)',
2754
+ maxLength: 200
2755
+ },
2756
+ matchAmountTolerance: {
2757
+ type: 'number',
2758
+ description: 'Amount tolerance percentage (0-1)',
2759
+ default: 0.075,
2760
+ minimum: 0,
2761
+ maximum: 1
2762
+ },
2763
+ defaultExpenseAccount: {
2764
+ type: 'string',
2765
+ description: 'Default expense account for auto-create',
2766
+ maxLength: 200
2767
+ },
2768
+ defaultPaymentAccount: {
2769
+ type: 'string',
2770
+ description: 'Default payment account for auto-create',
2771
+ maxLength: 200
2772
+ },
2773
+ defaultPayee: {
2774
+ type: 'string',
2775
+ description: 'Default payee for auto-create',
2776
+ maxLength: 200
2777
+ },
2778
+ autoCreate: {
2779
+ type: 'boolean',
2780
+ description: 'Auto-create transaction when expected date arrives',
2781
+ default: false
2782
+ },
2783
+ startDate: {
2784
+ type: 'string',
2785
+ description: 'Rule start date (ISO format)'
2786
+ },
2787
+ endDate: {
2788
+ type: 'string',
2789
+ description: 'Rule end date (ISO format)'
2790
+ }
2791
+ },
2792
+ required: [
2793
+ 'name',
2794
+ 'frequency',
2795
+ 'expectedAmount',
2796
+ 'currency',
2797
+ 'matchAmountTolerance',
2798
+ 'autoCreate'
2799
+ ]
2800
+ } as const;
2801
+
1743
2802
  export const $RecurringRuleResponseDto = {
1744
2803
  type: 'object',
1745
2804
  properties: {
@@ -1851,6 +2910,37 @@ export const $RecurringRuleResponseDto = {
1851
2910
  ]
1852
2911
  } as const;
1853
2912
 
2913
+ export const $CreateRuleFromTransactionDto = {
2914
+ type: 'object',
2915
+ properties: {
2916
+ frequency: {
2917
+ type: 'string',
2918
+ description: 'Recurring frequency',
2919
+ enum: [
2920
+ 'WEEKLY',
2921
+ 'BIWEEKLY',
2922
+ 'MONTHLY',
2923
+ 'BIMONTHLY',
2924
+ 'QUARTERLY',
2925
+ 'YEARLY',
2926
+ 'CUSTOM'
2927
+ ],
2928
+ example: 'MONTHLY'
2929
+ },
2930
+ name: {
2931
+ type: 'string',
2932
+ description: 'Optional name override (default: transaction payee)',
2933
+ maxLength: 100
2934
+ },
2935
+ icon: {
2936
+ type: 'string',
2937
+ description: 'Optional icon emoji',
2938
+ maxLength: 10
2939
+ }
2940
+ },
2941
+ required: ['frequency']
2942
+ } as const;
2943
+
1854
2944
  export const $RecurringRuleWithStatsResponseDto = {
1855
2945
  type: 'object',
1856
2946
  properties: {
@@ -2009,6 +3099,94 @@ export const $RecurringRuleWithStatsResponseDto = {
2009
3099
  ]
2010
3100
  } as const;
2011
3101
 
3102
+ export const $UpdateRecurringRuleDto = {
3103
+ type: 'object',
3104
+ properties: {
3105
+ name: {
3106
+ type: 'string',
3107
+ description: 'Rule name',
3108
+ maxLength: 100
3109
+ },
3110
+ icon: {
3111
+ type: 'string',
3112
+ description: 'Icon emoji',
3113
+ maxLength: 10
3114
+ },
3115
+ frequency: {
3116
+ type: 'string',
3117
+ description: 'Recurring frequency',
3118
+ enum: [
3119
+ 'WEEKLY',
3120
+ 'BIWEEKLY',
3121
+ 'MONTHLY',
3122
+ 'BIMONTHLY',
3123
+ 'QUARTERLY',
3124
+ 'YEARLY',
3125
+ 'CUSTOM'
3126
+ ]
3127
+ },
3128
+ expectedAmount: {
3129
+ type: 'number',
3130
+ description: 'Expected amount',
3131
+ minimum: 0
3132
+ },
3133
+ expectedDay: {
3134
+ type: 'number',
3135
+ description: 'Expected day of month (1-31)',
3136
+ minimum: 1,
3137
+ maximum: 31
3138
+ },
3139
+ customIntervalDays: {
3140
+ type: 'number',
3141
+ description: 'Custom interval in days',
3142
+ minimum: 1
3143
+ },
3144
+ currency: {
3145
+ type: 'string',
3146
+ description: 'Currency code',
3147
+ maxLength: 10
3148
+ },
3149
+ matchPayeePattern: {
3150
+ type: 'string',
3151
+ description: 'Payee matching pattern',
3152
+ maxLength: 200
3153
+ },
3154
+ matchAmountTolerance: {
3155
+ type: 'number',
3156
+ description: 'Amount tolerance percentage (0-1)',
3157
+ minimum: 0,
3158
+ maximum: 1
3159
+ },
3160
+ defaultExpenseAccount: {
3161
+ type: 'string',
3162
+ description: 'Default expense account',
3163
+ maxLength: 200
3164
+ },
3165
+ defaultPaymentAccount: {
3166
+ type: 'string',
3167
+ description: 'Default payment account',
3168
+ maxLength: 200
3169
+ },
3170
+ defaultPayee: {
3171
+ type: 'string',
3172
+ description: 'Default payee',
3173
+ maxLength: 200
3174
+ },
3175
+ autoCreate: {
3176
+ type: 'boolean',
3177
+ description: 'Auto-create transaction'
3178
+ },
3179
+ isActive: {
3180
+ type: 'boolean',
3181
+ description: 'Rule active status'
3182
+ },
3183
+ endDate: {
3184
+ type: 'string',
3185
+ description: 'Rule end date (ISO format)'
3186
+ }
3187
+ }
3188
+ } as const;
3189
+
2012
3190
  export const $ExpectedTransactionRuleDto = {
2013
3191
  type: 'object',
2014
3192
  properties: {
@@ -2125,6 +3303,50 @@ export const $ExpectedTransactionListResponseDto = {
2125
3303
  required: ['items', 'total']
2126
3304
  } as const;
2127
3305
 
3306
+ export const $ConfirmMatchDto = {
3307
+ type: 'object',
3308
+ properties: {
3309
+ transactionId: {
3310
+ type: 'string',
3311
+ description: 'Transaction ID to match with'
3312
+ }
3313
+ },
3314
+ required: ['transactionId']
3315
+ } as const;
3316
+
3317
+ export const $EnterNowDto = {
3318
+ type: 'object',
3319
+ properties: {
3320
+ expenseAccount: {
3321
+ type: 'string',
3322
+ description:
3323
+ 'Override expense account (uses rule default if not provided)',
3324
+ maxLength: 200
3325
+ },
3326
+ paymentAccount: {
3327
+ type: 'string',
3328
+ description:
3329
+ 'Override payment account (uses rule default if not provided)',
3330
+ maxLength: 200
3331
+ },
3332
+ amount: {
3333
+ type: 'number',
3334
+ description: 'Override amount (uses expected amount if not provided)',
3335
+ minimum: 0
3336
+ },
3337
+ payee: {
3338
+ type: 'string',
3339
+ description: 'Override payee (uses rule default if not provided)',
3340
+ maxLength: 200
3341
+ },
3342
+ narration: {
3343
+ type: 'string',
3344
+ description: 'Optional narration',
3345
+ maxLength: 500
3346
+ }
3347
+ }
3348
+ } as const;
3349
+
2128
3350
  export const $ForecastItemDto = {
2129
3351
  type: 'object',
2130
3352
  properties: {
@@ -2149,7 +3371,7 @@ export const $ForecastItemDto = {
2149
3371
  example: '2024-04-01'
2150
3372
  },
2151
3373
  icon: {
2152
- type: 'object',
3374
+ type: 'string',
2153
3375
  description: 'Rule icon emoji',
2154
3376
  example: '🏠',
2155
3377
  nullable: true
@@ -2249,34 +3471,135 @@ export const $ForecastResponseDto = {
2249
3471
  ]
2250
3472
  } as const;
2251
3473
 
2252
- export const $TransactionRuleResponseDto = {
3474
+ export const $CreateTransactionRuleDto = {
2253
3475
  type: 'object',
2254
3476
  properties: {
2255
- id: {
2256
- type: 'string',
2257
- description: 'Rule ID'
2258
- },
2259
3477
  name: {
2260
3478
  type: 'string',
2261
- description: 'Rule name'
3479
+ minLength: 1,
3480
+ maxLength: 100
2262
3481
  },
2263
3482
  description: {
2264
3483
  type: 'string',
2265
- description: 'Rule description'
3484
+ maxLength: 500
2266
3485
  },
2267
3486
  narrationKeywords: {
2268
- description: 'Keywords to match in transaction narration',
2269
- type: 'array',
2270
3487
  items: {
2271
- type: 'string'
2272
- }
3488
+ type: 'array'
3489
+ },
3490
+ maxItems: 50,
3491
+ type: 'array'
2273
3492
  },
2274
3493
  payeeKeywords: {
2275
- description: 'Keywords to match in payee name',
2276
- type: 'array',
2277
3494
  items: {
2278
- type: 'string'
2279
- }
3495
+ type: 'array'
3496
+ },
3497
+ maxItems: 50,
3498
+ type: 'array'
3499
+ },
3500
+ categoryKeywords: {
3501
+ items: {
3502
+ type: 'array'
3503
+ },
3504
+ maxItems: 50,
3505
+ type: 'array'
3506
+ },
3507
+ methodKeywords: {
3508
+ items: {
3509
+ type: 'array'
3510
+ },
3511
+ maxItems: 50,
3512
+ description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
3513
+ type: 'array'
3514
+ },
3515
+ categoryAccount: {
3516
+ type: 'string',
3517
+ maxLength: 200,
3518
+ description:
3519
+ 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
3520
+ },
3521
+ matchLogic: {
3522
+ type: 'string',
3523
+ enum: ['OR', 'AND'],
3524
+ default: 'OR'
3525
+ },
3526
+ amountMin: {
3527
+ type: 'number',
3528
+ minimum: 0,
3529
+ description: 'Minimum transaction amount (inclusive)'
3530
+ },
3531
+ amountMax: {
3532
+ type: 'number',
3533
+ minimum: 0,
3534
+ description: 'Maximum transaction amount (inclusive)'
3535
+ },
3536
+ priority: {
3537
+ type: 'number',
3538
+ default: 50,
3539
+ minimum: 0,
3540
+ maximum: 1000
3541
+ },
3542
+ additionalTags: {
3543
+ items: {
3544
+ type: 'array'
3545
+ },
3546
+ maxItems: 20,
3547
+ type: 'array'
3548
+ },
3549
+ additionalMetadata: {
3550
+ type: 'object'
3551
+ },
3552
+ upsertByPayee: {
3553
+ type: 'boolean',
3554
+ description:
3555
+ 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
3556
+ }
3557
+ },
3558
+ required: ['name', 'matchLogic', 'priority']
3559
+ } as const;
3560
+
3561
+ export const $AmountRangeDto = {
3562
+ type: 'object',
3563
+ properties: {
3564
+ min: {
3565
+ type: 'number',
3566
+ description: 'Minimum amount'
3567
+ },
3568
+ max: {
3569
+ type: 'number',
3570
+ description: 'Maximum amount'
3571
+ }
3572
+ }
3573
+ } as const;
3574
+
3575
+ export const $TransactionRuleResponseDto = {
3576
+ type: 'object',
3577
+ properties: {
3578
+ id: {
3579
+ type: 'string',
3580
+ description: 'Rule ID'
3581
+ },
3582
+ name: {
3583
+ type: 'string',
3584
+ description: 'Rule name'
3585
+ },
3586
+ description: {
3587
+ type: 'string',
3588
+ description: 'Rule description'
3589
+ },
3590
+ narrationKeywords: {
3591
+ description: 'Keywords to match in transaction narration',
3592
+ type: 'array',
3593
+ items: {
3594
+ type: 'string'
3595
+ }
3596
+ },
3597
+ payeeKeywords: {
3598
+ description: 'Keywords to match in payee name',
3599
+ type: 'array',
3600
+ items: {
3601
+ type: 'string'
3602
+ }
2280
3603
  },
2281
3604
  categoryKeywords: {
2282
3605
  description: 'Keywords to match in category',
@@ -2303,12 +3626,12 @@ export const $TransactionRuleResponseDto = {
2303
3626
  example: 'OR'
2304
3627
  },
2305
3628
  amountRange: {
2306
- type: 'object',
2307
3629
  description: 'Amount range for matching',
2308
- example: {
2309
- min: 0,
2310
- max: 100
2311
- }
3630
+ allOf: [
3631
+ {
3632
+ $ref: '#/components/schemas/AmountRangeDto'
3633
+ }
3634
+ ]
2312
3635
  },
2313
3636
  priority: {
2314
3637
  type: 'number',
@@ -2323,6 +3646,7 @@ export const $TransactionRuleResponseDto = {
2323
3646
  type: 'string',
2324
3647
  description: 'Learning source: NLP, REVIEW_CENTER, or null for manual',
2325
3648
  enum: ['NLP', 'REVIEW_CENTER'],
3649
+ nullable: true,
2326
3650
  example: 'REVIEW_CENTER'
2327
3651
  },
2328
3652
  autoApplyEnabled: {
@@ -2344,7 +3668,9 @@ export const $TransactionRuleResponseDto = {
2344
3668
  additionalMetadata: {
2345
3669
  type: 'object',
2346
3670
  description: 'Additional metadata',
2347
- example: {}
3671
+ additionalProperties: {
3672
+ type: 'string'
3673
+ }
2348
3674
  },
2349
3675
  createdAt: {
2350
3676
  format: 'date-time',
@@ -2517,6 +3843,64 @@ export const $ValidateRuleResponseDto = {
2517
3843
  required: ['valid', 'errors', 'warnings']
2518
3844
  } as const;
2519
3845
 
3846
+ export const $BulkCreateRulesDto = {
3847
+ type: 'object',
3848
+ properties: {
3849
+ rules: {
3850
+ items: {
3851
+ type: 'array'
3852
+ },
3853
+ description: 'Array of rules to import',
3854
+ type: 'array'
3855
+ },
3856
+ conflictStrategy: {
3857
+ type: 'string',
3858
+ enum: ['replace', 'skip'],
3859
+ default: 'skip',
3860
+ description:
3861
+ 'Conflict handling strategy: skip (default) ignores duplicates, replace soft-deletes existing rule'
3862
+ }
3863
+ },
3864
+ required: ['rules', 'conflictStrategy']
3865
+ } as const;
3866
+
3867
+ export const $BulkCreateRulesResponseDto = {
3868
+ type: 'object',
3869
+ properties: {
3870
+ successCount: {
3871
+ type: 'number',
3872
+ description: 'Number of successfully created rules'
3873
+ },
3874
+ failureCount: {
3875
+ type: 'number',
3876
+ description: 'Number of failed rules'
3877
+ },
3878
+ errors: {
3879
+ type: 'array',
3880
+ description: 'Error details for failed rules',
3881
+ items: {
3882
+ type: 'object',
3883
+ properties: {
3884
+ index: {
3885
+ type: 'number'
3886
+ },
3887
+ message: {
3888
+ type: 'string'
3889
+ }
3890
+ }
3891
+ }
3892
+ },
3893
+ createdRuleIds: {
3894
+ description: 'IDs of successfully created rules',
3895
+ type: 'array',
3896
+ items: {
3897
+ type: 'string'
3898
+ }
3899
+ }
3900
+ },
3901
+ required: ['successCount', 'failureCount', 'errors', 'createdRuleIds']
3902
+ } as const;
3903
+
2520
3904
  export const $ExportRulesResponseDto = {
2521
3905
  type: 'object',
2522
3906
  properties: {
@@ -2597,6 +3981,89 @@ export const $RuleStatisticsResponseDto = {
2597
3981
  ]
2598
3982
  } as const;
2599
3983
 
3984
+ export const $UpdateTransactionRuleDto = {
3985
+ type: 'object',
3986
+ properties: {
3987
+ name: {
3988
+ type: 'string',
3989
+ minLength: 1,
3990
+ maxLength: 100
3991
+ },
3992
+ description: {
3993
+ type: 'string',
3994
+ maxLength: 500
3995
+ },
3996
+ narrationKeywords: {
3997
+ items: {
3998
+ type: 'array'
3999
+ },
4000
+ maxItems: 50,
4001
+ type: 'array'
4002
+ },
4003
+ payeeKeywords: {
4004
+ items: {
4005
+ type: 'array'
4006
+ },
4007
+ maxItems: 50,
4008
+ type: 'array'
4009
+ },
4010
+ categoryKeywords: {
4011
+ items: {
4012
+ type: 'array'
4013
+ },
4014
+ maxItems: 50,
4015
+ type: 'array'
4016
+ },
4017
+ methodKeywords: {
4018
+ items: {
4019
+ type: 'array'
4020
+ },
4021
+ maxItems: 50,
4022
+ description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
4023
+ type: 'array'
4024
+ },
4025
+ categoryAccount: {
4026
+ type: 'string',
4027
+ maxLength: 200,
4028
+ description:
4029
+ 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
4030
+ },
4031
+ matchLogic: {
4032
+ type: 'string',
4033
+ enum: ['OR', 'AND']
4034
+ },
4035
+ amountMin: {
4036
+ type: 'number',
4037
+ minimum: 0,
4038
+ description: 'Minimum transaction amount (inclusive)'
4039
+ },
4040
+ amountMax: {
4041
+ type: 'number',
4042
+ minimum: 0,
4043
+ description: 'Maximum transaction amount (inclusive)'
4044
+ },
4045
+ priority: {
4046
+ type: 'number',
4047
+ minimum: 0,
4048
+ maximum: 1000
4049
+ },
4050
+ enabled: {
4051
+ type: 'boolean',
4052
+ description: 'Enable or disable the rule'
4053
+ },
4054
+ additionalTags: {
4055
+ items: {
4056
+ type: 'array'
4057
+ },
4058
+ maxItems: 20,
4059
+ type: 'array'
4060
+ },
4061
+ additionalMetadata: {
4062
+ type: 'object'
4063
+ }
4064
+ }
4065
+ } as const;
4066
+
2600
4067
  export const $TestRuleDto = {
2601
4068
  type: 'object',
2602
4069
  properties: {
@@ -2789,6 +4256,17 @@ export const $UpdateUserSettingDto = {
2789
4256
  }
2790
4257
  } as const;
2791
4258
 
4259
+ export const $UpdatePropertyDto = {
4260
+ type: 'object',
4261
+ properties: {
4262
+ value: {
4263
+ type: 'string',
4264
+ description: 'Property value'
4265
+ }
4266
+ },
4267
+ required: ['value']
4268
+ } as const;
4269
+
2792
4270
  export const $FileImportDto = {
2793
4271
  type: 'object',
2794
4272
  properties: {
@@ -3088,7 +4566,8 @@ export const $ImporterConfigDto = {
3088
4566
  'cmbc-credit',
3089
4567
  'icbc',
3090
4568
  'icbc-credit',
3091
- 'hsbc-hk'
4569
+ 'hsbc-hk-credit',
4570
+ 'hsbc-hk-debit'
3092
4571
  ]
3093
4572
  },
3094
4573
  version: {
@@ -3134,31 +4613,206 @@ export const $ImporterConfigDto = {
3134
4613
  ]
3135
4614
  } as const;
3136
4615
 
3137
- export const $ProviderSyncConfigDto = {
4616
+ export const $UpdateMapperDefaultsDto = {
3138
4617
  type: 'object',
3139
4618
  properties: {
3140
4619
  sourceAccount: {
3141
4620
  type: 'string',
3142
- description: 'Source account for the first posting',
3143
- example: 'Assets:Bank:Chase'
4621
+ description: 'Source account for transactions (Beancount format)',
4622
+ example: 'Assets:Alipay:Balance',
4623
+ pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
3144
4624
  },
3145
- defaultCurrency: {
4625
+ currency: {
3146
4626
  type: 'string',
3147
- description: 'Default currency for transactions',
3148
- example: 'USD'
4627
+ description: 'Default currency (ISO 4217 code)',
4628
+ example: 'CNY',
4629
+ minLength: 3,
4630
+ maxLength: 3,
4631
+ pattern: '^[A-Z]{3}$'
3149
4632
  },
3150
- defaultExpenseAccount: {
4633
+ expenseAccount: {
3151
4634
  type: 'string',
3152
- description: 'Default expense account for the second posting',
3153
- example: 'Expenses:Unknown'
4635
+ description: 'Default expense account (optional)',
4636
+ example: 'Expenses:Unknown',
4637
+ pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
3154
4638
  },
3155
- defaultIncomeAccount: {
4639
+ incomeAccount: {
3156
4640
  type: 'string',
3157
- description: 'Default income account for the second posting',
3158
- example: 'Income:Unknown'
4641
+ description: 'Default income account (optional)',
4642
+ example: 'Income:Unknown',
4643
+ pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
3159
4644
  },
3160
- filterPending: {
3161
- type: 'boolean',
4645
+ methodAccountMapping: {
4646
+ type: 'object',
4647
+ description:
4648
+ '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).',
4649
+ example: {
4650
+ HuaBei: 'Liabilities:Alipay:Huabei',
4651
+ CreditCard: 'Liabilities:CreditCard'
4652
+ }
4653
+ }
4654
+ }
4655
+ } as const;
4656
+
4657
+ export const $UpdateConfigDataDto = {
4658
+ type: 'object',
4659
+ properties: {
4660
+ defaults: {
4661
+ description: 'Mapper defaults configuration',
4662
+ allOf: [
4663
+ {
4664
+ $ref: '#/components/schemas/UpdateMapperDefaultsDto'
4665
+ }
4666
+ ]
4667
+ }
4668
+ }
4669
+ } as const;
4670
+
4671
+ export const $UpdateImporterConfigDto = {
4672
+ type: 'object',
4673
+ properties: {
4674
+ data: {
4675
+ description: 'Configuration data (v1 schema)',
4676
+ allOf: [
4677
+ {
4678
+ $ref: '#/components/schemas/UpdateConfigDataDto'
4679
+ }
4680
+ ]
4681
+ }
4682
+ }
4683
+ } as const;
4684
+
4685
+ export const $CreatePlatformDto = {
4686
+ type: 'object',
4687
+ properties: {
4688
+ name: {
4689
+ type: 'string',
4690
+ description: 'Platform name',
4691
+ example: 'Binance'
4692
+ },
4693
+ canonical: {
4694
+ type: 'string',
4695
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
4696
+ example: 'binance'
4697
+ },
4698
+ aliases: {
4699
+ description: 'Platform aliases (multi-language names for lookup)',
4700
+ example: ['Binance', 'Binance Exchange', 'BNB'],
4701
+ type: 'array',
4702
+ items: {
4703
+ type: 'string'
4704
+ }
4705
+ },
4706
+ url: {
4707
+ type: 'string',
4708
+ description: 'Platform URL',
4709
+ example: 'https://www.binance.com'
4710
+ },
4711
+ type: {
4712
+ type: 'string',
4713
+ description: 'Platform type',
4714
+ enum: [
4715
+ 'BANK',
4716
+ 'BROKERAGE',
4717
+ 'CRYPTO_EXCHANGE',
4718
+ 'PAYMENT',
4719
+ 'INVESTMENT',
4720
+ 'INSURANCE',
4721
+ 'OTHER'
4722
+ ],
4723
+ example: 'CRYPTO_EXCHANGE'
4724
+ },
4725
+ logoUrl: {
4726
+ type: 'string',
4727
+ description: 'Platform logo URL',
4728
+ example: 'https://example.com/logos/binance.png'
4729
+ },
4730
+ isActive: {
4731
+ type: 'boolean',
4732
+ description: 'Whether the platform is active',
4733
+ default: true
4734
+ }
4735
+ },
4736
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
4737
+ } as const;
4738
+
4739
+ export const $UpdatePlatformDto = {
4740
+ type: 'object',
4741
+ properties: {
4742
+ name: {
4743
+ type: 'string',
4744
+ description: 'Platform name',
4745
+ example: 'Binance'
4746
+ },
4747
+ canonical: {
4748
+ type: 'string',
4749
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
4750
+ example: 'binance'
4751
+ },
4752
+ aliases: {
4753
+ description: 'Platform aliases (multi-language names for lookup)',
4754
+ example: ['Binance', 'Binance Exchange', 'BNB'],
4755
+ type: 'array',
4756
+ items: {
4757
+ type: 'string'
4758
+ }
4759
+ },
4760
+ url: {
4761
+ type: 'string',
4762
+ description: 'Platform URL',
4763
+ example: 'https://www.binance.com'
4764
+ },
4765
+ type: {
4766
+ type: 'string',
4767
+ description: 'Platform type',
4768
+ enum: [
4769
+ 'BANK',
4770
+ 'BROKERAGE',
4771
+ 'CRYPTO_EXCHANGE',
4772
+ 'PAYMENT',
4773
+ 'INVESTMENT',
4774
+ 'INSURANCE',
4775
+ 'OTHER'
4776
+ ],
4777
+ example: 'CRYPTO_EXCHANGE'
4778
+ },
4779
+ logoUrl: {
4780
+ type: 'string',
4781
+ description: 'Platform logo URL',
4782
+ example: 'https://example.com/logos/binance.png'
4783
+ },
4784
+ isActive: {
4785
+ type: 'boolean',
4786
+ description: 'Whether the platform is active'
4787
+ }
4788
+ }
4789
+ } as const;
4790
+
4791
+ export const $ProviderSyncConfigDto = {
4792
+ type: 'object',
4793
+ properties: {
4794
+ sourceAccount: {
4795
+ type: 'string',
4796
+ description: 'Source account for the first posting',
4797
+ example: 'Assets:Bank:Chase'
4798
+ },
4799
+ defaultCurrency: {
4800
+ type: 'string',
4801
+ description: 'Default currency for transactions',
4802
+ example: 'USD'
4803
+ },
4804
+ defaultExpenseAccount: {
4805
+ type: 'string',
4806
+ description: 'Default expense account for the second posting',
4807
+ example: 'Expenses:Unknown'
4808
+ },
4809
+ defaultIncomeAccount: {
4810
+ type: 'string',
4811
+ description: 'Default income account for the second posting',
4812
+ example: 'Income:Unknown'
4813
+ },
4814
+ filterPending: {
4815
+ type: 'boolean',
3162
4816
  description: 'Filter pending transactions',
3163
4817
  default: true
3164
4818
  }
@@ -3268,7 +4922,8 @@ export const $SupportedProvidersResponseDto = {
3268
4922
  'gocardless',
3269
4923
  'simplefin',
3270
4924
  'yodlee',
3271
- 'beancount-direct'
4925
+ 'beancount-direct',
4926
+ 'parsed-bill'
3272
4927
  ],
3273
4928
  type: 'array',
3274
4929
  items: {
@@ -3279,6 +4934,16 @@ export const $SupportedProvidersResponseDto = {
3279
4934
  required: ['providers']
3280
4935
  } as const;
3281
4936
 
4937
+ export const $ParserTelemetryReportDto = {
4938
+ type: 'object',
4939
+ properties: {}
4940
+ } as const;
4941
+
4942
+ export const $UncoveredFormatMissDto = {
4943
+ type: 'object',
4944
+ properties: {}
4945
+ } as const;
4946
+
3282
4947
  export const $ProcessNlpDto = {
3283
4948
  type: 'object',
3284
4949
  properties: {
@@ -3293,6 +4958,16 @@ export const $ProcessNlpDto = {
3293
4958
  description:
3294
4959
  'Session ID for multi-turn conversation (auto-generated if not provided)',
3295
4960
  example: 'session_abc123'
4961
+ },
4962
+ parsedData: {
4963
+ type: 'object',
4964
+ description:
4965
+ 'Parsed data from previous NLP response for session recovery. Send back the parsedData received in confirm_payee/confirm responses.',
4966
+ example: {
4967
+ amount: 35,
4968
+ currency: 'CNY',
4969
+ payee: 'Starbucks'
4970
+ }
3296
4971
  }
3297
4972
  },
3298
4973
  required: ['message']
@@ -3942,181 +5617,728 @@ export const $NlpResponseDto = {
3942
5617
  },
3943
5618
  messageKey: {
3944
5619
  type: 'string',
3945
- description:
3946
- 'i18n message key for frontend translation. Use this instead of message for internationalization support.',
3947
- example: 'nlp.slot.prompt'
5620
+ description:
5621
+ 'i18n message key for frontend translation. Use this instead of message for internationalization support.',
5622
+ example: 'nlp.slot.prompt'
5623
+ },
5624
+ messageParams: {
5625
+ type: 'object',
5626
+ description:
5627
+ 'Parameters for message interpolation. Used with messageKey for dynamic values in translated messages.',
5628
+ example: {
5629
+ slot: 'amount',
5630
+ name: 'Starbucks',
5631
+ similarity: 85
5632
+ }
5633
+ },
5634
+ sessionId: {
5635
+ type: 'string',
5636
+ description:
5637
+ 'Session ID for multi-turn dialogue. Must be included in subsequent requests to continue the conversation.',
5638
+ example: 'session_abc123'
5639
+ },
5640
+ waitingFor: {
5641
+ type: 'string',
5642
+ description: 'Which slot is waiting for user input',
5643
+ example: 'amount'
5644
+ },
5645
+ transaction: {
5646
+ description: 'Created transaction info (for created action)',
5647
+ allOf: [
5648
+ {
5649
+ $ref: '#/components/schemas/NlpTransactionInfoDto'
5650
+ }
5651
+ ]
5652
+ },
5653
+ parsedData: {
5654
+ description:
5655
+ 'Parsed data for confirmation (when action is "confirm"). Contains extracted fields that user should verify before transaction creation.',
5656
+ allOf: [
5657
+ {
5658
+ $ref: '#/components/schemas/NlpParsedDataDto'
5659
+ }
5660
+ ]
5661
+ },
5662
+ duplicateData: {
5663
+ description:
5664
+ 'Duplicate detection data (when action is "confirm_duplicate"). Contains information about potential duplicate transaction for user confirmation.',
5665
+ allOf: [
5666
+ {
5667
+ $ref: '#/components/schemas/NlpDuplicateConfirmationDataDto'
5668
+ }
5669
+ ]
5670
+ },
5671
+ ruleData: {
5672
+ description:
5673
+ 'Rule match data (when action is "confirm_rule"). Contains information about medium-confidence rule match for user confirmation.',
5674
+ allOf: [
5675
+ {
5676
+ $ref: '#/components/schemas/NlpRuleConfirmationDataDto'
5677
+ }
5678
+ ]
5679
+ },
5680
+ accountData: {
5681
+ description:
5682
+ 'Account validation data (when action is "confirm_account"). Contains information about invalid account for user correction.',
5683
+ allOf: [
5684
+ {
5685
+ $ref: '#/components/schemas/NlpAccountConfirmationDataDto'
5686
+ }
5687
+ ]
5688
+ },
5689
+ payeeData: {
5690
+ description:
5691
+ 'Payee confirmation data (when action is "confirm_payee"). Contains information about medium/low confidence payee match for user confirmation.',
5692
+ allOf: [
5693
+ {
5694
+ $ref: '#/components/schemas/NlpPayeeConfirmationDataDto'
5695
+ }
5696
+ ]
5697
+ },
5698
+ confidence: {
5699
+ type: 'number',
5700
+ description: 'Overall confidence score (0-1)',
5701
+ example: 0.85
5702
+ },
5703
+ confidenceThreshold: {
5704
+ type: 'number',
5705
+ description:
5706
+ 'Confidence threshold for automatic creation (default: 0.75). When confidence < threshold, action will be "confirm" requiring user verification.',
5707
+ example: 0.75
5708
+ },
5709
+ recurringMatch: {
5710
+ description:
5711
+ 'Recurring transaction match info (when action is "created"). Contains match details when transaction matches a pending expected transaction.',
5712
+ allOf: [
5713
+ {
5714
+ $ref: '#/components/schemas/RecurringMatchInfoDto'
5715
+ }
5716
+ ]
5717
+ },
5718
+ recurringSuggestion: {
5719
+ description:
5720
+ 'Recurring rule creation suggestion (when action is "created"). Contains suggestion to create a recurring rule based on detected patterns. Only present when no existing rule matched and similar historical transactions were found.',
5721
+ allOf: [
5722
+ {
5723
+ $ref: '#/components/schemas/RecurringSuggestionDto'
5724
+ }
5725
+ ]
5726
+ },
5727
+ suggestedAccounts: {
5728
+ description:
5729
+ 'Suggested accounts for this transaction. Contains recommended source and destination accounts based on the detected intent and rules.',
5730
+ allOf: [
5731
+ {
5732
+ $ref: '#/components/schemas/NlpSuggestedAccountsDto'
5733
+ }
5734
+ ]
5735
+ },
5736
+ defaultAccounts: {
5737
+ description:
5738
+ 'Default accounts for the user/region. These are fallback accounts used when no specific suggestion is available.',
5739
+ allOf: [
5740
+ {
5741
+ $ref: '#/components/schemas/NlpDefaultAccountsDto'
5742
+ }
5743
+ ]
5744
+ }
5745
+ },
5746
+ required: ['status', 'action']
5747
+ } as const;
5748
+
5749
+ export const $BalanceByCurrencyDto = {
5750
+ type: 'object',
5751
+ properties: {
5752
+ currency: {
5753
+ type: 'string',
5754
+ description: 'ISO 4217 currency code',
5755
+ example: 'CNY'
5756
+ },
5757
+ balance: {
5758
+ type: 'string',
5759
+ description: 'Balance amount',
5760
+ example: '50000.00'
5761
+ }
5762
+ },
5763
+ required: ['currency', 'balance']
5764
+ } as const;
5765
+
5766
+ export const $NetWorthByCurrencyDto = {
5767
+ type: 'object',
5768
+ properties: {
5769
+ netWorth: {
5770
+ description: 'Net worth by currency',
5771
+ type: 'array',
5772
+ items: {
5773
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
5774
+ }
5775
+ },
5776
+ assets: {
5777
+ description: 'Assets by currency',
5778
+ type: 'array',
5779
+ items: {
5780
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
5781
+ }
5782
+ },
5783
+ liabilities: {
5784
+ description: 'Liabilities by currency',
5785
+ type: 'array',
5786
+ items: {
5787
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
5788
+ }
5789
+ }
5790
+ },
5791
+ required: ['netWorth', 'assets', 'liabilities']
5792
+ } as const;
5793
+
5794
+ export const $ConvertedNetWorthDto = {
5795
+ type: 'object',
5796
+ properties: {
5797
+ baseCurrency: {
5798
+ type: 'string',
5799
+ description: 'Base currency for conversion',
5800
+ example: 'CNY'
5801
+ },
5802
+ netWorth: {
5803
+ type: 'string',
5804
+ description: 'Converted net worth',
5805
+ example: '500000.00'
5806
+ },
5807
+ assets: {
5808
+ type: 'string',
5809
+ description: 'Converted assets',
5810
+ example: '600000.00'
5811
+ },
5812
+ liabilities: {
5813
+ type: 'string',
5814
+ description: 'Converted liabilities',
5815
+ example: '100000.00'
5816
+ },
5817
+ exchangeRates: {
5818
+ type: 'object',
5819
+ description: 'Exchange rates used for conversion',
5820
+ example: {
5821
+ USD: '7.200000',
5822
+ EUR: '7.800000'
5823
+ }
5824
+ }
5825
+ },
5826
+ required: [
5827
+ 'baseCurrency',
5828
+ 'netWorth',
5829
+ 'assets',
5830
+ 'liabilities',
5831
+ 'exchangeRates'
5832
+ ]
5833
+ } as const;
5834
+
5835
+ export const $ExchangeRateWarningDto = {
5836
+ type: 'object',
5837
+ properties: {
5838
+ type: {
5839
+ type: 'string',
5840
+ description: 'Warning type',
5841
+ example: 'MISSING_EXCHANGE_RATE'
5842
+ },
5843
+ currency: {
5844
+ type: 'string',
5845
+ description: 'Currency without exchange rate',
5846
+ example: 'EUR'
5847
+ },
5848
+ totalAmount: {
5849
+ type: 'string',
5850
+ description: 'Total amount affected',
5851
+ example: '1000.00'
5852
+ }
5853
+ },
5854
+ required: ['type', 'currency', 'totalAmount']
5855
+ } as const;
5856
+
5857
+ export const $NetWorthResponseDto = {
5858
+ type: 'object',
5859
+ properties: {
5860
+ netWorth: {
5861
+ type: 'string',
5862
+ description:
5863
+ 'Total net worth (assets - liabilities, converted to base currency)',
5864
+ example: '500000.00'
5865
+ },
5866
+ assets: {
5867
+ type: 'string',
5868
+ description: 'Total assets value (converted)',
5869
+ example: '600000.00'
5870
+ },
5871
+ liabilities: {
5872
+ type: 'string',
5873
+ description: 'Total liabilities value (positive number, converted)',
5874
+ example: '100000.00'
5875
+ },
5876
+ monthlyReturn: {
5877
+ type: 'string',
5878
+ description: 'Monthly return (change from last month)',
5879
+ example: '15000.00'
5880
+ },
5881
+ monthlyReturnPercentage: {
5882
+ type: 'string',
5883
+ description: 'Monthly return percentage',
5884
+ example: '3.15'
5885
+ },
5886
+ currency: {
5887
+ type: 'string',
5888
+ description: 'Base currency code',
5889
+ example: 'CNY'
5890
+ },
5891
+ asOf: {
5892
+ type: 'string',
5893
+ description: 'Data as of date (ISO 8601)',
5894
+ example: '2024-06-15T00:00:00.000Z'
5895
+ },
5896
+ byCurrency: {
5897
+ description: 'Balances grouped by original currency',
5898
+ allOf: [
5899
+ {
5900
+ $ref: '#/components/schemas/NetWorthByCurrencyDto'
5901
+ }
5902
+ ]
5903
+ },
5904
+ converted: {
5905
+ description:
5906
+ 'Converted values in base currency (undefined if no exchange rates available)',
5907
+ allOf: [
5908
+ {
5909
+ $ref: '#/components/schemas/ConvertedNetWorthDto'
5910
+ }
5911
+ ]
5912
+ },
5913
+ warnings: {
5914
+ description: 'Exchange rate warnings',
5915
+ type: 'array',
5916
+ items: {
5917
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
5918
+ }
5919
+ }
5920
+ },
5921
+ required: [
5922
+ 'netWorth',
5923
+ 'assets',
5924
+ 'liabilities',
5925
+ 'monthlyReturn',
5926
+ 'monthlyReturnPercentage',
5927
+ 'currency',
5928
+ 'asOf'
5929
+ ]
5930
+ } as const;
5931
+
5932
+ export const $AccountItemDto = {
5933
+ type: 'object',
5934
+ properties: {
5935
+ id: {
5936
+ type: 'string',
5937
+ description: 'Account ID'
5938
+ },
5939
+ name: {
5940
+ type: 'string',
5941
+ description: 'Full account name',
5942
+ example: 'Assets:Bank:CMB:Savings'
5943
+ },
5944
+ displayName: {
5945
+ type: 'string',
5946
+ description: 'Display name (last part of account path)',
5947
+ example: 'Savings'
5948
+ },
5949
+ balance: {
5950
+ type: 'string',
5951
+ description: 'Account balance',
5952
+ example: '50000.00'
5953
+ },
5954
+ currency: {
5955
+ type: 'string',
5956
+ description: 'Currency code',
5957
+ example: 'CNY'
5958
+ }
5959
+ },
5960
+ required: ['id', 'name', 'displayName', 'balance', 'currency']
5961
+ } as const;
5962
+
5963
+ export const $PlatformGroupDto = {
5964
+ type: 'object',
5965
+ properties: {
5966
+ platformId: {
5967
+ type: 'string',
5968
+ description: 'Platform ID'
5969
+ },
5970
+ platformName: {
5971
+ type: 'string',
5972
+ description: 'Platform display name',
5973
+ example: 'CMB Bank'
5974
+ },
5975
+ accounts: {
5976
+ description: 'Accounts within this platform',
5977
+ type: 'array',
5978
+ items: {
5979
+ $ref: '#/components/schemas/AccountItemDto'
5980
+ }
5981
+ },
5982
+ totalBalance: {
5983
+ type: 'string',
5984
+ description: 'Total balance across all accounts in platform',
5985
+ example: '100000.00'
5986
+ }
5987
+ },
5988
+ required: ['platformId', 'platformName', 'accounts', 'totalBalance']
5989
+ } as const;
5990
+
5991
+ export const $AccountsSummaryDto = {
5992
+ type: 'object',
5993
+ properties: {
5994
+ totalAccounts: {
5995
+ type: 'number',
5996
+ description: 'Total number of accounts'
5997
+ },
5998
+ totalPlatforms: {
5999
+ type: 'number',
6000
+ description: 'Total number of platforms'
6001
+ }
6002
+ },
6003
+ required: ['totalAccounts', 'totalPlatforms']
6004
+ } as const;
6005
+
6006
+ export const $AccountsResponseDto = {
6007
+ type: 'object',
6008
+ properties: {
6009
+ groups: {
6010
+ description: 'Account groups by platform',
6011
+ type: 'array',
6012
+ items: {
6013
+ $ref: '#/components/schemas/PlatformGroupDto'
6014
+ }
6015
+ },
6016
+ summary: {
6017
+ description: 'Summary statistics',
6018
+ allOf: [
6019
+ {
6020
+ $ref: '#/components/schemas/AccountsSummaryDto'
6021
+ }
6022
+ ]
6023
+ }
6024
+ },
6025
+ required: ['groups', 'summary']
6026
+ } as const;
6027
+
6028
+ export const $AccountItemWithAssetClassDto = {
6029
+ type: 'object',
6030
+ properties: {
6031
+ id: {
6032
+ type: 'string',
6033
+ description: 'Account ID'
6034
+ },
6035
+ name: {
6036
+ type: 'string',
6037
+ description: 'Full account name',
6038
+ example: 'Assets:Bank:CMB:Savings'
6039
+ },
6040
+ displayName: {
6041
+ type: 'string',
6042
+ description: 'Display name (last part of account path)',
6043
+ example: 'Savings'
6044
+ },
6045
+ balance: {
6046
+ type: 'string',
6047
+ description: 'Account balance',
6048
+ example: '50000.00'
6049
+ },
6050
+ currency: {
6051
+ type: 'string',
6052
+ description: 'Currency code',
6053
+ example: 'CNY'
6054
+ },
6055
+ assetClass: {
6056
+ type: 'string',
6057
+ description: 'Asset class',
6058
+ example: 'LIQUIDITY'
6059
+ },
6060
+ assetSubClass: {
6061
+ type: 'string',
6062
+ description: 'Asset sub-class (Prisma-compatible)',
6063
+ example: 'RETIREMENT_ACCOUNT'
6064
+ },
6065
+ regionalSubClass: {
6066
+ type: 'string',
6067
+ description: 'Regional sub-class (region-specific, for display)',
6068
+ example: 'FOUR_ZERO_ONE_K'
6069
+ },
6070
+ riskLevel: {
6071
+ type: 'string',
6072
+ description: 'Risk level',
6073
+ example: 'LOW'
6074
+ },
6075
+ source: {
6076
+ type: 'string',
6077
+ description:
6078
+ 'ADR-0105 classification provenance (holding level always; account level only on FALLBACK)',
6079
+ enum: ['USER_META', 'FIAT_CURRENCY', 'OPENBB_MAPPING', 'FALLBACK']
6080
+ }
6081
+ },
6082
+ required: ['id', 'name', 'displayName', 'balance', 'currency', 'assetClass']
6083
+ } as const;
6084
+
6085
+ export const $AssetClassGroupDto = {
6086
+ type: 'object',
6087
+ properties: {
6088
+ assetClass: {
6089
+ type: 'string',
6090
+ description: 'Asset class name',
6091
+ example: 'LIQUIDITY',
6092
+ enum: [
6093
+ 'LIQUIDITY',
6094
+ 'EQUITY',
6095
+ 'FIXED_INCOME',
6096
+ 'PRECIOUS_METALS',
6097
+ 'COMMODITY',
6098
+ 'INSURANCE',
6099
+ 'ALTERNATIVE_INVESTMENT',
6100
+ 'PERSONAL_ASSETS',
6101
+ 'LIABILITY',
6102
+ 'REAL_ESTATE',
6103
+ 'INDEX'
6104
+ ]
6105
+ },
6106
+ assetSubClass: {
6107
+ type: 'string',
6108
+ description: 'Asset sub-class name',
6109
+ example: 'DEPOSIT'
6110
+ },
6111
+ accounts: {
6112
+ description: 'Accounts within this asset class',
6113
+ type: 'array',
6114
+ items: {
6115
+ $ref: '#/components/schemas/AccountItemWithAssetClassDto'
6116
+ }
6117
+ },
6118
+ balanceByCurrency: {
6119
+ description: 'Balances grouped by currency',
6120
+ type: 'array',
6121
+ items: {
6122
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
6123
+ }
6124
+ },
6125
+ convertedBalance: {
6126
+ type: 'string',
6127
+ description: 'Converted balance in base currency',
6128
+ example: '100000.00'
6129
+ }
6130
+ },
6131
+ required: ['assetClass', 'accounts', 'balanceByCurrency']
6132
+ } as const;
6133
+
6134
+ export const $AccountExchangeRateWarningDto = {
6135
+ type: 'object',
6136
+ properties: {
6137
+ type: {
6138
+ type: 'string',
6139
+ description: 'Warning type',
6140
+ example: 'MISSING_EXCHANGE_RATE'
6141
+ },
6142
+ currency: {
6143
+ type: 'string',
6144
+ description: 'Currency without exchange rate',
6145
+ example: 'USD'
3948
6146
  },
3949
- messageParams: {
3950
- type: 'object',
3951
- description:
3952
- 'Parameters for message interpolation. Used with messageKey for dynamic values in translated messages.',
3953
- example: {
3954
- slot: 'amount',
3955
- name: 'Starbucks',
3956
- similarity: 85
6147
+ accounts: {
6148
+ description: 'Affected account paths',
6149
+ type: 'array',
6150
+ items: {
6151
+ type: 'string'
3957
6152
  }
3958
6153
  },
3959
- sessionId: {
6154
+ totalAmount: {
3960
6155
  type: 'string',
3961
- description:
3962
- 'Session ID for multi-turn dialogue. Must be included in subsequent requests to continue the conversation.',
3963
- example: 'session_abc123'
6156
+ description: 'Total amount in this currency',
6157
+ example: '5000.00'
6158
+ }
6159
+ },
6160
+ required: ['type', 'currency', 'accounts', 'totalAmount']
6161
+ } as const;
6162
+
6163
+ export const $AssetClassSummaryDto = {
6164
+ type: 'object',
6165
+ properties: {
6166
+ totalAccounts: {
6167
+ type: 'number',
6168
+ description: 'Total number of accounts'
3964
6169
  },
3965
- waitingFor: {
6170
+ totalAssetClasses: {
6171
+ type: 'number',
6172
+ description: 'Total number of asset classes'
6173
+ },
6174
+ baseCurrency: {
3966
6175
  type: 'string',
3967
- description: 'Which slot is waiting for user input',
3968
- example: 'amount'
6176
+ description: 'Base currency for conversion',
6177
+ example: 'CNY'
3969
6178
  },
3970
- transaction: {
3971
- description: 'Created transaction info (for created action)',
3972
- allOf: [
3973
- {
3974
- $ref: '#/components/schemas/NlpTransactionInfoDto'
3975
- }
3976
- ]
6179
+ warnings: {
6180
+ description: 'Exchange rate warnings',
6181
+ type: 'array',
6182
+ items: {
6183
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
6184
+ }
3977
6185
  },
3978
- parsedData: {
6186
+ fallback: {
6187
+ type: 'object',
3979
6188
  description:
3980
- 'Parsed data for confirmation (when action is "confirm"). Contains extracted fields that user should verify before transaction creation.',
3981
- allOf: [
3982
- {
3983
- $ref: '#/components/schemas/NlpParsedDataDto'
3984
- }
3985
- ]
6189
+ '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.'
6190
+ }
6191
+ },
6192
+ required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
6193
+ } as const;
6194
+
6195
+ export const $AssetClassAccountsResponseDto = {
6196
+ type: 'object',
6197
+ properties: {
6198
+ groups: {
6199
+ description: 'Account groups by asset class',
6200
+ type: 'array',
6201
+ items: {
6202
+ $ref: '#/components/schemas/AssetClassGroupDto'
6203
+ }
3986
6204
  },
3987
- duplicateData: {
3988
- description:
3989
- 'Duplicate detection data (when action is "confirm_duplicate"). Contains information about potential duplicate transaction for user confirmation.',
6205
+ summary: {
6206
+ description: 'Summary statistics',
3990
6207
  allOf: [
3991
6208
  {
3992
- $ref: '#/components/schemas/NlpDuplicateConfirmationDataDto'
6209
+ $ref: '#/components/schemas/AssetClassSummaryDto'
3993
6210
  }
3994
6211
  ]
3995
6212
  },
3996
- ruleData: {
6213
+ uncategorized: {
3997
6214
  description:
3998
- 'Rule match data (when action is "confirm_rule"). Contains information about medium-confidence rule match for user confirmation.',
6215
+ 'ADR-0105 §6 holding-level grey-area bucket (source=FALLBACK holdings peeled out of groups). Present only for groupBy=holdingAssetClass when FALLBACK holdings exist.',
3999
6216
  allOf: [
4000
6217
  {
4001
- $ref: '#/components/schemas/NlpRuleConfirmationDataDto'
6218
+ $ref: '#/components/schemas/AssetClassGroupDto'
4002
6219
  }
4003
6220
  ]
6221
+ }
6222
+ },
6223
+ required: ['groups', 'summary']
6224
+ } as const;
6225
+
6226
+ export const $HoldingAssetClassAccountSliceDto = {
6227
+ type: 'object',
6228
+ properties: {
6229
+ accountId: {
6230
+ type: 'string',
6231
+ description: 'Account ID'
4004
6232
  },
4005
- accountData: {
4006
- description:
4007
- 'Account validation data (when action is "confirm_account"). Contains information about invalid account for user correction.',
4008
- allOf: [
4009
- {
4010
- $ref: '#/components/schemas/NlpAccountConfirmationDataDto'
4011
- }
4012
- ]
6233
+ accountPath: {
6234
+ type: 'string',
6235
+ description: 'Full account path',
6236
+ example: 'Assets:US:Investments:Brokerage'
4013
6237
  },
4014
- payeeData: {
6238
+ accountCurrency: {
6239
+ type: 'string',
4015
6240
  description:
4016
- 'Payee confirmation data (when action is "confirm_payee"). Contains information about medium/low confidence payee match for user confirmation.',
4017
- allOf: [
4018
- {
4019
- $ref: '#/components/schemas/NlpPayeeConfirmationDataDto'
4020
- }
4021
- ]
4022
- },
4023
- confidence: {
4024
- type: 'number',
4025
- description: 'Overall confidence score (0-1)',
4026
- example: 0.85
6241
+ 'Currency of the holding with the largest converted base value; undefined when no holding is convertible',
6242
+ example: 'USD'
4027
6243
  },
4028
- confidenceThreshold: {
4029
- type: 'number',
6244
+ marketValueBase: {
6245
+ type: 'string',
4030
6246
  description:
4031
- 'Confidence threshold for automatic creation (default: 0.75). When confidence < threshold, action will be "confirm" requiring user verification.',
4032
- example: 0.75
6247
+ "Account's market value in base currency (Σ converted holdings; grey bucket included)",
6248
+ example: '50000.00'
4033
6249
  },
4034
- recurringMatch: {
6250
+ shareOfTotalPct: {
6251
+ type: 'number',
4035
6252
  description:
4036
- 'Recurring transaction match info (when action is "created"). Contains match details when transaction matches a pending expected transaction.',
4037
- allOf: [
4038
- {
4039
- $ref: '#/components/schemas/RecurringMatchInfoDto'
4040
- }
4041
- ]
6253
+ 'Share of the global total (0-100). 0 when globalTotal is zero (no NaN/Infinity).',
6254
+ example: 42.5
4042
6255
  },
4043
- recurringSuggestion: {
4044
- description:
4045
- 'Recurring rule creation suggestion (when action is "created"). Contains suggestion to create a recurring rule based on detected patterns. Only present when no existing rule matched and similar historical transactions were found.',
4046
- allOf: [
4047
- {
4048
- $ref: '#/components/schemas/RecurringSuggestionDto'
4049
- }
4050
- ]
6256
+ groups: {
6257
+ description: 'Per-account asset-class breakdown',
6258
+ type: 'array',
6259
+ items: {
6260
+ $ref: '#/components/schemas/AssetClassGroupDto'
6261
+ }
4051
6262
  },
4052
- suggestedAccounts: {
6263
+ uncategorized: {
4053
6264
  description:
4054
- 'Suggested accounts for this transaction. Contains recommended source and destination accounts based on the detected intent and rules.',
6265
+ 'Per-account grey bucket (source=FALLBACK holdings, incl. broker cash)',
4055
6266
  allOf: [
4056
6267
  {
4057
- $ref: '#/components/schemas/NlpSuggestedAccountsDto'
6268
+ $ref: '#/components/schemas/AssetClassGroupDto'
4058
6269
  }
4059
6270
  ]
4060
6271
  },
4061
- defaultAccounts: {
6272
+ holdings: {
4062
6273
  description:
4063
- 'Default accounts for the user/region. These are fallback accounts used when no specific suggestion is available.',
4064
- allOf: [
4065
- {
4066
- $ref: '#/components/schemas/NlpDefaultAccountsDto'
4067
- }
4068
- ]
6274
+ 'Every holding row for this account (account ID in each row’s `id` field)',
6275
+ type: 'array',
6276
+ items: {
6277
+ $ref: '#/components/schemas/AccountItemWithAssetClassDto'
6278
+ }
4069
6279
  }
4070
6280
  },
4071
- required: ['status', 'action']
6281
+ required: [
6282
+ 'accountId',
6283
+ 'accountPath',
6284
+ 'marketValueBase',
6285
+ 'shareOfTotalPct',
6286
+ 'groups',
6287
+ 'holdings'
6288
+ ]
4072
6289
  } as const;
4073
6290
 
4074
- export const $BalanceByCurrencyDto = {
6291
+ export const $HoldingAssetClassCrossAccountResponseDto = {
4075
6292
  type: 'object',
4076
6293
  properties: {
4077
- currency: {
4078
- type: 'string',
4079
- description: 'ISO 4217 currency code',
4080
- example: 'CNY'
6294
+ global: {
6295
+ description: 'Merged cross-account holding aggregation',
6296
+ allOf: [
6297
+ {
6298
+ $ref: '#/components/schemas/AssetClassAccountsResponseDto'
6299
+ }
6300
+ ]
4081
6301
  },
4082
- balance: {
4083
- type: 'string',
4084
- description: 'Balance amount',
4085
- example: '50000.00'
6302
+ byAccount: {
6303
+ description: 'Per-account slices',
6304
+ type: 'array',
6305
+ items: {
6306
+ $ref: '#/components/schemas/HoldingAssetClassAccountSliceDto'
6307
+ }
4086
6308
  }
4087
6309
  },
4088
- required: ['currency', 'balance']
6310
+ required: ['global', 'byAccount']
4089
6311
  } as const;
4090
6312
 
4091
- export const $NetWorthByCurrencyDto = {
6313
+ export const $CashFlowByCurrencyDto = {
4092
6314
  type: 'object',
4093
6315
  properties: {
4094
- netWorth: {
4095
- description: 'Net worth by currency',
6316
+ income: {
6317
+ description: 'Income by currency',
4096
6318
  type: 'array',
4097
6319
  items: {
4098
6320
  $ref: '#/components/schemas/BalanceByCurrencyDto'
4099
6321
  }
4100
6322
  },
4101
- assets: {
4102
- description: 'Assets by currency',
6323
+ expense: {
6324
+ description: 'Expense by currency',
4103
6325
  type: 'array',
4104
6326
  items: {
4105
6327
  $ref: '#/components/schemas/BalanceByCurrencyDto'
4106
6328
  }
4107
6329
  },
4108
- liabilities: {
4109
- description: 'Liabilities by currency',
6330
+ netSavings: {
6331
+ description: 'Net savings by currency',
4110
6332
  type: 'array',
4111
6333
  items: {
4112
6334
  $ref: '#/components/schemas/BalanceByCurrencyDto'
4113
6335
  }
4114
6336
  }
4115
6337
  },
4116
- required: ['netWorth', 'assets', 'liabilities']
6338
+ required: ['income', 'expense', 'netSavings']
4117
6339
  } as const;
4118
6340
 
4119
- export const $ConvertedNetWorthDto = {
6341
+ export const $ConvertedCashFlowDto = {
4120
6342
  type: 'object',
4121
6343
  properties: {
4122
6344
  baseCurrency: {
@@ -4124,114 +6346,78 @@ export const $ConvertedNetWorthDto = {
4124
6346
  description: 'Base currency for conversion',
4125
6347
  example: 'CNY'
4126
6348
  },
4127
- netWorth: {
6349
+ income: {
4128
6350
  type: 'string',
4129
- description: 'Converted net worth',
4130
- example: '500000.00'
6351
+ description: 'Converted income',
6352
+ example: '25000.00'
4131
6353
  },
4132
- assets: {
6354
+ expense: {
4133
6355
  type: 'string',
4134
- description: 'Converted assets',
4135
- example: '600000.00'
6356
+ description: 'Converted expense',
6357
+ example: '18000.00'
4136
6358
  },
4137
- liabilities: {
6359
+ netSavings: {
4138
6360
  type: 'string',
4139
- description: 'Converted liabilities',
4140
- example: '100000.00'
6361
+ description: 'Converted net savings',
6362
+ example: '7000.00'
4141
6363
  },
4142
6364
  exchangeRates: {
4143
6365
  type: 'object',
4144
6366
  description: 'Exchange rates used for conversion',
4145
6367
  example: {
4146
- USD: '7.200000',
4147
- EUR: '7.800000'
6368
+ USD: '7.200000'
4148
6369
  }
4149
6370
  }
4150
6371
  },
4151
- required: [
4152
- 'baseCurrency',
4153
- 'netWorth',
4154
- 'assets',
4155
- 'liabilities',
4156
- 'exchangeRates'
4157
- ]
4158
- } as const;
4159
-
4160
- export const $ExchangeRateWarningDto = {
4161
- type: 'object',
4162
- properties: {
4163
- type: {
4164
- type: 'string',
4165
- description: 'Warning type',
4166
- example: 'MISSING_EXCHANGE_RATE'
4167
- },
4168
- currency: {
4169
- type: 'string',
4170
- description: 'Currency without exchange rate',
4171
- example: 'EUR'
4172
- },
4173
- totalAmount: {
4174
- type: 'string',
4175
- description: 'Total amount affected',
4176
- example: '1000.00'
4177
- }
4178
- },
4179
- required: ['type', 'currency', 'totalAmount']
6372
+ required: ['baseCurrency', 'income', 'expense', 'netSavings', 'exchangeRates']
4180
6373
  } as const;
4181
6374
 
4182
- export const $NetWorthResponseDto = {
6375
+ export const $CashFlowResponseDto = {
4183
6376
  type: 'object',
4184
6377
  properties: {
4185
- netWorth: {
6378
+ period: {
4186
6379
  type: 'string',
4187
- description:
4188
- 'Total net worth (assets - liabilities, converted to base currency)',
4189
- example: '500000.00'
6380
+ description: 'Period identifier (YYYY-MM)',
6381
+ example: '2024-06'
4190
6382
  },
4191
- assets: {
6383
+ income: {
4192
6384
  type: 'string',
4193
- description: 'Total assets value (converted)',
4194
- example: '600000.00'
6385
+ description: 'Total income for the period (converted)',
6386
+ example: '25000.00'
4195
6387
  },
4196
- liabilities: {
6388
+ expense: {
4197
6389
  type: 'string',
4198
- description: 'Total liabilities value (positive number, converted)',
4199
- example: '100000.00'
6390
+ description: 'Total expenses for the period (converted)',
6391
+ example: '18000.00'
4200
6392
  },
4201
- monthlyReturn: {
6393
+ netSavings: {
4202
6394
  type: 'string',
4203
- description: 'Monthly return (change from last month)',
4204
- example: '15000.00'
6395
+ description: 'Net savings (income - expense, converted)',
6396
+ example: '7000.00'
4205
6397
  },
4206
- monthlyReturnPercentage: {
6398
+ savingsRate: {
4207
6399
  type: 'string',
4208
- description: 'Monthly return percentage',
4209
- example: '3.15'
6400
+ description: 'Savings rate percentage (netSavings / income * 100)',
6401
+ example: '28.00'
4210
6402
  },
4211
6403
  currency: {
4212
6404
  type: 'string',
4213
6405
  description: 'Base currency code',
4214
6406
  example: 'CNY'
4215
6407
  },
4216
- asOf: {
4217
- type: 'string',
4218
- description: 'Data as of date (ISO 8601)',
4219
- example: '2024-06-15T00:00:00.000Z'
4220
- },
4221
6408
  byCurrency: {
4222
- description: 'Balances grouped by original currency',
6409
+ description: 'Cash flow grouped by original currency',
4223
6410
  allOf: [
4224
6411
  {
4225
- $ref: '#/components/schemas/NetWorthByCurrencyDto'
6412
+ $ref: '#/components/schemas/CashFlowByCurrencyDto'
4226
6413
  }
4227
6414
  ]
4228
6415
  },
4229
6416
  converted: {
4230
- description:
4231
- 'Converted values in base currency (undefined if no exchange rates available)',
6417
+ description: 'Converted values in base currency',
4232
6418
  allOf: [
4233
6419
  {
4234
- $ref: '#/components/schemas/ConvertedNetWorthDto'
6420
+ $ref: '#/components/schemas/ConvertedCashFlowDto'
4235
6421
  }
4236
6422
  ]
4237
6423
  },
@@ -4244,417 +6430,459 @@ export const $NetWorthResponseDto = {
4244
6430
  }
4245
6431
  },
4246
6432
  required: [
4247
- 'netWorth',
4248
- 'assets',
4249
- 'liabilities',
4250
- 'monthlyReturn',
4251
- 'monthlyReturnPercentage',
4252
- 'currency',
4253
- 'asOf'
6433
+ 'period',
6434
+ 'income',
6435
+ 'expense',
6436
+ 'netSavings',
6437
+ 'savingsRate',
6438
+ 'currency'
4254
6439
  ]
4255
6440
  } as const;
4256
6441
 
4257
- export const $AccountItemDto = {
6442
+ export const $MonetaryDto = {
4258
6443
  type: 'object',
4259
6444
  properties: {
4260
- id: {
4261
- type: 'string',
4262
- description: 'Account ID'
4263
- },
4264
- name: {
4265
- type: 'string',
4266
- description: 'Full account name',
4267
- example: 'Assets:Bank:CMB:Savings'
4268
- },
4269
- displayName: {
4270
- type: 'string',
4271
- description: 'Display name (last part of account path)',
4272
- example: 'Savings'
4273
- },
4274
- balance: {
6445
+ amount: {
4275
6446
  type: 'string',
4276
- description: 'Account balance',
4277
- example: '50000.00'
6447
+ description: 'Amount (Decimal string)',
6448
+ example: '3000'
4278
6449
  },
4279
6450
  currency: {
4280
6451
  type: 'string',
4281
- description: 'Currency code',
4282
- example: 'CNY'
6452
+ description: 'ISO 4217 currency',
6453
+ example: 'USD'
6454
+ },
6455
+ baseCcyEquivalent: {
6456
+ type: 'object',
6457
+ description: 'Converted to user base currency (Decimal string)',
6458
+ example: '21600',
6459
+ nullable: true
4283
6460
  }
4284
6461
  },
4285
- required: ['id', 'name', 'displayName', 'balance', 'currency']
6462
+ required: ['amount', 'currency']
4286
6463
  } as const;
4287
6464
 
4288
- export const $PlatformGroupDto = {
6465
+ export const $CurrentPriceDto = {
4289
6466
  type: 'object',
4290
6467
  properties: {
4291
- platformId: {
6468
+ amount: {
4292
6469
  type: 'string',
4293
- description: 'Platform ID'
6470
+ description: 'Price amount (Decimal string)',
6471
+ example: '250'
4294
6472
  },
4295
- platformName: {
6473
+ currency: {
4296
6474
  type: 'string',
4297
- description: 'Platform display name',
4298
- example: 'CMB Bank'
6475
+ description: 'Price currency (ISO 4217)',
6476
+ example: 'USD'
4299
6477
  },
4300
- accounts: {
4301
- description: 'Accounts within this platform',
4302
- type: 'array',
4303
- items: {
4304
- $ref: '#/components/schemas/AccountItemDto'
4305
- }
6478
+ date: {
6479
+ type: 'string',
6480
+ description: 'Price date (ISO 8601)',
6481
+ example: '2024-06-01'
4306
6482
  },
4307
- totalBalance: {
6483
+ source: {
4308
6484
  type: 'string',
4309
- description: 'Total balance across all accounts in platform',
4310
- example: '100000.00'
6485
+ description: 'Price source',
6486
+ example: 'USER_OVERRIDE',
6487
+ enum: ['USER_OVERRIDE', 'OPENBB_EQUITY', 'OPENBB_CURRENCY']
4311
6488
  }
4312
6489
  },
4313
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
6490
+ required: ['amount', 'currency', 'date', 'source']
4314
6491
  } as const;
4315
6492
 
4316
- export const $AccountsSummaryDto = {
6493
+ export const $FxRateDto = {
4317
6494
  type: 'object',
4318
6495
  properties: {
4319
- totalAccounts: {
4320
- type: 'number',
4321
- description: 'Total number of accounts'
6496
+ from: {
6497
+ type: 'string',
6498
+ example: 'USD'
4322
6499
  },
4323
- totalPlatforms: {
4324
- type: 'number',
4325
- description: 'Total number of platforms'
4326
- }
4327
- },
4328
- required: ['totalAccounts', 'totalPlatforms']
4329
- } as const;
4330
-
4331
- export const $AccountsResponseDto = {
4332
- type: 'object',
4333
- properties: {
4334
- groups: {
4335
- description: 'Account groups by platform',
4336
- type: 'array',
4337
- items: {
4338
- $ref: '#/components/schemas/PlatformGroupDto'
4339
- }
6500
+ to: {
6501
+ type: 'string',
6502
+ example: 'CNY'
4340
6503
  },
4341
- summary: {
4342
- description: 'Summary statistics',
4343
- allOf: [
4344
- {
4345
- $ref: '#/components/schemas/AccountsSummaryDto'
4346
- }
4347
- ]
6504
+ rate: {
6505
+ type: 'string',
6506
+ description: 'FX rate (Decimal string)',
6507
+ example: '7.2'
6508
+ },
6509
+ date: {
6510
+ type: 'string',
6511
+ description: 'Rate date (ISO 8601)',
6512
+ example: '2024-01-15'
4348
6513
  }
4349
6514
  },
4350
- required: ['groups', 'summary']
6515
+ required: ['from', 'to', 'rate', 'date']
4351
6516
  } as const;
4352
6517
 
4353
- export const $AccountItemWithAssetClassDto = {
6518
+ export const $HoldingPnlRowDto = {
4354
6519
  type: 'object',
4355
6520
  properties: {
4356
- id: {
6521
+ accountId: {
4357
6522
  type: 'string',
4358
- description: 'Account ID'
6523
+ description: 'Account UUID',
6524
+ example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
4359
6525
  },
4360
- name: {
6526
+ accountPath: {
4361
6527
  type: 'string',
4362
- description: 'Full account name',
4363
- example: 'Assets:Bank:CMB:Savings'
6528
+ description: 'Full account path',
6529
+ example: 'Assets:US:Broker:AAPL'
4364
6530
  },
4365
- displayName: {
4366
- type: 'string',
4367
- description: 'Display name (last part of account path)',
4368
- example: 'Savings'
6531
+ accountCcy: {
6532
+ type: 'object',
6533
+ description: 'Account settlement currency (ISO 4217), from cost currency',
6534
+ nullable: true,
6535
+ example: 'USD'
4369
6536
  },
4370
- balance: {
6537
+ brokerType: {
6538
+ type: 'object',
6539
+ description: 'Broker type derived from Platform.type',
6540
+ nullable: true,
6541
+ example: 'broker'
6542
+ },
6543
+ symbol: {
4371
6544
  type: 'string',
4372
- description: 'Account balance',
4373
- example: '50000.00'
6545
+ description: 'Commodity symbol',
6546
+ example: 'AAPL'
4374
6547
  },
4375
- currency: {
6548
+ chartToken: {
4376
6549
  type: 'string',
4377
- description: 'Currency code',
4378
- example: 'CNY'
6550
+ description: 'Chart segment token (libs/common resolver)',
6551
+ example: 'equity',
6552
+ enum: ['equity', 'fund', 'bond', 'cash', 'other']
4379
6553
  },
4380
6554
  assetClass: {
4381
6555
  type: 'string',
4382
- description: 'Asset class',
4383
- example: 'LIQUIDITY'
6556
+ example: 'EQUITY'
4384
6557
  },
4385
6558
  assetSubClass: {
4386
- type: 'string',
4387
- description: 'Asset sub-class (Prisma-compatible)',
4388
- example: 'RETIREMENT_ACCOUNT'
6559
+ type: 'object',
6560
+ nullable: true,
6561
+ example: 'STOCK'
4389
6562
  },
4390
- regionalSubClass: {
6563
+ units: {
4391
6564
  type: 'string',
4392
- description: 'Regional sub-class (region-specific, for display)',
4393
- example: 'FOUR_ZERO_ONE_K'
6565
+ description: 'Net held units (Decimal string)',
6566
+ example: '12'
4394
6567
  },
4395
- riskLevel: {
4396
- type: 'string',
4397
- description: 'Risk level',
4398
- example: 'LOW'
4399
- }
4400
- },
4401
- required: ['id', 'name', 'displayName', 'balance', 'currency', 'assetClass']
4402
- } as const;
4403
-
4404
- export const $AssetClassGroupDto = {
4405
- type: 'object',
4406
- properties: {
4407
- assetClass: {
4408
- type: 'string',
4409
- description: 'Asset class name',
4410
- example: 'LIQUIDITY',
4411
- enum: [
4412
- 'LIQUIDITY',
4413
- 'EQUITY',
4414
- 'FIXED_INCOME',
4415
- 'PRECIOUS_METALS',
4416
- 'COMMODITY',
4417
- 'INSURANCE',
4418
- 'ALTERNATIVE_INVESTMENT',
4419
- 'PERSONAL_ASSETS',
4420
- 'LIABILITY',
4421
- 'REAL_ESTATE',
4422
- 'INDEX'
6568
+ averageCostPerUnit: {
6569
+ description:
6570
+ 'Average cost per unit; null when cost currency conflicts or no cost',
6571
+ nullable: true,
6572
+ allOf: [
6573
+ {
6574
+ $ref: '#/components/schemas/MonetaryDto'
6575
+ }
4423
6576
  ]
4424
6577
  },
4425
- assetSubClass: {
4426
- type: 'string',
4427
- description: 'Asset sub-class name',
4428
- example: 'DEPOSIT'
6578
+ costBasis: {
6579
+ description: 'Cost basis of held units',
6580
+ nullable: true,
6581
+ allOf: [
6582
+ {
6583
+ $ref: '#/components/schemas/MonetaryDto'
6584
+ }
6585
+ ]
4429
6586
  },
4430
- accounts: {
4431
- description: 'Accounts within this asset class',
4432
- type: 'array',
4433
- items: {
4434
- $ref: '#/components/schemas/AccountItemWithAssetClassDto'
4435
- }
6587
+ marketValue: {
6588
+ description: 'Market value at asOf price',
6589
+ nullable: true,
6590
+ allOf: [
6591
+ {
6592
+ $ref: '#/components/schemas/MonetaryDto'
6593
+ }
6594
+ ]
6595
+ },
6596
+ currentPrice: {
6597
+ description: 'Price used for market value',
6598
+ nullable: true,
6599
+ allOf: [
6600
+ {
6601
+ $ref: '#/components/schemas/CurrentPriceDto'
6602
+ }
6603
+ ]
6604
+ },
6605
+ unrealizedPnlBase: {
6606
+ type: 'object',
6607
+ description:
6608
+ 'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
6609
+ nullable: true,
6610
+ example: '6000'
6611
+ },
6612
+ unrealizedPnlPct: {
6613
+ type: 'object',
6614
+ description: 'Unrealized P&L % (Decimal string)',
6615
+ nullable: true,
6616
+ example: '25'
6617
+ },
6618
+ costFxRate: {
6619
+ description: 'Historical FX rate applied to cost basis',
6620
+ nullable: true,
6621
+ allOf: [
6622
+ {
6623
+ $ref: '#/components/schemas/FxRateDto'
6624
+ }
6625
+ ]
6626
+ },
6627
+ marketFxRate: {
6628
+ description: 'FX rate applied to market value',
6629
+ nullable: true,
6630
+ allOf: [
6631
+ {
6632
+ $ref: '#/components/schemas/FxRateDto'
6633
+ }
6634
+ ]
4436
6635
  },
4437
- balanceByCurrency: {
4438
- description: 'Balances grouped by currency',
4439
- type: 'array',
4440
- items: {
4441
- $ref: '#/components/schemas/BalanceByCurrencyDto'
4442
- }
6636
+ pctOfInvestedAssets: {
6637
+ type: 'object',
6638
+ description:
6639
+ 'Share of invested assets % (Decimal string); only for invested chartTokens',
6640
+ nullable: true,
6641
+ example: '40'
4443
6642
  },
4444
- convertedBalance: {
4445
- type: 'string',
4446
- description: 'Converted balance in base currency',
4447
- example: '100000.00'
6643
+ realizedPnl: {
6644
+ description:
6645
+ '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',
6646
+ nullable: true,
6647
+ allOf: [
6648
+ {
6649
+ $ref: '#/components/schemas/MonetaryDto'
6650
+ }
6651
+ ]
4448
6652
  }
4449
6653
  },
4450
- required: ['assetClass', 'accounts', 'balanceByCurrency']
6654
+ required: [
6655
+ 'accountId',
6656
+ 'accountPath',
6657
+ 'symbol',
6658
+ 'chartToken',
6659
+ 'assetClass',
6660
+ 'units'
6661
+ ]
4451
6662
  } as const;
4452
6663
 
4453
- export const $AccountExchangeRateWarningDto = {
6664
+ export const $HoldingPnlWarningDto = {
4454
6665
  type: 'object',
4455
6666
  properties: {
4456
6667
  type: {
4457
6668
  type: 'string',
4458
6669
  description: 'Warning type',
4459
- example: 'MISSING_EXCHANGE_RATE'
6670
+ example: 'MISSING_COST_FX_RATE',
6671
+ enum: [
6672
+ 'MISSING_COST_FX_RATE',
6673
+ 'MISSING_MARKET_FX_RATE',
6674
+ 'MISSING_SALE_PRICE',
6675
+ 'MISSING_REALIZED_FX_RATE',
6676
+ 'OVERSOLD_LOTS',
6677
+ 'NO_PRICE',
6678
+ 'MIXED_COST_CURRENCY'
6679
+ ]
4460
6680
  },
4461
- currency: {
4462
- type: 'string',
4463
- description: 'Currency without exchange rate',
4464
- example: 'USD'
6681
+ symbol: {
6682
+ type: 'object',
6683
+ nullable: true
4465
6684
  },
4466
- accounts: {
4467
- description: 'Affected account paths',
4468
- type: 'array',
4469
- items: {
4470
- type: 'string'
4471
- }
6685
+ accountId: {
6686
+ type: 'object',
6687
+ nullable: true
4472
6688
  },
4473
- totalAmount: {
4474
- type: 'string',
4475
- description: 'Total amount in this currency',
4476
- example: '5000.00'
6689
+ currency: {
6690
+ type: 'object',
6691
+ nullable: true
4477
6692
  }
4478
6693
  },
4479
- required: ['type', 'currency', 'accounts', 'totalAmount']
6694
+ required: ['type']
4480
6695
  } as const;
4481
6696
 
4482
- export const $AssetClassSummaryDto = {
6697
+ export const $HoldingPnlResponseDto = {
4483
6698
  type: 'object',
4484
6699
  properties: {
4485
- totalAccounts: {
4486
- type: 'number',
4487
- description: 'Total number of accounts'
4488
- },
4489
- totalAssetClasses: {
4490
- type: 'number',
4491
- description: 'Total number of asset classes'
6700
+ asOfDate: {
6701
+ type: 'string',
6702
+ example: '2026-07-08'
4492
6703
  },
4493
6704
  baseCurrency: {
4494
6705
  type: 'string',
4495
- description: 'Base currency for conversion',
4496
6706
  example: 'CNY'
4497
6707
  },
4498
- warnings: {
4499
- description: 'Exchange rate warnings',
4500
- type: 'array',
4501
- items: {
4502
- $ref: '#/components/schemas/AccountExchangeRateWarningDto'
4503
- }
4504
- }
4505
- },
4506
- required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
4507
- } as const;
4508
-
4509
- export const $AssetClassAccountsResponseDto = {
4510
- type: 'object',
4511
- properties: {
4512
- groups: {
4513
- description: 'Account groups by asset class',
4514
- type: 'array',
4515
- items: {
4516
- $ref: '#/components/schemas/AssetClassGroupDto'
4517
- }
4518
- },
4519
- summary: {
4520
- description: 'Summary statistics',
4521
- allOf: [
4522
- {
4523
- $ref: '#/components/schemas/AssetClassSummaryDto'
4524
- }
4525
- ]
4526
- }
4527
- },
4528
- required: ['groups', 'summary']
4529
- } as const;
4530
-
4531
- export const $CashFlowByCurrencyDto = {
4532
- type: 'object',
4533
- properties: {
4534
- income: {
4535
- description: 'Income by currency',
4536
- type: 'array',
4537
- items: {
4538
- $ref: '#/components/schemas/BalanceByCurrencyDto'
4539
- }
6708
+ method: {
6709
+ type: 'string',
6710
+ description:
6711
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
6712
+ enum: ['average', 'FIFO'],
6713
+ example: 'average'
4540
6714
  },
4541
- expense: {
4542
- description: 'Expense by currency',
6715
+ rows: {
4543
6716
  type: 'array',
4544
6717
  items: {
4545
- $ref: '#/components/schemas/BalanceByCurrencyDto'
6718
+ $ref: '#/components/schemas/HoldingPnlRowDto'
4546
6719
  }
4547
6720
  },
4548
- netSavings: {
4549
- description: 'Net savings by currency',
6721
+ warnings: {
4550
6722
  type: 'array',
4551
6723
  items: {
4552
- $ref: '#/components/schemas/BalanceByCurrencyDto'
6724
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
4553
6725
  }
4554
6726
  }
4555
6727
  },
4556
- required: ['income', 'expense', 'netSavings']
6728
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
4557
6729
  } as const;
4558
6730
 
4559
- export const $ConvertedCashFlowDto = {
6731
+ export const $CreateBeanPriceDto = {
4560
6732
  type: 'object',
4561
6733
  properties: {
4562
- baseCurrency: {
6734
+ currency: {
4563
6735
  type: 'string',
4564
- description: 'Base currency for conversion',
4565
- example: 'CNY'
6736
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6737
+ example: 'USD'
4566
6738
  },
4567
- income: {
6739
+ quoteCurrency: {
4568
6740
  type: 'string',
4569
- description: 'Converted income',
4570
- example: '25000.00'
6741
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
6742
+ example: 'CNY'
4571
6743
  },
4572
- expense: {
4573
- type: 'string',
4574
- description: 'Converted expense',
4575
- example: '18000.00'
6744
+ amount: {
6745
+ type: 'number',
6746
+ description:
6747
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
6748
+ example: 175.5,
6749
+ minimum: 0
4576
6750
  },
4577
- netSavings: {
6751
+ date: {
4578
6752
  type: 'string',
4579
- description: 'Converted net savings',
4580
- example: '7000.00'
6753
+ description: 'Price date (ISO 8601 format)',
6754
+ example: '2024-11-05'
4581
6755
  },
4582
- exchangeRates: {
6756
+ metadata: {
4583
6757
  type: 'object',
4584
- description: 'Exchange rates used for conversion',
6758
+ description:
6759
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
4585
6760
  example: {
4586
- USD: '7.200000'
6761
+ source: 'MANUAL',
6762
+ note: 'Bank valuation report',
6763
+ confidence: 0.95
4587
6764
  }
4588
6765
  }
4589
6766
  },
4590
- required: ['baseCurrency', 'income', 'expense', 'netSavings', 'exchangeRates']
6767
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
4591
6768
  } as const;
4592
6769
 
4593
- export const $CashFlowResponseDto = {
6770
+ export const $PriceResponseDto = {
4594
6771
  type: 'object',
4595
6772
  properties: {
4596
- period: {
6773
+ id: {
4597
6774
  type: 'string',
4598
- description: 'Period identifier (YYYY-MM)',
4599
- example: '2024-06'
6775
+ description: 'Unique identifier',
6776
+ example: 'uuid-123-456'
4600
6777
  },
4601
- income: {
6778
+ userId: {
4602
6779
  type: 'string',
4603
- description: 'Total income for the period (converted)',
4604
- example: '25000.00'
6780
+ description: 'User ID (owner of the price)',
6781
+ example: 'user-123'
4605
6782
  },
4606
- expense: {
6783
+ currency: {
4607
6784
  type: 'string',
4608
- description: 'Total expenses for the period (converted)',
4609
- example: '18000.00'
6785
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6786
+ example: 'BTC'
4610
6787
  },
4611
- netSavings: {
6788
+ quoteCurrency: {
4612
6789
  type: 'string',
4613
- description: 'Net savings (income - expense, converted)',
4614
- example: '7000.00'
6790
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
6791
+ example: 'USD'
4615
6792
  },
4616
- savingsRate: {
4617
- type: 'string',
4618
- description: 'Savings rate percentage (netSavings / income * 100)',
4619
- example: '28.00'
6793
+ amount: {
6794
+ type: 'number',
6795
+ description:
6796
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
6797
+ example: 50000
4620
6798
  },
4621
- currency: {
6799
+ date: {
4622
6800
  type: 'string',
4623
- description: 'Base currency code',
4624
- example: 'CNY'
6801
+ description:
6802
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
6803
+ example: '2024-01-01',
6804
+ format: 'date'
4625
6805
  },
4626
- byCurrency: {
4627
- description: 'Cash flow grouped by original currency',
4628
- allOf: [
4629
- {
4630
- $ref: '#/components/schemas/CashFlowByCurrencyDto'
4631
- }
4632
- ]
6806
+ meta: {
6807
+ type: 'object',
6808
+ description:
6809
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
6810
+ example: {
6811
+ source: 'MANUAL',
6812
+ note: 'User-defined price',
6813
+ confidence: 1
6814
+ }
4633
6815
  },
4634
- converted: {
4635
- description: 'Converted values in base currency',
4636
- allOf: [
4637
- {
4638
- $ref: '#/components/schemas/ConvertedCashFlowDto'
4639
- }
4640
- ]
6816
+ createdAt: {
6817
+ format: 'date-time',
6818
+ type: 'string',
6819
+ description: 'Creation timestamp',
6820
+ example: '2024-11-03T10:00:00Z'
4641
6821
  },
4642
- warnings: {
4643
- description: 'Exchange rate warnings',
6822
+ updatedAt: {
6823
+ format: 'date-time',
6824
+ type: 'string',
6825
+ description: 'Last update timestamp',
6826
+ example: '2024-11-03T10:00:00Z'
6827
+ }
6828
+ },
6829
+ required: [
6830
+ 'id',
6831
+ 'userId',
6832
+ 'currency',
6833
+ 'quoteCurrency',
6834
+ 'amount',
6835
+ 'date',
6836
+ 'meta',
6837
+ 'createdAt',
6838
+ 'updatedAt'
6839
+ ]
6840
+ } as const;
6841
+
6842
+ export const $PriceListResponseDto = {
6843
+ type: 'object',
6844
+ properties: {
6845
+ items: {
6846
+ description: 'List of prices',
4644
6847
  type: 'array',
4645
6848
  items: {
4646
- $ref: '#/components/schemas/ExchangeRateWarningDto'
6849
+ $ref: '#/components/schemas/PriceResponseDto'
4647
6850
  }
6851
+ },
6852
+ total: {
6853
+ type: 'number',
6854
+ description: 'Total number of prices',
6855
+ example: 42
4648
6856
  }
4649
6857
  },
4650
- required: [
4651
- 'period',
4652
- 'income',
4653
- 'expense',
4654
- 'netSavings',
4655
- 'savingsRate',
4656
- 'currency'
4657
- ]
6858
+ required: ['items', 'total']
6859
+ } as const;
6860
+
6861
+ export const $UpdateBeanPriceDto = {
6862
+ type: 'object',
6863
+ properties: {
6864
+ currency: {
6865
+ type: 'string',
6866
+ description: 'Currency being priced'
6867
+ },
6868
+ quoteCurrency: {
6869
+ type: 'string',
6870
+ description: 'Quote currency (pricing currency)'
6871
+ },
6872
+ amount: {
6873
+ type: 'number',
6874
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
6875
+ minimum: 0
6876
+ },
6877
+ date: {
6878
+ type: 'string',
6879
+ description: 'Price date (ISO 8601 format)'
6880
+ },
6881
+ metadata: {
6882
+ type: 'object',
6883
+ description: 'Metadata'
6884
+ }
6885
+ }
4658
6886
  } as const;
4659
6887
 
4660
6888
  export const $CurrencyBalanceDto = {