@firela/api-types 0.0.0-canary.074c27d4 → 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']
@@ -964,6 +1086,15 @@ export const $PostingDetailDto = {
964
1086
  description: 'Cost date',
965
1087
  example: '2024-01-15'
966
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
+ },
967
1098
  priceAmount: {
968
1099
  type: 'string',
969
1100
  description: 'Price amount',
@@ -1724,7 +1855,8 @@ export const $ResolveResultDto = {
1724
1855
  },
1725
1856
  resolutionId: {
1726
1857
  type: 'string',
1727
- description: 'Resolution ID for undo'
1858
+ description:
1859
+ 'Resolution ID for undo. Absent when the resolver rejected the decision (review stayed PENDING).'
1728
1860
  },
1729
1861
  canUndo: {
1730
1862
  type: 'boolean',
@@ -1742,7 +1874,7 @@ export const $ResolveResultDto = {
1742
1874
  example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1743
1875
  }
1744
1876
  },
1745
- required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
1877
+ required: ['success']
1746
1878
  } as const;
1747
1879
 
1748
1880
  export const $UndoResultDto = {
@@ -4180,6 +4312,144 @@ export const $UpdatePropertyDto = {
4180
4312
  required: ['value']
4181
4313
  } as const;
4182
4314
 
4315
+ export const $CreateBeanEventDto = {
4316
+ type: 'object',
4317
+ properties: {
4318
+ date: {
4319
+ type: 'string',
4320
+ description: 'Life event date (ISO 8601)',
4321
+ example: '2024-03-15'
4322
+ },
4323
+ type: {
4324
+ type: 'string',
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
+ }
4342
+ }
4343
+ },
4344
+ required: ['date', 'type', 'description']
4345
+ } as const;
4346
+
4347
+ export const $EventResponseDto = {
4348
+ type: 'object',
4349
+ properties: {
4350
+ id: {
4351
+ type: 'string',
4352
+ description: 'Unique identifier',
4353
+ example: 'uuid-123-456'
4354
+ },
4355
+ userId: {
4356
+ type: 'string',
4357
+ description: 'User ID (owner of the life event)',
4358
+ example: 'user-123'
4359
+ },
4360
+ date: {
4361
+ type: 'string',
4362
+ description: 'Life event date (ISO 8601 format)',
4363
+ example: '2024-03-15',
4364
+ format: 'date'
4365
+ },
4366
+ type: {
4367
+ type: 'string',
4368
+ description:
4369
+ 'Life event type (user-defined, e.g., "employer", "location")',
4370
+ example: 'employer'
4371
+ },
4372
+ description: {
4373
+ type: 'string',
4374
+ description:
4375
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4376
+ example: 'Acme Corp'
4377
+ },
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
+
4183
4453
  export const $FileImportDto = {
4184
4454
  type: 'object',
4185
4455
  properties: {
@@ -4852,6 +5122,11 @@ export const $ParserTelemetryReportDto = {
4852
5122
  properties: {}
4853
5123
  } as const;
4854
5124
 
5125
+ export const $UncoveredFormatMissDto = {
5126
+ type: 'object',
5127
+ properties: {}
5128
+ } as const;
5129
+
4855
5130
  export const $ProcessNlpDto = {
4856
5131
  type: 'object',
4857
5132
  properties: {
@@ -5979,6 +6254,12 @@ export const $AccountItemWithAssetClassDto = {
5979
6254
  type: 'string',
5980
6255
  description: 'Risk level',
5981
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']
5982
6263
  }
5983
6264
  },
5984
6265
  required: ['id', 'name', 'displayName', 'balance', 'currency', 'assetClass']
@@ -6084,6 +6365,11 @@ export const $AssetClassSummaryDto = {
6084
6365
  items: {
6085
6366
  $ref: '#/components/schemas/AccountExchangeRateWarningDto'
6086
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.'
6087
6373
  }
6088
6374
  },
6089
6375
  required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
@@ -6106,47 +6392,143 @@ export const $AssetClassAccountsResponseDto = {
6106
6392
  $ref: '#/components/schemas/AssetClassSummaryDto'
6107
6393
  }
6108
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
+ ]
6109
6404
  }
6110
6405
  },
6111
6406
  required: ['groups', 'summary']
6112
6407
  } as const;
6113
6408
 
6114
- export const $CashFlowByCurrencyDto = {
6409
+ export const $HoldingAssetClassAccountSliceDto = {
6115
6410
  type: 'object',
6116
6411
  properties: {
6117
- income: {
6118
- description: 'Income by currency',
6119
- type: 'array',
6120
- items: {
6121
- $ref: '#/components/schemas/BalanceByCurrencyDto'
6122
- }
6412
+ accountId: {
6413
+ type: 'string',
6414
+ description: 'Account ID'
6123
6415
  },
6124
- expense: {
6125
- description: 'Expense by currency',
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',
6126
6441
  type: 'array',
6127
6442
  items: {
6128
- $ref: '#/components/schemas/BalanceByCurrencyDto'
6443
+ $ref: '#/components/schemas/AssetClassGroupDto'
6129
6444
  }
6130
6445
  },
6131
- netSavings: {
6132
- description: 'Net savings by currency',
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)',
6133
6458
  type: 'array',
6134
6459
  items: {
6135
- $ref: '#/components/schemas/BalanceByCurrencyDto'
6460
+ $ref: '#/components/schemas/AccountItemWithAssetClassDto'
6136
6461
  }
6137
6462
  }
6138
6463
  },
6139
- required: ['income', 'expense', 'netSavings']
6464
+ required: [
6465
+ 'accountId',
6466
+ 'accountPath',
6467
+ 'marketValueBase',
6468
+ 'shareOfTotalPct',
6469
+ 'groups',
6470
+ 'holdings'
6471
+ ]
6140
6472
  } as const;
6141
6473
 
6142
- export const $ConvertedCashFlowDto = {
6474
+ export const $HoldingAssetClassCrossAccountResponseDto = {
6143
6475
  type: 'object',
6144
6476
  properties: {
6145
- baseCurrency: {
6146
- type: 'string',
6147
- description: 'Base currency for conversion',
6148
- example: 'CNY'
6149
- },
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
+
6496
+ export const $CashFlowByCurrencyDto = {
6497
+ type: 'object',
6498
+ properties: {
6499
+ income: {
6500
+ description: 'Income by currency',
6501
+ type: 'array',
6502
+ items: {
6503
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
6504
+ }
6505
+ },
6506
+ expense: {
6507
+ description: 'Expense by currency',
6508
+ type: 'array',
6509
+ items: {
6510
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
6511
+ }
6512
+ },
6513
+ netSavings: {
6514
+ description: 'Net savings by currency',
6515
+ type: 'array',
6516
+ items: {
6517
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
6518
+ }
6519
+ }
6520
+ },
6521
+ required: ['income', 'expense', 'netSavings']
6522
+ } as const;
6523
+
6524
+ export const $ConvertedCashFlowDto = {
6525
+ type: 'object',
6526
+ properties: {
6527
+ baseCurrency: {
6528
+ type: 'string',
6529
+ description: 'Base currency for conversion',
6530
+ example: 'CNY'
6531
+ },
6150
6532
  income: {
6151
6533
  type: 'string',
6152
6534
  description: 'Converted income',
@@ -6240,6 +6622,452 @@ export const $CashFlowResponseDto = {
6240
6622
  ]
6241
6623
  } as const;
6242
6624
 
6625
+ export const $MonetaryDto = {
6626
+ type: 'object',
6627
+ properties: {
6628
+ amount: {
6629
+ type: 'string',
6630
+ description: 'Amount (Decimal string)',
6631
+ example: '3000'
6632
+ },
6633
+ currency: {
6634
+ type: 'string',
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
6643
+ }
6644
+ },
6645
+ required: ['amount', 'currency']
6646
+ } as const;
6647
+
6648
+ export const $CurrentPriceDto = {
6649
+ type: 'object',
6650
+ properties: {
6651
+ amount: {
6652
+ type: 'string',
6653
+ description: 'Price amount (Decimal string)',
6654
+ example: '250'
6655
+ },
6656
+ currency: {
6657
+ type: 'string',
6658
+ description: 'Price currency (ISO 4217)',
6659
+ example: 'USD'
6660
+ },
6661
+ date: {
6662
+ type: 'string',
6663
+ description: 'Price date (ISO 8601)',
6664
+ example: '2024-06-01'
6665
+ },
6666
+ source: {
6667
+ type: 'string',
6668
+ description: 'Price source',
6669
+ example: 'USER_OVERRIDE',
6670
+ enum: ['USER_OVERRIDE', 'OPENBB_EQUITY', 'OPENBB_CURRENCY']
6671
+ }
6672
+ },
6673
+ required: ['amount', 'currency', 'date', 'source']
6674
+ } as const;
6675
+
6676
+ export const $FxRateDto = {
6677
+ type: 'object',
6678
+ properties: {
6679
+ from: {
6680
+ type: 'string',
6681
+ example: 'USD'
6682
+ },
6683
+ to: {
6684
+ type: 'string',
6685
+ example: 'CNY'
6686
+ },
6687
+ rate: {
6688
+ type: 'string',
6689
+ description: 'FX rate (Decimal string)',
6690
+ example: '7.2'
6691
+ },
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
+
6243
7071
  export const $CurrencyBalanceDto = {
6244
7072
  type: 'object',
6245
7073
  properties: {
@@ -6384,6 +7212,111 @@ export const $PortfolioTrendsResponseDto = {
6384
7212
  required: ['series', 'summary', 'period', 'granularity', 'currency']
6385
7213
  } as const;
6386
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
+
6387
7320
  export const $GenerateSnapshotBody = {
6388
7321
  type: 'object',
6389
7322
  properties: {}