@firela/api-types 0.0.0-canary.0327ab9e → 0.0.0-canary.09a8ff4c

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.
@@ -466,6 +466,66 @@ export const $RegionsMetadataResponseDto = {
466
466
  required: ['regions']
467
467
  } as const;
468
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
+
469
529
  export const $CreatePostingDto = {
470
530
  type: 'object',
471
531
  properties: {
@@ -495,6 +555,33 @@ export const $CreatePostingDto = {
495
555
  example: {
496
556
  'tax-lot': 'Q1-2024'
497
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
+ ]
498
585
  }
499
586
  },
500
587
  required: ['account']
@@ -573,6 +660,32 @@ export const $CreateTransactionDto = {
573
660
  required: ['date', 'narration', 'postings']
574
661
  } as const;
575
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
+
576
689
  export const $PostingResponseDto = {
577
690
  type: 'object',
578
691
  properties: {
@@ -591,6 +704,15 @@ export const $PostingResponseDto = {
591
704
  type: 'string',
592
705
  description: 'Currency',
593
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
+ ]
594
716
  }
595
717
  },
596
718
  required: ['account']
@@ -841,6 +963,85 @@ export const $BatchTransactionResponseDto = {
841
963
  required: ['succeeded', 'failed']
842
964
  } as const;
843
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
+
844
1045
  export const $PostingDetailDto = {
845
1046
  type: 'object',
846
1047
  properties: {
@@ -854,9 +1055,9 @@ export const $PostingDetailDto = {
854
1055
  description: 'Account ID',
855
1056
  example: 'clh1234567890abcdef'
856
1057
  },
857
- accountName: {
1058
+ account: {
858
1059
  type: 'string',
859
- description: 'Account name',
1060
+ description: 'Fully-qualified Beancount account path',
860
1061
  example: 'Assets:Bank:Checking'
861
1062
  },
862
1063
  units: {
@@ -885,6 +1086,15 @@ export const $PostingDetailDto = {
885
1086
  description: 'Cost date',
886
1087
  example: '2024-01-15'
887
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
+ },
888
1098
  priceAmount: {
889
1099
  type: 'string',
890
1100
  description: 'Price amount',
@@ -905,7 +1115,7 @@ export const $PostingDetailDto = {
905
1115
  description: 'Posting metadata'
906
1116
  }
907
1117
  },
908
- required: ['id', 'accountId', 'accountName']
1118
+ required: ['id', 'accountId', 'account']
909
1119
  } as const;
910
1120
 
911
1121
  export const $TransactionDetailDto = {
@@ -977,8 +1187,8 @@ export const $TransactionDetailDto = {
977
1187
  },
978
1188
  sourceType: {
979
1189
  type: 'string',
980
- description: 'Source type (how the transaction was created)',
981
- enum: ['NLP', 'CSV', 'OCR', 'API']
1190
+ description:
1191
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
982
1192
  },
983
1193
  sourcePlatform: {
984
1194
  type: 'string',
@@ -1011,6 +1221,18 @@ export const $TransactionDetailDto = {
1011
1221
  type: 'string',
1012
1222
  description: 'Correction reason (if voided or superseded)',
1013
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'
1014
1236
  }
1015
1237
  },
1016
1238
  required: [
@@ -1235,8 +1457,8 @@ export const $TransactionSummaryDto = {
1235
1457
  },
1236
1458
  sourceType: {
1237
1459
  type: 'string',
1238
- description: 'Source type (NLP, CSV, OCR, API)',
1239
- enum: ['NLP', 'CSV', 'OCR', 'API']
1460
+ description:
1461
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1240
1462
  },
1241
1463
  sourcePlatform: {
1242
1464
  type: 'string',
@@ -1303,7 +1525,8 @@ export const $ReviewSummaryDto = {
1303
1525
  },
1304
1526
  sourceType: {
1305
1527
  type: 'string',
1306
- description: 'Source type (NLP, CSV, OCR, API)'
1528
+ description:
1529
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1307
1530
  },
1308
1531
  sourcePlatform: {
1309
1532
  type: 'string',
@@ -1413,7 +1636,20 @@ export const $DecisionOptionDto = {
1413
1636
  properties: {
1414
1637
  value: {
1415
1638
  type: 'string',
1416
- 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
+ ]
1417
1653
  },
1418
1654
  labelKey: {
1419
1655
  type: 'string',
@@ -1488,7 +1724,8 @@ export const $ReviewDetailDto = {
1488
1724
  },
1489
1725
  sourceType: {
1490
1726
  type: 'string',
1491
- description: 'Source type (NLP, CSV, OCR, API)'
1727
+ description:
1728
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1492
1729
  },
1493
1730
  sourcePlatform: {
1494
1731
  type: 'string',
@@ -1568,7 +1805,20 @@ export const $ResolveReviewDto = {
1568
1805
  action: {
1569
1806
  type: 'string',
1570
1807
  description:
1571
- 'Decision action. Available actions vary by review type: DUPLICATE: UPGRADE_REPLACE, LINK_KEEP_BOTH, IGNORE_NEW, CONFIRM_DIFFERENT | RULE_MATCH: ACCEPT, REJECT, ACCEPT_AND_LEARN | PAYEE_MATCH: ACCEPT, REJECT, ACCEPT_AND_LEARN | ACCOUNT_VALIDATION: ACCEPT, CHOOSE_OTHER, CANCEL | PIPELINE_ERROR: FIX, IGNORE, CANCEL',
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
+ ],
1572
1822
  example: 'ACCEPT'
1573
1823
  },
1574
1824
  data: {
@@ -1605,7 +1855,8 @@ export const $ResolveResultDto = {
1605
1855
  },
1606
1856
  resolutionId: {
1607
1857
  type: 'string',
1608
- description: 'Resolution ID for undo'
1858
+ description:
1859
+ 'Resolution ID for undo. Absent when the resolver rejected the decision (review stayed PENDING).'
1609
1860
  },
1610
1861
  canUndo: {
1611
1862
  type: 'boolean',
@@ -1623,7 +1874,7 @@ export const $ResolveResultDto = {
1623
1874
  example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1624
1875
  }
1625
1876
  },
1626
- required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
1877
+ required: ['success']
1627
1878
  } as const;
1628
1879
 
1629
1880
  export const $UndoResultDto = {
@@ -1659,6 +1910,19 @@ export const $BatchResolveDto = {
1659
1910
  action: {
1660
1911
  type: 'string',
1661
1912
  description: 'Decision action to apply to all items',
1913
+ enum: [
1914
+ 'UPGRADE_REPLACE',
1915
+ 'LINK_KEEP_BOTH',
1916
+ 'IGNORE_NEW',
1917
+ 'CONFIRM_DIFFERENT',
1918
+ 'ACCEPT',
1919
+ 'REJECT',
1920
+ 'ACCEPT_AND_LEARN',
1921
+ 'CHOOSE_OTHER',
1922
+ 'CANCEL',
1923
+ 'FIX',
1924
+ 'IGNORE'
1925
+ ],
1662
1926
  example: 'ACCEPT'
1663
1927
  },
1664
1928
  data: {
@@ -4048,76 +4312,214 @@ export const $UpdatePropertyDto = {
4048
4312
  required: ['value']
4049
4313
  } as const;
4050
4314
 
4051
- export const $FileImportDto = {
4315
+ export const $CreateBeanEventDto = {
4052
4316
  type: 'object',
4053
4317
  properties: {
4054
- file: {
4318
+ date: {
4055
4319
  type: 'string',
4056
- format: 'binary',
4057
- description: 'Bill file to import (CSV, PDF, OFX, etc.)',
4058
- example: 'alipay.csv'
4059
- }
4060
- },
4061
- required: ['file']
4062
- } as const;
4063
-
4064
- export const $ImportErrorDto = {
4065
- type: 'object',
4066
- properties: {
4067
- index: {
4068
- type: 'number',
4069
- description: 'Index of failed transaction in the file',
4070
- example: 5
4320
+ description: 'Life event date (ISO 8601)',
4321
+ example: '2024-03-15'
4071
4322
  },
4072
- error: {
4323
+ type: {
4073
4324
  type: 'string',
4074
- description: 'Error message',
4075
- example: 'Transaction does not balance: -100 USD != 0'
4325
+ description:
4326
+ 'Life event type (e.g., "employer", "location", "marital-status") — user-defined, no enum constraint at engine layer',
4327
+ example: 'employer'
4328
+ },
4329
+ description: {
4330
+ type: 'string',
4331
+ description:
4332
+ 'Life event description. Empty string is a VALID value (distinct from absence).',
4333
+ example: 'Acme Corp'
4334
+ },
4335
+ meta: {
4336
+ type: 'object',
4337
+ description:
4338
+ 'Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)',
4339
+ example: {
4340
+ note: 'Promotion'
4341
+ }
4076
4342
  }
4077
4343
  },
4078
- required: ['index', 'error']
4344
+ required: ['date', 'type', 'description']
4079
4345
  } as const;
4080
4346
 
4081
- export const $ReviewItemPreviewDto = {
4347
+ export const $EventResponseDto = {
4082
4348
  type: 'object',
4083
4349
  properties: {
4084
- index: {
4085
- type: 'number',
4086
- description: 'Index in the import batch (for tracking)',
4087
- example: 0
4088
- },
4089
- date: {
4350
+ id: {
4090
4351
  type: 'string',
4091
- description: 'Transaction date (ISO format)',
4092
- example: '2026-03-05'
4093
- },
4094
- amount: {
4095
- type: 'number',
4096
- description: 'Transaction amount (absolute value)',
4097
- example: 99
4352
+ description: 'Unique identifier',
4353
+ example: 'uuid-123-456'
4098
4354
  },
4099
- currency: {
4355
+ userId: {
4100
4356
  type: 'string',
4101
- description: 'Currency code',
4102
- example: 'CNY'
4357
+ description: 'User ID (owner of the life event)',
4358
+ example: 'user-123'
4103
4359
  },
4104
- narration: {
4360
+ date: {
4105
4361
  type: 'string',
4106
- description: 'Transaction narration/description',
4107
- example: 'Restaurant expense'
4362
+ description: 'Life event date (ISO 8601 format)',
4363
+ example: '2024-03-15',
4364
+ format: 'date'
4108
4365
  },
4109
- payee: {
4366
+ type: {
4110
4367
  type: 'string',
4111
- description: 'Payee name',
4112
- example: 'Restaurant ABC'
4368
+ description:
4369
+ 'Life event type (user-defined, e.g., "employer", "location")',
4370
+ example: 'employer'
4113
4371
  },
4114
- category: {
4372
+ description: {
4115
4373
  type: 'string',
4116
- description: 'Inferred category from rule matching',
4117
- example: 'food'
4374
+ description:
4375
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4376
+ example: 'Acme Corp'
4118
4377
  },
4119
- confidence: {
4120
- type: 'number',
4378
+ meta: {
4379
+ type: 'object',
4380
+ description: 'Product-side metadata (free-form JSON)',
4381
+ example: {
4382
+ note: 'Promotion'
4383
+ }
4384
+ },
4385
+ createdAt: {
4386
+ format: 'date-time',
4387
+ type: 'string',
4388
+ description: 'Creation timestamp',
4389
+ example: '2024-03-15T10:00:00Z'
4390
+ },
4391
+ updatedAt: {
4392
+ format: 'date-time',
4393
+ type: 'string',
4394
+ description:
4395
+ 'Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.',
4396
+ example: '2024-03-15T10:00:00Z'
4397
+ }
4398
+ },
4399
+ required: [
4400
+ 'id',
4401
+ 'userId',
4402
+ 'date',
4403
+ 'type',
4404
+ 'description',
4405
+ 'meta',
4406
+ 'createdAt',
4407
+ 'updatedAt'
4408
+ ]
4409
+ } as const;
4410
+
4411
+ export const $EventListResponseDto = {
4412
+ type: 'object',
4413
+ properties: {
4414
+ items: {
4415
+ description: 'List of life events',
4416
+ type: 'array',
4417
+ items: {
4418
+ $ref: '#/components/schemas/EventResponseDto'
4419
+ }
4420
+ },
4421
+ total: {
4422
+ type: 'number',
4423
+ description: 'Total number of life events matching the query',
4424
+ example: 42
4425
+ }
4426
+ },
4427
+ required: ['items', 'total']
4428
+ } as const;
4429
+
4430
+ export const $UpdateBeanEventDto = {
4431
+ type: 'object',
4432
+ properties: {
4433
+ date: {
4434
+ type: 'string',
4435
+ description: 'Life event date (ISO 8601)'
4436
+ },
4437
+ type: {
4438
+ type: 'string',
4439
+ description: 'Life event type (user-defined)'
4440
+ },
4441
+ description: {
4442
+ type: 'string',
4443
+ description:
4444
+ 'Life event description. Empty string is a VALID value (distinct from absence).'
4445
+ },
4446
+ meta: {
4447
+ type: 'object',
4448
+ description: 'Product-side metadata (free-form JSON)'
4449
+ }
4450
+ }
4451
+ } as const;
4452
+
4453
+ export const $FileImportDto = {
4454
+ type: 'object',
4455
+ properties: {
4456
+ file: {
4457
+ type: 'string',
4458
+ format: 'binary',
4459
+ description: 'Bill file to import (CSV, PDF, OFX, etc.)',
4460
+ example: 'alipay.csv'
4461
+ }
4462
+ },
4463
+ required: ['file']
4464
+ } as const;
4465
+
4466
+ export const $ImportErrorDto = {
4467
+ type: 'object',
4468
+ properties: {
4469
+ index: {
4470
+ type: 'number',
4471
+ description: 'Index of failed transaction in the file',
4472
+ example: 5
4473
+ },
4474
+ error: {
4475
+ type: 'string',
4476
+ description: 'Error message',
4477
+ example: 'Transaction does not balance: -100 USD != 0'
4478
+ }
4479
+ },
4480
+ required: ['index', 'error']
4481
+ } as const;
4482
+
4483
+ export const $ReviewItemPreviewDto = {
4484
+ type: 'object',
4485
+ properties: {
4486
+ index: {
4487
+ type: 'number',
4488
+ description: 'Index in the import batch (for tracking)',
4489
+ example: 0
4490
+ },
4491
+ date: {
4492
+ type: 'string',
4493
+ description: 'Transaction date (ISO format)',
4494
+ example: '2026-03-05'
4495
+ },
4496
+ amount: {
4497
+ type: 'number',
4498
+ description: 'Transaction amount (absolute value)',
4499
+ example: 99
4500
+ },
4501
+ currency: {
4502
+ type: 'string',
4503
+ description: 'Currency code',
4504
+ example: 'CNY'
4505
+ },
4506
+ narration: {
4507
+ type: 'string',
4508
+ description: 'Transaction narration/description',
4509
+ example: 'Restaurant expense'
4510
+ },
4511
+ payee: {
4512
+ type: 'string',
4513
+ description: 'Payee name',
4514
+ example: 'Restaurant ABC'
4515
+ },
4516
+ category: {
4517
+ type: 'string',
4518
+ description: 'Inferred category from rule matching',
4519
+ example: 'food'
4520
+ },
4521
+ confidence: {
4522
+ type: 'number',
4121
4523
  description: 'Confidence score for the match (0-1)',
4122
4524
  example: 0.85
4123
4525
  },
@@ -4720,6 +5122,11 @@ export const $ParserTelemetryReportDto = {
4720
5122
  properties: {}
4721
5123
  } as const;
4722
5124
 
5125
+ export const $UncoveredFormatMissDto = {
5126
+ type: 'object',
5127
+ properties: {}
5128
+ } as const;
5129
+
4723
5130
  export const $ProcessNlpDto = {
4724
5131
  type: 'object',
4725
5132
  properties: {
@@ -5847,6 +6254,12 @@ export const $AccountItemWithAssetClassDto = {
5847
6254
  type: 'string',
5848
6255
  description: 'Risk level',
5849
6256
  example: 'LOW'
6257
+ },
6258
+ source: {
6259
+ type: 'string',
6260
+ description:
6261
+ 'ADR-0105 classification provenance (holding level always; account level only on FALLBACK)',
6262
+ enum: ['USER_META', 'FIAT_CURRENCY', 'OPENBB_MAPPING', 'FALLBACK']
5850
6263
  }
5851
6264
  },
5852
6265
  required: ['id', 'name', 'displayName', 'balance', 'currency', 'assetClass']
@@ -5952,6 +6365,11 @@ export const $AssetClassSummaryDto = {
5952
6365
  items: {
5953
6366
  $ref: '#/components/schemas/AccountExchangeRateWarningDto'
5954
6367
  }
6368
+ },
6369
+ fallback: {
6370
+ type: 'object',
6371
+ description:
6372
+ '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.'
5955
6373
  }
5956
6374
  },
5957
6375
  required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
@@ -5974,11 +6392,107 @@ export const $AssetClassAccountsResponseDto = {
5974
6392
  $ref: '#/components/schemas/AssetClassSummaryDto'
5975
6393
  }
5976
6394
  ]
6395
+ },
6396
+ uncategorized: {
6397
+ description:
6398
+ 'ADR-0105 §6 holding-level grey-area bucket (source=FALLBACK holdings peeled out of groups). Present only for groupBy=holdingAssetClass when FALLBACK holdings exist.',
6399
+ allOf: [
6400
+ {
6401
+ $ref: '#/components/schemas/AssetClassGroupDto'
6402
+ }
6403
+ ]
5977
6404
  }
5978
6405
  },
5979
6406
  required: ['groups', 'summary']
5980
6407
  } as const;
5981
6408
 
6409
+ export const $HoldingAssetClassAccountSliceDto = {
6410
+ type: 'object',
6411
+ properties: {
6412
+ accountId: {
6413
+ type: 'string',
6414
+ description: 'Account ID'
6415
+ },
6416
+ accountPath: {
6417
+ type: 'string',
6418
+ description: 'Full account path',
6419
+ example: 'Assets:US:Investments:Brokerage'
6420
+ },
6421
+ accountCurrency: {
6422
+ type: 'string',
6423
+ description:
6424
+ 'Currency of the holding with the largest converted base value; undefined when no holding is convertible',
6425
+ example: 'USD'
6426
+ },
6427
+ marketValueBase: {
6428
+ type: 'string',
6429
+ description:
6430
+ "Account's market value in base currency (Σ converted holdings; grey bucket included)",
6431
+ example: '50000.00'
6432
+ },
6433
+ shareOfTotalPct: {
6434
+ type: 'number',
6435
+ description:
6436
+ 'Share of the global total (0-100). 0 when globalTotal is zero (no NaN/Infinity).',
6437
+ example: 42.5
6438
+ },
6439
+ groups: {
6440
+ description: 'Per-account asset-class breakdown',
6441
+ type: 'array',
6442
+ items: {
6443
+ $ref: '#/components/schemas/AssetClassGroupDto'
6444
+ }
6445
+ },
6446
+ uncategorized: {
6447
+ description:
6448
+ 'Per-account grey bucket (source=FALLBACK holdings, incl. broker cash)',
6449
+ allOf: [
6450
+ {
6451
+ $ref: '#/components/schemas/AssetClassGroupDto'
6452
+ }
6453
+ ]
6454
+ },
6455
+ holdings: {
6456
+ description:
6457
+ 'Every holding row for this account (account ID in each row’s `id` field)',
6458
+ type: 'array',
6459
+ items: {
6460
+ $ref: '#/components/schemas/AccountItemWithAssetClassDto'
6461
+ }
6462
+ }
6463
+ },
6464
+ required: [
6465
+ 'accountId',
6466
+ 'accountPath',
6467
+ 'marketValueBase',
6468
+ 'shareOfTotalPct',
6469
+ 'groups',
6470
+ 'holdings'
6471
+ ]
6472
+ } as const;
6473
+
6474
+ export const $HoldingAssetClassCrossAccountResponseDto = {
6475
+ type: 'object',
6476
+ properties: {
6477
+ global: {
6478
+ description: 'Merged cross-account holding aggregation',
6479
+ allOf: [
6480
+ {
6481
+ $ref: '#/components/schemas/AssetClassAccountsResponseDto'
6482
+ }
6483
+ ]
6484
+ },
6485
+ byAccount: {
6486
+ description: 'Per-account slices',
6487
+ type: 'array',
6488
+ items: {
6489
+ $ref: '#/components/schemas/HoldingAssetClassAccountSliceDto'
6490
+ }
6491
+ }
6492
+ },
6493
+ required: ['global', 'byAccount']
6494
+ } as const;
6495
+
5982
6496
  export const $CashFlowByCurrencyDto = {
5983
6497
  type: 'object',
5984
6498
  properties: {
@@ -6108,71 +6622,517 @@ export const $CashFlowResponseDto = {
6108
6622
  ]
6109
6623
  } as const;
6110
6624
 
6111
- export const $CurrencyBalanceDto = {
6625
+ export const $MonetaryDto = {
6112
6626
  type: 'object',
6113
6627
  properties: {
6114
- currency: {
6628
+ amount: {
6115
6629
  type: 'string',
6116
- description: 'ISO 4217 currency code',
6117
- example: 'CNY'
6630
+ description: 'Amount (Decimal string)',
6631
+ example: '3000'
6118
6632
  },
6119
- balance: {
6633
+ currency: {
6120
6634
  type: 'string',
6121
- description: 'Balance amount',
6122
- example: '500000.00'
6635
+ description: 'ISO 4217 currency',
6636
+ example: 'USD'
6637
+ },
6638
+ baseCcyEquivalent: {
6639
+ type: 'object',
6640
+ description: 'Converted to user base currency (Decimal string)',
6641
+ example: '21600',
6642
+ nullable: true
6123
6643
  }
6124
6644
  },
6125
- required: ['currency', 'balance']
6645
+ required: ['amount', 'currency']
6126
6646
  } as const;
6127
6647
 
6128
- export const $TimeSeriesPointDto = {
6648
+ export const $CurrentPriceDto = {
6129
6649
  type: 'object',
6130
6650
  properties: {
6131
- date: {
6651
+ amount: {
6132
6652
  type: 'string',
6133
- description: 'Date in YYYY-MM-DD format',
6134
- example: '2024-06-15'
6653
+ description: 'Price amount (Decimal string)',
6654
+ example: '250'
6135
6655
  },
6136
- value: {
6656
+ currency: {
6137
6657
  type: 'string',
6138
- description: 'Value at this date (in base currency)',
6139
- example: '500000.00'
6658
+ description: 'Price currency (ISO 4217)',
6659
+ example: 'USD'
6140
6660
  },
6141
- change: {
6142
- type: 'object',
6143
- description: 'Change from previous point',
6144
- example: '5000.00'
6661
+ date: {
6662
+ type: 'string',
6663
+ description: 'Price date (ISO 8601)',
6664
+ example: '2024-06-01'
6145
6665
  },
6146
- byCurrency: {
6147
- description: 'Multi-currency breakdown for this point',
6148
- type: 'array',
6149
- items: {
6150
- $ref: '#/components/schemas/CurrencyBalanceDto'
6151
- }
6666
+ source: {
6667
+ type: 'string',
6668
+ description: 'Price source',
6669
+ example: 'USER_OVERRIDE',
6670
+ enum: ['USER_OVERRIDE', 'OPENBB_EQUITY', 'OPENBB_CURRENCY']
6152
6671
  }
6153
6672
  },
6154
- required: ['date', 'value']
6673
+ required: ['amount', 'currency', 'date', 'source']
6155
6674
  } as const;
6156
6675
 
6157
- export const $TrendSummaryDto = {
6676
+ export const $FxRateDto = {
6158
6677
  type: 'object',
6159
6678
  properties: {
6160
- startValue: {
6679
+ from: {
6161
6680
  type: 'string',
6162
- description: 'Value at start of period',
6163
- example: '450000.00'
6681
+ example: 'USD'
6164
6682
  },
6165
- endValue: {
6683
+ to: {
6166
6684
  type: 'string',
6167
- description: 'Value at end of period',
6168
- example: '500000.00'
6685
+ example: 'CNY'
6169
6686
  },
6170
- totalChange: {
6687
+ rate: {
6171
6688
  type: 'string',
6172
- description: 'Total change over period',
6173
- example: '50000.00'
6689
+ description: 'FX rate (Decimal string)',
6690
+ example: '7.2'
6174
6691
  },
6175
- totalChangePercentage: {
6692
+ date: {
6693
+ type: 'string',
6694
+ description: 'Rate date (ISO 8601)',
6695
+ example: '2024-01-15'
6696
+ }
6697
+ },
6698
+ required: ['from', 'to', 'rate', 'date']
6699
+ } as const;
6700
+
6701
+ export const $HoldingPnlRowDto = {
6702
+ type: 'object',
6703
+ properties: {
6704
+ accountId: {
6705
+ type: 'string',
6706
+ description: 'Account UUID',
6707
+ example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
6708
+ },
6709
+ accountPath: {
6710
+ type: 'string',
6711
+ description: 'Full account path',
6712
+ example: 'Assets:US:Broker:AAPL'
6713
+ },
6714
+ accountCcy: {
6715
+ type: 'object',
6716
+ description: 'Account settlement currency (ISO 4217), from cost currency',
6717
+ nullable: true,
6718
+ example: 'USD'
6719
+ },
6720
+ brokerType: {
6721
+ type: 'object',
6722
+ description: 'Broker type derived from Platform.type',
6723
+ nullable: true,
6724
+ example: 'broker'
6725
+ },
6726
+ symbol: {
6727
+ type: 'string',
6728
+ description: 'Commodity symbol',
6729
+ example: 'AAPL'
6730
+ },
6731
+ chartToken: {
6732
+ type: 'string',
6733
+ description: 'Chart segment token (libs/common resolver)',
6734
+ example: 'equity',
6735
+ enum: ['equity', 'fund', 'bond', 'cash', 'other']
6736
+ },
6737
+ assetClass: {
6738
+ type: 'string',
6739
+ example: 'EQUITY'
6740
+ },
6741
+ assetSubClass: {
6742
+ type: 'object',
6743
+ nullable: true,
6744
+ example: 'STOCK'
6745
+ },
6746
+ units: {
6747
+ type: 'string',
6748
+ description: 'Net held units (Decimal string)',
6749
+ example: '12'
6750
+ },
6751
+ averageCostPerUnit: {
6752
+ description:
6753
+ 'Average cost per unit; null when cost currency conflicts or no cost',
6754
+ nullable: true,
6755
+ allOf: [
6756
+ {
6757
+ $ref: '#/components/schemas/MonetaryDto'
6758
+ }
6759
+ ]
6760
+ },
6761
+ costBasis: {
6762
+ description: 'Cost basis of held units',
6763
+ nullable: true,
6764
+ allOf: [
6765
+ {
6766
+ $ref: '#/components/schemas/MonetaryDto'
6767
+ }
6768
+ ]
6769
+ },
6770
+ marketValue: {
6771
+ description: 'Market value at asOf price',
6772
+ nullable: true,
6773
+ allOf: [
6774
+ {
6775
+ $ref: '#/components/schemas/MonetaryDto'
6776
+ }
6777
+ ]
6778
+ },
6779
+ currentPrice: {
6780
+ description: 'Price used for market value',
6781
+ nullable: true,
6782
+ allOf: [
6783
+ {
6784
+ $ref: '#/components/schemas/CurrentPriceDto'
6785
+ }
6786
+ ]
6787
+ },
6788
+ unrealizedPnlBase: {
6789
+ type: 'object',
6790
+ description:
6791
+ 'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
6792
+ nullable: true,
6793
+ example: '6000'
6794
+ },
6795
+ unrealizedPnlPct: {
6796
+ type: 'object',
6797
+ description: 'Unrealized P&L % (Decimal string)',
6798
+ nullable: true,
6799
+ example: '25'
6800
+ },
6801
+ costFxRate: {
6802
+ description: 'Historical FX rate applied to cost basis',
6803
+ nullable: true,
6804
+ allOf: [
6805
+ {
6806
+ $ref: '#/components/schemas/FxRateDto'
6807
+ }
6808
+ ]
6809
+ },
6810
+ marketFxRate: {
6811
+ description: 'FX rate applied to market value',
6812
+ nullable: true,
6813
+ allOf: [
6814
+ {
6815
+ $ref: '#/components/schemas/FxRateDto'
6816
+ }
6817
+ ]
6818
+ },
6819
+ pctOfInvestedAssets: {
6820
+ type: 'object',
6821
+ description:
6822
+ 'Share of invested assets % (Decimal string); only for invested chartTokens',
6823
+ nullable: true,
6824
+ example: '40'
6825
+ },
6826
+ realizedPnl: {
6827
+ description:
6828
+ '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',
6829
+ nullable: true,
6830
+ allOf: [
6831
+ {
6832
+ $ref: '#/components/schemas/MonetaryDto'
6833
+ }
6834
+ ]
6835
+ }
6836
+ },
6837
+ required: [
6838
+ 'accountId',
6839
+ 'accountPath',
6840
+ 'symbol',
6841
+ 'chartToken',
6842
+ 'assetClass',
6843
+ 'units'
6844
+ ]
6845
+ } as const;
6846
+
6847
+ export const $HoldingPnlWarningDto = {
6848
+ type: 'object',
6849
+ properties: {
6850
+ type: {
6851
+ type: 'string',
6852
+ description: 'Warning type',
6853
+ example: 'MISSING_COST_FX_RATE',
6854
+ enum: [
6855
+ 'MISSING_COST_FX_RATE',
6856
+ 'MISSING_MARKET_FX_RATE',
6857
+ 'MISSING_SALE_PRICE',
6858
+ 'MISSING_REALIZED_FX_RATE',
6859
+ 'OVERSOLD_LOTS',
6860
+ 'NO_PRICE',
6861
+ 'MIXED_COST_CURRENCY'
6862
+ ]
6863
+ },
6864
+ symbol: {
6865
+ type: 'object',
6866
+ nullable: true
6867
+ },
6868
+ accountId: {
6869
+ type: 'object',
6870
+ nullable: true
6871
+ },
6872
+ currency: {
6873
+ type: 'object',
6874
+ nullable: true
6875
+ }
6876
+ },
6877
+ required: ['type']
6878
+ } as const;
6879
+
6880
+ export const $HoldingPnlResponseDto = {
6881
+ type: 'object',
6882
+ properties: {
6883
+ asOfDate: {
6884
+ type: 'string',
6885
+ example: '2026-07-08'
6886
+ },
6887
+ baseCurrency: {
6888
+ type: 'string',
6889
+ example: 'CNY'
6890
+ },
6891
+ method: {
6892
+ type: 'string',
6893
+ description:
6894
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
6895
+ enum: ['average', 'FIFO'],
6896
+ example: 'average'
6897
+ },
6898
+ rows: {
6899
+ type: 'array',
6900
+ items: {
6901
+ $ref: '#/components/schemas/HoldingPnlRowDto'
6902
+ }
6903
+ },
6904
+ warnings: {
6905
+ type: 'array',
6906
+ items: {
6907
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
6908
+ }
6909
+ }
6910
+ },
6911
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6912
+ } as const;
6913
+
6914
+ export const $CreateBeanPriceDto = {
6915
+ type: 'object',
6916
+ properties: {
6917
+ currency: {
6918
+ type: 'string',
6919
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6920
+ example: 'USD'
6921
+ },
6922
+ quoteCurrency: {
6923
+ type: 'string',
6924
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
6925
+ example: 'CNY'
6926
+ },
6927
+ amount: {
6928
+ type: 'number',
6929
+ description:
6930
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
6931
+ example: 175.5,
6932
+ minimum: 0
6933
+ },
6934
+ date: {
6935
+ type: 'string',
6936
+ description: 'Price date (ISO 8601 format)',
6937
+ example: '2024-11-05'
6938
+ },
6939
+ metadata: {
6940
+ type: 'object',
6941
+ description:
6942
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
6943
+ example: {
6944
+ source: 'MANUAL',
6945
+ note: 'Bank valuation report',
6946
+ confidence: 0.95
6947
+ }
6948
+ }
6949
+ },
6950
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
6951
+ } as const;
6952
+
6953
+ export const $PriceResponseDto = {
6954
+ type: 'object',
6955
+ properties: {
6956
+ id: {
6957
+ type: 'string',
6958
+ description: 'Unique identifier',
6959
+ example: 'uuid-123-456'
6960
+ },
6961
+ userId: {
6962
+ type: 'string',
6963
+ description: 'User ID (owner of the price)',
6964
+ example: 'user-123'
6965
+ },
6966
+ currency: {
6967
+ type: 'string',
6968
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6969
+ example: 'BTC'
6970
+ },
6971
+ quoteCurrency: {
6972
+ type: 'string',
6973
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
6974
+ example: 'USD'
6975
+ },
6976
+ amount: {
6977
+ type: 'number',
6978
+ description:
6979
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
6980
+ example: 50000
6981
+ },
6982
+ date: {
6983
+ type: 'string',
6984
+ description:
6985
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
6986
+ example: '2024-01-01',
6987
+ format: 'date'
6988
+ },
6989
+ meta: {
6990
+ type: 'object',
6991
+ description:
6992
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
6993
+ example: {
6994
+ source: 'MANUAL',
6995
+ note: 'User-defined price',
6996
+ confidence: 1
6997
+ }
6998
+ },
6999
+ createdAt: {
7000
+ format: 'date-time',
7001
+ type: 'string',
7002
+ description: 'Creation timestamp',
7003
+ example: '2024-11-03T10:00:00Z'
7004
+ },
7005
+ updatedAt: {
7006
+ format: 'date-time',
7007
+ type: 'string',
7008
+ description: 'Last update timestamp',
7009
+ example: '2024-11-03T10:00:00Z'
7010
+ }
7011
+ },
7012
+ required: [
7013
+ 'id',
7014
+ 'userId',
7015
+ 'currency',
7016
+ 'quoteCurrency',
7017
+ 'amount',
7018
+ 'date',
7019
+ 'meta',
7020
+ 'createdAt',
7021
+ 'updatedAt'
7022
+ ]
7023
+ } as const;
7024
+
7025
+ export const $PriceListResponseDto = {
7026
+ type: 'object',
7027
+ properties: {
7028
+ items: {
7029
+ description: 'List of prices',
7030
+ type: 'array',
7031
+ items: {
7032
+ $ref: '#/components/schemas/PriceResponseDto'
7033
+ }
7034
+ },
7035
+ total: {
7036
+ type: 'number',
7037
+ description: 'Total number of prices',
7038
+ example: 42
7039
+ }
7040
+ },
7041
+ required: ['items', 'total']
7042
+ } as const;
7043
+
7044
+ export const $UpdateBeanPriceDto = {
7045
+ type: 'object',
7046
+ properties: {
7047
+ currency: {
7048
+ type: 'string',
7049
+ description: 'Currency being priced'
7050
+ },
7051
+ quoteCurrency: {
7052
+ type: 'string',
7053
+ description: 'Quote currency (pricing currency)'
7054
+ },
7055
+ amount: {
7056
+ type: 'number',
7057
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
7058
+ minimum: 0
7059
+ },
7060
+ date: {
7061
+ type: 'string',
7062
+ description: 'Price date (ISO 8601 format)'
7063
+ },
7064
+ metadata: {
7065
+ type: 'object',
7066
+ description: 'Metadata'
7067
+ }
7068
+ }
7069
+ } as const;
7070
+
7071
+ export const $CurrencyBalanceDto = {
7072
+ type: 'object',
7073
+ properties: {
7074
+ currency: {
7075
+ type: 'string',
7076
+ description: 'ISO 4217 currency code',
7077
+ example: 'CNY'
7078
+ },
7079
+ balance: {
7080
+ type: 'string',
7081
+ description: 'Balance amount',
7082
+ example: '500000.00'
7083
+ }
7084
+ },
7085
+ required: ['currency', 'balance']
7086
+ } as const;
7087
+
7088
+ export const $TimeSeriesPointDto = {
7089
+ type: 'object',
7090
+ properties: {
7091
+ date: {
7092
+ type: 'string',
7093
+ description: 'Date in YYYY-MM-DD format',
7094
+ example: '2024-06-15'
7095
+ },
7096
+ value: {
7097
+ type: 'string',
7098
+ description: 'Value at this date (in base currency)',
7099
+ example: '500000.00'
7100
+ },
7101
+ change: {
7102
+ type: 'object',
7103
+ description: 'Change from previous point',
7104
+ example: '5000.00'
7105
+ },
7106
+ byCurrency: {
7107
+ description: 'Multi-currency breakdown for this point',
7108
+ type: 'array',
7109
+ items: {
7110
+ $ref: '#/components/schemas/CurrencyBalanceDto'
7111
+ }
7112
+ }
7113
+ },
7114
+ required: ['date', 'value']
7115
+ } as const;
7116
+
7117
+ export const $TrendSummaryDto = {
7118
+ type: 'object',
7119
+ properties: {
7120
+ startValue: {
7121
+ type: 'string',
7122
+ description: 'Value at start of period',
7123
+ example: '450000.00'
7124
+ },
7125
+ endValue: {
7126
+ type: 'string',
7127
+ description: 'Value at end of period',
7128
+ example: '500000.00'
7129
+ },
7130
+ totalChange: {
7131
+ type: 'string',
7132
+ description: 'Total change over period',
7133
+ example: '50000.00'
7134
+ },
7135
+ totalChangePercentage: {
6176
7136
  type: 'string',
6177
7137
  description: 'Total change percentage',
6178
7138
  example: '+11.11%'
@@ -6252,6 +7212,111 @@ export const $PortfolioTrendsResponseDto = {
6252
7212
  required: ['series', 'summary', 'period', 'granularity', 'currency']
6253
7213
  } as const;
6254
7214
 
7215
+ export const $CashFlowPointDto = {
7216
+ type: 'object',
7217
+ properties: {
7218
+ month: {
7219
+ type: 'string',
7220
+ description: 'Month key (YYYY-MM)',
7221
+ example: '2024-03'
7222
+ },
7223
+ income: {
7224
+ type: 'string',
7225
+ description: 'Income in base currency (absolute, converted)',
7226
+ example: '10000.00'
7227
+ },
7228
+ expense: {
7229
+ type: 'string',
7230
+ description: 'Expense in base currency (absolute, converted)',
7231
+ example: '5000.00'
7232
+ },
7233
+ netSavings: {
7234
+ type: 'string',
7235
+ description: 'netSavings = income − expense (savings positive)',
7236
+ example: '5000.00'
7237
+ }
7238
+ },
7239
+ required: ['month', 'income', 'expense', 'netSavings']
7240
+ } as const;
7241
+
7242
+ export const $CashFlowTrendSummaryDto = {
7243
+ type: 'object',
7244
+ properties: {
7245
+ totalIncome: {
7246
+ type: 'string',
7247
+ description: 'Total income across the period',
7248
+ example: '60000.00'
7249
+ },
7250
+ totalExpense: {
7251
+ type: 'string',
7252
+ description: 'Total expense across the period',
7253
+ example: '30000.00'
7254
+ },
7255
+ totalNetSavings: {
7256
+ type: 'string',
7257
+ description: 'income − expense across the period',
7258
+ example: '30000.00'
7259
+ },
7260
+ averageMonthlyNetSavings: {
7261
+ type: 'string',
7262
+ description:
7263
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
7264
+ example: '5000.00'
7265
+ }
7266
+ },
7267
+ required: [
7268
+ 'totalIncome',
7269
+ 'totalExpense',
7270
+ 'totalNetSavings',
7271
+ 'averageMonthlyNetSavings'
7272
+ ]
7273
+ } as const;
7274
+
7275
+ export const $CashFlowTrendsResponseDto = {
7276
+ type: 'object',
7277
+ properties: {
7278
+ series: {
7279
+ description:
7280
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
7281
+ type: 'array',
7282
+ items: {
7283
+ $ref: '#/components/schemas/CashFlowPointDto'
7284
+ }
7285
+ },
7286
+ summary: {
7287
+ description: 'Period totals',
7288
+ allOf: [
7289
+ {
7290
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
7291
+ }
7292
+ ]
7293
+ },
7294
+ period: {
7295
+ type: 'string',
7296
+ description: 'Period requested',
7297
+ example: '6m'
7298
+ },
7299
+ granularity: {
7300
+ type: 'string',
7301
+ description: 'Data granularity (v1 returns month buckets)',
7302
+ example: 'month'
7303
+ },
7304
+ currency: {
7305
+ type: 'string',
7306
+ description: 'Base currency for converted values',
7307
+ example: 'CNY'
7308
+ },
7309
+ warnings: {
7310
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
7311
+ type: 'array',
7312
+ items: {
7313
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7314
+ }
7315
+ }
7316
+ },
7317
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
7318
+ } as const;
7319
+
6255
7320
  export const $GenerateSnapshotBody = {
6256
7321
  type: 'object',
6257
7322
  properties: {}