@firela/api-types 0.0.0-canary.5639ea2d → 0.0.0-canary.5c1ed455

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']
@@ -399,6 +660,32 @@ export const $CreateTransactionDto = {
399
660
  required: ['date', 'narration', 'postings']
400
661
  } as const;
401
662
 
663
+ export const $CostDetailDto = {
664
+ type: 'object',
665
+ properties: {
666
+ number: {
667
+ type: 'string',
668
+ description: 'Per-unit cost basis (mirrors engine Cost.number)',
669
+ example: '240'
670
+ },
671
+ currency: {
672
+ type: 'string',
673
+ description: 'Cost currency',
674
+ example: 'USD'
675
+ },
676
+ date: {
677
+ type: 'string',
678
+ description: 'Lot acquisition date (ISO yyyy-mm-dd)',
679
+ example: '2024-01-15'
680
+ },
681
+ label: {
682
+ type: 'string',
683
+ description: 'Lot label',
684
+ example: 'lot-2024-01'
685
+ }
686
+ }
687
+ } as const;
688
+
402
689
  export const $PostingResponseDto = {
403
690
  type: 'object',
404
691
  properties: {
@@ -409,13 +696,23 @@ export const $PostingResponseDto = {
409
696
  },
410
697
  units: {
411
698
  type: 'string',
412
- description: 'Amount (may be null if interpolated)',
699
+ description:
700
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
413
701
  example: '100.50'
414
702
  },
415
703
  currency: {
416
704
  type: 'string',
417
705
  description: 'Currency',
418
706
  example: 'USD'
707
+ },
708
+ cost: {
709
+ description:
710
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
711
+ allOf: [
712
+ {
713
+ $ref: '#/components/schemas/CostDetailDto'
714
+ }
715
+ ]
419
716
  }
420
717
  },
421
718
  required: ['account']
@@ -607,27 +904,166 @@ export const $ApiProblemResponseDto = {
607
904
  required: ['type', 'title', 'status', 'detail']
608
905
  } as const;
609
906
 
610
- export const $PostingDetailDto = {
907
+ export const $BatchCreateTransactionDto = {
611
908
  type: 'object',
612
909
  properties: {
613
- id: {
614
- type: 'string',
615
- description: 'Posting ID',
616
- example: 'clh1234567890abcdef'
910
+ transactions: {
911
+ description: 'Array of transactions to create',
912
+ minItems: 1,
913
+ maxItems: 100,
914
+ type: 'array',
915
+ items: {
916
+ $ref: '#/components/schemas/CreateTransactionDto'
917
+ }
918
+ }
919
+ },
920
+ required: ['transactions']
921
+ } as const;
922
+
923
+ export const $BatchTransactionErrorDto = {
924
+ type: 'object',
925
+ properties: {
926
+ index: {
927
+ type: 'number',
928
+ description: 'Index of failed transaction in the input array',
929
+ example: 0
617
930
  },
618
- accountId: {
931
+ error: {
619
932
  type: 'string',
620
- description: 'Account ID',
621
- example: 'clh1234567890abcdef'
933
+ description: 'Error message describing the failure',
934
+ example: 'Transaction does not balance'
622
935
  },
623
- accountName: {
936
+ errorCode: {
624
937
  type: 'string',
625
- description: 'Account name',
938
+ description: 'Structured error code for programmatic handling',
939
+ example: 'INSUFFICIENT_QUANTITY'
940
+ }
941
+ },
942
+ required: ['index', 'error']
943
+ } as const;
944
+
945
+ export const $BatchTransactionResponseDto = {
946
+ type: 'object',
947
+ properties: {
948
+ succeeded: {
949
+ description: 'Successfully created transactions',
950
+ type: 'array',
951
+ items: {
952
+ $ref: '#/components/schemas/TransactionResponseDto'
953
+ }
954
+ },
955
+ failed: {
956
+ description: 'Failed transactions with error details',
957
+ type: 'array',
958
+ items: {
959
+ $ref: '#/components/schemas/BatchTransactionErrorDto'
960
+ }
961
+ }
962
+ },
963
+ required: ['succeeded', 'failed']
964
+ } as const;
965
+
966
+ export const $CorrectTransactionDto = {
967
+ type: 'object',
968
+ properties: {
969
+ date: {
970
+ type: 'string',
971
+ description: 'Transaction date (ISO 8601 format)',
972
+ example: '2024-11-28'
973
+ },
974
+ flag: {
975
+ type: 'string',
976
+ description: 'Transaction flag: * (cleared), ! (pending)',
977
+ enum: ['*', '!'],
978
+ example: '*'
979
+ },
980
+ payee: {
981
+ type: 'string',
982
+ description: 'Payee name',
983
+ example: 'Whole Foods Market'
984
+ },
985
+ narration: {
986
+ type: 'string',
987
+ description: 'Transaction narration/description',
988
+ example: 'Grocery shopping'
989
+ },
990
+ tags: {
991
+ description: 'Transaction tags (without # prefix)',
992
+ example: ['vacation', 'personal'],
993
+ type: 'array',
994
+ items: {
995
+ type: 'string'
996
+ }
997
+ },
998
+ links: {
999
+ description: 'Transaction links (without ^ prefix)',
1000
+ example: ['invoice-123'],
1001
+ type: 'array',
1002
+ items: {
1003
+ type: 'string'
1004
+ }
1005
+ },
1006
+ postings: {
1007
+ description:
1008
+ 'Transaction postings (minimum 1, typically 2 for double-entry)',
1009
+ type: 'array',
1010
+ items: {
1011
+ $ref: '#/components/schemas/CreatePostingDto'
1012
+ }
1013
+ },
1014
+ meta: {
1015
+ type: 'object',
1016
+ description: 'Transaction-level metadata',
1017
+ example: {
1018
+ invoice: '12345'
1019
+ }
1020
+ },
1021
+ idempotencyKey: {
1022
+ type: 'string',
1023
+ description:
1024
+ 'Unique key for idempotent transaction creation. If provided, duplicate requests with the same key will return the existing transaction.',
1025
+ example: 'import-2024-01-15-batch-001',
1026
+ maxLength: 128
1027
+ },
1028
+ autoCreateAccounts: {
1029
+ type: 'boolean',
1030
+ description:
1031
+ '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.',
1032
+ default: true,
1033
+ example: true
1034
+ },
1035
+ correctionReason: {
1036
+ type: 'string',
1037
+ description: 'Reason for correcting/superseding the original transaction',
1038
+ example: 'Wrong amount — corrected from receipt',
1039
+ maxLength: 500
1040
+ }
1041
+ },
1042
+ required: ['date', 'narration', 'postings']
1043
+ } as const;
1044
+
1045
+ export const $PostingDetailDto = {
1046
+ type: 'object',
1047
+ properties: {
1048
+ id: {
1049
+ type: 'string',
1050
+ description: 'Posting ID',
1051
+ example: 'clh1234567890abcdef'
1052
+ },
1053
+ accountId: {
1054
+ type: 'string',
1055
+ description: 'Account ID',
1056
+ example: 'clh1234567890abcdef'
1057
+ },
1058
+ account: {
1059
+ type: 'string',
1060
+ description: 'Fully-qualified Beancount account path',
626
1061
  example: 'Assets:Bank:Checking'
627
1062
  },
628
1063
  units: {
629
1064
  type: 'string',
630
- description: 'Amount (may be null if interpolated)',
1065
+ description:
1066
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
631
1067
  example: '100.50'
632
1068
  },
633
1069
  currency: {
@@ -650,6 +1086,15 @@ export const $PostingDetailDto = {
650
1086
  description: 'Cost date',
651
1087
  example: '2024-01-15'
652
1088
  },
1089
+ cost: {
1090
+ description:
1091
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
1092
+ allOf: [
1093
+ {
1094
+ $ref: '#/components/schemas/CostDetailDto'
1095
+ }
1096
+ ]
1097
+ },
653
1098
  priceAmount: {
654
1099
  type: 'string',
655
1100
  description: 'Price amount',
@@ -670,7 +1115,7 @@ export const $PostingDetailDto = {
670
1115
  description: 'Posting metadata'
671
1116
  }
672
1117
  },
673
- required: ['id', 'accountId', 'accountName']
1118
+ required: ['id', 'accountId', 'account']
674
1119
  } as const;
675
1120
 
676
1121
  export const $TransactionDetailDto = {
@@ -742,8 +1187,8 @@ export const $TransactionDetailDto = {
742
1187
  },
743
1188
  sourceType: {
744
1189
  type: 'string',
745
- description: 'Source type (how the transaction was created)',
746
- enum: ['NLP', 'CSV', 'OCR', 'API']
1190
+ description:
1191
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
747
1192
  },
748
1193
  sourcePlatform: {
749
1194
  type: 'string',
@@ -776,6 +1221,18 @@ export const $TransactionDetailDto = {
776
1221
  type: 'string',
777
1222
  description: 'Correction reason (if voided or superseded)',
778
1223
  example: 'Duplicate entry'
1224
+ },
1225
+ supersededBy: {
1226
+ type: 'string',
1227
+ description:
1228
+ 'ID of the transaction that supersedes this one (set when status=SUPERSEDED)',
1229
+ example: 'clh1234567890abcdef'
1230
+ },
1231
+ originalTxn: {
1232
+ type: 'string',
1233
+ description:
1234
+ 'ID of the transaction this one corrected/replaced (back-link on the replacement)',
1235
+ example: 'clh1234567890abcdef'
779
1236
  }
780
1237
  },
781
1238
  required: [
@@ -819,6 +1276,37 @@ export const $TransactionListResponseDto = {
819
1276
  required: ['data', 'total', 'limit', 'offset']
820
1277
  } as const;
821
1278
 
1279
+ export const $TagSuggestionDto = {
1280
+ type: 'object',
1281
+ properties: {
1282
+ tag: {
1283
+ type: 'string',
1284
+ description: 'Tag name',
1285
+ example: 'Monthly'
1286
+ },
1287
+ count: {
1288
+ type: 'number',
1289
+ description: 'Usage count across ACTIVE transactions',
1290
+ example: 12
1291
+ }
1292
+ },
1293
+ required: ['tag', 'count']
1294
+ } as const;
1295
+
1296
+ export const $TagSuggestionsResponseDto = {
1297
+ type: 'object',
1298
+ properties: {
1299
+ data: {
1300
+ description: 'Tag suggestions sorted as requested',
1301
+ type: 'array',
1302
+ items: {
1303
+ $ref: '#/components/schemas/TagSuggestionDto'
1304
+ }
1305
+ }
1306
+ },
1307
+ required: ['data']
1308
+ } as const;
1309
+
822
1310
  export const $UpdateTransactionDto = {
823
1311
  type: 'object',
824
1312
  properties: {
@@ -876,212 +1364,86 @@ export const $UpdateTransactionDto = {
876
1364
  }
877
1365
  } as const;
878
1366
 
879
- export const $AccountStandardResponseDto = {
1367
+ export const $BalanceResponseDto = {
880
1368
  type: 'object',
881
1369
  properties: {
882
- path: {
883
- type: 'string',
884
- description: 'Account path (hierarchical, colon-separated)',
885
- example: 'Assets:CN:Bank:ICBC:Checking'
886
- },
887
- type: {
1370
+ account: {
888
1371
  type: 'string',
889
- description: 'Account type in Beancount hierarchy',
890
- enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
891
- example: 'Assets'
1372
+ description: 'Account name',
1373
+ example: 'Assets:Bank:Checking'
892
1374
  },
893
- i18nKey: {
1375
+ balance: {
894
1376
  type: 'string',
895
- description: 'i18n key for localized display name',
896
- example: 'account.assets.cn.bank.icbc.checking'
1377
+ description: 'Balance amount (decimal string for precision)',
1378
+ example: '12345.67'
897
1379
  },
898
- description: {
1380
+ currency: {
899
1381
  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
- }
1382
+ description: 'Currency code',
1383
+ example: 'USD'
910
1384
  },
911
- icon: {
1385
+ date: {
912
1386
  type: 'string',
913
- description: 'Icon identifier for UI display',
914
- example: 'bank-icbc'
1387
+ description: 'Date of the balance calculation (ISO 8601)',
1388
+ example: '2024-12-31T00:00:00.000Z'
915
1389
  }
916
1390
  },
917
- required: ['path', 'type']
1391
+ required: ['account', 'balance', 'currency', 'date']
918
1392
  } as const;
919
1393
 
920
- export const $AccountStandardListResponseDto = {
1394
+ export const $MultiCurrencyBalanceResponseDto = {
921
1395
  type: 'object',
922
1396
  properties: {
923
- items: {
924
- description: 'Array of account templates',
925
- type: 'array',
926
- items: {
927
- $ref: '#/components/schemas/AccountStandardResponseDto'
928
- }
1397
+ account: {
1398
+ type: 'string',
1399
+ description: 'Account name',
1400
+ example: 'Assets:Bank:Checking'
929
1401
  },
930
- total: {
931
- type: 'number',
932
- description: 'Total number of account templates',
933
- example: 150
1402
+ balances: {
1403
+ type: 'object',
1404
+ description: 'Balances by currency',
1405
+ example: {
1406
+ USD: '12345.67',
1407
+ CNY: '100000.00'
1408
+ }
934
1409
  },
935
- region: {
1410
+ date: {
936
1411
  type: 'string',
937
- description: 'Region code',
938
- example: 'CN'
1412
+ description: 'Date of the balance calculation (ISO 8601)',
1413
+ example: '2024-12-31T00:00:00.000Z'
939
1414
  }
940
1415
  },
941
- required: ['items', 'total', 'region']
1416
+ required: ['account', 'balances', 'date']
942
1417
  } as const;
943
1418
 
944
- export const $RegionConfigDto = {
1419
+ export const $TransactionSummaryDto = {
945
1420
  type: 'object',
946
1421
  properties: {
947
- currency: {
1422
+ id: {
948
1423
  type: 'string',
949
- example: 'EUR'
1424
+ description: 'Transaction ID (null if transaction deleted)',
1425
+ example: 'clh1234567890abcdef',
1426
+ nullable: true
950
1427
  },
951
- dateFormat: {
1428
+ date: {
952
1429
  type: 'string',
953
- example: 'DD.MM.YYYY'
1430
+ description: 'Transaction date (YYYY-MM-DD)',
1431
+ example: '2024-03-15'
954
1432
  },
955
- locale: {
956
- type: 'string',
957
- example: 'de-DE'
958
- }
959
- },
960
- required: ['currency', 'dateFormat', 'locale']
961
- } as const;
962
-
963
- export const $RegionInfoDto = {
964
- type: 'object',
965
- properties: {
966
- code: {
1433
+ amount: {
967
1434
  type: 'string',
968
- example: 'de'
1435
+ description: 'Transaction amount (absolute value)',
1436
+ example: '128.50'
969
1437
  },
970
- displayName: {
1438
+ currency: {
971
1439
  type: 'string',
972
- example: 'Germany'
1440
+ description: 'Currency code',
1441
+ example: 'CNY'
973
1442
  },
974
- parent: {
1443
+ payee: {
975
1444
  type: 'string',
976
- example: 'eu-core'
977
- },
978
- chain: {
979
- example: ['eu-core', 'de'],
980
- type: 'array',
981
- items: {
982
- type: 'string'
983
- }
984
- },
985
- config: {
986
- $ref: '#/components/schemas/RegionConfigDto'
987
- }
988
- },
989
- required: ['code', 'displayName', 'chain', 'config']
990
- } as const;
991
-
992
- export const $RegionsMetadataResponseDto = {
993
- type: 'object',
994
- properties: {
995
- regions: {
996
- type: 'array',
997
- items: {
998
- $ref: '#/components/schemas/RegionInfoDto'
999
- }
1000
- }
1001
- },
1002
- required: ['regions']
1003
- } as const;
1004
-
1005
- export const $BalanceResponseDto = {
1006
- type: 'object',
1007
- properties: {
1008
- account: {
1009
- type: 'string',
1010
- description: 'Account name',
1011
- example: 'Assets:Bank:Checking'
1012
- },
1013
- balance: {
1014
- type: 'string',
1015
- description: 'Balance amount (decimal string for precision)',
1016
- example: '12345.67'
1017
- },
1018
- currency: {
1019
- type: 'string',
1020
- description: 'Currency code',
1021
- example: 'USD'
1022
- },
1023
- date: {
1024
- type: 'string',
1025
- description: 'Date of the balance calculation (ISO 8601)',
1026
- example: '2024-12-31T00:00:00.000Z'
1027
- }
1028
- },
1029
- required: ['account', 'balance', 'currency', 'date']
1030
- } as const;
1031
-
1032
- export const $MultiCurrencyBalanceResponseDto = {
1033
- type: 'object',
1034
- properties: {
1035
- account: {
1036
- type: 'string',
1037
- description: 'Account name',
1038
- example: 'Assets:Bank:Checking'
1039
- },
1040
- balances: {
1041
- type: 'object',
1042
- description: 'Balances by currency',
1043
- example: {
1044
- USD: '12345.67',
1045
- CNY: '100000.00'
1046
- }
1047
- },
1048
- date: {
1049
- type: 'string',
1050
- description: 'Date of the balance calculation (ISO 8601)',
1051
- example: '2024-12-31T00:00:00.000Z'
1052
- }
1053
- },
1054
- required: ['account', 'balances', 'date']
1055
- } as const;
1056
-
1057
- export const $TransactionSummaryDto = {
1058
- type: 'object',
1059
- properties: {
1060
- id: {
1061
- type: 'string',
1062
- description: 'Transaction ID (null if transaction deleted)',
1063
- example: 'clh1234567890abcdef',
1064
- nullable: true
1065
- },
1066
- date: {
1067
- type: 'string',
1068
- description: 'Transaction date (YYYY-MM-DD)',
1069
- example: '2024-03-15'
1070
- },
1071
- amount: {
1072
- type: 'string',
1073
- description: 'Transaction amount (absolute value)',
1074
- example: '128.50'
1075
- },
1076
- currency: {
1077
- type: 'string',
1078
- description: 'Currency code',
1079
- example: 'CNY'
1080
- },
1081
- payee: {
1082
- type: 'string',
1083
- description: 'Payee/Merchant name',
1084
- example: 'Starbucks'
1445
+ description: 'Payee/Merchant name',
1446
+ example: 'Starbucks'
1085
1447
  },
1086
1448
  narration: {
1087
1449
  type: 'string',
@@ -1095,8 +1457,8 @@ export const $TransactionSummaryDto = {
1095
1457
  },
1096
1458
  sourceType: {
1097
1459
  type: 'string',
1098
- description: 'Source type (NLP, CSV, OCR, API)',
1099
- enum: ['NLP', 'CSV', 'OCR', 'API']
1460
+ description:
1461
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1100
1462
  },
1101
1463
  sourcePlatform: {
1102
1464
  type: 'string',
@@ -1136,8 +1498,10 @@ export const $ReviewSummaryDto = {
1136
1498
  },
1137
1499
  confidenceLevel: {
1138
1500
  type: 'string',
1139
- description: 'Confidence level derived from score',
1140
- enum: ['HIGH', 'MEDIUM', 'LOW']
1501
+ description:
1502
+ 'Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.',
1503
+ enum: ['HIGH', 'MEDIUM', 'LOW'],
1504
+ nullable: true
1141
1505
  },
1142
1506
  summaryKey: {
1143
1507
  type: 'string',
@@ -1161,7 +1525,8 @@ export const $ReviewSummaryDto = {
1161
1525
  },
1162
1526
  sourceType: {
1163
1527
  type: 'string',
1164
- description: 'Source type (NLP, CSV, OCR, API)'
1528
+ description:
1529
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1165
1530
  },
1166
1531
  sourcePlatform: {
1167
1532
  type: 'string',
@@ -1271,7 +1636,20 @@ export const $DecisionOptionDto = {
1271
1636
  properties: {
1272
1637
  value: {
1273
1638
  type: 'string',
1274
- description: 'The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)'
1639
+ description: 'The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)',
1640
+ enum: [
1641
+ 'UPGRADE_REPLACE',
1642
+ 'LINK_KEEP_BOTH',
1643
+ 'IGNORE_NEW',
1644
+ 'CONFIRM_DIFFERENT',
1645
+ 'ACCEPT',
1646
+ 'REJECT',
1647
+ 'ACCEPT_AND_LEARN',
1648
+ 'CHOOSE_OTHER',
1649
+ 'CANCEL',
1650
+ 'FIX',
1651
+ 'IGNORE'
1652
+ ]
1275
1653
  },
1276
1654
  labelKey: {
1277
1655
  type: 'string',
@@ -1319,8 +1697,10 @@ export const $ReviewDetailDto = {
1319
1697
  },
1320
1698
  confidenceLevel: {
1321
1699
  type: 'string',
1322
- description: 'Confidence level derived from score',
1323
- enum: ['HIGH', 'MEDIUM', 'LOW']
1700
+ description:
1701
+ 'Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.',
1702
+ enum: ['HIGH', 'MEDIUM', 'LOW'],
1703
+ nullable: true
1324
1704
  },
1325
1705
  summaryKey: {
1326
1706
  type: 'string',
@@ -1344,7 +1724,8 @@ export const $ReviewDetailDto = {
1344
1724
  },
1345
1725
  sourceType: {
1346
1726
  type: 'string',
1347
- description: 'Source type (NLP, CSV, OCR, API)'
1727
+ description:
1728
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1348
1729
  },
1349
1730
  sourcePlatform: {
1350
1731
  type: 'string',
@@ -1418,6 +1799,208 @@ export const $ReviewDetailDto = {
1418
1799
  ]
1419
1800
  } as const;
1420
1801
 
1802
+ export const $ResolveReviewDto = {
1803
+ type: 'object',
1804
+ properties: {
1805
+ action: {
1806
+ type: 'string',
1807
+ description:
1808
+ 'Decision action. Valid actions vary by review type — see DecisionOptionDto.value returned by the review detail endpoint.',
1809
+ enum: [
1810
+ 'UPGRADE_REPLACE',
1811
+ 'LINK_KEEP_BOTH',
1812
+ 'IGNORE_NEW',
1813
+ 'CONFIRM_DIFFERENT',
1814
+ 'ACCEPT',
1815
+ 'REJECT',
1816
+ 'ACCEPT_AND_LEARN',
1817
+ 'CHOOSE_OTHER',
1818
+ 'CANCEL',
1819
+ 'FIX',
1820
+ 'IGNORE'
1821
+ ],
1822
+ example: 'ACCEPT'
1823
+ },
1824
+ data: {
1825
+ type: 'object',
1826
+ description:
1827
+ 'Additional data for the decision (e.g., selected account ID)',
1828
+ example: {
1829
+ accountId: 'acc-123'
1830
+ }
1831
+ }
1832
+ },
1833
+ required: ['action']
1834
+ } as const;
1835
+
1836
+ export const $ResolveResultDto = {
1837
+ type: 'object',
1838
+ properties: {
1839
+ success: {
1840
+ type: 'boolean',
1841
+ description: 'Whether resolution was successful'
1842
+ },
1843
+ messageKey: {
1844
+ type: 'string',
1845
+ description:
1846
+ 'i18n message key for result message (e.g., review.payee.result.mapped)'
1847
+ },
1848
+ messageParams: {
1849
+ type: 'object',
1850
+ description:
1851
+ 'Parameters for message interpolation (e.g., { name: "PayeeName" })',
1852
+ additionalProperties: {
1853
+ type: 'string'
1854
+ }
1855
+ },
1856
+ resolutionId: {
1857
+ type: 'string',
1858
+ description: 'Resolution ID for undo'
1859
+ },
1860
+ canUndo: {
1861
+ type: 'boolean',
1862
+ description: 'Whether this decision can be undone'
1863
+ },
1864
+ undoDeadline: {
1865
+ format: 'date-time',
1866
+ type: 'string',
1867
+ description: 'Deadline for undo (24h from resolution)'
1868
+ },
1869
+ learnedRuleId: {
1870
+ type: 'string',
1871
+ description:
1872
+ 'Rule ID if learning was triggered (ACCEPT_AND_LEARN actions). Use this to deep-link to the rule management page.',
1873
+ example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1874
+ }
1875
+ },
1876
+ required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
1877
+ } as const;
1878
+
1879
+ export const $UndoResultDto = {
1880
+ type: 'object',
1881
+ properties: {
1882
+ success: {
1883
+ type: 'boolean',
1884
+ description: 'Whether undo was successful'
1885
+ },
1886
+ message: {
1887
+ type: 'string',
1888
+ description: 'Message'
1889
+ },
1890
+ reviewId: {
1891
+ type: 'string',
1892
+ description: 'Review item ID that was restored'
1893
+ }
1894
+ },
1895
+ required: ['success', 'reviewId']
1896
+ } as const;
1897
+
1898
+ export const $BatchResolveDto = {
1899
+ type: 'object',
1900
+ properties: {
1901
+ reviewIds: {
1902
+ description: 'Review item IDs to resolve',
1903
+ example: ['review-1', 'review-2', 'review-3'],
1904
+ type: 'array',
1905
+ items: {
1906
+ type: 'string'
1907
+ }
1908
+ },
1909
+ action: {
1910
+ type: 'string',
1911
+ description: 'Decision action to apply to all items',
1912
+ enum: [
1913
+ 'UPGRADE_REPLACE',
1914
+ 'LINK_KEEP_BOTH',
1915
+ 'IGNORE_NEW',
1916
+ 'CONFIRM_DIFFERENT',
1917
+ 'ACCEPT',
1918
+ 'REJECT',
1919
+ 'ACCEPT_AND_LEARN',
1920
+ 'CHOOSE_OTHER',
1921
+ 'CANCEL',
1922
+ 'FIX',
1923
+ 'IGNORE'
1924
+ ],
1925
+ example: 'ACCEPT'
1926
+ },
1927
+ data: {
1928
+ type: 'object',
1929
+ description: 'Additional data for the decision'
1930
+ }
1931
+ },
1932
+ required: ['reviewIds', 'action']
1933
+ } as const;
1934
+
1935
+ export const $BatchResolveResultDto = {
1936
+ type: 'object',
1937
+ properties: {
1938
+ successCount: {
1939
+ type: 'number',
1940
+ description: 'Number of successfully resolved items'
1941
+ },
1942
+ failedCount: {
1943
+ type: 'number',
1944
+ description: 'Number of failed items'
1945
+ },
1946
+ results: {
1947
+ description: 'Details for each item',
1948
+ type: 'array',
1949
+ items: {
1950
+ type: 'string'
1951
+ }
1952
+ }
1953
+ },
1954
+ required: ['successCount', 'failedCount', 'results']
1955
+ } as const;
1956
+
1957
+ export const $CreatePayeeDto = {
1958
+ type: 'object',
1959
+ properties: {
1960
+ payee: {
1961
+ type: 'string',
1962
+ description:
1963
+ "User's original payee name (e.g., 'Starbucks', 'McDonald'). This is the raw payee string as entered by the user.",
1964
+ example: 'Starbucks',
1965
+ maxLength: 200
1966
+ },
1967
+ payeeProfileId: {
1968
+ type: 'string',
1969
+ description:
1970
+ 'Optional reference to global PayeeProfile for standardized data (merchant info, i18n keys, categories)',
1971
+ example: 'uuid-123',
1972
+ format: 'uuid'
1973
+ },
1974
+ customCategory: {
1975
+ type: 'string',
1976
+ description:
1977
+ "User's custom category for this payee (overrides PayeeProfile category)",
1978
+ example: 'Dining:Coffee',
1979
+ maxLength: 100
1980
+ },
1981
+ customTags: {
1982
+ description:
1983
+ "User's custom tags for this payee (e.g., ['favorite', 'work_meal'])",
1984
+ example: ['favorite', 'work_meal'],
1985
+ type: 'array',
1986
+ items: {
1987
+ type: 'string'
1988
+ }
1989
+ },
1990
+ meta: {
1991
+ type: 'object',
1992
+ description:
1993
+ 'Metadata for extended information (location, notes, contact info, etc.)',
1994
+ example: {
1995
+ location: 'Zhongguancun',
1996
+ note: 'Near subway station',
1997
+ favorite: true
1998
+ }
1999
+ }
2000
+ },
2001
+ required: ['payee']
2002
+ } as const;
2003
+
1421
2004
  export const $PayeeResponseDto = {
1422
2005
  type: 'object',
1423
2006
  properties: {
@@ -1437,14 +2020,14 @@ export const $PayeeResponseDto = {
1437
2020
  example: 'Starbucks'
1438
2021
  },
1439
2022
  payeeProfileId: {
1440
- type: 'object',
2023
+ type: 'string',
1441
2024
  description:
1442
2025
  'Reference to global PayeeProfile (merchant info, i18n keys, categories)',
1443
2026
  example: 'uuid-789',
1444
2027
  nullable: true
1445
2028
  },
1446
2029
  customCategory: {
1447
- type: 'object',
2030
+ type: 'string',
1448
2031
  description:
1449
2032
  "User's custom category (overrides PayeeProfile category if set)",
1450
2033
  example: 'Dining:Coffee',
@@ -1568,21 +2151,64 @@ export const $PayeeStatsResponseDto = {
1568
2151
  required: ['payee', 'transactionCount', 'lastUsedAt']
1569
2152
  } as const;
1570
2153
 
1571
- export const $PayeeProfileResponseDto = {
2154
+ export const $UpdatePayeeDto = {
1572
2155
  type: 'object',
1573
2156
  properties: {
1574
- id: {
2157
+ payeeProfileId: {
1575
2158
  type: 'string',
1576
- description: 'Unique identifier (UUID)',
1577
- example: '550e8400-e29b-41d4-a716-446655440000'
2159
+ description:
2160
+ 'Optional reference to global PayeeProfile for standardized data (merchant info, i18n keys, categories)',
2161
+ example: 'uuid-123',
2162
+ format: 'uuid'
1578
2163
  },
1579
- canonical: {
2164
+ customCategory: {
1580
2165
  type: 'string',
1581
- description: 'Canonical payee name (unique, case-insensitive)',
1582
- example: 'Starbucks'
2166
+ description:
2167
+ "User's custom category for this payee (overrides PayeeProfile category)",
2168
+ example: 'Dining:Coffee',
2169
+ maxLength: 100
2170
+ },
2171
+ customTags: {
2172
+ description:
2173
+ "User's custom tags for this payee (e.g., ['favorite', 'work_meal'])",
2174
+ example: ['favorite', 'work_meal'],
2175
+ type: 'array',
2176
+ items: {
2177
+ type: 'string'
2178
+ }
2179
+ },
2180
+ meta: {
2181
+ type: 'object',
2182
+ description:
2183
+ 'Metadata for extended information (location, notes, contact info, etc.). Will merge with existing metadata.',
2184
+ example: {
2185
+ location: 'Zhongguancun',
2186
+ note: 'Updated note',
2187
+ favorite: true
2188
+ }
2189
+ },
2190
+ isActive: {
2191
+ type: 'boolean',
2192
+ description:
2193
+ 'Enable or disable this payee. Disabled payees will not appear in autocomplete suggestions.',
2194
+ example: true
2195
+ }
2196
+ }
2197
+ } as const;
2198
+
2199
+ export const $CreatePayeeProfileDto = {
2200
+ type: 'object',
2201
+ properties: {
2202
+ canonical: {
2203
+ type: 'string',
2204
+ description:
2205
+ 'Canonical payee name (unique, case-insensitive). This is the primary identifier for the payee.',
2206
+ example: 'Starbucks',
2207
+ maxLength: 200
1583
2208
  },
1584
2209
  aliases: {
1585
- description: 'Multi-language aliases',
2210
+ description:
2211
+ 'Multi-language aliases for the payee. Used for matching user input in different languages.',
1586
2212
  example: ['Starbucks Coffee', 'SBUX'],
1587
2213
  type: 'array',
1588
2214
  items: {
@@ -1590,7 +2216,129 @@ export const $PayeeProfileResponseDto = {
1590
2216
  }
1591
2217
  },
1592
2218
  i18nKey: {
2219
+ type: 'string',
2220
+ description:
2221
+ 'Translation key for i18n integration (XLIFF translation system)',
2222
+ example: 'payee.starbucks',
2223
+ maxLength: 100
2224
+ },
2225
+ category: {
2226
+ type: 'string',
2227
+ description: 'Payee category classification',
2228
+ enum: [
2229
+ 'RESTAURANT',
2230
+ 'CAFE',
2231
+ 'FAST_FOOD',
2232
+ 'BAR',
2233
+ 'SUPERMARKET',
2234
+ 'CONVENIENCE_STORE',
2235
+ 'SHOPPING_MALL',
2236
+ 'ONLINE_SHOPPING',
2237
+ 'TAXI',
2238
+ 'RIDE_SHARING',
2239
+ 'PUBLIC_TRANSPORT',
2240
+ 'PARKING',
2241
+ 'GAS_STATION',
2242
+ 'UTILITIES',
2243
+ 'TELECOM',
2244
+ 'STREAMING',
2245
+ 'HEALTHCARE',
2246
+ 'EDUCATION',
2247
+ 'ENTERTAINMENT',
2248
+ 'SPORTS',
2249
+ 'TRAVEL',
2250
+ 'HOTEL',
2251
+ 'OTHER'
2252
+ ],
2253
+ example: 'CAFE'
2254
+ },
2255
+ subCategory: {
2256
+ type: 'string',
2257
+ description: 'Sub-category for more specific classification',
2258
+ example: 'coffee_chain',
2259
+ maxLength: 100
2260
+ },
2261
+ countries: {
2262
+ description:
2263
+ 'Country/region codes where the payee operates (ISO 3166-1 alpha-2)',
2264
+ example: ['CN', 'US', 'JP'],
2265
+ type: 'array',
2266
+ items: {
2267
+ type: 'string'
2268
+ }
2269
+ },
2270
+ primaryCountry: {
2271
+ type: 'string',
2272
+ description: 'Primary operating country (ISO 3166-1 alpha-2)',
2273
+ example: 'US',
2274
+ maxLength: 2
2275
+ },
2276
+ keywords: {
2277
+ description: 'Search keywords for fuzzy matching',
2278
+ example: ['coffee', 'cafe', 'drinks'],
2279
+ type: 'array',
2280
+ items: {
2281
+ type: 'string'
2282
+ }
2283
+ },
2284
+ logoUrl: {
2285
+ type: 'string',
2286
+ description: 'Payee logo URL',
2287
+ example: 'https://example.com/logo.png'
2288
+ },
2289
+ website: {
2290
+ type: 'string',
2291
+ description: 'Official website URL',
2292
+ example: 'https://www.starbucks.com'
2293
+ },
2294
+ description: {
2295
+ type: 'string',
2296
+ description: 'Payee description',
2297
+ example: 'Global coffeehouse chain headquartered in Seattle',
2298
+ maxLength: 1000
2299
+ },
2300
+ meta: {
1593
2301
  type: 'object',
2302
+ description:
2303
+ 'Extended metadata (business hours, contact info, additional details)',
2304
+ example: {
2305
+ businessHours: '07:00-22:00',
2306
+ phone: '+1-800-782-7282'
2307
+ }
2308
+ },
2309
+ dataSource: {
2310
+ type: 'string',
2311
+ description: 'Data source for this profile',
2312
+ enum: ['MANUAL', 'IMPORT', 'API', 'CROWDSOURCED'],
2313
+ default: 'MANUAL'
2314
+ }
2315
+ },
2316
+ required: ['canonical', 'category']
2317
+ } as const;
2318
+
2319
+ export const $PayeeProfileResponseDto = {
2320
+ type: 'object',
2321
+ properties: {
2322
+ id: {
2323
+ type: 'string',
2324
+ description: 'Unique identifier (UUID)',
2325
+ example: '550e8400-e29b-41d4-a716-446655440000'
2326
+ },
2327
+ canonical: {
2328
+ type: 'string',
2329
+ description: 'Canonical payee name (unique, case-insensitive)',
2330
+ example: 'Starbucks'
2331
+ },
2332
+ aliases: {
2333
+ description: 'Multi-language aliases',
2334
+ example: ['Starbucks Coffee', 'SBUX'],
2335
+ type: 'array',
2336
+ items: {
2337
+ type: 'string'
2338
+ }
2339
+ },
2340
+ i18nKey: {
2341
+ type: 'string',
1594
2342
  description: 'Translation key for i18n',
1595
2343
  example: 'payee.starbucks',
1596
2344
  nullable: true
@@ -1626,7 +2374,7 @@ export const $PayeeProfileResponseDto = {
1626
2374
  example: 'CAFE'
1627
2375
  },
1628
2376
  subCategory: {
1629
- type: 'object',
2377
+ type: 'string',
1630
2378
  description: 'Sub-category',
1631
2379
  example: 'coffee_chain',
1632
2380
  nullable: true
@@ -1640,7 +2388,7 @@ export const $PayeeProfileResponseDto = {
1640
2388
  }
1641
2389
  },
1642
2390
  primaryCountry: {
1643
- type: 'object',
2391
+ type: 'string',
1644
2392
  description: 'Primary operating country',
1645
2393
  example: 'US',
1646
2394
  nullable: true
@@ -1654,19 +2402,19 @@ export const $PayeeProfileResponseDto = {
1654
2402
  }
1655
2403
  },
1656
2404
  logoUrl: {
1657
- type: 'object',
2405
+ type: 'string',
1658
2406
  description: 'Logo URL',
1659
2407
  example: 'https://example.com/logo.png',
1660
2408
  nullable: true
1661
2409
  },
1662
2410
  website: {
1663
- type: 'object',
2411
+ type: 'string',
1664
2412
  description: 'Official website',
1665
2413
  example: 'https://www.starbucks.com',
1666
2414
  nullable: true
1667
2415
  },
1668
2416
  description: {
1669
- type: 'object',
2417
+ type: 'string',
1670
2418
  description: 'Description',
1671
2419
  example: 'Global coffeehouse chain',
1672
2420
  nullable: true
@@ -1682,9 +2430,10 @@ export const $PayeeProfileResponseDto = {
1682
2430
  example: 'MANUAL'
1683
2431
  },
1684
2432
  verifiedAt: {
1685
- type: 'object',
2433
+ type: 'string',
1686
2434
  description: 'Verification timestamp (null if not verified)',
1687
2435
  example: '2025-01-01T00:00:00.000Z',
2436
+ format: 'date-time',
1688
2437
  nullable: true
1689
2438
  },
1690
2439
  isActive: {
@@ -1739,86 +2488,361 @@ export const $PayeeProfileListResponseDto = {
1739
2488
  required: ['items', 'total']
1740
2489
  } as const;
1741
2490
 
1742
- export const $CommodityResponseDto = {
2491
+ export const $UpdatePayeeProfileDto = {
1743
2492
  type: 'object',
1744
2493
  properties: {
1745
- id: {
1746
- type: 'string',
1747
- description: 'Unique identifier',
1748
- example: 'uuid-123-456'
2494
+ aliases: {
2495
+ description:
2496
+ 'Multi-language aliases for the payee. Used for matching user input in different languages.',
2497
+ example: ['Starbucks Coffee', 'SBUX'],
2498
+ type: 'array',
2499
+ items: {
2500
+ type: 'string'
2501
+ }
1749
2502
  },
1750
- userId: {
1751
- type: 'object',
1752
- description: 'User ID (owner of the commodity)',
1753
- example: 'user-123',
1754
- nullable: true
2503
+ i18nKey: {
2504
+ type: 'string',
2505
+ description:
2506
+ 'Translation key for i18n integration (XLIFF translation system)',
2507
+ example: 'payee.starbucks',
2508
+ maxLength: 100
1755
2509
  },
1756
- symbol: {
2510
+ category: {
1757
2511
  type: 'string',
1758
- description: 'Commodity symbol (corresponds to Beancount currency field)',
1759
- example: 'AAPL'
2512
+ description: 'Payee category classification',
2513
+ enum: [
2514
+ 'RESTAURANT',
2515
+ 'CAFE',
2516
+ 'FAST_FOOD',
2517
+ 'BAR',
2518
+ 'SUPERMARKET',
2519
+ 'CONVENIENCE_STORE',
2520
+ 'SHOPPING_MALL',
2521
+ 'ONLINE_SHOPPING',
2522
+ 'TAXI',
2523
+ 'RIDE_SHARING',
2524
+ 'PUBLIC_TRANSPORT',
2525
+ 'PARKING',
2526
+ 'GAS_STATION',
2527
+ 'UTILITIES',
2528
+ 'TELECOM',
2529
+ 'STREAMING',
2530
+ 'HEALTHCARE',
2531
+ 'EDUCATION',
2532
+ 'ENTERTAINMENT',
2533
+ 'SPORTS',
2534
+ 'TRAVEL',
2535
+ 'HOTEL',
2536
+ 'OTHER'
2537
+ ],
2538
+ example: 'CAFE'
1760
2539
  },
1761
- date: {
2540
+ subCategory: {
1762
2541
  type: 'string',
1763
- description:
1764
- 'Commodity definition date (required per Beancount spec). Represents when this commodity was first defined in the accounting system.',
1765
- example: '2024-01-01',
1766
- format: 'date'
2542
+ description: 'Sub-category for more specific classification',
2543
+ example: 'coffee_chain',
2544
+ maxLength: 100
1767
2545
  },
1768
- metadata: {
1769
- type: 'object',
2546
+ countries: {
1770
2547
  description:
1771
- 'Metadata (corresponds to Beancount meta field). Contains name, assetClass, precision, note, tags, etc.',
1772
- example: {
1773
- name: 'Apple Inc.',
1774
- assetClass: 'stock',
1775
- precision: 2,
1776
- note: 'Tech stock',
1777
- source: 'AUTO_CREATED'
2548
+ 'Country/region codes where the payee operates (ISO 3166-1 alpha-2)',
2549
+ example: ['CN', 'US', 'JP'],
2550
+ type: 'array',
2551
+ items: {
2552
+ type: 'string'
1778
2553
  }
1779
2554
  },
1780
- symbolProfileId: {
1781
- type: 'object',
1782
- description:
1783
- 'Reference to SymbolProfile (market data integration, SaaS feature)',
1784
- example: 'uuid-789',
1785
- nullable: true
1786
- },
1787
- createdAt: {
1788
- format: 'date-time',
2555
+ primaryCountry: {
1789
2556
  type: 'string',
1790
- description: 'Creation timestamp',
1791
- example: '2024-11-03T10:00:00Z'
2557
+ description: 'Primary operating country (ISO 3166-1 alpha-2)',
2558
+ example: 'US',
2559
+ maxLength: 2
1792
2560
  },
1793
- updatedAt: {
1794
- format: 'date-time',
1795
- type: 'string',
1796
- description: 'Last update timestamp',
1797
- example: '2024-11-03T10:00:00Z'
1798
- }
1799
- },
1800
- required: ['id', 'symbol', 'date', 'metadata', 'createdAt', 'updatedAt']
1801
- } as const;
1802
-
1803
- export const $CommodityListResponseDto = {
1804
- type: 'object',
1805
- properties: {
1806
- items: {
1807
- description: 'List of commodities',
2561
+ keywords: {
2562
+ description: 'Search keywords for fuzzy matching',
2563
+ example: ['coffee', 'cafe', 'drinks'],
1808
2564
  type: 'array',
1809
2565
  items: {
1810
- $ref: '#/components/schemas/CommodityResponseDto'
2566
+ type: 'string'
1811
2567
  }
1812
2568
  },
1813
- total: {
1814
- type: 'number',
1815
- description: 'Total number of commodities',
2569
+ logoUrl: {
2570
+ type: 'string',
2571
+ description: 'Payee logo URL',
2572
+ example: 'https://example.com/logo.png'
2573
+ },
2574
+ website: {
2575
+ type: 'string',
2576
+ description: 'Official website URL',
2577
+ example: 'https://www.starbucks.com'
2578
+ },
2579
+ description: {
2580
+ type: 'string',
2581
+ description: 'Payee description',
2582
+ example: 'Global coffeehouse chain headquartered in Seattle',
2583
+ maxLength: 1000
2584
+ },
2585
+ meta: {
2586
+ type: 'object',
2587
+ description:
2588
+ 'Extended metadata (business hours, contact info, additional details)',
2589
+ example: {
2590
+ businessHours: '07:00-22:00',
2591
+ phone: '+1-800-782-7282'
2592
+ }
2593
+ },
2594
+ dataSource: {
2595
+ type: 'string',
2596
+ description: 'Data source for this profile',
2597
+ enum: ['MANUAL', 'IMPORT', 'API', 'CROWDSOURCED'],
2598
+ default: 'MANUAL'
2599
+ },
2600
+ isActive: {
2601
+ type: 'boolean',
2602
+ description: 'Whether the payee profile is active (soft delete)',
2603
+ example: true
2604
+ },
2605
+ verifiedAt: {
2606
+ type: 'string',
2607
+ description:
2608
+ 'Verification timestamp. Set to current time to verify, or null to unverify.',
2609
+ example: '2025-01-01T00:00:00.000Z',
2610
+ format: 'date-time',
2611
+ nullable: true
2612
+ }
2613
+ }
2614
+ } as const;
2615
+
2616
+ export const $CreateCommodityDto = {
2617
+ type: 'object',
2618
+ properties: {
2619
+ symbol: {
2620
+ type: 'string',
2621
+ description:
2622
+ 'Commodity symbol (e.g., AAPL, USD, BTC) - corresponds to Beancount currency field',
2623
+ example: 'AAPL',
2624
+ maxLength: 50
2625
+ },
2626
+ date: {
2627
+ type: 'string',
2628
+ description:
2629
+ 'Commodity definition date (ISO 8601, required per Beancount spec). Represents when this commodity was first defined in the accounting system.',
2630
+ example: '2024-01-01',
2631
+ format: 'date'
2632
+ },
2633
+ metadata: {
2634
+ type: 'object',
2635
+ description:
2636
+ 'Metadata (corresponds to Beancount meta field). Can contain name, assetClass, precision, note, tags, etc.',
2637
+ example: {
2638
+ name: 'Apple Inc.',
2639
+ assetClass: 'stock',
2640
+ precision: 2,
2641
+ note: 'Long-term investment',
2642
+ tags: ['tech', 'dividend']
2643
+ }
2644
+ }
2645
+ },
2646
+ required: ['symbol', 'date']
2647
+ } as const;
2648
+
2649
+ export const $CommodityResponseDto = {
2650
+ type: 'object',
2651
+ properties: {
2652
+ id: {
2653
+ type: 'string',
2654
+ description: 'Unique identifier',
2655
+ example: 'uuid-123-456'
2656
+ },
2657
+ userId: {
2658
+ type: 'string',
2659
+ description: 'User ID (owner of the commodity)',
2660
+ example: 'user-123',
2661
+ nullable: true
2662
+ },
2663
+ symbol: {
2664
+ type: 'string',
2665
+ description: 'Commodity symbol (corresponds to Beancount currency field)',
2666
+ example: 'AAPL'
2667
+ },
2668
+ date: {
2669
+ type: 'string',
2670
+ description:
2671
+ 'Commodity definition date (required per Beancount spec). Represents when this commodity was first defined in the accounting system.',
2672
+ example: '2024-01-01',
2673
+ format: 'date'
2674
+ },
2675
+ metadata: {
2676
+ type: 'object',
2677
+ description:
2678
+ 'Metadata (corresponds to Beancount meta field). Contains name, assetClass, precision, note, tags, etc.',
2679
+ example: {
2680
+ name: 'Apple Inc.',
2681
+ assetClass: 'stock',
2682
+ precision: 2,
2683
+ note: 'Tech stock',
2684
+ source: 'AUTO_CREATED'
2685
+ }
2686
+ },
2687
+ createdAt: {
2688
+ format: 'date-time',
2689
+ type: 'string',
2690
+ description: 'Creation timestamp',
2691
+ example: '2024-11-03T10:00:00Z'
2692
+ },
2693
+ updatedAt: {
2694
+ format: 'date-time',
2695
+ type: 'string',
2696
+ description: 'Last update timestamp',
2697
+ example: '2024-11-03T10:00:00Z'
2698
+ }
2699
+ },
2700
+ required: ['id', 'symbol', 'date', 'metadata', 'createdAt', 'updatedAt']
2701
+ } as const;
2702
+
2703
+ export const $CommodityListResponseDto = {
2704
+ type: 'object',
2705
+ properties: {
2706
+ items: {
2707
+ description: 'List of commodities',
2708
+ type: 'array',
2709
+ items: {
2710
+ $ref: '#/components/schemas/CommodityResponseDto'
2711
+ }
2712
+ },
2713
+ total: {
2714
+ type: 'number',
2715
+ description: 'Total number of commodities',
1816
2716
  example: 42
1817
2717
  }
1818
2718
  },
1819
2719
  required: ['items', 'total']
1820
2720
  } as const;
1821
2721
 
2722
+ export const $UpdateCommodityDto = {
2723
+ type: 'object',
2724
+ properties: {
2725
+ date: {
2726
+ type: 'string',
2727
+ description:
2728
+ 'Commodity definition date (ISO 8601). Represents when this commodity was first defined in the accounting system.',
2729
+ example: '2024-01-01',
2730
+ format: 'date'
2731
+ },
2732
+ metadata: {
2733
+ type: 'object',
2734
+ description:
2735
+ 'Metadata (corresponds to Beancount meta field). Will merge with existing metadata. Can contain name, assetClass, precision, note, tags, etc.',
2736
+ example: {
2737
+ name: 'Updated Apple Inc.',
2738
+ assetClass: 'equity',
2739
+ precision: 4,
2740
+ note: 'Updated investment strategy',
2741
+ lastReviewed: '2024-11-03'
2742
+ }
2743
+ }
2744
+ }
2745
+ } as const;
2746
+
2747
+ export const $CreateRecurringRuleDto = {
2748
+ type: 'object',
2749
+ properties: {
2750
+ name: {
2751
+ type: 'string',
2752
+ description: 'Rule name (unique per user)',
2753
+ maxLength: 100
2754
+ },
2755
+ icon: {
2756
+ type: 'string',
2757
+ description: 'Icon emoji',
2758
+ maxLength: 10
2759
+ },
2760
+ frequency: {
2761
+ type: 'string',
2762
+ description: 'Recurring frequency',
2763
+ enum: [
2764
+ 'WEEKLY',
2765
+ 'BIWEEKLY',
2766
+ 'MONTHLY',
2767
+ 'BIMONTHLY',
2768
+ 'QUARTERLY',
2769
+ 'YEARLY',
2770
+ 'CUSTOM'
2771
+ ]
2772
+ },
2773
+ expectedAmount: {
2774
+ type: 'number',
2775
+ description: 'Expected amount (positive number)',
2776
+ minimum: 0
2777
+ },
2778
+ expectedDay: {
2779
+ type: 'number',
2780
+ description: 'Expected day of month (1-31)',
2781
+ minimum: 1,
2782
+ maximum: 31
2783
+ },
2784
+ customIntervalDays: {
2785
+ type: 'number',
2786
+ description: 'Custom interval in days (required for CUSTOM frequency)',
2787
+ minimum: 1
2788
+ },
2789
+ currency: {
2790
+ type: 'string',
2791
+ description: 'Currency code',
2792
+ default: 'CNY',
2793
+ maxLength: 10
2794
+ },
2795
+ matchPayeePattern: {
2796
+ type: 'string',
2797
+ description: 'Payee matching pattern (supports wildcards)',
2798
+ maxLength: 200
2799
+ },
2800
+ matchAmountTolerance: {
2801
+ type: 'number',
2802
+ description: 'Amount tolerance percentage (0-1)',
2803
+ default: 0.075,
2804
+ minimum: 0,
2805
+ maximum: 1
2806
+ },
2807
+ defaultExpenseAccount: {
2808
+ type: 'string',
2809
+ description: 'Default expense account for auto-create',
2810
+ maxLength: 200
2811
+ },
2812
+ defaultPaymentAccount: {
2813
+ type: 'string',
2814
+ description: 'Default payment account for auto-create',
2815
+ maxLength: 200
2816
+ },
2817
+ defaultPayee: {
2818
+ type: 'string',
2819
+ description: 'Default payee for auto-create',
2820
+ maxLength: 200
2821
+ },
2822
+ autoCreate: {
2823
+ type: 'boolean',
2824
+ description: 'Auto-create transaction when expected date arrives',
2825
+ default: false
2826
+ },
2827
+ startDate: {
2828
+ type: 'string',
2829
+ description: 'Rule start date (ISO format)'
2830
+ },
2831
+ endDate: {
2832
+ type: 'string',
2833
+ description: 'Rule end date (ISO format)'
2834
+ }
2835
+ },
2836
+ required: [
2837
+ 'name',
2838
+ 'frequency',
2839
+ 'expectedAmount',
2840
+ 'currency',
2841
+ 'matchAmountTolerance',
2842
+ 'autoCreate'
2843
+ ]
2844
+ } as const;
2845
+
1822
2846
  export const $RecurringRuleResponseDto = {
1823
2847
  type: 'object',
1824
2848
  properties: {
@@ -1930,6 +2954,37 @@ export const $RecurringRuleResponseDto = {
1930
2954
  ]
1931
2955
  } as const;
1932
2956
 
2957
+ export const $CreateRuleFromTransactionDto = {
2958
+ type: 'object',
2959
+ properties: {
2960
+ frequency: {
2961
+ type: 'string',
2962
+ description: 'Recurring frequency',
2963
+ enum: [
2964
+ 'WEEKLY',
2965
+ 'BIWEEKLY',
2966
+ 'MONTHLY',
2967
+ 'BIMONTHLY',
2968
+ 'QUARTERLY',
2969
+ 'YEARLY',
2970
+ 'CUSTOM'
2971
+ ],
2972
+ example: 'MONTHLY'
2973
+ },
2974
+ name: {
2975
+ type: 'string',
2976
+ description: 'Optional name override (default: transaction payee)',
2977
+ maxLength: 100
2978
+ },
2979
+ icon: {
2980
+ type: 'string',
2981
+ description: 'Optional icon emoji',
2982
+ maxLength: 10
2983
+ }
2984
+ },
2985
+ required: ['frequency']
2986
+ } as const;
2987
+
1933
2988
  export const $RecurringRuleWithStatsResponseDto = {
1934
2989
  type: 'object',
1935
2990
  properties: {
@@ -2088,22 +3143,110 @@ export const $RecurringRuleWithStatsResponseDto = {
2088
3143
  ]
2089
3144
  } as const;
2090
3145
 
2091
- export const $ExpectedTransactionRuleDto = {
3146
+ export const $UpdateRecurringRuleDto = {
2092
3147
  type: 'object',
2093
3148
  properties: {
2094
3149
  name: {
2095
3150
  type: 'string',
2096
- description: 'Rule name'
3151
+ description: 'Rule name',
3152
+ maxLength: 100
2097
3153
  },
2098
3154
  icon: {
2099
- type: 'object',
2100
- description: 'Rule icon'
2101
- },
2102
- frequency: {
2103
3155
  type: 'string',
2104
- description: 'Rule frequency'
3156
+ description: 'Icon emoji',
3157
+ maxLength: 10
2105
3158
  },
2106
- currency: {
3159
+ frequency: {
3160
+ type: 'string',
3161
+ description: 'Recurring frequency',
3162
+ enum: [
3163
+ 'WEEKLY',
3164
+ 'BIWEEKLY',
3165
+ 'MONTHLY',
3166
+ 'BIMONTHLY',
3167
+ 'QUARTERLY',
3168
+ 'YEARLY',
3169
+ 'CUSTOM'
3170
+ ]
3171
+ },
3172
+ expectedAmount: {
3173
+ type: 'number',
3174
+ description: 'Expected amount',
3175
+ minimum: 0
3176
+ },
3177
+ expectedDay: {
3178
+ type: 'number',
3179
+ description: 'Expected day of month (1-31)',
3180
+ minimum: 1,
3181
+ maximum: 31
3182
+ },
3183
+ customIntervalDays: {
3184
+ type: 'number',
3185
+ description: 'Custom interval in days',
3186
+ minimum: 1
3187
+ },
3188
+ currency: {
3189
+ type: 'string',
3190
+ description: 'Currency code',
3191
+ maxLength: 10
3192
+ },
3193
+ matchPayeePattern: {
3194
+ type: 'string',
3195
+ description: 'Payee matching pattern',
3196
+ maxLength: 200
3197
+ },
3198
+ matchAmountTolerance: {
3199
+ type: 'number',
3200
+ description: 'Amount tolerance percentage (0-1)',
3201
+ minimum: 0,
3202
+ maximum: 1
3203
+ },
3204
+ defaultExpenseAccount: {
3205
+ type: 'string',
3206
+ description: 'Default expense account',
3207
+ maxLength: 200
3208
+ },
3209
+ defaultPaymentAccount: {
3210
+ type: 'string',
3211
+ description: 'Default payment account',
3212
+ maxLength: 200
3213
+ },
3214
+ defaultPayee: {
3215
+ type: 'string',
3216
+ description: 'Default payee',
3217
+ maxLength: 200
3218
+ },
3219
+ autoCreate: {
3220
+ type: 'boolean',
3221
+ description: 'Auto-create transaction'
3222
+ },
3223
+ isActive: {
3224
+ type: 'boolean',
3225
+ description: 'Rule active status'
3226
+ },
3227
+ endDate: {
3228
+ type: 'string',
3229
+ description: 'Rule end date (ISO format)'
3230
+ }
3231
+ }
3232
+ } as const;
3233
+
3234
+ export const $ExpectedTransactionRuleDto = {
3235
+ type: 'object',
3236
+ properties: {
3237
+ name: {
3238
+ type: 'string',
3239
+ description: 'Rule name'
3240
+ },
3241
+ icon: {
3242
+ type: 'object',
3243
+ description: 'Rule icon'
3244
+ },
3245
+ frequency: {
3246
+ type: 'string',
3247
+ description: 'Rule frequency'
3248
+ },
3249
+ currency: {
2107
3250
  type: 'string',
2108
3251
  description: 'Currency code'
2109
3252
  }
@@ -2204,6 +3347,50 @@ export const $ExpectedTransactionListResponseDto = {
2204
3347
  required: ['items', 'total']
2205
3348
  } as const;
2206
3349
 
3350
+ export const $ConfirmMatchDto = {
3351
+ type: 'object',
3352
+ properties: {
3353
+ transactionId: {
3354
+ type: 'string',
3355
+ description: 'Transaction ID to match with'
3356
+ }
3357
+ },
3358
+ required: ['transactionId']
3359
+ } as const;
3360
+
3361
+ export const $EnterNowDto = {
3362
+ type: 'object',
3363
+ properties: {
3364
+ expenseAccount: {
3365
+ type: 'string',
3366
+ description:
3367
+ 'Override expense account (uses rule default if not provided)',
3368
+ maxLength: 200
3369
+ },
3370
+ paymentAccount: {
3371
+ type: 'string',
3372
+ description:
3373
+ 'Override payment account (uses rule default if not provided)',
3374
+ maxLength: 200
3375
+ },
3376
+ amount: {
3377
+ type: 'number',
3378
+ description: 'Override amount (uses expected amount if not provided)',
3379
+ minimum: 0
3380
+ },
3381
+ payee: {
3382
+ type: 'string',
3383
+ description: 'Override payee (uses rule default if not provided)',
3384
+ maxLength: 200
3385
+ },
3386
+ narration: {
3387
+ type: 'string',
3388
+ description: 'Optional narration',
3389
+ maxLength: 500
3390
+ }
3391
+ }
3392
+ } as const;
3393
+
2207
3394
  export const $ForecastItemDto = {
2208
3395
  type: 'object',
2209
3396
  properties: {
@@ -2228,7 +3415,7 @@ export const $ForecastItemDto = {
2228
3415
  example: '2024-04-01'
2229
3416
  },
2230
3417
  icon: {
2231
- type: 'object',
3418
+ type: 'string',
2232
3419
  description: 'Rule icon emoji',
2233
3420
  example: '🏠',
2234
3421
  nullable: true
@@ -2328,6 +3515,107 @@ export const $ForecastResponseDto = {
2328
3515
  ]
2329
3516
  } as const;
2330
3517
 
3518
+ export const $CreateTransactionRuleDto = {
3519
+ type: 'object',
3520
+ properties: {
3521
+ name: {
3522
+ type: 'string',
3523
+ minLength: 1,
3524
+ maxLength: 100
3525
+ },
3526
+ description: {
3527
+ type: 'string',
3528
+ maxLength: 500
3529
+ },
3530
+ narrationKeywords: {
3531
+ items: {
3532
+ type: 'array'
3533
+ },
3534
+ maxItems: 50,
3535
+ type: 'array'
3536
+ },
3537
+ payeeKeywords: {
3538
+ items: {
3539
+ type: 'array'
3540
+ },
3541
+ maxItems: 50,
3542
+ type: 'array'
3543
+ },
3544
+ categoryKeywords: {
3545
+ items: {
3546
+ type: 'array'
3547
+ },
3548
+ maxItems: 50,
3549
+ type: 'array'
3550
+ },
3551
+ methodKeywords: {
3552
+ items: {
3553
+ type: 'array'
3554
+ },
3555
+ maxItems: 50,
3556
+ description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
3557
+ type: 'array'
3558
+ },
3559
+ categoryAccount: {
3560
+ type: 'string',
3561
+ maxLength: 200,
3562
+ description:
3563
+ 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
3564
+ },
3565
+ matchLogic: {
3566
+ type: 'string',
3567
+ enum: ['OR', 'AND'],
3568
+ default: 'OR'
3569
+ },
3570
+ amountMin: {
3571
+ type: 'number',
3572
+ minimum: 0,
3573
+ description: 'Minimum transaction amount (inclusive)'
3574
+ },
3575
+ amountMax: {
3576
+ type: 'number',
3577
+ minimum: 0,
3578
+ description: 'Maximum transaction amount (inclusive)'
3579
+ },
3580
+ priority: {
3581
+ type: 'number',
3582
+ default: 50,
3583
+ minimum: 0,
3584
+ maximum: 1000
3585
+ },
3586
+ additionalTags: {
3587
+ items: {
3588
+ type: 'array'
3589
+ },
3590
+ maxItems: 20,
3591
+ type: 'array'
3592
+ },
3593
+ additionalMetadata: {
3594
+ type: 'object'
3595
+ },
3596
+ upsertByPayee: {
3597
+ type: 'boolean',
3598
+ description:
3599
+ 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
3600
+ }
3601
+ },
3602
+ required: ['name', 'matchLogic', 'priority']
3603
+ } as const;
3604
+
3605
+ export const $AmountRangeDto = {
3606
+ type: 'object',
3607
+ properties: {
3608
+ min: {
3609
+ type: 'number',
3610
+ description: 'Minimum amount'
3611
+ },
3612
+ max: {
3613
+ type: 'number',
3614
+ description: 'Maximum amount'
3615
+ }
3616
+ }
3617
+ } as const;
3618
+
2331
3619
  export const $TransactionRuleResponseDto = {
2332
3620
  type: 'object',
2333
3621
  properties: {
@@ -2382,12 +3670,12 @@ export const $TransactionRuleResponseDto = {
2382
3670
  example: 'OR'
2383
3671
  },
2384
3672
  amountRange: {
2385
- type: 'object',
2386
3673
  description: 'Amount range for matching',
2387
- example: {
2388
- min: 0,
2389
- max: 100
2390
- }
3674
+ allOf: [
3675
+ {
3676
+ $ref: '#/components/schemas/AmountRangeDto'
3677
+ }
3678
+ ]
2391
3679
  },
2392
3680
  priority: {
2393
3681
  type: 'number',
@@ -2402,6 +3690,7 @@ export const $TransactionRuleResponseDto = {
2402
3690
  type: 'string',
2403
3691
  description: 'Learning source: NLP, REVIEW_CENTER, or null for manual',
2404
3692
  enum: ['NLP', 'REVIEW_CENTER'],
3693
+ nullable: true,
2405
3694
  example: 'REVIEW_CENTER'
2406
3695
  },
2407
3696
  autoApplyEnabled: {
@@ -2423,7 +3712,9 @@ export const $TransactionRuleResponseDto = {
2423
3712
  additionalMetadata: {
2424
3713
  type: 'object',
2425
3714
  description: 'Additional metadata',
2426
- example: {}
3715
+ additionalProperties: {
3716
+ type: 'string'
3717
+ }
2427
3718
  },
2428
3719
  createdAt: {
2429
3720
  format: 'date-time',
@@ -2596,53 +3887,111 @@ export const $ValidateRuleResponseDto = {
2596
3887
  required: ['valid', 'errors', 'warnings']
2597
3888
  } as const;
2598
3889
 
2599
- export const $ExportRulesResponseDto = {
3890
+ export const $BulkCreateRulesDto = {
2600
3891
  type: 'object',
2601
3892
  properties: {
2602
- exportedAt: {
2603
- type: 'string',
2604
- description: 'Export timestamp'
3893
+ rules: {
3894
+ items: {
3895
+ type: 'array'
3896
+ },
3897
+ description: 'Array of rules to import',
3898
+ type: 'array'
2605
3899
  },
2606
- userId: {
3900
+ conflictStrategy: {
2607
3901
  type: 'string',
2608
- description: 'User ID'
2609
- },
2610
- ruleCount: {
2611
- type: 'number',
2612
- description: 'Number of exported rules'
2613
- },
2614
- rules: {
2615
- type: 'array',
2616
- description: 'Exported rules'
3902
+ enum: ['replace', 'skip'],
3903
+ default: 'skip',
3904
+ description:
3905
+ 'Conflict handling strategy: skip (default) ignores duplicates, replace soft-deletes existing rule'
2617
3906
  }
2618
3907
  },
2619
- required: ['exportedAt', 'userId', 'ruleCount', 'rules']
3908
+ required: ['rules', 'conflictStrategy']
2620
3909
  } as const;
2621
3910
 
2622
- export const $RuleStatisticsResponseDto = {
3911
+ export const $BulkCreateRulesResponseDto = {
2623
3912
  type: 'object',
2624
3913
  properties: {
2625
- period: {
2626
- type: 'string',
2627
- description: 'Statistics time period',
2628
- enum: ['7d', '30d', '90d']
2629
- },
2630
- totalRules: {
2631
- type: 'number',
2632
- description: 'Total number of rules'
2633
- },
2634
- rulesWithMatches: {
3914
+ successCount: {
2635
3915
  type: 'number',
2636
- description: 'Number of rules with at least one match'
3916
+ description: 'Number of successfully created rules'
2637
3917
  },
2638
- totalMatches: {
3918
+ failureCount: {
2639
3919
  type: 'number',
2640
- description: 'Total number of matches across all rules'
3920
+ description: 'Number of failed rules'
2641
3921
  },
2642
- averageConfidence: {
2643
- type: 'number',
2644
- description: 'Average confidence score across all matches',
2645
- example: 0.82
3922
+ errors: {
3923
+ type: 'array',
3924
+ description: 'Error details for failed rules',
3925
+ items: {
3926
+ type: 'object',
3927
+ properties: {
3928
+ index: {
3929
+ type: 'number'
3930
+ },
3931
+ message: {
3932
+ type: 'string'
3933
+ }
3934
+ }
3935
+ }
3936
+ },
3937
+ createdRuleIds: {
3938
+ description: 'IDs of successfully created rules',
3939
+ type: 'array',
3940
+ items: {
3941
+ type: 'string'
3942
+ }
3943
+ }
3944
+ },
3945
+ required: ['successCount', 'failureCount', 'errors', 'createdRuleIds']
3946
+ } as const;
3947
+
3948
+ export const $ExportRulesResponseDto = {
3949
+ type: 'object',
3950
+ properties: {
3951
+ exportedAt: {
3952
+ type: 'string',
3953
+ description: 'Export timestamp'
3954
+ },
3955
+ userId: {
3956
+ type: 'string',
3957
+ description: 'User ID'
3958
+ },
3959
+ ruleCount: {
3960
+ type: 'number',
3961
+ description: 'Number of exported rules'
3962
+ },
3963
+ rules: {
3964
+ type: 'array',
3965
+ description: 'Exported rules'
3966
+ }
3967
+ },
3968
+ required: ['exportedAt', 'userId', 'ruleCount', 'rules']
3969
+ } as const;
3970
+
3971
+ export const $RuleStatisticsResponseDto = {
3972
+ type: 'object',
3973
+ properties: {
3974
+ period: {
3975
+ type: 'string',
3976
+ description: 'Statistics time period',
3977
+ enum: ['7d', '30d', '90d']
3978
+ },
3979
+ totalRules: {
3980
+ type: 'number',
3981
+ description: 'Total number of rules'
3982
+ },
3983
+ rulesWithMatches: {
3984
+ type: 'number',
3985
+ description: 'Number of rules with at least one match'
3986
+ },
3987
+ totalMatches: {
3988
+ type: 'number',
3989
+ description: 'Total number of matches across all rules'
3990
+ },
3991
+ averageConfidence: {
3992
+ type: 'number',
3993
+ description: 'Average confidence score across all matches',
3994
+ example: 0.82
2646
3995
  },
2647
3996
  ruleStats: {
2648
3997
  type: 'array',
@@ -2676,6 +4025,89 @@ export const $RuleStatisticsResponseDto = {
2676
4025
  ]
2677
4026
  } as const;
2678
4027
 
4028
+ export const $UpdateTransactionRuleDto = {
4029
+ type: 'object',
4030
+ properties: {
4031
+ name: {
4032
+ type: 'string',
4033
+ minLength: 1,
4034
+ maxLength: 100
4035
+ },
4036
+ description: {
4037
+ type: 'string',
4038
+ maxLength: 500
4039
+ },
4040
+ narrationKeywords: {
4041
+ items: {
4042
+ type: 'array'
4043
+ },
4044
+ maxItems: 50,
4045
+ type: 'array'
4046
+ },
4047
+ payeeKeywords: {
4048
+ items: {
4049
+ type: 'array'
4050
+ },
4051
+ maxItems: 50,
4052
+ type: 'array'
4053
+ },
4054
+ categoryKeywords: {
4055
+ items: {
4056
+ type: 'array'
4057
+ },
4058
+ maxItems: 50,
4059
+ type: 'array'
4060
+ },
4061
+ methodKeywords: {
4062
+ items: {
4063
+ type: 'array'
4064
+ },
4065
+ maxItems: 50,
4066
+ description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
4067
+ type: 'array'
4068
+ },
4069
+ categoryAccount: {
4070
+ type: 'string',
4071
+ maxLength: 200,
4072
+ description:
4073
+ 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
4074
+ },
4075
+ matchLogic: {
4076
+ type: 'string',
4077
+ enum: ['OR', 'AND']
4078
+ },
4079
+ amountMin: {
4080
+ type: 'number',
4081
+ minimum: 0,
4082
+ description: 'Minimum transaction amount (inclusive)'
4083
+ },
4084
+ amountMax: {
4085
+ type: 'number',
4086
+ minimum: 0,
4087
+ description: 'Maximum transaction amount (inclusive)'
4088
+ },
4089
+ priority: {
4090
+ type: 'number',
4091
+ minimum: 0,
4092
+ maximum: 1000
4093
+ },
4094
+ enabled: {
4095
+ type: 'boolean',
4096
+ description: 'Enable or disable the rule'
4097
+ },
4098
+ additionalTags: {
4099
+ items: {
4100
+ type: 'array'
4101
+ },
4102
+ maxItems: 20,
4103
+ type: 'array'
4104
+ },
4105
+ additionalMetadata: {
4106
+ type: 'object'
4107
+ }
4108
+ }
4109
+ } as const;
4110
+
2679
4111
  export const $TestRuleDto = {
2680
4112
  type: 'object',
2681
4113
  properties: {
@@ -2868,6 +4300,17 @@ export const $UpdateUserSettingDto = {
2868
4300
  }
2869
4301
  } as const;
2870
4302
 
4303
+ export const $UpdatePropertyDto = {
4304
+ type: 'object',
4305
+ properties: {
4306
+ value: {
4307
+ type: 'string',
4308
+ description: 'Property value'
4309
+ }
4310
+ },
4311
+ required: ['value']
4312
+ } as const;
4313
+
2871
4314
  export const $FileImportDto = {
2872
4315
  type: 'object',
2873
4316
  properties: {
@@ -3214,104 +4657,279 @@ export const $ImporterConfigDto = {
3214
4657
  ]
3215
4658
  } as const;
3216
4659
 
3217
- export const $ProviderSyncConfigDto = {
4660
+ export const $UpdateMapperDefaultsDto = {
3218
4661
  type: 'object',
3219
4662
  properties: {
3220
4663
  sourceAccount: {
3221
4664
  type: 'string',
3222
- description: 'Source account for the first posting',
3223
- example: 'Assets:Bank:Chase'
4665
+ description: 'Source account for transactions (Beancount format)',
4666
+ example: 'Assets:Alipay:Balance',
4667
+ pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
3224
4668
  },
3225
- defaultCurrency: {
4669
+ currency: {
3226
4670
  type: 'string',
3227
- description: 'Default currency for transactions',
3228
- example: 'USD'
4671
+ description: 'Default currency (ISO 4217 code)',
4672
+ example: 'CNY',
4673
+ minLength: 3,
4674
+ maxLength: 3,
4675
+ pattern: '^[A-Z]{3}$'
3229
4676
  },
3230
- defaultExpenseAccount: {
4677
+ expenseAccount: {
3231
4678
  type: 'string',
3232
- description: 'Default expense account for the second posting',
3233
- example: 'Expenses:Unknown'
4679
+ description: 'Default expense account (optional)',
4680
+ example: 'Expenses:Unknown',
4681
+ pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
3234
4682
  },
3235
- defaultIncomeAccount: {
4683
+ incomeAccount: {
3236
4684
  type: 'string',
3237
- description: 'Default income account for the second posting',
3238
- example: 'Income:Unknown'
4685
+ description: 'Default income account (optional)',
4686
+ example: 'Income:Unknown',
4687
+ pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
3239
4688
  },
3240
- filterPending: {
3241
- type: 'boolean',
3242
- description: 'Filter pending transactions',
3243
- default: true
4689
+ methodAccountMapping: {
4690
+ type: 'object',
4691
+ description:
4692
+ '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).',
4693
+ example: {
4694
+ HuaBei: 'Liabilities:Alipay:Huabei',
4695
+ CreditCard: 'Liabilities:CreditCard'
4696
+ }
3244
4697
  }
3245
- },
3246
- required: [
3247
- 'sourceAccount',
3248
- 'defaultCurrency',
3249
- 'defaultExpenseAccount',
3250
- 'defaultIncomeAccount'
3251
- ]
4698
+ }
3252
4699
  } as const;
3253
4700
 
3254
- export const $ProviderSyncDto = {
4701
+ export const $UpdateConfigDataDto = {
3255
4702
  type: 'object',
3256
4703
  properties: {
3257
- provider: {
3258
- type: 'string',
3259
- description:
3260
- 'Provider name (already in URL path, optional here for reference)',
3261
- example: 'plaid'
3262
- },
3263
- syncId: {
3264
- type: 'string',
3265
- description: 'Unique sync identifier for idempotency',
3266
- example: 'sync-12345'
3267
- },
3268
- config: {
3269
- description: 'Provider sync configuration',
4704
+ defaults: {
4705
+ description: 'Mapper defaults configuration',
3270
4706
  allOf: [
3271
4707
  {
3272
- $ref: '#/components/schemas/ProviderSyncConfigDto'
4708
+ $ref: '#/components/schemas/UpdateMapperDefaultsDto'
3273
4709
  }
3274
4710
  ]
3275
- },
3276
- transactions: {
3277
- type: 'array',
3278
- description: 'Raw transactions from provider',
3279
- example: [
4711
+ }
4712
+ }
4713
+ } as const;
4714
+
4715
+ export const $UpdateImporterConfigDto = {
4716
+ type: 'object',
4717
+ properties: {
4718
+ data: {
4719
+ description: 'Configuration data (v1 schema)',
4720
+ allOf: [
3280
4721
  {
3281
- transaction_id: 'txn-001',
3282
- amount: 50,
3283
- iso_currency_code: 'USD',
3284
- date: '2024-01-15',
3285
- merchant_name: 'Starbucks',
3286
- name: 'STARBUCKS STORE 12345',
3287
- pending: false,
3288
- account_id: 'acc-001'
4722
+ $ref: '#/components/schemas/UpdateConfigDataDto'
3289
4723
  }
3290
4724
  ]
3291
4725
  }
3292
- },
3293
- required: ['config', 'transactions']
4726
+ }
3294
4727
  } as const;
3295
4728
 
3296
- export const $ProviderSyncResponseDto = {
4729
+ export const $CreatePlatformDto = {
3297
4730
  type: 'object',
3298
4731
  properties: {
3299
- imported: {
3300
- type: 'number',
3301
- description: 'Number of transactions successfully imported',
3302
- example: 10
4732
+ name: {
4733
+ type: 'string',
4734
+ description: 'Platform name',
4735
+ example: 'Binance'
3303
4736
  },
3304
- skipped: {
3305
- type: 'number',
3306
- description: 'Number of transactions skipped (duplicates)',
3307
- example: 2
4737
+ canonical: {
4738
+ type: 'string',
4739
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
4740
+ example: 'binance'
3308
4741
  },
3309
- pendingReview: {
3310
- type: 'number',
3311
- description: 'Number of transactions pending review',
3312
- example: 3
4742
+ aliases: {
4743
+ description: 'Platform aliases (multi-language names for lookup)',
4744
+ example: ['Binance', 'Binance Exchange', 'BNB'],
4745
+ type: 'array',
4746
+ items: {
4747
+ type: 'string'
4748
+ }
3313
4749
  },
3314
- failed: {
4750
+ url: {
4751
+ type: 'string',
4752
+ description: 'Platform URL',
4753
+ example: 'https://www.binance.com'
4754
+ },
4755
+ type: {
4756
+ type: 'string',
4757
+ description: 'Platform type',
4758
+ enum: [
4759
+ 'BANK',
4760
+ 'BROKERAGE',
4761
+ 'CRYPTO_EXCHANGE',
4762
+ 'PAYMENT',
4763
+ 'INVESTMENT',
4764
+ 'INSURANCE',
4765
+ 'OTHER'
4766
+ ],
4767
+ example: 'CRYPTO_EXCHANGE'
4768
+ },
4769
+ logoUrl: {
4770
+ type: 'string',
4771
+ description: 'Platform logo URL',
4772
+ example: 'https://example.com/logos/binance.png'
4773
+ },
4774
+ isActive: {
4775
+ type: 'boolean',
4776
+ description: 'Whether the platform is active',
4777
+ default: true
4778
+ }
4779
+ },
4780
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
4781
+ } as const;
4782
+
4783
+ export const $UpdatePlatformDto = {
4784
+ type: 'object',
4785
+ properties: {
4786
+ name: {
4787
+ type: 'string',
4788
+ description: 'Platform name',
4789
+ example: 'Binance'
4790
+ },
4791
+ canonical: {
4792
+ type: 'string',
4793
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
4794
+ example: 'binance'
4795
+ },
4796
+ aliases: {
4797
+ description: 'Platform aliases (multi-language names for lookup)',
4798
+ example: ['Binance', 'Binance Exchange', 'BNB'],
4799
+ type: 'array',
4800
+ items: {
4801
+ type: 'string'
4802
+ }
4803
+ },
4804
+ url: {
4805
+ type: 'string',
4806
+ description: 'Platform URL',
4807
+ example: 'https://www.binance.com'
4808
+ },
4809
+ type: {
4810
+ type: 'string',
4811
+ description: 'Platform type',
4812
+ enum: [
4813
+ 'BANK',
4814
+ 'BROKERAGE',
4815
+ 'CRYPTO_EXCHANGE',
4816
+ 'PAYMENT',
4817
+ 'INVESTMENT',
4818
+ 'INSURANCE',
4819
+ 'OTHER'
4820
+ ],
4821
+ example: 'CRYPTO_EXCHANGE'
4822
+ },
4823
+ logoUrl: {
4824
+ type: 'string',
4825
+ description: 'Platform logo URL',
4826
+ example: 'https://example.com/logos/binance.png'
4827
+ },
4828
+ isActive: {
4829
+ type: 'boolean',
4830
+ description: 'Whether the platform is active'
4831
+ }
4832
+ }
4833
+ } as const;
4834
+
4835
+ export const $ProviderSyncConfigDto = {
4836
+ type: 'object',
4837
+ properties: {
4838
+ sourceAccount: {
4839
+ type: 'string',
4840
+ description: 'Source account for the first posting',
4841
+ example: 'Assets:Bank:Chase'
4842
+ },
4843
+ defaultCurrency: {
4844
+ type: 'string',
4845
+ description: 'Default currency for transactions',
4846
+ example: 'USD'
4847
+ },
4848
+ defaultExpenseAccount: {
4849
+ type: 'string',
4850
+ description: 'Default expense account for the second posting',
4851
+ example: 'Expenses:Unknown'
4852
+ },
4853
+ defaultIncomeAccount: {
4854
+ type: 'string',
4855
+ description: 'Default income account for the second posting',
4856
+ example: 'Income:Unknown'
4857
+ },
4858
+ filterPending: {
4859
+ type: 'boolean',
4860
+ description: 'Filter pending transactions',
4861
+ default: true
4862
+ }
4863
+ },
4864
+ required: [
4865
+ 'sourceAccount',
4866
+ 'defaultCurrency',
4867
+ 'defaultExpenseAccount',
4868
+ 'defaultIncomeAccount'
4869
+ ]
4870
+ } as const;
4871
+
4872
+ export const $ProviderSyncDto = {
4873
+ type: 'object',
4874
+ properties: {
4875
+ provider: {
4876
+ type: 'string',
4877
+ description:
4878
+ 'Provider name (already in URL path, optional here for reference)',
4879
+ example: 'plaid'
4880
+ },
4881
+ syncId: {
4882
+ type: 'string',
4883
+ description: 'Unique sync identifier for idempotency',
4884
+ example: 'sync-12345'
4885
+ },
4886
+ config: {
4887
+ description: 'Provider sync configuration',
4888
+ allOf: [
4889
+ {
4890
+ $ref: '#/components/schemas/ProviderSyncConfigDto'
4891
+ }
4892
+ ]
4893
+ },
4894
+ transactions: {
4895
+ type: 'array',
4896
+ description: 'Raw transactions from provider',
4897
+ example: [
4898
+ {
4899
+ transaction_id: 'txn-001',
4900
+ amount: 50,
4901
+ iso_currency_code: 'USD',
4902
+ date: '2024-01-15',
4903
+ merchant_name: 'Starbucks',
4904
+ name: 'STARBUCKS STORE 12345',
4905
+ pending: false,
4906
+ account_id: 'acc-001'
4907
+ }
4908
+ ]
4909
+ }
4910
+ },
4911
+ required: ['config', 'transactions']
4912
+ } as const;
4913
+
4914
+ export const $ProviderSyncResponseDto = {
4915
+ type: 'object',
4916
+ properties: {
4917
+ imported: {
4918
+ type: 'number',
4919
+ description: 'Number of transactions successfully imported',
4920
+ example: 10
4921
+ },
4922
+ skipped: {
4923
+ type: 'number',
4924
+ description: 'Number of transactions skipped (duplicates)',
4925
+ example: 2
4926
+ },
4927
+ pendingReview: {
4928
+ type: 'number',
4929
+ description: 'Number of transactions pending review',
4930
+ example: 3
4931
+ },
4932
+ failed: {
3315
4933
  type: 'number',
3316
4934
  description: 'Number of transactions that failed to import',
3317
4935
  example: 0
@@ -3365,6 +4983,11 @@ export const $ParserTelemetryReportDto = {
3365
4983
  properties: {}
3366
4984
  } as const;
3367
4985
 
4986
+ export const $UncoveredFormatMissDto = {
4987
+ type: 'object',
4988
+ properties: {}
4989
+ } as const;
4990
+
3368
4991
  export const $ProcessNlpDto = {
3369
4992
  type: 'object',
3370
4993
  properties: {
@@ -3379,6 +5002,16 @@ export const $ProcessNlpDto = {
3379
5002
  description:
3380
5003
  'Session ID for multi-turn conversation (auto-generated if not provided)',
3381
5004
  example: 'session_abc123'
5005
+ },
5006
+ parsedData: {
5007
+ type: 'object',
5008
+ description:
5009
+ 'Parsed data from previous NLP response for session recovery. Send back the parsedData received in confirm_payee/confirm responses.',
5010
+ example: {
5011
+ amount: 35,
5012
+ currency: 'CNY',
5013
+ payee: 'Starbucks'
5014
+ }
3382
5015
  }
3383
5016
  },
3384
5017
  required: ['message']
@@ -4482,6 +6115,12 @@ export const $AccountItemWithAssetClassDto = {
4482
6115
  type: 'string',
4483
6116
  description: 'Risk level',
4484
6117
  example: 'LOW'
6118
+ },
6119
+ source: {
6120
+ type: 'string',
6121
+ description:
6122
+ 'ADR-0105 classification provenance (holding level always; account level only on FALLBACK)',
6123
+ enum: ['USER_META', 'FIAT_CURRENCY', 'OPENBB_MAPPING', 'FALLBACK']
4485
6124
  }
4486
6125
  },
4487
6126
  required: ['id', 'name', 'displayName', 'balance', 'currency', 'assetClass']
@@ -4587,6 +6226,11 @@ export const $AssetClassSummaryDto = {
4587
6226
  items: {
4588
6227
  $ref: '#/components/schemas/AccountExchangeRateWarningDto'
4589
6228
  }
6229
+ },
6230
+ fallback: {
6231
+ type: 'object',
6232
+ description:
6233
+ '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.'
4590
6234
  }
4591
6235
  },
4592
6236
  required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
@@ -4609,11 +6253,107 @@ export const $AssetClassAccountsResponseDto = {
4609
6253
  $ref: '#/components/schemas/AssetClassSummaryDto'
4610
6254
  }
4611
6255
  ]
6256
+ },
6257
+ uncategorized: {
6258
+ description:
6259
+ 'ADR-0105 §6 holding-level grey-area bucket (source=FALLBACK holdings peeled out of groups). Present only for groupBy=holdingAssetClass when FALLBACK holdings exist.',
6260
+ allOf: [
6261
+ {
6262
+ $ref: '#/components/schemas/AssetClassGroupDto'
6263
+ }
6264
+ ]
4612
6265
  }
4613
6266
  },
4614
6267
  required: ['groups', 'summary']
4615
6268
  } as const;
4616
6269
 
6270
+ export const $HoldingAssetClassAccountSliceDto = {
6271
+ type: 'object',
6272
+ properties: {
6273
+ accountId: {
6274
+ type: 'string',
6275
+ description: 'Account ID'
6276
+ },
6277
+ accountPath: {
6278
+ type: 'string',
6279
+ description: 'Full account path',
6280
+ example: 'Assets:US:Investments:Brokerage'
6281
+ },
6282
+ accountCurrency: {
6283
+ type: 'string',
6284
+ description:
6285
+ 'Currency of the holding with the largest converted base value; undefined when no holding is convertible',
6286
+ example: 'USD'
6287
+ },
6288
+ marketValueBase: {
6289
+ type: 'string',
6290
+ description:
6291
+ "Account's market value in base currency (Σ converted holdings; grey bucket included)",
6292
+ example: '50000.00'
6293
+ },
6294
+ shareOfTotalPct: {
6295
+ type: 'number',
6296
+ description:
6297
+ 'Share of the global total (0-100). 0 when globalTotal is zero (no NaN/Infinity).',
6298
+ example: 42.5
6299
+ },
6300
+ groups: {
6301
+ description: 'Per-account asset-class breakdown',
6302
+ type: 'array',
6303
+ items: {
6304
+ $ref: '#/components/schemas/AssetClassGroupDto'
6305
+ }
6306
+ },
6307
+ uncategorized: {
6308
+ description:
6309
+ 'Per-account grey bucket (source=FALLBACK holdings, incl. broker cash)',
6310
+ allOf: [
6311
+ {
6312
+ $ref: '#/components/schemas/AssetClassGroupDto'
6313
+ }
6314
+ ]
6315
+ },
6316
+ holdings: {
6317
+ description:
6318
+ 'Every holding row for this account (account ID in each row’s `id` field)',
6319
+ type: 'array',
6320
+ items: {
6321
+ $ref: '#/components/schemas/AccountItemWithAssetClassDto'
6322
+ }
6323
+ }
6324
+ },
6325
+ required: [
6326
+ 'accountId',
6327
+ 'accountPath',
6328
+ 'marketValueBase',
6329
+ 'shareOfTotalPct',
6330
+ 'groups',
6331
+ 'holdings'
6332
+ ]
6333
+ } as const;
6334
+
6335
+ export const $HoldingAssetClassCrossAccountResponseDto = {
6336
+ type: 'object',
6337
+ properties: {
6338
+ global: {
6339
+ description: 'Merged cross-account holding aggregation',
6340
+ allOf: [
6341
+ {
6342
+ $ref: '#/components/schemas/AssetClassAccountsResponseDto'
6343
+ }
6344
+ ]
6345
+ },
6346
+ byAccount: {
6347
+ description: 'Per-account slices',
6348
+ type: 'array',
6349
+ items: {
6350
+ $ref: '#/components/schemas/HoldingAssetClassAccountSliceDto'
6351
+ }
6352
+ }
6353
+ },
6354
+ required: ['global', 'byAccount']
6355
+ } as const;
6356
+
4617
6357
  export const $CashFlowByCurrencyDto = {
4618
6358
  type: 'object',
4619
6359
  properties: {
@@ -4743,6 +6483,452 @@ export const $CashFlowResponseDto = {
4743
6483
  ]
4744
6484
  } as const;
4745
6485
 
6486
+ export const $MonetaryDto = {
6487
+ type: 'object',
6488
+ properties: {
6489
+ amount: {
6490
+ type: 'string',
6491
+ description: 'Amount (Decimal string)',
6492
+ example: '3000'
6493
+ },
6494
+ currency: {
6495
+ type: 'string',
6496
+ description: 'ISO 4217 currency',
6497
+ example: 'USD'
6498
+ },
6499
+ baseCcyEquivalent: {
6500
+ type: 'object',
6501
+ description: 'Converted to user base currency (Decimal string)',
6502
+ example: '21600',
6503
+ nullable: true
6504
+ }
6505
+ },
6506
+ required: ['amount', 'currency']
6507
+ } as const;
6508
+
6509
+ export const $CurrentPriceDto = {
6510
+ type: 'object',
6511
+ properties: {
6512
+ amount: {
6513
+ type: 'string',
6514
+ description: 'Price amount (Decimal string)',
6515
+ example: '250'
6516
+ },
6517
+ currency: {
6518
+ type: 'string',
6519
+ description: 'Price currency (ISO 4217)',
6520
+ example: 'USD'
6521
+ },
6522
+ date: {
6523
+ type: 'string',
6524
+ description: 'Price date (ISO 8601)',
6525
+ example: '2024-06-01'
6526
+ },
6527
+ source: {
6528
+ type: 'string',
6529
+ description: 'Price source',
6530
+ example: 'USER_OVERRIDE',
6531
+ enum: ['USER_OVERRIDE', 'OPENBB_EQUITY', 'OPENBB_CURRENCY']
6532
+ }
6533
+ },
6534
+ required: ['amount', 'currency', 'date', 'source']
6535
+ } as const;
6536
+
6537
+ export const $FxRateDto = {
6538
+ type: 'object',
6539
+ properties: {
6540
+ from: {
6541
+ type: 'string',
6542
+ example: 'USD'
6543
+ },
6544
+ to: {
6545
+ type: 'string',
6546
+ example: 'CNY'
6547
+ },
6548
+ rate: {
6549
+ type: 'string',
6550
+ description: 'FX rate (Decimal string)',
6551
+ example: '7.2'
6552
+ },
6553
+ date: {
6554
+ type: 'string',
6555
+ description: 'Rate date (ISO 8601)',
6556
+ example: '2024-01-15'
6557
+ }
6558
+ },
6559
+ required: ['from', 'to', 'rate', 'date']
6560
+ } as const;
6561
+
6562
+ export const $HoldingPnlRowDto = {
6563
+ type: 'object',
6564
+ properties: {
6565
+ accountId: {
6566
+ type: 'string',
6567
+ description: 'Account UUID',
6568
+ example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
6569
+ },
6570
+ accountPath: {
6571
+ type: 'string',
6572
+ description: 'Full account path',
6573
+ example: 'Assets:US:Broker:AAPL'
6574
+ },
6575
+ accountCcy: {
6576
+ type: 'object',
6577
+ description: 'Account settlement currency (ISO 4217), from cost currency',
6578
+ nullable: true,
6579
+ example: 'USD'
6580
+ },
6581
+ brokerType: {
6582
+ type: 'object',
6583
+ description: 'Broker type derived from Platform.type',
6584
+ nullable: true,
6585
+ example: 'broker'
6586
+ },
6587
+ symbol: {
6588
+ type: 'string',
6589
+ description: 'Commodity symbol',
6590
+ example: 'AAPL'
6591
+ },
6592
+ chartToken: {
6593
+ type: 'string',
6594
+ description: 'Chart segment token (libs/common resolver)',
6595
+ example: 'equity',
6596
+ enum: ['equity', 'fund', 'bond', 'cash', 'other']
6597
+ },
6598
+ assetClass: {
6599
+ type: 'string',
6600
+ example: 'EQUITY'
6601
+ },
6602
+ assetSubClass: {
6603
+ type: 'object',
6604
+ nullable: true,
6605
+ example: 'STOCK'
6606
+ },
6607
+ units: {
6608
+ type: 'string',
6609
+ description: 'Net held units (Decimal string)',
6610
+ example: '12'
6611
+ },
6612
+ averageCostPerUnit: {
6613
+ description:
6614
+ 'Average cost per unit; null when cost currency conflicts or no cost',
6615
+ nullable: true,
6616
+ allOf: [
6617
+ {
6618
+ $ref: '#/components/schemas/MonetaryDto'
6619
+ }
6620
+ ]
6621
+ },
6622
+ costBasis: {
6623
+ description: 'Cost basis of held units',
6624
+ nullable: true,
6625
+ allOf: [
6626
+ {
6627
+ $ref: '#/components/schemas/MonetaryDto'
6628
+ }
6629
+ ]
6630
+ },
6631
+ marketValue: {
6632
+ description: 'Market value at asOf price',
6633
+ nullable: true,
6634
+ allOf: [
6635
+ {
6636
+ $ref: '#/components/schemas/MonetaryDto'
6637
+ }
6638
+ ]
6639
+ },
6640
+ currentPrice: {
6641
+ description: 'Price used for market value',
6642
+ nullable: true,
6643
+ allOf: [
6644
+ {
6645
+ $ref: '#/components/schemas/CurrentPriceDto'
6646
+ }
6647
+ ]
6648
+ },
6649
+ unrealizedPnlBase: {
6650
+ type: 'object',
6651
+ description:
6652
+ 'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
6653
+ nullable: true,
6654
+ example: '6000'
6655
+ },
6656
+ unrealizedPnlPct: {
6657
+ type: 'object',
6658
+ description: 'Unrealized P&L % (Decimal string)',
6659
+ nullable: true,
6660
+ example: '25'
6661
+ },
6662
+ costFxRate: {
6663
+ description: 'Historical FX rate applied to cost basis',
6664
+ nullable: true,
6665
+ allOf: [
6666
+ {
6667
+ $ref: '#/components/schemas/FxRateDto'
6668
+ }
6669
+ ]
6670
+ },
6671
+ marketFxRate: {
6672
+ description: 'FX rate applied to market value',
6673
+ nullable: true,
6674
+ allOf: [
6675
+ {
6676
+ $ref: '#/components/schemas/FxRateDto'
6677
+ }
6678
+ ]
6679
+ },
6680
+ pctOfInvestedAssets: {
6681
+ type: 'object',
6682
+ description:
6683
+ 'Share of invested assets % (Decimal string); only for invested chartTokens',
6684
+ nullable: true,
6685
+ example: '40'
6686
+ },
6687
+ realizedPnl: {
6688
+ description:
6689
+ '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',
6690
+ nullable: true,
6691
+ allOf: [
6692
+ {
6693
+ $ref: '#/components/schemas/MonetaryDto'
6694
+ }
6695
+ ]
6696
+ }
6697
+ },
6698
+ required: [
6699
+ 'accountId',
6700
+ 'accountPath',
6701
+ 'symbol',
6702
+ 'chartToken',
6703
+ 'assetClass',
6704
+ 'units'
6705
+ ]
6706
+ } as const;
6707
+
6708
+ export const $HoldingPnlWarningDto = {
6709
+ type: 'object',
6710
+ properties: {
6711
+ type: {
6712
+ type: 'string',
6713
+ description: 'Warning type',
6714
+ example: 'MISSING_COST_FX_RATE',
6715
+ enum: [
6716
+ 'MISSING_COST_FX_RATE',
6717
+ 'MISSING_MARKET_FX_RATE',
6718
+ 'MISSING_SALE_PRICE',
6719
+ 'MISSING_REALIZED_FX_RATE',
6720
+ 'OVERSOLD_LOTS',
6721
+ 'NO_PRICE',
6722
+ 'MIXED_COST_CURRENCY'
6723
+ ]
6724
+ },
6725
+ symbol: {
6726
+ type: 'object',
6727
+ nullable: true
6728
+ },
6729
+ accountId: {
6730
+ type: 'object',
6731
+ nullable: true
6732
+ },
6733
+ currency: {
6734
+ type: 'object',
6735
+ nullable: true
6736
+ }
6737
+ },
6738
+ required: ['type']
6739
+ } as const;
6740
+
6741
+ export const $HoldingPnlResponseDto = {
6742
+ type: 'object',
6743
+ properties: {
6744
+ asOfDate: {
6745
+ type: 'string',
6746
+ example: '2026-07-08'
6747
+ },
6748
+ baseCurrency: {
6749
+ type: 'string',
6750
+ example: 'CNY'
6751
+ },
6752
+ method: {
6753
+ type: 'string',
6754
+ description:
6755
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
6756
+ enum: ['average', 'FIFO'],
6757
+ example: 'average'
6758
+ },
6759
+ rows: {
6760
+ type: 'array',
6761
+ items: {
6762
+ $ref: '#/components/schemas/HoldingPnlRowDto'
6763
+ }
6764
+ },
6765
+ warnings: {
6766
+ type: 'array',
6767
+ items: {
6768
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
6769
+ }
6770
+ }
6771
+ },
6772
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6773
+ } as const;
6774
+
6775
+ export const $CreateBeanPriceDto = {
6776
+ type: 'object',
6777
+ properties: {
6778
+ currency: {
6779
+ type: 'string',
6780
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6781
+ example: 'USD'
6782
+ },
6783
+ quoteCurrency: {
6784
+ type: 'string',
6785
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
6786
+ example: 'CNY'
6787
+ },
6788
+ amount: {
6789
+ type: 'number',
6790
+ description:
6791
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
6792
+ example: 175.5,
6793
+ minimum: 0
6794
+ },
6795
+ date: {
6796
+ type: 'string',
6797
+ description: 'Price date (ISO 8601 format)',
6798
+ example: '2024-11-05'
6799
+ },
6800
+ metadata: {
6801
+ type: 'object',
6802
+ description:
6803
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
6804
+ example: {
6805
+ source: 'MANUAL',
6806
+ note: 'Bank valuation report',
6807
+ confidence: 0.95
6808
+ }
6809
+ }
6810
+ },
6811
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
6812
+ } as const;
6813
+
6814
+ export const $PriceResponseDto = {
6815
+ type: 'object',
6816
+ properties: {
6817
+ id: {
6818
+ type: 'string',
6819
+ description: 'Unique identifier',
6820
+ example: 'uuid-123-456'
6821
+ },
6822
+ userId: {
6823
+ type: 'string',
6824
+ description: 'User ID (owner of the price)',
6825
+ example: 'user-123'
6826
+ },
6827
+ currency: {
6828
+ type: 'string',
6829
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6830
+ example: 'BTC'
6831
+ },
6832
+ quoteCurrency: {
6833
+ type: 'string',
6834
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
6835
+ example: 'USD'
6836
+ },
6837
+ amount: {
6838
+ type: 'number',
6839
+ description:
6840
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
6841
+ example: 50000
6842
+ },
6843
+ date: {
6844
+ type: 'string',
6845
+ description:
6846
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
6847
+ example: '2024-01-01',
6848
+ format: 'date'
6849
+ },
6850
+ meta: {
6851
+ type: 'object',
6852
+ description:
6853
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
6854
+ example: {
6855
+ source: 'MANUAL',
6856
+ note: 'User-defined price',
6857
+ confidence: 1
6858
+ }
6859
+ },
6860
+ createdAt: {
6861
+ format: 'date-time',
6862
+ type: 'string',
6863
+ description: 'Creation timestamp',
6864
+ example: '2024-11-03T10:00:00Z'
6865
+ },
6866
+ updatedAt: {
6867
+ format: 'date-time',
6868
+ type: 'string',
6869
+ description: 'Last update timestamp',
6870
+ example: '2024-11-03T10:00:00Z'
6871
+ }
6872
+ },
6873
+ required: [
6874
+ 'id',
6875
+ 'userId',
6876
+ 'currency',
6877
+ 'quoteCurrency',
6878
+ 'amount',
6879
+ 'date',
6880
+ 'meta',
6881
+ 'createdAt',
6882
+ 'updatedAt'
6883
+ ]
6884
+ } as const;
6885
+
6886
+ export const $PriceListResponseDto = {
6887
+ type: 'object',
6888
+ properties: {
6889
+ items: {
6890
+ description: 'List of prices',
6891
+ type: 'array',
6892
+ items: {
6893
+ $ref: '#/components/schemas/PriceResponseDto'
6894
+ }
6895
+ },
6896
+ total: {
6897
+ type: 'number',
6898
+ description: 'Total number of prices',
6899
+ example: 42
6900
+ }
6901
+ },
6902
+ required: ['items', 'total']
6903
+ } as const;
6904
+
6905
+ export const $UpdateBeanPriceDto = {
6906
+ type: 'object',
6907
+ properties: {
6908
+ currency: {
6909
+ type: 'string',
6910
+ description: 'Currency being priced'
6911
+ },
6912
+ quoteCurrency: {
6913
+ type: 'string',
6914
+ description: 'Quote currency (pricing currency)'
6915
+ },
6916
+ amount: {
6917
+ type: 'number',
6918
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
6919
+ minimum: 0
6920
+ },
6921
+ date: {
6922
+ type: 'string',
6923
+ description: 'Price date (ISO 8601 format)'
6924
+ },
6925
+ metadata: {
6926
+ type: 'object',
6927
+ description: 'Metadata'
6928
+ }
6929
+ }
6930
+ } as const;
6931
+
4746
6932
  export const $CurrencyBalanceDto = {
4747
6933
  type: 'object',
4748
6934
  properties: {