@firela/api-types 0.0.0-canary.6feee68d → 0.0.0-canary.792fa5f1

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']
@@ -583,7 +670,8 @@ export const $PostingResponseDto = {
583
670
  },
584
671
  units: {
585
672
  type: 'string',
586
- description: 'Amount (may be null if interpolated)',
673
+ description:
674
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
587
675
  example: '100.50'
588
676
  },
589
677
  currency: {
@@ -840,6 +928,85 @@ export const $BatchTransactionResponseDto = {
840
928
  required: ['succeeded', 'failed']
841
929
  } as const;
842
930
 
931
+ export const $CorrectTransactionDto = {
932
+ type: 'object',
933
+ properties: {
934
+ date: {
935
+ type: 'string',
936
+ description: 'Transaction date (ISO 8601 format)',
937
+ example: '2024-11-28'
938
+ },
939
+ flag: {
940
+ type: 'string',
941
+ description: 'Transaction flag: * (cleared), ! (pending)',
942
+ enum: ['*', '!'],
943
+ example: '*'
944
+ },
945
+ payee: {
946
+ type: 'string',
947
+ description: 'Payee name',
948
+ example: 'Whole Foods Market'
949
+ },
950
+ narration: {
951
+ type: 'string',
952
+ description: 'Transaction narration/description',
953
+ example: 'Grocery shopping'
954
+ },
955
+ tags: {
956
+ description: 'Transaction tags (without # prefix)',
957
+ example: ['vacation', 'personal'],
958
+ type: 'array',
959
+ items: {
960
+ type: 'string'
961
+ }
962
+ },
963
+ links: {
964
+ description: 'Transaction links (without ^ prefix)',
965
+ example: ['invoice-123'],
966
+ type: 'array',
967
+ items: {
968
+ type: 'string'
969
+ }
970
+ },
971
+ postings: {
972
+ description:
973
+ 'Transaction postings (minimum 1, typically 2 for double-entry)',
974
+ type: 'array',
975
+ items: {
976
+ $ref: '#/components/schemas/CreatePostingDto'
977
+ }
978
+ },
979
+ meta: {
980
+ type: 'object',
981
+ description: 'Transaction-level metadata',
982
+ example: {
983
+ invoice: '12345'
984
+ }
985
+ },
986
+ idempotencyKey: {
987
+ type: 'string',
988
+ description:
989
+ 'Unique key for idempotent transaction creation. If provided, duplicate requests with the same key will return the existing transaction.',
990
+ example: 'import-2024-01-15-batch-001',
991
+ maxLength: 128
992
+ },
993
+ autoCreateAccounts: {
994
+ type: 'boolean',
995
+ description:
996
+ 'Auto-create accounts if not found. When true, missing accounts will be automatically created. When false (default for API), missing accounts will cause a validation error. Set to true for quick entry scenarios where you want to create accounts on-the-fly.',
997
+ default: true,
998
+ example: true
999
+ },
1000
+ correctionReason: {
1001
+ type: 'string',
1002
+ description: 'Reason for correcting/superseding the original transaction',
1003
+ example: 'Wrong amount — corrected from receipt',
1004
+ maxLength: 500
1005
+ }
1006
+ },
1007
+ required: ['date', 'narration', 'postings']
1008
+ } as const;
1009
+
843
1010
  export const $PostingDetailDto = {
844
1011
  type: 'object',
845
1012
  properties: {
@@ -853,14 +1020,15 @@ export const $PostingDetailDto = {
853
1020
  description: 'Account ID',
854
1021
  example: 'clh1234567890abcdef'
855
1022
  },
856
- accountName: {
1023
+ account: {
857
1024
  type: 'string',
858
- description: 'Account name',
1025
+ description: 'Fully-qualified Beancount account path',
859
1026
  example: 'Assets:Bank:Checking'
860
1027
  },
861
1028
  units: {
862
1029
  type: 'string',
863
- description: 'Amount (may be null if interpolated)',
1030
+ description:
1031
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
864
1032
  example: '100.50'
865
1033
  },
866
1034
  currency: {
@@ -903,7 +1071,7 @@ export const $PostingDetailDto = {
903
1071
  description: 'Posting metadata'
904
1072
  }
905
1073
  },
906
- required: ['id', 'accountId', 'accountName']
1074
+ required: ['id', 'accountId', 'account']
907
1075
  } as const;
908
1076
 
909
1077
  export const $TransactionDetailDto = {
@@ -975,8 +1143,8 @@ export const $TransactionDetailDto = {
975
1143
  },
976
1144
  sourceType: {
977
1145
  type: 'string',
978
- description: 'Source type (how the transaction was created)',
979
- enum: ['NLP', 'CSV', 'OCR', 'API']
1146
+ description:
1147
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
980
1148
  },
981
1149
  sourcePlatform: {
982
1150
  type: 'string',
@@ -1009,6 +1177,18 @@ export const $TransactionDetailDto = {
1009
1177
  type: 'string',
1010
1178
  description: 'Correction reason (if voided or superseded)',
1011
1179
  example: 'Duplicate entry'
1180
+ },
1181
+ supersededBy: {
1182
+ type: 'string',
1183
+ description:
1184
+ 'ID of the transaction that supersedes this one (set when status=SUPERSEDED)',
1185
+ example: 'clh1234567890abcdef'
1186
+ },
1187
+ originalTxn: {
1188
+ type: 'string',
1189
+ description:
1190
+ 'ID of the transaction this one corrected/replaced (back-link on the replacement)',
1191
+ example: 'clh1234567890abcdef'
1012
1192
  }
1013
1193
  },
1014
1194
  required: [
@@ -1052,6 +1232,37 @@ export const $TransactionListResponseDto = {
1052
1232
  required: ['data', 'total', 'limit', 'offset']
1053
1233
  } as const;
1054
1234
 
1235
+ export const $TagSuggestionDto = {
1236
+ type: 'object',
1237
+ properties: {
1238
+ tag: {
1239
+ type: 'string',
1240
+ description: 'Tag name',
1241
+ example: 'Monthly'
1242
+ },
1243
+ count: {
1244
+ type: 'number',
1245
+ description: 'Usage count across ACTIVE transactions',
1246
+ example: 12
1247
+ }
1248
+ },
1249
+ required: ['tag', 'count']
1250
+ } as const;
1251
+
1252
+ export const $TagSuggestionsResponseDto = {
1253
+ type: 'object',
1254
+ properties: {
1255
+ data: {
1256
+ description: 'Tag suggestions sorted as requested',
1257
+ type: 'array',
1258
+ items: {
1259
+ $ref: '#/components/schemas/TagSuggestionDto'
1260
+ }
1261
+ }
1262
+ },
1263
+ required: ['data']
1264
+ } as const;
1265
+
1055
1266
  export const $UpdateTransactionDto = {
1056
1267
  type: 'object',
1057
1268
  properties: {
@@ -1202,8 +1413,8 @@ export const $TransactionSummaryDto = {
1202
1413
  },
1203
1414
  sourceType: {
1204
1415
  type: 'string',
1205
- description: 'Source type (NLP, CSV, OCR, API)',
1206
- enum: ['NLP', 'CSV', 'OCR', 'API']
1416
+ description:
1417
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1207
1418
  },
1208
1419
  sourcePlatform: {
1209
1420
  type: 'string',
@@ -1243,8 +1454,10 @@ export const $ReviewSummaryDto = {
1243
1454
  },
1244
1455
  confidenceLevel: {
1245
1456
  type: 'string',
1246
- description: 'Confidence level derived from score',
1247
- enum: ['HIGH', 'MEDIUM', 'LOW']
1457
+ description:
1458
+ 'Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.',
1459
+ enum: ['HIGH', 'MEDIUM', 'LOW'],
1460
+ nullable: true
1248
1461
  },
1249
1462
  summaryKey: {
1250
1463
  type: 'string',
@@ -1268,7 +1481,8 @@ export const $ReviewSummaryDto = {
1268
1481
  },
1269
1482
  sourceType: {
1270
1483
  type: 'string',
1271
- description: 'Source type (NLP, CSV, OCR, API)'
1484
+ description:
1485
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1272
1486
  },
1273
1487
  sourcePlatform: {
1274
1488
  type: 'string',
@@ -1378,7 +1592,20 @@ export const $DecisionOptionDto = {
1378
1592
  properties: {
1379
1593
  value: {
1380
1594
  type: 'string',
1381
- description: 'The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)'
1595
+ description: 'The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)',
1596
+ enum: [
1597
+ 'UPGRADE_REPLACE',
1598
+ 'LINK_KEEP_BOTH',
1599
+ 'IGNORE_NEW',
1600
+ 'CONFIRM_DIFFERENT',
1601
+ 'ACCEPT',
1602
+ 'REJECT',
1603
+ 'ACCEPT_AND_LEARN',
1604
+ 'CHOOSE_OTHER',
1605
+ 'CANCEL',
1606
+ 'FIX',
1607
+ 'IGNORE'
1608
+ ]
1382
1609
  },
1383
1610
  labelKey: {
1384
1611
  type: 'string',
@@ -1426,8 +1653,10 @@ export const $ReviewDetailDto = {
1426
1653
  },
1427
1654
  confidenceLevel: {
1428
1655
  type: 'string',
1429
- description: 'Confidence level derived from score',
1430
- enum: ['HIGH', 'MEDIUM', 'LOW']
1656
+ description:
1657
+ 'Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.',
1658
+ enum: ['HIGH', 'MEDIUM', 'LOW'],
1659
+ nullable: true
1431
1660
  },
1432
1661
  summaryKey: {
1433
1662
  type: 'string',
@@ -1451,7 +1680,8 @@ export const $ReviewDetailDto = {
1451
1680
  },
1452
1681
  sourceType: {
1453
1682
  type: 'string',
1454
- description: 'Source type (NLP, CSV, OCR, API)'
1683
+ description:
1684
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1455
1685
  },
1456
1686
  sourcePlatform: {
1457
1687
  type: 'string',
@@ -1531,7 +1761,20 @@ export const $ResolveReviewDto = {
1531
1761
  action: {
1532
1762
  type: 'string',
1533
1763
  description:
1534
- 'Decision action. Available actions vary by review type: DUPLICATE: UPGRADE_REPLACE, KEEP_EXISTING, KEEP_BOTH | PAYEE_MATCH: ACCEPT, REJECT, ACCEPT_AND_LEARN | ACCOUNT_VALIDATION: FIX, REJECT | RULE_MATCH: ACCEPT, REJECT, ACCEPT_AND_LEARN',
1764
+ 'Decision action. Valid actions vary by review type see DecisionOptionDto.value returned by the review detail endpoint.',
1765
+ enum: [
1766
+ 'UPGRADE_REPLACE',
1767
+ 'LINK_KEEP_BOTH',
1768
+ 'IGNORE_NEW',
1769
+ 'CONFIRM_DIFFERENT',
1770
+ 'ACCEPT',
1771
+ 'REJECT',
1772
+ 'ACCEPT_AND_LEARN',
1773
+ 'CHOOSE_OTHER',
1774
+ 'CANCEL',
1775
+ 'FIX',
1776
+ 'IGNORE'
1777
+ ],
1535
1778
  example: 'ACCEPT'
1536
1779
  },
1537
1780
  data: {
@@ -1622,6 +1865,19 @@ export const $BatchResolveDto = {
1622
1865
  action: {
1623
1866
  type: 'string',
1624
1867
  description: 'Decision action to apply to all items',
1868
+ enum: [
1869
+ 'UPGRADE_REPLACE',
1870
+ 'LINK_KEEP_BOTH',
1871
+ 'IGNORE_NEW',
1872
+ 'CONFIRM_DIFFERENT',
1873
+ 'ACCEPT',
1874
+ 'REJECT',
1875
+ 'ACCEPT_AND_LEARN',
1876
+ 'CHOOSE_OTHER',
1877
+ 'CANCEL',
1878
+ 'FIX',
1879
+ 'IGNORE'
1880
+ ],
1625
1881
  example: 'ACCEPT'
1626
1882
  },
1627
1883
  data: {
@@ -4683,6 +4939,11 @@ export const $ParserTelemetryReportDto = {
4683
4939
  properties: {}
4684
4940
  } as const;
4685
4941
 
4942
+ export const $UncoveredFormatMissDto = {
4943
+ type: 'object',
4944
+ properties: {}
4945
+ } as const;
4946
+
4686
4947
  export const $ProcessNlpDto = {
4687
4948
  type: 'object',
4688
4949
  properties: {
@@ -5810,6 +6071,12 @@ export const $AccountItemWithAssetClassDto = {
5810
6071
  type: 'string',
5811
6072
  description: 'Risk level',
5812
6073
  example: 'LOW'
6074
+ },
6075
+ source: {
6076
+ type: 'string',
6077
+ description:
6078
+ 'ADR-0105 classification provenance (holding level always; account level only on FALLBACK)',
6079
+ enum: ['USER_META', 'FIAT_CURRENCY', 'OPENBB_MAPPING', 'FALLBACK']
5813
6080
  }
5814
6081
  },
5815
6082
  required: ['id', 'name', 'displayName', 'balance', 'currency', 'assetClass']
@@ -5915,6 +6182,11 @@ export const $AssetClassSummaryDto = {
5915
6182
  items: {
5916
6183
  $ref: '#/components/schemas/AccountExchangeRateWarningDto'
5917
6184
  }
6185
+ },
6186
+ fallback: {
6187
+ type: 'object',
6188
+ description:
6189
+ 'ADR-0105 §4 fallback provenance stats (holding level only). valueRatio is the grey-area share of total converted value; count is the number of source=FALLBACK holdings.'
5918
6190
  }
5919
6191
  },
5920
6192
  required: ['totalAccounts', 'totalAssetClasses', 'baseCurrency']
@@ -5937,11 +6209,107 @@ export const $AssetClassAccountsResponseDto = {
5937
6209
  $ref: '#/components/schemas/AssetClassSummaryDto'
5938
6210
  }
5939
6211
  ]
6212
+ },
6213
+ uncategorized: {
6214
+ description:
6215
+ 'ADR-0105 §6 holding-level grey-area bucket (source=FALLBACK holdings peeled out of groups). Present only for groupBy=holdingAssetClass when FALLBACK holdings exist.',
6216
+ allOf: [
6217
+ {
6218
+ $ref: '#/components/schemas/AssetClassGroupDto'
6219
+ }
6220
+ ]
5940
6221
  }
5941
6222
  },
5942
6223
  required: ['groups', 'summary']
5943
6224
  } as const;
5944
6225
 
6226
+ export const $HoldingAssetClassAccountSliceDto = {
6227
+ type: 'object',
6228
+ properties: {
6229
+ accountId: {
6230
+ type: 'string',
6231
+ description: 'Account ID'
6232
+ },
6233
+ accountPath: {
6234
+ type: 'string',
6235
+ description: 'Full account path',
6236
+ example: 'Assets:US:Investments:Brokerage'
6237
+ },
6238
+ accountCurrency: {
6239
+ type: 'string',
6240
+ description:
6241
+ 'Currency of the holding with the largest converted base value; undefined when no holding is convertible',
6242
+ example: 'USD'
6243
+ },
6244
+ marketValueBase: {
6245
+ type: 'string',
6246
+ description:
6247
+ "Account's market value in base currency (Σ converted holdings; grey bucket included)",
6248
+ example: '50000.00'
6249
+ },
6250
+ shareOfTotalPct: {
6251
+ type: 'number',
6252
+ description:
6253
+ 'Share of the global total (0-100). 0 when globalTotal is zero (no NaN/Infinity).',
6254
+ example: 42.5
6255
+ },
6256
+ groups: {
6257
+ description: 'Per-account asset-class breakdown',
6258
+ type: 'array',
6259
+ items: {
6260
+ $ref: '#/components/schemas/AssetClassGroupDto'
6261
+ }
6262
+ },
6263
+ uncategorized: {
6264
+ description:
6265
+ 'Per-account grey bucket (source=FALLBACK holdings, incl. broker cash)',
6266
+ allOf: [
6267
+ {
6268
+ $ref: '#/components/schemas/AssetClassGroupDto'
6269
+ }
6270
+ ]
6271
+ },
6272
+ holdings: {
6273
+ description:
6274
+ 'Every holding row for this account (account ID in each row’s `id` field)',
6275
+ type: 'array',
6276
+ items: {
6277
+ $ref: '#/components/schemas/AccountItemWithAssetClassDto'
6278
+ }
6279
+ }
6280
+ },
6281
+ required: [
6282
+ 'accountId',
6283
+ 'accountPath',
6284
+ 'marketValueBase',
6285
+ 'shareOfTotalPct',
6286
+ 'groups',
6287
+ 'holdings'
6288
+ ]
6289
+ } as const;
6290
+
6291
+ export const $HoldingAssetClassCrossAccountResponseDto = {
6292
+ type: 'object',
6293
+ properties: {
6294
+ global: {
6295
+ description: 'Merged cross-account holding aggregation',
6296
+ allOf: [
6297
+ {
6298
+ $ref: '#/components/schemas/AssetClassAccountsResponseDto'
6299
+ }
6300
+ ]
6301
+ },
6302
+ byAccount: {
6303
+ description: 'Per-account slices',
6304
+ type: 'array',
6305
+ items: {
6306
+ $ref: '#/components/schemas/HoldingAssetClassAccountSliceDto'
6307
+ }
6308
+ }
6309
+ },
6310
+ required: ['global', 'byAccount']
6311
+ } as const;
6312
+
5945
6313
  export const $CashFlowByCurrencyDto = {
5946
6314
  type: 'object',
5947
6315
  properties: {
@@ -6071,6 +6439,452 @@ export const $CashFlowResponseDto = {
6071
6439
  ]
6072
6440
  } as const;
6073
6441
 
6442
+ export const $MonetaryDto = {
6443
+ type: 'object',
6444
+ properties: {
6445
+ amount: {
6446
+ type: 'string',
6447
+ description: 'Amount (Decimal string)',
6448
+ example: '3000'
6449
+ },
6450
+ currency: {
6451
+ type: 'string',
6452
+ description: 'ISO 4217 currency',
6453
+ example: 'USD'
6454
+ },
6455
+ baseCcyEquivalent: {
6456
+ type: 'object',
6457
+ description: 'Converted to user base currency (Decimal string)',
6458
+ example: '21600',
6459
+ nullable: true
6460
+ }
6461
+ },
6462
+ required: ['amount', 'currency']
6463
+ } as const;
6464
+
6465
+ export const $CurrentPriceDto = {
6466
+ type: 'object',
6467
+ properties: {
6468
+ amount: {
6469
+ type: 'string',
6470
+ description: 'Price amount (Decimal string)',
6471
+ example: '250'
6472
+ },
6473
+ currency: {
6474
+ type: 'string',
6475
+ description: 'Price currency (ISO 4217)',
6476
+ example: 'USD'
6477
+ },
6478
+ date: {
6479
+ type: 'string',
6480
+ description: 'Price date (ISO 8601)',
6481
+ example: '2024-06-01'
6482
+ },
6483
+ source: {
6484
+ type: 'string',
6485
+ description: 'Price source',
6486
+ example: 'USER_OVERRIDE',
6487
+ enum: ['USER_OVERRIDE', 'OPENBB_EQUITY', 'OPENBB_CURRENCY']
6488
+ }
6489
+ },
6490
+ required: ['amount', 'currency', 'date', 'source']
6491
+ } as const;
6492
+
6493
+ export const $FxRateDto = {
6494
+ type: 'object',
6495
+ properties: {
6496
+ from: {
6497
+ type: 'string',
6498
+ example: 'USD'
6499
+ },
6500
+ to: {
6501
+ type: 'string',
6502
+ example: 'CNY'
6503
+ },
6504
+ rate: {
6505
+ type: 'string',
6506
+ description: 'FX rate (Decimal string)',
6507
+ example: '7.2'
6508
+ },
6509
+ date: {
6510
+ type: 'string',
6511
+ description: 'Rate date (ISO 8601)',
6512
+ example: '2024-01-15'
6513
+ }
6514
+ },
6515
+ required: ['from', 'to', 'rate', 'date']
6516
+ } as const;
6517
+
6518
+ export const $HoldingPnlRowDto = {
6519
+ type: 'object',
6520
+ properties: {
6521
+ accountId: {
6522
+ type: 'string',
6523
+ description: 'Account UUID',
6524
+ example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
6525
+ },
6526
+ accountPath: {
6527
+ type: 'string',
6528
+ description: 'Full account path',
6529
+ example: 'Assets:US:Broker:AAPL'
6530
+ },
6531
+ accountCcy: {
6532
+ type: 'object',
6533
+ description: 'Account settlement currency (ISO 4217), from cost currency',
6534
+ nullable: true,
6535
+ example: 'USD'
6536
+ },
6537
+ brokerType: {
6538
+ type: 'object',
6539
+ description: 'Broker type derived from Platform.type',
6540
+ nullable: true,
6541
+ example: 'broker'
6542
+ },
6543
+ symbol: {
6544
+ type: 'string',
6545
+ description: 'Commodity symbol',
6546
+ example: 'AAPL'
6547
+ },
6548
+ chartToken: {
6549
+ type: 'string',
6550
+ description: 'Chart segment token (libs/common resolver)',
6551
+ example: 'equity',
6552
+ enum: ['equity', 'fund', 'bond', 'cash', 'other']
6553
+ },
6554
+ assetClass: {
6555
+ type: 'string',
6556
+ example: 'EQUITY'
6557
+ },
6558
+ assetSubClass: {
6559
+ type: 'object',
6560
+ nullable: true,
6561
+ example: 'STOCK'
6562
+ },
6563
+ units: {
6564
+ type: 'string',
6565
+ description: 'Net held units (Decimal string)',
6566
+ example: '12'
6567
+ },
6568
+ averageCostPerUnit: {
6569
+ description:
6570
+ 'Average cost per unit; null when cost currency conflicts or no cost',
6571
+ nullable: true,
6572
+ allOf: [
6573
+ {
6574
+ $ref: '#/components/schemas/MonetaryDto'
6575
+ }
6576
+ ]
6577
+ },
6578
+ costBasis: {
6579
+ description: 'Cost basis of held units',
6580
+ nullable: true,
6581
+ allOf: [
6582
+ {
6583
+ $ref: '#/components/schemas/MonetaryDto'
6584
+ }
6585
+ ]
6586
+ },
6587
+ marketValue: {
6588
+ description: 'Market value at asOf price',
6589
+ nullable: true,
6590
+ allOf: [
6591
+ {
6592
+ $ref: '#/components/schemas/MonetaryDto'
6593
+ }
6594
+ ]
6595
+ },
6596
+ currentPrice: {
6597
+ description: 'Price used for market value',
6598
+ nullable: true,
6599
+ allOf: [
6600
+ {
6601
+ $ref: '#/components/schemas/CurrentPriceDto'
6602
+ }
6603
+ ]
6604
+ },
6605
+ unrealizedPnlBase: {
6606
+ type: 'object',
6607
+ description:
6608
+ 'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
6609
+ nullable: true,
6610
+ example: '6000'
6611
+ },
6612
+ unrealizedPnlPct: {
6613
+ type: 'object',
6614
+ description: 'Unrealized P&L % (Decimal string)',
6615
+ nullable: true,
6616
+ example: '25'
6617
+ },
6618
+ costFxRate: {
6619
+ description: 'Historical FX rate applied to cost basis',
6620
+ nullable: true,
6621
+ allOf: [
6622
+ {
6623
+ $ref: '#/components/schemas/FxRateDto'
6624
+ }
6625
+ ]
6626
+ },
6627
+ marketFxRate: {
6628
+ description: 'FX rate applied to market value',
6629
+ nullable: true,
6630
+ allOf: [
6631
+ {
6632
+ $ref: '#/components/schemas/FxRateDto'
6633
+ }
6634
+ ]
6635
+ },
6636
+ pctOfInvestedAssets: {
6637
+ type: 'object',
6638
+ description:
6639
+ 'Share of invested assets % (Decimal string); only for invested chartTokens',
6640
+ nullable: true,
6641
+ example: '40'
6642
+ },
6643
+ realizedPnl: {
6644
+ description:
6645
+ 'Cumulative realized P&L on sold lots (asOf-date cutoff); null when the method has no applicable sells, a sell lacks a price, or any required FX rate is missing (never-mix). When a sell spans multiple currencies (cross-currency sale), amount and currency reflect the base currency; baseCcyEquivalent is always the authoritative dual-FX figure',
6646
+ nullable: true,
6647
+ allOf: [
6648
+ {
6649
+ $ref: '#/components/schemas/MonetaryDto'
6650
+ }
6651
+ ]
6652
+ }
6653
+ },
6654
+ required: [
6655
+ 'accountId',
6656
+ 'accountPath',
6657
+ 'symbol',
6658
+ 'chartToken',
6659
+ 'assetClass',
6660
+ 'units'
6661
+ ]
6662
+ } as const;
6663
+
6664
+ export const $HoldingPnlWarningDto = {
6665
+ type: 'object',
6666
+ properties: {
6667
+ type: {
6668
+ type: 'string',
6669
+ description: 'Warning type',
6670
+ example: 'MISSING_COST_FX_RATE',
6671
+ enum: [
6672
+ 'MISSING_COST_FX_RATE',
6673
+ 'MISSING_MARKET_FX_RATE',
6674
+ 'MISSING_SALE_PRICE',
6675
+ 'MISSING_REALIZED_FX_RATE',
6676
+ 'OVERSOLD_LOTS',
6677
+ 'NO_PRICE',
6678
+ 'MIXED_COST_CURRENCY'
6679
+ ]
6680
+ },
6681
+ symbol: {
6682
+ type: 'object',
6683
+ nullable: true
6684
+ },
6685
+ accountId: {
6686
+ type: 'object',
6687
+ nullable: true
6688
+ },
6689
+ currency: {
6690
+ type: 'object',
6691
+ nullable: true
6692
+ }
6693
+ },
6694
+ required: ['type']
6695
+ } as const;
6696
+
6697
+ export const $HoldingPnlResponseDto = {
6698
+ type: 'object',
6699
+ properties: {
6700
+ asOfDate: {
6701
+ type: 'string',
6702
+ example: '2026-07-08'
6703
+ },
6704
+ baseCurrency: {
6705
+ type: 'string',
6706
+ example: 'CNY'
6707
+ },
6708
+ method: {
6709
+ type: 'string',
6710
+ description:
6711
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
6712
+ enum: ['average', 'FIFO'],
6713
+ example: 'average'
6714
+ },
6715
+ rows: {
6716
+ type: 'array',
6717
+ items: {
6718
+ $ref: '#/components/schemas/HoldingPnlRowDto'
6719
+ }
6720
+ },
6721
+ warnings: {
6722
+ type: 'array',
6723
+ items: {
6724
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
6725
+ }
6726
+ }
6727
+ },
6728
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6729
+ } as const;
6730
+
6731
+ export const $CreateBeanPriceDto = {
6732
+ type: 'object',
6733
+ properties: {
6734
+ currency: {
6735
+ type: 'string',
6736
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6737
+ example: 'USD'
6738
+ },
6739
+ quoteCurrency: {
6740
+ type: 'string',
6741
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
6742
+ example: 'CNY'
6743
+ },
6744
+ amount: {
6745
+ type: 'number',
6746
+ description:
6747
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
6748
+ example: 175.5,
6749
+ minimum: 0
6750
+ },
6751
+ date: {
6752
+ type: 'string',
6753
+ description: 'Price date (ISO 8601 format)',
6754
+ example: '2024-11-05'
6755
+ },
6756
+ metadata: {
6757
+ type: 'object',
6758
+ description:
6759
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
6760
+ example: {
6761
+ source: 'MANUAL',
6762
+ note: 'Bank valuation report',
6763
+ confidence: 0.95
6764
+ }
6765
+ }
6766
+ },
6767
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
6768
+ } as const;
6769
+
6770
+ export const $PriceResponseDto = {
6771
+ type: 'object',
6772
+ properties: {
6773
+ id: {
6774
+ type: 'string',
6775
+ description: 'Unique identifier',
6776
+ example: 'uuid-123-456'
6777
+ },
6778
+ userId: {
6779
+ type: 'string',
6780
+ description: 'User ID (owner of the price)',
6781
+ example: 'user-123'
6782
+ },
6783
+ currency: {
6784
+ type: 'string',
6785
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6786
+ example: 'BTC'
6787
+ },
6788
+ quoteCurrency: {
6789
+ type: 'string',
6790
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
6791
+ example: 'USD'
6792
+ },
6793
+ amount: {
6794
+ type: 'number',
6795
+ description:
6796
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
6797
+ example: 50000
6798
+ },
6799
+ date: {
6800
+ type: 'string',
6801
+ description:
6802
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
6803
+ example: '2024-01-01',
6804
+ format: 'date'
6805
+ },
6806
+ meta: {
6807
+ type: 'object',
6808
+ description:
6809
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
6810
+ example: {
6811
+ source: 'MANUAL',
6812
+ note: 'User-defined price',
6813
+ confidence: 1
6814
+ }
6815
+ },
6816
+ createdAt: {
6817
+ format: 'date-time',
6818
+ type: 'string',
6819
+ description: 'Creation timestamp',
6820
+ example: '2024-11-03T10:00:00Z'
6821
+ },
6822
+ updatedAt: {
6823
+ format: 'date-time',
6824
+ type: 'string',
6825
+ description: 'Last update timestamp',
6826
+ example: '2024-11-03T10:00:00Z'
6827
+ }
6828
+ },
6829
+ required: [
6830
+ 'id',
6831
+ 'userId',
6832
+ 'currency',
6833
+ 'quoteCurrency',
6834
+ 'amount',
6835
+ 'date',
6836
+ 'meta',
6837
+ 'createdAt',
6838
+ 'updatedAt'
6839
+ ]
6840
+ } as const;
6841
+
6842
+ export const $PriceListResponseDto = {
6843
+ type: 'object',
6844
+ properties: {
6845
+ items: {
6846
+ description: 'List of prices',
6847
+ type: 'array',
6848
+ items: {
6849
+ $ref: '#/components/schemas/PriceResponseDto'
6850
+ }
6851
+ },
6852
+ total: {
6853
+ type: 'number',
6854
+ description: 'Total number of prices',
6855
+ example: 42
6856
+ }
6857
+ },
6858
+ required: ['items', 'total']
6859
+ } as const;
6860
+
6861
+ export const $UpdateBeanPriceDto = {
6862
+ type: 'object',
6863
+ properties: {
6864
+ currency: {
6865
+ type: 'string',
6866
+ description: 'Currency being priced'
6867
+ },
6868
+ quoteCurrency: {
6869
+ type: 'string',
6870
+ description: 'Quote currency (pricing currency)'
6871
+ },
6872
+ amount: {
6873
+ type: 'number',
6874
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
6875
+ minimum: 0
6876
+ },
6877
+ date: {
6878
+ type: 'string',
6879
+ description: 'Price date (ISO 8601 format)'
6880
+ },
6881
+ metadata: {
6882
+ type: 'object',
6883
+ description: 'Metadata'
6884
+ }
6885
+ }
6886
+ } as const;
6887
+
6074
6888
  export const $CurrencyBalanceDto = {
6075
6889
  type: 'object',
6076
6890
  properties: {